@vectororm/adapter-pinecone 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +99 -0
- package/dist/index.cjs +349 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +62 -0
- package/dist/index.d.ts +62 -0
- package/dist/index.js +324 -0
- package/dist/index.js.map +1 -0
- package/package.json +57 -0
package/README.md
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# @vectororm/adapter-pinecone
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@vectororm/adapter-pinecone)
|
|
4
|
+
[](https://opensource.org/licenses/Apache-2.0)
|
|
5
|
+
|
|
6
|
+
[Pinecone](https://www.pinecone.io/) adapter for [Glyph VectorORM](https://github.com/aviramroi/VectorORM).
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install @vectororm/core @vectororm/adapter-pinecone
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Prerequisites
|
|
15
|
+
|
|
16
|
+
A Pinecone account and API key. Set up at [pinecone.io](https://www.pinecone.io/).
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
### Standalone Adapter
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
import { PineconeAdapter } from '@vectororm/adapter-pinecone';
|
|
24
|
+
|
|
25
|
+
const adapter = new PineconeAdapter({
|
|
26
|
+
apiKey: process.env.PINECONE_API_KEY!,
|
|
27
|
+
environment: 'us-east-1-aws'
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
await adapter.connect();
|
|
31
|
+
|
|
32
|
+
// Create an index
|
|
33
|
+
await adapter.createCollection('my-index', 1536, 'cosine');
|
|
34
|
+
|
|
35
|
+
// Upsert vectors
|
|
36
|
+
await adapter.upsert('my-index', [
|
|
37
|
+
{
|
|
38
|
+
id: 'doc-1',
|
|
39
|
+
embedding: [0.1, 0.2, ...],
|
|
40
|
+
metadata: { title: 'My Document', __v_partition: 'finance' },
|
|
41
|
+
text: 'Document content...'
|
|
42
|
+
}
|
|
43
|
+
]);
|
|
44
|
+
|
|
45
|
+
// Search with filters
|
|
46
|
+
const results = await adapter.search('my-index', queryVector, {
|
|
47
|
+
topK: 10,
|
|
48
|
+
filter: { field: '__v_partition', op: 'eq', value: 'finance' }
|
|
49
|
+
});
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### With RAGClient
|
|
53
|
+
|
|
54
|
+
```typescript
|
|
55
|
+
import { RAGClient } from '@vectororm/core';
|
|
56
|
+
import { PineconeAdapter } from '@vectororm/adapter-pinecone';
|
|
57
|
+
|
|
58
|
+
const client = new RAGClient({
|
|
59
|
+
adapter: new PineconeAdapter({
|
|
60
|
+
apiKey: process.env.PINECONE_API_KEY!,
|
|
61
|
+
environment: 'us-east-1-aws'
|
|
62
|
+
}),
|
|
63
|
+
embedder: myEmbedder,
|
|
64
|
+
llm: myLLM,
|
|
65
|
+
defaultCollection: 'docs'
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
await client.createCollection('docs');
|
|
69
|
+
await client.ingest(['documents/*.pdf'], 'docs');
|
|
70
|
+
const result = await client.retrieve('search query');
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Configuration
|
|
74
|
+
|
|
75
|
+
```typescript
|
|
76
|
+
interface PineconeConfig {
|
|
77
|
+
apiKey: string; // Required: Pinecone API key
|
|
78
|
+
environment: string; // Required: Pinecone environment (e.g., 'us-east-1-aws')
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Environment variable fallbacks: `PINECONE_API_KEY`, `PINECONE_ENVIRONMENT`.
|
|
83
|
+
|
|
84
|
+
## Features
|
|
85
|
+
|
|
86
|
+
- Full CRUD operations (upsert, fetch, delete)
|
|
87
|
+
- Metadata filtering with Pinecone-native filter translation (`$eq`, `$in`, `$gt`, etc.)
|
|
88
|
+
- Index management (create, delete, exists, stats)
|
|
89
|
+
- Namespace support for multi-tenant isolation
|
|
90
|
+
- Paginated iteration for enrichment pipelines
|
|
91
|
+
|
|
92
|
+
## Documentation
|
|
93
|
+
|
|
94
|
+
- [API Guide](https://github.com/aviramroi/VectorORM/blob/main/docs/guide.md)
|
|
95
|
+
- [Full Project](https://github.com/aviramroi/VectorORM)
|
|
96
|
+
|
|
97
|
+
## License
|
|
98
|
+
|
|
99
|
+
Apache-2.0
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
PineconeAdapter: () => PineconeAdapter
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(index_exports);
|
|
26
|
+
|
|
27
|
+
// src/pinecone-adapter.ts
|
|
28
|
+
var import_core = require("@vectororm/core");
|
|
29
|
+
var import_pinecone = require("@pinecone-database/pinecone");
|
|
30
|
+
var PineconeAdapter = class extends import_core.VectorDBAdapter {
|
|
31
|
+
config;
|
|
32
|
+
client = null;
|
|
33
|
+
constructor(config) {
|
|
34
|
+
super();
|
|
35
|
+
if (!config.apiKey) {
|
|
36
|
+
throw new Error(
|
|
37
|
+
"PineconeAdapter: apiKey is required in config or PINECONE_API_KEY environment variable"
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
this.config = config;
|
|
41
|
+
}
|
|
42
|
+
// ============================================================================
|
|
43
|
+
// CONNECTION MANAGEMENT
|
|
44
|
+
// ============================================================================
|
|
45
|
+
async connect() {
|
|
46
|
+
try {
|
|
47
|
+
this.client = new import_pinecone.Pinecone({
|
|
48
|
+
apiKey: this.config.apiKey
|
|
49
|
+
});
|
|
50
|
+
await this.client.listIndexes();
|
|
51
|
+
} catch (error) {
|
|
52
|
+
throw new Error(
|
|
53
|
+
`Pinecone connection failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
54
|
+
{ cause: error }
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
async disconnect() {
|
|
59
|
+
this.client = null;
|
|
60
|
+
}
|
|
61
|
+
async isConnected() {
|
|
62
|
+
return this.client !== null;
|
|
63
|
+
}
|
|
64
|
+
// ============================================================================
|
|
65
|
+
// COLLECTION MANAGEMENT
|
|
66
|
+
// ============================================================================
|
|
67
|
+
async createCollection(name, dimension, metric = "cosine") {
|
|
68
|
+
if (!this.client) {
|
|
69
|
+
throw new Error("Not connected. Call connect() first.");
|
|
70
|
+
}
|
|
71
|
+
try {
|
|
72
|
+
const pineconeMetric = metric === "dotProduct" ? "dotproduct" : metric;
|
|
73
|
+
await this.client.createIndex({
|
|
74
|
+
name,
|
|
75
|
+
dimension,
|
|
76
|
+
metric: pineconeMetric,
|
|
77
|
+
spec: {
|
|
78
|
+
serverless: {
|
|
79
|
+
cloud: "aws",
|
|
80
|
+
region: "us-east-1"
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
} catch (error) {
|
|
85
|
+
throw new Error(
|
|
86
|
+
`Failed to create Pinecone index ${name}: ${error instanceof Error ? error.message : String(error)}`,
|
|
87
|
+
{ cause: error }
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
async deleteCollection(name) {
|
|
92
|
+
if (!this.client) {
|
|
93
|
+
throw new Error("Not connected. Call connect() first.");
|
|
94
|
+
}
|
|
95
|
+
try {
|
|
96
|
+
await this.client.deleteIndex(name);
|
|
97
|
+
} catch (error) {
|
|
98
|
+
throw new Error(
|
|
99
|
+
`Failed to delete Pinecone index ${name}: ${error instanceof Error ? error.message : String(error)}`,
|
|
100
|
+
{ cause: error }
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
async collectionExists(name) {
|
|
105
|
+
if (!this.client) {
|
|
106
|
+
throw new Error("Not connected. Call connect() first.");
|
|
107
|
+
}
|
|
108
|
+
try {
|
|
109
|
+
const indexes = await this.client.listIndexes();
|
|
110
|
+
return indexes.indexes?.some((idx) => idx.name === name) ?? false;
|
|
111
|
+
} catch (error) {
|
|
112
|
+
throw new Error(
|
|
113
|
+
`Failed to check if Pinecone index ${name} exists: ${error instanceof Error ? error.message : String(error)}`,
|
|
114
|
+
{ cause: error }
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
async getCollectionStats(name) {
|
|
119
|
+
if (!this.client) {
|
|
120
|
+
throw new Error("Not connected. Call connect() first.");
|
|
121
|
+
}
|
|
122
|
+
try {
|
|
123
|
+
const index = this.client.index(name);
|
|
124
|
+
const stats = await index.describeIndexStats();
|
|
125
|
+
return {
|
|
126
|
+
vectorCount: stats.totalRecordCount ?? 0,
|
|
127
|
+
dimension: stats.dimension ?? 0,
|
|
128
|
+
metric: "cosine",
|
|
129
|
+
// Pinecone doesn't return metric in stats, default to cosine
|
|
130
|
+
...stats
|
|
131
|
+
};
|
|
132
|
+
} catch (error) {
|
|
133
|
+
throw new Error(
|
|
134
|
+
`Failed to get Pinecone index stats for ${name}: ${error instanceof Error ? error.message : String(error)}`,
|
|
135
|
+
{ cause: error }
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
// ============================================================================
|
|
140
|
+
// VECTOR OPERATIONS
|
|
141
|
+
// ============================================================================
|
|
142
|
+
async upsert(collection, records) {
|
|
143
|
+
if (!this.client) {
|
|
144
|
+
throw new Error("Not connected. Call connect() first.");
|
|
145
|
+
}
|
|
146
|
+
try {
|
|
147
|
+
const index = this.client.index(collection);
|
|
148
|
+
const pineconeRecords = records.map((record) => ({
|
|
149
|
+
id: record.id,
|
|
150
|
+
values: record.embedding,
|
|
151
|
+
metadata: record.metadata
|
|
152
|
+
}));
|
|
153
|
+
await index.upsert(pineconeRecords);
|
|
154
|
+
} catch (error) {
|
|
155
|
+
throw new Error(
|
|
156
|
+
`Failed to upsert vectors to Pinecone index ${collection}: ${error instanceof Error ? error.message : String(error)}`,
|
|
157
|
+
{ cause: error }
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
async fetch(collection, ids) {
|
|
162
|
+
if (!this.client) {
|
|
163
|
+
throw new Error("Not connected. Call connect() first.");
|
|
164
|
+
}
|
|
165
|
+
try {
|
|
166
|
+
const index = this.client.index(collection);
|
|
167
|
+
const response = await index.fetch(ids);
|
|
168
|
+
return Object.entries(response.records || {}).map(([id, record]) => ({
|
|
169
|
+
id,
|
|
170
|
+
embedding: record.values || [],
|
|
171
|
+
metadata: record.metadata || {}
|
|
172
|
+
}));
|
|
173
|
+
} catch (error) {
|
|
174
|
+
throw new Error(
|
|
175
|
+
`Failed to fetch vectors from Pinecone index ${collection}: ${error instanceof Error ? error.message : String(error)}`,
|
|
176
|
+
{ cause: error }
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
async delete(collection, ids) {
|
|
181
|
+
if (!this.client) {
|
|
182
|
+
throw new Error("Not connected. Call connect() first.");
|
|
183
|
+
}
|
|
184
|
+
try {
|
|
185
|
+
const index = this.client.index(collection);
|
|
186
|
+
await index.deleteMany(ids);
|
|
187
|
+
} catch (error) {
|
|
188
|
+
throw new Error(
|
|
189
|
+
`Failed to delete vectors from Pinecone index ${collection}: ${error instanceof Error ? error.message : String(error)}`,
|
|
190
|
+
{ cause: error }
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
// ============================================================================
|
|
195
|
+
// METADATA OPERATIONS
|
|
196
|
+
// ============================================================================
|
|
197
|
+
async updateMetadata(collection, updates) {
|
|
198
|
+
if (!this.client) {
|
|
199
|
+
throw new Error("Not connected. Call connect() first.");
|
|
200
|
+
}
|
|
201
|
+
try {
|
|
202
|
+
const index = this.client.index(collection);
|
|
203
|
+
for (const update of updates) {
|
|
204
|
+
await index.update({
|
|
205
|
+
id: update.id,
|
|
206
|
+
metadata: update.metadata
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
} catch (error) {
|
|
210
|
+
throw new Error(
|
|
211
|
+
`Failed to update metadata in Pinecone index ${collection}: ${error instanceof Error ? error.message : String(error)}`,
|
|
212
|
+
{ cause: error }
|
|
213
|
+
);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
// ============================================================================
|
|
217
|
+
// SEARCH OPERATIONS
|
|
218
|
+
// ============================================================================
|
|
219
|
+
async search(collection, queryVector, options) {
|
|
220
|
+
if (!this.client) {
|
|
221
|
+
throw new Error("Not connected. Call connect() first.");
|
|
222
|
+
}
|
|
223
|
+
try {
|
|
224
|
+
const index = this.client.index(collection);
|
|
225
|
+
const pineconeFilter = options?.filter ? this.translateFilter(options.filter) : void 0;
|
|
226
|
+
const response = await index.query({
|
|
227
|
+
vector: queryVector,
|
|
228
|
+
topK: options?.topK || 10,
|
|
229
|
+
filter: pineconeFilter,
|
|
230
|
+
includeMetadata: options?.includeMetadata !== false,
|
|
231
|
+
includeValues: options?.includeValues || false
|
|
232
|
+
});
|
|
233
|
+
return {
|
|
234
|
+
records: (response.matches || []).map((match) => ({
|
|
235
|
+
id: match.id,
|
|
236
|
+
embedding: match.values || [],
|
|
237
|
+
metadata: match.metadata || {},
|
|
238
|
+
score: match.score
|
|
239
|
+
}))
|
|
240
|
+
};
|
|
241
|
+
} catch (error) {
|
|
242
|
+
throw new Error(
|
|
243
|
+
`Failed to search Pinecone index ${collection}: ${error instanceof Error ? error.message : String(error)}`,
|
|
244
|
+
{ cause: error }
|
|
245
|
+
);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
// ============================================================================
|
|
249
|
+
// FILTER TRANSLATION
|
|
250
|
+
// ============================================================================
|
|
251
|
+
translateFilter(filter) {
|
|
252
|
+
if ("and" in filter) {
|
|
253
|
+
const conditions = filter.and;
|
|
254
|
+
for (const condition of conditions) {
|
|
255
|
+
if ("and" in condition || "or" in condition) {
|
|
256
|
+
throw new Error(
|
|
257
|
+
"Nested compound filters not yet supported in PineconeAdapter. See TECH_DEBT.md",
|
|
258
|
+
{ cause: { filter } }
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
return {
|
|
263
|
+
$and: conditions.map((c) => this.translateFilter(c))
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
if ("or" in filter) {
|
|
267
|
+
throw new Error(
|
|
268
|
+
"OR filters not yet supported in PineconeAdapter. See TECH_DEBT.md",
|
|
269
|
+
{ cause: { filter } }
|
|
270
|
+
);
|
|
271
|
+
}
|
|
272
|
+
const { field, op, value } = filter;
|
|
273
|
+
const operatorMap = {
|
|
274
|
+
eq: "$eq",
|
|
275
|
+
ne: "$ne",
|
|
276
|
+
gt: "$gt",
|
|
277
|
+
gte: "$gte",
|
|
278
|
+
lt: "$lt",
|
|
279
|
+
lte: "$lte",
|
|
280
|
+
in: "$in",
|
|
281
|
+
nin: "$nin"
|
|
282
|
+
};
|
|
283
|
+
const pineconeOp = operatorMap[op];
|
|
284
|
+
if (!pineconeOp) {
|
|
285
|
+
throw new Error(
|
|
286
|
+
`Unsupported filter operator: ${op}`,
|
|
287
|
+
{ cause: { filter } }
|
|
288
|
+
);
|
|
289
|
+
}
|
|
290
|
+
return {
|
|
291
|
+
[field]: {
|
|
292
|
+
[pineconeOp]: value
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
// ============================================================================
|
|
297
|
+
// ITERATION
|
|
298
|
+
// ============================================================================
|
|
299
|
+
async *iterate(collection, options) {
|
|
300
|
+
if (!this.client) {
|
|
301
|
+
throw new Error("Not connected. Call connect() first.");
|
|
302
|
+
}
|
|
303
|
+
try {
|
|
304
|
+
const index = this.client.index(collection);
|
|
305
|
+
const batchSize = options?.batchSize || 100;
|
|
306
|
+
const pineconeFilter = options?.filter ? this.translateFilter(options.filter) : void 0;
|
|
307
|
+
let paginationToken = void 0;
|
|
308
|
+
let hasMore = true;
|
|
309
|
+
while (hasMore) {
|
|
310
|
+
const response = await index.listPaginated({
|
|
311
|
+
limit: batchSize,
|
|
312
|
+
paginationToken,
|
|
313
|
+
...pineconeFilter && { filter: pineconeFilter }
|
|
314
|
+
});
|
|
315
|
+
if (response.vectors && response.vectors.length > 0) {
|
|
316
|
+
const ids = response.vectors.map((v) => v.id).filter((id) => id !== void 0);
|
|
317
|
+
if (ids.length > 0) {
|
|
318
|
+
const records = await this.fetch(collection, ids);
|
|
319
|
+
yield records;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
paginationToken = response.pagination?.next;
|
|
323
|
+
hasMore = !!paginationToken;
|
|
324
|
+
}
|
|
325
|
+
} catch (error) {
|
|
326
|
+
throw new Error(
|
|
327
|
+
`Failed to iterate Pinecone index ${collection}: ${error instanceof Error ? error.message : String(error)}`,
|
|
328
|
+
{ cause: error }
|
|
329
|
+
);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
// ============================================================================
|
|
333
|
+
// CAPABILITY FLAGS
|
|
334
|
+
// ============================================================================
|
|
335
|
+
supportsMetadataUpdate() {
|
|
336
|
+
return true;
|
|
337
|
+
}
|
|
338
|
+
supportsFiltering() {
|
|
339
|
+
return true;
|
|
340
|
+
}
|
|
341
|
+
supportsBatchOperations() {
|
|
342
|
+
return true;
|
|
343
|
+
}
|
|
344
|
+
};
|
|
345
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
346
|
+
0 && (module.exports = {
|
|
347
|
+
PineconeAdapter
|
|
348
|
+
});
|
|
349
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/pinecone-adapter.ts"],"sourcesContent":["// Pinecone adapter exports\nexport { PineconeAdapter } from './pinecone-adapter';\nexport type { PineconeConfig } from './types';\n","import {\n VectorDBAdapter,\n type VectorRecord,\n type SearchResult,\n type UniversalFilter,\n type CollectionStats,\n type MetadataUpdate,\n type DistanceMetric,\n} from '@vectororm/core';\nimport { Pinecone } from '@pinecone-database/pinecone';\nimport type { PineconeConfig } from './types.js';\n\n/**\n * PineconeAdapter implements VectorDBAdapter for Pinecone vector database.\n *\n * Supports all VectorORM features including CRUD operations, filtering,\n * and metadata updates.\n */\nexport class PineconeAdapter extends VectorDBAdapter {\n private config: PineconeConfig;\n private client: Pinecone | null = null;\n\n constructor(config: PineconeConfig) {\n super();\n\n // Validate required config\n if (!config.apiKey) {\n throw new Error(\n 'PineconeAdapter: apiKey is required in config or PINECONE_API_KEY environment variable'\n );\n }\n\n this.config = config;\n // Client will be initialized in a separate step\n }\n\n // ============================================================================\n // CONNECTION MANAGEMENT\n // ============================================================================\n\n async connect(): Promise<void> {\n try {\n this.client = new Pinecone({\n apiKey: this.config.apiKey,\n });\n\n // Verify connection by listing indexes\n await this.client.listIndexes();\n } catch (error) {\n throw new Error(\n `Pinecone connection failed: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error }\n );\n }\n }\n\n async disconnect(): Promise<void> {\n this.client = null;\n }\n\n async isConnected(): Promise<boolean> {\n return this.client !== null;\n }\n\n // ============================================================================\n // COLLECTION MANAGEMENT\n // ============================================================================\n\n async createCollection(\n name: string,\n dimension: number,\n metric: DistanceMetric = 'cosine'\n ): Promise<void> {\n if (!this.client) {\n throw new Error('Not connected. Call connect() first.');\n }\n\n try {\n // Map our metric to Pinecone metric\n const pineconeMetric = metric === 'dotProduct' ? 'dotproduct' : metric;\n\n await this.client.createIndex({\n name,\n dimension,\n metric: pineconeMetric,\n spec: {\n serverless: {\n cloud: 'aws',\n region: 'us-east-1',\n },\n },\n });\n } catch (error) {\n throw new Error(\n `Failed to create Pinecone index ${name}: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error }\n );\n }\n }\n\n async deleteCollection(name: string): Promise<void> {\n if (!this.client) {\n throw new Error('Not connected. Call connect() first.');\n }\n\n try {\n await this.client.deleteIndex(name);\n } catch (error) {\n throw new Error(\n `Failed to delete Pinecone index ${name}: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error }\n );\n }\n }\n\n async collectionExists(name: string): Promise<boolean> {\n if (!this.client) {\n throw new Error('Not connected. Call connect() first.');\n }\n\n try {\n const indexes = await this.client.listIndexes();\n return indexes.indexes?.some((idx) => idx.name === name) ?? false;\n } catch (error) {\n throw new Error(\n `Failed to check if Pinecone index ${name} exists: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error }\n );\n }\n }\n\n async getCollectionStats(name: string): Promise<CollectionStats> {\n if (!this.client) {\n throw new Error('Not connected. Call connect() first.');\n }\n\n try {\n const index = this.client.index(name);\n const stats = await index.describeIndexStats();\n\n return {\n vectorCount: stats.totalRecordCount ?? 0,\n dimension: stats.dimension ?? 0,\n metric: 'cosine', // Pinecone doesn't return metric in stats, default to cosine\n ...stats,\n };\n } catch (error) {\n throw new Error(\n `Failed to get Pinecone index stats for ${name}: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error }\n );\n }\n }\n\n // ============================================================================\n // VECTOR OPERATIONS\n // ============================================================================\n\n async upsert(collection: string, records: VectorRecord[]): Promise<void> {\n if (!this.client) {\n throw new Error('Not connected. Call connect() first.');\n }\n\n try {\n const index = this.client.index(collection);\n\n // Convert VectorRecord[] to Pinecone format\n const pineconeRecords = records.map((record) => ({\n id: record.id,\n values: record.embedding,\n metadata: record.metadata,\n }));\n\n await index.upsert(pineconeRecords);\n } catch (error) {\n throw new Error(\n `Failed to upsert vectors to Pinecone index ${collection}: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error }\n );\n }\n }\n\n async fetch(collection: string, ids: string[]): Promise<VectorRecord[]> {\n if (!this.client) {\n throw new Error('Not connected. Call connect() first.');\n }\n\n try {\n const index = this.client.index(collection);\n const response = await index.fetch(ids);\n\n return Object.entries(response.records || {}).map(([id, record]) => ({\n id,\n embedding: record.values || [],\n metadata: record.metadata || {},\n }));\n } catch (error) {\n throw new Error(\n `Failed to fetch vectors from Pinecone index ${collection}: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error }\n );\n }\n }\n\n async delete(collection: string, ids: string[]): Promise<void> {\n if (!this.client) {\n throw new Error('Not connected. Call connect() first.');\n }\n\n try {\n const index = this.client.index(collection);\n await index.deleteMany(ids);\n } catch (error) {\n throw new Error(\n `Failed to delete vectors from Pinecone index ${collection}: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error }\n );\n }\n }\n\n // ============================================================================\n // METADATA OPERATIONS\n // ============================================================================\n\n async updateMetadata(\n collection: string,\n updates: MetadataUpdate[]\n ): Promise<void> {\n if (!this.client) {\n throw new Error('Not connected. Call connect() first.');\n }\n\n try {\n const index = this.client.index(collection);\n\n // Pinecone supports partial metadata updates via update()\n for (const update of updates) {\n await index.update({\n id: update.id,\n metadata: update.metadata,\n });\n }\n } catch (error) {\n throw new Error(\n `Failed to update metadata in Pinecone index ${collection}: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error }\n );\n }\n }\n\n // ============================================================================\n // SEARCH OPERATIONS\n // ============================================================================\n\n async search(\n collection: string,\n queryVector: number[],\n options?: {\n topK?: number;\n filter?: UniversalFilter;\n includeMetadata?: boolean;\n includeValues?: boolean;\n }\n ): Promise<SearchResult> {\n if (!this.client) {\n throw new Error('Not connected. Call connect() first.');\n }\n\n try {\n const index = this.client.index(collection);\n\n const pineconeFilter = options?.filter\n ? this.translateFilter(options.filter)\n : undefined;\n\n const response = await index.query({\n vector: queryVector,\n topK: options?.topK || 10,\n filter: pineconeFilter,\n includeMetadata: options?.includeMetadata !== false,\n includeValues: options?.includeValues || false,\n });\n\n return {\n records: (response.matches || []).map((match) => ({\n id: match.id,\n embedding: match.values || [],\n metadata: match.metadata || {},\n score: match.score,\n })),\n };\n } catch (error) {\n throw new Error(\n `Failed to search Pinecone index ${collection}: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error }\n );\n }\n }\n\n // ============================================================================\n // FILTER TRANSLATION\n // ============================================================================\n\n translateFilter(filter: UniversalFilter): any {\n // Handle compound AND filter\n if ('and' in filter) {\n const conditions = filter.and;\n\n // Check for nested compound filters (not supported yet)\n for (const condition of conditions) {\n if ('and' in condition || 'or' in condition) {\n throw new Error(\n 'Nested compound filters not yet supported in PineconeAdapter. See TECH_DEBT.md',\n { cause: { filter } }\n );\n }\n }\n\n return {\n $and: conditions.map((c) => this.translateFilter(c)),\n };\n }\n\n // Handle compound OR filter (not supported)\n if ('or' in filter) {\n throw new Error(\n 'OR filters not yet supported in PineconeAdapter. See TECH_DEBT.md',\n { cause: { filter } }\n );\n }\n\n // Handle basic filter condition\n const { field, op, value } = filter as any;\n\n // Operator mapping\n const operatorMap: Record<string, string> = {\n eq: '$eq',\n ne: '$ne',\n gt: '$gt',\n gte: '$gte',\n lt: '$lt',\n lte: '$lte',\n in: '$in',\n nin: '$nin',\n };\n\n const pineconeOp = operatorMap[op];\n if (!pineconeOp) {\n throw new Error(\n `Unsupported filter operator: ${op}`,\n { cause: { filter } }\n );\n }\n\n return {\n [field]: {\n [pineconeOp]: value,\n },\n };\n }\n\n // ============================================================================\n // ITERATION\n // ============================================================================\n\n async *iterate(\n collection: string,\n options?: {\n batchSize?: number;\n filter?: UniversalFilter;\n }\n ): AsyncIterableIterator<VectorRecord[]> {\n if (!this.client) {\n throw new Error('Not connected. Call connect() first.');\n }\n\n try {\n const index = this.client.index(collection);\n const batchSize = options?.batchSize || 100;\n const pineconeFilter = options?.filter\n ? this.translateFilter(options.filter)\n : undefined;\n\n // Pinecone uses pagination with tokens\n let paginationToken: string | undefined = undefined;\n let hasMore = true;\n\n while (hasMore) {\n const response = await index.listPaginated({\n limit: batchSize,\n paginationToken,\n ...(pineconeFilter && { filter: pineconeFilter }),\n });\n\n if (response.vectors && response.vectors.length > 0) {\n // Fetch full records with embeddings\n const ids = response.vectors\n .map((v) => v.id)\n .filter((id): id is string => id !== undefined);\n if (ids.length > 0) {\n const records = await this.fetch(collection, ids);\n yield records;\n }\n }\n\n // Check for more pages\n paginationToken = response.pagination?.next;\n hasMore = !!paginationToken;\n }\n } catch (error) {\n throw new Error(\n `Failed to iterate Pinecone index ${collection}: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error }\n );\n }\n }\n\n // ============================================================================\n // CAPABILITY FLAGS\n // ============================================================================\n\n supportsMetadataUpdate(): boolean {\n return true; // Pinecone supports metadata updates\n }\n\n supportsFiltering(): boolean {\n return true; // Pinecone supports metadata filtering\n }\n\n supportsBatchOperations(): boolean {\n return true; // Pinecone supports batch operations\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,kBAQO;AACP,sBAAyB;AASlB,IAAM,kBAAN,cAA8B,4BAAgB;AAAA,EAC3C;AAAA,EACA,SAA0B;AAAA,EAElC,YAAY,QAAwB;AAClC,UAAM;AAGN,QAAI,CAAC,OAAO,QAAQ;AAClB,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAEA,SAAK,SAAS;AAAA,EAEhB;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,UAAyB;AAC7B,QAAI;AACF,W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QAAI;AACF,YAAM,QAAQ,KAAK,OAAO,MAAM,UAAU;AAC1C,YAAM,YAAY,SAAS,aAAa;AACxC,YAAM,iBAAiB,SAAS,SAC5B,KAAK,gBAAgB,QAAQ,MAAM,IACnC;AAGJ,UAAI,kBAAsC;AAC1C,UAAI,UAAU;AAEd,aAAO,SAAS;AACd,cAAM,WAAW,MAAM,MAAM,cAAc;AAAA,UACzC,OAAO;AAAA,UACP;AAAA,UACA,GAAI,kBAAkB,EAAE,QAAQ,eAAe;AAAA,QACjD,CAAC;AAED,YAAI,SAAS,WAAW,SAAS,QAAQ,SAAS,GAAG;AAEnD,gBAAM,MAAM,SAAS,QAClB,IAAI,CAAC,MAAM,EAAE,EAAE,EACf,OAAO,CAAC,OAAqB,OAAO,MAAS;AAChD,cAAI,IAAI,SAAS,GAAG;AAClB,kBAAM,UAAU,MAAM,KAAK,MAAM,YAAY,GAAG;AAChD,kBAAM;AAAA,UACR;AAAA,QACF;AAGA,0BAAkB,SAAS,YAAY;AACvC,kBAAU,CAAC,CAAC;AAAA,MACd;AAAA,IACF,SAAS,OAAO;AACd,YAAM,IAAI;AAAA,QACR,oCAAoC,UAAU,KAAK,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;AAAA,QACzG,EAAE,OAAO,MAAM;AAAA,MACjB;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAMA,yBAAkC;AAChC,WAAO;AAAA,EACT;AAAA,EAEA,oBAA6B;AAC3B,WAAO;AAAA,EACT;AAAA,EAEA,0BAAmC;AACjC,WAAO;AAAA,EACT;AACF;","names":[]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { VectorDBAdapter, DistanceMetric, CollectionStats, VectorRecord, MetadataUpdate, UniversalFilter, SearchResult } from '@vectororm/core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Configuration for PineconeAdapter.
|
|
5
|
+
*
|
|
6
|
+
* Supports hybrid config: explicit values or environment variables.
|
|
7
|
+
*/
|
|
8
|
+
interface PineconeConfig {
|
|
9
|
+
/**
|
|
10
|
+
* Pinecone API key.
|
|
11
|
+
* Falls back to PINECONE_API_KEY environment variable.
|
|
12
|
+
*/
|
|
13
|
+
apiKey: string;
|
|
14
|
+
/**
|
|
15
|
+
* Pinecone environment (e.g., 'us-east1-gcp').
|
|
16
|
+
* Falls back to PINECONE_ENVIRONMENT environment variable.
|
|
17
|
+
*/
|
|
18
|
+
environment?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Pinecone project ID (optional).
|
|
21
|
+
*/
|
|
22
|
+
projectId?: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* PineconeAdapter implements VectorDBAdapter for Pinecone vector database.
|
|
27
|
+
*
|
|
28
|
+
* Supports all VectorORM features including CRUD operations, filtering,
|
|
29
|
+
* and metadata updates.
|
|
30
|
+
*/
|
|
31
|
+
declare class PineconeAdapter extends VectorDBAdapter {
|
|
32
|
+
private config;
|
|
33
|
+
private client;
|
|
34
|
+
constructor(config: PineconeConfig);
|
|
35
|
+
connect(): Promise<void>;
|
|
36
|
+
disconnect(): Promise<void>;
|
|
37
|
+
isConnected(): Promise<boolean>;
|
|
38
|
+
createCollection(name: string, dimension: number, metric?: DistanceMetric): Promise<void>;
|
|
39
|
+
deleteCollection(name: string): Promise<void>;
|
|
40
|
+
collectionExists(name: string): Promise<boolean>;
|
|
41
|
+
getCollectionStats(name: string): Promise<CollectionStats>;
|
|
42
|
+
upsert(collection: string, records: VectorRecord[]): Promise<void>;
|
|
43
|
+
fetch(collection: string, ids: string[]): Promise<VectorRecord[]>;
|
|
44
|
+
delete(collection: string, ids: string[]): Promise<void>;
|
|
45
|
+
updateMetadata(collection: string, updates: MetadataUpdate[]): Promise<void>;
|
|
46
|
+
search(collection: string, queryVector: number[], options?: {
|
|
47
|
+
topK?: number;
|
|
48
|
+
filter?: UniversalFilter;
|
|
49
|
+
includeMetadata?: boolean;
|
|
50
|
+
includeValues?: boolean;
|
|
51
|
+
}): Promise<SearchResult>;
|
|
52
|
+
translateFilter(filter: UniversalFilter): any;
|
|
53
|
+
iterate(collection: string, options?: {
|
|
54
|
+
batchSize?: number;
|
|
55
|
+
filter?: UniversalFilter;
|
|
56
|
+
}): AsyncIterableIterator<VectorRecord[]>;
|
|
57
|
+
supportsMetadataUpdate(): boolean;
|
|
58
|
+
supportsFiltering(): boolean;
|
|
59
|
+
supportsBatchOperations(): boolean;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export { PineconeAdapter, type PineconeConfig };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { VectorDBAdapter, DistanceMetric, CollectionStats, VectorRecord, MetadataUpdate, UniversalFilter, SearchResult } from '@vectororm/core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Configuration for PineconeAdapter.
|
|
5
|
+
*
|
|
6
|
+
* Supports hybrid config: explicit values or environment variables.
|
|
7
|
+
*/
|
|
8
|
+
interface PineconeConfig {
|
|
9
|
+
/**
|
|
10
|
+
* Pinecone API key.
|
|
11
|
+
* Falls back to PINECONE_API_KEY environment variable.
|
|
12
|
+
*/
|
|
13
|
+
apiKey: string;
|
|
14
|
+
/**
|
|
15
|
+
* Pinecone environment (e.g., 'us-east1-gcp').
|
|
16
|
+
* Falls back to PINECONE_ENVIRONMENT environment variable.
|
|
17
|
+
*/
|
|
18
|
+
environment?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Pinecone project ID (optional).
|
|
21
|
+
*/
|
|
22
|
+
projectId?: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* PineconeAdapter implements VectorDBAdapter for Pinecone vector database.
|
|
27
|
+
*
|
|
28
|
+
* Supports all VectorORM features including CRUD operations, filtering,
|
|
29
|
+
* and metadata updates.
|
|
30
|
+
*/
|
|
31
|
+
declare class PineconeAdapter extends VectorDBAdapter {
|
|
32
|
+
private config;
|
|
33
|
+
private client;
|
|
34
|
+
constructor(config: PineconeConfig);
|
|
35
|
+
connect(): Promise<void>;
|
|
36
|
+
disconnect(): Promise<void>;
|
|
37
|
+
isConnected(): Promise<boolean>;
|
|
38
|
+
createCollection(name: string, dimension: number, metric?: DistanceMetric): Promise<void>;
|
|
39
|
+
deleteCollection(name: string): Promise<void>;
|
|
40
|
+
collectionExists(name: string): Promise<boolean>;
|
|
41
|
+
getCollectionStats(name: string): Promise<CollectionStats>;
|
|
42
|
+
upsert(collection: string, records: VectorRecord[]): Promise<void>;
|
|
43
|
+
fetch(collection: string, ids: string[]): Promise<VectorRecord[]>;
|
|
44
|
+
delete(collection: string, ids: string[]): Promise<void>;
|
|
45
|
+
updateMetadata(collection: string, updates: MetadataUpdate[]): Promise<void>;
|
|
46
|
+
search(collection: string, queryVector: number[], options?: {
|
|
47
|
+
topK?: number;
|
|
48
|
+
filter?: UniversalFilter;
|
|
49
|
+
includeMetadata?: boolean;
|
|
50
|
+
includeValues?: boolean;
|
|
51
|
+
}): Promise<SearchResult>;
|
|
52
|
+
translateFilter(filter: UniversalFilter): any;
|
|
53
|
+
iterate(collection: string, options?: {
|
|
54
|
+
batchSize?: number;
|
|
55
|
+
filter?: UniversalFilter;
|
|
56
|
+
}): AsyncIterableIterator<VectorRecord[]>;
|
|
57
|
+
supportsMetadataUpdate(): boolean;
|
|
58
|
+
supportsFiltering(): boolean;
|
|
59
|
+
supportsBatchOperations(): boolean;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export { PineconeAdapter, type PineconeConfig };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
// src/pinecone-adapter.ts
|
|
2
|
+
import {
|
|
3
|
+
VectorDBAdapter
|
|
4
|
+
} from "@vectororm/core";
|
|
5
|
+
import { Pinecone } from "@pinecone-database/pinecone";
|
|
6
|
+
var PineconeAdapter = class extends VectorDBAdapter {
|
|
7
|
+
config;
|
|
8
|
+
client = null;
|
|
9
|
+
constructor(config) {
|
|
10
|
+
super();
|
|
11
|
+
if (!config.apiKey) {
|
|
12
|
+
throw new Error(
|
|
13
|
+
"PineconeAdapter: apiKey is required in config or PINECONE_API_KEY environment variable"
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
this.config = config;
|
|
17
|
+
}
|
|
18
|
+
// ============================================================================
|
|
19
|
+
// CONNECTION MANAGEMENT
|
|
20
|
+
// ============================================================================
|
|
21
|
+
async connect() {
|
|
22
|
+
try {
|
|
23
|
+
this.client = new Pinecone({
|
|
24
|
+
apiKey: this.config.apiKey
|
|
25
|
+
});
|
|
26
|
+
await this.client.listIndexes();
|
|
27
|
+
} catch (error) {
|
|
28
|
+
throw new Error(
|
|
29
|
+
`Pinecone connection failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
30
|
+
{ cause: error }
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
async disconnect() {
|
|
35
|
+
this.client = null;
|
|
36
|
+
}
|
|
37
|
+
async isConnected() {
|
|
38
|
+
return this.client !== null;
|
|
39
|
+
}
|
|
40
|
+
// ============================================================================
|
|
41
|
+
// COLLECTION MANAGEMENT
|
|
42
|
+
// ============================================================================
|
|
43
|
+
async createCollection(name, dimension, metric = "cosine") {
|
|
44
|
+
if (!this.client) {
|
|
45
|
+
throw new Error("Not connected. Call connect() first.");
|
|
46
|
+
}
|
|
47
|
+
try {
|
|
48
|
+
const pineconeMetric = metric === "dotProduct" ? "dotproduct" : metric;
|
|
49
|
+
await this.client.createIndex({
|
|
50
|
+
name,
|
|
51
|
+
dimension,
|
|
52
|
+
metric: pineconeMetric,
|
|
53
|
+
spec: {
|
|
54
|
+
serverless: {
|
|
55
|
+
cloud: "aws",
|
|
56
|
+
region: "us-east-1"
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
} catch (error) {
|
|
61
|
+
throw new Error(
|
|
62
|
+
`Failed to create Pinecone index ${name}: ${error instanceof Error ? error.message : String(error)}`,
|
|
63
|
+
{ cause: error }
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
async deleteCollection(name) {
|
|
68
|
+
if (!this.client) {
|
|
69
|
+
throw new Error("Not connected. Call connect() first.");
|
|
70
|
+
}
|
|
71
|
+
try {
|
|
72
|
+
await this.client.deleteIndex(name);
|
|
73
|
+
} catch (error) {
|
|
74
|
+
throw new Error(
|
|
75
|
+
`Failed to delete Pinecone index ${name}: ${error instanceof Error ? error.message : String(error)}`,
|
|
76
|
+
{ cause: error }
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
async collectionExists(name) {
|
|
81
|
+
if (!this.client) {
|
|
82
|
+
throw new Error("Not connected. Call connect() first.");
|
|
83
|
+
}
|
|
84
|
+
try {
|
|
85
|
+
const indexes = await this.client.listIndexes();
|
|
86
|
+
return indexes.indexes?.some((idx) => idx.name === name) ?? false;
|
|
87
|
+
} catch (error) {
|
|
88
|
+
throw new Error(
|
|
89
|
+
`Failed to check if Pinecone index ${name} exists: ${error instanceof Error ? error.message : String(error)}`,
|
|
90
|
+
{ cause: error }
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
async getCollectionStats(name) {
|
|
95
|
+
if (!this.client) {
|
|
96
|
+
throw new Error("Not connected. Call connect() first.");
|
|
97
|
+
}
|
|
98
|
+
try {
|
|
99
|
+
const index = this.client.index(name);
|
|
100
|
+
const stats = await index.describeIndexStats();
|
|
101
|
+
return {
|
|
102
|
+
vectorCount: stats.totalRecordCount ?? 0,
|
|
103
|
+
dimension: stats.dimension ?? 0,
|
|
104
|
+
metric: "cosine",
|
|
105
|
+
// Pinecone doesn't return metric in stats, default to cosine
|
|
106
|
+
...stats
|
|
107
|
+
};
|
|
108
|
+
} catch (error) {
|
|
109
|
+
throw new Error(
|
|
110
|
+
`Failed to get Pinecone index stats for ${name}: ${error instanceof Error ? error.message : String(error)}`,
|
|
111
|
+
{ cause: error }
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
// ============================================================================
|
|
116
|
+
// VECTOR OPERATIONS
|
|
117
|
+
// ============================================================================
|
|
118
|
+
async upsert(collection, records) {
|
|
119
|
+
if (!this.client) {
|
|
120
|
+
throw new Error("Not connected. Call connect() first.");
|
|
121
|
+
}
|
|
122
|
+
try {
|
|
123
|
+
const index = this.client.index(collection);
|
|
124
|
+
const pineconeRecords = records.map((record) => ({
|
|
125
|
+
id: record.id,
|
|
126
|
+
values: record.embedding,
|
|
127
|
+
metadata: record.metadata
|
|
128
|
+
}));
|
|
129
|
+
await index.upsert(pineconeRecords);
|
|
130
|
+
} catch (error) {
|
|
131
|
+
throw new Error(
|
|
132
|
+
`Failed to upsert vectors to Pinecone index ${collection}: ${error instanceof Error ? error.message : String(error)}`,
|
|
133
|
+
{ cause: error }
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
async fetch(collection, ids) {
|
|
138
|
+
if (!this.client) {
|
|
139
|
+
throw new Error("Not connected. Call connect() first.");
|
|
140
|
+
}
|
|
141
|
+
try {
|
|
142
|
+
const index = this.client.index(collection);
|
|
143
|
+
const response = await index.fetch(ids);
|
|
144
|
+
return Object.entries(response.records || {}).map(([id, record]) => ({
|
|
145
|
+
id,
|
|
146
|
+
embedding: record.values || [],
|
|
147
|
+
metadata: record.metadata || {}
|
|
148
|
+
}));
|
|
149
|
+
} catch (error) {
|
|
150
|
+
throw new Error(
|
|
151
|
+
`Failed to fetch vectors from Pinecone index ${collection}: ${error instanceof Error ? error.message : String(error)}`,
|
|
152
|
+
{ cause: error }
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
async delete(collection, ids) {
|
|
157
|
+
if (!this.client) {
|
|
158
|
+
throw new Error("Not connected. Call connect() first.");
|
|
159
|
+
}
|
|
160
|
+
try {
|
|
161
|
+
const index = this.client.index(collection);
|
|
162
|
+
await index.deleteMany(ids);
|
|
163
|
+
} catch (error) {
|
|
164
|
+
throw new Error(
|
|
165
|
+
`Failed to delete vectors from Pinecone index ${collection}: ${error instanceof Error ? error.message : String(error)}`,
|
|
166
|
+
{ cause: error }
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
// ============================================================================
|
|
171
|
+
// METADATA OPERATIONS
|
|
172
|
+
// ============================================================================
|
|
173
|
+
async updateMetadata(collection, updates) {
|
|
174
|
+
if (!this.client) {
|
|
175
|
+
throw new Error("Not connected. Call connect() first.");
|
|
176
|
+
}
|
|
177
|
+
try {
|
|
178
|
+
const index = this.client.index(collection);
|
|
179
|
+
for (const update of updates) {
|
|
180
|
+
await index.update({
|
|
181
|
+
id: update.id,
|
|
182
|
+
metadata: update.metadata
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
} catch (error) {
|
|
186
|
+
throw new Error(
|
|
187
|
+
`Failed to update metadata in Pinecone index ${collection}: ${error instanceof Error ? error.message : String(error)}`,
|
|
188
|
+
{ cause: error }
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
// ============================================================================
|
|
193
|
+
// SEARCH OPERATIONS
|
|
194
|
+
// ============================================================================
|
|
195
|
+
async search(collection, queryVector, options) {
|
|
196
|
+
if (!this.client) {
|
|
197
|
+
throw new Error("Not connected. Call connect() first.");
|
|
198
|
+
}
|
|
199
|
+
try {
|
|
200
|
+
const index = this.client.index(collection);
|
|
201
|
+
const pineconeFilter = options?.filter ? this.translateFilter(options.filter) : void 0;
|
|
202
|
+
const response = await index.query({
|
|
203
|
+
vector: queryVector,
|
|
204
|
+
topK: options?.topK || 10,
|
|
205
|
+
filter: pineconeFilter,
|
|
206
|
+
includeMetadata: options?.includeMetadata !== false,
|
|
207
|
+
includeValues: options?.includeValues || false
|
|
208
|
+
});
|
|
209
|
+
return {
|
|
210
|
+
records: (response.matches || []).map((match) => ({
|
|
211
|
+
id: match.id,
|
|
212
|
+
embedding: match.values || [],
|
|
213
|
+
metadata: match.metadata || {},
|
|
214
|
+
score: match.score
|
|
215
|
+
}))
|
|
216
|
+
};
|
|
217
|
+
} catch (error) {
|
|
218
|
+
throw new Error(
|
|
219
|
+
`Failed to search Pinecone index ${collection}: ${error instanceof Error ? error.message : String(error)}`,
|
|
220
|
+
{ cause: error }
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
// ============================================================================
|
|
225
|
+
// FILTER TRANSLATION
|
|
226
|
+
// ============================================================================
|
|
227
|
+
translateFilter(filter) {
|
|
228
|
+
if ("and" in filter) {
|
|
229
|
+
const conditions = filter.and;
|
|
230
|
+
for (const condition of conditions) {
|
|
231
|
+
if ("and" in condition || "or" in condition) {
|
|
232
|
+
throw new Error(
|
|
233
|
+
"Nested compound filters not yet supported in PineconeAdapter. See TECH_DEBT.md",
|
|
234
|
+
{ cause: { filter } }
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
return {
|
|
239
|
+
$and: conditions.map((c) => this.translateFilter(c))
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
if ("or" in filter) {
|
|
243
|
+
throw new Error(
|
|
244
|
+
"OR filters not yet supported in PineconeAdapter. See TECH_DEBT.md",
|
|
245
|
+
{ cause: { filter } }
|
|
246
|
+
);
|
|
247
|
+
}
|
|
248
|
+
const { field, op, value } = filter;
|
|
249
|
+
const operatorMap = {
|
|
250
|
+
eq: "$eq",
|
|
251
|
+
ne: "$ne",
|
|
252
|
+
gt: "$gt",
|
|
253
|
+
gte: "$gte",
|
|
254
|
+
lt: "$lt",
|
|
255
|
+
lte: "$lte",
|
|
256
|
+
in: "$in",
|
|
257
|
+
nin: "$nin"
|
|
258
|
+
};
|
|
259
|
+
const pineconeOp = operatorMap[op];
|
|
260
|
+
if (!pineconeOp) {
|
|
261
|
+
throw new Error(
|
|
262
|
+
`Unsupported filter operator: ${op}`,
|
|
263
|
+
{ cause: { filter } }
|
|
264
|
+
);
|
|
265
|
+
}
|
|
266
|
+
return {
|
|
267
|
+
[field]: {
|
|
268
|
+
[pineconeOp]: value
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
// ============================================================================
|
|
273
|
+
// ITERATION
|
|
274
|
+
// ============================================================================
|
|
275
|
+
async *iterate(collection, options) {
|
|
276
|
+
if (!this.client) {
|
|
277
|
+
throw new Error("Not connected. Call connect() first.");
|
|
278
|
+
}
|
|
279
|
+
try {
|
|
280
|
+
const index = this.client.index(collection);
|
|
281
|
+
const batchSize = options?.batchSize || 100;
|
|
282
|
+
const pineconeFilter = options?.filter ? this.translateFilter(options.filter) : void 0;
|
|
283
|
+
let paginationToken = void 0;
|
|
284
|
+
let hasMore = true;
|
|
285
|
+
while (hasMore) {
|
|
286
|
+
const response = await index.listPaginated({
|
|
287
|
+
limit: batchSize,
|
|
288
|
+
paginationToken,
|
|
289
|
+
...pineconeFilter && { filter: pineconeFilter }
|
|
290
|
+
});
|
|
291
|
+
if (response.vectors && response.vectors.length > 0) {
|
|
292
|
+
const ids = response.vectors.map((v) => v.id).filter((id) => id !== void 0);
|
|
293
|
+
if (ids.length > 0) {
|
|
294
|
+
const records = await this.fetch(collection, ids);
|
|
295
|
+
yield records;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
paginationToken = response.pagination?.next;
|
|
299
|
+
hasMore = !!paginationToken;
|
|
300
|
+
}
|
|
301
|
+
} catch (error) {
|
|
302
|
+
throw new Error(
|
|
303
|
+
`Failed to iterate Pinecone index ${collection}: ${error instanceof Error ? error.message : String(error)}`,
|
|
304
|
+
{ cause: error }
|
|
305
|
+
);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
// ============================================================================
|
|
309
|
+
// CAPABILITY FLAGS
|
|
310
|
+
// ============================================================================
|
|
311
|
+
supportsMetadataUpdate() {
|
|
312
|
+
return true;
|
|
313
|
+
}
|
|
314
|
+
supportsFiltering() {
|
|
315
|
+
return true;
|
|
316
|
+
}
|
|
317
|
+
supportsBatchOperations() {
|
|
318
|
+
return true;
|
|
319
|
+
}
|
|
320
|
+
};
|
|
321
|
+
export {
|
|
322
|
+
PineconeAdapter
|
|
323
|
+
};
|
|
324
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/pinecone-adapter.ts"],"sourcesContent":["import {\n VectorDBAdapter,\n type VectorRecord,\n type SearchResult,\n type UniversalFilter,\n type CollectionStats,\n type MetadataUpdate,\n type DistanceMetric,\n} from '@vectororm/core';\nimport { Pinecone } from '@pinecone-database/pinecone';\nimport type { PineconeConfig } from './types.js';\n\n/**\n * PineconeAdapter implements VectorDBAdapter for Pinecone vector database.\n *\n * Supports all VectorORM features including CRUD operations, filtering,\n * and metadata updates.\n */\nexport class PineconeAdapter extends VectorDBAdapter {\n private config: PineconeConfig;\n private client: Pinecone | null = null;\n\n constructor(config: PineconeConfig) {\n super();\n\n // Validate required config\n if (!config.apiKey) {\n throw new Error(\n 'PineconeAdapter: apiKey is required in config or PINECONE_API_KEY environment variable'\n );\n }\n\n this.config = config;\n // Client will be initialized in a separate step\n }\n\n // ============================================================================\n // CONNECTION MANAGEMENT\n // ============================================================================\n\n async connect(): Promise<void> {\n try {\n this.client = new Pinecone({\n apiKey: this.config.apiKey,\n });\n\n // Verify connection by listing indexes\n await this.client.listIndexes();\n } catch (error) {\n throw new Error(\n `Pinecone connection failed: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error }\n );\n }\n }\n\n async disconnect(): Promise<void> {\n this.client = null;\n }\n\n async isConnected(): Promise<boolean> {\n return this.client !== null;\n }\n\n // ============================================================================\n // COLLECTION MANAGEMENT\n // ============================================================================\n\n async createCollection(\n name: string,\n dimension: number,\n metric: DistanceMetric = 'cosine'\n ): Promise<void> {\n if (!this.client) {\n throw new Error('Not connected. Call connect() first.');\n }\n\n try {\n // Map our metric to Pinecone metric\n const pineconeMetric = metric === 'dotProduct' ? 'dotproduct' : metric;\n\n await this.client.createIndex({\n name,\n dimension,\n metric: pineconeMetric,\n spec: {\n serverless: {\n cloud: 'aws',\n region: 'us-east-1',\n },\n },\n });\n } catch (error) {\n throw new Error(\n `Failed to create Pinecone index ${name}: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error }\n );\n }\n }\n\n async deleteCollection(name: string): Promise<void> {\n if (!this.client) {\n throw new Error('Not connected. Call connect() first.');\n }\n\n try {\n await this.client.deleteIndex(name);\n } catch (error) {\n throw new Error(\n `Failed to delete Pinecone index ${name}: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error }\n );\n }\n }\n\n async collectionExists(name: string): Promise<boolean> {\n if (!this.client) {\n throw new Error('Not connected. Call connect() first.');\n }\n\n try {\n const indexes = await this.client.listIndexes();\n return indexes.indexes?.some((idx) => idx.name === name) ?? false;\n } catch (error) {\n throw new Error(\n `Failed to check if Pinecone index ${name} exists: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error }\n );\n }\n }\n\n async getCollectionStats(name: string): Promise<CollectionStats> {\n if (!this.client) {\n throw new Error('Not connected. Call connect() first.');\n }\n\n try {\n const index = this.client.index(name);\n const stats = await index.describeIndexStats();\n\n return {\n vectorCount: stats.totalRecordCount ?? 0,\n dimension: stats.dimension ?? 0,\n metric: 'cosine', // Pinecone doesn't return metric in stats, default to cosine\n ...stats,\n };\n } catch (error) {\n throw new Error(\n `Failed to get Pinecone index stats for ${name}: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error }\n );\n }\n }\n\n // ============================================================================\n // VECTOR OPERATIONS\n // ============================================================================\n\n async upsert(collection: string, records: VectorRecord[]): Promise<void> {\n if (!this.client) {\n throw new Error('Not connected. Call connect() first.');\n }\n\n try {\n const index = this.client.index(collection);\n\n // Convert VectorRecord[] to Pinecone format\n const pineconeRecords = records.map((record) => ({\n id: record.id,\n values: record.embedding,\n metadata: record.metadata,\n }));\n\n await index.upsert(pineconeRecords);\n } catch (error) {\n throw new Error(\n `Failed to upsert vectors to Pinecone index ${collection}: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error }\n );\n }\n }\n\n async fetch(collection: string, ids: string[]): Promise<VectorRecord[]> {\n if (!this.client) {\n throw new Error('Not connected. Call connect() first.');\n }\n\n try {\n const index = this.client.index(collection);\n const response = await index.fetch(ids);\n\n return Object.entries(response.records || {}).map(([id, record]) => ({\n id,\n embedding: record.values || [],\n metadata: record.metadata || {},\n }));\n } catch (error) {\n throw new Error(\n `Failed to fetch vectors from Pinecone index ${collection}: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error }\n );\n }\n }\n\n async delete(collection: string, ids: string[]): Promise<void> {\n if (!this.client) {\n throw new Error('Not connected. Call connect() first.');\n }\n\n try {\n const index = this.client.index(collection);\n await index.deleteMany(ids);\n } catch (error) {\n throw new Error(\n `Failed to delete vectors from Pinecone index ${collection}: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error }\n );\n }\n }\n\n // ============================================================================\n // METADATA OPERATIONS\n // ============================================================================\n\n async updateMetadata(\n collection: string,\n updates: MetadataUpdate[]\n ): Promise<void> {\n if (!this.client) {\n throw new Error('Not connected. Call connect() first.');\n }\n\n try {\n const index = this.client.index(collection);\n\n // Pinecone supports partial metadata updates via update()\n for (const update of updates) {\n await index.update({\n id: update.id,\n metadata: update.metadata,\n });\n }\n } catch (error) {\n throw new Error(\n `Failed to update metadata in Pinecone index ${collection}: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error }\n );\n }\n }\n\n // ============================================================================\n // SEARCH OPERATIONS\n // ============================================================================\n\n async search(\n collection: string,\n queryVector: number[],\n options?: {\n topK?: number;\n filter?: UniversalFilter;\n includeMetadata?: boolean;\n includeValues?: boolean;\n }\n ): Promise<SearchResult> {\n if (!this.client) {\n throw new Error('Not connected. Call connect() first.');\n }\n\n try {\n const index = this.client.index(collection);\n\n const pineconeFilter = options?.filter\n ? this.translateFilter(options.filter)\n : undefined;\n\n const response = await index.query({\n vector: queryVector,\n topK: options?.topK || 10,\n filter: pineconeFilter,\n includeMetadata: options?.includeMetadata !== false,\n includeValues: options?.includeValues || false,\n });\n\n return {\n records: (response.matches || []).map((match) => ({\n id: match.id,\n embedding: match.values || [],\n metadata: match.metadata || {},\n score: match.score,\n })),\n };\n } catch (error) {\n throw new Error(\n `Failed to search Pinecone index ${collection}: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error }\n );\n }\n }\n\n // ============================================================================\n // FILTER TRANSLATION\n // ============================================================================\n\n translateFilter(filter: UniversalFilter): any {\n // Handle compound AND filter\n if ('and' in filter) {\n const conditions = filter.and;\n\n // Check for nested compound filters (not supported yet)\n for (const condition of conditions) {\n if ('and' in condition || 'or' in condition) {\n throw new Error(\n 'Nested compound filters not yet supported in PineconeAdapter. See TECH_DEBT.md',\n { cause: { filter } }\n );\n }\n }\n\n return {\n $and: conditions.map((c) => this.translateFilter(c)),\n };\n }\n\n // Handle compound OR filter (not supported)\n if ('or' in filter) {\n throw new Error(\n 'OR filters not yet supported in PineconeAdapter. See TECH_DEBT.md',\n { cause: { filter } }\n );\n }\n\n // Handle basic filter condition\n const { field, op, value } = filter as any;\n\n // Operator mapping\n const operatorMap: Record<string, string> = {\n eq: '$eq',\n ne: '$ne',\n gt: '$gt',\n gte: '$gte',\n lt: '$lt',\n lte: '$lte',\n in: '$in',\n nin: '$nin',\n };\n\n const pineconeOp = operatorMap[op];\n if (!pineconeOp) {\n throw new Error(\n `Unsupported filter operator: ${op}`,\n { cause: { filter } }\n );\n }\n\n return {\n [field]: {\n [pineconeOp]: value,\n },\n };\n }\n\n // ============================================================================\n // ITERATION\n // ============================================================================\n\n async *iterate(\n collection: string,\n options?: {\n batchSize?: number;\n filter?: UniversalFilter;\n }\n ): AsyncIterableIterator<VectorRecord[]> {\n if (!this.client) {\n throw new Error('Not connected. Call connect() first.');\n }\n\n try {\n const index = this.client.index(collection);\n const batchSize = options?.batchSize || 100;\n const pineconeFilter = options?.filter\n ? this.translateFilter(options.filter)\n : undefined;\n\n // Pinecone uses pagination with tokens\n let paginationToken: string | undefined = undefined;\n let hasMore = true;\n\n while (hasMore) {\n const response = await index.listPaginated({\n limit: batchSize,\n paginationToken,\n ...(pineconeFilter && { filter: pineconeFilter }),\n });\n\n if (response.vectors && response.vectors.length > 0) {\n // Fetch full records with embeddings\n const ids = response.vectors\n .map((v) => v.id)\n .filter((id): id is string => id !== undefined);\n if (ids.length > 0) {\n const records = await this.fetch(collection, ids);\n yield records;\n }\n }\n\n // Check for more pages\n paginationToken = response.pagination?.next;\n hasMore = !!paginationToken;\n }\n } catch (error) {\n throw new Error(\n `Failed to iterate Pinecone index ${collection}: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error }\n );\n }\n }\n\n // ============================================================================\n // CAPABILITY FLAGS\n // ============================================================================\n\n supportsMetadataUpdate(): boolean {\n return true; // Pinecone supports metadata updates\n }\n\n supportsFiltering(): boolean {\n return true; // Pinecone supports metadata filtering\n }\n\n supportsBatchOperations(): boolean {\n return true; // Pinecone supports batch operations\n }\n}\n"],"mappings":";AAAA;AAAA,EACE;AAAA,OAOK;AACP,SAAS,gBAAgB;AASlB,IAAM,kBAAN,cAA8B,gBAAgB;AAAA,EAC3C;AAAA,EACA,SAA0B;AAAA,EAElC,YAAY,QAAwB;AAClC,UAAM;AAGN,QAAI,CAAC,OAAO,QAAQ;AAClB,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAEA,SAAK,SAAS;AAAA,EAEhB;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,UAAyB;AAC7B,QAAI;AACF,WAAK,SAAS,IAAI,SAAS;AAAA,QACzB,QAAQ,KAAK,OAAO;AAAA,MACtB,CAAC;AAGD,YAAM,KAAK,OAAO,YAAY;AAAA,IAChC,SAAS,OAAO;AACd,YAAM,IAAI;AAAA,QACR,+BAA+B,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;AAAA,QACrF,EAAE,OAAO,MAAM;AAAA,MACjB;AAAA,IAC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AAA,UACP;AAAA,UACA,GAAI,kBAAkB,EAAE,QAAQ,eAAe;AAAA,QACjD,CAAC;AAED,YAAI,SAAS,WAAW,SAAS,QAAQ,SAAS,GAAG;AAEnD,gBAAM,MAAM,SAAS,QAClB,IAAI,CAAC,MAAM,EAAE,EAAE,EACf,OAAO,CAAC,OAAqB,OAAO,MAAS;AAChD,cAAI,IAAI,SAAS,GAAG;AAClB,kBAAM,UAAU,MAAM,KAAK,MAAM,YAAY,GAAG;AAChD,kBAAM;AAAA,UACR;AAAA,QACF;AAGA,0BAAkB,SAAS,YAAY;AACvC,kBAAU,CAAC,CAAC;AAAA,MACd;AAAA,IACF,SAAS,OAAO;AACd,YAAM,IAAI;AAAA,QACR,oCAAoC,UAAU,KAAK,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;AAAA,QACzG,EAAE,OAAO,MAAM;AAAA,MACjB;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAMA,yBAAkC;AAChC,WAAO;AAAA,EACT;AAAA,EAEA,oBAA6B;AAC3B,WAAO;AAAA,EACT;AAAA,EAEA,0BAAmC;AACjC,WAAO;AAAA,EACT;AACF;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vectororm/adapter-pinecone",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Pinecone adapter for Glyph VectorORM",
|
|
5
|
+
"author": "Aviram Roisman",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"homepage": "https://github.com/aviramroi/VectorORM",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/aviramroi/VectorORM.git",
|
|
11
|
+
"directory": "packages/adapter-pinecone"
|
|
12
|
+
},
|
|
13
|
+
"publishConfig": {
|
|
14
|
+
"access": "public"
|
|
15
|
+
},
|
|
16
|
+
"type": "module",
|
|
17
|
+
"main": "./dist/index.js",
|
|
18
|
+
"module": "./dist/index.mjs",
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"require": "./dist/index.js",
|
|
24
|
+
"import": "./dist/index.mjs"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"files": ["dist", "README.md"],
|
|
28
|
+
"engines": {
|
|
29
|
+
"node": ">=18.0.0"
|
|
30
|
+
},
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "tsup",
|
|
33
|
+
"test": "vitest run",
|
|
34
|
+
"test:watch": "vitest",
|
|
35
|
+
"test:integration": "vitest run --config vitest.integration.config.ts"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@vectororm/core": "*",
|
|
39
|
+
"@pinecone-database/pinecone": "^2.0.0"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@types/node": "^20.10.0",
|
|
43
|
+
"tsup": "^8.0.0",
|
|
44
|
+
"typescript": "^5.3.3",
|
|
45
|
+
"vitest": "^1.0.0"
|
|
46
|
+
},
|
|
47
|
+
"peerDependencies": {
|
|
48
|
+
"@vectororm/core": "^0.1.0"
|
|
49
|
+
},
|
|
50
|
+
"keywords": [
|
|
51
|
+
"glyph",
|
|
52
|
+
"vectororm",
|
|
53
|
+
"pinecone",
|
|
54
|
+
"vector-database",
|
|
55
|
+
"adapter"
|
|
56
|
+
]
|
|
57
|
+
}
|