@mastra/opensearch 0.0.0-pass-headers-for-create-mastra-client-20250530010057 → 0.0.0-remove-unused-import-20250909212718

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 +0,0 @@
1
-
2
- > @mastra/opensearch@0.10.0 build /home/runner/work/mastra/mastra/stores/opensearch
3
- > tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting
4
-
5
- CLI Building entry: src/index.ts
6
- CLI Using tsconfig: tsconfig.json
7
- CLI tsup v8.4.0
8
- TSC Build start
9
- TSC ⚡️ Build success in 10775ms
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/opensearch/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/opensearch/dist/_tsup-dts-rollup.d.cts
16
- DTS ⚡️ Build success in 10998ms
17
- CLI Cleaning output folder
18
- ESM Build start
19
- CJS Build start
20
- ESM dist/index.js 21.72 KB
21
- ESM ⚡️ Build success in 977ms
22
- CJS dist/index.cjs 21.76 KB
23
- CJS ⚡️ Build success in 977ms
@@ -1,159 +0,0 @@
1
- import { BaseFilterTranslator } from '@mastra/core/vector/filter';
2
- import type { CreateIndexParams } from '@mastra/core';
3
- import type { DeleteIndexParams } from '@mastra/core';
4
- import type { DeleteVectorParams } from '@mastra/core';
5
- import type { DescribeIndexParams } from '@mastra/core';
6
- import type { IndexStats } from '@mastra/core';
7
- import { MastraVector } from '@mastra/core/vector';
8
- import type { OperatorSupport } from '@mastra/core/vector/filter';
9
- import type { QueryResult } from '@mastra/core';
10
- import type { QueryVectorParams } from '@mastra/core';
11
- import type { UpdateVectorParams } from '@mastra/core';
12
- import type { UpsertVectorParams } from '@mastra/core';
13
- import type { VectorFilter } from '@mastra/core/vector/filter';
14
-
15
- /**
16
- * Vector store prompt for OpenSearch. This prompt details supported filter operators, syntax, and usage examples.
17
- * Use this as a guide for constructing valid filters for OpenSearch vector queries in Mastra.
18
- */
19
- export declare const OPENSEARCH_PROMPT = "When querying OpenSearch, you can ONLY use the operators listed below. Any other operators will be rejected.\nImportant: Do not explain how to construct the filter\u2014use the specified operators and fields to search the content and return relevant results.\nIf a user tries to use an unsupported operator, reject the filter entirely and let them know that the operator is not supported.\n\nBasic Comparison Operators:\n- $eq: Exact match (default for 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- $all: Match all values in array\n Example: { \"tags\": { \"$all\": [\"premium\", \"sale\"] } }\n\nLogical Operators:\n- $and: Logical AND (implicit when using multiple conditions)\n 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\nRegex Operator:\n- $regex: Match using a regular expression (ECMAScript syntax)\n Example: { \"name\": { \"$regex\": \"^Sam.*son$\" } }\n Note: Regex queries are supported for string fields only. Use valid ECMAScript patterns; invalid patterns will throw an error.\n\nRestrictions:\n- Nested fields are supported using dot notation (e.g., \"address.city\").\n- Multiple conditions on the same field are supported (e.g., { \"price\": { \"$gte\": 100, \"$lte\": 1000 } }).\n- Only logical operators ($and, $or, $not) can be used at the top level.\n- All other 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- $not operator:\n - Must be an object\n - Cannot be empty\n - Can be used at field level or top level\n - Valid: { \"$not\": { \"field\": \"value\" } }\n - Valid: { \"field\": { \"$not\": { \"$eq\": \"value\" } } }\n- Array operators work on array fields only.\n- Empty arrays in conditions are handled gracefully.\n- Regex queries are case-sensitive by default; use patterns accordingly.\n\nExample Complex Query:\n{\n \"$and\": [\n { \"category\": { \"$in\": [\"electronics\", \"computers\"] } },\n { \"price\": { \"$gte\": 100, \"$lte\": 1000 } },\n { \"tags\": { \"$all\": [\"premium\"] } },\n { \"rating\": { \"$exists\": true, \"$gt\": 4 } },\n { \"$or\": [\n { \"stock\": { \"$gt\": 0 } },\n { \"preorder\": true }\n ]},\n { \"name\": { \"$regex\": \"^Sam.*son$\" } }\n ]\n}";
20
-
21
- /**
22
- * Translator for OpenSearch filter queries.
23
- * Maintains OpenSearch-compatible syntax while ensuring proper validation
24
- * and normalization of values.
25
- */
26
- export declare class OpenSearchFilterTranslator extends BaseFilterTranslator {
27
- protected getSupportedOperators(): OperatorSupport;
28
- translate(filter?: VectorFilter): VectorFilter;
29
- private translateNode;
30
- /**
31
- * Handles translation of nested objects with dot notation fields
32
- */
33
- private translateNestedObject;
34
- private translateLogicalOperator;
35
- private translateFieldOperator;
36
- /**
37
- * Translates regex patterns to OpenSearch query syntax
38
- */
39
- private translateRegexOperator;
40
- private addKeywordIfNeeded;
41
- /**
42
- * Helper method to handle special cases for the $not operator
43
- */
44
- private handleNotOperatorSpecialCases;
45
- private translateOperator;
46
- /**
47
- * Translates field conditions to OpenSearch query syntax
48
- * Handles special cases like range queries and multiple operators
49
- */
50
- private translateFieldConditions;
51
- /**
52
- * Checks if conditions can be optimized to a range query
53
- */
54
- private canOptimizeToRangeQuery;
55
- /**
56
- * Creates a range query from numeric operators
57
- */
58
- private createRangeQuery;
59
- }
60
-
61
- declare class OpenSearchVector extends MastraVector {
62
- private client;
63
- /**
64
- * Creates a new OpenSearchVector client.
65
- *
66
- * @param {string} url - The url of the OpenSearch node.
67
- */
68
- constructor({ url }: {
69
- url: string;
70
- });
71
- /**
72
- * Creates a new collection with the specified configuration.
73
- *
74
- * @param {string} indexName - The name of the collection to create.
75
- * @param {number} dimension - The dimension of the vectors to be stored in the collection.
76
- * @param {'cosine' | 'euclidean' | 'dotproduct'} [metric=cosine] - The metric to use to sort vectors in the collection.
77
- * @returns {Promise<void>} A promise that resolves when the collection is created.
78
- */
79
- createIndex({ indexName, dimension, metric }: CreateIndexParams): Promise<void>;
80
- /**
81
- * Lists all indexes.
82
- *
83
- * @returns {Promise<string[]>} A promise that resolves to an array of indexes.
84
- */
85
- listIndexes(): Promise<string[]>;
86
- /**
87
- * Retrieves statistics about a vector index.
88
- *
89
- * @param {string} indexName - The name of the index to describe
90
- * @returns A promise that resolves to the index statistics including dimension, count and metric
91
- */
92
- describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats>;
93
- /**
94
- * Deletes the specified index.
95
- *
96
- * @param {string} indexName - The name of the index to delete.
97
- * @returns {Promise<void>} A promise that resolves when the index is deleted.
98
- */
99
- deleteIndex({ indexName }: DeleteIndexParams): Promise<void>;
100
- /**
101
- * Inserts or updates vectors in the specified collection.
102
- *
103
- * @param {string} indexName - The name of the collection to upsert into.
104
- * @param {number[][]} vectors - An array of vectors to upsert.
105
- * @param {Record<string, any>[]} [metadata] - An optional array of metadata objects corresponding to each vector.
106
- * @param {string[]} [ids] - An optional array of IDs corresponding to each vector. If not provided, new IDs will be generated.
107
- * @returns {Promise<string[]>} A promise that resolves to an array of IDs of the upserted vectors.
108
- */
109
- upsert({ indexName, vectors, metadata, ids }: UpsertVectorParams): Promise<string[]>;
110
- /**
111
- * Queries the specified collection using a vector and optional filter.
112
- *
113
- * @param {string} indexName - The name of the collection to query.
114
- * @param {number[]} queryVector - The vector to query with.
115
- * @param {number} [topK] - The maximum number of results to return.
116
- * @param {Record<string, any>} [filter] - An optional filter to apply to the query. For more on filters in OpenSearch, see the filtering reference: https://opensearch.org/docs/latest/query-dsl/
117
- * @param {boolean} [includeVectors=false] - Whether to include the vectors in the response.
118
- * @returns {Promise<QueryResult[]>} A promise that resolves to an array of query results.
119
- */
120
- query({ indexName, queryVector, filter, topK, includeVector, }: QueryVectorParams): Promise<QueryResult[]>;
121
- /**
122
- * Validates the dimensions of the vectors.
123
- *
124
- * @param {number[][]} vectors - The vectors to validate.
125
- * @param {number} dimension - The dimension of the vectors.
126
- * @returns {void}
127
- */
128
- private validateVectorDimensions;
129
- /**
130
- * Transforms the filter to the OpenSearch DSL.
131
- *
132
- * @param {VectorFilter} filter - The filter to transform.
133
- * @returns {Record<string, any>} The transformed filter.
134
- */
135
- private transformFilter;
136
- /**
137
- * Updates a vector by its ID with the provided vector and/or metadata.
138
- * @param indexName - The name of the index containing the vector.
139
- * @param id - The ID of the vector to update.
140
- * @param update - An object containing the vector and/or metadata to update.
141
- * @param update.vector - An optional array of numbers representing the new vector.
142
- * @param update.metadata - An optional record containing the new metadata.
143
- * @returns A promise that resolves when the update is complete.
144
- * @throws Will throw an error if no updates are provided or if the update operation fails.
145
- */
146
- updateVector({ indexName, id, update }: UpdateVectorParams): Promise<void>;
147
- /**
148
- * Deletes a vector by its ID.
149
- * @param indexName - The name of the index containing the vector.
150
- * @param id - The ID of the vector to delete.
151
- * @returns A promise that resolves when the deletion is complete.
152
- * @throws Will throw an error if the deletion operation fails.
153
- */
154
- deleteVector({ indexName, id }: DeleteVectorParams): Promise<void>;
155
- }
156
- export { OpenSearchVector }
157
- export { OpenSearchVector as OpenSearchVector_alias_1 }
158
-
159
- export { }
@@ -1,159 +0,0 @@
1
- import { BaseFilterTranslator } from '@mastra/core/vector/filter';
2
- import type { CreateIndexParams } from '@mastra/core';
3
- import type { DeleteIndexParams } from '@mastra/core';
4
- import type { DeleteVectorParams } from '@mastra/core';
5
- import type { DescribeIndexParams } from '@mastra/core';
6
- import type { IndexStats } from '@mastra/core';
7
- import { MastraVector } from '@mastra/core/vector';
8
- import type { OperatorSupport } from '@mastra/core/vector/filter';
9
- import type { QueryResult } from '@mastra/core';
10
- import type { QueryVectorParams } from '@mastra/core';
11
- import type { UpdateVectorParams } from '@mastra/core';
12
- import type { UpsertVectorParams } from '@mastra/core';
13
- import type { VectorFilter } from '@mastra/core/vector/filter';
14
-
15
- /**
16
- * Vector store prompt for OpenSearch. This prompt details supported filter operators, syntax, and usage examples.
17
- * Use this as a guide for constructing valid filters for OpenSearch vector queries in Mastra.
18
- */
19
- export declare const OPENSEARCH_PROMPT = "When querying OpenSearch, you can ONLY use the operators listed below. Any other operators will be rejected.\nImportant: Do not explain how to construct the filter\u2014use the specified operators and fields to search the content and return relevant results.\nIf a user tries to use an unsupported operator, reject the filter entirely and let them know that the operator is not supported.\n\nBasic Comparison Operators:\n- $eq: Exact match (default for 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- $all: Match all values in array\n Example: { \"tags\": { \"$all\": [\"premium\", \"sale\"] } }\n\nLogical Operators:\n- $and: Logical AND (implicit when using multiple conditions)\n 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\nRegex Operator:\n- $regex: Match using a regular expression (ECMAScript syntax)\n Example: { \"name\": { \"$regex\": \"^Sam.*son$\" } }\n Note: Regex queries are supported for string fields only. Use valid ECMAScript patterns; invalid patterns will throw an error.\n\nRestrictions:\n- Nested fields are supported using dot notation (e.g., \"address.city\").\n- Multiple conditions on the same field are supported (e.g., { \"price\": { \"$gte\": 100, \"$lte\": 1000 } }).\n- Only logical operators ($and, $or, $not) can be used at the top level.\n- All other 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- $not operator:\n - Must be an object\n - Cannot be empty\n - Can be used at field level or top level\n - Valid: { \"$not\": { \"field\": \"value\" } }\n - Valid: { \"field\": { \"$not\": { \"$eq\": \"value\" } } }\n- Array operators work on array fields only.\n- Empty arrays in conditions are handled gracefully.\n- Regex queries are case-sensitive by default; use patterns accordingly.\n\nExample Complex Query:\n{\n \"$and\": [\n { \"category\": { \"$in\": [\"electronics\", \"computers\"] } },\n { \"price\": { \"$gte\": 100, \"$lte\": 1000 } },\n { \"tags\": { \"$all\": [\"premium\"] } },\n { \"rating\": { \"$exists\": true, \"$gt\": 4 } },\n { \"$or\": [\n { \"stock\": { \"$gt\": 0 } },\n { \"preorder\": true }\n ]},\n { \"name\": { \"$regex\": \"^Sam.*son$\" } }\n ]\n}";
20
-
21
- /**
22
- * Translator for OpenSearch filter queries.
23
- * Maintains OpenSearch-compatible syntax while ensuring proper validation
24
- * and normalization of values.
25
- */
26
- export declare class OpenSearchFilterTranslator extends BaseFilterTranslator {
27
- protected getSupportedOperators(): OperatorSupport;
28
- translate(filter?: VectorFilter): VectorFilter;
29
- private translateNode;
30
- /**
31
- * Handles translation of nested objects with dot notation fields
32
- */
33
- private translateNestedObject;
34
- private translateLogicalOperator;
35
- private translateFieldOperator;
36
- /**
37
- * Translates regex patterns to OpenSearch query syntax
38
- */
39
- private translateRegexOperator;
40
- private addKeywordIfNeeded;
41
- /**
42
- * Helper method to handle special cases for the $not operator
43
- */
44
- private handleNotOperatorSpecialCases;
45
- private translateOperator;
46
- /**
47
- * Translates field conditions to OpenSearch query syntax
48
- * Handles special cases like range queries and multiple operators
49
- */
50
- private translateFieldConditions;
51
- /**
52
- * Checks if conditions can be optimized to a range query
53
- */
54
- private canOptimizeToRangeQuery;
55
- /**
56
- * Creates a range query from numeric operators
57
- */
58
- private createRangeQuery;
59
- }
60
-
61
- declare class OpenSearchVector extends MastraVector {
62
- private client;
63
- /**
64
- * Creates a new OpenSearchVector client.
65
- *
66
- * @param {string} url - The url of the OpenSearch node.
67
- */
68
- constructor({ url }: {
69
- url: string;
70
- });
71
- /**
72
- * Creates a new collection with the specified configuration.
73
- *
74
- * @param {string} indexName - The name of the collection to create.
75
- * @param {number} dimension - The dimension of the vectors to be stored in the collection.
76
- * @param {'cosine' | 'euclidean' | 'dotproduct'} [metric=cosine] - The metric to use to sort vectors in the collection.
77
- * @returns {Promise<void>} A promise that resolves when the collection is created.
78
- */
79
- createIndex({ indexName, dimension, metric }: CreateIndexParams): Promise<void>;
80
- /**
81
- * Lists all indexes.
82
- *
83
- * @returns {Promise<string[]>} A promise that resolves to an array of indexes.
84
- */
85
- listIndexes(): Promise<string[]>;
86
- /**
87
- * Retrieves statistics about a vector index.
88
- *
89
- * @param {string} indexName - The name of the index to describe
90
- * @returns A promise that resolves to the index statistics including dimension, count and metric
91
- */
92
- describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats>;
93
- /**
94
- * Deletes the specified index.
95
- *
96
- * @param {string} indexName - The name of the index to delete.
97
- * @returns {Promise<void>} A promise that resolves when the index is deleted.
98
- */
99
- deleteIndex({ indexName }: DeleteIndexParams): Promise<void>;
100
- /**
101
- * Inserts or updates vectors in the specified collection.
102
- *
103
- * @param {string} indexName - The name of the collection to upsert into.
104
- * @param {number[][]} vectors - An array of vectors to upsert.
105
- * @param {Record<string, any>[]} [metadata] - An optional array of metadata objects corresponding to each vector.
106
- * @param {string[]} [ids] - An optional array of IDs corresponding to each vector. If not provided, new IDs will be generated.
107
- * @returns {Promise<string[]>} A promise that resolves to an array of IDs of the upserted vectors.
108
- */
109
- upsert({ indexName, vectors, metadata, ids }: UpsertVectorParams): Promise<string[]>;
110
- /**
111
- * Queries the specified collection using a vector and optional filter.
112
- *
113
- * @param {string} indexName - The name of the collection to query.
114
- * @param {number[]} queryVector - The vector to query with.
115
- * @param {number} [topK] - The maximum number of results to return.
116
- * @param {Record<string, any>} [filter] - An optional filter to apply to the query. For more on filters in OpenSearch, see the filtering reference: https://opensearch.org/docs/latest/query-dsl/
117
- * @param {boolean} [includeVectors=false] - Whether to include the vectors in the response.
118
- * @returns {Promise<QueryResult[]>} A promise that resolves to an array of query results.
119
- */
120
- query({ indexName, queryVector, filter, topK, includeVector, }: QueryVectorParams): Promise<QueryResult[]>;
121
- /**
122
- * Validates the dimensions of the vectors.
123
- *
124
- * @param {number[][]} vectors - The vectors to validate.
125
- * @param {number} dimension - The dimension of the vectors.
126
- * @returns {void}
127
- */
128
- private validateVectorDimensions;
129
- /**
130
- * Transforms the filter to the OpenSearch DSL.
131
- *
132
- * @param {VectorFilter} filter - The filter to transform.
133
- * @returns {Record<string, any>} The transformed filter.
134
- */
135
- private transformFilter;
136
- /**
137
- * Updates a vector by its ID with the provided vector and/or metadata.
138
- * @param indexName - The name of the index containing the vector.
139
- * @param id - The ID of the vector to update.
140
- * @param update - An object containing the vector and/or metadata to update.
141
- * @param update.vector - An optional array of numbers representing the new vector.
142
- * @param update.metadata - An optional record containing the new metadata.
143
- * @returns A promise that resolves when the update is complete.
144
- * @throws Will throw an error if no updates are provided or if the update operation fails.
145
- */
146
- updateVector({ indexName, id, update }: UpdateVectorParams): Promise<void>;
147
- /**
148
- * Deletes a vector by its ID.
149
- * @param indexName - The name of the index containing the vector.
150
- * @param id - The ID of the vector to delete.
151
- * @returns A promise that resolves when the deletion is complete.
152
- * @throws Will throw an error if the deletion operation fails.
153
- */
154
- deleteVector({ indexName, id }: DeleteVectorParams): Promise<void>;
155
- }
156
- export { OpenSearchVector }
157
- export { OpenSearchVector as OpenSearchVector_alias_1 }
158
-
159
- export { }
package/dist/index.d.cts DELETED
@@ -1 +0,0 @@
1
- export { OpenSearchVector } from './_tsup-dts-rollup.cjs';
@@ -1,23 +0,0 @@
1
- version: '3.8'
2
-
3
- services:
4
- opensearch:
5
- image: opensearchproject/opensearch:latest
6
- ports:
7
- - '9200:9200'
8
- volumes:
9
- - opensearch_data:/usr/share/opensearch/data
10
- environment:
11
- - discovery.type=single-node
12
- - OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m
13
- - bootstrap.memory_lock=true
14
- - DISABLE_SECURITY_PLUGIN=true
15
- ulimits:
16
- memlock:
17
- soft: -1
18
- hard: -1
19
- restart: always
20
-
21
- volumes:
22
- opensearch_data:
23
- driver: local
package/eslint.config.js DELETED
@@ -1,6 +0,0 @@
1
- import { createConfig } from '@internal/lint/eslint';
2
-
3
- const config = await createConfig();
4
-
5
- /** @type {import("eslint").Linter.Config[]} */
6
- export default [...config];
package/src/index.ts DELETED
@@ -1 +0,0 @@
1
- export * from './vector';