@mastra/opensearch 0.1.1-alpha.2 → 0.1.1-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/opensearch@0.1.1-alpha.2 build /home/runner/work/mastra/mastra/stores/opensearch
2
+ > @mastra/opensearch@0.1.1-alpha.4 build /home/runner/work/mastra/mastra/stores/opensearch
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 11556ms
9
+ TSC ⚡️ Build success in 9556ms
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/opensearch/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/opensearch/dist/_tsup-dts-rollup.d.cts
16
- DTS ⚡️ Build success in 11669ms
16
+ DTS ⚡️ Build success in 10879ms
17
17
  CLI Cleaning output folder
18
18
  ESM Build start
19
19
  CJS Build start
20
- CJS dist/index.cjs 21.37 KB
21
- CJS ⚡️ Build success in 915ms
22
- ESM dist/index.js 21.32 KB
23
- ESM ⚡️ Build success in 928ms
20
+ ESM dist/index.js 23.06 KB
21
+ ESM ⚡️ Build success in 1008ms
22
+ CJS dist/index.cjs 23.10 KB
23
+ CJS ⚡️ Build success in 1007ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @mastra/opensearch
2
2
 
3
+ ## 0.1.1-alpha.4
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [3e9c131]
8
+ - @mastra/core@0.9.4-alpha.4
9
+
10
+ ## 0.1.1-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.1.1-alpha.2
4
22
 
5
23
  ### Patch Changes
@@ -111,27 +111,53 @@ declare class OpenSearchVector extends MastraVector {
111
111
  */
112
112
  private transformFilter;
113
113
  /**
114
- * Updates a specific document in the index by ID.
114
+ * @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
115
115
  *
116
- * @param {string} indexName - The name of the index containing the document.
117
- * @param {string} id - The ID of the document to update.
118
- * @param {Object} update - The update to apply to the document.
119
- * @param {number[]} [update.vector] - Optional new vector to update.
120
- * @param {Record<string, any>} [update.metadata] - Optional new metadata to update.
121
- * @returns {Promise<void>} A promise that resolves when the document is updated.
116
+ * Updates a vector by its ID with the provided vector and/or metadata.
117
+ * @param indexName - The name of the index containing the vector.
118
+ * @param id - The ID of the vector to update.
119
+ * @param update - An object containing the vector and/or metadata to update.
120
+ * @param update.vector - An optional array of numbers representing the new vector.
121
+ * @param update.metadata - An optional record containing the new metadata.
122
+ * @returns A promise that resolves when the update is complete.
123
+ * @throws Will throw an error if no updates are provided or if the update operation fails.
122
124
  */
123
125
  updateIndexById(indexName: string, id: string, update: {
124
126
  vector?: number[];
125
127
  metadata?: Record<string, any>;
126
128
  }): Promise<void>;
127
129
  /**
128
- * Deletes a specific document from the index by ID.
130
+ * Updates a vector by its ID with the provided vector and/or metadata.
131
+ * @param indexName - The name of the index containing the vector.
132
+ * @param id - The ID of the vector to update.
133
+ * @param update - An object containing the vector and/or metadata to update.
134
+ * @param update.vector - An optional array of numbers representing the new vector.
135
+ * @param update.metadata - An optional record containing the new metadata.
136
+ * @returns A promise that resolves when the update is complete.
137
+ * @throws Will throw an error if no updates are provided or if the update operation fails.
138
+ */
139
+ updateVector(indexName: string, id: string, update: {
140
+ vector?: number[];
141
+ metadata?: Record<string, any>;
142
+ }): Promise<void>;
143
+ /**
144
+ * @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
129
145
  *
130
- * @param {string} indexName - The name of the index containing the document.
131
- * @param {string} id - The ID of the document to delete.
132
- * @returns {Promise<void>} A promise that resolves when the document is deleted.
146
+ * Deletes a vector by its ID.
147
+ * @param indexName - The name of the index containing the vector.
148
+ * @param id - The ID of the vector to delete.
149
+ * @returns A promise that resolves when the deletion is complete.
150
+ * @throws Will throw an error if the deletion operation fails.
133
151
  */
134
152
  deleteIndexById(indexName: string, id: string): Promise<void>;
153
+ /**
154
+ * Deletes a vector by its ID.
155
+ * @param indexName - The name of the index containing the vector.
156
+ * @param id - The ID of the vector to delete.
157
+ * @returns A promise that resolves when the deletion is complete.
158
+ * @throws Will throw an error if the deletion operation fails.
159
+ */
160
+ deleteVector(indexName: string, id: string): Promise<void>;
135
161
  }
136
162
  export { OpenSearchVector }
137
163
  export { OpenSearchVector as OpenSearchVector_alias_1 }
@@ -111,27 +111,53 @@ declare class OpenSearchVector extends MastraVector {
111
111
  */
112
112
  private transformFilter;
113
113
  /**
114
- * Updates a specific document in the index by ID.
114
+ * @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
115
115
  *
116
- * @param {string} indexName - The name of the index containing the document.
117
- * @param {string} id - The ID of the document to update.
118
- * @param {Object} update - The update to apply to the document.
119
- * @param {number[]} [update.vector] - Optional new vector to update.
120
- * @param {Record<string, any>} [update.metadata] - Optional new metadata to update.
121
- * @returns {Promise<void>} A promise that resolves when the document is updated.
116
+ * Updates a vector by its ID with the provided vector and/or metadata.
117
+ * @param indexName - The name of the index containing the vector.
118
+ * @param id - The ID of the vector to update.
119
+ * @param update - An object containing the vector and/or metadata to update.
120
+ * @param update.vector - An optional array of numbers representing the new vector.
121
+ * @param update.metadata - An optional record containing the new metadata.
122
+ * @returns A promise that resolves when the update is complete.
123
+ * @throws Will throw an error if no updates are provided or if the update operation fails.
122
124
  */
123
125
  updateIndexById(indexName: string, id: string, update: {
124
126
  vector?: number[];
125
127
  metadata?: Record<string, any>;
126
128
  }): Promise<void>;
127
129
  /**
128
- * Deletes a specific document from the index by ID.
130
+ * Updates a vector by its ID with the provided vector and/or metadata.
131
+ * @param indexName - The name of the index containing the vector.
132
+ * @param id - The ID of the vector to update.
133
+ * @param update - An object containing the vector and/or metadata to update.
134
+ * @param update.vector - An optional array of numbers representing the new vector.
135
+ * @param update.metadata - An optional record containing the new metadata.
136
+ * @returns A promise that resolves when the update is complete.
137
+ * @throws Will throw an error if no updates are provided or if the update operation fails.
138
+ */
139
+ updateVector(indexName: string, id: string, update: {
140
+ vector?: number[];
141
+ metadata?: Record<string, any>;
142
+ }): Promise<void>;
143
+ /**
144
+ * @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
129
145
  *
130
- * @param {string} indexName - The name of the index containing the document.
131
- * @param {string} id - The ID of the document to delete.
132
- * @returns {Promise<void>} A promise that resolves when the document is deleted.
146
+ * Deletes a vector by its ID.
147
+ * @param indexName - The name of the index containing the vector.
148
+ * @param id - The ID of the vector to delete.
149
+ * @returns A promise that resolves when the deletion is complete.
150
+ * @throws Will throw an error if the deletion operation fails.
133
151
  */
134
152
  deleteIndexById(indexName: string, id: string): Promise<void>;
153
+ /**
154
+ * Deletes a vector by its ID.
155
+ * @param indexName - The name of the index containing the vector.
156
+ * @param id - The ID of the vector to delete.
157
+ * @returns A promise that resolves when the deletion is complete.
158
+ * @throws Will throw an error if the deletion operation fails.
159
+ */
160
+ deleteVector(indexName: string, id: string): Promise<void>;
135
161
  }
136
162
  export { OpenSearchVector }
137
163
  export { OpenSearchVector as OpenSearchVector_alias_1 }
package/dist/index.cjs CHANGED
@@ -558,16 +558,36 @@ var OpenSearchVector = class extends vector.MastraVector {
558
558
  return translator.translate(filter);
559
559
  }
560
560
  /**
561
- * Updates a specific document in the index by ID.
561
+ * @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
562
562
  *
563
- * @param {string} indexName - The name of the index containing the document.
564
- * @param {string} id - The ID of the document to update.
565
- * @param {Object} update - The update to apply to the document.
566
- * @param {number[]} [update.vector] - Optional new vector to update.
567
- * @param {Record<string, any>} [update.metadata] - Optional new metadata to update.
568
- * @returns {Promise<void>} A promise that resolves when the document is updated.
563
+ * Updates a vector by its ID with the provided vector and/or metadata.
564
+ * @param indexName - The name of the index containing the vector.
565
+ * @param id - The ID of the vector to update.
566
+ * @param update - An object containing the vector and/or metadata to update.
567
+ * @param update.vector - An optional array of numbers representing the new vector.
568
+ * @param update.metadata - An optional record containing the new metadata.
569
+ * @returns A promise that resolves when the update is complete.
570
+ * @throws Will throw an error if no updates are provided or if the update operation fails.
569
571
  */
570
572
  async updateIndexById(indexName, id, update) {
573
+ this.logger.warn(
574
+ `Deprecation Warning: updateIndexById() is deprecated.
575
+ Please use updateVector() instead.
576
+ updateIndexById() will be removed on May 20th, 2025.`
577
+ );
578
+ await this.updateVector(indexName, id, update);
579
+ }
580
+ /**
581
+ * Updates a vector by its ID with the provided vector and/or metadata.
582
+ * @param indexName - The name of the index containing the vector.
583
+ * @param id - The ID of the vector to update.
584
+ * @param update - An object containing the vector and/or metadata to update.
585
+ * @param update.vector - An optional array of numbers representing the new vector.
586
+ * @param update.metadata - An optional record containing the new metadata.
587
+ * @returns A promise that resolves when the update is complete.
588
+ * @throws Will throw an error if no updates are provided or if the update operation fails.
589
+ */
590
+ async updateVector(indexName, id, update) {
571
591
  if (!update.vector && !update.metadata) {
572
592
  throw new Error("No updates provided");
573
593
  }
@@ -609,13 +629,30 @@ var OpenSearchVector = class extends vector.MastraVector {
609
629
  }
610
630
  }
611
631
  /**
612
- * Deletes a specific document from the index by ID.
632
+ * @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
613
633
  *
614
- * @param {string} indexName - The name of the index containing the document.
615
- * @param {string} id - The ID of the document to delete.
616
- * @returns {Promise<void>} A promise that resolves when the document is deleted.
634
+ * Deletes a vector by its ID.
635
+ * @param indexName - The name of the index containing the vector.
636
+ * @param id - The ID of the vector to delete.
637
+ * @returns A promise that resolves when the deletion is complete.
638
+ * @throws Will throw an error if the deletion operation fails.
617
639
  */
618
640
  async deleteIndexById(indexName, id) {
641
+ this.logger.warn(
642
+ `Deprecation Warning: deleteIndexById() is deprecated.
643
+ Please use deleteVector() instead.
644
+ deleteIndexById() will be removed on May 20th, 2025.`
645
+ );
646
+ await this.deleteVector(indexName, id);
647
+ }
648
+ /**
649
+ * Deletes a vector by its ID.
650
+ * @param indexName - The name of the index containing the vector.
651
+ * @param id - The ID of the vector to delete.
652
+ * @returns A promise that resolves when the deletion is complete.
653
+ * @throws Will throw an error if the deletion operation fails.
654
+ */
655
+ async deleteVector(indexName, id) {
619
656
  try {
620
657
  await this.client.delete({
621
658
  index: indexName,
package/dist/index.js CHANGED
@@ -556,16 +556,36 @@ var OpenSearchVector = class extends MastraVector {
556
556
  return translator.translate(filter);
557
557
  }
558
558
  /**
559
- * Updates a specific document in the index by ID.
559
+ * @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
560
560
  *
561
- * @param {string} indexName - The name of the index containing the document.
562
- * @param {string} id - The ID of the document to update.
563
- * @param {Object} update - The update to apply to the document.
564
- * @param {number[]} [update.vector] - Optional new vector to update.
565
- * @param {Record<string, any>} [update.metadata] - Optional new metadata to update.
566
- * @returns {Promise<void>} A promise that resolves when the document is updated.
561
+ * Updates a vector by its ID with the provided vector and/or metadata.
562
+ * @param indexName - The name of the index containing the vector.
563
+ * @param id - The ID of the vector to update.
564
+ * @param update - An object containing the vector and/or metadata to update.
565
+ * @param update.vector - An optional array of numbers representing the new vector.
566
+ * @param update.metadata - An optional record containing the new metadata.
567
+ * @returns A promise that resolves when the update is complete.
568
+ * @throws Will throw an error if no updates are provided or if the update operation fails.
567
569
  */
568
570
  async updateIndexById(indexName, id, update) {
571
+ this.logger.warn(
572
+ `Deprecation Warning: updateIndexById() is deprecated.
573
+ Please use updateVector() instead.
574
+ updateIndexById() will be removed on May 20th, 2025.`
575
+ );
576
+ await this.updateVector(indexName, id, update);
577
+ }
578
+ /**
579
+ * Updates a vector by its ID with the provided vector and/or metadata.
580
+ * @param indexName - The name of the index containing the vector.
581
+ * @param id - The ID of the vector to update.
582
+ * @param update - An object containing the vector and/or metadata to update.
583
+ * @param update.vector - An optional array of numbers representing the new vector.
584
+ * @param update.metadata - An optional record containing the new metadata.
585
+ * @returns A promise that resolves when the update is complete.
586
+ * @throws Will throw an error if no updates are provided or if the update operation fails.
587
+ */
588
+ async updateVector(indexName, id, update) {
569
589
  if (!update.vector && !update.metadata) {
570
590
  throw new Error("No updates provided");
571
591
  }
@@ -607,13 +627,30 @@ var OpenSearchVector = class extends MastraVector {
607
627
  }
608
628
  }
609
629
  /**
610
- * Deletes a specific document from the index by ID.
630
+ * @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
611
631
  *
612
- * @param {string} indexName - The name of the index containing the document.
613
- * @param {string} id - The ID of the document to delete.
614
- * @returns {Promise<void>} A promise that resolves when the document is deleted.
632
+ * Deletes a vector by its ID.
633
+ * @param indexName - The name of the index containing the vector.
634
+ * @param id - The ID of the vector to delete.
635
+ * @returns A promise that resolves when the deletion is complete.
636
+ * @throws Will throw an error if the deletion operation fails.
615
637
  */
616
638
  async deleteIndexById(indexName, id) {
639
+ this.logger.warn(
640
+ `Deprecation Warning: deleteIndexById() is deprecated.
641
+ Please use deleteVector() instead.
642
+ deleteIndexById() will be removed on May 20th, 2025.`
643
+ );
644
+ await this.deleteVector(indexName, id);
645
+ }
646
+ /**
647
+ * Deletes a vector by its ID.
648
+ * @param indexName - The name of the index containing the vector.
649
+ * @param id - The ID of the vector to delete.
650
+ * @returns A promise that resolves when the deletion is complete.
651
+ * @throws Will throw an error if the deletion operation fails.
652
+ */
653
+ async deleteVector(indexName, id) {
617
654
  try {
618
655
  await this.client.delete({
619
656
  index: indexName,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/opensearch",
3
- "version": "0.1.1-alpha.2",
3
+ "version": "0.1.1-alpha.4",
4
4
  "description": "OpenSearch vector store provider for Mastra",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -20,7 +20,7 @@
20
20
  },
21
21
  "dependencies": {
22
22
  "@opensearch-project/opensearch": "^3.4.0",
23
- "@mastra/core": "^0.9.4-alpha.2"
23
+ "@mastra/core": "^0.9.4-alpha.4"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@microsoft/api-extractor": "^7.52.1",
@@ -503,7 +503,7 @@ describe('OpenSearchVector', () => {
503
503
  metadata: newMetaData,
504
504
  };
505
505
 
506
- await vectorDB.updateIndexById(testIndexName, idToBeUpdated, update);
506
+ await vectorDB.updateVector(testIndexName, idToBeUpdated, update);
507
507
 
508
508
  const results: QueryResult[] = await vectorDB.query({
509
509
  indexName: testIndexName,
@@ -530,7 +530,7 @@ describe('OpenSearchVector', () => {
530
530
  metadata: newMetaData,
531
531
  };
532
532
 
533
- await vectorDB.updateIndexById(testIndexName, idToBeUpdated, update);
533
+ await vectorDB.updateVector(testIndexName, idToBeUpdated, update);
534
534
 
535
535
  const results: QueryResult[] = await vectorDB.query({
536
536
  indexName: testIndexName,
@@ -555,7 +555,7 @@ describe('OpenSearchVector', () => {
555
555
  vector: newVector,
556
556
  };
557
557
 
558
- await vectorDB.updateIndexById(testIndexName, idToBeUpdated, update);
558
+ await vectorDB.updateVector(testIndexName, idToBeUpdated, update);
559
559
 
560
560
  const results: QueryResult[] = await vectorDB.query({
561
561
  indexName: testIndexName,
@@ -569,7 +569,7 @@ describe('OpenSearchVector', () => {
569
569
  });
570
570
 
571
571
  it('should throw exception when no updates are given', async () => {
572
- await expect(vectorDB.updateIndexById(testIndexName, 'id', {})).rejects.toThrow('No updates provided');
572
+ await expect(vectorDB.updateVector(testIndexName, 'id', {})).rejects.toThrow('No updates provided');
573
573
  });
574
574
  });
575
575
 
@@ -594,7 +594,7 @@ describe('OpenSearchVector', () => {
594
594
  expect(ids).toHaveLength(3);
595
595
  const idToBeDeleted = ids[0];
596
596
 
597
- await vectorDB.deleteIndexById(testIndexName, idToBeDeleted);
597
+ await vectorDB.deleteVector(testIndexName, idToBeDeleted);
598
598
 
599
599
  const results: QueryResult[] = await vectorDB.query({
600
600
  indexName: testIndexName,
@@ -244,16 +244,41 @@ export class OpenSearchVector extends MastraVector {
244
244
  }
245
245
 
246
246
  /**
247
- * Updates a specific document in the index by ID.
247
+ * @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
248
248
  *
249
- * @param {string} indexName - The name of the index containing the document.
250
- * @param {string} id - The ID of the document to update.
251
- * @param {Object} update - The update to apply to the document.
252
- * @param {number[]} [update.vector] - Optional new vector to update.
253
- * @param {Record<string, any>} [update.metadata] - Optional new metadata to update.
254
- * @returns {Promise<void>} A promise that resolves when the document is updated.
249
+ * Updates a vector by its ID with the provided vector and/or metadata.
250
+ * @param indexName - The name of the index containing the vector.
251
+ * @param id - The ID of the vector to update.
252
+ * @param update - An object containing the vector and/or metadata to update.
253
+ * @param update.vector - An optional array of numbers representing the new vector.
254
+ * @param update.metadata - An optional record containing the new metadata.
255
+ * @returns A promise that resolves when the update is complete.
256
+ * @throws Will throw an error if no updates are provided or if the update operation fails.
255
257
  */
256
258
  async updateIndexById(
259
+ indexName: string,
260
+ id: string,
261
+ update: { vector?: number[]; metadata?: Record<string, any> },
262
+ ): Promise<void> {
263
+ this.logger.warn(
264
+ `Deprecation Warning: updateIndexById() is deprecated.
265
+ Please use updateVector() instead.
266
+ updateIndexById() will be removed on May 20th, 2025.`,
267
+ );
268
+ await this.updateVector(indexName, id, update);
269
+ }
270
+
271
+ /**
272
+ * Updates a vector by its ID with the provided vector and/or metadata.
273
+ * @param indexName - The name of the index containing the vector.
274
+ * @param id - The ID of the vector to update.
275
+ * @param update - An object containing the vector and/or metadata to update.
276
+ * @param update.vector - An optional array of numbers representing the new vector.
277
+ * @param update.metadata - An optional record containing the new metadata.
278
+ * @returns A promise that resolves when the update is complete.
279
+ * @throws Will throw an error if no updates are provided or if the update operation fails.
280
+ */
281
+ async updateVector(
257
282
  indexName: string,
258
283
  id: string,
259
284
  update: {
@@ -319,13 +344,31 @@ export class OpenSearchVector extends MastraVector {
319
344
  }
320
345
 
321
346
  /**
322
- * Deletes a specific document from the index by ID.
347
+ * @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
323
348
  *
324
- * @param {string} indexName - The name of the index containing the document.
325
- * @param {string} id - The ID of the document to delete.
326
- * @returns {Promise<void>} A promise that resolves when the document is deleted.
349
+ * Deletes a vector by its ID.
350
+ * @param indexName - The name of the index containing the vector.
351
+ * @param id - The ID of the vector to delete.
352
+ * @returns A promise that resolves when the deletion is complete.
353
+ * @throws Will throw an error if the deletion operation fails.
327
354
  */
328
355
  async deleteIndexById(indexName: string, id: string): Promise<void> {
356
+ this.logger.warn(
357
+ `Deprecation Warning: deleteIndexById() is deprecated.
358
+ Please use deleteVector() instead.
359
+ deleteIndexById() will be removed on May 20th, 2025.`,
360
+ );
361
+ await this.deleteVector(indexName, id);
362
+ }
363
+
364
+ /**
365
+ * Deletes a vector by its ID.
366
+ * @param indexName - The name of the index containing the vector.
367
+ * @param id - The ID of the vector to delete.
368
+ * @returns A promise that resolves when the deletion is complete.
369
+ * @throws Will throw an error if the deletion operation fails.
370
+ */
371
+ async deleteVector(indexName: string, id: string): Promise<void> {
329
372
  try {
330
373
  await this.client.delete({
331
374
  index: indexName,