@cloudflare/workers-types 4.20230904.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/experimental/index.d.ts
CHANGED
|
@@ -884,7 +884,7 @@ declare class TextDecoder {
|
|
|
884
884
|
}
|
|
885
885
|
declare class TextEncoder {
|
|
886
886
|
constructor();
|
|
887
|
-
encode(input?: string):
|
|
887
|
+
encode(input?: string): Uint8Array;
|
|
888
888
|
encodeInto(
|
|
889
889
|
input: string,
|
|
890
890
|
buffer: ArrayBuffer | ArrayBufferView
|
|
@@ -2951,9 +2951,6 @@ declare type ContinentCode = "AF" | "AN" | "AS" | "EU" | "NA" | "OC" | "SA";
|
|
|
2951
2951
|
declare type CfProperties<HostMetadata = unknown> =
|
|
2952
2952
|
| IncomingRequestCfProperties<HostMetadata>
|
|
2953
2953
|
| RequestInitCfProperties;
|
|
2954
|
-
// Copyright (c) 2022-2023 Cloudflare, Inc.
|
|
2955
|
-
// Licensed under the Apache 2.0 license found in the LICENSE file or at:
|
|
2956
|
-
// https://opensource.org/licenses/Apache-2.0
|
|
2957
2954
|
declare interface D1Result<T = unknown> {
|
|
2958
2955
|
results: T[];
|
|
2959
2956
|
success: true;
|
|
@@ -2978,9 +2975,6 @@ declare abstract class D1PreparedStatement {
|
|
|
2978
2975
|
all<T = Record<string, unknown>>(): Promise<D1Result<T>>;
|
|
2979
2976
|
raw<T = unknown[]>(): Promise<T[]>;
|
|
2980
2977
|
}
|
|
2981
|
-
// Copyright (c) 2023 Cloudflare, Inc.
|
|
2982
|
-
// Licensed under the Apache 2.0 license found in the LICENSE file or at:
|
|
2983
|
-
// https://opensource.org/licenses/Apache-2.0
|
|
2984
2978
|
/**
|
|
2985
2979
|
* An email message that can be sent from a Worker.
|
|
2986
2980
|
*/
|
|
@@ -3045,9 +3039,53 @@ declare module "cloudflare:email" {
|
|
|
3045
3039
|
};
|
|
3046
3040
|
export { _EmailMessage as EmailMessage };
|
|
3047
3041
|
}
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3042
|
+
declare interface Hyperdrive {
|
|
3043
|
+
/**
|
|
3044
|
+
* Connect directly to Hyperdrive as if it's your database, returning a TCP socket.
|
|
3045
|
+
*
|
|
3046
|
+
* Calling this method returns an idential socket to if you call
|
|
3047
|
+
* `connect("host:port")` using the `host` and `port` fields from this object.
|
|
3048
|
+
* Pick whichever approach works better with your preferred DB client library.
|
|
3049
|
+
*
|
|
3050
|
+
* Note that this socket is not yet authenticated -- it's expected that your
|
|
3051
|
+
* code (or preferably, the client library of your choice) will authenticate
|
|
3052
|
+
* using the information in this class's readonly fields.
|
|
3053
|
+
*/
|
|
3054
|
+
connect(): Socket;
|
|
3055
|
+
/**
|
|
3056
|
+
* A valid DB connection string that can be passed straight into the typical
|
|
3057
|
+
* client library/driver/ORM. This will typically be the easiest way to use
|
|
3058
|
+
* Hyperdrive.
|
|
3059
|
+
*/
|
|
3060
|
+
readonly connectionString: string;
|
|
3061
|
+
/*
|
|
3062
|
+
* A randomly generated hostname that is only valid within the context of the
|
|
3063
|
+
* currently running Worker which, when passed into `connect()` function from
|
|
3064
|
+
* the "cloudflare:sockets" module, will connect to the Hyperdrive instance
|
|
3065
|
+
* for your database.
|
|
3066
|
+
*/
|
|
3067
|
+
readonly host: string;
|
|
3068
|
+
/*
|
|
3069
|
+
* The port that must be paired the the host field when connecting.
|
|
3070
|
+
*/
|
|
3071
|
+
readonly port: string;
|
|
3072
|
+
/*
|
|
3073
|
+
* The username to use when authenticating to your database via Hyperdrive.
|
|
3074
|
+
* Unlike the host and password, this will be the same every time
|
|
3075
|
+
*/
|
|
3076
|
+
readonly user: string;
|
|
3077
|
+
/*
|
|
3078
|
+
* The randomly generated password to use when authenticating to your
|
|
3079
|
+
* database via Hyperdrive. Like the host field, this password is only valid
|
|
3080
|
+
* within the context of the currently running Worker instance from which
|
|
3081
|
+
* it's read.
|
|
3082
|
+
*/
|
|
3083
|
+
readonly password: string;
|
|
3084
|
+
/*
|
|
3085
|
+
* The name of the database to connect to.
|
|
3086
|
+
*/
|
|
3087
|
+
readonly database: string;
|
|
3088
|
+
}
|
|
3051
3089
|
declare type Params<P extends string = any> = Record<P, string | string[]>;
|
|
3052
3090
|
declare type EventContext<Env, P extends string, Data> = {
|
|
3053
3091
|
request: Request;
|
|
@@ -3094,13 +3132,10 @@ declare type PagesPluginFunction<
|
|
|
3094
3132
|
declare module "assets:*" {
|
|
3095
3133
|
export const onRequest: PagesFunction;
|
|
3096
3134
|
}
|
|
3097
|
-
// Copyright (c) 2023 Cloudflare, Inc.
|
|
3098
|
-
// Licensed under the Apache 2.0 license found in the LICENSE file or at:
|
|
3099
|
-
// https://opensource.org/licenses/Apache-2.0
|
|
3100
|
-
// https://developers.cloudflare.com/pub-sub/
|
|
3101
3135
|
// PubSubMessage represents an incoming PubSub message.
|
|
3102
3136
|
// The message includes metadata about the broker, the client, and the payload
|
|
3103
3137
|
// itself.
|
|
3138
|
+
// https://developers.cloudflare.com/pub-sub/
|
|
3104
3139
|
declare interface PubSubMessage {
|
|
3105
3140
|
// Message ID
|
|
3106
3141
|
readonly mid: number;
|
|
@@ -3131,9 +3166,6 @@ declare interface JsonWebKeyWithKid extends JsonWebKey {
|
|
|
3131
3166
|
// Key Identifier of the JWK
|
|
3132
3167
|
readonly kid: string;
|
|
3133
3168
|
}
|
|
3134
|
-
// Copyright (c) 2023 Cloudflare, Inc.
|
|
3135
|
-
// Licensed under the Apache 2.0 license found in the LICENSE file or at:
|
|
3136
|
-
// https://opensource.org/licenses/Apache-2.0
|
|
3137
3169
|
declare module "cloudflare:sockets" {
|
|
3138
3170
|
function _connect(
|
|
3139
3171
|
address: string | SocketAddress,
|
|
@@ -3141,10 +3173,149 @@ declare module "cloudflare:sockets" {
|
|
|
3141
3173
|
): Socket;
|
|
3142
3174
|
export { _connect as connect };
|
|
3143
3175
|
}
|
|
3144
|
-
// Copyright (c) 2023 Cloudflare, Inc.
|
|
3176
|
+
// Copyright (c) 2022-2023 Cloudflare, Inc.
|
|
3145
3177
|
// Licensed under the Apache 2.0 license found in the LICENSE file or at:
|
|
3146
3178
|
// https://opensource.org/licenses/Apache-2.0
|
|
3147
|
-
|
|
3179
|
+
/**
|
|
3180
|
+
* Additional information to associate with a vector.
|
|
3181
|
+
*/
|
|
3182
|
+
declare type VectorizeVectorMetadata =
|
|
3183
|
+
| string
|
|
3184
|
+
| number
|
|
3185
|
+
| boolean
|
|
3186
|
+
| string[]
|
|
3187
|
+
| Record<string, string | number | boolean | string[]>;
|
|
3188
|
+
declare type VectorFloatArray = Float32Array | Float64Array;
|
|
3189
|
+
declare interface VectorizeError {
|
|
3190
|
+
code?: number;
|
|
3191
|
+
error: string;
|
|
3192
|
+
}
|
|
3193
|
+
/**
|
|
3194
|
+
* A pre-configured list of known models.
|
|
3195
|
+
* These can be supplied in place of configuring explicit dimensions.
|
|
3196
|
+
*/
|
|
3197
|
+
declare type VectorizePreset =
|
|
3198
|
+
| "openapi-text-embedding-ada-002"
|
|
3199
|
+
| "workers-ai/bge-small-en"
|
|
3200
|
+
| "cohere/embed-multilingual-v2.0";
|
|
3201
|
+
/**
|
|
3202
|
+
* Supported distance metrics for an index.
|
|
3203
|
+
* Distance metrics determine how other "similar" vectors are determined.
|
|
3204
|
+
*/
|
|
3205
|
+
declare type VectorizeDistanceMetric = "euclidean" | "cosine" | "dot-product";
|
|
3206
|
+
declare interface VectorizeQueryOptions {
|
|
3207
|
+
topK?: number;
|
|
3208
|
+
namespace?: string;
|
|
3209
|
+
returnVectors?: boolean;
|
|
3210
|
+
}
|
|
3211
|
+
/**
|
|
3212
|
+
* Information about the configuration of an index.
|
|
3213
|
+
*/
|
|
3214
|
+
declare type VectorizeIndexConfig =
|
|
3215
|
+
| {
|
|
3216
|
+
dimensions: number;
|
|
3217
|
+
metric: VectorizeDistanceMetric;
|
|
3218
|
+
}
|
|
3219
|
+
| {
|
|
3220
|
+
preset: VectorizePreset;
|
|
3221
|
+
};
|
|
3222
|
+
/**
|
|
3223
|
+
* Metadata about an existing index.
|
|
3224
|
+
*/
|
|
3225
|
+
declare interface VectorizeIndexDetails {
|
|
3226
|
+
/** The unique ID of the index */
|
|
3227
|
+
readonly id: string;
|
|
3228
|
+
/** The name of the index. */
|
|
3229
|
+
name: string;
|
|
3230
|
+
/** (optional) A human readable description for the index. */
|
|
3231
|
+
description?: string;
|
|
3232
|
+
/** The index configuration, including the dimension size and distance metric. */
|
|
3233
|
+
config: VectorizeIndexConfig;
|
|
3234
|
+
/** The number of records containing vectors within the index. */
|
|
3235
|
+
vectorsCount: number;
|
|
3236
|
+
}
|
|
3237
|
+
/**
|
|
3238
|
+
* Represents a single vector value set along with its associated metadata.
|
|
3239
|
+
*/
|
|
3240
|
+
declare interface VectorizeVector {
|
|
3241
|
+
/** 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. */
|
|
3242
|
+
id: string;
|
|
3243
|
+
/** The vector values */
|
|
3244
|
+
values: VectorFloatArray | number[];
|
|
3245
|
+
/** The namespace this vector belongs to. */
|
|
3246
|
+
namespace?: string;
|
|
3247
|
+
/** Metadata associated with the binding. Includes the values of the other fields and potentially additional details. */
|
|
3248
|
+
metadata?: Record<string, VectorizeVectorMetadata>;
|
|
3249
|
+
}
|
|
3250
|
+
/**
|
|
3251
|
+
* Represents a matched vector for a query along with its score and (if specified) the matching vector information.
|
|
3252
|
+
*/
|
|
3253
|
+
declare interface VectorizeMatch {
|
|
3254
|
+
/** 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. */
|
|
3255
|
+
vectorId: string;
|
|
3256
|
+
/** The score or rank for similarity, when returned as a result */
|
|
3257
|
+
score: number;
|
|
3258
|
+
/** Vector data for the match. Included only if the user specified they want it returned (via {@link VectorizeQueryOptions}). */
|
|
3259
|
+
vector?: VectorizeVector;
|
|
3260
|
+
}
|
|
3261
|
+
/**
|
|
3262
|
+
* A set of vector {@link VectorizeMatch} for a particular query.
|
|
3263
|
+
*/
|
|
3264
|
+
declare interface VectorizeMatches {
|
|
3265
|
+
matches: VectorizeMatch[];
|
|
3266
|
+
count: number;
|
|
3267
|
+
}
|
|
3268
|
+
/**
|
|
3269
|
+
* Results of an operation that performed a mutation on a set of vectors.
|
|
3270
|
+
* Here, `ids` is a list of vectors that were successfully processed.
|
|
3271
|
+
*/
|
|
3272
|
+
declare interface VectorizeVectorMutation {
|
|
3273
|
+
/* List of ids of vectors that were successfully processed. */
|
|
3274
|
+
ids: string[];
|
|
3275
|
+
/* Total count of the number of processed vectors. */
|
|
3276
|
+
count: number;
|
|
3277
|
+
}
|
|
3278
|
+
declare abstract class VectorizeIndex {
|
|
3279
|
+
/**
|
|
3280
|
+
* Get information about the currently bound index.
|
|
3281
|
+
* @returns A promise that resolves with information about the current index.
|
|
3282
|
+
*/
|
|
3283
|
+
public describe(): Promise<VectorizeIndexDetails>;
|
|
3284
|
+
/**
|
|
3285
|
+
* Use the provided vector to perform a similarity search across the index.
|
|
3286
|
+
* @param vector Input vector that will be used to drive the similarity search.
|
|
3287
|
+
* @param options Configuration options to massage the returned data.
|
|
3288
|
+
* @returns A promise that resolves with matched and scored vectors.
|
|
3289
|
+
*/
|
|
3290
|
+
public query(
|
|
3291
|
+
vector: VectorFloatArray | number[],
|
|
3292
|
+
options: VectorizeQueryOptions
|
|
3293
|
+
): Promise<VectorizeMatches>;
|
|
3294
|
+
/**
|
|
3295
|
+
* Insert a list of vectors into the index dataset. If a provided id exists, an error will be thrown.
|
|
3296
|
+
* @param vectors List of vectors that will be inserted.
|
|
3297
|
+
* @returns A promise that resolves with the ids & count of records that were successfully processed.
|
|
3298
|
+
*/
|
|
3299
|
+
public insert(vectors: VectorizeVector[]): Promise<VectorizeVectorMutation>;
|
|
3300
|
+
/**
|
|
3301
|
+
* Upsert a list of vectors into the index dataset. If a provided id exists, it will be replaced with the new values.
|
|
3302
|
+
* @param vectors List of vectors that will be upserted.
|
|
3303
|
+
* @returns A promise that resolves with the ids & count of records that were successfully processed.
|
|
3304
|
+
*/
|
|
3305
|
+
public upsert(vectors: VectorizeVector[]): Promise<VectorizeVectorMutation>;
|
|
3306
|
+
/**
|
|
3307
|
+
* Delete a list of vectors with a matching id.
|
|
3308
|
+
* @param ids List of vector ids that should be deleted.
|
|
3309
|
+
* @returns A promise that resolves with the ids & count of records that were successfully processed (and thus deleted).
|
|
3310
|
+
*/
|
|
3311
|
+
public deleteByIds(ids: string[]): Promise<VectorizeVectorMutation>;
|
|
3312
|
+
/**
|
|
3313
|
+
* Get a list of vectors with a matching id.
|
|
3314
|
+
* @param ids List of vector ids that should be returned.
|
|
3315
|
+
* @returns A promise that resolves with the raw unscored vectors matching the id set.
|
|
3316
|
+
*/
|
|
3317
|
+
public getByIds(ids: string[]): Promise<VectorizeVector[]>;
|
|
3318
|
+
}
|
|
3148
3319
|
declare interface DynamicDispatchLimits {
|
|
3149
3320
|
/**
|
|
3150
3321
|
* Limit CPU time in milliseconds.
|
package/experimental/index.ts
CHANGED
|
@@ -886,7 +886,7 @@ export declare class TextDecoder {
|
|
|
886
886
|
}
|
|
887
887
|
export declare class TextEncoder {
|
|
888
888
|
constructor();
|
|
889
|
-
encode(input?: string):
|
|
889
|
+
encode(input?: string): Uint8Array;
|
|
890
890
|
encodeInto(
|
|
891
891
|
input: string,
|
|
892
892
|
buffer: ArrayBuffer | ArrayBufferView
|
|
@@ -2956,9 +2956,6 @@ export type ContinentCode = "AF" | "AN" | "AS" | "EU" | "NA" | "OC" | "SA";
|
|
|
2956
2956
|
export type CfProperties<HostMetadata = unknown> =
|
|
2957
2957
|
| IncomingRequestCfProperties<HostMetadata>
|
|
2958
2958
|
| RequestInitCfProperties;
|
|
2959
|
-
// Copyright (c) 2022-2023 Cloudflare, Inc.
|
|
2960
|
-
// Licensed under the Apache 2.0 license found in the LICENSE file or at:
|
|
2961
|
-
// https://opensource.org/licenses/Apache-2.0
|
|
2962
2959
|
export interface D1Result<T = unknown> {
|
|
2963
2960
|
results: T[];
|
|
2964
2961
|
success: true;
|
|
@@ -2983,9 +2980,6 @@ export declare abstract class D1PreparedStatement {
|
|
|
2983
2980
|
all<T = Record<string, unknown>>(): Promise<D1Result<T>>;
|
|
2984
2981
|
raw<T = unknown[]>(): Promise<T[]>;
|
|
2985
2982
|
}
|
|
2986
|
-
// Copyright (c) 2023 Cloudflare, Inc.
|
|
2987
|
-
// Licensed under the Apache 2.0 license found in the LICENSE file or at:
|
|
2988
|
-
// https://opensource.org/licenses/Apache-2.0
|
|
2989
2983
|
/**
|
|
2990
2984
|
* An email message that can be sent from a Worker.
|
|
2991
2985
|
*/
|
|
@@ -3043,9 +3037,53 @@ export type EmailExportedHandler<Env = unknown> = (
|
|
|
3043
3037
|
env: Env,
|
|
3044
3038
|
ctx: ExecutionContext
|
|
3045
3039
|
) => void | Promise<void>;
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3040
|
+
export interface Hyperdrive {
|
|
3041
|
+
/**
|
|
3042
|
+
* Connect directly to Hyperdrive as if it's your database, returning a TCP socket.
|
|
3043
|
+
*
|
|
3044
|
+
* Calling this method returns an idential socket to if you call
|
|
3045
|
+
* `connect("host:port")` using the `host` and `port` fields from this object.
|
|
3046
|
+
* Pick whichever approach works better with your preferred DB client library.
|
|
3047
|
+
*
|
|
3048
|
+
* Note that this socket is not yet authenticated -- it's expected that your
|
|
3049
|
+
* code (or preferably, the client library of your choice) will authenticate
|
|
3050
|
+
* using the information in this class's readonly fields.
|
|
3051
|
+
*/
|
|
3052
|
+
connect(): Socket;
|
|
3053
|
+
/**
|
|
3054
|
+
* A valid DB connection string that can be passed straight into the typical
|
|
3055
|
+
* client library/driver/ORM. This will typically be the easiest way to use
|
|
3056
|
+
* Hyperdrive.
|
|
3057
|
+
*/
|
|
3058
|
+
readonly connectionString: string;
|
|
3059
|
+
/*
|
|
3060
|
+
* A randomly generated hostname that is only valid within the context of the
|
|
3061
|
+
* currently running Worker which, when passed into `connect()` function from
|
|
3062
|
+
* the "cloudflare:sockets" module, will connect to the Hyperdrive instance
|
|
3063
|
+
* for your database.
|
|
3064
|
+
*/
|
|
3065
|
+
readonly host: string;
|
|
3066
|
+
/*
|
|
3067
|
+
* The port that must be paired the the host field when connecting.
|
|
3068
|
+
*/
|
|
3069
|
+
readonly port: string;
|
|
3070
|
+
/*
|
|
3071
|
+
* The username to use when authenticating to your database via Hyperdrive.
|
|
3072
|
+
* Unlike the host and password, this will be the same every time
|
|
3073
|
+
*/
|
|
3074
|
+
readonly user: string;
|
|
3075
|
+
/*
|
|
3076
|
+
* The randomly generated password to use when authenticating to your
|
|
3077
|
+
* database via Hyperdrive. Like the host field, this password is only valid
|
|
3078
|
+
* within the context of the currently running Worker instance from which
|
|
3079
|
+
* it's read.
|
|
3080
|
+
*/
|
|
3081
|
+
readonly password: string;
|
|
3082
|
+
/*
|
|
3083
|
+
* The name of the database to connect to.
|
|
3084
|
+
*/
|
|
3085
|
+
readonly database: string;
|
|
3086
|
+
}
|
|
3049
3087
|
export type Params<P extends string = any> = Record<P, string | string[]>;
|
|
3050
3088
|
export type EventContext<Env, P extends string, Data> = {
|
|
3051
3089
|
request: Request;
|
|
@@ -3089,13 +3127,10 @@ export type PagesPluginFunction<
|
|
|
3089
3127
|
> = (
|
|
3090
3128
|
context: EventPluginContext<Env, Params, Data, PluginArgs>
|
|
3091
3129
|
) => Response | Promise<Response>;
|
|
3092
|
-
// Copyright (c) 2023 Cloudflare, Inc.
|
|
3093
|
-
// Licensed under the Apache 2.0 license found in the LICENSE file or at:
|
|
3094
|
-
// https://opensource.org/licenses/Apache-2.0
|
|
3095
|
-
// https://developers.cloudflare.com/pub-sub/
|
|
3096
3130
|
// PubSubMessage represents an incoming PubSub message.
|
|
3097
3131
|
// The message includes metadata about the broker, the client, and the payload
|
|
3098
3132
|
// itself.
|
|
3133
|
+
// https://developers.cloudflare.com/pub-sub/
|
|
3099
3134
|
export interface PubSubMessage {
|
|
3100
3135
|
// Message ID
|
|
3101
3136
|
readonly mid: number;
|
|
@@ -3126,10 +3161,149 @@ export interface JsonWebKeyWithKid extends JsonWebKey {
|
|
|
3126
3161
|
// Key Identifier of the JWK
|
|
3127
3162
|
readonly kid: string;
|
|
3128
3163
|
}
|
|
3129
|
-
// Copyright (c) 2023 Cloudflare, Inc.
|
|
3164
|
+
// Copyright (c) 2022-2023 Cloudflare, Inc.
|
|
3130
3165
|
// Licensed under the Apache 2.0 license found in the LICENSE file or at:
|
|
3131
3166
|
// https://opensource.org/licenses/Apache-2.0
|
|
3132
|
-
|
|
3167
|
+
/**
|
|
3168
|
+
* Additional information to associate with a vector.
|
|
3169
|
+
*/
|
|
3170
|
+
export type VectorizeVectorMetadata =
|
|
3171
|
+
| string
|
|
3172
|
+
| number
|
|
3173
|
+
| boolean
|
|
3174
|
+
| string[]
|
|
3175
|
+
| Record<string, string | number | boolean | string[]>;
|
|
3176
|
+
export type VectorFloatArray = Float32Array | Float64Array;
|
|
3177
|
+
export interface VectorizeError {
|
|
3178
|
+
code?: number;
|
|
3179
|
+
error: string;
|
|
3180
|
+
}
|
|
3181
|
+
/**
|
|
3182
|
+
* A pre-configured list of known models.
|
|
3183
|
+
* These can be supplied in place of configuring explicit dimensions.
|
|
3184
|
+
*/
|
|
3185
|
+
export type VectorizePreset =
|
|
3186
|
+
| "openapi-text-embedding-ada-002"
|
|
3187
|
+
| "workers-ai/bge-small-en"
|
|
3188
|
+
| "cohere/embed-multilingual-v2.0";
|
|
3189
|
+
/**
|
|
3190
|
+
* Supported distance metrics for an index.
|
|
3191
|
+
* Distance metrics determine how other "similar" vectors are determined.
|
|
3192
|
+
*/
|
|
3193
|
+
export type VectorizeDistanceMetric = "euclidean" | "cosine" | "dot-product";
|
|
3194
|
+
export interface VectorizeQueryOptions {
|
|
3195
|
+
topK?: number;
|
|
3196
|
+
namespace?: string;
|
|
3197
|
+
returnVectors?: boolean;
|
|
3198
|
+
}
|
|
3199
|
+
/**
|
|
3200
|
+
* Information about the configuration of an index.
|
|
3201
|
+
*/
|
|
3202
|
+
export type VectorizeIndexConfig =
|
|
3203
|
+
| {
|
|
3204
|
+
dimensions: number;
|
|
3205
|
+
metric: VectorizeDistanceMetric;
|
|
3206
|
+
}
|
|
3207
|
+
| {
|
|
3208
|
+
preset: VectorizePreset;
|
|
3209
|
+
};
|
|
3210
|
+
/**
|
|
3211
|
+
* Metadata about an existing index.
|
|
3212
|
+
*/
|
|
3213
|
+
export interface VectorizeIndexDetails {
|
|
3214
|
+
/** The unique ID of the index */
|
|
3215
|
+
readonly id: string;
|
|
3216
|
+
/** The name of the index. */
|
|
3217
|
+
name: string;
|
|
3218
|
+
/** (optional) A human readable description for the index. */
|
|
3219
|
+
description?: string;
|
|
3220
|
+
/** The index configuration, including the dimension size and distance metric. */
|
|
3221
|
+
config: VectorizeIndexConfig;
|
|
3222
|
+
/** The number of records containing vectors within the index. */
|
|
3223
|
+
vectorsCount: number;
|
|
3224
|
+
}
|
|
3225
|
+
/**
|
|
3226
|
+
* Represents a single vector value set along with its associated metadata.
|
|
3227
|
+
*/
|
|
3228
|
+
export interface VectorizeVector {
|
|
3229
|
+
/** 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. */
|
|
3230
|
+
id: string;
|
|
3231
|
+
/** The vector values */
|
|
3232
|
+
values: VectorFloatArray | number[];
|
|
3233
|
+
/** The namespace this vector belongs to. */
|
|
3234
|
+
namespace?: string;
|
|
3235
|
+
/** Metadata associated with the binding. Includes the values of the other fields and potentially additional details. */
|
|
3236
|
+
metadata?: Record<string, VectorizeVectorMetadata>;
|
|
3237
|
+
}
|
|
3238
|
+
/**
|
|
3239
|
+
* Represents a matched vector for a query along with its score and (if specified) the matching vector information.
|
|
3240
|
+
*/
|
|
3241
|
+
export interface VectorizeMatch {
|
|
3242
|
+
/** 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. */
|
|
3243
|
+
vectorId: string;
|
|
3244
|
+
/** The score or rank for similarity, when returned as a result */
|
|
3245
|
+
score: number;
|
|
3246
|
+
/** Vector data for the match. Included only if the user specified they want it returned (via {@link VectorizeQueryOptions}). */
|
|
3247
|
+
vector?: VectorizeVector;
|
|
3248
|
+
}
|
|
3249
|
+
/**
|
|
3250
|
+
* A set of vector {@link VectorizeMatch} for a particular query.
|
|
3251
|
+
*/
|
|
3252
|
+
export interface VectorizeMatches {
|
|
3253
|
+
matches: VectorizeMatch[];
|
|
3254
|
+
count: number;
|
|
3255
|
+
}
|
|
3256
|
+
/**
|
|
3257
|
+
* Results of an operation that performed a mutation on a set of vectors.
|
|
3258
|
+
* Here, `ids` is a list of vectors that were successfully processed.
|
|
3259
|
+
*/
|
|
3260
|
+
export interface VectorizeVectorMutation {
|
|
3261
|
+
/* List of ids of vectors that were successfully processed. */
|
|
3262
|
+
ids: string[];
|
|
3263
|
+
/* Total count of the number of processed vectors. */
|
|
3264
|
+
count: number;
|
|
3265
|
+
}
|
|
3266
|
+
export declare abstract class VectorizeIndex {
|
|
3267
|
+
/**
|
|
3268
|
+
* Get information about the currently bound index.
|
|
3269
|
+
* @returns A promise that resolves with information about the current index.
|
|
3270
|
+
*/
|
|
3271
|
+
public describe(): Promise<VectorizeIndexDetails>;
|
|
3272
|
+
/**
|
|
3273
|
+
* Use the provided vector to perform a similarity search across the index.
|
|
3274
|
+
* @param vector Input vector that will be used to drive the similarity search.
|
|
3275
|
+
* @param options Configuration options to massage the returned data.
|
|
3276
|
+
* @returns A promise that resolves with matched and scored vectors.
|
|
3277
|
+
*/
|
|
3278
|
+
public query(
|
|
3279
|
+
vector: VectorFloatArray | number[],
|
|
3280
|
+
options: VectorizeQueryOptions
|
|
3281
|
+
): Promise<VectorizeMatches>;
|
|
3282
|
+
/**
|
|
3283
|
+
* Insert a list of vectors into the index dataset. If a provided id exists, an error will be thrown.
|
|
3284
|
+
* @param vectors List of vectors that will be inserted.
|
|
3285
|
+
* @returns A promise that resolves with the ids & count of records that were successfully processed.
|
|
3286
|
+
*/
|
|
3287
|
+
public insert(vectors: VectorizeVector[]): Promise<VectorizeVectorMutation>;
|
|
3288
|
+
/**
|
|
3289
|
+
* Upsert a list of vectors into the index dataset. If a provided id exists, it will be replaced with the new values.
|
|
3290
|
+
* @param vectors List of vectors that will be upserted.
|
|
3291
|
+
* @returns A promise that resolves with the ids & count of records that were successfully processed.
|
|
3292
|
+
*/
|
|
3293
|
+
public upsert(vectors: VectorizeVector[]): Promise<VectorizeVectorMutation>;
|
|
3294
|
+
/**
|
|
3295
|
+
* Delete a list of vectors with a matching id.
|
|
3296
|
+
* @param ids List of vector ids that should be deleted.
|
|
3297
|
+
* @returns A promise that resolves with the ids & count of records that were successfully processed (and thus deleted).
|
|
3298
|
+
*/
|
|
3299
|
+
public deleteByIds(ids: string[]): Promise<VectorizeVectorMutation>;
|
|
3300
|
+
/**
|
|
3301
|
+
* Get a list of vectors with a matching id.
|
|
3302
|
+
* @param ids List of vector ids that should be returned.
|
|
3303
|
+
* @returns A promise that resolves with the raw unscored vectors matching the id set.
|
|
3304
|
+
*/
|
|
3305
|
+
public getByIds(ids: string[]): Promise<VectorizeVector[]>;
|
|
3306
|
+
}
|
|
3133
3307
|
export interface DynamicDispatchLimits {
|
|
3134
3308
|
/**
|
|
3135
3309
|
* Limit CPU time in milliseconds.
|