@mastra/opensearch 0.10.0 → 0.10.1-alpha.0

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,23 @@
1
1
 
2
- > @mastra/opensearch@0.10.0-alpha.1 build /home/runner/work/mastra/mastra/stores/opensearch
2
+ > @mastra/opensearch@0.10.1-alpha.0 build /home/runner/work/mastra/mastra/stores/opensearch
3
3
  > tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting
4
4
 
5
5
  CLI Building entry: src/index.ts
6
6
  CLI Using tsconfig: tsconfig.json
7
7
  CLI tsup v8.4.0
8
8
  TSC Build start
9
- TSC ⚡️ Build success in 10374ms
9
+ TSC ⚡️ Build success in 9209ms
10
10
  DTS Build start
11
11
  CLI Target: es2022
12
12
  Analysis will use the bundled TypeScript version 5.8.3
13
13
  Writing package typings: /home/runner/work/mastra/mastra/stores/opensearch/dist/_tsup-dts-rollup.d.ts
14
14
  Analysis will use the bundled TypeScript version 5.8.3
15
15
  Writing package typings: /home/runner/work/mastra/mastra/stores/opensearch/dist/_tsup-dts-rollup.d.cts
16
- DTS ⚡️ Build success in 9941ms
16
+ DTS ⚡️ Build success in 10807ms
17
17
  CLI Cleaning output folder
18
18
  ESM Build start
19
19
  CJS Build start
20
20
  CJS dist/index.cjs 21.76 KB
21
- CJS ⚡️ Build success in 913ms
21
+ CJS ⚡️ Build success in 763ms
22
22
  ESM dist/index.js 21.72 KB
23
- ESM ⚡️ Build success in 920ms
23
+ ESM ⚡️ Build success in 1003ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @mastra/opensearch
2
2
 
3
+ ## 0.10.1-alpha.0
4
+
5
+ ### Patch Changes
6
+
7
+ - 915ca1a: Added disconnect function for couchbase and added docs
8
+ Added prompt for OpenSearchVector
9
+ - Updated dependencies [ee77e78]
10
+ - Updated dependencies [2901125]
11
+ - @mastra/core@0.10.2-alpha.1
12
+
3
13
  ## 0.10.0
4
14
 
5
15
  ### Minor Changes
@@ -12,6 +12,12 @@ import type { UpdateVectorParams } from '@mastra/core';
12
12
  import type { UpsertVectorParams } from '@mastra/core';
13
13
  import type { VectorFilter } from '@mastra/core/vector/filter';
14
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
+
15
21
  /**
16
22
  * Translator for OpenSearch filter queries.
17
23
  * Maintains OpenSearch-compatible syntax while ensuring proper validation
@@ -12,6 +12,12 @@ import type { UpdateVectorParams } from '@mastra/core';
12
12
  import type { UpsertVectorParams } from '@mastra/core';
13
13
  import type { VectorFilter } from '@mastra/core/vector/filter';
14
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
+
15
21
  /**
16
22
  * Translator for OpenSearch filter queries.
17
23
  * Maintains OpenSearch-compatible syntax while ensuring proper validation
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/opensearch",
3
- "version": "0.10.0",
3
+ "version": "0.10.1-alpha.0",
4
4
  "description": "OpenSearch vector store provider for Mastra",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -28,8 +28,8 @@
28
28
  "tsup": "^8.4.0",
29
29
  "typescript": "^5.8.2",
30
30
  "vitest": "^3.0.8",
31
- "@internal/lint": "0.0.6",
32
- "@mastra/core": "0.10.0"
31
+ "@internal/lint": "0.0.7",
32
+ "@mastra/core": "0.10.2-alpha.1"
33
33
  },
34
34
  "peerDependencies": {
35
35
  "@mastra/core": "^0.10.0"
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Vector store prompt for OpenSearch. This prompt details supported filter operators, syntax, and usage examples.
3
+ * Use this as a guide for constructing valid filters for OpenSearch vector queries in Mastra.
4
+ */
5
+ export const OPENSEARCH_PROMPT = `When querying OpenSearch, you can ONLY use the operators listed below. Any other operators will be rejected.
6
+ Important: Do not explain how to construct the filter—use the specified operators and fields to search the content and return relevant results.
7
+ If a user tries to use an unsupported operator, reject the filter entirely and let them know that the operator is not supported.
8
+
9
+ Basic Comparison Operators:
10
+ - $eq: Exact match (default for field: value)
11
+ Example: { "category": "electronics" }
12
+ - $ne: Not equal
13
+ Example: { "category": { "$ne": "electronics" } }
14
+ - $gt: Greater than
15
+ Example: { "price": { "$gt": 100 } }
16
+ - $gte: Greater than or equal
17
+ Example: { "price": { "$gte": 100 } }
18
+ - $lt: Less than
19
+ Example: { "price": { "$lt": 100 } }
20
+ - $lte: Less than or equal
21
+ Example: { "price": { "$lte": 100 } }
22
+
23
+ Array Operators:
24
+ - $in: Match any value in array
25
+ Example: { "category": { "$in": ["electronics", "books"] } }
26
+ - $nin: Does not match any value in array
27
+ Example: { "category": { "$nin": ["electronics", "books"] } }
28
+ - $all: Match all values in array
29
+ Example: { "tags": { "$all": ["premium", "sale"] } }
30
+
31
+ Logical Operators:
32
+ - $and: Logical AND (implicit when using multiple conditions)
33
+ Example: { "$and": [{ "price": { "$gt": 100 } }, { "category": "electronics" }] }
34
+ - $or: Logical OR
35
+ Example: { "$or": [{ "price": { "$lt": 50 } }, { "category": "books" }] }
36
+ - $not: Logical NOT
37
+ Example: { "$not": { "category": "electronics" } }
38
+
39
+ Element Operators:
40
+ - $exists: Check if field exists
41
+ Example: { "rating": { "$exists": true } }
42
+
43
+ Regex Operator:
44
+ - $regex: Match using a regular expression (ECMAScript syntax)
45
+ Example: { "name": { "$regex": "^Sam.*son$" } }
46
+ Note: Regex queries are supported for string fields only. Use valid ECMAScript patterns; invalid patterns will throw an error.
47
+
48
+ Restrictions:
49
+ - Nested fields are supported using dot notation (e.g., "address.city").
50
+ - Multiple conditions on the same field are supported (e.g., { "price": { "$gte": 100, "$lte": 1000 } }).
51
+ - Only logical operators ($and, $or, $not) can be used at the top level.
52
+ - All other operators must be used within a field condition.
53
+ Valid: { "field": { "$gt": 100 } }
54
+ Valid: { "$and": [...] }
55
+ Invalid: { "$gt": 100 }
56
+ - Logical operators must contain field conditions, not direct operators.
57
+ Valid: { "$and": [{ "field": { "$gt": 100 } }] }
58
+ Invalid: { "$and": [{ "$gt": 100 }] }
59
+ - $not operator:
60
+ - Must be an object
61
+ - Cannot be empty
62
+ - Can be used at field level or top level
63
+ - Valid: { "$not": { "field": "value" } }
64
+ - Valid: { "field": { "$not": { "$eq": "value" } } }
65
+ - Array operators work on array fields only.
66
+ - Empty arrays in conditions are handled gracefully.
67
+ - Regex queries are case-sensitive by default; use patterns accordingly.
68
+
69
+ Example Complex Query:
70
+ {
71
+ "$and": [
72
+ { "category": { "$in": ["electronics", "computers"] } },
73
+ { "price": { "$gte": 100, "$lte": 1000 } },
74
+ { "tags": { "$all": ["premium"] } },
75
+ { "rating": { "$exists": true, "$gt": 4 } },
76
+ { "$or": [
77
+ { "stock": { "$gt": 0 } },
78
+ { "preorder": true }
79
+ ]},
80
+ { "name": { "$regex": "^Sam.*son$" } }
81
+ ]
82
+ }`;