@mastra/opensearch 0.1.1 → 0.2.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/opensearch@0.1.1-alpha.4 build /home/runner/work/mastra/mastra/stores/opensearch
2
+ > @mastra/opensearch@0.2.0-alpha.1 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 11037ms
9
+ TSC ⚡️ Build success in 10415ms
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 9888ms
16
+ DTS ⚡️ Build success in 11166ms
17
17
  CLI Cleaning output folder
18
18
  ESM Build start
19
19
  CJS Build start
20
- ESM dist/index.js 23.06 KB
21
- ESM ⚡️ Build success in 932ms
22
- CJS dist/index.cjs 23.10 KB
23
- CJS ⚡️ Build success in 941ms
20
+ ESM dist/index.js 21.72 KB
21
+ ESM ⚡️ Build success in 764ms
22
+ CJS dist/index.cjs 21.76 KB
23
+ CJS ⚡️ Build success in 763ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,40 @@
1
1
  # @mastra/opensearch
2
2
 
3
+ ## 0.2.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.1.2-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.1.1
4
39
 
5
40
  ### Patch Changes
@@ -1,10 +1,14 @@
1
1
  import { BaseFilterTranslator } from '@mastra/core/vector/filter';
2
2
  import type { CreateIndexParams } from '@mastra/core';
3
+ import type { DeleteIndexParams } from '@mastra/core';
4
+ import type { DeleteVectorParams } from '@mastra/core';
5
+ import type { DescribeIndexParams } from '@mastra/core';
3
6
  import type { IndexStats } from '@mastra/core';
4
7
  import { MastraVector } from '@mastra/core/vector';
5
8
  import type { OperatorSupport } from '@mastra/core/vector/filter';
6
9
  import type { QueryResult } from '@mastra/core';
7
10
  import type { QueryVectorParams } from '@mastra/core';
11
+ import type { UpdateVectorParams } from '@mastra/core';
8
12
  import type { UpsertVectorParams } from '@mastra/core';
9
13
  import type { VectorFilter } from '@mastra/core/vector/filter';
10
14
 
@@ -50,7 +54,14 @@ export declare class OpenSearchFilterTranslator extends BaseFilterTranslator {
50
54
 
51
55
  declare class OpenSearchVector extends MastraVector {
52
56
  private client;
53
- constructor(url: string);
57
+ /**
58
+ * Creates a new OpenSearchVector client.
59
+ *
60
+ * @param {string} url - The url of the OpenSearch node.
61
+ */
62
+ constructor({ url }: {
63
+ url: string;
64
+ });
54
65
  /**
55
66
  * Creates a new collection with the specified configuration.
56
67
  *
@@ -59,21 +70,27 @@ declare class OpenSearchVector extends MastraVector {
59
70
  * @param {'cosine' | 'euclidean' | 'dotproduct'} [metric=cosine] - The metric to use to sort vectors in the collection.
60
71
  * @returns {Promise<void>} A promise that resolves when the collection is created.
61
72
  */
62
- createIndex(params: CreateIndexParams): Promise<void>;
73
+ createIndex({ indexName, dimension, metric }: CreateIndexParams): Promise<void>;
63
74
  /**
64
75
  * Lists all indexes.
65
76
  *
66
77
  * @returns {Promise<string[]>} A promise that resolves to an array of indexes.
67
78
  */
68
79
  listIndexes(): Promise<string[]>;
69
- describeIndex(indexName: string): Promise<IndexStats>;
80
+ /**
81
+ * Retrieves statistics about a vector index.
82
+ *
83
+ * @param {string} indexName - The name of the index to describe
84
+ * @returns A promise that resolves to the index statistics including dimension, count and metric
85
+ */
86
+ describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats>;
70
87
  /**
71
88
  * Deletes the specified index.
72
89
  *
73
90
  * @param {string} indexName - The name of the index to delete.
74
91
  * @returns {Promise<void>} A promise that resolves when the index is deleted.
75
92
  */
76
- deleteIndex(indexName: string): Promise<void>;
93
+ deleteIndex({ indexName }: DeleteIndexParams): Promise<void>;
77
94
  /**
78
95
  * Inserts or updates vectors in the specified collection.
79
96
  *
@@ -83,7 +100,7 @@ declare class OpenSearchVector extends MastraVector {
83
100
  * @param {string[]} [ids] - An optional array of IDs corresponding to each vector. If not provided, new IDs will be generated.
84
101
  * @returns {Promise<string[]>} A promise that resolves to an array of IDs of the upserted vectors.
85
102
  */
86
- upsert(params: UpsertVectorParams): Promise<string[]>;
103
+ upsert({ indexName, vectors, metadata, ids }: UpsertVectorParams): Promise<string[]>;
87
104
  /**
88
105
  * Queries the specified collection using a vector and optional filter.
89
106
  *
@@ -94,7 +111,7 @@ declare class OpenSearchVector extends MastraVector {
94
111
  * @param {boolean} [includeVectors=false] - Whether to include the vectors in the response.
95
112
  * @returns {Promise<QueryResult[]>} A promise that resolves to an array of query results.
96
113
  */
97
- query(params: QueryVectorParams): Promise<QueryResult[]>;
114
+ query({ indexName, queryVector, filter, topK, includeVector, }: QueryVectorParams): Promise<QueryResult[]>;
98
115
  /**
99
116
  * Validates the dimensions of the vectors.
100
117
  *
@@ -111,8 +128,6 @@ declare class OpenSearchVector extends MastraVector {
111
128
  */
112
129
  private transformFilter;
113
130
  /**
114
- * @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
115
- *
116
131
  * Updates a vector by its ID with the provided vector and/or metadata.
117
132
  * @param indexName - The name of the index containing the vector.
118
133
  * @param id - The ID of the vector to update.
@@ -122,34 +137,7 @@ declare class OpenSearchVector extends MastraVector {
122
137
  * @returns A promise that resolves when the update is complete.
123
138
  * @throws Will throw an error if no updates are provided or if the update operation fails.
124
139
  */
125
- updateIndexById(indexName: string, id: string, update: {
126
- vector?: number[];
127
- metadata?: Record<string, any>;
128
- }): Promise<void>;
129
- /**
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.
145
- *
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.
151
- */
152
- deleteIndexById(indexName: string, id: string): Promise<void>;
140
+ updateVector({ indexName, id, update }: UpdateVectorParams): Promise<void>;
153
141
  /**
154
142
  * Deletes a vector by its ID.
155
143
  * @param indexName - The name of the index containing the vector.
@@ -157,7 +145,7 @@ declare class OpenSearchVector extends MastraVector {
157
145
  * @returns A promise that resolves when the deletion is complete.
158
146
  * @throws Will throw an error if the deletion operation fails.
159
147
  */
160
- deleteVector(indexName: string, id: string): Promise<void>;
148
+ deleteVector({ indexName, id }: DeleteVectorParams): Promise<void>;
161
149
  }
162
150
  export { OpenSearchVector }
163
151
  export { OpenSearchVector as OpenSearchVector_alias_1 }
@@ -1,10 +1,14 @@
1
1
  import { BaseFilterTranslator } from '@mastra/core/vector/filter';
2
2
  import type { CreateIndexParams } from '@mastra/core';
3
+ import type { DeleteIndexParams } from '@mastra/core';
4
+ import type { DeleteVectorParams } from '@mastra/core';
5
+ import type { DescribeIndexParams } from '@mastra/core';
3
6
  import type { IndexStats } from '@mastra/core';
4
7
  import { MastraVector } from '@mastra/core/vector';
5
8
  import type { OperatorSupport } from '@mastra/core/vector/filter';
6
9
  import type { QueryResult } from '@mastra/core';
7
10
  import type { QueryVectorParams } from '@mastra/core';
11
+ import type { UpdateVectorParams } from '@mastra/core';
8
12
  import type { UpsertVectorParams } from '@mastra/core';
9
13
  import type { VectorFilter } from '@mastra/core/vector/filter';
10
14
 
@@ -50,7 +54,14 @@ export declare class OpenSearchFilterTranslator extends BaseFilterTranslator {
50
54
 
51
55
  declare class OpenSearchVector extends MastraVector {
52
56
  private client;
53
- constructor(url: string);
57
+ /**
58
+ * Creates a new OpenSearchVector client.
59
+ *
60
+ * @param {string} url - The url of the OpenSearch node.
61
+ */
62
+ constructor({ url }: {
63
+ url: string;
64
+ });
54
65
  /**
55
66
  * Creates a new collection with the specified configuration.
56
67
  *
@@ -59,21 +70,27 @@ declare class OpenSearchVector extends MastraVector {
59
70
  * @param {'cosine' | 'euclidean' | 'dotproduct'} [metric=cosine] - The metric to use to sort vectors in the collection.
60
71
  * @returns {Promise<void>} A promise that resolves when the collection is created.
61
72
  */
62
- createIndex(params: CreateIndexParams): Promise<void>;
73
+ createIndex({ indexName, dimension, metric }: CreateIndexParams): Promise<void>;
63
74
  /**
64
75
  * Lists all indexes.
65
76
  *
66
77
  * @returns {Promise<string[]>} A promise that resolves to an array of indexes.
67
78
  */
68
79
  listIndexes(): Promise<string[]>;
69
- describeIndex(indexName: string): Promise<IndexStats>;
80
+ /**
81
+ * Retrieves statistics about a vector index.
82
+ *
83
+ * @param {string} indexName - The name of the index to describe
84
+ * @returns A promise that resolves to the index statistics including dimension, count and metric
85
+ */
86
+ describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats>;
70
87
  /**
71
88
  * Deletes the specified index.
72
89
  *
73
90
  * @param {string} indexName - The name of the index to delete.
74
91
  * @returns {Promise<void>} A promise that resolves when the index is deleted.
75
92
  */
76
- deleteIndex(indexName: string): Promise<void>;
93
+ deleteIndex({ indexName }: DeleteIndexParams): Promise<void>;
77
94
  /**
78
95
  * Inserts or updates vectors in the specified collection.
79
96
  *
@@ -83,7 +100,7 @@ declare class OpenSearchVector extends MastraVector {
83
100
  * @param {string[]} [ids] - An optional array of IDs corresponding to each vector. If not provided, new IDs will be generated.
84
101
  * @returns {Promise<string[]>} A promise that resolves to an array of IDs of the upserted vectors.
85
102
  */
86
- upsert(params: UpsertVectorParams): Promise<string[]>;
103
+ upsert({ indexName, vectors, metadata, ids }: UpsertVectorParams): Promise<string[]>;
87
104
  /**
88
105
  * Queries the specified collection using a vector and optional filter.
89
106
  *
@@ -94,7 +111,7 @@ declare class OpenSearchVector extends MastraVector {
94
111
  * @param {boolean} [includeVectors=false] - Whether to include the vectors in the response.
95
112
  * @returns {Promise<QueryResult[]>} A promise that resolves to an array of query results.
96
113
  */
97
- query(params: QueryVectorParams): Promise<QueryResult[]>;
114
+ query({ indexName, queryVector, filter, topK, includeVector, }: QueryVectorParams): Promise<QueryResult[]>;
98
115
  /**
99
116
  * Validates the dimensions of the vectors.
100
117
  *
@@ -111,8 +128,6 @@ declare class OpenSearchVector extends MastraVector {
111
128
  */
112
129
  private transformFilter;
113
130
  /**
114
- * @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
115
- *
116
131
  * Updates a vector by its ID with the provided vector and/or metadata.
117
132
  * @param indexName - The name of the index containing the vector.
118
133
  * @param id - The ID of the vector to update.
@@ -122,34 +137,7 @@ declare class OpenSearchVector extends MastraVector {
122
137
  * @returns A promise that resolves when the update is complete.
123
138
  * @throws Will throw an error if no updates are provided or if the update operation fails.
124
139
  */
125
- updateIndexById(indexName: string, id: string, update: {
126
- vector?: number[];
127
- metadata?: Record<string, any>;
128
- }): Promise<void>;
129
- /**
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.
145
- *
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.
151
- */
152
- deleteIndexById(indexName: string, id: string): Promise<void>;
140
+ updateVector({ indexName, id, update }: UpdateVectorParams): Promise<void>;
153
141
  /**
154
142
  * Deletes a vector by its ID.
155
143
  * @param indexName - The name of the index containing the vector.
@@ -157,7 +145,7 @@ declare class OpenSearchVector extends MastraVector {
157
145
  * @returns A promise that resolves when the deletion is complete.
158
146
  * @throws Will throw an error if the deletion operation fails.
159
147
  */
160
- deleteVector(indexName: string, id: string): Promise<void>;
148
+ deleteVector({ indexName, id }: DeleteVectorParams): Promise<void>;
161
149
  }
162
150
  export { OpenSearchVector }
163
151
  export { OpenSearchVector as OpenSearchVector_alias_1 }
package/dist/index.cjs CHANGED
@@ -364,7 +364,12 @@ var REVERSE_METRIC_MAPPING = {
364
364
  };
365
365
  var OpenSearchVector = class extends vector.MastraVector {
366
366
  client;
367
- constructor(url) {
367
+ /**
368
+ * Creates a new OpenSearchVector client.
369
+ *
370
+ * @param {string} url - The url of the OpenSearch node.
371
+ */
372
+ constructor({ url }) {
368
373
  super();
369
374
  this.client = new opensearch.Client({ node: url });
370
375
  }
@@ -376,8 +381,7 @@ var OpenSearchVector = class extends vector.MastraVector {
376
381
  * @param {'cosine' | 'euclidean' | 'dotproduct'} [metric=cosine] - The metric to use to sort vectors in the collection.
377
382
  * @returns {Promise<void>} A promise that resolves when the collection is created.
378
383
  */
379
- async createIndex(params) {
380
- const { indexName, dimension, metric = "cosine" } = params;
384
+ async createIndex({ indexName, dimension, metric = "cosine" }) {
381
385
  if (!Number.isInteger(dimension) || dimension <= 0) {
382
386
  throw new Error("Dimension must be a positive integer");
383
387
  }
@@ -429,7 +433,13 @@ var OpenSearchVector = class extends vector.MastraVector {
429
433
  throw new Error(`Failed to list indexes: ${error.message}`);
430
434
  }
431
435
  }
432
- async describeIndex(indexName) {
436
+ /**
437
+ * Retrieves statistics about a vector index.
438
+ *
439
+ * @param {string} indexName - The name of the index to describe
440
+ * @returns A promise that resolves to the index statistics including dimension, count and metric
441
+ */
442
+ async describeIndex({ indexName }) {
433
443
  const { body: indexInfo } = await this.client.indices.get({ index: indexName });
434
444
  const mappings = indexInfo[indexName]?.mappings;
435
445
  const embedding = mappings?.properties?.embedding;
@@ -447,7 +457,7 @@ var OpenSearchVector = class extends vector.MastraVector {
447
457
  * @param {string} indexName - The name of the index to delete.
448
458
  * @returns {Promise<void>} A promise that resolves when the index is deleted.
449
459
  */
450
- async deleteIndex(indexName) {
460
+ async deleteIndex({ indexName }) {
451
461
  try {
452
462
  await this.client.indices.delete({ index: indexName });
453
463
  } catch (error) {
@@ -463,11 +473,10 @@ var OpenSearchVector = class extends vector.MastraVector {
463
473
  * @param {string[]} [ids] - An optional array of IDs corresponding to each vector. If not provided, new IDs will be generated.
464
474
  * @returns {Promise<string[]>} A promise that resolves to an array of IDs of the upserted vectors.
465
475
  */
466
- async upsert(params) {
467
- const { indexName, vectors, metadata = [], ids } = params;
476
+ async upsert({ indexName, vectors, metadata = [], ids }) {
468
477
  const vectorIds = ids || vectors.map(() => crypto.randomUUID());
469
478
  const operations = [];
470
- const indexInfo = await this.describeIndex(indexName);
479
+ const indexInfo = await this.describeIndex({ indexName });
471
480
  this.validateVectorDimensions(vectors, indexInfo.dimension);
472
481
  for (let i = 0; i < vectors.length; i++) {
473
482
  const operation = {
@@ -504,8 +513,13 @@ var OpenSearchVector = class extends vector.MastraVector {
504
513
  * @param {boolean} [includeVectors=false] - Whether to include the vectors in the response.
505
514
  * @returns {Promise<QueryResult[]>} A promise that resolves to an array of query results.
506
515
  */
507
- async query(params) {
508
- const { indexName, queryVector, filter, topK = 10, includeVector = false } = params;
516
+ async query({
517
+ indexName,
518
+ queryVector,
519
+ filter,
520
+ topK = 10,
521
+ includeVector = false
522
+ }) {
509
523
  try {
510
524
  const translatedFilter = this.transformFilter(filter);
511
525
  const response = await this.client.search({
@@ -558,8 +572,6 @@ var OpenSearchVector = class extends vector.MastraVector {
558
572
  return translator.translate(filter);
559
573
  }
560
574
  /**
561
- * @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
562
- *
563
575
  * Updates a vector by its ID with the provided vector and/or metadata.
564
576
  * @param indexName - The name of the index containing the vector.
565
577
  * @param id - The ID of the vector to update.
@@ -569,25 +581,7 @@ var OpenSearchVector = class extends vector.MastraVector {
569
581
  * @returns A promise that resolves when the update is complete.
570
582
  * @throws Will throw an error if no updates are provided or if the update operation fails.
571
583
  */
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) {
584
+ async updateVector({ indexName, id, update }) {
591
585
  if (!update.vector && !update.metadata) {
592
586
  throw new Error("No updates provided");
593
587
  }
@@ -606,7 +600,7 @@ var OpenSearchVector = class extends vector.MastraVector {
606
600
  id: source.id || id
607
601
  };
608
602
  if (update.vector) {
609
- const indexInfo = await this.describeIndex(indexName);
603
+ const indexInfo = await this.describeIndex({ indexName });
610
604
  this.validateVectorDimensions([update.vector], indexInfo.dimension);
611
605
  updatedDoc.embedding = update.vector;
612
606
  } else if (source.embedding) {
@@ -628,23 +622,6 @@ var OpenSearchVector = class extends vector.MastraVector {
628
622
  throw error;
629
623
  }
630
624
  }
631
- /**
632
- * @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
633
- *
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.
639
- */
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
625
  /**
649
626
  * Deletes a vector by its ID.
650
627
  * @param indexName - The name of the index containing the vector.
@@ -652,7 +629,7 @@ var OpenSearchVector = class extends vector.MastraVector {
652
629
  * @returns A promise that resolves when the deletion is complete.
653
630
  * @throws Will throw an error if the deletion operation fails.
654
631
  */
655
- async deleteVector(indexName, id) {
632
+ async deleteVector({ indexName, id }) {
656
633
  try {
657
634
  await this.client.delete({
658
635
  index: indexName,
package/dist/index.js CHANGED
@@ -362,7 +362,12 @@ var REVERSE_METRIC_MAPPING = {
362
362
  };
363
363
  var OpenSearchVector = class extends MastraVector {
364
364
  client;
365
- constructor(url) {
365
+ /**
366
+ * Creates a new OpenSearchVector client.
367
+ *
368
+ * @param {string} url - The url of the OpenSearch node.
369
+ */
370
+ constructor({ url }) {
366
371
  super();
367
372
  this.client = new Client({ node: url });
368
373
  }
@@ -374,8 +379,7 @@ var OpenSearchVector = class extends MastraVector {
374
379
  * @param {'cosine' | 'euclidean' | 'dotproduct'} [metric=cosine] - The metric to use to sort vectors in the collection.
375
380
  * @returns {Promise<void>} A promise that resolves when the collection is created.
376
381
  */
377
- async createIndex(params) {
378
- const { indexName, dimension, metric = "cosine" } = params;
382
+ async createIndex({ indexName, dimension, metric = "cosine" }) {
379
383
  if (!Number.isInteger(dimension) || dimension <= 0) {
380
384
  throw new Error("Dimension must be a positive integer");
381
385
  }
@@ -427,7 +431,13 @@ var OpenSearchVector = class extends MastraVector {
427
431
  throw new Error(`Failed to list indexes: ${error.message}`);
428
432
  }
429
433
  }
430
- async describeIndex(indexName) {
434
+ /**
435
+ * Retrieves statistics about a vector index.
436
+ *
437
+ * @param {string} indexName - The name of the index to describe
438
+ * @returns A promise that resolves to the index statistics including dimension, count and metric
439
+ */
440
+ async describeIndex({ indexName }) {
431
441
  const { body: indexInfo } = await this.client.indices.get({ index: indexName });
432
442
  const mappings = indexInfo[indexName]?.mappings;
433
443
  const embedding = mappings?.properties?.embedding;
@@ -445,7 +455,7 @@ var OpenSearchVector = class extends MastraVector {
445
455
  * @param {string} indexName - The name of the index to delete.
446
456
  * @returns {Promise<void>} A promise that resolves when the index is deleted.
447
457
  */
448
- async deleteIndex(indexName) {
458
+ async deleteIndex({ indexName }) {
449
459
  try {
450
460
  await this.client.indices.delete({ index: indexName });
451
461
  } catch (error) {
@@ -461,11 +471,10 @@ var OpenSearchVector = class extends MastraVector {
461
471
  * @param {string[]} [ids] - An optional array of IDs corresponding to each vector. If not provided, new IDs will be generated.
462
472
  * @returns {Promise<string[]>} A promise that resolves to an array of IDs of the upserted vectors.
463
473
  */
464
- async upsert(params) {
465
- const { indexName, vectors, metadata = [], ids } = params;
474
+ async upsert({ indexName, vectors, metadata = [], ids }) {
466
475
  const vectorIds = ids || vectors.map(() => crypto.randomUUID());
467
476
  const operations = [];
468
- const indexInfo = await this.describeIndex(indexName);
477
+ const indexInfo = await this.describeIndex({ indexName });
469
478
  this.validateVectorDimensions(vectors, indexInfo.dimension);
470
479
  for (let i = 0; i < vectors.length; i++) {
471
480
  const operation = {
@@ -502,8 +511,13 @@ var OpenSearchVector = class extends MastraVector {
502
511
  * @param {boolean} [includeVectors=false] - Whether to include the vectors in the response.
503
512
  * @returns {Promise<QueryResult[]>} A promise that resolves to an array of query results.
504
513
  */
505
- async query(params) {
506
- const { indexName, queryVector, filter, topK = 10, includeVector = false } = params;
514
+ async query({
515
+ indexName,
516
+ queryVector,
517
+ filter,
518
+ topK = 10,
519
+ includeVector = false
520
+ }) {
507
521
  try {
508
522
  const translatedFilter = this.transformFilter(filter);
509
523
  const response = await this.client.search({
@@ -556,8 +570,6 @@ var OpenSearchVector = class extends MastraVector {
556
570
  return translator.translate(filter);
557
571
  }
558
572
  /**
559
- * @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
560
- *
561
573
  * Updates a vector by its ID with the provided vector and/or metadata.
562
574
  * @param indexName - The name of the index containing the vector.
563
575
  * @param id - The ID of the vector to update.
@@ -567,25 +579,7 @@ var OpenSearchVector = class extends MastraVector {
567
579
  * @returns A promise that resolves when the update is complete.
568
580
  * @throws Will throw an error if no updates are provided or if the update operation fails.
569
581
  */
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) {
582
+ async updateVector({ indexName, id, update }) {
589
583
  if (!update.vector && !update.metadata) {
590
584
  throw new Error("No updates provided");
591
585
  }
@@ -604,7 +598,7 @@ var OpenSearchVector = class extends MastraVector {
604
598
  id: source.id || id
605
599
  };
606
600
  if (update.vector) {
607
- const indexInfo = await this.describeIndex(indexName);
601
+ const indexInfo = await this.describeIndex({ indexName });
608
602
  this.validateVectorDimensions([update.vector], indexInfo.dimension);
609
603
  updatedDoc.embedding = update.vector;
610
604
  } else if (source.embedding) {
@@ -626,23 +620,6 @@ var OpenSearchVector = class extends MastraVector {
626
620
  throw error;
627
621
  }
628
622
  }
629
- /**
630
- * @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
631
- *
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.
637
- */
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
623
  /**
647
624
  * Deletes a vector by its ID.
648
625
  * @param indexName - The name of the index containing the vector.
@@ -650,7 +627,7 @@ var OpenSearchVector = class extends MastraVector {
650
627
  * @returns A promise that resolves when the deletion is complete.
651
628
  * @throws Will throw an error if the deletion operation fails.
652
629
  */
653
- async deleteVector(indexName, id) {
630
+ async deleteVector({ indexName, id }) {
654
631
  try {
655
632
  await this.client.delete({
656
633
  index: indexName,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/opensearch",
3
- "version": "0.1.1",
3
+ "version": "0.2.0-alpha.1",
4
4
  "description": "OpenSearch vector store provider for Mastra",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -19,8 +19,7 @@
19
19
  "./package.json": "./package.json"
20
20
  },
21
21
  "dependencies": {
22
- "@opensearch-project/opensearch": "^3.4.0",
23
- "@mastra/core": "^0.9.4"
22
+ "@opensearch-project/opensearch": "^3.4.0"
24
23
  },
25
24
  "devDependencies": {
26
25
  "@microsoft/api-extractor": "^7.52.1",
@@ -29,7 +28,11 @@
29
28
  "tsup": "^8.4.0",
30
29
  "typescript": "^5.8.2",
31
30
  "vitest": "^3.0.8",
32
- "@internal/lint": "0.0.5"
31
+ "@internal/lint": "0.0.5",
32
+ "@mastra/core": "0.10.0-alpha.1"
33
+ },
34
+ "peerDependencies": {
35
+ "@mastra/core": "^0.9.4"
33
36
  },
34
37
  "scripts": {
35
38
  "build": "tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting",
@@ -39,31 +39,31 @@ describe('OpenSearchVector', () => {
39
39
 
40
40
  beforeAll(async () => {
41
41
  // Initialize PgVector
42
- vectorDB = new OpenSearchVector(url);
42
+ vectorDB = new OpenSearchVector({ url });
43
43
  });
44
44
 
45
45
  afterAll(async () => {
46
46
  // Clean up test tables
47
- await vectorDB.deleteIndex(testIndexName);
47
+ await vectorDB.deleteIndex({ indexName: testIndexName });
48
48
  });
49
49
 
50
50
  // Index Management Tests
51
51
  describe('Index Management', () => {
52
52
  describe('createIndex', () => {
53
53
  afterAll(async () => {
54
- await vectorDB.deleteIndex(testIndexName2);
54
+ await vectorDB.deleteIndex({ indexName: testIndexName2 });
55
55
  });
56
56
 
57
57
  it('should create a new vector table with specified dimensions', async () => {
58
58
  await vectorDB.createIndex({ indexName: testIndexName, dimension: 3 });
59
- const stats = await vectorDB.describeIndex(testIndexName);
59
+ const stats = await vectorDB.describeIndex({ indexName: testIndexName });
60
60
  expect(stats?.dimension).toBe(3);
61
61
  expect(stats?.count).toBe(0);
62
62
  });
63
63
 
64
64
  it('should create index with specified metric', async () => {
65
65
  await vectorDB.createIndex({ indexName: testIndexName2, dimension: 3, metric: 'euclidean' });
66
- const stats = await vectorDB.describeIndex(testIndexName2);
66
+ const stats = await vectorDB.describeIndex({ indexName: testIndexName2 });
67
67
  expect(stats.metric).toBe('euclidean');
68
68
  });
69
69
 
@@ -75,7 +75,7 @@ describe('OpenSearchVector', () => {
75
75
  describe('metrics', () => {
76
76
  const testIndex = 'test_metric';
77
77
  afterEach(async () => {
78
- await vectorDB.deleteIndex(testIndex);
78
+ await vectorDB.deleteIndex({ indexName: testIndex });
79
79
  });
80
80
  it('should create index with cosine metric', async () => {
81
81
  await vectorDB.createIndex({
@@ -83,7 +83,7 @@ describe('OpenSearchVector', () => {
83
83
  dimension: 3,
84
84
  metric: 'cosine',
85
85
  });
86
- const stats = await vectorDB.describeIndex(testIndex);
86
+ const stats = await vectorDB.describeIndex({ indexName: testIndex });
87
87
  expect(stats.metric).toBe('cosine');
88
88
  });
89
89
 
@@ -93,7 +93,7 @@ describe('OpenSearchVector', () => {
93
93
  dimension: 3,
94
94
  metric: 'euclidean',
95
95
  });
96
- const stats = await vectorDB.describeIndex(testIndex);
96
+ const stats = await vectorDB.describeIndex({ indexName: testIndex });
97
97
  expect(stats.metric).toBe('euclidean');
98
98
  });
99
99
 
@@ -103,7 +103,7 @@ describe('OpenSearchVector', () => {
103
103
  dimension: 3,
104
104
  metric: 'dotproduct',
105
105
  });
106
- const stats = await vectorDB.describeIndex(testIndex);
106
+ const stats = await vectorDB.describeIndex({ indexName: testIndex });
107
107
  expect(stats.metric).toBe('dotproduct');
108
108
  });
109
109
  });
@@ -115,7 +115,7 @@ describe('OpenSearchVector', () => {
115
115
  });
116
116
 
117
117
  afterAll(async () => {
118
- await vectorDB.deleteIndex(indexName);
118
+ await vectorDB.deleteIndex({ indexName });
119
119
  });
120
120
 
121
121
  it('should list all vector tables', async () => {
@@ -124,7 +124,7 @@ describe('OpenSearchVector', () => {
124
124
  });
125
125
 
126
126
  it('should not return created index in list if it is deleted', async () => {
127
- await vectorDB.deleteIndex(indexName);
127
+ await vectorDB.deleteIndex({ indexName });
128
128
  const indexes = await vectorDB.listIndexes();
129
129
  expect(indexes).not.toContain(indexName);
130
130
  });
@@ -137,7 +137,7 @@ describe('OpenSearchVector', () => {
137
137
  });
138
138
 
139
139
  afterAll(async () => {
140
- await vectorDB.deleteIndex(indexName);
140
+ await vectorDB.deleteIndex({ indexName });
141
141
  });
142
142
 
143
143
  it('should return correct index stats', async () => {
@@ -147,7 +147,7 @@ describe('OpenSearchVector', () => {
147
147
  ];
148
148
  await vectorDB.upsert({ indexName, vectors });
149
149
 
150
- const stats = await vectorDB.describeIndex(indexName);
150
+ const stats = await vectorDB.describeIndex({ indexName });
151
151
  expect(stats).toEqual({
152
152
  dimension: 3,
153
153
  count: 2,
@@ -156,7 +156,7 @@ describe('OpenSearchVector', () => {
156
156
  });
157
157
 
158
158
  it('should throw error for non-existent index', async () => {
159
- await expect(vectorDB.describeIndex('non_existent')).rejects.toThrow();
159
+ await expect(vectorDB.describeIndex({ indexName: 'non_existent' })).rejects.toThrow();
160
160
  });
161
161
  });
162
162
 
@@ -170,7 +170,7 @@ describe('OpenSearchVector', () => {
170
170
  expect(indexes).toContain(testIndexName);
171
171
 
172
172
  // Delete the index after the test
173
- await vectorDB.deleteIndex(testIndexName);
173
+ await vectorDB.deleteIndex({ indexName: testIndexName });
174
174
  });
175
175
 
176
176
  it('should throw an error if dimension is not a positive integer', async () => {
@@ -186,7 +186,7 @@ describe('OpenSearchVector', () => {
186
186
  let indexes = await vectorDB.listIndexes();
187
187
  expect(indexes).toContain(deleteTestIndex);
188
188
 
189
- await vectorDB.deleteIndex(deleteTestIndex);
189
+ await vectorDB.deleteIndex({ indexName: deleteTestIndex });
190
190
 
191
191
  indexes = await vectorDB.listIndexes();
192
192
  expect(indexes).not.toContain(deleteTestIndex);
@@ -201,7 +201,7 @@ describe('OpenSearchVector', () => {
201
201
  });
202
202
 
203
203
  afterEach(async () => {
204
- await vectorDB.deleteIndex(testIndexName);
204
+ await vectorDB.deleteIndex({ indexName: testIndexName });
205
205
  });
206
206
 
207
207
  describe('query', () => {
@@ -421,7 +421,7 @@ describe('OpenSearchVector', () => {
421
421
  });
422
422
 
423
423
  afterEach(async () => {
424
- await vectorDB.deleteIndex(testIndexName);
424
+ await vectorDB.deleteIndex({ indexName: testIndexName });
425
425
  });
426
426
 
427
427
  it('should insert new vectors', async () => {
@@ -432,7 +432,7 @@ describe('OpenSearchVector', () => {
432
432
  const ids = await vectorDB.upsert({ indexName: testIndexName, vectors });
433
433
 
434
434
  expect(ids).toHaveLength(2);
435
- const stats = await vectorDB.describeIndex(testIndexName);
435
+ const stats = await vectorDB.describeIndex({ indexName: testIndexName });
436
436
  expect(stats.count).toBe(2);
437
437
  });
438
438
 
@@ -485,7 +485,7 @@ describe('OpenSearchVector', () => {
485
485
  });
486
486
 
487
487
  afterEach(async () => {
488
- await vectorDB.deleteIndex(testIndexName);
488
+ await vectorDB.deleteIndex({ indexName: testIndexName });
489
489
  });
490
490
 
491
491
  it('should update the vector by id', async () => {
@@ -503,7 +503,7 @@ describe('OpenSearchVector', () => {
503
503
  metadata: newMetaData,
504
504
  };
505
505
 
506
- await vectorDB.updateVector(testIndexName, idToBeUpdated, update);
506
+ await vectorDB.updateVector({ indexName: testIndexName, id: 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.updateVector(testIndexName, idToBeUpdated, update);
533
+ await vectorDB.updateVector({ indexName: testIndexName, id: 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.updateVector(testIndexName, idToBeUpdated, update);
558
+ await vectorDB.updateVector({ indexName: testIndexName, id: idToBeUpdated, update });
559
559
 
560
560
  const results: QueryResult[] = await vectorDB.query({
561
561
  indexName: testIndexName,
@@ -569,7 +569,9 @@ describe('OpenSearchVector', () => {
569
569
  });
570
570
 
571
571
  it('should throw exception when no updates are given', async () => {
572
- await expect(vectorDB.updateVector(testIndexName, 'id', {})).rejects.toThrow('No updates provided');
572
+ await expect(vectorDB.updateVector({ indexName: testIndexName, id: 'id', update: {} })).rejects.toThrow(
573
+ 'No updates provided',
574
+ );
573
575
  });
574
576
  });
575
577
 
@@ -586,7 +588,7 @@ describe('OpenSearchVector', () => {
586
588
  });
587
589
 
588
590
  afterEach(async () => {
589
- await vectorDB.deleteIndex(testIndexName);
591
+ await vectorDB.deleteIndex({ indexName: testIndexName });
590
592
  });
591
593
 
592
594
  it('should delete the vector by id', async () => {
@@ -594,7 +596,7 @@ describe('OpenSearchVector', () => {
594
596
  expect(ids).toHaveLength(3);
595
597
  const idToBeDeleted = ids[0];
596
598
 
597
- await vectorDB.deleteVector(testIndexName, idToBeDeleted);
599
+ await vectorDB.deleteVector({ indexName: testIndexName, id: idToBeDeleted });
598
600
 
599
601
  const results: QueryResult[] = await vectorDB.query({
600
602
  indexName: testIndexName,
@@ -663,7 +665,7 @@ describe('OpenSearchVector', () => {
663
665
  });
664
666
 
665
667
  afterEach(async () => {
666
- await vectorDB.deleteIndex(indexName);
668
+ await vectorDB.deleteIndex({ indexName });
667
669
  });
668
670
 
669
671
  // Numeric Comparison Tests
@@ -1487,7 +1489,7 @@ describe('OpenSearchVector', () => {
1487
1489
  });
1488
1490
 
1489
1491
  afterAll(async () => {
1490
- await vectorDB.deleteIndex(testIndexName);
1492
+ await vectorDB.deleteIndex({ indexName: testIndexName });
1491
1493
  });
1492
1494
 
1493
1495
  it('should handle non-existent index queries', async () => {
@@ -1550,7 +1552,7 @@ describe('OpenSearchVector', () => {
1550
1552
  infoSpy.mockRestore();
1551
1553
  warnSpy.mockRestore();
1552
1554
  // Cleanup
1553
- await vectorDB.deleteIndex(duplicateIndexName);
1555
+ await vectorDB.deleteIndex({ indexName: duplicateIndexName });
1554
1556
  }
1555
1557
  });
1556
1558
  });
@@ -1,4 +1,14 @@
1
- import type { CreateIndexParams, IndexStats, QueryResult, QueryVectorParams, UpsertVectorParams } from '@mastra/core';
1
+ import type {
2
+ CreateIndexParams,
3
+ DeleteIndexParams,
4
+ DeleteVectorParams,
5
+ DescribeIndexParams,
6
+ IndexStats,
7
+ QueryResult,
8
+ QueryVectorParams,
9
+ UpdateVectorParams,
10
+ UpsertVectorParams,
11
+ } from '@mastra/core';
2
12
  import { MastraVector } from '@mastra/core/vector';
3
13
  import type { VectorFilter } from '@mastra/core/vector/filter';
4
14
  import { Client as OpenSearchClient } from '@opensearch-project/opensearch';
@@ -19,7 +29,12 @@ const REVERSE_METRIC_MAPPING = {
19
29
  export class OpenSearchVector extends MastraVector {
20
30
  private client: OpenSearchClient;
21
31
 
22
- constructor(url: string) {
32
+ /**
33
+ * Creates a new OpenSearchVector client.
34
+ *
35
+ * @param {string} url - The url of the OpenSearch node.
36
+ */
37
+ constructor({ url }: { url: string }) {
23
38
  super();
24
39
  this.client = new OpenSearchClient({ node: url });
25
40
  }
@@ -32,9 +47,7 @@ export class OpenSearchVector extends MastraVector {
32
47
  * @param {'cosine' | 'euclidean' | 'dotproduct'} [metric=cosine] - The metric to use to sort vectors in the collection.
33
48
  * @returns {Promise<void>} A promise that resolves when the collection is created.
34
49
  */
35
- async createIndex(params: CreateIndexParams): Promise<void> {
36
- const { indexName, dimension, metric = 'cosine' } = params;
37
-
50
+ async createIndex({ indexName, dimension, metric = 'cosine' }: CreateIndexParams): Promise<void> {
38
51
  if (!Number.isInteger(dimension) || dimension <= 0) {
39
52
  throw new Error('Dimension must be a positive integer');
40
53
  }
@@ -93,7 +106,13 @@ export class OpenSearchVector extends MastraVector {
93
106
  }
94
107
  }
95
108
 
96
- async describeIndex(indexName: string): Promise<IndexStats> {
109
+ /**
110
+ * Retrieves statistics about a vector index.
111
+ *
112
+ * @param {string} indexName - The name of the index to describe
113
+ * @returns A promise that resolves to the index statistics including dimension, count and metric
114
+ */
115
+ async describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats> {
97
116
  const { body: indexInfo } = await this.client.indices.get({ index: indexName });
98
117
  const mappings = indexInfo[indexName]?.mappings;
99
118
  const embedding: any = mappings?.properties?.embedding;
@@ -114,7 +133,7 @@ export class OpenSearchVector extends MastraVector {
114
133
  * @param {string} indexName - The name of the index to delete.
115
134
  * @returns {Promise<void>} A promise that resolves when the index is deleted.
116
135
  */
117
- async deleteIndex(indexName: string): Promise<void> {
136
+ async deleteIndex({ indexName }: DeleteIndexParams): Promise<void> {
118
137
  try {
119
138
  await this.client.indices.delete({ index: indexName });
120
139
  } catch (error) {
@@ -131,14 +150,12 @@ export class OpenSearchVector extends MastraVector {
131
150
  * @param {string[]} [ids] - An optional array of IDs corresponding to each vector. If not provided, new IDs will be generated.
132
151
  * @returns {Promise<string[]>} A promise that resolves to an array of IDs of the upserted vectors.
133
152
  */
134
- async upsert(params: UpsertVectorParams): Promise<string[]> {
135
- const { indexName, vectors, metadata = [], ids } = params;
136
-
153
+ async upsert({ indexName, vectors, metadata = [], ids }: UpsertVectorParams): Promise<string[]> {
137
154
  const vectorIds = ids || vectors.map(() => crypto.randomUUID());
138
155
  const operations = [];
139
156
 
140
157
  // Get index stats to check dimension
141
- const indexInfo = await this.describeIndex(indexName);
158
+ const indexInfo = await this.describeIndex({ indexName });
142
159
 
143
160
  // Validate vector dimensions
144
161
  this.validateVectorDimensions(vectors, indexInfo.dimension);
@@ -183,9 +200,13 @@ export class OpenSearchVector extends MastraVector {
183
200
  * @param {boolean} [includeVectors=false] - Whether to include the vectors in the response.
184
201
  * @returns {Promise<QueryResult[]>} A promise that resolves to an array of query results.
185
202
  */
186
- async query(params: QueryVectorParams): Promise<QueryResult[]> {
187
- const { indexName, queryVector, filter, topK = 10, includeVector = false } = params;
188
-
203
+ async query({
204
+ indexName,
205
+ queryVector,
206
+ filter,
207
+ topK = 10,
208
+ includeVector = false,
209
+ }: QueryVectorParams): Promise<QueryResult[]> {
189
210
  try {
190
211
  const translatedFilter = this.transformFilter(filter);
191
212
 
@@ -243,31 +264,6 @@ export class OpenSearchVector extends MastraVector {
243
264
  return translator.translate(filter);
244
265
  }
245
266
 
246
- /**
247
- * @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
248
- *
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.
257
- */
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
267
  /**
272
268
  * Updates a vector by its ID with the provided vector and/or metadata.
273
269
  * @param indexName - The name of the index containing the vector.
@@ -278,14 +274,7 @@ export class OpenSearchVector extends MastraVector {
278
274
  * @returns A promise that resolves when the update is complete.
279
275
  * @throws Will throw an error if no updates are provided or if the update operation fails.
280
276
  */
281
- async updateVector(
282
- indexName: string,
283
- id: string,
284
- update: {
285
- vector?: number[];
286
- metadata?: Record<string, any>;
287
- },
288
- ): Promise<void> {
277
+ async updateVector({ indexName, id, update }: UpdateVectorParams): Promise<void> {
289
278
  if (!update.vector && !update.metadata) {
290
279
  throw new Error('No updates provided');
291
280
  }
@@ -313,7 +302,7 @@ export class OpenSearchVector extends MastraVector {
313
302
  // Update vector if provided
314
303
  if (update.vector) {
315
304
  // Get index stats to check dimension
316
- const indexInfo = await this.describeIndex(indexName);
305
+ const indexInfo = await this.describeIndex({ indexName });
317
306
 
318
307
  // Validate vector dimensions
319
308
  this.validateVectorDimensions([update.vector], indexInfo.dimension);
@@ -343,24 +332,6 @@ export class OpenSearchVector extends MastraVector {
343
332
  }
344
333
  }
345
334
 
346
- /**
347
- * @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
348
- *
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.
354
- */
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
335
  /**
365
336
  * Deletes a vector by its ID.
366
337
  * @param indexName - The name of the index containing the vector.
@@ -368,7 +339,7 @@ export class OpenSearchVector extends MastraVector {
368
339
  * @returns A promise that resolves when the deletion is complete.
369
340
  * @throws Will throw an error if the deletion operation fails.
370
341
  */
371
- async deleteVector(indexName: string, id: string): Promise<void> {
342
+ async deleteVector({ indexName, id }: DeleteVectorParams): Promise<void> {
372
343
  try {
373
344
  await this.client.delete({
374
345
  index: indexName,