@mastra/upstash 0.0.0-working-memory-per-user-20250620163010 → 0.0.0-zod-v4-compat-part-2-20250822105954

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.
Files changed (57) hide show
  1. package/CHANGELOG.md +268 -6
  2. package/LICENSE.md +12 -4
  3. package/README.md +98 -0
  4. package/dist/index.cjs +1629 -626
  5. package/dist/index.cjs.map +1 -0
  6. package/dist/index.d.ts +4 -4
  7. package/dist/index.d.ts.map +1 -0
  8. package/dist/index.js +1645 -642
  9. package/dist/index.js.map +1 -0
  10. package/dist/storage/domains/legacy-evals/index.d.ts +28 -0
  11. package/dist/storage/domains/legacy-evals/index.d.ts.map +1 -0
  12. package/dist/storage/domains/memory/index.d.ts +86 -0
  13. package/dist/storage/domains/memory/index.d.ts.map +1 -0
  14. package/dist/storage/domains/operations/index.d.ts +40 -0
  15. package/dist/storage/domains/operations/index.d.ts.map +1 -0
  16. package/dist/storage/domains/scores/index.d.ts +65 -0
  17. package/dist/storage/domains/scores/index.d.ts.map +1 -0
  18. package/dist/storage/domains/traces/index.d.ts +28 -0
  19. package/dist/storage/domains/traces/index.d.ts.map +1 -0
  20. package/dist/storage/domains/utils.d.ts +12 -0
  21. package/dist/storage/domains/utils.d.ts.map +1 -0
  22. package/dist/storage/domains/workflows/index.d.ts +36 -0
  23. package/dist/storage/domains/workflows/index.d.ts.map +1 -0
  24. package/dist/storage/index.d.ts +208 -0
  25. package/dist/storage/index.d.ts.map +1 -0
  26. package/dist/vector/filter.d.ts +21 -0
  27. package/dist/vector/filter.d.ts.map +1 -0
  28. package/dist/vector/index.d.ts +79 -0
  29. package/dist/vector/index.d.ts.map +1 -0
  30. package/dist/vector/prompt.d.ts +6 -0
  31. package/dist/vector/prompt.d.ts.map +1 -0
  32. package/dist/vector/types.d.ts +23 -0
  33. package/dist/vector/types.d.ts.map +1 -0
  34. package/docker-compose.yaml +1 -1
  35. package/package.json +12 -12
  36. package/src/storage/domains/legacy-evals/index.ts +279 -0
  37. package/src/storage/domains/memory/index.ts +972 -0
  38. package/src/storage/domains/operations/index.ts +168 -0
  39. package/src/storage/domains/scores/index.ts +216 -0
  40. package/src/storage/domains/traces/index.ts +172 -0
  41. package/src/storage/domains/utils.ts +57 -0
  42. package/src/storage/domains/workflows/index.ts +243 -0
  43. package/src/storage/index.test.ts +13 -0
  44. package/src/storage/index.ts +149 -1078
  45. package/src/vector/filter.test.ts +7 -6
  46. package/src/vector/filter.ts +10 -4
  47. package/src/vector/hybrid.test.ts +1455 -0
  48. package/src/vector/index.test.ts +4 -4
  49. package/src/vector/index.ts +155 -69
  50. package/src/vector/types.ts +26 -0
  51. package/tsconfig.build.json +9 -0
  52. package/tsconfig.json +1 -1
  53. package/tsup.config.ts +22 -0
  54. package/dist/_tsup-dts-rollup.d.cts +0 -318
  55. package/dist/_tsup-dts-rollup.d.ts +0 -318
  56. package/dist/index.d.cts +0 -4
  57. 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/);
@@ -1,7 +1,13 @@
1
1
  import { BaseFilterTranslator } from '@mastra/core/vector/filter';
2
- import type { FieldCondition, OperatorSupport, VectorFilter } from '@mastra/core/vector/filter';
2
+ import type { OperatorSupport, VectorFilter, OperatorValueMap } from '@mastra/core/vector/filter';
3
3
 
4
- export class UpstashFilterTranslator extends BaseFilterTranslator {
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?: VectorFilter): string | undefined {
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: VectorFilter | FieldCondition, path: string = ''): string {
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
  }