@mastra/chroma 0.0.0-vector-query-tool-provider-options-20250828222356 → 0.0.0-vector-extension-schema-20250922130418

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.
package/CHANGELOG.md CHANGED
@@ -1,11 +1,147 @@
1
1
  # @mastra/chroma
2
2
 
3
- ## 0.0.0-vector-query-tool-provider-options-20250828222356
3
+ ## 0.0.0-vector-extension-schema-20250922130418
4
4
 
5
5
  ### Patch Changes
6
6
 
7
- - Updated dependencies [[`637f323`](https://github.com/mastra-ai/mastra/commit/637f32371d79a8f78c52c0d53411af0915fcec67), [`29de0e1`](https://github.com/mastra-ai/mastra/commit/29de0e1b0a7173317ae7d1ab0c0993167c659f2b), [`00c74e7`](https://github.com/mastra-ai/mastra/commit/00c74e73b1926be0d475693bb886fb67a22ff352), [`6ac697e`](https://github.com/mastra-ai/mastra/commit/6ac697edcc2435482c247cba615277ec4765dcc4), [`af90672`](https://github.com/mastra-ai/mastra/commit/af906722d8da28688882193b1e531026f9e2e81e), [`56041d0`](https://github.com/mastra-ai/mastra/commit/56041d018863a3da6b98c512e47348647c075fb3), [`5de1555`](https://github.com/mastra-ai/mastra/commit/5de15554d3d6695211945a36928f6657e76cddc9), [`1ed5a3e`](https://github.com/mastra-ai/mastra/commit/1ed5a3e19330374c4347a4237cd2f4b9ffb60376)]:
8
- - @mastra/core@0.0.0-vector-query-tool-provider-options-20250828222356
7
+ - Update Peerdeps for packages based on core minor bump ([#8025](https://github.com/mastra-ai/mastra/pull/8025))
8
+
9
+ - Updated dependencies [[`cf34503`](https://github.com/mastra-ai/mastra/commit/cf345031de4e157f29087946449e60b965e9c8a9), [`6b4b1e4`](https://github.com/mastra-ai/mastra/commit/6b4b1e4235428d39e51cbda9832704c0ba70ab32), [`3469fca`](https://github.com/mastra-ai/mastra/commit/3469fca7bb7e5e19369ff9f7044716a5e4b02585), [`a61f23f`](https://github.com/mastra-ai/mastra/commit/a61f23fbbca4b88b763d94f1d784c47895ed72d7), [`d1dc606`](https://github.com/mastra-ai/mastra/commit/d1dc6067b0557a71190b68d56ee15b48c26d2411), [`c45298a`](https://github.com/mastra-ai/mastra/commit/c45298a0a0791db35cf79f1199d77004da0704cb), [`c4a8204`](https://github.com/mastra-ai/mastra/commit/c4a82046bfd241d6044e234bc5917d5a01fe6b55), [`d3bd4d4`](https://github.com/mastra-ai/mastra/commit/d3bd4d482a685bbb67bfa89be91c90dca3fa71ad)]:
10
+ - @mastra/core@0.0.0-vector-extension-schema-20250922130418
11
+
12
+ ## 0.11.9
13
+
14
+ ### Patch Changes
15
+
16
+ - dependencies updates: ([#7860](https://github.com/mastra-ai/mastra/pull/7860))
17
+ - Updated dependency [`chromadb@^3.0.15` ↗︎](https://www.npmjs.com/package/chromadb/v/3.0.15) (from `^3.0.14`, in `dependencies`)
18
+
19
+ - Update peerdep of @mastra/core ([#7619](https://github.com/mastra-ai/mastra/pull/7619))
20
+
21
+ - Updated dependencies [[`197cbb2`](https://github.com/mastra-ai/mastra/commit/197cbb248fc8cb4bbf61bf70b770f1388b445df2), [`a1bb887`](https://github.com/mastra-ai/mastra/commit/a1bb887e8bfae44230f487648da72e96ef824561), [`6590763`](https://github.com/mastra-ai/mastra/commit/65907630ef4bf4127067cecd1cb21b56f55d5f1b), [`fb84c21`](https://github.com/mastra-ai/mastra/commit/fb84c21859d09bdc8f158bd5412bdc4b5835a61c), [`5802bf5`](https://github.com/mastra-ai/mastra/commit/5802bf57f6182e4b67c28d7d91abed349a8d14f3), [`5bda53a`](https://github.com/mastra-ai/mastra/commit/5bda53a9747bfa7d876d754fc92c83a06e503f62), [`c2eade3`](https://github.com/mastra-ai/mastra/commit/c2eade3508ef309662f065e5f340d7840295dd53), [`f26a8fd`](https://github.com/mastra-ai/mastra/commit/f26a8fd99fcb0497a5d86c28324430d7f6a5fb83), [`222965a`](https://github.com/mastra-ai/mastra/commit/222965a98ce8197b86673ec594244650b5960257), [`6047778`](https://github.com/mastra-ai/mastra/commit/6047778e501df460648f31decddf8e443f36e373), [`a0f5f1c`](https://github.com/mastra-ai/mastra/commit/a0f5f1ca39c3c5c6d26202e9fcab986b4fe14568), [`9d4fc09`](https://github.com/mastra-ai/mastra/commit/9d4fc09b2ad55caa7738c7ceb3a905e454f74cdd), [`05c7abf`](https://github.com/mastra-ai/mastra/commit/05c7abfe105a015b7760c9bf33ff4419727502a0), [`0324ceb`](https://github.com/mastra-ai/mastra/commit/0324ceb8af9d16c12a531f90e575f6aab797ac81), [`d75ccf0`](https://github.com/mastra-ai/mastra/commit/d75ccf06dfd2582b916aa12624e3cd61b279edf1), [`0f9d227`](https://github.com/mastra-ai/mastra/commit/0f9d227890a98db33865abbea39daf407cd55ef7), [`b356f5f`](https://github.com/mastra-ai/mastra/commit/b356f5f7566cb3edb755d91f00b72fc1420b2a37), [`de056a0`](https://github.com/mastra-ai/mastra/commit/de056a02cbb43f6aa0380ab2150ea404af9ec0dd), [`f5ce05f`](https://github.com/mastra-ai/mastra/commit/f5ce05f831d42c69559bf4c0fdb46ccb920fc3a3), [`60c9cec`](https://github.com/mastra-ai/mastra/commit/60c9cec7048a79a87440f7840c383875bd710d93), [`c93532a`](https://github.com/mastra-ai/mastra/commit/c93532a340b80e4dd946d4c138d9381de5f70399), [`6cb1fcb`](https://github.com/mastra-ai/mastra/commit/6cb1fcbc8d0378ffed0d17784c96e68f30cb0272), [`aee4f00`](https://github.com/mastra-ai/mastra/commit/aee4f00e61e1a42e81a6d74ff149dbe69e32695a), [`9f6f30f`](https://github.com/mastra-ai/mastra/commit/9f6f30f04ec6648bbca798ea8aad59317c40d8db), [`547c621`](https://github.com/mastra-ai/mastra/commit/547c62104af3f7a551b3754e9cbdf0a3fbba15e4), [`897995e`](https://github.com/mastra-ai/mastra/commit/897995e630d572fe2891e7ede817938cabb43251), [`0fed8f2`](https://github.com/mastra-ai/mastra/commit/0fed8f2aa84b167b3415ea6f8f70755775132c8d), [`4f9ea8c`](https://github.com/mastra-ai/mastra/commit/4f9ea8c95ea74ba9abbf3b2ab6106c7d7bc45689), [`1a1fbe6`](https://github.com/mastra-ai/mastra/commit/1a1fbe66efb7d94abc373ed0dd9676adb8122454), [`d706fad`](https://github.com/mastra-ai/mastra/commit/d706fad6e6e4b72357b18d229ba38e6c913c0e70), [`87fd07f`](https://github.com/mastra-ai/mastra/commit/87fd07ff35387a38728967163460231b5d33ae3b), [`5c3768f`](https://github.com/mastra-ai/mastra/commit/5c3768fa959454232ad76715c381f4aac00c6881), [`2685a78`](https://github.com/mastra-ai/mastra/commit/2685a78f224b8b04e20d4fab5ac1adb638190071), [`36f39c0`](https://github.com/mastra-ai/mastra/commit/36f39c00dc794952dc3c11aab91c2fa8bca74b11), [`239b5a4`](https://github.com/mastra-ai/mastra/commit/239b5a497aeae2e8b4d764f46217cfff2284788e), [`8a3f5e4`](https://github.com/mastra-ai/mastra/commit/8a3f5e4212ec36b302957deb4bd47005ab598382)]:
22
+ - @mastra/core@0.17.0
23
+
24
+ ## 0.11.9-alpha.0
25
+
26
+ ### Patch Changes
27
+
28
+ - dependencies updates: ([#7860](https://github.com/mastra-ai/mastra/pull/7860))
29
+ - Updated dependency [`chromadb@^3.0.15` ↗︎](https://www.npmjs.com/package/chromadb/v/3.0.15) (from `^3.0.14`, in `dependencies`)
30
+
31
+ - Update peerdep of @mastra/core ([#7619](https://github.com/mastra-ai/mastra/pull/7619))
32
+
33
+ - Updated dependencies [[`a1bb887`](https://github.com/mastra-ai/mastra/commit/a1bb887e8bfae44230f487648da72e96ef824561), [`a0f5f1c`](https://github.com/mastra-ai/mastra/commit/a0f5f1ca39c3c5c6d26202e9fcab986b4fe14568), [`b356f5f`](https://github.com/mastra-ai/mastra/commit/b356f5f7566cb3edb755d91f00b72fc1420b2a37), [`f5ce05f`](https://github.com/mastra-ai/mastra/commit/f5ce05f831d42c69559bf4c0fdb46ccb920fc3a3), [`9f6f30f`](https://github.com/mastra-ai/mastra/commit/9f6f30f04ec6648bbca798ea8aad59317c40d8db), [`d706fad`](https://github.com/mastra-ai/mastra/commit/d706fad6e6e4b72357b18d229ba38e6c913c0e70), [`5c3768f`](https://github.com/mastra-ai/mastra/commit/5c3768fa959454232ad76715c381f4aac00c6881), [`8a3f5e4`](https://github.com/mastra-ai/mastra/commit/8a3f5e4212ec36b302957deb4bd47005ab598382)]:
34
+ - @mastra/core@0.17.0-alpha.3
35
+
36
+ ## 0.11.8
37
+
38
+ ### Patch Changes
39
+
40
+ - 1483200: dependencies updates:
41
+ - Updated dependency [`chromadb@^3.0.14` ↗︎](https://www.npmjs.com/package/chromadb/v/3.0.14) (from `^3.0.11`, in `dependencies`)
42
+ - 376913a: Update peerdeps
43
+ - Updated dependencies [8fbf79e]
44
+ - Updated dependencies [fd83526]
45
+ - Updated dependencies [d0b90ab]
46
+ - Updated dependencies [6f5eb7a]
47
+ - Updated dependencies [a01cf14]
48
+ - Updated dependencies [a9e50ee]
49
+ - Updated dependencies [5397eb4]
50
+ - Updated dependencies [c9f4e4a]
51
+ - Updated dependencies [0acbc80]
52
+ - @mastra/core@0.16.0
53
+
54
+ ## 0.11.8-alpha.1
55
+
56
+ ### Patch Changes
57
+
58
+ - 376913a: Update peerdeps
59
+ - Updated dependencies [8fbf79e]
60
+ - @mastra/core@0.16.0-alpha.1
61
+
62
+ ## 0.11.8-alpha.0
63
+
64
+ ### Patch Changes
65
+
66
+ - 1483200: dependencies updates:
67
+ - Updated dependency [`chromadb@^3.0.14` ↗︎](https://www.npmjs.com/package/chromadb/v/3.0.14) (from `^3.0.11`, in `dependencies`)
68
+ - Updated dependencies [fd83526]
69
+ - Updated dependencies [d0b90ab]
70
+ - Updated dependencies [6f5eb7a]
71
+ - Updated dependencies [a01cf14]
72
+ - Updated dependencies [a9e50ee]
73
+ - Updated dependencies [5397eb4]
74
+ - Updated dependencies [c9f4e4a]
75
+ - Updated dependencies [0acbc80]
76
+ - @mastra/core@0.16.0-alpha.0
77
+
78
+ ## 0.11.7
79
+
80
+ ### Patch Changes
81
+
82
+ - de3cbc6: Update the `package.json` file to include additional fields like `repository`, `homepage` or `files`.
83
+ - f0dfcac: updated core peerdep
84
+ - Updated dependencies [ab48c97]
85
+ - Updated dependencies [85ef90b]
86
+ - Updated dependencies [aedbbfa]
87
+ - Updated dependencies [ff89505]
88
+ - Updated dependencies [637f323]
89
+ - Updated dependencies [de3cbc6]
90
+ - Updated dependencies [c19bcf7]
91
+ - Updated dependencies [4474d04]
92
+ - Updated dependencies [183dc95]
93
+ - Updated dependencies [a1111e2]
94
+ - Updated dependencies [b42a961]
95
+ - Updated dependencies [61debef]
96
+ - Updated dependencies [9beaeff]
97
+ - Updated dependencies [29de0e1]
98
+ - Updated dependencies [f643c65]
99
+ - Updated dependencies [00c74e7]
100
+ - Updated dependencies [fef7375]
101
+ - Updated dependencies [e3d8fea]
102
+ - Updated dependencies [45e4d39]
103
+ - Updated dependencies [9eee594]
104
+ - Updated dependencies [7149d8d]
105
+ - Updated dependencies [822c2e8]
106
+ - Updated dependencies [979912c]
107
+ - Updated dependencies [7dcf4c0]
108
+ - Updated dependencies [4106a58]
109
+ - Updated dependencies [ad78bfc]
110
+ - Updated dependencies [0302f50]
111
+ - Updated dependencies [6ac697e]
112
+ - Updated dependencies [74db265]
113
+ - Updated dependencies [0ce418a]
114
+ - Updated dependencies [af90672]
115
+ - Updated dependencies [8387952]
116
+ - Updated dependencies [7f3b8da]
117
+ - Updated dependencies [905352b]
118
+ - Updated dependencies [599d04c]
119
+ - Updated dependencies [56041d0]
120
+ - Updated dependencies [3412597]
121
+ - Updated dependencies [5eca5d2]
122
+ - Updated dependencies [f2cda47]
123
+ - Updated dependencies [5de1555]
124
+ - Updated dependencies [cfd377a]
125
+ - Updated dependencies [1ed5a3e]
126
+ - @mastra/core@0.15.3
127
+
128
+ ## 0.11.7-alpha.1
129
+
130
+ ### Patch Changes
131
+
132
+ - [#7394](https://github.com/mastra-ai/mastra/pull/7394) [`f0dfcac`](https://github.com/mastra-ai/mastra/commit/f0dfcac4458bdf789b975e2d63e984f5d1e7c4d3) Thanks [@NikAiyer](https://github.com/NikAiyer)! - updated core peerdep
133
+
134
+ - Updated dependencies [[`7149d8d`](https://github.com/mastra-ai/mastra/commit/7149d8d4bdc1edf0008e0ca9b7925eb0b8b60dbe)]:
135
+ - @mastra/core@0.15.3-alpha.7
136
+
137
+ ## 0.11.7-alpha.0
138
+
139
+ ### Patch Changes
140
+
141
+ - [#7343](https://github.com/mastra-ai/mastra/pull/7343) [`de3cbc6`](https://github.com/mastra-ai/mastra/commit/de3cbc61079211431bd30487982ea3653517278e) Thanks [@LekoArts](https://github.com/LekoArts)! - Update the `package.json` file to include additional fields like `repository`, `homepage` or `files`.
142
+
143
+ - Updated dependencies [[`85ef90b`](https://github.com/mastra-ai/mastra/commit/85ef90bb2cd4ae4df855c7ac175f7d392c55c1bf), [`de3cbc6`](https://github.com/mastra-ai/mastra/commit/de3cbc61079211431bd30487982ea3653517278e)]:
144
+ - @mastra/core@0.15.3-alpha.5
9
145
 
10
146
  ## 0.11.6
11
147
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/chroma",
3
- "version": "0.0.0-vector-query-tool-provider-options-20250828222356",
3
+ "version": "0.0.0-vector-extension-schema-20250922130418",
4
4
  "description": "Chroma vector store provider for Mastra",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -18,24 +18,37 @@
18
18
  },
19
19
  "./package.json": "./package.json"
20
20
  },
21
- "license": "MIT",
21
+ "license": "Apache-2.0",
22
22
  "dependencies": {
23
- "chromadb": "^3.0.11"
23
+ "chromadb": "^3.0.15"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@microsoft/api-extractor": "^7.52.8",
27
27
  "@types/node": "^20.19.0",
28
- "eslint": "^9.30.1",
28
+ "eslint": "^9.35.0",
29
29
  "tsup": "^8.5.0",
30
30
  "typescript": "^5.8.3",
31
31
  "vitest": "^3.2.4",
32
- "@internal/lint": "0.0.0-vector-query-tool-provider-options-20250828222356",
33
- "@internal/storage-test-utils": "0.0.30",
34
- "@internal/types-builder": "0.0.0-vector-query-tool-provider-options-20250828222356",
35
- "@mastra/core": "0.0.0-vector-query-tool-provider-options-20250828222356"
32
+ "@internal/lint": "0.0.0-vector-extension-schema-20250922130418",
33
+ "@mastra/core": "0.0.0-vector-extension-schema-20250922130418",
34
+ "@internal/types-builder": "0.0.0-vector-extension-schema-20250922130418",
35
+ "@internal/storage-test-utils": "0.0.37"
36
36
  },
37
37
  "peerDependencies": {
38
- "@mastra/core": "0.0.0-vector-query-tool-provider-options-20250828222356"
38
+ "@mastra/core": "0.0.0-vector-extension-schema-20250922130418"
39
+ },
40
+ "files": [
41
+ "dist",
42
+ "CHANGELOG.md"
43
+ ],
44
+ "homepage": "https://mastra.ai",
45
+ "repository": {
46
+ "type": "git",
47
+ "url": "git+https://github.com/mastra-ai/mastra.git",
48
+ "directory": "stores/chroma"
49
+ },
50
+ "bugs": {
51
+ "url": "https://github.com/mastra-ai/mastra/issues"
39
52
  },
40
53
  "scripts": {
41
54
  "build": "tsup --silent --config tsup.config.ts",
@@ -1,7 +0,0 @@
1
- services:
2
- chroma:
3
- image: chromadb/chroma
4
- ports:
5
- - 8000:8000
6
- volumes:
7
- pgdata:
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,2 +0,0 @@
1
- export * from './vector/index';
2
- export { CHROMA_PROMPT } from './vector/prompt';
@@ -1,421 +0,0 @@
1
- import { describe, it, expect, beforeEach } from 'vitest';
2
-
3
- import type { ChromaVectorFilter } from './filter';
4
- import { ChromaFilterTranslator } from './filter';
5
-
6
- describe('ChromaFilterTranslator', () => {
7
- let translator: ChromaFilterTranslator;
8
-
9
- beforeEach(() => {
10
- translator = new ChromaFilterTranslator();
11
- });
12
-
13
- // Basic Filter Operations
14
- describe('basic operations', () => {
15
- it('handles empty filters', () => {
16
- expect(translator.translate({})).toEqual({});
17
- expect(translator.translate(null)).toEqual(null);
18
- expect(translator.translate(undefined)).toEqual(undefined);
19
- });
20
-
21
- it('retains implicit equality', () => {
22
- const filter: ChromaVectorFilter = { field: 'value' };
23
- expect(translator.translate(filter)).toEqual({ field: 'value' });
24
- });
25
-
26
- it('converts multiple top-level fields to $and', () => {
27
- const filter: ChromaVectorFilter = {
28
- field1: 'value1',
29
- field2: 'value2',
30
- };
31
- expect(translator.translate(filter)).toEqual({
32
- $and: [{ field1: 'value1' }, { field2: 'value2' }],
33
- });
34
- });
35
-
36
- it('handles multiple operators on same field', () => {
37
- const filter: ChromaVectorFilter = {
38
- price: { $gt: 100, $lt: 200 },
39
- quantity: { $gte: 10, $lte: 20 },
40
- };
41
- expect(translator.translate(filter)).toEqual({
42
- $and: [
43
- { price: { $gt: 100 } },
44
- { price: { $lt: 200 } },
45
- { quantity: { $gte: 10 } },
46
- { quantity: { $lte: 20 } },
47
- ],
48
- });
49
- });
50
-
51
- it('normalizes date values', () => {
52
- const date = new Date('2024-01-01');
53
- const filter: ChromaVectorFilter = { timestamp: { $gt: date } };
54
- expect(translator.translate(filter)).toEqual({ timestamp: { $gt: date.toISOString() } });
55
- });
56
- });
57
-
58
- // Array Operations
59
- describe('array operations', () => {
60
- it('handles arrays as $in operator', () => {
61
- const filter: ChromaVectorFilter = { tags: ['tag1', 'tag2'] };
62
- expect(translator.translate(filter)).toEqual({ tags: { $in: ['tag1', 'tag2'] } });
63
- });
64
-
65
- it('handles empty array values', () => {
66
- // $in with empty array is valid in Pinecone
67
- expect(translator.translate({ tags: { $in: [] } })).toEqual({ tags: { $in: [] } });
68
- });
69
-
70
- it('handles arrays as direct values', () => {
71
- // Direct array value should be converted to $in
72
- const filter: ChromaVectorFilter = { field: ['value1', 'value2'] };
73
- expect(translator.translate(filter)).toEqual({
74
- field: { $in: ['value1', 'value2'] },
75
- });
76
-
77
- // Empty direct array
78
- const filter2 = { field: [] };
79
- expect(translator.translate(filter2)).toEqual({ field: { $in: [] } });
80
- });
81
-
82
- describe('$in operator variations', () => {
83
- it('handles $in with various values', () => {
84
- // Empty array
85
- expect(translator.translate({ field: { $in: [] } })).toEqual({ field: { $in: [] } });
86
-
87
- // Single value
88
- expect(translator.translate({ field: { $in: ['value'] } })).toEqual({ field: { $in: ['value'] } });
89
-
90
- // Multiple values
91
- expect(translator.translate({ field: { $in: [1, 'two', true] } })).toEqual({
92
- field: { $in: [1, 'two', true] },
93
- });
94
-
95
- // With dates
96
- const date = new Date('2024-01-01');
97
- expect(translator.translate({ field: { $in: [date.toISOString()] } })).toEqual({
98
- field: { $in: [date.toISOString()] },
99
- });
100
- });
101
- });
102
- });
103
-
104
- // Logical Operators
105
- describe('logical operators', () => {
106
- it('handles logical operators', () => {
107
- const filter: ChromaVectorFilter = {
108
- $or: [{ status: { $eq: 'active' } }, { age: { $gt: 25 } }],
109
- };
110
- expect(translator.translate(filter)).toEqual({
111
- $or: [{ status: { $eq: 'active' } }, { age: { $gt: 25 } }],
112
- });
113
- });
114
-
115
- it('handles nested logical operators', () => {
116
- const filter: ChromaVectorFilter = {
117
- $and: [
118
- { status: { $eq: 'active' } },
119
- {
120
- $or: [{ category: { $in: ['A', 'B'] } }, { $and: [{ price: { $gt: 100 } }, { stock: { $lt: 50 } }] }],
121
- },
122
- ],
123
- };
124
- expect(translator.translate(filter)).toEqual({
125
- $and: [
126
- { status: { $eq: 'active' } },
127
- {
128
- $or: [{ category: { $in: ['A', 'B'] } }, { $and: [{ price: { $gt: 100 } }, { stock: { $lt: 50 } }] }],
129
- },
130
- ],
131
- });
132
- });
133
-
134
- it('handles nested arrays in logical operators', () => {
135
- expect(
136
- translator.translate({
137
- $and: [{ field1: { $in: ['a', 'b'] } }, { field2: { $in: ['c', 'd'] } }],
138
- }),
139
- ).toEqual({
140
- $and: [
141
- { field1: { $in: ['a', 'b'] } },
142
- {
143
- field2: { $in: ['c', 'd'] },
144
- },
145
- ],
146
- });
147
- });
148
-
149
- it('handles complex nested conditions', () => {
150
- const filter: ChromaVectorFilter = {
151
- $or: [
152
- { age: { $gt: 25 } },
153
- {
154
- status: { $eq: 'active' },
155
- theme: 'dark',
156
- },
157
- ],
158
- };
159
- expect(translator.translate(filter)).toEqual({
160
- $or: [
161
- { age: { $gt: 25 } },
162
- {
163
- $and: [{ status: { $eq: 'active' } }, { theme: 'dark' }],
164
- },
165
- ],
166
- });
167
- });
168
- });
169
-
170
- // Nested Objects and Fields
171
- describe('nested objects and fields', () => {
172
- it('flattens nested objects to dot notation', () => {
173
- const filter = {
174
- user: {
175
- profile: {
176
- age: { $gt: 25 },
177
- },
178
- },
179
- };
180
- expect(translator.translate(filter)).toEqual({ 'user.profile.age': { $gt: 25 } });
181
- });
182
-
183
- it('preserves empty objects as exact match conditions', () => {
184
- const filter: ChromaVectorFilter = {
185
- metadata: {},
186
- 'user.profile': {},
187
- };
188
-
189
- expect(translator.translate(filter)).toEqual({
190
- $and: [{ metadata: {} }, { 'user.profile': {} }],
191
- });
192
- });
193
-
194
- it('handles empty objects in logical operators', () => {
195
- const filter: ChromaVectorFilter = {
196
- $or: [{}, { status: 'active' }],
197
- };
198
-
199
- expect(translator.translate(filter)).toEqual({
200
- $or: [{}, { status: 'active' }],
201
- });
202
- });
203
-
204
- it('preserves empty objects in nested structures', () => {
205
- const filter = {
206
- user: {
207
- profile: {
208
- settings: {},
209
- },
210
- },
211
- };
212
-
213
- expect(translator.translate(filter)).toEqual({
214
- 'user.profile.settings': {},
215
- });
216
- });
217
-
218
- it('handles empty objects in comparison operators', () => {
219
- const filter: ChromaVectorFilter = {
220
- metadata: { $eq: {} },
221
- };
222
-
223
- expect(translator.translate(filter)).toEqual({
224
- metadata: { $eq: {} },
225
- });
226
- });
227
-
228
- it('handles empty objects in array operators', () => {
229
- const filter: ChromaVectorFilter = {
230
- tags: { $in: [{}] },
231
- };
232
-
233
- expect(translator.translate(filter)).toEqual({
234
- tags: { $in: [{}] },
235
- });
236
- });
237
-
238
- it('handles multiple empty nested fields', () => {
239
- const filter = {
240
- metadata: {},
241
- settings: {},
242
- config: { nested: {} },
243
- };
244
-
245
- expect(translator.translate(filter)).toEqual({
246
- $and: [{ metadata: {} }, { settings: {} }, { 'config.nested': {} }],
247
- });
248
- });
249
- });
250
-
251
- // Operator Validation
252
- describe('operator validation', () => {
253
- describe('logical operator validation', () => {
254
- it('allows $and and $or at root level', () => {
255
- const validFilters = [
256
- {
257
- $and: [{ field1: 'value1' }, { field2: 'value2' }],
258
- },
259
- {
260
- $or: [{ field1: 'value1' }, { field2: 'value2' }],
261
- },
262
- {
263
- $and: [{ field1: 'value1' }],
264
- $or: [{ field2: 'value2' }],
265
- },
266
- ];
267
-
268
- validFilters.forEach(filter => {
269
- expect(() => translator.translate(filter)).not.toThrow();
270
- });
271
- });
272
-
273
- it('allows nested $and and $or within other logical operators', () => {
274
- const validFilters = [
275
- {
276
- $and: [
277
- { field1: 'value1' },
278
- {
279
- $or: [{ field2: 'value2' }, { field3: 'value3' }],
280
- },
281
- ],
282
- },
283
- {
284
- $or: [
285
- { field1: 'value1' },
286
- {
287
- $and: [{ field2: 'value2' }, { field3: 'value3' }],
288
- },
289
- ],
290
- },
291
- ];
292
-
293
- validFilters.forEach(filter => {
294
- expect(() => translator.translate(filter)).not.toThrow();
295
- });
296
- });
297
-
298
- it('throws error for logical operators in field-level conditions', () => {
299
- const invalidFilters = [
300
- {
301
- field: {
302
- $and: [{ $eq: 'value1' }, { $eq: 'value2' }],
303
- },
304
- },
305
- {
306
- field: {
307
- $or: [{ $eq: 'value1' }, { $eq: 'value2' }],
308
- },
309
- },
310
- {
311
- nested: {
312
- field: {
313
- $and: [{ $eq: 'value1' }, { $eq: 'value2' }],
314
- },
315
- },
316
- },
317
- ];
318
-
319
- invalidFilters.forEach(filter => {
320
- expect(() => translator.translate(filter)).toThrow(/cannot be used at field level/);
321
- });
322
- });
323
-
324
- it('throws error for direct operators in logical operator arrays', () => {
325
- const invalidFilters = [
326
- {
327
- $and: [{ $eq: 'value' }, { $gt: 100 }],
328
- },
329
- {
330
- $or: [{ $in: ['value1', 'value2'] }],
331
- },
332
- {
333
- $and: [{ field1: 'value1' }, { $or: [{ $eq: 'value2' }] }],
334
- },
335
- ];
336
-
337
- invalidFilters.forEach(filter => {
338
- expect(() => translator.translate(filter)).toThrow(/must contain field conditions/);
339
- });
340
- });
341
-
342
- it('throws error for unsupported logical operators', () => {
343
- const invalidFilters: any = [
344
- {
345
- $not: { field: 'value' },
346
- },
347
- {
348
- $nor: [{ field: 'value' }],
349
- },
350
- {
351
- $and: [{ field1: 'value1' }, { $nor: [{ field2: 'value2' }] }],
352
- },
353
- {
354
- field: { $not: { $eq: 'value' } },
355
- },
356
- ];
357
-
358
- // @ts-expect-error
359
- invalidFilters.forEach(filter => {
360
- expect(() => translator.translate(filter)).toThrow(/Unsupported operator/);
361
- });
362
- });
363
- });
364
-
365
- it('ensure all operator filters are supported', () => {
366
- const supportedFilters = [
367
- { field: { $eq: 'value' } },
368
- { field: { $ne: 'value' } },
369
- { field: { $gt: 'value' } },
370
- { field: { $gte: 'value' } },
371
- { field: { $lt: 'value' } },
372
- { field: { $lte: 'value' } },
373
- { field: { $in: ['value'] } },
374
- { $and: [{ field: { $eq: 'value' } }] },
375
- { $or: [{ field: { $eq: 'value' } }] },
376
- ];
377
- supportedFilters.forEach(filter => {
378
- expect(() => translator.translate(filter)).not.toThrow();
379
- });
380
- });
381
-
382
- it('throws error for unsupported operators', () => {
383
- const unsupportedFilters: any = [
384
- { field: { $regex: 'pattern' } },
385
- { field: { $contains: 'value' } },
386
- { field: { $exists: true } },
387
- { field: { $elemMatch: { $gt: 5 } } },
388
- { field: { $nor: [{ $eq: 'value' }] } },
389
- { field: { $not: [{ $eq: 'value' }] } },
390
- { field: { $regex: 'pattern', $options: 'i' } },
391
- { field: { $all: [{ $eq: 'value' }] } },
392
- ];
393
-
394
- // @ts-expect-error
395
- unsupportedFilters.forEach(filter => {
396
- expect(() => translator.translate(filter)).toThrow(/Unsupported operator/);
397
- });
398
- });
399
-
400
- it('throws error for regex operators', () => {
401
- const filter = { field: /pattern/i };
402
- expect(() => translator.translate(filter)).toThrow();
403
- });
404
- it('throws error for non-logical operators at top level', () => {
405
- const invalidFilters: any = [{ $gt: 100 }, { $in: ['value1', 'value2'] }, { $eq: true }];
406
-
407
- // @ts-expect-error
408
- invalidFilters.forEach(filter => {
409
- expect(() => translator.translate(filter)).toThrow(/Invalid top-level operator/);
410
- });
411
- });
412
-
413
- it('allows logical operators at top level', () => {
414
- const validFilters = [{ $and: [{ field: 'value' }] }, { $or: [{ field: 'value' }] }];
415
-
416
- validFilters.forEach(filter => {
417
- expect(() => translator.translate(filter)).not.toThrow();
418
- });
419
- });
420
- });
421
- });