@mastra/qdrant 0.11.2 → 0.11.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,23 +1,4 @@
1
1
 
2
- > @mastra/qdrant@0.11.2-alpha.0 build /home/runner/work/mastra/mastra/stores/qdrant
3
- > tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting
2
+ > @mastra/qdrant@0.11.3-alpha.0 build /home/runner/work/mastra/mastra/stores/qdrant
3
+ > tsup --silent --config tsup.config.ts
4
4
 
5
- CLI Building entry: src/index.ts
6
- CLI Using tsconfig: tsconfig.json
7
- CLI tsup v8.5.0
8
- TSC Build start
9
- TSC ⚡️ Build success in 9935ms
10
- DTS Build start
11
- CLI Target: es2022
12
- Analysis will use the bundled TypeScript version 5.8.3
13
- Writing package typings: /home/runner/work/mastra/mastra/stores/qdrant/dist/_tsup-dts-rollup.d.ts
14
- Analysis will use the bundled TypeScript version 5.8.3
15
- Writing package typings: /home/runner/work/mastra/mastra/stores/qdrant/dist/_tsup-dts-rollup.d.cts
16
- DTS ⚡️ Build success in 12160ms
17
- CLI Cleaning output folder
18
- ESM Build start
19
- CJS Build start
20
- ESM dist/index.js 21.00 KB
21
- ESM ⚡️ Build success in 713ms
22
- CJS dist/index.cjs 21.23 KB
23
- CJS ⚡️ Build success in 713ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,39 @@
1
1
  # @mastra/qdrant
2
2
 
3
+ ## 0.11.3
4
+
5
+ ### Patch Changes
6
+
7
+ - 4a406ec: fixes TypeScript declaration file imports to ensure proper ESM compatibility
8
+ - Updated dependencies [cb36de0]
9
+ - Updated dependencies [d0496e6]
10
+ - Updated dependencies [a82b851]
11
+ - Updated dependencies [ea0c5f2]
12
+ - Updated dependencies [41a0a0e]
13
+ - Updated dependencies [2871020]
14
+ - Updated dependencies [94f4812]
15
+ - Updated dependencies [e202b82]
16
+ - Updated dependencies [e00f6a0]
17
+ - Updated dependencies [4a406ec]
18
+ - Updated dependencies [b0e43c1]
19
+ - Updated dependencies [5d377e5]
20
+ - Updated dependencies [1fb812e]
21
+ - Updated dependencies [35c5798]
22
+ - @mastra/core@0.13.0
23
+
24
+ ## 0.11.3-alpha.0
25
+
26
+ ### Patch Changes
27
+
28
+ - 4a406ec: fixes TypeScript declaration file imports to ensure proper ESM compatibility
29
+ - Updated dependencies [cb36de0]
30
+ - Updated dependencies [a82b851]
31
+ - Updated dependencies [41a0a0e]
32
+ - Updated dependencies [2871020]
33
+ - Updated dependencies [4a406ec]
34
+ - Updated dependencies [5d377e5]
35
+ - @mastra/core@0.13.0-alpha.2
36
+
3
37
  ## 0.11.2
4
38
 
5
39
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -652,3 +652,5 @@ Example Complex Query:
652
652
 
653
653
  exports.QDRANT_PROMPT = QDRANT_PROMPT;
654
654
  exports.QdrantVector = QdrantVector;
655
+ //# sourceMappingURL=index.cjs.map
656
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/vector/filter.ts","../src/vector/index.ts","../src/vector/prompt.ts"],"names":["BaseFilterTranslator","MastraVector","QdrantClient","error","MastraError","ErrorDomain","ErrorCategory"],"mappings":";;;;;;;;AAwHO,IAAM,sBAAA,GAAN,cAAqCA,2BAAA,CAAyC;AAAA,EAChE,kBAAkB,GAAA,EAAqC;AACxE,IAAA,OAAO,MAAM,iBAAA,CAAkB,GAAG,CAAA,IAAK,GAAA,KAAQ,YAAY,GAAA,KAAQ,YAAA;AAAA,EACrE;AAAA,EAEmB,qBAAA,GAAyC;AAC1D,IAAA,OAAO;AAAA,MACL,GAAGA,2BAAA,CAAqB,iBAAA;AAAA,MACxB,OAAA,EAAS,CAAC,MAAA,EAAQ,KAAA,EAAO,MAAM,CAAA;AAAA,MAC/B,KAAA,EAAO,CAAC,KAAA,EAAO,MAAM,CAAA;AAAA,MACrB,KAAA,EAAO,CAAC,QAAQ,CAAA;AAAA,MA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A;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA","file":"index.cjs","sourcesContent":["import { BaseFilterTranslator } from '@mastra/core/vector/filter';\nimport type {\n VectorFilter,\n LogicalOperator,\n OperatorSupport,\n OperatorValueMap,\n LogicalOperatorValueMap,\n BlacklistedRootOperators,\n} from '@mastra/core/vector/filter';\n\ntype QdrantOperatorValueMap = Omit<OperatorValueMap, '$options' | '$elemMatch' | '$all'> & {\n /**\n * $count: Filter by array length or value count.\n * Example: { tags: { $count: { gt: 2 } } }\n */\n $count: {\n $gt?: number;\n $gte?: number;\n $lt?: number;\n $lte?: number;\n $eq?: number;\n };\n\n /**\n * $geo: Geospatial filter.\n * Example: { location: { $geo: { type: 'geo_radius', center: [lon, lat], radius: 1000 } } }\n */\n $geo: {\n type: string;\n [key: string]: any;\n };\n\n /**\n * $hasId: Filter by point IDs.\n * Allowed at root level.\n * Example: { $hasId: '123' } or { $hasId: ['123', '456'] }\n */\n $hasId: string | string[];\n\n /**\n * $nested: Nested object filter.\n * Example: { metadata: { $nested: { key: 'foo', filter: { $eq: 'bar' } } } }\n */\n $nested: {\n // Additional properties depend on the nested object structure\n [key: string]: any;\n };\n\n /**\n * $hasVector: Filter by vector existence or field.\n * Allowed at root level.\n * Example: { $hasVector: true } or { $hasVector: 'vector_field' }\n */\n $hasVector: boolean | string;\n\n /**\n * $datetime: RFC 3339 datetime range.\n * Example: { createdAt: { $datetime: { gte: '2024-01-01T00:00:00Z' } } }\n */\n $datetime: {\n key?: string;\n range?: {\n gt?: Date | string;\n gte?: Date | string;\n lt?: Date | string;\n lte?: Date | string;\n eq?: Date | string;\n };\n };\n\n /**\n * $null: Check if a field is null.\n * Example: { metadata: { $null: true } }\n */\n $null: boolean;\n\n /**\n * $empty: Check if an array or object field is empty.\n * Example: { tags: { $empty: true } }\n */\n $empty: boolean;\n};\n\ntype QdrantLogicalOperatorValueMap = Omit<LogicalOperatorValueMap, '$nor'>;\n\ntype QdrantBlacklistedRootOperators =\n | BlacklistedRootOperators\n | '$count'\n | '$geo'\n | '$nested'\n | '$datetime'\n | '$null'\n | '$empty';\n\nexport type QdrantVectorFilter = VectorFilter<\n keyof QdrantOperatorValueMap,\n QdrantOperatorValueMap,\n QdrantLogicalOperatorValueMap,\n QdrantBlacklistedRootOperators\n>;\n\n/**\n * Translates MongoDB-style filters to Qdrant compatible filters.\n *\n * Key transformations:\n * - $and -> must\n * - $or -> should\n * - $not -> must_not\n * - { field: { $op: value } } -> { key: field, match/range: { value/gt/lt: value } }\n *\n * Custom operators (Qdrant-specific):\n * - $count -> values_count (array length/value count)\n * - $geo -> geo filters (box, radius, polygon)\n * - $hasId -> has_id filter\n * - $nested -> nested object filters\n * - $hasVector -> vector existence check\n * - $datetime -> RFC 3339 datetime range\n * - $null -> is_null check\n * - $empty -> is_empty check\n */\nexport class QdrantFilterTranslator extends BaseFilterTranslator<QdrantVectorFilter> {\n protected override isLogicalOperator(key: string): key is LogicalOperator {\n return super.isLogicalOperator(key) || key === '$hasId' || key === '$hasVector';\n }\n\n protected override getSupportedOperators(): OperatorSupport {\n return {\n ...BaseFilterTranslator.DEFAULT_OPERATORS,\n logical: ['$and', '$or', '$not'],\n array: ['$in', '$nin'],\n regex: ['$regex'],\n custom: ['$count', '$geo', '$nested', '$datetime', '$null', '$empty', '$hasId', '$hasVector'],\n };\n }\n\n translate(filter?: QdrantVectorFilter): QdrantVectorFilter {\n if (this.isEmpty(filter)) return filter;\n this.validateFilter(filter);\n return this.translateNode(filter);\n }\n\n private createCondition(type: string, value: any, fieldKey?: string) {\n const condition = { [type]: value };\n return fieldKey ? { key: fieldKey, ...condition } : condition;\n }\n\n private translateNode(node: QdrantVectorFilter, isNested: boolean = false, fieldKey?: string): any {\n if (!this.isEmpty(node) && !!node && typeof node === 'object' && 'must' in node) {\n return node;\n }\n\n if (this.isPrimitive(node)) {\n if (node === null) {\n return { is_null: { key: fieldKey } };\n }\n return this.createCondition('match', { value: this.normalizeComparisonValue(node) }, fieldKey);\n }\n\n if (this.isRegex(node)) {\n throw new Error('Direct regex pattern format is not supported in Qdrant');\n }\n\n if (Array.isArray(node)) {\n return node.length === 0\n ? { is_empty: { key: fieldKey } }\n : this.createCondition('match', { any: this.normalizeArrayValues(node) }, fieldKey);\n }\n\n const entries = Object.entries(node as Record<string, any>);\n\n // Handle logical operators first\n const logicalResult = this.handleLogicalOperators(entries, isNested);\n if (logicalResult) {\n return logicalResult;\n }\n\n // Handle field conditions\n const { conditions, range, matchCondition } = this.handleFieldConditions(entries, fieldKey);\n\n if (Object.keys(range).length > 0) {\n conditions.push({ key: fieldKey, range });\n }\n\n if (matchCondition) {\n conditions.push({ key: fieldKey, match: matchCondition });\n }\n\n return this.buildFinalConditions(conditions, isNested);\n }\n\n private buildFinalConditions(conditions: any[], isNested: boolean): any {\n if (conditions.length === 0) {\n return {};\n } else if (conditions.length === 1 && isNested) {\n return conditions[0];\n } else {\n return { must: conditions };\n }\n }\n\n private handleLogicalOperators(entries: [string, any][], isNested: boolean): any | null {\n const firstKey = entries[0]?.[0];\n\n if (firstKey && this.isLogicalOperator(firstKey) && !this.isCustomOperator(firstKey)) {\n const [key, value] = entries[0]!;\n const qdrantOp = this.getQdrantLogicalOp(key);\n return {\n [qdrantOp]: Array.isArray(value)\n ? value.map(v => this.translateNode(v, true))\n : [this.translateNode(value, true)],\n };\n }\n\n if (\n entries.length > 1 &&\n !isNested &&\n entries.every(([key]) => !this.isOperator(key) && !this.isCustomOperator(key))\n ) {\n return {\n must: entries.map(([key, value]) => this.translateNode(value, true, key)),\n };\n }\n\n return null;\n }\n\n private handleFieldConditions(\n entries: [string, any][],\n fieldKey?: string,\n ): { conditions: any[]; range: Record<string, any>; matchCondition: Record<string, any> | null } {\n const conditions = [];\n let range: Record<string, any> = {};\n let matchCondition: Record<string, any> | null = null;\n\n for (const [key, value] of entries) {\n if (this.isCustomOperator(key)) {\n const customOp = this.translateCustomOperator(key, value, fieldKey);\n conditions.push(customOp);\n } else if (this.isOperator(key)) {\n const opResult = this.translateOperatorValue(key, value);\n if (opResult.range) {\n Object.assign(range, opResult.range);\n } else {\n matchCondition = opResult;\n }\n } else {\n const nestedKey = fieldKey ? `${fieldKey}.${key}` : key;\n const nestedCondition = this.translateNode(value, true, nestedKey);\n\n if (nestedCondition.must) {\n conditions.push(...nestedCondition.must);\n } else if (!this.isEmpty(nestedCondition)) {\n conditions.push(nestedCondition);\n }\n }\n }\n\n return { conditions, range, matchCondition };\n }\n\n private translateCustomOperator(op: string, value: any, fieldKey?: string): any {\n switch (op) {\n case '$count':\n const countConditions = Object.entries(value).reduce(\n (acc, [k, v]) => ({\n ...acc,\n [k.replace('$', '')]: v,\n }),\n {},\n );\n return { key: fieldKey, values_count: countConditions };\n case '$geo':\n const geoOp = this.translateGeoFilter(value.type, value);\n return { key: fieldKey, ...geoOp };\n case '$hasId':\n return { has_id: Array.isArray(value) ? value : [value] };\n case '$nested':\n return {\n nested: {\n key: fieldKey,\n filter: this.translateNode(value),\n },\n };\n case '$hasVector':\n return { has_vector: value };\n case '$datetime':\n return {\n key: fieldKey,\n range: this.normalizeDatetimeRange(value.range),\n };\n case '$null':\n return { is_null: { key: fieldKey } };\n case '$empty':\n return { is_empty: { key: fieldKey } };\n default:\n throw new Error(`Unsupported custom operator: ${op}`);\n }\n }\n\n private getQdrantLogicalOp(op: string): string {\n switch (op) {\n case '$and':\n return 'must';\n case '$or':\n return 'should';\n case '$not':\n return 'must_not';\n default:\n throw new Error(`Unsupported logical operator: ${op}`);\n }\n }\n\n private translateOperatorValue(operator: string, value: any): any {\n const normalizedValue = this.normalizeComparisonValue(value);\n\n switch (operator) {\n case '$eq':\n return { value: normalizedValue };\n case '$ne':\n return { except: [normalizedValue] };\n case '$gt':\n return { range: { gt: normalizedValue } };\n case '$gte':\n return { range: { gte: normalizedValue } };\n case '$lt':\n return { range: { lt: normalizedValue } };\n case '$lte':\n return { range: { lte: normalizedValue } };\n case '$in':\n return { any: this.normalizeArrayValues(value) };\n case '$nin':\n return { except: this.normalizeArrayValues(value) };\n case '$regex':\n return { text: value };\n case 'exists':\n return value\n ? {\n must_not: [{ is_null: { key: value } }, { is_empty: { key: value } }],\n }\n : {\n is_empty: { key: value },\n };\n default:\n throw new Error(`Unsupported operator: ${operator}`);\n }\n }\n\n private translateGeoFilter(type: string, value: any): any {\n switch (type) {\n case 'box':\n return {\n geo_bounding_box: {\n top_left: value.top_left,\n bottom_right: value.bottom_right,\n },\n };\n case 'radius':\n return {\n geo_radius: {\n center: value.center,\n radius: value.radius,\n },\n };\n case 'polygon':\n return {\n geo_polygon: {\n exterior: value.exterior,\n interiors: value.interiors,\n },\n };\n default:\n throw new Error(`Unsupported geo filter type: ${type}`);\n }\n }\n\n private normalizeDatetimeRange(value: any): any {\n const range: Record<string, string> = {};\n for (const [op, val] of Object.entries(value)) {\n if (val instanceof Date) {\n range[op] = val.toISOString();\n } else if (typeof val === 'string') {\n // Assume string is already in proper format\n range[op] = val;\n }\n }\n return range;\n }\n}\n","import { MastraError, ErrorDomain, ErrorCategory } from '@mastra/core/error';\nimport { MastraVector } from '@mastra/core/vector';\nimport type {\n QueryResult,\n IndexStats,\n CreateIndexParams,\n UpsertVectorParams,\n QueryVectorParams,\n DescribeIndexParams,\n DeleteIndexParams,\n DeleteVectorParams,\n UpdateVectorParams,\n} from '@mastra/core/vector';\nimport { QdrantClient } from '@qdrant/js-client-rest';\nimport type { Schemas } from '@qdrant/js-client-rest';\n\nimport { QdrantFilterTranslator } from './filter';\nimport type { QdrantVectorFilter } from './filter';\n\nconst BATCH_SIZE = 256;\nconst DISTANCE_MAPPING: Record<string, Schemas['Distance']> = {\n cosine: 'Cosine',\n euclidean: 'Euclid',\n dotproduct: 'Dot',\n};\n\ntype QdrantQueryVectorParams = QueryVectorParams<QdrantVectorFilter>;\n\nexport class QdrantVector extends MastraVector {\n private client: QdrantClient;\n\n /**\n * Creates a new QdrantVector client.\n * @param url - The URL of the Qdrant server.\n * @param apiKey - The API key for Qdrant.\n * @param https - Whether to use HTTPS.\n */\n constructor({ url, apiKey, https }: { url: string; apiKey?: string; https?: boolean }) {\n super();\n const baseClient = new QdrantClient({\n url,\n apiKey,\n https,\n });\n const telemetry = this.__getTelemetry();\n this.client =\n telemetry?.traceClass(baseClient, {\n spanNamePrefix: 'qdrant-vector',\n attributes: {\n 'vector.type': 'qdrant',\n },\n }) ?? baseClient;\n }\n\n async upsert({ indexName, vectors, metadata, ids }: UpsertVectorParams): Promise<string[]> {\n const pointIds = ids || vectors.map(() => crypto.randomUUID());\n\n const records = vectors.map((vector, i) => ({\n id: pointIds[i],\n vector: vector,\n payload: metadata?.[i] || {},\n }));\n\n try {\n for (let i = 0; i < records.length; i += BATCH_SIZE) {\n const batch = records.slice(i, i + BATCH_SIZE);\n await this.client.upsert(indexName, {\n // @ts-expect-error\n points: batch,\n wait: true,\n });\n }\n\n return pointIds;\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_QDRANT_VECTOR_UPSERT_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, vectorCount: vectors.length },\n },\n error,\n );\n }\n }\n\n async createIndex({ indexName, dimension, metric = 'cosine' }: CreateIndexParams): Promise<void> {\n try {\n if (!Number.isInteger(dimension) || dimension <= 0) {\n throw new Error('Dimension must be a positive integer');\n }\n if (!DISTANCE_MAPPING[metric]) {\n throw new Error(`Invalid metric: \"${metric}\". Must be one of: cosine, euclidean, dotproduct`);\n }\n } catch (validationError) {\n throw new MastraError(\n {\n id: 'STORAGE_QDRANT_VECTOR_CREATE_INDEX_INVALID_ARGS',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName, dimension, metric },\n },\n validationError,\n );\n }\n\n try {\n await this.client.createCollection(indexName, {\n vectors: {\n size: dimension,\n distance: DISTANCE_MAPPING[metric],\n },\n });\n } catch (error: any) {\n const message = error?.message || error?.toString();\n // Qdrant typically returns 409 for existing collection\n if (error?.status === 409 || (typeof message === 'string' && message.toLowerCase().includes('exists'))) {\n // Fetch collection info and check dimension\n await this.validateExistingIndex(indexName, dimension, metric);\n return;\n }\n\n throw new MastraError(\n {\n id: 'STORAGE_QDRANT_VECTOR_CREATE_INDEX_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, dimension, metric },\n },\n error,\n );\n }\n }\n\n transformFilter(filter?: QdrantVectorFilter) {\n const translator = new QdrantFilterTranslator();\n return translator.translate(filter);\n }\n\n async query({\n indexName,\n queryVector,\n topK = 10,\n filter,\n includeVector = false,\n }: QdrantQueryVectorParams): Promise<QueryResult[]> {\n const translatedFilter = this.transformFilter(filter) ?? {};\n\n try {\n const results = (\n await this.client.query(indexName, {\n query: queryVector,\n limit: topK,\n filter: translatedFilter,\n with_payload: true,\n with_vector: includeVector,\n })\n ).points;\n\n return results.map(match => {\n let vector: number[] = [];\n if (includeVector) {\n if (Array.isArray(match.vector)) {\n // If it's already an array of numbers\n vector = match.vector as number[];\n } else if (typeof match.vector === 'object' && match.vector !== null) {\n // If it's an object with vector data\n vector = Object.values(match.vector).filter(v => typeof v === 'number');\n }\n }\n\n return {\n id: match.id as string,\n score: match.score || 0,\n metadata: match.payload as Record<string, any>,\n ...(includeVector && { vector }),\n };\n });\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_QDRANT_VECTOR_QUERY_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, topK },\n },\n error,\n );\n }\n }\n\n async listIndexes(): Promise<string[]> {\n try {\n const response = await this.client.getCollections();\n return response.collections.map(collection => collection.name) || [];\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_QDRANT_VECTOR_LIST_INDEXES_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n },\n error,\n );\n }\n }\n\n /**\n * Retrieves statistics about a vector index.\n *\n * @param {string} indexName - The name of the index to describe\n * @returns A promise that resolves to the index statistics including dimension, count and metric\n */\n async describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats> {\n try {\n const { config, points_count } = await this.client.getCollection(indexName);\n\n const distance = config.params.vectors?.distance as Schemas['Distance'];\n return {\n dimension: config.params.vectors?.size as number,\n count: points_count || 0,\n // @ts-expect-error\n metric: Object.keys(DISTANCE_MAPPING).find(key => DISTANCE_MAPPING[key] === distance),\n };\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_QDRANT_VECTOR_DESCRIBE_INDEX_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n async deleteIndex({ indexName }: DeleteIndexParams): Promise<void> {\n try {\n await this.client.deleteCollection(indexName);\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_QDRANT_VECTOR_DELETE_INDEX_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n /**\n * Updates a vector by its ID with the provided vector and/or metadata.\n * @param indexName - The name of the index containing the vector.\n * @param id - The ID of the vector to update.\n * @param update - An object containing the vector and/or metadata to update.\n * @param update.vector - An optional array of numbers representing the new vector.\n * @param update.metadata - An optional record containing the new metadata.\n * @returns A promise that resolves when the update is complete.\n * @throws Will throw an error if no updates are provided or if the update operation fails.\n */\n async updateVector({ indexName, id, update }: UpdateVectorParams): Promise<void> {\n try {\n if (!update.vector && !update.metadata) {\n throw new Error('No updates provided');\n }\n } catch (validationError) {\n throw new MastraError(\n {\n id: 'STORAGE_QDRANT_VECTOR_UPDATE_VECTOR_INVALID_ARGS',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName, id },\n },\n validationError,\n );\n }\n\n const pointId = this.parsePointId(id);\n\n try {\n // Handle metadata-only update\n if (update.metadata && !update.vector) {\n // For metadata-only updates, use the setPayload method\n await this.client.setPayload(indexName, { payload: update.metadata, points: [pointId] });\n return;\n }\n\n // Handle vector-only update\n if (update.vector && !update.metadata) {\n await this.client.updateVectors(indexName, {\n points: [\n {\n id: pointId,\n vector: update.vector,\n },\n ],\n });\n return;\n }\n\n // Handle both vector and metadata update\n if (update.vector && update.metadata) {\n const point = {\n id: pointId,\n vector: update.vector,\n payload: update.metadata,\n };\n\n await this.client.upsert(indexName, {\n points: [point],\n });\n return;\n }\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_QDRANT_VECTOR_UPDATE_VECTOR_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, id },\n },\n error,\n );\n }\n }\n\n /**\n * Deletes a vector by its ID.\n * @param indexName - The name of the index containing the vector.\n * @param id - The ID of the vector to delete.\n * @returns A promise that resolves when the deletion is complete.\n * @throws Will throw an error if the deletion operation fails.\n */\n async deleteVector({ indexName, id }: DeleteVectorParams): Promise<void> {\n try {\n // Parse the ID - Qdrant supports both string and numeric IDs\n const pointId = this.parsePointId(id);\n\n // Use the Qdrant client to delete the point from the collection\n await this.client.delete(indexName, {\n points: [pointId],\n });\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_QDRANT_VECTOR_DELETE_VECTOR_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, id },\n },\n error,\n );\n }\n }\n\n /**\n * Parses and converts a string ID to the appropriate type (string or number) for Qdrant point operations.\n *\n * Qdrant supports both numeric and string IDs. This helper method ensures IDs are in the correct format\n * before sending them to the Qdrant client API.\n *\n * @param id - The ID string to parse\n * @returns The parsed ID as either a number (if string contains only digits) or the original string\n *\n * @example\n * // Numeric ID strings are converted to numbers\n * parsePointId(\"123\") => 123\n * parsePointId(\"42\") => 42\n * parsePointId(\"0\") => 0\n *\n * // String IDs containing any non-digit characters remain as strings\n * parsePointId(\"doc-123\") => \"doc-123\"\n * parsePointId(\"user_42\") => \"user_42\"\n * parsePointId(\"abc123\") => \"abc123\"\n * parsePointId(\"123abc\") => \"123abc\"\n * parsePointId(\"\") => \"\"\n * parsePointId(\"uuid-5678-xyz\") => \"uuid-5678-xyz\"\n *\n * @remarks\n * - This conversion is important because Qdrant treats numeric and string IDs differently\n * - Only positive integers are converted to numbers (negative numbers with minus signs remain strings)\n * - The method uses base-10 parsing, so leading zeros will be dropped in numeric conversions\n * - reference: https://qdrant.tech/documentation/concepts/points/?q=qdrant+point+id#point-ids\n */\n private parsePointId(id: string): string | number {\n // Try to parse as number if it looks like one\n if (/^\\d+$/.test(id)) {\n return parseInt(id, 10);\n }\n return id;\n }\n}\n","/**\n * Vector store specific prompt that details supported operators and examples.\n * This prompt helps users construct valid filters for Qdrant Vector.\n */\nexport const QDRANT_PROMPT = `When querying Qdrant, you can ONLY use the operators listed below. Any other operators will be rejected.\nImportant: Don't explain how to construct the filter - use the specified operators and fields to search the content and return relevant results.\nIf a user tries to give an explicit operator that is not supported, reject the filter entirely and let them know that the operator is not supported.\n\nBasic Comparison Operators:\n- $eq: Exact match (default when using field: value)\n Example: { \"category\": \"electronics\" }\n- $ne: Not equal\n Example: { \"category\": { \"$ne\": \"electronics\" } }\n- $gt: Greater than\n Example: { \"price\": { \"$gt\": 100 } }\n- $gte: Greater than or equal\n Example: { \"price\": { \"$gte\": 100 } }\n- $lt: Less than\n Example: { \"price\": { \"$lt\": 100 } }\n- $lte: Less than or equal\n Example: { \"price\": { \"$lte\": 100 } }\n\nArray Operators:\n- $in: Match any value in array\n Example: { \"category\": { \"$in\": [\"electronics\", \"books\"] } }\n- $nin: Does not match any value in array\n Example: { \"category\": { \"$nin\": [\"electronics\", \"books\"] } }\n\nLogical Operators:\n- $and: Logical AND (can be implicit or explicit)\n Implicit Example: { \"price\": { \"$gt\": 100 }, \"category\": \"electronics\" }\n Explicit Example: { \"$and\": [{ \"price\": { \"$gt\": 100 } }, { \"category\": \"electronics\" }] }\n- $or: Logical OR\n Example: { \"$or\": [{ \"price\": { \"$lt\": 50 } }, { \"category\": \"books\" }] }\n- $not: Logical NOT\n Example: { \"$not\": { \"category\": \"electronics\" } }\n\nElement Operators:\n- $exists: Check if field exists\n Example: { \"rating\": { \"$exists\": true } }\n- $match: Match text using full-text search\n Example: { \"description\": { \"$match\": \"gaming laptop\" } }\n- $null: Check if field is null\n Example: { \"rating\": { \"$null\": true } }\n\nRestrictions:\n- Regex patterns are not supported\n- Only $and, $or, and $not logical operators are supported at the top level\n- Empty arrays in $in/$nin will return no results\n- Nested fields are supported using dot notation\n- Multiple conditions on the same field are supported with both implicit and explicit $and\n- At least one key-value pair is required in filter object\n- Empty objects and undefined values are treated as no filter\n- Invalid types in comparison operators will throw errors\n- All non-logical operators must be used within a field condition\n Valid: { \"field\": { \"$gt\": 100 } }\n Valid: { \"$and\": [...] }\n Invalid: { \"$gt\": 100 }\n- Logical operators must contain field conditions, not direct operators\n Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n Invalid: { \"$and\": [{ \"$gt\": 100 }] }\n- Logical operators ($and, $or, $not):\n - Can only be used at top level or nested within other logical operators\n - Can not be used on a field level, or be nested inside a field\n - Can not be used inside an operator\n - Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n - Valid: { \"$or\": [{ \"$and\": [{ \"field\": { \"$gt\": 100 } }] }] }\n - Invalid: { \"field\": { \"$and\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$or\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$gt\": { \"$and\": [{...}] } } }\n\nExample Complex Query:\n{\n \"$and\": [\n { \"category\": { \"$in\": [\"electronics\", \"computers\"] } },\n { \"price\": { \"$gte\": 100, \"$lte\": 1000 } },\n { \"description\": { \"$match\": \"gaming laptop\" } },\n { \"rating\": { \"$exists\": true, \"$gt\": 4 } },\n { \"$or\": [\n { \"stock\": { \"$gt\": 0 } },\n { \"preorder\": { \"$null\": false } }\n ]},\n { \"$not\": { \"status\": \"discontinued\" } }\n ]\n}`;\n"]}
package/dist/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
- export { QDRANT_PROMPT } from './_tsup-dts-rollup.js';
2
- export { QdrantVector } from './_tsup-dts-rollup.js';
1
+ export * from './vector/index.js';
2
+ export { QDRANT_PROMPT } from './vector/prompt.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC"}
package/dist/index.js CHANGED
@@ -649,3 +649,5 @@ Example Complex Query:
649
649
  }`;
650
650
 
651
651
  export { QDRANT_PROMPT, QdrantVector };
652
+ //# sourceMappingURL=index.js.map
653
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/vector/filter.ts","../src/vector/index.ts","../src/vector/prompt.ts"],"names":[],"mappings":";;;;;;AAwHO,IAAM,sBAAA,GAAN,cAAqC,oBAAA,CAAyC;AAAA,EAChE,kBAAkB,GAAA,EAAqC;AACxE,IAAA,OAAO,MAAM,iBAAA,CAAkB,GAAG,CAAA,IAAK,GAAA,KAAQ,YAAY,GAAA,KAAQ,YAAA;AAAA,EACrE;AAAA,EAEmB,qBAAA,GAAyC;AAC1D,IAAA,OAAO;AAAA,MACL,GAAG,oBAAA,CAAqB,iBAAA;AAAA,MACxB,OAAA,EAAS,CAAC,MA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AAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA","file":"index.js","sourcesContent":["import { BaseFilterTranslator } from '@mastra/core/vector/filter';\nimport type {\n VectorFilter,\n LogicalOperator,\n OperatorSupport,\n OperatorValueMap,\n LogicalOperatorValueMap,\n BlacklistedRootOperators,\n} from '@mastra/core/vector/filter';\n\ntype QdrantOperatorValueMap = Omit<OperatorValueMap, '$options' | '$elemMatch' | '$all'> & {\n /**\n * $count: Filter by array length or value count.\n * Example: { tags: { $count: { gt: 2 } } }\n */\n $count: {\n $gt?: number;\n $gte?: number;\n $lt?: number;\n $lte?: number;\n $eq?: number;\n };\n\n /**\n * $geo: Geospatial filter.\n * Example: { location: { $geo: { type: 'geo_radius', center: [lon, lat], radius: 1000 } } }\n */\n $geo: {\n type: string;\n [key: string]: any;\n };\n\n /**\n * $hasId: Filter by point IDs.\n * Allowed at root level.\n * Example: { $hasId: '123' } or { $hasId: ['123', '456'] }\n */\n $hasId: string | string[];\n\n /**\n * $nested: Nested object filter.\n * Example: { metadata: { $nested: { key: 'foo', filter: { $eq: 'bar' } } } }\n */\n $nested: {\n // Additional properties depend on the nested object structure\n [key: string]: any;\n };\n\n /**\n * $hasVector: Filter by vector existence or field.\n * Allowed at root level.\n * Example: { $hasVector: true } or { $hasVector: 'vector_field' }\n */\n $hasVector: boolean | string;\n\n /**\n * $datetime: RFC 3339 datetime range.\n * Example: { createdAt: { $datetime: { gte: '2024-01-01T00:00:00Z' } } }\n */\n $datetime: {\n key?: string;\n range?: {\n gt?: Date | string;\n gte?: Date | string;\n lt?: Date | string;\n lte?: Date | string;\n eq?: Date | string;\n };\n };\n\n /**\n * $null: Check if a field is null.\n * Example: { metadata: { $null: true } }\n */\n $null: boolean;\n\n /**\n * $empty: Check if an array or object field is empty.\n * Example: { tags: { $empty: true } }\n */\n $empty: boolean;\n};\n\ntype QdrantLogicalOperatorValueMap = Omit<LogicalOperatorValueMap, '$nor'>;\n\ntype QdrantBlacklistedRootOperators =\n | BlacklistedRootOperators\n | '$count'\n | '$geo'\n | '$nested'\n | '$datetime'\n | '$null'\n | '$empty';\n\nexport type QdrantVectorFilter = VectorFilter<\n keyof QdrantOperatorValueMap,\n QdrantOperatorValueMap,\n QdrantLogicalOperatorValueMap,\n QdrantBlacklistedRootOperators\n>;\n\n/**\n * Translates MongoDB-style filters to Qdrant compatible filters.\n *\n * Key transformations:\n * - $and -> must\n * - $or -> should\n * - $not -> must_not\n * - { field: { $op: value } } -> { key: field, match/range: { value/gt/lt: value } }\n *\n * Custom operators (Qdrant-specific):\n * - $count -> values_count (array length/value count)\n * - $geo -> geo filters (box, radius, polygon)\n * - $hasId -> has_id filter\n * - $nested -> nested object filters\n * - $hasVector -> vector existence check\n * - $datetime -> RFC 3339 datetime range\n * - $null -> is_null check\n * - $empty -> is_empty check\n */\nexport class QdrantFilterTranslator extends BaseFilterTranslator<QdrantVectorFilter> {\n protected override isLogicalOperator(key: string): key is LogicalOperator {\n return super.isLogicalOperator(key) || key === '$hasId' || key === '$hasVector';\n }\n\n protected override getSupportedOperators(): OperatorSupport {\n return {\n ...BaseFilterTranslator.DEFAULT_OPERATORS,\n logical: ['$and', '$or', '$not'],\n array: ['$in', '$nin'],\n regex: ['$regex'],\n custom: ['$count', '$geo', '$nested', '$datetime', '$null', '$empty', '$hasId', '$hasVector'],\n };\n }\n\n translate(filter?: QdrantVectorFilter): QdrantVectorFilter {\n if (this.isEmpty(filter)) return filter;\n this.validateFilter(filter);\n return this.translateNode(filter);\n }\n\n private createCondition(type: string, value: any, fieldKey?: string) {\n const condition = { [type]: value };\n return fieldKey ? { key: fieldKey, ...condition } : condition;\n }\n\n private translateNode(node: QdrantVectorFilter, isNested: boolean = false, fieldKey?: string): any {\n if (!this.isEmpty(node) && !!node && typeof node === 'object' && 'must' in node) {\n return node;\n }\n\n if (this.isPrimitive(node)) {\n if (node === null) {\n return { is_null: { key: fieldKey } };\n }\n return this.createCondition('match', { value: this.normalizeComparisonValue(node) }, fieldKey);\n }\n\n if (this.isRegex(node)) {\n throw new Error('Direct regex pattern format is not supported in Qdrant');\n }\n\n if (Array.isArray(node)) {\n return node.length === 0\n ? { is_empty: { key: fieldKey } }\n : this.createCondition('match', { any: this.normalizeArrayValues(node) }, fieldKey);\n }\n\n const entries = Object.entries(node as Record<string, any>);\n\n // Handle logical operators first\n const logicalResult = this.handleLogicalOperators(entries, isNested);\n if (logicalResult) {\n return logicalResult;\n }\n\n // Handle field conditions\n const { conditions, range, matchCondition } = this.handleFieldConditions(entries, fieldKey);\n\n if (Object.keys(range).length > 0) {\n conditions.push({ key: fieldKey, range });\n }\n\n if (matchCondition) {\n conditions.push({ key: fieldKey, match: matchCondition });\n }\n\n return this.buildFinalConditions(conditions, isNested);\n }\n\n private buildFinalConditions(conditions: any[], isNested: boolean): any {\n if (conditions.length === 0) {\n return {};\n } else if (conditions.length === 1 && isNested) {\n return conditions[0];\n } else {\n return { must: conditions };\n }\n }\n\n private handleLogicalOperators(entries: [string, any][], isNested: boolean): any | null {\n const firstKey = entries[0]?.[0];\n\n if (firstKey && this.isLogicalOperator(firstKey) && !this.isCustomOperator(firstKey)) {\n const [key, value] = entries[0]!;\n const qdrantOp = this.getQdrantLogicalOp(key);\n return {\n [qdrantOp]: Array.isArray(value)\n ? value.map(v => this.translateNode(v, true))\n : [this.translateNode(value, true)],\n };\n }\n\n if (\n entries.length > 1 &&\n !isNested &&\n entries.every(([key]) => !this.isOperator(key) && !this.isCustomOperator(key))\n ) {\n return {\n must: entries.map(([key, value]) => this.translateNode(value, true, key)),\n };\n }\n\n return null;\n }\n\n private handleFieldConditions(\n entries: [string, any][],\n fieldKey?: string,\n ): { conditions: any[]; range: Record<string, any>; matchCondition: Record<string, any> | null } {\n const conditions = [];\n let range: Record<string, any> = {};\n let matchCondition: Record<string, any> | null = null;\n\n for (const [key, value] of entries) {\n if (this.isCustomOperator(key)) {\n const customOp = this.translateCustomOperator(key, value, fieldKey);\n conditions.push(customOp);\n } else if (this.isOperator(key)) {\n const opResult = this.translateOperatorValue(key, value);\n if (opResult.range) {\n Object.assign(range, opResult.range);\n } else {\n matchCondition = opResult;\n }\n } else {\n const nestedKey = fieldKey ? `${fieldKey}.${key}` : key;\n const nestedCondition = this.translateNode(value, true, nestedKey);\n\n if (nestedCondition.must) {\n conditions.push(...nestedCondition.must);\n } else if (!this.isEmpty(nestedCondition)) {\n conditions.push(nestedCondition);\n }\n }\n }\n\n return { conditions, range, matchCondition };\n }\n\n private translateCustomOperator(op: string, value: any, fieldKey?: string): any {\n switch (op) {\n case '$count':\n const countConditions = Object.entries(value).reduce(\n (acc, [k, v]) => ({\n ...acc,\n [k.replace('$', '')]: v,\n }),\n {},\n );\n return { key: fieldKey, values_count: countConditions };\n case '$geo':\n const geoOp = this.translateGeoFilter(value.type, value);\n return { key: fieldKey, ...geoOp };\n case '$hasId':\n return { has_id: Array.isArray(value) ? value : [value] };\n case '$nested':\n return {\n nested: {\n key: fieldKey,\n filter: this.translateNode(value),\n },\n };\n case '$hasVector':\n return { has_vector: value };\n case '$datetime':\n return {\n key: fieldKey,\n range: this.normalizeDatetimeRange(value.range),\n };\n case '$null':\n return { is_null: { key: fieldKey } };\n case '$empty':\n return { is_empty: { key: fieldKey } };\n default:\n throw new Error(`Unsupported custom operator: ${op}`);\n }\n }\n\n private getQdrantLogicalOp(op: string): string {\n switch (op) {\n case '$and':\n return 'must';\n case '$or':\n return 'should';\n case '$not':\n return 'must_not';\n default:\n throw new Error(`Unsupported logical operator: ${op}`);\n }\n }\n\n private translateOperatorValue(operator: string, value: any): any {\n const normalizedValue = this.normalizeComparisonValue(value);\n\n switch (operator) {\n case '$eq':\n return { value: normalizedValue };\n case '$ne':\n return { except: [normalizedValue] };\n case '$gt':\n return { range: { gt: normalizedValue } };\n case '$gte':\n return { range: { gte: normalizedValue } };\n case '$lt':\n return { range: { lt: normalizedValue } };\n case '$lte':\n return { range: { lte: normalizedValue } };\n case '$in':\n return { any: this.normalizeArrayValues(value) };\n case '$nin':\n return { except: this.normalizeArrayValues(value) };\n case '$regex':\n return { text: value };\n case 'exists':\n return value\n ? {\n must_not: [{ is_null: { key: value } }, { is_empty: { key: value } }],\n }\n : {\n is_empty: { key: value },\n };\n default:\n throw new Error(`Unsupported operator: ${operator}`);\n }\n }\n\n private translateGeoFilter(type: string, value: any): any {\n switch (type) {\n case 'box':\n return {\n geo_bounding_box: {\n top_left: value.top_left,\n bottom_right: value.bottom_right,\n },\n };\n case 'radius':\n return {\n geo_radius: {\n center: value.center,\n radius: value.radius,\n },\n };\n case 'polygon':\n return {\n geo_polygon: {\n exterior: value.exterior,\n interiors: value.interiors,\n },\n };\n default:\n throw new Error(`Unsupported geo filter type: ${type}`);\n }\n }\n\n private normalizeDatetimeRange(value: any): any {\n const range: Record<string, string> = {};\n for (const [op, val] of Object.entries(value)) {\n if (val instanceof Date) {\n range[op] = val.toISOString();\n } else if (typeof val === 'string') {\n // Assume string is already in proper format\n range[op] = val;\n }\n }\n return range;\n }\n}\n","import { MastraError, ErrorDomain, ErrorCategory } from '@mastra/core/error';\nimport { MastraVector } from '@mastra/core/vector';\nimport type {\n QueryResult,\n IndexStats,\n CreateIndexParams,\n UpsertVectorParams,\n QueryVectorParams,\n DescribeIndexParams,\n DeleteIndexParams,\n DeleteVectorParams,\n UpdateVectorParams,\n} from '@mastra/core/vector';\nimport { QdrantClient } from '@qdrant/js-client-rest';\nimport type { Schemas } from '@qdrant/js-client-rest';\n\nimport { QdrantFilterTranslator } from './filter';\nimport type { QdrantVectorFilter } from './filter';\n\nconst BATCH_SIZE = 256;\nconst DISTANCE_MAPPING: Record<string, Schemas['Distance']> = {\n cosine: 'Cosine',\n euclidean: 'Euclid',\n dotproduct: 'Dot',\n};\n\ntype QdrantQueryVectorParams = QueryVectorParams<QdrantVectorFilter>;\n\nexport class QdrantVector extends MastraVector {\n private client: QdrantClient;\n\n /**\n * Creates a new QdrantVector client.\n * @param url - The URL of the Qdrant server.\n * @param apiKey - The API key for Qdrant.\n * @param https - Whether to use HTTPS.\n */\n constructor({ url, apiKey, https }: { url: string; apiKey?: string; https?: boolean }) {\n super();\n const baseClient = new QdrantClient({\n url,\n apiKey,\n https,\n });\n const telemetry = this.__getTelemetry();\n this.client =\n telemetry?.traceClass(baseClient, {\n spanNamePrefix: 'qdrant-vector',\n attributes: {\n 'vector.type': 'qdrant',\n },\n }) ?? baseClient;\n }\n\n async upsert({ indexName, vectors, metadata, ids }: UpsertVectorParams): Promise<string[]> {\n const pointIds = ids || vectors.map(() => crypto.randomUUID());\n\n const records = vectors.map((vector, i) => ({\n id: pointIds[i],\n vector: vector,\n payload: metadata?.[i] || {},\n }));\n\n try {\n for (let i = 0; i < records.length; i += BATCH_SIZE) {\n const batch = records.slice(i, i + BATCH_SIZE);\n await this.client.upsert(indexName, {\n // @ts-expect-error\n points: batch,\n wait: true,\n });\n }\n\n return pointIds;\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_QDRANT_VECTOR_UPSERT_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, vectorCount: vectors.length },\n },\n error,\n );\n }\n }\n\n async createIndex({ indexName, dimension, metric = 'cosine' }: CreateIndexParams): Promise<void> {\n try {\n if (!Number.isInteger(dimension) || dimension <= 0) {\n throw new Error('Dimension must be a positive integer');\n }\n if (!DISTANCE_MAPPING[metric]) {\n throw new Error(`Invalid metric: \"${metric}\". Must be one of: cosine, euclidean, dotproduct`);\n }\n } catch (validationError) {\n throw new MastraError(\n {\n id: 'STORAGE_QDRANT_VECTOR_CREATE_INDEX_INVALID_ARGS',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName, dimension, metric },\n },\n validationError,\n );\n }\n\n try {\n await this.client.createCollection(indexName, {\n vectors: {\n size: dimension,\n distance: DISTANCE_MAPPING[metric],\n },\n });\n } catch (error: any) {\n const message = error?.message || error?.toString();\n // Qdrant typically returns 409 for existing collection\n if (error?.status === 409 || (typeof message === 'string' && message.toLowerCase().includes('exists'))) {\n // Fetch collection info and check dimension\n await this.validateExistingIndex(indexName, dimension, metric);\n return;\n }\n\n throw new MastraError(\n {\n id: 'STORAGE_QDRANT_VECTOR_CREATE_INDEX_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, dimension, metric },\n },\n error,\n );\n }\n }\n\n transformFilter(filter?: QdrantVectorFilter) {\n const translator = new QdrantFilterTranslator();\n return translator.translate(filter);\n }\n\n async query({\n indexName,\n queryVector,\n topK = 10,\n filter,\n includeVector = false,\n }: QdrantQueryVectorParams): Promise<QueryResult[]> {\n const translatedFilter = this.transformFilter(filter) ?? {};\n\n try {\n const results = (\n await this.client.query(indexName, {\n query: queryVector,\n limit: topK,\n filter: translatedFilter,\n with_payload: true,\n with_vector: includeVector,\n })\n ).points;\n\n return results.map(match => {\n let vector: number[] = [];\n if (includeVector) {\n if (Array.isArray(match.vector)) {\n // If it's already an array of numbers\n vector = match.vector as number[];\n } else if (typeof match.vector === 'object' && match.vector !== null) {\n // If it's an object with vector data\n vector = Object.values(match.vector).filter(v => typeof v === 'number');\n }\n }\n\n return {\n id: match.id as string,\n score: match.score || 0,\n metadata: match.payload as Record<string, any>,\n ...(includeVector && { vector }),\n };\n });\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_QDRANT_VECTOR_QUERY_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, topK },\n },\n error,\n );\n }\n }\n\n async listIndexes(): Promise<string[]> {\n try {\n const response = await this.client.getCollections();\n return response.collections.map(collection => collection.name) || [];\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_QDRANT_VECTOR_LIST_INDEXES_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n },\n error,\n );\n }\n }\n\n /**\n * Retrieves statistics about a vector index.\n *\n * @param {string} indexName - The name of the index to describe\n * @returns A promise that resolves to the index statistics including dimension, count and metric\n */\n async describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats> {\n try {\n const { config, points_count } = await this.client.getCollection(indexName);\n\n const distance = config.params.vectors?.distance as Schemas['Distance'];\n return {\n dimension: config.params.vectors?.size as number,\n count: points_count || 0,\n // @ts-expect-error\n metric: Object.keys(DISTANCE_MAPPING).find(key => DISTANCE_MAPPING[key] === distance),\n };\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_QDRANT_VECTOR_DESCRIBE_INDEX_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n async deleteIndex({ indexName }: DeleteIndexParams): Promise<void> {\n try {\n await this.client.deleteCollection(indexName);\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_QDRANT_VECTOR_DELETE_INDEX_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n /**\n * Updates a vector by its ID with the provided vector and/or metadata.\n * @param indexName - The name of the index containing the vector.\n * @param id - The ID of the vector to update.\n * @param update - An object containing the vector and/or metadata to update.\n * @param update.vector - An optional array of numbers representing the new vector.\n * @param update.metadata - An optional record containing the new metadata.\n * @returns A promise that resolves when the update is complete.\n * @throws Will throw an error if no updates are provided or if the update operation fails.\n */\n async updateVector({ indexName, id, update }: UpdateVectorParams): Promise<void> {\n try {\n if (!update.vector && !update.metadata) {\n throw new Error('No updates provided');\n }\n } catch (validationError) {\n throw new MastraError(\n {\n id: 'STORAGE_QDRANT_VECTOR_UPDATE_VECTOR_INVALID_ARGS',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.USER,\n details: { indexName, id },\n },\n validationError,\n );\n }\n\n const pointId = this.parsePointId(id);\n\n try {\n // Handle metadata-only update\n if (update.metadata && !update.vector) {\n // For metadata-only updates, use the setPayload method\n await this.client.setPayload(indexName, { payload: update.metadata, points: [pointId] });\n return;\n }\n\n // Handle vector-only update\n if (update.vector && !update.metadata) {\n await this.client.updateVectors(indexName, {\n points: [\n {\n id: pointId,\n vector: update.vector,\n },\n ],\n });\n return;\n }\n\n // Handle both vector and metadata update\n if (update.vector && update.metadata) {\n const point = {\n id: pointId,\n vector: update.vector,\n payload: update.metadata,\n };\n\n await this.client.upsert(indexName, {\n points: [point],\n });\n return;\n }\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_QDRANT_VECTOR_UPDATE_VECTOR_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, id },\n },\n error,\n );\n }\n }\n\n /**\n * Deletes a vector by its ID.\n * @param indexName - The name of the index containing the vector.\n * @param id - The ID of the vector to delete.\n * @returns A promise that resolves when the deletion is complete.\n * @throws Will throw an error if the deletion operation fails.\n */\n async deleteVector({ indexName, id }: DeleteVectorParams): Promise<void> {\n try {\n // Parse the ID - Qdrant supports both string and numeric IDs\n const pointId = this.parsePointId(id);\n\n // Use the Qdrant client to delete the point from the collection\n await this.client.delete(indexName, {\n points: [pointId],\n });\n } catch (error) {\n throw new MastraError(\n {\n id: 'STORAGE_QDRANT_VECTOR_DELETE_VECTOR_FAILED',\n domain: ErrorDomain.STORAGE,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, id },\n },\n error,\n );\n }\n }\n\n /**\n * Parses and converts a string ID to the appropriate type (string or number) for Qdrant point operations.\n *\n * Qdrant supports both numeric and string IDs. This helper method ensures IDs are in the correct format\n * before sending them to the Qdrant client API.\n *\n * @param id - The ID string to parse\n * @returns The parsed ID as either a number (if string contains only digits) or the original string\n *\n * @example\n * // Numeric ID strings are converted to numbers\n * parsePointId(\"123\") => 123\n * parsePointId(\"42\") => 42\n * parsePointId(\"0\") => 0\n *\n * // String IDs containing any non-digit characters remain as strings\n * parsePointId(\"doc-123\") => \"doc-123\"\n * parsePointId(\"user_42\") => \"user_42\"\n * parsePointId(\"abc123\") => \"abc123\"\n * parsePointId(\"123abc\") => \"123abc\"\n * parsePointId(\"\") => \"\"\n * parsePointId(\"uuid-5678-xyz\") => \"uuid-5678-xyz\"\n *\n * @remarks\n * - This conversion is important because Qdrant treats numeric and string IDs differently\n * - Only positive integers are converted to numbers (negative numbers with minus signs remain strings)\n * - The method uses base-10 parsing, so leading zeros will be dropped in numeric conversions\n * - reference: https://qdrant.tech/documentation/concepts/points/?q=qdrant+point+id#point-ids\n */\n private parsePointId(id: string): string | number {\n // Try to parse as number if it looks like one\n if (/^\\d+$/.test(id)) {\n return parseInt(id, 10);\n }\n return id;\n }\n}\n","/**\n * Vector store specific prompt that details supported operators and examples.\n * This prompt helps users construct valid filters for Qdrant Vector.\n */\nexport const QDRANT_PROMPT = `When querying Qdrant, you can ONLY use the operators listed below. Any other operators will be rejected.\nImportant: Don't explain how to construct the filter - use the specified operators and fields to search the content and return relevant results.\nIf a user tries to give an explicit operator that is not supported, reject the filter entirely and let them know that the operator is not supported.\n\nBasic Comparison Operators:\n- $eq: Exact match (default when using field: value)\n Example: { \"category\": \"electronics\" }\n- $ne: Not equal\n Example: { \"category\": { \"$ne\": \"electronics\" } }\n- $gt: Greater than\n Example: { \"price\": { \"$gt\": 100 } }\n- $gte: Greater than or equal\n Example: { \"price\": { \"$gte\": 100 } }\n- $lt: Less than\n Example: { \"price\": { \"$lt\": 100 } }\n- $lte: Less than or equal\n Example: { \"price\": { \"$lte\": 100 } }\n\nArray Operators:\n- $in: Match any value in array\n Example: { \"category\": { \"$in\": [\"electronics\", \"books\"] } }\n- $nin: Does not match any value in array\n Example: { \"category\": { \"$nin\": [\"electronics\", \"books\"] } }\n\nLogical Operators:\n- $and: Logical AND (can be implicit or explicit)\n Implicit Example: { \"price\": { \"$gt\": 100 }, \"category\": \"electronics\" }\n Explicit Example: { \"$and\": [{ \"price\": { \"$gt\": 100 } }, { \"category\": \"electronics\" }] }\n- $or: Logical OR\n Example: { \"$or\": [{ \"price\": { \"$lt\": 50 } }, { \"category\": \"books\" }] }\n- $not: Logical NOT\n Example: { \"$not\": { \"category\": \"electronics\" } }\n\nElement Operators:\n- $exists: Check if field exists\n Example: { \"rating\": { \"$exists\": true } }\n- $match: Match text using full-text search\n Example: { \"description\": { \"$match\": \"gaming laptop\" } }\n- $null: Check if field is null\n Example: { \"rating\": { \"$null\": true } }\n\nRestrictions:\n- Regex patterns are not supported\n- Only $and, $or, and $not logical operators are supported at the top level\n- Empty arrays in $in/$nin will return no results\n- Nested fields are supported using dot notation\n- Multiple conditions on the same field are supported with both implicit and explicit $and\n- At least one key-value pair is required in filter object\n- Empty objects and undefined values are treated as no filter\n- Invalid types in comparison operators will throw errors\n- All non-logical operators must be used within a field condition\n Valid: { \"field\": { \"$gt\": 100 } }\n Valid: { \"$and\": [...] }\n Invalid: { \"$gt\": 100 }\n- Logical operators must contain field conditions, not direct operators\n Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n Invalid: { \"$and\": [{ \"$gt\": 100 }] }\n- Logical operators ($and, $or, $not):\n - Can only be used at top level or nested within other logical operators\n - Can not be used on a field level, or be nested inside a field\n - Can not be used inside an operator\n - Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n - Valid: { \"$or\": [{ \"$and\": [{ \"field\": { \"$gt\": 100 } }] }] }\n - Invalid: { \"field\": { \"$and\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$or\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$gt\": { \"$and\": [{...}] } } }\n\nExample Complex Query:\n{\n \"$and\": [\n { \"category\": { \"$in\": [\"electronics\", \"computers\"] } },\n { \"price\": { \"$gte\": 100, \"$lte\": 1000 } },\n { \"description\": { \"$match\": \"gaming laptop\" } },\n { \"rating\": { \"$exists\": true, \"$gt\": 4 } },\n { \"$or\": [\n { \"stock\": { \"$gt\": 0 } },\n { \"preorder\": { \"$null\": false } }\n ]},\n { \"$not\": { \"status\": \"discontinued\" } }\n ]\n}`;\n"]}
@@ -0,0 +1,105 @@
1
+ import { BaseFilterTranslator } from '@mastra/core/vector/filter';
2
+ import type { VectorFilter, LogicalOperator, OperatorSupport, OperatorValueMap, LogicalOperatorValueMap, BlacklistedRootOperators } from '@mastra/core/vector/filter';
3
+ type QdrantOperatorValueMap = Omit<OperatorValueMap, '$options' | '$elemMatch' | '$all'> & {
4
+ /**
5
+ * $count: Filter by array length or value count.
6
+ * Example: { tags: { $count: { gt: 2 } } }
7
+ */
8
+ $count: {
9
+ $gt?: number;
10
+ $gte?: number;
11
+ $lt?: number;
12
+ $lte?: number;
13
+ $eq?: number;
14
+ };
15
+ /**
16
+ * $geo: Geospatial filter.
17
+ * Example: { location: { $geo: { type: 'geo_radius', center: [lon, lat], radius: 1000 } } }
18
+ */
19
+ $geo: {
20
+ type: string;
21
+ [key: string]: any;
22
+ };
23
+ /**
24
+ * $hasId: Filter by point IDs.
25
+ * Allowed at root level.
26
+ * Example: { $hasId: '123' } or { $hasId: ['123', '456'] }
27
+ */
28
+ $hasId: string | string[];
29
+ /**
30
+ * $nested: Nested object filter.
31
+ * Example: { metadata: { $nested: { key: 'foo', filter: { $eq: 'bar' } } } }
32
+ */
33
+ $nested: {
34
+ [key: string]: any;
35
+ };
36
+ /**
37
+ * $hasVector: Filter by vector existence or field.
38
+ * Allowed at root level.
39
+ * Example: { $hasVector: true } or { $hasVector: 'vector_field' }
40
+ */
41
+ $hasVector: boolean | string;
42
+ /**
43
+ * $datetime: RFC 3339 datetime range.
44
+ * Example: { createdAt: { $datetime: { gte: '2024-01-01T00:00:00Z' } } }
45
+ */
46
+ $datetime: {
47
+ key?: string;
48
+ range?: {
49
+ gt?: Date | string;
50
+ gte?: Date | string;
51
+ lt?: Date | string;
52
+ lte?: Date | string;
53
+ eq?: Date | string;
54
+ };
55
+ };
56
+ /**
57
+ * $null: Check if a field is null.
58
+ * Example: { metadata: { $null: true } }
59
+ */
60
+ $null: boolean;
61
+ /**
62
+ * $empty: Check if an array or object field is empty.
63
+ * Example: { tags: { $empty: true } }
64
+ */
65
+ $empty: boolean;
66
+ };
67
+ type QdrantLogicalOperatorValueMap = Omit<LogicalOperatorValueMap, '$nor'>;
68
+ type QdrantBlacklistedRootOperators = BlacklistedRootOperators | '$count' | '$geo' | '$nested' | '$datetime' | '$null' | '$empty';
69
+ export type QdrantVectorFilter = VectorFilter<keyof QdrantOperatorValueMap, QdrantOperatorValueMap, QdrantLogicalOperatorValueMap, QdrantBlacklistedRootOperators>;
70
+ /**
71
+ * Translates MongoDB-style filters to Qdrant compatible filters.
72
+ *
73
+ * Key transformations:
74
+ * - $and -> must
75
+ * - $or -> should
76
+ * - $not -> must_not
77
+ * - { field: { $op: value } } -> { key: field, match/range: { value/gt/lt: value } }
78
+ *
79
+ * Custom operators (Qdrant-specific):
80
+ * - $count -> values_count (array length/value count)
81
+ * - $geo -> geo filters (box, radius, polygon)
82
+ * - $hasId -> has_id filter
83
+ * - $nested -> nested object filters
84
+ * - $hasVector -> vector existence check
85
+ * - $datetime -> RFC 3339 datetime range
86
+ * - $null -> is_null check
87
+ * - $empty -> is_empty check
88
+ */
89
+ export declare class QdrantFilterTranslator extends BaseFilterTranslator<QdrantVectorFilter> {
90
+ protected isLogicalOperator(key: string): key is LogicalOperator;
91
+ protected getSupportedOperators(): OperatorSupport;
92
+ translate(filter?: QdrantVectorFilter): QdrantVectorFilter;
93
+ private createCondition;
94
+ private translateNode;
95
+ private buildFinalConditions;
96
+ private handleLogicalOperators;
97
+ private handleFieldConditions;
98
+ private translateCustomOperator;
99
+ private getQdrantLogicalOp;
100
+ private translateOperatorValue;
101
+ private translateGeoFilter;
102
+ private normalizeDatetimeRange;
103
+ }
104
+ export {};
105
+ //# sourceMappingURL=filter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../../src/vector/filter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,KAAK,EACV,YAAY,EACZ,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,uBAAuB,EACvB,wBAAwB,EACzB,MAAM,4BAA4B,CAAC;AAEpC,KAAK,sBAAsB,GAAG,IAAI,CAAC,gBAAgB,EAAE,UAAU,GAAG,YAAY,GAAG,MAAM,CAAC,GAAG;IACzF;;;OAGG;IACH,MAAM,EAAE;QACN,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,GAAG,CAAC,EAAE,MAAM,CAAC;KACd,CAAC;IAEF;;;OAGG;IACH,IAAI,EAAE;QACJ,IAAI,EAAE,MAAM,CAAC;QACb,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACpB,CAAC;IAEF;;;;OAIG;IACH,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAE1B;;;OAGG;IACH,OAAO,EAAE;QAEP,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACpB,CAAC;IAEF;;;;OAIG;IACH,UAAU,EAAE,OAAO,GAAG,MAAM,CAAC;IAE7B;;;OAGG;IACH,SAAS,EAAE;QACT,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,KAAK,CAAC,EAAE;YACN,EAAE,CAAC,E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QueryResult, IndexStats, CreateIndexParams, UpsertVectorParams, QueryVectorParams, DescribeIndexParams, DeleteIndexParams, DeleteVectorParams, UpdateVectorParams } from '@mastra/core/vector';
3
+ import type { QdrantVectorFilter } from './filter.js';
4
+ type QdrantQueryVectorParams = QueryVectorParams<QdrantVectorFilter>;
5
+ export declare class QdrantVector extends MastraVector {
6
+ private client;
7
+ /**
8
+ * Creates a new QdrantVector client.
9
+ * @param url - The URL of the Qdrant server.
10
+ * @param apiKey - The API key for Qdrant.
11
+ * @param https - Whether to use HTTPS.
12
+ */
13
+ constructor({ url, apiKey, https }: {
14
+ url: string;
15
+ apiKey?: string;
16
+ https?: boolean;
17
+ });
18
+ upsert({ indexName, vectors, metadata, ids }: UpsertVectorParams): Promise<string[]>;
19
+ createIndex({ indexName, dimension, metric }: CreateIndexParams): Promise<void>;
20
+ transformFilter(filter?: QdrantVectorFilter): QdrantVectorFilter;
21
+ query({ indexName, queryVector, topK, filter, includeVector, }: QdrantQueryVectorParams): Promise<QueryResult[]>;
22
+ listIndexes(): Promise<string[]>;
23
+ /**
24
+ * Retrieves statistics about a vector index.
25
+ *
26
+ * @param {string} indexName - The name of the index to describe
27
+ * @returns A promise that resolves to the index statistics including dimension, count and metric
28
+ */
29
+ describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats>;
30
+ deleteIndex({ indexName }: DeleteIndexParams): Promise<void>;
31
+ /**
32
+ * Updates a vector by its ID with the provided vector and/or metadata.
33
+ * @param indexName - The name of the index containing the vector.
34
+ * @param id - The ID of the vector to update.
35
+ * @param update - An object containing the vector and/or metadata to update.
36
+ * @param update.vector - An optional array of numbers representing the new vector.
37
+ * @param update.metadata - An optional record containing the new metadata.
38
+ * @returns A promise that resolves when the update is complete.
39
+ * @throws Will throw an error if no updates are provided or if the update operation fails.
40
+ */
41
+ updateVector({ indexName, id, update }: UpdateVectorParams): Promise<void>;
42
+ /**
43
+ * Deletes a vector by its ID.
44
+ * @param indexName - The name of the index containing the vector.
45
+ * @param id - The ID of the vector to delete.
46
+ * @returns A promise that resolves when the deletion is complete.
47
+ * @throws Will throw an error if the deletion operation fails.
48
+ */
49
+ deleteVector({ indexName, id }: DeleteVectorParams): Promise<void>;
50
+ /**
51
+ * Parses and converts a string ID to the appropriate type (string or number) for Qdrant point operations.
52
+ *
53
+ * Qdrant supports both numeric and string IDs. This helper method ensures IDs are in the correct format
54
+ * before sending them to the Qdrant client API.
55
+ *
56
+ * @param id - The ID string to parse
57
+ * @returns The parsed ID as either a number (if string contains only digits) or the original string
58
+ *
59
+ * @example
60
+ * // Numeric ID strings are converted to numbers
61
+ * parsePointId("123") => 123
62
+ * parsePointId("42") => 42
63
+ * parsePointId("0") => 0
64
+ *
65
+ * // String IDs containing any non-digit characters remain as strings
66
+ * parsePointId("doc-123") => "doc-123"
67
+ * parsePointId("user_42") => "user_42"
68
+ * parsePointId("abc123") => "abc123"
69
+ * parsePointId("123abc") => "123abc"
70
+ * parsePointId("") => ""
71
+ * parsePointId("uuid-5678-xyz") => "uuid-5678-xyz"
72
+ *
73
+ * @remarks
74
+ * - This conversion is important because Qdrant treats numeric and string IDs differently
75
+ * - Only positive integers are converted to numbers (negative numbers with minus signs remain strings)
76
+ * - The method uses base-10 parsing, so leading zeros will be dropped in numeric conversions
77
+ * - reference: https://qdrant.tech/documentation/concepts/points/?q=qdrant+point+id#point-ids
78
+ */
79
+ private parsePointId;
80
+ }
81
+ export {};
82
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vector/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EACnB,MAAM,qBAAqB,CAAC;AAK7B,OAAO,KAAK,EAAE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;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACH,OAAO,CAAC,YAAY;CAOrB"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Vector store specific prompt that details supported operators and examples.
3
+ * This prompt helps users construct valid filters for Qdrant Vector.
4
+ */
5
+ export declare const QDRANT_PROMPT = "When querying Qdrant, you can ONLY use the operators listed below. Any other operators will be rejected.\nImportant: Don't explain how to construct the filter - use the specified operators and fields to search the content and return relevant results.\nIf a user tries to give an explicit operator that is not supported, reject the filter entirely and let them know that the operator is not supported.\n\nBasic Comparison Operators:\n- $eq: Exact match (default when using field: value)\n Example: { \"category\": \"electronics\" }\n- $ne: Not equal\n Example: { \"category\": { \"$ne\": \"electronics\" } }\n- $gt: Greater than\n Example: { \"price\": { \"$gt\": 100 } }\n- $gte: Greater than or equal\n Example: { \"price\": { \"$gte\": 100 } }\n- $lt: Less than\n Example: { \"price\": { \"$lt\": 100 } }\n- $lte: Less than or equal\n Example: { \"price\": { \"$lte\": 100 } }\n\nArray Operators:\n- $in: Match any value in array\n Example: { \"category\": { \"$in\": [\"electronics\", \"books\"] } }\n- $nin: Does not match any value in array\n Example: { \"category\": { \"$nin\": [\"electronics\", \"books\"] } }\n\nLogical Operators:\n- $and: Logical AND (can be implicit or explicit)\n Implicit Example: { \"price\": { \"$gt\": 100 }, \"category\": \"electronics\" }\n Explicit Example: { \"$and\": [{ \"price\": { \"$gt\": 100 } }, { \"category\": \"electronics\" }] }\n- $or: Logical OR\n Example: { \"$or\": [{ \"price\": { \"$lt\": 50 } }, { \"category\": \"books\" }] }\n- $not: Logical NOT\n Example: { \"$not\": { \"category\": \"electronics\" } }\n\nElement Operators:\n- $exists: Check if field exists\n Example: { \"rating\": { \"$exists\": true } }\n- $match: Match text using full-text search\n Example: { \"description\": { \"$match\": \"gaming laptop\" } }\n- $null: Check if field is null\n Example: { \"rating\": { \"$null\": true } }\n\nRestrictions:\n- Regex patterns are not supported\n- Only $and, $or, and $not logical operators are supported at the top level\n- Empty arrays in $in/$nin will return no results\n- Nested fields are supported using dot notation\n- Multiple conditions on the same field are supported with both implicit and explicit $and\n- At least one key-value pair is required in filter object\n- Empty objects and undefined values are treated as no filter\n- Invalid types in comparison operators will throw errors\n- All non-logical operators must be used within a field condition\n Valid: { \"field\": { \"$gt\": 100 } }\n Valid: { \"$and\": [...] }\n Invalid: { \"$gt\": 100 }\n- Logical operators must contain field conditions, not direct operators\n Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n Invalid: { \"$and\": [{ \"$gt\": 100 }] }\n- Logical operators ($and, $or, $not):\n - Can only be used at top level or nested within other logical operators\n - Can not be used on a field level, or be nested inside a field\n - Can not be used inside an operator\n - Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n - Valid: { \"$or\": [{ \"$and\": [{ \"field\": { \"$gt\": 100 } }] }] }\n - Invalid: { \"field\": { \"$and\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$or\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$gt\": { \"$and\": [{...}] } } }\n\nExample Complex Query:\n{\n \"$and\": [\n { \"category\": { \"$in\": [\"electronics\", \"computers\"] } },\n { \"price\": { \"$gte\": 100, \"$lte\": 1000 } },\n { \"description\": { \"$match\": \"gaming laptop\" } },\n { \"rating\": { \"$exists\": true, \"$gt\": 4 } },\n { \"$or\": [\n { \"stock\": { \"$gt\": 0 } },\n { \"preorder\": { \"$null\": false } }\n ]},\n { \"$not\": { \"status\": \"discontinued\" } }\n ]\n}";
6
+ //# sourceMappingURL=prompt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../src/vector/prompt.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,aAAa,gpHAgFxB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/qdrant",
3
- "version": "0.11.2",
3
+ "version": "0.11.3",
4
4
  "description": "Qdrant vector store provider for Mastra",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -12,7 +12,7 @@
12
12
  "default": "./dist/index.js"
13
13
  },
14
14
  "require": {
15
- "types": "./dist/index.d.cts",
15
+ "types": "./dist/index.d.ts",
16
16
  "default": "./dist/index.cjs"
17
17
  }
18
18
  },
@@ -29,15 +29,16 @@
29
29
  "tsup": "^8.5.0",
30
30
  "typescript": "^5.8.3",
31
31
  "vitest": "^3.2.4",
32
- "@internal/lint": "0.0.24",
33
- "@mastra/core": "0.12.0"
32
+ "@internal/lint": "0.0.27",
33
+ "@internal/types-builder": "0.0.2",
34
+ "@mastra/core": "0.13.0"
34
35
  },
35
36
  "peerDependencies": {
36
- "@mastra/core": ">=0.10.7-0 <0.13.0-0"
37
+ "@mastra/core": ">=0.10.7-0 <0.14.0-0"
37
38
  },
38
39
  "scripts": {
39
- "build": "tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting",
40
- "build:watch": "pnpm build --watch",
40
+ "build": "tsup --silent --config tsup.config.ts",
41
+ "build:watch": "tsup --watch --silent --config tsup.config.ts",
41
42
  "test": "vitest run",
42
43
  "lint": "eslint ."
43
44
  }
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": ["./tsconfig.json", "../../tsconfig.build.json"],
3
+ "compilerOptions": {
4
+ "outDir": "./dist",
5
+ "rootDir": "./src"
6
+ },
7
+ "include": ["src/**/*"],
8
+ "exclude": ["node_modules", "**/*.test.ts", "src/**/*.mock.ts"]
9
+ }
package/tsconfig.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "extends": "../../tsconfig.node.json",
3
- "include": ["src/**/*"],
3
+ "include": ["src/**/*", "tsup.config.ts"],
4
4
  "exclude": ["node_modules", "**/*.test.ts"]
5
5
  }
package/tsup.config.ts ADDED
@@ -0,0 +1,17 @@
1
+ import { generateTypes } from '@internal/types-builder';
2
+ import { defineConfig } from 'tsup';
3
+
4
+ export default defineConfig({
5
+ entry: ['src/index.ts'],
6
+ format: ['esm', 'cjs'],
7
+ clean: true,
8
+ dts: false,
9
+ splitting: true,
10
+ treeshake: {
11
+ preset: 'smallest',
12
+ },
13
+ sourcemap: true,
14
+ onSuccess: async () => {
15
+ await generateTypes(process.cwd());
16
+ },
17
+ });
@@ -1,214 +0,0 @@
1
- import { BaseFilterTranslator } from '@mastra/core/vector/filter';
2
- import type { BlacklistedRootOperators } from '@mastra/core/vector/filter';
3
- import type { CreateIndexParams } from '@mastra/core/vector';
4
- import type { DeleteIndexParams } from '@mastra/core/vector';
5
- import type { DeleteVectorParams } from '@mastra/core/vector';
6
- import type { DescribeIndexParams } from '@mastra/core/vector';
7
- import type { IndexStats } from '@mastra/core/vector';
8
- import type { LogicalOperator } from '@mastra/core/vector/filter';
9
- import type { LogicalOperatorValueMap } from '@mastra/core/vector/filter';
10
- import { MastraVector } from '@mastra/core/vector';
11
- import type { OperatorSupport } from '@mastra/core/vector/filter';
12
- import type { OperatorValueMap } from '@mastra/core/vector/filter';
13
- import type { QueryResult } from '@mastra/core/vector';
14
- import type { QueryVectorParams } from '@mastra/core/vector';
15
- import type { UpdateVectorParams } from '@mastra/core/vector';
16
- import type { UpsertVectorParams } from '@mastra/core/vector';
17
- import type { VectorFilter } from '@mastra/core/vector/filter';
18
-
19
- /**
20
- * Vector store specific prompt that details supported operators and examples.
21
- * This prompt helps users construct valid filters for Qdrant Vector.
22
- */
23
- declare const QDRANT_PROMPT = "When querying Qdrant, you can ONLY use the operators listed below. Any other operators will be rejected.\nImportant: Don't explain how to construct the filter - use the specified operators and fields to search the content and return relevant results.\nIf a user tries to give an explicit operator that is not supported, reject the filter entirely and let them know that the operator is not supported.\n\nBasic Comparison Operators:\n- $eq: Exact match (default when using field: value)\n Example: { \"category\": \"electronics\" }\n- $ne: Not equal\n Example: { \"category\": { \"$ne\": \"electronics\" } }\n- $gt: Greater than\n Example: { \"price\": { \"$gt\": 100 } }\n- $gte: Greater than or equal\n Example: { \"price\": { \"$gte\": 100 } }\n- $lt: Less than\n Example: { \"price\": { \"$lt\": 100 } }\n- $lte: Less than or equal\n Example: { \"price\": { \"$lte\": 100 } }\n\nArray Operators:\n- $in: Match any value in array\n Example: { \"category\": { \"$in\": [\"electronics\", \"books\"] } }\n- $nin: Does not match any value in array\n Example: { \"category\": { \"$nin\": [\"electronics\", \"books\"] } }\n\nLogical Operators:\n- $and: Logical AND (can be implicit or explicit)\n Implicit Example: { \"price\": { \"$gt\": 100 }, \"category\": \"electronics\" }\n Explicit Example: { \"$and\": [{ \"price\": { \"$gt\": 100 } }, { \"category\": \"electronics\" }] }\n- $or: Logical OR\n Example: { \"$or\": [{ \"price\": { \"$lt\": 50 } }, { \"category\": \"books\" }] }\n- $not: Logical NOT\n Example: { \"$not\": { \"category\": \"electronics\" } }\n\nElement Operators:\n- $exists: Check if field exists\n Example: { \"rating\": { \"$exists\": true } }\n- $match: Match text using full-text search\n Example: { \"description\": { \"$match\": \"gaming laptop\" } }\n- $null: Check if field is null\n Example: { \"rating\": { \"$null\": true } }\n\nRestrictions:\n- Regex patterns are not supported\n- Only $and, $or, and $not logical operators are supported at the top level\n- Empty arrays in $in/$nin will return no results\n- Nested fields are supported using dot notation\n- Multiple conditions on the same field are supported with both implicit and explicit $and\n- At least one key-value pair is required in filter object\n- Empty objects and undefined values are treated as no filter\n- Invalid types in comparison operators will throw errors\n- All non-logical operators must be used within a field condition\n Valid: { \"field\": { \"$gt\": 100 } }\n Valid: { \"$and\": [...] }\n Invalid: { \"$gt\": 100 }\n- Logical operators must contain field conditions, not direct operators\n Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n Invalid: { \"$and\": [{ \"$gt\": 100 }] }\n- Logical operators ($and, $or, $not):\n - Can only be used at top level or nested within other logical operators\n - Can not be used on a field level, or be nested inside a field\n - Can not be used inside an operator\n - Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n - Valid: { \"$or\": [{ \"$and\": [{ \"field\": { \"$gt\": 100 } }] }] }\n - Invalid: { \"field\": { \"$and\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$or\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$gt\": { \"$and\": [{...}] } } }\n\nExample Complex Query:\n{\n \"$and\": [\n { \"category\": { \"$in\": [\"electronics\", \"computers\"] } },\n { \"price\": { \"$gte\": 100, \"$lte\": 1000 } },\n { \"description\": { \"$match\": \"gaming laptop\" } },\n { \"rating\": { \"$exists\": true, \"$gt\": 4 } },\n { \"$or\": [\n { \"stock\": { \"$gt\": 0 } },\n { \"preorder\": { \"$null\": false } }\n ]},\n { \"$not\": { \"status\": \"discontinued\" } }\n ]\n}";
24
- export { QDRANT_PROMPT }
25
- export { QDRANT_PROMPT as QDRANT_PROMPT_alias_1 }
26
-
27
- declare type QdrantBlacklistedRootOperators = BlacklistedRootOperators | '$count' | '$geo' | '$nested' | '$datetime' | '$null' | '$empty';
28
-
29
- /**
30
- * Translates MongoDB-style filters to Qdrant compatible filters.
31
- *
32
- * Key transformations:
33
- * - $and -> must
34
- * - $or -> should
35
- * - $not -> must_not
36
- * - { field: { $op: value } } -> { key: field, match/range: { value/gt/lt: value } }
37
- *
38
- * Custom operators (Qdrant-specific):
39
- * - $count -> values_count (array length/value count)
40
- * - $geo -> geo filters (box, radius, polygon)
41
- * - $hasId -> has_id filter
42
- * - $nested -> nested object filters
43
- * - $hasVector -> vector existence check
44
- * - $datetime -> RFC 3339 datetime range
45
- * - $null -> is_null check
46
- * - $empty -> is_empty check
47
- */
48
- export declare class QdrantFilterTranslator extends BaseFilterTranslator<QdrantVectorFilter> {
49
- protected isLogicalOperator(key: string): key is LogicalOperator;
50
- protected getSupportedOperators(): OperatorSupport;
51
- translate(filter?: QdrantVectorFilter): QdrantVectorFilter;
52
- private createCondition;
53
- private translateNode;
54
- private buildFinalConditions;
55
- private handleLogicalOperators;
56
- private handleFieldConditions;
57
- private translateCustomOperator;
58
- private getQdrantLogicalOp;
59
- private translateOperatorValue;
60
- private translateGeoFilter;
61
- private normalizeDatetimeRange;
62
- }
63
-
64
- declare type QdrantLogicalOperatorValueMap = Omit<LogicalOperatorValueMap, '$nor'>;
65
-
66
- declare type QdrantOperatorValueMap = Omit<OperatorValueMap, '$options' | '$elemMatch' | '$all'> & {
67
- /**
68
- * $count: Filter by array length or value count.
69
- * Example: { tags: { $count: { gt: 2 } } }
70
- */
71
- $count: {
72
- $gt?: number;
73
- $gte?: number;
74
- $lt?: number;
75
- $lte?: number;
76
- $eq?: number;
77
- };
78
- /**
79
- * $geo: Geospatial filter.
80
- * Example: { location: { $geo: { type: 'geo_radius', center: [lon, lat], radius: 1000 } } }
81
- */
82
- $geo: {
83
- type: string;
84
- [key: string]: any;
85
- };
86
- /**
87
- * $hasId: Filter by point IDs.
88
- * Allowed at root level.
89
- * Example: { $hasId: '123' } or { $hasId: ['123', '456'] }
90
- */
91
- $hasId: string | string[];
92
- /**
93
- * $nested: Nested object filter.
94
- * Example: { metadata: { $nested: { key: 'foo', filter: { $eq: 'bar' } } } }
95
- */
96
- $nested: {
97
- [key: string]: any;
98
- };
99
- /**
100
- * $hasVector: Filter by vector existence or field.
101
- * Allowed at root level.
102
- * Example: { $hasVector: true } or { $hasVector: 'vector_field' }
103
- */
104
- $hasVector: boolean | string;
105
- /**
106
- * $datetime: RFC 3339 datetime range.
107
- * Example: { createdAt: { $datetime: { gte: '2024-01-01T00:00:00Z' } } }
108
- */
109
- $datetime: {
110
- key?: string;
111
- range?: {
112
- gt?: Date | string;
113
- gte?: Date | string;
114
- lt?: Date | string;
115
- lte?: Date | string;
116
- eq?: Date | string;
117
- };
118
- };
119
- /**
120
- * $null: Check if a field is null.
121
- * Example: { metadata: { $null: true } }
122
- */
123
- $null: boolean;
124
- /**
125
- * $empty: Check if an array or object field is empty.
126
- * Example: { tags: { $empty: true } }
127
- */
128
- $empty: boolean;
129
- };
130
-
131
- declare type QdrantQueryVectorParams = QueryVectorParams<QdrantVectorFilter>;
132
-
133
- declare class QdrantVector extends MastraVector {
134
- private client;
135
- /**
136
- * Creates a new QdrantVector client.
137
- * @param url - The URL of the Qdrant server.
138
- * @param apiKey - The API key for Qdrant.
139
- * @param https - Whether to use HTTPS.
140
- */
141
- constructor({ url, apiKey, https }: {
142
- url: string;
143
- apiKey?: string;
144
- https?: boolean;
145
- });
146
- upsert({ indexName, vectors, metadata, ids }: UpsertVectorParams): Promise<string[]>;
147
- createIndex({ indexName, dimension, metric }: CreateIndexParams): Promise<void>;
148
- transformFilter(filter?: QdrantVectorFilter): QdrantVectorFilter;
149
- query({ indexName, queryVector, topK, filter, includeVector, }: QdrantQueryVectorParams): Promise<QueryResult[]>;
150
- listIndexes(): Promise<string[]>;
151
- /**
152
- * Retrieves statistics about a vector index.
153
- *
154
- * @param {string} indexName - The name of the index to describe
155
- * @returns A promise that resolves to the index statistics including dimension, count and metric
156
- */
157
- describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats>;
158
- deleteIndex({ indexName }: DeleteIndexParams): Promise<void>;
159
- /**
160
- * Updates a vector by its ID with the provided vector and/or metadata.
161
- * @param indexName - The name of the index containing the vector.
162
- * @param id - The ID of the vector to update.
163
- * @param update - An object containing the vector and/or metadata to update.
164
- * @param update.vector - An optional array of numbers representing the new vector.
165
- * @param update.metadata - An optional record containing the new metadata.
166
- * @returns A promise that resolves when the update is complete.
167
- * @throws Will throw an error if no updates are provided or if the update operation fails.
168
- */
169
- updateVector({ indexName, id, update }: UpdateVectorParams): Promise<void>;
170
- /**
171
- * Deletes a vector by its ID.
172
- * @param indexName - The name of the index containing the vector.
173
- * @param id - The ID of the vector to delete.
174
- * @returns A promise that resolves when the deletion is complete.
175
- * @throws Will throw an error if the deletion operation fails.
176
- */
177
- deleteVector({ indexName, id }: DeleteVectorParams): Promise<void>;
178
- /**
179
- * Parses and converts a string ID to the appropriate type (string or number) for Qdrant point operations.
180
- *
181
- * Qdrant supports both numeric and string IDs. This helper method ensures IDs are in the correct format
182
- * before sending them to the Qdrant client API.
183
- *
184
- * @param id - The ID string to parse
185
- * @returns The parsed ID as either a number (if string contains only digits) or the original string
186
- *
187
- * @example
188
- * // Numeric ID strings are converted to numbers
189
- * parsePointId("123") => 123
190
- * parsePointId("42") => 42
191
- * parsePointId("0") => 0
192
- *
193
- * // String IDs containing any non-digit characters remain as strings
194
- * parsePointId("doc-123") => "doc-123"
195
- * parsePointId("user_42") => "user_42"
196
- * parsePointId("abc123") => "abc123"
197
- * parsePointId("123abc") => "123abc"
198
- * parsePointId("") => ""
199
- * parsePointId("uuid-5678-xyz") => "uuid-5678-xyz"
200
- *
201
- * @remarks
202
- * - This conversion is important because Qdrant treats numeric and string IDs differently
203
- * - Only positive integers are converted to numbers (negative numbers with minus signs remain strings)
204
- * - The method uses base-10 parsing, so leading zeros will be dropped in numeric conversions
205
- * - reference: https://qdrant.tech/documentation/concepts/points/?q=qdrant+point+id#point-ids
206
- */
207
- private parsePointId;
208
- }
209
- export { QdrantVector }
210
- export { QdrantVector as QdrantVector_alias_1 }
211
-
212
- export declare type QdrantVectorFilter = VectorFilter<keyof QdrantOperatorValueMap, QdrantOperatorValueMap, QdrantLogicalOperatorValueMap, QdrantBlacklistedRootOperators>;
213
-
214
- export { }
@@ -1,214 +0,0 @@
1
- import { BaseFilterTranslator } from '@mastra/core/vector/filter';
2
- import type { BlacklistedRootOperators } from '@mastra/core/vector/filter';
3
- import type { CreateIndexParams } from '@mastra/core/vector';
4
- import type { DeleteIndexParams } from '@mastra/core/vector';
5
- import type { DeleteVectorParams } from '@mastra/core/vector';
6
- import type { DescribeIndexParams } from '@mastra/core/vector';
7
- import type { IndexStats } from '@mastra/core/vector';
8
- import type { LogicalOperator } from '@mastra/core/vector/filter';
9
- import type { LogicalOperatorValueMap } from '@mastra/core/vector/filter';
10
- import { MastraVector } from '@mastra/core/vector';
11
- import type { OperatorSupport } from '@mastra/core/vector/filter';
12
- import type { OperatorValueMap } from '@mastra/core/vector/filter';
13
- import type { QueryResult } from '@mastra/core/vector';
14
- import type { QueryVectorParams } from '@mastra/core/vector';
15
- import type { UpdateVectorParams } from '@mastra/core/vector';
16
- import type { UpsertVectorParams } from '@mastra/core/vector';
17
- import type { VectorFilter } from '@mastra/core/vector/filter';
18
-
19
- /**
20
- * Vector store specific prompt that details supported operators and examples.
21
- * This prompt helps users construct valid filters for Qdrant Vector.
22
- */
23
- declare const QDRANT_PROMPT = "When querying Qdrant, you can ONLY use the operators listed below. Any other operators will be rejected.\nImportant: Don't explain how to construct the filter - use the specified operators and fields to search the content and return relevant results.\nIf a user tries to give an explicit operator that is not supported, reject the filter entirely and let them know that the operator is not supported.\n\nBasic Comparison Operators:\n- $eq: Exact match (default when using field: value)\n Example: { \"category\": \"electronics\" }\n- $ne: Not equal\n Example: { \"category\": { \"$ne\": \"electronics\" } }\n- $gt: Greater than\n Example: { \"price\": { \"$gt\": 100 } }\n- $gte: Greater than or equal\n Example: { \"price\": { \"$gte\": 100 } }\n- $lt: Less than\n Example: { \"price\": { \"$lt\": 100 } }\n- $lte: Less than or equal\n Example: { \"price\": { \"$lte\": 100 } }\n\nArray Operators:\n- $in: Match any value in array\n Example: { \"category\": { \"$in\": [\"electronics\", \"books\"] } }\n- $nin: Does not match any value in array\n Example: { \"category\": { \"$nin\": [\"electronics\", \"books\"] } }\n\nLogical Operators:\n- $and: Logical AND (can be implicit or explicit)\n Implicit Example: { \"price\": { \"$gt\": 100 }, \"category\": \"electronics\" }\n Explicit Example: { \"$and\": [{ \"price\": { \"$gt\": 100 } }, { \"category\": \"electronics\" }] }\n- $or: Logical OR\n Example: { \"$or\": [{ \"price\": { \"$lt\": 50 } }, { \"category\": \"books\" }] }\n- $not: Logical NOT\n Example: { \"$not\": { \"category\": \"electronics\" } }\n\nElement Operators:\n- $exists: Check if field exists\n Example: { \"rating\": { \"$exists\": true } }\n- $match: Match text using full-text search\n Example: { \"description\": { \"$match\": \"gaming laptop\" } }\n- $null: Check if field is null\n Example: { \"rating\": { \"$null\": true } }\n\nRestrictions:\n- Regex patterns are not supported\n- Only $and, $or, and $not logical operators are supported at the top level\n- Empty arrays in $in/$nin will return no results\n- Nested fields are supported using dot notation\n- Multiple conditions on the same field are supported with both implicit and explicit $and\n- At least one key-value pair is required in filter object\n- Empty objects and undefined values are treated as no filter\n- Invalid types in comparison operators will throw errors\n- All non-logical operators must be used within a field condition\n Valid: { \"field\": { \"$gt\": 100 } }\n Valid: { \"$and\": [...] }\n Invalid: { \"$gt\": 100 }\n- Logical operators must contain field conditions, not direct operators\n Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n Invalid: { \"$and\": [{ \"$gt\": 100 }] }\n- Logical operators ($and, $or, $not):\n - Can only be used at top level or nested within other logical operators\n - Can not be used on a field level, or be nested inside a field\n - Can not be used inside an operator\n - Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n - Valid: { \"$or\": [{ \"$and\": [{ \"field\": { \"$gt\": 100 } }] }] }\n - Invalid: { \"field\": { \"$and\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$or\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$gt\": { \"$and\": [{...}] } } }\n\nExample Complex Query:\n{\n \"$and\": [\n { \"category\": { \"$in\": [\"electronics\", \"computers\"] } },\n { \"price\": { \"$gte\": 100, \"$lte\": 1000 } },\n { \"description\": { \"$match\": \"gaming laptop\" } },\n { \"rating\": { \"$exists\": true, \"$gt\": 4 } },\n { \"$or\": [\n { \"stock\": { \"$gt\": 0 } },\n { \"preorder\": { \"$null\": false } }\n ]},\n { \"$not\": { \"status\": \"discontinued\" } }\n ]\n}";
24
- export { QDRANT_PROMPT }
25
- export { QDRANT_PROMPT as QDRANT_PROMPT_alias_1 }
26
-
27
- declare type QdrantBlacklistedRootOperators = BlacklistedRootOperators | '$count' | '$geo' | '$nested' | '$datetime' | '$null' | '$empty';
28
-
29
- /**
30
- * Translates MongoDB-style filters to Qdrant compatible filters.
31
- *
32
- * Key transformations:
33
- * - $and -> must
34
- * - $or -> should
35
- * - $not -> must_not
36
- * - { field: { $op: value } } -> { key: field, match/range: { value/gt/lt: value } }
37
- *
38
- * Custom operators (Qdrant-specific):
39
- * - $count -> values_count (array length/value count)
40
- * - $geo -> geo filters (box, radius, polygon)
41
- * - $hasId -> has_id filter
42
- * - $nested -> nested object filters
43
- * - $hasVector -> vector existence check
44
- * - $datetime -> RFC 3339 datetime range
45
- * - $null -> is_null check
46
- * - $empty -> is_empty check
47
- */
48
- export declare class QdrantFilterTranslator extends BaseFilterTranslator<QdrantVectorFilter> {
49
- protected isLogicalOperator(key: string): key is LogicalOperator;
50
- protected getSupportedOperators(): OperatorSupport;
51
- translate(filter?: QdrantVectorFilter): QdrantVectorFilter;
52
- private createCondition;
53
- private translateNode;
54
- private buildFinalConditions;
55
- private handleLogicalOperators;
56
- private handleFieldConditions;
57
- private translateCustomOperator;
58
- private getQdrantLogicalOp;
59
- private translateOperatorValue;
60
- private translateGeoFilter;
61
- private normalizeDatetimeRange;
62
- }
63
-
64
- declare type QdrantLogicalOperatorValueMap = Omit<LogicalOperatorValueMap, '$nor'>;
65
-
66
- declare type QdrantOperatorValueMap = Omit<OperatorValueMap, '$options' | '$elemMatch' | '$all'> & {
67
- /**
68
- * $count: Filter by array length or value count.
69
- * Example: { tags: { $count: { gt: 2 } } }
70
- */
71
- $count: {
72
- $gt?: number;
73
- $gte?: number;
74
- $lt?: number;
75
- $lte?: number;
76
- $eq?: number;
77
- };
78
- /**
79
- * $geo: Geospatial filter.
80
- * Example: { location: { $geo: { type: 'geo_radius', center: [lon, lat], radius: 1000 } } }
81
- */
82
- $geo: {
83
- type: string;
84
- [key: string]: any;
85
- };
86
- /**
87
- * $hasId: Filter by point IDs.
88
- * Allowed at root level.
89
- * Example: { $hasId: '123' } or { $hasId: ['123', '456'] }
90
- */
91
- $hasId: string | string[];
92
- /**
93
- * $nested: Nested object filter.
94
- * Example: { metadata: { $nested: { key: 'foo', filter: { $eq: 'bar' } } } }
95
- */
96
- $nested: {
97
- [key: string]: any;
98
- };
99
- /**
100
- * $hasVector: Filter by vector existence or field.
101
- * Allowed at root level.
102
- * Example: { $hasVector: true } or { $hasVector: 'vector_field' }
103
- */
104
- $hasVector: boolean | string;
105
- /**
106
- * $datetime: RFC 3339 datetime range.
107
- * Example: { createdAt: { $datetime: { gte: '2024-01-01T00:00:00Z' } } }
108
- */
109
- $datetime: {
110
- key?: string;
111
- range?: {
112
- gt?: Date | string;
113
- gte?: Date | string;
114
- lt?: Date | string;
115
- lte?: Date | string;
116
- eq?: Date | string;
117
- };
118
- };
119
- /**
120
- * $null: Check if a field is null.
121
- * Example: { metadata: { $null: true } }
122
- */
123
- $null: boolean;
124
- /**
125
- * $empty: Check if an array or object field is empty.
126
- * Example: { tags: { $empty: true } }
127
- */
128
- $empty: boolean;
129
- };
130
-
131
- declare type QdrantQueryVectorParams = QueryVectorParams<QdrantVectorFilter>;
132
-
133
- declare class QdrantVector extends MastraVector {
134
- private client;
135
- /**
136
- * Creates a new QdrantVector client.
137
- * @param url - The URL of the Qdrant server.
138
- * @param apiKey - The API key for Qdrant.
139
- * @param https - Whether to use HTTPS.
140
- */
141
- constructor({ url, apiKey, https }: {
142
- url: string;
143
- apiKey?: string;
144
- https?: boolean;
145
- });
146
- upsert({ indexName, vectors, metadata, ids }: UpsertVectorParams): Promise<string[]>;
147
- createIndex({ indexName, dimension, metric }: CreateIndexParams): Promise<void>;
148
- transformFilter(filter?: QdrantVectorFilter): QdrantVectorFilter;
149
- query({ indexName, queryVector, topK, filter, includeVector, }: QdrantQueryVectorParams): Promise<QueryResult[]>;
150
- listIndexes(): Promise<string[]>;
151
- /**
152
- * Retrieves statistics about a vector index.
153
- *
154
- * @param {string} indexName - The name of the index to describe
155
- * @returns A promise that resolves to the index statistics including dimension, count and metric
156
- */
157
- describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats>;
158
- deleteIndex({ indexName }: DeleteIndexParams): Promise<void>;
159
- /**
160
- * Updates a vector by its ID with the provided vector and/or metadata.
161
- * @param indexName - The name of the index containing the vector.
162
- * @param id - The ID of the vector to update.
163
- * @param update - An object containing the vector and/or metadata to update.
164
- * @param update.vector - An optional array of numbers representing the new vector.
165
- * @param update.metadata - An optional record containing the new metadata.
166
- * @returns A promise that resolves when the update is complete.
167
- * @throws Will throw an error if no updates are provided or if the update operation fails.
168
- */
169
- updateVector({ indexName, id, update }: UpdateVectorParams): Promise<void>;
170
- /**
171
- * Deletes a vector by its ID.
172
- * @param indexName - The name of the index containing the vector.
173
- * @param id - The ID of the vector to delete.
174
- * @returns A promise that resolves when the deletion is complete.
175
- * @throws Will throw an error if the deletion operation fails.
176
- */
177
- deleteVector({ indexName, id }: DeleteVectorParams): Promise<void>;
178
- /**
179
- * Parses and converts a string ID to the appropriate type (string or number) for Qdrant point operations.
180
- *
181
- * Qdrant supports both numeric and string IDs. This helper method ensures IDs are in the correct format
182
- * before sending them to the Qdrant client API.
183
- *
184
- * @param id - The ID string to parse
185
- * @returns The parsed ID as either a number (if string contains only digits) or the original string
186
- *
187
- * @example
188
- * // Numeric ID strings are converted to numbers
189
- * parsePointId("123") => 123
190
- * parsePointId("42") => 42
191
- * parsePointId("0") => 0
192
- *
193
- * // String IDs containing any non-digit characters remain as strings
194
- * parsePointId("doc-123") => "doc-123"
195
- * parsePointId("user_42") => "user_42"
196
- * parsePointId("abc123") => "abc123"
197
- * parsePointId("123abc") => "123abc"
198
- * parsePointId("") => ""
199
- * parsePointId("uuid-5678-xyz") => "uuid-5678-xyz"
200
- *
201
- * @remarks
202
- * - This conversion is important because Qdrant treats numeric and string IDs differently
203
- * - Only positive integers are converted to numbers (negative numbers with minus signs remain strings)
204
- * - The method uses base-10 parsing, so leading zeros will be dropped in numeric conversions
205
- * - reference: https://qdrant.tech/documentation/concepts/points/?q=qdrant+point+id#point-ids
206
- */
207
- private parsePointId;
208
- }
209
- export { QdrantVector }
210
- export { QdrantVector as QdrantVector_alias_1 }
211
-
212
- export declare type QdrantVectorFilter = VectorFilter<keyof QdrantOperatorValueMap, QdrantOperatorValueMap, QdrantLogicalOperatorValueMap, QdrantBlacklistedRootOperators>;
213
-
214
- export { }
package/dist/index.d.cts DELETED
@@ -1,2 +0,0 @@
1
- export { QDRANT_PROMPT } from './_tsup-dts-rollup.cjs';
2
- export { QdrantVector } from './_tsup-dts-rollup.cjs';