Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@pinecone-database/pinecone

Package Overview
Dependencies
Maintainers
1
Versions
724
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pinecone-database/pinecone - npm Package Compare versions

Comparing version 4.0.0 to 4.1.0

dist/external-app/assertResponse.d.ts

2

dist/__tests__/pinecone.test.js

@@ -154,3 +154,3 @@ "use strict";

}).toThrow('Object contained invalid properties: unknownProp. Valid properties include apiKey, controllerHostUrl,' +
' fetchApi, additionalHeaders, sourceTag.');
' fetchApi, additionalHeaders, sourceTag, maxRetries.');
});

@@ -157,0 +157,0 @@ });

@@ -64,2 +64,6 @@ "use strict";

},
tags: {
example: 'tag',
},
deletionProtection: 'disabled', // Redundant, but for example purposes
};

@@ -69,3 +73,9 @@ fakeConfigure = jest.fn().mockResolvedValue(indexModel);

return [4 /*yield*/, (0, configureIndex_1.configureIndex)(IOA)('index-name', {
spec: { pod: { replicas: 4, podType: 'p2.x2' } },
spec: {
pod: { replicas: 4, podType: 'p2.x2' },
},
deletionProtection: 'disabled',
tags: {
example: 'tag',
},
})];

@@ -79,2 +89,6 @@ case 1:

spec: { pod: { replicas: 4, podType: 'p2.x2' } },
deletionProtection: 'disabled',
tags: {
example: 'tag',
},
},

@@ -81,0 +95,0 @@ });

@@ -109,3 +109,3 @@ "use strict";

_a.sent();
return [4 /*yield*/, expect(toThrow).rejects.toThrowError('Object contained invalid properties: speculoos. Valid properties include deletionProtection, spec.')];
return [4 /*yield*/, expect(toThrow).rejects.toThrowError('Object contained invalid properties: speculoos. Valid properties include deletionProtection, spec, tags.')];
case 2:

@@ -131,3 +131,3 @@ _a.sent();

_a.sent();
return [4 /*yield*/, expect(toThrowSpec).rejects.toThrowError('You must pass either a `spec`, `deletionProtection` or both to configureIndex in order to update.')];
return [4 /*yield*/, expect(toThrowSpec).rejects.toThrowError('You must pass either `spec`, `deletionProtection` or `tags` to configureIndex in order to update.')];
case 2:

@@ -134,0 +134,0 @@ _a.sent();

@@ -89,2 +89,5 @@ "use strict";

},
tags: {
example: 'tag',
},
})];

@@ -106,2 +109,5 @@ case 1:

},
tags: {
example: 'tag',
},
},

@@ -270,3 +276,4 @@ });

_a.sent();
return [4 /*yield*/, expect(toThrow).rejects.toThrowError('Object contained invalid properties: dimensionlshgoiwe. Valid properties include spec, name, dimension, metric, deletionProtection, waitUntilReady, suppressConflicts.')];
return [4 /*yield*/, expect(toThrow).rejects.toThrowError('Object contained invalid properties: dimensionlshgoiwe. Valid properties include spec, name, dimension,' +
' metric, deletionProtection, waitUntilReady, suppressConflicts, tags.')];
case 2:

@@ -273,0 +280,0 @@ _a.sent();

@@ -5,3 +5,3 @@ import { ManageIndexesApi, IndexModel, ConfigureIndexRequest } from '../pinecone-generated-ts-fetch/db_control';

export declare const ConfigureIndexRequestProperties: ConfigureIndexRequestType[];
export declare const configureIndex: (api: ManageIndexesApi) => (indexName: IndexName, options: ConfigureIndexRequest) => Promise<IndexModel>;
export declare const configureIndex: (api: ManageIndexesApi) => (indexName: IndexName, options: ConfigureIndexRequest, maxRetries?: number) => Promise<IndexModel>;
export {};

@@ -42,5 +42,7 @@ "use strict";

var validateProperties_1 = require("../utils/validateProperties");
var utils_1 = require("../utils");
exports.ConfigureIndexRequestProperties = [
'deletionProtection',
'spec',
'tags',
];

@@ -57,4 +59,4 @@ var configureIndex = function (api) {

// not provided
if (!options.spec && !options.deletionProtection) {
throw new errors_1.PineconeArgumentError('You must pass either a `spec`, `deletionProtection` or both to configureIndex in order to update.');
if (!options.spec && !options.deletionProtection && !options.tags) {
throw new errors_1.PineconeArgumentError('You must pass either `spec`, `deletionProtection` or `tags` to configureIndex in order to update.');
}

@@ -72,3 +74,4 @@ if (options.spec) {

};
return function (indexName, options) { return __awaiter(void 0, void 0, void 0, function () {
return function (indexName, options, maxRetries) { return __awaiter(void 0, void 0, void 0, function () {
var retryWrapper;
return __generator(this, function (_a) {

@@ -78,3 +81,4 @@ switch (_a.label) {

validator(indexName, options);
return [4 /*yield*/, api.configureIndex({
retryWrapper = new utils_1.RetryOnServerFailure(api.configureIndex.bind(api), maxRetries);
return [4 /*yield*/, retryWrapper.execute({
indexName: indexName,

@@ -81,0 +85,0 @@ configureIndexRequest: options,

@@ -53,2 +53,3 @@ "use strict";

'suppressConflicts',
'tags',
];

@@ -55,0 +56,0 @@ var CreateIndexSpecProperties = ['serverless', 'pod'];

@@ -159,3 +159,4 @@ import type { FetchOptions } from './vectors/fetch';

*
* // Records from namespace 'foo' are now deleted. Records in other namespaces are not modified.
* // Records from the default namespace '' are now deleted. Records in other namespaces are not modified.
*
* await index.describeIndexStats();

@@ -170,6 +171,2 @@ * // {

* // }
*
* await index.deleteAll();
* // Since no namespace was specified, records in default namespace '' are now deleted.
*
* ```

@@ -176,0 +173,0 @@ * @throws {@link Errors.PineconeConnectionError} when network problems or an outage of Pinecone's APIs prevent the request from being completed.

@@ -187,3 +187,4 @@ "use strict";

*
* // Records from namespace 'foo' are now deleted. Records in other namespaces are not modified.
* // Records from the default namespace '' are now deleted. Records in other namespaces are not modified.
*
* await index.describeIndexStats();

@@ -198,6 +199,2 @@ * // {

* // }
*
* await index.deleteAll();
* // Since no namespace was specified, records in default namespace '' are now deleted.
*
* ```

@@ -382,3 +379,3 @@ * @throws {@link Errors.PineconeConnectionError} when network problems or an outage of Pinecone's APIs prevent the request from being completed.

switch (_a.label) {
case 0: return [4 /*yield*/, this._upsertCommand.run(data)];
case 0: return [4 /*yield*/, this._upsertCommand.run(data, this.config.maxRetries)];
case 1: return [2 /*return*/, _a.sent()];

@@ -471,3 +468,3 @@ }

switch (_a.label) {
case 0: return [4 /*yield*/, this._updateCommand.run(options)];
case 0: return [4 /*yield*/, this._updateCommand.run(options, this.config.maxRetries)];
case 1: return [2 /*return*/, _a.sent()];

@@ -474,0 +471,0 @@ }

@@ -26,2 +26,6 @@ import type { FetchAPI, HTTPHeaders } from '../../pinecone-generated-ts-fetch/db_data';

sourceTag?: string;
/**
* Optional configuration field for specifying the maximum number of retries for a request. Defaults to 3.
*/
maxRetries?: number;
};

@@ -28,0 +32,0 @@ type PineconeConfigurationType = keyof PineconeConfiguration;

@@ -10,2 +10,3 @@ "use strict";

'sourceTag',
'maxRetries',
];

@@ -12,0 +13,0 @@ exports.PineconeRecordsProperties = [

@@ -29,3 +29,3 @@ import { VectorOperationsProvider } from './vectorOperationsProvider';

validator: (options: UpdateOptions<T>) => void;
run(options: UpdateOptions<T>): Promise<void>;
run(options: UpdateOptions<T>, maxRetries?: number): Promise<void>;
}

@@ -53,2 +53,3 @@ "use strict";

var validateProperties_1 = require("../../utils/validateProperties");
var utils_1 = require("../../utils");
var UpdateOptionsProperties = [

@@ -73,5 +74,5 @@ 'id',

}
UpdateCommand.prototype.run = function (options) {
UpdateCommand.prototype.run = function (options, maxRetries) {
return __awaiter(this, void 0, void 0, function () {
var requestOptions, api;
var requestOptions, api, retryWrapper;
return __generator(this, function (_a) {

@@ -90,3 +91,4 @@ switch (_a.label) {

api = _a.sent();
return [4 /*yield*/, api.updateVector({
retryWrapper = new utils_1.RetryOnServerFailure(api.updateVector.bind(api), maxRetries);
return [4 /*yield*/, retryWrapper.execute({
updateRequest: __assign(__assign({}, requestOptions), { namespace: this.namespace }),

@@ -93,0 +95,0 @@ })];

@@ -8,3 +8,3 @@ import { VectorOperationsProvider } from './vectorOperationsProvider';

validator: (records: Array<PineconeRecord<T>>) => void;
run(records: Array<PineconeRecord<T>>): Promise<void>;
run(records: Array<PineconeRecord<T>>, maxRetries?: number): Promise<void>;
}

@@ -43,2 +43,3 @@ "use strict";

var validateProperties_1 = require("../../utils/validateProperties");
var utils_1 = require("../../utils");
var UpsertCommand = /** @class */ (function () {

@@ -66,5 +67,5 @@ function UpsertCommand(apiProvider, namespace) {

}
UpsertCommand.prototype.run = function (records) {
UpsertCommand.prototype.run = function (records, maxRetries) {
return __awaiter(this, void 0, void 0, function () {
var api;
var api, retryWrapper;
return __generator(this, function (_a) {

@@ -77,3 +78,4 @@ switch (_a.label) {

api = _a.sent();
return [4 /*yield*/, api.upsertVectors({
retryWrapper = new utils_1.RetryOnServerFailure(api.upsertVectors.bind(api), maxRetries);
return [4 /*yield*/, retryWrapper.execute({
upsertRequest: {

@@ -80,0 +82,0 @@ vectors: records,

@@ -52,3 +52,19 @@ import { BasePineconeError } from './base';

}
export declare class PineconeMaxRetriesExceededError extends BasePineconeError {
constructor(retries: number);
}
/**
* This error indicates API responses are returning with status 503 and
* Pinecone itself is down. Check the [status page](https://status.pinecone.io/)
* for information about current or recent outages.
*
* The difference between this error (503) and a PineconeInternalServerError (500) is that this error does NOT indicate
* that the server is _unable_ to process the request, just that the server will not process the request.
*
* @see [Pinecone's status page](https://status.pinecone.io/)
*/
export declare class PineconeUnavailableError extends BasePineconeError {
constructor(failedRequest: FailedRequestInfo);
}
/**
* This error is thrown when you are attempting to use a feature that is

@@ -72,2 +88,2 @@ * not implemented or unavailable to you on your current plan. Free indexes

/** @internal */
export declare const mapHttpStatusError: (failedRequestInfo: FailedRequestInfo) => PineconeBadRequestError | PineconeAuthorizationError | PineconeNotFoundError | PineconeConflictError | PineconeInternalServerError | PineconeNotImplementedError;
export declare const mapHttpStatusError: (failedRequestInfo: FailedRequestInfo) => PineconeBadRequestError | PineconeAuthorizationError | PineconeNotFoundError | PineconeConflictError | PineconeInternalServerError | PineconeUnavailableError | PineconeNotImplementedError;

@@ -18,3 +18,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.mapHttpStatusError = exports.PineconeUnmappedHttpError = exports.PineconeNotImplementedError = exports.PineconeInternalServerError = exports.PineconeConflictError = exports.PineconeNotFoundError = exports.PineconeAuthorizationError = exports.PineconeBadRequestError = void 0;
exports.mapHttpStatusError = exports.PineconeUnmappedHttpError = exports.PineconeNotImplementedError = exports.PineconeUnavailableError = exports.PineconeMaxRetriesExceededError = exports.PineconeInternalServerError = exports.PineconeConflictError = exports.PineconeNotFoundError = exports.PineconeAuthorizationError = exports.PineconeBadRequestError = void 0;
var base_1 = require("./base");

@@ -117,9 +117,10 @@ var CONFIG_HELP = "You can find the configuration values for your project in the Pinecone developer console at https://app.pinecone.io";

var _this = this;
var url = failedRequest.url, body = failedRequest.body;
var url = failedRequest.url, body = failedRequest.body, status = failedRequest.status;
var intro = url
? "An internal server error occured while calling the ".concat(url, " endpoint.")
? "An internal server error occurred while calling the ".concat(url, " endpoint.")
: '';
var help = "To see overall service health and learn whether this seems like a large-scale problem or one specific to your request, please go to https://status.pinecone.io/ to view our status page. If you believe the error reflects a problem with this client, please file a bug report in the github issue tracker at https://github.com/pinecone-io/pinecone-ts-client";
var statusMessage = status ? "Status Code: ".concat(status, ".") : '';
var bodyMessage = body ? "Body: ".concat(body) : '';
_this = _super.call(this, [intro, help, bodyMessage].join(' ').trim()) || this;
_this = _super.call(this, [intro, statusMessage, help, bodyMessage].join(' ').trim()) || this;
_this.name = 'PineconeInternalServerError';

@@ -131,3 +132,47 @@ return _this;

exports.PineconeInternalServerError = PineconeInternalServerError;
/* We can choose to throw this error when we want to limit requests to the server. When instantiated, pass the
number of retries the user has made already. */
var PineconeMaxRetriesExceededError = /** @class */ (function (_super) {
__extends(PineconeMaxRetriesExceededError, _super);
function PineconeMaxRetriesExceededError(retries) {
var _this = this;
var intro = "You have exceeded the max configured retries (".concat(retries, "). ");
var help = 'Increase the maxRetries field in the RetryOptions object to retry more times. If you believe the' +
' error reflects a problem with this client, please file a bug report in the github issue tracker at https://github.com/pinecone-io/pinecone-ts-client';
_this = _super.call(this, [intro, help].join(' ').trim()) || this;
_this.name = 'PineconeMaxRetriesExceededError';
return _this;
}
return PineconeMaxRetriesExceededError;
}(base_1.BasePineconeError));
exports.PineconeMaxRetriesExceededError = PineconeMaxRetriesExceededError;
/**
* This error indicates API responses are returning with status 503 and
* Pinecone itself is down. Check the [status page](https://status.pinecone.io/)
* for information about current or recent outages.
*
* The difference between this error (503) and a PineconeInternalServerError (500) is that this error does NOT indicate
* that the server is _unable_ to process the request, just that the server will not process the request.
*
* @see [Pinecone's status page](https://status.pinecone.io/)
*/
var PineconeUnavailableError = /** @class */ (function (_super) {
__extends(PineconeUnavailableError, _super);
function PineconeUnavailableError(failedRequest) {
var _this = this;
var url = failedRequest.url, body = failedRequest.body, status = failedRequest.status;
var intro = url
? "The Pinecone service (".concat(url, ") is temporarily unavailable.")
: '';
var statusMessage = status ? "Status Code: ".concat(status, ".") : '';
var help = "To see overall service health and learn whether this seems like a large-scale problem or one specific to your request, please go to https://status.pinecone.io/ to view our status page. If you believe the error reflects a problem with this client, please file a bug report in the github issue tracker at https://github.com/pinecone-io/pinecone-ts-client";
var bodyMessage = body ? "Body: ".concat(body) : '';
_this = _super.call(this, [intro, statusMessage, help, bodyMessage].join(' ').trim()) || this;
_this.name = 'PineconeUnavailableError';
return _this;
}
return PineconeUnavailableError;
}(base_1.BasePineconeError));
exports.PineconeUnavailableError = PineconeUnavailableError;
/**
* This error is thrown when you are attempting to use a feature that is

@@ -195,2 +240,4 @@ * not implemented or unavailable to you on your current plan. Free indexes

return new PineconeNotImplementedError(failedRequestInfo);
case 503:
return new PineconeUnavailableError(failedRequestInfo);
default:

@@ -197,0 +244,0 @@ throw new PineconeUnmappedHttpError(failedRequestInfo);

@@ -39,3 +39,2 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var errors_1 = require("../../errors");
var index_1 = require("../../index");

@@ -64,2 +63,3 @@ var test_helpers_1 = require("../test-helpers");

},
tags: { project: 'pinecone-integration-tests' },
waitUntilReady: true,

@@ -82,2 +82,3 @@ })];

waitUntilReady: true,
tags: { project: 'pinecone-integration-tests' },
})];

@@ -133,3 +134,3 @@ case 2:

test('scale podType up', function () { return __awaiter(void 0, void 0, void 0, function () {
var description, state, retryCount, maxRetries, e_1, description2;
var description, description2;
var _a, _b;

@@ -142,36 +143,12 @@ return __generator(this, function (_c) {

expect((_a = description.spec.pod) === null || _a === void 0 ? void 0 : _a.podType).toEqual('p1.x1');
state = true;
retryCount = 0;
maxRetries = 10;
_c.label = 2;
case 2:
if (!(state && retryCount < maxRetries)) return [3 /*break*/, 10];
_c.label = 3;
case 3:
_c.trys.push([3, 5, , 9]);
return [4 /*yield*/, pinecone.configureIndex(podIndexName, {
spec: { pod: { podType: 'p1.x2' } },
})];
case 4:
case 2:
_c.sent();
state = false;
return [3 /*break*/, 9];
case 5:
e_1 = _c.sent();
if (!(e_1 instanceof errors_1.PineconeInternalServerError)) return [3 /*break*/, 7];
retryCount++;
return [4 /*yield*/, (0, test_helpers_1.sleep)(2000)];
case 6:
return [4 /*yield*/, (0, test_helpers_1.waitUntilReady)(podIndexName)];
case 3:
_c.sent();
return [3 /*break*/, 8];
case 7:
console.log('Unexpected error:', e_1);
throw e_1;
case 8: return [3 /*break*/, 9];
case 9: return [3 /*break*/, 2];
case 10: return [4 /*yield*/, (0, test_helpers_1.waitUntilReady)(podIndexName)];
case 11:
_c.sent();
return [4 /*yield*/, pinecone.describeIndex(podIndexName)];
case 12:
case 4:
description2 = _c.sent();

@@ -183,2 +160,25 @@ expect((_b = description2.spec.pod) === null || _b === void 0 ? void 0 : _b.podType).toEqual('p1.x2');

}); });
test('Remove index tag from pod index', function () { return __awaiter(void 0, void 0, void 0, function () {
var description, description2;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, pinecone.describeIndex(podIndexName)];
case 1:
description = _a.sent();
expect(description.tags).toEqual({
project: 'pinecone-integration-tests',
});
return [4 /*yield*/, pinecone.configureIndex(podIndexName, {
tags: { project: '' },
})];
case 2:
_a.sent();
return [4 /*yield*/, pinecone.describeIndex(podIndexName)];
case 3:
description2 = _a.sent();
expect(description2.tags).toBeUndefined();
return [2 /*return*/];
}
});
}); });
});

@@ -217,6 +217,94 @@ describe('serverless index', function () {

}); });
test('Add/remove index tag(s) on serverless index', function () { return __awaiter(void 0, void 0, void 0, function () {
var description, description2, description3, description4;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, pinecone.describeIndex(serverlessIndexName)];
case 1:
description = _a.sent();
expect(description.tags).toEqual({
project: 'pinecone-integration-tests',
});
// Add a tag
return [4 /*yield*/, pinecone.configureIndex(serverlessIndexName, {
tags: { testTag: 'testValue' },
})];
case 2:
// Add a tag
_a.sent();
return [4 /*yield*/, pinecone.describeIndex(serverlessIndexName)];
case 3:
description2 = _a.sent();
expect(description2.tags).toEqual({
project: 'pinecone-integration-tests',
testTag: 'testValue',
});
// Remove that tag
return [4 /*yield*/, pinecone.configureIndex(serverlessIndexName, {
tags: { testTag: '' }, // Passing null/undefined here is not allowed due to type safety (must eval to string)
})];
case 4:
// Remove that tag
_a.sent();
return [4 /*yield*/, pinecone.describeIndex(serverlessIndexName)];
case 5:
description3 = _a.sent();
if (description3.tags != null) {
expect(description3.tags['testTag']).toBeUndefined();
expect(description3.tags['project']).toEqual('pinecone-integration-tests');
}
// Confirm when config'ing other things about the index, tags are not changed
return [4 /*yield*/, pinecone.configureIndex(serverlessIndexName, {
deletionProtection: 'enabled',
})];
case 6:
// Confirm when config'ing other things about the index, tags are not changed
_a.sent();
return [4 /*yield*/, pinecone.describeIndex(serverlessIndexName)];
case 7:
description4 = _a.sent();
if (description4.tags != null) {
expect(description4.tags['testTag']).toBeUndefined();
expect(description4.tags['project']).toEqual('pinecone-integration-tests');
}
// (Cleanup) Disable deletion protection
return [4 /*yield*/, pinecone.configureIndex(serverlessIndexName, {
deletionProtection: 'disabled',
})];
case 8:
// (Cleanup) Disable deletion protection
_a.sent();
return [2 /*return*/];
}
});
}); });
test('Update a tag value in a serverless index', function () { return __awaiter(void 0, void 0, void 0, function () {
var description, description2;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, pinecone.describeIndex(serverlessIndexName)];
case 1:
description = _a.sent();
expect(description.tags).toEqual({
project: 'pinecone-integration-tests',
});
return [4 /*yield*/, pinecone.configureIndex(serverlessIndexName, {
tags: { project: 'updated-project' },
})];
case 2:
_a.sent();
return [4 /*yield*/, pinecone.describeIndex(serverlessIndexName)];
case 3:
description2 = _a.sent();
if (description2.tags != null) {
expect(description2.tags['project']).toEqual('updated-project');
}
return [2 /*return*/];
}
});
}); });
});
describe('error cases', function () {
test('cannot configure index with invalid index name', function () { return __awaiter(void 0, void 0, void 0, function () {
var e_2, err;
var e_1, err;
return __generator(this, function (_a) {

@@ -233,4 +321,4 @@ switch (_a.label) {

case 2:
e_2 = _a.sent();
err = e_2;
e_1 = _a.sent();
err = e_1;
expect(err.name).toEqual('PineconeNotFoundError');

@@ -243,3 +331,3 @@ return [3 /*break*/, 3];

test('cannot configure index when exceeding quota', function () { return __awaiter(void 0, void 0, void 0, function () {
var e_3, err;
var e_2, err;
return __generator(this, function (_a) {

@@ -256,4 +344,4 @@ switch (_a.label) {

case 2:
e_3 = _a.sent();
err = e_3;
e_2 = _a.sent();
err = e_2;
expect(err.name).toEqual('PineconeBadRequestError');

@@ -268,3 +356,3 @@ expect(err.message).toContain("You've reached the max pods allowed in project");

test('cannot change base pod type', function () { return __awaiter(void 0, void 0, void 0, function () {
var e_4, err;
var e_3, err;
return __generator(this, function (_a) {

@@ -283,4 +371,4 @@ switch (_a.label) {

case 2:
e_4 = _a.sent();
err = e_4;
e_3 = _a.sent();
err = e_3;
expect(err.name).toEqual('PineconeBadRequestError');

@@ -294,3 +382,3 @@ expect(err.message).toContain('Bad request: Cannot change pod type');

test('cannot set deletionProtection value other than enabled / disabled', function () { return __awaiter(void 0, void 0, void 0, function () {
var e_5, err;
var e_4, err;
return __generator(this, function (_a) {

@@ -308,4 +396,4 @@ switch (_a.label) {

case 2:
e_5 = _a.sent();
err = e_5;
e_4 = _a.sent();
err = e_4;
expect(err.name).toEqual('PineconeBadRequestError');

@@ -319,3 +407,3 @@ expect(err.message).toContain('Invalid deletion_protection, value should be either enabled or disabled');

test('cannot configure pod spec for serverless', function () { return __awaiter(void 0, void 0, void 0, function () {
var e_6, err;
var e_5, err;
return __generator(this, function (_a) {

@@ -332,4 +420,4 @@ switch (_a.label) {

case 2:
e_6 = _a.sent();
err = e_6;
e_5 = _a.sent();
err = e_5;
expect(err.name).toEqual('PineconeBadRequestError');

@@ -336,0 +424,0 @@ expect(err.message).toContain('Configuring replicas and pod type is not supported for serverless');

@@ -66,2 +66,3 @@ "use strict";

waitUntilReady: true,
tags: { project: 'pinecone-integration-tests' },
})];

@@ -77,2 +78,5 @@ case 1:

expect(description.host).toBeDefined();
expect(description.tags).toEqual({
project: 'pinecone-integration-tests',
});
return [4 /*yield*/, pinecone.deleteIndex(indexName)];

@@ -79,0 +83,0 @@ case 3:

@@ -66,2 +66,5 @@ "use strict";

expect(description.status.state).toEqual('Ready');
expect(description.tags).toEqual({
project: 'pinecone-integration-tests-serverless',
});
return [2 /*return*/];

@@ -68,0 +71,0 @@ }

@@ -75,5 +75,2 @@ "use strict";

_a.sent();
return [4 /*yield*/, pinecone.deleteIndex(indexName)];
case 2:
_a.sent();
return [2 /*return*/];

@@ -80,0 +77,0 @@ }

@@ -66,3 +66,3 @@ "use strict";

expect(listResults).toBeDefined();
// expect(listResults.pagination).toBeDefined(); todo: re-enable this once pagination bug is fixed (https://app.asana.com/0/1204819992273155/1207992392793971/f)
expect(listResults.pagination).toBeUndefined(); // Only 11 records in the index, so no pag token returned
expect((_a = listResults.vectors) === null || _a === void 0 ? void 0 : _a.length).toBe(11);

@@ -86,2 +86,3 @@ expect(listResults.namespace).toBe(test_helpers_1.globalNamespaceOne);

expect((_a = listResults.vectors) === null || _a === void 0 ? void 0 : _a.length).toBe(1);
expect(listResults.pagination).toBeUndefined();
return [2 /*return*/];

@@ -104,2 +105,3 @@ }

expect((_a = listResults.vectors) === null || _a === void 0 ? void 0 : _a.length).toBe(3);
expect(listResults.pagination).toBeDefined();
return [4 /*yield*/, serverlessIndex.listPaginated({

@@ -106,0 +108,0 @@ prefix: test_helpers_1.prefix,

"use strict";
/* This file tests both Upsert and Update operations. It additionally tests the RetryOnServerFailure implementation
on the Upsert operation. */
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -38,5 +40,12 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var index_1 = require("../../../index");
var test_helpers_1 = require("../../test-helpers");
var utils_1 = require("../../../utils");
var errors_1 = require("../../../errors");
var http_1 = __importDefault(require("http"));
var url_1 = require("url");
// todo: add pods

@@ -129,2 +138,165 @@ var pinecone, serverlessIndex, serverlessIndexName;

});
// Retry logic tests
describe('Testing retry logic via a mock, in-memory http server', function () {
var recordsToUpsert = (0, test_helpers_1.generateRecords)({
dimension: 2,
quantity: 1,
withSparseValues: false,
withMetadata: true,
});
var server; // Note: server cannot be something like an express server due to conflicts w/edge runtime
var mockServerlessIndex;
var callCount;
var op;
// Helper function to start the server with a specific response pattern
var startMockServer = function (shouldSucceedOnSecondCall) {
// Create http server
server = http_1.default.createServer(function (req, res) {
var pathname = (0, url_1.parse)(req.url || '', true).pathname;
if (req.method === 'POST' && pathname === "/vectors/".concat(op)) {
callCount++;
if (shouldSucceedOnSecondCall && callCount === 1) {
res.writeHead(503, { 'Content-Type': 'application/json' });
res.end(JSON.stringify({ name: 'PineconeUnavailableError', status: 503 }));
}
else if (shouldSucceedOnSecondCall && callCount === 2) {
res.writeHead(200, { 'Content-Type': 'application/json' });
res.end(JSON.stringify({ status: 200, data: 'Success' }));
}
else {
res.writeHead(503, { 'Content-Type': 'application/json' });
res.end(JSON.stringify({ name: 'PineconeUnavailableError', status: 503 }));
}
}
else {
res.writeHead(404); // Not found
res.end();
}
});
server.listen(4000); // Host server on local port 4000
};
beforeEach(function () {
callCount = 0;
});
afterEach(function () { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
// Close server and reset mocks
return [4 /*yield*/, new Promise(function (resolve) { return server.close(function () { return resolve(); }); })];
case 1:
// Close server and reset mocks
_a.sent();
jest.clearAllMocks();
return [2 /*return*/];
}
});
}); });
test('Upsert operation should retry 1x if server responds 1x with error and 1x with success', function () { return __awaiter(void 0, void 0, void 0, function () {
var retrySpy, delaySpy;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
op = 'upsert';
pinecone = new index_1.Pinecone({
apiKey: process.env['PINECONE_API_KEY'] || '',
maxRetries: 2,
});
mockServerlessIndex = pinecone
.Index(serverlessIndexName, 'http://localhost:4000')
.namespace(test_helpers_1.globalNamespaceOne);
retrySpy = jest.spyOn(utils_1.RetryOnServerFailure.prototype, 'execute');
delaySpy = jest.spyOn(utils_1.RetryOnServerFailure.prototype, 'delay');
// Start server with a successful response on the second call
startMockServer(true);
// Call Upsert operation
return [4 /*yield*/, mockServerlessIndex.upsert(recordsToUpsert)];
case 1:
// Call Upsert operation
_a.sent();
// 2 total tries: 1 initial call, 1 retry
expect(retrySpy).toHaveBeenCalledTimes(1); // passes
expect(delaySpy).toHaveBeenCalledTimes(1); // fails
expect(callCount).toBe(2);
return [2 /*return*/];
}
});
}); });
test('Update operation should retry 1x if server responds 1x with error and 1x with success', function () { return __awaiter(void 0, void 0, void 0, function () {
var retrySpy, delaySpy, recordIdToUpdate, newMetadata;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
op = 'update';
pinecone = new index_1.Pinecone({
apiKey: process.env['PINECONE_API_KEY'] || '',
maxRetries: 2,
});
mockServerlessIndex = pinecone
.Index(serverlessIndexName, 'http://localhost:4000')
.namespace(test_helpers_1.globalNamespaceOne);
retrySpy = jest.spyOn(utils_1.RetryOnServerFailure.prototype, 'execute');
delaySpy = jest.spyOn(utils_1.RetryOnServerFailure.prototype, 'delay');
// Start server with a successful response on the second call
startMockServer(true);
recordIdToUpdate = recordsToUpsert[0].id;
newMetadata = { flavor: 'chocolate' };
// Call Update operation
return [4 /*yield*/, mockServerlessIndex.update({
id: recordIdToUpdate,
metadata: newMetadata,
})];
case 1:
// Call Update operation
_a.sent();
// 2 total tries: 1 initial call, 1 retry
expect(retrySpy).toHaveBeenCalledTimes(1);
expect(delaySpy).toHaveBeenCalledTimes(1);
expect(callCount).toBe(2);
return [2 /*return*/];
}
});
}); });
test('Max retries exceeded w/o resolve', function () { return __awaiter(void 0, void 0, void 0, function () {
var retrySpy, delaySpy, errorResult;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
op = 'upsert';
return [4 /*yield*/, (0, test_helpers_1.sleep)(500)];
case 1:
_a.sent(); // In Node20+, tcp connections changed: https://github.com/pinecone-io/pinecone-ts-client/pull/318#issuecomment-2560180936
pinecone = new index_1.Pinecone({
apiKey: process.env['PINECONE_API_KEY'] || '',
maxRetries: 3,
});
mockServerlessIndex = pinecone
.Index(serverlessIndexName, 'http://localhost:4000')
.namespace(test_helpers_1.globalNamespaceOne);
retrySpy = jest.spyOn(utils_1.RetryOnServerFailure.prototype, 'execute');
delaySpy = jest.spyOn(utils_1.RetryOnServerFailure.prototype, 'delay');
// Start server with persistent 503 errors on every call
startMockServer(false);
errorResult = function () { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, mockServerlessIndex.upsert(recordsToUpsert)];
case 1:
_a.sent();
return [2 /*return*/];
}
});
}); };
return [4 /*yield*/, expect(errorResult).rejects.toThrowError(errors_1.PineconeMaxRetriesExceededError)];
case 2:
_a.sent();
// Out of 3 total tries, 2 are retries (i.e. delays), and 1 is the initial call:
expect(retrySpy).toHaveBeenCalledTimes(1);
expect(delaySpy).toHaveBeenCalledTimes(2);
expect(callCount).toBe(3);
return [2 /*return*/];
}
});
}); });
});
//# sourceMappingURL=upsertAndUpdate.test.js.map

@@ -111,2 +111,3 @@ "use strict";

waitUntilReady: true,
tags: { project: 'pinecone-integration-tests-serverless' },
})];

@@ -113,0 +114,0 @@ case 5:

@@ -33,3 +33,3 @@ /**

/**
* Custom user tags added to an index. Keys must be alphanumeric and 80 characters or less. Values must be 120 characters or less.
* Custom user tags added to an index. Keys must be 80 characters or less. Values must be 120 characters or less. Keys must be alphanumeric, '_', or '-'. Values must be alphanumeric, ';', '@', '_', '-', '.', '+', or ' '. To unset a key, set the value to be an empty string.
* @type {{ [key: string]: string; }}

@@ -40,3 +40,3 @@ * @memberof ConfigureIndexRequest

[key: string]: string;
} | null;
};
}

@@ -43,0 +43,0 @@ /**

@@ -45,3 +45,3 @@ /**

/**
* Custom user tags added to an index. Keys must be alphanumeric and 80 characters or less. Values must be 120 characters or less.
* Custom user tags added to an index. Keys must be 80 characters or less. Values must be 120 characters or less. Keys must be alphanumeric, '_', or '-'. Values must be alphanumeric, ';', '@', '_', '-', '.', '+', or ' '. To unset a key, set the value to be an empty string.
* @type {{ [key: string]: string; }}

@@ -52,3 +52,3 @@ * @memberof CreateIndexRequest

[key: string]: string;
} | null;
};
/**

@@ -55,0 +55,0 @@ *

@@ -52,3 +52,3 @@ /**

/**
* Custom user tags added to an index. Keys must be alphanumeric and 80 characters or less. Values must be 120 characters or less.
* Custom user tags added to an index. Keys must be 80 characters or less. Values must be 120 characters or less. Keys must be alphanumeric, '_', or '-'. Values must be alphanumeric, ';', '@', '_', '-', '.', '+', or ' '. To unset a key, set the value to be an empty string.
* @type {{ [key: string]: string; }}

@@ -59,3 +59,3 @@ * @memberof IndexModel

[key: string]: string;
} | null;
};
/**

@@ -62,0 +62,0 @@ *

@@ -32,3 +32,3 @@ /**

/**
* The `cancel_import` operation cancels an import operation if it is not yet finished. It has no effect if the operation is already finished. For guidance and examples, see [Import data](https://docs.pinecone.io/guides/data/import-data).
* The `cancel_import` operation cancels an import operation if it is not yet finished. It has no effect if the operation is already finished. For guidance and examples, see [Import data](https://docs.pinecone.io/guides/data/import-data).
* Cancel an import

@@ -38,3 +38,3 @@ */

/**
* The `cancel_import` operation cancels an import operation if it is not yet finished. It has no effect if the operation is already finished. For guidance and examples, see [Import data](https://docs.pinecone.io/guides/data/import-data).
* The `cancel_import` operation cancels an import operation if it is not yet finished. It has no effect if the operation is already finished. For guidance and examples, see [Import data](https://docs.pinecone.io/guides/data/import-data).
* Cancel an import

@@ -44,3 +44,3 @@ */

/**
* The `describe_import` operation returns details of a specific import operation. For guidance and examples, see [Import data](https://docs.pinecone.io/guides/data/import-data).
* The `describe_import` operation returns details of a specific import operation. For guidance and examples, see [Import data](https://docs.pinecone.io/guides/data/import-data).
* Describe an import

@@ -50,3 +50,3 @@ */

/**
* The `describe_import` operation returns details of a specific import operation. For guidance and examples, see [Import data](https://docs.pinecone.io/guides/data/import-data).
* The `describe_import` operation returns details of a specific import operation. For guidance and examples, see [Import data](https://docs.pinecone.io/guides/data/import-data).
* Describe an import

@@ -56,3 +56,3 @@ */

/**
* The `list_imports` operation lists all recent and ongoing import operations. For guidance and examples, see [Import data](https://docs.pinecone.io/guides/data/import-data).
* The `list_imports` operation lists all recent and ongoing import operations. By default, `list_imports` returns up to 100 imports per page. If the `limit` parameter is set, `list` returns up to that number of imports instead. Whenever there are additional IDs to return, the response also includes a `pagination_token` that you can use to get the next batch of imports. When the response does not include a `pagination_token`, there are no more imports to return. For guidance and examples, see [Import data](https://docs.pinecone.io/guides/data/import-data).
* List imports

@@ -62,3 +62,3 @@ */

/**
* The `list_imports` operation lists all recent and ongoing import operations. For guidance and examples, see [Import data](https://docs.pinecone.io/guides/data/import-data).
* The `list_imports` operation lists all recent and ongoing import operations. By default, `list_imports` returns up to 100 imports per page. If the `limit` parameter is set, `list` returns up to that number of imports instead. Whenever there are additional IDs to return, the response also includes a `pagination_token` that you can use to get the next batch of imports. When the response does not include a `pagination_token`, there are no more imports to return. For guidance and examples, see [Import data](https://docs.pinecone.io/guides/data/import-data).
* List imports

@@ -68,3 +68,3 @@ */

/**
* The `start_import` operation starts an asynchronous import of vectors from object storage into an index. For guidance and examples, see [Import data](https://docs.pinecone.io/guides/data/import-data).
* The `start_import` operation starts an asynchronous import of vectors from object storage into an index. For guidance and examples, see [Import data](https://docs.pinecone.io/guides/data/import-data).
* Start import

@@ -74,3 +74,3 @@ */

/**
* The `start_import` operation starts an asynchronous import of vectors from object storage into an index. For guidance and examples, see [Import data](https://docs.pinecone.io/guides/data/import-data).
* The `start_import` operation starts an asynchronous import of vectors from object storage into an index. For guidance and examples, see [Import data](https://docs.pinecone.io/guides/data/import-data).
* Start import

@@ -77,0 +77,0 @@ */

@@ -102,3 +102,3 @@ "use strict";

/**
* The `cancel_import` operation cancels an import operation if it is not yet finished. It has no effect if the operation is already finished. For guidance and examples, see [Import data](https://docs.pinecone.io/guides/data/import-data).
* The `cancel_import` operation cancels an import operation if it is not yet finished. It has no effect if the operation is already finished. For guidance and examples, see [Import data](https://docs.pinecone.io/guides/data/import-data).
* Cancel an import

@@ -134,3 +134,3 @@ */

/**
* The `cancel_import` operation cancels an import operation if it is not yet finished. It has no effect if the operation is already finished. For guidance and examples, see [Import data](https://docs.pinecone.io/guides/data/import-data).
* The `cancel_import` operation cancels an import operation if it is not yet finished. It has no effect if the operation is already finished. For guidance and examples, see [Import data](https://docs.pinecone.io/guides/data/import-data).
* Cancel an import

@@ -153,3 +153,3 @@ */

/**
* The `describe_import` operation returns details of a specific import operation. For guidance and examples, see [Import data](https://docs.pinecone.io/guides/data/import-data).
* The `describe_import` operation returns details of a specific import operation. For guidance and examples, see [Import data](https://docs.pinecone.io/guides/data/import-data).
* Describe an import

@@ -185,3 +185,3 @@ */

/**
* The `describe_import` operation returns details of a specific import operation. For guidance and examples, see [Import data](https://docs.pinecone.io/guides/data/import-data).
* The `describe_import` operation returns details of a specific import operation. For guidance and examples, see [Import data](https://docs.pinecone.io/guides/data/import-data).
* Describe an import

@@ -204,3 +204,3 @@ */

/**
* The `list_imports` operation lists all recent and ongoing import operations. For guidance and examples, see [Import data](https://docs.pinecone.io/guides/data/import-data).
* The `list_imports` operation lists all recent and ongoing import operations. By default, `list_imports` returns up to 100 imports per page. If the `limit` parameter is set, `list` returns up to that number of imports instead. Whenever there are additional IDs to return, the response also includes a `pagination_token` that you can use to get the next batch of imports. When the response does not include a `pagination_token`, there are no more imports to return. For guidance and examples, see [Import data](https://docs.pinecone.io/guides/data/import-data).
* List imports

@@ -239,3 +239,3 @@ */

/**
* The `list_imports` operation lists all recent and ongoing import operations. For guidance and examples, see [Import data](https://docs.pinecone.io/guides/data/import-data).
* The `list_imports` operation lists all recent and ongoing import operations. By default, `list_imports` returns up to 100 imports per page. If the `limit` parameter is set, `list` returns up to that number of imports instead. Whenever there are additional IDs to return, the response also includes a `pagination_token` that you can use to get the next batch of imports. When the response does not include a `pagination_token`, there are no more imports to return. For guidance and examples, see [Import data](https://docs.pinecone.io/guides/data/import-data).
* List imports

@@ -259,3 +259,3 @@ */

/**
* The `start_import` operation starts an asynchronous import of vectors from object storage into an index. For guidance and examples, see [Import data](https://docs.pinecone.io/guides/data/import-data).
* The `start_import` operation starts an asynchronous import of vectors from object storage into an index. For guidance and examples, see [Import data](https://docs.pinecone.io/guides/data/import-data).
* Start import

@@ -293,3 +293,3 @@ */

/**
* The `start_import` operation starts an asynchronous import of vectors from object storage into an index. For guidance and examples, see [Import data](https://docs.pinecone.io/guides/data/import-data).
* The `start_import` operation starts an asynchronous import of vectors from object storage into an index. For guidance and examples, see [Import data](https://docs.pinecone.io/guides/data/import-data).
* Start import

@@ -296,0 +296,0 @@ */

@@ -54,3 +54,3 @@ /**

/**
* The `describe_index_stats` operation returns statistics about the contents of an index, including the vector count per namespace, the number of dimensions, and the index fullness. Serverless indexes scale automatically as needed, so index fullness is relevant only for pod-based indexes. For pod-based indexes, the index fullness result may be inaccurate during pod resizing; to get the status of a pod resizing process, use [`describe_index`](https://docs.pinecone.io/reference/api/control-plane/describe_index).
* The `describe_index_stats` operation returns statistics about the contents of an index, including the vector count per namespace, the number of dimensions, and the index fullness. Serverless indexes scale automatically as needed, so index fullness is relevant only for pod-based indexes.
* Get index stats

@@ -60,3 +60,3 @@ */

/**
* The `describe_index_stats` operation returns statistics about the contents of an index, including the vector count per namespace, the number of dimensions, and the index fullness. Serverless indexes scale automatically as needed, so index fullness is relevant only for pod-based indexes. For pod-based indexes, the index fullness result may be inaccurate during pod resizing; to get the status of a pod resizing process, use [`describe_index`](https://docs.pinecone.io/reference/api/control-plane/describe_index).
* The `describe_index_stats` operation returns statistics about the contents of an index, including the vector count per namespace, the number of dimensions, and the index fullness. Serverless indexes scale automatically as needed, so index fullness is relevant only for pod-based indexes.
* Get index stats

@@ -76,3 +76,3 @@ */

/**
* The `list` operation lists the IDs of vectors in a single namespace of a serverless index. An optional prefix can be passed to limit the results to IDs with a common prefix. `list` returns up to 100 IDs at a time by default in sorted order (bitwise \"C\" collation). If the `limit` parameter is set, `list` returns up to that number of IDs instead. Whenever there are additional IDs to return, the response also includes a `pagination_token` that you can use to get the next batch of IDs. When the response does not include a `pagination_token`, there are no more IDs to return. For guidance and examples, see [List record IDs](https://docs.pinecone.io/guides/data/list-record-ids). **Note:** `list_vectors` is supported only for serverless indexes.
* The `list` operation lists the IDs of vectors in a single namespace of a serverless index. An optional prefix can be passed to limit the results to IDs with a common prefix. By default, `list` returns up to 100 IDs per page in sorted order (bitwise \"C\" collation). If the `limit` parameter is set, `list` returns up to that number of IDs instead. Whenever there are additional IDs to return, the response also includes a `pagination_token` that you can use to get the next batch of IDs. When the response does not include a `pagination_token`, there are no more IDs to return. For guidance and examples, see [List record IDs](https://docs.pinecone.io/guides/data/list-record-ids). **Note:** `list_vectors` is supported only for serverless indexes.
* List vector IDs

@@ -82,3 +82,3 @@ */

/**
* The `list` operation lists the IDs of vectors in a single namespace of a serverless index. An optional prefix can be passed to limit the results to IDs with a common prefix. `list` returns up to 100 IDs at a time by default in sorted order (bitwise \"C\" collation). If the `limit` parameter is set, `list` returns up to that number of IDs instead. Whenever there are additional IDs to return, the response also includes a `pagination_token` that you can use to get the next batch of IDs. When the response does not include a `pagination_token`, there are no more IDs to return. For guidance and examples, see [List record IDs](https://docs.pinecone.io/guides/data/list-record-ids). **Note:** `list_vectors` is supported only for serverless indexes.
* The `list` operation lists the IDs of vectors in a single namespace of a serverless index. An optional prefix can be passed to limit the results to IDs with a common prefix. By default, `list` returns up to 100 IDs per page in sorted order (bitwise \"C\" collation). If the `limit` parameter is set, `list` returns up to that number of IDs instead. Whenever there are additional IDs to return, the response also includes a `pagination_token` that you can use to get the next batch of IDs. When the response does not include a `pagination_token`, there are no more IDs to return. For guidance and examples, see [List record IDs](https://docs.pinecone.io/guides/data/list-record-ids). **Note:** `list_vectors` is supported only for serverless indexes.
* List vector IDs

@@ -85,0 +85,0 @@ */

@@ -153,3 +153,3 @@ "use strict";

/**
* The `describe_index_stats` operation returns statistics about the contents of an index, including the vector count per namespace, the number of dimensions, and the index fullness. Serverless indexes scale automatically as needed, so index fullness is relevant only for pod-based indexes. For pod-based indexes, the index fullness result may be inaccurate during pod resizing; to get the status of a pod resizing process, use [`describe_index`](https://docs.pinecone.io/reference/api/control-plane/describe_index).
* The `describe_index_stats` operation returns statistics about the contents of an index, including the vector count per namespace, the number of dimensions, and the index fullness. Serverless indexes scale automatically as needed, so index fullness is relevant only for pod-based indexes.
* Get index stats

@@ -187,3 +187,3 @@ */

/**
* The `describe_index_stats` operation returns statistics about the contents of an index, including the vector count per namespace, the number of dimensions, and the index fullness. Serverless indexes scale automatically as needed, so index fullness is relevant only for pod-based indexes. For pod-based indexes, the index fullness result may be inaccurate during pod resizing; to get the status of a pod resizing process, use [`describe_index`](https://docs.pinecone.io/reference/api/control-plane/describe_index).
* The `describe_index_stats` operation returns statistics about the contents of an index, including the vector count per namespace, the number of dimensions, and the index fullness. Serverless indexes scale automatically as needed, so index fullness is relevant only for pod-based indexes.
* Get index stats

@@ -261,3 +261,3 @@ */

/**
* The `list` operation lists the IDs of vectors in a single namespace of a serverless index. An optional prefix can be passed to limit the results to IDs with a common prefix. `list` returns up to 100 IDs at a time by default in sorted order (bitwise \"C\" collation). If the `limit` parameter is set, `list` returns up to that number of IDs instead. Whenever there are additional IDs to return, the response also includes a `pagination_token` that you can use to get the next batch of IDs. When the response does not include a `pagination_token`, there are no more IDs to return. For guidance and examples, see [List record IDs](https://docs.pinecone.io/guides/data/list-record-ids). **Note:** `list_vectors` is supported only for serverless indexes.
* The `list` operation lists the IDs of vectors in a single namespace of a serverless index. An optional prefix can be passed to limit the results to IDs with a common prefix. By default, `list` returns up to 100 IDs per page in sorted order (bitwise \"C\" collation). If the `limit` parameter is set, `list` returns up to that number of IDs instead. Whenever there are additional IDs to return, the response also includes a `pagination_token` that you can use to get the next batch of IDs. When the response does not include a `pagination_token`, there are no more IDs to return. For guidance and examples, see [List record IDs](https://docs.pinecone.io/guides/data/list-record-ids). **Note:** `list_vectors` is supported only for serverless indexes.
* List vector IDs

@@ -302,3 +302,3 @@ */

/**
* The `list` operation lists the IDs of vectors in a single namespace of a serverless index. An optional prefix can be passed to limit the results to IDs with a common prefix. `list` returns up to 100 IDs at a time by default in sorted order (bitwise \"C\" collation). If the `limit` parameter is set, `list` returns up to that number of IDs instead. Whenever there are additional IDs to return, the response also includes a `pagination_token` that you can use to get the next batch of IDs. When the response does not include a `pagination_token`, there are no more IDs to return. For guidance and examples, see [List record IDs](https://docs.pinecone.io/guides/data/list-record-ids). **Note:** `list_vectors` is supported only for serverless indexes.
* The `list` operation lists the IDs of vectors in a single namespace of a serverless index. An optional prefix can be passed to limit the results to IDs with a common prefix. By default, `list` returns up to 100 IDs per page in sorted order (bitwise \"C\" collation). If the `limit` parameter is set, `list` returns up to that number of IDs instead. Whenever there are additional IDs to return, the response also includes a `pagination_token` that you can use to get the next batch of IDs. When the response does not include a `pagination_token`, there are no more IDs to return. For guidance and examples, see [List record IDs](https://docs.pinecone.io/guides/data/list-record-ids). **Note:** `list_vectors` is supported only for serverless indexes.
* List vector IDs

@@ -305,0 +305,0 @@ */

@@ -37,3 +37,3 @@ /**

/**
* If specified, the metadata filter here will be used to select the vectors to delete. This is mutually exclusive with specifying ids to delete in the ids param or using delete_all=True. See [Filter with metadata](https://docs.pinecone.io/guides/data/filter-with-metadata).
* If specified, the metadata filter here will be used to select the vectors to delete. This is mutually exclusive with specifying ids to delete in the ids param or using delete_all=True. See [Understanding metadata](https://docs.pinecone.io/guides/data/understanding-metadata).
* Serverless indexes do not support delete by metadata. Instead, you can use the `list` operation to fetch the vector IDs based on their common ID prefix and then delete the records by ID.

@@ -40,0 +40,0 @@ * @type {object}

@@ -19,3 +19,3 @@ /**

/**
* If this parameter is present, the operation only returns statistics for vectors that satisfy the filter. See [Filter with metadata](https://docs.pinecone.io/guides/data/filter-with-metadata).
* If this parameter is present, the operation only returns statistics for vectors that satisfy the filter. See [Understanding metadata](https://docs.pinecone.io/guides/data/understanding-metadata).
*

@@ -22,0 +22,0 @@ * Serverless indexes do not support filtering `describe_index_stats` by metadata.

@@ -49,3 +49,3 @@ /**

/**
* The progress made by the operation out of 100
* The progress made by the operation, as a percentage.
* @type {number}

@@ -52,0 +52,0 @@ * @memberof ImportModel

@@ -38,3 +38,3 @@ /**

*
* The index fullness result may be inaccurate during pod resizing; to get the status of a pod resizing process, use [`describe_index`](https://docs.pinecone.io/reference/api/control-plane/describe_index).
* The index fullness result may be inaccurate during pod resizing; to get the status of a pod resizing process, use [`describe_index`](https://docs.pinecone.io/reference/api/2024-10/control-plane/describe_index).
* @type {number}

@@ -41,0 +41,0 @@ * @memberof IndexDescription

@@ -33,3 +33,3 @@ /**

/**
* The filter to apply. You can use vector metadata to limit your search. See [Filter with metadata](https://docs.pinecone.io/guides/data/filter-with-metadata).
* The filter to apply. You can use vector metadata to limit your search. See [Understanding metadata](https://docs.pinecone.io/guides/data/understanding-metadata).
* @type {object}

@@ -36,0 +36,0 @@ * @memberof QueryRequest

@@ -20,3 +20,3 @@ /**

/**
* The id of the storage integration that should be used to access the data.
* The id of the [storage integration](https://docs.pinecone.io/guides/operations/integrations/manage-storage-integrations) that should be used to access the data.
* @type {string}

@@ -27,3 +27,3 @@ * @memberof StartImportRequest

/**
* The URI prefix under which the data to import is available. All data within this prefix will be listed then imported into the target index. Currently only `s3://` URIs are supported.
* The [URI prefix](https://docs.pinecone.io/guides/data/understanding-imports#directory-structure) under which the data to import is available. All data within this prefix will be listed then imported into the target index. Currently only `s3://` URIs are supported.
* @type {string}

@@ -30,0 +30,0 @@ * @memberof StartImportRequest

@@ -19,3 +19,3 @@ /**

/**
* Unique identifier for the import operations.
* Unique identifier for the import operation.
* @type {string}

@@ -22,0 +22,0 @@ * @memberof StartImportResponse

@@ -21,3 +21,3 @@ /**

/**
* The [model](https://docs.pinecone.io/guides/inference/understanding-inference#models) to use for embedding generation.
* The [model](https://docs.pinecone.io/guides/inference/understanding-inference#embedding-models) to use for embedding generation.
* @type {string}

@@ -24,0 +24,0 @@ * @memberof EmbedRequest

@@ -25,3 +25,3 @@ /**

/**
* The relevance score of the document normalized between 0 and 1.
* The relevance of the document to the query, normalized between 0 and 1, with scores closer to 1 indicating higher relevance.
* @type {number}

@@ -28,0 +28,0 @@ * @memberof RankedDocument

@@ -19,3 +19,3 @@ /**

/**
* The [model](https://docs.pinecone.io/guides/inference/understanding-inference#models) to use for reranking.
* The [model](https://docs.pinecone.io/guides/inference/understanding-inference#reranking-models) to use for reranking.
* @type {string}

@@ -22,0 +22,0 @@ * @memberof RerankRequest

@@ -215,3 +215,4 @@ import { CreateIndexOptions, IndexName, CollectionName } from './control';

* }
* }
* },
* tags: { 'team': 'data-science' }
* })

@@ -235,3 +236,4 @@ * ```

* },
* suppressConflicts: true
* suppressConflicts: true,
* tags: { 'team': 'data-science' }
* })

@@ -254,3 +256,4 @@ * ```

* },
* waitUntilReady: true
* waitUntilReady: true,
* tags: { 'team': 'data-science' }
* });

@@ -280,2 +283,3 @@ *

* },
* tags: { 'team': 'data-science' }
* })

@@ -316,3 +320,4 @@ * ```

* Use this method to update configuration on an existing index. For both pod-based and serverless indexes you can update
* the deletionProtection status of an index. For pod-based index you can also configure the number of replicas and pod type.
* the deletionProtection status of an index and/or change any index tags. For pod-based index you can also
* configure the number of replicas and pod type.
*

@@ -319,0 +324,0 @@ * @example

@@ -328,3 +328,4 @@ "use strict";

* }
* }
* },
* tags: { 'team': 'data-science' }
* })

@@ -348,3 +349,4 @@ * ```

* },
* suppressConflicts: true
* suppressConflicts: true,
* tags: { 'team': 'data-science' }
* })

@@ -367,3 +369,4 @@ * ```

* },
* waitUntilReady: true
* waitUntilReady: true,
* tags: { 'team': 'data-science' }
* });

@@ -393,2 +396,3 @@ *

* },
* tags: { 'team': 'data-science' }
* })

@@ -444,3 +448,4 @@ * ```

* Use this method to update configuration on an existing index. For both pod-based and serverless indexes you can update
* the deletionProtection status of an index. For pod-based index you can also configure the number of replicas and pod type.
* the deletionProtection status of an index and/or change any index tags. For pod-based index you can also
* configure the number of replicas and pod type.
*

@@ -465,3 +470,3 @@ * @example

Pinecone.prototype.configureIndex = function (indexName, options) {
return this._configureIndex(indexName, options);
return this._configureIndex(indexName, options, this.config.maxRetries);
};

@@ -468,0 +473,0 @@ /**

@@ -6,2 +6,3 @@ import { debugLog } from './debugLog';

import { getFetch } from './fetch';
export { debugLog, normalizeUrl, queryParamsStringify, buildUserAgent, getFetch, };
import { RetryOnServerFailure } from './retries';
export { debugLog, normalizeUrl, queryParamsStringify, buildUserAgent, getFetch, RetryOnServerFailure, };
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getFetch = exports.buildUserAgent = exports.queryParamsStringify = exports.normalizeUrl = exports.debugLog = void 0;
exports.RetryOnServerFailure = exports.getFetch = exports.buildUserAgent = exports.queryParamsStringify = exports.normalizeUrl = exports.debugLog = void 0;
var debugLog_1 = require("./debugLog");

@@ -14,2 +14,4 @@ Object.defineProperty(exports, "debugLog", { enumerable: true, get: function () { return debugLog_1.debugLog; } });

Object.defineProperty(exports, "getFetch", { enumerable: true, get: function () { return fetch_1.getFetch; } });
var retries_1 = require("./retries");
Object.defineProperty(exports, "RetryOnServerFailure", { enumerable: true, get: function () { return retries_1.RetryOnServerFailure; } });
//# sourceMappingURL=index.js.map
{
"name": "@pinecone-database/pinecone",
"version": "3.0.3"
"version": "4.0.0"
}
{
"name": "@pinecone-database/pinecone",
"version": "4.0.0",
"version": "4.1.0",
"main": "dist/index.js",

@@ -29,2 +29,3 @@ "repository": {

"test:integration:cleanup": "npm run build && node utils/cleanupResources.ts",
"test:external-app-local": "chmod +x src/external-app/local-external-app.sh && src/external-app/local-external-app.sh",
"test:unit": "jest src/"

@@ -39,3 +40,3 @@ },

"@types/jest": "^29.5.0",
"@types/node": "^18.11.17",
"@types/node": "^18.19.61",
"@typescript-eslint/eslint-plugin": "^5.59.11",

@@ -51,3 +52,3 @@ "@typescript-eslint/parser": "^5.59.11",

"typedoc": "^0.24.8",
"typescript": "^4.9.4"
"typescript": "^4.9.5"
},

@@ -57,6 +58,3 @@ "types": "dist/index.d.ts",

"/dist"
],
"dependencies": {
"encoding": "^0.1.13"
}
]
}

@@ -71,2 +71,4 @@ # Pinecone Node.js SDK &middot; ![License](https://img.shields.io/github/license/pinecone-io/pinecone-ts-client?color=orange) ![npm](https://img.shields.io/npm/v/%40pinecone-database%2Fpinecone?link=https%3A%2F%2Fwww.npmjs.com%2Fpackage%2F%40pinecone-database%2Fpinecone) ![npm](https://img.shields.io/npm/dw/%40pinecone-database/pinecone?style=flat&color=blue&link=https%3A%2F%2Fwww.npmjs.com%2Fpackage%2F%40pinecone-database%2Fpinecone) ![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/pinecone-io/pinecone-ts-client/merge.yml?label=CI&link=https%3A%2F%2Fgithub.com%2Fpinecone-io%2Fpinecone-ts-client%2Factions%2Fworkflows%2Fmerge.yml)

If you prefer to pass configuration in code, the constructor accepts a config object containing the `apiKey` value.
This is the object in which you would pass properties like `maxRetries` (defaults to `3`) for retryable operations
(`upsert`, `update`, and `configureIndex`).

@@ -78,2 +80,3 @@ ```typescript

apiKey: 'your_api_key',
maxRetries: 5,
});

@@ -165,2 +168,3 @@ ```

},
tags: { team: 'data-science' },
});

@@ -190,2 +194,3 @@ ```

},
tags: { team: 'data-science' },
},

@@ -348,2 +353,37 @@

#### Create or configure an index with index tags
You can create or configure serverless and pod indexes with [tags](https://docs.pinecone.io/guides/indexes/tag-an-index).
Indexes can hold an arbitrary number of tags outlining metadata
you would like attached to the index object itself, such as team ownership, project, or any other relevant information.
```typescript
import { Pinecone } from '@pinecone-database/pinecone';
const pc = new Pinecone();
// Create index with tag
await pc.createIndex({
name: 'tag-index',
dimension: 1536,
metric: 'cosine',
spec: {
serverless: {
cloud: 'aws',
region: 'us-west-2',
},
},
tags: { team: 'data-science' }, // index tag
});
// Configure index with a new tag
await pc.configureIndex('tag-index', {
tags: { project: 'recommendation' }, // new index tag
});
// Delete an existing tag
await pc.configureIndex('tag-index', {
tags: { project: '' }, // Pass an empty string to an existing key to delete a tag; this will delete the `project` tag
});
```
### Describe Index

@@ -931,15 +971,29 @@

The `listPaginated` method can be used to list record ids matching a particular id prefix in a paginated format. With clever assignment
of record ids, this can be used to help model hierarchical relationships between different records such as when there are embeddings for multiple chunks or fragments related to the same document.
The `listPaginated` method can be used to list record IDs matching a particular ID prefix in a paginated format. With
[clever assignment
of record ids](https://docs.pinecone.io/guides/data/manage-rag-documents#use-id-prefixes), this can be used to help model hierarchical relationships between different records such as when there are embeddings for multiple chunks or fragments related to the same document.
Notes:
- When you do not specify a `prefix`, the default prefix is an empty string, which returns all vector IDs
in your index
- There is a hard limit of `100` vector IDs if no `limit` is specified. Consequently, if there are fewer than `100`
vector IDs that match a given `prefix` in your index, and you do not specify a `limit`, your `paginationToken`
will be `undefined`
The following example shows how to fetch both pages of vector IDs for vectors whose IDs contain the prefix `doc1#`,
assuming a `limit` of `3` and `doc1` document being [chunked](https://www.pinecone.io/learn/chunking-strategies/) into `4` vectors.
```typescript
const pc = new Pinecone();
const index = pc.index('my-index').namespace('my-namespace');
const results = await index.listPaginated({ prefix: 'doc1#' });
// Fetch the 1st 3 vector IDs matching prefix 'doc1#'
const results = await index.listPaginated({ limit: 3, prefix: 'doc1#' });
console.log(results);
// {
// vectors: [
// { id: 'doc1#01' }, { id: 'doc1#02' }, { id: 'doc1#03' },
// { id: 'doc1#04' }, { id: 'doc1#05' }, { id: 'doc1#06' },
// { id: 'doc1#07' }, { id: 'doc1#08' }, { id: 'doc1#09' },
// { id: 'doc1#01' }
// { id: 'doc1#02' }
// { id: 'doc1#03' }
// ...

@@ -954,7 +1008,16 @@ // ],

// Fetch the next page of results
await index.listPaginated({
// Fetch the final vector ID matching prefix 'doc1#' using the paginationToken returned by the previous call
const nextResults = await index.listPaginated({
prefix: 'doc1#',
paginationToken: results.pagination?.next,
});
console.log(nextResults);
// {
// vectors: [
// { id: 'doc1#04' }
// ],
// pagination: undefined,
// namespace: 'my-namespace',
// usage: { readUnits: 1 }
// }
```

@@ -1191,1 +1254,8 @@

```
## Testing
All testing takes place automatically in CI and is configured using Github actions
and workflows, located in the `.github` directory of this repo.
See [CONTRIBUTING.md](CONTRIBUTING.md) for more information.

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

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

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

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

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc