@mastra/pinecone 0.2.13 → 0.3.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/pinecone@0.2.13-alpha.4 build /home/runner/work/mastra/mastra/stores/pinecone
2
+ > @mastra/pinecone@0.3.0-alpha.1 build /home/runner/work/mastra/mastra/stores/pinecone
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 5073ms
9
+ TSC ⚡️ Build success in 8231ms
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/pinecone/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/pinecone/dist/_tsup-dts-rollup.d.cts
16
- DTS ⚡️ Build success in 9962ms
16
+ DTS ⚡️ Build success in 10007ms
17
17
  CLI Cleaning output folder
18
18
  ESM Build start
19
19
  CJS Build start
20
- ESM dist/index.js 14.09 KB
21
- ESM ⚡️ Build success in 641ms
22
- CJS dist/index.cjs 14.15 KB
23
- CJS ⚡️ Build success in 648ms
20
+ ESM dist/index.js 12.38 KB
21
+ ESM ⚡️ Build success in 683ms
22
+ CJS dist/index.cjs 12.45 KB
23
+ CJS ⚡️ Build success in 682ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,40 @@
1
1
  # @mastra/pinecone
2
2
 
3
+ ## 0.3.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.2.14-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.2.13
4
39
 
5
40
  ### Patch Changes
@@ -1,15 +1,16 @@
1
1
  import { BaseFilterTranslator } from '@mastra/core/vector/filter';
2
2
  import type { CreateIndexParams } from '@mastra/core/vector';
3
+ import type { DeleteIndexParams } from '@mastra/core/vector';
4
+ import type { DeleteVectorParams } from '@mastra/core/vector';
5
+ import type { DescribeIndexParams } from '@mastra/core/vector';
3
6
  import type { IndexStats } from '@mastra/core/vector';
4
7
  import type { IndexStatsDescription } from '@pinecone-database/pinecone';
5
8
  import { MastraVector } from '@mastra/core/vector';
6
9
  import type { OperatorSupport } from '@mastra/core/vector/filter';
7
- import type { ParamsToArgs } from '@mastra/core/vector';
8
10
  import type { QueryResult } from '@mastra/core/vector';
9
- import type { QueryVectorArgs } from '@mastra/core/vector';
10
11
  import type { QueryVectorParams } from '@mastra/core/vector';
11
12
  import type { RecordSparseValues } from '@pinecone-database/pinecone';
12
- import type { UpsertVectorArgs } from '@mastra/core/vector';
13
+ import type { UpdateVectorParams } from '@mastra/core/vector';
13
14
  import type { UpsertVectorParams } from '@mastra/core/vector';
14
15
  import type { VectorFilter } from '@mastra/core/vector/filter';
15
16
 
@@ -21,6 +22,10 @@ declare const PINECONE_PROMPT = "When querying Pinecone, you can ONLY use the op
21
22
  export { PINECONE_PROMPT }
22
23
  export { PINECONE_PROMPT as PINECONE_PROMPT_alias_1 }
23
24
 
25
+ declare interface PineconeDeleteVectorParams extends DeleteVectorParams {
26
+ namespace?: string;
27
+ }
28
+
24
29
  export declare class PineconeFilterTranslator extends BaseFilterTranslator {
25
30
  protected getSupportedOperators(): OperatorSupport;
26
31
  translate(filter?: VectorFilter): VectorFilter;
@@ -32,14 +37,14 @@ declare interface PineconeIndexStats extends IndexStats {
32
37
  namespaces?: IndexStatsDescription['namespaces'];
33
38
  }
34
39
 
35
- declare type PineconeQueryVectorArgs = [...QueryVectorArgs, string?, RecordSparseValues?];
36
-
37
40
  declare interface PineconeQueryVectorParams extends QueryVectorParams {
38
41
  namespace?: string;
39
42
  sparseVector?: RecordSparseValues;
40
43
  }
41
44
 
42
- declare type PineconeUpsertVectorArgs = [...UpsertVectorArgs, string?, RecordSparseValues[]?];
45
+ declare interface PineconeUpdateVectorParams extends UpdateVectorParams {
46
+ namespace?: string;
47
+ }
43
48
 
44
49
  declare interface PineconeUpsertVectorParams extends UpsertVectorParams {
45
50
  namespace?: string;
@@ -48,32 +53,29 @@ declare interface PineconeUpsertVectorParams extends UpsertVectorParams {
48
53
 
49
54
  declare class PineconeVector extends MastraVector {
50
55
  private client;
51
- constructor(apiKey: string, environment?: string);
56
+ /**
57
+ * Creates a new PineconeVector client.
58
+ * @param apiKey - The API key for Pinecone.
59
+ * @param environment - The environment for Pinecone.
60
+ */
61
+ constructor({ apiKey, environment }: {
62
+ apiKey: string;
63
+ environment?: string;
64
+ });
52
65
  get indexSeparator(): string;
53
- createIndex(...args: ParamsToArgs<CreateIndexParams>): Promise<void>;
54
- upsert(...args: ParamsToArgs<PineconeUpsertVectorParams> | PineconeUpsertVectorArgs): Promise<string[]>;
66
+ createIndex({ indexName, dimension, metric }: CreateIndexParams): Promise<void>;
67
+ upsert({ indexName, vectors, metadata, ids, namespace, sparseVectors, }: PineconeUpsertVectorParams): Promise<string[]>;
55
68
  transformFilter(filter?: VectorFilter): VectorFilter;
56
- query(...args: ParamsToArgs<PineconeQueryVectorParams> | PineconeQueryVectorArgs): Promise<QueryResult[]>;
69
+ query({ indexName, queryVector, topK, filter, includeVector, namespace, sparseVector, }: PineconeQueryVectorParams): Promise<QueryResult[]>;
57
70
  listIndexes(): Promise<string[]>;
58
- describeIndex(indexName: string): Promise<PineconeIndexStats>;
59
- deleteIndex(indexName: string): Promise<void>;
60
71
  /**
61
- * @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
72
+ * Retrieves statistics about a vector index.
62
73
  *
63
- * Updates a vector by its ID with the provided vector and/or metadata.
64
- * @param indexName - The name of the index containing the vector.
65
- * @param id - The ID of the vector to update.
66
- * @param update - An object containing the vector and/or metadata to update.
67
- * @param update.vector - An optional array of numbers representing the new vector.
68
- * @param update.metadata - An optional record containing the new metadata.
69
- * @param namespace - The namespace of the index (optional).
70
- * @returns A promise that resolves when the update is complete.
71
- * @throws Will throw an error if no updates are provided or if the update operation fails.
74
+ * @param {string} indexName - The name of the index to describe
75
+ * @returns A promise that resolves to the index statistics including dimension, count and metric
72
76
  */
73
- updateIndexById(indexName: string, id: string, update: {
74
- vector?: number[];
75
- metadata?: Record<string, any>;
76
- }, namespace?: string): Promise<void>;
77
+ describeIndex({ indexName }: DescribeIndexParams): Promise<PineconeIndexStats>;
78
+ deleteIndex({ indexName }: DeleteIndexParams): Promise<void>;
77
79
  /**
78
80
  * Updates a vector by its ID with the provided vector and/or metadata.
79
81
  * @param indexName - The name of the index containing the vector.
@@ -85,21 +87,7 @@ declare class PineconeVector extends MastraVector {
85
87
  * @returns A promise that resolves when the update is complete.
86
88
  * @throws Will throw an error if no updates are provided or if the update operation fails.
87
89
  */
88
- updateVector(indexName: string, id: string, update: {
89
- vector?: number[];
90
- metadata?: Record<string, any>;
91
- }, namespace?: string): Promise<void>;
92
- /**
93
- * @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
94
- *
95
- * Deletes a vector by its ID.
96
- * @param indexName - The name of the index containing the vector.
97
- * @param id - The ID of the vector to delete.
98
- * @param namespace - The namespace of the index (optional).
99
- * @returns A promise that resolves when the deletion is complete.
100
- * @throws Will throw an error if the deletion operation fails.
101
- */
102
- deleteIndexById(indexName: string, id: string, namespace?: string): Promise<void>;
90
+ updateVector({ indexName, id, update, namespace }: PineconeUpdateVectorParams): Promise<void>;
103
91
  /**
104
92
  * Deletes a vector by its ID.
105
93
  * @param indexName - The name of the index containing the vector.
@@ -108,7 +96,7 @@ declare class PineconeVector extends MastraVector {
108
96
  * @returns A promise that resolves when the deletion is complete.
109
97
  * @throws Will throw an error if the deletion operation fails.
110
98
  */
111
- deleteVector(indexName: string, id: string, namespace?: string): Promise<void>;
99
+ deleteVector({ indexName, id, namespace }: PineconeDeleteVectorParams): Promise<void>;
112
100
  }
113
101
  export { PineconeVector }
114
102
  export { PineconeVector as PineconeVector_alias_1 }
@@ -1,15 +1,16 @@
1
1
  import { BaseFilterTranslator } from '@mastra/core/vector/filter';
2
2
  import type { CreateIndexParams } from '@mastra/core/vector';
3
+ import type { DeleteIndexParams } from '@mastra/core/vector';
4
+ import type { DeleteVectorParams } from '@mastra/core/vector';
5
+ import type { DescribeIndexParams } from '@mastra/core/vector';
3
6
  import type { IndexStats } from '@mastra/core/vector';
4
7
  import type { IndexStatsDescription } from '@pinecone-database/pinecone';
5
8
  import { MastraVector } from '@mastra/core/vector';
6
9
  import type { OperatorSupport } from '@mastra/core/vector/filter';
7
- import type { ParamsToArgs } from '@mastra/core/vector';
8
10
  import type { QueryResult } from '@mastra/core/vector';
9
- import type { QueryVectorArgs } from '@mastra/core/vector';
10
11
  import type { QueryVectorParams } from '@mastra/core/vector';
11
12
  import type { RecordSparseValues } from '@pinecone-database/pinecone';
12
- import type { UpsertVectorArgs } from '@mastra/core/vector';
13
+ import type { UpdateVectorParams } from '@mastra/core/vector';
13
14
  import type { UpsertVectorParams } from '@mastra/core/vector';
14
15
  import type { VectorFilter } from '@mastra/core/vector/filter';
15
16
 
@@ -21,6 +22,10 @@ declare const PINECONE_PROMPT = "When querying Pinecone, you can ONLY use the op
21
22
  export { PINECONE_PROMPT }
22
23
  export { PINECONE_PROMPT as PINECONE_PROMPT_alias_1 }
23
24
 
25
+ declare interface PineconeDeleteVectorParams extends DeleteVectorParams {
26
+ namespace?: string;
27
+ }
28
+
24
29
  export declare class PineconeFilterTranslator extends BaseFilterTranslator {
25
30
  protected getSupportedOperators(): OperatorSupport;
26
31
  translate(filter?: VectorFilter): VectorFilter;
@@ -32,14 +37,14 @@ declare interface PineconeIndexStats extends IndexStats {
32
37
  namespaces?: IndexStatsDescription['namespaces'];
33
38
  }
34
39
 
35
- declare type PineconeQueryVectorArgs = [...QueryVectorArgs, string?, RecordSparseValues?];
36
-
37
40
  declare interface PineconeQueryVectorParams extends QueryVectorParams {
38
41
  namespace?: string;
39
42
  sparseVector?: RecordSparseValues;
40
43
  }
41
44
 
42
- declare type PineconeUpsertVectorArgs = [...UpsertVectorArgs, string?, RecordSparseValues[]?];
45
+ declare interface PineconeUpdateVectorParams extends UpdateVectorParams {
46
+ namespace?: string;
47
+ }
43
48
 
44
49
  declare interface PineconeUpsertVectorParams extends UpsertVectorParams {
45
50
  namespace?: string;
@@ -48,32 +53,29 @@ declare interface PineconeUpsertVectorParams extends UpsertVectorParams {
48
53
 
49
54
  declare class PineconeVector extends MastraVector {
50
55
  private client;
51
- constructor(apiKey: string, environment?: string);
56
+ /**
57
+ * Creates a new PineconeVector client.
58
+ * @param apiKey - The API key for Pinecone.
59
+ * @param environment - The environment for Pinecone.
60
+ */
61
+ constructor({ apiKey, environment }: {
62
+ apiKey: string;
63
+ environment?: string;
64
+ });
52
65
  get indexSeparator(): string;
53
- createIndex(...args: ParamsToArgs<CreateIndexParams>): Promise<void>;
54
- upsert(...args: ParamsToArgs<PineconeUpsertVectorParams> | PineconeUpsertVectorArgs): Promise<string[]>;
66
+ createIndex({ indexName, dimension, metric }: CreateIndexParams): Promise<void>;
67
+ upsert({ indexName, vectors, metadata, ids, namespace, sparseVectors, }: PineconeUpsertVectorParams): Promise<string[]>;
55
68
  transformFilter(filter?: VectorFilter): VectorFilter;
56
- query(...args: ParamsToArgs<PineconeQueryVectorParams> | PineconeQueryVectorArgs): Promise<QueryResult[]>;
69
+ query({ indexName, queryVector, topK, filter, includeVector, namespace, sparseVector, }: PineconeQueryVectorParams): Promise<QueryResult[]>;
57
70
  listIndexes(): Promise<string[]>;
58
- describeIndex(indexName: string): Promise<PineconeIndexStats>;
59
- deleteIndex(indexName: string): Promise<void>;
60
71
  /**
61
- * @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
72
+ * Retrieves statistics about a vector index.
62
73
  *
63
- * Updates a vector by its ID with the provided vector and/or metadata.
64
- * @param indexName - The name of the index containing the vector.
65
- * @param id - The ID of the vector to update.
66
- * @param update - An object containing the vector and/or metadata to update.
67
- * @param update.vector - An optional array of numbers representing the new vector.
68
- * @param update.metadata - An optional record containing the new metadata.
69
- * @param namespace - The namespace of the index (optional).
70
- * @returns A promise that resolves when the update is complete.
71
- * @throws Will throw an error if no updates are provided or if the update operation fails.
74
+ * @param {string} indexName - The name of the index to describe
75
+ * @returns A promise that resolves to the index statistics including dimension, count and metric
72
76
  */
73
- updateIndexById(indexName: string, id: string, update: {
74
- vector?: number[];
75
- metadata?: Record<string, any>;
76
- }, namespace?: string): Promise<void>;
77
+ describeIndex({ indexName }: DescribeIndexParams): Promise<PineconeIndexStats>;
78
+ deleteIndex({ indexName }: DeleteIndexParams): Promise<void>;
77
79
  /**
78
80
  * Updates a vector by its ID with the provided vector and/or metadata.
79
81
  * @param indexName - The name of the index containing the vector.
@@ -85,21 +87,7 @@ declare class PineconeVector extends MastraVector {
85
87
  * @returns A promise that resolves when the update is complete.
86
88
  * @throws Will throw an error if no updates are provided or if the update operation fails.
87
89
  */
88
- updateVector(indexName: string, id: string, update: {
89
- vector?: number[];
90
- metadata?: Record<string, any>;
91
- }, namespace?: string): Promise<void>;
92
- /**
93
- * @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
94
- *
95
- * Deletes a vector by its ID.
96
- * @param indexName - The name of the index containing the vector.
97
- * @param id - The ID of the vector to delete.
98
- * @param namespace - The namespace of the index (optional).
99
- * @returns A promise that resolves when the deletion is complete.
100
- * @throws Will throw an error if the deletion operation fails.
101
- */
102
- deleteIndexById(indexName: string, id: string, namespace?: string): Promise<void>;
90
+ updateVector({ indexName, id, update, namespace }: PineconeUpdateVectorParams): Promise<void>;
103
91
  /**
104
92
  * Deletes a vector by its ID.
105
93
  * @param indexName - The name of the index containing the vector.
@@ -108,7 +96,7 @@ declare class PineconeVector extends MastraVector {
108
96
  * @returns A promise that resolves when the deletion is complete.
109
97
  * @throws Will throw an error if the deletion operation fails.
110
98
  */
111
- deleteVector(indexName: string, id: string, namespace?: string): Promise<void>;
99
+ deleteVector({ indexName, id, namespace }: PineconeDeleteVectorParams): Promise<void>;
112
100
  }
113
101
  export { PineconeVector }
114
102
  export { PineconeVector as PineconeVector_alias_1 }
package/dist/index.cjs CHANGED
@@ -85,7 +85,12 @@ var PineconeFilterTranslator = class extends filter.BaseFilterTranslator {
85
85
  // src/vector/index.ts
86
86
  var PineconeVector = class extends vector.MastraVector {
87
87
  client;
88
- constructor(apiKey, environment) {
88
+ /**
89
+ * Creates a new PineconeVector client.
90
+ * @param apiKey - The API key for Pinecone.
91
+ * @param environment - The environment for Pinecone.
92
+ */
93
+ constructor({ apiKey, environment }) {
89
94
  super();
90
95
  const opts = { apiKey };
91
96
  if (environment) {
@@ -103,9 +108,7 @@ var PineconeVector = class extends vector.MastraVector {
103
108
  get indexSeparator() {
104
109
  return "-";
105
110
  }
106
- async createIndex(...args) {
107
- const params = this.normalizeArgs("createIndex", args);
108
- const { indexName, dimension, metric = "cosine" } = params;
111
+ async createIndex({ indexName, dimension, metric = "cosine" }) {
109
112
  if (!Number.isInteger(dimension) || dimension <= 0) {
110
113
  throw new Error("Dimension must be a positive integer");
111
114
  }
@@ -133,12 +136,14 @@ var PineconeVector = class extends vector.MastraVector {
133
136
  throw error;
134
137
  }
135
138
  }
136
- async upsert(...args) {
137
- const params = this.normalizeArgs("upsert", args, [
138
- "namespace",
139
- "sparseVectors"
140
- ]);
141
- const { indexName, vectors, metadata, ids, namespace, sparseVectors } = params;
139
+ async upsert({
140
+ indexName,
141
+ vectors,
142
+ metadata,
143
+ ids,
144
+ namespace,
145
+ sparseVectors
146
+ }) {
142
147
  const index = this.client.Index(indexName).namespace(namespace || "");
143
148
  const vectorIds = ids || vectors.map(() => crypto.randomUUID());
144
149
  const records = vectors.map((vector, i) => ({
@@ -158,12 +163,15 @@ var PineconeVector = class extends vector.MastraVector {
158
163
  const translator = new PineconeFilterTranslator();
159
164
  return translator.translate(filter);
160
165
  }
161
- async query(...args) {
162
- const params = this.normalizeArgs("query", args, [
163
- "namespace",
164
- "sparseVector"
165
- ]);
166
- const { indexName, queryVector, topK = 10, filter, includeVector = false, namespace, sparseVector } = params;
166
+ async query({
167
+ indexName,
168
+ queryVector,
169
+ topK = 10,
170
+ filter,
171
+ includeVector = false,
172
+ namespace,
173
+ sparseVector
174
+ }) {
167
175
  const index = this.client.Index(indexName).namespace(namespace || "");
168
176
  const translatedFilter = this.transformFilter(filter) ?? void 0;
169
177
  const queryParams = {
@@ -188,7 +196,13 @@ var PineconeVector = class extends vector.MastraVector {
188
196
  const indexesResult = await this.client.listIndexes();
189
197
  return indexesResult?.indexes?.map((index) => index.name) || [];
190
198
  }
191
- async describeIndex(indexName) {
199
+ /**
200
+ * Retrieves statistics about a vector index.
201
+ *
202
+ * @param {string} indexName - The name of the index to describe
203
+ * @returns A promise that resolves to the index statistics including dimension, count and metric
204
+ */
205
+ async describeIndex({ indexName }) {
192
206
  const index = this.client.Index(indexName);
193
207
  const stats = await index.describeIndexStats();
194
208
  const description = await this.client.describeIndex(indexName);
@@ -199,34 +213,13 @@ var PineconeVector = class extends vector.MastraVector {
199
213
  namespaces: stats.namespaces
200
214
  };
201
215
  }
202
- async deleteIndex(indexName) {
216
+ async deleteIndex({ indexName }) {
203
217
  try {
204
218
  await this.client.deleteIndex(indexName);
205
219
  } catch (error) {
206
220
  throw new Error(`Failed to delete Pinecone index: ${error.message}`);
207
221
  }
208
222
  }
209
- /**
210
- * @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
211
- *
212
- * Updates a vector by its ID with the provided vector and/or metadata.
213
- * @param indexName - The name of the index containing the vector.
214
- * @param id - The ID of the vector to update.
215
- * @param update - An object containing the vector and/or metadata to update.
216
- * @param update.vector - An optional array of numbers representing the new vector.
217
- * @param update.metadata - An optional record containing the new metadata.
218
- * @param namespace - The namespace of the index (optional).
219
- * @returns A promise that resolves when the update is complete.
220
- * @throws Will throw an error if no updates are provided or if the update operation fails.
221
- */
222
- async updateIndexById(indexName, id, update, namespace) {
223
- this.logger.warn(
224
- `Deprecation Warning: updateIndexById() is deprecated.
225
- Please use updateVector() instead.
226
- updateIndexById() will be removed on May 20th, 2025.`
227
- );
228
- await this.updateVector(indexName, id, update, namespace);
229
- }
230
223
  /**
231
224
  * Updates a vector by its ID with the provided vector and/or metadata.
232
225
  * @param indexName - The name of the index containing the vector.
@@ -238,7 +231,7 @@ var PineconeVector = class extends vector.MastraVector {
238
231
  * @returns A promise that resolves when the update is complete.
239
232
  * @throws Will throw an error if no updates are provided or if the update operation fails.
240
233
  */
241
- async updateVector(indexName, id, update, namespace) {
234
+ async updateVector({ indexName, id, update, namespace }) {
242
235
  try {
243
236
  if (!update.vector && !update.metadata) {
244
237
  throw new Error("No updates provided");
@@ -256,24 +249,6 @@ var PineconeVector = class extends vector.MastraVector {
256
249
  throw new Error(`Failed to update vector by id: ${id} for index name: ${indexName}: ${error.message}`);
257
250
  }
258
251
  }
259
- /**
260
- * @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
261
- *
262
- * Deletes a vector by its ID.
263
- * @param indexName - The name of the index containing the vector.
264
- * @param id - The ID of the vector to delete.
265
- * @param namespace - The namespace of the index (optional).
266
- * @returns A promise that resolves when the deletion is complete.
267
- * @throws Will throw an error if the deletion operation fails.
268
- */
269
- async deleteIndexById(indexName, id, namespace) {
270
- this.logger.warn(
271
- `Deprecation Warning: deleteIndexById() is deprecated.
272
- Please use deleteVector() instead.
273
- deleteIndexById() will be removed on May 20th, 2025.`
274
- );
275
- await this.deleteVector(indexName, id, namespace);
276
- }
277
252
  /**
278
253
  * Deletes a vector by its ID.
279
254
  * @param indexName - The name of the index containing the vector.
@@ -282,7 +257,7 @@ var PineconeVector = class extends vector.MastraVector {
282
257
  * @returns A promise that resolves when the deletion is complete.
283
258
  * @throws Will throw an error if the deletion operation fails.
284
259
  */
285
- async deleteVector(indexName, id, namespace) {
260
+ async deleteVector({ indexName, id, namespace }) {
286
261
  try {
287
262
  const index = this.client.Index(indexName).namespace(namespace || "");
288
263
  await index.deleteOne(id);
package/dist/index.js CHANGED
@@ -83,7 +83,12 @@ var PineconeFilterTranslator = class extends BaseFilterTranslator {
83
83
  // src/vector/index.ts
84
84
  var PineconeVector = class extends MastraVector {
85
85
  client;
86
- constructor(apiKey, environment) {
86
+ /**
87
+ * Creates a new PineconeVector client.
88
+ * @param apiKey - The API key for Pinecone.
89
+ * @param environment - The environment for Pinecone.
90
+ */
91
+ constructor({ apiKey, environment }) {
87
92
  super();
88
93
  const opts = { apiKey };
89
94
  if (environment) {
@@ -101,9 +106,7 @@ var PineconeVector = class extends MastraVector {
101
106
  get indexSeparator() {
102
107
  return "-";
103
108
  }
104
- async createIndex(...args) {
105
- const params = this.normalizeArgs("createIndex", args);
106
- const { indexName, dimension, metric = "cosine" } = params;
109
+ async createIndex({ indexName, dimension, metric = "cosine" }) {
107
110
  if (!Number.isInteger(dimension) || dimension <= 0) {
108
111
  throw new Error("Dimension must be a positive integer");
109
112
  }
@@ -131,12 +134,14 @@ var PineconeVector = class extends MastraVector {
131
134
  throw error;
132
135
  }
133
136
  }
134
- async upsert(...args) {
135
- const params = this.normalizeArgs("upsert", args, [
136
- "namespace",
137
- "sparseVectors"
138
- ]);
139
- const { indexName, vectors, metadata, ids, namespace, sparseVectors } = params;
137
+ async upsert({
138
+ indexName,
139
+ vectors,
140
+ metadata,
141
+ ids,
142
+ namespace,
143
+ sparseVectors
144
+ }) {
140
145
  const index = this.client.Index(indexName).namespace(namespace || "");
141
146
  const vectorIds = ids || vectors.map(() => crypto.randomUUID());
142
147
  const records = vectors.map((vector, i) => ({
@@ -156,12 +161,15 @@ var PineconeVector = class extends MastraVector {
156
161
  const translator = new PineconeFilterTranslator();
157
162
  return translator.translate(filter);
158
163
  }
159
- async query(...args) {
160
- const params = this.normalizeArgs("query", args, [
161
- "namespace",
162
- "sparseVector"
163
- ]);
164
- const { indexName, queryVector, topK = 10, filter, includeVector = false, namespace, sparseVector } = params;
164
+ async query({
165
+ indexName,
166
+ queryVector,
167
+ topK = 10,
168
+ filter,
169
+ includeVector = false,
170
+ namespace,
171
+ sparseVector
172
+ }) {
165
173
  const index = this.client.Index(indexName).namespace(namespace || "");
166
174
  const translatedFilter = this.transformFilter(filter) ?? void 0;
167
175
  const queryParams = {
@@ -186,7 +194,13 @@ var PineconeVector = class extends MastraVector {
186
194
  const indexesResult = await this.client.listIndexes();
187
195
  return indexesResult?.indexes?.map((index) => index.name) || [];
188
196
  }
189
- async describeIndex(indexName) {
197
+ /**
198
+ * Retrieves statistics about a vector index.
199
+ *
200
+ * @param {string} indexName - The name of the index to describe
201
+ * @returns A promise that resolves to the index statistics including dimension, count and metric
202
+ */
203
+ async describeIndex({ indexName }) {
190
204
  const index = this.client.Index(indexName);
191
205
  const stats = await index.describeIndexStats();
192
206
  const description = await this.client.describeIndex(indexName);
@@ -197,34 +211,13 @@ var PineconeVector = class extends MastraVector {
197
211
  namespaces: stats.namespaces
198
212
  };
199
213
  }
200
- async deleteIndex(indexName) {
214
+ async deleteIndex({ indexName }) {
201
215
  try {
202
216
  await this.client.deleteIndex(indexName);
203
217
  } catch (error) {
204
218
  throw new Error(`Failed to delete Pinecone index: ${error.message}`);
205
219
  }
206
220
  }
207
- /**
208
- * @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
209
- *
210
- * Updates a vector by its ID with the provided vector and/or metadata.
211
- * @param indexName - The name of the index containing the vector.
212
- * @param id - The ID of the vector to update.
213
- * @param update - An object containing the vector and/or metadata to update.
214
- * @param update.vector - An optional array of numbers representing the new vector.
215
- * @param update.metadata - An optional record containing the new metadata.
216
- * @param namespace - The namespace of the index (optional).
217
- * @returns A promise that resolves when the update is complete.
218
- * @throws Will throw an error if no updates are provided or if the update operation fails.
219
- */
220
- async updateIndexById(indexName, id, update, namespace) {
221
- this.logger.warn(
222
- `Deprecation Warning: updateIndexById() is deprecated.
223
- Please use updateVector() instead.
224
- updateIndexById() will be removed on May 20th, 2025.`
225
- );
226
- await this.updateVector(indexName, id, update, namespace);
227
- }
228
221
  /**
229
222
  * Updates a vector by its ID with the provided vector and/or metadata.
230
223
  * @param indexName - The name of the index containing the vector.
@@ -236,7 +229,7 @@ var PineconeVector = class extends MastraVector {
236
229
  * @returns A promise that resolves when the update is complete.
237
230
  * @throws Will throw an error if no updates are provided or if the update operation fails.
238
231
  */
239
- async updateVector(indexName, id, update, namespace) {
232
+ async updateVector({ indexName, id, update, namespace }) {
240
233
  try {
241
234
  if (!update.vector && !update.metadata) {
242
235
  throw new Error("No updates provided");
@@ -254,24 +247,6 @@ var PineconeVector = class extends MastraVector {
254
247
  throw new Error(`Failed to update vector by id: ${id} for index name: ${indexName}: ${error.message}`);
255
248
  }
256
249
  }
257
- /**
258
- * @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
259
- *
260
- * Deletes a vector by its ID.
261
- * @param indexName - The name of the index containing the vector.
262
- * @param id - The ID of the vector to delete.
263
- * @param namespace - The namespace of the index (optional).
264
- * @returns A promise that resolves when the deletion is complete.
265
- * @throws Will throw an error if the deletion operation fails.
266
- */
267
- async deleteIndexById(indexName, id, namespace) {
268
- this.logger.warn(
269
- `Deprecation Warning: deleteIndexById() is deprecated.
270
- Please use deleteVector() instead.
271
- deleteIndexById() will be removed on May 20th, 2025.`
272
- );
273
- await this.deleteVector(indexName, id, namespace);
274
- }
275
250
  /**
276
251
  * Deletes a vector by its ID.
277
252
  * @param indexName - The name of the index containing the vector.
@@ -280,7 +255,7 @@ var PineconeVector = class extends MastraVector {
280
255
  * @returns A promise that resolves when the deletion is complete.
281
256
  * @throws Will throw an error if the deletion operation fails.
282
257
  */
283
- async deleteVector(indexName, id, namespace) {
258
+ async deleteVector({ indexName, id, namespace }) {
284
259
  try {
285
260
  const index = this.client.Index(indexName).namespace(namespace || "");
286
261
  await index.deleteOne(id);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/pinecone",
3
- "version": "0.2.13",
3
+ "version": "0.3.0-alpha.1",
4
4
  "description": "Pinecone vector store provider for Mastra",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -20,8 +20,7 @@
20
20
  },
21
21
  "license": "MIT",
22
22
  "dependencies": {
23
- "@pinecone-database/pinecone": "^3.0.3",
24
- "@mastra/core": "^0.9.4"
23
+ "@pinecone-database/pinecone": "^3.0.3"
25
24
  },
26
25
  "devDependencies": {
27
26
  "@microsoft/api-extractor": "^7.52.5",
@@ -31,7 +30,11 @@
31
30
  "tsup": "^8.4.0",
32
31
  "typescript": "^5.8.2",
33
32
  "vitest": "^3.1.2",
34
- "@internal/lint": "0.0.5"
33
+ "@internal/lint": "0.0.5",
34
+ "@mastra/core": "0.10.0-alpha.1"
35
+ },
36
+ "peerDependencies": {
37
+ "@mastra/core": "^0.9.4"
35
38
  },
36
39
  "scripts": {
37
40
  "build": "tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting",
@@ -36,7 +36,7 @@ function waitUntilReady(vectorDB: PineconeVector, indexName: string) {
36
36
  return new Promise(resolve => {
37
37
  const interval = setInterval(async () => {
38
38
  try {
39
- const stats = await vectorDB.describeIndex(indexName);
39
+ const stats = await vectorDB.describeIndex({ indexName });
40
40
  if (!!stats) {
41
41
  clearInterval(interval);
42
42
  resolve(true);
@@ -86,7 +86,7 @@ function waitUntilVectorsIndexed(
86
86
 
87
87
  const interval = setInterval(async () => {
88
88
  try {
89
- const stats = await vectorDB.describeIndex(indexName);
89
+ const stats = await vectorDB.describeIndex({ indexName });
90
90
  const check = exactCount ? stats?.count === expectedCount : stats?.count >= expectedCount;
91
91
  if (stats && check) {
92
92
  if (stats.count === lastCount) {
@@ -122,34 +122,36 @@ describe.skip('PineconeVector Integration Tests', () => {
122
122
  const dimension = 3;
123
123
 
124
124
  beforeAll(async () => {
125
- vectorDB = new PineconeVector(PINECONE_API_KEY);
125
+ vectorDB = new PineconeVector({
126
+ apiKey: PINECONE_API_KEY,
127
+ });
126
128
  // Delete test index
127
129
  try {
128
- await vectorDB.deleteIndex(testIndexName);
130
+ await vectorDB.deleteIndex({ indexName: testIndexName });
129
131
  await waitUntilIndexDeleted(vectorDB, testIndexName);
130
132
  } catch {
131
133
  // Ignore errors if index doesn't exist
132
134
  }
133
135
  try {
134
- await vectorDB.deleteIndex(indexNameUpdate);
136
+ await vectorDB.deleteIndex({ indexName: indexNameUpdate });
135
137
  await waitUntilIndexDeleted(vectorDB, indexNameUpdate);
136
138
  } catch {
137
139
  // Ignore errors if index doesn't exist
138
140
  }
139
141
  try {
140
- await vectorDB.deleteIndex(indexNameDelete);
142
+ await vectorDB.deleteIndex({ indexName: indexNameDelete });
141
143
  await waitUntilIndexDeleted(vectorDB, indexNameDelete);
142
144
  } catch {
143
145
  // Ignore errors if index doesn't exist
144
146
  }
145
147
  try {
146
- await vectorDB.deleteIndex(indexNameNamespace);
148
+ await vectorDB.deleteIndex({ indexName: indexNameNamespace });
147
149
  await waitUntilIndexDeleted(vectorDB, indexNameNamespace);
148
150
  } catch {
149
151
  // Ignore errors if index doesn't exist
150
152
  }
151
153
  try {
152
- await vectorDB.deleteIndex(indexNameHybrid);
154
+ await vectorDB.deleteIndex({ indexName: indexNameHybrid });
153
155
  await waitUntilIndexDeleted(vectorDB, indexNameHybrid);
154
156
  } catch {
155
157
  // Ignore errors if index doesn't exist
@@ -162,27 +164,27 @@ describe.skip('PineconeVector Integration Tests', () => {
162
164
  afterAll(async () => {
163
165
  // Cleanup: delete test index
164
166
  try {
165
- await vectorDB.deleteIndex(testIndexName);
167
+ await vectorDB.deleteIndex({ indexName: testIndexName });
166
168
  } catch {
167
169
  // Ignore errors if index doesn't exist
168
170
  }
169
171
  try {
170
- await vectorDB.deleteIndex(indexNameUpdate);
172
+ await vectorDB.deleteIndex({ indexName: indexNameUpdate });
171
173
  } catch {
172
174
  // Ignore errors if index doesn't exist
173
175
  }
174
176
  try {
175
- await vectorDB.deleteIndex(indexNameDelete);
177
+ await vectorDB.deleteIndex({ indexName: indexNameDelete });
176
178
  } catch {
177
179
  // Ignore errors if index doesn't exist
178
180
  }
179
181
  try {
180
- await vectorDB.deleteIndex(indexNameNamespace);
182
+ await vectorDB.deleteIndex({ indexName: indexNameNamespace });
181
183
  } catch {
182
184
  // Ignore errors if index doesn't exist
183
185
  }
184
186
  try {
185
- await vectorDB.deleteIndex(indexNameHybrid);
187
+ await vectorDB.deleteIndex({ indexName: indexNameHybrid });
186
188
  } catch {
187
189
  // Ignore errors if index doesn't exist
188
190
  }
@@ -195,7 +197,7 @@ describe.skip('PineconeVector Integration Tests', () => {
195
197
  }, 500000);
196
198
 
197
199
  it('should describe index with correct properties', async () => {
198
- const stats = await vectorDB.describeIndex(testIndexName);
200
+ const stats = await vectorDB.describeIndex({ indexName: testIndexName });
199
201
  expect(stats.dimension).toBe(dimension);
200
202
  expect(stats.metric).toBe('cosine');
201
203
  expect(typeof stats.count).toBe('number');
@@ -260,7 +262,7 @@ describe.skip('PineconeVector Integration Tests', () => {
260
262
 
261
263
  afterEach(async () => {
262
264
  try {
263
- await vectorDB.deleteIndex(indexNameUpdate);
265
+ await vectorDB.deleteIndex({ indexName: indexNameUpdate });
264
266
  await waitUntilIndexDeleted(vectorDB, indexNameUpdate);
265
267
  } catch {
266
268
  // Ignore errors if index doesn't exist
@@ -282,7 +284,7 @@ describe.skip('PineconeVector Integration Tests', () => {
282
284
  metadata: newMetaData,
283
285
  };
284
286
 
285
- await vectorDB.updateVector(indexNameUpdate, idToBeUpdated, update);
287
+ await vectorDB.updateVector({ indexName: indexNameUpdate, id: idToBeUpdated, update });
286
288
 
287
289
  await waitUntilVectorsIndexed(vectorDB, indexNameUpdate, 3);
288
290
 
@@ -311,7 +313,7 @@ describe.skip('PineconeVector Integration Tests', () => {
311
313
  metadata: newMetaData,
312
314
  };
313
315
 
314
- await vectorDB.updateVector(indexNameUpdate, idToBeUpdated, update);
316
+ await vectorDB.updateVector({ indexName: indexNameUpdate, id: idToBeUpdated, update });
315
317
 
316
318
  await waitUntilVectorsIndexed(vectorDB, indexNameUpdate, 3);
317
319
 
@@ -338,7 +340,7 @@ describe.skip('PineconeVector Integration Tests', () => {
338
340
  vector: newVector,
339
341
  };
340
342
 
341
- await vectorDB.updateVector(indexNameUpdate, idToBeUpdated, update);
343
+ await vectorDB.updateVector({ indexName: indexNameUpdate, id: idToBeUpdated, update });
342
344
 
343
345
  await waitUntilVectorsIndexed(vectorDB, indexNameUpdate, 3);
344
346
 
@@ -355,12 +357,16 @@ describe.skip('PineconeVector Integration Tests', () => {
355
357
  }, 500000);
356
358
 
357
359
  it('should throw exception when no updates are given', async () => {
358
- await expect(vectorDB.updateVector(indexNameUpdate, 'id', {})).rejects.toThrow('No updates provided');
360
+ await expect(vectorDB.updateVector({ indexName: indexNameUpdate, id: 'id', update: {} })).rejects.toThrow(
361
+ 'No updates provided',
362
+ );
359
363
  });
360
364
 
361
365
  it('should throw error for non-existent index', async () => {
362
366
  const nonExistentIndex = 'non-existent-index';
363
- await expect(vectorDB.updateVector(nonExistentIndex, 'test-id', { vector: [1, 2, 3] })).rejects.toThrow();
367
+ await expect(
368
+ vectorDB.updateVector({ indexName: nonExistentIndex, id: 'test-id', update: { vector: [1, 2, 3] } }),
369
+ ).rejects.toThrow();
364
370
  });
365
371
 
366
372
  it('should throw error for invalid vector dimension', async () => {
@@ -371,7 +377,7 @@ describe.skip('PineconeVector Integration Tests', () => {
371
377
  });
372
378
 
373
379
  await expect(
374
- vectorDB.updateVector(indexNameUpdate, id, { vector: [1, 2] }), // Wrong dimension
380
+ vectorDB.updateVector({ indexName: indexNameUpdate, id, update: { vector: [1, 2] } }), // Wrong dimension
375
381
  ).rejects.toThrow();
376
382
  }, 500000);
377
383
  });
@@ -390,7 +396,7 @@ describe.skip('PineconeVector Integration Tests', () => {
390
396
 
391
397
  afterEach(async () => {
392
398
  try {
393
- await vectorDB.deleteIndex(indexNameDelete);
399
+ await vectorDB.deleteIndex({ indexName: indexNameDelete });
394
400
  await waitUntilIndexDeleted(vectorDB, indexNameDelete);
395
401
  } catch {
396
402
  // Ignore errors if index doesn't exist
@@ -402,7 +408,7 @@ describe.skip('PineconeVector Integration Tests', () => {
402
408
  expect(ids).toHaveLength(3);
403
409
  const idToBeDeleted = ids[0];
404
410
 
405
- await vectorDB.deleteVector(indexNameDelete, idToBeDeleted);
411
+ await vectorDB.deleteVector({ indexName: indexNameDelete, id: idToBeDeleted });
406
412
  await waitUntilVectorsIndexed(vectorDB, indexNameDelete, 2, true);
407
413
 
408
414
  // Query all vectors similar to the deleted one
@@ -432,7 +438,7 @@ describe.skip('PineconeVector Integration Tests', () => {
432
438
 
433
439
  afterEach(async () => {
434
440
  try {
435
- await vectorDB.deleteIndex(indexNameNamespace);
441
+ await vectorDB.deleteIndex({ indexName: indexNameNamespace });
436
442
  await waitUntilIndexDeleted(vectorDB, indexNameNamespace);
437
443
  } catch {
438
444
  // Ignore errors if index doesn't exist
@@ -490,7 +496,12 @@ describe.skip('PineconeVector Integration Tests', () => {
490
496
  await waitUntilVectorsIndexed(vectorDB, indexNameNamespace, 1);
491
497
 
492
498
  // Update in namespace1
493
- await vectorDB.updateVector(indexNameNamespace, id, { metadata: { label: 'updated' } }, namespace1);
499
+ await vectorDB.updateVector({
500
+ indexName: indexNameNamespace,
501
+ id,
502
+ update: { metadata: { label: 'updated' } },
503
+ namespace: namespace1,
504
+ });
494
505
 
495
506
  await waitUntilVectorsIndexed(vectorDB, indexNameNamespace, 1);
496
507
 
@@ -515,7 +526,7 @@ describe.skip('PineconeVector Integration Tests', () => {
515
526
  await waitUntilVectorsIndexed(vectorDB, indexNameNamespace, 1);
516
527
 
517
528
  // Delete from namespace1
518
- await vectorDB.deleteVector(indexNameNamespace, id, namespace1);
529
+ await vectorDB.deleteVector({ indexName: indexNameNamespace, id, namespace: namespace1 });
519
530
 
520
531
  await waitUntilVectorsIndexed(vectorDB, indexNameNamespace, 0, true);
521
532
 
@@ -545,7 +556,7 @@ describe.skip('PineconeVector Integration Tests', () => {
545
556
  });
546
557
  await waitUntilVectorsIndexed(vectorDB, indexNameNamespace, 2);
547
558
 
548
- const stats = await vectorDB.describeIndex(indexNameNamespace);
559
+ const stats = await vectorDB.describeIndex({ indexName: indexNameNamespace });
549
560
  expect(stats.namespaces).toBeDefined();
550
561
  expect(stats.namespaces?.[namespace1]).toBeDefined();
551
562
  expect(stats.namespaces?.[namespace2]).toBeDefined();
@@ -561,7 +572,7 @@ describe.skip('PineconeVector Integration Tests', () => {
561
572
  });
562
573
 
563
574
  afterAll(async () => {
564
- await vectorDB.deleteIndex(testIndexName);
575
+ await vectorDB.deleteIndex({ indexName: testIndexName });
565
576
  });
566
577
  it('should handle non-existent index query gracefully', async () => {
567
578
  const nonExistentIndex = 'non-existent-index';
@@ -623,7 +634,7 @@ describe.skip('PineconeVector Integration Tests', () => {
623
634
  infoSpy.mockRestore();
624
635
  warnSpy.mockRestore();
625
636
  // Cleanup
626
- await vectorDB.deleteIndex(duplicateIndexName);
637
+ await vectorDB.deleteIndex({ indexName: duplicateIndexName });
627
638
  }
628
639
  });
629
640
  });
@@ -1402,7 +1413,7 @@ describe.skip('PineconeVector Integration Tests', () => {
1402
1413
 
1403
1414
  afterEach(async () => {
1404
1415
  try {
1405
- await vectorDB.deleteIndex(indexNameHybrid);
1416
+ await vectorDB.deleteIndex({ indexName: indexNameHybrid });
1406
1417
  await waitUntilIndexDeleted(vectorDB, indexNameHybrid);
1407
1418
  } catch {
1408
1419
  // Ignore errors if index doesn't exist
@@ -1467,144 +1478,4 @@ describe.skip('PineconeVector Integration Tests', () => {
1467
1478
  expect(hybridResults).toHaveLength(1);
1468
1479
  });
1469
1480
  });
1470
-
1471
- describe('Deprecation Warnings', () => {
1472
- const indexName = 'testdeprecationwarnings';
1473
-
1474
- const indexName2 = 'testdeprecationwarnings2';
1475
-
1476
- const indexName3 = 'testdeprecationwarnings3';
1477
-
1478
- const indexName4 = 'testdeprecationwarnings4';
1479
-
1480
- let warnSpy;
1481
-
1482
- beforeAll(async () => {
1483
- try {
1484
- await vectorDB.deleteIndex(indexName);
1485
- } catch {
1486
- // Ignore errors if index doesn't exist
1487
- }
1488
- try {
1489
- await vectorDB.deleteIndex(indexName2);
1490
- } catch {
1491
- // Ignore errors if index doesn't exist
1492
- }
1493
- try {
1494
- await vectorDB.deleteIndex(indexName3);
1495
- } catch {
1496
- // Ignore errors if index doesn't exist
1497
- }
1498
- try {
1499
- await vectorDB.deleteIndex(indexName4);
1500
- } catch {
1501
- // Ignore errors if index doesn't exist
1502
- }
1503
- await vectorDB.createIndex({ indexName: indexName, dimension: 3 });
1504
- await waitUntilReady(vectorDB, indexName);
1505
- });
1506
-
1507
- afterAll(async () => {
1508
- try {
1509
- await vectorDB.deleteIndex(indexName);
1510
- } catch {
1511
- // Ignore errors if index doesn't exist
1512
- }
1513
- try {
1514
- await vectorDB.deleteIndex(indexName2);
1515
- } catch {
1516
- // Ignore errors if index doesn't exist
1517
- }
1518
- try {
1519
- await vectorDB.deleteIndex(indexName3);
1520
- } catch {
1521
- // Ignore errors if index doesn't exist
1522
- }
1523
- try {
1524
- await vectorDB.deleteIndex(indexName4);
1525
- } catch {
1526
- // Ignore errors if index doesn't exist
1527
- }
1528
- });
1529
-
1530
- beforeEach(async () => {
1531
- warnSpy = vi.spyOn(vectorDB['logger'], 'warn');
1532
- });
1533
-
1534
- afterEach(async () => {
1535
- warnSpy.mockRestore();
1536
- });
1537
-
1538
- it('should show deprecation warning when using individual args for createIndex', async () => {
1539
- await vectorDB.createIndex(indexName2, 3, 'cosine');
1540
- await waitUntilReady(vectorDB, indexName2);
1541
- expect(warnSpy).toHaveBeenCalledWith(
1542
- expect.stringContaining('Deprecation Warning: Passing individual arguments to createIndex() is deprecated'),
1543
- );
1544
- });
1545
-
1546
- it('should show deprecation warning when using individual args for upsert', async () => {
1547
- await vectorDB.upsert(indexName, [[1, 2, 3]], [{ test: 'data' }]);
1548
-
1549
- expect(warnSpy).toHaveBeenCalledWith(
1550
- expect.stringContaining('Deprecation Warning: Passing individual arguments to upsert() is deprecated'),
1551
- );
1552
- });
1553
-
1554
- it('should show deprecation warning when using individual args for query', async () => {
1555
- await vectorDB.query(indexName, [1, 2, 3], 5);
1556
-
1557
- expect(warnSpy).toHaveBeenCalledWith(
1558
- expect.stringContaining('Deprecation Warning: Passing individual arguments to query() is deprecated'),
1559
- );
1560
- });
1561
-
1562
- it('should not show deprecation warning when using object param for query', async () => {
1563
- await vectorDB.query({
1564
- indexName,
1565
- queryVector: [1, 2, 3],
1566
- topK: 5,
1567
- });
1568
-
1569
- expect(warnSpy).not.toHaveBeenCalled();
1570
- });
1571
-
1572
- it('should not show deprecation warning when using object param for createIndex', async () => {
1573
- await vectorDB.createIndex({
1574
- indexName: indexName3,
1575
- dimension: 3,
1576
- metric: 'cosine',
1577
- });
1578
-
1579
- expect(warnSpy).not.toHaveBeenCalled();
1580
- });
1581
-
1582
- it('should not show deprecation warning when using object param for upsert', async () => {
1583
- await vectorDB.upsert({
1584
- indexName,
1585
- vectors: [[1, 2, 3]],
1586
- metadata: [{ test: 'data' }],
1587
- });
1588
-
1589
- expect(warnSpy).not.toHaveBeenCalled();
1590
- });
1591
-
1592
- it('should maintain backward compatibility with individual args', async () => {
1593
- // Query
1594
- const queryResults = await vectorDB.query(indexName, [1, 2, 3], 5);
1595
- expect(Array.isArray(queryResults)).toBe(true);
1596
-
1597
- // CreateIndex
1598
- await expect(vectorDB.createIndex(indexName4, 3, 'cosine')).resolves.not.toThrow();
1599
- await waitUntilReady(vectorDB, indexName4);
1600
- // Upsert
1601
- const upsertResults = await vectorDB.upsert({
1602
- indexName,
1603
- vectors: [[1, 2, 3]],
1604
- metadata: [{ test: 'data' }],
1605
- });
1606
- expect(Array.isArray(upsertResults)).toBe(true);
1607
- expect(upsertResults).toHaveLength(1);
1608
- });
1609
- });
1610
1481
  });
@@ -5,9 +5,10 @@ import type {
5
5
  CreateIndexParams,
6
6
  UpsertVectorParams,
7
7
  QueryVectorParams,
8
- ParamsToArgs,
9
- QueryVectorArgs,
10
- UpsertVectorArgs,
8
+ DescribeIndexParams,
9
+ DeleteIndexParams,
10
+ DeleteVectorParams,
11
+ UpdateVectorParams,
11
12
  } from '@mastra/core/vector';
12
13
  import type { VectorFilter } from '@mastra/core/vector/filter';
13
14
  import { Pinecone } from '@pinecone-database/pinecone';
@@ -29,27 +30,33 @@ interface PineconeQueryVectorParams extends QueryVectorParams {
29
30
  sparseVector?: RecordSparseValues;
30
31
  }
31
32
 
32
- type PineconeQueryVectorArgs = [...QueryVectorArgs, string?, RecordSparseValues?];
33
-
34
33
  interface PineconeUpsertVectorParams extends UpsertVectorParams {
35
34
  namespace?: string;
36
35
  sparseVectors?: RecordSparseValues[];
37
36
  }
38
37
 
39
- type PineconeUpsertVectorArgs = [...UpsertVectorArgs, string?, RecordSparseValues[]?];
38
+ interface PineconeUpdateVectorParams extends UpdateVectorParams {
39
+ namespace?: string;
40
+ }
41
+
42
+ interface PineconeDeleteVectorParams extends DeleteVectorParams {
43
+ namespace?: string;
44
+ }
40
45
 
41
46
  export class PineconeVector extends MastraVector {
42
47
  private client: Pinecone;
43
48
 
44
- constructor(apiKey: string, environment?: string) {
49
+ /**
50
+ * Creates a new PineconeVector client.
51
+ * @param apiKey - The API key for Pinecone.
52
+ * @param environment - The environment for Pinecone.
53
+ */
54
+ constructor({ apiKey, environment }: { apiKey: string; environment?: string }) {
45
55
  super();
46
-
47
56
  const opts: { apiKey: string; controllerHostUrl?: string } = { apiKey };
48
-
49
57
  if (environment) {
50
58
  opts['controllerHostUrl'] = environment;
51
59
  }
52
-
53
60
  const baseClient = new Pinecone(opts);
54
61
  const telemetry = this.__getTelemetry();
55
62
  this.client =
@@ -65,11 +72,7 @@ export class PineconeVector extends MastraVector {
65
72
  return '-';
66
73
  }
67
74
 
68
- async createIndex(...args: ParamsToArgs<CreateIndexParams>): Promise<void> {
69
- const params = this.normalizeArgs<CreateIndexParams>('createIndex', args);
70
-
71
- const { indexName, dimension, metric = 'cosine' } = params;
72
-
75
+ async createIndex({ indexName, dimension, metric = 'cosine' }: CreateIndexParams): Promise<void> {
73
76
  if (!Number.isInteger(dimension) || dimension <= 0) {
74
77
  throw new Error('Dimension must be a positive integer');
75
78
  }
@@ -105,14 +108,14 @@ export class PineconeVector extends MastraVector {
105
108
  }
106
109
  }
107
110
 
108
- async upsert(...args: ParamsToArgs<PineconeUpsertVectorParams> | PineconeUpsertVectorArgs): Promise<string[]> {
109
- const params = this.normalizeArgs<PineconeUpsertVectorParams, PineconeUpsertVectorArgs>('upsert', args, [
110
- 'namespace',
111
- 'sparseVectors',
112
- ]);
113
-
114
- const { indexName, vectors, metadata, ids, namespace, sparseVectors } = params;
115
-
111
+ async upsert({
112
+ indexName,
113
+ vectors,
114
+ metadata,
115
+ ids,
116
+ namespace,
117
+ sparseVectors,
118
+ }: PineconeUpsertVectorParams): Promise<string[]> {
116
119
  const index = this.client.Index(indexName).namespace(namespace || '');
117
120
 
118
121
  // Generate IDs if not provided
@@ -140,14 +143,15 @@ export class PineconeVector extends MastraVector {
140
143
  return translator.translate(filter);
141
144
  }
142
145
 
143
- async query(...args: ParamsToArgs<PineconeQueryVectorParams> | PineconeQueryVectorArgs): Promise<QueryResult[]> {
144
- const params = this.normalizeArgs<PineconeQueryVectorParams, PineconeQueryVectorArgs>('query', args, [
145
- 'namespace',
146
- 'sparseVector',
147
- ]);
148
-
149
- const { indexName, queryVector, topK = 10, filter, includeVector = false, namespace, sparseVector } = params;
150
-
146
+ async query({
147
+ indexName,
148
+ queryVector,
149
+ topK = 10,
150
+ filter,
151
+ includeVector = false,
152
+ namespace,
153
+ sparseVector,
154
+ }: PineconeQueryVectorParams): Promise<QueryResult[]> {
151
155
  const index = this.client.Index(indexName).namespace(namespace || '');
152
156
 
153
157
  const translatedFilter = this.transformFilter(filter) ?? undefined;
@@ -180,7 +184,13 @@ export class PineconeVector extends MastraVector {
180
184
  return indexesResult?.indexes?.map(index => index.name) || [];
181
185
  }
182
186
 
183
- async describeIndex(indexName: string): Promise<PineconeIndexStats> {
187
+ /**
188
+ * Retrieves statistics about a vector index.
189
+ *
190
+ * @param {string} indexName - The name of the index to describe
191
+ * @returns A promise that resolves to the index statistics including dimension, count and metric
192
+ */
193
+ async describeIndex({ indexName }: DescribeIndexParams): Promise<PineconeIndexStats> {
184
194
  const index = this.client.Index(indexName);
185
195
  const stats = await index.describeIndexStats();
186
196
  const description = await this.client.describeIndex(indexName);
@@ -193,39 +203,13 @@ export class PineconeVector extends MastraVector {
193
203
  };
194
204
  }
195
205
 
196
- async deleteIndex(indexName: string): Promise<void> {
206
+ async deleteIndex({ indexName }: DeleteIndexParams): Promise<void> {
197
207
  try {
198
208
  await this.client.deleteIndex(indexName);
199
209
  } catch (error: any) {
200
210
  throw new Error(`Failed to delete Pinecone index: ${error.message}`);
201
211
  }
202
212
  }
203
- /**
204
- * @deprecated Use {@link updateVector} instead. This method will be removed on May 20th, 2025.
205
- *
206
- * Updates a vector by its ID with the provided vector and/or metadata.
207
- * @param indexName - The name of the index containing the vector.
208
- * @param id - The ID of the vector to update.
209
- * @param update - An object containing the vector and/or metadata to update.
210
- * @param update.vector - An optional array of numbers representing the new vector.
211
- * @param update.metadata - An optional record containing the new metadata.
212
- * @param namespace - The namespace of the index (optional).
213
- * @returns A promise that resolves when the update is complete.
214
- * @throws Will throw an error if no updates are provided or if the update operation fails.
215
- */
216
- async updateIndexById(
217
- indexName: string,
218
- id: string,
219
- update: { vector?: number[]; metadata?: Record<string, any> },
220
- namespace?: string,
221
- ): Promise<void> {
222
- this.logger.warn(
223
- `Deprecation Warning: updateIndexById() is deprecated.
224
- Please use updateVector() instead.
225
- updateIndexById() will be removed on May 20th, 2025.`,
226
- );
227
- await this.updateVector(indexName, id, update, namespace);
228
- }
229
213
 
230
214
  /**
231
215
  * Updates a vector by its ID with the provided vector and/or metadata.
@@ -238,15 +222,7 @@ export class PineconeVector extends MastraVector {
238
222
  * @returns A promise that resolves when the update is complete.
239
223
  * @throws Will throw an error if no updates are provided or if the update operation fails.
240
224
  */
241
- async updateVector(
242
- indexName: string,
243
- id: string,
244
- update: {
245
- vector?: number[];
246
- metadata?: Record<string, any>;
247
- },
248
- namespace?: string,
249
- ): Promise<void> {
225
+ async updateVector({ indexName, id, update, namespace }: PineconeUpdateVectorParams): Promise<void> {
250
226
  try {
251
227
  if (!update.vector && !update.metadata) {
252
228
  throw new Error('No updates provided');
@@ -270,25 +246,6 @@ export class PineconeVector extends MastraVector {
270
246
  }
271
247
  }
272
248
 
273
- /**
274
- * @deprecated Use {@link deleteVector} instead. This method will be removed on May 20th, 2025.
275
- *
276
- * Deletes a vector by its ID.
277
- * @param indexName - The name of the index containing the vector.
278
- * @param id - The ID of the vector to delete.
279
- * @param namespace - The namespace of the index (optional).
280
- * @returns A promise that resolves when the deletion is complete.
281
- * @throws Will throw an error if the deletion operation fails.
282
- */
283
- async deleteIndexById(indexName: string, id: string, namespace?: string): Promise<void> {
284
- this.logger.warn(
285
- `Deprecation Warning: deleteIndexById() is deprecated.
286
- Please use deleteVector() instead.
287
- deleteIndexById() will be removed on May 20th, 2025.`,
288
- );
289
- await this.deleteVector(indexName, id, namespace);
290
- }
291
-
292
249
  /**
293
250
  * Deletes a vector by its ID.
294
251
  * @param indexName - The name of the index containing the vector.
@@ -297,7 +254,7 @@ export class PineconeVector extends MastraVector {
297
254
  * @returns A promise that resolves when the deletion is complete.
298
255
  * @throws Will throw an error if the deletion operation fails.
299
256
  */
300
- async deleteVector(indexName: string, id: string, namespace?: string): Promise<void> {
257
+ async deleteVector({ indexName, id, namespace }: PineconeDeleteVectorParams): Promise<void> {
301
258
  try {
302
259
  const index = this.client.Index(indexName).namespace(namespace || '');
303
260
  await index.deleteOne(id);