@mastra/upstash 0.3.4 → 0.3.5-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/upstash@0.3.4-alpha.4 build /home/runner/work/mastra/mastra/stores/upstash
2
+ > @mastra/upstash@0.3.5-alpha.0 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 8244ms
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 11442ms
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 32.29 KB
21
+ ESM ⚡️ Build success in 996ms
22
+ CJS dist/index.cjs 32.43 KB
23
+ CJS ⚡️ Build success in 996ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @mastra/upstash
2
2
 
3
+ ## 0.3.5-alpha.0
4
+
5
+ ### Patch Changes
6
+
7
+ - d0ee3c6: Change all public functions and constructors in vector stores to use named args and prepare to phase out positional args
8
+ - Updated dependencies [f53a6ac]
9
+ - Updated dependencies [eabdcd9]
10
+ - Updated dependencies [90be034]
11
+ - Updated dependencies [99f050a]
12
+ - Updated dependencies [d0ee3c6]
13
+ - Updated dependencies [23f258c]
14
+ - Updated dependencies [2672a05]
15
+ - @mastra/core@0.9.5-alpha.0
16
+
3
17
  ## 0.3.4
4
18
 
5
19
  ### Patch Changes
@@ -1,6 +1,10 @@
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';
@@ -12,6 +16,7 @@ import type { StorageColumn } from '@mastra/core/storage';
12
16
  import type { StorageGetMessagesArg } from '@mastra/core/storage';
13
17
  import type { StorageThreadType } from '@mastra/core/memory';
14
18
  import type { TABLE_NAMES } from '@mastra/core/storage';
19
+ import type { UpdateVectorParams } from '@mastra/core/vector';
15
20
  import type { UpsertVectorParams } from '@mastra/core/vector';
16
21
  import type { VectorFilter } from '@mastra/core/vector/filter';
17
22
  import type { WorkflowRun } from '@mastra/core/storage';
@@ -150,12 +155,15 @@ declare class UpstashVector extends MastraVector {
150
155
  createIndex(..._args: ParamsToArgs<CreateIndexParams>): Promise<void>;
151
156
  query(...args: ParamsToArgs<QueryVectorParams>): Promise<QueryResult[]>;
152
157
  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>;
158
+ /**
159
+ * Retrieves statistics about a vector index.
160
+ *
161
+ * @param params - The parameters for describing an index
162
+ * @param params.indexName - The name of the index to describe
163
+ * @returns A promise that resolves to the index statistics including dimension, count and metric
164
+ */
165
+ describeIndex(...args: ParamsToArgs<DescribeIndexParams>): Promise<IndexStats>;
166
+ deleteIndex(...args: ParamsToArgs<DeleteIndexParams>): Promise<void>;
159
167
  /**
160
168
  * @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
161
169
  *
@@ -182,10 +190,7 @@ declare class UpstashVector extends MastraVector {
182
190
  * @returns A promise that resolves when the update is complete.
183
191
  * @throws Will throw an error if no updates are provided or if the update operation fails.
184
192
  */
185
- updateVector(indexName: string, id: string, update: {
186
- vector?: number[];
187
- metadata?: Record<string, any>;
188
- }): Promise<void>;
193
+ updateVector(...args: ParamsToArgs<UpdateVectorParams>): Promise<void>;
189
194
  /**
190
195
  * @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
191
196
  *
@@ -203,7 +208,7 @@ declare class UpstashVector extends MastraVector {
203
208
  * @returns A promise that resolves when the deletion is complete.
204
209
  * @throws Will throw an error if the deletion operation fails.
205
210
  */
206
- deleteVector(indexName: string, id: string): Promise<void>;
211
+ deleteVector(...args: ParamsToArgs<DeleteVectorParams>): Promise<void>;
207
212
  }
208
213
  export { UpstashVector }
209
214
  export { UpstashVector as UpstashVector_alias_1 }
@@ -1,6 +1,10 @@
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';
@@ -12,6 +16,7 @@ import type { StorageColumn } from '@mastra/core/storage';
12
16
  import type { StorageGetMessagesArg } from '@mastra/core/storage';
13
17
  import type { StorageThreadType } from '@mastra/core/memory';
14
18
  import type { TABLE_NAMES } from '@mastra/core/storage';
19
+ import type { UpdateVectorParams } from '@mastra/core/vector';
15
20
  import type { UpsertVectorParams } from '@mastra/core/vector';
16
21
  import type { VectorFilter } from '@mastra/core/vector/filter';
17
22
  import type { WorkflowRun } from '@mastra/core/storage';
@@ -150,12 +155,15 @@ declare class UpstashVector extends MastraVector {
150
155
  createIndex(..._args: ParamsToArgs<CreateIndexParams>): Promise<void>;
151
156
  query(...args: ParamsToArgs<QueryVectorParams>): Promise<QueryResult[]>;
152
157
  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>;
158
+ /**
159
+ * Retrieves statistics about a vector index.
160
+ *
161
+ * @param params - The parameters for describing an index
162
+ * @param params.indexName - The name of the index to describe
163
+ * @returns A promise that resolves to the index statistics including dimension, count and metric
164
+ */
165
+ describeIndex(...args: ParamsToArgs<DescribeIndexParams>): Promise<IndexStats>;
166
+ deleteIndex(...args: ParamsToArgs<DeleteIndexParams>): Promise<void>;
159
167
  /**
160
168
  * @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
161
169
  *
@@ -182,10 +190,7 @@ declare class UpstashVector extends MastraVector {
182
190
  * @returns A promise that resolves when the update is complete.
183
191
  * @throws Will throw an error if no updates are provided or if the update operation fails.
184
192
  */
185
- updateVector(indexName: string, id: string, update: {
186
- vector?: number[];
187
- metadata?: Record<string, any>;
188
- }): Promise<void>;
193
+ updateVector(...args: ParamsToArgs<UpdateVectorParams>): Promise<void>;
189
194
  /**
190
195
  * @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
191
196
  *
@@ -203,7 +208,7 @@ declare class UpstashVector extends MastraVector {
203
208
  * @returns A promise that resolves when the deletion is complete.
204
209
  * @throws Will throw an error if the deletion operation fails.
205
210
  */
206
- deleteVector(indexName: string, id: string): Promise<void>;
211
+ deleteVector(...args: ParamsToArgs<DeleteVectorParams>): Promise<void>;
207
212
  }
208
213
  export { UpstashVector }
209
214
  export { UpstashVector as UpstashVector_alias_1 }
package/dist/index.cjs CHANGED
@@ -719,7 +719,16 @@ var UpstashVector = class extends vector.MastraVector {
719
719
  const indexes = await this.client.listNamespaces();
720
720
  return indexes.filter(Boolean);
721
721
  }
722
- async describeIndex(indexName) {
722
+ /**
723
+ * Retrieves statistics about a vector index.
724
+ *
725
+ * @param params - The parameters for describing an index
726
+ * @param params.indexName - The name of the index to describe
727
+ * @returns A promise that resolves to the index statistics including dimension, count and metric
728
+ */
729
+ async describeIndex(...args) {
730
+ const params = this.normalizeArgs("describeIndex", args);
731
+ const { indexName } = params;
723
732
  const info = await this.client.info();
724
733
  return {
725
734
  dimension: info.dimension,
@@ -727,7 +736,9 @@ var UpstashVector = class extends vector.MastraVector {
727
736
  metric: info?.similarityFunction?.toLowerCase()
728
737
  };
729
738
  }
730
- async deleteIndex(indexName) {
739
+ async deleteIndex(...args) {
740
+ const params = this.normalizeArgs("deleteIndex", args);
741
+ const { indexName } = params;
731
742
  try {
732
743
  await this.client.deleteNamespace(indexName);
733
744
  } catch (error) {
@@ -752,7 +763,7 @@ var UpstashVector = class extends vector.MastraVector {
752
763
  Please use updateVector() instead.
753
764
  updateIndexById() will be removed on May 20th, 2025.`
754
765
  );
755
- await this.updateVector(indexName, id, update);
766
+ await this.updateVector({ indexName, id, update });
756
767
  }
757
768
  /**
758
769
  * Updates a vector by its ID with the provided vector and/or metadata.
@@ -764,7 +775,9 @@ var UpstashVector = class extends vector.MastraVector {
764
775
  * @returns A promise that resolves when the update is complete.
765
776
  * @throws Will throw an error if no updates are provided or if the update operation fails.
766
777
  */
767
- async updateVector(indexName, id, update) {
778
+ async updateVector(...args) {
779
+ const params = this.normalizeArgs("updateVector", args);
780
+ const { indexName, id, update } = params;
768
781
  try {
769
782
  if (!update.vector && !update.metadata) {
770
783
  throw new Error("No update data provided");
@@ -806,7 +819,7 @@ var UpstashVector = class extends vector.MastraVector {
806
819
  Please use deleteVector() instead.
807
820
  deleteIndexById() will be removed on May 20th, 2025.`
808
821
  );
809
- await this.deleteVector(indexName, id);
822
+ await this.deleteVector({ indexName, id });
810
823
  }
811
824
  /**
812
825
  * Deletes a vector by its ID.
@@ -815,7 +828,9 @@ var UpstashVector = class extends vector.MastraVector {
815
828
  * @returns A promise that resolves when the deletion is complete.
816
829
  * @throws Will throw an error if the deletion operation fails.
817
830
  */
818
- async deleteVector(indexName, id) {
831
+ async deleteVector(...args) {
832
+ const params = this.normalizeArgs("deleteVector", args);
833
+ const { indexName, id } = params;
819
834
  try {
820
835
  await this.client.delete(id, {
821
836
  namespace: indexName
package/dist/index.js CHANGED
@@ -717,7 +717,16 @@ var UpstashVector = class extends MastraVector {
717
717
  const indexes = await this.client.listNamespaces();
718
718
  return indexes.filter(Boolean);
719
719
  }
720
- async describeIndex(indexName) {
720
+ /**
721
+ * Retrieves statistics about a vector index.
722
+ *
723
+ * @param params - The parameters for describing an index
724
+ * @param params.indexName - The name of the index to describe
725
+ * @returns A promise that resolves to the index statistics including dimension, count and metric
726
+ */
727
+ async describeIndex(...args) {
728
+ const params = this.normalizeArgs("describeIndex", args);
729
+ const { indexName } = params;
721
730
  const info = await this.client.info();
722
731
  return {
723
732
  dimension: info.dimension,
@@ -725,7 +734,9 @@ var UpstashVector = class extends MastraVector {
725
734
  metric: info?.similarityFunction?.toLowerCase()
726
735
  };
727
736
  }
728
- async deleteIndex(indexName) {
737
+ async deleteIndex(...args) {
738
+ const params = this.normalizeArgs("deleteIndex", args);
739
+ const { indexName } = params;
729
740
  try {
730
741
  await this.client.deleteNamespace(indexName);
731
742
  } catch (error) {
@@ -750,7 +761,7 @@ var UpstashVector = class extends MastraVector {
750
761
  Please use updateVector() instead.
751
762
  updateIndexById() will be removed on May 20th, 2025.`
752
763
  );
753
- await this.updateVector(indexName, id, update);
764
+ await this.updateVector({ indexName, id, update });
754
765
  }
755
766
  /**
756
767
  * Updates a vector by its ID with the provided vector and/or metadata.
@@ -762,7 +773,9 @@ var UpstashVector = class extends MastraVector {
762
773
  * @returns A promise that resolves when the update is complete.
763
774
  * @throws Will throw an error if no updates are provided or if the update operation fails.
764
775
  */
765
- async updateVector(indexName, id, update) {
776
+ async updateVector(...args) {
777
+ const params = this.normalizeArgs("updateVector", args);
778
+ const { indexName, id, update } = params;
766
779
  try {
767
780
  if (!update.vector && !update.metadata) {
768
781
  throw new Error("No update data provided");
@@ -804,7 +817,7 @@ var UpstashVector = class extends MastraVector {
804
817
  Please use deleteVector() instead.
805
818
  deleteIndexById() will be removed on May 20th, 2025.`
806
819
  );
807
- await this.deleteVector(indexName, id);
820
+ await this.deleteVector({ indexName, id });
808
821
  }
809
822
  /**
810
823
  * Deletes a vector by its ID.
@@ -813,7 +826,9 @@ var UpstashVector = class extends MastraVector {
813
826
  * @returns A promise that resolves when the deletion is complete.
814
827
  * @throws Will throw an error if the deletion operation fails.
815
828
  */
816
- async deleteVector(indexName, id) {
829
+ async deleteVector(...args) {
830
+ const params = this.normalizeArgs("deleteVector", args);
831
+ const { indexName, id } = params;
817
832
  try {
818
833
  await this.client.delete(id, {
819
834
  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.3.5-alpha.0",
4
4
  "description": "Upstash provider for Mastra - includes both vector and db storage capabilities",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -22,7 +22,7 @@
22
22
  "dependencies": {
23
23
  "@upstash/redis": "^1.34.5",
24
24
  "@upstash/vector": "^1.2.1",
25
- "@mastra/core": "^0.9.4"
25
+ "@mastra/core": "^0.9.5-alpha.0"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@microsoft/api-extractor": "^7.52.5",
@@ -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 () => {
@@ -1208,8 +1210,8 @@ describe.skipIf(!process.env.UPSTASH_VECTOR_URL || !process.env.UPSTASH_VECTOR_T
1208
1210
  let warnSpy;
1209
1211
 
1210
1212
  afterAll(async () => {
1211
- await vectorStore.deleteIndex(indexName);
1212
- await vectorStore.deleteIndex(indexName2);
1213
+ await vectorStore.deleteIndex({ indexName });
1214
+ await vectorStore.deleteIndex({ indexName: indexName2 });
1213
1215
  });
1214
1216
 
1215
1217
  beforeEach(async () => {
@@ -1218,7 +1220,7 @@ describe.skipIf(!process.env.UPSTASH_VECTOR_URL || !process.env.UPSTASH_VECTOR_T
1218
1220
 
1219
1221
  afterEach(async () => {
1220
1222
  warnSpy.mockRestore();
1221
- await vectorStore.deleteIndex(indexName2);
1223
+ await vectorStore.deleteIndex({ indexName: indexName2 });
1222
1224
  });
1223
1225
 
1224
1226
  const createVector = (primaryDimension: number, value: number = 1.0): number[] => {
@@ -1,9 +1,14 @@
1
1
  import { MastraVector } from '@mastra/core/vector';
2
2
  import type {
3
3
  CreateIndexParams,
4
+ DeleteIndexParams,
5
+ DeleteVectorParams,
6
+ DescribeIndexParams,
7
+ IndexStats,
4
8
  ParamsToArgs,
5
9
  QueryResult,
6
10
  QueryVectorParams,
11
+ UpdateVectorParams,
7
12
  UpsertVectorParams,
8
13
  } from '@mastra/core/vector';
9
14
  import type { VectorFilter } from '@mastra/core/vector/filter';
@@ -80,7 +85,16 @@ export class UpstashVector extends MastraVector {
80
85
  return indexes.filter(Boolean);
81
86
  }
82
87
 
83
- async describeIndex(indexName: string) {
88
+ /**
89
+ * Retrieves statistics about a vector index.
90
+ *
91
+ * @param params - The parameters for describing an index
92
+ * @param params.indexName - The name of the index to describe
93
+ * @returns A promise that resolves to the index statistics including dimension, count and metric
94
+ */
95
+ async describeIndex(...args: ParamsToArgs<DescribeIndexParams>): Promise<IndexStats> {
96
+ const params = this.normalizeArgs<DescribeIndexParams>('describeIndex', args);
97
+ const { indexName } = params;
84
98
  const info = await this.client.info();
85
99
 
86
100
  return {
@@ -90,7 +104,9 @@ export class UpstashVector extends MastraVector {
90
104
  };
91
105
  }
92
106
 
93
- async deleteIndex(indexName: string): Promise<void> {
107
+ async deleteIndex(...args: ParamsToArgs<DeleteIndexParams>): Promise<void> {
108
+ const params = this.normalizeArgs<DeleteIndexParams>('deleteIndex', args);
109
+ const { indexName } = params;
94
110
  try {
95
111
  await this.client.deleteNamespace(indexName);
96
112
  } catch (error) {
@@ -120,7 +136,7 @@ export class UpstashVector extends MastraVector {
120
136
  Please use updateVector() instead.
121
137
  updateIndexById() will be removed on May 20th, 2025.`,
122
138
  );
123
- await this.updateVector(indexName, id, update);
139
+ await this.updateVector({ indexName, id, update });
124
140
  }
125
141
 
126
142
  /**
@@ -133,14 +149,9 @@ export class UpstashVector extends MastraVector {
133
149
  * @returns A promise that resolves when the update is complete.
134
150
  * @throws Will throw an error if no updates are provided or if the update operation fails.
135
151
  */
136
- async updateVector(
137
- indexName: string,
138
- id: string,
139
- update: {
140
- vector?: number[];
141
- metadata?: Record<string, any>;
142
- },
143
- ): Promise<void> {
152
+ async updateVector(...args: ParamsToArgs<UpdateVectorParams>): Promise<void> {
153
+ const params = this.normalizeArgs<UpdateVectorParams>('updateVector', args);
154
+ const { indexName, id, update } = params;
144
155
  try {
145
156
  if (!update.vector && !update.metadata) {
146
157
  throw new Error('No update data provided');
@@ -189,7 +200,7 @@ export class UpstashVector extends MastraVector {
189
200
  Please use deleteVector() instead.
190
201
  deleteIndexById() will be removed on May 20th, 2025.`,
191
202
  );
192
- await this.deleteVector(indexName, id);
203
+ await this.deleteVector({ indexName, id });
193
204
  }
194
205
 
195
206
  /**
@@ -199,7 +210,9 @@ export class UpstashVector extends MastraVector {
199
210
  * @returns A promise that resolves when the deletion is complete.
200
211
  * @throws Will throw an error if the deletion operation fails.
201
212
  */
202
- async deleteVector(indexName: string, id: string): Promise<void> {
213
+ async deleteVector(...args: ParamsToArgs<DeleteVectorParams>): Promise<void> {
214
+ const params = this.normalizeArgs<DeleteVectorParams>('deleteVector', args);
215
+ const { indexName, id } = params;
203
216
  try {
204
217
  await this.client.delete(id, {
205
218
  namespace: indexName,