@mastra/upstash 0.0.0-working-memory-per-user-20250620163010 → 0.0.0-zod-v4-compat-part-2-20250820135355
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 +268 -6
- package/LICENSE.md +12 -4
- package/README.md +98 -0
- package/dist/index.cjs +1629 -626
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1645 -642
- package/dist/index.js.map +1 -0
- package/dist/storage/domains/legacy-evals/index.d.ts +28 -0
- package/dist/storage/domains/legacy-evals/index.d.ts.map +1 -0
- package/dist/storage/domains/memory/index.d.ts +86 -0
- package/dist/storage/domains/memory/index.d.ts.map +1 -0
- package/dist/storage/domains/operations/index.d.ts +40 -0
- package/dist/storage/domains/operations/index.d.ts.map +1 -0
- package/dist/storage/domains/scores/index.d.ts +65 -0
- package/dist/storage/domains/scores/index.d.ts.map +1 -0
- package/dist/storage/domains/traces/index.d.ts +28 -0
- package/dist/storage/domains/traces/index.d.ts.map +1 -0
- package/dist/storage/domains/utils.d.ts +12 -0
- package/dist/storage/domains/utils.d.ts.map +1 -0
- package/dist/storage/domains/workflows/index.d.ts +36 -0
- package/dist/storage/domains/workflows/index.d.ts.map +1 -0
- package/dist/storage/index.d.ts +208 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/vector/filter.d.ts +21 -0
- package/dist/vector/filter.d.ts.map +1 -0
- package/dist/vector/index.d.ts +79 -0
- package/dist/vector/index.d.ts.map +1 -0
- package/dist/vector/prompt.d.ts +6 -0
- package/dist/vector/prompt.d.ts.map +1 -0
- package/dist/vector/types.d.ts +23 -0
- package/dist/vector/types.d.ts.map +1 -0
- package/docker-compose.yaml +1 -1
- package/package.json +12 -12
- package/src/storage/domains/legacy-evals/index.ts +279 -0
- package/src/storage/domains/memory/index.ts +972 -0
- package/src/storage/domains/operations/index.ts +168 -0
- package/src/storage/domains/scores/index.ts +216 -0
- package/src/storage/domains/traces/index.ts +172 -0
- package/src/storage/domains/utils.ts +57 -0
- package/src/storage/domains/workflows/index.ts +243 -0
- package/src/storage/index.test.ts +13 -0
- package/src/storage/index.ts +149 -1078
- package/src/vector/filter.test.ts +7 -6
- package/src/vector/filter.ts +10 -4
- package/src/vector/hybrid.test.ts +1455 -0
- package/src/vector/index.test.ts +4 -4
- package/src/vector/index.ts +155 -69
- package/src/vector/types.ts +26 -0
- package/tsconfig.build.json +9 -0
- package/tsconfig.json +1 -1
- package/tsup.config.ts +22 -0
- package/dist/_tsup-dts-rollup.d.cts +0 -318
- package/dist/_tsup-dts-rollup.d.ts +0 -318
- package/dist/index.d.cts +0 -4
- package/src/storage/upstash.test.ts +0 -1386
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { describe, it, expect, beforeEach } from 'vitest';
|
|
2
2
|
|
|
3
|
+
import type { UpstashVectorFilter } from './filter';
|
|
3
4
|
import { UpstashFilterTranslator } from './filter';
|
|
4
5
|
|
|
5
6
|
describe('UpstashFilterTranslator', () => {
|
|
@@ -22,7 +23,7 @@ describe('UpstashFilterTranslator', () => {
|
|
|
22
23
|
|
|
23
24
|
it('translates nested paths', () => {
|
|
24
25
|
expect(translator.translate({ 'geography.continent': 'Asia' })).toBe("geography.continent = 'Asia'");
|
|
25
|
-
expect(translator.translate({ geography: { continent: 'Asia' } })).toBe("geography.continent = 'Asia'");
|
|
26
|
+
expect(translator.translate({ geography: { continent: 'Asia' } } as any)).toBe("geography.continent = 'Asia'");
|
|
26
27
|
});
|
|
27
28
|
|
|
28
29
|
it('translates comparison operators', () => {
|
|
@@ -65,7 +66,7 @@ describe('UpstashFilterTranslator', () => {
|
|
|
65
66
|
});
|
|
66
67
|
|
|
67
68
|
it('translates complex nested conditions', () => {
|
|
68
|
-
const filter = {
|
|
69
|
+
const filter: UpstashVectorFilter = {
|
|
69
70
|
$and: [
|
|
70
71
|
{ population: { $gte: 1000000 } },
|
|
71
72
|
{ 'geography.continent': 'Asia' },
|
|
@@ -154,7 +155,7 @@ describe('UpstashFilterTranslator', () => {
|
|
|
154
155
|
|
|
155
156
|
describe('complex scenarios', () => {
|
|
156
157
|
it('deeply nested logical operators', () => {
|
|
157
|
-
const filter = {
|
|
158
|
+
const filter: UpstashVectorFilter = {
|
|
158
159
|
$or: [
|
|
159
160
|
{
|
|
160
161
|
$and: [
|
|
@@ -214,7 +215,7 @@ describe('UpstashFilterTranslator', () => {
|
|
|
214
215
|
});
|
|
215
216
|
|
|
216
217
|
it('complex filtering with all operator types', () => {
|
|
217
|
-
const filter = {
|
|
218
|
+
const filter: UpstashVectorFilter = {
|
|
218
219
|
$and: [
|
|
219
220
|
{
|
|
220
221
|
$or: [{ name: { $regex: 'San*' } }, { name: { $regex: 'New*' } }],
|
|
@@ -531,7 +532,7 @@ describe('UpstashFilterTranslator', () => {
|
|
|
531
532
|
});
|
|
532
533
|
|
|
533
534
|
it('throws error for invalid $not operator', () => {
|
|
534
|
-
expect(() => translator.translate({ field: { $not: true } })).toThrow();
|
|
535
|
+
expect(() => translator.translate({ field: { $not: true } } as any)).toThrow();
|
|
535
536
|
});
|
|
536
537
|
|
|
537
538
|
it('throws error for regex operators', () => {
|
|
@@ -539,7 +540,7 @@ describe('UpstashFilterTranslator', () => {
|
|
|
539
540
|
expect(() => translator.translate(filter)).toThrow();
|
|
540
541
|
});
|
|
541
542
|
it('throws error for non-logical operators at top level', () => {
|
|
542
|
-
const invalidFilters = [{ $gt: 100 }, { $in: ['value1', 'value2'] }, { $eq: true }];
|
|
543
|
+
const invalidFilters: any = [{ $gt: 100 }, { $in: ['value1', 'value2'] }, { $eq: true }];
|
|
543
544
|
|
|
544
545
|
invalidFilters.forEach(filter => {
|
|
545
546
|
expect(() => translator.translate(filter)).toThrow(/Invalid top-level operator/);
|
package/src/vector/filter.ts
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { BaseFilterTranslator } from '@mastra/core/vector/filter';
|
|
2
|
-
import type {
|
|
2
|
+
import type { OperatorSupport, VectorFilter, OperatorValueMap } from '@mastra/core/vector/filter';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
type UpstashOperatorValueMap = Omit<OperatorValueMap, '$options' | '$elemMatch'> & {
|
|
5
|
+
$contains: string;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export type UpstashVectorFilter = VectorFilter<keyof UpstashOperatorValueMap, UpstashOperatorValueMap>;
|
|
9
|
+
|
|
10
|
+
export class UpstashFilterTranslator extends BaseFilterTranslator<UpstashVectorFilter, string | undefined> {
|
|
5
11
|
protected override getSupportedOperators(): OperatorSupport {
|
|
6
12
|
return {
|
|
7
13
|
...BaseFilterTranslator.DEFAULT_OPERATORS,
|
|
@@ -11,13 +17,13 @@ export class UpstashFilterTranslator extends BaseFilterTranslator {
|
|
|
11
17
|
};
|
|
12
18
|
}
|
|
13
19
|
|
|
14
|
-
translate(filter?:
|
|
20
|
+
translate(filter?: UpstashVectorFilter): string | undefined {
|
|
15
21
|
if (this.isEmpty(filter)) return undefined;
|
|
16
22
|
this.validateFilter(filter);
|
|
17
23
|
return this.translateNode(filter);
|
|
18
24
|
}
|
|
19
25
|
|
|
20
|
-
private translateNode(node:
|
|
26
|
+
private translateNode(node: UpstashVectorFilter, path: string = ''): string {
|
|
21
27
|
if (this.isRegex(node)) {
|
|
22
28
|
throw new Error('Direct regex pattern format is not supported in Upstash');
|
|
23
29
|
}
|