@pinecone-database/pinecone
Advanced tools
Comparing version 0.1.6-dev.20230628000547 to 0.1.6-dev.20230629000549
@@ -1,2 +0,2 @@ | ||
import { describeIndex, listIndexes, createIndex, deleteIndex, configureIndex } from './control'; | ||
import { describeIndex, listIndexes, createIndex, deleteIndex, configureIndex, listCollections, createCollection, describeCollection, deleteCollection } from './control'; | ||
import { Static } from '@sinclair/typebox'; | ||
@@ -125,2 +125,58 @@ declare const ClientConfigurationSchema: import("@sinclair/typebox").TObject<{ | ||
/** | ||
* Create a new collection from an existing index | ||
* | ||
* @example | ||
* ```js | ||
* const indexList = await client.listIndexes() | ||
* await client.createCollection({ | ||
* name: 'my-collection', | ||
* source: indexList[0] | ||
* }) | ||
* ``` | ||
* | ||
* | ||
* @param options - The collection configuration. | ||
* @param options.name - The name of the collection. Must be unique within the project and contain alphanumeric and hyphen characters. The name must start and end with alphanumeric characters. | ||
* @param options.source - The name of the index to use as the source for the collection. | ||
* @returns a promise that resolves when the request to create the collection is completed. | ||
*/ | ||
createCollection: ReturnType<typeof createCollection>; | ||
/** | ||
* List all collections in a project | ||
* | ||
* @example | ||
* ```js | ||
* await client.listCollections() | ||
* ``` | ||
* | ||
* @returns A promise that resolves to an array of collection objects. | ||
*/ | ||
listCollections: ReturnType<typeof listCollections>; | ||
/** | ||
* Delete a collection by collection name | ||
* | ||
* @example | ||
* ``` | ||
* const collectionList = await client.listCollections() | ||
* const collectionName = collectionList[0] | ||
* await client.deleteCollection(collectionName) | ||
* ``` | ||
* | ||
* @param collectionName - The name of the collection to delete. | ||
* @returns A promise that resolves when the request to delete the collection is completed. | ||
*/ | ||
deleteCollection: ReturnType<typeof deleteCollection>; | ||
/** | ||
* Describe a collection | ||
* | ||
* @example | ||
* ```js | ||
* await client.describeCollection('my-collection') | ||
* ``` | ||
* | ||
* @param collectionName - The name of the collection to describe. | ||
* @returns A promise that resolves to a collection object with type {@link CollectionDescription}. | ||
*/ | ||
describeCollection: ReturnType<typeof describeCollection>; | ||
/** | ||
* Creates a new Pinecone client. Most users will not need to call this directly, but rather use the `Pinecone` {@link Pinecone.createClient} method which aggregates information from multiple configuration sources. | ||
@@ -127,0 +183,0 @@ * |
@@ -46,2 +46,6 @@ "use strict"; | ||
this.configureIndex = (0, control_1.configureIndex)(api); | ||
this.createCollection = (0, control_1.createCollection)(api); | ||
this.listCollections = (0, control_1.listCollections)(api); | ||
this.describeCollection = (0, control_1.describeCollection)(api); | ||
this.deleteCollection = (0, control_1.deleteCollection)(api); | ||
} | ||
@@ -48,0 +52,0 @@ /** @internal */ |
@@ -67,5 +67,2 @@ "use strict"; | ||
}; | ||
jest.mock('../../pinecone-generated-ts-fetch', function () { return ({ | ||
IndexOperationsApi: IOA, | ||
}); }); | ||
return [4 /*yield*/, (0, describeIndex_1.describeIndex)(IOA)('index-name')]; | ||
@@ -98,5 +95,2 @@ case 1: | ||
}; | ||
jest.mock('../../pinecone-generated-ts-fetch', function () { return ({ | ||
IndexOperationsApi: IOA, | ||
}); }); | ||
expectToThrow = function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) { | ||
@@ -121,5 +115,2 @@ switch (_a.label) { | ||
}; | ||
jest.mock('../../pinecone-generated-ts-fetch', function () { return ({ | ||
IndexOperationsApi: IOA, | ||
}); }); | ||
expectToThrow = function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) { | ||
@@ -144,5 +135,2 @@ switch (_a.label) { | ||
}; | ||
jest.mock('../../pinecone-generated-ts-fetch', function () { return ({ | ||
IndexOperationsApi: IOA, | ||
}); }); | ||
expectToThrow = function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) { | ||
@@ -171,5 +159,2 @@ switch (_a.label) { | ||
}; | ||
jest.mock('../../pinecone-generated-ts-fetch', function () { return ({ | ||
IndexOperationsApi: IOA, | ||
}); }); | ||
expectToThrow = function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) { | ||
@@ -200,5 +185,2 @@ switch (_a.label) { | ||
}; | ||
jest.mock('../../pinecone-generated-ts-fetch', function () { return ({ | ||
IndexOperationsApi: IOA, | ||
}); }); | ||
expectToThrow = function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) { | ||
@@ -226,5 +208,2 @@ switch (_a.label) { | ||
}; | ||
jest.mock('../../pinecone-generated-ts-fetch', function () { return ({ | ||
IndexOperationsApi: IOA, | ||
}); }); | ||
expectToThrow = function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) { | ||
@@ -254,5 +233,2 @@ switch (_a.label) { | ||
}; | ||
jest.mock('../../pinecone-generated-ts-fetch', function () { return ({ | ||
IndexOperationsApi: IOA, | ||
}); }); | ||
expectToThrow = function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) { | ||
@@ -259,0 +235,0 @@ switch (_a.label) { |
export { describeIndex } from './describeIndex'; | ||
export type { IndexName } from './describeIndex'; | ||
export { listIndexes } from './listIndexes'; | ||
export { IndexList } from './listIndexes'; | ||
export { createIndex } from './createIndex'; | ||
export type { CreateIndexOptions } from './createIndex'; | ||
export { deleteIndex } from './deleteIndex'; | ||
export { configureIndex } from './configureIndex'; | ||
export type { CreateIndexOptions } from './createIndex'; | ||
export type { IndexName } from './describeIndex'; | ||
export type { IndexList } from './listIndexes'; | ||
export type { ConfigureIndexOptions } from './configureIndex'; | ||
export { createCollection } from './createCollection'; | ||
export { describeCollection } from './describeCollection'; | ||
export { listCollections } from './listCollections'; | ||
export { deleteCollection } from './deleteCollection'; | ||
export type { CollectionName, CollectionList } from './listCollections'; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.configureIndex = exports.deleteIndex = exports.createIndex = exports.listIndexes = exports.describeIndex = void 0; | ||
exports.deleteCollection = exports.listCollections = exports.describeCollection = exports.createCollection = exports.configureIndex = exports.deleteIndex = exports.createIndex = exports.listIndexes = exports.describeIndex = void 0; | ||
// Index Operations | ||
var describeIndex_1 = require("./describeIndex"); | ||
@@ -14,2 +15,11 @@ Object.defineProperty(exports, "describeIndex", { enumerable: true, get: function () { return describeIndex_1.describeIndex; } }); | ||
Object.defineProperty(exports, "configureIndex", { enumerable: true, get: function () { return configureIndex_1.configureIndex; } }); | ||
// Collection Operations | ||
var createCollection_1 = require("./createCollection"); | ||
Object.defineProperty(exports, "createCollection", { enumerable: true, get: function () { return createCollection_1.createCollection; } }); | ||
var describeCollection_1 = require("./describeCollection"); | ||
Object.defineProperty(exports, "describeCollection", { enumerable: true, get: function () { return describeCollection_1.describeCollection; } }); | ||
var listCollections_1 = require("./listCollections"); | ||
Object.defineProperty(exports, "listCollections", { enumerable: true, get: function () { return listCollections_1.listCollections; } }); | ||
var deleteCollection_1 = require("./deleteCollection"); | ||
Object.defineProperty(exports, "deleteCollection", { enumerable: true, get: function () { return deleteCollection_1.deleteCollection; } }); | ||
//# sourceMappingURL=index.js.map |
import { IndexOperationsApi } from '../pinecone-generated-ts-fetch'; | ||
import type { FailedRequestInfo } from '../errors'; | ||
export declare const validIndexMessage: (api: IndexOperationsApi, name: string, requestInfo: FailedRequestInfo) => Promise<string>; | ||
export declare const validCollectionMessage: (api: IndexOperationsApi, name: string, requestInfo: FailedRequestInfo) => Promise<string>; |
@@ -50,3 +50,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.validIndexMessage = void 0; | ||
exports.validCollectionMessage = exports.validIndexMessage = void 0; | ||
var errors_1 = require("../errors"); | ||
@@ -76,2 +76,25 @@ var validIndexMessage = function (api, name, requestInfo) { return __awaiter(void 0, void 0, void 0, function () { | ||
exports.validIndexMessage = validIndexMessage; | ||
var validCollectionMessage = function (api, name, requestInfo) { return __awaiter(void 0, void 0, void 0, function () { | ||
var validNames, e_2; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
_a.trys.push([0, 2, , 3]); | ||
return [4 /*yield*/, api.listCollections()]; | ||
case 1: | ||
validNames = _a.sent(); | ||
return [2 /*return*/, "Collection '".concat(name, "' does not exist. Valid collection names: [").concat(validNames | ||
.map(function (n) { return "'".concat(n, "'"); }) | ||
.join(', '), "]")]; | ||
case 2: | ||
e_2 = _a.sent(); | ||
// Expect to end up here only if a second error occurs while fetching valid collection names. | ||
// We can show the error from the failed call to describeIndex, but without listing | ||
// index names. | ||
throw (0, errors_1.mapHttpStatusError)(__assign(__assign({}, requestInfo), { message: "Collection '".concat(name, "' does not exist.") })); | ||
case 3: return [2 /*return*/]; | ||
} | ||
}); | ||
}); }; | ||
exports.validCollectionMessage = validCollectionMessage; | ||
//# sourceMappingURL=utils.js.map |
{ | ||
"name": "@pinecone-database/pinecone", | ||
"version": "0.1.6-dev.20230628000547", | ||
"version": "0.1.6-dev.20230629000549", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "repository": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
646377
213
10180