File tree Expand file tree Collapse file tree
apps/sim/lib/knowledge/search Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -233,6 +233,9 @@ describe('search pipeline diagnostics', () => {
233233 'application/vnd.google-apps.document'
234234 )
235235 expect ( documentKindLabel ( 'Quarterly plan for a private customer' ) ) . toBe ( 'other' )
236+ expect ( documentKindLabel ( 'ProjectAtlas_Q3' ) ) . toBe ( 'other' )
237+ expect ( documentKindLabel ( 'atlas-launch-notes' ) ) . toBe ( 'other' )
238+ expect ( documentKindLabel ( 'notes/atlas' ) ) . toBe ( 'other' )
236239 expect ( documentKindLabel ( undefined ) ) . toBeUndefined ( )
237240 } )
238241
Original file line number Diff line number Diff line change @@ -182,13 +182,18 @@ export function describeSearchRequest(input: {
182182 }
183183}
184184
185+ /** Lowercase type names such as `message` or `merge_requests`, as provider adapters define them. */
186+ const DOCUMENT_KIND = / ^ [ a - z ] [ a - z 0 - 9 _ ] { 0 , 31 } $ /
187+ /** A registered MIME type, which Drive reports as a file's kind. */
188+ const MIME_TYPE = / ^ ( a p p l i c a t i o n | a u d i o | f o n t | i m a g e | m o d e l | t e x t | v i d e o ) \/ [ a - z 0 - 9 ] [ a - z 0 - 9 . + - ] { 0 , 79 } $ /
189+
185190/**
186- * A provider's document type reduced to a bounded token. Kinds are code-defined except a few
187- * passed through from a provider, such as a Drive MIME type, so anything else becomes `other`.
191+ * A provider's document type when it is a type name or MIME type. A kind passed through from a
192+ * provider in any other form, which could carry free text, becomes `other`.
188193 */
189194export function documentKindLabel ( kind : string | undefined ) : string | undefined {
190195 if ( ! kind ) return undefined
191- return / ^ [ \w . + / - ] { 1 , 80 } $ / . test ( kind ) ? kind : 'other'
196+ return DOCUMENT_KIND . test ( kind ) || MIME_TYPE . test ( kind ) ? kind : 'other'
192197}
193198
194199interface StageTiming {
You can’t perform that action at this time.
0 commit comments