// AUTO-GENERATED by scripts/generate.ts from .generated-specs. Do not edit. import * as S from "@distilled.cloud/core/schema"; import * as API from "@distilled.cloud/core/api"; import * as T from "../traits.ts"; import { CloudflareProtocol, CloudflarePaginatedProtocol, type CloudflareOpError, type CloudflareOpContext, } from "../protocol.ts"; import { cloudflarePaginate, ResultInfo } from "../pagination.ts"; import { CloudflareError, CloudflareRateLimited } from "../errors.ts"; import * as Retry from "../retry.ts"; export type { CloudflareOpError, CloudflareOpContext }; /** Fallback camelCase→wire mapping for opaque content (mined from the distilled SDK). */ const KEY_DICTIONARY: Record> = { createdOn: "created_on", modifiedOn: "modified_on", }; export class Gone extends /*@__PURE__*/ T.applyErrorMatchers( /*@__PURE__*/ S.TaggedError()("Gone", { code: S.Number, message: S.String, }), [{ code: 3005 }, { message: { includes: "index deleted" } }], ) {} export class IndexAlreadyExists extends /*@__PURE__*/ T.applyErrorMatchers( /*@__PURE__*/ S.TaggedError()("IndexAlreadyExists", { code: S.Number, message: S.String, }), [{ code: 3002 }], ) {} export class IndexInvalidConfig extends /*@__PURE__*/ T.applyErrorMatchers( /*@__PURE__*/ S.TaggedError()("IndexInvalidConfig", { code: S.Number, message: S.String, }), [{ code: 3003 }], ) {} export class IndexInvalidName extends /*@__PURE__*/ T.applyErrorMatchers( /*@__PURE__*/ S.TaggedError()("IndexInvalidName", { code: S.Number, message: S.String, }), [{ code: 3001 }], ) {} export class MetadataIndexAlreadyExists extends /*@__PURE__*/ T.applyErrorMatchers( /*@__PURE__*/ S.TaggedError()( "MetadataIndexAlreadyExists", { code: S.Number, message: S.String, }, ), [{ code: 40004 }], ) {} export class MetadataIndexInvalidType extends /*@__PURE__*/ T.applyErrorMatchers( /*@__PURE__*/ S.TaggedError()( "MetadataIndexInvalidType", { code: S.Number, message: S.String, }, ), [{ code: 40026 }], ) {} export class MetadataIndexNotFound extends /*@__PURE__*/ T.applyErrorMatchers( /*@__PURE__*/ S.TaggedError()( "MetadataIndexNotFound", { code: S.Number, message: S.String, }, ), [{ code: 40005 }], ) {} export class NotFound extends /*@__PURE__*/ T.applyErrorMatchers( /*@__PURE__*/ S.TaggedError()("NotFound", { code: S.Number, message: S.String, }), [{ code: 3000 }], ) {} export type IndexesCreateRequestConfigIndexDimensionConfigurationMetric = | "cosine" | "euclidean" | "dot-product"; export const IndexesCreateRequestConfigIndexDimensionConfigurationMetric = /*@__PURE__*/ S.String; export interface IndexesCreateRequestConfigIndexDimensionConfiguration { /** Specifies the number of dimensions for the index */ dimensions: number; /** Specifies the type of metric to use calculating distance. */ metric: | IndexesCreateRequestConfigIndexDimensionConfigurationMetric | (string & {}); } export const IndexesCreateRequestConfigIndexDimensionConfiguration = /*@__PURE__*/ S.suspend(() => S.Struct({ dimensions: S.Number, metric: IndexesCreateRequestConfigIndexDimensionConfigurationMetric, }), ).annotate({ identifier: "IndexesCreateRequestConfigIndexDimensionConfiguration", }) as any as S.Schema; export type IndexesCreateRequestConfigVectorizeIndexPresetConfigurationPreset = | "@cf/baai/bge-small-en-v1.5" | "@cf/baai/bge-base-en-v1.5" | "@cf/baai/bge-large-en-v1.5" | "openai/text-embedding-ada-002" | "cohere/embed-multilingual-v2.0"; export const IndexesCreateRequestConfigVectorizeIndexPresetConfigurationPreset = /*@__PURE__*/ S.String; export interface IndexesCreateRequestConfigVectorizeIndexPresetConfiguration { /** Specifies the preset to use for the index. */ preset: | IndexesCreateRequestConfigVectorizeIndexPresetConfigurationPreset | (string & {}); } export const IndexesCreateRequestConfigVectorizeIndexPresetConfiguration = /*@__PURE__*/ S.suspend(() => S.Struct({ preset: IndexesCreateRequestConfigVectorizeIndexPresetConfigurationPreset, }), ).annotate({ identifier: "IndexesCreateRequestConfigVectorizeIndexPresetConfiguration", }) as any as S.Schema; export type IndexesCreateRequestConfig = | IndexesCreateRequestConfigIndexDimensionConfiguration | IndexesCreateRequestConfigVectorizeIndexPresetConfiguration; export const IndexesCreateRequestConfig = /*@__PURE__*/ S.Unknown.pipe( T.UnionCases([["dimensions", "metric"], ["preset"]]), ); export interface CreateIndexRequest { /** Identifier */ accountId: string; /** Specifies the type of configuration to use for the index. */ config: IndexesCreateRequestConfig; name: string; /** Specifies the description of the index. */ description?: string; } export const CreateIndexRequest = /*@__PURE__*/ S.suspend(() => S.Struct({ accountId: S.String.pipe(T.Label("account_id")), config: IndexesCreateRequestConfig, name: S.String, description: S.optional(S.String), }) .pipe( T.Http({ method: "POST", uri: "/accounts/{account_id}/vectorize/v2/indexes", code: 200, }), ) .pipe(T.KeyDictionary(KEY_DICTIONARY)), ).annotate({ identifier: "CreateIndexRequest", }) as any as S.Schema; export type IndexesCreateResponseConfigMetric = | "cosine" | "euclidean" | "dot-product"; export const IndexesCreateResponseConfigMetric = /*@__PURE__*/ S.String; export interface IndexesCreateResponseConfig { /** Specifies the number of dimensions for the index */ dimensions: number; /** Specifies the type of metric to use calculating distance. */ metric: IndexesCreateResponseConfigMetric; } export const IndexesCreateResponseConfig = /*@__PURE__*/ S.suspend(() => S.Struct({ dimensions: S.Number, metric: IndexesCreateResponseConfigMetric, }), ).annotate({ identifier: "IndexesCreateResponseConfig", }) as any as S.Schema; /** Unwrapped `result` payload of the Cloudflare v4 response envelope. */ export interface CreateIndexResponse { config?: IndexesCreateResponseConfig | null; /** Specifies the timestamp the resource was created as an ISO8601 string. */ createdOn?: string | null; /** Specifies the description of the index. */ description?: string | null; /** Specifies the timestamp the resource was modified as an ISO8601 string. */ modifiedOn?: string | null; name?: string | null; } export const CreateIndexResponse = /*@__PURE__*/ S.suspend(() => S.Struct({ config: S.optional(S.NullOr(IndexesCreateResponseConfig)), createdOn: S.optional(S.NullOr(S.String).pipe(T.Body("created_on"))), description: S.optional(S.NullOr(S.String)), modifiedOn: S.optional(S.NullOr(S.String).pipe(T.Body("modified_on"))), name: S.optional(S.NullOr(S.String)), }).pipe(T.KeyDictionary(KEY_DICTIONARY)), ).annotate({ identifier: "CreateIndexResponse", }) as any as S.Schema; export type IndexesMetadataIndexCreateRequestIndexType = | "string" | "number" | "boolean"; export const IndexesMetadataIndexCreateRequestIndexType = /*@__PURE__*/ S.String; export interface CreateIndexMetadataIndexRequest { /** Identifier */ accountId: string; indexName: string; /** Specifies the type of metadata property to index. */ indexType: IndexesMetadataIndexCreateRequestIndexType | (string & {}); /** Specifies the metadata property to index. */ propertyName: string; } export const CreateIndexMetadataIndexRequest = /*@__PURE__*/ S.suspend(() => S.Struct({ accountId: S.String.pipe(T.Label("account_id")), indexName: S.String.pipe(T.Label("index_name")), indexType: IndexesMetadataIndexCreateRequestIndexType, propertyName: S.String, }) .pipe( T.Http({ method: "POST", uri: "/accounts/{account_id}/vectorize/v2/indexes/{index_name}/metadata_index/create", code: 200, }), ) .pipe(T.KeyDictionary(KEY_DICTIONARY)), ).annotate({ identifier: "CreateIndexMetadataIndexRequest", }) as any as S.Schema; /** Unwrapped `result` payload of the Cloudflare v4 response envelope. */ export interface CreateIndexMetadataIndexResponse { /** The unique identifier for the async mutation operation containing the changeset. */ mutationId?: string | null; } export const CreateIndexMetadataIndexResponse = /*@__PURE__*/ S.suspend(() => S.Struct({ mutationId: S.optional(S.NullOr(S.String)), }).pipe(T.KeyDictionary(KEY_DICTIONARY)), ).annotate({ identifier: "CreateIndexMetadataIndexResponse", }) as any as S.Schema; export type IndexesDeleteByIdsRequestIdsList = Array; export const IndexesDeleteByIdsRequestIdsList = /*@__PURE__*/ S.Array( S.String, ) as any as S.Schema; export interface DeleteByIdsIndexRequest { /** Identifier */ accountId: string; indexName: string; /** A list of vector identifiers to delete from the index indicated by the path. */ ids?: IndexesDeleteByIdsRequestIdsList; } export const DeleteByIdsIndexRequest = /*@__PURE__*/ S.suspend(() => S.Struct({ accountId: S.String.pipe(T.Label("account_id")), indexName: S.String.pipe(T.Label("index_name")), ids: S.optional(IndexesDeleteByIdsRequestIdsList), }) .pipe( T.Http({ method: "POST", uri: "/accounts/{account_id}/vectorize/v2/indexes/{index_name}/delete_by_ids", code: 200, }), ) .pipe(T.KeyDictionary(KEY_DICTIONARY)), ).annotate({ identifier: "DeleteByIdsIndexRequest", }) as any as S.Schema; /** Unwrapped `result` payload of the Cloudflare v4 response envelope. */ export interface DeleteByIdsIndexResponse { /** The unique identifier for the async mutation operation containing the changeset. */ mutationId?: string | null; } export const DeleteByIdsIndexResponse = /*@__PURE__*/ S.suspend(() => S.Struct({ mutationId: S.optional(S.NullOr(S.String)), }).pipe(T.KeyDictionary(KEY_DICTIONARY)), ).annotate({ identifier: "DeleteByIdsIndexResponse", }) as any as S.Schema; export interface DeleteIndexRequest { /** Identifier */ accountId: string; indexName: string; } export const DeleteIndexRequest = /*@__PURE__*/ S.suspend(() => S.Struct({ accountId: S.String.pipe(T.Label("account_id")), indexName: S.String.pipe(T.Label("index_name")), }) .pipe( T.Http({ method: "DELETE", uri: "/accounts/{account_id}/vectorize/v2/indexes/{index_name}", code: 200, }), ) .pipe(T.KeyDictionary(KEY_DICTIONARY)), ).annotate({ identifier: "DeleteIndexRequest", }) as any as S.Schema; export type DeleteIndexResponse = unknown; export const DeleteIndexResponse = /*@__PURE__*/ S.suspend(() => S.Unknown.pipe(T.EnvelopePayloadRoot(), T.KeyDictionary(KEY_DICTIONARY)), ).annotate({ identifier: "DeleteIndexResponse", }) as any as S.Schema; export interface DeleteIndexMetadataIndexRequest { /** Identifier */ accountId: string; indexName: string; /** Specifies the metadata property for which the index must be deleted. */ propertyName: string; } export const DeleteIndexMetadataIndexRequest = /*@__PURE__*/ S.suspend(() => S.Struct({ accountId: S.String.pipe(T.Label("account_id")), indexName: S.String.pipe(T.Label("index_name")), propertyName: S.String, }) .pipe( T.Http({ method: "POST", uri: "/accounts/{account_id}/vectorize/v2/indexes/{index_name}/metadata_index/delete", code: 200, }), ) .pipe(T.KeyDictionary(KEY_DICTIONARY)), ).annotate({ identifier: "DeleteIndexMetadataIndexRequest", }) as any as S.Schema; /** Unwrapped `result` payload of the Cloudflare v4 response envelope. */ export interface DeleteIndexMetadataIndexResponse { /** The unique identifier for the async mutation operation containing the changeset. */ mutationId?: string | null; } export const DeleteIndexMetadataIndexResponse = /*@__PURE__*/ S.suspend(() => S.Struct({ mutationId: S.optional(S.NullOr(S.String)), }).pipe(T.KeyDictionary(KEY_DICTIONARY)), ).annotate({ identifier: "DeleteIndexMetadataIndexResponse", }) as any as S.Schema; export type IndexesGetByIdsRequestIdsList = Array; export const IndexesGetByIdsRequestIdsList = /*@__PURE__*/ S.Array( S.String, ) as any as S.Schema; export interface GetByIdsIndexRequest { /** Identifier */ accountId: string; indexName: string; /** A list of vector identifiers to retrieve from the index indicated by the path. */ ids?: IndexesGetByIdsRequestIdsList; } export const GetByIdsIndexRequest = /*@__PURE__*/ S.suspend(() => S.Struct({ accountId: S.String.pipe(T.Label("account_id")), indexName: S.String.pipe(T.Label("index_name")), ids: S.optional(IndexesGetByIdsRequestIdsList), }) .pipe( T.Http({ method: "POST", uri: "/accounts/{account_id}/vectorize/v2/indexes/{index_name}/get_by_ids", code: 200, }), ) .pipe(T.KeyDictionary(KEY_DICTIONARY)), ).annotate({ identifier: "GetByIdsIndexRequest", }) as any as S.Schema; export type GetByIdsIndexResponse = unknown; export const GetByIdsIndexResponse = /*@__PURE__*/ S.suspend(() => S.Unknown.pipe(T.EnvelopePayloadRoot(), T.KeyDictionary(KEY_DICTIONARY)), ).annotate({ identifier: "GetByIdsIndexResponse", }) as any as S.Schema; export interface GetIndexRequest { /** Identifier */ accountId: string; indexName: string; } export const GetIndexRequest = /*@__PURE__*/ S.suspend(() => S.Struct({ accountId: S.String.pipe(T.Label("account_id")), indexName: S.String.pipe(T.Label("index_name")), }) .pipe( T.Http({ method: "GET", uri: "/accounts/{account_id}/vectorize/v2/indexes/{index_name}", code: 200, }), ) .pipe(T.KeyDictionary(KEY_DICTIONARY)), ).annotate({ identifier: "GetIndexRequest", }) as any as S.Schema; export type IndexesGetResponseConfigMetric = | "cosine" | "euclidean" | "dot-product"; export const IndexesGetResponseConfigMetric = /*@__PURE__*/ S.String; export interface IndexesGetResponseConfig { /** Specifies the number of dimensions for the index */ dimensions: number; /** Specifies the type of metric to use calculating distance. */ metric: IndexesGetResponseConfigMetric; } export const IndexesGetResponseConfig = /*@__PURE__*/ S.suspend(() => S.Struct({ dimensions: S.Number, metric: IndexesGetResponseConfigMetric, }), ).annotate({ identifier: "IndexesGetResponseConfig", }) as any as S.Schema; /** Unwrapped `result` payload of the Cloudflare v4 response envelope. */ export interface GetIndexResponse { config?: IndexesGetResponseConfig | null; /** Specifies the timestamp the resource was created as an ISO8601 string. */ createdOn?: string | null; /** Specifies the description of the index. */ description?: string | null; /** Specifies the timestamp the resource was modified as an ISO8601 string. */ modifiedOn?: string | null; name?: string | null; } export const GetIndexResponse = /*@__PURE__*/ S.suspend(() => S.Struct({ config: S.optional(S.NullOr(IndexesGetResponseConfig)), createdOn: S.optional(S.NullOr(S.String).pipe(T.Body("created_on"))), description: S.optional(S.NullOr(S.String)), modifiedOn: S.optional(S.NullOr(S.String).pipe(T.Body("modified_on"))), name: S.optional(S.NullOr(S.String)), }).pipe(T.KeyDictionary(KEY_DICTIONARY)), ).annotate({ identifier: "GetIndexResponse", }) as any as S.Schema; export interface GetIndexInfoRequest { /** Identifier */ accountId: string; indexName: string; } export const GetIndexInfoRequest = /*@__PURE__*/ S.suspend(() => S.Struct({ accountId: S.String.pipe(T.Label("account_id")), indexName: S.String.pipe(T.Label("index_name")), }) .pipe( T.Http({ method: "GET", uri: "/accounts/{account_id}/vectorize/v2/indexes/{index_name}/info", code: 200, }), ) .pipe(T.KeyDictionary(KEY_DICTIONARY)), ).annotate({ identifier: "GetIndexInfoRequest", }) as any as S.Schema; /** Unwrapped `result` payload of the Cloudflare v4 response envelope. */ export interface GetIndexInfoResponse { /** Specifies the number of dimensions for the index */ dimensions?: number | null; /** Specifies the timestamp the last mutation batch was processed as an ISO8601 string. */ processedUpToDatetime?: string | null; /** The unique identifier for the async mutation operation containing the changeset. */ processedUpToMutation?: string | null; /** Specifies the number of vectors present in the index */ vectorCount?: number | null; } export const GetIndexInfoResponse = /*@__PURE__*/ S.suspend(() => S.Struct({ dimensions: S.optional(S.NullOr(S.Number)), processedUpToDatetime: S.optional(S.NullOr(S.String)), processedUpToMutation: S.optional(S.NullOr(S.String)), vectorCount: S.optional(S.NullOr(S.Number)), }).pipe(T.KeyDictionary(KEY_DICTIONARY)), ).annotate({ identifier: "GetIndexInfoResponse", }) as any as S.Schema; export type IndexesInsertRequestUnparsableBehavior = "error" | "discard"; export const IndexesInsertRequestUnparsableBehavior = /*@__PURE__*/ S.String; export interface InsertIndexRequest { /** Identifier */ accountId: string; indexName: string; /** Behavior for ndjson parse failures. */ unparsableBehavior?: IndexesInsertRequestUnparsableBehavior | (string & {}); /** Vectors as newline-delimited JSON (application/x-ndjson), one vector object per line. */ body: Blob | Uint8Array | ArrayBuffer | string; } export const InsertIndexRequest = /*@__PURE__*/ S.suspend(() => S.Struct({ accountId: S.String.pipe(T.Label("account_id")), indexName: S.String.pipe(T.Label("index_name")), unparsableBehavior: S.optional( IndexesInsertRequestUnparsableBehavior.pipe( T.Query("unparsable-behavior"), ), ), body: S.String.pipe(T.HttpBody()), }) .pipe( T.Http({ method: "POST", uri: "/accounts/{account_id}/vectorize/v2/indexes/{index_name}/insert", code: 200, bodyMediaType: "application/x-ndjson", }), ) .pipe(T.KeyDictionary(KEY_DICTIONARY)), ).annotate({ identifier: "InsertIndexRequest", }) as any as S.Schema; /** Unwrapped `result` payload of the Cloudflare v4 response envelope. */ export interface InsertIndexResponse { /** The unique identifier for the async mutation operation containing the changeset. */ mutationId?: string | null; } export const InsertIndexResponse = /*@__PURE__*/ S.suspend(() => S.Struct({ mutationId: S.optional(S.NullOr(S.String)), }).pipe(T.KeyDictionary(KEY_DICTIONARY)), ).annotate({ identifier: "InsertIndexResponse", }) as any as S.Schema; export interface ListIndexesRequest { /** Identifier */ accountId: string; } export const ListIndexesRequest = /*@__PURE__*/ S.suspend(() => S.Struct({ accountId: S.String.pipe(T.Label("account_id")), }) .pipe( T.Http({ method: "GET", uri: "/accounts/{account_id}/vectorize/v2/indexes", code: 200, }), ) .pipe(T.KeyDictionary(KEY_DICTIONARY)), ).annotate({ identifier: "ListIndexesRequest", }) as any as S.Schema; export type IndexesListResultItemConfigMetric = | "cosine" | "euclidean" | "dot-product"; export const IndexesListResultItemConfigMetric = /*@__PURE__*/ S.String; export interface IndexesListResultItemConfig { /** Specifies the number of dimensions for the index */ dimensions: number; /** Specifies the type of metric to use calculating distance. */ metric: IndexesListResultItemConfigMetric; } export const IndexesListResultItemConfig = /*@__PURE__*/ S.suspend(() => S.Struct({ dimensions: S.Number, metric: IndexesListResultItemConfigMetric, }), ).annotate({ identifier: "IndexesListResultItemConfig", }) as any as S.Schema; export interface IndexesListResultItem { config?: IndexesListResultItemConfig | null; /** Specifies the timestamp the resource was created as an ISO8601 string. */ createdOn?: string | null; /** Specifies the description of the index. */ description?: string | null; /** Specifies the timestamp the resource was modified as an ISO8601 string. */ modifiedOn?: string | null; name?: string | null; } export const IndexesListResultItem = /*@__PURE__*/ S.suspend(() => S.Struct({ config: S.optional(S.NullOr(IndexesListResultItemConfig)), createdOn: S.optional(S.NullOr(S.String).pipe(T.Body("created_on"))), description: S.optional(S.NullOr(S.String)), modifiedOn: S.optional(S.NullOr(S.String).pipe(T.Body("modified_on"))), name: S.optional(S.NullOr(S.String)), }), ).annotate({ identifier: "IndexesListResultItem", }) as any as S.Schema; export type IndexesListResultList = Array; export const IndexesListResultList = /*@__PURE__*/ S.Array( IndexesListResultItem, ) as any as S.Schema; export interface ListIndexesResponse { /** The unwrapped `result` payload of the v4 response envelope. */ result: IndexesListResultList; /** Pagination info from the envelope's `result_info`. */ resultInfo?: ResultInfo | null; } export const ListIndexesResponse = /*@__PURE__*/ S.suspend(() => S.Struct({ result: IndexesListResultList.pipe(T.EnvelopePayload()), resultInfo: S.optional(S.NullOr(ResultInfo).pipe(T.ResultInfo())), }).pipe(T.KeyDictionary(KEY_DICTIONARY)), ).annotate({ identifier: "ListIndexesResponse", }) as any as S.Schema; export interface ListIndexMetadataIndexesRequest { /** Identifier */ accountId: string; indexName: string; } export const ListIndexMetadataIndexesRequest = /*@__PURE__*/ S.suspend(() => S.Struct({ accountId: S.String.pipe(T.Label("account_id")), indexName: S.String.pipe(T.Label("index_name")), }) .pipe( T.Http({ method: "GET", uri: "/accounts/{account_id}/vectorize/v2/indexes/{index_name}/metadata_index/list", code: 200, }), ) .pipe(T.KeyDictionary(KEY_DICTIONARY)), ).annotate({ identifier: "ListIndexMetadataIndexesRequest", }) as any as S.Schema; export type IndexesMetadataIndexListResponseMetadataIndexesItemIndexType = | "string" | "number" | "boolean"; export const IndexesMetadataIndexListResponseMetadataIndexesItemIndexType = /*@__PURE__*/ S.String; export interface IndexesMetadataIndexListResponseMetadataIndexesItem { /** Specifies the type of indexed metadata property. */ indexType?: IndexesMetadataIndexListResponseMetadataIndexesItemIndexType | null; /** Specifies the indexed metadata property. */ propertyName?: string | null; } export const IndexesMetadataIndexListResponseMetadataIndexesItem = /*@__PURE__*/ S.suspend(() => S.Struct({ indexType: S.optional( S.NullOr(IndexesMetadataIndexListResponseMetadataIndexesItemIndexType), ), propertyName: S.optional(S.NullOr(S.String)), }), ).annotate({ identifier: "IndexesMetadataIndexListResponseMetadataIndexesItem", }) as any as S.Schema; export type IndexesMetadataIndexListResponseMetadataIndexesList = Array; export const IndexesMetadataIndexListResponseMetadataIndexesList = /*@__PURE__*/ S.Array( IndexesMetadataIndexListResponseMetadataIndexesItem, ) as any as S.Schema; /** Unwrapped `result` payload of the Cloudflare v4 response envelope. */ export interface ListIndexMetadataIndexesResponse { /** Array of indexed metadata properties. */ metadataIndexes?: IndexesMetadataIndexListResponseMetadataIndexesList | null; } export const ListIndexMetadataIndexesResponse = /*@__PURE__*/ S.suspend(() => S.Struct({ metadataIndexes: S.optional( S.NullOr(IndexesMetadataIndexListResponseMetadataIndexesList), ), }).pipe(T.KeyDictionary(KEY_DICTIONARY)), ).annotate({ identifier: "ListIndexMetadataIndexesResponse", }) as any as S.Schema; export interface ListVectorsIndexRequest { /** Identifier */ accountId: string; indexName: string; /** Maximum number of vectors to return */ count?: number; /** Cursor for pagination to get the next page of results */ cursor?: string; } export const ListVectorsIndexRequest = /*@__PURE__*/ S.suspend(() => S.Struct({ accountId: S.String.pipe(T.Label("account_id")), indexName: S.String.pipe(T.Label("index_name")), count: S.optional(S.Number.pipe(T.Query())), cursor: S.optional(S.String.pipe(T.Query())), }) .pipe( T.Http({ method: "GET", uri: "/accounts/{account_id}/vectorize/v2/indexes/{index_name}/list", code: 200, }), ) .pipe(T.KeyDictionary(KEY_DICTIONARY)), ).annotate({ identifier: "ListVectorsIndexRequest", }) as any as S.Schema; export interface IndexesListVectorsResponseVectorsItem { /** Identifier for a Vector */ id: string; } export const IndexesListVectorsResponseVectorsItem = /*@__PURE__*/ S.suspend( () => S.Struct({ id: S.String, }), ).annotate({ identifier: "IndexesListVectorsResponseVectorsItem", }) as any as S.Schema; export type IndexesListVectorsResponseVectorsList = Array; export const IndexesListVectorsResponseVectorsList = /*@__PURE__*/ S.Array( IndexesListVectorsResponseVectorsItem, ) as any as S.Schema; /** Unwrapped `result` payload of the Cloudflare v4 response envelope. */ export interface ListVectorsIndexResponse { /** Number of vectors returned in this response */ count: number; /** Whether there are more vectors available beyond this response */ isTruncated: boolean; /** Total number of vectors in the index */ totalCount: number; /** Array of vector items */ vectors: IndexesListVectorsResponseVectorsList; /** When the cursor expires as an ISO8601 string */ cursorExpirationTimestamp?: string | null; /** Cursor for the next page of results */ nextCursor?: string | null; } export const ListVectorsIndexResponse = /*@__PURE__*/ S.suspend(() => S.Struct({ count: S.Number, isTruncated: S.Boolean, totalCount: S.Number, vectors: IndexesListVectorsResponseVectorsList, cursorExpirationTimestamp: S.optional(S.NullOr(S.String)), nextCursor: S.optional(S.NullOr(S.String)), }).pipe(T.KeyDictionary(KEY_DICTIONARY)), ).annotate({ identifier: "ListVectorsIndexResponse", }) as any as S.Schema; export type IndexesQueryRequestVectorList = Array; export const IndexesQueryRequestVectorList = /*@__PURE__*/ S.Array( S.Number, ) as any as S.Schema; export type IndexesQueryRequestReturnMetadata = "none" | "indexed" | "all"; export const IndexesQueryRequestReturnMetadata = /*@__PURE__*/ S.String; export interface QueryIndexRequest { /** Identifier */ accountId: string; indexName: string; /** The search vector that will be used to find the nearest neighbors. */ vector: IndexesQueryRequestVectorList; /** A metadata filter expression used to limit nearest neighbor results. */ filter?: unknown; /** Whether to return no metadata, indexed metadata or all metadata associated with the closest vectors. */ returnMetadata?: IndexesQueryRequestReturnMetadata | (string & {}); /** Whether to return the values associated with the closest vectors. */ returnValues?: boolean; /** The number of nearest neighbors to find. */ topK?: number; } export const QueryIndexRequest = /*@__PURE__*/ S.suspend(() => S.Struct({ accountId: S.String.pipe(T.Label("account_id")), indexName: S.String.pipe(T.Label("index_name")), vector: IndexesQueryRequestVectorList, filter: S.optional(S.Unknown), returnMetadata: S.optional(IndexesQueryRequestReturnMetadata), returnValues: S.optional(S.Boolean), topK: S.optional(S.Number), }) .pipe( T.Http({ method: "POST", uri: "/accounts/{account_id}/vectorize/v2/indexes/{index_name}/query", code: 200, }), ) .pipe(T.KeyDictionary(KEY_DICTIONARY)), ).annotate({ identifier: "QueryIndexRequest", }) as any as S.Schema; export type IndexesQueryResponseMatchesItemValuesList = Array; export const IndexesQueryResponseMatchesItemValuesList = /*@__PURE__*/ S.Array( S.Number, ) as any as S.Schema; export interface IndexesQueryResponseMatchesItem { /** Identifier for a Vector */ id?: string | null; metadata?: unknown | null; namespace?: string | null; /** The score of the vector according to the index's distance metric */ score?: number | null; values?: IndexesQueryResponseMatchesItemValuesList | null; } export const IndexesQueryResponseMatchesItem = /*@__PURE__*/ S.suspend(() => S.Struct({ id: S.optional(S.NullOr(S.String)), metadata: S.optional(S.NullOr(S.Unknown)), namespace: S.optional(S.NullOr(S.String)), score: S.optional(S.NullOr(S.Number)), values: S.optional(S.NullOr(IndexesQueryResponseMatchesItemValuesList)), }), ).annotate({ identifier: "IndexesQueryResponseMatchesItem", }) as any as S.Schema; export type IndexesQueryResponseMatchesList = Array; export const IndexesQueryResponseMatchesList = /*@__PURE__*/ S.Array( IndexesQueryResponseMatchesItem, ) as any as S.Schema; /** Unwrapped `result` payload of the Cloudflare v4 response envelope. */ export interface QueryIndexResponse { /** Specifies the count of vectors returned by the search */ count?: number | null; /** Array of vectors matched by the search */ matches?: IndexesQueryResponseMatchesList | null; } export const QueryIndexResponse = /*@__PURE__*/ S.suspend(() => S.Struct({ count: S.optional(S.NullOr(S.Number)), matches: S.optional(S.NullOr(IndexesQueryResponseMatchesList)), }).pipe(T.KeyDictionary(KEY_DICTIONARY)), ).annotate({ identifier: "QueryIndexResponse", }) as any as S.Schema; export type IndexesUpsertRequestUnparsableBehavior = "error" | "discard"; export const IndexesUpsertRequestUnparsableBehavior = /*@__PURE__*/ S.String; export interface UpsertIndexRequest { /** Identifier */ accountId: string; indexName: string; /** Behavior for ndjson parse failures. */ unparsableBehavior?: IndexesUpsertRequestUnparsableBehavior | (string & {}); /** Vectors as newline-delimited JSON (application/x-ndjson), one vector object per line. */ body: Blob | Uint8Array | ArrayBuffer | string; } export const UpsertIndexRequest = /*@__PURE__*/ S.suspend(() => S.Struct({ accountId: S.String.pipe(T.Label("account_id")), indexName: S.String.pipe(T.Label("index_name")), unparsableBehavior: S.optional( IndexesUpsertRequestUnparsableBehavior.pipe( T.Query("unparsable-behavior"), ), ), body: S.String.pipe(T.HttpBody()), }) .pipe( T.Http({ method: "POST", uri: "/accounts/{account_id}/vectorize/v2/indexes/{index_name}/upsert", code: 200, bodyMediaType: "application/x-ndjson", }), ) .pipe(T.KeyDictionary(KEY_DICTIONARY)), ).annotate({ identifier: "UpsertIndexRequest", }) as any as S.Schema; /** Unwrapped `result` payload of the Cloudflare v4 response envelope. */ export interface UpsertIndexResponse { /** The unique identifier for the async mutation operation containing the changeset. */ mutationId?: string | null; } export const UpsertIndexResponse = /*@__PURE__*/ S.suspend(() => S.Struct({ mutationId: S.optional(S.NullOr(S.String)), }).pipe(T.KeyDictionary(KEY_DICTIONARY)), ).annotate({ identifier: "UpsertIndexResponse", }) as any as S.Schema; export type CreateIndexError = | IndexAlreadyExists | IndexInvalidName | IndexInvalidConfig | CloudflareOpError; /** Creates and returns a new Vectorize Index. */ export const createIndex: API.OperationMethod< CreateIndexRequest, CreateIndexResponse, CreateIndexError, CloudflareOpContext > = /*@__PURE__*/ API.make(() => ({ input: CreateIndexRequest, output: CreateIndexResponse, errors: [ IndexAlreadyExists, IndexInvalidName, IndexInvalidConfig, CloudflareRateLimited, CloudflareError, ], protocol: CloudflareProtocol, retry: Retry.Retry, })); export type CreateIndexMetadataIndexError = | NotFound | MetadataIndexAlreadyExists | MetadataIndexInvalidType | CloudflareOpError; /** Enable metadata filtering based on metadata property. Limited to 10 properties. */ export const createIndexMetadataIndex: API.OperationMethod< CreateIndexMetadataIndexRequest, CreateIndexMetadataIndexResponse, CreateIndexMetadataIndexError, CloudflareOpContext > = /*@__PURE__*/ API.make(() => ({ input: CreateIndexMetadataIndexRequest, output: CreateIndexMetadataIndexResponse, errors: [ NotFound, MetadataIndexAlreadyExists, MetadataIndexInvalidType, CloudflareRateLimited, CloudflareError, ], protocol: CloudflareProtocol, retry: Retry.Retry, })); export type DeleteByIdsIndexError = CloudflareOpError; /** Delete a set of vectors from an index by their vector identifiers. */ export const deleteByIdsIndex: API.OperationMethod< DeleteByIdsIndexRequest, DeleteByIdsIndexResponse, DeleteByIdsIndexError, CloudflareOpContext > = /*@__PURE__*/ API.make(() => ({ input: DeleteByIdsIndexRequest, output: DeleteByIdsIndexResponse, errors: [CloudflareRateLimited, CloudflareError], protocol: CloudflareProtocol, retry: Retry.Retry, })); export type DeleteIndexError = NotFound | Gone | CloudflareOpError; /** Deletes the specified Vectorize Index. */ export const deleteIndex: API.OperationMethod< DeleteIndexRequest, DeleteIndexResponse, DeleteIndexError, CloudflareOpContext > = /*@__PURE__*/ API.make(() => ({ input: DeleteIndexRequest, output: DeleteIndexResponse, errors: [NotFound, Gone, CloudflareRateLimited, CloudflareError], protocol: CloudflareProtocol, retry: Retry.Retry, })); export type DeleteIndexMetadataIndexError = | NotFound | Gone | MetadataIndexNotFound | CloudflareOpError; /** Allow Vectorize to delete the specified metadata index. */ export const deleteIndexMetadataIndex: API.OperationMethod< DeleteIndexMetadataIndexRequest, DeleteIndexMetadataIndexResponse, DeleteIndexMetadataIndexError, CloudflareOpContext > = /*@__PURE__*/ API.make(() => ({ input: DeleteIndexMetadataIndexRequest, output: DeleteIndexMetadataIndexResponse, errors: [ NotFound, Gone, MetadataIndexNotFound, CloudflareRateLimited, CloudflareError, ], protocol: CloudflareProtocol, retry: Retry.Retry, })); export type GetByIdsIndexError = CloudflareOpError; /** Get a set of vectors from an index by their vector identifiers. */ export const getByIdsIndex: API.OperationMethod< GetByIdsIndexRequest, GetByIdsIndexResponse, GetByIdsIndexError, CloudflareOpContext > = /*@__PURE__*/ API.make(() => ({ input: GetByIdsIndexRequest, output: GetByIdsIndexResponse, errors: [CloudflareRateLimited, CloudflareError], protocol: CloudflareProtocol, retry: Retry.Retry, })); export type GetIndexError = NotFound | Gone | CloudflareOpError; /** Returns the specified Vectorize Index. */ export const getIndex: API.OperationMethod< GetIndexRequest, GetIndexResponse, GetIndexError, CloudflareOpContext > = /*@__PURE__*/ API.make(() => ({ input: GetIndexRequest, output: GetIndexResponse, errors: [NotFound, Gone, CloudflareRateLimited, CloudflareError], protocol: CloudflareProtocol, retry: Retry.Retry, })); export type GetIndexInfoError = CloudflareOpError; /** Get information about a vectorize index. */ export const getIndexInfo: API.OperationMethod< GetIndexInfoRequest, GetIndexInfoResponse, GetIndexInfoError, CloudflareOpContext > = /*@__PURE__*/ API.make(() => ({ input: GetIndexInfoRequest, output: GetIndexInfoResponse, errors: [CloudflareRateLimited, CloudflareError], protocol: CloudflareProtocol, retry: Retry.Retry, })); export type InsertIndexError = CloudflareOpError; /** Inserts vectors into the specified index and returns a mutation id corresponding to the vectors enqueued for insertion. */ export const insertIndex: API.OperationMethod< InsertIndexRequest, InsertIndexResponse, InsertIndexError, CloudflareOpContext > = /*@__PURE__*/ API.make(() => ({ input: InsertIndexRequest, output: InsertIndexResponse, errors: [CloudflareRateLimited, CloudflareError], protocol: CloudflareProtocol, retry: Retry.Retry, })); export type ListIndexesError = NotFound | Gone | CloudflareOpError; /** Returns a list of Vectorize Indexes */ export const listIndexes: API.PaginatedOperationMethod< ListIndexesRequest, ListIndexesResponse, ListIndexesError, CloudflareOpContext, IndexesListResultItem > = /*@__PURE__*/ API.makePaginated( () => ({ input: ListIndexesRequest, output: ListIndexesResponse, errors: [NotFound, Gone, CloudflareRateLimited, CloudflareError], protocol: CloudflarePaginatedProtocol, retry: Retry.Retry, pagination: { mode: "single", items: "result" } as const, }), cloudflarePaginate, ) as any; export type ListIndexMetadataIndexesError = NotFound | Gone | CloudflareOpError; /** List Metadata Indexes for the specified Vectorize Index. */ export const listIndexMetadataIndexes: API.OperationMethod< ListIndexMetadataIndexesRequest, ListIndexMetadataIndexesResponse, ListIndexMetadataIndexesError, CloudflareOpContext > = /*@__PURE__*/ API.make(() => ({ input: ListIndexMetadataIndexesRequest, output: ListIndexMetadataIndexesResponse, errors: [NotFound, Gone, CloudflareRateLimited, CloudflareError], protocol: CloudflareProtocol, retry: Retry.Retry, })); export type ListVectorsIndexError = CloudflareOpError; /** Returns a paginated list of vector identifiers from the specified index. */ export const listVectorsIndex: API.OperationMethod< ListVectorsIndexRequest, ListVectorsIndexResponse, ListVectorsIndexError, CloudflareOpContext > = /*@__PURE__*/ API.make(() => ({ input: ListVectorsIndexRequest, output: ListVectorsIndexResponse, errors: [CloudflareRateLimited, CloudflareError], protocol: CloudflareProtocol, retry: Retry.Retry, })); export type QueryIndexError = CloudflareOpError; /** Finds vectors closest to a given vector in an index. */ export const queryIndex: API.OperationMethod< QueryIndexRequest, QueryIndexResponse, QueryIndexError, CloudflareOpContext > = /*@__PURE__*/ API.make(() => ({ input: QueryIndexRequest, output: QueryIndexResponse, errors: [CloudflareRateLimited, CloudflareError], protocol: CloudflareProtocol, retry: Retry.Retry, })); export type UpsertIndexError = CloudflareOpError; /** Upserts vectors into the specified index, creating them if they do not exist and returns a mutation id corresponding to the vectors enqueued for upsertion. */ export const upsertIndex: API.OperationMethod< UpsertIndexRequest, UpsertIndexResponse, UpsertIndexError, CloudflareOpContext > = /*@__PURE__*/ API.make(() => ({ input: UpsertIndexRequest, output: UpsertIndexResponse, errors: [CloudflareRateLimited, CloudflareError], protocol: CloudflareProtocol, retry: Retry.Retry, }));