@mastra/upstash 0.3.4 → 0.4.0-alpha.1

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/upstash@0.3.4-alpha.4 build /home/runner/work/mastra/mastra/stores/upstash
2
+ > @mastra/upstash@0.4.0-alpha.1 build /home/runner/work/mastra/mastra/stores/upstash
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 7912ms
9
+ TSC ⚡️ Build success in 8537ms
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/upstash/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/upstash/dist/_tsup-dts-rollup.d.cts
16
- DTS ⚡️ Build success in 11998ms
16
+ DTS ⚡️ Build success in 11892ms
17
17
  CLI Cleaning output folder
18
18
  ESM Build start
19
19
  CJS Build start
20
- ESM dist/index.js 31.64 KB
21
- ESM ⚡️ Build success in 947ms
22
- CJS dist/index.cjs 31.78 KB
23
- CJS ⚡️ Build success in 1204ms
20
+ ESM dist/index.js 30.09 KB
21
+ ESM ⚡️ Build success in 1126ms
22
+ CJS dist/index.cjs 30.23 KB
23
+ CJS ⚡️ Build success in 1126ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,40 @@
1
1
  # @mastra/upstash
2
2
 
3
+ ## 0.4.0-alpha.1
4
+
5
+ ### Minor Changes
6
+
7
+ - 83da932: Move @mastra/core to peerdeps
8
+
9
+ ### Patch Changes
10
+
11
+ - a7292b0: BREAKING(@mastra/core, all vector stores): Vector store breaking changes (remove deprecated functions and positional arguments)
12
+ - Updated dependencies [b3a3d63]
13
+ - Updated dependencies [344f453]
14
+ - Updated dependencies [0a3ae6d]
15
+ - Updated dependencies [95911be]
16
+ - Updated dependencies [5eb5a99]
17
+ - Updated dependencies [7e632c5]
18
+ - Updated dependencies [1e9fbfa]
19
+ - Updated dependencies [b2ae5aa]
20
+ - Updated dependencies [a7292b0]
21
+ - Updated dependencies [0dcb9f0]
22
+ - @mastra/core@0.10.0-alpha.1
23
+
24
+ ## 0.3.5-alpha.0
25
+
26
+ ### Patch Changes
27
+
28
+ - d0ee3c6: Change all public functions and constructors in vector stores to use named args and prepare to phase out positional args
29
+ - Updated dependencies [f53a6ac]
30
+ - Updated dependencies [eabdcd9]
31
+ - Updated dependencies [90be034]
32
+ - Updated dependencies [99f050a]
33
+ - Updated dependencies [d0ee3c6]
34
+ - Updated dependencies [23f258c]
35
+ - Updated dependencies [2672a05]
36
+ - @mastra/core@0.9.5-alpha.0
37
+
3
38
  ## 0.3.4
4
39
 
5
40
  ### Patch Changes
@@ -1,17 +1,21 @@
1
1
  import { BaseFilterTranslator } from '@mastra/core/vector/filter';
2
2
  import type { CreateIndexParams } from '@mastra/core/vector';
3
+ import type { DeleteIndexParams } from '@mastra/core/vector';
4
+ import type { DeleteVectorParams } from '@mastra/core/vector';
5
+ import type { DescribeIndexParams } from '@mastra/core/vector';
3
6
  import type { EvalRow } from '@mastra/core/storage';
7
+ import type { IndexStats } from '@mastra/core/vector';
4
8
  import { MastraStorage } from '@mastra/core/storage';
5
9
  import { MastraVector } from '@mastra/core/vector';
6
10
  import type { MessageType } from '@mastra/core/memory';
7
11
  import type { OperatorSupport } from '@mastra/core/vector/filter';
8
- import type { ParamsToArgs } from '@mastra/core/vector';
9
12
  import type { QueryResult } from '@mastra/core/vector';
10
13
  import type { QueryVectorParams } from '@mastra/core/vector';
11
14
  import type { StorageColumn } from '@mastra/core/storage';
12
15
  import type { StorageGetMessagesArg } from '@mastra/core/storage';
13
16
  import type { StorageThreadType } from '@mastra/core/memory';
14
17
  import type { TABLE_NAMES } from '@mastra/core/storage';
18
+ import type { UpdateVectorParams } from '@mastra/core/vector';
15
19
  import type { UpsertVectorParams } from '@mastra/core/vector';
16
20
  import type { VectorFilter } from '@mastra/core/vector/filter';
17
21
  import type { WorkflowRun } from '@mastra/core/storage';
@@ -145,33 +149,19 @@ declare class UpstashVector extends MastraVector {
145
149
  url: string;
146
150
  token: string;
147
151
  });
148
- upsert(...args: ParamsToArgs<UpsertVectorParams>): Promise<string[]>;
152
+ upsert({ indexName, vectors, metadata, ids }: UpsertVectorParams): Promise<string[]>;
149
153
  transformFilter(filter?: VectorFilter): string | undefined;
150
- createIndex(..._args: ParamsToArgs<CreateIndexParams>): Promise<void>;
151
- query(...args: ParamsToArgs<QueryVectorParams>): Promise<QueryResult[]>;
154
+ createIndex(_params: CreateIndexParams): Promise<void>;
155
+ query({ indexName, queryVector, topK, filter, includeVector, }: QueryVectorParams): Promise<QueryResult[]>;
152
156
  listIndexes(): Promise<string[]>;
153
- describeIndex(indexName: string): Promise<{
154
- dimension: number;
155
- count: number;
156
- metric: "cosine" | "euclidean" | "dotproduct";
157
- }>;
158
- deleteIndex(indexName: string): Promise<void>;
159
157
  /**
160
- * @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
158
+ * Retrieves statistics about a vector index.
161
159
  *
162
- * Updates a vector by its ID with the provided vector and/or metadata.
163
- * @param indexName - The name of the index containing the vector.
164
- * @param id - The ID of the vector to update.
165
- * @param update - An object containing the vector and/or metadata to update.
166
- * @param update.vector - An optional array of numbers representing the new vector.
167
- * @param update.metadata - An optional record containing the new metadata.
168
- * @returns A promise that resolves when the update is complete.
169
- * @throws Will throw an error if no updates are provided or if the update operation fails.
160
+ * @param {string} indexName - The name of the index to describe
161
+ * @returns A promise that resolves to the index statistics including dimension, count and metric
170
162
  */
171
- updateIndexById(indexName: string, id: string, update: {
172
- vector?: number[];
173
- metadata?: Record<string, any>;
174
- }): Promise<void>;
163
+ describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats>;
164
+ deleteIndex({ indexName }: DeleteIndexParams): Promise<void>;
175
165
  /**
176
166
  * Updates a vector by its ID with the provided vector and/or metadata.
177
167
  * @param indexName - The name of the index containing the vector.
@@ -182,20 +172,7 @@ declare class UpstashVector extends MastraVector {
182
172
  * @returns A promise that resolves when the update is complete.
183
173
  * @throws Will throw an error if no updates are provided or if the update operation fails.
184
174
  */
185
- updateVector(indexName: string, id: string, update: {
186
- vector?: number[];
187
- metadata?: Record<string, any>;
188
- }): Promise<void>;
189
- /**
190
- * @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
191
- *
192
- * Deletes a vector by its ID.
193
- * @param indexName - The name of the index containing the vector.
194
- * @param id - The ID of the vector to delete.
195
- * @returns A promise that resolves when the deletion is complete.
196
- * @throws Will throw an error if the deletion operation fails.
197
- */
198
- deleteIndexById(indexName: string, id: string): Promise<void>;
175
+ updateVector({ indexName, id, update }: UpdateVectorParams): Promise<void>;
199
176
  /**
200
177
  * Deletes a vector by its ID.
201
178
  * @param indexName - The name of the index containing the vector.
@@ -203,7 +180,7 @@ declare class UpstashVector extends MastraVector {
203
180
  * @returns A promise that resolves when the deletion is complete.
204
181
  * @throws Will throw an error if the deletion operation fails.
205
182
  */
206
- deleteVector(indexName: string, id: string): Promise<void>;
183
+ deleteVector({ indexName, id }: DeleteVectorParams): Promise<void>;
207
184
  }
208
185
  export { UpstashVector }
209
186
  export { UpstashVector as UpstashVector_alias_1 }
@@ -1,17 +1,21 @@
1
1
  import { BaseFilterTranslator } from '@mastra/core/vector/filter';
2
2
  import type { CreateIndexParams } from '@mastra/core/vector';
3
+ import type { DeleteIndexParams } from '@mastra/core/vector';
4
+ import type { DeleteVectorParams } from '@mastra/core/vector';
5
+ import type { DescribeIndexParams } from '@mastra/core/vector';
3
6
  import type { EvalRow } from '@mastra/core/storage';
7
+ import type { IndexStats } from '@mastra/core/vector';
4
8
  import { MastraStorage } from '@mastra/core/storage';
5
9
  import { MastraVector } from '@mastra/core/vector';
6
10
  import type { MessageType } from '@mastra/core/memory';
7
11
  import type { OperatorSupport } from '@mastra/core/vector/filter';
8
- import type { ParamsToArgs } from '@mastra/core/vector';
9
12
  import type { QueryResult } from '@mastra/core/vector';
10
13
  import type { QueryVectorParams } from '@mastra/core/vector';
11
14
  import type { StorageColumn } from '@mastra/core/storage';
12
15
  import type { StorageGetMessagesArg } from '@mastra/core/storage';
13
16
  import type { StorageThreadType } from '@mastra/core/memory';
14
17
  import type { TABLE_NAMES } from '@mastra/core/storage';
18
+ import type { UpdateVectorParams } from '@mastra/core/vector';
15
19
  import type { UpsertVectorParams } from '@mastra/core/vector';
16
20
  import type { VectorFilter } from '@mastra/core/vector/filter';
17
21
  import type { WorkflowRun } from '@mastra/core/storage';
@@ -145,33 +149,19 @@ declare class UpstashVector extends MastraVector {
145
149
  url: string;
146
150
  token: string;
147
151
  });
148
- upsert(...args: ParamsToArgs<UpsertVectorParams>): Promise<string[]>;
152
+ upsert({ indexName, vectors, metadata, ids }: UpsertVectorParams): Promise<string[]>;
149
153
  transformFilter(filter?: VectorFilter): string | undefined;
150
- createIndex(..._args: ParamsToArgs<CreateIndexParams>): Promise<void>;
151
- query(...args: ParamsToArgs<QueryVectorParams>): Promise<QueryResult[]>;
154
+ createIndex(_params: CreateIndexParams): Promise<void>;
155
+ query({ indexName, queryVector, topK, filter, includeVector, }: QueryVectorParams): Promise<QueryResult[]>;
152
156
  listIndexes(): Promise<string[]>;
153
- describeIndex(indexName: string): Promise<{
154
- dimension: number;
155
- count: number;
156
- metric: "cosine" | "euclidean" | "dotproduct";
157
- }>;
158
- deleteIndex(indexName: string): Promise<void>;
159
157
  /**
160
- * @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
158
+ * Retrieves statistics about a vector index.
161
159
  *
162
- * Updates a vector by its ID with the provided vector and/or metadata.
163
- * @param indexName - The name of the index containing the vector.
164
- * @param id - The ID of the vector to update.
165
- * @param update - An object containing the vector and/or metadata to update.
166
- * @param update.vector - An optional array of numbers representing the new vector.
167
- * @param update.metadata - An optional record containing the new metadata.
168
- * @returns A promise that resolves when the update is complete.
169
- * @throws Will throw an error if no updates are provided or if the update operation fails.
160
+ * @param {string} indexName - The name of the index to describe
161
+ * @returns A promise that resolves to the index statistics including dimension, count and metric
170
162
  */
171
- updateIndexById(indexName: string, id: string, update: {
172
- vector?: number[];
173
- metadata?: Record<string, any>;
174
- }): Promise<void>;
163
+ describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats>;
164
+ deleteIndex({ indexName }: DeleteIndexParams): Promise<void>;
175
165
  /**
176
166
  * Updates a vector by its ID with the provided vector and/or metadata.
177
167
  * @param indexName - The name of the index containing the vector.
@@ -182,20 +172,7 @@ declare class UpstashVector extends MastraVector {
182
172
  * @returns A promise that resolves when the update is complete.
183
173
  * @throws Will throw an error if no updates are provided or if the update operation fails.
184
174
  */
185
- updateVector(indexName: string, id: string, update: {
186
- vector?: number[];
187
- metadata?: Record<string, any>;
188
- }): Promise<void>;
189
- /**
190
- * @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
191
- *
192
- * Deletes a vector by its ID.
193
- * @param indexName - The name of the index containing the vector.
194
- * @param id - The ID of the vector to delete.
195
- * @returns A promise that resolves when the deletion is complete.
196
- * @throws Will throw an error if the deletion operation fails.
197
- */
198
- deleteIndexById(indexName: string, id: string): Promise<void>;
175
+ updateVector({ indexName, id, update }: UpdateVectorParams): Promise<void>;
199
176
  /**
200
177
  * Deletes a vector by its ID.
201
178
  * @param indexName - The name of the index containing the vector.
@@ -203,7 +180,7 @@ declare class UpstashVector extends MastraVector {
203
180
  * @returns A promise that resolves when the deletion is complete.
204
181
  * @throws Will throw an error if the deletion operation fails.
205
182
  */
206
- deleteVector(indexName: string, id: string): Promise<void>;
183
+ deleteVector({ indexName, id }: DeleteVectorParams): Promise<void>;
207
184
  }
208
185
  export { UpstashVector }
209
186
  export { UpstashVector as UpstashVector_alias_1 }
package/dist/index.cjs CHANGED
@@ -675,9 +675,7 @@ var UpstashVector = class extends vector.MastraVector {
675
675
  token
676
676
  });
677
677
  }
678
- async upsert(...args) {
679
- const params = this.normalizeArgs("upsert", args);
680
- const { indexName, vectors, metadata, ids } = params;
678
+ async upsert({ indexName, vectors, metadata, ids }) {
681
679
  const generatedIds = ids || vectors.map(() => crypto.randomUUID());
682
680
  const points = vectors.map((vector, index) => ({
683
681
  id: generatedIds[index],
@@ -693,12 +691,16 @@ var UpstashVector = class extends vector.MastraVector {
693
691
  const translator = new UpstashFilterTranslator();
694
692
  return translator.translate(filter);
695
693
  }
696
- async createIndex(..._args) {
694
+ async createIndex(_params) {
697
695
  console.log("No need to call createIndex for Upstash");
698
696
  }
699
- async query(...args) {
700
- const params = this.normalizeArgs("query", args);
701
- const { indexName, queryVector, topK = 10, filter, includeVector = false } = params;
697
+ async query({
698
+ indexName,
699
+ queryVector,
700
+ topK = 10,
701
+ filter,
702
+ includeVector = false
703
+ }) {
702
704
  const ns = this.client.namespace(indexName);
703
705
  const filterString = this.transformFilter(filter);
704
706
  const results = await ns.query({
@@ -719,7 +721,13 @@ var UpstashVector = class extends vector.MastraVector {
719
721
  const indexes = await this.client.listNamespaces();
720
722
  return indexes.filter(Boolean);
721
723
  }
722
- async describeIndex(indexName) {
724
+ /**
725
+ * Retrieves statistics about a vector index.
726
+ *
727
+ * @param {string} indexName - The name of the index to describe
728
+ * @returns A promise that resolves to the index statistics including dimension, count and metric
729
+ */
730
+ async describeIndex({ indexName }) {
723
731
  const info = await this.client.info();
724
732
  return {
725
733
  dimension: info.dimension,
@@ -727,7 +735,7 @@ var UpstashVector = class extends vector.MastraVector {
727
735
  metric: info?.similarityFunction?.toLowerCase()
728
736
  };
729
737
  }
730
- async deleteIndex(indexName) {
738
+ async deleteIndex({ indexName }) {
731
739
  try {
732
740
  await this.client.deleteNamespace(indexName);
733
741
  } catch (error) {
@@ -735,8 +743,6 @@ var UpstashVector = class extends vector.MastraVector {
735
743
  }
736
744
  }
737
745
  /**
738
- * @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
739
- *
740
746
  * Updates a vector by its ID with the provided vector and/or metadata.
741
747
  * @param indexName - The name of the index containing the vector.
742
748
  * @param id - The ID of the vector to update.
@@ -746,25 +752,7 @@ var UpstashVector = class extends vector.MastraVector {
746
752
  * @returns A promise that resolves when the update is complete.
747
753
  * @throws Will throw an error if no updates are provided or if the update operation fails.
748
754
  */
749
- async updateIndexById(indexName, id, update) {
750
- this.logger.warn(
751
- `Deprecation Warning: updateIndexById() is deprecated.
752
- Please use updateVector() instead.
753
- updateIndexById() will be removed on May 20th, 2025.`
754
- );
755
- await this.updateVector(indexName, id, update);
756
- }
757
- /**
758
- * Updates a vector by its ID with the provided vector and/or metadata.
759
- * @param indexName - The name of the index containing the vector.
760
- * @param id - The ID of the vector to update.
761
- * @param update - An object containing the vector and/or metadata to update.
762
- * @param update.vector - An optional array of numbers representing the new vector.
763
- * @param update.metadata - An optional record containing the new metadata.
764
- * @returns A promise that resolves when the update is complete.
765
- * @throws Will throw an error if no updates are provided or if the update operation fails.
766
- */
767
- async updateVector(indexName, id, update) {
755
+ async updateVector({ indexName, id, update }) {
768
756
  try {
769
757
  if (!update.vector && !update.metadata) {
770
758
  throw new Error("No update data provided");
@@ -791,23 +779,6 @@ var UpstashVector = class extends vector.MastraVector {
791
779
  throw new Error(`Failed to update vector by id: ${id} for index name: ${indexName}: ${error.message}`);
792
780
  }
793
781
  }
794
- /**
795
- * @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
796
- *
797
- * Deletes a vector by its ID.
798
- * @param indexName - The name of the index containing the vector.
799
- * @param id - The ID of the vector to delete.
800
- * @returns A promise that resolves when the deletion is complete.
801
- * @throws Will throw an error if the deletion operation fails.
802
- */
803
- async deleteIndexById(indexName, id) {
804
- this.logger.warn(
805
- `Deprecation Warning: deleteIndexById() is deprecated.
806
- Please use deleteVector() instead.
807
- deleteIndexById() will be removed on May 20th, 2025.`
808
- );
809
- await this.deleteVector(indexName, id);
810
- }
811
782
  /**
812
783
  * Deletes a vector by its ID.
813
784
  * @param indexName - The name of the index containing the vector.
@@ -815,7 +786,7 @@ var UpstashVector = class extends vector.MastraVector {
815
786
  * @returns A promise that resolves when the deletion is complete.
816
787
  * @throws Will throw an error if the deletion operation fails.
817
788
  */
818
- async deleteVector(indexName, id) {
789
+ async deleteVector({ indexName, id }) {
819
790
  try {
820
791
  await this.client.delete(id, {
821
792
  namespace: indexName
package/dist/index.js CHANGED
@@ -673,9 +673,7 @@ var UpstashVector = class extends MastraVector {
673
673
  token
674
674
  });
675
675
  }
676
- async upsert(...args) {
677
- const params = this.normalizeArgs("upsert", args);
678
- const { indexName, vectors, metadata, ids } = params;
676
+ async upsert({ indexName, vectors, metadata, ids }) {
679
677
  const generatedIds = ids || vectors.map(() => crypto.randomUUID());
680
678
  const points = vectors.map((vector, index) => ({
681
679
  id: generatedIds[index],
@@ -691,12 +689,16 @@ var UpstashVector = class extends MastraVector {
691
689
  const translator = new UpstashFilterTranslator();
692
690
  return translator.translate(filter);
693
691
  }
694
- async createIndex(..._args) {
692
+ async createIndex(_params) {
695
693
  console.log("No need to call createIndex for Upstash");
696
694
  }
697
- async query(...args) {
698
- const params = this.normalizeArgs("query", args);
699
- const { indexName, queryVector, topK = 10, filter, includeVector = false } = params;
695
+ async query({
696
+ indexName,
697
+ queryVector,
698
+ topK = 10,
699
+ filter,
700
+ includeVector = false
701
+ }) {
700
702
  const ns = this.client.namespace(indexName);
701
703
  const filterString = this.transformFilter(filter);
702
704
  const results = await ns.query({
@@ -717,7 +719,13 @@ var UpstashVector = class extends MastraVector {
717
719
  const indexes = await this.client.listNamespaces();
718
720
  return indexes.filter(Boolean);
719
721
  }
720
- async describeIndex(indexName) {
722
+ /**
723
+ * Retrieves statistics about a vector index.
724
+ *
725
+ * @param {string} indexName - The name of the index to describe
726
+ * @returns A promise that resolves to the index statistics including dimension, count and metric
727
+ */
728
+ async describeIndex({ indexName }) {
721
729
  const info = await this.client.info();
722
730
  return {
723
731
  dimension: info.dimension,
@@ -725,7 +733,7 @@ var UpstashVector = class extends MastraVector {
725
733
  metric: info?.similarityFunction?.toLowerCase()
726
734
  };
727
735
  }
728
- async deleteIndex(indexName) {
736
+ async deleteIndex({ indexName }) {
729
737
  try {
730
738
  await this.client.deleteNamespace(indexName);
731
739
  } catch (error) {
@@ -733,8 +741,6 @@ var UpstashVector = class extends MastraVector {
733
741
  }
734
742
  }
735
743
  /**
736
- * @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
737
- *
738
744
  * Updates a vector by its ID with the provided vector and/or metadata.
739
745
  * @param indexName - The name of the index containing the vector.
740
746
  * @param id - The ID of the vector to update.
@@ -744,25 +750,7 @@ var UpstashVector = class extends MastraVector {
744
750
  * @returns A promise that resolves when the update is complete.
745
751
  * @throws Will throw an error if no updates are provided or if the update operation fails.
746
752
  */
747
- async updateIndexById(indexName, id, update) {
748
- this.logger.warn(
749
- `Deprecation Warning: updateIndexById() is deprecated.
750
- Please use updateVector() instead.
751
- updateIndexById() will be removed on May 20th, 2025.`
752
- );
753
- await this.updateVector(indexName, id, update);
754
- }
755
- /**
756
- * Updates a vector by its ID with the provided vector and/or metadata.
757
- * @param indexName - The name of the index containing the vector.
758
- * @param id - The ID of the vector to update.
759
- * @param update - An object containing the vector and/or metadata to update.
760
- * @param update.vector - An optional array of numbers representing the new vector.
761
- * @param update.metadata - An optional record containing the new metadata.
762
- * @returns A promise that resolves when the update is complete.
763
- * @throws Will throw an error if no updates are provided or if the update operation fails.
764
- */
765
- async updateVector(indexName, id, update) {
753
+ async updateVector({ indexName, id, update }) {
766
754
  try {
767
755
  if (!update.vector && !update.metadata) {
768
756
  throw new Error("No update data provided");
@@ -789,23 +777,6 @@ var UpstashVector = class extends MastraVector {
789
777
  throw new Error(`Failed to update vector by id: ${id} for index name: ${indexName}: ${error.message}`);
790
778
  }
791
779
  }
792
- /**
793
- * @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
794
- *
795
- * Deletes a vector by its ID.
796
- * @param indexName - The name of the index containing the vector.
797
- * @param id - The ID of the vector to delete.
798
- * @returns A promise that resolves when the deletion is complete.
799
- * @throws Will throw an error if the deletion operation fails.
800
- */
801
- async deleteIndexById(indexName, id) {
802
- this.logger.warn(
803
- `Deprecation Warning: deleteIndexById() is deprecated.
804
- Please use deleteVector() instead.
805
- deleteIndexById() will be removed on May 20th, 2025.`
806
- );
807
- await this.deleteVector(indexName, id);
808
- }
809
780
  /**
810
781
  * Deletes a vector by its ID.
811
782
  * @param indexName - The name of the index containing the vector.
@@ -813,7 +784,7 @@ var UpstashVector = class extends MastraVector {
813
784
  * @returns A promise that resolves when the deletion is complete.
814
785
  * @throws Will throw an error if the deletion operation fails.
815
786
  */
816
- async deleteVector(indexName, id) {
787
+ async deleteVector({ indexName, id }) {
817
788
  try {
818
789
  await this.client.delete(id, {
819
790
  namespace: indexName
@@ -3,13 +3,13 @@ services:
3
3
  redis:
4
4
  image: redis:7-alpine
5
5
  ports:
6
- - "6379:6379"
6
+ - '6379:6379'
7
7
  command: redis-server --requirepass redis_password
8
8
  serverless-redis-http:
9
9
  image: hiett/serverless-redis-http:latest
10
10
  ports:
11
- - "8079:80"
11
+ - '8079:80'
12
12
  environment:
13
13
  SRH_MODE: env
14
14
  SRH_TOKEN: test_token
15
- SRH_CONNECTION_STRING: "redis://:redis_password@redis:6379"
15
+ SRH_CONNECTION_STRING: 'redis://:redis_password@redis:6379'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/upstash",
3
- "version": "0.3.4",
3
+ "version": "0.4.0-alpha.1",
4
4
  "description": "Upstash provider for Mastra - includes both vector and db storage capabilities",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -21,8 +21,7 @@
21
21
  "license": "MIT",
22
22
  "dependencies": {
23
23
  "@upstash/redis": "^1.34.5",
24
- "@upstash/vector": "^1.2.1",
25
- "@mastra/core": "^0.9.4"
24
+ "@upstash/vector": "^1.2.1"
26
25
  },
27
26
  "devDependencies": {
28
27
  "@microsoft/api-extractor": "^7.52.5",
@@ -32,7 +31,11 @@
32
31
  "tsup": "^8.4.0",
33
32
  "typescript": "^5.8.2",
34
33
  "vitest": "^3.1.2",
35
- "@internal/lint": "0.0.5"
34
+ "@internal/lint": "0.0.5",
35
+ "@mastra/core": "0.10.0-alpha.1"
36
+ },
37
+ "peerDependencies": {
38
+ "@mastra/core": "^0.9.4"
36
39
  },
37
40
  "scripts": {
38
41
  "pretest": "docker compose up -d",
@@ -1,7 +1,7 @@
1
1
  import type { QueryResult } from '@mastra/core/vector';
2
2
  import dotenv from 'dotenv';
3
3
 
4
- import { describe, it, expect, beforeAll, afterAll, beforeEach, vi, afterEach } from 'vitest';
4
+ import { describe, it, expect, beforeAll, afterAll, afterEach } from 'vitest';
5
5
 
6
6
  import { UpstashVector } from './';
7
7
 
@@ -13,7 +13,7 @@ function waitUntilVectorsIndexed(vector: UpstashVector, indexName: string, expec
13
13
  let attempts = 0;
14
14
  const interval = setInterval(async () => {
15
15
  try {
16
- const stats = await vector.describeIndex(indexName);
16
+ const stats = await vector.describeIndex({ indexName });
17
17
  if (stats && stats.count >= expectedCount) {
18
18
  clearInterval(interval);
19
19
  resolve(true);
@@ -59,12 +59,12 @@ describe.skipIf(!process.env.UPSTASH_VECTOR_URL || !process.env.UPSTASH_VECTOR_T
59
59
 
60
60
  // Cleanup: delete test index
61
61
  try {
62
- await vectorStore.deleteIndex(testIndexName);
62
+ await vectorStore.deleteIndex({ indexName: testIndexName });
63
63
  } catch (error) {
64
64
  console.warn('Failed to delete test index:', error);
65
65
  }
66
66
  try {
67
- await vectorStore.deleteIndex(filterIndexName);
67
+ await vectorStore.deleteIndex({ indexName: filterIndexName });
68
68
  } catch (error) {
69
69
  console.warn('Failed to delete filter index:', error);
70
70
  }
@@ -122,7 +122,7 @@ describe.skipIf(!process.env.UPSTASH_VECTOR_URL || !process.env.UPSTASH_VECTOR_T
122
122
  const testIndexName = 'test-index';
123
123
 
124
124
  afterEach(async () => {
125
- await vectorStore.deleteIndex(testIndexName);
125
+ await vectorStore.deleteIndex({ indexName: testIndexName });
126
126
  });
127
127
 
128
128
  it('should update the vector by id', async () => {
@@ -140,7 +140,7 @@ describe.skipIf(!process.env.UPSTASH_VECTOR_URL || !process.env.UPSTASH_VECTOR_T
140
140
  metadata: newMetaData,
141
141
  };
142
142
 
143
- await vectorStore.updateVector(testIndexName, idToBeUpdated, update);
143
+ await vectorStore.updateVector({ indexName: testIndexName, id: idToBeUpdated, update });
144
144
 
145
145
  await waitUntilVectorsIndexed(vectorStore, testIndexName, 3);
146
146
 
@@ -167,7 +167,7 @@ describe.skipIf(!process.env.UPSTASH_VECTOR_URL || !process.env.UPSTASH_VECTOR_T
167
167
  metadata: newMetaData,
168
168
  };
169
169
 
170
- await expect(vectorStore.updateVector(testIndexName, 'id', update)).rejects.toThrow(
170
+ await expect(vectorStore.updateVector({ indexName: testIndexName, id: 'id', update })).rejects.toThrow(
171
171
  'Both vector and metadata must be provided for an update',
172
172
  );
173
173
  });
@@ -183,7 +183,7 @@ describe.skipIf(!process.env.UPSTASH_VECTOR_URL || !process.env.UPSTASH_VECTOR_T
183
183
  vector: newVector,
184
184
  };
185
185
 
186
- await vectorStore.updateVector(testIndexName, idToBeUpdated, update);
186
+ await vectorStore.updateVector({ indexName: testIndexName, id: idToBeUpdated, update });
187
187
 
188
188
  await waitUntilVectorsIndexed(vectorStore, testIndexName, 3);
189
189
 
@@ -198,7 +198,9 @@ describe.skipIf(!process.env.UPSTASH_VECTOR_URL || !process.env.UPSTASH_VECTOR_T
198
198
  }, 500000);
199
199
 
200
200
  it('should throw exception when no updates are given', async () => {
201
- await expect(vectorStore.updateVector(testIndexName, 'id', {})).rejects.toThrow('No update data provided');
201
+ await expect(vectorStore.updateVector({ indexName: testIndexName, id: 'id', update: {} })).rejects.toThrow(
202
+ 'No update data provided',
203
+ );
202
204
  });
203
205
  });
204
206
 
@@ -206,7 +208,7 @@ describe.skipIf(!process.env.UPSTASH_VECTOR_URL || !process.env.UPSTASH_VECTOR_T
206
208
  const testVectors = [createVector(0, 1.0), createVector(1, 1.0), createVector(2, 1.0)];
207
209
 
208
210
  afterEach(async () => {
209
- await vectorStore.deleteIndex(testIndexName);
211
+ await vectorStore.deleteIndex({ indexName: testIndexName });
210
212
  });
211
213
 
212
214
  it('should delete the vector by id', async () => {
@@ -214,7 +216,7 @@ describe.skipIf(!process.env.UPSTASH_VECTOR_URL || !process.env.UPSTASH_VECTOR_T
214
216
  expect(ids).toHaveLength(3);
215
217
  const idToBeDeleted = ids[0];
216
218
 
217
- await vectorStore.deleteVector(testIndexName, idToBeDeleted);
219
+ await vectorStore.deleteVector({ indexName: testIndexName, id: idToBeDeleted });
218
220
 
219
221
  const results: QueryResult[] = await vectorStore.query({
220
222
  indexName: testIndexName,
@@ -246,7 +248,7 @@ describe.skipIf(!process.env.UPSTASH_VECTOR_URL || !process.env.UPSTASH_VECTOR_T
246
248
  });
247
249
 
248
250
  it('should describe an index correctly', async () => {
249
- const stats = await vectorStore.describeIndex('mastra_default');
251
+ const stats = await vectorStore.describeIndex({ indexName: 'mastra_default' });
250
252
  expect(stats).toEqual({
251
253
  dimension: 1536,
252
254
  metric: 'cosine',
@@ -262,7 +264,7 @@ describe.skipIf(!process.env.UPSTASH_VECTOR_URL || !process.env.UPSTASH_VECTOR_T
262
264
  });
263
265
 
264
266
  afterAll(async () => {
265
- await vectorStore.deleteIndex(testIndexName);
267
+ await vectorStore.deleteIndex({ indexName: testIndexName });
266
268
  });
267
269
 
268
270
  it('should handle invalid dimension vectors', async () => {
@@ -1200,97 +1202,4 @@ describe.skipIf(!process.env.UPSTASH_VECTOR_URL || !process.env.UPSTASH_VECTOR_T
1200
1202
  });
1201
1203
  });
1202
1204
  });
1203
- describe('Deprecation Warnings', () => {
1204
- const indexName = 'testdeprecationwarnings';
1205
-
1206
- const indexName2 = 'testdeprecationwarnings2';
1207
-
1208
- let warnSpy;
1209
-
1210
- afterAll(async () => {
1211
- await vectorStore.deleteIndex(indexName);
1212
- await vectorStore.deleteIndex(indexName2);
1213
- });
1214
-
1215
- beforeEach(async () => {
1216
- warnSpy = vi.spyOn(vectorStore['logger'], 'warn');
1217
- });
1218
-
1219
- afterEach(async () => {
1220
- warnSpy.mockRestore();
1221
- await vectorStore.deleteIndex(indexName2);
1222
- });
1223
-
1224
- const createVector = (primaryDimension: number, value: number = 1.0): number[] => {
1225
- const vector = new Array(VECTOR_DIMENSION).fill(0);
1226
- vector[primaryDimension] = value;
1227
- // Normalize the vector for cosine similarity
1228
- const magnitude = Math.sqrt(vector.reduce((sum, val) => sum + val * val, 0));
1229
- return vector.map(val => val / magnitude);
1230
- };
1231
-
1232
- it('should show deprecation warning when using individual args for upsert', async () => {
1233
- await vectorStore.upsert(indexName, [createVector(0, 2)], [{ test: 'data' }]);
1234
-
1235
- expect(warnSpy).toHaveBeenCalledWith(
1236
- expect.stringContaining('Deprecation Warning: Passing individual arguments to upsert() is deprecated'),
1237
- );
1238
- });
1239
-
1240
- it('should show deprecation warning when using individual args for query', async () => {
1241
- await vectorStore.query(indexName, createVector(0, 2), 5);
1242
-
1243
- expect(warnSpy).toHaveBeenCalledWith(
1244
- expect.stringContaining('Deprecation Warning: Passing individual arguments to query() is deprecated'),
1245
- );
1246
- });
1247
-
1248
- it('should not show deprecation warning when using object param for query', async () => {
1249
- await vectorStore.query({
1250
- indexName,
1251
- queryVector: createVector(0, 2),
1252
- topK: 5,
1253
- });
1254
-
1255
- expect(warnSpy).not.toHaveBeenCalled();
1256
- });
1257
-
1258
- it('should not show deprecation warning when using object param for createIndex', async () => {
1259
- await vectorStore.createIndex({
1260
- indexName: indexName2,
1261
- dimension: 3,
1262
- metric: 'cosine',
1263
- });
1264
-
1265
- expect(warnSpy).not.toHaveBeenCalled();
1266
- });
1267
-
1268
- it('should not show deprecation warning when using object param for upsert', async () => {
1269
- await vectorStore.upsert({
1270
- indexName,
1271
- vectors: [createVector(0, 2)],
1272
- metadata: [{ test: 'data' }],
1273
- });
1274
-
1275
- expect(warnSpy).not.toHaveBeenCalled();
1276
- });
1277
-
1278
- it('should maintain backward compatibility with individual args', async () => {
1279
- // Query
1280
- const queryResults = await vectorStore.query(indexName, createVector(0, 2), 5);
1281
- expect(Array.isArray(queryResults)).toBe(true);
1282
-
1283
- // CreateIndex
1284
- await expect(vectorStore.createIndex(indexName2, 3, 'cosine')).resolves.not.toThrow();
1285
-
1286
- // Upsert
1287
- const upsertResults = await vectorStore.upsert({
1288
- indexName,
1289
- vectors: [createVector(0, 2)],
1290
- metadata: [{ test: 'data' }],
1291
- });
1292
- expect(Array.isArray(upsertResults)).toBe(true);
1293
- expect(upsertResults).toHaveLength(1);
1294
- });
1295
- });
1296
1205
  });
@@ -1,9 +1,13 @@
1
1
  import { MastraVector } from '@mastra/core/vector';
2
2
  import type {
3
3
  CreateIndexParams,
4
- ParamsToArgs,
4
+ DeleteIndexParams,
5
+ DeleteVectorParams,
6
+ DescribeIndexParams,
7
+ IndexStats,
5
8
  QueryResult,
6
9
  QueryVectorParams,
10
+ UpdateVectorParams,
7
11
  UpsertVectorParams,
8
12
  } from '@mastra/core/vector';
9
13
  import type { VectorFilter } from '@mastra/core/vector/filter';
@@ -22,11 +26,7 @@ export class UpstashVector extends MastraVector {
22
26
  });
23
27
  }
24
28
 
25
- async upsert(...args: ParamsToArgs<UpsertVectorParams>): Promise<string[]> {
26
- const params = this.normalizeArgs<UpsertVectorParams>('upsert', args);
27
-
28
- const { indexName, vectors, metadata, ids } = params;
29
-
29
+ async upsert({ indexName, vectors, metadata, ids }: UpsertVectorParams): Promise<string[]> {
30
30
  const generatedIds = ids || vectors.map(() => crypto.randomUUID());
31
31
 
32
32
  const points = vectors.map((vector, index) => ({
@@ -46,15 +46,17 @@ export class UpstashVector extends MastraVector {
46
46
  return translator.translate(filter);
47
47
  }
48
48
 
49
- async createIndex(..._args: ParamsToArgs<CreateIndexParams>): Promise<void> {
49
+ async createIndex(_params: CreateIndexParams): Promise<void> {
50
50
  console.log('No need to call createIndex for Upstash');
51
51
  }
52
52
 
53
- async query(...args: ParamsToArgs<QueryVectorParams>): Promise<QueryResult[]> {
54
- const params = this.normalizeArgs<QueryVectorParams>('query', args);
55
-
56
- const { indexName, queryVector, topK = 10, filter, includeVector = false } = params;
57
-
53
+ async query({
54
+ indexName,
55
+ queryVector,
56
+ topK = 10,
57
+ filter,
58
+ includeVector = false,
59
+ }: QueryVectorParams): Promise<QueryResult[]> {
58
60
  const ns = this.client.namespace(indexName);
59
61
 
60
62
  const filterString = this.transformFilter(filter);
@@ -80,7 +82,13 @@ export class UpstashVector extends MastraVector {
80
82
  return indexes.filter(Boolean);
81
83
  }
82
84
 
83
- async describeIndex(indexName: string) {
85
+ /**
86
+ * Retrieves statistics about a vector index.
87
+ *
88
+ * @param {string} indexName - The name of the index to describe
89
+ * @returns A promise that resolves to the index statistics including dimension, count and metric
90
+ */
91
+ async describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats> {
84
92
  const info = await this.client.info();
85
93
 
86
94
  return {
@@ -90,7 +98,7 @@ export class UpstashVector extends MastraVector {
90
98
  };
91
99
  }
92
100
 
93
- async deleteIndex(indexName: string): Promise<void> {
101
+ async deleteIndex({ indexName }: DeleteIndexParams): Promise<void> {
94
102
  try {
95
103
  await this.client.deleteNamespace(indexName);
96
104
  } catch (error) {
@@ -98,31 +106,6 @@ export class UpstashVector extends MastraVector {
98
106
  }
99
107
  }
100
108
 
101
- /**
102
- * @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
103
- *
104
- * Updates a vector by its ID with the provided vector and/or metadata.
105
- * @param indexName - The name of the index containing the vector.
106
- * @param id - The ID of the vector to update.
107
- * @param update - An object containing the vector and/or metadata to update.
108
- * @param update.vector - An optional array of numbers representing the new vector.
109
- * @param update.metadata - An optional record containing the new metadata.
110
- * @returns A promise that resolves when the update is complete.
111
- * @throws Will throw an error if no updates are provided or if the update operation fails.
112
- */
113
- async updateIndexById(
114
- indexName: string,
115
- id: string,
116
- update: { vector?: number[]; metadata?: Record<string, any> },
117
- ): Promise<void> {
118
- this.logger.warn(
119
- `Deprecation Warning: updateIndexById() is deprecated.
120
- Please use updateVector() instead.
121
- updateIndexById() will be removed on May 20th, 2025.`,
122
- );
123
- await this.updateVector(indexName, id, update);
124
- }
125
-
126
109
  /**
127
110
  * Updates a vector by its ID with the provided vector and/or metadata.
128
111
  * @param indexName - The name of the index containing the vector.
@@ -133,14 +116,7 @@ export class UpstashVector extends MastraVector {
133
116
  * @returns A promise that resolves when the update is complete.
134
117
  * @throws Will throw an error if no updates are provided or if the update operation fails.
135
118
  */
136
- async updateVector(
137
- indexName: string,
138
- id: string,
139
- update: {
140
- vector?: number[];
141
- metadata?: Record<string, any>;
142
- },
143
- ): Promise<void> {
119
+ async updateVector({ indexName, id, update }: UpdateVectorParams): Promise<void> {
144
120
  try {
145
121
  if (!update.vector && !update.metadata) {
146
122
  throw new Error('No update data provided');
@@ -174,24 +150,6 @@ export class UpstashVector extends MastraVector {
174
150
  }
175
151
  }
176
152
 
177
- /**
178
- * @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
179
- *
180
- * Deletes a vector by its ID.
181
- * @param indexName - The name of the index containing the vector.
182
- * @param id - The ID of the vector to delete.
183
- * @returns A promise that resolves when the deletion is complete.
184
- * @throws Will throw an error if the deletion operation fails.
185
- */
186
- async deleteIndexById(indexName: string, id: string): Promise<void> {
187
- this.logger.warn(
188
- `Deprecation Warning: deleteIndexById() is deprecated.
189
- Please use deleteVector() instead.
190
- deleteIndexById() will be removed on May 20th, 2025.`,
191
- );
192
- await this.deleteVector(indexName, id);
193
- }
194
-
195
153
  /**
196
154
  * Deletes a vector by its ID.
197
155
  * @param indexName - The name of the index containing the vector.
@@ -199,7 +157,7 @@ export class UpstashVector extends MastraVector {
199
157
  * @returns A promise that resolves when the deletion is complete.
200
158
  * @throws Will throw an error if the deletion operation fails.
201
159
  */
202
- async deleteVector(indexName: string, id: string): Promise<void> {
160
+ async deleteVector({ indexName, id }: DeleteVectorParams): Promise<void> {
203
161
  try {
204
162
  await this.client.delete(id, {
205
163
  namespace: indexName,