@mastra/upstash 0.3.4-alpha.2 → 0.3.4-alpha.4

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.2 build /home/runner/work/mastra/mastra/stores/upstash
2
+ > @mastra/upstash@0.3.4-alpha.4 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 9305ms
9
+ TSC ⚡️ Build success in 10315ms
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 12182ms
16
+ DTS ⚡️ Build success in 10816ms
17
17
  CLI Cleaning output folder
18
18
  ESM Build start
19
19
  CJS Build start
20
- ESM dist/index.js 28.88 KB
21
- ESM ⚡️ Build success in 1011ms
22
- CJS dist/index.cjs 29.03 KB
23
- CJS ⚡️ Build success in 1012ms
20
+ ESM dist/index.js 31.64 KB
21
+ ESM ⚡️ Build success in 1009ms
22
+ CJS dist/index.cjs 31.78 KB
23
+ CJS ⚡️ Build success in 1013ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @mastra/upstash
2
2
 
3
+ ## 0.3.4-alpha.4
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [3e9c131]
8
+ - @mastra/core@0.9.4-alpha.4
9
+
10
+ ## 0.3.4-alpha.3
11
+
12
+ ### Patch Changes
13
+
14
+ - c3bd795: [MASTRA-3358] Deprecate updateIndexById and deleteIndexById
15
+ - Updated dependencies [396be50]
16
+ - Updated dependencies [c3bd795]
17
+ - Updated dependencies [da082f8]
18
+ - Updated dependencies [a5810ce]
19
+ - @mastra/core@0.9.4-alpha.3
20
+
3
21
  ## 0.3.4-alpha.2
4
22
 
5
23
  ### Patch Changes
@@ -156,11 +156,54 @@ declare class UpstashVector extends MastraVector {
156
156
  metric: "cosine" | "euclidean" | "dotproduct";
157
157
  }>;
158
158
  deleteIndex(indexName: string): Promise<void>;
159
+ /**
160
+ * @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
161
+ *
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.
170
+ */
159
171
  updateIndexById(indexName: string, id: string, update: {
160
172
  vector?: number[];
161
173
  metadata?: Record<string, any>;
162
174
  }): Promise<void>;
175
+ /**
176
+ * Updates a vector by its ID with the provided vector and/or metadata.
177
+ * @param indexName - The name of the index containing the vector.
178
+ * @param id - The ID of the vector to update.
179
+ * @param update - An object containing the vector and/or metadata to update.
180
+ * @param update.vector - An optional array of numbers representing the new vector.
181
+ * @param update.metadata - An optional record containing the new metadata.
182
+ * @returns A promise that resolves when the update is complete.
183
+ * @throws Will throw an error if no updates are provided or if the update operation fails.
184
+ */
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
+ */
163
198
  deleteIndexById(indexName: string, id: string): Promise<void>;
199
+ /**
200
+ * Deletes a vector by its ID.
201
+ * @param indexName - The name of the index containing the vector.
202
+ * @param id - The ID of the vector to delete.
203
+ * @returns A promise that resolves when the deletion is complete.
204
+ * @throws Will throw an error if the deletion operation fails.
205
+ */
206
+ deleteVector(indexName: string, id: string): Promise<void>;
164
207
  }
165
208
  export { UpstashVector }
166
209
  export { UpstashVector as UpstashVector_alias_1 }
@@ -156,11 +156,54 @@ declare class UpstashVector extends MastraVector {
156
156
  metric: "cosine" | "euclidean" | "dotproduct";
157
157
  }>;
158
158
  deleteIndex(indexName: string): Promise<void>;
159
+ /**
160
+ * @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
161
+ *
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.
170
+ */
159
171
  updateIndexById(indexName: string, id: string, update: {
160
172
  vector?: number[];
161
173
  metadata?: Record<string, any>;
162
174
  }): Promise<void>;
175
+ /**
176
+ * Updates a vector by its ID with the provided vector and/or metadata.
177
+ * @param indexName - The name of the index containing the vector.
178
+ * @param id - The ID of the vector to update.
179
+ * @param update - An object containing the vector and/or metadata to update.
180
+ * @param update.vector - An optional array of numbers representing the new vector.
181
+ * @param update.metadata - An optional record containing the new metadata.
182
+ * @returns A promise that resolves when the update is complete.
183
+ * @throws Will throw an error if no updates are provided or if the update operation fails.
184
+ */
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
+ */
163
198
  deleteIndexById(indexName: string, id: string): Promise<void>;
199
+ /**
200
+ * Deletes a vector by its ID.
201
+ * @param indexName - The name of the index containing the vector.
202
+ * @param id - The ID of the vector to delete.
203
+ * @returns A promise that resolves when the deletion is complete.
204
+ * @throws Will throw an error if the deletion operation fails.
205
+ */
206
+ deleteVector(indexName: string, id: string): Promise<void>;
164
207
  }
165
208
  export { UpstashVector }
166
209
  export { UpstashVector as UpstashVector_alias_1 }
package/dist/index.cjs CHANGED
@@ -734,36 +734,94 @@ var UpstashVector = class extends vector.MastraVector {
734
734
  console.error("Failed to delete namespace:", error);
735
735
  }
736
736
  }
737
+ /**
738
+ * @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
739
+ *
740
+ * Updates a vector by its ID with the provided vector and/or metadata.
741
+ * @param indexName - The name of the index containing the vector.
742
+ * @param id - The ID of the vector to update.
743
+ * @param update - An object containing the vector and/or metadata to update.
744
+ * @param update.vector - An optional array of numbers representing the new vector.
745
+ * @param update.metadata - An optional record containing the new metadata.
746
+ * @returns A promise that resolves when the update is complete.
747
+ * @throws Will throw an error if no updates are provided or if the update operation fails.
748
+ */
737
749
  async updateIndexById(indexName, id, update) {
738
- if (!update.vector && !update.metadata) {
739
- throw new Error("No update data provided");
740
- }
741
- if (!update.vector && update.metadata) {
742
- throw new Error("Both vector and metadata must be provided for an update");
743
- }
744
- const updatePayload = { id };
745
- if (update.vector) {
746
- updatePayload.vector = update.vector;
747
- }
748
- if (update.metadata) {
749
- updatePayload.metadata = update.metadata;
750
- }
751
- const points = {
752
- id: updatePayload.id,
753
- vector: updatePayload.vector,
754
- metadata: updatePayload.metadata
755
- };
756
- await this.client.upsert(points, {
757
- namespace: indexName
758
- });
759
- }
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) {
768
+ try {
769
+ if (!update.vector && !update.metadata) {
770
+ throw new Error("No update data provided");
771
+ }
772
+ if (!update.vector && update.metadata) {
773
+ throw new Error("Both vector and metadata must be provided for an update");
774
+ }
775
+ const updatePayload = { id };
776
+ if (update.vector) {
777
+ updatePayload.vector = update.vector;
778
+ }
779
+ if (update.metadata) {
780
+ updatePayload.metadata = update.metadata;
781
+ }
782
+ const points = {
783
+ id: updatePayload.id,
784
+ vector: updatePayload.vector,
785
+ metadata: updatePayload.metadata
786
+ };
787
+ await this.client.upsert(points, {
788
+ namespace: indexName
789
+ });
790
+ } catch (error) {
791
+ throw new Error(`Failed to update vector by id: ${id} for index name: ${indexName}: ${error.message}`);
792
+ }
793
+ }
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
+ */
760
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
+ /**
812
+ * Deletes a vector by its ID.
813
+ * @param indexName - The name of the index containing the vector.
814
+ * @param id - The ID of the vector to delete.
815
+ * @returns A promise that resolves when the deletion is complete.
816
+ * @throws Will throw an error if the deletion operation fails.
817
+ */
818
+ async deleteVector(indexName, id) {
761
819
  try {
762
820
  await this.client.delete(id, {
763
821
  namespace: indexName
764
822
  });
765
823
  } catch (error) {
766
- console.error("Failed to delete index by ID:", error);
824
+ console.error(`Failed to delete vector by id: ${id} for index name: ${indexName}:`, error);
767
825
  }
768
826
  }
769
827
  };
package/dist/index.js CHANGED
@@ -732,36 +732,94 @@ var UpstashVector = class extends MastraVector {
732
732
  console.error("Failed to delete namespace:", error);
733
733
  }
734
734
  }
735
+ /**
736
+ * @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
737
+ *
738
+ * Updates a vector by its ID with the provided vector and/or metadata.
739
+ * @param indexName - The name of the index containing the vector.
740
+ * @param id - The ID of the vector to update.
741
+ * @param update - An object containing the vector and/or metadata to update.
742
+ * @param update.vector - An optional array of numbers representing the new vector.
743
+ * @param update.metadata - An optional record containing the new metadata.
744
+ * @returns A promise that resolves when the update is complete.
745
+ * @throws Will throw an error if no updates are provided or if the update operation fails.
746
+ */
735
747
  async updateIndexById(indexName, id, update) {
736
- if (!update.vector && !update.metadata) {
737
- throw new Error("No update data provided");
738
- }
739
- if (!update.vector && update.metadata) {
740
- throw new Error("Both vector and metadata must be provided for an update");
741
- }
742
- const updatePayload = { id };
743
- if (update.vector) {
744
- updatePayload.vector = update.vector;
745
- }
746
- if (update.metadata) {
747
- updatePayload.metadata = update.metadata;
748
- }
749
- const points = {
750
- id: updatePayload.id,
751
- vector: updatePayload.vector,
752
- metadata: updatePayload.metadata
753
- };
754
- await this.client.upsert(points, {
755
- namespace: indexName
756
- });
757
- }
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) {
766
+ try {
767
+ if (!update.vector && !update.metadata) {
768
+ throw new Error("No update data provided");
769
+ }
770
+ if (!update.vector && update.metadata) {
771
+ throw new Error("Both vector and metadata must be provided for an update");
772
+ }
773
+ const updatePayload = { id };
774
+ if (update.vector) {
775
+ updatePayload.vector = update.vector;
776
+ }
777
+ if (update.metadata) {
778
+ updatePayload.metadata = update.metadata;
779
+ }
780
+ const points = {
781
+ id: updatePayload.id,
782
+ vector: updatePayload.vector,
783
+ metadata: updatePayload.metadata
784
+ };
785
+ await this.client.upsert(points, {
786
+ namespace: indexName
787
+ });
788
+ } catch (error) {
789
+ throw new Error(`Failed to update vector by id: ${id} for index name: ${indexName}: ${error.message}`);
790
+ }
791
+ }
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
+ */
758
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
+ /**
810
+ * Deletes a vector by its ID.
811
+ * @param indexName - The name of the index containing the vector.
812
+ * @param id - The ID of the vector to delete.
813
+ * @returns A promise that resolves when the deletion is complete.
814
+ * @throws Will throw an error if the deletion operation fails.
815
+ */
816
+ async deleteVector(indexName, id) {
759
817
  try {
760
818
  await this.client.delete(id, {
761
819
  namespace: indexName
762
820
  });
763
821
  } catch (error) {
764
- console.error("Failed to delete index by ID:", error);
822
+ console.error(`Failed to delete vector by id: ${id} for index name: ${indexName}:`, error);
765
823
  }
766
824
  }
767
825
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/upstash",
3
- "version": "0.3.4-alpha.2",
3
+ "version": "0.3.4-alpha.4",
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-alpha.2"
25
+ "@mastra/core": "^0.9.4-alpha.4"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@microsoft/api-extractor": "^7.52.5",
@@ -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.updateIndexById(testIndexName, idToBeUpdated, update);
143
+ await vectorStore.updateVector(testIndexName, 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.updateIndexById(testIndexName, 'id', update)).rejects.toThrow(
170
+ await expect(vectorStore.updateVector(testIndexName, '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.updateIndexById(testIndexName, idToBeUpdated, update);
186
+ await vectorStore.updateVector(testIndexName, idToBeUpdated, update);
187
187
 
188
188
  await waitUntilVectorsIndexed(vectorStore, testIndexName, 3);
189
189
 
@@ -198,7 +198,7 @@ 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.updateIndexById(testIndexName, 'id', {})).rejects.toThrow('No update data provided');
201
+ await expect(vectorStore.updateVector(testIndexName, 'id', {})).rejects.toThrow('No update data provided');
202
202
  });
203
203
  });
204
204
 
@@ -214,7 +214,7 @@ describe.skipIf(!process.env.UPSTASH_VECTOR_URL || !process.env.UPSTASH_VECTOR_T
214
214
  expect(ids).toHaveLength(3);
215
215
  const idToBeDeleted = ids[0];
216
216
 
217
- await vectorStore.deleteIndexById(testIndexName, idToBeDeleted);
217
+ await vectorStore.deleteVector(testIndexName, idToBeDeleted);
218
218
 
219
219
  const results: QueryResult[] = await vectorStore.query({
220
220
  indexName: testIndexName,
@@ -98,7 +98,42 @@ export class UpstashVector extends MastraVector {
98
98
  }
99
99
  }
100
100
 
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
+ */
101
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
+ /**
127
+ * Updates a vector by its ID with the provided vector and/or metadata.
128
+ * @param indexName - The name of the index containing the vector.
129
+ * @param id - The ID of the vector to update.
130
+ * @param update - An object containing the vector and/or metadata to update.
131
+ * @param update.vector - An optional array of numbers representing the new vector.
132
+ * @param update.metadata - An optional record containing the new metadata.
133
+ * @returns A promise that resolves when the update is complete.
134
+ * @throws Will throw an error if no updates are provided or if the update operation fails.
135
+ */
136
+ async updateVector(
102
137
  indexName: string,
103
138
  id: string,
104
139
  update: {
@@ -106,42 +141,71 @@ export class UpstashVector extends MastraVector {
106
141
  metadata?: Record<string, any>;
107
142
  },
108
143
  ): Promise<void> {
109
- if (!update.vector && !update.metadata) {
110
- throw new Error('No update data provided');
111
- }
112
-
113
- // The upstash client throws an exception as: 'This index requires dense vectors' when
114
- // only metadata is present in the update object.
115
- if (!update.vector && update.metadata) {
116
- throw new Error('Both vector and metadata must be provided for an update');
117
- }
118
-
119
- const updatePayload: any = { id: id };
120
- if (update.vector) {
121
- updatePayload.vector = update.vector;
122
- }
123
- if (update.metadata) {
124
- updatePayload.metadata = update.metadata;
144
+ try {
145
+ if (!update.vector && !update.metadata) {
146
+ throw new Error('No update data provided');
147
+ }
148
+
149
+ // The upstash client throws an exception as: 'This index requires dense vectors' when
150
+ // only metadata is present in the update object.
151
+ if (!update.vector && update.metadata) {
152
+ throw new Error('Both vector and metadata must be provided for an update');
153
+ }
154
+
155
+ const updatePayload: any = { id: id };
156
+ if (update.vector) {
157
+ updatePayload.vector = update.vector;
158
+ }
159
+ if (update.metadata) {
160
+ updatePayload.metadata = update.metadata;
161
+ }
162
+
163
+ const points = {
164
+ id: updatePayload.id,
165
+ vector: updatePayload.vector,
166
+ metadata: updatePayload.metadata,
167
+ };
168
+
169
+ await this.client.upsert(points, {
170
+ namespace: indexName,
171
+ });
172
+ } catch (error: any) {
173
+ throw new Error(`Failed to update vector by id: ${id} for index name: ${indexName}: ${error.message}`);
125
174
  }
126
-
127
- const points = {
128
- id: updatePayload.id,
129
- vector: updatePayload.vector,
130
- metadata: updatePayload.metadata,
131
- };
132
-
133
- await this.client.upsert(points, {
134
- namespace: indexName,
135
- });
136
175
  }
137
176
 
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
+ */
138
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
+ /**
196
+ * Deletes a vector by its ID.
197
+ * @param indexName - The name of the index containing the vector.
198
+ * @param id - The ID of the vector to delete.
199
+ * @returns A promise that resolves when the deletion is complete.
200
+ * @throws Will throw an error if the deletion operation fails.
201
+ */
202
+ async deleteVector(indexName: string, id: string): Promise<void> {
139
203
  try {
140
204
  await this.client.delete(id, {
141
205
  namespace: indexName,
142
206
  });
143
207
  } catch (error) {
144
- console.error('Failed to delete index by ID:', error);
208
+ console.error(`Failed to delete vector by id: ${id} for index name: ${indexName}:`, error);
145
209
  }
146
210
  }
147
211
  }