@cloudflare/workers-types 4.20230830.0 → 4.20230914.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/2021-11-03/index.d.ts +190 -19
- package/2021-11-03/index.ts +190 -16
- package/2022-01-31/index.d.ts +190 -19
- package/2022-01-31/index.ts +190 -16
- package/2022-03-21/index.d.ts +190 -19
- package/2022-03-21/index.ts +190 -16
- package/2022-08-04/index.d.ts +190 -19
- package/2022-08-04/index.ts +190 -16
- package/2022-10-31/index.d.ts +190 -19
- package/2022-10-31/index.ts +190 -16
- package/2022-11-30/index.d.ts +190 -19
- package/2022-11-30/index.ts +190 -16
- package/2023-03-01/index.d.ts +190 -19
- package/2023-03-01/index.ts +190 -16
- package/2023-07-01/index.d.ts +190 -19
- package/2023-07-01/index.ts +190 -16
- package/experimental/index.d.ts +190 -19
- package/experimental/index.ts +190 -16
- package/index.d.ts +190 -19
- package/index.ts +190 -16
- package/oldest/index.d.ts +190 -19
- package/oldest/index.ts +190 -16
- package/package.json +1 -1
package/2023-03-01/index.d.ts
CHANGED
|
@@ -875,7 +875,7 @@ declare class TextDecoder {
|
|
|
875
875
|
}
|
|
876
876
|
declare class TextEncoder {
|
|
877
877
|
constructor();
|
|
878
|
-
encode(input?: string):
|
|
878
|
+
encode(input?: string): Uint8Array;
|
|
879
879
|
encodeInto(
|
|
880
880
|
input: string,
|
|
881
881
|
buffer: ArrayBuffer | ArrayBufferView
|
|
@@ -2894,9 +2894,6 @@ declare type ContinentCode = "AF" | "AN" | "AS" | "EU" | "NA" | "OC" | "SA";
|
|
|
2894
2894
|
declare type CfProperties<HostMetadata = unknown> =
|
|
2895
2895
|
| IncomingRequestCfProperties<HostMetadata>
|
|
2896
2896
|
| RequestInitCfProperties;
|
|
2897
|
-
// Copyright (c) 2022-2023 Cloudflare, Inc.
|
|
2898
|
-
// Licensed under the Apache 2.0 license found in the LICENSE file or at:
|
|
2899
|
-
// https://opensource.org/licenses/Apache-2.0
|
|
2900
2897
|
declare interface D1Result<T = unknown> {
|
|
2901
2898
|
results: T[];
|
|
2902
2899
|
success: true;
|
|
@@ -2921,9 +2918,6 @@ declare abstract class D1PreparedStatement {
|
|
|
2921
2918
|
all<T = Record<string, unknown>>(): Promise<D1Result<T>>;
|
|
2922
2919
|
raw<T = unknown[]>(): Promise<T[]>;
|
|
2923
2920
|
}
|
|
2924
|
-
// Copyright (c) 2023 Cloudflare, Inc.
|
|
2925
|
-
// Licensed under the Apache 2.0 license found in the LICENSE file or at:
|
|
2926
|
-
// https://opensource.org/licenses/Apache-2.0
|
|
2927
2921
|
/**
|
|
2928
2922
|
* An email message that can be sent from a Worker.
|
|
2929
2923
|
*/
|
|
@@ -2988,9 +2982,53 @@ declare module "cloudflare:email" {
|
|
|
2988
2982
|
};
|
|
2989
2983
|
export { _EmailMessage as EmailMessage };
|
|
2990
2984
|
}
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2985
|
+
declare interface Hyperdrive {
|
|
2986
|
+
/**
|
|
2987
|
+
* Connect directly to Hyperdrive as if it's your database, returning a TCP socket.
|
|
2988
|
+
*
|
|
2989
|
+
* Calling this method returns an idential socket to if you call
|
|
2990
|
+
* `connect("host:port")` using the `host` and `port` fields from this object.
|
|
2991
|
+
* Pick whichever approach works better with your preferred DB client library.
|
|
2992
|
+
*
|
|
2993
|
+
* Note that this socket is not yet authenticated -- it's expected that your
|
|
2994
|
+
* code (or preferably, the client library of your choice) will authenticate
|
|
2995
|
+
* using the information in this class's readonly fields.
|
|
2996
|
+
*/
|
|
2997
|
+
connect(): Socket;
|
|
2998
|
+
/**
|
|
2999
|
+
* A valid DB connection string that can be passed straight into the typical
|
|
3000
|
+
* client library/driver/ORM. This will typically be the easiest way to use
|
|
3001
|
+
* Hyperdrive.
|
|
3002
|
+
*/
|
|
3003
|
+
readonly connectionString: string;
|
|
3004
|
+
/*
|
|
3005
|
+
* A randomly generated hostname that is only valid within the context of the
|
|
3006
|
+
* currently running Worker which, when passed into `connect()` function from
|
|
3007
|
+
* the "cloudflare:sockets" module, will connect to the Hyperdrive instance
|
|
3008
|
+
* for your database.
|
|
3009
|
+
*/
|
|
3010
|
+
readonly host: string;
|
|
3011
|
+
/*
|
|
3012
|
+
* The port that must be paired the the host field when connecting.
|
|
3013
|
+
*/
|
|
3014
|
+
readonly port: string;
|
|
3015
|
+
/*
|
|
3016
|
+
* The username to use when authenticating to your database via Hyperdrive.
|
|
3017
|
+
* Unlike the host and password, this will be the same every time
|
|
3018
|
+
*/
|
|
3019
|
+
readonly user: string;
|
|
3020
|
+
/*
|
|
3021
|
+
* The randomly generated password to use when authenticating to your
|
|
3022
|
+
* database via Hyperdrive. Like the host field, this password is only valid
|
|
3023
|
+
* within the context of the currently running Worker instance from which
|
|
3024
|
+
* it's read.
|
|
3025
|
+
*/
|
|
3026
|
+
readonly password: string;
|
|
3027
|
+
/*
|
|
3028
|
+
* The name of the database to connect to.
|
|
3029
|
+
*/
|
|
3030
|
+
readonly database: string;
|
|
3031
|
+
}
|
|
2994
3032
|
declare type Params<P extends string = any> = Record<P, string | string[]>;
|
|
2995
3033
|
declare type EventContext<Env, P extends string, Data> = {
|
|
2996
3034
|
request: Request;
|
|
@@ -3037,13 +3075,10 @@ declare type PagesPluginFunction<
|
|
|
3037
3075
|
declare module "assets:*" {
|
|
3038
3076
|
export const onRequest: PagesFunction;
|
|
3039
3077
|
}
|
|
3040
|
-
// Copyright (c) 2023 Cloudflare, Inc.
|
|
3041
|
-
// Licensed under the Apache 2.0 license found in the LICENSE file or at:
|
|
3042
|
-
// https://opensource.org/licenses/Apache-2.0
|
|
3043
|
-
// https://developers.cloudflare.com/pub-sub/
|
|
3044
3078
|
// PubSubMessage represents an incoming PubSub message.
|
|
3045
3079
|
// The message includes metadata about the broker, the client, and the payload
|
|
3046
3080
|
// itself.
|
|
3081
|
+
// https://developers.cloudflare.com/pub-sub/
|
|
3047
3082
|
declare interface PubSubMessage {
|
|
3048
3083
|
// Message ID
|
|
3049
3084
|
readonly mid: number;
|
|
@@ -3074,9 +3109,6 @@ declare interface JsonWebKeyWithKid extends JsonWebKey {
|
|
|
3074
3109
|
// Key Identifier of the JWK
|
|
3075
3110
|
readonly kid: string;
|
|
3076
3111
|
}
|
|
3077
|
-
// Copyright (c) 2023 Cloudflare, Inc.
|
|
3078
|
-
// Licensed under the Apache 2.0 license found in the LICENSE file or at:
|
|
3079
|
-
// https://opensource.org/licenses/Apache-2.0
|
|
3080
3112
|
declare module "cloudflare:sockets" {
|
|
3081
3113
|
function _connect(
|
|
3082
3114
|
address: string | SocketAddress,
|
|
@@ -3084,10 +3116,149 @@ declare module "cloudflare:sockets" {
|
|
|
3084
3116
|
): Socket;
|
|
3085
3117
|
export { _connect as connect };
|
|
3086
3118
|
}
|
|
3087
|
-
// Copyright (c) 2023 Cloudflare, Inc.
|
|
3119
|
+
// Copyright (c) 2022-2023 Cloudflare, Inc.
|
|
3088
3120
|
// Licensed under the Apache 2.0 license found in the LICENSE file or at:
|
|
3089
3121
|
// https://opensource.org/licenses/Apache-2.0
|
|
3090
|
-
|
|
3122
|
+
/**
|
|
3123
|
+
* Additional information to associate with a vector.
|
|
3124
|
+
*/
|
|
3125
|
+
declare type VectorizeVectorMetadata =
|
|
3126
|
+
| string
|
|
3127
|
+
| number
|
|
3128
|
+
| boolean
|
|
3129
|
+
| string[]
|
|
3130
|
+
| Record<string, string | number | boolean | string[]>;
|
|
3131
|
+
declare type VectorFloatArray = Float32Array | Float64Array;
|
|
3132
|
+
declare interface VectorizeError {
|
|
3133
|
+
code?: number;
|
|
3134
|
+
error: string;
|
|
3135
|
+
}
|
|
3136
|
+
/**
|
|
3137
|
+
* A pre-configured list of known models.
|
|
3138
|
+
* These can be supplied in place of configuring explicit dimensions.
|
|
3139
|
+
*/
|
|
3140
|
+
declare type VectorizePreset =
|
|
3141
|
+
| "openapi-text-embedding-ada-002"
|
|
3142
|
+
| "workers-ai/bge-small-en"
|
|
3143
|
+
| "cohere/embed-multilingual-v2.0";
|
|
3144
|
+
/**
|
|
3145
|
+
* Supported distance metrics for an index.
|
|
3146
|
+
* Distance metrics determine how other "similar" vectors are determined.
|
|
3147
|
+
*/
|
|
3148
|
+
declare type VectorizeDistanceMetric = "euclidean" | "cosine" | "dot-product";
|
|
3149
|
+
declare interface VectorizeQueryOptions {
|
|
3150
|
+
topK?: number;
|
|
3151
|
+
namespace?: string;
|
|
3152
|
+
returnVectors?: boolean;
|
|
3153
|
+
}
|
|
3154
|
+
/**
|
|
3155
|
+
* Information about the configuration of an index.
|
|
3156
|
+
*/
|
|
3157
|
+
declare type VectorizeIndexConfig =
|
|
3158
|
+
| {
|
|
3159
|
+
dimensions: number;
|
|
3160
|
+
metric: VectorizeDistanceMetric;
|
|
3161
|
+
}
|
|
3162
|
+
| {
|
|
3163
|
+
preset: VectorizePreset;
|
|
3164
|
+
};
|
|
3165
|
+
/**
|
|
3166
|
+
* Metadata about an existing index.
|
|
3167
|
+
*/
|
|
3168
|
+
declare interface VectorizeIndexDetails {
|
|
3169
|
+
/** The unique ID of the index */
|
|
3170
|
+
readonly id: string;
|
|
3171
|
+
/** The name of the index. */
|
|
3172
|
+
name: string;
|
|
3173
|
+
/** (optional) A human readable description for the index. */
|
|
3174
|
+
description?: string;
|
|
3175
|
+
/** The index configuration, including the dimension size and distance metric. */
|
|
3176
|
+
config: VectorizeIndexConfig;
|
|
3177
|
+
/** The number of records containing vectors within the index. */
|
|
3178
|
+
vectorsCount: number;
|
|
3179
|
+
}
|
|
3180
|
+
/**
|
|
3181
|
+
* Represents a single vector value set along with its associated metadata.
|
|
3182
|
+
*/
|
|
3183
|
+
declare interface VectorizeVector {
|
|
3184
|
+
/** The ID for the vector. This can be user-defined, and must be unique. It should uniquely identify the object, and is best set based on the ID of what the vector represents. */
|
|
3185
|
+
id: string;
|
|
3186
|
+
/** The vector values */
|
|
3187
|
+
values: VectorFloatArray | number[];
|
|
3188
|
+
/** The namespace this vector belongs to. */
|
|
3189
|
+
namespace?: string;
|
|
3190
|
+
/** Metadata associated with the binding. Includes the values of the other fields and potentially additional details. */
|
|
3191
|
+
metadata?: Record<string, VectorizeVectorMetadata>;
|
|
3192
|
+
}
|
|
3193
|
+
/**
|
|
3194
|
+
* Represents a matched vector for a query along with its score and (if specified) the matching vector information.
|
|
3195
|
+
*/
|
|
3196
|
+
declare interface VectorizeMatch {
|
|
3197
|
+
/** The ID for the vector. This can be user-defined, and must be unique. It should uniquely identify the object, and is best set based on the ID of what the vector represents. */
|
|
3198
|
+
vectorId: string;
|
|
3199
|
+
/** The score or rank for similarity, when returned as a result */
|
|
3200
|
+
score: number;
|
|
3201
|
+
/** Vector data for the match. Included only if the user specified they want it returned (via {@link VectorizeQueryOptions}). */
|
|
3202
|
+
vector?: VectorizeVector;
|
|
3203
|
+
}
|
|
3204
|
+
/**
|
|
3205
|
+
* A set of vector {@link VectorizeMatch} for a particular query.
|
|
3206
|
+
*/
|
|
3207
|
+
declare interface VectorizeMatches {
|
|
3208
|
+
matches: VectorizeMatch[];
|
|
3209
|
+
count: number;
|
|
3210
|
+
}
|
|
3211
|
+
/**
|
|
3212
|
+
* Results of an operation that performed a mutation on a set of vectors.
|
|
3213
|
+
* Here, `ids` is a list of vectors that were successfully processed.
|
|
3214
|
+
*/
|
|
3215
|
+
declare interface VectorizeVectorMutation {
|
|
3216
|
+
/* List of ids of vectors that were successfully processed. */
|
|
3217
|
+
ids: string[];
|
|
3218
|
+
/* Total count of the number of processed vectors. */
|
|
3219
|
+
count: number;
|
|
3220
|
+
}
|
|
3221
|
+
declare abstract class VectorizeIndex {
|
|
3222
|
+
/**
|
|
3223
|
+
* Get information about the currently bound index.
|
|
3224
|
+
* @returns A promise that resolves with information about the current index.
|
|
3225
|
+
*/
|
|
3226
|
+
public describe(): Promise<VectorizeIndexDetails>;
|
|
3227
|
+
/**
|
|
3228
|
+
* Use the provided vector to perform a similarity search across the index.
|
|
3229
|
+
* @param vector Input vector that will be used to drive the similarity search.
|
|
3230
|
+
* @param options Configuration options to massage the returned data.
|
|
3231
|
+
* @returns A promise that resolves with matched and scored vectors.
|
|
3232
|
+
*/
|
|
3233
|
+
public query(
|
|
3234
|
+
vector: VectorFloatArray | number[],
|
|
3235
|
+
options: VectorizeQueryOptions
|
|
3236
|
+
): Promise<VectorizeMatches>;
|
|
3237
|
+
/**
|
|
3238
|
+
* Insert a list of vectors into the index dataset. If a provided id exists, an error will be thrown.
|
|
3239
|
+
* @param vectors List of vectors that will be inserted.
|
|
3240
|
+
* @returns A promise that resolves with the ids & count of records that were successfully processed.
|
|
3241
|
+
*/
|
|
3242
|
+
public insert(vectors: VectorizeVector[]): Promise<VectorizeVectorMutation>;
|
|
3243
|
+
/**
|
|
3244
|
+
* Upsert a list of vectors into the index dataset. If a provided id exists, it will be replaced with the new values.
|
|
3245
|
+
* @param vectors List of vectors that will be upserted.
|
|
3246
|
+
* @returns A promise that resolves with the ids & count of records that were successfully processed.
|
|
3247
|
+
*/
|
|
3248
|
+
public upsert(vectors: VectorizeVector[]): Promise<VectorizeVectorMutation>;
|
|
3249
|
+
/**
|
|
3250
|
+
* Delete a list of vectors with a matching id.
|
|
3251
|
+
* @param ids List of vector ids that should be deleted.
|
|
3252
|
+
* @returns A promise that resolves with the ids & count of records that were successfully processed (and thus deleted).
|
|
3253
|
+
*/
|
|
3254
|
+
public deleteByIds(ids: string[]): Promise<VectorizeVectorMutation>;
|
|
3255
|
+
/**
|
|
3256
|
+
* Get a list of vectors with a matching id.
|
|
3257
|
+
* @param ids List of vector ids that should be returned.
|
|
3258
|
+
* @returns A promise that resolves with the raw unscored vectors matching the id set.
|
|
3259
|
+
*/
|
|
3260
|
+
public getByIds(ids: string[]): Promise<VectorizeVector[]>;
|
|
3261
|
+
}
|
|
3091
3262
|
declare interface DynamicDispatchLimits {
|
|
3092
3263
|
/**
|
|
3093
3264
|
* Limit CPU time in milliseconds.
|
package/2023-03-01/index.ts
CHANGED
|
@@ -877,7 +877,7 @@ export declare class TextDecoder {
|
|
|
877
877
|
}
|
|
878
878
|
export declare class TextEncoder {
|
|
879
879
|
constructor();
|
|
880
|
-
encode(input?: string):
|
|
880
|
+
encode(input?: string): Uint8Array;
|
|
881
881
|
encodeInto(
|
|
882
882
|
input: string,
|
|
883
883
|
buffer: ArrayBuffer | ArrayBufferView
|
|
@@ -2899,9 +2899,6 @@ export type ContinentCode = "AF" | "AN" | "AS" | "EU" | "NA" | "OC" | "SA";
|
|
|
2899
2899
|
export type CfProperties<HostMetadata = unknown> =
|
|
2900
2900
|
| IncomingRequestCfProperties<HostMetadata>
|
|
2901
2901
|
| RequestInitCfProperties;
|
|
2902
|
-
// Copyright (c) 2022-2023 Cloudflare, Inc.
|
|
2903
|
-
// Licensed under the Apache 2.0 license found in the LICENSE file or at:
|
|
2904
|
-
// https://opensource.org/licenses/Apache-2.0
|
|
2905
2902
|
export interface D1Result<T = unknown> {
|
|
2906
2903
|
results: T[];
|
|
2907
2904
|
success: true;
|
|
@@ -2926,9 +2923,6 @@ export declare abstract class D1PreparedStatement {
|
|
|
2926
2923
|
all<T = Record<string, unknown>>(): Promise<D1Result<T>>;
|
|
2927
2924
|
raw<T = unknown[]>(): Promise<T[]>;
|
|
2928
2925
|
}
|
|
2929
|
-
// Copyright (c) 2023 Cloudflare, Inc.
|
|
2930
|
-
// Licensed under the Apache 2.0 license found in the LICENSE file or at:
|
|
2931
|
-
// https://opensource.org/licenses/Apache-2.0
|
|
2932
2926
|
/**
|
|
2933
2927
|
* An email message that can be sent from a Worker.
|
|
2934
2928
|
*/
|
|
@@ -2986,9 +2980,53 @@ export type EmailExportedHandler<Env = unknown> = (
|
|
|
2986
2980
|
env: Env,
|
|
2987
2981
|
ctx: ExecutionContext
|
|
2988
2982
|
) => void | Promise<void>;
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2983
|
+
export interface Hyperdrive {
|
|
2984
|
+
/**
|
|
2985
|
+
* Connect directly to Hyperdrive as if it's your database, returning a TCP socket.
|
|
2986
|
+
*
|
|
2987
|
+
* Calling this method returns an idential socket to if you call
|
|
2988
|
+
* `connect("host:port")` using the `host` and `port` fields from this object.
|
|
2989
|
+
* Pick whichever approach works better with your preferred DB client library.
|
|
2990
|
+
*
|
|
2991
|
+
* Note that this socket is not yet authenticated -- it's expected that your
|
|
2992
|
+
* code (or preferably, the client library of your choice) will authenticate
|
|
2993
|
+
* using the information in this class's readonly fields.
|
|
2994
|
+
*/
|
|
2995
|
+
connect(): Socket;
|
|
2996
|
+
/**
|
|
2997
|
+
* A valid DB connection string that can be passed straight into the typical
|
|
2998
|
+
* client library/driver/ORM. This will typically be the easiest way to use
|
|
2999
|
+
* Hyperdrive.
|
|
3000
|
+
*/
|
|
3001
|
+
readonly connectionString: string;
|
|
3002
|
+
/*
|
|
3003
|
+
* A randomly generated hostname that is only valid within the context of the
|
|
3004
|
+
* currently running Worker which, when passed into `connect()` function from
|
|
3005
|
+
* the "cloudflare:sockets" module, will connect to the Hyperdrive instance
|
|
3006
|
+
* for your database.
|
|
3007
|
+
*/
|
|
3008
|
+
readonly host: string;
|
|
3009
|
+
/*
|
|
3010
|
+
* The port that must be paired the the host field when connecting.
|
|
3011
|
+
*/
|
|
3012
|
+
readonly port: string;
|
|
3013
|
+
/*
|
|
3014
|
+
* The username to use when authenticating to your database via Hyperdrive.
|
|
3015
|
+
* Unlike the host and password, this will be the same every time
|
|
3016
|
+
*/
|
|
3017
|
+
readonly user: string;
|
|
3018
|
+
/*
|
|
3019
|
+
* The randomly generated password to use when authenticating to your
|
|
3020
|
+
* database via Hyperdrive. Like the host field, this password is only valid
|
|
3021
|
+
* within the context of the currently running Worker instance from which
|
|
3022
|
+
* it's read.
|
|
3023
|
+
*/
|
|
3024
|
+
readonly password: string;
|
|
3025
|
+
/*
|
|
3026
|
+
* The name of the database to connect to.
|
|
3027
|
+
*/
|
|
3028
|
+
readonly database: string;
|
|
3029
|
+
}
|
|
2992
3030
|
export type Params<P extends string = any> = Record<P, string | string[]>;
|
|
2993
3031
|
export type EventContext<Env, P extends string, Data> = {
|
|
2994
3032
|
request: Request;
|
|
@@ -3032,13 +3070,10 @@ export type PagesPluginFunction<
|
|
|
3032
3070
|
> = (
|
|
3033
3071
|
context: EventPluginContext<Env, Params, Data, PluginArgs>
|
|
3034
3072
|
) => Response | Promise<Response>;
|
|
3035
|
-
// Copyright (c) 2023 Cloudflare, Inc.
|
|
3036
|
-
// Licensed under the Apache 2.0 license found in the LICENSE file or at:
|
|
3037
|
-
// https://opensource.org/licenses/Apache-2.0
|
|
3038
|
-
// https://developers.cloudflare.com/pub-sub/
|
|
3039
3073
|
// PubSubMessage represents an incoming PubSub message.
|
|
3040
3074
|
// The message includes metadata about the broker, the client, and the payload
|
|
3041
3075
|
// itself.
|
|
3076
|
+
// https://developers.cloudflare.com/pub-sub/
|
|
3042
3077
|
export interface PubSubMessage {
|
|
3043
3078
|
// Message ID
|
|
3044
3079
|
readonly mid: number;
|
|
@@ -3069,10 +3104,149 @@ export interface JsonWebKeyWithKid extends JsonWebKey {
|
|
|
3069
3104
|
// Key Identifier of the JWK
|
|
3070
3105
|
readonly kid: string;
|
|
3071
3106
|
}
|
|
3072
|
-
// Copyright (c) 2023 Cloudflare, Inc.
|
|
3107
|
+
// Copyright (c) 2022-2023 Cloudflare, Inc.
|
|
3073
3108
|
// Licensed under the Apache 2.0 license found in the LICENSE file or at:
|
|
3074
3109
|
// https://opensource.org/licenses/Apache-2.0
|
|
3075
|
-
|
|
3110
|
+
/**
|
|
3111
|
+
* Additional information to associate with a vector.
|
|
3112
|
+
*/
|
|
3113
|
+
export type VectorizeVectorMetadata =
|
|
3114
|
+
| string
|
|
3115
|
+
| number
|
|
3116
|
+
| boolean
|
|
3117
|
+
| string[]
|
|
3118
|
+
| Record<string, string | number | boolean | string[]>;
|
|
3119
|
+
export type VectorFloatArray = Float32Array | Float64Array;
|
|
3120
|
+
export interface VectorizeError {
|
|
3121
|
+
code?: number;
|
|
3122
|
+
error: string;
|
|
3123
|
+
}
|
|
3124
|
+
/**
|
|
3125
|
+
* A pre-configured list of known models.
|
|
3126
|
+
* These can be supplied in place of configuring explicit dimensions.
|
|
3127
|
+
*/
|
|
3128
|
+
export type VectorizePreset =
|
|
3129
|
+
| "openapi-text-embedding-ada-002"
|
|
3130
|
+
| "workers-ai/bge-small-en"
|
|
3131
|
+
| "cohere/embed-multilingual-v2.0";
|
|
3132
|
+
/**
|
|
3133
|
+
* Supported distance metrics for an index.
|
|
3134
|
+
* Distance metrics determine how other "similar" vectors are determined.
|
|
3135
|
+
*/
|
|
3136
|
+
export type VectorizeDistanceMetric = "euclidean" | "cosine" | "dot-product";
|
|
3137
|
+
export interface VectorizeQueryOptions {
|
|
3138
|
+
topK?: number;
|
|
3139
|
+
namespace?: string;
|
|
3140
|
+
returnVectors?: boolean;
|
|
3141
|
+
}
|
|
3142
|
+
/**
|
|
3143
|
+
* Information about the configuration of an index.
|
|
3144
|
+
*/
|
|
3145
|
+
export type VectorizeIndexConfig =
|
|
3146
|
+
| {
|
|
3147
|
+
dimensions: number;
|
|
3148
|
+
metric: VectorizeDistanceMetric;
|
|
3149
|
+
}
|
|
3150
|
+
| {
|
|
3151
|
+
preset: VectorizePreset;
|
|
3152
|
+
};
|
|
3153
|
+
/**
|
|
3154
|
+
* Metadata about an existing index.
|
|
3155
|
+
*/
|
|
3156
|
+
export interface VectorizeIndexDetails {
|
|
3157
|
+
/** The unique ID of the index */
|
|
3158
|
+
readonly id: string;
|
|
3159
|
+
/** The name of the index. */
|
|
3160
|
+
name: string;
|
|
3161
|
+
/** (optional) A human readable description for the index. */
|
|
3162
|
+
description?: string;
|
|
3163
|
+
/** The index configuration, including the dimension size and distance metric. */
|
|
3164
|
+
config: VectorizeIndexConfig;
|
|
3165
|
+
/** The number of records containing vectors within the index. */
|
|
3166
|
+
vectorsCount: number;
|
|
3167
|
+
}
|
|
3168
|
+
/**
|
|
3169
|
+
* Represents a single vector value set along with its associated metadata.
|
|
3170
|
+
*/
|
|
3171
|
+
export interface VectorizeVector {
|
|
3172
|
+
/** The ID for the vector. This can be user-defined, and must be unique. It should uniquely identify the object, and is best set based on the ID of what the vector represents. */
|
|
3173
|
+
id: string;
|
|
3174
|
+
/** The vector values */
|
|
3175
|
+
values: VectorFloatArray | number[];
|
|
3176
|
+
/** The namespace this vector belongs to. */
|
|
3177
|
+
namespace?: string;
|
|
3178
|
+
/** Metadata associated with the binding. Includes the values of the other fields and potentially additional details. */
|
|
3179
|
+
metadata?: Record<string, VectorizeVectorMetadata>;
|
|
3180
|
+
}
|
|
3181
|
+
/**
|
|
3182
|
+
* Represents a matched vector for a query along with its score and (if specified) the matching vector information.
|
|
3183
|
+
*/
|
|
3184
|
+
export interface VectorizeMatch {
|
|
3185
|
+
/** The ID for the vector. This can be user-defined, and must be unique. It should uniquely identify the object, and is best set based on the ID of what the vector represents. */
|
|
3186
|
+
vectorId: string;
|
|
3187
|
+
/** The score or rank for similarity, when returned as a result */
|
|
3188
|
+
score: number;
|
|
3189
|
+
/** Vector data for the match. Included only if the user specified they want it returned (via {@link VectorizeQueryOptions}). */
|
|
3190
|
+
vector?: VectorizeVector;
|
|
3191
|
+
}
|
|
3192
|
+
/**
|
|
3193
|
+
* A set of vector {@link VectorizeMatch} for a particular query.
|
|
3194
|
+
*/
|
|
3195
|
+
export interface VectorizeMatches {
|
|
3196
|
+
matches: VectorizeMatch[];
|
|
3197
|
+
count: number;
|
|
3198
|
+
}
|
|
3199
|
+
/**
|
|
3200
|
+
* Results of an operation that performed a mutation on a set of vectors.
|
|
3201
|
+
* Here, `ids` is a list of vectors that were successfully processed.
|
|
3202
|
+
*/
|
|
3203
|
+
export interface VectorizeVectorMutation {
|
|
3204
|
+
/* List of ids of vectors that were successfully processed. */
|
|
3205
|
+
ids: string[];
|
|
3206
|
+
/* Total count of the number of processed vectors. */
|
|
3207
|
+
count: number;
|
|
3208
|
+
}
|
|
3209
|
+
export declare abstract class VectorizeIndex {
|
|
3210
|
+
/**
|
|
3211
|
+
* Get information about the currently bound index.
|
|
3212
|
+
* @returns A promise that resolves with information about the current index.
|
|
3213
|
+
*/
|
|
3214
|
+
public describe(): Promise<VectorizeIndexDetails>;
|
|
3215
|
+
/**
|
|
3216
|
+
* Use the provided vector to perform a similarity search across the index.
|
|
3217
|
+
* @param vector Input vector that will be used to drive the similarity search.
|
|
3218
|
+
* @param options Configuration options to massage the returned data.
|
|
3219
|
+
* @returns A promise that resolves with matched and scored vectors.
|
|
3220
|
+
*/
|
|
3221
|
+
public query(
|
|
3222
|
+
vector: VectorFloatArray | number[],
|
|
3223
|
+
options: VectorizeQueryOptions
|
|
3224
|
+
): Promise<VectorizeMatches>;
|
|
3225
|
+
/**
|
|
3226
|
+
* Insert a list of vectors into the index dataset. If a provided id exists, an error will be thrown.
|
|
3227
|
+
* @param vectors List of vectors that will be inserted.
|
|
3228
|
+
* @returns A promise that resolves with the ids & count of records that were successfully processed.
|
|
3229
|
+
*/
|
|
3230
|
+
public insert(vectors: VectorizeVector[]): Promise<VectorizeVectorMutation>;
|
|
3231
|
+
/**
|
|
3232
|
+
* Upsert a list of vectors into the index dataset. If a provided id exists, it will be replaced with the new values.
|
|
3233
|
+
* @param vectors List of vectors that will be upserted.
|
|
3234
|
+
* @returns A promise that resolves with the ids & count of records that were successfully processed.
|
|
3235
|
+
*/
|
|
3236
|
+
public upsert(vectors: VectorizeVector[]): Promise<VectorizeVectorMutation>;
|
|
3237
|
+
/**
|
|
3238
|
+
* Delete a list of vectors with a matching id.
|
|
3239
|
+
* @param ids List of vector ids that should be deleted.
|
|
3240
|
+
* @returns A promise that resolves with the ids & count of records that were successfully processed (and thus deleted).
|
|
3241
|
+
*/
|
|
3242
|
+
public deleteByIds(ids: string[]): Promise<VectorizeVectorMutation>;
|
|
3243
|
+
/**
|
|
3244
|
+
* Get a list of vectors with a matching id.
|
|
3245
|
+
* @param ids List of vector ids that should be returned.
|
|
3246
|
+
* @returns A promise that resolves with the raw unscored vectors matching the id set.
|
|
3247
|
+
*/
|
|
3248
|
+
public getByIds(ids: string[]): Promise<VectorizeVector[]>;
|
|
3249
|
+
}
|
|
3076
3250
|
export interface DynamicDispatchLimits {
|
|
3077
3251
|
/**
|
|
3078
3252
|
* Limit CPU time in milliseconds.
|