@vectorstores/azure 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +58 -11
- package/dist/index.d.cts +11 -7
- package/dist/index.d.ts +11 -7
- package/dist/index.edge-light.d.ts +11 -7
- package/dist/index.edge-light.js +58 -11
- package/dist/index.js +58 -11
- package/dist/storage.cjs +1 -214
- package/dist/storage.d.cts +3 -121
- package/dist/storage.d.ts +3 -121
- package/dist/storage.edge-light.d.ts +3 -121
- package/dist/storage.edge-light.js +3 -212
- package/dist/storage.js +3 -212
- package/package.json +3 -3
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { BaseKVStore
|
|
2
|
-
import { MongoClient } from 'mongodb';
|
|
1
|
+
import { BaseKVStore } from '@vectorstores/core';
|
|
3
2
|
import { CosmosClient } from '@azure/cosmos';
|
|
4
3
|
import { DefaultAzureCredential } from '@azure/identity';
|
|
5
4
|
import { getEnv } from '@vectorstores/env';
|
|
6
5
|
|
|
7
|
-
var version = "0.1.
|
|
6
|
+
var version = "0.1.4";
|
|
8
7
|
var pkg = {
|
|
9
8
|
version: version};
|
|
10
9
|
|
|
@@ -67,60 +66,6 @@ class AzureCosmosVCoreKVStore extends BaseKVStore {
|
|
|
67
66
|
}
|
|
68
67
|
}
|
|
69
68
|
|
|
70
|
-
const DEFAULT_DATABASE$3 = "DocumentStoreDB";
|
|
71
|
-
const DEFAULT_COLLECTION$1 = "DocumentStoreCollection";
|
|
72
|
-
class AzureCosmosVCoreDocumentStore extends KVDocumentStore {
|
|
73
|
-
constructor({ azureCosmosVCoreKVStore, namespace }){
|
|
74
|
-
super(azureCosmosVCoreKVStore, namespace);
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Static method for creating an instance using a MongoClient.
|
|
78
|
-
* @returns Instance of AzureCosmosVCoreDocumentStore
|
|
79
|
-
* @param mongoClient - MongoClient instance
|
|
80
|
-
* @param dbName - Database name
|
|
81
|
-
* @param collectionName - Collection name
|
|
82
|
-
* @example
|
|
83
|
-
* ```ts
|
|
84
|
-
* const mongoClient = new MongoClient("mongodb://localhost:27017");
|
|
85
|
-
* const indexStore = AzureCosmosVCoreDocumentStore.fromMongoClient(mongoClient, "my_db", "my_collection");
|
|
86
|
-
* ```
|
|
87
|
-
*/ static fromMongoClient(mongoClient, dbName = DEFAULT_DATABASE$3, collectionName = DEFAULT_COLLECTION$1) {
|
|
88
|
-
const azureCosmosVCoreKVStore = new AzureCosmosVCoreKVStore({
|
|
89
|
-
mongoClient,
|
|
90
|
-
dbName,
|
|
91
|
-
collectionName
|
|
92
|
-
});
|
|
93
|
-
const namespace = `${dbName}.${collectionName}`;
|
|
94
|
-
return new AzureCosmosVCoreDocumentStore({
|
|
95
|
-
azureCosmosVCoreKVStore,
|
|
96
|
-
namespace
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Static method for creating an instance using a connection string.
|
|
101
|
-
* @returns Instance of AzureCosmosVCoreDocumentStore
|
|
102
|
-
* @param connectionString - MongoDB connection string
|
|
103
|
-
* @param dbName - Database name
|
|
104
|
-
* @param collectionName - Collection name
|
|
105
|
-
* @example
|
|
106
|
-
* ```ts
|
|
107
|
-
* const indexStore = AzureCosmosVCoreDocumentStore.fromConnectionString("mongodb://localhost:27017", "my_db", "my_collection");
|
|
108
|
-
* ```
|
|
109
|
-
*/ static fromConnectionString(connectionString, dbName = DEFAULT_DATABASE$3, collectionName = DEFAULT_COLLECTION$1) {
|
|
110
|
-
const mongoClient = new MongoClient(connectionString, {
|
|
111
|
-
appName: "VECTORSTORES_JS"
|
|
112
|
-
});
|
|
113
|
-
return new AzureCosmosVCoreDocumentStore({
|
|
114
|
-
azureCosmosVCoreKVStore: new AzureCosmosVCoreKVStore({
|
|
115
|
-
mongoClient,
|
|
116
|
-
dbName,
|
|
117
|
-
collectionName
|
|
118
|
-
}),
|
|
119
|
-
namespace: `${dbName}.${collectionName}`
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
69
|
const USER_AGENT_SUFFIX = "vectorstores-cdbnosql-kvstore-javascript";
|
|
125
70
|
const DEFAULT_CHAT_DATABASE = "KVStoreDB";
|
|
126
71
|
const DEFAULT_CHAT_CONTAINER = "KVStoreContainer";
|
|
@@ -294,158 +239,4 @@ class AzureCosmosNoSqlKVStore extends BaseKVStore {
|
|
|
294
239
|
}
|
|
295
240
|
}
|
|
296
241
|
|
|
297
|
-
|
|
298
|
-
const DEFAULT_CONTAINER$1 = "DocumentStoreContainer";
|
|
299
|
-
class AzureCosmosNoSqlDocumentStore extends KVDocumentStore {
|
|
300
|
-
constructor({ azureCosmosNoSqlKVStore, namespace }){
|
|
301
|
-
super(azureCosmosNoSqlKVStore, namespace);
|
|
302
|
-
}
|
|
303
|
-
/**
|
|
304
|
-
* Static method for creating an instance using a connection string.
|
|
305
|
-
* If no connection string is provided, it will attempt to use the env variable `AZURE_COSMOSDB_NOSQL_CONNECTION_STRING` as connection string.
|
|
306
|
-
* @returns Instance of AzureCosmosNoSqlDocumentStore
|
|
307
|
-
*/ static fromConnectionString(options = {}) {
|
|
308
|
-
options.dbName = options.dbName || DEFAULT_DATABASE$2;
|
|
309
|
-
options.containerName = options.containerName || DEFAULT_CONTAINER$1;
|
|
310
|
-
const azureCosmosNoSqlKVStore = AzureCosmosNoSqlKVStore.fromConnectionString(options);
|
|
311
|
-
const namespace = `${options.dbName}.${options.containerName}`;
|
|
312
|
-
return new AzureCosmosNoSqlDocumentStore({
|
|
313
|
-
azureCosmosNoSqlKVStore,
|
|
314
|
-
namespace
|
|
315
|
-
});
|
|
316
|
-
}
|
|
317
|
-
/**
|
|
318
|
-
* Static method for creating an instance using a account endpoint and key.
|
|
319
|
-
* If no endpoint and key is provided, it will attempt to use the env variable `AZURE_COSMOSDB_NOSQL_ACCOUNT_ENDPOINT` as enpoint and `AZURE_COSMOSDB_NOSQL_ACCOUNT_KEY` as key.
|
|
320
|
-
* @returns Instance of AzureCosmosNoSqlDocumentStore
|
|
321
|
-
*/ static fromAccountAndKey(options = {}) {
|
|
322
|
-
options.dbName = options.dbName || DEFAULT_DATABASE$2;
|
|
323
|
-
options.containerName = options.containerName || DEFAULT_CONTAINER$1;
|
|
324
|
-
const azureCosmosNoSqlKVStore = AzureCosmosNoSqlKVStore.fromAccountAndKey(options);
|
|
325
|
-
const namespace = `${options.dbName}.${options.containerName}`;
|
|
326
|
-
return new AzureCosmosNoSqlDocumentStore({
|
|
327
|
-
azureCosmosNoSqlKVStore,
|
|
328
|
-
namespace
|
|
329
|
-
});
|
|
330
|
-
}
|
|
331
|
-
/**
|
|
332
|
-
* Static method for creating an instance using AAD token.
|
|
333
|
-
* If no endpoint and credentials are provided, it will attempt to use the env variable `AZURE_COSMOSDB_NOSQL_ACCOUNT_ENDPOINT` as endpoint and use DefaultAzureCredential() as credentials.
|
|
334
|
-
* @returns Instance of AzureCosmosNoSqlDocumentStore
|
|
335
|
-
*/ static fromAadToken(options = {}) {
|
|
336
|
-
options.dbName = options.dbName || DEFAULT_DATABASE$2;
|
|
337
|
-
options.containerName = options.containerName || DEFAULT_CONTAINER$1;
|
|
338
|
-
const azureCosmosNoSqlKVStore = AzureCosmosNoSqlKVStore.fromAadToken(options);
|
|
339
|
-
const namespace = `${options.dbName}.${options.containerName}`;
|
|
340
|
-
return new AzureCosmosNoSqlDocumentStore({
|
|
341
|
-
azureCosmosNoSqlKVStore,
|
|
342
|
-
namespace
|
|
343
|
-
});
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
const DEFAULT_DATABASE$1 = "IndexStoreDB";
|
|
348
|
-
const DEFAULT_COLLECTION = "IndexStoreCollection";
|
|
349
|
-
class AzureCosmosVCoreIndexStore extends KVIndexStore {
|
|
350
|
-
constructor({ azureCosmosVCoreKVStore, namespace }){
|
|
351
|
-
super(azureCosmosVCoreKVStore, namespace);
|
|
352
|
-
}
|
|
353
|
-
/**
|
|
354
|
-
* Static method for creating an instance using a MongoClient.
|
|
355
|
-
* @returns Instance of AzureCosmosVCoreIndexStore
|
|
356
|
-
* @param mongoClient - MongoClient instance
|
|
357
|
-
* @param dbName - Database name
|
|
358
|
-
* @param collectionName - Collection name
|
|
359
|
-
* @example
|
|
360
|
-
* ```ts
|
|
361
|
-
* const mongoClient = new MongoClient("mongodb://localhost:27017");
|
|
362
|
-
* const indexStore = AzureCosmosVCoreIndexStore.fromMongoClient(mongoClient, "my_db", "my_collection");
|
|
363
|
-
* ```
|
|
364
|
-
*/ static fromMongoClient(mongoClient, dbName = DEFAULT_DATABASE$1, collectionName = DEFAULT_COLLECTION) {
|
|
365
|
-
const azureCosmosVCoreKVStore = new AzureCosmosVCoreKVStore({
|
|
366
|
-
mongoClient,
|
|
367
|
-
dbName,
|
|
368
|
-
collectionName
|
|
369
|
-
});
|
|
370
|
-
const namespace = `${dbName}.${collectionName}`;
|
|
371
|
-
return new AzureCosmosVCoreIndexStore({
|
|
372
|
-
azureCosmosVCoreKVStore,
|
|
373
|
-
namespace
|
|
374
|
-
});
|
|
375
|
-
}
|
|
376
|
-
/**
|
|
377
|
-
* Static method for creating an instance using a connection string.
|
|
378
|
-
* @returns Instance of AzureCosmosVCoreIndexStore
|
|
379
|
-
* @param connectionString - MongoDB connection string
|
|
380
|
-
* @param dbName - Database name
|
|
381
|
-
* @param collectionName - Collection name
|
|
382
|
-
* @example
|
|
383
|
-
* ```ts
|
|
384
|
-
* const indexStore = AzureCosmosVCoreIndexStore.fromConnectionString("mongodb://localhost:27017", "my_db", "my_collection");
|
|
385
|
-
* ```
|
|
386
|
-
*/ static fromConnectionString(connectionString, dbName = DEFAULT_DATABASE$1, collectionName = DEFAULT_COLLECTION) {
|
|
387
|
-
const mongoClient = new MongoClient(connectionString, {
|
|
388
|
-
appName: "VECTORSTORES_JS"
|
|
389
|
-
});
|
|
390
|
-
return new AzureCosmosVCoreIndexStore({
|
|
391
|
-
azureCosmosVCoreKVStore: new AzureCosmosVCoreKVStore({
|
|
392
|
-
mongoClient,
|
|
393
|
-
dbName,
|
|
394
|
-
collectionName
|
|
395
|
-
}),
|
|
396
|
-
namespace: `${dbName}.${collectionName}`
|
|
397
|
-
});
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
const DEFAULT_DATABASE = "IndexStoreDB";
|
|
402
|
-
const DEFAULT_CONTAINER = "IndexStoreContainer";
|
|
403
|
-
class AzureCosmosNoSqlIndexStore extends KVIndexStore {
|
|
404
|
-
constructor({ azureCosmosNoSqlKVStore, namespace }){
|
|
405
|
-
super(azureCosmosNoSqlKVStore, namespace);
|
|
406
|
-
}
|
|
407
|
-
/**
|
|
408
|
-
* Static method for creating an instance using a connection string.
|
|
409
|
-
* If no connection string is provided, it will attempt to use the env variable `AZURE_COSMOSDB_NOSQL_CONNECTION_STRING` as connection string.
|
|
410
|
-
* @returns Instance of AzureCosmosNoSqlIndexStore
|
|
411
|
-
*/ static fromConnectionString(options = {}) {
|
|
412
|
-
options.dbName = options.dbName || DEFAULT_DATABASE;
|
|
413
|
-
options.containerName = options.containerName || DEFAULT_CONTAINER;
|
|
414
|
-
const azureCosmosNoSqlKVStore = AzureCosmosNoSqlKVStore.fromConnectionString(options);
|
|
415
|
-
const namespace = `${options.dbName}.${options.containerName}`;
|
|
416
|
-
return new AzureCosmosNoSqlIndexStore({
|
|
417
|
-
azureCosmosNoSqlKVStore,
|
|
418
|
-
namespace
|
|
419
|
-
});
|
|
420
|
-
}
|
|
421
|
-
/**
|
|
422
|
-
* Static method for creating an instance using a account endpoint and key.
|
|
423
|
-
* If no endpoint and key is provided, it will attempt to use the env variable `AZURE_COSMOSDB_NOSQL_ACCOUNT_ENDPOINT` as enpoint and `AZURE_COSMOSDB_NOSQL_ACCOUNT_KEY` as key.
|
|
424
|
-
* @returns Instance of AzureCosmosNoSqlIndexStore
|
|
425
|
-
*/ static fromAccountAndKey(options = {}) {
|
|
426
|
-
options.dbName = options.dbName || DEFAULT_DATABASE;
|
|
427
|
-
options.containerName = options.containerName || DEFAULT_CONTAINER;
|
|
428
|
-
const azureCosmosNoSqlKVStore = AzureCosmosNoSqlKVStore.fromAccountAndKey(options);
|
|
429
|
-
const namespace = `${options.dbName}.${options.containerName}`;
|
|
430
|
-
return new AzureCosmosNoSqlIndexStore({
|
|
431
|
-
azureCosmosNoSqlKVStore,
|
|
432
|
-
namespace
|
|
433
|
-
});
|
|
434
|
-
}
|
|
435
|
-
/**
|
|
436
|
-
* Static method for creating an instance using AAD token.
|
|
437
|
-
* If no endpoint and credentials are provided, it will attempt to use the env variable `AZURE_COSMOSDB_NOSQL_ACCOUNT_ENDPOINT` as endpoint and use DefaultAzureCredential() as credentials.
|
|
438
|
-
* @returns Instance of AzureCosmosNoSqlIndexStore
|
|
439
|
-
*/ static fromAadToken(options = {}) {
|
|
440
|
-
options.dbName = options.dbName || DEFAULT_DATABASE;
|
|
441
|
-
options.containerName = options.containerName || DEFAULT_CONTAINER;
|
|
442
|
-
const azureCosmosNoSqlKVStore = AzureCosmosNoSqlKVStore.fromAadToken(options);
|
|
443
|
-
const namespace = `${options.dbName}.${options.containerName}`;
|
|
444
|
-
return new AzureCosmosNoSqlIndexStore({
|
|
445
|
-
azureCosmosNoSqlKVStore,
|
|
446
|
-
namespace
|
|
447
|
-
});
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
export { AzureCosmosNoSqlDocumentStore, AzureCosmosNoSqlIndexStore, AzureCosmosNoSqlKVStore, AzureCosmosVCoreDocumentStore, AzureCosmosVCoreIndexStore, AzureCosmosVCoreKVStore };
|
|
242
|
+
export { AzureCosmosNoSqlKVStore, AzureCosmosVCoreKVStore };
|
package/dist/storage.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { BaseKVStore
|
|
2
|
-
import { MongoClient } from 'mongodb';
|
|
1
|
+
import { BaseKVStore } from '@vectorstores/core';
|
|
3
2
|
import { CosmosClient } from '@azure/cosmos';
|
|
4
3
|
import { DefaultAzureCredential } from '@azure/identity';
|
|
5
4
|
import { getEnv } from '@vectorstores/env';
|
|
6
5
|
|
|
7
|
-
var version = "0.1.
|
|
6
|
+
var version = "0.1.4";
|
|
8
7
|
var pkg = {
|
|
9
8
|
version: version};
|
|
10
9
|
|
|
@@ -67,60 +66,6 @@ class AzureCosmosVCoreKVStore extends BaseKVStore {
|
|
|
67
66
|
}
|
|
68
67
|
}
|
|
69
68
|
|
|
70
|
-
const DEFAULT_DATABASE$3 = "DocumentStoreDB";
|
|
71
|
-
const DEFAULT_COLLECTION$1 = "DocumentStoreCollection";
|
|
72
|
-
class AzureCosmosVCoreDocumentStore extends KVDocumentStore {
|
|
73
|
-
constructor({ azureCosmosVCoreKVStore, namespace }){
|
|
74
|
-
super(azureCosmosVCoreKVStore, namespace);
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Static method for creating an instance using a MongoClient.
|
|
78
|
-
* @returns Instance of AzureCosmosVCoreDocumentStore
|
|
79
|
-
* @param mongoClient - MongoClient instance
|
|
80
|
-
* @param dbName - Database name
|
|
81
|
-
* @param collectionName - Collection name
|
|
82
|
-
* @example
|
|
83
|
-
* ```ts
|
|
84
|
-
* const mongoClient = new MongoClient("mongodb://localhost:27017");
|
|
85
|
-
* const indexStore = AzureCosmosVCoreDocumentStore.fromMongoClient(mongoClient, "my_db", "my_collection");
|
|
86
|
-
* ```
|
|
87
|
-
*/ static fromMongoClient(mongoClient, dbName = DEFAULT_DATABASE$3, collectionName = DEFAULT_COLLECTION$1) {
|
|
88
|
-
const azureCosmosVCoreKVStore = new AzureCosmosVCoreKVStore({
|
|
89
|
-
mongoClient,
|
|
90
|
-
dbName,
|
|
91
|
-
collectionName
|
|
92
|
-
});
|
|
93
|
-
const namespace = `${dbName}.${collectionName}`;
|
|
94
|
-
return new AzureCosmosVCoreDocumentStore({
|
|
95
|
-
azureCosmosVCoreKVStore,
|
|
96
|
-
namespace
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Static method for creating an instance using a connection string.
|
|
101
|
-
* @returns Instance of AzureCosmosVCoreDocumentStore
|
|
102
|
-
* @param connectionString - MongoDB connection string
|
|
103
|
-
* @param dbName - Database name
|
|
104
|
-
* @param collectionName - Collection name
|
|
105
|
-
* @example
|
|
106
|
-
* ```ts
|
|
107
|
-
* const indexStore = AzureCosmosVCoreDocumentStore.fromConnectionString("mongodb://localhost:27017", "my_db", "my_collection");
|
|
108
|
-
* ```
|
|
109
|
-
*/ static fromConnectionString(connectionString, dbName = DEFAULT_DATABASE$3, collectionName = DEFAULT_COLLECTION$1) {
|
|
110
|
-
const mongoClient = new MongoClient(connectionString, {
|
|
111
|
-
appName: "VECTORSTORES_JS"
|
|
112
|
-
});
|
|
113
|
-
return new AzureCosmosVCoreDocumentStore({
|
|
114
|
-
azureCosmosVCoreKVStore: new AzureCosmosVCoreKVStore({
|
|
115
|
-
mongoClient,
|
|
116
|
-
dbName,
|
|
117
|
-
collectionName
|
|
118
|
-
}),
|
|
119
|
-
namespace: `${dbName}.${collectionName}`
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
69
|
const USER_AGENT_SUFFIX = "vectorstores-cdbnosql-kvstore-javascript";
|
|
125
70
|
const DEFAULT_CHAT_DATABASE = "KVStoreDB";
|
|
126
71
|
const DEFAULT_CHAT_CONTAINER = "KVStoreContainer";
|
|
@@ -294,158 +239,4 @@ class AzureCosmosNoSqlKVStore extends BaseKVStore {
|
|
|
294
239
|
}
|
|
295
240
|
}
|
|
296
241
|
|
|
297
|
-
|
|
298
|
-
const DEFAULT_CONTAINER$1 = "DocumentStoreContainer";
|
|
299
|
-
class AzureCosmosNoSqlDocumentStore extends KVDocumentStore {
|
|
300
|
-
constructor({ azureCosmosNoSqlKVStore, namespace }){
|
|
301
|
-
super(azureCosmosNoSqlKVStore, namespace);
|
|
302
|
-
}
|
|
303
|
-
/**
|
|
304
|
-
* Static method for creating an instance using a connection string.
|
|
305
|
-
* If no connection string is provided, it will attempt to use the env variable `AZURE_COSMOSDB_NOSQL_CONNECTION_STRING` as connection string.
|
|
306
|
-
* @returns Instance of AzureCosmosNoSqlDocumentStore
|
|
307
|
-
*/ static fromConnectionString(options = {}) {
|
|
308
|
-
options.dbName = options.dbName || DEFAULT_DATABASE$2;
|
|
309
|
-
options.containerName = options.containerName || DEFAULT_CONTAINER$1;
|
|
310
|
-
const azureCosmosNoSqlKVStore = AzureCosmosNoSqlKVStore.fromConnectionString(options);
|
|
311
|
-
const namespace = `${options.dbName}.${options.containerName}`;
|
|
312
|
-
return new AzureCosmosNoSqlDocumentStore({
|
|
313
|
-
azureCosmosNoSqlKVStore,
|
|
314
|
-
namespace
|
|
315
|
-
});
|
|
316
|
-
}
|
|
317
|
-
/**
|
|
318
|
-
* Static method for creating an instance using a account endpoint and key.
|
|
319
|
-
* If no endpoint and key is provided, it will attempt to use the env variable `AZURE_COSMOSDB_NOSQL_ACCOUNT_ENDPOINT` as enpoint and `AZURE_COSMOSDB_NOSQL_ACCOUNT_KEY` as key.
|
|
320
|
-
* @returns Instance of AzureCosmosNoSqlDocumentStore
|
|
321
|
-
*/ static fromAccountAndKey(options = {}) {
|
|
322
|
-
options.dbName = options.dbName || DEFAULT_DATABASE$2;
|
|
323
|
-
options.containerName = options.containerName || DEFAULT_CONTAINER$1;
|
|
324
|
-
const azureCosmosNoSqlKVStore = AzureCosmosNoSqlKVStore.fromAccountAndKey(options);
|
|
325
|
-
const namespace = `${options.dbName}.${options.containerName}`;
|
|
326
|
-
return new AzureCosmosNoSqlDocumentStore({
|
|
327
|
-
azureCosmosNoSqlKVStore,
|
|
328
|
-
namespace
|
|
329
|
-
});
|
|
330
|
-
}
|
|
331
|
-
/**
|
|
332
|
-
* Static method for creating an instance using AAD token.
|
|
333
|
-
* If no endpoint and credentials are provided, it will attempt to use the env variable `AZURE_COSMOSDB_NOSQL_ACCOUNT_ENDPOINT` as endpoint and use DefaultAzureCredential() as credentials.
|
|
334
|
-
* @returns Instance of AzureCosmosNoSqlDocumentStore
|
|
335
|
-
*/ static fromAadToken(options = {}) {
|
|
336
|
-
options.dbName = options.dbName || DEFAULT_DATABASE$2;
|
|
337
|
-
options.containerName = options.containerName || DEFAULT_CONTAINER$1;
|
|
338
|
-
const azureCosmosNoSqlKVStore = AzureCosmosNoSqlKVStore.fromAadToken(options);
|
|
339
|
-
const namespace = `${options.dbName}.${options.containerName}`;
|
|
340
|
-
return new AzureCosmosNoSqlDocumentStore({
|
|
341
|
-
azureCosmosNoSqlKVStore,
|
|
342
|
-
namespace
|
|
343
|
-
});
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
const DEFAULT_DATABASE$1 = "IndexStoreDB";
|
|
348
|
-
const DEFAULT_COLLECTION = "IndexStoreCollection";
|
|
349
|
-
class AzureCosmosVCoreIndexStore extends KVIndexStore {
|
|
350
|
-
constructor({ azureCosmosVCoreKVStore, namespace }){
|
|
351
|
-
super(azureCosmosVCoreKVStore, namespace);
|
|
352
|
-
}
|
|
353
|
-
/**
|
|
354
|
-
* Static method for creating an instance using a MongoClient.
|
|
355
|
-
* @returns Instance of AzureCosmosVCoreIndexStore
|
|
356
|
-
* @param mongoClient - MongoClient instance
|
|
357
|
-
* @param dbName - Database name
|
|
358
|
-
* @param collectionName - Collection name
|
|
359
|
-
* @example
|
|
360
|
-
* ```ts
|
|
361
|
-
* const mongoClient = new MongoClient("mongodb://localhost:27017");
|
|
362
|
-
* const indexStore = AzureCosmosVCoreIndexStore.fromMongoClient(mongoClient, "my_db", "my_collection");
|
|
363
|
-
* ```
|
|
364
|
-
*/ static fromMongoClient(mongoClient, dbName = DEFAULT_DATABASE$1, collectionName = DEFAULT_COLLECTION) {
|
|
365
|
-
const azureCosmosVCoreKVStore = new AzureCosmosVCoreKVStore({
|
|
366
|
-
mongoClient,
|
|
367
|
-
dbName,
|
|
368
|
-
collectionName
|
|
369
|
-
});
|
|
370
|
-
const namespace = `${dbName}.${collectionName}`;
|
|
371
|
-
return new AzureCosmosVCoreIndexStore({
|
|
372
|
-
azureCosmosVCoreKVStore,
|
|
373
|
-
namespace
|
|
374
|
-
});
|
|
375
|
-
}
|
|
376
|
-
/**
|
|
377
|
-
* Static method for creating an instance using a connection string.
|
|
378
|
-
* @returns Instance of AzureCosmosVCoreIndexStore
|
|
379
|
-
* @param connectionString - MongoDB connection string
|
|
380
|
-
* @param dbName - Database name
|
|
381
|
-
* @param collectionName - Collection name
|
|
382
|
-
* @example
|
|
383
|
-
* ```ts
|
|
384
|
-
* const indexStore = AzureCosmosVCoreIndexStore.fromConnectionString("mongodb://localhost:27017", "my_db", "my_collection");
|
|
385
|
-
* ```
|
|
386
|
-
*/ static fromConnectionString(connectionString, dbName = DEFAULT_DATABASE$1, collectionName = DEFAULT_COLLECTION) {
|
|
387
|
-
const mongoClient = new MongoClient(connectionString, {
|
|
388
|
-
appName: "VECTORSTORES_JS"
|
|
389
|
-
});
|
|
390
|
-
return new AzureCosmosVCoreIndexStore({
|
|
391
|
-
azureCosmosVCoreKVStore: new AzureCosmosVCoreKVStore({
|
|
392
|
-
mongoClient,
|
|
393
|
-
dbName,
|
|
394
|
-
collectionName
|
|
395
|
-
}),
|
|
396
|
-
namespace: `${dbName}.${collectionName}`
|
|
397
|
-
});
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
const DEFAULT_DATABASE = "IndexStoreDB";
|
|
402
|
-
const DEFAULT_CONTAINER = "IndexStoreContainer";
|
|
403
|
-
class AzureCosmosNoSqlIndexStore extends KVIndexStore {
|
|
404
|
-
constructor({ azureCosmosNoSqlKVStore, namespace }){
|
|
405
|
-
super(azureCosmosNoSqlKVStore, namespace);
|
|
406
|
-
}
|
|
407
|
-
/**
|
|
408
|
-
* Static method for creating an instance using a connection string.
|
|
409
|
-
* If no connection string is provided, it will attempt to use the env variable `AZURE_COSMOSDB_NOSQL_CONNECTION_STRING` as connection string.
|
|
410
|
-
* @returns Instance of AzureCosmosNoSqlIndexStore
|
|
411
|
-
*/ static fromConnectionString(options = {}) {
|
|
412
|
-
options.dbName = options.dbName || DEFAULT_DATABASE;
|
|
413
|
-
options.containerName = options.containerName || DEFAULT_CONTAINER;
|
|
414
|
-
const azureCosmosNoSqlKVStore = AzureCosmosNoSqlKVStore.fromConnectionString(options);
|
|
415
|
-
const namespace = `${options.dbName}.${options.containerName}`;
|
|
416
|
-
return new AzureCosmosNoSqlIndexStore({
|
|
417
|
-
azureCosmosNoSqlKVStore,
|
|
418
|
-
namespace
|
|
419
|
-
});
|
|
420
|
-
}
|
|
421
|
-
/**
|
|
422
|
-
* Static method for creating an instance using a account endpoint and key.
|
|
423
|
-
* If no endpoint and key is provided, it will attempt to use the env variable `AZURE_COSMOSDB_NOSQL_ACCOUNT_ENDPOINT` as enpoint and `AZURE_COSMOSDB_NOSQL_ACCOUNT_KEY` as key.
|
|
424
|
-
* @returns Instance of AzureCosmosNoSqlIndexStore
|
|
425
|
-
*/ static fromAccountAndKey(options = {}) {
|
|
426
|
-
options.dbName = options.dbName || DEFAULT_DATABASE;
|
|
427
|
-
options.containerName = options.containerName || DEFAULT_CONTAINER;
|
|
428
|
-
const azureCosmosNoSqlKVStore = AzureCosmosNoSqlKVStore.fromAccountAndKey(options);
|
|
429
|
-
const namespace = `${options.dbName}.${options.containerName}`;
|
|
430
|
-
return new AzureCosmosNoSqlIndexStore({
|
|
431
|
-
azureCosmosNoSqlKVStore,
|
|
432
|
-
namespace
|
|
433
|
-
});
|
|
434
|
-
}
|
|
435
|
-
/**
|
|
436
|
-
* Static method for creating an instance using AAD token.
|
|
437
|
-
* If no endpoint and credentials are provided, it will attempt to use the env variable `AZURE_COSMOSDB_NOSQL_ACCOUNT_ENDPOINT` as endpoint and use DefaultAzureCredential() as credentials.
|
|
438
|
-
* @returns Instance of AzureCosmosNoSqlIndexStore
|
|
439
|
-
*/ static fromAadToken(options = {}) {
|
|
440
|
-
options.dbName = options.dbName || DEFAULT_DATABASE;
|
|
441
|
-
options.containerName = options.containerName || DEFAULT_CONTAINER;
|
|
442
|
-
const azureCosmosNoSqlKVStore = AzureCosmosNoSqlKVStore.fromAadToken(options);
|
|
443
|
-
const namespace = `${options.dbName}.${options.containerName}`;
|
|
444
|
-
return new AzureCosmosNoSqlIndexStore({
|
|
445
|
-
azureCosmosNoSqlKVStore,
|
|
446
|
-
namespace
|
|
447
|
-
});
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
export { AzureCosmosNoSqlDocumentStore, AzureCosmosNoSqlIndexStore, AzureCosmosNoSqlKVStore, AzureCosmosVCoreDocumentStore, AzureCosmosVCoreIndexStore, AzureCosmosVCoreKVStore };
|
|
242
|
+
export { AzureCosmosNoSqlKVStore, AzureCosmosVCoreKVStore };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vectorstores/azure",
|
|
3
3
|
"description": "Azure Storage for vectorstores",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.4",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
7
7
|
"module": "./dist/index.js",
|
|
@@ -55,11 +55,11 @@
|
|
|
55
55
|
"@types/node": "^24.0.13",
|
|
56
56
|
"dotenv": "^17.2.0",
|
|
57
57
|
"vitest": "^2.1.5",
|
|
58
|
-
"@vectorstores/core": "0.1.
|
|
58
|
+
"@vectorstores/core": "0.1.4",
|
|
59
59
|
"@vectorstores/env": "0.1.0"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
62
|
-
"@vectorstores/core": "0.1.
|
|
62
|
+
"@vectorstores/core": "0.1.4",
|
|
63
63
|
"@vectorstores/env": "0.1.0"
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|