pinecone-io / pinecone-ts-client

The official TypeScript/Node client for the Pinecone vector database
https://www.pinecone.io
Apache License 2.0
182 stars 38 forks source link

[Feature] Export `ListResponse` type #209

Closed MikeCarbone closed 6 months ago

MikeCarbone commented 6 months ago

Is this your first time submitting a feature request?

Describe the feature

When incorporating the delete function using the new serverless API, I needed access to the ListResponse type for this function, which will recursively delete all vectors related to a source document:

async function deletePineconePage(page: ListResponse) {
  if (page.vectors) {
    const pageVectorIds = page.vectors.map((vector) => vector.id);
    await index.deleteMany(pageVectorIds);
    if (page?.pagination?.next) {
      const nextPage = await index.listPaginated({
        prefix: `source_${sourceId}#`,
        paginationToken: page.pagination.next,
      });
      return await deletePineconePage(nextPage);
    }
  }
}
const initialPage = await index.listPaginated({
  prefix: `source_${sourceId}#`,
});
await deletePineconePage(initialPage);

Describe alternatives you've considered

Unfortunately, that ListResponse type is not exported from the main package. Instead I had to import the type from the build:

import type { ListResponse } from "@pinecone-database/pinecone/dist/pinecone-generated-ts-fetch";

Who will this benefit?

Anyone trying to access the type after using the new index.listPaginated option

Are you interested in contributing this feature?

No

Anything else?

No response

austin-denoble commented 6 months ago

Thank you for flagging, this interface should have been exported from the top level of the package. v2.1.1 exports the interface. You can find details here: https://github.com/pinecone-io/pinecone-ts-client/releases/tag/v2.1.1

MikeCarbone commented 6 months ago

Great! Thanks @austin-denoble !