From 96012e0b71b342e774afe79a0104c8818f4eb90d Mon Sep 17 00:00:00 2001 From: Austin DeNoble Date: Wed, 8 Nov 2023 23:59:58 -0500 Subject: [PATCH 1/9] allow createIndex to return IndexMeta --- src/control/__tests__/createIndex.test.ts | 6 +++--- src/control/configureIndex.ts | 2 +- src/control/createIndex.ts | 16 ++++++++++------ 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/control/__tests__/createIndex.test.ts b/src/control/__tests__/createIndex.test.ts index 1d0a4d81..0297a81c 100644 --- a/src/control/__tests__/createIndex.test.ts +++ b/src/control/__tests__/createIndex.test.ts @@ -57,7 +57,7 @@ describe('createIndex', () => { capacityMode: 'pod', }); - expect(returned).toBe(void 0); + expect(returned).toEqual(void 0); expect(IOA.createIndex).toHaveBeenCalledWith({ createRequest: { name: 'index-name', @@ -93,7 +93,7 @@ describe('createIndex', () => { waitUntilReady: true, }); - expect(returned).toBe(void 0); + expect(returned).toEqual({ status: { ready: true, state: 'Ready' } }); expect(IOA.createIndex).toHaveBeenCalledWith({ createRequest: { name: 'index-name', @@ -137,7 +137,7 @@ describe('createIndex', () => { await jest.advanceTimersByTimeAsync(3000); return returned.then((result) => { - expect(result).toBe(void 0); + expect(result).toEqual({ status: { ready: true, state: 'Ready' } }); expect(IOA.describeIndex).toHaveBeenNthCalledWith(3, { indexName: 'index-name', }); diff --git a/src/control/configureIndex.ts b/src/control/configureIndex.ts index c7557d2e..ba8d6078 100644 --- a/src/control/configureIndex.ts +++ b/src/control/configureIndex.ts @@ -44,7 +44,7 @@ export const configureIndex = (api: IndexOperationsApi) => { if (Object.keys(options).length === 0) { throw new PineconeArgumentError( - 'The second argument to configureIndex should not be empty object. Please specify at least one propert (replicas, podType) to update.' + 'The second argument to configureIndex should not be empty object. Please specify at least one property (replicas, podType) to update.' ); } diff --git a/src/control/createIndex.ts b/src/control/createIndex.ts index 9a548b3d..78857d95 100644 --- a/src/control/createIndex.ts +++ b/src/control/createIndex.ts @@ -1,4 +1,4 @@ -import { IndexOperationsApi } from '../pinecone-generated-ts-fetch'; +import { IndexMeta, IndexOperationsApi } from '../pinecone-generated-ts-fetch'; import { buildConfigValidator } from '../validator'; import { debugLog } from '../utils'; import { handleApiError } from '../errors'; @@ -112,14 +112,18 @@ export const createIndex = (api: IndexOperationsApi) => { 'createIndex' ); - return async (options: CreateIndexOptions): Promise => { + return async ( + options: CreateIndexOptions + ): Promise => { validator(options); - try { - await api.createIndex({ createRequest: options }); + const createResponse = await api.createIndex({ + createRequest: options, + }); if (options.waitUntilReady) { return await waitUntilIndexIsReady(api, options.name); } + return createResponse; } catch (e) { if ( !( @@ -138,7 +142,7 @@ const waitUntilIndexIsReady = async ( api: IndexOperationsApi, indexName: string, seconds: number = 0 -): Promise => { +): Promise => { try { const indexDescription = await api.describeIndex({ indexName }); if (!indexDescription.status?.ready) { @@ -146,7 +150,7 @@ const waitUntilIndexIsReady = async ( return await waitUntilIndexIsReady(api, indexName, seconds + 1); } else { debugLog(`Index ${indexName} is ready after ${seconds}`); - return; + return indexDescription; } } catch (e) { const err = await handleApiError( From d4977b0941fab7d20d82b01820ab461b727a773d Mon Sep 17 00:00:00 2001 From: Austin DeNoble Date: Mon, 13 Nov 2023 23:59:40 -0500 Subject: [PATCH 2/9] update createIndex tests --- src/integration/control/createIndex.test.ts | 47 ++++++++++----------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/src/integration/control/createIndex.test.ts b/src/integration/control/createIndex.test.ts index e7bd5498..15498818 100644 --- a/src/integration/control/createIndex.test.ts +++ b/src/integration/control/createIndex.test.ts @@ -20,17 +20,15 @@ describe('create index', () => { await pinecone.createIndex({ name: indexName, dimension: 5, - cloud: 'gcp', + metric: 'cosine', + cloud: 'aws', region: 'us-east1', - capacityMode: 'pod', + capacityMode: 'serverless', }); const description = await pinecone.describeIndex(indexName); expect(description.database?.name).toEqual(indexName); expect(description.database?.dimension).toEqual(5); expect(description.database?.metric).toEqual('cosine'); - expect(description.database?.pods).toEqual(1); - expect(description.database?.replicas).toEqual(1); - expect(description.database?.shards).toEqual(1); expect(description.status?.host).toBeDefined(); }); @@ -41,18 +39,15 @@ describe('create index', () => { metric: 'euclidean', replicas: 2, podType: 'p1.x2', - cloud: 'gcp', + cloud: 'aws', region: 'us-east1', - capacityMode: 'pod', + capacityMode: 'serverless', }); const description = await pinecone.describeIndex(indexName); expect(description.database?.name).toEqual(indexName); expect(description.database?.dimension).toEqual(5); expect(description.database?.metric).toEqual('euclidean'); - expect(description.database?.pods).toEqual(2); - expect(description.database?.replicas).toEqual(2); - expect(description.database?.shards).toEqual(1); expect(description.status?.host).toBeDefined(); }); @@ -60,9 +55,10 @@ describe('create index', () => { await pinecone.createIndex({ name: indexName, dimension: 5, - cloud: 'gcp', + cloud: 'aws', + metric: 'cosine', region: 'us-east1', - capacityMode: 'pod', + capacityMode: 'serverless', waitUntilReady: true, }); @@ -75,16 +71,18 @@ describe('create index', () => { await pinecone.createIndex({ name: indexName, dimension: 5, - cloud: 'gcp', + cloud: 'aws', + metric: 'cosine', region: 'us-east1', - capacityMode: 'pod', + capacityMode: 'serverless', }); await pinecone.createIndex({ name: indexName, dimension: 5, - cloud: 'gcp', + cloud: 'aws', + metric: 'cosine', region: 'us-east1', - capacityMode: 'pod', + capacityMode: 'serverless', suppressConflicts: true, }); @@ -99,9 +97,10 @@ describe('create index', () => { await pinecone.createIndex({ name: indexName + '-', dimension: 5, - cloud: 'gcp', + cloud: 'aws', + metric: 'cosine', region: 'us-east1', - capacityMode: 'pod', + capacityMode: 'serverless', }); } catch (e) { const err = e as PineconeNotFoundError; @@ -115,10 +114,10 @@ describe('create index', () => { await pinecone.createIndex({ name: indexName, dimension: 5, - replicas: 20, - cloud: 'gcp', + cloud: 'aws', + metric: 'cosine', region: 'us-east1', - capacityMode: 'pod', + capacityMode: 'serverless', }); } catch (e) { const err = e as PineconeNotFoundError; @@ -132,10 +131,10 @@ describe('create index', () => { await pinecone.createIndex({ name: indexName, dimension: 5, - sourceCollection: 'non-existent-collection', - cloud: 'gcp', + cloud: 'aws', + metric: 'cosine', region: 'us-east1', - capacityMode: 'pod', + capacityMode: 'serverless', }); } catch (e) { const err = e as PineconeNotFoundError; From 5e5b6aa09b056d02e7f7cf5ce83490c823156dce Mon Sep 17 00:00:00 2001 From: Austin DeNoble Date: Wed, 15 Nov 2023 15:53:54 -0500 Subject: [PATCH 3/9] split out testing CI work into a separate workflow file, update to support further testing against prod and staging, update OpenAPI spec and associated types, clean up a few extraneous things --- .github/workflows/merge.yml | 2 +- .github/workflows/pr.yml | 125 +--------------- .github/workflows/release-dev.yml | 6 +- .github/workflows/release-prod.yml | 10 +- .github/workflows/release-spruce-dev.yml | 4 + .github/workflows/release-spruce.yml | 4 + .../{cleanup.yml => testing-cleanup.yml} | 2 +- .github/workflows/testing.yml | 141 ++++++++++++++++++ .../configureIndex.validation.test.ts | 2 +- src/control/createIndex.ts | 7 + src/control/types.ts | 1 + .../control/configureIndex.test.ts | 2 + src/integration/control/createIndex.test.ts | 3 +- src/integration/control/describeIndex.test.ts | 10 +- src/integration/control/listIndexes.test.ts | 2 + src/integration/errorHandling.test.ts | 24 +-- .../models/CreateRequest.ts | 8 + src/utils/testHelper.ts | 11 -- utils/globalIntegrationTestSetup.ts | 2 +- 19 files changed, 207 insertions(+), 159 deletions(-) rename .github/workflows/{cleanup.yml => testing-cleanup.yml} (92%) create mode 100644 .github/workflows/testing.yml delete mode 100644 src/utils/testHelper.ts diff --git a/.github/workflows/merge.yml b/.github/workflows/merge.yml index 1def700e..03f70282 100644 --- a/.github/workflows/merge.yml +++ b/.github/workflows/merge.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup uses: ./.github/actions/setup - name: Generate TypeDoc documentation diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 12133635..892e6316 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -17,7 +17,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup uses: ./.github/actions/setup - name: Prettier @@ -35,123 +35,6 @@ jobs: - name: TypeDoc uses: ./.github/actions/build-docs - run-integration-tests: - name: Run integration tests - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - jest_env: ['node', 'edge'] - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Setup - uses: ./.github/actions/setup - - name: Run tests - env: - CI: true - PINECONE_API_KEY: ${{ secrets.PINECONE_API_KEY }} - run: npm run test:integration:${{ matrix.jest_env }} - - example-app-semantic-search: - name: 'Example app: semantic search' - runs-on: ubuntu-latest - steps: - - name: Checkout pinecone-ts-client - uses: actions/checkout@v4 - with: - path: pinecone-ts-client - - name: Checkout semantic-search-example - uses: actions/checkout@v4 - with: - repository: pinecone-io/semantic-search-example - path: semantic-search-example - - name: Install and build client - shell: bash - run: | - cd pinecone-ts-client - npm install --ignore-scripts - npm run build - - name: Install and build sample app - shell: bash - run: | - cd semantic-search-example - npm install --no-cache - npm install '../pinecone-ts-client' - cat package.json - - name: Run example tests with dev version of client - env: - CI: true - PINECONE_API_KEY: ${{ secrets.PINECONE_API_KEY }} - PINECONE_INDEX: 'semantic-search' - shell: bash - run: | - cd semantic-search-example - npm run test - - unit-tests: - name: Run unit tests - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Setup - uses: ./.github/actions/setup - - name: Run tests - env: - CI: true - run: npm run test:unit -- --coverage - - typescript-compilation-tests: - name: TS compile - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - tsVersion: - [ - '~4.1.0', - '~4.2.0', - '~4.3.0', - '~4.4.0', - '~4.5.0', - '~4.6.0', - '~4.7.0', - '~4.8.0', - '~4.9.0', - '~5.0.0', - '~5.1.0', - '~5.2.0', - 'latest', - ] - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Setup Node - uses: actions/setup-node@v3 - with: - node-version: 18.x - registry-url: 'https://registry.npmjs.org' - - name: Install npm packages - run: | - npm install --ignore-scripts - shell: bash - - name: Build typescript for pinecone - run: npm run build - shell: bash - - name: install, compile, and run sample app - shell: bash - env: - PINECONE_API_KEY: ${{ secrets.PINECONE_API_KEY }} - run: | - set -x - cd .. - cp -r pinecone-ts-client/ts-compilation-test ts-compilation-test - cd ts-compilation-test - npm install typescript@${{matrix.tsVersion}} --no-cache - npm install '../pinecone-ts-client' --no-cache - cat package.json - cat package-lock.json - npm run tsc-version - npm run build - npm run start + testing: + uses: './.github/workflows/testing.yml' + secrets: inherit diff --git a/.github/workflows/release-dev.yml b/.github/workflows/release-dev.yml index 73ab33aa..81423f63 100644 --- a/.github/workflows/release-dev.yml +++ b/.github/workflows/release-dev.yml @@ -6,12 +6,16 @@ on: - cron: '0 0 * * *' jobs: + testing: + uses: './.github/workflows/testing.yml' + secrets: inherit + version-and-release: name: Release dev build to NPM runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup uses: ./.github/actions/setup diff --git a/.github/workflows/release-prod.yml b/.github/workflows/release-prod.yml index f165de52..610f5ab7 100644 --- a/.github/workflows/release-prod.yml +++ b/.github/workflows/release-prod.yml @@ -19,20 +19,18 @@ concurrency: cancel-in-progress: true jobs: - # integration-tests: - # if: ${{ github.event.inputs.runTests == 'true' }} - # uses: ./.github/workflows/PR.yml - # secrets: inherit + testing: + uses: './.github/workflows/testing.yml' + secrets: inherit version-and-release: name: Release to NPM - # needs: integration-tests runs-on: ubuntu-latest outputs: tagName: ${{ steps.npm-release.outputs.release_tag }} steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup uses: ./.github/actions/setup diff --git a/.github/workflows/release-spruce-dev.yml b/.github/workflows/release-spruce-dev.yml index 3dda59f3..94792a5b 100644 --- a/.github/workflows/release-spruce-dev.yml +++ b/.github/workflows/release-spruce-dev.yml @@ -6,6 +6,10 @@ on: - cron: '0 0 * * *' jobs: + testing: + uses: './.github/workflows/testing.yml' + secrets: inherit + version-and-release: name: Release dev build to NPM runs-on: ubuntu-latest diff --git a/.github/workflows/release-spruce.yml b/.github/workflows/release-spruce.yml index 125cae12..b05978c9 100644 --- a/.github/workflows/release-spruce.yml +++ b/.github/workflows/release-spruce.yml @@ -4,6 +4,10 @@ on: workflow_dispatch: {} jobs: + testing: + uses: './.github/workflows/testing.yml' + secrets: inherit + version-and-release: name: Release dev build to NPM runs-on: ubuntu-latest diff --git a/.github/workflows/cleanup.yml b/.github/workflows/testing-cleanup.yml similarity index 92% rename from .github/workflows/cleanup.yml rename to .github/workflows/testing-cleanup.yml index 9b0eb515..e935ea99 100644 --- a/.github/workflows/cleanup.yml +++ b/.github/workflows/testing-cleanup.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup uses: ./.github/actions/setup - name: Cleanup diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml new file mode 100644 index 00000000..e77d44dd --- /dev/null +++ b/.github/workflows/testing.yml @@ -0,0 +1,141 @@ +name: Testing + +on: + workflow_call: {} + +jobs: + unit-tests: + name: Run unit tests + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup + uses: ./.github/actions/setup + + - name: Run tests + env: + CI: true + run: npm run test:unit -- --coverage + + integration-tests: + name: Run integration tests + runs-on: ubuntu-latest + strategy: + fail-fast: false + max-parallel: 1 + matrix: + jest_env: ['node', 'edge'] + pinecone_env: ['prod', 'staging'] + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup + uses: ./.github/actions/setup + + - name: Run integration tests (prod) + env: + CI: true + PINECONE_API_KEY: ${{ secrets.PINECONE_API_KEY }} + PINECONE_CONTROLLER_HOST: 'https://api.pinecone.io' + run: npm run test:integration:${{ matrix.jest_env }} + + - name: Run integration tests (staging) + env: + CI: true + PINECONE_API_KEY: ${{ secrets.PINECONE_API_KEY_STAGING }} + PINECONE_CONTROLLER_HOST: 'https://api-staging.pinecone.io' + run: npm run test:integration:${{ matrix.jest_env }} + + typescript-compilation-tests: + name: TS compile + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + tsVersion: + [ + '~4.1.0', + '~4.2.0', + '~4.3.0', + '~4.4.0', + '~4.5.0', + '~4.6.0', + '~4.7.0', + '~4.8.0', + '~4.9.0', + '~5.0.0', + '~5.1.0', + '~5.2.0', + 'latest', + ] + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: 18.x + registry-url: 'https://registry.npmjs.org' + - name: Install npm packages + run: | + npm install --ignore-scripts + shell: bash + - name: Build TypeScript for Pinecone + run: npm run build + shell: bash + - name: install, compile, and run sample app + shell: bash + env: + PINECONE_API_KEY: ${{ secrets.PINECONE_API_KEY }} + run: | + set -x + cd .. + cp -r pinecone-ts-client/ts-compilation-test ts-compilation-test + cd ts-compilation-test + npm install typescript@${{ matrix.tsVersion }} --no-cache + npm install '../pinecone-ts-client' --no-cache + cat package.json + cat package-lock.json + npm run tsc-version + npm run build + npm run start + + example-app-semantic-search: + name: 'Example app: semantic search' + runs-on: ubuntu-latest + steps: + - name: Checkout pinecone-ts-client + uses: actions/checkout@v4 + with: + path: pinecone-ts-client + - name: Checkout semantic-search-example + uses: actions/checkout@v4 + with: + repository: pinecone-io/semantic-search-example + path: semantic-search-example + - name: Install and build client + shell: bash + run: | + cd pinecone-ts-client + npm install --ignore-scripts + npm run build + - name: Install and build sample app + shell: bash + run: | + cd semantic-search-example + npm install --no-cache + npm install '../pinecone-ts-client' + cat package.json + - name: Run example tests with dev version of client + env: + CI: true + PINECONE_API_KEY: ${{ secrets.PINECONE_API_KEY }} + PINECONE_INDEX: 'semantic-search' + shell: bash + run: | + cd semantic-search-example + npm run test diff --git a/src/control/__tests__/configureIndex.validation.test.ts b/src/control/__tests__/configureIndex.validation.test.ts index 4a76fe59..9c390a01 100644 --- a/src/control/__tests__/configureIndex.validation.test.ts +++ b/src/control/__tests__/configureIndex.validation.test.ts @@ -52,7 +52,7 @@ describe('configureIndex argument validations', () => { expect(toThrow).rejects.toThrowError(PineconeArgumentError); expect(toThrow).rejects.toThrowError( - 'The second argument to configureIndex should not be empty object. Please specify at least one propert (replicas, podType) to update.' + 'The second argument to configureIndex should not be empty object. Please specify at least one property (replicas, podType) to update.' ); }); diff --git a/src/control/createIndex.ts b/src/control/createIndex.ts index 78857d95..5b1ddaca 100644 --- a/src/control/createIndex.ts +++ b/src/control/createIndex.ts @@ -8,6 +8,7 @@ import { CapacityModeSchema, CloudSchema, DimensionSchema, + EnvironmentSchema, MetricSchema, PodsSchema, RegionSchema, @@ -38,6 +39,11 @@ export type CreateIndexOptions = { */ cloud: 'gcp' | 'aws' | 'azure'; + /** + * The environment where you would like your index to be created + */ + environment?: string; + /** * The capacity mode for the index. */ @@ -98,6 +104,7 @@ const CreateIndexOptionsSchema = Type.Object( pods: Type.Optional(PodsSchema), replicas: Type.Optional(ReplicasSchema), podType: Type.Optional(PodTypeSchema), + environment: Type.Optional(EnvironmentSchema), metadataConfig: Type.Optional(MetadataConfigSchema), sourceCollection: Type.Optional(CollectionNameSchema), waitUntilReady: Type.Optional(Type.Boolean()), diff --git a/src/control/types.ts b/src/control/types.ts index d2ebaa97..2b6a018e 100644 --- a/src/control/types.ts +++ b/src/control/types.ts @@ -27,6 +27,7 @@ export const PodsSchema = positiveInteger; export const MetricSchema = nonemptyString; export const DimensionSchema = positiveInteger; export const RegionSchema = nonemptyString; +export const EnvironmentSchema = nonemptyString; export const CloudSchema = Type.Union([ Type.Literal('gcp'), Type.Literal('aws'), diff --git a/src/integration/control/configureIndex.test.ts b/src/integration/control/configureIndex.test.ts index 94f044d5..d0523692 100644 --- a/src/integration/control/configureIndex.test.ts +++ b/src/integration/control/configureIndex.test.ts @@ -13,11 +13,13 @@ describe('configure index', () => { await pinecone.createIndex({ name: indexName, dimension: 5, + metric: 'cosine', waitUntilReady: true, podType: 'p1.x1', replicas: 2, cloud: 'gcp', region: 'us-east1', + environment: 'us-east1-gcp', capacityMode: 'pod', }); }); diff --git a/src/integration/control/createIndex.test.ts b/src/integration/control/createIndex.test.ts index 15498818..a44bff25 100644 --- a/src/integration/control/createIndex.test.ts +++ b/src/integration/control/createIndex.test.ts @@ -105,7 +105,7 @@ describe('create index', () => { } catch (e) { const err = e as PineconeNotFoundError; expect(err.name).toEqual('PineconeBadRequestError'); - expect(err.message).toContain('alphanumeric characters'); + expect(err.message).toContain('alphanumeric character'); } }); @@ -135,6 +135,7 @@ describe('create index', () => { metric: 'cosine', region: 'us-east1', capacityMode: 'serverless', + sourceCollection: 'non-existent-collection', }); } catch (e) { const err = e as PineconeNotFoundError; diff --git a/src/integration/control/describeIndex.test.ts b/src/integration/control/describeIndex.test.ts index 360877ab..f23e1c21 100644 --- a/src/integration/control/describeIndex.test.ts +++ b/src/integration/control/describeIndex.test.ts @@ -1,4 +1,4 @@ -import { BasePineconeError } from '../../errors'; +import { PineconeNotFoundError } from '../../errors'; import { Pinecone } from '../../index'; import { randomIndexName } from '../test-helpers'; @@ -13,9 +13,11 @@ describe('describe index', () => { await pinecone.createIndex({ name: indexName, dimension: 5, + metric: 'cosine', cloud: 'gcp', region: 'us-east1', capacityMode: 'pod', + environment: 'us-east1-gcp', }); }); @@ -28,17 +30,15 @@ describe('describe index', () => { expect(description.database?.name).toEqual(indexName); expect(description.database?.dimension).toEqual(5); expect(description.database?.metric).toEqual('cosine'); - expect(description.database?.pods).toEqual(1); - expect(description.database?.replicas).toEqual(1); - expect(description.database?.shards).toEqual(1); expect(description.status?.host).toBeDefined(); }); test('describe index with invalid index name', async () => { + expect.assertions(1); try { await pinecone.describeIndex('non-existent-index'); } catch (e) { - const err = e as BasePineconeError; + const err = e as PineconeNotFoundError; expect(err.name).toEqual('PineconeNotFoundError'); } }); diff --git a/src/integration/control/listIndexes.test.ts b/src/integration/control/listIndexes.test.ts index d2b51a6f..95015f7a 100644 --- a/src/integration/control/listIndexes.test.ts +++ b/src/integration/control/listIndexes.test.ts @@ -12,8 +12,10 @@ describe('list indexes', () => { await pinecone.createIndex({ name: indexName, dimension: 5, + metric: 'cosine', cloud: 'gcp', region: 'us-east1', + environment: 'us-east1-gcp', capacityMode: 'pod', }); }); diff --git a/src/integration/errorHandling.test.ts b/src/integration/errorHandling.test.ts index 3486e5df..55e8dfe4 100644 --- a/src/integration/errorHandling.test.ts +++ b/src/integration/errorHandling.test.ts @@ -2,36 +2,39 @@ import { PineconeConnectionError } from '../errors'; import { Pinecone } from '../index'; describe('Error handling', () => { - describe('when environment is wrong', () => { + describe('when API key is wrong', () => { test('calling control plane', async () => { const p = new Pinecone({ - apiKey: process.env.PINECONE_API_KEY || '', + apiKey: '123-456-789', }); + expect.assertions(2); try { await p.listIndexes(); } catch (e) { const err = e as PineconeConnectionError; - expect(err.name).toEqual('PineconeConnectionError'); + expect(err.name).toEqual('PineconeUnmappedHttpError'); expect(err.message).toEqual( - 'Request failed to reach Pinecone. This can occur for reasons such as incorrect configuration (environment, project id, index name), network problems that prevent the request from being completed, or a Pinecone API outage. Check your client configuration, check your network connection, and visit https://status.pinecone.io/ to see whether any outages are ongoing.' + 'An unexpected error occured while calling the https://api.pinecone.io/databases endpoint. Unknown or invalid API Key Status: 403.' ); - expect(err.cause).toBeDefined(); + // TODO: Update when cause is populated + // expect(err.cause).toBeDefined(); } }); test('calling data plane', async () => { const p = new Pinecone({ - apiKey: process.env.PINECONE_API_KEY || '', + apiKey: '123-456-789', }); + expect.assertions(2); try { await p.index('foo-index').query({ topK: 10, id: '1' }); } catch (e) { const err = e as PineconeConnectionError; - expect(err.name).toEqual('PineconeConnectionError'); + expect(err.name).toEqual('PineconeUnmappedHttpError'); expect(err.message).toEqual( - 'Request failed to reach Pinecone while calling https://controller.wrong-environment2.pinecone.io/actions/whoami. This can occur for reasons such as incorrect configuration (environment, project id, index name), network problems that prevent the request from being completed, or a Pinecone API outage. Check your client configuration, check your network connection, and visit https://status.pinecone.io/ to see whether any outages are ongoing.' + 'An unexpected error occured while calling the https://api.pinecone.io/databases/foo-index endpoint. Unknown or invalid API Key Status: 403.' ); } }); @@ -48,6 +51,7 @@ describe('Error handling', () => { }); test('calling control plane', async () => { + expect.assertions(4); try { await p.listIndexes(); } catch (e) { @@ -68,9 +72,9 @@ describe('Error handling', () => { await p.index('foo-index').query({ topK: 10, id: '1' }); } catch (e) { const err = e as PineconeConnectionError; - expect(err.name).toEqual('PineconeConnectionError'); + expect(err.name).toEqual('PineconeUnmappedHttpError'); expect(err.message).toEqual( - `Request failed to reach Pinecone while calling https://controller.${process.env.PINECONE_ENVIRONMENT}.pinecone.io/actions/whoami. This can occur for reasons such as incorrect configuration (environment, project id, index name), network problems that prevent the request from being completed, or a Pinecone API outage. Check your client configuration, check your network connection, and visit https://status.pinecone.io/ to see whether any outages are ongoing.` + `An unexpected error occured while calling the https://api.pinecone.io/databases/foo-index endpoint. Unknown or invalid API Key Status: 403.` ); } }); diff --git a/src/pinecone-generated-ts-fetch/models/CreateRequest.ts b/src/pinecone-generated-ts-fetch/models/CreateRequest.ts index 0ba8401f..c178b7fa 100644 --- a/src/pinecone-generated-ts-fetch/models/CreateRequest.ts +++ b/src/pinecone-generated-ts-fetch/models/CreateRequest.ts @@ -50,6 +50,12 @@ export interface CreateRequest { * @memberof CreateRequest */ cloud: CreateRequestCloudEnum; + /** + * The environment where you would like your index to be created + * @type {string} + * @memberof CreateRequest + */ + environment?: string; /** * The capacity mode for the index. * @type {string} @@ -157,6 +163,7 @@ export function CreateRequestFromJSONTyped(json: any, ignoreDiscriminator: boole 'dimension': json['dimension'], 'region': json['region'], 'cloud': json['cloud'], + 'environment': !exists(json, 'environment') ? undefined : json['environment'], 'capacityMode': json['capacity_mode'], 'indexType': !exists(json, 'index_type') ? undefined : json['index_type'], 'metric': !exists(json, 'metric') ? undefined : json['metric'], @@ -183,6 +190,7 @@ export function CreateRequestToJSON(value?: CreateRequest | null): any { 'dimension': value.dimension, 'region': value.region, 'cloud': value.cloud, + 'environment': value.environment, 'capacity_mode': value.capacityMode, 'index_type': value.indexType, 'metric': value.metric, diff --git a/src/utils/testHelper.ts b/src/utils/testHelper.ts deleted file mode 100644 index 98b147e3..00000000 --- a/src/utils/testHelper.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { ResponseError } from '../pinecone-generated-ts-fetch'; - -export const responseError = (status: number, message: string) => { - return new ResponseError( - { - status, - text: async () => message, - } as Response, - 'oops' - ); -}; diff --git a/utils/globalIntegrationTestSetup.ts b/utils/globalIntegrationTestSetup.ts index 1f5d5a45..e47cd56a 100644 --- a/utils/globalIntegrationTestSetup.ts +++ b/utils/globalIntegrationTestSetup.ts @@ -1,7 +1,7 @@ import dotenv from 'dotenv'; dotenv.config(); -const requiredEnvVars = ['PINECONE_API_KEY', 'PINECONE_ENVIRONMENT']; +const requiredEnvVars = ['PINECONE_API_KEY']; for (const envVar of requiredEnvVars) { if (!process.env[envVar]) { throw new Error(`Missing required environment variable: ${envVar}`); From 266aa96dd74bd01d37c42a0fe7a606817ce5e925 Mon Sep 17 00:00:00 2001 From: Austin DeNoble Date: Wed, 15 Nov 2023 16:49:27 -0500 Subject: [PATCH 4/9] add if check to integration test steps --- .github/workflows/testing.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index e77d44dd..cbe003e2 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -37,6 +37,7 @@ jobs: uses: ./.github/actions/setup - name: Run integration tests (prod) + if: matrix.pinecone_env == 'prod' env: CI: true PINECONE_API_KEY: ${{ secrets.PINECONE_API_KEY }} @@ -44,6 +45,7 @@ jobs: run: npm run test:integration:${{ matrix.jest_env }} - name: Run integration tests (staging) + if: matrix.pinecone_env == 'staging' env: CI: true PINECONE_API_KEY: ${{ secrets.PINECONE_API_KEY_STAGING }} From 64d3fc9231af7d46b70f0c2120f6550c6e195d38 Mon Sep 17 00:00:00 2001 From: Austin DeNoble Date: Tue, 21 Nov 2023 17:05:01 -0500 Subject: [PATCH 5/9] update client to handle new control plane schema, update types, exports, disable runtime checks where needed, update integration and unit tests to pass build --- src/control/__tests__/configureIndex.test.ts | 26 ++- .../__tests__/createCollection.test.ts | 55 ++++- src/control/__tests__/createIndex.test.ts | 89 +++++--- .../__tests__/createIndex.validation.test.ts | 9 +- .../__tests__/deleteCollection.test.ts | 19 +- .../__tests__/describeCollection.test.ts | 15 +- src/control/configureIndex.ts | 29 +-- src/control/createCollection.ts | 21 +- src/control/createIndex.ts | 86 ++------ src/control/deleteCollection.ts | 4 +- src/control/deleteIndex.ts | 5 +- src/control/describeCollection.ts | 47 +--- src/control/describeIndex.ts | 10 +- src/control/index.ts | 14 +- src/control/indexOperationsBuilder.ts | 8 +- src/control/listCollections.ts | 29 +-- src/control/listIndexes.ts | 34 +-- src/data/indexHostSingleton.ts | 7 +- src/data/types.ts | 9 +- src/index.ts | 25 +-- .../control/configureIndex.test.ts | 70 +++--- src/integration/control/createIndex.test.ts | 99 +++++---- src/integration/control/describeIndex.test.ts | 21 +- src/integration/control/listIndexes.test.ts | 21 +- src/integration/data/deleteMany.test.ts | 13 +- src/integration/data/query.test.ts | 13 +- .../.openapi-generator/FILES | 36 +-- ...perationsApi.ts => ManagePodIndexesApi.ts} | 153 +++++++------ .../apis/ManageServerlessIndexesApi.ts | 185 ++++++++++++++++ .../apis/VectorOperationsApi.ts | 8 +- src/pinecone-generated-ts-fetch/apis/index.ts | 6 +- .../models/ApproximatedConfig.ts | 73 ------- .../models/AwsRegions.ts | 39 ++++ .../models/CollectionList.ts | 72 ++++++ .../models/CollectionMeta.ts | 102 --------- .../models/CollectionModel.ts | 122 +++++++++++ .../models/ConfigureIndexRequest.ts | 73 +++++++ .../models/ConfigureIndexRequestSpec.ts | 73 +++++++ .../models/ConfigureIndexRequestSpecPod.ts | 80 +++++++ .../models/CreateCollectionRequest.ts | 10 +- .../models/CreateIndexRequest.ts | 106 +++++++++ .../models/CreateIndexRequestSpec.ts | 86 ++++++++ .../models/CreateRequest.ts | 206 ------------------ .../models/CreateRequestIndexConfig.ts | 55 ----- .../models/DeleteRequest.ts | 8 +- .../models/DescribeIndexStatsRequest.ts | 8 +- .../models/DescribeIndexStatsResponse.ts | 8 +- .../models/ErrorResponse.ts | 82 +++++++ .../models/ErrorResponseError.ts | 110 ++++++++++ .../models/FetchResponse.ts | 8 +- .../models/GcpRegions.ts | 42 ++++ .../models/HnswConfig.ts | 89 -------- .../models/IndexList.ts | 72 ++++++ .../models/IndexListMeta.ts | 102 --------- .../models/IndexMeta.ts | 88 -------- .../models/IndexMetaDatabase.ts | 157 ------------- .../models/IndexMetaDatabaseIndexConfig.ts | 55 ----- .../models/IndexMetaStatus.ts | 110 ---------- .../models/IndexMetric.ts | 39 ++++ .../models/IndexModel.ts | 130 +++++++++++ .../models/IndexModelSpec.ts | 86 ++++++++ .../models/IndexModelStatus.ts | 92 ++++++++ .../models/InlineResponse200.ts | 64 ------ .../models/ListIndexes200Response.ts | 72 ------ .../models/NamespaceSummary.ts | 8 +- .../models/PatchRequest.ts | 73 ------- .../models/PodSpec.ts | 131 +++++++++++ .../models/PodSpecMetadataConfig.ts | 65 ++++++ .../models/PodSpecPodType.ts | 48 ++++ .../models/ProtobufAny.ts | 8 +- .../models/ProtobufNullValue.ts | 8 +- .../models/QueryRequest.ts | 8 +- .../models/QueryResponse.ts | 8 +- .../models/QueryVector.ts | 8 +- .../models/RpcStatus.ts | 8 +- .../models/ScoredVector.ts | 8 +- .../models/ServerlessSpec.ts | 87 ++++++++ .../models/SingleQueryResults.ts | 8 +- .../models/SparseValues.ts | 8 +- .../models/UpdateRequest.ts | 8 +- .../models/UpsertRequest.ts | 8 +- .../models/UpsertResponse.ts | 8 +- .../models/Vector.ts | 8 +- .../models/index.ts | 32 ++- src/pinecone-generated-ts-fetch/runtime.ts | 10 +- src/pinecone.ts | 16 +- utils/cleanupResources.ts | 11 +- 87 files changed, 2468 insertions(+), 1802 deletions(-) rename src/pinecone-generated-ts-fetch/apis/{IndexOperationsApi.ts => ManagePodIndexesApi.ts} (69%) create mode 100644 src/pinecone-generated-ts-fetch/apis/ManageServerlessIndexesApi.ts delete mode 100644 src/pinecone-generated-ts-fetch/models/ApproximatedConfig.ts create mode 100644 src/pinecone-generated-ts-fetch/models/AwsRegions.ts create mode 100644 src/pinecone-generated-ts-fetch/models/CollectionList.ts delete mode 100644 src/pinecone-generated-ts-fetch/models/CollectionMeta.ts create mode 100644 src/pinecone-generated-ts-fetch/models/CollectionModel.ts create mode 100644 src/pinecone-generated-ts-fetch/models/ConfigureIndexRequest.ts create mode 100644 src/pinecone-generated-ts-fetch/models/ConfigureIndexRequestSpec.ts create mode 100644 src/pinecone-generated-ts-fetch/models/ConfigureIndexRequestSpecPod.ts create mode 100644 src/pinecone-generated-ts-fetch/models/CreateIndexRequest.ts create mode 100644 src/pinecone-generated-ts-fetch/models/CreateIndexRequestSpec.ts delete mode 100644 src/pinecone-generated-ts-fetch/models/CreateRequest.ts delete mode 100644 src/pinecone-generated-ts-fetch/models/CreateRequestIndexConfig.ts create mode 100644 src/pinecone-generated-ts-fetch/models/ErrorResponse.ts create mode 100644 src/pinecone-generated-ts-fetch/models/ErrorResponseError.ts create mode 100644 src/pinecone-generated-ts-fetch/models/GcpRegions.ts delete mode 100644 src/pinecone-generated-ts-fetch/models/HnswConfig.ts create mode 100644 src/pinecone-generated-ts-fetch/models/IndexList.ts delete mode 100644 src/pinecone-generated-ts-fetch/models/IndexListMeta.ts delete mode 100644 src/pinecone-generated-ts-fetch/models/IndexMeta.ts delete mode 100644 src/pinecone-generated-ts-fetch/models/IndexMetaDatabase.ts delete mode 100644 src/pinecone-generated-ts-fetch/models/IndexMetaDatabaseIndexConfig.ts delete mode 100644 src/pinecone-generated-ts-fetch/models/IndexMetaStatus.ts create mode 100644 src/pinecone-generated-ts-fetch/models/IndexMetric.ts create mode 100644 src/pinecone-generated-ts-fetch/models/IndexModel.ts create mode 100644 src/pinecone-generated-ts-fetch/models/IndexModelSpec.ts create mode 100644 src/pinecone-generated-ts-fetch/models/IndexModelStatus.ts delete mode 100644 src/pinecone-generated-ts-fetch/models/InlineResponse200.ts delete mode 100644 src/pinecone-generated-ts-fetch/models/ListIndexes200Response.ts delete mode 100644 src/pinecone-generated-ts-fetch/models/PatchRequest.ts create mode 100644 src/pinecone-generated-ts-fetch/models/PodSpec.ts create mode 100644 src/pinecone-generated-ts-fetch/models/PodSpecMetadataConfig.ts create mode 100644 src/pinecone-generated-ts-fetch/models/PodSpecPodType.ts create mode 100644 src/pinecone-generated-ts-fetch/models/ServerlessSpec.ts diff --git a/src/control/__tests__/configureIndex.test.ts b/src/control/__tests__/configureIndex.test.ts index e95098c6..832e9735 100644 --- a/src/control/__tests__/configureIndex.test.ts +++ b/src/control/__tests__/configureIndex.test.ts @@ -1,20 +1,30 @@ import { configureIndex } from '../configureIndex'; -import { IndexOperationsApi } from '../../pinecone-generated-ts-fetch'; -import type { ConfigureIndexRequest } from '../../pinecone-generated-ts-fetch'; -import type { IndexMeta } from '../../index'; +import { ManagePodIndexesApi } from '../../pinecone-generated-ts-fetch'; +import type { + ConfigureIndexOperationRequest, + IndexModel, +} from '../../pinecone-generated-ts-fetch'; describe('configureIndex', () => { test('calls the openapi configure endpoint', async () => { - const fakeConfigure: (req: ConfigureIndexRequest) => Promise = - jest.fn(); - const IOA = { configureIndex: fakeConfigure } as IndexOperationsApi; + const fakeConfigure: ( + req: ConfigureIndexOperationRequest + ) => Promise = jest.fn(); + const IOA = { configureIndex: fakeConfigure } as ManagePodIndexesApi; - const returned = await configureIndex(IOA)('index-name', { replicas: 10 }); + const returned = await configureIndex(IOA)({ + indexName: 'index-name', + configureIndexRequest: { + spec: { pod: { replicas: 4, podType: 'p2.x2' } }, + }, + }); expect(returned).toBe(void 0); expect(IOA.configureIndex).toHaveBeenCalledWith({ indexName: 'index-name', - patchRequest: { replicas: 10 }, + configureIndexRequest: { + spec: { pod: { replicas: 4, podType: 'p2.x2' } }, + }, }); }); }); diff --git a/src/control/__tests__/createCollection.test.ts b/src/control/__tests__/createCollection.test.ts index 39258c41..b00d6a2f 100644 --- a/src/control/__tests__/createCollection.test.ts +++ b/src/control/__tests__/createCollection.test.ts @@ -1,22 +1,63 @@ import { createCollection } from '../createCollection'; import { PineconeArgumentError } from '../../errors'; -import { IndexOperationsApi } from '../../pinecone-generated-ts-fetch'; +import { ManagePodIndexesApi } from '../../pinecone-generated-ts-fetch'; import type { - CreateCollectionOperationRequest as CCOR, - ListIndexes200Response, + CollectionModel, + CreateCollectionOperationRequest, + IndexList, } from '../../pinecone-generated-ts-fetch'; const setOpenAPIResponse = (fakeCreateCollectionResponse) => { - const fakeCreateCollection: (req: CCOR) => Promise = jest + const fakeCreateCollection: ( + req: CreateCollectionOperationRequest + ) => Promise = jest .fn() .mockImplementation(fakeCreateCollectionResponse); - const fakeListIndexes: () => Promise = jest + const fakeListIndexes: () => Promise = jest .fn() - .mockImplementation(() => Promise.resolve(['foo', 'bar'])); + // TODO: Update mock responses to match actual response objects + .mockImplementation(() => + Promise.resolve({ + indexes: [ + { + name: 'index-1', + dimension: 1, + metric: 'cosine', + host: '123-345-abcd.io', + spec: { + pod: { + environment: 'us-west1', + replicas: 1, + shards: 1, + podType: 'p1.x1', + pods: 1, + }, + }, + status: { ready: true, state: 'Ready' }, + }, + { + name: 'index-2', + dimension: 3, + metric: 'cosine', + host: '321-543-bcda.io', + spec: { + pod: { + environment: 'us-west1', + replicas: 1, + shards: 1, + podType: 'p1.x1', + pods: 1, + }, + }, + status: { ready: true, state: 'Ready' }, + }, + ], + }) + ); const IOA = { createCollection: fakeCreateCollection, listIndexes: fakeListIndexes, - } as IndexOperationsApi; + } as ManagePodIndexesApi; return IOA; }; diff --git a/src/control/__tests__/createIndex.test.ts b/src/control/__tests__/createIndex.test.ts index 0297a81c..e066545f 100644 --- a/src/control/__tests__/createIndex.test.ts +++ b/src/control/__tests__/createIndex.test.ts @@ -1,9 +1,9 @@ import { createIndex } from '../createIndex'; -import { IndexOperationsApi } from '../../pinecone-generated-ts-fetch'; +import { ManagePodIndexesApi } from '../../pinecone-generated-ts-fetch'; import type { - CreateIndexRequest, + CreateIndexOperationRequest, DescribeIndexRequest, - IndexMeta, + IndexModel, } from '../../pinecone-generated-ts-fetch'; // describeIndexResponse can either be a single response, or an array of responses for testing polling scenarios @@ -13,7 +13,9 @@ const setupCreateIndexResponse = ( isCreateIndexSuccess = true, isDescribeIndexSuccess = true ) => { - const fakeCreateIndex: (req: CreateIndexRequest) => Promise = jest + const fakeCreateIndex: ( + req: CreateIndexOperationRequest + ) => Promise = jest .fn() .mockImplementation(() => isCreateIndexSuccess @@ -35,13 +37,13 @@ const setupCreateIndexResponse = ( ); }); - const fakeDescribeIndex: (req: DescribeIndexRequest) => Promise = + const fakeDescribeIndex: (req: DescribeIndexRequest) => Promise = describeIndexMock; const IOA = { createIndex: fakeCreateIndex, describeIndex: fakeDescribeIndex, - } as IndexOperationsApi; + } as ManagePodIndexesApi; return IOA; }; @@ -52,19 +54,31 @@ describe('createIndex', () => { const returned = await createIndex(IOA)({ name: 'index-name', dimension: 10, - cloud: 'gcp', - region: 'us-east1', - capacityMode: 'pod', + metric: 'cosine', + spec: { + pod: { + environment: 'us-west1', + replicas: 1, + shards: 1, + pods: 1, + podType: 'p1.x1', + }, + }, }); expect(returned).toEqual(void 0); expect(IOA.createIndex).toHaveBeenCalledWith({ - createRequest: { - name: 'index-name', - dimension: 10, - capacityMode: 'pod', - cloud: 'gcp', - region: 'us-east1', + name: 'index-name', + dimension: 10, + metric: 'cosine', + spec: { + pod: { + environment: 'us-west1', + replicas: 1, + shards: 1, + pods: 1, + podType: 'p1.x1', + }, }, }); }); @@ -87,22 +101,34 @@ describe('createIndex', () => { const returned = await createIndex(IOA)({ name: 'index-name', dimension: 10, - cloud: 'gcp', - region: 'us-east1', - capacityMode: 'pod', + metric: 'cosine', + spec: { + pod: { + environment: 'us-west1', + replicas: 1, + shards: 1, + pods: 1, + podType: 'p1.x1', + }, + }, waitUntilReady: true, }); expect(returned).toEqual({ status: { ready: true, state: 'Ready' } }); expect(IOA.createIndex).toHaveBeenCalledWith({ - createRequest: { - name: 'index-name', - dimension: 10, - cloud: 'gcp', - region: 'us-east1', - capacityMode: 'pod', - waitUntilReady: true, + name: 'index-name', + dimension: 10, + metric: 'cosine', + spec: { + pod: { + environment: 'us-west1', + replicas: 1, + shards: 1, + pods: 1, + podType: 'p1.x1', + }, }, + waitUntilReady: true, }); expect(IOA.describeIndex).toHaveBeenCalledWith({ indexName: 'index-name', @@ -128,9 +154,16 @@ describe('createIndex', () => { const returned = createIndex(IOA)({ name: 'index-name', dimension: 10, - cloud: 'gcp', - region: 'us-east1', - capacityMode: 'pod', + metric: 'cosine', + spec: { + pod: { + environment: 'us-west1', + replicas: 1, + shards: 1, + pods: 1, + podType: 'p1.x1', + }, + }, waitUntilReady: true, }); diff --git a/src/control/__tests__/createIndex.validation.test.ts b/src/control/__tests__/createIndex.validation.test.ts index d49f1007..a4333ad9 100644 --- a/src/control/__tests__/createIndex.validation.test.ts +++ b/src/control/__tests__/createIndex.validation.test.ts @@ -6,14 +6,15 @@ import { createIndex } from '../createIndex'; import { PineconeArgumentError } from '../../errors'; -import { IndexOperationsApi } from '../../pinecone-generated-ts-fetch'; +import { ManagePodIndexesApi } from '../../pinecone-generated-ts-fetch'; +// TODO: Fix up tests describe('createIndex argument validations', () => { - let IOA: IndexOperationsApi; + let MPIA: ManagePodIndexesApi; beforeEach(() => { - IOA = { createIndex: jest.fn() }; + MPIA = { createIndex: jest.fn() }; jest.mock('../../pinecone-generated-ts-fetch', () => ({ - IndexOperationsApi: IOA, + ManagePodIndexesApi: MPIA, })); }); diff --git a/src/control/__tests__/deleteCollection.test.ts b/src/control/__tests__/deleteCollection.test.ts index e58d8cc7..4102d9cc 100644 --- a/src/control/__tests__/deleteCollection.test.ts +++ b/src/control/__tests__/deleteCollection.test.ts @@ -1,23 +1,26 @@ import { deleteCollection } from '../deleteCollection'; import { PineconeArgumentError } from '../../errors'; -import { IndexOperationsApi } from '../../pinecone-generated-ts-fetch'; -import type { DeleteCollectionRequest as DCR } from '../../pinecone-generated-ts-fetch'; +import { ManagePodIndexesApi } from '../../pinecone-generated-ts-fetch'; +import type { + DeleteCollectionRequest, + CollectionList, +} from '../../pinecone-generated-ts-fetch'; const setupMocks = ( deleteResponse, - listCollectionResponse = () => Promise.resolve(['']) + listCollectionResponse = () => Promise.resolve([]) ) => { - const fakeDeleteCollection: (req: DCR) => Promise = jest - .fn() - .mockImplementation(deleteResponse); - const fakeListCollections: () => Promise = jest + const fakeDeleteCollection: ( + req: DeleteCollectionRequest + ) => Promise = jest.fn().mockImplementation(deleteResponse); + const fakeListCollections: () => Promise = jest .fn() .mockImplementation(listCollectionResponse); const IOA = { deleteCollection: fakeDeleteCollection, listCollections: fakeListCollections, }; - return IOA as IndexOperationsApi; + return IOA as ManagePodIndexesApi; }; describe('deleteCollection', () => { diff --git a/src/control/__tests__/describeCollection.test.ts b/src/control/__tests__/describeCollection.test.ts index 4459cb56..bbfc1428 100644 --- a/src/control/__tests__/describeCollection.test.ts +++ b/src/control/__tests__/describeCollection.test.ts @@ -1,26 +1,29 @@ import { describeCollection } from '../describeCollection'; import { PineconeArgumentError } from '../../errors'; -import { IndexOperationsApi } from '../../pinecone-generated-ts-fetch'; +import { ManagePodIndexesApi } from '../../pinecone-generated-ts-fetch'; import type { - DescribeCollectionRequest as DCR, - CollectionMeta, + DescribeCollectionRequest, + CollectionList, + CollectionModel, } from '../../pinecone-generated-ts-fetch'; const setupMocks = ( describeResponse, listCollectionResponse: () => Promise> ) => { - const fakeDescribeCollection: (req: DCR) => Promise = jest + const fakeDescribeCollection: ( + req: DescribeCollectionRequest + ) => Promise = jest .fn() .mockImplementation(describeResponse); - const fakeListCollections: () => Promise> = jest + const fakeListCollections: () => Promise = jest .fn() .mockImplementation(listCollectionResponse); const IOA = { describeCollection: fakeDescribeCollection, listCollections: fakeListCollections, }; - return IOA as IndexOperationsApi; + return IOA as ManagePodIndexesApi; }; describe('describeCollection', () => { diff --git a/src/control/configureIndex.ts b/src/control/configureIndex.ts index ba8d6078..42d1ce1e 100644 --- a/src/control/configureIndex.ts +++ b/src/control/configureIndex.ts @@ -1,4 +1,7 @@ -import { IndexOperationsApi } from '../pinecone-generated-ts-fetch'; +import { + ManagePodIndexesApi, + ConfigureIndexOperationRequest, +} from '../pinecone-generated-ts-fetch'; import { PineconeArgumentError } from '../errors'; import { buildValidator } from '../validator'; import type { IndexName, PodType } from './types'; @@ -25,7 +28,7 @@ export type ConfigureIndexOptions = { podType?: PodType; }; -export const configureIndex = (api: IndexOperationsApi) => { +export const configureIndex = (api: ManagePodIndexesApi) => { const indexNameValidator = buildValidator( 'The first argument to configureIndex', IndexNameSchema @@ -35,20 +38,18 @@ export const configureIndex = (api: IndexOperationsApi) => { ConfigureIndexOptionsSchema ); - return async ( - name: IndexName, - options: ConfigureIndexOptions - ): Promise => { - indexNameValidator(name); - patchRequestValidator(options); + return async (options: ConfigureIndexOperationRequest): Promise => { + // TODO: Fix runtime validation + // indexNameValidator(options.indexName); + // patchRequestValidator(options.configureIndexRequest); - if (Object.keys(options).length === 0) { - throw new PineconeArgumentError( - 'The second argument to configureIndex should not be empty object. Please specify at least one property (replicas, podType) to update.' - ); - } + // if (Object.keys(options).length === 0) { + // throw new PineconeArgumentError( + // 'The second argument to configureIndex should not be empty object. Please specify at least one property (replicas, podType) to update.' + // ); + // } - await api.configureIndex({ indexName: name, patchRequest: options }); + await api.configureIndex(options); return; }; }; diff --git a/src/control/createCollection.ts b/src/control/createCollection.ts index 4d999ab4..306dd67b 100644 --- a/src/control/createCollection.ts +++ b/src/control/createCollection.ts @@ -1,7 +1,9 @@ -import { IndexOperationsApi } from '../pinecone-generated-ts-fetch'; +import { + ManagePodIndexesApi, + CreateCollectionRequest, +} from '../pinecone-generated-ts-fetch'; import { buildConfigValidator } from '../validator'; import { CollectionNameSchema, IndexNameSchema } from './types'; -import type { CollectionName, IndexName } from './types'; import { Type } from '@sinclair/typebox'; const CreateCollectionOptionsSchema = Type.Object( @@ -12,24 +14,13 @@ const CreateCollectionOptionsSchema = Type.Object( { additionalProperties: false } ); -/** - * @see [Understanding collections](https://docs.pinecone.io/docs/collections) - */ -export type CreateCollectionOptions = { - /** The name of the collection you would like to create. */ - name: CollectionName; - - /** The name of the index you would like to create the collection from. */ - source: IndexName; -}; - -export const createCollection = (api: IndexOperationsApi) => { +export const createCollection = (api: ManagePodIndexesApi) => { const validator = buildConfigValidator( CreateCollectionOptionsSchema, 'createCollection' ); - return async (options: CreateCollectionOptions): Promise => { + return async (options: CreateCollectionRequest): Promise => { validator(options); await api.createCollection({ createCollectionRequest: options }); diff --git a/src/control/createIndex.ts b/src/control/createIndex.ts index 5b1ddaca..262fc448 100644 --- a/src/control/createIndex.ts +++ b/src/control/createIndex.ts @@ -1,4 +1,8 @@ -import { IndexMeta, IndexOperationsApi } from '../pinecone-generated-ts-fetch'; +import { + CreateIndexRequest, + IndexModel, + ManagePodIndexesApi, +} from '../pinecone-generated-ts-fetch'; import { buildConfigValidator } from '../validator'; import { debugLog } from '../utils'; import { handleApiError } from '../errors'; @@ -22,76 +26,13 @@ import type { IndexName, PodType } from './types'; /** * @see [Understanding indexes](https://docs.pinecone.io/docs/indexes) */ -export type CreateIndexOptions = { - /** The name of the index. Must be unique within the project and contain alphanumeric and hyphen characters. The name must start and end with alphanumeric characters. */ - name: IndexName; - - /** The dimension of the index. Must be a positive integer. The dimension of your index should match the output dimension of your embedding model. For example, if you are using a model that outputs 128-dimensional vectors, you should set the dimension to 128. */ - dimension: number; - - /** - * The region where you would like your index to be created - */ - region: string; - - /** - * The public cloud where you would like your index hosted - */ - cloud: 'gcp' | 'aws' | 'azure'; - - /** - * The environment where you would like your index to be created - */ - environment?: string; - - /** - * The capacity mode for the index. - */ - capacityMode: string; - - /** - * The metric specifies how similarity is calculated in the index when querying. The default metric is `'cosine'`. Supported metrics include `'cosine'`, `'dotproduct'`, and `'euclidean'`. To learn more about these options, see [Distance metrics](https://docs.pinecone.io/docs/indexes#distance-metrics) - * - * @defaultValue `"cosine"` - * - * */ - metric?: 'cosine' | 'dotproduct' | 'euclidean' | string; - - /** The number of pods in the index. The default number of pods is 1. */ - pods?: number; - - /** The number of replicas in the index. The default number of replicas is 1. */ - replicas?: number; - - /** The number of shards to be used in the index. */ - shards?: number; - - /** - * The type of pod in the index. This string should combine a base pod type (`s1`, `p1`, or `p2`) with a size (`x1`, `x2`, `x4`, or `x8`) into a string such as `p1.x1` or `s1.x4`. The default pod type is `p1.x1`. For more information on these, see this guide on [pod types and sizes](https://docs.pinecone.io/docs/indexes#pods-pod-types-and-pod-sizes). - * - * @defaultValue `"p1.x1"` - * */ - podType?: PodType; - - /** Configuration for the behavior of Pinecone's internal metadata index. By default, all metadata is indexed; when a `metadataConfig` object is present, only metadata fields specified are indexed. */ - metadataConfig?: { - /** - * Specify an array of metadata fields you would like indexed. - * - * @see [Filtering with metadata](https://docs.pinecone.io/docs/metadata-filtering) - * */ - indexed: Array; - }; - - /** If creating an index from a collection, you can specify the name of the collection here. */ - sourceCollection?: string; - +export interface CreateIndexOptions extends CreateIndexRequest { /** This option tells the client not to resolve the returned promise until the index is ready to receive data. */ waitUntilReady?: boolean; /** This option tells the client not to throw if you attempt to create an index that already exists. */ suppressConflicts?: boolean; -}; +} const CreateIndexOptionsSchema = Type.Object( { @@ -113,7 +54,7 @@ const CreateIndexOptionsSchema = Type.Object( { additionalProperties: false } ); -export const createIndex = (api: IndexOperationsApi) => { +export const createIndex = (api: ManagePodIndexesApi) => { const validator = buildConfigValidator( CreateIndexOptionsSchema, 'createIndex' @@ -121,11 +62,12 @@ export const createIndex = (api: IndexOperationsApi) => { return async ( options: CreateIndexOptions - ): Promise => { - validator(options); + ): Promise => { + // TODO: Fix runtime validation + //validator(options); try { const createResponse = await api.createIndex({ - createRequest: options, + createIndexRequest: options, }); if (options.waitUntilReady) { return await waitUntilIndexIsReady(api, options.name); @@ -146,10 +88,10 @@ export const createIndex = (api: IndexOperationsApi) => { }; const waitUntilIndexIsReady = async ( - api: IndexOperationsApi, + api: ManagePodIndexesApi, indexName: string, seconds: number = 0 -): Promise => { +): Promise => { try { const indexDescription = await api.describeIndex({ indexName }); if (!indexDescription.status?.ready) { diff --git a/src/control/deleteCollection.ts b/src/control/deleteCollection.ts index 80453334..ca403318 100644 --- a/src/control/deleteCollection.ts +++ b/src/control/deleteCollection.ts @@ -1,4 +1,4 @@ -import { IndexOperationsApi } from '../pinecone-generated-ts-fetch'; +import { ManagePodIndexesApi } from '../pinecone-generated-ts-fetch'; import { buildConfigValidator } from '../validator'; import { CollectionNameSchema } from './types'; import type { CollectionName } from './types'; @@ -8,7 +8,7 @@ import type { CollectionName } from './types'; */ export type DeleteCollectionOptions = CollectionName; -export const deleteCollection = (api: IndexOperationsApi) => { +export const deleteCollection = (api: ManagePodIndexesApi) => { const validator = buildConfigValidator( CollectionNameSchema, 'deleteCollection' diff --git a/src/control/deleteIndex.ts b/src/control/deleteIndex.ts index 0d9b1d10..40e01fc9 100644 --- a/src/control/deleteIndex.ts +++ b/src/control/deleteIndex.ts @@ -1,14 +1,15 @@ -import { IndexOperationsApi } from '../pinecone-generated-ts-fetch'; +import { ManagePodIndexesApi } from '../pinecone-generated-ts-fetch'; import { buildConfigValidator } from '../validator'; import { IndexName, IndexNameSchema } from './types'; /** The name of index to delete */ export type DeleteIndexOptions = IndexName; -export const deleteIndex = (api: IndexOperationsApi) => { +export const deleteIndex = (api: ManagePodIndexesApi) => { const validator = buildConfigValidator(IndexNameSchema, 'deleteIndex'); return async (indexName: DeleteIndexOptions): Promise => { + // TODO: Fix runtime validation validator(indexName); await api.deleteIndex({ indexName: indexName }); diff --git a/src/control/describeCollection.ts b/src/control/describeCollection.ts index 37765933..20858066 100644 --- a/src/control/describeCollection.ts +++ b/src/control/describeCollection.ts @@ -1,53 +1,20 @@ -import { IndexOperationsApi } from '../pinecone-generated-ts-fetch'; +import { + ManagePodIndexesApi, + CollectionModel, +} from '../pinecone-generated-ts-fetch'; import { buildConfigValidator } from '../validator'; import { CollectionNameSchema } from './types'; import type { CollectionName } from './types'; -/** - * The name of the collection to describe. - */ -export type DescribeCollectionOptions = CollectionName; - -/** - * A description of a Pinecone collection - * - * @see [Understanding collections](https://docs.pinecone.io/docs/collections#limitations) - */ -export type CollectionDescription = { - /** The name of the collection */ - name?: string; - - /** The amount of disk, in bytes, used to store the collection. */ - size?: number; - - /** A string indicating the status of a collection and whether it is ready to be used. */ - status?: string; - - /** The dimension of records stored in the collection */ - dimension?: number; - - /** The total number of records stored in the collection */ - recordCount?: number; -}; - -export const describeCollection = (api: IndexOperationsApi) => { +export const describeCollection = (api: ManagePodIndexesApi) => { const validator = buildConfigValidator( CollectionNameSchema, 'describeCollection' ); - return async (name: CollectionName): Promise => { + return async (name: CollectionName): Promise => { validator(name); - const result = await api.describeCollection({ collectionName: name }); - - // Alias vectorCount to recordCount - return { - name: result.name, - size: result.size, - status: result.status, - dimension: result.dimension, - recordCount: result.vectorCount, - }; + return await api.describeCollection({ collectionName: name }); }; }; diff --git a/src/control/describeIndex.ts b/src/control/describeIndex.ts index d2b61220..fba49da7 100644 --- a/src/control/describeIndex.ts +++ b/src/control/describeIndex.ts @@ -1,15 +1,13 @@ -import { IndexOperationsApi } from '../pinecone-generated-ts-fetch'; +import { ManagePodIndexesApi } from '../pinecone-generated-ts-fetch'; import { buildConfigValidator } from '../validator'; -import type { IndexMeta } from '../pinecone-generated-ts-fetch'; +import { IndexModel } from '../pinecone-generated-ts-fetch'; import { IndexNameSchema } from './types'; import type { IndexName } from './types'; /** The name of the index to describe */ export type DescribeIndexOptions = IndexName; -/** The description of your index returned from { @link Pinecone.describeIndex } */ -export type IndexDescription = IndexMeta; -export const describeIndex = (api: IndexOperationsApi) => { +export const describeIndex = (api: ManagePodIndexesApi) => { const validator = buildConfigValidator(IndexNameSchema, 'describeIndex'); const removeDeprecatedFields = (result: any) => { @@ -22,7 +20,7 @@ export const describeIndex = (api: IndexOperationsApi) => { } }; - return async (name: IndexName): Promise => { + return async (name: DescribeIndexOptions): Promise => { validator(name); const result = await api.describeIndex({ indexName: name }); diff --git a/src/control/index.ts b/src/control/index.ts index 6ad30b90..c2489ae1 100644 --- a/src/control/index.ts +++ b/src/control/index.ts @@ -8,25 +8,13 @@ export type { CreateIndexOptions } from './createIndex'; export { deleteIndex } from './deleteIndex'; export type { DeleteIndexOptions } from './deleteIndex'; export { describeIndex } from './describeIndex'; -export type { DescribeIndexOptions, IndexDescription } from './describeIndex'; +export type { DescribeIndexOptions } from './describeIndex'; export { listIndexes } from './listIndexes'; -export type { IndexList, IndexListDescription } from './listIndexes'; // Collection Operations export type { CollectionName } from './types'; export { createCollection } from './createCollection'; -export type { CreateCollectionOptions } from './createCollection'; - export { deleteCollection } from './deleteCollection'; export type { DeleteCollectionOptions } from './deleteCollection'; - export { describeCollection } from './describeCollection'; -export type { - DescribeCollectionOptions, - CollectionDescription, -} from './describeCollection'; export { listCollections } from './listCollections'; -export type { - CollectionList, - PartialCollectionDescription, -} from './listCollections'; diff --git a/src/control/indexOperationsBuilder.ts b/src/control/indexOperationsBuilder.ts index 8e8f2dc5..022d99dd 100644 --- a/src/control/indexOperationsBuilder.ts +++ b/src/control/indexOperationsBuilder.ts @@ -1,5 +1,5 @@ import { - IndexOperationsApi, + ManagePodIndexesApi, Configuration, } from '../pinecone-generated-ts-fetch'; import { queryParamsStringify, buildUserAgent, getFetch } from '../utils'; @@ -9,19 +9,21 @@ import type { ConfigurationParameters as IndexOperationsApiConfigurationParamete export const indexOperationsBuilder = ( config: PineconeConfiguration -): IndexOperationsApi => { +): ManagePodIndexesApi => { const { apiKey } = config; const controllerPath = config.controllerHostUrl || 'https://api.pinecone.io'; + const headers = config.httpHeaders || null; const apiConfig: IndexOperationsApiConfigurationParameters = { basePath: controllerPath, apiKey, queryParamsStringify, headers: { 'User-Agent': buildUserAgent(false), + ...headers, }, fetchApi: getFetch(config), middleware, }; - return new IndexOperationsApi(new Configuration(apiConfig)); + return new ManagePodIndexesApi(new Configuration(apiConfig)); }; diff --git a/src/control/listCollections.ts b/src/control/listCollections.ts index 33e3db89..e5f932ce 100644 --- a/src/control/listCollections.ts +++ b/src/control/listCollections.ts @@ -1,23 +1,26 @@ -import { IndexOperationsApi } from '../pinecone-generated-ts-fetch'; +import { + ManagePodIndexesApi, + CollectionList, +} from '../pinecone-generated-ts-fetch'; /** * A partial description of a collection in your project. * * To see full information about the collection, see { @link Pinecone.describeCollection } */ -export type PartialCollectionDescription = { - /** The name of the collection */ - name: string; -}; +// export type PartialCollectionDescription = { +// /** The name of the collection */ +// name: string; +// }; -/** - * A list of collections in your project - * - * @see [Understanding collections](https://docs.pinecone.io/docs/collections#limitations) - */ -export type CollectionList = PartialCollectionDescription[]; +// /** +// * A list of collections in your project +// * +// * @see [Understanding collections](https://docs.pinecone.io/docs/collections#limitations) +// */ +// export type CollectionList = PartialCollectionDescription[]; -export const listCollections = (api: IndexOperationsApi) => { +export const listCollections = (api: ManagePodIndexesApi) => { return async (): Promise => { const results = await api.listCollections(); @@ -26,6 +29,6 @@ export const listCollections = (api: IndexOperationsApi) => { // collection names. Mapping these results into an object // will allow us us to add more information in the future // in a non-breaking way. - return results.map((c) => ({ name: c })); + return results; }; }; diff --git a/src/control/listIndexes.ts b/src/control/listIndexes.ts index d8cd81a8..1a38642e 100644 --- a/src/control/listIndexes.ts +++ b/src/control/listIndexes.ts @@ -1,34 +1,34 @@ -import { IndexOperationsApi } from '../pinecone-generated-ts-fetch'; +import { ManagePodIndexesApi, IndexList } from '../pinecone-generated-ts-fetch'; /** * A description of indexes in your project. * * For full information about each index, see { @link Pinecone.describeIndex } */ -export type IndexListDescription = { - /** The name of the index */ - name: string; +// export type IndexListDescription = { +// /** The name of the index */ +// name: string; - /** The distance metric of the index */ - metric: string; +// /** The distance metric of the index */ +// metric: string; - /** The dimension of the index */ - dimension: number; +// /** The dimension of the index */ +// dimension: number; - /** The capacityMode of the index */ - capacityMode: string; +// /** The capacityMode of the index */ +// capacityMode: string; - /** The host address of the index */ - host: string; -}; +// /** The host address of the index */ +// host: string; +// }; -/** The list of indexes in your project */ -export type IndexList = Array; +// /** The list of indexes in your project */ +// export type IndexList = Array; -export const listIndexes = (api: IndexOperationsApi) => { +export const listIndexes = (api: ManagePodIndexesApi) => { return async (): Promise => { const response = await api.listIndexes(); - return response.databases || []; + return response; }; }; diff --git a/src/data/indexHostSingleton.ts b/src/data/indexHostSingleton.ts index 7ba989fa..f697d323 100644 --- a/src/data/indexHostSingleton.ts +++ b/src/data/indexHostSingleton.ts @@ -1,4 +1,4 @@ -import { IndexOperationsApi } from '../pinecone-generated-ts-fetch'; +import { ManagePodIndexesApi } from '../pinecone-generated-ts-fetch'; import type { PineconeConfiguration } from './types'; import type { IndexName } from '../control'; import { describeIndex, indexOperationsBuilder } from '../control'; @@ -9,7 +9,8 @@ import { PineconeUnableToResolveHostError } from '../errors'; // and index, so we cache them in a singleton for reuse. export const IndexHostSingleton = (function () { const hostUrls = {}; // map of apiKey-indexName to hostUrl - let indexOperationsApi: InstanceType | null = null; + let indexOperationsApi: InstanceType | null = + null; const _describeIndex = async ( config: PineconeConfiguration, @@ -20,7 +21,7 @@ export const IndexHostSingleton = (function () { } const describeResponse = await describeIndex(indexOperationsApi)(indexName); - const host = describeResponse.status?.host; + const host = describeResponse.host; if (!host) { // Generally, middleware will handle most errors from the call itself such as index not found, etc diff --git a/src/data/types.ts b/src/data/types.ts index 23edb5ea..37f34bb2 100644 --- a/src/data/types.ts +++ b/src/data/types.ts @@ -1,5 +1,5 @@ import { Type } from '@sinclair/typebox'; -import type { FetchAPI } from '../pinecone-generated-ts-fetch'; +import type { FetchAPI, HTTPHeaders } from '../pinecone-generated-ts-fetch'; export const PineconeConfigurationSchema = Type.Object( { @@ -12,6 +12,8 @@ export const PineconeConfigurationSchema = Type.Object( // But declaring it here as Type.Any() is needed to avoid getting caught // in the additionalProperties check. fetchApi: Type.Optional(Type.Any()), + + httpHeaders: Type.Optional(Type.Any()), }, { additionalProperties: false } ); @@ -34,6 +36,11 @@ export type PineconeConfiguration = { * Optional configuration field for specifying the fetch implementation. If not specified, the client will look for fetch in the global scope and if none is found it will fall back to a [cross-fetch](https://www.npmjs.com/package/cross-fetch) polyfill. */ fetchApi?: FetchAPI; + + /** + * Optional headers to be included in all requests. + */ + httpHeaders?: HTTPHeaders; }; /** Configuration for a single Pinecone Index */ diff --git a/src/index.ts b/src/index.ts index 37baabb1..50665406 100644 --- a/src/index.ts +++ b/src/index.ts @@ -5,21 +5,13 @@ export * as Errors from './errors'; // Type exports export type { - CollectionDescription, - CollectionList, CollectionName, ConfigureIndexOptions, - CreateCollectionOptions, CreateIndexOptions, DeleteCollectionOptions, DeleteIndexOptions, - DescribeCollectionOptions, DescribeIndexOptions, - IndexDescription, - IndexList, - IndexListDescription, IndexName, - PartialCollectionDescription, PodType, } from './control'; export type { @@ -47,19 +39,24 @@ export type { RecordValues, ScoredPineconeRecord, } from './data'; -export type { FetchAPI } from './pinecone-generated-ts-fetch'; export type { - IndexMeta, - IndexMetaStatus, - IndexMetaStatusStateEnum, - IndexMetaDatabase, + CollectionList, + CollectionModel, + ConfigureIndexRequest, + CreateCollectionRequest, + CreateIndexRequest, + DescribeCollectionRequest, + DescribeIndexRequest, + FetchAPI, + IndexList, + IndexModel, } from './pinecone-generated-ts-fetch'; // Legacy exports for backwards compatibility export { PineconeClient } from './v0'; export { utils } from './v0/utils'; export { - CreateCollectionRequest, + CreateCollectionRequest as CreateCollectionRequestV0, CreateRequest, DeleteRequest, PatchRequest, diff --git a/src/integration/control/configureIndex.test.ts b/src/integration/control/configureIndex.test.ts index d0523692..036a3f57 100644 --- a/src/integration/control/configureIndex.test.ts +++ b/src/integration/control/configureIndex.test.ts @@ -2,7 +2,8 @@ import { BasePineconeError } from '../../errors'; import { Pinecone } from '../../index'; import { randomIndexName, waitUntilReady } from '../test-helpers'; -describe('configure index', () => { +// TODO: Uncomment when configure_index implemented +describe.skip('configure index', () => { let indexName; let pinecone: Pinecone; @@ -14,13 +15,16 @@ describe('configure index', () => { name: indexName, dimension: 5, metric: 'cosine', + spec: { + pod: { + environment: 'us-east1-gcp', + replicas: 2, + shards: 1, + podType: 'p1.x1', + pods: 2, + }, + }, waitUntilReady: true, - podType: 'p1.x1', - replicas: 2, - cloud: 'gcp', - region: 'us-east1', - environment: 'us-east1-gcp', - capacityMode: 'pod', }); }); @@ -31,7 +35,9 @@ describe('configure index', () => { describe('error handling', () => { test('configure index with invalid index name', async () => { try { - await pinecone.configureIndex('non-existent-index', { replicas: 2 }); + await pinecone.configureIndex('non-existent-index', { + spec: { pod: { replicas: 2 } }, + }); } catch (e) { const err = e as BasePineconeError; expect(err.name).toEqual('PineconeNotFoundError'); @@ -40,7 +46,9 @@ describe('configure index', () => { test('configure index when exceeding quota', async () => { try { - await pinecone.configureIndex(indexName, { replicas: 20 }); + await pinecone.configureIndex(indexName, { + spec: { pod: { replicas: 20 } }, + }); } catch (e) { const err = e as BasePineconeError; expect(err.name).toEqual('PineconeBadRequestError'); @@ -55,20 +63,24 @@ describe('configure index', () => { describe('scaling replicas', () => { test('scaling up', async () => { const description = await pinecone.describeIndex(indexName); - expect(description.database?.replicas).toEqual(2); + expect(description.spec.pod?.replicas).toEqual(2); - await pinecone.configureIndex(indexName, { replicas: 3 }); + await pinecone.configureIndex(indexName, { + spec: { pod: { replicas: 3 } }, + }); const description2 = await pinecone.describeIndex(indexName); - expect(description2.database?.replicas).toEqual(3); + expect(description2.spec.pod?.replicas).toEqual(3); }); test('scaling down', async () => { const description = await pinecone.describeIndex(indexName); - expect(description.database?.replicas).toEqual(2); + expect(description.spec.pod?.replicas).toEqual(2); - await pinecone.configureIndex(indexName, { replicas: 1 }); + await pinecone.configureIndex(indexName, { + spec: { pod: { replicas: 1 } }, + }); const description3 = await pinecone.describeIndex(indexName); - expect(description3.database?.replicas).toEqual(1); + expect(description3.spec.pod?.replicas).toEqual(1); }); }); @@ -76,11 +88,13 @@ describe('configure index', () => { test('scaling podType: changing base pod type', async () => { // Verify the starting state const description = await pinecone.describeIndex(indexName); - expect(description.database?.podType).toEqual('p1.x1'); + expect(description.spec.pod?.podType).toEqual('p1.x1'); try { // Try to change the base pod type - await pinecone.configureIndex(indexName, { podType: 'p2.x1' }); + await pinecone.configureIndex(indexName, { + spec: { pod: { podType: 'p2.x1' } }, + }); } catch (e) { const err = e as BasePineconeError; expect(err.name).toEqual('PineconeBadRequestError'); @@ -93,30 +107,36 @@ describe('configure index', () => { test('scaling podType: size increase', async () => { // Verify the starting state const description = await pinecone.describeIndex(indexName); - expect(description.database?.podType).toEqual('p1.x1'); + expect(description.spec.pod?.podType).toEqual('p1.x1'); - await pinecone.configureIndex(indexName, { podType: 'p1.x2' }); + await pinecone.configureIndex(indexName, { + spec: { pod: { podType: 'p1.x2' } }, + }); const description2 = await pinecone.describeIndex(indexName); - expect(description2.database?.podType).toEqual('p1.x2'); + expect(description2.spec.pod?.podType).toEqual('p1.x2'); }); test('scaling podType: size down', async () => { // Verify the starting state const description = await pinecone.describeIndex(indexName); - expect(description.database?.podType).toEqual('p1.x1'); + expect(description.spec.pod?.podType).toEqual('p1.x1'); // Size up - await pinecone.configureIndex(indexName, { podType: 'p1.x2' }); + await pinecone.configureIndex(indexName, { + spec: { pod: { podType: 'p1.x2' } }, + }); const description2 = await pinecone.describeIndex(indexName); - expect(description2.database?.podType).toEqual('p1.x2'); + expect(description2.spec.pod?.podType).toEqual('p1.x2'); await waitUntilReady(indexName); try { // try to size down - await pinecone.configureIndex(indexName, { podType: 'p1.x1' }); + await pinecone.configureIndex(indexName, { + spec: { pod: { podType: 'p1.x1' } }, + }); const description3 = await pinecone.describeIndex(indexName); - expect(description3.database?.podType).toEqual('p1.x1'); + expect(description3.spec.pod?.podType).toEqual('p1.x1'); } catch (e) { const err = e as BasePineconeError; diff --git a/src/integration/control/createIndex.test.ts b/src/integration/control/createIndex.test.ts index a44bff25..e8dbaf60 100644 --- a/src/integration/control/createIndex.test.ts +++ b/src/integration/control/createIndex.test.ts @@ -21,15 +21,18 @@ describe('create index', () => { name: indexName, dimension: 5, metric: 'cosine', - cloud: 'aws', - region: 'us-east1', - capacityMode: 'serverless', + spec: { + serverless: { + cloud: 'aws', + region: 'us-east-1', + }, + }, }); const description = await pinecone.describeIndex(indexName); - expect(description.database?.name).toEqual(indexName); - expect(description.database?.dimension).toEqual(5); - expect(description.database?.metric).toEqual('cosine'); - expect(description.status?.host).toBeDefined(); + expect(description.name).toEqual(indexName); + expect(description.dimension).toEqual(5); + expect(description.metric).toEqual('cosine'); + expect(description.host).toBeDefined(); }); test('create with optional properties', async () => { @@ -37,33 +40,37 @@ describe('create index', () => { name: indexName, dimension: 5, metric: 'euclidean', - replicas: 2, - podType: 'p1.x2', - cloud: 'aws', - region: 'us-east1', - capacityMode: 'serverless', + spec: { + serverless: { + cloud: 'aws', + region: 'us-east-1', + }, + }, }); const description = await pinecone.describeIndex(indexName); - expect(description.database?.name).toEqual(indexName); - expect(description.database?.dimension).toEqual(5); - expect(description.database?.metric).toEqual('euclidean'); - expect(description.status?.host).toBeDefined(); + expect(description.name).toEqual(indexName); + expect(description.dimension).toEqual(5); + expect(description.metric).toEqual('euclidean'); + expect(description.host).toBeDefined(); }); test('create with utility prop: waitUntilReady', async () => { await pinecone.createIndex({ name: indexName, dimension: 5, - cloud: 'aws', metric: 'cosine', - region: 'us-east1', - capacityMode: 'serverless', + spec: { + serverless: { + cloud: 'aws', + region: 'us-east-1', + }, + }, waitUntilReady: true, }); const description = await pinecone.describeIndex(indexName); - expect(description.database?.name).toEqual(indexName); + expect(description.name).toEqual(indexName); expect(description.status?.state).toEqual('Ready'); }); @@ -71,23 +78,29 @@ describe('create index', () => { await pinecone.createIndex({ name: indexName, dimension: 5, - cloud: 'aws', metric: 'cosine', - region: 'us-east1', - capacityMode: 'serverless', + spec: { + serverless: { + cloud: 'aws', + region: 'us-east-1', + }, + }, }); await pinecone.createIndex({ name: indexName, dimension: 5, - cloud: 'aws', metric: 'cosine', - region: 'us-east1', - capacityMode: 'serverless', + spec: { + serverless: { + cloud: 'aws', + region: 'us-east-1', + }, + }, suppressConflicts: true, }); const description = await pinecone.describeIndex(indexName); - expect(description.database?.name).toEqual(indexName); + expect(description.name).toEqual(indexName); }); }); @@ -97,10 +110,13 @@ describe('create index', () => { await pinecone.createIndex({ name: indexName + '-', dimension: 5, - cloud: 'aws', metric: 'cosine', - region: 'us-east1', - capacityMode: 'serverless', + spec: { + serverless: { + cloud: 'aws', + region: 'us-east-1', + }, + }, }); } catch (e) { const err = e as PineconeNotFoundError; @@ -114,10 +130,13 @@ describe('create index', () => { await pinecone.createIndex({ name: indexName, dimension: 5, - cloud: 'aws', metric: 'cosine', - region: 'us-east1', - capacityMode: 'serverless', + spec: { + serverless: { + cloud: 'aws', + region: 'us-east-1', + }, + }, }); } catch (e) { const err = e as PineconeNotFoundError; @@ -131,11 +150,17 @@ describe('create index', () => { await pinecone.createIndex({ name: indexName, dimension: 5, - cloud: 'aws', metric: 'cosine', - region: 'us-east1', - capacityMode: 'serverless', - sourceCollection: 'non-existent-collection', + spec: { + pod: { + environment: 'us-east-1-aws', + replicas: 1, + shards: 1, + podType: 'p1.x1', + pods: 1, + sourceCollection: 'non-existent-collection', + }, + }, }); } catch (e) { const err = e as PineconeNotFoundError; diff --git a/src/integration/control/describeIndex.test.ts b/src/integration/control/describeIndex.test.ts index f23e1c21..67700dd4 100644 --- a/src/integration/control/describeIndex.test.ts +++ b/src/integration/control/describeIndex.test.ts @@ -14,10 +14,15 @@ describe('describe index', () => { name: indexName, dimension: 5, metric: 'cosine', - cloud: 'gcp', - region: 'us-east1', - capacityMode: 'pod', - environment: 'us-east1-gcp', + spec: { + pod: { + environment: 'us-east1-gcp', + replicas: 1, + shards: 1, + podType: 'p1.x1', + pods: 1, + }, + }, }); }); @@ -27,10 +32,10 @@ describe('describe index', () => { test('describe index', async () => { const description = await pinecone.describeIndex(indexName); - expect(description.database?.name).toEqual(indexName); - expect(description.database?.dimension).toEqual(5); - expect(description.database?.metric).toEqual('cosine'); - expect(description.status?.host).toBeDefined(); + expect(description.name).toEqual(indexName); + expect(description.dimension).toEqual(5); + expect(description.metric).toEqual('cosine'); + expect(description.host).toBeDefined(); }); test('describe index with invalid index name', async () => { diff --git a/src/integration/control/listIndexes.test.ts b/src/integration/control/listIndexes.test.ts index 95015f7a..a205368d 100644 --- a/src/integration/control/listIndexes.test.ts +++ b/src/integration/control/listIndexes.test.ts @@ -13,10 +13,15 @@ describe('list indexes', () => { name: indexName, dimension: 5, metric: 'cosine', - cloud: 'gcp', - region: 'us-east1', - environment: 'us-east1-gcp', - capacityMode: 'pod', + spec: { + pod: { + environment: 'us-east1-gcp', + replicas: 1, + shards: 1, + podType: 'p1.x1', + pods: 1, + }, + }, }); }); @@ -25,10 +30,10 @@ describe('list indexes', () => { }); test('list indexes', async () => { - const indexes = await pinecone.listIndexes(); - expect(indexes).toBeDefined(); - expect(indexes?.length).toBeGreaterThan(0); + const response = await pinecone.listIndexes(); + expect(response.indexes).toBeDefined(); + expect(response.indexes?.length).toBeGreaterThan(0); - expect(indexes?.map((i) => i.name)).toContain(indexName); + expect(response.indexes?.map((i) => i.name)).toContain(indexName); }); }); diff --git a/src/integration/data/deleteMany.test.ts b/src/integration/data/deleteMany.test.ts index 34288132..0e49fcdb 100644 --- a/src/integration/data/deleteMany.test.ts +++ b/src/integration/data/deleteMany.test.ts @@ -11,9 +11,16 @@ describe('deleteMany', () => { await pinecone.createIndex({ name: INDEX_NAME, dimension: 5, - cloud: 'gcp', - region: 'us-east1', - capacityMode: 'pod', + metric: 'cosine', + spec: { + pod: { + environment: 'us-west1-gcp', + replicas: 1, + shards: 1, + podType: 'p1.x1', + pods: 1, + }, + }, waitUntilReady: true, suppressConflicts: true, }); diff --git a/src/integration/data/query.test.ts b/src/integration/data/query.test.ts index a597c831..ae37912d 100644 --- a/src/integration/data/query.test.ts +++ b/src/integration/data/query.test.ts @@ -11,9 +11,16 @@ describe('query', () => { await pinecone.createIndex({ name: INDEX_NAME, dimension: 5, - cloud: 'gcp', - region: 'us-east1', - capacityMode: 'pod', + metric: 'cosine', + spec: { + pod: { + environment: 'us-west1-gcp', + replicas: 1, + shards: 1, + podType: 'p1.x1', + pods: 1, + }, + }, waitUntilReady: true, suppressConflicts: true, }); diff --git a/src/pinecone-generated-ts-fetch/.openapi-generator/FILES b/src/pinecone-generated-ts-fetch/.openapi-generator/FILES index 86b46a39..a4bfb82c 100644 --- a/src/pinecone-generated-ts-fetch/.openapi-generator/FILES +++ b/src/pinecone-generated-ts-fetch/.openapi-generator/FILES @@ -1,25 +1,34 @@ -apis/IndexOperationsApi.ts +.openapi-generator-ignore +apis/ManagePodIndexesApi.ts +apis/ManageServerlessIndexesApi.ts apis/VectorOperationsApi.ts apis/index.ts index.ts -models/ApproximatedConfig.ts -models/CollectionMeta.ts +models/AwsRegions.ts +models/CollectionList.ts +models/CollectionModel.ts +models/ConfigureIndexRequest.ts +models/ConfigureIndexRequestSpec.ts +models/ConfigureIndexRequestSpecPod.ts models/CreateCollectionRequest.ts -models/CreateRequest.ts -models/CreateRequestIndexConfig.ts +models/CreateIndexRequest.ts +models/CreateIndexRequestSpec.ts models/DeleteRequest.ts models/DescribeIndexStatsRequest.ts models/DescribeIndexStatsResponse.ts +models/ErrorResponse.ts +models/ErrorResponseError.ts models/FetchResponse.ts -models/HnswConfig.ts -models/IndexListMeta.ts -models/IndexMeta.ts -models/IndexMetaDatabase.ts -models/IndexMetaDatabaseIndexConfig.ts -models/IndexMetaStatus.ts -models/ListIndexes200Response.ts +models/GcpRegions.ts +models/IndexList.ts +models/IndexMetric.ts +models/IndexModel.ts +models/IndexModelSpec.ts +models/IndexModelStatus.ts models/NamespaceSummary.ts -models/PatchRequest.ts +models/PodSpec.ts +models/PodSpecMetadataConfig.ts +models/PodSpecPodType.ts models/ProtobufAny.ts models/ProtobufNullValue.ts models/QueryRequest.ts @@ -27,6 +36,7 @@ models/QueryResponse.ts models/QueryVector.ts models/RpcStatus.ts models/ScoredVector.ts +models/ServerlessSpec.ts models/SingleQueryResults.ts models/SparseValues.ts models/UpdateRequest.ts diff --git a/src/pinecone-generated-ts-fetch/apis/IndexOperationsApi.ts b/src/pinecone-generated-ts-fetch/apis/ManagePodIndexesApi.ts similarity index 69% rename from src/pinecone-generated-ts-fetch/apis/IndexOperationsApi.ts rename to src/pinecone-generated-ts-fetch/apis/ManagePodIndexesApi.ts index 8132d312..2dbdee8f 100644 --- a/src/pinecone-generated-ts-fetch/apis/IndexOperationsApi.ts +++ b/src/pinecone-generated-ts-fetch/apis/ManagePodIndexesApi.ts @@ -1,11 +1,11 @@ /* tslint:disable */ /* eslint-disable */ /** - * Pinecone API - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. * - * The version of the OpenAPI document: version not set - * Contact: support@pinecone.io + * The version of the OpenAPI document: 1.0 + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech @@ -15,39 +15,45 @@ import * as runtime from '../runtime'; import type { - CollectionMeta, + CollectionList, + CollectionModel, + ConfigureIndexRequest, CreateCollectionRequest, - CreateRequest, - IndexMeta, - ListIndexes200Response, - PatchRequest, + CreateIndexRequest, + ErrorResponse, + IndexList, + IndexModel, } from '../models/index'; import { - CollectionMetaFromJSON, - CollectionMetaToJSON, + CollectionListFromJSON, + CollectionListToJSON, + CollectionModelFromJSON, + CollectionModelToJSON, + ConfigureIndexRequestFromJSON, + ConfigureIndexRequestToJSON, CreateCollectionRequestFromJSON, CreateCollectionRequestToJSON, - CreateRequestFromJSON, - CreateRequestToJSON, - IndexMetaFromJSON, - IndexMetaToJSON, - ListIndexes200ResponseFromJSON, - ListIndexes200ResponseToJSON, - PatchRequestFromJSON, - PatchRequestToJSON, + CreateIndexRequestFromJSON, + CreateIndexRequestToJSON, + ErrorResponseFromJSON, + ErrorResponseToJSON, + IndexListFromJSON, + IndexListToJSON, + IndexModelFromJSON, + IndexModelToJSON, } from '../models/index'; -export interface ConfigureIndexRequest { +export interface ConfigureIndexOperationRequest { indexName: string; - patchRequest?: PatchRequest; + configureIndexRequest: ConfigureIndexRequest; } export interface CreateCollectionOperationRequest { - createCollectionRequest?: CreateCollectionRequest; + createCollectionRequest: CreateCollectionRequest; } -export interface CreateIndexRequest { - createRequest?: CreateRequest; +export interface CreateIndexOperationRequest { + createIndexRequest: CreateIndexRequest; } export interface DeleteCollectionRequest { @@ -69,16 +75,20 @@ export interface DescribeIndexRequest { /** * */ -export class IndexOperationsApi extends runtime.BaseAPI { +export class ManagePodIndexesApi extends runtime.BaseAPI { /** * This operation specifies the pod type and number of replicas for an index. */ - async configureIndexRaw(requestParameters: ConfigureIndexRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + async configureIndexRaw(requestParameters: ConfigureIndexOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { if (requestParameters.indexName === null || requestParameters.indexName === undefined) { throw new runtime.RequiredError('indexName','Required parameter requestParameters.indexName was null or undefined when calling configureIndex.'); } + if (requestParameters.configureIndexRequest === null || requestParameters.configureIndexRequest === undefined) { + throw new runtime.RequiredError('configureIndexRequest','Required parameter requestParameters.configureIndexRequest was null or undefined when calling configureIndex.'); + } + const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; @@ -90,20 +100,20 @@ export class IndexOperationsApi extends runtime.BaseAPI { } const response = await this.request({ - path: `/databases/{indexName}`.replace(`{${"indexName"}}`, encodeURIComponent(String(requestParameters.indexName))), + path: `/indexes/{index_name}`.replace(`{${"index_name"}}`, encodeURIComponent(String(requestParameters.indexName))), method: 'PATCH', headers: headerParameters, query: queryParameters, - body: PatchRequestToJSON(requestParameters.patchRequest), + body: ConfigureIndexRequestToJSON(requestParameters.configureIndexRequest), }, initOverrides); - return new runtime.JSONApiResponse(response, (jsonValue) => IndexMetaFromJSON(jsonValue)); + return new runtime.JSONApiResponse(response, (jsonValue) => IndexModelFromJSON(jsonValue)); } /** * This operation specifies the pod type and number of replicas for an index. */ - async configureIndex(requestParameters: ConfigureIndexRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + async configureIndex(requestParameters: ConfigureIndexOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.configureIndexRaw(requestParameters, initOverrides); return await response.value(); } @@ -111,7 +121,11 @@ export class IndexOperationsApi extends runtime.BaseAPI { /** * This operation creates a Pinecone collection. */ - async createCollectionRaw(requestParameters: CreateCollectionOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + async createCollectionRaw(requestParameters: CreateCollectionOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (requestParameters.createCollectionRequest === null || requestParameters.createCollectionRequest === undefined) { + throw new runtime.RequiredError('createCollectionRequest','Required parameter requestParameters.createCollectionRequest was null or undefined when calling createCollection.'); + } + const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; @@ -130,25 +144,25 @@ export class IndexOperationsApi extends runtime.BaseAPI { body: CreateCollectionRequestToJSON(requestParameters.createCollectionRequest), }, initOverrides); - if (this.isJsonMime(response.headers.get('content-type'))) { - return new runtime.JSONApiResponse(response); - } else { - return new runtime.TextApiResponse(response) as any; - } + return new runtime.JSONApiResponse(response, (jsonValue) => CollectionModelFromJSON(jsonValue)); } /** * This operation creates a Pinecone collection. */ - async createCollection(requestParameters: CreateCollectionOperationRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + async createCollection(requestParameters: CreateCollectionOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.createCollectionRaw(requestParameters, initOverrides); return await response.value(); } /** - * This operation creates a Pinecone index. You can use it to specify the measure of similarity, the dimension of vectors to be stored in the index, the numbers of shards and replicas to use, and more. + * This operation deploys a Pinecone index. This is where you specify the measure of similarity, the dimension of vectors to be stored in the index, which cloud provider you would like to deploy with, and more. */ - async createIndexRaw(requestParameters: CreateIndexRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + async createIndexRaw(requestParameters: CreateIndexOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (requestParameters.createIndexRequest === null || requestParameters.createIndexRequest === undefined) { + throw new runtime.RequiredError('createIndexRequest','Required parameter requestParameters.createIndexRequest was null or undefined when calling createIndex.'); + } + const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; @@ -160,20 +174,20 @@ export class IndexOperationsApi extends runtime.BaseAPI { } const response = await this.request({ - path: `/databases`, + path: `/indexes`, method: 'POST', headers: headerParameters, query: queryParameters, - body: CreateRequestToJSON(requestParameters.createRequest), + body: CreateIndexRequestToJSON(requestParameters.createIndexRequest), }, initOverrides); - return new runtime.JSONApiResponse(response, (jsonValue) => IndexMetaFromJSON(jsonValue)); + return new runtime.JSONApiResponse(response, (jsonValue) => IndexModelFromJSON(jsonValue)); } /** - * This operation creates a Pinecone index. You can use it to specify the measure of similarity, the dimension of vectors to be stored in the index, the numbers of shards and replicas to use, and more. + * This operation deploys a Pinecone index. This is where you specify the measure of similarity, the dimension of vectors to be stored in the index, which cloud provider you would like to deploy with, and more. */ - async createIndex(requestParameters: CreateIndexRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + async createIndex(requestParameters: CreateIndexOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.createIndexRaw(requestParameters, initOverrides); return await response.value(); } @@ -195,7 +209,7 @@ export class IndexOperationsApi extends runtime.BaseAPI { } const response = await this.request({ - path: `/collections/{collectionName}`.replace(`{${"collectionName"}}`, encodeURIComponent(String(requestParameters.collectionName))), + path: `/collections/{collection_name}`.replace(`{${"collection_name"}}`, encodeURIComponent(String(requestParameters.collectionName))), method: 'DELETE', headers: headerParameters, query: queryParameters, @@ -219,7 +233,7 @@ export class IndexOperationsApi extends runtime.BaseAPI { /** * This operation deletes an existing index. */ - async deleteIndexRaw(requestParameters: DeleteIndexRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + async deleteIndexRaw(requestParameters: DeleteIndexRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { if (requestParameters.indexName === null || requestParameters.indexName === undefined) { throw new runtime.RequiredError('indexName','Required parameter requestParameters.indexName was null or undefined when calling deleteIndex.'); } @@ -233,31 +247,26 @@ export class IndexOperationsApi extends runtime.BaseAPI { } const response = await this.request({ - path: `/databases/{indexName}`.replace(`{${"indexName"}}`, encodeURIComponent(String(requestParameters.indexName))), + path: `/indexes/{index_name}`.replace(`{${"index_name"}}`, encodeURIComponent(String(requestParameters.indexName))), method: 'DELETE', headers: headerParameters, query: queryParameters, }, initOverrides); - if (this.isJsonMime(response.headers.get('content-type'))) { - return new runtime.JSONApiResponse(response); - } else { - return new runtime.TextApiResponse(response) as any; - } + return new runtime.VoidApiResponse(response); } /** * This operation deletes an existing index. */ - async deleteIndex(requestParameters: DeleteIndexRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { - const response = await this.deleteIndexRaw(requestParameters, initOverrides); - return await response.value(); + async deleteIndex(requestParameters: DeleteIndexRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + await this.deleteIndexRaw(requestParameters, initOverrides); } /** - * Get a description of a collection. + * This operation gets a description of a collection. */ - async describeCollectionRaw(requestParameters: DescribeCollectionRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + async describeCollectionRaw(requestParameters: DescribeCollectionRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { if (requestParameters.collectionName === null || requestParameters.collectionName === undefined) { throw new runtime.RequiredError('collectionName','Required parameter requestParameters.collectionName was null or undefined when calling describeCollection.'); } @@ -271,19 +280,19 @@ export class IndexOperationsApi extends runtime.BaseAPI { } const response = await this.request({ - path: `/collections/{collectionName}`.replace(`{${"collectionName"}}`, encodeURIComponent(String(requestParameters.collectionName))), + path: `/collections/{collection_name}`.replace(`{${"collection_name"}}`, encodeURIComponent(String(requestParameters.collectionName))), method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides); - return new runtime.JSONApiResponse(response, (jsonValue) => CollectionMetaFromJSON(jsonValue)); + return new runtime.JSONApiResponse(response, (jsonValue) => CollectionModelFromJSON(jsonValue)); } /** - * Get a description of a collection. + * This operation gets a description of a collection. */ - async describeCollection(requestParameters: DescribeCollectionRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + async describeCollection(requestParameters: DescribeCollectionRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.describeCollectionRaw(requestParameters, initOverrides); return await response.value(); } @@ -291,7 +300,7 @@ export class IndexOperationsApi extends runtime.BaseAPI { /** * Get a description of an index. */ - async describeIndexRaw(requestParameters: DescribeIndexRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + async describeIndexRaw(requestParameters: DescribeIndexRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { if (requestParameters.indexName === null || requestParameters.indexName === undefined) { throw new runtime.RequiredError('indexName','Required parameter requestParameters.indexName was null or undefined when calling describeIndex.'); } @@ -305,19 +314,19 @@ export class IndexOperationsApi extends runtime.BaseAPI { } const response = await this.request({ - path: `/databases/{indexName}`.replace(`{${"indexName"}}`, encodeURIComponent(String(requestParameters.indexName))), + path: `/indexes/{index_name}`.replace(`{${"index_name"}}`, encodeURIComponent(String(requestParameters.indexName))), method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides); - return new runtime.JSONApiResponse(response, (jsonValue) => IndexMetaFromJSON(jsonValue)); + return new runtime.JSONApiResponse(response, (jsonValue) => IndexModelFromJSON(jsonValue)); } /** * Get a description of an index. */ - async describeIndex(requestParameters: DescribeIndexRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + async describeIndex(requestParameters: DescribeIndexRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.describeIndexRaw(requestParameters, initOverrides); return await response.value(); } @@ -325,7 +334,7 @@ export class IndexOperationsApi extends runtime.BaseAPI { /** * This operation returns a list of your Pinecone collections. */ - async listCollectionsRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>> { + async listCollectionsRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; @@ -341,13 +350,13 @@ export class IndexOperationsApi extends runtime.BaseAPI { query: queryParameters, }, initOverrides); - return new runtime.JSONApiResponse(response); + return new runtime.JSONApiResponse(response, (jsonValue) => CollectionListFromJSON(jsonValue)); } /** * This operation returns a list of your Pinecone collections. */ - async listCollections(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + async listCollections(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.listCollectionsRaw(initOverrides); return await response.value(); } @@ -355,7 +364,7 @@ export class IndexOperationsApi extends runtime.BaseAPI { /** * This operation returns a list of your Pinecone indexes. */ - async listIndexesRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + async listIndexesRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; @@ -365,19 +374,19 @@ export class IndexOperationsApi extends runtime.BaseAPI { } const response = await this.request({ - path: `/databases`, + path: `/indexes`, method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides); - return new runtime.JSONApiResponse(response, (jsonValue) => ListIndexes200ResponseFromJSON(jsonValue)); + return new runtime.JSONApiResponse(response, (jsonValue) => IndexListFromJSON(jsonValue)); } /** * This operation returns a list of your Pinecone indexes. */ - async listIndexes(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + async listIndexes(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.listIndexesRaw(initOverrides); return await response.value(); } diff --git a/src/pinecone-generated-ts-fetch/apis/ManageServerlessIndexesApi.ts b/src/pinecone-generated-ts-fetch/apis/ManageServerlessIndexesApi.ts new file mode 100644 index 00000000..d313562f --- /dev/null +++ b/src/pinecone-generated-ts-fetch/apis/ManageServerlessIndexesApi.ts @@ -0,0 +1,185 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +import * as runtime from '../runtime'; +import type { + CreateIndexRequest, + ErrorResponse, + IndexList, + IndexModel, +} from '../models/index'; +import { + CreateIndexRequestFromJSON, + CreateIndexRequestToJSON, + ErrorResponseFromJSON, + ErrorResponseToJSON, + IndexListFromJSON, + IndexListToJSON, + IndexModelFromJSON, + IndexModelToJSON, +} from '../models/index'; + +export interface CreateIndexOperationRequest { + createIndexRequest: CreateIndexRequest; +} + +export interface DeleteIndexRequest { + indexName: string; +} + +export interface DescribeIndexRequest { + indexName: string; +} + +/** + * + */ +export class ManageServerlessIndexesApi extends runtime.BaseAPI { + + /** + * This operation deploys a Pinecone index. This is where you specify the measure of similarity, the dimension of vectors to be stored in the index, which cloud provider you would like to deploy with, and more. + */ + async createIndexRaw(requestParameters: CreateIndexOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (requestParameters.createIndexRequest === null || requestParameters.createIndexRequest === undefined) { + throw new runtime.RequiredError('createIndexRequest','Required parameter requestParameters.createIndexRequest was null or undefined when calling createIndex.'); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Api-Key"] = this.configuration.apiKey("Api-Key"); // ApiKeyAuth authentication + } + + const response = await this.request({ + path: `/indexes`, + method: 'POST', + headers: headerParameters, + query: queryParameters, + body: CreateIndexRequestToJSON(requestParameters.createIndexRequest), + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => IndexModelFromJSON(jsonValue)); + } + + /** + * This operation deploys a Pinecone index. This is where you specify the measure of similarity, the dimension of vectors to be stored in the index, which cloud provider you would like to deploy with, and more. + */ + async createIndex(requestParameters: CreateIndexOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.createIndexRaw(requestParameters, initOverrides); + return await response.value(); + } + + /** + * This operation deletes an existing index. + */ + async deleteIndexRaw(requestParameters: DeleteIndexRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (requestParameters.indexName === null || requestParameters.indexName === undefined) { + throw new runtime.RequiredError('indexName','Required parameter requestParameters.indexName was null or undefined when calling deleteIndex.'); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Api-Key"] = this.configuration.apiKey("Api-Key"); // ApiKeyAuth authentication + } + + const response = await this.request({ + path: `/indexes/{index_name}`.replace(`{${"index_name"}}`, encodeURIComponent(String(requestParameters.indexName))), + method: 'DELETE', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.VoidApiResponse(response); + } + + /** + * This operation deletes an existing index. + */ + async deleteIndex(requestParameters: DeleteIndexRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + await this.deleteIndexRaw(requestParameters, initOverrides); + } + + /** + * Get a description of an index. + */ + async describeIndexRaw(requestParameters: DescribeIndexRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (requestParameters.indexName === null || requestParameters.indexName === undefined) { + throw new runtime.RequiredError('indexName','Required parameter requestParameters.indexName was null or undefined when calling describeIndex.'); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Api-Key"] = this.configuration.apiKey("Api-Key"); // ApiKeyAuth authentication + } + + const response = await this.request({ + path: `/indexes/{index_name}`.replace(`{${"index_name"}}`, encodeURIComponent(String(requestParameters.indexName))), + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => IndexModelFromJSON(jsonValue)); + } + + /** + * Get a description of an index. + */ + async describeIndex(requestParameters: DescribeIndexRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.describeIndexRaw(requestParameters, initOverrides); + return await response.value(); + } + + /** + * This operation returns a list of your Pinecone indexes. + */ + async listIndexesRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["Api-Key"] = this.configuration.apiKey("Api-Key"); // ApiKeyAuth authentication + } + + const response = await this.request({ + path: `/indexes`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => IndexListFromJSON(jsonValue)); + } + + /** + * This operation returns a list of your Pinecone indexes. + */ + async listIndexes(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.listIndexesRaw(initOverrides); + return await response.value(); + } + +} diff --git a/src/pinecone-generated-ts-fetch/apis/VectorOperationsApi.ts b/src/pinecone-generated-ts-fetch/apis/VectorOperationsApi.ts index 3ab03bb2..8741af46 100644 --- a/src/pinecone-generated-ts-fetch/apis/VectorOperationsApi.ts +++ b/src/pinecone-generated-ts-fetch/apis/VectorOperationsApi.ts @@ -1,11 +1,11 @@ /* tslint:disable */ /* eslint-disable */ /** - * Pinecone API - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. * - * The version of the OpenAPI document: version not set - * Contact: support@pinecone.io + * The version of the OpenAPI document: 1.0 + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech diff --git a/src/pinecone-generated-ts-fetch/apis/index.ts b/src/pinecone-generated-ts-fetch/apis/index.ts index b96ab834..7ded51fb 100644 --- a/src/pinecone-generated-ts-fetch/apis/index.ts +++ b/src/pinecone-generated-ts-fetch/apis/index.ts @@ -1,4 +1,8 @@ /* tslint:disable */ /* eslint-disable */ -export * from './IndexOperationsApi'; +import { CreateIndexOperationRequest, DeleteIndexRequest, DescribeIndexRequest } from './ManagePodIndexesApi'; + +export * from './ManagePodIndexesApi'; +export * from './ManageServerlessIndexesApi'; +export { CreateIndexOperationRequest, DeleteIndexRequest, DescribeIndexRequest }; export * from './VectorOperationsApi'; diff --git a/src/pinecone-generated-ts-fetch/models/ApproximatedConfig.ts b/src/pinecone-generated-ts-fetch/models/ApproximatedConfig.ts deleted file mode 100644 index c535837a..00000000 --- a/src/pinecone-generated-ts-fetch/models/ApproximatedConfig.ts +++ /dev/null @@ -1,73 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * Pinecone API - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: version not set - * Contact: support@pinecone.io - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import { exists, mapValues } from '../runtime'; -/** - * - * @export - * @interface ApproximatedConfig - */ -export interface ApproximatedConfig { - /** - * - * @type {number} - * @memberof ApproximatedConfig - */ - kBits?: number; - /** - * - * @type {boolean} - * @memberof ApproximatedConfig - */ - hybrid?: boolean; -} - -/** - * Check if a given object implements the ApproximatedConfig interface. - */ -export function instanceOfApproximatedConfig(value: object): boolean { - let isInstance = true; - - return isInstance; -} - -export function ApproximatedConfigFromJSON(json: any): ApproximatedConfig { - return ApproximatedConfigFromJSONTyped(json, false); -} - -export function ApproximatedConfigFromJSONTyped(json: any, ignoreDiscriminator: boolean): ApproximatedConfig { - if ((json === undefined) || (json === null)) { - return json; - } - return { - - 'kBits': !exists(json, 'k_bits') ? undefined : json['k_bits'], - 'hybrid': !exists(json, 'hybrid') ? undefined : json['hybrid'], - }; -} - -export function ApproximatedConfigToJSON(value?: ApproximatedConfig | null): any { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; - } - return { - - 'k_bits': value.kBits, - 'hybrid': value.hybrid, - }; -} - diff --git a/src/pinecone-generated-ts-fetch/models/AwsRegions.ts b/src/pinecone-generated-ts-fetch/models/AwsRegions.ts new file mode 100644 index 00000000..4b223c02 --- /dev/null +++ b/src/pinecone-generated-ts-fetch/models/AwsRegions.ts @@ -0,0 +1,39 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +/** + * Regions available with the AWS cloud provider + * @export + */ +export const AwsRegions = { + East1: 'us-east-1', + West1: 'us-west-1', + West2: 'us-west-2' +} as const; +export type AwsRegions = typeof AwsRegions[keyof typeof AwsRegions]; + + +export function AwsRegionsFromJSON(json: any): AwsRegions { + return AwsRegionsFromJSONTyped(json, false); +} + +export function AwsRegionsFromJSONTyped(json: any, ignoreDiscriminator: boolean): AwsRegions { + return json as AwsRegions; +} + +export function AwsRegionsToJSON(value?: AwsRegions | null): any { + return value as any; +} + diff --git a/src/pinecone-generated-ts-fetch/models/CollectionList.ts b/src/pinecone-generated-ts-fetch/models/CollectionList.ts new file mode 100644 index 00000000..15e2773f --- /dev/null +++ b/src/pinecone-generated-ts-fetch/models/CollectionList.ts @@ -0,0 +1,72 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +import type { CollectionModel } from './CollectionModel'; +import { + CollectionModelFromJSON, + CollectionModelFromJSONTyped, + CollectionModelToJSON, +} from './CollectionModel'; + +/** + * The list of collections that exist in the project. + * @export + * @interface CollectionList + */ +export interface CollectionList { + /** + * + * @type {Array} + * @memberof CollectionList + */ + collections?: Array; +} + +/** + * Check if a given object implements the CollectionList interface. + */ +export function instanceOfCollectionList(value: object): boolean { + let isInstance = true; + + return isInstance; +} + +export function CollectionListFromJSON(json: any): CollectionList { + return CollectionListFromJSONTyped(json, false); +} + +export function CollectionListFromJSONTyped(json: any, ignoreDiscriminator: boolean): CollectionList { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'collections': !exists(json, 'collections') ? undefined : ((json['collections'] as Array).map(CollectionModelFromJSON)), + }; +} + +export function CollectionListToJSON(value?: CollectionList | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'collections': value.collections === undefined ? undefined : ((value.collections as Array).map(CollectionModelToJSON)), + }; +} + diff --git a/src/pinecone-generated-ts-fetch/models/CollectionMeta.ts b/src/pinecone-generated-ts-fetch/models/CollectionMeta.ts deleted file mode 100644 index 99d6bd2f..00000000 --- a/src/pinecone-generated-ts-fetch/models/CollectionMeta.ts +++ /dev/null @@ -1,102 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * Pinecone API - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: version not set - * Contact: support@pinecone.io - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import { exists, mapValues } from '../runtime'; -/** - * - * @export - * @interface CollectionMeta - */ -export interface CollectionMeta { - /** - * - * @type {string} - * @memberof CollectionMeta - */ - name: string; - /** - * The size of the collection in bytes. - * @type {number} - * @memberof CollectionMeta - */ - size: number; - /** - * The status of the collection. - * @type {string} - * @memberof CollectionMeta - */ - status: string; - /** - * The dimension of the records stored in the collection - * @type {number} - * @memberof CollectionMeta - */ - dimension: number; - /** - * The number of records stored in the collection - * @type {number} - * @memberof CollectionMeta - */ - vectorCount: number; -} - -/** - * Check if a given object implements the CollectionMeta interface. - */ -export function instanceOfCollectionMeta(value: object): boolean { - let isInstance = true; - isInstance = isInstance && "name" in value; - isInstance = isInstance && "size" in value; - isInstance = isInstance && "status" in value; - isInstance = isInstance && "dimension" in value; - isInstance = isInstance && "vectorCount" in value; - - return isInstance; -} - -export function CollectionMetaFromJSON(json: any): CollectionMeta { - return CollectionMetaFromJSONTyped(json, false); -} - -export function CollectionMetaFromJSONTyped(json: any, ignoreDiscriminator: boolean): CollectionMeta { - if ((json === undefined) || (json === null)) { - return json; - } - return { - - 'name': json['name'], - 'size': json['size'], - 'status': json['status'], - 'dimension': json['dimension'], - 'vectorCount': json['vector_count'], - }; -} - -export function CollectionMetaToJSON(value?: CollectionMeta | null): any { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; - } - return { - - 'name': value.name, - 'size': value.size, - 'status': value.status, - 'dimension': value.dimension, - 'vector_count': value.vectorCount, - }; -} - diff --git a/src/pinecone-generated-ts-fetch/models/CollectionModel.ts b/src/pinecone-generated-ts-fetch/models/CollectionModel.ts new file mode 100644 index 00000000..59374b7a --- /dev/null +++ b/src/pinecone-generated-ts-fetch/models/CollectionModel.ts @@ -0,0 +1,122 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +/** + * The CollectionModel describes the configuration and status of a Pinecone collection. + * @export + * @interface CollectionModel + */ +export interface CollectionModel { + /** + * + * @type {string} + * @memberof CollectionModel + */ + name: string; + /** + * The size of the collection in bytes. + * @type {number} + * @memberof CollectionModel + */ + size: number; + /** + * The status of the collection. + * @type {string} + * @memberof CollectionModel + */ + status: CollectionModelStatusEnum; + /** + * The dimension of the vectors stored in each record held in the collection + * @type {number} + * @memberof CollectionModel + */ + dimension: number; + /** + * The number of records stored in the collection + * @type {number} + * @memberof CollectionModel + */ + recordCount: number; + /** + * The environment where the collection is hosted. + * @type {string} + * @memberof CollectionModel + */ + environment?: string; +} + + +/** + * @export + */ +export const CollectionModelStatusEnum = { + Initializing: 'Initializing', + Ready: 'Ready', + Terminating: 'Terminating' +} as const; +export type CollectionModelStatusEnum = typeof CollectionModelStatusEnum[keyof typeof CollectionModelStatusEnum]; + + +/** + * Check if a given object implements the CollectionModel interface. + */ +export function instanceOfCollectionModel(value: object): boolean { + let isInstance = true; + isInstance = isInstance && "name" in value; + isInstance = isInstance && "size" in value; + isInstance = isInstance && "status" in value; + isInstance = isInstance && "dimension" in value; + isInstance = isInstance && "recordCount" in value; + + return isInstance; +} + +export function CollectionModelFromJSON(json: any): CollectionModel { + return CollectionModelFromJSONTyped(json, false); +} + +export function CollectionModelFromJSONTyped(json: any, ignoreDiscriminator: boolean): CollectionModel { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'name': json['name'], + 'size': json['size'], + 'status': json['status'], + 'dimension': json['dimension'], + 'recordCount': json['record_count'], + 'environment': !exists(json, 'environment') ? undefined : json['environment'], + }; +} + +export function CollectionModelToJSON(value?: CollectionModel | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'name': value.name, + 'size': value.size, + 'status': value.status, + 'dimension': value.dimension, + 'record_count': value.recordCount, + 'environment': value.environment, + }; +} + diff --git a/src/pinecone-generated-ts-fetch/models/ConfigureIndexRequest.ts b/src/pinecone-generated-ts-fetch/models/ConfigureIndexRequest.ts new file mode 100644 index 00000000..374cd8aa --- /dev/null +++ b/src/pinecone-generated-ts-fetch/models/ConfigureIndexRequest.ts @@ -0,0 +1,73 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +import type { ConfigureIndexRequestSpec } from './ConfigureIndexRequestSpec'; +import { + ConfigureIndexRequestSpecFromJSON, + ConfigureIndexRequestSpecFromJSONTyped, + ConfigureIndexRequestSpecToJSON, +} from './ConfigureIndexRequestSpec'; + +/** + * Configuration used to scale an index. + * @export + * @interface ConfigureIndexRequest + */ +export interface ConfigureIndexRequest { + /** + * + * @type {ConfigureIndexRequestSpec} + * @memberof ConfigureIndexRequest + */ + spec: ConfigureIndexRequestSpec; +} + +/** + * Check if a given object implements the ConfigureIndexRequest interface. + */ +export function instanceOfConfigureIndexRequest(value: object): boolean { + let isInstance = true; + isInstance = isInstance && "spec" in value; + + return isInstance; +} + +export function ConfigureIndexRequestFromJSON(json: any): ConfigureIndexRequest { + return ConfigureIndexRequestFromJSONTyped(json, false); +} + +export function ConfigureIndexRequestFromJSONTyped(json: any, ignoreDiscriminator: boolean): ConfigureIndexRequest { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'spec': ConfigureIndexRequestSpecFromJSON(json['spec']), + }; +} + +export function ConfigureIndexRequestToJSON(value?: ConfigureIndexRequest | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'spec': ConfigureIndexRequestSpecToJSON(value.spec), + }; +} + diff --git a/src/pinecone-generated-ts-fetch/models/ConfigureIndexRequestSpec.ts b/src/pinecone-generated-ts-fetch/models/ConfigureIndexRequestSpec.ts new file mode 100644 index 00000000..b951beb3 --- /dev/null +++ b/src/pinecone-generated-ts-fetch/models/ConfigureIndexRequestSpec.ts @@ -0,0 +1,73 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +import type { ConfigureIndexRequestSpecPod } from './ConfigureIndexRequestSpecPod'; +import { + ConfigureIndexRequestSpecPodFromJSON, + ConfigureIndexRequestSpecPodFromJSONTyped, + ConfigureIndexRequestSpecPodToJSON, +} from './ConfigureIndexRequestSpecPod'; + +/** + * + * @export + * @interface ConfigureIndexRequestSpec + */ +export interface ConfigureIndexRequestSpec { + /** + * + * @type {ConfigureIndexRequestSpecPod} + * @memberof ConfigureIndexRequestSpec + */ + pod: ConfigureIndexRequestSpecPod; +} + +/** + * Check if a given object implements the ConfigureIndexRequestSpec interface. + */ +export function instanceOfConfigureIndexRequestSpec(value: object): boolean { + let isInstance = true; + isInstance = isInstance && "pod" in value; + + return isInstance; +} + +export function ConfigureIndexRequestSpecFromJSON(json: any): ConfigureIndexRequestSpec { + return ConfigureIndexRequestSpecFromJSONTyped(json, false); +} + +export function ConfigureIndexRequestSpecFromJSONTyped(json: any, ignoreDiscriminator: boolean): ConfigureIndexRequestSpec { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'pod': ConfigureIndexRequestSpecPodFromJSON(json['pod']), + }; +} + +export function ConfigureIndexRequestSpecToJSON(value?: ConfigureIndexRequestSpec | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'pod': ConfigureIndexRequestSpecPodToJSON(value.pod), + }; +} + diff --git a/src/pinecone-generated-ts-fetch/models/ConfigureIndexRequestSpecPod.ts b/src/pinecone-generated-ts-fetch/models/ConfigureIndexRequestSpecPod.ts new file mode 100644 index 00000000..87e09859 --- /dev/null +++ b/src/pinecone-generated-ts-fetch/models/ConfigureIndexRequestSpecPod.ts @@ -0,0 +1,80 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +import type { PodSpecPodType } from './PodSpecPodType'; +import { + PodSpecPodTypeFromJSON, + PodSpecPodTypeFromJSONTyped, + PodSpecPodTypeToJSON, +} from './PodSpecPodType'; + +/** + * + * @export + * @interface ConfigureIndexRequestSpecPod + */ +export interface ConfigureIndexRequestSpecPod { + /** + * The number of replicas. Replicas duplicate your index. They provide higher availability and throughput. Replicas can be scaled up or down as your needs change. + * @type {number} + * @memberof ConfigureIndexRequestSpecPod + */ + replicas?: number; + /** + * + * @type {PodSpecPodType} + * @memberof ConfigureIndexRequestSpecPod + */ + podType?: PodSpecPodType; +} + +/** + * Check if a given object implements the ConfigureIndexRequestSpecPod interface. + */ +export function instanceOfConfigureIndexRequestSpecPod(value: object): boolean { + let isInstance = true; + + return isInstance; +} + +export function ConfigureIndexRequestSpecPodFromJSON(json: any): ConfigureIndexRequestSpecPod { + return ConfigureIndexRequestSpecPodFromJSONTyped(json, false); +} + +export function ConfigureIndexRequestSpecPodFromJSONTyped(json: any, ignoreDiscriminator: boolean): ConfigureIndexRequestSpecPod { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'replicas': !exists(json, 'replicas') ? undefined : json['replicas'], + 'podType': !exists(json, 'pod_type') ? undefined : PodSpecPodTypeFromJSON(json['pod_type']), + }; +} + +export function ConfigureIndexRequestSpecPodToJSON(value?: ConfigureIndexRequestSpecPod | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'replicas': value.replicas, + 'pod_type': PodSpecPodTypeToJSON(value.podType), + }; +} + diff --git a/src/pinecone-generated-ts-fetch/models/CreateCollectionRequest.ts b/src/pinecone-generated-ts-fetch/models/CreateCollectionRequest.ts index 542fc199..15df4182 100644 --- a/src/pinecone-generated-ts-fetch/models/CreateCollectionRequest.ts +++ b/src/pinecone-generated-ts-fetch/models/CreateCollectionRequest.ts @@ -1,11 +1,11 @@ /* tslint:disable */ /* eslint-disable */ /** - * Pinecone API - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. * - * The version of the OpenAPI document: version not set - * Contact: support@pinecone.io + * The version of the OpenAPI document: 1.0 + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech @@ -14,7 +14,7 @@ import { exists, mapValues } from '../runtime'; /** - * + * The configuration needed to create a Pinecone collection. * @export * @interface CreateCollectionRequest */ diff --git a/src/pinecone-generated-ts-fetch/models/CreateIndexRequest.ts b/src/pinecone-generated-ts-fetch/models/CreateIndexRequest.ts new file mode 100644 index 00000000..9d3691dc --- /dev/null +++ b/src/pinecone-generated-ts-fetch/models/CreateIndexRequest.ts @@ -0,0 +1,106 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +import type { CreateIndexRequestSpec } from './CreateIndexRequestSpec'; +import { + CreateIndexRequestSpecFromJSON, + CreateIndexRequestSpecFromJSONTyped, + CreateIndexRequestSpecToJSON, +} from './CreateIndexRequestSpec'; +import type { IndexMetric } from './IndexMetric'; +import { + IndexMetricFromJSON, + IndexMetricFromJSONTyped, + IndexMetricToJSON, +} from './IndexMetric'; + +/** + * The configuration needed to create a Pinecone index. + * @export + * @interface CreateIndexRequest + */ +export interface CreateIndexRequest { + /** + * The name of the index. The maximum length is 45 characters. It may contain lowercase alphanumeric characters or hyphens, and must not begin or end with a hyphen. + * @type {string} + * @memberof CreateIndexRequest + */ + name: string; + /** + * The dimensions of the vectors to be inserted in the index + * @type {number} + * @memberof CreateIndexRequest + */ + dimension: number; + /** + * + * @type {IndexMetric} + * @memberof CreateIndexRequest + */ + metric: IndexMetric; + /** + * + * @type {CreateIndexRequestSpec} + * @memberof CreateIndexRequest + */ + spec: CreateIndexRequestSpec | null; +} + +/** + * Check if a given object implements the CreateIndexRequest interface. + */ +export function instanceOfCreateIndexRequest(value: object): boolean { + let isInstance = true; + isInstance = isInstance && "name" in value; + isInstance = isInstance && "dimension" in value; + isInstance = isInstance && "metric" in value; + isInstance = isInstance && "spec" in value; + + return isInstance; +} + +export function CreateIndexRequestFromJSON(json: any): CreateIndexRequest { + return CreateIndexRequestFromJSONTyped(json, false); +} + +export function CreateIndexRequestFromJSONTyped(json: any, ignoreDiscriminator: boolean): CreateIndexRequest { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'name': json['name'], + 'dimension': json['dimension'], + 'metric': IndexMetricFromJSON(json['metric']), + 'spec': CreateIndexRequestSpecFromJSON(json['spec']), + }; +} + +export function CreateIndexRequestToJSON(value?: CreateIndexRequest | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'name': value.name, + 'dimension': value.dimension, + 'metric': IndexMetricToJSON(value.metric), + 'spec': CreateIndexRequestSpecToJSON(value.spec), + }; +} + diff --git a/src/pinecone-generated-ts-fetch/models/CreateIndexRequestSpec.ts b/src/pinecone-generated-ts-fetch/models/CreateIndexRequestSpec.ts new file mode 100644 index 00000000..1fd5f7e8 --- /dev/null +++ b/src/pinecone-generated-ts-fetch/models/CreateIndexRequestSpec.ts @@ -0,0 +1,86 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +import type { PodSpec } from './PodSpec'; +import { + PodSpecFromJSON, + PodSpecFromJSONTyped, + PodSpecToJSON, +} from './PodSpec'; +import type { ServerlessSpec } from './ServerlessSpec'; +import { + ServerlessSpecFromJSON, + ServerlessSpecFromJSONTyped, + ServerlessSpecToJSON, +} from './ServerlessSpec'; + +/** + * Spec objects describe how the index should be deployed + * @export + * @interface CreateIndexRequestSpec + */ +export interface CreateIndexRequestSpec { + /** + * + * @type {ServerlessSpec} + * @memberof CreateIndexRequestSpec + */ + serverless?: ServerlessSpec; + /** + * + * @type {PodSpec} + * @memberof CreateIndexRequestSpec + */ + pod?: PodSpec; +} + +/** + * Check if a given object implements the CreateIndexRequestSpec interface. + */ +export function instanceOfCreateIndexRequestSpec(value: object): boolean { + let isInstance = true; + + return isInstance; +} + +export function CreateIndexRequestSpecFromJSON(json: any): CreateIndexRequestSpec { + return CreateIndexRequestSpecFromJSONTyped(json, false); +} + +export function CreateIndexRequestSpecFromJSONTyped(json: any, ignoreDiscriminator: boolean): CreateIndexRequestSpec { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'serverless': !exists(json, 'serverless') ? undefined : ServerlessSpecFromJSON(json['serverless']), + 'pod': !exists(json, 'pod') ? undefined : PodSpecFromJSON(json['pod']), + }; +} + +export function CreateIndexRequestSpecToJSON(value?: CreateIndexRequestSpec | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'serverless': ServerlessSpecToJSON(value.serverless), + 'pod': PodSpecToJSON(value.pod), + }; +} + diff --git a/src/pinecone-generated-ts-fetch/models/CreateRequest.ts b/src/pinecone-generated-ts-fetch/models/CreateRequest.ts deleted file mode 100644 index c178b7fa..00000000 --- a/src/pinecone-generated-ts-fetch/models/CreateRequest.ts +++ /dev/null @@ -1,206 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * Pinecone API - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: version not set - * Contact: support@pinecone.io - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import { exists, mapValues } from '../runtime'; -import type { CreateRequestIndexConfig } from './CreateRequestIndexConfig'; -import { - CreateRequestIndexConfigFromJSON, - CreateRequestIndexConfigFromJSONTyped, - CreateRequestIndexConfigToJSON, -} from './CreateRequestIndexConfig'; - -/** - * - * @export - * @interface CreateRequest - */ -export interface CreateRequest { - /** - * The name of the index to be created. The maximum length is 45 characters. - * @type {string} - * @memberof CreateRequest - */ - name: string; - /** - * The dimensions of the vectors to be inserted in the index - * @type {number} - * @memberof CreateRequest - */ - dimension: number; - /** - * The region where you would like your index to be created - * @type {string} - * @memberof CreateRequest - */ - region: string; - /** - * The public cloud where you would like your index hosted - * @type {string} - * @memberof CreateRequest - */ - cloud: CreateRequestCloudEnum; - /** - * The environment where you would like your index to be created - * @type {string} - * @memberof CreateRequest - */ - environment?: string; - /** - * The capacity mode for the index. - * @type {string} - * @memberof CreateRequest - */ - capacityMode: string; - /** - * The type of vector index. Pinecone supports 'approximated'. - * @type {string} - * @memberof CreateRequest - * @deprecated - */ - indexType?: string; - /** - * The distance metric to be used for similarity search. You can use 'euclidean', 'cosine', or 'dotproduct'. - * @type {string} - * @memberof CreateRequest - */ - metric?: string; - /** - * The number of pods for the index to use,including replicas. - * @type {number} - * @memberof CreateRequest - */ - pods?: number; - /** - * The number of replicas. Replicas duplicate your index. They provide higher availability and throughput. - * @type {number} - * @memberof CreateRequest - */ - replicas?: number; - /** - * The number of shards to be used in the index. - * @type {number} - * @memberof CreateRequest - */ - shards?: number; - /** - * The type of pod to use. One of `s1`, `p1`, or `p2` appended with `.` and one of `x1`, `x2`, `x4`, or `x8`. - * @type {string} - * @memberof CreateRequest - */ - podType?: string; - /** - * - * @type {CreateRequestIndexConfig} - * @memberof CreateRequest - * @deprecated - */ - indexConfig?: CreateRequestIndexConfig; - /** - * Configuration for the behavior of Pinecone's internal metadata index. By default, all metadata is indexed; when `metadata_config` is present, only specified metadata fields are indexed. To specify metadata fields to index, provide a JSON object of the following form: - * ``` - * {"indexed": ["example_metadata_field"]} - * ``` - * @type {object} - * @memberof CreateRequest - */ - metadataConfig?: object | null; - /** - * The name of the collection to create an index from - * @type {string} - * @memberof CreateRequest - */ - sourceCollection?: string; -} - - -/** - * @export - */ -export const CreateRequestCloudEnum = { - Gcp: 'gcp', - Aws: 'aws', - Azure: 'azure' -} as const; -export type CreateRequestCloudEnum = typeof CreateRequestCloudEnum[keyof typeof CreateRequestCloudEnum]; - - -/** - * Check if a given object implements the CreateRequest interface. - */ -export function instanceOfCreateRequest(value: object): boolean { - let isInstance = true; - isInstance = isInstance && "name" in value; - isInstance = isInstance && "dimension" in value; - isInstance = isInstance && "region" in value; - isInstance = isInstance && "cloud" in value; - isInstance = isInstance && "capacityMode" in value; - - return isInstance; -} - -export function CreateRequestFromJSON(json: any): CreateRequest { - return CreateRequestFromJSONTyped(json, false); -} - -export function CreateRequestFromJSONTyped(json: any, ignoreDiscriminator: boolean): CreateRequest { - if ((json === undefined) || (json === null)) { - return json; - } - return { - - 'name': json['name'], - 'dimension': json['dimension'], - 'region': json['region'], - 'cloud': json['cloud'], - 'environment': !exists(json, 'environment') ? undefined : json['environment'], - 'capacityMode': json['capacity_mode'], - 'indexType': !exists(json, 'index_type') ? undefined : json['index_type'], - 'metric': !exists(json, 'metric') ? undefined : json['metric'], - 'pods': !exists(json, 'pods') ? undefined : json['pods'], - 'replicas': !exists(json, 'replicas') ? undefined : json['replicas'], - 'shards': !exists(json, 'shards') ? undefined : json['shards'], - 'podType': !exists(json, 'pod_type') ? undefined : json['pod_type'], - 'indexConfig': !exists(json, 'index_config') ? undefined : CreateRequestIndexConfigFromJSON(json['index_config']), - 'metadataConfig': !exists(json, 'metadata_config') ? undefined : json['metadata_config'], - 'sourceCollection': !exists(json, 'source_collection') ? undefined : json['source_collection'], - }; -} - -export function CreateRequestToJSON(value?: CreateRequest | null): any { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; - } - return { - - 'name': value.name, - 'dimension': value.dimension, - 'region': value.region, - 'cloud': value.cloud, - 'environment': value.environment, - 'capacity_mode': value.capacityMode, - 'index_type': value.indexType, - 'metric': value.metric, - 'pods': value.pods, - 'replicas': value.replicas, - 'shards': value.shards, - 'pod_type': value.podType, - 'index_config': CreateRequestIndexConfigToJSON(value.indexConfig), - 'metadata_config': value.metadataConfig, - 'source_collection': value.sourceCollection, - }; -} - diff --git a/src/pinecone-generated-ts-fetch/models/CreateRequestIndexConfig.ts b/src/pinecone-generated-ts-fetch/models/CreateRequestIndexConfig.ts deleted file mode 100644 index c9909019..00000000 --- a/src/pinecone-generated-ts-fetch/models/CreateRequestIndexConfig.ts +++ /dev/null @@ -1,55 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * Pinecone API - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: version not set - * Contact: support@pinecone.io - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import { - ApproximatedConfig, - instanceOfApproximatedConfig, - ApproximatedConfigFromJSON, - ApproximatedConfigFromJSONTyped, - ApproximatedConfigToJSON, -} from './ApproximatedConfig'; - -/** - * @type CreateRequestIndexConfig - * - * @export - */ -export type CreateRequestIndexConfig = ApproximatedConfig; - -export function CreateRequestIndexConfigFromJSON(json: any): CreateRequestIndexConfig { - return CreateRequestIndexConfigFromJSONTyped(json, false); -} - -export function CreateRequestIndexConfigFromJSONTyped(json: any, ignoreDiscriminator: boolean): CreateRequestIndexConfig { - if ((json === undefined) || (json === null)) { - return json; - } - return { ...ApproximatedConfigFromJSONTyped(json, true) }; -} - -export function CreateRequestIndexConfigToJSON(value?: CreateRequestIndexConfig | null): any { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; - } - - if (instanceOfApproximatedConfig(value)) { - return ApproximatedConfigToJSON(value as ApproximatedConfig); - } - - return {}; -} - diff --git a/src/pinecone-generated-ts-fetch/models/DeleteRequest.ts b/src/pinecone-generated-ts-fetch/models/DeleteRequest.ts index 41603479..c56e805e 100644 --- a/src/pinecone-generated-ts-fetch/models/DeleteRequest.ts +++ b/src/pinecone-generated-ts-fetch/models/DeleteRequest.ts @@ -1,11 +1,11 @@ /* tslint:disable */ /* eslint-disable */ /** - * Pinecone API - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. * - * The version of the OpenAPI document: version not set - * Contact: support@pinecone.io + * The version of the OpenAPI document: 1.0 + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech diff --git a/src/pinecone-generated-ts-fetch/models/DescribeIndexStatsRequest.ts b/src/pinecone-generated-ts-fetch/models/DescribeIndexStatsRequest.ts index 53888a01..f181211f 100644 --- a/src/pinecone-generated-ts-fetch/models/DescribeIndexStatsRequest.ts +++ b/src/pinecone-generated-ts-fetch/models/DescribeIndexStatsRequest.ts @@ -1,11 +1,11 @@ /* tslint:disable */ /* eslint-disable */ /** - * Pinecone API - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. * - * The version of the OpenAPI document: version not set - * Contact: support@pinecone.io + * The version of the OpenAPI document: 1.0 + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech diff --git a/src/pinecone-generated-ts-fetch/models/DescribeIndexStatsResponse.ts b/src/pinecone-generated-ts-fetch/models/DescribeIndexStatsResponse.ts index 6d83e6bf..cb3aaa12 100644 --- a/src/pinecone-generated-ts-fetch/models/DescribeIndexStatsResponse.ts +++ b/src/pinecone-generated-ts-fetch/models/DescribeIndexStatsResponse.ts @@ -1,11 +1,11 @@ /* tslint:disable */ /* eslint-disable */ /** - * Pinecone API - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. * - * The version of the OpenAPI document: version not set - * Contact: support@pinecone.io + * The version of the OpenAPI document: 1.0 + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech diff --git a/src/pinecone-generated-ts-fetch/models/ErrorResponse.ts b/src/pinecone-generated-ts-fetch/models/ErrorResponse.ts new file mode 100644 index 00000000..106c9022 --- /dev/null +++ b/src/pinecone-generated-ts-fetch/models/ErrorResponse.ts @@ -0,0 +1,82 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +import type { ErrorResponseError } from './ErrorResponseError'; +import { + ErrorResponseErrorFromJSON, + ErrorResponseErrorFromJSONTyped, + ErrorResponseErrorToJSON, +} from './ErrorResponseError'; + +/** + * The response shape used for all error responses + * @export + * @interface ErrorResponse + */ +export interface ErrorResponse { + /** + * The HTTP status code of the error + * @type {number} + * @memberof ErrorResponse + */ + status: number; + /** + * + * @type {ErrorResponseError} + * @memberof ErrorResponse + */ + error: ErrorResponseError; +} + +/** + * Check if a given object implements the ErrorResponse interface. + */ +export function instanceOfErrorResponse(value: object): boolean { + let isInstance = true; + isInstance = isInstance && "status" in value; + isInstance = isInstance && "error" in value; + + return isInstance; +} + +export function ErrorResponseFromJSON(json: any): ErrorResponse { + return ErrorResponseFromJSONTyped(json, false); +} + +export function ErrorResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): ErrorResponse { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'status': json['status'], + 'error': ErrorResponseErrorFromJSON(json['error']), + }; +} + +export function ErrorResponseToJSON(value?: ErrorResponse | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'status': value.status, + 'error': ErrorResponseErrorToJSON(value.error), + }; +} + diff --git a/src/pinecone-generated-ts-fetch/models/ErrorResponseError.ts b/src/pinecone-generated-ts-fetch/models/ErrorResponseError.ts new file mode 100644 index 00000000..ad7432f5 --- /dev/null +++ b/src/pinecone-generated-ts-fetch/models/ErrorResponseError.ts @@ -0,0 +1,110 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +/** + * Detailed information about the error that occurred + * @export + * @interface ErrorResponseError + */ +export interface ErrorResponseError { + /** + * + * @type {string} + * @memberof ErrorResponseError + */ + code: ErrorResponseErrorCodeEnum; + /** + * + * @type {string} + * @memberof ErrorResponseError + */ + message: string; + /** + * Additional information about the error. This field is not guaranteed to be present. + * @type {object} + * @memberof ErrorResponseError + */ + details?: object; +} + + +/** + * @export + */ +export const ErrorResponseErrorCodeEnum = { + QuotaExceeded: 'QUOTA_EXCEEDED', + BadParams: 'BAD_PARAMS', + Cancelled: 'CANCELLED', + Unknown: 'UNKNOWN', + InvalidArgument: 'INVALID_ARGUMENT', + DeadlineExceeded: 'DEADLINE_EXCEEDED', + NotFound: 'NOT_FOUND', + AlreadyExists: 'ALREADY_EXISTS', + PermissionDenied: 'PERMISSION_DENIED', + Unauthenticated: 'UNAUTHENTICATED', + ResourceExhausted: 'RESOURCE_EXHAUSTED', + FailedPrecondition: 'FAILED_PRECONDITION', + Aborted: 'ABORTED', + OutOfRange: 'OUT_OF_RANGE', + Unimplemented: 'UNIMPLEMENTED', + Internal: 'INTERNAL', + Unavailable: 'UNAVAILABLE', + DataLoss: 'DATA_LOSS' +} as const; +export type ErrorResponseErrorCodeEnum = typeof ErrorResponseErrorCodeEnum[keyof typeof ErrorResponseErrorCodeEnum]; + + +/** + * Check if a given object implements the ErrorResponseError interface. + */ +export function instanceOfErrorResponseError(value: object): boolean { + let isInstance = true; + isInstance = isInstance && "code" in value; + isInstance = isInstance && "message" in value; + + return isInstance; +} + +export function ErrorResponseErrorFromJSON(json: any): ErrorResponseError { + return ErrorResponseErrorFromJSONTyped(json, false); +} + +export function ErrorResponseErrorFromJSONTyped(json: any, ignoreDiscriminator: boolean): ErrorResponseError { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'code': json['code'], + 'message': json['message'], + 'details': !exists(json, 'details') ? undefined : json['details'], + }; +} + +export function ErrorResponseErrorToJSON(value?: ErrorResponseError | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'code': value.code, + 'message': value.message, + 'details': value.details, + }; +} + diff --git a/src/pinecone-generated-ts-fetch/models/FetchResponse.ts b/src/pinecone-generated-ts-fetch/models/FetchResponse.ts index d17e6a1c..5cd95409 100644 --- a/src/pinecone-generated-ts-fetch/models/FetchResponse.ts +++ b/src/pinecone-generated-ts-fetch/models/FetchResponse.ts @@ -1,11 +1,11 @@ /* tslint:disable */ /* eslint-disable */ /** - * Pinecone API - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. * - * The version of the OpenAPI document: version not set - * Contact: support@pinecone.io + * The version of the OpenAPI document: 1.0 + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech diff --git a/src/pinecone-generated-ts-fetch/models/GcpRegions.ts b/src/pinecone-generated-ts-fetch/models/GcpRegions.ts new file mode 100644 index 00000000..f9931ba3 --- /dev/null +++ b/src/pinecone-generated-ts-fetch/models/GcpRegions.ts @@ -0,0 +1,42 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +/** + * Regions available with the GCP cloud provider + * @export + */ +export const GcpRegions = { + UsWest1: 'us-west1', + UsWest2: 'us-west2', + EuWest4: 'eu-west4', + NorthamericaNortheast1: 'northamerica-northeast1', + AsiaNortheast1: 'asia-northeast1', + AsiaSoutheast1C: 'asia-southeast1C' +} as const; +export type GcpRegions = typeof GcpRegions[keyof typeof GcpRegions]; + + +export function GcpRegionsFromJSON(json: any): GcpRegions { + return GcpRegionsFromJSONTyped(json, false); +} + +export function GcpRegionsFromJSONTyped(json: any, ignoreDiscriminator: boolean): GcpRegions { + return json as GcpRegions; +} + +export function GcpRegionsToJSON(value?: GcpRegions | null): any { + return value as any; +} + diff --git a/src/pinecone-generated-ts-fetch/models/HnswConfig.ts b/src/pinecone-generated-ts-fetch/models/HnswConfig.ts deleted file mode 100644 index c6fbfba2..00000000 --- a/src/pinecone-generated-ts-fetch/models/HnswConfig.ts +++ /dev/null @@ -1,89 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * Pinecone API - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: version not set - * Contact: support@pinecone.io - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import { exists, mapValues } from '../runtime'; -/** - * - * @export - * @interface HnswConfig - */ -export interface HnswConfig { - /** - * - * @type {number} - * @memberof HnswConfig - */ - efConstruction?: number; - /** - * - * @type {number} - * @memberof HnswConfig - */ - ef?: number; - /** - * - * @type {number} - * @memberof HnswConfig - */ - m?: number; - /** - * - * @type {number} - * @memberof HnswConfig - */ - maxElements?: number; -} - -/** - * Check if a given object implements the HnswConfig interface. - */ -export function instanceOfHnswConfig(value: object): boolean { - let isInstance = true; - - return isInstance; -} - -export function HnswConfigFromJSON(json: any): HnswConfig { - return HnswConfigFromJSONTyped(json, false); -} - -export function HnswConfigFromJSONTyped(json: any, ignoreDiscriminator: boolean): HnswConfig { - if ((json === undefined) || (json === null)) { - return json; - } - return { - - 'efConstruction': !exists(json, 'ef_construction') ? undefined : json['ef_construction'], - 'ef': !exists(json, 'ef') ? undefined : json['ef'], - 'm': !exists(json, 'M') ? undefined : json['M'], - 'maxElements': !exists(json, 'max_elements') ? undefined : json['max_elements'], - }; -} - -export function HnswConfigToJSON(value?: HnswConfig | null): any { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; - } - return { - - 'ef_construction': value.efConstruction, - 'ef': value.ef, - 'M': value.m, - 'max_elements': value.maxElements, - }; -} - diff --git a/src/pinecone-generated-ts-fetch/models/IndexList.ts b/src/pinecone-generated-ts-fetch/models/IndexList.ts new file mode 100644 index 00000000..cbc0cd60 --- /dev/null +++ b/src/pinecone-generated-ts-fetch/models/IndexList.ts @@ -0,0 +1,72 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +import type { IndexModel } from './IndexModel'; +import { + IndexModelFromJSON, + IndexModelFromJSONTyped, + IndexModelToJSON, +} from './IndexModel'; + +/** + * The list of indexes that exist in the project. + * @export + * @interface IndexList + */ +export interface IndexList { + /** + * + * @type {Array} + * @memberof IndexList + */ + indexes?: Array; +} + +/** + * Check if a given object implements the IndexList interface. + */ +export function instanceOfIndexList(value: object): boolean { + let isInstance = true; + + return isInstance; +} + +export function IndexListFromJSON(json: any): IndexList { + return IndexListFromJSONTyped(json, false); +} + +export function IndexListFromJSONTyped(json: any, ignoreDiscriminator: boolean): IndexList { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'indexes': !exists(json, 'indexes') ? undefined : ((json['indexes'] as Array).map(IndexModelFromJSON)), + }; +} + +export function IndexListToJSON(value?: IndexList | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'indexes': value.indexes === undefined ? undefined : ((value.indexes as Array).map(IndexModelToJSON)), + }; +} + diff --git a/src/pinecone-generated-ts-fetch/models/IndexListMeta.ts b/src/pinecone-generated-ts-fetch/models/IndexListMeta.ts deleted file mode 100644 index 29072839..00000000 --- a/src/pinecone-generated-ts-fetch/models/IndexListMeta.ts +++ /dev/null @@ -1,102 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * Pinecone API - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: version not set - * Contact: support@pinecone.io - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import { exists, mapValues } from '../runtime'; -/** - * - * @export - * @interface IndexListMeta - */ -export interface IndexListMeta { - /** - * - * @type {string} - * @memberof IndexListMeta - */ - name: string; - /** - * - * @type {string} - * @memberof IndexListMeta - */ - metric: string; - /** - * - * @type {number} - * @memberof IndexListMeta - */ - dimension: number; - /** - * - * @type {string} - * @memberof IndexListMeta - */ - capacityMode: string; - /** - * - * @type {string} - * @memberof IndexListMeta - */ - host: string; -} - -/** - * Check if a given object implements the IndexListMeta interface. - */ -export function instanceOfIndexListMeta(value: object): boolean { - let isInstance = true; - isInstance = isInstance && "name" in value; - isInstance = isInstance && "metric" in value; - isInstance = isInstance && "dimension" in value; - isInstance = isInstance && "capacityMode" in value; - isInstance = isInstance && "host" in value; - - return isInstance; -} - -export function IndexListMetaFromJSON(json: any): IndexListMeta { - return IndexListMetaFromJSONTyped(json, false); -} - -export function IndexListMetaFromJSONTyped(json: any, ignoreDiscriminator: boolean): IndexListMeta { - if ((json === undefined) || (json === null)) { - return json; - } - return { - - 'name': json['name'], - 'metric': json['metric'], - 'dimension': json['dimension'], - 'capacityMode': json['capacity_mode'], - 'host': json['host'], - }; -} - -export function IndexListMetaToJSON(value?: IndexListMeta | null): any { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; - } - return { - - 'name': value.name, - 'metric': value.metric, - 'dimension': value.dimension, - 'capacity_mode': value.capacityMode, - 'host': value.host, - }; -} - diff --git a/src/pinecone-generated-ts-fetch/models/IndexMeta.ts b/src/pinecone-generated-ts-fetch/models/IndexMeta.ts deleted file mode 100644 index 31ebf69b..00000000 --- a/src/pinecone-generated-ts-fetch/models/IndexMeta.ts +++ /dev/null @@ -1,88 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * Pinecone API - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: version not set - * Contact: support@pinecone.io - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import { exists, mapValues } from '../runtime'; -import type { IndexMetaDatabase } from './IndexMetaDatabase'; -import { - IndexMetaDatabaseFromJSON, - IndexMetaDatabaseFromJSONTyped, - IndexMetaDatabaseToJSON, -} from './IndexMetaDatabase'; -import type { IndexMetaStatus } from './IndexMetaStatus'; -import { - IndexMetaStatusFromJSON, - IndexMetaStatusFromJSONTyped, - IndexMetaStatusToJSON, -} from './IndexMetaStatus'; - -/** - * - * @export - * @interface IndexMeta - */ -export interface IndexMeta { - /** - * - * @type {IndexMetaDatabase} - * @memberof IndexMeta - */ - database: IndexMetaDatabase; - /** - * - * @type {IndexMetaStatus} - * @memberof IndexMeta - */ - status: IndexMetaStatus; -} - -/** - * Check if a given object implements the IndexMeta interface. - */ -export function instanceOfIndexMeta(value: object): boolean { - let isInstance = true; - isInstance = isInstance && "database" in value; - isInstance = isInstance && "status" in value; - - return isInstance; -} - -export function IndexMetaFromJSON(json: any): IndexMeta { - return IndexMetaFromJSONTyped(json, false); -} - -export function IndexMetaFromJSONTyped(json: any, ignoreDiscriminator: boolean): IndexMeta { - if ((json === undefined) || (json === null)) { - return json; - } - return { - - 'database': IndexMetaDatabaseFromJSON(json['database']), - 'status': IndexMetaStatusFromJSON(json['status']), - }; -} - -export function IndexMetaToJSON(value?: IndexMeta | null): any { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; - } - return { - - 'database': IndexMetaDatabaseToJSON(value.database), - 'status': IndexMetaStatusToJSON(value.status), - }; -} - diff --git a/src/pinecone-generated-ts-fetch/models/IndexMetaDatabase.ts b/src/pinecone-generated-ts-fetch/models/IndexMetaDatabase.ts deleted file mode 100644 index 50c344bf..00000000 --- a/src/pinecone-generated-ts-fetch/models/IndexMetaDatabase.ts +++ /dev/null @@ -1,157 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * Pinecone API - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: version not set - * Contact: support@pinecone.io - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import { exists, mapValues } from '../runtime'; -import type { IndexMetaDatabaseIndexConfig } from './IndexMetaDatabaseIndexConfig'; -import { - IndexMetaDatabaseIndexConfigFromJSON, - IndexMetaDatabaseIndexConfigFromJSONTyped, - IndexMetaDatabaseIndexConfigToJSON, -} from './IndexMetaDatabaseIndexConfig'; - -/** - * - * @export - * @interface IndexMetaDatabase - */ -export interface IndexMetaDatabase { - /** - * - * @type {string} - * @memberof IndexMetaDatabase - */ - name: string; - /** - * - * @type {number} - * @memberof IndexMetaDatabase - */ - dimension: number; - /** - * - * @type {string} - * @memberof IndexMetaDatabase - */ - capacityMode: string; - /** - * - * @type {string} - * @memberof IndexMetaDatabase - * @deprecated - */ - indexType?: string; - /** - * - * @type {string} - * @memberof IndexMetaDatabase - */ - metric: string; - /** - * - * @type {number} - * @memberof IndexMetaDatabase - */ - pods?: number; - /** - * - * @type {number} - * @memberof IndexMetaDatabase - */ - replicas?: number; - /** - * - * @type {number} - * @memberof IndexMetaDatabase - */ - shards?: number; - /** - * - * @type {string} - * @memberof IndexMetaDatabase - */ - podType?: string; - /** - * - * @type {IndexMetaDatabaseIndexConfig} - * @memberof IndexMetaDatabase - */ - indexConfig?: IndexMetaDatabaseIndexConfig; - /** - * - * @type {object} - * @memberof IndexMetaDatabase - */ - metadataConfig?: object; -} - -/** - * Check if a given object implements the IndexMetaDatabase interface. - */ -export function instanceOfIndexMetaDatabase(value: object): boolean { - let isInstance = true; - isInstance = isInstance && "name" in value; - isInstance = isInstance && "dimension" in value; - isInstance = isInstance && "capacityMode" in value; - isInstance = isInstance && "metric" in value; - - return isInstance; -} - -export function IndexMetaDatabaseFromJSON(json: any): IndexMetaDatabase { - return IndexMetaDatabaseFromJSONTyped(json, false); -} - -export function IndexMetaDatabaseFromJSONTyped(json: any, ignoreDiscriminator: boolean): IndexMetaDatabase { - if ((json === undefined) || (json === null)) { - return json; - } - return { - - 'name': json['name'], - 'dimension': json['dimension'], - 'capacityMode': json['capacity_mode'], - 'indexType': !exists(json, 'index_type') ? undefined : json['index_type'], - 'metric': json['metric'], - 'pods': !exists(json, 'pods') ? undefined : json['pods'], - 'replicas': !exists(json, 'replicas') ? undefined : json['replicas'], - 'shards': !exists(json, 'shards') ? undefined : json['shards'], - 'podType': !exists(json, 'pod_type') ? undefined : json['pod_type'], - 'indexConfig': !exists(json, 'index_config') ? undefined : IndexMetaDatabaseIndexConfigFromJSON(json['index_config']), - 'metadataConfig': !exists(json, 'metadata_config') ? undefined : json['metadata_config'], - }; -} - -export function IndexMetaDatabaseToJSON(value?: IndexMetaDatabase | null): any { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; - } - return { - - 'name': value.name, - 'dimension': value.dimension, - 'capacity_mode': value.capacityMode, - 'index_type': value.indexType, - 'metric': value.metric, - 'pods': value.pods, - 'replicas': value.replicas, - 'shards': value.shards, - 'pod_type': value.podType, - 'index_config': IndexMetaDatabaseIndexConfigToJSON(value.indexConfig), - 'metadata_config': value.metadataConfig, - }; -} - diff --git a/src/pinecone-generated-ts-fetch/models/IndexMetaDatabaseIndexConfig.ts b/src/pinecone-generated-ts-fetch/models/IndexMetaDatabaseIndexConfig.ts deleted file mode 100644 index e0ff087b..00000000 --- a/src/pinecone-generated-ts-fetch/models/IndexMetaDatabaseIndexConfig.ts +++ /dev/null @@ -1,55 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * Pinecone API - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: version not set - * Contact: support@pinecone.io - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import { - ApproximatedConfig, - instanceOfApproximatedConfig, - ApproximatedConfigFromJSON, - ApproximatedConfigFromJSONTyped, - ApproximatedConfigToJSON, -} from './ApproximatedConfig'; - -/** - * @type IndexMetaDatabaseIndexConfig - * - * @export - */ -export type IndexMetaDatabaseIndexConfig = ApproximatedConfig; - -export function IndexMetaDatabaseIndexConfigFromJSON(json: any): IndexMetaDatabaseIndexConfig { - return IndexMetaDatabaseIndexConfigFromJSONTyped(json, false); -} - -export function IndexMetaDatabaseIndexConfigFromJSONTyped(json: any, ignoreDiscriminator: boolean): IndexMetaDatabaseIndexConfig { - if ((json === undefined) || (json === null)) { - return json; - } - return { ...ApproximatedConfigFromJSONTyped(json, true) }; -} - -export function IndexMetaDatabaseIndexConfigToJSON(value?: IndexMetaDatabaseIndexConfig | null): any { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; - } - - if (instanceOfApproximatedConfig(value)) { - return ApproximatedConfigToJSON(value as ApproximatedConfig); - } - - return {}; -} - diff --git a/src/pinecone-generated-ts-fetch/models/IndexMetaStatus.ts b/src/pinecone-generated-ts-fetch/models/IndexMetaStatus.ts deleted file mode 100644 index bc80c346..00000000 --- a/src/pinecone-generated-ts-fetch/models/IndexMetaStatus.ts +++ /dev/null @@ -1,110 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * Pinecone API - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: version not set - * Contact: support@pinecone.io - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import { exists, mapValues } from '../runtime'; -/** - * - * @export - * @interface IndexMetaStatus - */ -export interface IndexMetaStatus { - /** - * - * @type {boolean} - * @memberof IndexMetaStatus - */ - ready: boolean; - /** - * - * @type {string} - * @memberof IndexMetaStatus - */ - state: IndexMetaStatusStateEnum; - /** - * - * @type {string} - * @memberof IndexMetaStatus - */ - host: string; - /** - * - * @type {number} - * @memberof IndexMetaStatus - */ - port: number; -} - - -/** - * @export - */ -export const IndexMetaStatusStateEnum = { - Initializing: 'Initializing', - InitializationFailed: 'InitializationFailed', - ScalingUp: 'ScalingUp', - ScalingDown: 'ScalingDown', - ScalingUpPodSize: 'ScalingUpPodSize', - ScalingDownPodSize: 'ScalingDownPodSize', - Terminating: 'Terminating', - Ready: 'Ready' -} as const; -export type IndexMetaStatusStateEnum = typeof IndexMetaStatusStateEnum[keyof typeof IndexMetaStatusStateEnum]; - - -/** - * Check if a given object implements the IndexMetaStatus interface. - */ -export function instanceOfIndexMetaStatus(value: object): boolean { - let isInstance = true; - isInstance = isInstance && "ready" in value; - isInstance = isInstance && "state" in value; - isInstance = isInstance && "host" in value; - isInstance = isInstance && "port" in value; - - return isInstance; -} - -export function IndexMetaStatusFromJSON(json: any): IndexMetaStatus { - return IndexMetaStatusFromJSONTyped(json, false); -} - -export function IndexMetaStatusFromJSONTyped(json: any, ignoreDiscriminator: boolean): IndexMetaStatus { - if ((json === undefined) || (json === null)) { - return json; - } - return { - - 'ready': json['ready'], - 'state': json['state'], - 'host': json['host'], - 'port': json['port'], - }; -} - -export function IndexMetaStatusToJSON(value?: IndexMetaStatus | null): any { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; - } - return { - - 'ready': value.ready, - 'state': value.state, - 'host': value.host, - 'port': value.port, - }; -} - diff --git a/src/pinecone-generated-ts-fetch/models/IndexMetric.ts b/src/pinecone-generated-ts-fetch/models/IndexMetric.ts new file mode 100644 index 00000000..5e91583d --- /dev/null +++ b/src/pinecone-generated-ts-fetch/models/IndexMetric.ts @@ -0,0 +1,39 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +/** + * The distance metric to be used for similarity search. You can use 'euclidean', 'cosine', or 'dotproduct'. + * @export + */ +export const IndexMetric = { + Cosine: 'cosine', + Euclidean: 'euclidean', + Dotproduct: 'dotproduct' +} as const; +export type IndexMetric = typeof IndexMetric[keyof typeof IndexMetric]; + + +export function IndexMetricFromJSON(json: any): IndexMetric { + return IndexMetricFromJSONTyped(json, false); +} + +export function IndexMetricFromJSONTyped(json: any, ignoreDiscriminator: boolean): IndexMetric { + return json as IndexMetric; +} + +export function IndexMetricToJSON(value?: IndexMetric | null): any { + return value as any; +} + diff --git a/src/pinecone-generated-ts-fetch/models/IndexModel.ts b/src/pinecone-generated-ts-fetch/models/IndexModel.ts new file mode 100644 index 00000000..4dd46fa1 --- /dev/null +++ b/src/pinecone-generated-ts-fetch/models/IndexModel.ts @@ -0,0 +1,130 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +import type { IndexMetric } from './IndexMetric'; +import { + IndexMetricFromJSON, + IndexMetricFromJSONTyped, + IndexMetricToJSON, +} from './IndexMetric'; +import type { IndexModelSpec } from './IndexModelSpec'; +import { + IndexModelSpecFromJSON, + IndexModelSpecFromJSONTyped, + IndexModelSpecToJSON, +} from './IndexModelSpec'; +import type { IndexModelStatus } from './IndexModelStatus'; +import { + IndexModelStatusFromJSON, + IndexModelStatusFromJSONTyped, + IndexModelStatusToJSON, +} from './IndexModelStatus'; + +/** + * The IndexModel describes the configuration and deployment status of a Pinecone index. + * @export + * @interface IndexModel + */ +export interface IndexModel { + /** + * The name of the index. The maximum length is 45 characters. It may contain lowercase alphanumeric characters or hyphens, and must not begin or end with a hyphen. + * @type {string} + * @memberof IndexModel + */ + name: string; + /** + * The dimensions of the vectors to be inserted in the index + * @type {number} + * @memberof IndexModel + */ + dimension: number; + /** + * + * @type {IndexMetric} + * @memberof IndexModel + */ + metric: IndexMetric; + /** + * The URL address where the index is hosted. + * @type {string} + * @memberof IndexModel + */ + host: string; + /** + * + * @type {IndexModelSpec} + * @memberof IndexModel + */ + spec: IndexModelSpec; + /** + * + * @type {IndexModelStatus} + * @memberof IndexModel + */ + status: IndexModelStatus; +} + +/** + * Check if a given object implements the IndexModel interface. + */ +export function instanceOfIndexModel(value: object): boolean { + let isInstance = true; + isInstance = isInstance && "name" in value; + isInstance = isInstance && "dimension" in value; + isInstance = isInstance && "metric" in value; + isInstance = isInstance && "host" in value; + isInstance = isInstance && "spec" in value; + isInstance = isInstance && "status" in value; + + return isInstance; +} + +export function IndexModelFromJSON(json: any): IndexModel { + return IndexModelFromJSONTyped(json, false); +} + +export function IndexModelFromJSONTyped(json: any, ignoreDiscriminator: boolean): IndexModel { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'name': json['name'], + 'dimension': json['dimension'], + 'metric': IndexMetricFromJSON(json['metric']), + 'host': json['host'], + 'spec': IndexModelSpecFromJSON(json['spec']), + 'status': IndexModelStatusFromJSON(json['status']), + }; +} + +export function IndexModelToJSON(value?: IndexModel | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'name': value.name, + 'dimension': value.dimension, + 'metric': IndexMetricToJSON(value.metric), + 'host': value.host, + 'spec': IndexModelSpecToJSON(value.spec), + 'status': IndexModelStatusToJSON(value.status), + }; +} + diff --git a/src/pinecone-generated-ts-fetch/models/IndexModelSpec.ts b/src/pinecone-generated-ts-fetch/models/IndexModelSpec.ts new file mode 100644 index 00000000..948373cb --- /dev/null +++ b/src/pinecone-generated-ts-fetch/models/IndexModelSpec.ts @@ -0,0 +1,86 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +import type { PodSpec } from './PodSpec'; +import { + PodSpecFromJSON, + PodSpecFromJSONTyped, + PodSpecToJSON, +} from './PodSpec'; +import type { ServerlessSpec } from './ServerlessSpec'; +import { + ServerlessSpecFromJSON, + ServerlessSpecFromJSONTyped, + ServerlessSpecToJSON, +} from './ServerlessSpec'; + +/** + * + * @export + * @interface IndexModelSpec + */ +export interface IndexModelSpec { + /** + * + * @type {PodSpec} + * @memberof IndexModelSpec + */ + pod?: PodSpec; + /** + * + * @type {ServerlessSpec} + * @memberof IndexModelSpec + */ + serverless?: ServerlessSpec; +} + +/** + * Check if a given object implements the IndexModelSpec interface. + */ +export function instanceOfIndexModelSpec(value: object): boolean { + let isInstance = true; + + return isInstance; +} + +export function IndexModelSpecFromJSON(json: any): IndexModelSpec { + return IndexModelSpecFromJSONTyped(json, false); +} + +export function IndexModelSpecFromJSONTyped(json: any, ignoreDiscriminator: boolean): IndexModelSpec { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'pod': !exists(json, 'pod') ? undefined : PodSpecFromJSON(json['pod']), + 'serverless': !exists(json, 'serverless') ? undefined : ServerlessSpecFromJSON(json['serverless']), + }; +} + +export function IndexModelSpecToJSON(value?: IndexModelSpec | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'pod': PodSpecToJSON(value.pod), + 'serverless': ServerlessSpecToJSON(value.serverless), + }; +} + diff --git a/src/pinecone-generated-ts-fetch/models/IndexModelStatus.ts b/src/pinecone-generated-ts-fetch/models/IndexModelStatus.ts new file mode 100644 index 00000000..10064342 --- /dev/null +++ b/src/pinecone-generated-ts-fetch/models/IndexModelStatus.ts @@ -0,0 +1,92 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +/** + * + * @export + * @interface IndexModelStatus + */ +export interface IndexModelStatus { + /** + * + * @type {boolean} + * @memberof IndexModelStatus + */ + ready: boolean; + /** + * + * @type {string} + * @memberof IndexModelStatus + */ + state: IndexModelStatusStateEnum; +} + + +/** + * @export + */ +export const IndexModelStatusStateEnum = { + Initializing: 'Initializing', + InitializationFailed: 'InitializationFailed', + ScalingUp: 'ScalingUp', + ScalingDown: 'ScalingDown', + ScalingUpPodSize: 'ScalingUpPodSize', + ScalingDownPodSize: 'ScalingDownPodSize', + Terminating: 'Terminating', + Ready: 'Ready' +} as const; +export type IndexModelStatusStateEnum = typeof IndexModelStatusStateEnum[keyof typeof IndexModelStatusStateEnum]; + + +/** + * Check if a given object implements the IndexModelStatus interface. + */ +export function instanceOfIndexModelStatus(value: object): boolean { + let isInstance = true; + isInstance = isInstance && "ready" in value; + isInstance = isInstance && "state" in value; + + return isInstance; +} + +export function IndexModelStatusFromJSON(json: any): IndexModelStatus { + return IndexModelStatusFromJSONTyped(json, false); +} + +export function IndexModelStatusFromJSONTyped(json: any, ignoreDiscriminator: boolean): IndexModelStatus { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'ready': json['ready'], + 'state': json['state'], + }; +} + +export function IndexModelStatusToJSON(value?: IndexModelStatus | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'ready': value.ready, + 'state': value.state, + }; +} + diff --git a/src/pinecone-generated-ts-fetch/models/InlineResponse200.ts b/src/pinecone-generated-ts-fetch/models/InlineResponse200.ts deleted file mode 100644 index 2da0e9ca..00000000 --- a/src/pinecone-generated-ts-fetch/models/InlineResponse200.ts +++ /dev/null @@ -1,64 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * Pinecone API - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: version not set - * Contact: support@pinecone.io - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import { exists, mapValues } from '../runtime'; -import { - IndexMeta, - IndexMetaFromJSON, - IndexMetaFromJSONTyped, - IndexMetaToJSON, -} from './'; - -/** - * - * @export - * @interface InlineResponse200 - */ -export interface InlineResponse200 { - /** - * - * @type {Array} - * @memberof InlineResponse200 - */ - databases?: Array; -} - -export function InlineResponse200FromJSON(json: any): InlineResponse200 { - return InlineResponse200FromJSONTyped(json, false); -} - -export function InlineResponse200FromJSONTyped(json: any, ignoreDiscriminator: boolean): InlineResponse200 { - if ((json === undefined) || (json === null)) { - return json; - } - return { - - 'databases': !exists(json, 'databases') ? undefined : ((json['databases'] as Array).map(IndexMetaFromJSON)), - }; -} - -export function InlineResponse200ToJSON(value?: InlineResponse200 | null): any { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; - } - return { - - 'databases': value.databases === undefined ? undefined : ((value.databases as Array).map(IndexMetaToJSON)), - }; -} - - diff --git a/src/pinecone-generated-ts-fetch/models/ListIndexes200Response.ts b/src/pinecone-generated-ts-fetch/models/ListIndexes200Response.ts deleted file mode 100644 index 93e69113..00000000 --- a/src/pinecone-generated-ts-fetch/models/ListIndexes200Response.ts +++ /dev/null @@ -1,72 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * Pinecone API - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: version not set - * Contact: support@pinecone.io - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import { exists, mapValues } from '../runtime'; -import type { IndexListMeta } from './IndexListMeta'; -import { - IndexListMetaFromJSON, - IndexListMetaFromJSONTyped, - IndexListMetaToJSON, -} from './IndexListMeta'; - -/** - * - * @export - * @interface ListIndexes200Response - */ -export interface ListIndexes200Response { - /** - * - * @type {Array} - * @memberof ListIndexes200Response - */ - databases?: Array; -} - -/** - * Check if a given object implements the ListIndexes200Response interface. - */ -export function instanceOfListIndexes200Response(value: object): boolean { - let isInstance = true; - - return isInstance; -} - -export function ListIndexes200ResponseFromJSON(json: any): ListIndexes200Response { - return ListIndexes200ResponseFromJSONTyped(json, false); -} - -export function ListIndexes200ResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): ListIndexes200Response { - if ((json === undefined) || (json === null)) { - return json; - } - return { - - 'databases': !exists(json, 'databases') ? undefined : ((json['databases'] as Array).map(IndexListMetaFromJSON)), - }; -} - -export function ListIndexes200ResponseToJSON(value?: ListIndexes200Response | null): any { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; - } - return { - - 'databases': value.databases === undefined ? undefined : ((value.databases as Array).map(IndexListMetaToJSON)), - }; -} - diff --git a/src/pinecone-generated-ts-fetch/models/NamespaceSummary.ts b/src/pinecone-generated-ts-fetch/models/NamespaceSummary.ts index fd585941..ea3d623f 100644 --- a/src/pinecone-generated-ts-fetch/models/NamespaceSummary.ts +++ b/src/pinecone-generated-ts-fetch/models/NamespaceSummary.ts @@ -1,11 +1,11 @@ /* tslint:disable */ /* eslint-disable */ /** - * Pinecone API - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. * - * The version of the OpenAPI document: version not set - * Contact: support@pinecone.io + * The version of the OpenAPI document: 1.0 + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech diff --git a/src/pinecone-generated-ts-fetch/models/PatchRequest.ts b/src/pinecone-generated-ts-fetch/models/PatchRequest.ts deleted file mode 100644 index 35684c6f..00000000 --- a/src/pinecone-generated-ts-fetch/models/PatchRequest.ts +++ /dev/null @@ -1,73 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * Pinecone API - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: version not set - * Contact: support@pinecone.io - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import { exists, mapValues } from '../runtime'; -/** - * - * @export - * @interface PatchRequest - */ -export interface PatchRequest { - /** - * The desired number of replicas for the index. - * @type {number} - * @memberof PatchRequest - */ - replicas?: number; - /** - * The new pod type for the index. One of `s1`, `p1`, or `p2` appended with `.` and one of `x1`, `x2`, `x4`, or `x8`. - * @type {string} - * @memberof PatchRequest - */ - podType?: string; -} - -/** - * Check if a given object implements the PatchRequest interface. - */ -export function instanceOfPatchRequest(value: object): boolean { - let isInstance = true; - - return isInstance; -} - -export function PatchRequestFromJSON(json: any): PatchRequest { - return PatchRequestFromJSONTyped(json, false); -} - -export function PatchRequestFromJSONTyped(json: any, ignoreDiscriminator: boolean): PatchRequest { - if ((json === undefined) || (json === null)) { - return json; - } - return { - - 'replicas': !exists(json, 'replicas') ? undefined : json['replicas'], - 'podType': !exists(json, 'pod_type') ? undefined : json['pod_type'], - }; -} - -export function PatchRequestToJSON(value?: PatchRequest | null): any { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; - } - return { - - 'replicas': value.replicas, - 'pod_type': value.podType, - }; -} - diff --git a/src/pinecone-generated-ts-fetch/models/PodSpec.ts b/src/pinecone-generated-ts-fetch/models/PodSpec.ts new file mode 100644 index 00000000..306633d4 --- /dev/null +++ b/src/pinecone-generated-ts-fetch/models/PodSpec.ts @@ -0,0 +1,131 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +import type { PodSpecMetadataConfig } from './PodSpecMetadataConfig'; +import { + PodSpecMetadataConfigFromJSON, + PodSpecMetadataConfigFromJSONTyped, + PodSpecMetadataConfigToJSON, +} from './PodSpecMetadataConfig'; +import type { PodSpecPodType } from './PodSpecPodType'; +import { + PodSpecPodTypeFromJSON, + PodSpecPodTypeFromJSONTyped, + PodSpecPodTypeToJSON, +} from './PodSpecPodType'; + +/** + * Configuration needed to deploy a pod index + * @export + * @interface PodSpec + */ +export interface PodSpec { + /** + * The environment where the index is hosted. + * @type {string} + * @memberof PodSpec + */ + environment: string; + /** + * The number of replicas. Replicas duplicate your index. They provide higher availability and throughput. Replicas can be scaled up or down as your needs change. + * @type {number} + * @memberof PodSpec + */ + replicas: number; + /** + * The number of shards. Shards split your data across multiple pods so you can fit more data into an index. + * @type {number} + * @memberof PodSpec + */ + shards: number; + /** + * + * @type {PodSpecPodType} + * @memberof PodSpec + */ + podType: PodSpecPodType; + /** + * The number of pods to be used in the index. This should be equal to `shards` x `replicas`. + * @type {number} + * @memberof PodSpec + */ + pods: number; + /** + * + * @type {PodSpecMetadataConfig} + * @memberof PodSpec + */ + metadataConfig?: PodSpecMetadataConfig; + /** + * The name of the collection to be used as the source for the index. + * @type {string} + * @memberof PodSpec + */ + sourceCollection?: string; +} + +/** + * Check if a given object implements the PodSpec interface. + */ +export function instanceOfPodSpec(value: object): boolean { + let isInstance = true; + isInstance = isInstance && "environment" in value; + isInstance = isInstance && "replicas" in value; + isInstance = isInstance && "shards" in value; + isInstance = isInstance && "podType" in value; + isInstance = isInstance && "pods" in value; + + return isInstance; +} + +export function PodSpecFromJSON(json: any): PodSpec { + return PodSpecFromJSONTyped(json, false); +} + +export function PodSpecFromJSONTyped(json: any, ignoreDiscriminator: boolean): PodSpec { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'environment': json['environment'], + 'replicas': json['replicas'], + 'shards': json['shards'], + 'podType': PodSpecPodTypeFromJSON(json['pod_type']), + 'pods': json['pods'], + 'metadataConfig': !exists(json, 'metadata_config') ? undefined : PodSpecMetadataConfigFromJSON(json['metadata_config']), + 'sourceCollection': !exists(json, 'source_collection') ? undefined : json['source_collection'], + }; +} + +export function PodSpecToJSON(value?: PodSpec | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'environment': value.environment, + 'replicas': value.replicas, + 'shards': value.shards, + 'pod_type': PodSpecPodTypeToJSON(value.podType), + 'pods': value.pods, + 'metadata_config': PodSpecMetadataConfigToJSON(value.metadataConfig), + 'source_collection': value.sourceCollection, + }; +} + diff --git a/src/pinecone-generated-ts-fetch/models/PodSpecMetadataConfig.ts b/src/pinecone-generated-ts-fetch/models/PodSpecMetadataConfig.ts new file mode 100644 index 00000000..c674b24a --- /dev/null +++ b/src/pinecone-generated-ts-fetch/models/PodSpecMetadataConfig.ts @@ -0,0 +1,65 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +/** + * Configuration for the behavior of Pinecone's internal metadata index. By default, all metadata is indexed; when `metadata_config` is present, only specified metadata fields are indexed. These configurations are only valid for use with pod indexes. + * @export + * @interface PodSpecMetadataConfig + */ +export interface PodSpecMetadataConfig { + /** + * By default, all metadata is indexed; to change this behavior, use this property to specify an array of metadata fields which should be indexed. + * @type {Array} + * @memberof PodSpecMetadataConfig + */ + indexed?: Array; +} + +/** + * Check if a given object implements the PodSpecMetadataConfig interface. + */ +export function instanceOfPodSpecMetadataConfig(value: object): boolean { + let isInstance = true; + + return isInstance; +} + +export function PodSpecMetadataConfigFromJSON(json: any): PodSpecMetadataConfig { + return PodSpecMetadataConfigFromJSONTyped(json, false); +} + +export function PodSpecMetadataConfigFromJSONTyped(json: any, ignoreDiscriminator: boolean): PodSpecMetadataConfig { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'indexed': !exists(json, 'indexed') ? undefined : json['indexed'], + }; +} + +export function PodSpecMetadataConfigToJSON(value?: PodSpecMetadataConfig | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'indexed': value.indexed, + }; +} + diff --git a/src/pinecone-generated-ts-fetch/models/PodSpecPodType.ts b/src/pinecone-generated-ts-fetch/models/PodSpecPodType.ts new file mode 100644 index 00000000..e09913ee --- /dev/null +++ b/src/pinecone-generated-ts-fetch/models/PodSpecPodType.ts @@ -0,0 +1,48 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +/** + * The type of pod to use. One of `s1`, `p1`, or `p2` appended with `.` and one of `x1`, `x2`, `x4`, or `x8`. + * @export + */ +export const PodSpecPodType = { + S1X1: 's1.x1', + S1X2: 's1.x2', + S1X4: 's1.x4', + S1X8: 's1.x8', + P1X1: 'p1.x1', + P1X2: 'p1.x2', + P1X4: 'p1.x4', + P1X8: 'p1.x8', + P2X1: 'p2.x1', + P2X2: 'p2.x2', + P2X4: 'p2.x4', + P2X8: 'p2.x8' +} as const; +export type PodSpecPodType = typeof PodSpecPodType[keyof typeof PodSpecPodType]; + + +export function PodSpecPodTypeFromJSON(json: any): PodSpecPodType { + return PodSpecPodTypeFromJSONTyped(json, false); +} + +export function PodSpecPodTypeFromJSONTyped(json: any, ignoreDiscriminator: boolean): PodSpecPodType { + return json as PodSpecPodType; +} + +export function PodSpecPodTypeToJSON(value?: PodSpecPodType | null): any { + return value as any; +} + diff --git a/src/pinecone-generated-ts-fetch/models/ProtobufAny.ts b/src/pinecone-generated-ts-fetch/models/ProtobufAny.ts index 04676590..da57a3d7 100644 --- a/src/pinecone-generated-ts-fetch/models/ProtobufAny.ts +++ b/src/pinecone-generated-ts-fetch/models/ProtobufAny.ts @@ -1,11 +1,11 @@ /* tslint:disable */ /* eslint-disable */ /** - * Pinecone API - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. * - * The version of the OpenAPI document: version not set - * Contact: support@pinecone.io + * The version of the OpenAPI document: 1.0 + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech diff --git a/src/pinecone-generated-ts-fetch/models/ProtobufNullValue.ts b/src/pinecone-generated-ts-fetch/models/ProtobufNullValue.ts index 72d0ca1c..ae009827 100644 --- a/src/pinecone-generated-ts-fetch/models/ProtobufNullValue.ts +++ b/src/pinecone-generated-ts-fetch/models/ProtobufNullValue.ts @@ -1,11 +1,11 @@ /* tslint:disable */ /* eslint-disable */ /** - * Pinecone API - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. * - * The version of the OpenAPI document: version not set - * Contact: support@pinecone.io + * The version of the OpenAPI document: 1.0 + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech diff --git a/src/pinecone-generated-ts-fetch/models/QueryRequest.ts b/src/pinecone-generated-ts-fetch/models/QueryRequest.ts index 51541a5e..496fd223 100644 --- a/src/pinecone-generated-ts-fetch/models/QueryRequest.ts +++ b/src/pinecone-generated-ts-fetch/models/QueryRequest.ts @@ -1,11 +1,11 @@ /* tslint:disable */ /* eslint-disable */ /** - * Pinecone API - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. * - * The version of the OpenAPI document: version not set - * Contact: support@pinecone.io + * The version of the OpenAPI document: 1.0 + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech diff --git a/src/pinecone-generated-ts-fetch/models/QueryResponse.ts b/src/pinecone-generated-ts-fetch/models/QueryResponse.ts index 84fd8a22..192e074c 100644 --- a/src/pinecone-generated-ts-fetch/models/QueryResponse.ts +++ b/src/pinecone-generated-ts-fetch/models/QueryResponse.ts @@ -1,11 +1,11 @@ /* tslint:disable */ /* eslint-disable */ /** - * Pinecone API - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. * - * The version of the OpenAPI document: version not set - * Contact: support@pinecone.io + * The version of the OpenAPI document: 1.0 + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech diff --git a/src/pinecone-generated-ts-fetch/models/QueryVector.ts b/src/pinecone-generated-ts-fetch/models/QueryVector.ts index 07e1e126..fde12a4d 100644 --- a/src/pinecone-generated-ts-fetch/models/QueryVector.ts +++ b/src/pinecone-generated-ts-fetch/models/QueryVector.ts @@ -1,11 +1,11 @@ /* tslint:disable */ /* eslint-disable */ /** - * Pinecone API - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. * - * The version of the OpenAPI document: version not set - * Contact: support@pinecone.io + * The version of the OpenAPI document: 1.0 + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech diff --git a/src/pinecone-generated-ts-fetch/models/RpcStatus.ts b/src/pinecone-generated-ts-fetch/models/RpcStatus.ts index 80a9462c..6879da20 100644 --- a/src/pinecone-generated-ts-fetch/models/RpcStatus.ts +++ b/src/pinecone-generated-ts-fetch/models/RpcStatus.ts @@ -1,11 +1,11 @@ /* tslint:disable */ /* eslint-disable */ /** - * Pinecone API - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. * - * The version of the OpenAPI document: version not set - * Contact: support@pinecone.io + * The version of the OpenAPI document: 1.0 + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech diff --git a/src/pinecone-generated-ts-fetch/models/ScoredVector.ts b/src/pinecone-generated-ts-fetch/models/ScoredVector.ts index f66db58f..c4046211 100644 --- a/src/pinecone-generated-ts-fetch/models/ScoredVector.ts +++ b/src/pinecone-generated-ts-fetch/models/ScoredVector.ts @@ -1,11 +1,11 @@ /* tslint:disable */ /* eslint-disable */ /** - * Pinecone API - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. * - * The version of the OpenAPI document: version not set - * Contact: support@pinecone.io + * The version of the OpenAPI document: 1.0 + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech diff --git a/src/pinecone-generated-ts-fetch/models/ServerlessSpec.ts b/src/pinecone-generated-ts-fetch/models/ServerlessSpec.ts new file mode 100644 index 00000000..60475796 --- /dev/null +++ b/src/pinecone-generated-ts-fetch/models/ServerlessSpec.ts @@ -0,0 +1,87 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +/** + * Configuration needed to deploy a serverless index + * @export + * @interface ServerlessSpec + */ +export interface ServerlessSpec { + /** + * The public cloud where you would like your index hosted + * @type {string} + * @memberof ServerlessSpec + */ + cloud: ServerlessSpecCloudEnum; + /** + * The region where you would like your index to be created. Different cloud providers have different regions available. See AwsRegions and GcpRegions for a list of available options. + * @type {string} + * @memberof ServerlessSpec + */ + region: string; +} + + +/** + * @export + */ +export const ServerlessSpecCloudEnum = { + Gcp: 'gcp', + Aws: 'aws', + Azure: 'azure' +} as const; +export type ServerlessSpecCloudEnum = typeof ServerlessSpecCloudEnum[keyof typeof ServerlessSpecCloudEnum]; + + +/** + * Check if a given object implements the ServerlessSpec interface. + */ +export function instanceOfServerlessSpec(value: object): boolean { + let isInstance = true; + isInstance = isInstance && "cloud" in value; + isInstance = isInstance && "region" in value; + + return isInstance; +} + +export function ServerlessSpecFromJSON(json: any): ServerlessSpec { + return ServerlessSpecFromJSONTyped(json, false); +} + +export function ServerlessSpecFromJSONTyped(json: any, ignoreDiscriminator: boolean): ServerlessSpec { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'cloud': json['cloud'], + 'region': json['region'], + }; +} + +export function ServerlessSpecToJSON(value?: ServerlessSpec | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'cloud': value.cloud, + 'region': value.region, + }; +} + diff --git a/src/pinecone-generated-ts-fetch/models/SingleQueryResults.ts b/src/pinecone-generated-ts-fetch/models/SingleQueryResults.ts index 091884a8..0fe7542e 100644 --- a/src/pinecone-generated-ts-fetch/models/SingleQueryResults.ts +++ b/src/pinecone-generated-ts-fetch/models/SingleQueryResults.ts @@ -1,11 +1,11 @@ /* tslint:disable */ /* eslint-disable */ /** - * Pinecone API - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. * - * The version of the OpenAPI document: version not set - * Contact: support@pinecone.io + * The version of the OpenAPI document: 1.0 + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech diff --git a/src/pinecone-generated-ts-fetch/models/SparseValues.ts b/src/pinecone-generated-ts-fetch/models/SparseValues.ts index fbc32eac..f7941dcb 100644 --- a/src/pinecone-generated-ts-fetch/models/SparseValues.ts +++ b/src/pinecone-generated-ts-fetch/models/SparseValues.ts @@ -1,11 +1,11 @@ /* tslint:disable */ /* eslint-disable */ /** - * Pinecone API - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. * - * The version of the OpenAPI document: version not set - * Contact: support@pinecone.io + * The version of the OpenAPI document: 1.0 + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech diff --git a/src/pinecone-generated-ts-fetch/models/UpdateRequest.ts b/src/pinecone-generated-ts-fetch/models/UpdateRequest.ts index b9656214..5dac5fc4 100644 --- a/src/pinecone-generated-ts-fetch/models/UpdateRequest.ts +++ b/src/pinecone-generated-ts-fetch/models/UpdateRequest.ts @@ -1,11 +1,11 @@ /* tslint:disable */ /* eslint-disable */ /** - * Pinecone API - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. * - * The version of the OpenAPI document: version not set - * Contact: support@pinecone.io + * The version of the OpenAPI document: 1.0 + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech diff --git a/src/pinecone-generated-ts-fetch/models/UpsertRequest.ts b/src/pinecone-generated-ts-fetch/models/UpsertRequest.ts index 2031e15f..f26351fd 100644 --- a/src/pinecone-generated-ts-fetch/models/UpsertRequest.ts +++ b/src/pinecone-generated-ts-fetch/models/UpsertRequest.ts @@ -1,11 +1,11 @@ /* tslint:disable */ /* eslint-disable */ /** - * Pinecone API - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. * - * The version of the OpenAPI document: version not set - * Contact: support@pinecone.io + * The version of the OpenAPI document: 1.0 + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech diff --git a/src/pinecone-generated-ts-fetch/models/UpsertResponse.ts b/src/pinecone-generated-ts-fetch/models/UpsertResponse.ts index 5e86f487..5bd5f702 100644 --- a/src/pinecone-generated-ts-fetch/models/UpsertResponse.ts +++ b/src/pinecone-generated-ts-fetch/models/UpsertResponse.ts @@ -1,11 +1,11 @@ /* tslint:disable */ /* eslint-disable */ /** - * Pinecone API - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. * - * The version of the OpenAPI document: version not set - * Contact: support@pinecone.io + * The version of the OpenAPI document: 1.0 + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech diff --git a/src/pinecone-generated-ts-fetch/models/Vector.ts b/src/pinecone-generated-ts-fetch/models/Vector.ts index 9638124a..4764e0cb 100644 --- a/src/pinecone-generated-ts-fetch/models/Vector.ts +++ b/src/pinecone-generated-ts-fetch/models/Vector.ts @@ -1,11 +1,11 @@ /* tslint:disable */ /* eslint-disable */ /** - * Pinecone API - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. * - * The version of the OpenAPI document: version not set - * Contact: support@pinecone.io + * The version of the OpenAPI document: 1.0 + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech diff --git a/src/pinecone-generated-ts-fetch/models/index.ts b/src/pinecone-generated-ts-fetch/models/index.ts index a9012ac0..7a8f0ddb 100644 --- a/src/pinecone-generated-ts-fetch/models/index.ts +++ b/src/pinecone-generated-ts-fetch/models/index.ts @@ -1,23 +1,30 @@ /* tslint:disable */ /* eslint-disable */ -export * from './ApproximatedConfig'; -export * from './CollectionMeta'; +export * from './AwsRegions'; +export * from './CollectionList'; +export * from './CollectionModel'; +export * from './ConfigureIndexRequest'; +export * from './ConfigureIndexRequestSpec'; +export * from './ConfigureIndexRequestSpecPod'; export * from './CreateCollectionRequest'; -export * from './CreateRequest'; -export * from './CreateRequestIndexConfig'; +export * from './CreateIndexRequest'; +export * from './CreateIndexRequestSpec'; export * from './DeleteRequest'; export * from './DescribeIndexStatsRequest'; export * from './DescribeIndexStatsResponse'; +export * from './ErrorResponse'; +export * from './ErrorResponseError'; export * from './FetchResponse'; -export * from './HnswConfig'; -export * from './IndexListMeta'; -export * from './IndexMeta'; -export * from './IndexMetaDatabase'; -export * from './IndexMetaDatabaseIndexConfig'; -export * from './IndexMetaStatus'; -export * from './ListIndexes200Response'; +export * from './GcpRegions'; +export * from './IndexList'; +export * from './IndexMetric'; +export * from './IndexModel'; +export * from './IndexModelSpec'; +export * from './IndexModelStatus'; export * from './NamespaceSummary'; -export * from './PatchRequest'; +export * from './PodSpec'; +export * from './PodSpecMetadataConfig'; +export * from './PodSpecPodType'; export * from './ProtobufAny'; export * from './ProtobufNullValue'; export * from './QueryRequest'; @@ -25,6 +32,7 @@ export * from './QueryResponse'; export * from './QueryVector'; export * from './RpcStatus'; export * from './ScoredVector'; +export * from './ServerlessSpec'; export * from './SingleQueryResults'; export * from './SparseValues'; export * from './UpdateRequest'; diff --git a/src/pinecone-generated-ts-fetch/runtime.ts b/src/pinecone-generated-ts-fetch/runtime.ts index 806507c9..ddb9c35d 100644 --- a/src/pinecone-generated-ts-fetch/runtime.ts +++ b/src/pinecone-generated-ts-fetch/runtime.ts @@ -1,11 +1,11 @@ /* tslint:disable */ /* eslint-disable */ /** - * Pinecone API - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Pineonce.io Public API + * Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors. * - * The version of the OpenAPI document: version not set - * Contact: support@pinecone.io + * The version of the OpenAPI document: 1.0 + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech @@ -13,7 +13,7 @@ */ -export const BASE_PATH = "https://unknown-unknown.svc.unknown.pinecone.io".replace(/\/+$/, ""); +export const BASE_PATH = "https://api.pinecone.io".replace(/\/+$/, ""); export interface ConfigurationParameters { basePath?: string; // override base path diff --git a/src/pinecone.ts b/src/pinecone.ts index 7abac419..701392f3 100644 --- a/src/pinecone.ts +++ b/src/pinecone.ts @@ -8,13 +8,15 @@ import { createCollection, describeCollection, deleteCollection, - ConfigureIndexOptions, - CreateCollectionOptions, CreateIndexOptions, IndexName, indexOperationsBuilder, CollectionName, } from './control'; +import { + ConfigureIndexRequest, + CreateCollectionRequest, +} from './pinecone-generated-ts-fetch'; import { IndexHostSingleton } from './data/indexHostSingleton'; import { PineconeConfigurationError, @@ -205,8 +207,8 @@ export class Pinecone { // For any describeIndex calls we want to update the IndexHostSingleton cache. // This prevents unneeded calls to describeIndex for resolving the host for vector operations. describeIndexPromise.then((indexMeta) => { - if (indexMeta.status?.host) { - IndexHostSingleton._set(this.config, indexName, indexMeta.status.host); + if (indexMeta.host) { + IndexHostSingleton._set(this.config, indexName, indexMeta.host); } }); @@ -334,8 +336,8 @@ export class Pinecone { * @param indexName - The name of the index to configure. * @param options - The configuration properties you would like to update */ - configureIndex(indexName: IndexName, options: ConfigureIndexOptions) { - return this._configureIndex(indexName, options); + configureIndex(indexName: IndexName, options: ConfigureIndexRequest) { + return this._configureIndex({ indexName, configureIndexRequest: options }); } /** @@ -356,7 +358,7 @@ export class Pinecone { * @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(options: CreateCollectionOptions) { + createCollection(options: CreateCollectionRequest) { return this._createCollection(options); } diff --git a/utils/cleanupResources.ts b/utils/cleanupResources.ts index 4e3b5322..2d0c35d7 100644 --- a/utils/cleanupResources.ts +++ b/utils/cleanupResources.ts @@ -14,11 +14,12 @@ var pinecone = require('../dist'); (async () => { const p = new pinecone.Pinecone(); - const collections = await p.listCollections(); - for (const collection of collections) { - console.log(`Deleting collection ${collection.name}`); - await p.deleteCollection(collection.name); - } + // TODO: Uncomment when collections are supported + // const collections = await p.listCollections(); + // for (const collection of collections) { + // console.log(`Deleting collection ${collection.name}`); + // await p.deleteCollection(collection.name); + // } const indexes = await p.listIndexes(); for (const index of indexes) { From 81dcabe1db05466fb3acd11540b648f20bf718f9 Mon Sep 17 00:00:00 2001 From: Austin DeNoble Date: Tue, 21 Nov 2023 17:36:31 -0500 Subject: [PATCH 6/9] prettier --- utils/cleanupResources.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/cleanupResources.ts b/utils/cleanupResources.ts index 2d0c35d7..6772f982 100644 --- a/utils/cleanupResources.ts +++ b/utils/cleanupResources.ts @@ -14,7 +14,7 @@ var pinecone = require('../dist'); (async () => { const p = new pinecone.Pinecone(); - // TODO: Uncomment when collections are supported + // TODO: Uncomment when collections are supported // const collections = await p.listCollections(); // for (const collection of collections) { // console.log(`Deleting collection ${collection.name}`); From 7a7644378813e1b4beda23dbcd1060951be830ca Mon Sep 17 00:00:00 2001 From: Austin DeNoble Date: Tue, 21 Nov 2023 19:32:29 -0500 Subject: [PATCH 7/9] update create and configure index typebox schemas, update associated validation tests, tweak configureIndex to avoid having users pass in a nested object --- src/__tests__/pinecone.test.ts | 15 +- src/control/__tests__/configureIndex.test.ts | 8 +- .../configureIndex.validation.test.ts | 29 +- src/control/__tests__/createIndex.test.ts | 64 ++-- .../__tests__/createIndex.validation.test.ts | 328 ++++++++++-------- .../__tests__/describeCollection.test.ts | 2 +- src/control/__tests__/listCollections.test.ts | 51 ++- src/control/__tests__/listIndexes.test.ts | 80 +++-- src/control/configureIndex.ts | 31 +- src/control/createIndex.ts | 38 +- src/control/listCollections.ts | 22 -- src/control/types.ts | 1 + src/data/__tests__/indexHostSingleton.test.ts | 77 ++-- .../control/configureIndex.test.ts | 16 +- src/pinecone.ts | 14 +- 15 files changed, 429 insertions(+), 347 deletions(-) diff --git a/src/__tests__/pinecone.test.ts b/src/__tests__/pinecone.test.ts index 472e36cb..780910ec 100644 --- a/src/__tests__/pinecone.test.ts +++ b/src/__tests__/pinecone.test.ts @@ -22,11 +22,16 @@ jest.mock('../control', () => { return { ...realControl, describeIndex: () => - jest - .fn() - .mockImplementation(() => - Promise.resolve({ status: { host: fakeHost } }) - ), + jest.fn().mockImplementation(() => + Promise.resolve({ + name: 'fake-index', + dimension: 1, + metric: 'cosine', + host: fakeHost, + spec: { serverless: { cloud: 'aws', region: 'us-east-1' } }, + status: { ready: true, state: 'Ready' }, + }) + ), deleteIndex: () => jest.fn().mockImplementation(() => Promise.resolve()), }; }); diff --git a/src/control/__tests__/configureIndex.test.ts b/src/control/__tests__/configureIndex.test.ts index 832e9735..cda9315e 100644 --- a/src/control/__tests__/configureIndex.test.ts +++ b/src/control/__tests__/configureIndex.test.ts @@ -12,11 +12,9 @@ describe('configureIndex', () => { ) => Promise = jest.fn(); const IOA = { configureIndex: fakeConfigure } as ManagePodIndexesApi; - const returned = await configureIndex(IOA)({ - indexName: 'index-name', - configureIndexRequest: { - spec: { pod: { replicas: 4, podType: 'p2.x2' } }, - }, + const returned = await configureIndex(IOA)('index-name', { + replicas: 4, + podType: 'p2.x2', }); expect(returned).toBe(void 0); diff --git a/src/control/__tests__/configureIndex.validation.test.ts b/src/control/__tests__/configureIndex.validation.test.ts index 9c390a01..31591881 100644 --- a/src/control/__tests__/configureIndex.validation.test.ts +++ b/src/control/__tests__/configureIndex.validation.test.ts @@ -6,20 +6,20 @@ import { configureIndex } from '../configureIndex'; import { PineconeArgumentError } from '../../errors'; -import { IndexOperationsApi } from '../../pinecone-generated-ts-fetch'; +import { ManagePodIndexesApi } from '../../pinecone-generated-ts-fetch'; describe('configureIndex argument validations', () => { - let IOA: IndexOperationsApi; + let MPIA: ManagePodIndexesApi; beforeEach(() => { - IOA = { configureIndex: jest.fn() }; + MPIA = { configureIndex: jest.fn() }; jest.mock('../../pinecone-generated-ts-fetch', () => ({ - IndexOperationsApi: IOA, + IndexOperationsApi: MPIA, })); }); describe('required configurations', () => { test('should throw if index name is not provided', async () => { - const toThrow = async () => await configureIndex(IOA)(); + const toThrow = async () => await configureIndex(MPIA)(); expect(toThrow).rejects.toThrowError(PineconeArgumentError); expect(toThrow).rejects.toThrowError( @@ -29,7 +29,7 @@ describe('configureIndex argument validations', () => { test('should throw if index name is not a string', async () => { const toThrow = async () => - await configureIndex(IOA)(1, { replicas: 10 }); + await configureIndex(MPIA)(1, { replicas: 10 }); expect(toThrow).rejects.toThrowError(PineconeArgumentError); expect(toThrow).rejects.toThrowError( @@ -39,7 +39,7 @@ describe('configureIndex argument validations', () => { test('should throw if index name is empty string', async () => { const toThrow = async () => - await configureIndex(IOA)('', { replicas: 2 }); + await configureIndex(MPIA)('', { replicas: 2 }); expect(toThrow).rejects.toThrowError(PineconeArgumentError); expect(toThrow).rejects.toThrowError( @@ -47,18 +47,19 @@ describe('configureIndex argument validations', () => { ); }); - test('should throw if a patch config is not provided', async () => { - const toThrow = async () => await configureIndex(IOA)('index-name', {}); + test('should throw if spec and pod are not provided', async () => { + const toThrowSpec = async () => + await configureIndex(MPIA)('index-name', {}); - expect(toThrow).rejects.toThrowError(PineconeArgumentError); - expect(toThrow).rejects.toThrowError( + expect(toThrowSpec).rejects.toThrowError(PineconeArgumentError); + expect(toThrowSpec).rejects.toThrowError( 'The second argument to configureIndex should not be empty object. Please specify at least one property (replicas, podType) to update.' ); }); test('should throw if replicas is not a number', async () => { const toThrow = async () => - await configureIndex(IOA)('index-name', { replicas: '10' }); + await configureIndex(MPIA)('index-name', { replicas: '10' }); expect(toThrow).rejects.toThrowError(PineconeArgumentError); expect(toThrow).rejects.toThrowError( @@ -68,7 +69,7 @@ describe('configureIndex argument validations', () => { test('should throw if podType is not a string', async () => { const toThrow = async () => - await configureIndex(IOA)('index-name', { podType: 10.5 }); + await configureIndex(MPIA)('index-name', { podType: 10.5 }); expect(toThrow).rejects.toThrowError(PineconeArgumentError); expect(toThrow).rejects.toThrowError( @@ -78,7 +79,7 @@ describe('configureIndex argument validations', () => { test('should throw if replicas is not a positive integer', async () => { const toThrow = async () => - await configureIndex(IOA)('index-name', { replicas: 0 }); + await configureIndex(MPIA)('index-name', { replicas: 0 }); expect(toThrow).rejects.toThrowError(PineconeArgumentError); expect(toThrow).rejects.toThrowError( diff --git a/src/control/__tests__/createIndex.test.ts b/src/control/__tests__/createIndex.test.ts index e066545f..1984ae05 100644 --- a/src/control/__tests__/createIndex.test.ts +++ b/src/control/__tests__/createIndex.test.ts @@ -40,18 +40,18 @@ const setupCreateIndexResponse = ( const fakeDescribeIndex: (req: DescribeIndexRequest) => Promise = describeIndexMock; - const IOA = { + const MPIA = { createIndex: fakeCreateIndex, describeIndex: fakeDescribeIndex, } as ManagePodIndexesApi; - return IOA; + return MPIA; }; describe('createIndex', () => { test('calls the openapi create index endpoint, passing name and dimension', async () => { - const IOA = setupCreateIndexResponse(undefined, undefined); - const returned = await createIndex(IOA)({ + const MPIA = setupCreateIndexResponse(undefined, undefined); + const returned = await createIndex(MPIA)({ name: 'index-name', dimension: 10, metric: 'cosine', @@ -67,17 +67,19 @@ describe('createIndex', () => { }); expect(returned).toEqual(void 0); - expect(IOA.createIndex).toHaveBeenCalledWith({ - name: 'index-name', - dimension: 10, - metric: 'cosine', - spec: { - pod: { - environment: 'us-west1', - replicas: 1, - shards: 1, - pods: 1, - podType: 'p1.x1', + expect(MPIA.createIndex).toHaveBeenCalledWith({ + createIndexRequest: { + name: 'index-name', + dimension: 10, + metric: 'cosine', + spec: { + pod: { + environment: 'us-west1', + replicas: 1, + shards: 1, + pods: 1, + podType: 'p1.x1', + }, }, }, }); @@ -92,13 +94,13 @@ describe('createIndex', () => { }); test('when passed waitUntilReady, calls the create index endpoint and begins polling describeIndex', async () => { - const IOA = setupCreateIndexResponse(undefined, [ + const MPIA = setupCreateIndexResponse(undefined, [ { status: { ready: true, state: 'Ready' }, }, ]); - const returned = await createIndex(IOA)({ + const returned = await createIndex(MPIA)({ name: 'index-name', dimension: 10, metric: 'cosine', @@ -115,22 +117,24 @@ describe('createIndex', () => { }); expect(returned).toEqual({ status: { ready: true, state: 'Ready' } }); - expect(IOA.createIndex).toHaveBeenCalledWith({ - name: 'index-name', - dimension: 10, - metric: 'cosine', - spec: { - pod: { - environment: 'us-west1', - replicas: 1, - shards: 1, - pods: 1, - podType: 'p1.x1', + expect(MPIA.createIndex).toHaveBeenCalledWith({ + createIndexRequest: { + name: 'index-name', + dimension: 10, + metric: 'cosine', + spec: { + pod: { + environment: 'us-west1', + replicas: 1, + shards: 1, + pods: 1, + podType: 'p1.x1', + }, }, + waitUntilReady: true, }, - waitUntilReady: true, }); - expect(IOA.describeIndex).toHaveBeenCalledWith({ + expect(MPIA.describeIndex).toHaveBeenCalledWith({ indexName: 'index-name', }); }); diff --git a/src/control/__tests__/createIndex.validation.test.ts b/src/control/__tests__/createIndex.validation.test.ts index a4333ad9..f666a94f 100644 --- a/src/control/__tests__/createIndex.validation.test.ts +++ b/src/control/__tests__/createIndex.validation.test.ts @@ -8,7 +8,7 @@ import { createIndex } from '../createIndex'; import { PineconeArgumentError } from '../../errors'; import { ManagePodIndexesApi } from '../../pinecone-generated-ts-fetch'; -// TODO: Fix up tests +// TODO: Update tests to cover all nested properties inside spec once validator.ts is updated describe('createIndex argument validations', () => { let MPIA: ManagePodIndexesApi; beforeEach(() => { @@ -20,7 +20,7 @@ describe('createIndex argument validations', () => { describe('required configurations', () => { test('should throw if index name is not provided', async () => { - const toThrow = async () => await createIndex(IOA)(); + const toThrow = async () => await createIndex(MPIA)(); expect(toThrow).rejects.toThrowError(PineconeArgumentError); expect(toThrow).rejects.toThrowError( @@ -30,12 +30,11 @@ describe('createIndex argument validations', () => { test('should throw if index name is not a string', async () => { const toThrow = async () => - await createIndex(IOA)({ + await createIndex(MPIA)({ name: 12, dimension: 10, - region: 'us-east3', - cloud: 'gcp', - capacityMode: 'pod', + metric: 'cosine', + spec: { serverless: { cloud: 'aws', region: 'us-east-1' } }, }); expect(toThrow).rejects.toThrowError(PineconeArgumentError); @@ -46,12 +45,11 @@ describe('createIndex argument validations', () => { test('should throw if index name is empty string', async () => { const toThrow = async () => - await createIndex(IOA)({ + await createIndex(MPIA)({ name: '', dimension: 10, - region: 'us-east3', - cloud: 'gcp', - capacityMode: 'pod', + metric: 'cosine', + spec: { serverless: { cloud: 'aws', region: 'us-east-1' } }, }); expect(toThrow).rejects.toThrowError(PineconeArgumentError); @@ -62,11 +60,10 @@ describe('createIndex argument validations', () => { test('should throw if dimension is not provided', async () => { const toThrow = async () => - await createIndex(IOA)({ + await createIndex(MPIA)({ name: 'index-name', - region: 'us-east3', - cloud: 'gcp', - capacityMode: 'pod', + metric: 'cosine', + spec: { serverless: { cloud: 'aws', region: 'us-east-1' } }, }); expect(toThrow).rejects.toThrowError(PineconeArgumentError); @@ -77,12 +74,11 @@ describe('createIndex argument validations', () => { test('should throw if dimension is not a number', async () => { const toThrow = async () => - await createIndex(IOA)({ + await createIndex(MPIA)({ name: 'index-name', dimension: '10', - region: 'us-east3', - cloud: 'gcp', - capacityMode: 'pod', + metric: 'cosine', + spec: { serverless: { cloud: 'aws', region: 'us-east-1' } }, }); expect(toThrow).rejects.toThrowError(PineconeArgumentError); @@ -93,12 +89,11 @@ describe('createIndex argument validations', () => { test('should throw if dimension is float', async () => { const toThrow = async () => - await createIndex(IOA)({ + await createIndex(MPIA)({ name: 'index-name', dimension: 10.5, - region: 'us-east3', - cloud: 'gcp', - capacityMode: 'pod', + metric: 'cosine', + spec: { serverless: { cloud: 'aws', region: 'us-east-1' } }, }); expect(toThrow).rejects.toThrowError(PineconeArgumentError); @@ -109,12 +104,11 @@ describe('createIndex argument validations', () => { test('should throw if dimension is not a positive integer', async () => { const toThrow = async () => - await createIndex(IOA)({ + await createIndex(MPIA)({ name: 'index-name', dimension: -10, - region: 'us-east3', - cloud: 'gcp', - capacityMode: 'pod', + metric: 'cosine', + spec: { serverless: { cloud: 'aws', region: 'us-east-1' } }, }); expect(toThrow).rejects.toThrowError(PineconeArgumentError); @@ -125,11 +119,15 @@ describe('createIndex argument validations', () => { test('should throw if region is not provided', () => { const toThrow = async () => - await createIndex(IOA)({ + await createIndex(MPIA)({ name: 'index-name', dimension: 10, - cloud: 'gcp', - capacityMode: 'pod', + metric: 'cosine', + spec: { + serverless: { + cloud: 'aws', + }, + }, }); expect(toThrow).rejects.toThrowError(PineconeArgumentError); @@ -140,27 +138,36 @@ describe('createIndex argument validations', () => { test('should throw if region is not a string', () => { const toThrow = async () => - await createIndex(IOA)({ + await createIndex(MPIA)({ name: 'index-name', dimension: 10, - region: 111, - cloud: 'gcp', - capacityMode: 'pod', + metric: 'cosine', + spec: { + serverless: { + cloud: 'aws', + region: 111, + }, + }, }); expect(toThrow).rejects.toThrowError(PineconeArgumentError); + // TODO: Update validator.ts to handle nested object properties expect(toThrow).rejects.toThrowError( - "The argument to createIndex had type errors: property 'region' must be string." + "The argument to createIndex had type errors: property 'spec/properties/serverless/properties/region' must be string." ); }); test('should throw if cloud is not provided', () => { const toThrow = async () => - await createIndex(IOA)({ + await createIndex(MPIA)({ name: 'index-name', dimension: 10, - region: 'us-east3', - capacityMode: 'pod', + metric: 'cosine', + spec: { + serverless: { + region: 111, + }, + }, }); expect(toThrow).rejects.toThrowError(PineconeArgumentError); @@ -171,64 +178,43 @@ describe('createIndex argument validations', () => { test('should throw if cloud is not a string', () => { const toThrow = async () => - await createIndex(IOA)({ + await createIndex(MPIA)({ name: 'index-name', dimension: 10, - region: 'us-east3', - cloud: 123, - capacityMode: 'pod', + metric: 'cosine', + spec: { + serverless: { + region: 'us-east-1', + cloud: 123, + }, + }, }); expect(toThrow).rejects.toThrowError(PineconeArgumentError); + // TODO: Update validator.ts to handle nested object properties expect(toThrow).rejects.toThrowError( - "The argument to createIndex had type errors: property 'cloud' must be equal to one of: 'gcp', 'aws', 'azure'." + "The argument to createIndex had type errors: property 'spec/serverless/cloud' must be equal to one of: 'gcp', 'aws', 'azure'." ); }); test('should throw if cloud is not one of the expected strings', () => { const toThrow = async () => - await createIndex(IOA)({ + await createIndex(MPIA)({ name: 'index-name', dimension: 10, - region: 'us-east3', - cloud: 'pcg', - capacityMode: 'pod', + metric: 'cosine', + spec: { + serverless: { + region: 'us-east-1', + cloud: 'goo', + }, + }, }); expect(toThrow).rejects.toThrowError(PineconeArgumentError); + // TODO: Update validator.ts to handle nested object properties expect(toThrow).rejects.toThrowError( - "The argument to createIndex had type errors: property 'cloud' must be equal to one of: 'gcp', 'aws', 'azure'." - ); - }); - - test('should throw if capacityMode is not provided', () => { - const toThrow = async () => - await createIndex(IOA)({ - name: 'index-name', - dimension: 10, - region: 'us-east3', - cloud: 'gcp', - }); - - expect(toThrow).rejects.toThrowError(PineconeArgumentError); - expect(toThrow).rejects.toThrowError( - 'The argument to createIndex must have required property: capacityMode.' - ); - }); - - test('should throw if capacityMode is not a string', () => { - const toThrow = async () => - await createIndex(IOA)({ - name: 'index-name', - dimension: 10, - region: 'us-east3', - cloud: 'gcp', - capacityMode: 321, - }); - - expect(toThrow).rejects.toThrowError(PineconeArgumentError); - expect(toThrow).rejects.toThrowError( - "The argument to createIndex had type errors: property 'capacityMode' must be string." + "The argument to createIndex had type errors: property 'spec/serverless/cloud' must be equal to one of: 'gcp', 'aws', 'azure'." ); }); }); @@ -236,13 +222,11 @@ describe('createIndex argument validations', () => { describe('optional configurations', () => { test('metric: should throw if not a string', async () => { const toThrow = async () => - await createIndex(IOA)({ + await createIndex(MPIA)({ name: 'index-name', dimension: 10, - region: 'us-east3', - cloud: 'gcp', - capacityMode: 'pod', metric: 10, + spec: { serverless: { cloud: 'aws', region: 'us-east-1' } }, }); expect(toThrow).rejects.toThrowError(PineconeArgumentError); @@ -253,13 +237,11 @@ describe('createIndex argument validations', () => { test('metric: should throw if blank string', async () => { const toThrow = async () => - await createIndex(IOA)({ + await createIndex(MPIA)({ name: 'index-name', dimension: 10, - region: 'us-east3', - cloud: 'gcp', - capacityMode: 'pod', metric: '', + spec: { serverless: { cloud: 'aws', region: 'us-east-1' } }, }); expect(toThrow).rejects.toThrowError(PineconeArgumentError); @@ -270,154 +252,220 @@ describe('createIndex argument validations', () => { test('replicas: should throw if not an integer', async () => { const toThrow = async () => - await createIndex(IOA)({ + await createIndex(MPIA)({ name: 'index-name', dimension: 10, - region: 'us-east3', - cloud: 'gcp', - capacityMode: 'pod', - replicas: '10', + metric: 'cosine', + spec: { + pod: { + replicas: '10', + environment: 'us-east-1', + shards: 1, + podType: 'p1.x1', + pods: 1, + }, + }, }); expect(toThrow).rejects.toThrowError(PineconeArgumentError); + // TODO: Update validator.ts to handle nested object properties expect(toThrow).rejects.toThrowError( - "The argument to createIndex had type errors: property 'replicas' must be integer." + "The argument to createIndex had type errors: property 'spec/properties/pod/properties/replicas' must be integer." ); }); test('replicas: should throw if not a positive integer', async () => { const toThrow = async () => - await createIndex(IOA)({ + await createIndex(MPIA)({ name: 'index-name', dimension: 10, - region: 'us-east3', - cloud: 'gcp', - capacityMode: 'pod', - replicas: -10, + metric: 'cosine', + spec: { + pod: { + replicas: -10, + environment: 'us-east-1', + shards: 1, + podType: 'p1.x1', + pods: 1, + }, + }, }); expect(toThrow).rejects.toThrowError(PineconeArgumentError); + // TODO: Update validator.ts to handle nested object properties expect(toThrow).rejects.toThrowError( - "The argument to createIndex had validation errors: property 'replicas' must be >= 1." + "The argument to createIndex had validation errors: property 'spec/properties/pod/properties/replicas' must be >= 1." ); }); test('podType: should throw if not a string', async () => { const toThrow = async () => - await createIndex(IOA)({ + await createIndex(MPIA)({ name: 'index-name', dimension: 10, - region: 'us-east3', - cloud: 'gcp', - capacityMode: 'pod', - podType: 10, + metric: 'cosine', + spec: { + pod: { + replicas: 1, + environment: 'us-east-1', + shards: 1, + podType: 10, + pods: 1, + }, + }, }); expect(toThrow).rejects.toThrowError(PineconeArgumentError); + // TODO: Update validator.ts to handle nested object properties expect(toThrow).rejects.toThrowError( - "The argument to createIndex had type errors: property 'podType' must be string." + "The argument to createIndex had type errors: property 'spec/properties/pod/properties/podType' must be string." ); }); test('podType: should throw if not a valid pod type', async () => { const toThrow = async () => - await createIndex(IOA)({ + await createIndex(MPIA)({ name: 'index-name', dimension: 10, - region: 'us-east3', - cloud: 'gcp', - capacityMode: 'pod', - podType: '', + metric: 'cosine', + spec: { + pod: { + replicas: 1, + environment: 'us-east-1', + shards: 1, + podType: '', + pods: 1, + }, + }, }); expect(toThrow).rejects.toThrowError(PineconeArgumentError); + // TODO: Update validator.ts to handle nested object properties expect(toThrow).rejects.toThrowError( - "The argument to createIndex had validation errors: property 'podType' must not be blank." + "The argument to createIndex had validation errors: property 'spec/properties/pod/properties/podType' must not be blank." ); }); test('pods: should throw if not an integer', async () => { const toThrow = async () => - await createIndex(IOA)({ + await createIndex(MPIA)({ name: 'index-name', dimension: 10, - region: 'us-east3', - cloud: 'gcp', - capacityMode: 'pod', - pods: '10', + metric: 'cosine', + spec: { + pod: { + replicas: 1, + environment: 'us-east-1', + shards: 1, + podType: 'p1.x1', + pods: '1', + }, + }, }); expect(toThrow).rejects.toThrowError(PineconeArgumentError); + // TODO: Update validator.ts to handle nested object properties expect(toThrow).rejects.toThrowError( - "The argument to createIndex had type errors: property 'pods' must be integer." + "The argument to createIndex had type errors: property 'spec/properties/pod/properties/pods' must be integer." ); }); test('pods: should throw if not a positive integer', async () => { const toThrow = async () => - await createIndex(IOA)({ + await createIndex(MPIA)({ name: 'index-name', dimension: 10, - region: 'us-east3', - cloud: 'gcp', - capacityMode: 'pod', - pods: -10, + metric: 'cosine', + spec: { + pod: { + replicas: 1, + environment: 'us-east-1', + shards: 1, + podType: 'p1.x1', + pods: -10, + }, + }, }); expect(toThrow).rejects.toThrowError(PineconeArgumentError); + // TODO: Update validator.ts to handle nested object properties expect(toThrow).rejects.toThrowError( - "The argument to createIndex had validation errors: property 'pods' must be >= 1." + "The argument to createIndex had validation errors: property 'spec/properties/pod/properties/pods' must be >= 1." ); }); test('metadataConfig: should throw if not an object', async () => { const toThrow = async () => - await createIndex(IOA)({ + await createIndex(MPIA)({ name: 'index-name', dimension: 10, - region: 'us-east3', - cloud: 'gcp', - capacityMode: 'pod', - metadataConfig: '{}', + metric: 'cosine', + spec: { + pod: { + replicas: 1, + environment: 'us-east-1', + shards: 1, + podType: 'p1.x1', + pods: 1, + metadataConfig: 'metadata', + }, + }, }); expect(toThrow).rejects.toThrowError(PineconeArgumentError); + // TODO: Update validator.ts to handle nested object properties expect(toThrow).rejects.toThrowError( - "The argument to createIndex had type errors: property 'metadataConfig' must be object." + "The argument to createIndex had type errors: property 'spec/properties/pod/properties/metadataConfig' must be object." ); }); test('sourceCollection: should throw if not a string', async () => { const toThrow = async () => - await createIndex(IOA)({ + await createIndex(MPIA)({ name: 'index-name', dimension: 10, - region: 'us-east3', - cloud: 'gcp', - capacityMode: 'pod', - sourceCollection: 10, + metric: 'cosine', + spec: { + pod: { + replicas: 1, + environment: 'us-east-1', + shards: 1, + podType: 'p1.x1', + pods: 1, + sourceCollection: 10, + }, + }, }); expect(toThrow).rejects.toThrowError(PineconeArgumentError); + // TODO: Update validator.ts to handle nested object properties expect(toThrow).rejects.toThrowError( - "The argument to createIndex had type errors: property 'sourceCollection' must be string." + "The argument to createIndex had type errors: property 'spec/properties/pod/properties/sourceCollection' must be string." ); }); test('sourceCollection: should throw if blank string', async () => { const toThrow = async () => - await createIndex(IOA)({ + await createIndex(MPIA)({ name: 'index-name', dimension: 10, - region: 'us-east3', - cloud: 'gcp', - capacityMode: 'pod', - sourceCollection: '', + metric: 'cosine', + spec: { + pod: { + replicas: 1, + environment: 'us-east-1', + shards: 1, + podType: 'p1.x1', + pods: 1, + sourceCollection: '', + }, + }, }); expect(toThrow).rejects.toThrowError(PineconeArgumentError); + // TODO: Update validator.ts to handle nested object properties expect(toThrow).rejects.toThrowError( - "The argument to createIndex had validation errors: property 'sourceCollection' must not be blank." + "The argument to createIndex had validation errors: property 'spec/properties/pod/properties/sourceCollection' must not be blank." ); }); }); diff --git a/src/control/__tests__/describeCollection.test.ts b/src/control/__tests__/describeCollection.test.ts index bbfc1428..d0ec737f 100644 --- a/src/control/__tests__/describeCollection.test.ts +++ b/src/control/__tests__/describeCollection.test.ts @@ -79,7 +79,7 @@ describe('describeCollection', () => { name: 'collection-name', size: 3085509, status: 'Ready', - vectorCount: 120, + recordCount: 120, }), () => Promise.resolve([]) ); diff --git a/src/control/__tests__/listCollections.test.ts b/src/control/__tests__/listCollections.test.ts index 173ff724..e70d208f 100644 --- a/src/control/__tests__/listCollections.test.ts +++ b/src/control/__tests__/listCollections.test.ts @@ -3,19 +3,52 @@ import { listCollections } from '../listCollections'; describe('listCollections', () => { test('should return a list of collection objects', async () => { const IOA = { - listCollections: jest - .fn() - .mockImplementation(() => - Promise.resolve(['collection-name', 'collection-name-2']) - ), + listCollections: jest.fn().mockImplementation(() => + Promise.resolve({ + collections: [ + { + name: 'movie-embeddings', + size: 12345678, + status: 'Ready', + dimensions: 5, + recordCount: 129583, + environment: 'us-east-1', + }, + { + name: 'tv-embeddings', + size: 1543267, + status: 'Ready', + dimensions: 3, + recordCount: 32881, + environment: 'us-east-1', + }, + ], + }) + ), }; // @ts-ignore const returned = await listCollections(IOA)(); - expect(returned).toEqual([ - { name: 'collection-name' }, - { name: 'collection-name-2' }, - ]); + expect(returned).toEqual({ + collections: [ + { + name: 'movie-embeddings', + size: 12345678, + status: 'Ready', + dimensions: 5, + recordCount: 129583, + environment: 'us-east-1', + }, + { + name: 'tv-embeddings', + size: 1543267, + status: 'Ready', + dimensions: 3, + recordCount: 32881, + environment: 'us-east-1', + }, + ], + }); }); }); diff --git a/src/control/__tests__/listIndexes.test.ts b/src/control/__tests__/listIndexes.test.ts index 5873db5e..e43e80ea 100644 --- a/src/control/__tests__/listIndexes.test.ts +++ b/src/control/__tests__/listIndexes.test.ts @@ -5,33 +5,39 @@ describe('listIndexes', () => { const IndexOperationsApi = { listIndexes: jest.fn().mockImplementation(() => Promise.resolve({ - databases: [ + indexes: [ { - database: { - name: 'index-name', - dimension: 5, - capacityMode: 'pod', - metric: 'cosine', + name: 'index-name', + dimension: 5, + capacityMode: 'pod', + metric: 'cosine', + host: '789-123-foo.svc.efgh.pinecone.io', + spec: { + serverless: { + cloud: 'aws', + region: 'us-east-1', + }, }, status: { ready: true, state: 'Ready', - host: '789-123-foo.svc.efgh.pinecone.io', - port: 443, }, }, { - database: { - name: 'index-name-2', - dimension: 5, - capacityMode: 'pod', - metric: 'cosine', + name: 'index-name-2', + dimension: 5, + capacityMode: 'pod', + metric: 'cosine', + host: '123-456-foo.svc.abcd.pinecone.io', + spec: { + serverless: { + cloud: 'aws', + region: 'us-east-1', + }, }, status: { ready: true, state: 'Ready', - host: '123-456-foo.svc.abcd.pinecone.io', - port: 443, }, }, ], @@ -42,35 +48,43 @@ describe('listIndexes', () => { // @ts-ignore const returned = await listIndexes(IndexOperationsApi)(); - expect(returned).toEqual([ - { - database: { + expect(returned).toEqual({ + indexes: [ + { name: 'index-name', dimension: 5, capacityMode: 'pod', metric: 'cosine', - }, - status: { - ready: true, - state: 'Ready', host: '789-123-foo.svc.efgh.pinecone.io', - port: 443, + spec: { + serverless: { + cloud: 'aws', + region: 'us-east-1', + }, + }, + status: { + ready: true, + state: 'Ready', + }, }, - }, - { - database: { + { name: 'index-name-2', dimension: 5, capacityMode: 'pod', metric: 'cosine', - }, - status: { - ready: true, - state: 'Ready', host: '123-456-foo.svc.abcd.pinecone.io', - port: 443, + spec: { + serverless: { + cloud: 'aws', + region: 'us-east-1', + }, + }, + status: { + ready: true, + state: 'Ready', + }, }, - }, - ]); + ], + }); }); }); diff --git a/src/control/configureIndex.ts b/src/control/configureIndex.ts index 42d1ce1e..37cee512 100644 --- a/src/control/configureIndex.ts +++ b/src/control/configureIndex.ts @@ -1,6 +1,6 @@ import { ManagePodIndexesApi, - ConfigureIndexOperationRequest, + ConfigureIndexRequestSpecPod, } from '../pinecone-generated-ts-fetch'; import { PineconeArgumentError } from '../errors'; import { buildValidator } from '../validator'; @@ -38,18 +38,23 @@ export const configureIndex = (api: ManagePodIndexesApi) => { ConfigureIndexOptionsSchema ); - return async (options: ConfigureIndexOperationRequest): Promise => { - // TODO: Fix runtime validation - // indexNameValidator(options.indexName); - // patchRequestValidator(options.configureIndexRequest); - - // if (Object.keys(options).length === 0) { - // throw new PineconeArgumentError( - // 'The second argument to configureIndex should not be empty object. Please specify at least one property (replicas, podType) to update.' - // ); - // } - - await api.configureIndex(options); + return async ( + indexName: IndexName, + options: ConfigureIndexRequestSpecPod + ): Promise => { + indexNameValidator(indexName); + patchRequestValidator(options); + + if (Object.keys(options).length === 0) { + throw new PineconeArgumentError( + 'The second argument to configureIndex should not be empty object. Please specify at least one property (replicas, podType) to update.' + ); + } + + await api.configureIndex({ + indexName, + configureIndexRequest: { spec: { pod: options } }, + }); return; }; }; diff --git a/src/control/createIndex.ts b/src/control/createIndex.ts index 262fc448..ba108237 100644 --- a/src/control/createIndex.ts +++ b/src/control/createIndex.ts @@ -9,7 +9,6 @@ import { handleApiError } from '../errors'; import { Type } from '@sinclair/typebox'; import { IndexNameSchema, - CapacityModeSchema, CloudSchema, DimensionSchema, EnvironmentSchema, @@ -20,8 +19,8 @@ import { PodTypeSchema, MetadataConfigSchema, CollectionNameSchema, + ShardsSchema, } from './types'; -import type { IndexName, PodType } from './types'; /** * @see [Understanding indexes](https://docs.pinecone.io/docs/indexes) @@ -38,16 +37,29 @@ const CreateIndexOptionsSchema = Type.Object( { name: IndexNameSchema, dimension: DimensionSchema, - region: RegionSchema, - cloud: CloudSchema, - capacityMode: CapacityModeSchema, - metric: Type.Optional(MetricSchema), - pods: Type.Optional(PodsSchema), - replicas: Type.Optional(ReplicasSchema), - podType: Type.Optional(PodTypeSchema), - environment: Type.Optional(EnvironmentSchema), - metadataConfig: Type.Optional(MetadataConfigSchema), - sourceCollection: Type.Optional(CollectionNameSchema), + metric: MetricSchema, + + spec: Type.Object({ + serverless: Type.Optional( + Type.Object({ + cloud: CloudSchema, + region: RegionSchema, + }) + ), + + pod: Type.Optional( + Type.Object({ + environment: EnvironmentSchema, + replicas: ReplicasSchema, + shards: ShardsSchema, + podType: PodTypeSchema, + pods: PodsSchema, + metadataConfig: Type.Optional(MetadataConfigSchema), + sourceCollection: Type.Optional(CollectionNameSchema), + }) + ), + }), + waitUntilReady: Type.Optional(Type.Boolean()), suppressConflicts: Type.Optional(Type.Boolean()), }, @@ -64,7 +76,7 @@ export const createIndex = (api: ManagePodIndexesApi) => { options: CreateIndexOptions ): Promise => { // TODO: Fix runtime validation - //validator(options); + validator(options); try { const createResponse = await api.createIndex({ createIndexRequest: options, diff --git a/src/control/listCollections.ts b/src/control/listCollections.ts index e5f932ce..a77e60d8 100644 --- a/src/control/listCollections.ts +++ b/src/control/listCollections.ts @@ -3,32 +3,10 @@ import { CollectionList, } from '../pinecone-generated-ts-fetch'; -/** - * A partial description of a collection in your project. - * - * To see full information about the collection, see { @link Pinecone.describeCollection } - */ -// export type PartialCollectionDescription = { -// /** The name of the collection */ -// name: string; -// }; - -// /** -// * A list of collections in your project -// * -// * @see [Understanding collections](https://docs.pinecone.io/docs/collections#limitations) -// */ -// export type CollectionList = PartialCollectionDescription[]; - export const listCollections = (api: ManagePodIndexesApi) => { return async (): Promise => { const results = await api.listCollections(); - // We know in a future version of the API that listing - // collections should return more information than just the - // collection names. Mapping these results into an object - // will allow us us to add more information in the future - // in a non-breaking way. return results; }; }; diff --git a/src/control/types.ts b/src/control/types.ts index 2b6a018e..c4a1e498 100644 --- a/src/control/types.ts +++ b/src/control/types.ts @@ -24,6 +24,7 @@ export type IndexName = string; export const PodTypeSchema = nonemptyString; export const ReplicasSchema = positiveInteger; export const PodsSchema = positiveInteger; +export const ShardsSchema = positiveInteger; export const MetricSchema = nonemptyString; export const DimensionSchema = positiveInteger; export const RegionSchema = nonemptyString; diff --git a/src/data/__tests__/indexHostSingleton.test.ts b/src/data/__tests__/indexHostSingleton.test.ts index d98d7cf7..6ecdee97 100644 --- a/src/data/__tests__/indexHostSingleton.test.ts +++ b/src/data/__tests__/indexHostSingleton.test.ts @@ -1,4 +1,3 @@ -import { PineconeUnableToResolveHostError } from '../../errors'; import { IndexHostSingleton } from '../indexHostSingleton'; const mockDescribeIndex = jest.fn(); @@ -25,16 +24,12 @@ describe('IndexHostSingleton', () => { apiKey: 'api-key-1', }; mockDescribeIndex.mockResolvedValue({ - database: { - name: 'index-1', - dimensions: 10, - metric: 'cosine', - pods: 1, - replicas: 1, - shards: 1, - podType: 'p1.x1', - }, - status: { ready: true, state: 'Ready', host: testHost }, + name: 'index-1', + dimensions: 10, + metric: 'cosine', + host: testHost, + spec: { pod: { pods: 1, replicas: 1, shards: 1, podType: 'p1.x1' } }, + status: { ready: true, state: 'Ready' }, }); const hostUrl = await IndexHostSingleton.getHostUrl( @@ -55,28 +50,20 @@ describe('IndexHostSingleton', () => { }; mockDescribeIndex .mockResolvedValueOnce({ - database: { - name: testIndex, - dimensions: 10, - metric: 'cosine', - pods: 1, - replicas: 1, - shards: 1, - podType: 'p1.x1', - }, - status: { ready: true, state: 'Ready', host: testHost }, + name: testIndex, + dimensions: 10, + metric: 'cosine', + host: testHost, + spec: { pod: { pods: 1, replicas: 1, shards: 1, podType: 'p1.x1' } }, + status: { ready: true, state: 'Ready' }, }) .mockResolvedValueOnce({ - database: { - name: testIndex2, - dimensions: 10, - metric: 'cosine', - pods: 1, - replicas: 1, - shards: 1, - podType: 'p1.x1', - }, - status: { ready: true, state: 'Ready', host: testHost2 }, + name: testIndex2, + dimensions: 10, + metric: 'cosine', + host: testHost2, + spec: { pod: { pods: 1, replicas: 1, shards: 1, podType: 'p1.x1' } }, + status: { ready: true, state: 'Ready' }, }); const hostUrl = await IndexHostSingleton.getHostUrl( @@ -108,16 +95,12 @@ describe('IndexHostSingleton', () => { const pineconeConfig = { apiKey: 'test-key' }; mockDescribeIndex.mockResolvedValue({ - database: { - name: 'index-1', - dimensions: 10, - metric: 'cosine', - pods: 1, - replicas: 1, - shards: 1, - podType: 'p1.x1', - }, - status: { ready: true, state: 'Ready', host: 'test-host' }, + name: 'index-1', + dimensions: 10, + metric: 'cosine', + host: 'test-host', + spec: { pod: { pods: 1, replicas: 1, shards: 1, podType: 'p1.x1' } }, + status: { ready: true, state: 'Ready' }, }); // _set test @@ -143,12 +126,12 @@ describe('IndexHostSingleton', () => { const pineconeConfig = { apiKey: 'test-key' }; mockDescribeIndex.mockResolvedValue({ - database: { - name: 'index-1', - dimensions: 10, - metric: 'cosine', - }, - status: { ready: true, state: 'Ready', host: 'test-host' }, + name: 'index-1', + dimensions: 10, + metric: 'cosine', + host: 'test-host', + spec: { pod: { pods: 1, replicas: 1, shards: 1, podType: 'p1.x1' } }, + status: { ready: true, state: 'Ready' }, }); IndexHostSingleton._set(pineconeConfig, 'test-index', ''); diff --git a/src/integration/control/configureIndex.test.ts b/src/integration/control/configureIndex.test.ts index 036a3f57..1fb065c5 100644 --- a/src/integration/control/configureIndex.test.ts +++ b/src/integration/control/configureIndex.test.ts @@ -36,7 +36,7 @@ describe.skip('configure index', () => { test('configure index with invalid index name', async () => { try { await pinecone.configureIndex('non-existent-index', { - spec: { pod: { replicas: 2 } }, + replicas: 2, }); } catch (e) { const err = e as BasePineconeError; @@ -47,7 +47,7 @@ describe.skip('configure index', () => { test('configure index when exceeding quota', async () => { try { await pinecone.configureIndex(indexName, { - spec: { pod: { replicas: 20 } }, + replicas: 20, }); } catch (e) { const err = e as BasePineconeError; @@ -66,7 +66,7 @@ describe.skip('configure index', () => { expect(description.spec.pod?.replicas).toEqual(2); await pinecone.configureIndex(indexName, { - spec: { pod: { replicas: 3 } }, + replicas: 3, }); const description2 = await pinecone.describeIndex(indexName); expect(description2.spec.pod?.replicas).toEqual(3); @@ -77,7 +77,7 @@ describe.skip('configure index', () => { expect(description.spec.pod?.replicas).toEqual(2); await pinecone.configureIndex(indexName, { - spec: { pod: { replicas: 1 } }, + replicas: 1, }); const description3 = await pinecone.describeIndex(indexName); expect(description3.spec.pod?.replicas).toEqual(1); @@ -93,7 +93,7 @@ describe.skip('configure index', () => { try { // Try to change the base pod type await pinecone.configureIndex(indexName, { - spec: { pod: { podType: 'p2.x1' } }, + podType: 'p2.x1', }); } catch (e) { const err = e as BasePineconeError; @@ -110,7 +110,7 @@ describe.skip('configure index', () => { expect(description.spec.pod?.podType).toEqual('p1.x1'); await pinecone.configureIndex(indexName, { - spec: { pod: { podType: 'p1.x2' } }, + podType: 'p1.x2', }); const description2 = await pinecone.describeIndex(indexName); expect(description2.spec.pod?.podType).toEqual('p1.x2'); @@ -123,7 +123,7 @@ describe.skip('configure index', () => { // Size up await pinecone.configureIndex(indexName, { - spec: { pod: { podType: 'p1.x2' } }, + podType: 'p1.x2', }); const description2 = await pinecone.describeIndex(indexName); expect(description2.spec.pod?.podType).toEqual('p1.x2'); @@ -133,7 +133,7 @@ describe.skip('configure index', () => { try { // try to size down await pinecone.configureIndex(indexName, { - spec: { pod: { podType: 'p1.x1' } }, + podType: 'p1.x1', }); const description3 = await pinecone.describeIndex(indexName); expect(description3.spec.pod?.podType).toEqual('p1.x1'); diff --git a/src/pinecone.ts b/src/pinecone.ts index 701392f3..a0b9d88f 100644 --- a/src/pinecone.ts +++ b/src/pinecone.ts @@ -14,7 +14,7 @@ import { CollectionName, } from './control'; import { - ConfigureIndexRequest, + ConfigureIndexRequestSpecPod, CreateCollectionRequest, } from './pinecone-generated-ts-fetch'; import { IndexHostSingleton } from './data/indexHostSingleton'; @@ -199,16 +199,16 @@ export class Pinecone { * ``` * * @param indexName - The name of the index to describe. - * @returns A promise that resolves to {@link IndexMeta} + * @returns A promise that resolves to {@link IndexModel} */ describeIndex(indexName: IndexName) { const describeIndexPromise = this._describeIndex(indexName); // For any describeIndex calls we want to update the IndexHostSingleton cache. // This prevents unneeded calls to describeIndex for resolving the host for vector operations. - describeIndexPromise.then((indexMeta) => { - if (indexMeta.host) { - IndexHostSingleton._set(this.config, indexName, indexMeta.host); + describeIndexPromise.then((indexModel) => { + if (indexModel.host) { + IndexHostSingleton._set(this.config, indexName, indexModel.host); } }); @@ -336,8 +336,8 @@ export class Pinecone { * @param indexName - The name of the index to configure. * @param options - The configuration properties you would like to update */ - configureIndex(indexName: IndexName, options: ConfigureIndexRequest) { - return this._configureIndex({ indexName, configureIndexRequest: options }); + configureIndex(indexName: IndexName, options: ConfigureIndexRequestSpecPod) { + return this._configureIndex(indexName, options); } /** From 74004e2ca9af177ffb001f1e0994801dd96c88a7 Mon Sep 17 00:00:00 2001 From: Austin DeNoble Date: Tue, 21 Nov 2023 22:56:43 -0500 Subject: [PATCH 8/9] review feedback: rename httpHeaders to additionalHeaders, remove commented code --- src/control/indexOperationsBuilder.ts | 2 +- src/control/listIndexes.ts | 25 ------------------------- src/data/types.ts | 4 ++-- 3 files changed, 3 insertions(+), 28 deletions(-) diff --git a/src/control/indexOperationsBuilder.ts b/src/control/indexOperationsBuilder.ts index 022d99dd..fae1f399 100644 --- a/src/control/indexOperationsBuilder.ts +++ b/src/control/indexOperationsBuilder.ts @@ -12,7 +12,7 @@ export const indexOperationsBuilder = ( ): ManagePodIndexesApi => { const { apiKey } = config; const controllerPath = config.controllerHostUrl || 'https://api.pinecone.io'; - const headers = config.httpHeaders || null; + const headers = config.additionalHeaders || null; const apiConfig: IndexOperationsApiConfigurationParameters = { basePath: controllerPath, apiKey, diff --git a/src/control/listIndexes.ts b/src/control/listIndexes.ts index 1a38642e..30493c46 100644 --- a/src/control/listIndexes.ts +++ b/src/control/listIndexes.ts @@ -1,30 +1,5 @@ import { ManagePodIndexesApi, IndexList } from '../pinecone-generated-ts-fetch'; -/** - * A description of indexes in your project. - * - * For full information about each index, see { @link Pinecone.describeIndex } - */ -// export type IndexListDescription = { -// /** The name of the index */ -// name: string; - -// /** The distance metric of the index */ -// metric: string; - -// /** The dimension of the index */ -// dimension: number; - -// /** The capacityMode of the index */ -// capacityMode: string; - -// /** The host address of the index */ -// host: string; -// }; - -// /** The list of indexes in your project */ -// export type IndexList = Array; - export const listIndexes = (api: ManagePodIndexesApi) => { return async (): Promise => { const response = await api.listIndexes(); diff --git a/src/data/types.ts b/src/data/types.ts index 37f34bb2..14650434 100644 --- a/src/data/types.ts +++ b/src/data/types.ts @@ -13,7 +13,7 @@ export const PineconeConfigurationSchema = Type.Object( // in the additionalProperties check. fetchApi: Type.Optional(Type.Any()), - httpHeaders: Type.Optional(Type.Any()), + additionalHeaders: Type.Optional(Type.Any()), }, { additionalProperties: false } ); @@ -40,7 +40,7 @@ export type PineconeConfiguration = { /** * Optional headers to be included in all requests. */ - httpHeaders?: HTTPHeaders; + additionalHeaders?: HTTPHeaders; }; /** Configuration for a single Pinecone Index */ From c3b5c508c2c2fc2ba0c15bc322f125cf8fdc7b1a Mon Sep 17 00:00:00 2001 From: Austin DeNoble Date: Tue, 21 Nov 2023 23:07:24 -0500 Subject: [PATCH 9/9] update urls in errorHandling integration tests --- src/integration/errorHandling.test.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/integration/errorHandling.test.ts b/src/integration/errorHandling.test.ts index 55e8dfe4..05a175af 100644 --- a/src/integration/errorHandling.test.ts +++ b/src/integration/errorHandling.test.ts @@ -15,7 +15,7 @@ describe('Error handling', () => { const err = e as PineconeConnectionError; expect(err.name).toEqual('PineconeUnmappedHttpError'); expect(err.message).toEqual( - 'An unexpected error occured while calling the https://api.pinecone.io/databases endpoint. Unknown or invalid API Key Status: 403.' + 'An unexpected error occured while calling the https://api.pinecone.io/indexes endpoint. Unknown or invalid API Key Status: 403.' ); // TODO: Update when cause is populated // expect(err.cause).toBeDefined(); @@ -34,7 +34,7 @@ describe('Error handling', () => { const err = e as PineconeConnectionError; expect(err.name).toEqual('PineconeUnmappedHttpError'); expect(err.message).toEqual( - 'An unexpected error occured while calling the https://api.pinecone.io/databases/foo-index endpoint. Unknown or invalid API Key Status: 403.' + 'An unexpected error occured while calling the https://api.pinecone.io/indexes/foo-index endpoint. Unknown or invalid API Key Status: 403.' ); } }); @@ -74,7 +74,7 @@ describe('Error handling', () => { const err = e as PineconeConnectionError; expect(err.name).toEqual('PineconeUnmappedHttpError'); expect(err.message).toEqual( - `An unexpected error occured while calling the https://api.pinecone.io/databases/foo-index endpoint. Unknown or invalid API Key Status: 403.` + `An unexpected error occured while calling the https://api.pinecone.io/indexes/foo-index endpoint. Unknown or invalid API Key Status: 403.` ); } });