Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
parkpow
GitHub Repository: parkpow/deep-license-plate-recognition
Path: blob/master/webhooks/stream-parkpow-webhook-worker/worker-configuration.d.ts
1093 views
1
/* eslint-disable */
2
// Generated by Wrangler by running `wrangler types` (hash: f0149d2b77774d1b4a0b0913415378e4)
3
// Runtime types generated with [email protected] 2025-11-04
4
declare namespace Cloudflare {
5
interface GlobalProps {
6
mainModule: typeof import("./src/index");
7
}
8
interface Env {
9
PARKPOW_ENDPOINT: "https://app.parkpow.com/api/v1/webhook-receiver/";
10
}
11
}
12
interface Env extends Cloudflare.Env {}
13
14
// Begin runtime types
15
/*! *****************************************************************************
16
Copyright (c) Cloudflare. All rights reserved.
17
Copyright (c) Microsoft Corporation. All rights reserved.
18
19
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
20
this file except in compliance with the License. You may obtain a copy of the
21
License at http://www.apache.org/licenses/LICENSE-2.0
22
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
23
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
24
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
25
MERCHANTABLITY OR NON-INFRINGEMENT.
26
See the Apache Version 2.0 License for specific language governing permissions
27
and limitations under the License.
28
***************************************************************************** */
29
/* eslint-disable */
30
// noinspection JSUnusedGlobalSymbols
31
declare var onmessage: never;
32
/**
33
* An abnormal event (called an exception) which occurs as a result of calling a method or accessing a property of a web API.
34
*
35
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException)
36
*/
37
declare class DOMException extends Error {
38
constructor(message?: string, name?: string);
39
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException/message) */
40
readonly message: string;
41
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException/name) */
42
readonly name: string;
43
/**
44
* @deprecated
45
*
46
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException/code)
47
*/
48
readonly code: number;
49
static readonly INDEX_SIZE_ERR: number;
50
static readonly DOMSTRING_SIZE_ERR: number;
51
static readonly HIERARCHY_REQUEST_ERR: number;
52
static readonly WRONG_DOCUMENT_ERR: number;
53
static readonly INVALID_CHARACTER_ERR: number;
54
static readonly NO_DATA_ALLOWED_ERR: number;
55
static readonly NO_MODIFICATION_ALLOWED_ERR: number;
56
static readonly NOT_FOUND_ERR: number;
57
static readonly NOT_SUPPORTED_ERR: number;
58
static readonly INUSE_ATTRIBUTE_ERR: number;
59
static readonly INVALID_STATE_ERR: number;
60
static readonly SYNTAX_ERR: number;
61
static readonly INVALID_MODIFICATION_ERR: number;
62
static readonly NAMESPACE_ERR: number;
63
static readonly INVALID_ACCESS_ERR: number;
64
static readonly VALIDATION_ERR: number;
65
static readonly TYPE_MISMATCH_ERR: number;
66
static readonly SECURITY_ERR: number;
67
static readonly NETWORK_ERR: number;
68
static readonly ABORT_ERR: number;
69
static readonly URL_MISMATCH_ERR: number;
70
static readonly QUOTA_EXCEEDED_ERR: number;
71
static readonly TIMEOUT_ERR: number;
72
static readonly INVALID_NODE_TYPE_ERR: number;
73
static readonly DATA_CLONE_ERR: number;
74
get stack(): any;
75
set stack(value: any);
76
}
77
type WorkerGlobalScopeEventMap = {
78
fetch: FetchEvent;
79
scheduled: ScheduledEvent;
80
queue: QueueEvent;
81
unhandledrejection: PromiseRejectionEvent;
82
rejectionhandled: PromiseRejectionEvent;
83
};
84
declare abstract class WorkerGlobalScope extends EventTarget<WorkerGlobalScopeEventMap> {
85
EventTarget: typeof EventTarget;
86
}
87
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console) */
88
interface Console {
89
"assert"(condition?: boolean, ...data: any[]): void;
90
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/clear_static) */
91
clear(): void;
92
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/count_static) */
93
count(label?: string): void;
94
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/countReset_static) */
95
countReset(label?: string): void;
96
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/debug_static) */
97
debug(...data: any[]): void;
98
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/dir_static) */
99
dir(item?: any, options?: any): void;
100
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/dirxml_static) */
101
dirxml(...data: any[]): void;
102
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/error_static) */
103
error(...data: any[]): void;
104
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/group_static) */
105
group(...data: any[]): void;
106
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/groupCollapsed_static) */
107
groupCollapsed(...data: any[]): void;
108
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/groupEnd_static) */
109
groupEnd(): void;
110
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/info_static) */
111
info(...data: any[]): void;
112
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/log_static) */
113
log(...data: any[]): void;
114
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/table_static) */
115
table(tabularData?: any, properties?: string[]): void;
116
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/time_static) */
117
time(label?: string): void;
118
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/timeEnd_static) */
119
timeEnd(label?: string): void;
120
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/timeLog_static) */
121
timeLog(label?: string, ...data: any[]): void;
122
timeStamp(label?: string): void;
123
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/trace_static) */
124
trace(...data: any[]): void;
125
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/warn_static) */
126
warn(...data: any[]): void;
127
}
128
declare const console: Console;
129
type BufferSource = ArrayBufferView | ArrayBuffer;
130
type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array;
131
declare namespace WebAssembly {
132
class CompileError extends Error {
133
constructor(message?: string);
134
}
135
class RuntimeError extends Error {
136
constructor(message?: string);
137
}
138
type ValueType = "anyfunc" | "externref" | "f32" | "f64" | "i32" | "i64" | "v128";
139
interface GlobalDescriptor {
140
value: ValueType;
141
mutable?: boolean;
142
}
143
class Global {
144
constructor(descriptor: GlobalDescriptor, value?: any);
145
value: any;
146
valueOf(): any;
147
}
148
type ImportValue = ExportValue | number;
149
type ModuleImports = Record<string, ImportValue>;
150
type Imports = Record<string, ModuleImports>;
151
type ExportValue = Function | Global | Memory | Table;
152
type Exports = Record<string, ExportValue>;
153
class Instance {
154
constructor(module: Module, imports?: Imports);
155
readonly exports: Exports;
156
}
157
interface MemoryDescriptor {
158
initial: number;
159
maximum?: number;
160
shared?: boolean;
161
}
162
class Memory {
163
constructor(descriptor: MemoryDescriptor);
164
readonly buffer: ArrayBuffer;
165
grow(delta: number): number;
166
}
167
type ImportExportKind = "function" | "global" | "memory" | "table";
168
interface ModuleExportDescriptor {
169
kind: ImportExportKind;
170
name: string;
171
}
172
interface ModuleImportDescriptor {
173
kind: ImportExportKind;
174
module: string;
175
name: string;
176
}
177
abstract class Module {
178
static customSections(module: Module, sectionName: string): ArrayBuffer[];
179
static exports(module: Module): ModuleExportDescriptor[];
180
static imports(module: Module): ModuleImportDescriptor[];
181
}
182
type TableKind = "anyfunc" | "externref";
183
interface TableDescriptor {
184
element: TableKind;
185
initial: number;
186
maximum?: number;
187
}
188
class Table {
189
constructor(descriptor: TableDescriptor, value?: any);
190
readonly length: number;
191
get(index: number): any;
192
grow(delta: number, value?: any): number;
193
set(index: number, value?: any): void;
194
}
195
function instantiate(module: Module, imports?: Imports): Promise<Instance>;
196
function validate(bytes: BufferSource): boolean;
197
}
198
/**
199
* This ServiceWorker API interface represents the global execution context of a service worker.
200
* Available only in secure contexts.
201
*
202
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ServiceWorkerGlobalScope)
203
*/
204
interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
205
DOMException: typeof DOMException;
206
WorkerGlobalScope: typeof WorkerGlobalScope;
207
btoa(data: string): string;
208
atob(data: string): string;
209
setTimeout(callback: (...args: any[]) => void, msDelay?: number): number;
210
setTimeout<Args extends any[]>(callback: (...args: Args) => void, msDelay?: number, ...args: Args): number;
211
clearTimeout(timeoutId: number | null): void;
212
setInterval(callback: (...args: any[]) => void, msDelay?: number): number;
213
setInterval<Args extends any[]>(callback: (...args: Args) => void, msDelay?: number, ...args: Args): number;
214
clearInterval(timeoutId: number | null): void;
215
queueMicrotask(task: Function): void;
216
structuredClone<T>(value: T, options?: StructuredSerializeOptions): T;
217
reportError(error: any): void;
218
fetch(input: RequestInfo | URL, init?: RequestInit<RequestInitCfProperties>): Promise<Response>;
219
self: ServiceWorkerGlobalScope;
220
crypto: Crypto;
221
caches: CacheStorage;
222
scheduler: Scheduler;
223
performance: Performance;
224
Cloudflare: Cloudflare;
225
readonly origin: string;
226
Event: typeof Event;
227
ExtendableEvent: typeof ExtendableEvent;
228
CustomEvent: typeof CustomEvent;
229
PromiseRejectionEvent: typeof PromiseRejectionEvent;
230
FetchEvent: typeof FetchEvent;
231
TailEvent: typeof TailEvent;
232
TraceEvent: typeof TailEvent;
233
ScheduledEvent: typeof ScheduledEvent;
234
MessageEvent: typeof MessageEvent;
235
CloseEvent: typeof CloseEvent;
236
ReadableStreamDefaultReader: typeof ReadableStreamDefaultReader;
237
ReadableStreamBYOBReader: typeof ReadableStreamBYOBReader;
238
ReadableStream: typeof ReadableStream;
239
WritableStream: typeof WritableStream;
240
WritableStreamDefaultWriter: typeof WritableStreamDefaultWriter;
241
TransformStream: typeof TransformStream;
242
ByteLengthQueuingStrategy: typeof ByteLengthQueuingStrategy;
243
CountQueuingStrategy: typeof CountQueuingStrategy;
244
ErrorEvent: typeof ErrorEvent;
245
MessageChannel: typeof MessageChannel;
246
MessagePort: typeof MessagePort;
247
EventSource: typeof EventSource;
248
ReadableStreamBYOBRequest: typeof ReadableStreamBYOBRequest;
249
ReadableStreamDefaultController: typeof ReadableStreamDefaultController;
250
ReadableByteStreamController: typeof ReadableByteStreamController;
251
WritableStreamDefaultController: typeof WritableStreamDefaultController;
252
TransformStreamDefaultController: typeof TransformStreamDefaultController;
253
CompressionStream: typeof CompressionStream;
254
DecompressionStream: typeof DecompressionStream;
255
TextEncoderStream: typeof TextEncoderStream;
256
TextDecoderStream: typeof TextDecoderStream;
257
Headers: typeof Headers;
258
Body: typeof Body;
259
Request: typeof Request;
260
Response: typeof Response;
261
WebSocket: typeof WebSocket;
262
WebSocketPair: typeof WebSocketPair;
263
WebSocketRequestResponsePair: typeof WebSocketRequestResponsePair;
264
AbortController: typeof AbortController;
265
AbortSignal: typeof AbortSignal;
266
TextDecoder: typeof TextDecoder;
267
TextEncoder: typeof TextEncoder;
268
navigator: Navigator;
269
Navigator: typeof Navigator;
270
URL: typeof URL;
271
URLSearchParams: typeof URLSearchParams;
272
URLPattern: typeof URLPattern;
273
Blob: typeof Blob;
274
File: typeof File;
275
FormData: typeof FormData;
276
Crypto: typeof Crypto;
277
SubtleCrypto: typeof SubtleCrypto;
278
CryptoKey: typeof CryptoKey;
279
CacheStorage: typeof CacheStorage;
280
Cache: typeof Cache;
281
FixedLengthStream: typeof FixedLengthStream;
282
IdentityTransformStream: typeof IdentityTransformStream;
283
HTMLRewriter: typeof HTMLRewriter;
284
}
285
declare function addEventListener<Type extends keyof WorkerGlobalScopeEventMap>(type: Type, handler: EventListenerOrEventListenerObject<WorkerGlobalScopeEventMap[Type]>, options?: EventTargetAddEventListenerOptions | boolean): void;
286
declare function removeEventListener<Type extends keyof WorkerGlobalScopeEventMap>(type: Type, handler: EventListenerOrEventListenerObject<WorkerGlobalScopeEventMap[Type]>, options?: EventTargetEventListenerOptions | boolean): void;
287
/**
288
* Dispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise.
289
*
290
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/dispatchEvent)
291
*/
292
declare function dispatchEvent(event: WorkerGlobalScopeEventMap[keyof WorkerGlobalScopeEventMap]): boolean;
293
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/btoa) */
294
declare function btoa(data: string): string;
295
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/atob) */
296
declare function atob(data: string): string;
297
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/setTimeout) */
298
declare function setTimeout(callback: (...args: any[]) => void, msDelay?: number): number;
299
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/setTimeout) */
300
declare function setTimeout<Args extends any[]>(callback: (...args: Args) => void, msDelay?: number, ...args: Args): number;
301
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/clearTimeout) */
302
declare function clearTimeout(timeoutId: number | null): void;
303
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/setInterval) */
304
declare function setInterval(callback: (...args: any[]) => void, msDelay?: number): number;
305
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/setInterval) */
306
declare function setInterval<Args extends any[]>(callback: (...args: Args) => void, msDelay?: number, ...args: Args): number;
307
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/clearInterval) */
308
declare function clearInterval(timeoutId: number | null): void;
309
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/queueMicrotask) */
310
declare function queueMicrotask(task: Function): void;
311
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/structuredClone) */
312
declare function structuredClone<T>(value: T, options?: StructuredSerializeOptions): T;
313
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/reportError) */
314
declare function reportError(error: any): void;
315
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/fetch) */
316
declare function fetch(input: RequestInfo | URL, init?: RequestInit<RequestInitCfProperties>): Promise<Response>;
317
declare const self: ServiceWorkerGlobalScope;
318
/**
319
* The Web Crypto API provides a set of low-level functions for common cryptographic tasks.
320
* The Workers runtime implements the full surface of this API, but with some differences in
321
* the [supported algorithms](https://developers.cloudflare.com/workers/runtime-apis/web-crypto/#supported-algorithms)
322
* compared to those implemented in most browsers.
323
*
324
* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/web-crypto/)
325
*/
326
declare const crypto: Crypto;
327
/**
328
* The Cache API allows fine grained control of reading and writing from the Cloudflare global network cache.
329
*
330
* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/)
331
*/
332
declare const caches: CacheStorage;
333
declare const scheduler: Scheduler;
334
/**
335
* The Workers runtime supports a subset of the Performance API, used to measure timing and performance,
336
* as well as timing of subrequests and other operations.
337
*
338
* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/)
339
*/
340
declare const performance: Performance;
341
declare const Cloudflare: Cloudflare;
342
declare const origin: string;
343
declare const navigator: Navigator;
344
interface TestController {
345
}
346
interface ExecutionContext<Props = unknown> {
347
waitUntil(promise: Promise<any>): void;
348
passThroughOnException(): void;
349
readonly props: Props;
350
}
351
type ExportedHandlerFetchHandler<Env = unknown, CfHostMetadata = unknown> = (request: Request<CfHostMetadata, IncomingRequestCfProperties<CfHostMetadata>>, env: Env, ctx: ExecutionContext) => Response | Promise<Response>;
352
type ExportedHandlerTailHandler<Env = unknown> = (events: TraceItem[], env: Env, ctx: ExecutionContext) => void | Promise<void>;
353
type ExportedHandlerTraceHandler<Env = unknown> = (traces: TraceItem[], env: Env, ctx: ExecutionContext) => void | Promise<void>;
354
type ExportedHandlerTailStreamHandler<Env = unknown> = (event: TailStream.TailEvent<TailStream.Onset>, env: Env, ctx: ExecutionContext) => TailStream.TailEventHandlerType | Promise<TailStream.TailEventHandlerType>;
355
type ExportedHandlerScheduledHandler<Env = unknown> = (controller: ScheduledController, env: Env, ctx: ExecutionContext) => void | Promise<void>;
356
type ExportedHandlerQueueHandler<Env = unknown, Message = unknown> = (batch: MessageBatch<Message>, env: Env, ctx: ExecutionContext) => void | Promise<void>;
357
type ExportedHandlerTestHandler<Env = unknown> = (controller: TestController, env: Env, ctx: ExecutionContext) => void | Promise<void>;
358
interface ExportedHandler<Env = unknown, QueueHandlerMessage = unknown, CfHostMetadata = unknown> {
359
fetch?: ExportedHandlerFetchHandler<Env, CfHostMetadata>;
360
tail?: ExportedHandlerTailHandler<Env>;
361
trace?: ExportedHandlerTraceHandler<Env>;
362
tailStream?: ExportedHandlerTailStreamHandler<Env>;
363
scheduled?: ExportedHandlerScheduledHandler<Env>;
364
test?: ExportedHandlerTestHandler<Env>;
365
email?: EmailExportedHandler<Env>;
366
queue?: ExportedHandlerQueueHandler<Env, QueueHandlerMessage>;
367
}
368
interface StructuredSerializeOptions {
369
transfer?: any[];
370
}
371
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/PromiseRejectionEvent) */
372
declare abstract class PromiseRejectionEvent extends Event {
373
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/PromiseRejectionEvent/promise) */
374
readonly promise: Promise<any>;
375
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/PromiseRejectionEvent/reason) */
376
readonly reason: any;
377
}
378
declare abstract class Navigator {
379
sendBeacon(url: string, body?: (ReadableStream | string | (ArrayBuffer | ArrayBufferView) | Blob | FormData | URLSearchParams | URLSearchParams)): boolean;
380
readonly userAgent: string;
381
readonly hardwareConcurrency: number;
382
readonly language: string;
383
readonly languages: string[];
384
}
385
interface AlarmInvocationInfo {
386
readonly isRetry: boolean;
387
readonly retryCount: number;
388
}
389
interface Cloudflare {
390
readonly compatibilityFlags: Record<string, boolean>;
391
}
392
interface DurableObject {
393
fetch(request: Request): Response | Promise<Response>;
394
alarm?(alarmInfo?: AlarmInvocationInfo): void | Promise<void>;
395
webSocketMessage?(ws: WebSocket, message: string | ArrayBuffer): void | Promise<void>;
396
webSocketClose?(ws: WebSocket, code: number, reason: string, wasClean: boolean): void | Promise<void>;
397
webSocketError?(ws: WebSocket, error: unknown): void | Promise<void>;
398
}
399
type DurableObjectStub<T extends Rpc.DurableObjectBranded | undefined = undefined> = Fetcher<T, "alarm" | "webSocketMessage" | "webSocketClose" | "webSocketError"> & {
400
readonly id: DurableObjectId;
401
readonly name?: string;
402
};
403
interface DurableObjectId {
404
toString(): string;
405
equals(other: DurableObjectId): boolean;
406
readonly name?: string;
407
}
408
declare abstract class DurableObjectNamespace<T extends Rpc.DurableObjectBranded | undefined = undefined> {
409
newUniqueId(options?: DurableObjectNamespaceNewUniqueIdOptions): DurableObjectId;
410
idFromName(name: string): DurableObjectId;
411
idFromString(id: string): DurableObjectId;
412
get(id: DurableObjectId, options?: DurableObjectNamespaceGetDurableObjectOptions): DurableObjectStub<T>;
413
getByName(name: string, options?: DurableObjectNamespaceGetDurableObjectOptions): DurableObjectStub<T>;
414
jurisdiction(jurisdiction: DurableObjectJurisdiction): DurableObjectNamespace<T>;
415
}
416
type DurableObjectJurisdiction = "eu" | "fedramp" | "fedramp-high";
417
interface DurableObjectNamespaceNewUniqueIdOptions {
418
jurisdiction?: DurableObjectJurisdiction;
419
}
420
type DurableObjectLocationHint = "wnam" | "enam" | "sam" | "weur" | "eeur" | "apac" | "oc" | "afr" | "me";
421
interface DurableObjectNamespaceGetDurableObjectOptions {
422
locationHint?: DurableObjectLocationHint;
423
}
424
interface DurableObjectClass<_T extends Rpc.DurableObjectBranded | undefined = undefined> {
425
}
426
interface DurableObjectState<Props = unknown> {
427
waitUntil(promise: Promise<any>): void;
428
readonly props: Props;
429
readonly id: DurableObjectId;
430
readonly storage: DurableObjectStorage;
431
container?: Container;
432
blockConcurrencyWhile<T>(callback: () => Promise<T>): Promise<T>;
433
acceptWebSocket(ws: WebSocket, tags?: string[]): void;
434
getWebSockets(tag?: string): WebSocket[];
435
setWebSocketAutoResponse(maybeReqResp?: WebSocketRequestResponsePair): void;
436
getWebSocketAutoResponse(): WebSocketRequestResponsePair | null;
437
getWebSocketAutoResponseTimestamp(ws: WebSocket): Date | null;
438
setHibernatableWebSocketEventTimeout(timeoutMs?: number): void;
439
getHibernatableWebSocketEventTimeout(): number | null;
440
getTags(ws: WebSocket): string[];
441
abort(reason?: string): void;
442
}
443
interface DurableObjectTransaction {
444
get<T = unknown>(key: string, options?: DurableObjectGetOptions): Promise<T | undefined>;
445
get<T = unknown>(keys: string[], options?: DurableObjectGetOptions): Promise<Map<string, T>>;
446
list<T = unknown>(options?: DurableObjectListOptions): Promise<Map<string, T>>;
447
put<T>(key: string, value: T, options?: DurableObjectPutOptions): Promise<void>;
448
put<T>(entries: Record<string, T>, options?: DurableObjectPutOptions): Promise<void>;
449
delete(key: string, options?: DurableObjectPutOptions): Promise<boolean>;
450
delete(keys: string[], options?: DurableObjectPutOptions): Promise<number>;
451
rollback(): void;
452
getAlarm(options?: DurableObjectGetAlarmOptions): Promise<number | null>;
453
setAlarm(scheduledTime: number | Date, options?: DurableObjectSetAlarmOptions): Promise<void>;
454
deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise<void>;
455
}
456
interface DurableObjectStorage {
457
get<T = unknown>(key: string, options?: DurableObjectGetOptions): Promise<T | undefined>;
458
get<T = unknown>(keys: string[], options?: DurableObjectGetOptions): Promise<Map<string, T>>;
459
list<T = unknown>(options?: DurableObjectListOptions): Promise<Map<string, T>>;
460
put<T>(key: string, value: T, options?: DurableObjectPutOptions): Promise<void>;
461
put<T>(entries: Record<string, T>, options?: DurableObjectPutOptions): Promise<void>;
462
delete(key: string, options?: DurableObjectPutOptions): Promise<boolean>;
463
delete(keys: string[], options?: DurableObjectPutOptions): Promise<number>;
464
deleteAll(options?: DurableObjectPutOptions): Promise<void>;
465
transaction<T>(closure: (txn: DurableObjectTransaction) => Promise<T>): Promise<T>;
466
getAlarm(options?: DurableObjectGetAlarmOptions): Promise<number | null>;
467
setAlarm(scheduledTime: number | Date, options?: DurableObjectSetAlarmOptions): Promise<void>;
468
deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise<void>;
469
sync(): Promise<void>;
470
sql: SqlStorage;
471
kv: SyncKvStorage;
472
transactionSync<T>(closure: () => T): T;
473
getCurrentBookmark(): Promise<string>;
474
getBookmarkForTime(timestamp: number | Date): Promise<string>;
475
onNextSessionRestoreBookmark(bookmark: string): Promise<string>;
476
}
477
interface DurableObjectListOptions {
478
start?: string;
479
startAfter?: string;
480
end?: string;
481
prefix?: string;
482
reverse?: boolean;
483
limit?: number;
484
allowConcurrency?: boolean;
485
noCache?: boolean;
486
}
487
interface DurableObjectGetOptions {
488
allowConcurrency?: boolean;
489
noCache?: boolean;
490
}
491
interface DurableObjectGetAlarmOptions {
492
allowConcurrency?: boolean;
493
}
494
interface DurableObjectPutOptions {
495
allowConcurrency?: boolean;
496
allowUnconfirmed?: boolean;
497
noCache?: boolean;
498
}
499
interface DurableObjectSetAlarmOptions {
500
allowConcurrency?: boolean;
501
allowUnconfirmed?: boolean;
502
}
503
declare class WebSocketRequestResponsePair {
504
constructor(request: string, response: string);
505
get request(): string;
506
get response(): string;
507
}
508
interface AnalyticsEngineDataset {
509
writeDataPoint(event?: AnalyticsEngineDataPoint): void;
510
}
511
interface AnalyticsEngineDataPoint {
512
indexes?: ((ArrayBuffer | string) | null)[];
513
doubles?: number[];
514
blobs?: ((ArrayBuffer | string) | null)[];
515
}
516
/**
517
* An event which takes place in the DOM.
518
*
519
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event)
520
*/
521
declare class Event {
522
constructor(type: string, init?: EventInit);
523
/**
524
* Returns the type of event, e.g. "click", "hashchange", or "submit".
525
*
526
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/type)
527
*/
528
get type(): string;
529
/**
530
* Returns the event's phase, which is one of NONE, CAPTURING_PHASE, AT_TARGET, and BUBBLING_PHASE.
531
*
532
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/eventPhase)
533
*/
534
get eventPhase(): number;
535
/**
536
* Returns true or false depending on how event was initialized. True if event invokes listeners past a ShadowRoot node that is the root of its target, and false otherwise.
537
*
538
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/composed)
539
*/
540
get composed(): boolean;
541
/**
542
* Returns true or false depending on how event was initialized. True if event goes through its target's ancestors in reverse tree order, and false otherwise.
543
*
544
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/bubbles)
545
*/
546
get bubbles(): boolean;
547
/**
548
* Returns true or false depending on how event was initialized. Its return value does not always carry meaning, but true can indicate that part of the operation during which event was dispatched, can be canceled by invoking the preventDefault() method.
549
*
550
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/cancelable)
551
*/
552
get cancelable(): boolean;
553
/**
554
* Returns true if preventDefault() was invoked successfully to indicate cancelation, and false otherwise.
555
*
556
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/defaultPrevented)
557
*/
558
get defaultPrevented(): boolean;
559
/**
560
* @deprecated
561
*
562
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/returnValue)
563
*/
564
get returnValue(): boolean;
565
/**
566
* Returns the object whose event listener's callback is currently being invoked.
567
*
568
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/currentTarget)
569
*/
570
get currentTarget(): EventTarget | undefined;
571
/**
572
* Returns the object to which event is dispatched (its target).
573
*
574
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/target)
575
*/
576
get target(): EventTarget | undefined;
577
/**
578
* @deprecated
579
*
580
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/srcElement)
581
*/
582
get srcElement(): EventTarget | undefined;
583
/**
584
* Returns the event's timestamp as the number of milliseconds measured relative to the time origin.
585
*
586
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/timeStamp)
587
*/
588
get timeStamp(): number;
589
/**
590
* Returns true if event was dispatched by the user agent, and false otherwise.
591
*
592
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/isTrusted)
593
*/
594
get isTrusted(): boolean;
595
/**
596
* @deprecated
597
*
598
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/cancelBubble)
599
*/
600
get cancelBubble(): boolean;
601
/**
602
* @deprecated
603
*
604
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/cancelBubble)
605
*/
606
set cancelBubble(value: boolean);
607
/**
608
* Invoking this method prevents event from reaching any registered event listeners after the current one finishes running and, when dispatched in a tree, also prevents event from reaching any other objects.
609
*
610
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/stopImmediatePropagation)
611
*/
612
stopImmediatePropagation(): void;
613
/**
614
* If invoked when the cancelable attribute value is true, and while executing a listener for the event with passive set to false, signals to the operation that caused event to be dispatched that it needs to be canceled.
615
*
616
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/preventDefault)
617
*/
618
preventDefault(): void;
619
/**
620
* When dispatched in a tree, invoking this method prevents event from reaching any objects other than the current object.
621
*
622
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/stopPropagation)
623
*/
624
stopPropagation(): void;
625
/**
626
* Returns the invocation target objects of event's path (objects on which listeners will be invoked), except for any nodes in shadow trees of which the shadow root's mode is "closed" that are not reachable from event's currentTarget.
627
*
628
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/composedPath)
629
*/
630
composedPath(): EventTarget[];
631
static readonly NONE: number;
632
static readonly CAPTURING_PHASE: number;
633
static readonly AT_TARGET: number;
634
static readonly BUBBLING_PHASE: number;
635
}
636
interface EventInit {
637
bubbles?: boolean;
638
cancelable?: boolean;
639
composed?: boolean;
640
}
641
type EventListener<EventType extends Event = Event> = (event: EventType) => void;
642
interface EventListenerObject<EventType extends Event = Event> {
643
handleEvent(event: EventType): void;
644
}
645
type EventListenerOrEventListenerObject<EventType extends Event = Event> = EventListener<EventType> | EventListenerObject<EventType>;
646
/**
647
* EventTarget is a DOM interface implemented by objects that can receive events and may have listeners for them.
648
*
649
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget)
650
*/
651
declare class EventTarget<EventMap extends Record<string, Event> = Record<string, Event>> {
652
constructor();
653
/**
654
* Appends an event listener for events whose type attribute value is type. The callback argument sets the callback that will be invoked when the event is dispatched.
655
*
656
* The options argument sets listener-specific options. For compatibility this can be a boolean, in which case the method behaves exactly as if the value was specified as options's capture.
657
*
658
* When set to true, options's capture prevents callback from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. When false (or not present), callback will not be invoked when event's eventPhase attribute value is CAPTURING_PHASE. Either way, callback will be invoked if event's eventPhase attribute value is AT_TARGET.
659
*
660
* When set to true, options's passive indicates that the callback will not cancel the event by invoking preventDefault(). This is used to enable performance optimizations described in § 2.8 Observing event listeners.
661
*
662
* When set to true, options's once indicates that the callback will only be invoked once after which the event listener will be removed.
663
*
664
* If an AbortSignal is passed for options's signal, then the event listener will be removed when signal is aborted.
665
*
666
* The event listener is appended to target's event listener list and is not appended if it has the same type, callback, and capture.
667
*
668
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/addEventListener)
669
*/
670
addEventListener<Type extends keyof EventMap>(type: Type, handler: EventListenerOrEventListenerObject<EventMap[Type]>, options?: EventTargetAddEventListenerOptions | boolean): void;
671
/**
672
* Removes the event listener in target's event listener list with the same type, callback, and options.
673
*
674
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/removeEventListener)
675
*/
676
removeEventListener<Type extends keyof EventMap>(type: Type, handler: EventListenerOrEventListenerObject<EventMap[Type]>, options?: EventTargetEventListenerOptions | boolean): void;
677
/**
678
* Dispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise.
679
*
680
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/dispatchEvent)
681
*/
682
dispatchEvent(event: EventMap[keyof EventMap]): boolean;
683
}
684
interface EventTargetEventListenerOptions {
685
capture?: boolean;
686
}
687
interface EventTargetAddEventListenerOptions {
688
capture?: boolean;
689
passive?: boolean;
690
once?: boolean;
691
signal?: AbortSignal;
692
}
693
interface EventTargetHandlerObject {
694
handleEvent: (event: Event) => any | undefined;
695
}
696
/**
697
* A controller object that allows you to abort one or more DOM requests as and when desired.
698
*
699
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortController)
700
*/
701
declare class AbortController {
702
constructor();
703
/**
704
* Returns the AbortSignal object associated with this object.
705
*
706
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortController/signal)
707
*/
708
get signal(): AbortSignal;
709
/**
710
* Invoking this method will set this object's AbortSignal's aborted flag and signal to any observers that the associated activity is to be aborted.
711
*
712
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortController/abort)
713
*/
714
abort(reason?: any): void;
715
}
716
/**
717
* A signal object that allows you to communicate with a DOM request (such as a Fetch) and abort it if required via an AbortController object.
718
*
719
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal)
720
*/
721
declare abstract class AbortSignal extends EventTarget {
722
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/abort_static) */
723
static abort(reason?: any): AbortSignal;
724
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/timeout_static) */
725
static timeout(delay: number): AbortSignal;
726
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/any_static) */
727
static any(signals: AbortSignal[]): AbortSignal;
728
/**
729
* Returns true if this AbortSignal's AbortController has signaled to abort, and false otherwise.
730
*
731
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/aborted)
732
*/
733
get aborted(): boolean;
734
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/reason) */
735
get reason(): any;
736
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/abort_event) */
737
get onabort(): any | null;
738
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/abort_event) */
739
set onabort(value: any | null);
740
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/throwIfAborted) */
741
throwIfAborted(): void;
742
}
743
interface Scheduler {
744
wait(delay: number, maybeOptions?: SchedulerWaitOptions): Promise<void>;
745
}
746
interface SchedulerWaitOptions {
747
signal?: AbortSignal;
748
}
749
/**
750
* Extends the lifetime of the install and activate events dispatched on the global scope as part of the service worker lifecycle. This ensures that any functional events (like FetchEvent) are not dispatched until it upgrades database schemas and deletes the outdated cache entries.
751
*
752
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ExtendableEvent)
753
*/
754
declare abstract class ExtendableEvent extends Event {
755
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ExtendableEvent/waitUntil) */
756
waitUntil(promise: Promise<any>): void;
757
}
758
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CustomEvent) */
759
declare class CustomEvent<T = any> extends Event {
760
constructor(type: string, init?: CustomEventCustomEventInit);
761
/**
762
* Returns any custom data event was created with. Typically used for synthetic events.
763
*
764
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CustomEvent/detail)
765
*/
766
get detail(): T;
767
}
768
interface CustomEventCustomEventInit {
769
bubbles?: boolean;
770
cancelable?: boolean;
771
composed?: boolean;
772
detail?: any;
773
}
774
/**
775
* A file-like object of immutable, raw data. Blobs represent data that isn't necessarily in a JavaScript-native format. The File interface is based on Blob, inheriting blob functionality and expanding it to support files on the user's system.
776
*
777
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob)
778
*/
779
declare class Blob {
780
constructor(type?: ((ArrayBuffer | ArrayBufferView) | string | Blob)[], options?: BlobOptions);
781
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/size) */
782
get size(): number;
783
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/type) */
784
get type(): string;
785
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/slice) */
786
slice(start?: number, end?: number, type?: string): Blob;
787
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/arrayBuffer) */
788
arrayBuffer(): Promise<ArrayBuffer>;
789
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/bytes) */
790
bytes(): Promise<Uint8Array>;
791
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/text) */
792
text(): Promise<string>;
793
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/stream) */
794
stream(): ReadableStream;
795
}
796
interface BlobOptions {
797
type?: string;
798
}
799
/**
800
* Provides information about files and allows JavaScript in a web page to access their content.
801
*
802
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/File)
803
*/
804
declare class File extends Blob {
805
constructor(bits: ((ArrayBuffer | ArrayBufferView) | string | Blob)[] | undefined, name: string, options?: FileOptions);
806
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/File/name) */
807
get name(): string;
808
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/File/lastModified) */
809
get lastModified(): number;
810
}
811
interface FileOptions {
812
type?: string;
813
lastModified?: number;
814
}
815
/**
816
* The Cache API allows fine grained control of reading and writing from the Cloudflare global network cache.
817
*
818
* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/)
819
*/
820
declare abstract class CacheStorage {
821
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CacheStorage/open) */
822
open(cacheName: string): Promise<Cache>;
823
readonly default: Cache;
824
}
825
/**
826
* The Cache API allows fine grained control of reading and writing from the Cloudflare global network cache.
827
*
828
* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/)
829
*/
830
declare abstract class Cache {
831
/* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/#delete) */
832
delete(request: RequestInfo | URL, options?: CacheQueryOptions): Promise<boolean>;
833
/* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/#match) */
834
match(request: RequestInfo | URL, options?: CacheQueryOptions): Promise<Response | undefined>;
835
/* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/#put) */
836
put(request: RequestInfo | URL, response: Response): Promise<void>;
837
}
838
interface CacheQueryOptions {
839
ignoreMethod?: boolean;
840
}
841
/**
842
* The Web Crypto API provides a set of low-level functions for common cryptographic tasks.
843
* The Workers runtime implements the full surface of this API, but with some differences in
844
* the [supported algorithms](https://developers.cloudflare.com/workers/runtime-apis/web-crypto/#supported-algorithms)
845
* compared to those implemented in most browsers.
846
*
847
* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/web-crypto/)
848
*/
849
declare abstract class Crypto {
850
/**
851
* Available only in secure contexts.
852
*
853
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Crypto/subtle)
854
*/
855
get subtle(): SubtleCrypto;
856
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Crypto/getRandomValues) */
857
getRandomValues<T extends Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | BigInt64Array | BigUint64Array>(buffer: T): T;
858
/**
859
* Available only in secure contexts.
860
*
861
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Crypto/randomUUID)
862
*/
863
randomUUID(): string;
864
DigestStream: typeof DigestStream;
865
}
866
/**
867
* This Web Crypto API interface provides a number of low-level cryptographic functions. It is accessed via the Crypto.subtle properties available in a window context (via Window.crypto).
868
* Available only in secure contexts.
869
*
870
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto)
871
*/
872
declare abstract class SubtleCrypto {
873
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/encrypt) */
874
encrypt(algorithm: string | SubtleCryptoEncryptAlgorithm, key: CryptoKey, plainText: ArrayBuffer | ArrayBufferView): Promise<ArrayBuffer>;
875
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/decrypt) */
876
decrypt(algorithm: string | SubtleCryptoEncryptAlgorithm, key: CryptoKey, cipherText: ArrayBuffer | ArrayBufferView): Promise<ArrayBuffer>;
877
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/sign) */
878
sign(algorithm: string | SubtleCryptoSignAlgorithm, key: CryptoKey, data: ArrayBuffer | ArrayBufferView): Promise<ArrayBuffer>;
879
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/verify) */
880
verify(algorithm: string | SubtleCryptoSignAlgorithm, key: CryptoKey, signature: ArrayBuffer | ArrayBufferView, data: ArrayBuffer | ArrayBufferView): Promise<boolean>;
881
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/digest) */
882
digest(algorithm: string | SubtleCryptoHashAlgorithm, data: ArrayBuffer | ArrayBufferView): Promise<ArrayBuffer>;
883
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/generateKey) */
884
generateKey(algorithm: string | SubtleCryptoGenerateKeyAlgorithm, extractable: boolean, keyUsages: string[]): Promise<CryptoKey | CryptoKeyPair>;
885
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/deriveKey) */
886
deriveKey(algorithm: string | SubtleCryptoDeriveKeyAlgorithm, baseKey: CryptoKey, derivedKeyAlgorithm: string | SubtleCryptoImportKeyAlgorithm, extractable: boolean, keyUsages: string[]): Promise<CryptoKey>;
887
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/deriveBits) */
888
deriveBits(algorithm: string | SubtleCryptoDeriveKeyAlgorithm, baseKey: CryptoKey, length?: number | null): Promise<ArrayBuffer>;
889
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/importKey) */
890
importKey(format: string, keyData: (ArrayBuffer | ArrayBufferView) | JsonWebKey, algorithm: string | SubtleCryptoImportKeyAlgorithm, extractable: boolean, keyUsages: string[]): Promise<CryptoKey>;
891
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/exportKey) */
892
exportKey(format: string, key: CryptoKey): Promise<ArrayBuffer | JsonWebKey>;
893
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/wrapKey) */
894
wrapKey(format: string, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: string | SubtleCryptoEncryptAlgorithm): Promise<ArrayBuffer>;
895
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/unwrapKey) */
896
unwrapKey(format: string, wrappedKey: ArrayBuffer | ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: string | SubtleCryptoEncryptAlgorithm, unwrappedKeyAlgorithm: string | SubtleCryptoImportKeyAlgorithm, extractable: boolean, keyUsages: string[]): Promise<CryptoKey>;
897
timingSafeEqual(a: ArrayBuffer | ArrayBufferView, b: ArrayBuffer | ArrayBufferView): boolean;
898
}
899
/**
900
* The CryptoKey dictionary of the Web Crypto API represents a cryptographic key.
901
* Available only in secure contexts.
902
*
903
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey)
904
*/
905
declare abstract class CryptoKey {
906
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/type) */
907
readonly type: string;
908
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/extractable) */
909
readonly extractable: boolean;
910
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/algorithm) */
911
readonly algorithm: CryptoKeyKeyAlgorithm | CryptoKeyAesKeyAlgorithm | CryptoKeyHmacKeyAlgorithm | CryptoKeyRsaKeyAlgorithm | CryptoKeyEllipticKeyAlgorithm | CryptoKeyArbitraryKeyAlgorithm;
912
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/usages) */
913
readonly usages: string[];
914
}
915
interface CryptoKeyPair {
916
publicKey: CryptoKey;
917
privateKey: CryptoKey;
918
}
919
interface JsonWebKey {
920
kty: string;
921
use?: string;
922
key_ops?: string[];
923
alg?: string;
924
ext?: boolean;
925
crv?: string;
926
x?: string;
927
y?: string;
928
d?: string;
929
n?: string;
930
e?: string;
931
p?: string;
932
q?: string;
933
dp?: string;
934
dq?: string;
935
qi?: string;
936
oth?: RsaOtherPrimesInfo[];
937
k?: string;
938
}
939
interface RsaOtherPrimesInfo {
940
r?: string;
941
d?: string;
942
t?: string;
943
}
944
interface SubtleCryptoDeriveKeyAlgorithm {
945
name: string;
946
salt?: (ArrayBuffer | ArrayBufferView);
947
iterations?: number;
948
hash?: (string | SubtleCryptoHashAlgorithm);
949
$public?: CryptoKey;
950
info?: (ArrayBuffer | ArrayBufferView);
951
}
952
interface SubtleCryptoEncryptAlgorithm {
953
name: string;
954
iv?: (ArrayBuffer | ArrayBufferView);
955
additionalData?: (ArrayBuffer | ArrayBufferView);
956
tagLength?: number;
957
counter?: (ArrayBuffer | ArrayBufferView);
958
length?: number;
959
label?: (ArrayBuffer | ArrayBufferView);
960
}
961
interface SubtleCryptoGenerateKeyAlgorithm {
962
name: string;
963
hash?: (string | SubtleCryptoHashAlgorithm);
964
modulusLength?: number;
965
publicExponent?: (ArrayBuffer | ArrayBufferView);
966
length?: number;
967
namedCurve?: string;
968
}
969
interface SubtleCryptoHashAlgorithm {
970
name: string;
971
}
972
interface SubtleCryptoImportKeyAlgorithm {
973
name: string;
974
hash?: (string | SubtleCryptoHashAlgorithm);
975
length?: number;
976
namedCurve?: string;
977
compressed?: boolean;
978
}
979
interface SubtleCryptoSignAlgorithm {
980
name: string;
981
hash?: (string | SubtleCryptoHashAlgorithm);
982
dataLength?: number;
983
saltLength?: number;
984
}
985
interface CryptoKeyKeyAlgorithm {
986
name: string;
987
}
988
interface CryptoKeyAesKeyAlgorithm {
989
name: string;
990
length: number;
991
}
992
interface CryptoKeyHmacKeyAlgorithm {
993
name: string;
994
hash: CryptoKeyKeyAlgorithm;
995
length: number;
996
}
997
interface CryptoKeyRsaKeyAlgorithm {
998
name: string;
999
modulusLength: number;
1000
publicExponent: ArrayBuffer | ArrayBufferView;
1001
hash?: CryptoKeyKeyAlgorithm;
1002
}
1003
interface CryptoKeyEllipticKeyAlgorithm {
1004
name: string;
1005
namedCurve: string;
1006
}
1007
interface CryptoKeyArbitraryKeyAlgorithm {
1008
name: string;
1009
hash?: CryptoKeyKeyAlgorithm;
1010
namedCurve?: string;
1011
length?: number;
1012
}
1013
declare class DigestStream extends WritableStream<ArrayBuffer | ArrayBufferView> {
1014
constructor(algorithm: string | SubtleCryptoHashAlgorithm);
1015
readonly digest: Promise<ArrayBuffer>;
1016
get bytesWritten(): number | bigint;
1017
}
1018
/**
1019
* A decoder for a specific method, that is a specific character encoding, like utf-8, iso-8859-2, koi8, cp1261, gbk, etc. A decoder takes a stream of bytes as input and emits a stream of code points. For a more scalable, non-native library, see StringView – a C-like representation of strings based on typed arrays.
1020
*
1021
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextDecoder)
1022
*/
1023
declare class TextDecoder {
1024
constructor(label?: string, options?: TextDecoderConstructorOptions);
1025
/**
1026
* Returns the result of running encoding's decoder. The method can be invoked zero or more times with options's stream set to true, and then once without options's stream (or set to false), to process a fragmented input. If the invocation without options's stream (or set to false) has no input, it's clearest to omit both arguments.
1027
*
1028
* ```
1029
* var string = "", decoder = new TextDecoder(encoding), buffer;
1030
* while(buffer = next_chunk()) {
1031
* string += decoder.decode(buffer, {stream:true});
1032
* }
1033
* string += decoder.decode(); // end-of-queue
1034
* ```
1035
*
1036
* If the error mode is "fatal" and encoding's decoder returns error, throws a TypeError.
1037
*
1038
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextDecoder/decode)
1039
*/
1040
decode(input?: (ArrayBuffer | ArrayBufferView), options?: TextDecoderDecodeOptions): string;
1041
get encoding(): string;
1042
get fatal(): boolean;
1043
get ignoreBOM(): boolean;
1044
}
1045
/**
1046
* TextEncoder takes a stream of code points as input and emits a stream of bytes. For a more scalable, non-native library, see StringView – a C-like representation of strings based on typed arrays.
1047
*
1048
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextEncoder)
1049
*/
1050
declare class TextEncoder {
1051
constructor();
1052
/**
1053
* Returns the result of running UTF-8's encoder.
1054
*
1055
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextEncoder/encode)
1056
*/
1057
encode(input?: string): Uint8Array;
1058
/**
1059
* Runs the UTF-8 encoder on source, stores the result of that operation into destination, and returns the progress made as an object wherein read is the number of converted code units of source and written is the number of bytes modified in destination.
1060
*
1061
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextEncoder/encodeInto)
1062
*/
1063
encodeInto(input: string, buffer: ArrayBuffer | ArrayBufferView): TextEncoderEncodeIntoResult;
1064
get encoding(): string;
1065
}
1066
interface TextDecoderConstructorOptions {
1067
fatal: boolean;
1068
ignoreBOM: boolean;
1069
}
1070
interface TextDecoderDecodeOptions {
1071
stream: boolean;
1072
}
1073
interface TextEncoderEncodeIntoResult {
1074
read: number;
1075
written: number;
1076
}
1077
/**
1078
* Events providing information related to errors in scripts or in files.
1079
*
1080
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent)
1081
*/
1082
declare class ErrorEvent extends Event {
1083
constructor(type: string, init?: ErrorEventErrorEventInit);
1084
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/filename) */
1085
get filename(): string;
1086
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/message) */
1087
get message(): string;
1088
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/lineno) */
1089
get lineno(): number;
1090
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/colno) */
1091
get colno(): number;
1092
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/error) */
1093
get error(): any;
1094
}
1095
interface ErrorEventErrorEventInit {
1096
message?: string;
1097
filename?: string;
1098
lineno?: number;
1099
colno?: number;
1100
error?: any;
1101
}
1102
/**
1103
* A message received by a target object.
1104
*
1105
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent)
1106
*/
1107
declare class MessageEvent extends Event {
1108
constructor(type: string, initializer: MessageEventInit);
1109
/**
1110
* Returns the data of the message.
1111
*
1112
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/data)
1113
*/
1114
readonly data: any;
1115
/**
1116
* Returns the origin of the message, for server-sent events and cross-document messaging.
1117
*
1118
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/origin)
1119
*/
1120
readonly origin: string | null;
1121
/**
1122
* Returns the last event ID string, for server-sent events.
1123
*
1124
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/lastEventId)
1125
*/
1126
readonly lastEventId: string;
1127
/**
1128
* Returns the WindowProxy of the source window, for cross-document messaging, and the MessagePort being attached, in the connect event fired at SharedWorkerGlobalScope objects.
1129
*
1130
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/source)
1131
*/
1132
readonly source: MessagePort | null;
1133
/**
1134
* Returns the MessagePort array sent with the message, for cross-document messaging and channel messaging.
1135
*
1136
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/ports)
1137
*/
1138
readonly ports: MessagePort[];
1139
}
1140
interface MessageEventInit {
1141
data: ArrayBuffer | string;
1142
}
1143
/**
1144
* Provides a way to easily construct a set of key/value pairs representing form fields and their values, which can then be easily sent using the XMLHttpRequest.send() method. It uses the same format a form would use if the encoding type were set to "multipart/form-data".
1145
*
1146
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData)
1147
*/
1148
declare class FormData {
1149
constructor();
1150
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/append) */
1151
append(name: string, value: string): void;
1152
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/append) */
1153
append(name: string, value: Blob, filename?: string): void;
1154
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/delete) */
1155
delete(name: string): void;
1156
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/get) */
1157
get(name: string): (File | string) | null;
1158
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/getAll) */
1159
getAll(name: string): (File | string)[];
1160
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/has) */
1161
has(name: string): boolean;
1162
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/set) */
1163
set(name: string, value: string): void;
1164
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/set) */
1165
set(name: string, value: Blob, filename?: string): void;
1166
/* Returns an array of key, value pairs for every entry in the list. */
1167
entries(): IterableIterator<[
1168
key: string,
1169
value: File | string
1170
]>;
1171
/* Returns a list of keys in the list. */
1172
keys(): IterableIterator<string>;
1173
/* Returns a list of values in the list. */
1174
values(): IterableIterator<(File | string)>;
1175
forEach<This = unknown>(callback: (this: This, value: File | string, key: string, parent: FormData) => void, thisArg?: This): void;
1176
[Symbol.iterator](): IterableIterator<[
1177
key: string,
1178
value: File | string
1179
]>;
1180
}
1181
interface ContentOptions {
1182
html?: boolean;
1183
}
1184
declare class HTMLRewriter {
1185
constructor();
1186
on(selector: string, handlers: HTMLRewriterElementContentHandlers): HTMLRewriter;
1187
onDocument(handlers: HTMLRewriterDocumentContentHandlers): HTMLRewriter;
1188
transform(response: Response): Response;
1189
}
1190
interface HTMLRewriterElementContentHandlers {
1191
element?(element: Element): void | Promise<void>;
1192
comments?(comment: Comment): void | Promise<void>;
1193
text?(element: Text): void | Promise<void>;
1194
}
1195
interface HTMLRewriterDocumentContentHandlers {
1196
doctype?(doctype: Doctype): void | Promise<void>;
1197
comments?(comment: Comment): void | Promise<void>;
1198
text?(text: Text): void | Promise<void>;
1199
end?(end: DocumentEnd): void | Promise<void>;
1200
}
1201
interface Doctype {
1202
readonly name: string | null;
1203
readonly publicId: string | null;
1204
readonly systemId: string | null;
1205
}
1206
interface Element {
1207
tagName: string;
1208
readonly attributes: IterableIterator<string[]>;
1209
readonly removed: boolean;
1210
readonly namespaceURI: string;
1211
getAttribute(name: string): string | null;
1212
hasAttribute(name: string): boolean;
1213
setAttribute(name: string, value: string): Element;
1214
removeAttribute(name: string): Element;
1215
before(content: string | ReadableStream | Response, options?: ContentOptions): Element;
1216
after(content: string | ReadableStream | Response, options?: ContentOptions): Element;
1217
prepend(content: string | ReadableStream | Response, options?: ContentOptions): Element;
1218
append(content: string | ReadableStream | Response, options?: ContentOptions): Element;
1219
replace(content: string | ReadableStream | Response, options?: ContentOptions): Element;
1220
remove(): Element;
1221
removeAndKeepContent(): Element;
1222
setInnerContent(content: string | ReadableStream | Response, options?: ContentOptions): Element;
1223
onEndTag(handler: (tag: EndTag) => void | Promise<void>): void;
1224
}
1225
interface EndTag {
1226
name: string;
1227
before(content: string | ReadableStream | Response, options?: ContentOptions): EndTag;
1228
after(content: string | ReadableStream | Response, options?: ContentOptions): EndTag;
1229
remove(): EndTag;
1230
}
1231
interface Comment {
1232
text: string;
1233
readonly removed: boolean;
1234
before(content: string, options?: ContentOptions): Comment;
1235
after(content: string, options?: ContentOptions): Comment;
1236
replace(content: string, options?: ContentOptions): Comment;
1237
remove(): Comment;
1238
}
1239
interface Text {
1240
readonly text: string;
1241
readonly lastInTextNode: boolean;
1242
readonly removed: boolean;
1243
before(content: string | ReadableStream | Response, options?: ContentOptions): Text;
1244
after(content: string | ReadableStream | Response, options?: ContentOptions): Text;
1245
replace(content: string | ReadableStream | Response, options?: ContentOptions): Text;
1246
remove(): Text;
1247
}
1248
interface DocumentEnd {
1249
append(content: string, options?: ContentOptions): DocumentEnd;
1250
}
1251
/**
1252
* This is the event type for fetch events dispatched on the service worker global scope. It contains information about the fetch, including the request and how the receiver will treat the response. It provides the event.respondWith() method, which allows us to provide a response to this fetch.
1253
*
1254
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FetchEvent)
1255
*/
1256
declare abstract class FetchEvent extends ExtendableEvent {
1257
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FetchEvent/request) */
1258
readonly request: Request;
1259
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FetchEvent/respondWith) */
1260
respondWith(promise: Response | Promise<Response>): void;
1261
passThroughOnException(): void;
1262
}
1263
type HeadersInit = Headers | Iterable<Iterable<string>> | Record<string, string>;
1264
/**
1265
* This Fetch API interface allows you to perform various actions on HTTP request and response headers. These actions include retrieving, setting, adding to, and removing. A Headers object has an associated header list, which is initially empty and consists of zero or more name and value pairs.  You can add to this using methods like append() (see Examples.) In all methods of this interface, header names are matched by case-insensitive byte sequence.
1266
*
1267
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers)
1268
*/
1269
declare class Headers {
1270
constructor(init?: HeadersInit);
1271
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/get) */
1272
get(name: string): string | null;
1273
getAll(name: string): string[];
1274
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/getSetCookie) */
1275
getSetCookie(): string[];
1276
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/has) */
1277
has(name: string): boolean;
1278
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/set) */
1279
set(name: string, value: string): void;
1280
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/append) */
1281
append(name: string, value: string): void;
1282
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/delete) */
1283
delete(name: string): void;
1284
forEach<This = unknown>(callback: (this: This, value: string, key: string, parent: Headers) => void, thisArg?: This): void;
1285
/* Returns an iterator allowing to go through all key/value pairs contained in this object. */
1286
entries(): IterableIterator<[
1287
key: string,
1288
value: string
1289
]>;
1290
/* Returns an iterator allowing to go through all keys of the key/value pairs contained in this object. */
1291
keys(): IterableIterator<string>;
1292
/* Returns an iterator allowing to go through all values of the key/value pairs contained in this object. */
1293
values(): IterableIterator<string>;
1294
[Symbol.iterator](): IterableIterator<[
1295
key: string,
1296
value: string
1297
]>;
1298
}
1299
type BodyInit = ReadableStream<Uint8Array> | string | ArrayBuffer | ArrayBufferView | Blob | URLSearchParams | FormData;
1300
declare abstract class Body {
1301
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/body) */
1302
get body(): ReadableStream | null;
1303
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/bodyUsed) */
1304
get bodyUsed(): boolean;
1305
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/arrayBuffer) */
1306
arrayBuffer(): Promise<ArrayBuffer>;
1307
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/bytes) */
1308
bytes(): Promise<Uint8Array>;
1309
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/text) */
1310
text(): Promise<string>;
1311
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/json) */
1312
json<T>(): Promise<T>;
1313
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/formData) */
1314
formData(): Promise<FormData>;
1315
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/blob) */
1316
blob(): Promise<Blob>;
1317
}
1318
/**
1319
* This Fetch API interface represents the response to a request.
1320
*
1321
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response)
1322
*/
1323
declare var Response: {
1324
prototype: Response;
1325
new (body?: BodyInit | null, init?: ResponseInit): Response;
1326
error(): Response;
1327
redirect(url: string, status?: number): Response;
1328
json(any: any, maybeInit?: (ResponseInit | Response)): Response;
1329
};
1330
/**
1331
* This Fetch API interface represents the response to a request.
1332
*
1333
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response)
1334
*/
1335
interface Response extends Body {
1336
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/clone) */
1337
clone(): Response;
1338
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/status) */
1339
status: number;
1340
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/statusText) */
1341
statusText: string;
1342
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/headers) */
1343
headers: Headers;
1344
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/ok) */
1345
ok: boolean;
1346
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/redirected) */
1347
redirected: boolean;
1348
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/url) */
1349
url: string;
1350
webSocket: WebSocket | null;
1351
cf: any | undefined;
1352
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/type) */
1353
type: "default" | "error";
1354
}
1355
interface ResponseInit {
1356
status?: number;
1357
statusText?: string;
1358
headers?: HeadersInit;
1359
cf?: any;
1360
webSocket?: (WebSocket | null);
1361
encodeBody?: "automatic" | "manual";
1362
}
1363
type RequestInfo<CfHostMetadata = unknown, Cf = CfProperties<CfHostMetadata>> = Request<CfHostMetadata, Cf> | string;
1364
/**
1365
* This Fetch API interface represents a resource request.
1366
*
1367
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request)
1368
*/
1369
declare var Request: {
1370
prototype: Request;
1371
new <CfHostMetadata = unknown, Cf = CfProperties<CfHostMetadata>>(input: RequestInfo<CfProperties> | URL, init?: RequestInit<Cf>): Request<CfHostMetadata, Cf>;
1372
};
1373
/**
1374
* This Fetch API interface represents a resource request.
1375
*
1376
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request)
1377
*/
1378
interface Request<CfHostMetadata = unknown, Cf = CfProperties<CfHostMetadata>> extends Body {
1379
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/clone) */
1380
clone(): Request<CfHostMetadata, Cf>;
1381
/**
1382
* Returns request's HTTP method, which is "GET" by default.
1383
*
1384
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/method)
1385
*/
1386
method: string;
1387
/**
1388
* Returns the URL of request as a string.
1389
*
1390
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/url)
1391
*/
1392
url: string;
1393
/**
1394
* Returns a Headers object consisting of the headers associated with request. Note that headers added in the network layer by the user agent will not be accounted for in this object, e.g., the "Host" header.
1395
*
1396
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/headers)
1397
*/
1398
headers: Headers;
1399
/**
1400
* Returns the redirect mode associated with request, which is a string indicating how redirects for the request will be handled during fetching. A request will follow redirects by default.
1401
*
1402
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/redirect)
1403
*/
1404
redirect: string;
1405
fetcher: Fetcher | null;
1406
/**
1407
* Returns the signal associated with request, which is an AbortSignal object indicating whether or not request has been aborted, and its abort event handler.
1408
*
1409
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/signal)
1410
*/
1411
signal: AbortSignal;
1412
cf: Cf | undefined;
1413
/**
1414
* Returns request's subresource integrity metadata, which is a cryptographic hash of the resource being fetched. Its value consists of multiple hashes separated by whitespace. [SRI]
1415
*
1416
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/integrity)
1417
*/
1418
integrity: string;
1419
/**
1420
* Returns a boolean indicating whether or not request can outlive the global in which it was created.
1421
*
1422
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/keepalive)
1423
*/
1424
keepalive: boolean;
1425
/**
1426
* Returns the cache mode associated with request, which is a string indicating how the request will interact with the browser's cache when fetching.
1427
*
1428
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/cache)
1429
*/
1430
cache?: "no-store" | "no-cache";
1431
}
1432
interface RequestInit<Cf = CfProperties> {
1433
/* A string to set request's method. */
1434
method?: string;
1435
/* A Headers object, an object literal, or an array of two-item arrays to set request's headers. */
1436
headers?: HeadersInit;
1437
/* A BodyInit object or null to set request's body. */
1438
body?: BodyInit | null;
1439
/* A string indicating whether request follows redirects, results in an error upon encountering a redirect, or returns the redirect (in an opaque fashion). Sets request's redirect. */
1440
redirect?: string;
1441
fetcher?: (Fetcher | null);
1442
cf?: Cf;
1443
/* A string indicating how the request will interact with the browser's cache to set request's cache. */
1444
cache?: "no-store" | "no-cache";
1445
/* A cryptographic hash of the resource to be fetched by request. Sets request's integrity. */
1446
integrity?: string;
1447
/* An AbortSignal to set request's signal. */
1448
signal?: (AbortSignal | null);
1449
encodeResponseBody?: "automatic" | "manual";
1450
}
1451
type Service<T extends (new (...args: any[]) => Rpc.WorkerEntrypointBranded) | Rpc.WorkerEntrypointBranded | ExportedHandler<any, any, any> | undefined = undefined> = T extends new (...args: any[]) => Rpc.WorkerEntrypointBranded ? Fetcher<InstanceType<T>> : T extends Rpc.WorkerEntrypointBranded ? Fetcher<T> : T extends Exclude<Rpc.EntrypointBranded, Rpc.WorkerEntrypointBranded> ? never : Fetcher<undefined>;
1452
type Fetcher<T extends Rpc.EntrypointBranded | undefined = undefined, Reserved extends string = never> = (T extends Rpc.EntrypointBranded ? Rpc.Provider<T, Reserved | "fetch" | "connect"> : unknown) & {
1453
fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
1454
connect(address: SocketAddress | string, options?: SocketOptions): Socket;
1455
};
1456
interface KVNamespaceListKey<Metadata, Key extends string = string> {
1457
name: Key;
1458
expiration?: number;
1459
metadata?: Metadata;
1460
}
1461
type KVNamespaceListResult<Metadata, Key extends string = string> = {
1462
list_complete: false;
1463
keys: KVNamespaceListKey<Metadata, Key>[];
1464
cursor: string;
1465
cacheStatus: string | null;
1466
} | {
1467
list_complete: true;
1468
keys: KVNamespaceListKey<Metadata, Key>[];
1469
cacheStatus: string | null;
1470
};
1471
interface KVNamespace<Key extends string = string> {
1472
get(key: Key, options?: Partial<KVNamespaceGetOptions<undefined>>): Promise<string | null>;
1473
get(key: Key, type: "text"): Promise<string | null>;
1474
get<ExpectedValue = unknown>(key: Key, type: "json"): Promise<ExpectedValue | null>;
1475
get(key: Key, type: "arrayBuffer"): Promise<ArrayBuffer | null>;
1476
get(key: Key, type: "stream"): Promise<ReadableStream | null>;
1477
get(key: Key, options?: KVNamespaceGetOptions<"text">): Promise<string | null>;
1478
get<ExpectedValue = unknown>(key: Key, options?: KVNamespaceGetOptions<"json">): Promise<ExpectedValue | null>;
1479
get(key: Key, options?: KVNamespaceGetOptions<"arrayBuffer">): Promise<ArrayBuffer | null>;
1480
get(key: Key, options?: KVNamespaceGetOptions<"stream">): Promise<ReadableStream | null>;
1481
get(key: Array<Key>, type: "text"): Promise<Map<string, string | null>>;
1482
get<ExpectedValue = unknown>(key: Array<Key>, type: "json"): Promise<Map<string, ExpectedValue | null>>;
1483
get(key: Array<Key>, options?: Partial<KVNamespaceGetOptions<undefined>>): Promise<Map<string, string | null>>;
1484
get(key: Array<Key>, options?: KVNamespaceGetOptions<"text">): Promise<Map<string, string | null>>;
1485
get<ExpectedValue = unknown>(key: Array<Key>, options?: KVNamespaceGetOptions<"json">): Promise<Map<string, ExpectedValue | null>>;
1486
list<Metadata = unknown>(options?: KVNamespaceListOptions): Promise<KVNamespaceListResult<Metadata, Key>>;
1487
put(key: Key, value: string | ArrayBuffer | ArrayBufferView | ReadableStream, options?: KVNamespacePutOptions): Promise<void>;
1488
getWithMetadata<Metadata = unknown>(key: Key, options?: Partial<KVNamespaceGetOptions<undefined>>): Promise<KVNamespaceGetWithMetadataResult<string, Metadata>>;
1489
getWithMetadata<Metadata = unknown>(key: Key, type: "text"): Promise<KVNamespaceGetWithMetadataResult<string, Metadata>>;
1490
getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(key: Key, type: "json"): Promise<KVNamespaceGetWithMetadataResult<ExpectedValue, Metadata>>;
1491
getWithMetadata<Metadata = unknown>(key: Key, type: "arrayBuffer"): Promise<KVNamespaceGetWithMetadataResult<ArrayBuffer, Metadata>>;
1492
getWithMetadata<Metadata = unknown>(key: Key, type: "stream"): Promise<KVNamespaceGetWithMetadataResult<ReadableStream, Metadata>>;
1493
getWithMetadata<Metadata = unknown>(key: Key, options: KVNamespaceGetOptions<"text">): Promise<KVNamespaceGetWithMetadataResult<string, Metadata>>;
1494
getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(key: Key, options: KVNamespaceGetOptions<"json">): Promise<KVNamespaceGetWithMetadataResult<ExpectedValue, Metadata>>;
1495
getWithMetadata<Metadata = unknown>(key: Key, options: KVNamespaceGetOptions<"arrayBuffer">): Promise<KVNamespaceGetWithMetadataResult<ArrayBuffer, Metadata>>;
1496
getWithMetadata<Metadata = unknown>(key: Key, options: KVNamespaceGetOptions<"stream">): Promise<KVNamespaceGetWithMetadataResult<ReadableStream, Metadata>>;
1497
getWithMetadata<Metadata = unknown>(key: Array<Key>, type: "text"): Promise<Map<string, KVNamespaceGetWithMetadataResult<string, Metadata>>>;
1498
getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(key: Array<Key>, type: "json"): Promise<Map<string, KVNamespaceGetWithMetadataResult<ExpectedValue, Metadata>>>;
1499
getWithMetadata<Metadata = unknown>(key: Array<Key>, options?: Partial<KVNamespaceGetOptions<undefined>>): Promise<Map<string, KVNamespaceGetWithMetadataResult<string, Metadata>>>;
1500
getWithMetadata<Metadata = unknown>(key: Array<Key>, options?: KVNamespaceGetOptions<"text">): Promise<Map<string, KVNamespaceGetWithMetadataResult<string, Metadata>>>;
1501
getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(key: Array<Key>, options?: KVNamespaceGetOptions<"json">): Promise<Map<string, KVNamespaceGetWithMetadataResult<ExpectedValue, Metadata>>>;
1502
delete(key: Key): Promise<void>;
1503
}
1504
interface KVNamespaceListOptions {
1505
limit?: number;
1506
prefix?: (string | null);
1507
cursor?: (string | null);
1508
}
1509
interface KVNamespaceGetOptions<Type> {
1510
type: Type;
1511
cacheTtl?: number;
1512
}
1513
interface KVNamespacePutOptions {
1514
expiration?: number;
1515
expirationTtl?: number;
1516
metadata?: (any | null);
1517
}
1518
interface KVNamespaceGetWithMetadataResult<Value, Metadata> {
1519
value: Value | null;
1520
metadata: Metadata | null;
1521
cacheStatus: string | null;
1522
}
1523
type QueueContentType = "text" | "bytes" | "json" | "v8";
1524
interface Queue<Body = unknown> {
1525
send(message: Body, options?: QueueSendOptions): Promise<void>;
1526
sendBatch(messages: Iterable<MessageSendRequest<Body>>, options?: QueueSendBatchOptions): Promise<void>;
1527
}
1528
interface QueueSendOptions {
1529
contentType?: QueueContentType;
1530
delaySeconds?: number;
1531
}
1532
interface QueueSendBatchOptions {
1533
delaySeconds?: number;
1534
}
1535
interface MessageSendRequest<Body = unknown> {
1536
body: Body;
1537
contentType?: QueueContentType;
1538
delaySeconds?: number;
1539
}
1540
interface QueueRetryOptions {
1541
delaySeconds?: number;
1542
}
1543
interface Message<Body = unknown> {
1544
readonly id: string;
1545
readonly timestamp: Date;
1546
readonly body: Body;
1547
readonly attempts: number;
1548
retry(options?: QueueRetryOptions): void;
1549
ack(): void;
1550
}
1551
interface QueueEvent<Body = unknown> extends ExtendableEvent {
1552
readonly messages: readonly Message<Body>[];
1553
readonly queue: string;
1554
retryAll(options?: QueueRetryOptions): void;
1555
ackAll(): void;
1556
}
1557
interface MessageBatch<Body = unknown> {
1558
readonly messages: readonly Message<Body>[];
1559
readonly queue: string;
1560
retryAll(options?: QueueRetryOptions): void;
1561
ackAll(): void;
1562
}
1563
interface R2Error extends Error {
1564
readonly name: string;
1565
readonly code: number;
1566
readonly message: string;
1567
readonly action: string;
1568
readonly stack: any;
1569
}
1570
interface R2ListOptions {
1571
limit?: number;
1572
prefix?: string;
1573
cursor?: string;
1574
delimiter?: string;
1575
startAfter?: string;
1576
include?: ("httpMetadata" | "customMetadata")[];
1577
}
1578
declare abstract class R2Bucket {
1579
head(key: string): Promise<R2Object | null>;
1580
get(key: string, options: R2GetOptions & {
1581
onlyIf: R2Conditional | Headers;
1582
}): Promise<R2ObjectBody | R2Object | null>;
1583
get(key: string, options?: R2GetOptions): Promise<R2ObjectBody | null>;
1584
put(key: string, value: ReadableStream | ArrayBuffer | ArrayBufferView | string | null | Blob, options?: R2PutOptions & {
1585
onlyIf: R2Conditional | Headers;
1586
}): Promise<R2Object | null>;
1587
put(key: string, value: ReadableStream | ArrayBuffer | ArrayBufferView | string | null | Blob, options?: R2PutOptions): Promise<R2Object>;
1588
createMultipartUpload(key: string, options?: R2MultipartOptions): Promise<R2MultipartUpload>;
1589
resumeMultipartUpload(key: string, uploadId: string): R2MultipartUpload;
1590
delete(keys: string | string[]): Promise<void>;
1591
list(options?: R2ListOptions): Promise<R2Objects>;
1592
}
1593
interface R2MultipartUpload {
1594
readonly key: string;
1595
readonly uploadId: string;
1596
uploadPart(partNumber: number, value: ReadableStream | (ArrayBuffer | ArrayBufferView) | string | Blob, options?: R2UploadPartOptions): Promise<R2UploadedPart>;
1597
abort(): Promise<void>;
1598
complete(uploadedParts: R2UploadedPart[]): Promise<R2Object>;
1599
}
1600
interface R2UploadedPart {
1601
partNumber: number;
1602
etag: string;
1603
}
1604
declare abstract class R2Object {
1605
readonly key: string;
1606
readonly version: string;
1607
readonly size: number;
1608
readonly etag: string;
1609
readonly httpEtag: string;
1610
readonly checksums: R2Checksums;
1611
readonly uploaded: Date;
1612
readonly httpMetadata?: R2HTTPMetadata;
1613
readonly customMetadata?: Record<string, string>;
1614
readonly range?: R2Range;
1615
readonly storageClass: string;
1616
readonly ssecKeyMd5?: string;
1617
writeHttpMetadata(headers: Headers): void;
1618
}
1619
interface R2ObjectBody extends R2Object {
1620
get body(): ReadableStream;
1621
get bodyUsed(): boolean;
1622
arrayBuffer(): Promise<ArrayBuffer>;
1623
bytes(): Promise<Uint8Array>;
1624
text(): Promise<string>;
1625
json<T>(): Promise<T>;
1626
blob(): Promise<Blob>;
1627
}
1628
type R2Range = {
1629
offset: number;
1630
length?: number;
1631
} | {
1632
offset?: number;
1633
length: number;
1634
} | {
1635
suffix: number;
1636
};
1637
interface R2Conditional {
1638
etagMatches?: string;
1639
etagDoesNotMatch?: string;
1640
uploadedBefore?: Date;
1641
uploadedAfter?: Date;
1642
secondsGranularity?: boolean;
1643
}
1644
interface R2GetOptions {
1645
onlyIf?: (R2Conditional | Headers);
1646
range?: (R2Range | Headers);
1647
ssecKey?: (ArrayBuffer | string);
1648
}
1649
interface R2PutOptions {
1650
onlyIf?: (R2Conditional | Headers);
1651
httpMetadata?: (R2HTTPMetadata | Headers);
1652
customMetadata?: Record<string, string>;
1653
md5?: ((ArrayBuffer | ArrayBufferView) | string);
1654
sha1?: ((ArrayBuffer | ArrayBufferView) | string);
1655
sha256?: ((ArrayBuffer | ArrayBufferView) | string);
1656
sha384?: ((ArrayBuffer | ArrayBufferView) | string);
1657
sha512?: ((ArrayBuffer | ArrayBufferView) | string);
1658
storageClass?: string;
1659
ssecKey?: (ArrayBuffer | string);
1660
}
1661
interface R2MultipartOptions {
1662
httpMetadata?: (R2HTTPMetadata | Headers);
1663
customMetadata?: Record<string, string>;
1664
storageClass?: string;
1665
ssecKey?: (ArrayBuffer | string);
1666
}
1667
interface R2Checksums {
1668
readonly md5?: ArrayBuffer;
1669
readonly sha1?: ArrayBuffer;
1670
readonly sha256?: ArrayBuffer;
1671
readonly sha384?: ArrayBuffer;
1672
readonly sha512?: ArrayBuffer;
1673
toJSON(): R2StringChecksums;
1674
}
1675
interface R2StringChecksums {
1676
md5?: string;
1677
sha1?: string;
1678
sha256?: string;
1679
sha384?: string;
1680
sha512?: string;
1681
}
1682
interface R2HTTPMetadata {
1683
contentType?: string;
1684
contentLanguage?: string;
1685
contentDisposition?: string;
1686
contentEncoding?: string;
1687
cacheControl?: string;
1688
cacheExpiry?: Date;
1689
}
1690
type R2Objects = {
1691
objects: R2Object[];
1692
delimitedPrefixes: string[];
1693
} & ({
1694
truncated: true;
1695
cursor: string;
1696
} | {
1697
truncated: false;
1698
});
1699
interface R2UploadPartOptions {
1700
ssecKey?: (ArrayBuffer | string);
1701
}
1702
declare abstract class ScheduledEvent extends ExtendableEvent {
1703
readonly scheduledTime: number;
1704
readonly cron: string;
1705
noRetry(): void;
1706
}
1707
interface ScheduledController {
1708
readonly scheduledTime: number;
1709
readonly cron: string;
1710
noRetry(): void;
1711
}
1712
interface QueuingStrategy<T = any> {
1713
highWaterMark?: (number | bigint);
1714
size?: (chunk: T) => number | bigint;
1715
}
1716
interface UnderlyingSink<W = any> {
1717
type?: string;
1718
start?: (controller: WritableStreamDefaultController) => void | Promise<void>;
1719
write?: (chunk: W, controller: WritableStreamDefaultController) => void | Promise<void>;
1720
abort?: (reason: any) => void | Promise<void>;
1721
close?: () => void | Promise<void>;
1722
}
1723
interface UnderlyingByteSource {
1724
type: "bytes";
1725
autoAllocateChunkSize?: number;
1726
start?: (controller: ReadableByteStreamController) => void | Promise<void>;
1727
pull?: (controller: ReadableByteStreamController) => void | Promise<void>;
1728
cancel?: (reason: any) => void | Promise<void>;
1729
}
1730
interface UnderlyingSource<R = any> {
1731
type?: "" | undefined;
1732
start?: (controller: ReadableStreamDefaultController<R>) => void | Promise<void>;
1733
pull?: (controller: ReadableStreamDefaultController<R>) => void | Promise<void>;
1734
cancel?: (reason: any) => void | Promise<void>;
1735
expectedLength?: (number | bigint);
1736
}
1737
interface Transformer<I = any, O = any> {
1738
readableType?: string;
1739
writableType?: string;
1740
start?: (controller: TransformStreamDefaultController<O>) => void | Promise<void>;
1741
transform?: (chunk: I, controller: TransformStreamDefaultController<O>) => void | Promise<void>;
1742
flush?: (controller: TransformStreamDefaultController<O>) => void | Promise<void>;
1743
cancel?: (reason: any) => void | Promise<void>;
1744
expectedLength?: number;
1745
}
1746
interface StreamPipeOptions {
1747
/**
1748
* Pipes this readable stream to a given writable stream destination. The way in which the piping process behaves under various error conditions can be customized with a number of passed options. It returns a promise that fulfills when the piping process completes successfully, or rejects if any errors were encountered.
1749
*
1750
* Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader.
1751
*
1752
* Errors and closures of the source and destination streams propagate as follows:
1753
*
1754
* An error in this source readable stream will abort destination, unless preventAbort is truthy. The returned promise will be rejected with the source's error, or with any error that occurs during aborting the destination.
1755
*
1756
* An error in destination will cancel this source readable stream, unless preventCancel is truthy. The returned promise will be rejected with the destination's error, or with any error that occurs during canceling the source.
1757
*
1758
* When this source readable stream closes, destination will be closed, unless preventClose is truthy. The returned promise will be fulfilled once this process completes, unless an error is encountered while closing the destination, in which case it will be rejected with that error.
1759
*
1760
* If destination starts out closed or closing, this source readable stream will be canceled, unless preventCancel is true. The returned promise will be rejected with an error indicating piping to a closed stream failed, or with any error that occurs during canceling the source.
1761
*
1762
* The signal option can be set to an AbortSignal to allow aborting an ongoing pipe operation via the corresponding AbortController. In this case, this source readable stream will be canceled, and destination aborted, unless the respective options preventCancel or preventAbort are set.
1763
*/
1764
preventClose?: boolean;
1765
preventAbort?: boolean;
1766
preventCancel?: boolean;
1767
signal?: AbortSignal;
1768
}
1769
type ReadableStreamReadResult<R = any> = {
1770
done: false;
1771
value: R;
1772
} | {
1773
done: true;
1774
value?: undefined;
1775
};
1776
/**
1777
* This Streams API interface represents a readable stream of byte data. The Fetch API offers a concrete instance of a ReadableStream through the body property of a Response object.
1778
*
1779
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream)
1780
*/
1781
interface ReadableStream<R = any> {
1782
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/locked) */
1783
get locked(): boolean;
1784
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/cancel) */
1785
cancel(reason?: any): Promise<void>;
1786
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/getReader) */
1787
getReader(): ReadableStreamDefaultReader<R>;
1788
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/getReader) */
1789
getReader(options: ReadableStreamGetReaderOptions): ReadableStreamBYOBReader;
1790
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/pipeThrough) */
1791
pipeThrough<T>(transform: ReadableWritablePair<T, R>, options?: StreamPipeOptions): ReadableStream<T>;
1792
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/pipeTo) */
1793
pipeTo(destination: WritableStream<R>, options?: StreamPipeOptions): Promise<void>;
1794
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/tee) */
1795
tee(): [
1796
ReadableStream<R>,
1797
ReadableStream<R>
1798
];
1799
values(options?: ReadableStreamValuesOptions): AsyncIterableIterator<R>;
1800
[Symbol.asyncIterator](options?: ReadableStreamValuesOptions): AsyncIterableIterator<R>;
1801
}
1802
/**
1803
* This Streams API interface represents a readable stream of byte data. The Fetch API offers a concrete instance of a ReadableStream through the body property of a Response object.
1804
*
1805
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream)
1806
*/
1807
declare const ReadableStream: {
1808
prototype: ReadableStream;
1809
new (underlyingSource: UnderlyingByteSource, strategy?: QueuingStrategy<Uint8Array>): ReadableStream<Uint8Array>;
1810
new <R = any>(underlyingSource?: UnderlyingSource<R>, strategy?: QueuingStrategy<R>): ReadableStream<R>;
1811
};
1812
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultReader) */
1813
declare class ReadableStreamDefaultReader<R = any> {
1814
constructor(stream: ReadableStream);
1815
get closed(): Promise<void>;
1816
cancel(reason?: any): Promise<void>;
1817
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultReader/read) */
1818
read(): Promise<ReadableStreamReadResult<R>>;
1819
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultReader/releaseLock) */
1820
releaseLock(): void;
1821
}
1822
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader) */
1823
declare class ReadableStreamBYOBReader {
1824
constructor(stream: ReadableStream);
1825
get closed(): Promise<void>;
1826
cancel(reason?: any): Promise<void>;
1827
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader/read) */
1828
read<T extends ArrayBufferView>(view: T): Promise<ReadableStreamReadResult<T>>;
1829
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader/releaseLock) */
1830
releaseLock(): void;
1831
readAtLeast<T extends ArrayBufferView>(minElements: number, view: T): Promise<ReadableStreamReadResult<T>>;
1832
}
1833
interface ReadableStreamBYOBReaderReadableStreamBYOBReaderReadOptions {
1834
min?: number;
1835
}
1836
interface ReadableStreamGetReaderOptions {
1837
/**
1838
* Creates a ReadableStreamBYOBReader and locks the stream to the new reader.
1839
*
1840
* This call behaves the same way as the no-argument variant, except that it only works on readable byte streams, i.e. streams which were constructed specifically with the ability to handle "bring your own buffer" reading. The returned BYOB reader provides the ability to directly read individual chunks from the stream via its read() method, into developer-supplied buffers, allowing more precise control over allocation.
1841
*/
1842
mode: "byob";
1843
}
1844
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest) */
1845
declare abstract class ReadableStreamBYOBRequest {
1846
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest/view) */
1847
get view(): Uint8Array | null;
1848
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest/respond) */
1849
respond(bytesWritten: number): void;
1850
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest/respondWithNewView) */
1851
respondWithNewView(view: ArrayBuffer | ArrayBufferView): void;
1852
get atLeast(): number | null;
1853
}
1854
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController) */
1855
declare abstract class ReadableStreamDefaultController<R = any> {
1856
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController/desiredSize) */
1857
get desiredSize(): number | null;
1858
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController/close) */
1859
close(): void;
1860
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController/enqueue) */
1861
enqueue(chunk?: R): void;
1862
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController/error) */
1863
error(reason: any): void;
1864
}
1865
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController) */
1866
declare abstract class ReadableByteStreamController {
1867
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/byobRequest) */
1868
get byobRequest(): ReadableStreamBYOBRequest | null;
1869
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/desiredSize) */
1870
get desiredSize(): number | null;
1871
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/close) */
1872
close(): void;
1873
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/enqueue) */
1874
enqueue(chunk: ArrayBuffer | ArrayBufferView): void;
1875
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/error) */
1876
error(reason: any): void;
1877
}
1878
/**
1879
* This Streams API interface represents a controller allowing control of a WritableStream's state. When constructing a WritableStream, the underlying sink is given a corresponding WritableStreamDefaultController instance to manipulate.
1880
*
1881
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultController)
1882
*/
1883
declare abstract class WritableStreamDefaultController {
1884
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultController/signal) */
1885
get signal(): AbortSignal;
1886
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultController/error) */
1887
error(reason?: any): void;
1888
}
1889
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController) */
1890
declare abstract class TransformStreamDefaultController<O = any> {
1891
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController/desiredSize) */
1892
get desiredSize(): number | null;
1893
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController/enqueue) */
1894
enqueue(chunk?: O): void;
1895
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController/error) */
1896
error(reason: any): void;
1897
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController/terminate) */
1898
terminate(): void;
1899
}
1900
interface ReadableWritablePair<R = any, W = any> {
1901
/**
1902
* Provides a convenient, chainable way of piping this readable stream through a transform stream (or any other { writable, readable } pair). It simply pipes the stream into the writable side of the supplied pair, and returns the readable side for further use.
1903
*
1904
* Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader.
1905
*/
1906
writable: WritableStream<W>;
1907
readable: ReadableStream<R>;
1908
}
1909
/**
1910
* This Streams API interface provides a standard abstraction for writing streaming data to a destination, known as a sink. This object comes with built-in backpressure and queuing.
1911
*
1912
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream)
1913
*/
1914
declare class WritableStream<W = any> {
1915
constructor(underlyingSink?: UnderlyingSink, queuingStrategy?: QueuingStrategy);
1916
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream/locked) */
1917
get locked(): boolean;
1918
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream/abort) */
1919
abort(reason?: any): Promise<void>;
1920
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream/close) */
1921
close(): Promise<void>;
1922
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream/getWriter) */
1923
getWriter(): WritableStreamDefaultWriter<W>;
1924
}
1925
/**
1926
* This Streams API interface is the object returned by WritableStream.getWriter() and once created locks the < writer to the WritableStream ensuring that no other streams can write to the underlying sink.
1927
*
1928
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter)
1929
*/
1930
declare class WritableStreamDefaultWriter<W = any> {
1931
constructor(stream: WritableStream);
1932
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/closed) */
1933
get closed(): Promise<void>;
1934
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/ready) */
1935
get ready(): Promise<void>;
1936
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/desiredSize) */
1937
get desiredSize(): number | null;
1938
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/abort) */
1939
abort(reason?: any): Promise<void>;
1940
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/close) */
1941
close(): Promise<void>;
1942
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/write) */
1943
write(chunk?: W): Promise<void>;
1944
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/releaseLock) */
1945
releaseLock(): void;
1946
}
1947
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStream) */
1948
declare class TransformStream<I = any, O = any> {
1949
constructor(transformer?: Transformer<I, O>, writableStrategy?: QueuingStrategy<I>, readableStrategy?: QueuingStrategy<O>);
1950
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStream/readable) */
1951
get readable(): ReadableStream<O>;
1952
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStream/writable) */
1953
get writable(): WritableStream<I>;
1954
}
1955
declare class FixedLengthStream extends IdentityTransformStream {
1956
constructor(expectedLength: number | bigint, queuingStrategy?: IdentityTransformStreamQueuingStrategy);
1957
}
1958
declare class IdentityTransformStream extends TransformStream<ArrayBuffer | ArrayBufferView, Uint8Array> {
1959
constructor(queuingStrategy?: IdentityTransformStreamQueuingStrategy);
1960
}
1961
interface IdentityTransformStreamQueuingStrategy {
1962
highWaterMark?: (number | bigint);
1963
}
1964
interface ReadableStreamValuesOptions {
1965
preventCancel?: boolean;
1966
}
1967
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CompressionStream) */
1968
declare class CompressionStream extends TransformStream<ArrayBuffer | ArrayBufferView, Uint8Array> {
1969
constructor(format: "gzip" | "deflate" | "deflate-raw");
1970
}
1971
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/DecompressionStream) */
1972
declare class DecompressionStream extends TransformStream<ArrayBuffer | ArrayBufferView, Uint8Array> {
1973
constructor(format: "gzip" | "deflate" | "deflate-raw");
1974
}
1975
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextEncoderStream) */
1976
declare class TextEncoderStream extends TransformStream<string, Uint8Array> {
1977
constructor();
1978
get encoding(): string;
1979
}
1980
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextDecoderStream) */
1981
declare class TextDecoderStream extends TransformStream<ArrayBuffer | ArrayBufferView, string> {
1982
constructor(label?: string, options?: TextDecoderStreamTextDecoderStreamInit);
1983
get encoding(): string;
1984
get fatal(): boolean;
1985
get ignoreBOM(): boolean;
1986
}
1987
interface TextDecoderStreamTextDecoderStreamInit {
1988
fatal?: boolean;
1989
ignoreBOM?: boolean;
1990
}
1991
/**
1992
* This Streams API interface provides a built-in byte length queuing strategy that can be used when constructing streams.
1993
*
1994
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ByteLengthQueuingStrategy)
1995
*/
1996
declare class ByteLengthQueuingStrategy implements QueuingStrategy<ArrayBufferView> {
1997
constructor(init: QueuingStrategyInit);
1998
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ByteLengthQueuingStrategy/highWaterMark) */
1999
get highWaterMark(): number;
2000
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ByteLengthQueuingStrategy/size) */
2001
get size(): (chunk?: any) => number;
2002
}
2003
/**
2004
* This Streams API interface provides a built-in byte length queuing strategy that can be used when constructing streams.
2005
*
2006
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CountQueuingStrategy)
2007
*/
2008
declare class CountQueuingStrategy implements QueuingStrategy {
2009
constructor(init: QueuingStrategyInit);
2010
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CountQueuingStrategy/highWaterMark) */
2011
get highWaterMark(): number;
2012
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CountQueuingStrategy/size) */
2013
get size(): (chunk?: any) => number;
2014
}
2015
interface QueuingStrategyInit {
2016
/**
2017
* Creates a new ByteLengthQueuingStrategy with the provided high water mark.
2018
*
2019
* Note that the provided high water mark will not be validated ahead of time. Instead, if it is negative, NaN, or not a number, the resulting ByteLengthQueuingStrategy will cause the corresponding stream constructor to throw.
2020
*/
2021
highWaterMark: number;
2022
}
2023
interface ScriptVersion {
2024
id?: string;
2025
tag?: string;
2026
message?: string;
2027
}
2028
declare abstract class TailEvent extends ExtendableEvent {
2029
readonly events: TraceItem[];
2030
readonly traces: TraceItem[];
2031
}
2032
interface TraceItem {
2033
readonly event: (TraceItemFetchEventInfo | TraceItemJsRpcEventInfo | TraceItemScheduledEventInfo | TraceItemAlarmEventInfo | TraceItemQueueEventInfo | TraceItemEmailEventInfo | TraceItemTailEventInfo | TraceItemCustomEventInfo | TraceItemHibernatableWebSocketEventInfo) | null;
2034
readonly eventTimestamp: number | null;
2035
readonly logs: TraceLog[];
2036
readonly exceptions: TraceException[];
2037
readonly diagnosticsChannelEvents: TraceDiagnosticChannelEvent[];
2038
readonly scriptName: string | null;
2039
readonly entrypoint?: string;
2040
readonly scriptVersion?: ScriptVersion;
2041
readonly dispatchNamespace?: string;
2042
readonly scriptTags?: string[];
2043
readonly durableObjectId?: string;
2044
readonly outcome: string;
2045
readonly executionModel: string;
2046
readonly truncated: boolean;
2047
readonly cpuTime: number;
2048
readonly wallTime: number;
2049
}
2050
interface TraceItemAlarmEventInfo {
2051
readonly scheduledTime: Date;
2052
}
2053
interface TraceItemCustomEventInfo {
2054
}
2055
interface TraceItemScheduledEventInfo {
2056
readonly scheduledTime: number;
2057
readonly cron: string;
2058
}
2059
interface TraceItemQueueEventInfo {
2060
readonly queue: string;
2061
readonly batchSize: number;
2062
}
2063
interface TraceItemEmailEventInfo {
2064
readonly mailFrom: string;
2065
readonly rcptTo: string;
2066
readonly rawSize: number;
2067
}
2068
interface TraceItemTailEventInfo {
2069
readonly consumedEvents: TraceItemTailEventInfoTailItem[];
2070
}
2071
interface TraceItemTailEventInfoTailItem {
2072
readonly scriptName: string | null;
2073
}
2074
interface TraceItemFetchEventInfo {
2075
readonly response?: TraceItemFetchEventInfoResponse;
2076
readonly request: TraceItemFetchEventInfoRequest;
2077
}
2078
interface TraceItemFetchEventInfoRequest {
2079
readonly cf?: any;
2080
readonly headers: Record<string, string>;
2081
readonly method: string;
2082
readonly url: string;
2083
getUnredacted(): TraceItemFetchEventInfoRequest;
2084
}
2085
interface TraceItemFetchEventInfoResponse {
2086
readonly status: number;
2087
}
2088
interface TraceItemJsRpcEventInfo {
2089
readonly rpcMethod: string;
2090
}
2091
interface TraceItemHibernatableWebSocketEventInfo {
2092
readonly getWebSocketEvent: TraceItemHibernatableWebSocketEventInfoMessage | TraceItemHibernatableWebSocketEventInfoClose | TraceItemHibernatableWebSocketEventInfoError;
2093
}
2094
interface TraceItemHibernatableWebSocketEventInfoMessage {
2095
readonly webSocketEventType: string;
2096
}
2097
interface TraceItemHibernatableWebSocketEventInfoClose {
2098
readonly webSocketEventType: string;
2099
readonly code: number;
2100
readonly wasClean: boolean;
2101
}
2102
interface TraceItemHibernatableWebSocketEventInfoError {
2103
readonly webSocketEventType: string;
2104
}
2105
interface TraceLog {
2106
readonly timestamp: number;
2107
readonly level: string;
2108
readonly message: any;
2109
}
2110
interface TraceException {
2111
readonly timestamp: number;
2112
readonly message: string;
2113
readonly name: string;
2114
readonly stack?: string;
2115
}
2116
interface TraceDiagnosticChannelEvent {
2117
readonly timestamp: number;
2118
readonly channel: string;
2119
readonly message: any;
2120
}
2121
interface TraceMetrics {
2122
readonly cpuTime: number;
2123
readonly wallTime: number;
2124
}
2125
interface UnsafeTraceMetrics {
2126
fromTrace(item: TraceItem): TraceMetrics;
2127
}
2128
/**
2129
* The URL interface represents an object providing static methods used for creating object URLs.
2130
*
2131
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL)
2132
*/
2133
declare class URL {
2134
constructor(url: string | URL, base?: string | URL);
2135
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/origin) */
2136
get origin(): string;
2137
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/href) */
2138
get href(): string;
2139
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/href) */
2140
set href(value: string);
2141
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/protocol) */
2142
get protocol(): string;
2143
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/protocol) */
2144
set protocol(value: string);
2145
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/username) */
2146
get username(): string;
2147
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/username) */
2148
set username(value: string);
2149
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/password) */
2150
get password(): string;
2151
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/password) */
2152
set password(value: string);
2153
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/host) */
2154
get host(): string;
2155
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/host) */
2156
set host(value: string);
2157
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hostname) */
2158
get hostname(): string;
2159
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hostname) */
2160
set hostname(value: string);
2161
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/port) */
2162
get port(): string;
2163
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/port) */
2164
set port(value: string);
2165
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/pathname) */
2166
get pathname(): string;
2167
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/pathname) */
2168
set pathname(value: string);
2169
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/search) */
2170
get search(): string;
2171
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/search) */
2172
set search(value: string);
2173
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hash) */
2174
get hash(): string;
2175
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hash) */
2176
set hash(value: string);
2177
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/searchParams) */
2178
get searchParams(): URLSearchParams;
2179
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/toJSON) */
2180
toJSON(): string;
2181
/*function toString() { [native code] }*/
2182
toString(): string;
2183
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/canParse_static) */
2184
static canParse(url: string, base?: string): boolean;
2185
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/parse_static) */
2186
static parse(url: string, base?: string): URL | null;
2187
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/createObjectURL_static) */
2188
static createObjectURL(object: File | Blob): string;
2189
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/revokeObjectURL_static) */
2190
static revokeObjectURL(object_url: string): void;
2191
}
2192
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams) */
2193
declare class URLSearchParams {
2194
constructor(init?: (Iterable<Iterable<string>> | Record<string, string> | string));
2195
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/size) */
2196
get size(): number;
2197
/**
2198
* Appends a specified key/value pair as a new search parameter.
2199
*
2200
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/append)
2201
*/
2202
append(name: string, value: string): void;
2203
/**
2204
* Deletes the given search parameter, and its associated value, from the list of all search parameters.
2205
*
2206
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/delete)
2207
*/
2208
delete(name: string, value?: string): void;
2209
/**
2210
* Returns the first value associated to the given search parameter.
2211
*
2212
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/get)
2213
*/
2214
get(name: string): string | null;
2215
/**
2216
* Returns all the values association with a given search parameter.
2217
*
2218
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/getAll)
2219
*/
2220
getAll(name: string): string[];
2221
/**
2222
* Returns a Boolean indicating if such a search parameter exists.
2223
*
2224
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/has)
2225
*/
2226
has(name: string, value?: string): boolean;
2227
/**
2228
* Sets the value associated to a given search parameter to the given value. If there were several values, delete the others.
2229
*
2230
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/set)
2231
*/
2232
set(name: string, value: string): void;
2233
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/sort) */
2234
sort(): void;
2235
/* Returns an array of key, value pairs for every entry in the search params. */
2236
entries(): IterableIterator<[
2237
key: string,
2238
value: string
2239
]>;
2240
/* Returns a list of keys in the search params. */
2241
keys(): IterableIterator<string>;
2242
/* Returns a list of values in the search params. */
2243
values(): IterableIterator<string>;
2244
forEach<This = unknown>(callback: (this: This, value: string, key: string, parent: URLSearchParams) => void, thisArg?: This): void;
2245
/*function toString() { [native code] } Returns a string containing a query string suitable for use in a URL. Does not include the question mark. */
2246
toString(): string;
2247
[Symbol.iterator](): IterableIterator<[
2248
key: string,
2249
value: string
2250
]>;
2251
}
2252
declare class URLPattern {
2253
constructor(input?: (string | URLPatternInit), baseURL?: (string | URLPatternOptions), patternOptions?: URLPatternOptions);
2254
get protocol(): string;
2255
get username(): string;
2256
get password(): string;
2257
get hostname(): string;
2258
get port(): string;
2259
get pathname(): string;
2260
get search(): string;
2261
get hash(): string;
2262
get hasRegExpGroups(): boolean;
2263
test(input?: (string | URLPatternInit), baseURL?: string): boolean;
2264
exec(input?: (string | URLPatternInit), baseURL?: string): URLPatternResult | null;
2265
}
2266
interface URLPatternInit {
2267
protocol?: string;
2268
username?: string;
2269
password?: string;
2270
hostname?: string;
2271
port?: string;
2272
pathname?: string;
2273
search?: string;
2274
hash?: string;
2275
baseURL?: string;
2276
}
2277
interface URLPatternComponentResult {
2278
input: string;
2279
groups: Record<string, string>;
2280
}
2281
interface URLPatternResult {
2282
inputs: (string | URLPatternInit)[];
2283
protocol: URLPatternComponentResult;
2284
username: URLPatternComponentResult;
2285
password: URLPatternComponentResult;
2286
hostname: URLPatternComponentResult;
2287
port: URLPatternComponentResult;
2288
pathname: URLPatternComponentResult;
2289
search: URLPatternComponentResult;
2290
hash: URLPatternComponentResult;
2291
}
2292
interface URLPatternOptions {
2293
ignoreCase?: boolean;
2294
}
2295
/**
2296
* A CloseEvent is sent to clients using WebSockets when the connection is closed. This is delivered to the listener indicated by the WebSocket object's onclose attribute.
2297
*
2298
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent)
2299
*/
2300
declare class CloseEvent extends Event {
2301
constructor(type: string, initializer?: CloseEventInit);
2302
/**
2303
* Returns the WebSocket connection close code provided by the server.
2304
*
2305
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent/code)
2306
*/
2307
readonly code: number;
2308
/**
2309
* Returns the WebSocket connection close reason provided by the server.
2310
*
2311
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent/reason)
2312
*/
2313
readonly reason: string;
2314
/**
2315
* Returns true if the connection closed cleanly; false otherwise.
2316
*
2317
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent/wasClean)
2318
*/
2319
readonly wasClean: boolean;
2320
}
2321
interface CloseEventInit {
2322
code?: number;
2323
reason?: string;
2324
wasClean?: boolean;
2325
}
2326
type WebSocketEventMap = {
2327
close: CloseEvent;
2328
message: MessageEvent;
2329
open: Event;
2330
error: ErrorEvent;
2331
};
2332
/**
2333
* Provides the API for creating and managing a WebSocket connection to a server, as well as for sending and receiving data on the connection.
2334
*
2335
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket)
2336
*/
2337
declare var WebSocket: {
2338
prototype: WebSocket;
2339
new (url: string, protocols?: (string[] | string)): WebSocket;
2340
readonly READY_STATE_CONNECTING: number;
2341
readonly CONNECTING: number;
2342
readonly READY_STATE_OPEN: number;
2343
readonly OPEN: number;
2344
readonly READY_STATE_CLOSING: number;
2345
readonly CLOSING: number;
2346
readonly READY_STATE_CLOSED: number;
2347
readonly CLOSED: number;
2348
};
2349
/**
2350
* Provides the API for creating and managing a WebSocket connection to a server, as well as for sending and receiving data on the connection.
2351
*
2352
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket)
2353
*/
2354
interface WebSocket extends EventTarget<WebSocketEventMap> {
2355
accept(): void;
2356
/**
2357
* Transmits data using the WebSocket connection. data can be a string, a Blob, an ArrayBuffer, or an ArrayBufferView.
2358
*
2359
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/send)
2360
*/
2361
send(message: (ArrayBuffer | ArrayBufferView) | string): void;
2362
/**
2363
* Closes the WebSocket connection, optionally using code as the the WebSocket connection close code and reason as the the WebSocket connection close reason.
2364
*
2365
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/close)
2366
*/
2367
close(code?: number, reason?: string): void;
2368
serializeAttachment(attachment: any): void;
2369
deserializeAttachment(): any | null;
2370
/**
2371
* Returns the state of the WebSocket object's connection. It can have the values described below.
2372
*
2373
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/readyState)
2374
*/
2375
readyState: number;
2376
/**
2377
* Returns the URL that was used to establish the WebSocket connection.
2378
*
2379
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/url)
2380
*/
2381
url: string | null;
2382
/**
2383
* Returns the subprotocol selected by the server, if any. It can be used in conjunction with the array form of the constructor's second argument to perform subprotocol negotiation.
2384
*
2385
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/protocol)
2386
*/
2387
protocol: string | null;
2388
/**
2389
* Returns the extensions selected by the server, if any.
2390
*
2391
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/extensions)
2392
*/
2393
extensions: string | null;
2394
}
2395
declare const WebSocketPair: {
2396
new (): {
2397
0: WebSocket;
2398
1: WebSocket;
2399
};
2400
};
2401
interface SqlStorage {
2402
exec<T extends Record<string, SqlStorageValue>>(query: string, ...bindings: any[]): SqlStorageCursor<T>;
2403
get databaseSize(): number;
2404
Cursor: typeof SqlStorageCursor;
2405
Statement: typeof SqlStorageStatement;
2406
}
2407
declare abstract class SqlStorageStatement {
2408
}
2409
type SqlStorageValue = ArrayBuffer | string | number | null;
2410
declare abstract class SqlStorageCursor<T extends Record<string, SqlStorageValue>> {
2411
next(): {
2412
done?: false;
2413
value: T;
2414
} | {
2415
done: true;
2416
value?: never;
2417
};
2418
toArray(): T[];
2419
one(): T;
2420
raw<U extends SqlStorageValue[]>(): IterableIterator<U>;
2421
columnNames: string[];
2422
get rowsRead(): number;
2423
get rowsWritten(): number;
2424
[Symbol.iterator](): IterableIterator<T>;
2425
}
2426
interface Socket {
2427
get readable(): ReadableStream;
2428
get writable(): WritableStream;
2429
get closed(): Promise<void>;
2430
get opened(): Promise<SocketInfo>;
2431
get upgraded(): boolean;
2432
get secureTransport(): "on" | "off" | "starttls";
2433
close(): Promise<void>;
2434
startTls(options?: TlsOptions): Socket;
2435
}
2436
interface SocketOptions {
2437
secureTransport?: string;
2438
allowHalfOpen: boolean;
2439
highWaterMark?: (number | bigint);
2440
}
2441
interface SocketAddress {
2442
hostname: string;
2443
port: number;
2444
}
2445
interface TlsOptions {
2446
expectedServerHostname?: string;
2447
}
2448
interface SocketInfo {
2449
remoteAddress?: string;
2450
localAddress?: string;
2451
}
2452
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource) */
2453
declare class EventSource extends EventTarget {
2454
constructor(url: string, init?: EventSourceEventSourceInit);
2455
/**
2456
* Aborts any instances of the fetch algorithm started for this EventSource object, and sets the readyState attribute to CLOSED.
2457
*
2458
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/close)
2459
*/
2460
close(): void;
2461
/**
2462
* Returns the URL providing the event stream.
2463
*
2464
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/url)
2465
*/
2466
get url(): string;
2467
/**
2468
* Returns true if the credentials mode for connection requests to the URL providing the event stream is set to "include", and false otherwise.
2469
*
2470
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/withCredentials)
2471
*/
2472
get withCredentials(): boolean;
2473
/**
2474
* Returns the state of this EventSource object's connection. It can have the values described below.
2475
*
2476
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/readyState)
2477
*/
2478
get readyState(): number;
2479
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */
2480
get onopen(): any | null;
2481
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */
2482
set onopen(value: any | null);
2483
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */
2484
get onmessage(): any | null;
2485
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */
2486
set onmessage(value: any | null);
2487
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */
2488
get onerror(): any | null;
2489
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */
2490
set onerror(value: any | null);
2491
static readonly CONNECTING: number;
2492
static readonly OPEN: number;
2493
static readonly CLOSED: number;
2494
static from(stream: ReadableStream): EventSource;
2495
}
2496
interface EventSourceEventSourceInit {
2497
withCredentials?: boolean;
2498
fetcher?: Fetcher;
2499
}
2500
interface Container {
2501
get running(): boolean;
2502
start(options?: ContainerStartupOptions): void;
2503
monitor(): Promise<void>;
2504
destroy(error?: any): Promise<void>;
2505
signal(signo: number): void;
2506
getTcpPort(port: number): Fetcher;
2507
}
2508
interface ContainerStartupOptions {
2509
entrypoint?: string[];
2510
enableInternet: boolean;
2511
env?: Record<string, string>;
2512
}
2513
/**
2514
* This Channel Messaging API interface represents one of the two ports of a MessageChannel, allowing messages to be sent from one port and listening out for them arriving at the other.
2515
*
2516
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort)
2517
*/
2518
declare abstract class MessagePort extends EventTarget {
2519
/**
2520
* Posts a message through the channel. Objects listed in transfer are transferred, not just cloned, meaning that they are no longer usable on the sending side.
2521
*
2522
* Throws a "DataCloneError" DOMException if transfer contains duplicate objects or port, or if message could not be cloned.
2523
*
2524
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/postMessage)
2525
*/
2526
postMessage(data?: any, options?: (any[] | MessagePortPostMessageOptions)): void;
2527
/**
2528
* Disconnects the port, so that it is no longer active.
2529
*
2530
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/close)
2531
*/
2532
close(): void;
2533
/**
2534
* Begins dispatching messages received on the port.
2535
*
2536
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/start)
2537
*/
2538
start(): void;
2539
get onmessage(): any | null;
2540
set onmessage(value: any | null);
2541
}
2542
/**
2543
* This Channel Messaging API interface allows us to create a new message channel and send data through it via its two MessagePort properties.
2544
*
2545
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel)
2546
*/
2547
declare class MessageChannel {
2548
constructor();
2549
/**
2550
* Returns the first MessagePort object.
2551
*
2552
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel/port1)
2553
*/
2554
readonly port1: MessagePort;
2555
/**
2556
* Returns the second MessagePort object.
2557
*
2558
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel/port2)
2559
*/
2560
readonly port2: MessagePort;
2561
}
2562
interface MessagePortPostMessageOptions {
2563
transfer?: any[];
2564
}
2565
type LoopbackForExport<T extends (new (...args: any[]) => Rpc.EntrypointBranded) | ExportedHandler<any, any, any> | undefined = undefined> = T extends new (...args: any[]) => Rpc.WorkerEntrypointBranded ? LoopbackServiceStub<InstanceType<T>> : T extends new (...args: any[]) => Rpc.DurableObjectBranded ? LoopbackDurableObjectClass<InstanceType<T>> : T extends ExportedHandler<any, any, any> ? LoopbackServiceStub<undefined> : undefined;
2566
type LoopbackServiceStub<T extends Rpc.WorkerEntrypointBranded | undefined = undefined> = Fetcher<T> & (T extends CloudflareWorkersModule.WorkerEntrypoint<any, infer Props> ? (opts: {
2567
props?: Props;
2568
}) => Fetcher<T> : (opts: {
2569
props?: any;
2570
}) => Fetcher<T>);
2571
type LoopbackDurableObjectClass<T extends Rpc.DurableObjectBranded | undefined = undefined> = DurableObjectClass<T> & (T extends CloudflareWorkersModule.DurableObject<any, infer Props> ? (opts: {
2572
props?: Props;
2573
}) => DurableObjectClass<T> : (opts: {
2574
props?: any;
2575
}) => DurableObjectClass<T>);
2576
interface SyncKvStorage {
2577
get<T = unknown>(key: string): T | undefined;
2578
list<T = unknown>(options?: SyncKvListOptions): Iterable<[
2579
string,
2580
T
2581
]>;
2582
put<T>(key: string, value: T): void;
2583
delete(key: string): boolean;
2584
}
2585
interface SyncKvListOptions {
2586
start?: string;
2587
startAfter?: string;
2588
end?: string;
2589
prefix?: string;
2590
reverse?: boolean;
2591
limit?: number;
2592
}
2593
interface WorkerStub {
2594
getEntrypoint<T extends Rpc.WorkerEntrypointBranded | undefined>(name?: string, options?: WorkerStubEntrypointOptions): Fetcher<T>;
2595
}
2596
interface WorkerStubEntrypointOptions {
2597
props?: any;
2598
}
2599
interface WorkerLoader {
2600
get(name: string, getCode: () => WorkerLoaderWorkerCode | Promise<WorkerLoaderWorkerCode>): WorkerStub;
2601
}
2602
interface WorkerLoaderModule {
2603
js?: string;
2604
cjs?: string;
2605
text?: string;
2606
data?: ArrayBuffer;
2607
json?: any;
2608
py?: string;
2609
}
2610
interface WorkerLoaderWorkerCode {
2611
compatibilityDate: string;
2612
compatibilityFlags?: string[];
2613
allowExperimental?: boolean;
2614
mainModule: string;
2615
modules: Record<string, WorkerLoaderModule | string>;
2616
env?: any;
2617
globalOutbound?: (Fetcher | null);
2618
tails?: Fetcher[];
2619
streamingTails?: Fetcher[];
2620
}
2621
/**
2622
* The Workers runtime supports a subset of the Performance API, used to measure timing and performance,
2623
* as well as timing of subrequests and other operations.
2624
*
2625
* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/)
2626
*/
2627
declare abstract class Performance {
2628
/* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/#performancetimeorigin) */
2629
get timeOrigin(): number;
2630
/* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/#performancenow) */
2631
now(): number;
2632
}
2633
type AiImageClassificationInput = {
2634
image: number[];
2635
};
2636
type AiImageClassificationOutput = {
2637
score?: number;
2638
label?: string;
2639
}[];
2640
declare abstract class BaseAiImageClassification {
2641
inputs: AiImageClassificationInput;
2642
postProcessedOutputs: AiImageClassificationOutput;
2643
}
2644
type AiImageToTextInput = {
2645
image: number[];
2646
prompt?: string;
2647
max_tokens?: number;
2648
temperature?: number;
2649
top_p?: number;
2650
top_k?: number;
2651
seed?: number;
2652
repetition_penalty?: number;
2653
frequency_penalty?: number;
2654
presence_penalty?: number;
2655
raw?: boolean;
2656
messages?: RoleScopedChatInput[];
2657
};
2658
type AiImageToTextOutput = {
2659
description: string;
2660
};
2661
declare abstract class BaseAiImageToText {
2662
inputs: AiImageToTextInput;
2663
postProcessedOutputs: AiImageToTextOutput;
2664
}
2665
type AiImageTextToTextInput = {
2666
image: string;
2667
prompt?: string;
2668
max_tokens?: number;
2669
temperature?: number;
2670
ignore_eos?: boolean;
2671
top_p?: number;
2672
top_k?: number;
2673
seed?: number;
2674
repetition_penalty?: number;
2675
frequency_penalty?: number;
2676
presence_penalty?: number;
2677
raw?: boolean;
2678
messages?: RoleScopedChatInput[];
2679
};
2680
type AiImageTextToTextOutput = {
2681
description: string;
2682
};
2683
declare abstract class BaseAiImageTextToText {
2684
inputs: AiImageTextToTextInput;
2685
postProcessedOutputs: AiImageTextToTextOutput;
2686
}
2687
type AiMultimodalEmbeddingsInput = {
2688
image: string;
2689
text: string[];
2690
};
2691
type AiIMultimodalEmbeddingsOutput = {
2692
data: number[][];
2693
shape: number[];
2694
};
2695
declare abstract class BaseAiMultimodalEmbeddings {
2696
inputs: AiImageTextToTextInput;
2697
postProcessedOutputs: AiImageTextToTextOutput;
2698
}
2699
type AiObjectDetectionInput = {
2700
image: number[];
2701
};
2702
type AiObjectDetectionOutput = {
2703
score?: number;
2704
label?: string;
2705
}[];
2706
declare abstract class BaseAiObjectDetection {
2707
inputs: AiObjectDetectionInput;
2708
postProcessedOutputs: AiObjectDetectionOutput;
2709
}
2710
type AiSentenceSimilarityInput = {
2711
source: string;
2712
sentences: string[];
2713
};
2714
type AiSentenceSimilarityOutput = number[];
2715
declare abstract class BaseAiSentenceSimilarity {
2716
inputs: AiSentenceSimilarityInput;
2717
postProcessedOutputs: AiSentenceSimilarityOutput;
2718
}
2719
type AiAutomaticSpeechRecognitionInput = {
2720
audio: number[];
2721
};
2722
type AiAutomaticSpeechRecognitionOutput = {
2723
text?: string;
2724
words?: {
2725
word: string;
2726
start: number;
2727
end: number;
2728
}[];
2729
vtt?: string;
2730
};
2731
declare abstract class BaseAiAutomaticSpeechRecognition {
2732
inputs: AiAutomaticSpeechRecognitionInput;
2733
postProcessedOutputs: AiAutomaticSpeechRecognitionOutput;
2734
}
2735
type AiSummarizationInput = {
2736
input_text: string;
2737
max_length?: number;
2738
};
2739
type AiSummarizationOutput = {
2740
summary: string;
2741
};
2742
declare abstract class BaseAiSummarization {
2743
inputs: AiSummarizationInput;
2744
postProcessedOutputs: AiSummarizationOutput;
2745
}
2746
type AiTextClassificationInput = {
2747
text: string;
2748
};
2749
type AiTextClassificationOutput = {
2750
score?: number;
2751
label?: string;
2752
}[];
2753
declare abstract class BaseAiTextClassification {
2754
inputs: AiTextClassificationInput;
2755
postProcessedOutputs: AiTextClassificationOutput;
2756
}
2757
type AiTextEmbeddingsInput = {
2758
text: string | string[];
2759
};
2760
type AiTextEmbeddingsOutput = {
2761
shape: number[];
2762
data: number[][];
2763
};
2764
declare abstract class BaseAiTextEmbeddings {
2765
inputs: AiTextEmbeddingsInput;
2766
postProcessedOutputs: AiTextEmbeddingsOutput;
2767
}
2768
type RoleScopedChatInput = {
2769
role: "user" | "assistant" | "system" | "tool" | (string & NonNullable<unknown>);
2770
content: string;
2771
name?: string;
2772
};
2773
type AiTextGenerationToolLegacyInput = {
2774
name: string;
2775
description: string;
2776
parameters?: {
2777
type: "object" | (string & NonNullable<unknown>);
2778
properties: {
2779
[key: string]: {
2780
type: string;
2781
description?: string;
2782
};
2783
};
2784
required: string[];
2785
};
2786
};
2787
type AiTextGenerationToolInput = {
2788
type: "function" | (string & NonNullable<unknown>);
2789
function: {
2790
name: string;
2791
description: string;
2792
parameters?: {
2793
type: "object" | (string & NonNullable<unknown>);
2794
properties: {
2795
[key: string]: {
2796
type: string;
2797
description?: string;
2798
};
2799
};
2800
required: string[];
2801
};
2802
};
2803
};
2804
type AiTextGenerationFunctionsInput = {
2805
name: string;
2806
code: string;
2807
};
2808
type AiTextGenerationResponseFormat = {
2809
type: string;
2810
json_schema?: any;
2811
};
2812
type AiTextGenerationInput = {
2813
prompt?: string;
2814
raw?: boolean;
2815
stream?: boolean;
2816
max_tokens?: number;
2817
temperature?: number;
2818
top_p?: number;
2819
top_k?: number;
2820
seed?: number;
2821
repetition_penalty?: number;
2822
frequency_penalty?: number;
2823
presence_penalty?: number;
2824
messages?: RoleScopedChatInput[];
2825
response_format?: AiTextGenerationResponseFormat;
2826
tools?: AiTextGenerationToolInput[] | AiTextGenerationToolLegacyInput[] | (object & NonNullable<unknown>);
2827
functions?: AiTextGenerationFunctionsInput[];
2828
};
2829
type AiTextGenerationToolLegacyOutput = {
2830
name: string;
2831
arguments: unknown;
2832
};
2833
type AiTextGenerationToolOutput = {
2834
id: string;
2835
type: "function";
2836
function: {
2837
name: string;
2838
arguments: string;
2839
};
2840
};
2841
type UsageTags = {
2842
prompt_tokens: number;
2843
completion_tokens: number;
2844
total_tokens: number;
2845
};
2846
type AiTextGenerationOutput = {
2847
response?: string;
2848
tool_calls?: AiTextGenerationToolLegacyOutput[] & AiTextGenerationToolOutput[];
2849
usage?: UsageTags;
2850
};
2851
declare abstract class BaseAiTextGeneration {
2852
inputs: AiTextGenerationInput;
2853
postProcessedOutputs: AiTextGenerationOutput;
2854
}
2855
type AiTextToSpeechInput = {
2856
prompt: string;
2857
lang?: string;
2858
};
2859
type AiTextToSpeechOutput = Uint8Array | {
2860
audio: string;
2861
};
2862
declare abstract class BaseAiTextToSpeech {
2863
inputs: AiTextToSpeechInput;
2864
postProcessedOutputs: AiTextToSpeechOutput;
2865
}
2866
type AiTextToImageInput = {
2867
prompt: string;
2868
negative_prompt?: string;
2869
height?: number;
2870
width?: number;
2871
image?: number[];
2872
image_b64?: string;
2873
mask?: number[];
2874
num_steps?: number;
2875
strength?: number;
2876
guidance?: number;
2877
seed?: number;
2878
};
2879
type AiTextToImageOutput = ReadableStream<Uint8Array>;
2880
declare abstract class BaseAiTextToImage {
2881
inputs: AiTextToImageInput;
2882
postProcessedOutputs: AiTextToImageOutput;
2883
}
2884
type AiTranslationInput = {
2885
text: string;
2886
target_lang: string;
2887
source_lang?: string;
2888
};
2889
type AiTranslationOutput = {
2890
translated_text?: string;
2891
};
2892
declare abstract class BaseAiTranslation {
2893
inputs: AiTranslationInput;
2894
postProcessedOutputs: AiTranslationOutput;
2895
}
2896
type Ai_Cf_Baai_Bge_Base_En_V1_5_Input = {
2897
text: string | string[];
2898
/**
2899
* The pooling method used in the embedding process. `cls` pooling will generate more accurate embeddings on larger inputs - however, embeddings created with cls pooling are not compatible with embeddings generated with mean pooling. The default pooling method is `mean` in order for this to not be a breaking change, but we highly suggest using the new `cls` pooling for better accuracy.
2900
*/
2901
pooling?: "mean" | "cls";
2902
} | {
2903
/**
2904
* Batch of the embeddings requests to run using async-queue
2905
*/
2906
requests: {
2907
text: string | string[];
2908
/**
2909
* The pooling method used in the embedding process. `cls` pooling will generate more accurate embeddings on larger inputs - however, embeddings created with cls pooling are not compatible with embeddings generated with mean pooling. The default pooling method is `mean` in order for this to not be a breaking change, but we highly suggest using the new `cls` pooling for better accuracy.
2910
*/
2911
pooling?: "mean" | "cls";
2912
}[];
2913
};
2914
type Ai_Cf_Baai_Bge_Base_En_V1_5_Output = {
2915
shape?: number[];
2916
/**
2917
* Embeddings of the requested text values
2918
*/
2919
data?: number[][];
2920
/**
2921
* The pooling method used in the embedding process.
2922
*/
2923
pooling?: "mean" | "cls";
2924
} | AsyncResponse;
2925
interface AsyncResponse {
2926
/**
2927
* The async request id that can be used to obtain the results.
2928
*/
2929
request_id?: string;
2930
}
2931
declare abstract class Base_Ai_Cf_Baai_Bge_Base_En_V1_5 {
2932
inputs: Ai_Cf_Baai_Bge_Base_En_V1_5_Input;
2933
postProcessedOutputs: Ai_Cf_Baai_Bge_Base_En_V1_5_Output;
2934
}
2935
type Ai_Cf_Openai_Whisper_Input = string | {
2936
/**
2937
* An array of integers that represent the audio data constrained to 8-bit unsigned integer values
2938
*/
2939
audio: number[];
2940
};
2941
interface Ai_Cf_Openai_Whisper_Output {
2942
/**
2943
* The transcription
2944
*/
2945
text: string;
2946
word_count?: number;
2947
words?: {
2948
word?: string;
2949
/**
2950
* The second this word begins in the recording
2951
*/
2952
start?: number;
2953
/**
2954
* The ending second when the word completes
2955
*/
2956
end?: number;
2957
}[];
2958
vtt?: string;
2959
}
2960
declare abstract class Base_Ai_Cf_Openai_Whisper {
2961
inputs: Ai_Cf_Openai_Whisper_Input;
2962
postProcessedOutputs: Ai_Cf_Openai_Whisper_Output;
2963
}
2964
type Ai_Cf_Meta_M2M100_1_2B_Input = {
2965
/**
2966
* The text to be translated
2967
*/
2968
text: string;
2969
/**
2970
* The language code of the source text (e.g., 'en' for English). Defaults to 'en' if not specified
2971
*/
2972
source_lang?: string;
2973
/**
2974
* The language code to translate the text into (e.g., 'es' for Spanish)
2975
*/
2976
target_lang: string;
2977
} | {
2978
/**
2979
* Batch of the embeddings requests to run using async-queue
2980
*/
2981
requests: {
2982
/**
2983
* The text to be translated
2984
*/
2985
text: string;
2986
/**
2987
* The language code of the source text (e.g., 'en' for English). Defaults to 'en' if not specified
2988
*/
2989
source_lang?: string;
2990
/**
2991
* The language code to translate the text into (e.g., 'es' for Spanish)
2992
*/
2993
target_lang: string;
2994
}[];
2995
};
2996
type Ai_Cf_Meta_M2M100_1_2B_Output = {
2997
/**
2998
* The translated text in the target language
2999
*/
3000
translated_text?: string;
3001
} | AsyncResponse;
3002
declare abstract class Base_Ai_Cf_Meta_M2M100_1_2B {
3003
inputs: Ai_Cf_Meta_M2M100_1_2B_Input;
3004
postProcessedOutputs: Ai_Cf_Meta_M2M100_1_2B_Output;
3005
}
3006
type Ai_Cf_Baai_Bge_Small_En_V1_5_Input = {
3007
text: string | string[];
3008
/**
3009
* The pooling method used in the embedding process. `cls` pooling will generate more accurate embeddings on larger inputs - however, embeddings created with cls pooling are not compatible with embeddings generated with mean pooling. The default pooling method is `mean` in order for this to not be a breaking change, but we highly suggest using the new `cls` pooling for better accuracy.
3010
*/
3011
pooling?: "mean" | "cls";
3012
} | {
3013
/**
3014
* Batch of the embeddings requests to run using async-queue
3015
*/
3016
requests: {
3017
text: string | string[];
3018
/**
3019
* The pooling method used in the embedding process. `cls` pooling will generate more accurate embeddings on larger inputs - however, embeddings created with cls pooling are not compatible with embeddings generated with mean pooling. The default pooling method is `mean` in order for this to not be a breaking change, but we highly suggest using the new `cls` pooling for better accuracy.
3020
*/
3021
pooling?: "mean" | "cls";
3022
}[];
3023
};
3024
type Ai_Cf_Baai_Bge_Small_En_V1_5_Output = {
3025
shape?: number[];
3026
/**
3027
* Embeddings of the requested text values
3028
*/
3029
data?: number[][];
3030
/**
3031
* The pooling method used in the embedding process.
3032
*/
3033
pooling?: "mean" | "cls";
3034
} | AsyncResponse;
3035
declare abstract class Base_Ai_Cf_Baai_Bge_Small_En_V1_5 {
3036
inputs: Ai_Cf_Baai_Bge_Small_En_V1_5_Input;
3037
postProcessedOutputs: Ai_Cf_Baai_Bge_Small_En_V1_5_Output;
3038
}
3039
type Ai_Cf_Baai_Bge_Large_En_V1_5_Input = {
3040
text: string | string[];
3041
/**
3042
* The pooling method used in the embedding process. `cls` pooling will generate more accurate embeddings on larger inputs - however, embeddings created with cls pooling are not compatible with embeddings generated with mean pooling. The default pooling method is `mean` in order for this to not be a breaking change, but we highly suggest using the new `cls` pooling for better accuracy.
3043
*/
3044
pooling?: "mean" | "cls";
3045
} | {
3046
/**
3047
* Batch of the embeddings requests to run using async-queue
3048
*/
3049
requests: {
3050
text: string | string[];
3051
/**
3052
* The pooling method used in the embedding process. `cls` pooling will generate more accurate embeddings on larger inputs - however, embeddings created with cls pooling are not compatible with embeddings generated with mean pooling. The default pooling method is `mean` in order for this to not be a breaking change, but we highly suggest using the new `cls` pooling for better accuracy.
3053
*/
3054
pooling?: "mean" | "cls";
3055
}[];
3056
};
3057
type Ai_Cf_Baai_Bge_Large_En_V1_5_Output = {
3058
shape?: number[];
3059
/**
3060
* Embeddings of the requested text values
3061
*/
3062
data?: number[][];
3063
/**
3064
* The pooling method used in the embedding process.
3065
*/
3066
pooling?: "mean" | "cls";
3067
} | AsyncResponse;
3068
declare abstract class Base_Ai_Cf_Baai_Bge_Large_En_V1_5 {
3069
inputs: Ai_Cf_Baai_Bge_Large_En_V1_5_Input;
3070
postProcessedOutputs: Ai_Cf_Baai_Bge_Large_En_V1_5_Output;
3071
}
3072
type Ai_Cf_Unum_Uform_Gen2_Qwen_500M_Input = string | {
3073
/**
3074
* The input text prompt for the model to generate a response.
3075
*/
3076
prompt?: string;
3077
/**
3078
* If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
3079
*/
3080
raw?: boolean;
3081
/**
3082
* Controls the creativity of the AI's responses by adjusting how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
3083
*/
3084
top_p?: number;
3085
/**
3086
* Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
3087
*/
3088
top_k?: number;
3089
/**
3090
* Random seed for reproducibility of the generation.
3091
*/
3092
seed?: number;
3093
/**
3094
* Penalty for repeated tokens; higher values discourage repetition.
3095
*/
3096
repetition_penalty?: number;
3097
/**
3098
* Decreases the likelihood of the model repeating the same lines verbatim.
3099
*/
3100
frequency_penalty?: number;
3101
/**
3102
* Increases the likelihood of the model introducing new topics.
3103
*/
3104
presence_penalty?: number;
3105
image: number[] | (string & NonNullable<unknown>);
3106
/**
3107
* The maximum number of tokens to generate in the response.
3108
*/
3109
max_tokens?: number;
3110
};
3111
interface Ai_Cf_Unum_Uform_Gen2_Qwen_500M_Output {
3112
description?: string;
3113
}
3114
declare abstract class Base_Ai_Cf_Unum_Uform_Gen2_Qwen_500M {
3115
inputs: Ai_Cf_Unum_Uform_Gen2_Qwen_500M_Input;
3116
postProcessedOutputs: Ai_Cf_Unum_Uform_Gen2_Qwen_500M_Output;
3117
}
3118
type Ai_Cf_Openai_Whisper_Tiny_En_Input = string | {
3119
/**
3120
* An array of integers that represent the audio data constrained to 8-bit unsigned integer values
3121
*/
3122
audio: number[];
3123
};
3124
interface Ai_Cf_Openai_Whisper_Tiny_En_Output {
3125
/**
3126
* The transcription
3127
*/
3128
text: string;
3129
word_count?: number;
3130
words?: {
3131
word?: string;
3132
/**
3133
* The second this word begins in the recording
3134
*/
3135
start?: number;
3136
/**
3137
* The ending second when the word completes
3138
*/
3139
end?: number;
3140
}[];
3141
vtt?: string;
3142
}
3143
declare abstract class Base_Ai_Cf_Openai_Whisper_Tiny_En {
3144
inputs: Ai_Cf_Openai_Whisper_Tiny_En_Input;
3145
postProcessedOutputs: Ai_Cf_Openai_Whisper_Tiny_En_Output;
3146
}
3147
interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input {
3148
/**
3149
* Base64 encoded value of the audio data.
3150
*/
3151
audio: string;
3152
/**
3153
* Supported tasks are 'translate' or 'transcribe'.
3154
*/
3155
task?: string;
3156
/**
3157
* The language of the audio being transcribed or translated.
3158
*/
3159
language?: string;
3160
/**
3161
* Preprocess the audio with a voice activity detection model.
3162
*/
3163
vad_filter?: boolean;
3164
/**
3165
* A text prompt to help provide context to the model on the contents of the audio.
3166
*/
3167
initial_prompt?: string;
3168
/**
3169
* The prefix it appended the the beginning of the output of the transcription and can guide the transcription result.
3170
*/
3171
prefix?: string;
3172
}
3173
interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Output {
3174
transcription_info?: {
3175
/**
3176
* The language of the audio being transcribed or translated.
3177
*/
3178
language?: string;
3179
/**
3180
* The confidence level or probability of the detected language being accurate, represented as a decimal between 0 and 1.
3181
*/
3182
language_probability?: number;
3183
/**
3184
* The total duration of the original audio file, in seconds.
3185
*/
3186
duration?: number;
3187
/**
3188
* The duration of the audio after applying Voice Activity Detection (VAD) to remove silent or irrelevant sections, in seconds.
3189
*/
3190
duration_after_vad?: number;
3191
};
3192
/**
3193
* The complete transcription of the audio.
3194
*/
3195
text: string;
3196
/**
3197
* The total number of words in the transcription.
3198
*/
3199
word_count?: number;
3200
segments?: {
3201
/**
3202
* The starting time of the segment within the audio, in seconds.
3203
*/
3204
start?: number;
3205
/**
3206
* The ending time of the segment within the audio, in seconds.
3207
*/
3208
end?: number;
3209
/**
3210
* The transcription of the segment.
3211
*/
3212
text?: string;
3213
/**
3214
* The temperature used in the decoding process, controlling randomness in predictions. Lower values result in more deterministic outputs.
3215
*/
3216
temperature?: number;
3217
/**
3218
* The average log probability of the predictions for the words in this segment, indicating overall confidence.
3219
*/
3220
avg_logprob?: number;
3221
/**
3222
* The compression ratio of the input to the output, measuring how much the text was compressed during the transcription process.
3223
*/
3224
compression_ratio?: number;
3225
/**
3226
* The probability that the segment contains no speech, represented as a decimal between 0 and 1.
3227
*/
3228
no_speech_prob?: number;
3229
words?: {
3230
/**
3231
* The individual word transcribed from the audio.
3232
*/
3233
word?: string;
3234
/**
3235
* The starting time of the word within the audio, in seconds.
3236
*/
3237
start?: number;
3238
/**
3239
* The ending time of the word within the audio, in seconds.
3240
*/
3241
end?: number;
3242
}[];
3243
}[];
3244
/**
3245
* The transcription in WebVTT format, which includes timing and text information for use in subtitles.
3246
*/
3247
vtt?: string;
3248
}
3249
declare abstract class Base_Ai_Cf_Openai_Whisper_Large_V3_Turbo {
3250
inputs: Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input;
3251
postProcessedOutputs: Ai_Cf_Openai_Whisper_Large_V3_Turbo_Output;
3252
}
3253
type Ai_Cf_Baai_Bge_M3_Input = BGEM3InputQueryAndContexts | BGEM3InputEmbedding | {
3254
/**
3255
* Batch of the embeddings requests to run using async-queue
3256
*/
3257
requests: (BGEM3InputQueryAndContexts1 | BGEM3InputEmbedding1)[];
3258
};
3259
interface BGEM3InputQueryAndContexts {
3260
/**
3261
* A query you wish to perform against the provided contexts. If no query is provided the model with respond with embeddings for contexts
3262
*/
3263
query?: string;
3264
/**
3265
* List of provided contexts. Note that the index in this array is important, as the response will refer to it.
3266
*/
3267
contexts: {
3268
/**
3269
* One of the provided context content
3270
*/
3271
text?: string;
3272
}[];
3273
/**
3274
* When provided with too long context should the model error out or truncate the context to fit?
3275
*/
3276
truncate_inputs?: boolean;
3277
}
3278
interface BGEM3InputEmbedding {
3279
text: string | string[];
3280
/**
3281
* When provided with too long context should the model error out or truncate the context to fit?
3282
*/
3283
truncate_inputs?: boolean;
3284
}
3285
interface BGEM3InputQueryAndContexts1 {
3286
/**
3287
* A query you wish to perform against the provided contexts. If no query is provided the model with respond with embeddings for contexts
3288
*/
3289
query?: string;
3290
/**
3291
* List of provided contexts. Note that the index in this array is important, as the response will refer to it.
3292
*/
3293
contexts: {
3294
/**
3295
* One of the provided context content
3296
*/
3297
text?: string;
3298
}[];
3299
/**
3300
* When provided with too long context should the model error out or truncate the context to fit?
3301
*/
3302
truncate_inputs?: boolean;
3303
}
3304
interface BGEM3InputEmbedding1 {
3305
text: string | string[];
3306
/**
3307
* When provided with too long context should the model error out or truncate the context to fit?
3308
*/
3309
truncate_inputs?: boolean;
3310
}
3311
type Ai_Cf_Baai_Bge_M3_Output = BGEM3OuputQuery | BGEM3OutputEmbeddingForContexts | BGEM3OuputEmbedding | AsyncResponse;
3312
interface BGEM3OuputQuery {
3313
response?: {
3314
/**
3315
* Index of the context in the request
3316
*/
3317
id?: number;
3318
/**
3319
* Score of the context under the index.
3320
*/
3321
score?: number;
3322
}[];
3323
}
3324
interface BGEM3OutputEmbeddingForContexts {
3325
response?: number[][];
3326
shape?: number[];
3327
/**
3328
* The pooling method used in the embedding process.
3329
*/
3330
pooling?: "mean" | "cls";
3331
}
3332
interface BGEM3OuputEmbedding {
3333
shape?: number[];
3334
/**
3335
* Embeddings of the requested text values
3336
*/
3337
data?: number[][];
3338
/**
3339
* The pooling method used in the embedding process.
3340
*/
3341
pooling?: "mean" | "cls";
3342
}
3343
declare abstract class Base_Ai_Cf_Baai_Bge_M3 {
3344
inputs: Ai_Cf_Baai_Bge_M3_Input;
3345
postProcessedOutputs: Ai_Cf_Baai_Bge_M3_Output;
3346
}
3347
interface Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Input {
3348
/**
3349
* A text description of the image you want to generate.
3350
*/
3351
prompt: string;
3352
/**
3353
* The number of diffusion steps; higher values can improve quality but take longer.
3354
*/
3355
steps?: number;
3356
}
3357
interface Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Output {
3358
/**
3359
* The generated image in Base64 format.
3360
*/
3361
image?: string;
3362
}
3363
declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_1_Schnell {
3364
inputs: Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Input;
3365
postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Output;
3366
}
3367
type Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Input = Prompt | Messages;
3368
interface Prompt {
3369
/**
3370
* The input text prompt for the model to generate a response.
3371
*/
3372
prompt: string;
3373
image?: number[] | (string & NonNullable<unknown>);
3374
/**
3375
* If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
3376
*/
3377
raw?: boolean;
3378
/**
3379
* If true, the response will be streamed back incrementally using SSE, Server Sent Events.
3380
*/
3381
stream?: boolean;
3382
/**
3383
* The maximum number of tokens to generate in the response.
3384
*/
3385
max_tokens?: number;
3386
/**
3387
* Controls the randomness of the output; higher values produce more random results.
3388
*/
3389
temperature?: number;
3390
/**
3391
* Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
3392
*/
3393
top_p?: number;
3394
/**
3395
* Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
3396
*/
3397
top_k?: number;
3398
/**
3399
* Random seed for reproducibility of the generation.
3400
*/
3401
seed?: number;
3402
/**
3403
* Penalty for repeated tokens; higher values discourage repetition.
3404
*/
3405
repetition_penalty?: number;
3406
/**
3407
* Decreases the likelihood of the model repeating the same lines verbatim.
3408
*/
3409
frequency_penalty?: number;
3410
/**
3411
* Increases the likelihood of the model introducing new topics.
3412
*/
3413
presence_penalty?: number;
3414
/**
3415
* Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.
3416
*/
3417
lora?: string;
3418
}
3419
interface Messages {
3420
/**
3421
* An array of message objects representing the conversation history.
3422
*/
3423
messages: {
3424
/**
3425
* The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
3426
*/
3427
role?: string;
3428
/**
3429
* The tool call id. Must be supplied for tool calls for Mistral-3. If you don't know what to put here you can fall back to 000000001
3430
*/
3431
tool_call_id?: string;
3432
content?: string | {
3433
/**
3434
* Type of the content provided
3435
*/
3436
type?: string;
3437
text?: string;
3438
image_url?: {
3439
/**
3440
* image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
3441
*/
3442
url?: string;
3443
};
3444
}[] | {
3445
/**
3446
* Type of the content provided
3447
*/
3448
type?: string;
3449
text?: string;
3450
image_url?: {
3451
/**
3452
* image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
3453
*/
3454
url?: string;
3455
};
3456
};
3457
}[];
3458
image?: number[] | (string & NonNullable<unknown>);
3459
functions?: {
3460
name: string;
3461
code: string;
3462
}[];
3463
/**
3464
* A list of tools available for the assistant to use.
3465
*/
3466
tools?: ({
3467
/**
3468
* The name of the tool. More descriptive the better.
3469
*/
3470
name: string;
3471
/**
3472
* A brief description of what the tool does.
3473
*/
3474
description: string;
3475
/**
3476
* Schema defining the parameters accepted by the tool.
3477
*/
3478
parameters: {
3479
/**
3480
* The type of the parameters object (usually 'object').
3481
*/
3482
type: string;
3483
/**
3484
* List of required parameter names.
3485
*/
3486
required?: string[];
3487
/**
3488
* Definitions of each parameter.
3489
*/
3490
properties: {
3491
[k: string]: {
3492
/**
3493
* The data type of the parameter.
3494
*/
3495
type: string;
3496
/**
3497
* A description of the expected parameter.
3498
*/
3499
description: string;
3500
};
3501
};
3502
};
3503
} | {
3504
/**
3505
* Specifies the type of tool (e.g., 'function').
3506
*/
3507
type: string;
3508
/**
3509
* Details of the function tool.
3510
*/
3511
function: {
3512
/**
3513
* The name of the function.
3514
*/
3515
name: string;
3516
/**
3517
* A brief description of what the function does.
3518
*/
3519
description: string;
3520
/**
3521
* Schema defining the parameters accepted by the function.
3522
*/
3523
parameters: {
3524
/**
3525
* The type of the parameters object (usually 'object').
3526
*/
3527
type: string;
3528
/**
3529
* List of required parameter names.
3530
*/
3531
required?: string[];
3532
/**
3533
* Definitions of each parameter.
3534
*/
3535
properties: {
3536
[k: string]: {
3537
/**
3538
* The data type of the parameter.
3539
*/
3540
type: string;
3541
/**
3542
* A description of the expected parameter.
3543
*/
3544
description: string;
3545
};
3546
};
3547
};
3548
};
3549
})[];
3550
/**
3551
* If true, the response will be streamed back incrementally.
3552
*/
3553
stream?: boolean;
3554
/**
3555
* The maximum number of tokens to generate in the response.
3556
*/
3557
max_tokens?: number;
3558
/**
3559
* Controls the randomness of the output; higher values produce more random results.
3560
*/
3561
temperature?: number;
3562
/**
3563
* Controls the creativity of the AI's responses by adjusting how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
3564
*/
3565
top_p?: number;
3566
/**
3567
* Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
3568
*/
3569
top_k?: number;
3570
/**
3571
* Random seed for reproducibility of the generation.
3572
*/
3573
seed?: number;
3574
/**
3575
* Penalty for repeated tokens; higher values discourage repetition.
3576
*/
3577
repetition_penalty?: number;
3578
/**
3579
* Decreases the likelihood of the model repeating the same lines verbatim.
3580
*/
3581
frequency_penalty?: number;
3582
/**
3583
* Increases the likelihood of the model introducing new topics.
3584
*/
3585
presence_penalty?: number;
3586
}
3587
type Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Output = {
3588
/**
3589
* The generated text response from the model
3590
*/
3591
response?: string;
3592
/**
3593
* An array of tool calls requests made during the response generation
3594
*/
3595
tool_calls?: {
3596
/**
3597
* The arguments passed to be passed to the tool call request
3598
*/
3599
arguments?: object;
3600
/**
3601
* The name of the tool to be called
3602
*/
3603
name?: string;
3604
}[];
3605
};
3606
declare abstract class Base_Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct {
3607
inputs: Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Input;
3608
postProcessedOutputs: Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Output;
3609
}
3610
type Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Input = Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Prompt | Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Messages | AsyncBatch;
3611
interface Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Prompt {
3612
/**
3613
* The input text prompt for the model to generate a response.
3614
*/
3615
prompt: string;
3616
/**
3617
* Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.
3618
*/
3619
lora?: string;
3620
response_format?: JSONMode;
3621
/**
3622
* If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
3623
*/
3624
raw?: boolean;
3625
/**
3626
* If true, the response will be streamed back incrementally using SSE, Server Sent Events.
3627
*/
3628
stream?: boolean;
3629
/**
3630
* The maximum number of tokens to generate in the response.
3631
*/
3632
max_tokens?: number;
3633
/**
3634
* Controls the randomness of the output; higher values produce more random results.
3635
*/
3636
temperature?: number;
3637
/**
3638
* Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
3639
*/
3640
top_p?: number;
3641
/**
3642
* Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
3643
*/
3644
top_k?: number;
3645
/**
3646
* Random seed for reproducibility of the generation.
3647
*/
3648
seed?: number;
3649
/**
3650
* Penalty for repeated tokens; higher values discourage repetition.
3651
*/
3652
repetition_penalty?: number;
3653
/**
3654
* Decreases the likelihood of the model repeating the same lines verbatim.
3655
*/
3656
frequency_penalty?: number;
3657
/**
3658
* Increases the likelihood of the model introducing new topics.
3659
*/
3660
presence_penalty?: number;
3661
}
3662
interface JSONMode {
3663
type?: "json_object" | "json_schema";
3664
json_schema?: unknown;
3665
}
3666
interface Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Messages {
3667
/**
3668
* An array of message objects representing the conversation history.
3669
*/
3670
messages: {
3671
/**
3672
* The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
3673
*/
3674
role: string;
3675
/**
3676
* The content of the message as a string.
3677
*/
3678
content: string;
3679
}[];
3680
functions?: {
3681
name: string;
3682
code: string;
3683
}[];
3684
/**
3685
* A list of tools available for the assistant to use.
3686
*/
3687
tools?: ({
3688
/**
3689
* The name of the tool. More descriptive the better.
3690
*/
3691
name: string;
3692
/**
3693
* A brief description of what the tool does.
3694
*/
3695
description: string;
3696
/**
3697
* Schema defining the parameters accepted by the tool.
3698
*/
3699
parameters: {
3700
/**
3701
* The type of the parameters object (usually 'object').
3702
*/
3703
type: string;
3704
/**
3705
* List of required parameter names.
3706
*/
3707
required?: string[];
3708
/**
3709
* Definitions of each parameter.
3710
*/
3711
properties: {
3712
[k: string]: {
3713
/**
3714
* The data type of the parameter.
3715
*/
3716
type: string;
3717
/**
3718
* A description of the expected parameter.
3719
*/
3720
description: string;
3721
};
3722
};
3723
};
3724
} | {
3725
/**
3726
* Specifies the type of tool (e.g., 'function').
3727
*/
3728
type: string;
3729
/**
3730
* Details of the function tool.
3731
*/
3732
function: {
3733
/**
3734
* The name of the function.
3735
*/
3736
name: string;
3737
/**
3738
* A brief description of what the function does.
3739
*/
3740
description: string;
3741
/**
3742
* Schema defining the parameters accepted by the function.
3743
*/
3744
parameters: {
3745
/**
3746
* The type of the parameters object (usually 'object').
3747
*/
3748
type: string;
3749
/**
3750
* List of required parameter names.
3751
*/
3752
required?: string[];
3753
/**
3754
* Definitions of each parameter.
3755
*/
3756
properties: {
3757
[k: string]: {
3758
/**
3759
* The data type of the parameter.
3760
*/
3761
type: string;
3762
/**
3763
* A description of the expected parameter.
3764
*/
3765
description: string;
3766
};
3767
};
3768
};
3769
};
3770
})[];
3771
response_format?: JSONMode;
3772
/**
3773
* If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
3774
*/
3775
raw?: boolean;
3776
/**
3777
* If true, the response will be streamed back incrementally using SSE, Server Sent Events.
3778
*/
3779
stream?: boolean;
3780
/**
3781
* The maximum number of tokens to generate in the response.
3782
*/
3783
max_tokens?: number;
3784
/**
3785
* Controls the randomness of the output; higher values produce more random results.
3786
*/
3787
temperature?: number;
3788
/**
3789
* Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
3790
*/
3791
top_p?: number;
3792
/**
3793
* Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
3794
*/
3795
top_k?: number;
3796
/**
3797
* Random seed for reproducibility of the generation.
3798
*/
3799
seed?: number;
3800
/**
3801
* Penalty for repeated tokens; higher values discourage repetition.
3802
*/
3803
repetition_penalty?: number;
3804
/**
3805
* Decreases the likelihood of the model repeating the same lines verbatim.
3806
*/
3807
frequency_penalty?: number;
3808
/**
3809
* Increases the likelihood of the model introducing new topics.
3810
*/
3811
presence_penalty?: number;
3812
}
3813
interface AsyncBatch {
3814
requests?: {
3815
/**
3816
* User-supplied reference. This field will be present in the response as well it can be used to reference the request and response. It's NOT validated to be unique.
3817
*/
3818
external_reference?: string;
3819
/**
3820
* Prompt for the text generation model
3821
*/
3822
prompt?: string;
3823
/**
3824
* If true, the response will be streamed back incrementally using SSE, Server Sent Events.
3825
*/
3826
stream?: boolean;
3827
/**
3828
* The maximum number of tokens to generate in the response.
3829
*/
3830
max_tokens?: number;
3831
/**
3832
* Controls the randomness of the output; higher values produce more random results.
3833
*/
3834
temperature?: number;
3835
/**
3836
* Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
3837
*/
3838
top_p?: number;
3839
/**
3840
* Random seed for reproducibility of the generation.
3841
*/
3842
seed?: number;
3843
/**
3844
* Penalty for repeated tokens; higher values discourage repetition.
3845
*/
3846
repetition_penalty?: number;
3847
/**
3848
* Decreases the likelihood of the model repeating the same lines verbatim.
3849
*/
3850
frequency_penalty?: number;
3851
/**
3852
* Increases the likelihood of the model introducing new topics.
3853
*/
3854
presence_penalty?: number;
3855
response_format?: JSONMode;
3856
}[];
3857
}
3858
type Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Output = {
3859
/**
3860
* The generated text response from the model
3861
*/
3862
response: string;
3863
/**
3864
* Usage statistics for the inference request
3865
*/
3866
usage?: {
3867
/**
3868
* Total number of tokens in input
3869
*/
3870
prompt_tokens?: number;
3871
/**
3872
* Total number of tokens in output
3873
*/
3874
completion_tokens?: number;
3875
/**
3876
* Total number of input and output tokens
3877
*/
3878
total_tokens?: number;
3879
};
3880
/**
3881
* An array of tool calls requests made during the response generation
3882
*/
3883
tool_calls?: {
3884
/**
3885
* The arguments passed to be passed to the tool call request
3886
*/
3887
arguments?: object;
3888
/**
3889
* The name of the tool to be called
3890
*/
3891
name?: string;
3892
}[];
3893
} | string | AsyncResponse;
3894
declare abstract class Base_Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast {
3895
inputs: Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Input;
3896
postProcessedOutputs: Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Output;
3897
}
3898
interface Ai_Cf_Meta_Llama_Guard_3_8B_Input {
3899
/**
3900
* An array of message objects representing the conversation history.
3901
*/
3902
messages: {
3903
/**
3904
* The role of the message sender must alternate between 'user' and 'assistant'.
3905
*/
3906
role: "user" | "assistant";
3907
/**
3908
* The content of the message as a string.
3909
*/
3910
content: string;
3911
}[];
3912
/**
3913
* The maximum number of tokens to generate in the response.
3914
*/
3915
max_tokens?: number;
3916
/**
3917
* Controls the randomness of the output; higher values produce more random results.
3918
*/
3919
temperature?: number;
3920
/**
3921
* Dictate the output format of the generated response.
3922
*/
3923
response_format?: {
3924
/**
3925
* Set to json_object to process and output generated text as JSON.
3926
*/
3927
type?: string;
3928
};
3929
}
3930
interface Ai_Cf_Meta_Llama_Guard_3_8B_Output {
3931
response?: string | {
3932
/**
3933
* Whether the conversation is safe or not.
3934
*/
3935
safe?: boolean;
3936
/**
3937
* A list of what hazard categories predicted for the conversation, if the conversation is deemed unsafe.
3938
*/
3939
categories?: string[];
3940
};
3941
/**
3942
* Usage statistics for the inference request
3943
*/
3944
usage?: {
3945
/**
3946
* Total number of tokens in input
3947
*/
3948
prompt_tokens?: number;
3949
/**
3950
* Total number of tokens in output
3951
*/
3952
completion_tokens?: number;
3953
/**
3954
* Total number of input and output tokens
3955
*/
3956
total_tokens?: number;
3957
};
3958
}
3959
declare abstract class Base_Ai_Cf_Meta_Llama_Guard_3_8B {
3960
inputs: Ai_Cf_Meta_Llama_Guard_3_8B_Input;
3961
postProcessedOutputs: Ai_Cf_Meta_Llama_Guard_3_8B_Output;
3962
}
3963
interface Ai_Cf_Baai_Bge_Reranker_Base_Input {
3964
/**
3965
* A query you wish to perform against the provided contexts.
3966
*/
3967
/**
3968
* Number of returned results starting with the best score.
3969
*/
3970
top_k?: number;
3971
/**
3972
* List of provided contexts. Note that the index in this array is important, as the response will refer to it.
3973
*/
3974
contexts: {
3975
/**
3976
* One of the provided context content
3977
*/
3978
text?: string;
3979
}[];
3980
}
3981
interface Ai_Cf_Baai_Bge_Reranker_Base_Output {
3982
response?: {
3983
/**
3984
* Index of the context in the request
3985
*/
3986
id?: number;
3987
/**
3988
* Score of the context under the index.
3989
*/
3990
score?: number;
3991
}[];
3992
}
3993
declare abstract class Base_Ai_Cf_Baai_Bge_Reranker_Base {
3994
inputs: Ai_Cf_Baai_Bge_Reranker_Base_Input;
3995
postProcessedOutputs: Ai_Cf_Baai_Bge_Reranker_Base_Output;
3996
}
3997
type Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Input = Qwen2_5_Coder_32B_Instruct_Prompt | Qwen2_5_Coder_32B_Instruct_Messages;
3998
interface Qwen2_5_Coder_32B_Instruct_Prompt {
3999
/**
4000
* The input text prompt for the model to generate a response.
4001
*/
4002
prompt: string;
4003
/**
4004
* Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.
4005
*/
4006
lora?: string;
4007
response_format?: JSONMode;
4008
/**
4009
* If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
4010
*/
4011
raw?: boolean;
4012
/**
4013
* If true, the response will be streamed back incrementally using SSE, Server Sent Events.
4014
*/
4015
stream?: boolean;
4016
/**
4017
* The maximum number of tokens to generate in the response.
4018
*/
4019
max_tokens?: number;
4020
/**
4021
* Controls the randomness of the output; higher values produce more random results.
4022
*/
4023
temperature?: number;
4024
/**
4025
* Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
4026
*/
4027
top_p?: number;
4028
/**
4029
* Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
4030
*/
4031
top_k?: number;
4032
/**
4033
* Random seed for reproducibility of the generation.
4034
*/
4035
seed?: number;
4036
/**
4037
* Penalty for repeated tokens; higher values discourage repetition.
4038
*/
4039
repetition_penalty?: number;
4040
/**
4041
* Decreases the likelihood of the model repeating the same lines verbatim.
4042
*/
4043
frequency_penalty?: number;
4044
/**
4045
* Increases the likelihood of the model introducing new topics.
4046
*/
4047
presence_penalty?: number;
4048
}
4049
interface Qwen2_5_Coder_32B_Instruct_Messages {
4050
/**
4051
* An array of message objects representing the conversation history.
4052
*/
4053
messages: {
4054
/**
4055
* The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
4056
*/
4057
role: string;
4058
/**
4059
* The content of the message as a string.
4060
*/
4061
content: string;
4062
}[];
4063
functions?: {
4064
name: string;
4065
code: string;
4066
}[];
4067
/**
4068
* A list of tools available for the assistant to use.
4069
*/
4070
tools?: ({
4071
/**
4072
* The name of the tool. More descriptive the better.
4073
*/
4074
name: string;
4075
/**
4076
* A brief description of what the tool does.
4077
*/
4078
description: string;
4079
/**
4080
* Schema defining the parameters accepted by the tool.
4081
*/
4082
parameters: {
4083
/**
4084
* The type of the parameters object (usually 'object').
4085
*/
4086
type: string;
4087
/**
4088
* List of required parameter names.
4089
*/
4090
required?: string[];
4091
/**
4092
* Definitions of each parameter.
4093
*/
4094
properties: {
4095
[k: string]: {
4096
/**
4097
* The data type of the parameter.
4098
*/
4099
type: string;
4100
/**
4101
* A description of the expected parameter.
4102
*/
4103
description: string;
4104
};
4105
};
4106
};
4107
} | {
4108
/**
4109
* Specifies the type of tool (e.g., 'function').
4110
*/
4111
type: string;
4112
/**
4113
* Details of the function tool.
4114
*/
4115
function: {
4116
/**
4117
* The name of the function.
4118
*/
4119
name: string;
4120
/**
4121
* A brief description of what the function does.
4122
*/
4123
description: string;
4124
/**
4125
* Schema defining the parameters accepted by the function.
4126
*/
4127
parameters: {
4128
/**
4129
* The type of the parameters object (usually 'object').
4130
*/
4131
type: string;
4132
/**
4133
* List of required parameter names.
4134
*/
4135
required?: string[];
4136
/**
4137
* Definitions of each parameter.
4138
*/
4139
properties: {
4140
[k: string]: {
4141
/**
4142
* The data type of the parameter.
4143
*/
4144
type: string;
4145
/**
4146
* A description of the expected parameter.
4147
*/
4148
description: string;
4149
};
4150
};
4151
};
4152
};
4153
})[];
4154
response_format?: JSONMode;
4155
/**
4156
* If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
4157
*/
4158
raw?: boolean;
4159
/**
4160
* If true, the response will be streamed back incrementally using SSE, Server Sent Events.
4161
*/
4162
stream?: boolean;
4163
/**
4164
* The maximum number of tokens to generate in the response.
4165
*/
4166
max_tokens?: number;
4167
/**
4168
* Controls the randomness of the output; higher values produce more random results.
4169
*/
4170
temperature?: number;
4171
/**
4172
* Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
4173
*/
4174
top_p?: number;
4175
/**
4176
* Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
4177
*/
4178
top_k?: number;
4179
/**
4180
* Random seed for reproducibility of the generation.
4181
*/
4182
seed?: number;
4183
/**
4184
* Penalty for repeated tokens; higher values discourage repetition.
4185
*/
4186
repetition_penalty?: number;
4187
/**
4188
* Decreases the likelihood of the model repeating the same lines verbatim.
4189
*/
4190
frequency_penalty?: number;
4191
/**
4192
* Increases the likelihood of the model introducing new topics.
4193
*/
4194
presence_penalty?: number;
4195
}
4196
type Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Output = {
4197
/**
4198
* The generated text response from the model
4199
*/
4200
response: string;
4201
/**
4202
* Usage statistics for the inference request
4203
*/
4204
usage?: {
4205
/**
4206
* Total number of tokens in input
4207
*/
4208
prompt_tokens?: number;
4209
/**
4210
* Total number of tokens in output
4211
*/
4212
completion_tokens?: number;
4213
/**
4214
* Total number of input and output tokens
4215
*/
4216
total_tokens?: number;
4217
};
4218
/**
4219
* An array of tool calls requests made during the response generation
4220
*/
4221
tool_calls?: {
4222
/**
4223
* The arguments passed to be passed to the tool call request
4224
*/
4225
arguments?: object;
4226
/**
4227
* The name of the tool to be called
4228
*/
4229
name?: string;
4230
}[];
4231
};
4232
declare abstract class Base_Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct {
4233
inputs: Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Input;
4234
postProcessedOutputs: Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Output;
4235
}
4236
type Ai_Cf_Qwen_Qwq_32B_Input = Qwen_Qwq_32B_Prompt | Qwen_Qwq_32B_Messages;
4237
interface Qwen_Qwq_32B_Prompt {
4238
/**
4239
* The input text prompt for the model to generate a response.
4240
*/
4241
prompt: string;
4242
/**
4243
* JSON schema that should be fulfilled for the response.
4244
*/
4245
guided_json?: object;
4246
/**
4247
* If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
4248
*/
4249
raw?: boolean;
4250
/**
4251
* If true, the response will be streamed back incrementally using SSE, Server Sent Events.
4252
*/
4253
stream?: boolean;
4254
/**
4255
* The maximum number of tokens to generate in the response.
4256
*/
4257
max_tokens?: number;
4258
/**
4259
* Controls the randomness of the output; higher values produce more random results.
4260
*/
4261
temperature?: number;
4262
/**
4263
* Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
4264
*/
4265
top_p?: number;
4266
/**
4267
* Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
4268
*/
4269
top_k?: number;
4270
/**
4271
* Random seed for reproducibility of the generation.
4272
*/
4273
seed?: number;
4274
/**
4275
* Penalty for repeated tokens; higher values discourage repetition.
4276
*/
4277
repetition_penalty?: number;
4278
/**
4279
* Decreases the likelihood of the model repeating the same lines verbatim.
4280
*/
4281
frequency_penalty?: number;
4282
/**
4283
* Increases the likelihood of the model introducing new topics.
4284
*/
4285
presence_penalty?: number;
4286
}
4287
interface Qwen_Qwq_32B_Messages {
4288
/**
4289
* An array of message objects representing the conversation history.
4290
*/
4291
messages: {
4292
/**
4293
* The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
4294
*/
4295
role?: string;
4296
/**
4297
* The tool call id. Must be supplied for tool calls for Mistral-3. If you don't know what to put here you can fall back to 000000001
4298
*/
4299
tool_call_id?: string;
4300
content?: string | {
4301
/**
4302
* Type of the content provided
4303
*/
4304
type?: string;
4305
text?: string;
4306
image_url?: {
4307
/**
4308
* image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
4309
*/
4310
url?: string;
4311
};
4312
}[] | {
4313
/**
4314
* Type of the content provided
4315
*/
4316
type?: string;
4317
text?: string;
4318
image_url?: {
4319
/**
4320
* image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
4321
*/
4322
url?: string;
4323
};
4324
};
4325
}[];
4326
functions?: {
4327
name: string;
4328
code: string;
4329
}[];
4330
/**
4331
* A list of tools available for the assistant to use.
4332
*/
4333
tools?: ({
4334
/**
4335
* The name of the tool. More descriptive the better.
4336
*/
4337
name: string;
4338
/**
4339
* A brief description of what the tool does.
4340
*/
4341
description: string;
4342
/**
4343
* Schema defining the parameters accepted by the tool.
4344
*/
4345
parameters: {
4346
/**
4347
* The type of the parameters object (usually 'object').
4348
*/
4349
type: string;
4350
/**
4351
* List of required parameter names.
4352
*/
4353
required?: string[];
4354
/**
4355
* Definitions of each parameter.
4356
*/
4357
properties: {
4358
[k: string]: {
4359
/**
4360
* The data type of the parameter.
4361
*/
4362
type: string;
4363
/**
4364
* A description of the expected parameter.
4365
*/
4366
description: string;
4367
};
4368
};
4369
};
4370
} | {
4371
/**
4372
* Specifies the type of tool (e.g., 'function').
4373
*/
4374
type: string;
4375
/**
4376
* Details of the function tool.
4377
*/
4378
function: {
4379
/**
4380
* The name of the function.
4381
*/
4382
name: string;
4383
/**
4384
* A brief description of what the function does.
4385
*/
4386
description: string;
4387
/**
4388
* Schema defining the parameters accepted by the function.
4389
*/
4390
parameters: {
4391
/**
4392
* The type of the parameters object (usually 'object').
4393
*/
4394
type: string;
4395
/**
4396
* List of required parameter names.
4397
*/
4398
required?: string[];
4399
/**
4400
* Definitions of each parameter.
4401
*/
4402
properties: {
4403
[k: string]: {
4404
/**
4405
* The data type of the parameter.
4406
*/
4407
type: string;
4408
/**
4409
* A description of the expected parameter.
4410
*/
4411
description: string;
4412
};
4413
};
4414
};
4415
};
4416
})[];
4417
/**
4418
* JSON schema that should be fufilled for the response.
4419
*/
4420
guided_json?: object;
4421
/**
4422
* If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
4423
*/
4424
raw?: boolean;
4425
/**
4426
* If true, the response will be streamed back incrementally using SSE, Server Sent Events.
4427
*/
4428
stream?: boolean;
4429
/**
4430
* The maximum number of tokens to generate in the response.
4431
*/
4432
max_tokens?: number;
4433
/**
4434
* Controls the randomness of the output; higher values produce more random results.
4435
*/
4436
temperature?: number;
4437
/**
4438
* Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
4439
*/
4440
top_p?: number;
4441
/**
4442
* Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
4443
*/
4444
top_k?: number;
4445
/**
4446
* Random seed for reproducibility of the generation.
4447
*/
4448
seed?: number;
4449
/**
4450
* Penalty for repeated tokens; higher values discourage repetition.
4451
*/
4452
repetition_penalty?: number;
4453
/**
4454
* Decreases the likelihood of the model repeating the same lines verbatim.
4455
*/
4456
frequency_penalty?: number;
4457
/**
4458
* Increases the likelihood of the model introducing new topics.
4459
*/
4460
presence_penalty?: number;
4461
}
4462
type Ai_Cf_Qwen_Qwq_32B_Output = {
4463
/**
4464
* The generated text response from the model
4465
*/
4466
response: string;
4467
/**
4468
* Usage statistics for the inference request
4469
*/
4470
usage?: {
4471
/**
4472
* Total number of tokens in input
4473
*/
4474
prompt_tokens?: number;
4475
/**
4476
* Total number of tokens in output
4477
*/
4478
completion_tokens?: number;
4479
/**
4480
* Total number of input and output tokens
4481
*/
4482
total_tokens?: number;
4483
};
4484
/**
4485
* An array of tool calls requests made during the response generation
4486
*/
4487
tool_calls?: {
4488
/**
4489
* The arguments passed to be passed to the tool call request
4490
*/
4491
arguments?: object;
4492
/**
4493
* The name of the tool to be called
4494
*/
4495
name?: string;
4496
}[];
4497
};
4498
declare abstract class Base_Ai_Cf_Qwen_Qwq_32B {
4499
inputs: Ai_Cf_Qwen_Qwq_32B_Input;
4500
postProcessedOutputs: Ai_Cf_Qwen_Qwq_32B_Output;
4501
}
4502
type Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Input = Mistral_Small_3_1_24B_Instruct_Prompt | Mistral_Small_3_1_24B_Instruct_Messages;
4503
interface Mistral_Small_3_1_24B_Instruct_Prompt {
4504
/**
4505
* The input text prompt for the model to generate a response.
4506
*/
4507
prompt: string;
4508
/**
4509
* JSON schema that should be fulfilled for the response.
4510
*/
4511
guided_json?: object;
4512
/**
4513
* If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
4514
*/
4515
raw?: boolean;
4516
/**
4517
* If true, the response will be streamed back incrementally using SSE, Server Sent Events.
4518
*/
4519
stream?: boolean;
4520
/**
4521
* The maximum number of tokens to generate in the response.
4522
*/
4523
max_tokens?: number;
4524
/**
4525
* Controls the randomness of the output; higher values produce more random results.
4526
*/
4527
temperature?: number;
4528
/**
4529
* Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
4530
*/
4531
top_p?: number;
4532
/**
4533
* Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
4534
*/
4535
top_k?: number;
4536
/**
4537
* Random seed for reproducibility of the generation.
4538
*/
4539
seed?: number;
4540
/**
4541
* Penalty for repeated tokens; higher values discourage repetition.
4542
*/
4543
repetition_penalty?: number;
4544
/**
4545
* Decreases the likelihood of the model repeating the same lines verbatim.
4546
*/
4547
frequency_penalty?: number;
4548
/**
4549
* Increases the likelihood of the model introducing new topics.
4550
*/
4551
presence_penalty?: number;
4552
}
4553
interface Mistral_Small_3_1_24B_Instruct_Messages {
4554
/**
4555
* An array of message objects representing the conversation history.
4556
*/
4557
messages: {
4558
/**
4559
* The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
4560
*/
4561
role?: string;
4562
/**
4563
* The tool call id. Must be supplied for tool calls for Mistral-3. If you don't know what to put here you can fall back to 000000001
4564
*/
4565
tool_call_id?: string;
4566
content?: string | {
4567
/**
4568
* Type of the content provided
4569
*/
4570
type?: string;
4571
text?: string;
4572
image_url?: {
4573
/**
4574
* image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
4575
*/
4576
url?: string;
4577
};
4578
}[] | {
4579
/**
4580
* Type of the content provided
4581
*/
4582
type?: string;
4583
text?: string;
4584
image_url?: {
4585
/**
4586
* image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
4587
*/
4588
url?: string;
4589
};
4590
};
4591
}[];
4592
functions?: {
4593
name: string;
4594
code: string;
4595
}[];
4596
/**
4597
* A list of tools available for the assistant to use.
4598
*/
4599
tools?: ({
4600
/**
4601
* The name of the tool. More descriptive the better.
4602
*/
4603
name: string;
4604
/**
4605
* A brief description of what the tool does.
4606
*/
4607
description: string;
4608
/**
4609
* Schema defining the parameters accepted by the tool.
4610
*/
4611
parameters: {
4612
/**
4613
* The type of the parameters object (usually 'object').
4614
*/
4615
type: string;
4616
/**
4617
* List of required parameter names.
4618
*/
4619
required?: string[];
4620
/**
4621
* Definitions of each parameter.
4622
*/
4623
properties: {
4624
[k: string]: {
4625
/**
4626
* The data type of the parameter.
4627
*/
4628
type: string;
4629
/**
4630
* A description of the expected parameter.
4631
*/
4632
description: string;
4633
};
4634
};
4635
};
4636
} | {
4637
/**
4638
* Specifies the type of tool (e.g., 'function').
4639
*/
4640
type: string;
4641
/**
4642
* Details of the function tool.
4643
*/
4644
function: {
4645
/**
4646
* The name of the function.
4647
*/
4648
name: string;
4649
/**
4650
* A brief description of what the function does.
4651
*/
4652
description: string;
4653
/**
4654
* Schema defining the parameters accepted by the function.
4655
*/
4656
parameters: {
4657
/**
4658
* The type of the parameters object (usually 'object').
4659
*/
4660
type: string;
4661
/**
4662
* List of required parameter names.
4663
*/
4664
required?: string[];
4665
/**
4666
* Definitions of each parameter.
4667
*/
4668
properties: {
4669
[k: string]: {
4670
/**
4671
* The data type of the parameter.
4672
*/
4673
type: string;
4674
/**
4675
* A description of the expected parameter.
4676
*/
4677
description: string;
4678
};
4679
};
4680
};
4681
};
4682
})[];
4683
/**
4684
* JSON schema that should be fufilled for the response.
4685
*/
4686
guided_json?: object;
4687
/**
4688
* If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
4689
*/
4690
raw?: boolean;
4691
/**
4692
* If true, the response will be streamed back incrementally using SSE, Server Sent Events.
4693
*/
4694
stream?: boolean;
4695
/**
4696
* The maximum number of tokens to generate in the response.
4697
*/
4698
max_tokens?: number;
4699
/**
4700
* Controls the randomness of the output; higher values produce more random results.
4701
*/
4702
temperature?: number;
4703
/**
4704
* Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
4705
*/
4706
top_p?: number;
4707
/**
4708
* Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
4709
*/
4710
top_k?: number;
4711
/**
4712
* Random seed for reproducibility of the generation.
4713
*/
4714
seed?: number;
4715
/**
4716
* Penalty for repeated tokens; higher values discourage repetition.
4717
*/
4718
repetition_penalty?: number;
4719
/**
4720
* Decreases the likelihood of the model repeating the same lines verbatim.
4721
*/
4722
frequency_penalty?: number;
4723
/**
4724
* Increases the likelihood of the model introducing new topics.
4725
*/
4726
presence_penalty?: number;
4727
}
4728
type Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Output = {
4729
/**
4730
* The generated text response from the model
4731
*/
4732
response: string;
4733
/**
4734
* Usage statistics for the inference request
4735
*/
4736
usage?: {
4737
/**
4738
* Total number of tokens in input
4739
*/
4740
prompt_tokens?: number;
4741
/**
4742
* Total number of tokens in output
4743
*/
4744
completion_tokens?: number;
4745
/**
4746
* Total number of input and output tokens
4747
*/
4748
total_tokens?: number;
4749
};
4750
/**
4751
* An array of tool calls requests made during the response generation
4752
*/
4753
tool_calls?: {
4754
/**
4755
* The arguments passed to be passed to the tool call request
4756
*/
4757
arguments?: object;
4758
/**
4759
* The name of the tool to be called
4760
*/
4761
name?: string;
4762
}[];
4763
};
4764
declare abstract class Base_Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct {
4765
inputs: Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Input;
4766
postProcessedOutputs: Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Output;
4767
}
4768
type Ai_Cf_Google_Gemma_3_12B_It_Input = Google_Gemma_3_12B_It_Prompt | Google_Gemma_3_12B_It_Messages;
4769
interface Google_Gemma_3_12B_It_Prompt {
4770
/**
4771
* The input text prompt for the model to generate a response.
4772
*/
4773
prompt: string;
4774
/**
4775
* JSON schema that should be fufilled for the response.
4776
*/
4777
guided_json?: object;
4778
/**
4779
* If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
4780
*/
4781
raw?: boolean;
4782
/**
4783
* If true, the response will be streamed back incrementally using SSE, Server Sent Events.
4784
*/
4785
stream?: boolean;
4786
/**
4787
* The maximum number of tokens to generate in the response.
4788
*/
4789
max_tokens?: number;
4790
/**
4791
* Controls the randomness of the output; higher values produce more random results.
4792
*/
4793
temperature?: number;
4794
/**
4795
* Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
4796
*/
4797
top_p?: number;
4798
/**
4799
* Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
4800
*/
4801
top_k?: number;
4802
/**
4803
* Random seed for reproducibility of the generation.
4804
*/
4805
seed?: number;
4806
/**
4807
* Penalty for repeated tokens; higher values discourage repetition.
4808
*/
4809
repetition_penalty?: number;
4810
/**
4811
* Decreases the likelihood of the model repeating the same lines verbatim.
4812
*/
4813
frequency_penalty?: number;
4814
/**
4815
* Increases the likelihood of the model introducing new topics.
4816
*/
4817
presence_penalty?: number;
4818
}
4819
interface Google_Gemma_3_12B_It_Messages {
4820
/**
4821
* An array of message objects representing the conversation history.
4822
*/
4823
messages: {
4824
/**
4825
* The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
4826
*/
4827
role?: string;
4828
content?: string | {
4829
/**
4830
* Type of the content provided
4831
*/
4832
type?: string;
4833
text?: string;
4834
image_url?: {
4835
/**
4836
* image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
4837
*/
4838
url?: string;
4839
};
4840
}[] | {
4841
/**
4842
* Type of the content provided
4843
*/
4844
type?: string;
4845
text?: string;
4846
image_url?: {
4847
/**
4848
* image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
4849
*/
4850
url?: string;
4851
};
4852
};
4853
}[];
4854
functions?: {
4855
name: string;
4856
code: string;
4857
}[];
4858
/**
4859
* A list of tools available for the assistant to use.
4860
*/
4861
tools?: ({
4862
/**
4863
* The name of the tool. More descriptive the better.
4864
*/
4865
name: string;
4866
/**
4867
* A brief description of what the tool does.
4868
*/
4869
description: string;
4870
/**
4871
* Schema defining the parameters accepted by the tool.
4872
*/
4873
parameters: {
4874
/**
4875
* The type of the parameters object (usually 'object').
4876
*/
4877
type: string;
4878
/**
4879
* List of required parameter names.
4880
*/
4881
required?: string[];
4882
/**
4883
* Definitions of each parameter.
4884
*/
4885
properties: {
4886
[k: string]: {
4887
/**
4888
* The data type of the parameter.
4889
*/
4890
type: string;
4891
/**
4892
* A description of the expected parameter.
4893
*/
4894
description: string;
4895
};
4896
};
4897
};
4898
} | {
4899
/**
4900
* Specifies the type of tool (e.g., 'function').
4901
*/
4902
type: string;
4903
/**
4904
* Details of the function tool.
4905
*/
4906
function: {
4907
/**
4908
* The name of the function.
4909
*/
4910
name: string;
4911
/**
4912
* A brief description of what the function does.
4913
*/
4914
description: string;
4915
/**
4916
* Schema defining the parameters accepted by the function.
4917
*/
4918
parameters: {
4919
/**
4920
* The type of the parameters object (usually 'object').
4921
*/
4922
type: string;
4923
/**
4924
* List of required parameter names.
4925
*/
4926
required?: string[];
4927
/**
4928
* Definitions of each parameter.
4929
*/
4930
properties: {
4931
[k: string]: {
4932
/**
4933
* The data type of the parameter.
4934
*/
4935
type: string;
4936
/**
4937
* A description of the expected parameter.
4938
*/
4939
description: string;
4940
};
4941
};
4942
};
4943
};
4944
})[];
4945
/**
4946
* JSON schema that should be fufilled for the response.
4947
*/
4948
guided_json?: object;
4949
/**
4950
* If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
4951
*/
4952
raw?: boolean;
4953
/**
4954
* If true, the response will be streamed back incrementally using SSE, Server Sent Events.
4955
*/
4956
stream?: boolean;
4957
/**
4958
* The maximum number of tokens to generate in the response.
4959
*/
4960
max_tokens?: number;
4961
/**
4962
* Controls the randomness of the output; higher values produce more random results.
4963
*/
4964
temperature?: number;
4965
/**
4966
* Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
4967
*/
4968
top_p?: number;
4969
/**
4970
* Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
4971
*/
4972
top_k?: number;
4973
/**
4974
* Random seed for reproducibility of the generation.
4975
*/
4976
seed?: number;
4977
/**
4978
* Penalty for repeated tokens; higher values discourage repetition.
4979
*/
4980
repetition_penalty?: number;
4981
/**
4982
* Decreases the likelihood of the model repeating the same lines verbatim.
4983
*/
4984
frequency_penalty?: number;
4985
/**
4986
* Increases the likelihood of the model introducing new topics.
4987
*/
4988
presence_penalty?: number;
4989
}
4990
type Ai_Cf_Google_Gemma_3_12B_It_Output = {
4991
/**
4992
* The generated text response from the model
4993
*/
4994
response: string;
4995
/**
4996
* Usage statistics for the inference request
4997
*/
4998
usage?: {
4999
/**
5000
* Total number of tokens in input
5001
*/
5002
prompt_tokens?: number;
5003
/**
5004
* Total number of tokens in output
5005
*/
5006
completion_tokens?: number;
5007
/**
5008
* Total number of input and output tokens
5009
*/
5010
total_tokens?: number;
5011
};
5012
/**
5013
* An array of tool calls requests made during the response generation
5014
*/
5015
tool_calls?: {
5016
/**
5017
* The arguments passed to be passed to the tool call request
5018
*/
5019
arguments?: object;
5020
/**
5021
* The name of the tool to be called
5022
*/
5023
name?: string;
5024
}[];
5025
};
5026
declare abstract class Base_Ai_Cf_Google_Gemma_3_12B_It {
5027
inputs: Ai_Cf_Google_Gemma_3_12B_It_Input;
5028
postProcessedOutputs: Ai_Cf_Google_Gemma_3_12B_It_Output;
5029
}
5030
type Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Input = Ai_Cf_Meta_Llama_4_Prompt | Ai_Cf_Meta_Llama_4_Messages | Ai_Cf_Meta_Llama_4_Async_Batch;
5031
interface Ai_Cf_Meta_Llama_4_Prompt {
5032
/**
5033
* The input text prompt for the model to generate a response.
5034
*/
5035
prompt: string;
5036
/**
5037
* JSON schema that should be fulfilled for the response.
5038
*/
5039
guided_json?: object;
5040
response_format?: JSONMode;
5041
/**
5042
* If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
5043
*/
5044
raw?: boolean;
5045
/**
5046
* If true, the response will be streamed back incrementally using SSE, Server Sent Events.
5047
*/
5048
stream?: boolean;
5049
/**
5050
* The maximum number of tokens to generate in the response.
5051
*/
5052
max_tokens?: number;
5053
/**
5054
* Controls the randomness of the output; higher values produce more random results.
5055
*/
5056
temperature?: number;
5057
/**
5058
* Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
5059
*/
5060
top_p?: number;
5061
/**
5062
* Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
5063
*/
5064
top_k?: number;
5065
/**
5066
* Random seed for reproducibility of the generation.
5067
*/
5068
seed?: number;
5069
/**
5070
* Penalty for repeated tokens; higher values discourage repetition.
5071
*/
5072
repetition_penalty?: number;
5073
/**
5074
* Decreases the likelihood of the model repeating the same lines verbatim.
5075
*/
5076
frequency_penalty?: number;
5077
/**
5078
* Increases the likelihood of the model introducing new topics.
5079
*/
5080
presence_penalty?: number;
5081
}
5082
interface Ai_Cf_Meta_Llama_4_Messages {
5083
/**
5084
* An array of message objects representing the conversation history.
5085
*/
5086
messages: {
5087
/**
5088
* The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
5089
*/
5090
role?: string;
5091
/**
5092
* The tool call id. If you don't know what to put here you can fall back to 000000001
5093
*/
5094
tool_call_id?: string;
5095
content?: string | {
5096
/**
5097
* Type of the content provided
5098
*/
5099
type?: string;
5100
text?: string;
5101
image_url?: {
5102
/**
5103
* image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
5104
*/
5105
url?: string;
5106
};
5107
}[] | {
5108
/**
5109
* Type of the content provided
5110
*/
5111
type?: string;
5112
text?: string;
5113
image_url?: {
5114
/**
5115
* image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
5116
*/
5117
url?: string;
5118
};
5119
};
5120
}[];
5121
functions?: {
5122
name: string;
5123
code: string;
5124
}[];
5125
/**
5126
* A list of tools available for the assistant to use.
5127
*/
5128
tools?: ({
5129
/**
5130
* The name of the tool. More descriptive the better.
5131
*/
5132
name: string;
5133
/**
5134
* A brief description of what the tool does.
5135
*/
5136
description: string;
5137
/**
5138
* Schema defining the parameters accepted by the tool.
5139
*/
5140
parameters: {
5141
/**
5142
* The type of the parameters object (usually 'object').
5143
*/
5144
type: string;
5145
/**
5146
* List of required parameter names.
5147
*/
5148
required?: string[];
5149
/**
5150
* Definitions of each parameter.
5151
*/
5152
properties: {
5153
[k: string]: {
5154
/**
5155
* The data type of the parameter.
5156
*/
5157
type: string;
5158
/**
5159
* A description of the expected parameter.
5160
*/
5161
description: string;
5162
};
5163
};
5164
};
5165
} | {
5166
/**
5167
* Specifies the type of tool (e.g., 'function').
5168
*/
5169
type: string;
5170
/**
5171
* Details of the function tool.
5172
*/
5173
function: {
5174
/**
5175
* The name of the function.
5176
*/
5177
name: string;
5178
/**
5179
* A brief description of what the function does.
5180
*/
5181
description: string;
5182
/**
5183
* Schema defining the parameters accepted by the function.
5184
*/
5185
parameters: {
5186
/**
5187
* The type of the parameters object (usually 'object').
5188
*/
5189
type: string;
5190
/**
5191
* List of required parameter names.
5192
*/
5193
required?: string[];
5194
/**
5195
* Definitions of each parameter.
5196
*/
5197
properties: {
5198
[k: string]: {
5199
/**
5200
* The data type of the parameter.
5201
*/
5202
type: string;
5203
/**
5204
* A description of the expected parameter.
5205
*/
5206
description: string;
5207
};
5208
};
5209
};
5210
};
5211
})[];
5212
response_format?: JSONMode;
5213
/**
5214
* JSON schema that should be fufilled for the response.
5215
*/
5216
guided_json?: object;
5217
/**
5218
* If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
5219
*/
5220
raw?: boolean;
5221
/**
5222
* If true, the response will be streamed back incrementally using SSE, Server Sent Events.
5223
*/
5224
stream?: boolean;
5225
/**
5226
* The maximum number of tokens to generate in the response.
5227
*/
5228
max_tokens?: number;
5229
/**
5230
* Controls the randomness of the output; higher values produce more random results.
5231
*/
5232
temperature?: number;
5233
/**
5234
* Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
5235
*/
5236
top_p?: number;
5237
/**
5238
* Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
5239
*/
5240
top_k?: number;
5241
/**
5242
* Random seed for reproducibility of the generation.
5243
*/
5244
seed?: number;
5245
/**
5246
* Penalty for repeated tokens; higher values discourage repetition.
5247
*/
5248
repetition_penalty?: number;
5249
/**
5250
* Decreases the likelihood of the model repeating the same lines verbatim.
5251
*/
5252
frequency_penalty?: number;
5253
/**
5254
* Increases the likelihood of the model introducing new topics.
5255
*/
5256
presence_penalty?: number;
5257
}
5258
interface Ai_Cf_Meta_Llama_4_Async_Batch {
5259
requests: (Ai_Cf_Meta_Llama_4_Prompt_Inner | Ai_Cf_Meta_Llama_4_Messages_Inner)[];
5260
}
5261
interface Ai_Cf_Meta_Llama_4_Prompt_Inner {
5262
/**
5263
* The input text prompt for the model to generate a response.
5264
*/
5265
prompt: string;
5266
/**
5267
* JSON schema that should be fulfilled for the response.
5268
*/
5269
guided_json?: object;
5270
response_format?: JSONMode;
5271
/**
5272
* If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
5273
*/
5274
raw?: boolean;
5275
/**
5276
* If true, the response will be streamed back incrementally using SSE, Server Sent Events.
5277
*/
5278
stream?: boolean;
5279
/**
5280
* The maximum number of tokens to generate in the response.
5281
*/
5282
max_tokens?: number;
5283
/**
5284
* Controls the randomness of the output; higher values produce more random results.
5285
*/
5286
temperature?: number;
5287
/**
5288
* Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
5289
*/
5290
top_p?: number;
5291
/**
5292
* Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
5293
*/
5294
top_k?: number;
5295
/**
5296
* Random seed for reproducibility of the generation.
5297
*/
5298
seed?: number;
5299
/**
5300
* Penalty for repeated tokens; higher values discourage repetition.
5301
*/
5302
repetition_penalty?: number;
5303
/**
5304
* Decreases the likelihood of the model repeating the same lines verbatim.
5305
*/
5306
frequency_penalty?: number;
5307
/**
5308
* Increases the likelihood of the model introducing new topics.
5309
*/
5310
presence_penalty?: number;
5311
}
5312
interface Ai_Cf_Meta_Llama_4_Messages_Inner {
5313
/**
5314
* An array of message objects representing the conversation history.
5315
*/
5316
messages: {
5317
/**
5318
* The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
5319
*/
5320
role?: string;
5321
/**
5322
* The tool call id. If you don't know what to put here you can fall back to 000000001
5323
*/
5324
tool_call_id?: string;
5325
content?: string | {
5326
/**
5327
* Type of the content provided
5328
*/
5329
type?: string;
5330
text?: string;
5331
image_url?: {
5332
/**
5333
* image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
5334
*/
5335
url?: string;
5336
};
5337
}[] | {
5338
/**
5339
* Type of the content provided
5340
*/
5341
type?: string;
5342
text?: string;
5343
image_url?: {
5344
/**
5345
* image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
5346
*/
5347
url?: string;
5348
};
5349
};
5350
}[];
5351
functions?: {
5352
name: string;
5353
code: string;
5354
}[];
5355
/**
5356
* A list of tools available for the assistant to use.
5357
*/
5358
tools?: ({
5359
/**
5360
* The name of the tool. More descriptive the better.
5361
*/
5362
name: string;
5363
/**
5364
* A brief description of what the tool does.
5365
*/
5366
description: string;
5367
/**
5368
* Schema defining the parameters accepted by the tool.
5369
*/
5370
parameters: {
5371
/**
5372
* The type of the parameters object (usually 'object').
5373
*/
5374
type: string;
5375
/**
5376
* List of required parameter names.
5377
*/
5378
required?: string[];
5379
/**
5380
* Definitions of each parameter.
5381
*/
5382
properties: {
5383
[k: string]: {
5384
/**
5385
* The data type of the parameter.
5386
*/
5387
type: string;
5388
/**
5389
* A description of the expected parameter.
5390
*/
5391
description: string;
5392
};
5393
};
5394
};
5395
} | {
5396
/**
5397
* Specifies the type of tool (e.g., 'function').
5398
*/
5399
type: string;
5400
/**
5401
* Details of the function tool.
5402
*/
5403
function: {
5404
/**
5405
* The name of the function.
5406
*/
5407
name: string;
5408
/**
5409
* A brief description of what the function does.
5410
*/
5411
description: string;
5412
/**
5413
* Schema defining the parameters accepted by the function.
5414
*/
5415
parameters: {
5416
/**
5417
* The type of the parameters object (usually 'object').
5418
*/
5419
type: string;
5420
/**
5421
* List of required parameter names.
5422
*/
5423
required?: string[];
5424
/**
5425
* Definitions of each parameter.
5426
*/
5427
properties: {
5428
[k: string]: {
5429
/**
5430
* The data type of the parameter.
5431
*/
5432
type: string;
5433
/**
5434
* A description of the expected parameter.
5435
*/
5436
description: string;
5437
};
5438
};
5439
};
5440
};
5441
})[];
5442
response_format?: JSONMode;
5443
/**
5444
* JSON schema that should be fufilled for the response.
5445
*/
5446
guided_json?: object;
5447
/**
5448
* If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
5449
*/
5450
raw?: boolean;
5451
/**
5452
* If true, the response will be streamed back incrementally using SSE, Server Sent Events.
5453
*/
5454
stream?: boolean;
5455
/**
5456
* The maximum number of tokens to generate in the response.
5457
*/
5458
max_tokens?: number;
5459
/**
5460
* Controls the randomness of the output; higher values produce more random results.
5461
*/
5462
temperature?: number;
5463
/**
5464
* Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
5465
*/
5466
top_p?: number;
5467
/**
5468
* Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
5469
*/
5470
top_k?: number;
5471
/**
5472
* Random seed for reproducibility of the generation.
5473
*/
5474
seed?: number;
5475
/**
5476
* Penalty for repeated tokens; higher values discourage repetition.
5477
*/
5478
repetition_penalty?: number;
5479
/**
5480
* Decreases the likelihood of the model repeating the same lines verbatim.
5481
*/
5482
frequency_penalty?: number;
5483
/**
5484
* Increases the likelihood of the model introducing new topics.
5485
*/
5486
presence_penalty?: number;
5487
}
5488
type Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Output = {
5489
/**
5490
* The generated text response from the model
5491
*/
5492
response: string;
5493
/**
5494
* Usage statistics for the inference request
5495
*/
5496
usage?: {
5497
/**
5498
* Total number of tokens in input
5499
*/
5500
prompt_tokens?: number;
5501
/**
5502
* Total number of tokens in output
5503
*/
5504
completion_tokens?: number;
5505
/**
5506
* Total number of input and output tokens
5507
*/
5508
total_tokens?: number;
5509
};
5510
/**
5511
* An array of tool calls requests made during the response generation
5512
*/
5513
tool_calls?: {
5514
/**
5515
* The tool call id.
5516
*/
5517
id?: string;
5518
/**
5519
* Specifies the type of tool (e.g., 'function').
5520
*/
5521
type?: string;
5522
/**
5523
* Details of the function tool.
5524
*/
5525
function?: {
5526
/**
5527
* The name of the tool to be called
5528
*/
5529
name?: string;
5530
/**
5531
* The arguments passed to be passed to the tool call request
5532
*/
5533
arguments?: object;
5534
};
5535
}[];
5536
};
5537
declare abstract class Base_Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct {
5538
inputs: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Input;
5539
postProcessedOutputs: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Output;
5540
}
5541
interface Ai_Cf_Deepgram_Nova_3_Input {
5542
audio: {
5543
body: object;
5544
contentType: string;
5545
};
5546
/**
5547
* Sets how the model will interpret strings submitted to the custom_topic param. When strict, the model will only return topics submitted using the custom_topic param. When extended, the model will return its own detected topics in addition to those submitted using the custom_topic param.
5548
*/
5549
custom_topic_mode?: "extended" | "strict";
5550
/**
5551
* Custom topics you want the model to detect within your input audio or text if present Submit up to 100
5552
*/
5553
custom_topic?: string;
5554
/**
5555
* Sets how the model will interpret intents submitted to the custom_intent param. When strict, the model will only return intents submitted using the custom_intent param. When extended, the model will return its own detected intents in addition those submitted using the custom_intents param
5556
*/
5557
custom_intent_mode?: "extended" | "strict";
5558
/**
5559
* Custom intents you want the model to detect within your input audio if present
5560
*/
5561
custom_intent?: string;
5562
/**
5563
* Identifies and extracts key entities from content in submitted audio
5564
*/
5565
detect_entities?: boolean;
5566
/**
5567
* Identifies the dominant language spoken in submitted audio
5568
*/
5569
detect_language?: boolean;
5570
/**
5571
* Recognize speaker changes. Each word in the transcript will be assigned a speaker number starting at 0
5572
*/
5573
diarize?: boolean;
5574
/**
5575
* Identify and extract key entities from content in submitted audio
5576
*/
5577
dictation?: boolean;
5578
/**
5579
* Specify the expected encoding of your submitted audio
5580
*/
5581
encoding?: "linear16" | "flac" | "mulaw" | "amr-nb" | "amr-wb" | "opus" | "speex" | "g729";
5582
/**
5583
* Arbitrary key-value pairs that are attached to the API response for usage in downstream processing
5584
*/
5585
extra?: string;
5586
/**
5587
* Filler Words can help transcribe interruptions in your audio, like 'uh' and 'um'
5588
*/
5589
filler_words?: boolean;
5590
/**
5591
* Key term prompting can boost or suppress specialized terminology and brands.
5592
*/
5593
keyterm?: string;
5594
/**
5595
* Keywords can boost or suppress specialized terminology and brands.
5596
*/
5597
keywords?: string;
5598
/**
5599
* The BCP-47 language tag that hints at the primary spoken language. Depending on the Model and API endpoint you choose only certain languages are available.
5600
*/
5601
language?: string;
5602
/**
5603
* Spoken measurements will be converted to their corresponding abbreviations.
5604
*/
5605
measurements?: boolean;
5606
/**
5607
* Opts out requests from the Deepgram Model Improvement Program. Refer to our Docs for pricing impacts before setting this to true. https://dpgr.am/deepgram-mip.
5608
*/
5609
mip_opt_out?: boolean;
5610
/**
5611
* Mode of operation for the model representing broad area of topic that will be talked about in the supplied audio
5612
*/
5613
mode?: "general" | "medical" | "finance";
5614
/**
5615
* Transcribe each audio channel independently.
5616
*/
5617
multichannel?: boolean;
5618
/**
5619
* Numerals converts numbers from written format to numerical format.
5620
*/
5621
numerals?: boolean;
5622
/**
5623
* Splits audio into paragraphs to improve transcript readability.
5624
*/
5625
paragraphs?: boolean;
5626
/**
5627
* Profanity Filter looks for recognized profanity and converts it to the nearest recognized non-profane word or removes it from the transcript completely.
5628
*/
5629
profanity_filter?: boolean;
5630
/**
5631
* Add punctuation and capitalization to the transcript.
5632
*/
5633
punctuate?: boolean;
5634
/**
5635
* Redaction removes sensitive information from your transcripts.
5636
*/
5637
redact?: string;
5638
/**
5639
* Search for terms or phrases in submitted audio and replaces them.
5640
*/
5641
replace?: string;
5642
/**
5643
* Search for terms or phrases in submitted audio.
5644
*/
5645
search?: string;
5646
/**
5647
* Recognizes the sentiment throughout a transcript or text.
5648
*/
5649
sentiment?: boolean;
5650
/**
5651
* Apply formatting to transcript output. When set to true, additional formatting will be applied to transcripts to improve readability.
5652
*/
5653
smart_format?: boolean;
5654
/**
5655
* Detect topics throughout a transcript or text.
5656
*/
5657
topics?: boolean;
5658
/**
5659
* Segments speech into meaningful semantic units.
5660
*/
5661
utterances?: boolean;
5662
/**
5663
* Seconds to wait before detecting a pause between words in submitted audio.
5664
*/
5665
utt_split?: number;
5666
/**
5667
* The number of channels in the submitted audio
5668
*/
5669
channels?: number;
5670
/**
5671
* Specifies whether the streaming endpoint should provide ongoing transcription updates as more audio is received. When set to true, the endpoint sends continuous updates, meaning transcription results may evolve over time. Note: Supported only for webosockets.
5672
*/
5673
interim_results?: boolean;
5674
/**
5675
* Indicates how long model will wait to detect whether a speaker has finished speaking or pauses for a significant period of time. When set to a value, the streaming endpoint immediately finalizes the transcription for the processed time range and returns the transcript with a speech_final parameter set to true. Can also be set to false to disable endpointing
5676
*/
5677
endpointing?: string;
5678
/**
5679
* Indicates that speech has started. You'll begin receiving Speech Started messages upon speech starting. Note: Supported only for webosockets.
5680
*/
5681
vad_events?: boolean;
5682
/**
5683
* Indicates how long model will wait to send an UtteranceEnd message after a word has been transcribed. Use with interim_results. Note: Supported only for webosockets.
5684
*/
5685
utterance_end_ms?: boolean;
5686
}
5687
interface Ai_Cf_Deepgram_Nova_3_Output {
5688
results?: {
5689
channels?: {
5690
alternatives?: {
5691
confidence?: number;
5692
transcript?: string;
5693
words?: {
5694
confidence?: number;
5695
end?: number;
5696
start?: number;
5697
word?: string;
5698
}[];
5699
}[];
5700
}[];
5701
summary?: {
5702
result?: string;
5703
short?: string;
5704
};
5705
sentiments?: {
5706
segments?: {
5707
text?: string;
5708
start_word?: number;
5709
end_word?: number;
5710
sentiment?: string;
5711
sentiment_score?: number;
5712
}[];
5713
average?: {
5714
sentiment?: string;
5715
sentiment_score?: number;
5716
};
5717
};
5718
};
5719
}
5720
declare abstract class Base_Ai_Cf_Deepgram_Nova_3 {
5721
inputs: Ai_Cf_Deepgram_Nova_3_Input;
5722
postProcessedOutputs: Ai_Cf_Deepgram_Nova_3_Output;
5723
}
5724
type Ai_Cf_Pipecat_Ai_Smart_Turn_V2_Input = {
5725
/**
5726
* readable stream with audio data and content-type specified for that data
5727
*/
5728
audio: {
5729
body: object;
5730
contentType: string;
5731
};
5732
/**
5733
* type of data PCM data that's sent to the inference server as raw array
5734
*/
5735
dtype?: "uint8" | "float32" | "float64";
5736
} | {
5737
/**
5738
* base64 encoded audio data
5739
*/
5740
audio: string;
5741
/**
5742
* type of data PCM data that's sent to the inference server as raw array
5743
*/
5744
dtype?: "uint8" | "float32" | "float64";
5745
};
5746
interface Ai_Cf_Pipecat_Ai_Smart_Turn_V2_Output {
5747
/**
5748
* if true, end-of-turn was detected
5749
*/
5750
is_complete?: boolean;
5751
/**
5752
* probability of the end-of-turn detection
5753
*/
5754
probability?: number;
5755
}
5756
declare abstract class Base_Ai_Cf_Pipecat_Ai_Smart_Turn_V2 {
5757
inputs: Ai_Cf_Pipecat_Ai_Smart_Turn_V2_Input;
5758
postProcessedOutputs: Ai_Cf_Pipecat_Ai_Smart_Turn_V2_Output;
5759
}
5760
type Ai_Cf_Openai_Gpt_Oss_120B_Input = GPT_OSS_120B_Responses | GPT_OSS_120B_Responses_Async;
5761
interface GPT_OSS_120B_Responses {
5762
/**
5763
* Responses API Input messages. Refer to OpenAI Responses API docs to learn more about supported content types
5764
*/
5765
input: string | unknown[];
5766
reasoning?: {
5767
/**
5768
* Constrains effort on reasoning for reasoning models. Currently supported values are low, medium, and high. Reducing reasoning effort can result in faster responses and fewer tokens used on reasoning in a response.
5769
*/
5770
effort?: "low" | "medium" | "high";
5771
/**
5772
* A summary of the reasoning performed by the model. This can be useful for debugging and understanding the model's reasoning process. One of auto, concise, or detailed.
5773
*/
5774
summary?: "auto" | "concise" | "detailed";
5775
};
5776
}
5777
interface GPT_OSS_120B_Responses_Async {
5778
requests: {
5779
/**
5780
* Responses API Input messages. Refer to OpenAI Responses API docs to learn more about supported content types
5781
*/
5782
input: string | unknown[];
5783
reasoning?: {
5784
/**
5785
* Constrains effort on reasoning for reasoning models. Currently supported values are low, medium, and high. Reducing reasoning effort can result in faster responses and fewer tokens used on reasoning in a response.
5786
*/
5787
effort?: "low" | "medium" | "high";
5788
/**
5789
* A summary of the reasoning performed by the model. This can be useful for debugging and understanding the model's reasoning process. One of auto, concise, or detailed.
5790
*/
5791
summary?: "auto" | "concise" | "detailed";
5792
};
5793
}[];
5794
}
5795
type Ai_Cf_Openai_Gpt_Oss_120B_Output = {} | (string & NonNullable<unknown>);
5796
declare abstract class Base_Ai_Cf_Openai_Gpt_Oss_120B {
5797
inputs: Ai_Cf_Openai_Gpt_Oss_120B_Input;
5798
postProcessedOutputs: Ai_Cf_Openai_Gpt_Oss_120B_Output;
5799
}
5800
type Ai_Cf_Openai_Gpt_Oss_20B_Input = GPT_OSS_20B_Responses | GPT_OSS_20B_Responses_Async;
5801
interface GPT_OSS_20B_Responses {
5802
/**
5803
* Responses API Input messages. Refer to OpenAI Responses API docs to learn more about supported content types
5804
*/
5805
input: string | unknown[];
5806
reasoning?: {
5807
/**
5808
* Constrains effort on reasoning for reasoning models. Currently supported values are low, medium, and high. Reducing reasoning effort can result in faster responses and fewer tokens used on reasoning in a response.
5809
*/
5810
effort?: "low" | "medium" | "high";
5811
/**
5812
* A summary of the reasoning performed by the model. This can be useful for debugging and understanding the model's reasoning process. One of auto, concise, or detailed.
5813
*/
5814
summary?: "auto" | "concise" | "detailed";
5815
};
5816
}
5817
interface GPT_OSS_20B_Responses_Async {
5818
requests: {
5819
/**
5820
* Responses API Input messages. Refer to OpenAI Responses API docs to learn more about supported content types
5821
*/
5822
input: string | unknown[];
5823
reasoning?: {
5824
/**
5825
* Constrains effort on reasoning for reasoning models. Currently supported values are low, medium, and high. Reducing reasoning effort can result in faster responses and fewer tokens used on reasoning in a response.
5826
*/
5827
effort?: "low" | "medium" | "high";
5828
/**
5829
* A summary of the reasoning performed by the model. This can be useful for debugging and understanding the model's reasoning process. One of auto, concise, or detailed.
5830
*/
5831
summary?: "auto" | "concise" | "detailed";
5832
};
5833
}[];
5834
}
5835
type Ai_Cf_Openai_Gpt_Oss_20B_Output = {} | (string & NonNullable<unknown>);
5836
declare abstract class Base_Ai_Cf_Openai_Gpt_Oss_20B {
5837
inputs: Ai_Cf_Openai_Gpt_Oss_20B_Input;
5838
postProcessedOutputs: Ai_Cf_Openai_Gpt_Oss_20B_Output;
5839
}
5840
interface Ai_Cf_Leonardo_Phoenix_1_0_Input {
5841
/**
5842
* A text description of the image you want to generate.
5843
*/
5844
prompt: string;
5845
/**
5846
* Controls how closely the generated image should adhere to the prompt; higher values make the image more aligned with the prompt
5847
*/
5848
guidance?: number;
5849
/**
5850
* Random seed for reproducibility of the image generation
5851
*/
5852
seed?: number;
5853
/**
5854
* The height of the generated image in pixels
5855
*/
5856
height?: number;
5857
/**
5858
* The width of the generated image in pixels
5859
*/
5860
width?: number;
5861
/**
5862
* The number of diffusion steps; higher values can improve quality but take longer
5863
*/
5864
num_steps?: number;
5865
/**
5866
* Specify what to exclude from the generated images
5867
*/
5868
negative_prompt?: string;
5869
}
5870
/**
5871
* The generated image in JPEG format
5872
*/
5873
type Ai_Cf_Leonardo_Phoenix_1_0_Output = string;
5874
declare abstract class Base_Ai_Cf_Leonardo_Phoenix_1_0 {
5875
inputs: Ai_Cf_Leonardo_Phoenix_1_0_Input;
5876
postProcessedOutputs: Ai_Cf_Leonardo_Phoenix_1_0_Output;
5877
}
5878
interface Ai_Cf_Leonardo_Lucid_Origin_Input {
5879
/**
5880
* A text description of the image you want to generate.
5881
*/
5882
prompt: string;
5883
/**
5884
* Controls how closely the generated image should adhere to the prompt; higher values make the image more aligned with the prompt
5885
*/
5886
guidance?: number;
5887
/**
5888
* Random seed for reproducibility of the image generation
5889
*/
5890
seed?: number;
5891
/**
5892
* The height of the generated image in pixels
5893
*/
5894
height?: number;
5895
/**
5896
* The width of the generated image in pixels
5897
*/
5898
width?: number;
5899
/**
5900
* The number of diffusion steps; higher values can improve quality but take longer
5901
*/
5902
num_steps?: number;
5903
/**
5904
* The number of diffusion steps; higher values can improve quality but take longer
5905
*/
5906
steps?: number;
5907
}
5908
interface Ai_Cf_Leonardo_Lucid_Origin_Output {
5909
/**
5910
* The generated image in Base64 format.
5911
*/
5912
image?: string;
5913
}
5914
declare abstract class Base_Ai_Cf_Leonardo_Lucid_Origin {
5915
inputs: Ai_Cf_Leonardo_Lucid_Origin_Input;
5916
postProcessedOutputs: Ai_Cf_Leonardo_Lucid_Origin_Output;
5917
}
5918
interface Ai_Cf_Deepgram_Aura_1_Input {
5919
/**
5920
* Speaker used to produce the audio.
5921
*/
5922
speaker?: "angus" | "asteria" | "arcas" | "orion" | "orpheus" | "athena" | "luna" | "zeus" | "perseus" | "helios" | "hera" | "stella";
5923
/**
5924
* Encoding of the output audio.
5925
*/
5926
encoding?: "linear16" | "flac" | "mulaw" | "alaw" | "mp3" | "opus" | "aac";
5927
/**
5928
* Container specifies the file format wrapper for the output audio. The available options depend on the encoding type..
5929
*/
5930
container?: "none" | "wav" | "ogg";
5931
/**
5932
* The text content to be converted to speech
5933
*/
5934
text: string;
5935
/**
5936
* Sample Rate specifies the sample rate for the output audio. Based on the encoding, different sample rates are supported. For some encodings, the sample rate is not configurable
5937
*/
5938
sample_rate?: number;
5939
/**
5940
* The bitrate of the audio in bits per second. Choose from predefined ranges or specific values based on the encoding type.
5941
*/
5942
bit_rate?: number;
5943
}
5944
/**
5945
* The generated audio in MP3 format
5946
*/
5947
type Ai_Cf_Deepgram_Aura_1_Output = string;
5948
declare abstract class Base_Ai_Cf_Deepgram_Aura_1 {
5949
inputs: Ai_Cf_Deepgram_Aura_1_Input;
5950
postProcessedOutputs: Ai_Cf_Deepgram_Aura_1_Output;
5951
}
5952
interface AiModels {
5953
"@cf/huggingface/distilbert-sst-2-int8": BaseAiTextClassification;
5954
"@cf/stabilityai/stable-diffusion-xl-base-1.0": BaseAiTextToImage;
5955
"@cf/runwayml/stable-diffusion-v1-5-inpainting": BaseAiTextToImage;
5956
"@cf/runwayml/stable-diffusion-v1-5-img2img": BaseAiTextToImage;
5957
"@cf/lykon/dreamshaper-8-lcm": BaseAiTextToImage;
5958
"@cf/bytedance/stable-diffusion-xl-lightning": BaseAiTextToImage;
5959
"@cf/myshell-ai/melotts": BaseAiTextToSpeech;
5960
"@cf/google/embeddinggemma-300m": BaseAiTextEmbeddings;
5961
"@cf/microsoft/resnet-50": BaseAiImageClassification;
5962
"@cf/meta/llama-2-7b-chat-int8": BaseAiTextGeneration;
5963
"@cf/mistral/mistral-7b-instruct-v0.1": BaseAiTextGeneration;
5964
"@cf/meta/llama-2-7b-chat-fp16": BaseAiTextGeneration;
5965
"@hf/thebloke/llama-2-13b-chat-awq": BaseAiTextGeneration;
5966
"@hf/thebloke/mistral-7b-instruct-v0.1-awq": BaseAiTextGeneration;
5967
"@hf/thebloke/zephyr-7b-beta-awq": BaseAiTextGeneration;
5968
"@hf/thebloke/openhermes-2.5-mistral-7b-awq": BaseAiTextGeneration;
5969
"@hf/thebloke/neural-chat-7b-v3-1-awq": BaseAiTextGeneration;
5970
"@hf/thebloke/llamaguard-7b-awq": BaseAiTextGeneration;
5971
"@hf/thebloke/deepseek-coder-6.7b-base-awq": BaseAiTextGeneration;
5972
"@hf/thebloke/deepseek-coder-6.7b-instruct-awq": BaseAiTextGeneration;
5973
"@cf/deepseek-ai/deepseek-math-7b-instruct": BaseAiTextGeneration;
5974
"@cf/defog/sqlcoder-7b-2": BaseAiTextGeneration;
5975
"@cf/openchat/openchat-3.5-0106": BaseAiTextGeneration;
5976
"@cf/tiiuae/falcon-7b-instruct": BaseAiTextGeneration;
5977
"@cf/thebloke/discolm-german-7b-v1-awq": BaseAiTextGeneration;
5978
"@cf/qwen/qwen1.5-0.5b-chat": BaseAiTextGeneration;
5979
"@cf/qwen/qwen1.5-7b-chat-awq": BaseAiTextGeneration;
5980
"@cf/qwen/qwen1.5-14b-chat-awq": BaseAiTextGeneration;
5981
"@cf/tinyllama/tinyllama-1.1b-chat-v1.0": BaseAiTextGeneration;
5982
"@cf/microsoft/phi-2": BaseAiTextGeneration;
5983
"@cf/qwen/qwen1.5-1.8b-chat": BaseAiTextGeneration;
5984
"@cf/mistral/mistral-7b-instruct-v0.2-lora": BaseAiTextGeneration;
5985
"@hf/nousresearch/hermes-2-pro-mistral-7b": BaseAiTextGeneration;
5986
"@hf/nexusflow/starling-lm-7b-beta": BaseAiTextGeneration;
5987
"@hf/google/gemma-7b-it": BaseAiTextGeneration;
5988
"@cf/meta-llama/llama-2-7b-chat-hf-lora": BaseAiTextGeneration;
5989
"@cf/google/gemma-2b-it-lora": BaseAiTextGeneration;
5990
"@cf/google/gemma-7b-it-lora": BaseAiTextGeneration;
5991
"@hf/mistral/mistral-7b-instruct-v0.2": BaseAiTextGeneration;
5992
"@cf/meta/llama-3-8b-instruct": BaseAiTextGeneration;
5993
"@cf/fblgit/una-cybertron-7b-v2-bf16": BaseAiTextGeneration;
5994
"@cf/meta/llama-3-8b-instruct-awq": BaseAiTextGeneration;
5995
"@hf/meta-llama/meta-llama-3-8b-instruct": BaseAiTextGeneration;
5996
"@cf/meta/llama-3.1-8b-instruct-fp8": BaseAiTextGeneration;
5997
"@cf/meta/llama-3.1-8b-instruct-awq": BaseAiTextGeneration;
5998
"@cf/meta/llama-3.2-3b-instruct": BaseAiTextGeneration;
5999
"@cf/meta/llama-3.2-1b-instruct": BaseAiTextGeneration;
6000
"@cf/deepseek-ai/deepseek-r1-distill-qwen-32b": BaseAiTextGeneration;
6001
"@cf/facebook/bart-large-cnn": BaseAiSummarization;
6002
"@cf/llava-hf/llava-1.5-7b-hf": BaseAiImageToText;
6003
"@cf/baai/bge-base-en-v1.5": Base_Ai_Cf_Baai_Bge_Base_En_V1_5;
6004
"@cf/openai/whisper": Base_Ai_Cf_Openai_Whisper;
6005
"@cf/meta/m2m100-1.2b": Base_Ai_Cf_Meta_M2M100_1_2B;
6006
"@cf/baai/bge-small-en-v1.5": Base_Ai_Cf_Baai_Bge_Small_En_V1_5;
6007
"@cf/baai/bge-large-en-v1.5": Base_Ai_Cf_Baai_Bge_Large_En_V1_5;
6008
"@cf/unum/uform-gen2-qwen-500m": Base_Ai_Cf_Unum_Uform_Gen2_Qwen_500M;
6009
"@cf/openai/whisper-tiny-en": Base_Ai_Cf_Openai_Whisper_Tiny_En;
6010
"@cf/openai/whisper-large-v3-turbo": Base_Ai_Cf_Openai_Whisper_Large_V3_Turbo;
6011
"@cf/baai/bge-m3": Base_Ai_Cf_Baai_Bge_M3;
6012
"@cf/black-forest-labs/flux-1-schnell": Base_Ai_Cf_Black_Forest_Labs_Flux_1_Schnell;
6013
"@cf/meta/llama-3.2-11b-vision-instruct": Base_Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct;
6014
"@cf/meta/llama-3.3-70b-instruct-fp8-fast": Base_Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast;
6015
"@cf/meta/llama-guard-3-8b": Base_Ai_Cf_Meta_Llama_Guard_3_8B;
6016
"@cf/baai/bge-reranker-base": Base_Ai_Cf_Baai_Bge_Reranker_Base;
6017
"@cf/qwen/qwen2.5-coder-32b-instruct": Base_Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct;
6018
"@cf/qwen/qwq-32b": Base_Ai_Cf_Qwen_Qwq_32B;
6019
"@cf/mistralai/mistral-small-3.1-24b-instruct": Base_Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct;
6020
"@cf/google/gemma-3-12b-it": Base_Ai_Cf_Google_Gemma_3_12B_It;
6021
"@cf/meta/llama-4-scout-17b-16e-instruct": Base_Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct;
6022
"@cf/deepgram/nova-3": Base_Ai_Cf_Deepgram_Nova_3;
6023
"@cf/pipecat-ai/smart-turn-v2": Base_Ai_Cf_Pipecat_Ai_Smart_Turn_V2;
6024
"@cf/openai/gpt-oss-120b": Base_Ai_Cf_Openai_Gpt_Oss_120B;
6025
"@cf/openai/gpt-oss-20b": Base_Ai_Cf_Openai_Gpt_Oss_20B;
6026
"@cf/leonardo/phoenix-1.0": Base_Ai_Cf_Leonardo_Phoenix_1_0;
6027
"@cf/leonardo/lucid-origin": Base_Ai_Cf_Leonardo_Lucid_Origin;
6028
"@cf/deepgram/aura-1": Base_Ai_Cf_Deepgram_Aura_1;
6029
}
6030
type AiOptions = {
6031
/**
6032
* Send requests as an asynchronous batch job, only works for supported models
6033
* https://developers.cloudflare.com/workers-ai/features/batch-api
6034
*/
6035
queueRequest?: boolean;
6036
/**
6037
* Establish websocket connections, only works for supported models
6038
*/
6039
websocket?: boolean;
6040
gateway?: GatewayOptions;
6041
returnRawResponse?: boolean;
6042
prefix?: string;
6043
extraHeaders?: object;
6044
};
6045
type AiModelsSearchParams = {
6046
author?: string;
6047
hide_experimental?: boolean;
6048
page?: number;
6049
per_page?: number;
6050
search?: string;
6051
source?: number;
6052
task?: string;
6053
};
6054
type AiModelsSearchObject = {
6055
id: string;
6056
source: number;
6057
name: string;
6058
description: string;
6059
task: {
6060
id: string;
6061
name: string;
6062
description: string;
6063
};
6064
tags: string[];
6065
properties: {
6066
property_id: string;
6067
value: string;
6068
}[];
6069
};
6070
interface InferenceUpstreamError extends Error {
6071
}
6072
interface AiInternalError extends Error {
6073
}
6074
type AiModelListType = Record<string, any>;
6075
declare abstract class Ai<AiModelList extends AiModelListType = AiModels> {
6076
aiGatewayLogId: string | null;
6077
gateway(gatewayId: string): AiGateway;
6078
autorag(autoragId: string): AutoRAG;
6079
run<Name extends keyof AiModelList, Options extends AiOptions, InputOptions extends AiModelList[Name]["inputs"]>(model: Name, inputs: InputOptions, options?: Options): Promise<Options extends {
6080
returnRawResponse: true;
6081
} | {
6082
websocket: true;
6083
} ? Response : InputOptions extends {
6084
stream: true;
6085
} ? ReadableStream : AiModelList[Name]["postProcessedOutputs"]>;
6086
models(params?: AiModelsSearchParams): Promise<AiModelsSearchObject[]>;
6087
toMarkdown(): ToMarkdownService;
6088
toMarkdown(files: {
6089
name: string;
6090
blob: Blob;
6091
}[], options?: {
6092
gateway?: GatewayOptions;
6093
extraHeaders?: object;
6094
}): Promise<ConversionResponse[]>;
6095
toMarkdown(files: {
6096
name: string;
6097
blob: Blob;
6098
}, options?: {
6099
gateway?: GatewayOptions;
6100
extraHeaders?: object;
6101
}): Promise<ConversionResponse>;
6102
}
6103
type GatewayRetries = {
6104
maxAttempts?: 1 | 2 | 3 | 4 | 5;
6105
retryDelayMs?: number;
6106
backoff?: 'constant' | 'linear' | 'exponential';
6107
};
6108
type GatewayOptions = {
6109
id: string;
6110
cacheKey?: string;
6111
cacheTtl?: number;
6112
skipCache?: boolean;
6113
metadata?: Record<string, number | string | boolean | null | bigint>;
6114
collectLog?: boolean;
6115
eventId?: string;
6116
requestTimeoutMs?: number;
6117
retries?: GatewayRetries;
6118
};
6119
type UniversalGatewayOptions = Exclude<GatewayOptions, 'id'> & {
6120
/**
6121
** @deprecated
6122
*/
6123
id?: string;
6124
};
6125
type AiGatewayPatchLog = {
6126
score?: number | null;
6127
feedback?: -1 | 1 | null;
6128
metadata?: Record<string, number | string | boolean | null | bigint> | null;
6129
};
6130
type AiGatewayLog = {
6131
id: string;
6132
provider: string;
6133
model: string;
6134
model_type?: string;
6135
path: string;
6136
duration: number;
6137
request_type?: string;
6138
request_content_type?: string;
6139
status_code: number;
6140
response_content_type?: string;
6141
success: boolean;
6142
cached: boolean;
6143
tokens_in?: number;
6144
tokens_out?: number;
6145
metadata?: Record<string, number | string | boolean | null | bigint>;
6146
step?: number;
6147
cost?: number;
6148
custom_cost?: boolean;
6149
request_size: number;
6150
request_head?: string;
6151
request_head_complete: boolean;
6152
response_size: number;
6153
response_head?: string;
6154
response_head_complete: boolean;
6155
created_at: Date;
6156
};
6157
type AIGatewayProviders = 'workers-ai' | 'anthropic' | 'aws-bedrock' | 'azure-openai' | 'google-vertex-ai' | 'huggingface' | 'openai' | 'perplexity-ai' | 'replicate' | 'groq' | 'cohere' | 'google-ai-studio' | 'mistral' | 'grok' | 'openrouter' | 'deepseek' | 'cerebras' | 'cartesia' | 'elevenlabs' | 'adobe-firefly';
6158
type AIGatewayHeaders = {
6159
'cf-aig-metadata': Record<string, number | string | boolean | null | bigint> | string;
6160
'cf-aig-custom-cost': {
6161
per_token_in?: number;
6162
per_token_out?: number;
6163
} | {
6164
total_cost?: number;
6165
} | string;
6166
'cf-aig-cache-ttl': number | string;
6167
'cf-aig-skip-cache': boolean | string;
6168
'cf-aig-cache-key': string;
6169
'cf-aig-event-id': string;
6170
'cf-aig-request-timeout': number | string;
6171
'cf-aig-max-attempts': number | string;
6172
'cf-aig-retry-delay': number | string;
6173
'cf-aig-backoff': string;
6174
'cf-aig-collect-log': boolean | string;
6175
Authorization: string;
6176
'Content-Type': string;
6177
[key: string]: string | number | boolean | object;
6178
};
6179
type AIGatewayUniversalRequest = {
6180
provider: AIGatewayProviders | string; // eslint-disable-line
6181
endpoint: string;
6182
headers: Partial<AIGatewayHeaders>;
6183
query: unknown;
6184
};
6185
interface AiGatewayInternalError extends Error {
6186
}
6187
interface AiGatewayLogNotFound extends Error {
6188
}
6189
declare abstract class AiGateway {
6190
patchLog(logId: string, data: AiGatewayPatchLog): Promise<void>;
6191
getLog(logId: string): Promise<AiGatewayLog>;
6192
run(data: AIGatewayUniversalRequest | AIGatewayUniversalRequest[], options?: {
6193
gateway?: UniversalGatewayOptions;
6194
extraHeaders?: object;
6195
}): Promise<Response>;
6196
getUrl(provider?: AIGatewayProviders | string): Promise<string>; // eslint-disable-line
6197
}
6198
interface AutoRAGInternalError extends Error {
6199
}
6200
interface AutoRAGNotFoundError extends Error {
6201
}
6202
interface AutoRAGUnauthorizedError extends Error {
6203
}
6204
interface AutoRAGNameNotSetError extends Error {
6205
}
6206
type ComparisonFilter = {
6207
key: string;
6208
type: 'eq' | 'ne' | 'gt' | 'gte' | 'lt' | 'lte';
6209
value: string | number | boolean;
6210
};
6211
type CompoundFilter = {
6212
type: 'and' | 'or';
6213
filters: ComparisonFilter[];
6214
};
6215
type AutoRagSearchRequest = {
6216
query: string;
6217
filters?: CompoundFilter | ComparisonFilter;
6218
max_num_results?: number;
6219
ranking_options?: {
6220
ranker?: string;
6221
score_threshold?: number;
6222
};
6223
rewrite_query?: boolean;
6224
};
6225
type AutoRagAiSearchRequest = AutoRagSearchRequest & {
6226
stream?: boolean;
6227
system_prompt?: string;
6228
};
6229
type AutoRagAiSearchRequestStreaming = Omit<AutoRagAiSearchRequest, 'stream'> & {
6230
stream: true;
6231
};
6232
type AutoRagSearchResponse = {
6233
object: 'vector_store.search_results.page';
6234
search_query: string;
6235
data: {
6236
file_id: string;
6237
filename: string;
6238
score: number;
6239
attributes: Record<string, string | number | boolean | null>;
6240
content: {
6241
type: 'text';
6242
text: string;
6243
}[];
6244
}[];
6245
has_more: boolean;
6246
next_page: string | null;
6247
};
6248
type AutoRagListResponse = {
6249
id: string;
6250
enable: boolean;
6251
type: string;
6252
source: string;
6253
vectorize_name: string;
6254
paused: boolean;
6255
status: string;
6256
}[];
6257
type AutoRagAiSearchResponse = AutoRagSearchResponse & {
6258
response: string;
6259
};
6260
declare abstract class AutoRAG {
6261
list(): Promise<AutoRagListResponse>;
6262
search(params: AutoRagSearchRequest): Promise<AutoRagSearchResponse>;
6263
aiSearch(params: AutoRagAiSearchRequestStreaming): Promise<Response>;
6264
aiSearch(params: AutoRagAiSearchRequest): Promise<AutoRagAiSearchResponse>;
6265
aiSearch(params: AutoRagAiSearchRequest): Promise<AutoRagAiSearchResponse | Response>;
6266
}
6267
interface BasicImageTransformations {
6268
/**
6269
* Maximum width in image pixels. The value must be an integer.
6270
*/
6271
width?: number;
6272
/**
6273
* Maximum height in image pixels. The value must be an integer.
6274
*/
6275
height?: number;
6276
/**
6277
* Resizing mode as a string. It affects interpretation of width and height
6278
* options:
6279
* - scale-down: Similar to contain, but the image is never enlarged. If
6280
* the image is larger than given width or height, it will be resized.
6281
* Otherwise its original size will be kept.
6282
* - contain: Resizes to maximum size that fits within the given width and
6283
* height. If only a single dimension is given (e.g. only width), the
6284
* image will be shrunk or enlarged to exactly match that dimension.
6285
* Aspect ratio is always preserved.
6286
* - cover: Resizes (shrinks or enlarges) to fill the entire area of width
6287
* and height. If the image has an aspect ratio different from the ratio
6288
* of width and height, it will be cropped to fit.
6289
* - crop: The image will be shrunk and cropped to fit within the area
6290
* specified by width and height. The image will not be enlarged. For images
6291
* smaller than the given dimensions it's the same as scale-down. For
6292
* images larger than the given dimensions, it's the same as cover.
6293
* See also trim.
6294
* - pad: Resizes to the maximum size that fits within the given width and
6295
* height, and then fills the remaining area with a background color
6296
* (white by default). Use of this mode is not recommended, as the same
6297
* effect can be more efficiently achieved with the contain mode and the
6298
* CSS object-fit: contain property.
6299
* - squeeze: Stretches and deforms to the width and height given, even if it
6300
* breaks aspect ratio
6301
*/
6302
fit?: "scale-down" | "contain" | "cover" | "crop" | "pad" | "squeeze";
6303
/**
6304
* Image segmentation using artificial intelligence models. Sets pixels not
6305
* within selected segment area to transparent e.g "foreground" sets every
6306
* background pixel as transparent.
6307
*/
6308
segment?: "foreground";
6309
/**
6310
* When cropping with fit: "cover", this defines the side or point that should
6311
* be left uncropped. The value is either a string
6312
* "left", "right", "top", "bottom", "auto", or "center" (the default),
6313
* or an object {x, y} containing focal point coordinates in the original
6314
* image expressed as fractions ranging from 0.0 (top or left) to 1.0
6315
* (bottom or right), 0.5 being the center. {fit: "cover", gravity: "top"} will
6316
* crop bottom or left and right sides as necessary, but won’t crop anything
6317
* from the top. {fit: "cover", gravity: {x:0.5, y:0.2}} will crop each side to
6318
* preserve as much as possible around a point at 20% of the height of the
6319
* source image.
6320
*/
6321
gravity?: 'face' | 'left' | 'right' | 'top' | 'bottom' | 'center' | 'auto' | 'entropy' | BasicImageTransformationsGravityCoordinates;
6322
/**
6323
* Background color to add underneath the image. Applies only to images with
6324
* transparency (such as PNG). Accepts any CSS color (#RRGGBB, rgba(…),
6325
* hsl(…), etc.)
6326
*/
6327
background?: string;
6328
/**
6329
* Number of degrees (90, 180, 270) to rotate the image by. width and height
6330
* options refer to axes after rotation.
6331
*/
6332
rotate?: 0 | 90 | 180 | 270 | 360;
6333
}
6334
interface BasicImageTransformationsGravityCoordinates {
6335
x?: number;
6336
y?: number;
6337
mode?: 'remainder' | 'box-center';
6338
}
6339
/**
6340
* In addition to the properties you can set in the RequestInit dict
6341
* that you pass as an argument to the Request constructor, you can
6342
* set certain properties of a `cf` object to control how Cloudflare
6343
* features are applied to that new Request.
6344
*
6345
* Note: Currently, these properties cannot be tested in the
6346
* playground.
6347
*/
6348
interface RequestInitCfProperties extends Record<string, unknown> {
6349
cacheEverything?: boolean;
6350
/**
6351
* A request's cache key is what determines if two requests are
6352
* "the same" for caching purposes. If a request has the same cache key
6353
* as some previous request, then we can serve the same cached response for
6354
* both. (e.g. 'some-key')
6355
*
6356
* Only available for Enterprise customers.
6357
*/
6358
cacheKey?: string;
6359
/**
6360
* This allows you to append additional Cache-Tag response headers
6361
* to the origin response without modifications to the origin server.
6362
* This will allow for greater control over the Purge by Cache Tag feature
6363
* utilizing changes only in the Workers process.
6364
*
6365
* Only available for Enterprise customers.
6366
*/
6367
cacheTags?: string[];
6368
/**
6369
* Force response to be cached for a given number of seconds. (e.g. 300)
6370
*/
6371
cacheTtl?: number;
6372
/**
6373
* Force response to be cached for a given number of seconds based on the Origin status code.
6374
* (e.g. { '200-299': 86400, '404': 1, '500-599': 0 })
6375
*/
6376
cacheTtlByStatus?: Record<string, number>;
6377
scrapeShield?: boolean;
6378
apps?: boolean;
6379
image?: RequestInitCfPropertiesImage;
6380
minify?: RequestInitCfPropertiesImageMinify;
6381
mirage?: boolean;
6382
polish?: "lossy" | "lossless" | "off";
6383
r2?: RequestInitCfPropertiesR2;
6384
/**
6385
* Redirects the request to an alternate origin server. You can use this,
6386
* for example, to implement load balancing across several origins.
6387
* (e.g.us-east.example.com)
6388
*
6389
* Note - For security reasons, the hostname set in resolveOverride must
6390
* be proxied on the same Cloudflare zone of the incoming request.
6391
* Otherwise, the setting is ignored. CNAME hosts are allowed, so to
6392
* resolve to a host under a different domain or a DNS only domain first
6393
* declare a CNAME record within your own zone’s DNS mapping to the
6394
* external hostname, set proxy on Cloudflare, then set resolveOverride
6395
* to point to that CNAME record.
6396
*/
6397
resolveOverride?: string;
6398
}
6399
interface RequestInitCfPropertiesImageDraw extends BasicImageTransformations {
6400
/**
6401
* Absolute URL of the image file to use for the drawing. It can be any of
6402
* the supported file formats. For drawing of watermarks or non-rectangular
6403
* overlays we recommend using PNG or WebP images.
6404
*/
6405
url: string;
6406
/**
6407
* Floating-point number between 0 (transparent) and 1 (opaque).
6408
* For example, opacity: 0.5 makes overlay semitransparent.
6409
*/
6410
opacity?: number;
6411
/**
6412
* - If set to true, the overlay image will be tiled to cover the entire
6413
* area. This is useful for stock-photo-like watermarks.
6414
* - If set to "x", the overlay image will be tiled horizontally only
6415
* (form a line).
6416
* - If set to "y", the overlay image will be tiled vertically only
6417
* (form a line).
6418
*/
6419
repeat?: true | "x" | "y";
6420
/**
6421
* Position of the overlay image relative to a given edge. Each property is
6422
* an offset in pixels. 0 aligns exactly to the edge. For example, left: 10
6423
* positions left side of the overlay 10 pixels from the left edge of the
6424
* image it's drawn over. bottom: 0 aligns bottom of the overlay with bottom
6425
* of the background image.
6426
*
6427
* Setting both left & right, or both top & bottom is an error.
6428
*
6429
* If no position is specified, the image will be centered.
6430
*/
6431
top?: number;
6432
left?: number;
6433
bottom?: number;
6434
right?: number;
6435
}
6436
interface RequestInitCfPropertiesImage extends BasicImageTransformations {
6437
/**
6438
* Device Pixel Ratio. Default 1. Multiplier for width/height that makes it
6439
* easier to specify higher-DPI sizes in <img srcset>.
6440
*/
6441
dpr?: number;
6442
/**
6443
* Allows you to trim your image. Takes dpr into account and is performed before
6444
* resizing or rotation.
6445
*
6446
* It can be used as:
6447
* - left, top, right, bottom - it will specify the number of pixels to cut
6448
* off each side
6449
* - width, height - the width/height you'd like to end up with - can be used
6450
* in combination with the properties above
6451
* - border - this will automatically trim the surroundings of an image based on
6452
* it's color. It consists of three properties:
6453
* - color: rgb or hex representation of the color you wish to trim (todo: verify the rgba bit)
6454
* - tolerance: difference from color to treat as color
6455
* - keep: the number of pixels of border to keep
6456
*/
6457
trim?: "border" | {
6458
top?: number;
6459
bottom?: number;
6460
left?: number;
6461
right?: number;
6462
width?: number;
6463
height?: number;
6464
border?: boolean | {
6465
color?: string;
6466
tolerance?: number;
6467
keep?: number;
6468
};
6469
};
6470
/**
6471
* Quality setting from 1-100 (useful values are in 60-90 range). Lower values
6472
* make images look worse, but load faster. The default is 85. It applies only
6473
* to JPEG and WebP images. It doesn’t have any effect on PNG.
6474
*/
6475
quality?: number | "low" | "medium-low" | "medium-high" | "high";
6476
/**
6477
* Output format to generate. It can be:
6478
* - avif: generate images in AVIF format.
6479
* - webp: generate images in Google WebP format. Set quality to 100 to get
6480
* the WebP-lossless format.
6481
* - json: instead of generating an image, outputs information about the
6482
* image, in JSON format. The JSON object will contain image size
6483
* (before and after resizing), source image’s MIME type, file size, etc.
6484
* - jpeg: generate images in JPEG format.
6485
* - png: generate images in PNG format.
6486
*/
6487
format?: "avif" | "webp" | "json" | "jpeg" | "png" | "baseline-jpeg" | "png-force" | "svg";
6488
/**
6489
* Whether to preserve animation frames from input files. Default is true.
6490
* Setting it to false reduces animations to still images. This setting is
6491
* recommended when enlarging images or processing arbitrary user content,
6492
* because large GIF animations can weigh tens or even hundreds of megabytes.
6493
* It is also useful to set anim:false when using format:"json" to get the
6494
* response quicker without the number of frames.
6495
*/
6496
anim?: boolean;
6497
/**
6498
* What EXIF data should be preserved in the output image. Note that EXIF
6499
* rotation and embedded color profiles are always applied ("baked in" into
6500
* the image), and aren't affected by this option. Note that if the Polish
6501
* feature is enabled, all metadata may have been removed already and this
6502
* option may have no effect.
6503
* - keep: Preserve most of EXIF metadata, including GPS location if there's
6504
* any.
6505
* - copyright: Only keep the copyright tag, and discard everything else.
6506
* This is the default behavior for JPEG files.
6507
* - none: Discard all invisible EXIF metadata. Currently WebP and PNG
6508
* output formats always discard metadata.
6509
*/
6510
metadata?: "keep" | "copyright" | "none";
6511
/**
6512
* Strength of sharpening filter to apply to the image. Floating-point
6513
* number between 0 (no sharpening, default) and 10 (maximum). 1.0 is a
6514
* recommended value for downscaled images.
6515
*/
6516
sharpen?: number;
6517
/**
6518
* Radius of a blur filter (approximate gaussian). Maximum supported radius
6519
* is 250.
6520
*/
6521
blur?: number;
6522
/**
6523
* Overlays are drawn in the order they appear in the array (last array
6524
* entry is the topmost layer).
6525
*/
6526
draw?: RequestInitCfPropertiesImageDraw[];
6527
/**
6528
* Fetching image from authenticated origin. Setting this property will
6529
* pass authentication headers (Authorization, Cookie, etc.) through to
6530
* the origin.
6531
*/
6532
"origin-auth"?: "share-publicly";
6533
/**
6534
* Adds a border around the image. The border is added after resizing. Border
6535
* width takes dpr into account, and can be specified either using a single
6536
* width property, or individually for each side.
6537
*/
6538
border?: {
6539
color: string;
6540
width: number;
6541
} | {
6542
color: string;
6543
top: number;
6544
right: number;
6545
bottom: number;
6546
left: number;
6547
};
6548
/**
6549
* Increase brightness by a factor. A value of 1.0 equals no change, a value
6550
* of 0.5 equals half brightness, and a value of 2.0 equals twice as bright.
6551
* 0 is ignored.
6552
*/
6553
brightness?: number;
6554
/**
6555
* Increase contrast by a factor. A value of 1.0 equals no change, a value of
6556
* 0.5 equals low contrast, and a value of 2.0 equals high contrast. 0 is
6557
* ignored.
6558
*/
6559
contrast?: number;
6560
/**
6561
* Increase exposure by a factor. A value of 1.0 equals no change, a value of
6562
* 0.5 darkens the image, and a value of 2.0 lightens the image. 0 is ignored.
6563
*/
6564
gamma?: number;
6565
/**
6566
* Increase contrast by a factor. A value of 1.0 equals no change, a value of
6567
* 0.5 equals low contrast, and a value of 2.0 equals high contrast. 0 is
6568
* ignored.
6569
*/
6570
saturation?: number;
6571
/**
6572
* Flips the images horizontally, vertically, or both. Flipping is applied before
6573
* rotation, so if you apply flip=h,rotate=90 then the image will be flipped
6574
* horizontally, then rotated by 90 degrees.
6575
*/
6576
flip?: 'h' | 'v' | 'hv';
6577
/**
6578
* Slightly reduces latency on a cache miss by selecting a
6579
* quickest-to-compress file format, at a cost of increased file size and
6580
* lower image quality. It will usually override the format option and choose
6581
* JPEG over WebP or AVIF. We do not recommend using this option, except in
6582
* unusual circumstances like resizing uncacheable dynamically-generated
6583
* images.
6584
*/
6585
compression?: "fast";
6586
}
6587
interface RequestInitCfPropertiesImageMinify {
6588
javascript?: boolean;
6589
css?: boolean;
6590
html?: boolean;
6591
}
6592
interface RequestInitCfPropertiesR2 {
6593
/**
6594
* Colo id of bucket that an object is stored in
6595
*/
6596
bucketColoId?: number;
6597
}
6598
/**
6599
* Request metadata provided by Cloudflare's edge.
6600
*/
6601
type IncomingRequestCfProperties<HostMetadata = unknown> = IncomingRequestCfPropertiesBase & IncomingRequestCfPropertiesBotManagementEnterprise & IncomingRequestCfPropertiesCloudflareForSaaSEnterprise<HostMetadata> & IncomingRequestCfPropertiesGeographicInformation & IncomingRequestCfPropertiesCloudflareAccessOrApiShield;
6602
interface IncomingRequestCfPropertiesBase extends Record<string, unknown> {
6603
/**
6604
* [ASN](https://www.iana.org/assignments/as-numbers/as-numbers.xhtml) of the incoming request.
6605
*
6606
* @example 395747
6607
*/
6608
asn?: number;
6609
/**
6610
* The organization which owns the ASN of the incoming request.
6611
*
6612
* @example "Google Cloud"
6613
*/
6614
asOrganization?: string;
6615
/**
6616
* The original value of the `Accept-Encoding` header if Cloudflare modified it.
6617
*
6618
* @example "gzip, deflate, br"
6619
*/
6620
clientAcceptEncoding?: string;
6621
/**
6622
* The number of milliseconds it took for the request to reach your worker.
6623
*
6624
* @example 22
6625
*/
6626
clientTcpRtt?: number;
6627
/**
6628
* The three-letter [IATA](https://en.wikipedia.org/wiki/IATA_airport_code)
6629
* airport code of the data center that the request hit.
6630
*
6631
* @example "DFW"
6632
*/
6633
colo: string;
6634
/**
6635
* Represents the upstream's response to a
6636
* [TCP `keepalive` message](https://tldp.org/HOWTO/TCP-Keepalive-HOWTO/overview.html)
6637
* from cloudflare.
6638
*
6639
* For workers with no upstream, this will always be `1`.
6640
*
6641
* @example 3
6642
*/
6643
edgeRequestKeepAliveStatus: IncomingRequestCfPropertiesEdgeRequestKeepAliveStatus;
6644
/**
6645
* The HTTP Protocol the request used.
6646
*
6647
* @example "HTTP/2"
6648
*/
6649
httpProtocol: string;
6650
/**
6651
* The browser-requested prioritization information in the request object.
6652
*
6653
* If no information was set, defaults to the empty string `""`
6654
*
6655
* @example "weight=192;exclusive=0;group=3;group-weight=127"
6656
* @default ""
6657
*/
6658
requestPriority: string;
6659
/**
6660
* The TLS version of the connection to Cloudflare.
6661
* In requests served over plaintext (without TLS), this property is the empty string `""`.
6662
*
6663
* @example "TLSv1.3"
6664
*/
6665
tlsVersion: string;
6666
/**
6667
* The cipher for the connection to Cloudflare.
6668
* In requests served over plaintext (without TLS), this property is the empty string `""`.
6669
*
6670
* @example "AEAD-AES128-GCM-SHA256"
6671
*/
6672
tlsCipher: string;
6673
/**
6674
* Metadata containing the [`HELLO`](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.1.2) and [`FINISHED`](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.9) messages from this request's TLS handshake.
6675
*
6676
* If the incoming request was served over plaintext (without TLS) this field is undefined.
6677
*/
6678
tlsExportedAuthenticator?: IncomingRequestCfPropertiesExportedAuthenticatorMetadata;
6679
}
6680
interface IncomingRequestCfPropertiesBotManagementBase {
6681
/**
6682
* Cloudflare’s [level of certainty](https://developers.cloudflare.com/bots/concepts/bot-score/) that a request comes from a bot,
6683
* represented as an integer percentage between `1` (almost certainly a bot) and `99` (almost certainly human).
6684
*
6685
* @example 54
6686
*/
6687
score: number;
6688
/**
6689
* A boolean value that is true if the request comes from a good bot, like Google or Bing.
6690
* Most customers choose to allow this traffic. For more details, see [Traffic from known bots](https://developers.cloudflare.com/firewall/known-issues-and-faq/#how-does-firewall-rules-handle-traffic-from-known-bots).
6691
*/
6692
verifiedBot: boolean;
6693
/**
6694
* A boolean value that is true if the request originates from a
6695
* Cloudflare-verified proxy service.
6696
*/
6697
corporateProxy: boolean;
6698
/**
6699
* A boolean value that's true if the request matches [file extensions](https://developers.cloudflare.com/bots/reference/static-resources/) for many types of static resources.
6700
*/
6701
staticResource: boolean;
6702
/**
6703
* List of IDs that correlate to the Bot Management heuristic detections made on a request (you can have multiple heuristic detections on the same request).
6704
*/
6705
detectionIds: number[];
6706
}
6707
interface IncomingRequestCfPropertiesBotManagement {
6708
/**
6709
* Results of Cloudflare's Bot Management analysis
6710
*/
6711
botManagement: IncomingRequestCfPropertiesBotManagementBase;
6712
/**
6713
* Duplicate of `botManagement.score`.
6714
*
6715
* @deprecated
6716
*/
6717
clientTrustScore: number;
6718
}
6719
interface IncomingRequestCfPropertiesBotManagementEnterprise extends IncomingRequestCfPropertiesBotManagement {
6720
/**
6721
* Results of Cloudflare's Bot Management analysis
6722
*/
6723
botManagement: IncomingRequestCfPropertiesBotManagementBase & {
6724
/**
6725
* A [JA3 Fingerprint](https://developers.cloudflare.com/bots/concepts/ja3-fingerprint/) to help profile specific SSL/TLS clients
6726
* across different destination IPs, Ports, and X509 certificates.
6727
*/
6728
ja3Hash: string;
6729
};
6730
}
6731
interface IncomingRequestCfPropertiesCloudflareForSaaSEnterprise<HostMetadata> {
6732
/**
6733
* Custom metadata set per-host in [Cloudflare for SaaS](https://developers.cloudflare.com/cloudflare-for-platforms/cloudflare-for-saas/).
6734
*
6735
* This field is only present if you have Cloudflare for SaaS enabled on your account
6736
* and you have followed the [required steps to enable it]((https://developers.cloudflare.com/cloudflare-for-platforms/cloudflare-for-saas/domain-support/custom-metadata/)).
6737
*/
6738
hostMetadata?: HostMetadata;
6739
}
6740
interface IncomingRequestCfPropertiesCloudflareAccessOrApiShield {
6741
/**
6742
* Information about the client certificate presented to Cloudflare.
6743
*
6744
* This is populated when the incoming request is served over TLS using
6745
* either Cloudflare Access or API Shield (mTLS)
6746
* and the presented SSL certificate has a valid
6747
* [Certificate Serial Number](https://ldapwiki.com/wiki/Certificate%20Serial%20Number)
6748
* (i.e., not `null` or `""`).
6749
*
6750
* Otherwise, a set of placeholder values are used.
6751
*
6752
* The property `certPresented` will be set to `"1"` when
6753
* the object is populated (i.e. the above conditions were met).
6754
*/
6755
tlsClientAuth: IncomingRequestCfPropertiesTLSClientAuth | IncomingRequestCfPropertiesTLSClientAuthPlaceholder;
6756
}
6757
/**
6758
* Metadata about the request's TLS handshake
6759
*/
6760
interface IncomingRequestCfPropertiesExportedAuthenticatorMetadata {
6761
/**
6762
* The client's [`HELLO` message](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.1.2), encoded in hexadecimal
6763
*
6764
* @example "44372ba35fa1270921d318f34c12f155dc87b682cf36a790cfaa3ba8737a1b5d"
6765
*/
6766
clientHandshake: string;
6767
/**
6768
* The server's [`HELLO` message](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.1.2), encoded in hexadecimal
6769
*
6770
* @example "44372ba35fa1270921d318f34c12f155dc87b682cf36a790cfaa3ba8737a1b5d"
6771
*/
6772
serverHandshake: string;
6773
/**
6774
* The client's [`FINISHED` message](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.9), encoded in hexadecimal
6775
*
6776
* @example "084ee802fe1348f688220e2a6040a05b2199a761f33cf753abb1b006792d3f8b"
6777
*/
6778
clientFinished: string;
6779
/**
6780
* The server's [`FINISHED` message](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.9), encoded in hexadecimal
6781
*
6782
* @example "084ee802fe1348f688220e2a6040a05b2199a761f33cf753abb1b006792d3f8b"
6783
*/
6784
serverFinished: string;
6785
}
6786
/**
6787
* Geographic data about the request's origin.
6788
*/
6789
interface IncomingRequestCfPropertiesGeographicInformation {
6790
/**
6791
* The [ISO 3166-1 Alpha 2](https://www.iso.org/iso-3166-country-codes.html) country code the request originated from.
6792
*
6793
* If your worker is [configured to accept TOR connections](https://support.cloudflare.com/hc/en-us/articles/203306930-Understanding-Cloudflare-Tor-support-and-Onion-Routing), this may also be `"T1"`, indicating a request that originated over TOR.
6794
*
6795
* If Cloudflare is unable to determine where the request originated this property is omitted.
6796
*
6797
* The country code `"T1"` is used for requests originating on TOR.
6798
*
6799
* @example "GB"
6800
*/
6801
country?: Iso3166Alpha2Code | "T1";
6802
/**
6803
* If present, this property indicates that the request originated in the EU
6804
*
6805
* @example "1"
6806
*/
6807
isEUCountry?: "1";
6808
/**
6809
* A two-letter code indicating the continent the request originated from.
6810
*
6811
* @example "AN"
6812
*/
6813
continent?: ContinentCode;
6814
/**
6815
* The city the request originated from
6816
*
6817
* @example "Austin"
6818
*/
6819
city?: string;
6820
/**
6821
* Postal code of the incoming request
6822
*
6823
* @example "78701"
6824
*/
6825
postalCode?: string;
6826
/**
6827
* Latitude of the incoming request
6828
*
6829
* @example "30.27130"
6830
*/
6831
latitude?: string;
6832
/**
6833
* Longitude of the incoming request
6834
*
6835
* @example "-97.74260"
6836
*/
6837
longitude?: string;
6838
/**
6839
* Timezone of the incoming request
6840
*
6841
* @example "America/Chicago"
6842
*/
6843
timezone?: string;
6844
/**
6845
* If known, the ISO 3166-2 name for the first level region associated with
6846
* the IP address of the incoming request
6847
*
6848
* @example "Texas"
6849
*/
6850
region?: string;
6851
/**
6852
* If known, the ISO 3166-2 code for the first-level region associated with
6853
* the IP address of the incoming request
6854
*
6855
* @example "TX"
6856
*/
6857
regionCode?: string;
6858
/**
6859
* Metro code (DMA) of the incoming request
6860
*
6861
* @example "635"
6862
*/
6863
metroCode?: string;
6864
}
6865
/** Data about the incoming request's TLS certificate */
6866
interface IncomingRequestCfPropertiesTLSClientAuth {
6867
/** Always `"1"`, indicating that the certificate was presented */
6868
certPresented: "1";
6869
/**
6870
* Result of certificate verification.
6871
*
6872
* @example "FAILED:self signed certificate"
6873
*/
6874
certVerified: Exclude<CertVerificationStatus, "NONE">;
6875
/** The presented certificate's revokation status.
6876
*
6877
* - A value of `"1"` indicates the certificate has been revoked
6878
* - A value of `"0"` indicates the certificate has not been revoked
6879
*/
6880
certRevoked: "1" | "0";
6881
/**
6882
* The certificate issuer's [distinguished name](https://knowledge.digicert.com/generalinformation/INFO1745.html)
6883
*
6884
* @example "CN=cloudflareaccess.com, C=US, ST=Texas, L=Austin, O=Cloudflare"
6885
*/
6886
certIssuerDN: string;
6887
/**
6888
* The certificate subject's [distinguished name](https://knowledge.digicert.com/generalinformation/INFO1745.html)
6889
*
6890
* @example "CN=*.cloudflareaccess.com, C=US, ST=Texas, L=Austin, O=Cloudflare"
6891
*/
6892
certSubjectDN: string;
6893
/**
6894
* The certificate issuer's [distinguished name](https://knowledge.digicert.com/generalinformation/INFO1745.html) ([RFC 2253](https://www.rfc-editor.org/rfc/rfc2253.html) formatted)
6895
*
6896
* @example "CN=cloudflareaccess.com, C=US, ST=Texas, L=Austin, O=Cloudflare"
6897
*/
6898
certIssuerDNRFC2253: string;
6899
/**
6900
* The certificate subject's [distinguished name](https://knowledge.digicert.com/generalinformation/INFO1745.html) ([RFC 2253](https://www.rfc-editor.org/rfc/rfc2253.html) formatted)
6901
*
6902
* @example "CN=*.cloudflareaccess.com, C=US, ST=Texas, L=Austin, O=Cloudflare"
6903
*/
6904
certSubjectDNRFC2253: string;
6905
/** The certificate issuer's distinguished name (legacy policies) */
6906
certIssuerDNLegacy: string;
6907
/** The certificate subject's distinguished name (legacy policies) */
6908
certSubjectDNLegacy: string;
6909
/**
6910
* The certificate's serial number
6911
*
6912
* @example "00936EACBE07F201DF"
6913
*/
6914
certSerial: string;
6915
/**
6916
* The certificate issuer's serial number
6917
*
6918
* @example "2489002934BDFEA34"
6919
*/
6920
certIssuerSerial: string;
6921
/**
6922
* The certificate's Subject Key Identifier
6923
*
6924
* @example "BB:AF:7E:02:3D:FA:A6:F1:3C:84:8E:AD:EE:38:98:EC:D9:32:32:D4"
6925
*/
6926
certSKI: string;
6927
/**
6928
* The certificate issuer's Subject Key Identifier
6929
*
6930
* @example "BB:AF:7E:02:3D:FA:A6:F1:3C:84:8E:AD:EE:38:98:EC:D9:32:32:D4"
6931
*/
6932
certIssuerSKI: string;
6933
/**
6934
* The certificate's SHA-1 fingerprint
6935
*
6936
* @example "6b9109f323999e52259cda7373ff0b4d26bd232e"
6937
*/
6938
certFingerprintSHA1: string;
6939
/**
6940
* The certificate's SHA-256 fingerprint
6941
*
6942
* @example "acf77cf37b4156a2708e34c4eb755f9b5dbbe5ebb55adfec8f11493438d19e6ad3f157f81fa3b98278453d5652b0c1fd1d71e5695ae4d709803a4d3f39de9dea"
6943
*/
6944
certFingerprintSHA256: string;
6945
/**
6946
* The effective starting date of the certificate
6947
*
6948
* @example "Dec 22 19:39:00 2018 GMT"
6949
*/
6950
certNotBefore: string;
6951
/**
6952
* The effective expiration date of the certificate
6953
*
6954
* @example "Dec 22 19:39:00 2018 GMT"
6955
*/
6956
certNotAfter: string;
6957
}
6958
/** Placeholder values for TLS Client Authorization */
6959
interface IncomingRequestCfPropertiesTLSClientAuthPlaceholder {
6960
certPresented: "0";
6961
certVerified: "NONE";
6962
certRevoked: "0";
6963
certIssuerDN: "";
6964
certSubjectDN: "";
6965
certIssuerDNRFC2253: "";
6966
certSubjectDNRFC2253: "";
6967
certIssuerDNLegacy: "";
6968
certSubjectDNLegacy: "";
6969
certSerial: "";
6970
certIssuerSerial: "";
6971
certSKI: "";
6972
certIssuerSKI: "";
6973
certFingerprintSHA1: "";
6974
certFingerprintSHA256: "";
6975
certNotBefore: "";
6976
certNotAfter: "";
6977
}
6978
/** Possible outcomes of TLS verification */
6979
declare type CertVerificationStatus =
6980
/** Authentication succeeded */
6981
"SUCCESS"
6982
/** No certificate was presented */
6983
| "NONE"
6984
/** Failed because the certificate was self-signed */
6985
| "FAILED:self signed certificate"
6986
/** Failed because the certificate failed a trust chain check */
6987
| "FAILED:unable to verify the first certificate"
6988
/** Failed because the certificate not yet valid */
6989
| "FAILED:certificate is not yet valid"
6990
/** Failed because the certificate is expired */
6991
| "FAILED:certificate has expired"
6992
/** Failed for another unspecified reason */
6993
| "FAILED";
6994
/**
6995
* An upstream endpoint's response to a TCP `keepalive` message from Cloudflare.
6996
*/
6997
declare type IncomingRequestCfPropertiesEdgeRequestKeepAliveStatus = 0 /** Unknown */ | 1 /** no keepalives (not found) */ | 2 /** no connection re-use, opening keepalive connection failed */ | 3 /** no connection re-use, keepalive accepted and saved */ | 4 /** connection re-use, refused by the origin server (`TCP FIN`) */ | 5; /** connection re-use, accepted by the origin server */
6998
/** ISO 3166-1 Alpha-2 codes */
6999
declare type Iso3166Alpha2Code = "AD" | "AE" | "AF" | "AG" | "AI" | "AL" | "AM" | "AO" | "AQ" | "AR" | "AS" | "AT" | "AU" | "AW" | "AX" | "AZ" | "BA" | "BB" | "BD" | "BE" | "BF" | "BG" | "BH" | "BI" | "BJ" | "BL" | "BM" | "BN" | "BO" | "BQ" | "BR" | "BS" | "BT" | "BV" | "BW" | "BY" | "BZ" | "CA" | "CC" | "CD" | "CF" | "CG" | "CH" | "CI" | "CK" | "CL" | "CM" | "CN" | "CO" | "CR" | "CU" | "CV" | "CW" | "CX" | "CY" | "CZ" | "DE" | "DJ" | "DK" | "DM" | "DO" | "DZ" | "EC" | "EE" | "EG" | "EH" | "ER" | "ES" | "ET" | "FI" | "FJ" | "FK" | "FM" | "FO" | "FR" | "GA" | "GB" | "GD" | "GE" | "GF" | "GG" | "GH" | "GI" | "GL" | "GM" | "GN" | "GP" | "GQ" | "GR" | "GS" | "GT" | "GU" | "GW" | "GY" | "HK" | "HM" | "HN" | "HR" | "HT" | "HU" | "ID" | "IE" | "IL" | "IM" | "IN" | "IO" | "IQ" | "IR" | "IS" | "IT" | "JE" | "JM" | "JO" | "JP" | "KE" | "KG" | "KH" | "KI" | "KM" | "KN" | "KP" | "KR" | "KW" | "KY" | "KZ" | "LA" | "LB" | "LC" | "LI" | "LK" | "LR" | "LS" | "LT" | "LU" | "LV" | "LY" | "MA" | "MC" | "MD" | "ME" | "MF" | "MG" | "MH" | "MK" | "ML" | "MM" | "MN" | "MO" | "MP" | "MQ" | "MR" | "MS" | "MT" | "MU" | "MV" | "MW" | "MX" | "MY" | "MZ" | "NA" | "NC" | "NE" | "NF" | "NG" | "NI" | "NL" | "NO" | "NP" | "NR" | "NU" | "NZ" | "OM" | "PA" | "PE" | "PF" | "PG" | "PH" | "PK" | "PL" | "PM" | "PN" | "PR" | "PS" | "PT" | "PW" | "PY" | "QA" | "RE" | "RO" | "RS" | "RU" | "RW" | "SA" | "SB" | "SC" | "SD" | "SE" | "SG" | "SH" | "SI" | "SJ" | "SK" | "SL" | "SM" | "SN" | "SO" | "SR" | "SS" | "ST" | "SV" | "SX" | "SY" | "SZ" | "TC" | "TD" | "TF" | "TG" | "TH" | "TJ" | "TK" | "TL" | "TM" | "TN" | "TO" | "TR" | "TT" | "TV" | "TW" | "TZ" | "UA" | "UG" | "UM" | "US" | "UY" | "UZ" | "VA" | "VC" | "VE" | "VG" | "VI" | "VN" | "VU" | "WF" | "WS" | "YE" | "YT" | "ZA" | "ZM" | "ZW";
7000
/** The 2-letter continent codes Cloudflare uses */
7001
declare type ContinentCode = "AF" | "AN" | "AS" | "EU" | "NA" | "OC" | "SA";
7002
type CfProperties<HostMetadata = unknown> = IncomingRequestCfProperties<HostMetadata> | RequestInitCfProperties;
7003
interface D1Meta {
7004
duration: number;
7005
size_after: number;
7006
rows_read: number;
7007
rows_written: number;
7008
last_row_id: number;
7009
changed_db: boolean;
7010
changes: number;
7011
/**
7012
* The region of the database instance that executed the query.
7013
*/
7014
served_by_region?: string;
7015
/**
7016
* True if-and-only-if the database instance that executed the query was the primary.
7017
*/
7018
served_by_primary?: boolean;
7019
timings?: {
7020
/**
7021
* The duration of the SQL query execution by the database instance. It doesn't include any network time.
7022
*/
7023
sql_duration_ms: number;
7024
};
7025
/**
7026
* Number of total attempts to execute the query, due to automatic retries.
7027
* Note: All other fields in the response like `timings` only apply to the last attempt.
7028
*/
7029
total_attempts?: number;
7030
}
7031
interface D1Response {
7032
success: true;
7033
meta: D1Meta & Record<string, unknown>;
7034
error?: never;
7035
}
7036
type D1Result<T = unknown> = D1Response & {
7037
results: T[];
7038
};
7039
interface D1ExecResult {
7040
count: number;
7041
duration: number;
7042
}
7043
type D1SessionConstraint =
7044
// Indicates that the first query should go to the primary, and the rest queries
7045
// using the same D1DatabaseSession will go to any replica that is consistent with
7046
// the bookmark maintained by the session (returned by the first query).
7047
'first-primary'
7048
// Indicates that the first query can go anywhere (primary or replica), and the rest queries
7049
// using the same D1DatabaseSession will go to any replica that is consistent with
7050
// the bookmark maintained by the session (returned by the first query).
7051
| 'first-unconstrained';
7052
type D1SessionBookmark = string;
7053
declare abstract class D1Database {
7054
prepare(query: string): D1PreparedStatement;
7055
batch<T = unknown>(statements: D1PreparedStatement[]): Promise<D1Result<T>[]>;
7056
exec(query: string): Promise<D1ExecResult>;
7057
/**
7058
* Creates a new D1 Session anchored at the given constraint or the bookmark.
7059
* All queries executed using the created session will have sequential consistency,
7060
* meaning that all writes done through the session will be visible in subsequent reads.
7061
*
7062
* @param constraintOrBookmark Either the session constraint or the explicit bookmark to anchor the created session.
7063
*/
7064
withSession(constraintOrBookmark?: D1SessionBookmark | D1SessionConstraint): D1DatabaseSession;
7065
/**
7066
* @deprecated dump() will be removed soon, only applies to deprecated alpha v1 databases.
7067
*/
7068
dump(): Promise<ArrayBuffer>;
7069
}
7070
declare abstract class D1DatabaseSession {
7071
prepare(query: string): D1PreparedStatement;
7072
batch<T = unknown>(statements: D1PreparedStatement[]): Promise<D1Result<T>[]>;
7073
/**
7074
* @returns The latest session bookmark across all executed queries on the session.
7075
* If no query has been executed yet, `null` is returned.
7076
*/
7077
getBookmark(): D1SessionBookmark | null;
7078
}
7079
declare abstract class D1PreparedStatement {
7080
bind(...values: unknown[]): D1PreparedStatement;
7081
first<T = unknown>(colName: string): Promise<T | null>;
7082
first<T = Record<string, unknown>>(): Promise<T | null>;
7083
run<T = Record<string, unknown>>(): Promise<D1Result<T>>;
7084
all<T = Record<string, unknown>>(): Promise<D1Result<T>>;
7085
raw<T = unknown[]>(options: {
7086
columnNames: true;
7087
}): Promise<[
7088
string[],
7089
...T[]
7090
]>;
7091
raw<T = unknown[]>(options?: {
7092
columnNames?: false;
7093
}): Promise<T[]>;
7094
}
7095
// `Disposable` was added to TypeScript's standard lib types in version 5.2.
7096
// To support older TypeScript versions, define an empty `Disposable` interface.
7097
// Users won't be able to use `using`/`Symbol.dispose` without upgrading to 5.2,
7098
// but this will ensure type checking on older versions still passes.
7099
// TypeScript's interface merging will ensure our empty interface is effectively
7100
// ignored when `Disposable` is included in the standard lib.
7101
interface Disposable {
7102
}
7103
/**
7104
* An email message that can be sent from a Worker.
7105
*/
7106
interface EmailMessage {
7107
/**
7108
* Envelope From attribute of the email message.
7109
*/
7110
readonly from: string;
7111
/**
7112
* Envelope To attribute of the email message.
7113
*/
7114
readonly to: string;
7115
}
7116
/**
7117
* An email message that is sent to a consumer Worker and can be rejected/forwarded.
7118
*/
7119
interface ForwardableEmailMessage extends EmailMessage {
7120
/**
7121
* Stream of the email message content.
7122
*/
7123
readonly raw: ReadableStream<Uint8Array>;
7124
/**
7125
* An [Headers object](https://developer.mozilla.org/en-US/docs/Web/API/Headers).
7126
*/
7127
readonly headers: Headers;
7128
/**
7129
* Size of the email message content.
7130
*/
7131
readonly rawSize: number;
7132
/**
7133
* Reject this email message by returning a permanent SMTP error back to the connecting client including the given reason.
7134
* @param reason The reject reason.
7135
* @returns void
7136
*/
7137
setReject(reason: string): void;
7138
/**
7139
* Forward this email message to a verified destination address of the account.
7140
* @param rcptTo Verified destination address.
7141
* @param headers A [Headers object](https://developer.mozilla.org/en-US/docs/Web/API/Headers).
7142
* @returns A promise that resolves when the email message is forwarded.
7143
*/
7144
forward(rcptTo: string, headers?: Headers): Promise<void>;
7145
/**
7146
* Reply to the sender of this email message with a new EmailMessage object.
7147
* @param message The reply message.
7148
* @returns A promise that resolves when the email message is replied.
7149
*/
7150
reply(message: EmailMessage): Promise<void>;
7151
}
7152
/**
7153
* A binding that allows a Worker to send email messages.
7154
*/
7155
interface SendEmail {
7156
send(message: EmailMessage): Promise<void>;
7157
}
7158
declare abstract class EmailEvent extends ExtendableEvent {
7159
readonly message: ForwardableEmailMessage;
7160
}
7161
declare type EmailExportedHandler<Env = unknown> = (message: ForwardableEmailMessage, env: Env, ctx: ExecutionContext) => void | Promise<void>;
7162
declare module "cloudflare:email" {
7163
let _EmailMessage: {
7164
prototype: EmailMessage;
7165
new (from: string, to: string, raw: ReadableStream | string): EmailMessage;
7166
};
7167
export { _EmailMessage as EmailMessage };
7168
}
7169
/**
7170
* Hello World binding to serve as an explanatory example. DO NOT USE
7171
*/
7172
interface HelloWorldBinding {
7173
/**
7174
* Retrieve the current stored value
7175
*/
7176
get(): Promise<{
7177
value: string;
7178
ms?: number;
7179
}>;
7180
/**
7181
* Set a new stored value
7182
*/
7183
set(value: string): Promise<void>;
7184
}
7185
interface Hyperdrive {
7186
/**
7187
* Connect directly to Hyperdrive as if it's your database, returning a TCP socket.
7188
*
7189
* Calling this method returns an idential socket to if you call
7190
* `connect("host:port")` using the `host` and `port` fields from this object.
7191
* Pick whichever approach works better with your preferred DB client library.
7192
*
7193
* Note that this socket is not yet authenticated -- it's expected that your
7194
* code (or preferably, the client library of your choice) will authenticate
7195
* using the information in this class's readonly fields.
7196
*/
7197
connect(): Socket;
7198
/**
7199
* A valid DB connection string that can be passed straight into the typical
7200
* client library/driver/ORM. This will typically be the easiest way to use
7201
* Hyperdrive.
7202
*/
7203
readonly connectionString: string;
7204
/*
7205
* A randomly generated hostname that is only valid within the context of the
7206
* currently running Worker which, when passed into `connect()` function from
7207
* the "cloudflare:sockets" module, will connect to the Hyperdrive instance
7208
* for your database.
7209
*/
7210
readonly host: string;
7211
/*
7212
* The port that must be paired the the host field when connecting.
7213
*/
7214
readonly port: number;
7215
/*
7216
* The username to use when authenticating to your database via Hyperdrive.
7217
* Unlike the host and password, this will be the same every time
7218
*/
7219
readonly user: string;
7220
/*
7221
* The randomly generated password to use when authenticating to your
7222
* database via Hyperdrive. Like the host field, this password is only valid
7223
* within the context of the currently running Worker instance from which
7224
* it's read.
7225
*/
7226
readonly password: string;
7227
/*
7228
* The name of the database to connect to.
7229
*/
7230
readonly database: string;
7231
}
7232
// Copyright (c) 2024 Cloudflare, Inc.
7233
// Licensed under the Apache 2.0 license found in the LICENSE file or at:
7234
// https://opensource.org/licenses/Apache-2.0
7235
type ImageInfoResponse = {
7236
format: 'image/svg+xml';
7237
} | {
7238
format: string;
7239
fileSize: number;
7240
width: number;
7241
height: number;
7242
};
7243
type ImageTransform = {
7244
width?: number;
7245
height?: number;
7246
background?: string;
7247
blur?: number;
7248
border?: {
7249
color?: string;
7250
width?: number;
7251
} | {
7252
top?: number;
7253
bottom?: number;
7254
left?: number;
7255
right?: number;
7256
};
7257
brightness?: number;
7258
contrast?: number;
7259
fit?: 'scale-down' | 'contain' | 'pad' | 'squeeze' | 'cover' | 'crop';
7260
flip?: 'h' | 'v' | 'hv';
7261
gamma?: number;
7262
segment?: 'foreground';
7263
gravity?: 'face' | 'left' | 'right' | 'top' | 'bottom' | 'center' | 'auto' | 'entropy' | {
7264
x?: number;
7265
y?: number;
7266
mode: 'remainder' | 'box-center';
7267
};
7268
rotate?: 0 | 90 | 180 | 270;
7269
saturation?: number;
7270
sharpen?: number;
7271
trim?: 'border' | {
7272
top?: number;
7273
bottom?: number;
7274
left?: number;
7275
right?: number;
7276
width?: number;
7277
height?: number;
7278
border?: boolean | {
7279
color?: string;
7280
tolerance?: number;
7281
keep?: number;
7282
};
7283
};
7284
};
7285
type ImageDrawOptions = {
7286
opacity?: number;
7287
repeat?: boolean | string;
7288
top?: number;
7289
left?: number;
7290
bottom?: number;
7291
right?: number;
7292
};
7293
type ImageInputOptions = {
7294
encoding?: 'base64';
7295
};
7296
type ImageOutputOptions = {
7297
format: 'image/jpeg' | 'image/png' | 'image/gif' | 'image/webp' | 'image/avif' | 'rgb' | 'rgba';
7298
quality?: number;
7299
background?: string;
7300
anim?: boolean;
7301
};
7302
interface ImagesBinding {
7303
/**
7304
* Get image metadata (type, width and height)
7305
* @throws {@link ImagesError} with code 9412 if input is not an image
7306
* @param stream The image bytes
7307
*/
7308
info(stream: ReadableStream<Uint8Array>, options?: ImageInputOptions): Promise<ImageInfoResponse>;
7309
/**
7310
* Begin applying a series of transformations to an image
7311
* @param stream The image bytes
7312
* @returns A transform handle
7313
*/
7314
input(stream: ReadableStream<Uint8Array>, options?: ImageInputOptions): ImageTransformer;
7315
}
7316
interface ImageTransformer {
7317
/**
7318
* Apply transform next, returning a transform handle.
7319
* You can then apply more transformations, draw, or retrieve the output.
7320
* @param transform
7321
*/
7322
transform(transform: ImageTransform): ImageTransformer;
7323
/**
7324
* Draw an image on this transformer, returning a transform handle.
7325
* You can then apply more transformations, draw, or retrieve the output.
7326
* @param image The image (or transformer that will give the image) to draw
7327
* @param options The options configuring how to draw the image
7328
*/
7329
draw(image: ReadableStream<Uint8Array> | ImageTransformer, options?: ImageDrawOptions): ImageTransformer;
7330
/**
7331
* Retrieve the image that results from applying the transforms to the
7332
* provided input
7333
* @param options Options that apply to the output e.g. output format
7334
*/
7335
output(options: ImageOutputOptions): Promise<ImageTransformationResult>;
7336
}
7337
type ImageTransformationOutputOptions = {
7338
encoding?: 'base64';
7339
};
7340
interface ImageTransformationResult {
7341
/**
7342
* The image as a response, ready to store in cache or return to users
7343
*/
7344
response(): Response;
7345
/**
7346
* The content type of the returned image
7347
*/
7348
contentType(): string;
7349
/**
7350
* The bytes of the response
7351
*/
7352
image(options?: ImageTransformationOutputOptions): ReadableStream<Uint8Array>;
7353
}
7354
interface ImagesError extends Error {
7355
readonly code: number;
7356
readonly message: string;
7357
readonly stack?: string;
7358
}
7359
/**
7360
* Media binding for transforming media streams.
7361
* Provides the entry point for media transformation operations.
7362
*/
7363
interface MediaBinding {
7364
/**
7365
* Creates a media transformer from an input stream.
7366
* @param media - The input media bytes
7367
* @returns A MediaTransformer instance for applying transformations
7368
*/
7369
input(media: ReadableStream<Uint8Array>): MediaTransformer;
7370
}
7371
/**
7372
* Media transformer for applying transformation operations to media content.
7373
* Handles sizing, fitting, and other input transformation parameters.
7374
*/
7375
interface MediaTransformer {
7376
/**
7377
* Applies transformation options to the media content.
7378
* @param transform - Configuration for how the media should be transformed
7379
* @returns A generator for producing the transformed media output
7380
*/
7381
transform(transform: MediaTransformationInputOptions): MediaTransformationGenerator;
7382
}
7383
/**
7384
* Generator for producing media transformation results.
7385
* Configures the output format and parameters for the transformed media.
7386
*/
7387
interface MediaTransformationGenerator {
7388
/**
7389
* Generates the final media output with specified options.
7390
* @param output - Configuration for the output format and parameters
7391
* @returns The final transformation result containing the transformed media
7392
*/
7393
output(output: MediaTransformationOutputOptions): MediaTransformationResult;
7394
}
7395
/**
7396
* Result of a media transformation operation.
7397
* Provides multiple ways to access the transformed media content.
7398
*/
7399
interface MediaTransformationResult {
7400
/**
7401
* Returns the transformed media as a readable stream of bytes.
7402
* @returns A stream containing the transformed media data
7403
*/
7404
media(): ReadableStream<Uint8Array>;
7405
/**
7406
* Returns the transformed media as an HTTP response object.
7407
* @returns The transformed media as a Response, ready to store in cache or return to users
7408
*/
7409
response(): Response;
7410
/**
7411
* Returns the MIME type of the transformed media.
7412
* @returns The content type string (e.g., 'image/jpeg', 'video/mp4')
7413
*/
7414
contentType(): string;
7415
}
7416
/**
7417
* Configuration options for transforming media input.
7418
* Controls how the media should be resized and fitted.
7419
*/
7420
type MediaTransformationInputOptions = {
7421
/** How the media should be resized to fit the specified dimensions */
7422
fit?: 'contain' | 'cover' | 'scale-down';
7423
/** Target width in pixels */
7424
width?: number;
7425
/** Target height in pixels */
7426
height?: number;
7427
};
7428
/**
7429
* Configuration options for Media Transformations output.
7430
* Controls the format, timing, and type of the generated output.
7431
*/
7432
type MediaTransformationOutputOptions = {
7433
/**
7434
* Output mode determining the type of media to generate
7435
*/
7436
mode?: 'video' | 'spritesheet' | 'frame' | 'audio';
7437
/** Whether to include audio in the output */
7438
audio?: boolean;
7439
/**
7440
* Starting timestamp for frame extraction or start time for clips. (e.g. '2s').
7441
*/
7442
time?: string;
7443
/**
7444
* Duration for video clips, audio extraction, and spritesheet generation (e.g. '5s').
7445
*/
7446
duration?: string;
7447
/**
7448
* Number of frames in the spritesheet.
7449
*/
7450
imageCount?: number;
7451
/**
7452
* Output format for the generated media.
7453
*/
7454
format?: 'jpg' | 'png' | 'm4a';
7455
};
7456
/**
7457
* Error object for media transformation operations.
7458
* Extends the standard Error interface with additional media-specific information.
7459
*/
7460
interface MediaError extends Error {
7461
readonly code: number;
7462
readonly message: string;
7463
readonly stack?: string;
7464
}
7465
declare module 'cloudflare:node' {
7466
interface NodeStyleServer {
7467
listen(...args: unknown[]): this;
7468
address(): {
7469
port?: number | null | undefined;
7470
};
7471
}
7472
export function httpServerHandler(port: number): ExportedHandler;
7473
export function httpServerHandler(options: {
7474
port: number;
7475
}): ExportedHandler;
7476
export function httpServerHandler(server: NodeStyleServer): ExportedHandler;
7477
}
7478
type Params<P extends string = any> = Record<P, string | string[]>;
7479
type EventContext<Env, P extends string, Data> = {
7480
request: Request<unknown, IncomingRequestCfProperties<unknown>>;
7481
functionPath: string;
7482
waitUntil: (promise: Promise<any>) => void;
7483
passThroughOnException: () => void;
7484
next: (input?: Request | string, init?: RequestInit) => Promise<Response>;
7485
env: Env & {
7486
ASSETS: {
7487
fetch: typeof fetch;
7488
};
7489
};
7490
params: Params<P>;
7491
data: Data;
7492
};
7493
type PagesFunction<Env = unknown, Params extends string = any, Data extends Record<string, unknown> = Record<string, unknown>> = (context: EventContext<Env, Params, Data>) => Response | Promise<Response>;
7494
type EventPluginContext<Env, P extends string, Data, PluginArgs> = {
7495
request: Request<unknown, IncomingRequestCfProperties<unknown>>;
7496
functionPath: string;
7497
waitUntil: (promise: Promise<any>) => void;
7498
passThroughOnException: () => void;
7499
next: (input?: Request | string, init?: RequestInit) => Promise<Response>;
7500
env: Env & {
7501
ASSETS: {
7502
fetch: typeof fetch;
7503
};
7504
};
7505
params: Params<P>;
7506
data: Data;
7507
pluginArgs: PluginArgs;
7508
};
7509
type PagesPluginFunction<Env = unknown, Params extends string = any, Data extends Record<string, unknown> = Record<string, unknown>, PluginArgs = unknown> = (context: EventPluginContext<Env, Params, Data, PluginArgs>) => Response | Promise<Response>;
7510
declare module "assets:*" {
7511
export const onRequest: PagesFunction;
7512
}
7513
// Copyright (c) 2022-2023 Cloudflare, Inc.
7514
// Licensed under the Apache 2.0 license found in the LICENSE file or at:
7515
// https://opensource.org/licenses/Apache-2.0
7516
declare module "cloudflare:pipelines" {
7517
export abstract class PipelineTransformationEntrypoint<Env = unknown, I extends PipelineRecord = PipelineRecord, O extends PipelineRecord = PipelineRecord> {
7518
protected env: Env;
7519
protected ctx: ExecutionContext;
7520
constructor(ctx: ExecutionContext, env: Env);
7521
/**
7522
* run recieves an array of PipelineRecord which can be
7523
* transformed and returned to the pipeline
7524
* @param records Incoming records from the pipeline to be transformed
7525
* @param metadata Information about the specific pipeline calling the transformation entrypoint
7526
* @returns A promise containing the transformed PipelineRecord array
7527
*/
7528
public run(records: I[], metadata: PipelineBatchMetadata): Promise<O[]>;
7529
}
7530
export type PipelineRecord = Record<string, unknown>;
7531
export type PipelineBatchMetadata = {
7532
pipelineId: string;
7533
pipelineName: string;
7534
};
7535
export interface Pipeline<T extends PipelineRecord = PipelineRecord> {
7536
/**
7537
* The Pipeline interface represents the type of a binding to a Pipeline
7538
*
7539
* @param records The records to send to the pipeline
7540
*/
7541
send(records: T[]): Promise<void>;
7542
}
7543
}
7544
// PubSubMessage represents an incoming PubSub message.
7545
// The message includes metadata about the broker, the client, and the payload
7546
// itself.
7547
// https://developers.cloudflare.com/pub-sub/
7548
interface PubSubMessage {
7549
// Message ID
7550
readonly mid: number;
7551
// MQTT broker FQDN in the form mqtts://BROKER.NAMESPACE.cloudflarepubsub.com:PORT
7552
readonly broker: string;
7553
// The MQTT topic the message was sent on.
7554
readonly topic: string;
7555
// The client ID of the client that published this message.
7556
readonly clientId: string;
7557
// The unique identifier (JWT ID) used by the client to authenticate, if token
7558
// auth was used.
7559
readonly jti?: string;
7560
// A Unix timestamp (seconds from Jan 1, 1970), set when the Pub/Sub Broker
7561
// received the message from the client.
7562
readonly receivedAt: number;
7563
// An (optional) string with the MIME type of the payload, if set by the
7564
// client.
7565
readonly contentType: string;
7566
// Set to 1 when the payload is a UTF-8 string
7567
// https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901063
7568
readonly payloadFormatIndicator: number;
7569
// Pub/Sub (MQTT) payloads can be UTF-8 strings, or byte arrays.
7570
// You can use payloadFormatIndicator to inspect this before decoding.
7571
payload: string | Uint8Array;
7572
}
7573
// JsonWebKey extended by kid parameter
7574
interface JsonWebKeyWithKid extends JsonWebKey {
7575
// Key Identifier of the JWK
7576
readonly kid: string;
7577
}
7578
interface RateLimitOptions {
7579
key: string;
7580
}
7581
interface RateLimitOutcome {
7582
success: boolean;
7583
}
7584
interface RateLimit {
7585
/**
7586
* Rate limit a request based on the provided options.
7587
* @see https://developers.cloudflare.com/workers/runtime-apis/bindings/rate-limit/
7588
* @returns A promise that resolves with the outcome of the rate limit.
7589
*/
7590
limit(options: RateLimitOptions): Promise<RateLimitOutcome>;
7591
}
7592
// Namespace for RPC utility types. Unfortunately, we can't use a `module` here as these types need
7593
// to referenced by `Fetcher`. This is included in the "importable" version of the types which
7594
// strips all `module` blocks.
7595
declare namespace Rpc {
7596
// Branded types for identifying `WorkerEntrypoint`/`DurableObject`/`Target`s.
7597
// TypeScript uses *structural* typing meaning anything with the same shape as type `T` is a `T`.
7598
// For the classes exported by `cloudflare:workers` we want *nominal* typing (i.e. we only want to
7599
// accept `WorkerEntrypoint` from `cloudflare:workers`, not any other class with the same shape)
7600
export const __RPC_STUB_BRAND: '__RPC_STUB_BRAND';
7601
export const __RPC_TARGET_BRAND: '__RPC_TARGET_BRAND';
7602
export const __WORKER_ENTRYPOINT_BRAND: '__WORKER_ENTRYPOINT_BRAND';
7603
export const __DURABLE_OBJECT_BRAND: '__DURABLE_OBJECT_BRAND';
7604
export const __WORKFLOW_ENTRYPOINT_BRAND: '__WORKFLOW_ENTRYPOINT_BRAND';
7605
export interface RpcTargetBranded {
7606
[__RPC_TARGET_BRAND]: never;
7607
}
7608
export interface WorkerEntrypointBranded {
7609
[__WORKER_ENTRYPOINT_BRAND]: never;
7610
}
7611
export interface DurableObjectBranded {
7612
[__DURABLE_OBJECT_BRAND]: never;
7613
}
7614
export interface WorkflowEntrypointBranded {
7615
[__WORKFLOW_ENTRYPOINT_BRAND]: never;
7616
}
7617
export type EntrypointBranded = WorkerEntrypointBranded | DurableObjectBranded | WorkflowEntrypointBranded;
7618
// Types that can be used through `Stub`s
7619
export type Stubable = RpcTargetBranded | ((...args: any[]) => any);
7620
// Types that can be passed over RPC
7621
// The reason for using a generic type here is to build a serializable subset of structured
7622
// cloneable composite types. This allows types defined with the "interface" keyword to pass the
7623
// serializable check as well. Otherwise, only types defined with the "type" keyword would pass.
7624
type Serializable<T> =
7625
// Structured cloneables
7626
BaseType
7627
// Structured cloneable composites
7628
| Map<T extends Map<infer U, unknown> ? Serializable<U> : never, T extends Map<unknown, infer U> ? Serializable<U> : never> | Set<T extends Set<infer U> ? Serializable<U> : never> | ReadonlyArray<T extends ReadonlyArray<infer U> ? Serializable<U> : never> | {
7629
[K in keyof T]: K extends number | string ? Serializable<T[K]> : never;
7630
}
7631
// Special types
7632
| Stub<Stubable>
7633
// Serialized as stubs, see `Stubify`
7634
| Stubable;
7635
// Base type for all RPC stubs, including common memory management methods.
7636
// `T` is used as a marker type for unwrapping `Stub`s later.
7637
interface StubBase<T extends Stubable> extends Disposable {
7638
[__RPC_STUB_BRAND]: T;
7639
dup(): this;
7640
}
7641
export type Stub<T extends Stubable> = Provider<T> & StubBase<T>;
7642
// This represents all the types that can be sent as-is over an RPC boundary
7643
type BaseType = void | undefined | null | boolean | number | bigint | string | TypedArray | ArrayBuffer | DataView | Date | Error | RegExp | ReadableStream<Uint8Array> | WritableStream<Uint8Array> | Request | Response | Headers;
7644
// Recursively rewrite all `Stubable` types with `Stub`s
7645
// prettier-ignore
7646
type Stubify<T> = T extends Stubable ? Stub<T> : T extends Map<infer K, infer V> ? Map<Stubify<K>, Stubify<V>> : T extends Set<infer V> ? Set<Stubify<V>> : T extends Array<infer V> ? Array<Stubify<V>> : T extends ReadonlyArray<infer V> ? ReadonlyArray<Stubify<V>> : T extends BaseType ? T : T extends {
7647
[key: string | number]: any;
7648
} ? {
7649
[K in keyof T]: Stubify<T[K]>;
7650
} : T;
7651
// Recursively rewrite all `Stub<T>`s with the corresponding `T`s.
7652
// Note we use `StubBase` instead of `Stub` here to avoid circular dependencies:
7653
// `Stub` depends on `Provider`, which depends on `Unstubify`, which would depend on `Stub`.
7654
// prettier-ignore
7655
type Unstubify<T> = T extends StubBase<infer V> ? V : T extends Map<infer K, infer V> ? Map<Unstubify<K>, Unstubify<V>> : T extends Set<infer V> ? Set<Unstubify<V>> : T extends Array<infer V> ? Array<Unstubify<V>> : T extends ReadonlyArray<infer V> ? ReadonlyArray<Unstubify<V>> : T extends BaseType ? T : T extends {
7656
[key: string | number]: unknown;
7657
} ? {
7658
[K in keyof T]: Unstubify<T[K]>;
7659
} : T;
7660
type UnstubifyAll<A extends any[]> = {
7661
[I in keyof A]: Unstubify<A[I]>;
7662
};
7663
// Utility type for adding `Provider`/`Disposable`s to `object` types only.
7664
// Note `unknown & T` is equivalent to `T`.
7665
type MaybeProvider<T> = T extends object ? Provider<T> : unknown;
7666
type MaybeDisposable<T> = T extends object ? Disposable : unknown;
7667
// Type for method return or property on an RPC interface.
7668
// - Stubable types are replaced by stubs.
7669
// - Serializable types are passed by value, with stubable types replaced by stubs
7670
// and a top-level `Disposer`.
7671
// Everything else can't be passed over PRC.
7672
// Technically, we use custom thenables here, but they quack like `Promise`s.
7673
// Intersecting with `(Maybe)Provider` allows pipelining.
7674
// prettier-ignore
7675
type Result<R> = R extends Stubable ? Promise<Stub<R>> & Provider<R> : R extends Serializable<R> ? Promise<Stubify<R> & MaybeDisposable<R>> & MaybeProvider<R> : never;
7676
// Type for method or property on an RPC interface.
7677
// For methods, unwrap `Stub`s in parameters, and rewrite returns to be `Result`s.
7678
// Unwrapping `Stub`s allows calling with `Stubable` arguments.
7679
// For properties, rewrite types to be `Result`s.
7680
// In each case, unwrap `Promise`s.
7681
type MethodOrProperty<V> = V extends (...args: infer P) => infer R ? (...args: UnstubifyAll<P>) => Result<Awaited<R>> : Result<Awaited<V>>;
7682
// Type for the callable part of an `Provider` if `T` is callable.
7683
// This is intersected with methods/properties.
7684
type MaybeCallableProvider<T> = T extends (...args: any[]) => any ? MethodOrProperty<T> : unknown;
7685
// Base type for all other types providing RPC-like interfaces.
7686
// Rewrites all methods/properties to be `MethodOrProperty`s, while preserving callable types.
7687
// `Reserved` names (e.g. stub method names like `dup()`) and symbols can't be accessed over RPC.
7688
export type Provider<T extends object, Reserved extends string = never> = MaybeCallableProvider<T> & {
7689
[K in Exclude<keyof T, Reserved | symbol | keyof StubBase<never>>]: MethodOrProperty<T[K]>;
7690
};
7691
}
7692
declare namespace Cloudflare {
7693
// Type of `env`.
7694
//
7695
// The specific project can extend `Env` by redeclaring it in project-specific files. Typescript
7696
// will merge all declarations.
7697
//
7698
// You can use `wrangler types` to generate the `Env` type automatically.
7699
interface Env {
7700
}
7701
// Project-specific parameters used to inform types.
7702
//
7703
// This interface is, again, intended to be declared in project-specific files, and then that
7704
// declaration will be merged with this one.
7705
//
7706
// A project should have a declaration like this:
7707
//
7708
// interface GlobalProps {
7709
// // Declares the main module's exports. Used to populate Cloudflare.Exports aka the type
7710
// // of `ctx.exports`.
7711
// mainModule: typeof import("my-main-module");
7712
//
7713
// // Declares which of the main module's exports are configured with durable storage, and
7714
// // thus should behave as Durable Object namsepace bindings.
7715
// durableNamespaces: "MyDurableObject" | "AnotherDurableObject";
7716
// }
7717
//
7718
// You can use `wrangler types` to generate `GlobalProps` automatically.
7719
interface GlobalProps {
7720
}
7721
// Evaluates to the type of a property in GlobalProps, defaulting to `Default` if it is not
7722
// present.
7723
type GlobalProp<K extends string, Default> = K extends keyof GlobalProps ? GlobalProps[K] : Default;
7724
// The type of the program's main module exports, if known. Requires `GlobalProps` to declare the
7725
// `mainModule` property.
7726
type MainModule = GlobalProp<"mainModule", {}>;
7727
// The type of ctx.exports, which contains loopback bindings for all top-level exports.
7728
type Exports = {
7729
[K in keyof MainModule]: LoopbackForExport<MainModule[K]>
7730
// If the export is listed in `durableNamespaces`, then it is also a
7731
// DurableObjectNamespace.
7732
& (K extends GlobalProp<"durableNamespaces", never> ? MainModule[K] extends new (...args: any[]) => infer DoInstance ? DoInstance extends Rpc.DurableObjectBranded ? DurableObjectNamespace<DoInstance> : DurableObjectNamespace<undefined> : DurableObjectNamespace<undefined> : {});
7733
};
7734
}
7735
declare namespace CloudflareWorkersModule {
7736
export type RpcStub<T extends Rpc.Stubable> = Rpc.Stub<T>;
7737
export const RpcStub: {
7738
new <T extends Rpc.Stubable>(value: T): Rpc.Stub<T>;
7739
};
7740
export abstract class RpcTarget implements Rpc.RpcTargetBranded {
7741
[Rpc.__RPC_TARGET_BRAND]: never;
7742
}
7743
// `protected` fields don't appear in `keyof`s, so can't be accessed over RPC
7744
export abstract class WorkerEntrypoint<Env = Cloudflare.Env, Props = {}> implements Rpc.WorkerEntrypointBranded {
7745
[Rpc.__WORKER_ENTRYPOINT_BRAND]: never;
7746
protected ctx: ExecutionContext<Props>;
7747
protected env: Env;
7748
constructor(ctx: ExecutionContext, env: Env);
7749
fetch?(request: Request): Response | Promise<Response>;
7750
tail?(events: TraceItem[]): void | Promise<void>;
7751
trace?(traces: TraceItem[]): void | Promise<void>;
7752
scheduled?(controller: ScheduledController): void | Promise<void>;
7753
queue?(batch: MessageBatch<unknown>): void | Promise<void>;
7754
test?(controller: TestController): void | Promise<void>;
7755
}
7756
export abstract class DurableObject<Env = Cloudflare.Env, Props = {}> implements Rpc.DurableObjectBranded {
7757
[Rpc.__DURABLE_OBJECT_BRAND]: never;
7758
protected ctx: DurableObjectState<Props>;
7759
protected env: Env;
7760
constructor(ctx: DurableObjectState, env: Env);
7761
fetch?(request: Request): Response | Promise<Response>;
7762
alarm?(alarmInfo?: AlarmInvocationInfo): void | Promise<void>;
7763
webSocketMessage?(ws: WebSocket, message: string | ArrayBuffer): void | Promise<void>;
7764
webSocketClose?(ws: WebSocket, code: number, reason: string, wasClean: boolean): void | Promise<void>;
7765
webSocketError?(ws: WebSocket, error: unknown): void | Promise<void>;
7766
}
7767
export type WorkflowDurationLabel = 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year';
7768
export type WorkflowSleepDuration = `${number} ${WorkflowDurationLabel}${'s' | ''}` | number;
7769
export type WorkflowDelayDuration = WorkflowSleepDuration;
7770
export type WorkflowTimeoutDuration = WorkflowSleepDuration;
7771
export type WorkflowRetentionDuration = WorkflowSleepDuration;
7772
export type WorkflowBackoff = 'constant' | 'linear' | 'exponential';
7773
export type WorkflowStepConfig = {
7774
retries?: {
7775
limit: number;
7776
delay: WorkflowDelayDuration | number;
7777
backoff?: WorkflowBackoff;
7778
};
7779
timeout?: WorkflowTimeoutDuration | number;
7780
};
7781
export type WorkflowEvent<T> = {
7782
payload: Readonly<T>;
7783
timestamp: Date;
7784
instanceId: string;
7785
};
7786
export type WorkflowStepEvent<T> = {
7787
payload: Readonly<T>;
7788
timestamp: Date;
7789
type: string;
7790
};
7791
export abstract class WorkflowStep {
7792
do<T extends Rpc.Serializable<T>>(name: string, callback: () => Promise<T>): Promise<T>;
7793
do<T extends Rpc.Serializable<T>>(name: string, config: WorkflowStepConfig, callback: () => Promise<T>): Promise<T>;
7794
sleep: (name: string, duration: WorkflowSleepDuration) => Promise<void>;
7795
sleepUntil: (name: string, timestamp: Date | number) => Promise<void>;
7796
waitForEvent<T extends Rpc.Serializable<T>>(name: string, options: {
7797
type: string;
7798
timeout?: WorkflowTimeoutDuration | number;
7799
}): Promise<WorkflowStepEvent<T>>;
7800
}
7801
export abstract class WorkflowEntrypoint<Env = unknown, T extends Rpc.Serializable<T> | unknown = unknown> implements Rpc.WorkflowEntrypointBranded {
7802
[Rpc.__WORKFLOW_ENTRYPOINT_BRAND]: never;
7803
protected ctx: ExecutionContext;
7804
protected env: Env;
7805
constructor(ctx: ExecutionContext, env: Env);
7806
run(event: Readonly<WorkflowEvent<T>>, step: WorkflowStep): Promise<unknown>;
7807
}
7808
export function waitUntil(promise: Promise<unknown>): void;
7809
export const env: Cloudflare.Env;
7810
}
7811
declare module 'cloudflare:workers' {
7812
export = CloudflareWorkersModule;
7813
}
7814
interface SecretsStoreSecret {
7815
/**
7816
* Get a secret from the Secrets Store, returning a string of the secret value
7817
* if it exists, or throws an error if it does not exist
7818
*/
7819
get(): Promise<string>;
7820
}
7821
declare module "cloudflare:sockets" {
7822
function _connect(address: string | SocketAddress, options?: SocketOptions): Socket;
7823
export { _connect as connect };
7824
}
7825
type ConversionResponse = {
7826
name: string;
7827
mimeType: string;
7828
} & ({
7829
format: "markdown";
7830
tokens: number;
7831
data: string;
7832
} | {
7833
format: "error";
7834
error: string;
7835
});
7836
type SupportedFileFormat = {
7837
mimeType: string;
7838
extension: string;
7839
};
7840
declare abstract class ToMarkdownService {
7841
transform(files: {
7842
name: string;
7843
blob: Blob;
7844
}[], options?: {
7845
gateway?: GatewayOptions;
7846
extraHeaders?: object;
7847
}): Promise<ConversionResponse[]>;
7848
transform(files: {
7849
name: string;
7850
blob: Blob;
7851
}, options?: {
7852
gateway?: GatewayOptions;
7853
extraHeaders?: object;
7854
}): Promise<ConversionResponse>;
7855
supported(): Promise<SupportedFileFormat[]>;
7856
}
7857
declare namespace TailStream {
7858
interface Header {
7859
readonly name: string;
7860
readonly value: string;
7861
}
7862
interface FetchEventInfo {
7863
readonly type: "fetch";
7864
readonly method: string;
7865
readonly url: string;
7866
readonly cfJson?: object;
7867
readonly headers: Header[];
7868
}
7869
interface JsRpcEventInfo {
7870
readonly type: "jsrpc";
7871
}
7872
interface ScheduledEventInfo {
7873
readonly type: "scheduled";
7874
readonly scheduledTime: Date;
7875
readonly cron: string;
7876
}
7877
interface AlarmEventInfo {
7878
readonly type: "alarm";
7879
readonly scheduledTime: Date;
7880
}
7881
interface QueueEventInfo {
7882
readonly type: "queue";
7883
readonly queueName: string;
7884
readonly batchSize: number;
7885
}
7886
interface EmailEventInfo {
7887
readonly type: "email";
7888
readonly mailFrom: string;
7889
readonly rcptTo: string;
7890
readonly rawSize: number;
7891
}
7892
interface TraceEventInfo {
7893
readonly type: "trace";
7894
readonly traces: (string | null)[];
7895
}
7896
interface HibernatableWebSocketEventInfoMessage {
7897
readonly type: "message";
7898
}
7899
interface HibernatableWebSocketEventInfoError {
7900
readonly type: "error";
7901
}
7902
interface HibernatableWebSocketEventInfoClose {
7903
readonly type: "close";
7904
readonly code: number;
7905
readonly wasClean: boolean;
7906
}
7907
interface HibernatableWebSocketEventInfo {
7908
readonly type: "hibernatableWebSocket";
7909
readonly info: HibernatableWebSocketEventInfoClose | HibernatableWebSocketEventInfoError | HibernatableWebSocketEventInfoMessage;
7910
}
7911
interface CustomEventInfo {
7912
readonly type: "custom";
7913
}
7914
interface FetchResponseInfo {
7915
readonly type: "fetch";
7916
readonly statusCode: number;
7917
}
7918
type EventOutcome = "ok" | "canceled" | "exception" | "unknown" | "killSwitch" | "daemonDown" | "exceededCpu" | "exceededMemory" | "loadShed" | "responseStreamDisconnected" | "scriptNotFound";
7919
interface ScriptVersion {
7920
readonly id: string;
7921
readonly tag?: string;
7922
readonly message?: string;
7923
}
7924
interface Onset {
7925
readonly type: "onset";
7926
readonly attributes: Attribute[];
7927
// id for the span being opened by this Onset event.
7928
readonly spanId: string;
7929
readonly dispatchNamespace?: string;
7930
readonly entrypoint?: string;
7931
readonly executionModel: string;
7932
readonly scriptName?: string;
7933
readonly scriptTags?: string[];
7934
readonly scriptVersion?: ScriptVersion;
7935
readonly info: FetchEventInfo | JsRpcEventInfo | ScheduledEventInfo | AlarmEventInfo | QueueEventInfo | EmailEventInfo | TraceEventInfo | HibernatableWebSocketEventInfo | CustomEventInfo;
7936
}
7937
interface Outcome {
7938
readonly type: "outcome";
7939
readonly outcome: EventOutcome;
7940
readonly cpuTime: number;
7941
readonly wallTime: number;
7942
}
7943
interface SpanOpen {
7944
readonly type: "spanOpen";
7945
readonly name: string;
7946
// id for the span being opened by this SpanOpen event.
7947
readonly spanId: string;
7948
readonly info?: FetchEventInfo | JsRpcEventInfo | Attributes;
7949
}
7950
interface SpanClose {
7951
readonly type: "spanClose";
7952
readonly outcome: EventOutcome;
7953
}
7954
interface DiagnosticChannelEvent {
7955
readonly type: "diagnosticChannel";
7956
readonly channel: string;
7957
readonly message: any;
7958
}
7959
interface Exception {
7960
readonly type: "exception";
7961
readonly name: string;
7962
readonly message: string;
7963
readonly stack?: string;
7964
}
7965
interface Log {
7966
readonly type: "log";
7967
readonly level: "debug" | "error" | "info" | "log" | "warn";
7968
readonly message: object;
7969
}
7970
// This marks the worker handler return information.
7971
// This is separate from Outcome because the worker invocation can live for a long time after
7972
// returning. For example - Websockets that return an http upgrade response but then continue
7973
// streaming information or SSE http connections.
7974
interface Return {
7975
readonly type: "return";
7976
readonly info?: FetchResponseInfo;
7977
}
7978
interface Attribute {
7979
readonly name: string;
7980
readonly value: string | string[] | boolean | boolean[] | number | number[] | bigint | bigint[];
7981
}
7982
interface Attributes {
7983
readonly type: "attributes";
7984
readonly info: Attribute[];
7985
}
7986
type EventType = Onset | Outcome | SpanOpen | SpanClose | DiagnosticChannelEvent | Exception | Log | Return | Attributes;
7987
// Context in which this trace event lives.
7988
interface SpanContext {
7989
// Single id for the entire top-level invocation
7990
// This should be a new traceId for the first worker stage invoked in the eyeball request and then
7991
// same-account service-bindings should reuse the same traceId but cross-account service-bindings
7992
// should use a new traceId.
7993
readonly traceId: string;
7994
// spanId in which this event is handled
7995
// for Onset and SpanOpen events this would be the parent span id
7996
// for Outcome and SpanClose these this would be the span id of the opening Onset and SpanOpen events
7997
// For Hibernate and Mark this would be the span under which they were emitted.
7998
// spanId is not set ONLY if:
7999
// 1. This is an Onset event
8000
// 2. We are not inherting any SpanContext. (e.g. this is a cross-account service binding or a new top-level invocation)
8001
readonly spanId?: string;
8002
}
8003
interface TailEvent<Event extends EventType> {
8004
// invocation id of the currently invoked worker stage.
8005
// invocation id will always be unique to every Onset event and will be the same until the Outcome event.
8006
readonly invocationId: string;
8007
// Inherited spanContext for this event.
8008
readonly spanContext: SpanContext;
8009
readonly timestamp: Date;
8010
readonly sequence: number;
8011
readonly event: Event;
8012
}
8013
type TailEventHandler<Event extends EventType = EventType> = (event: TailEvent<Event>) => void | Promise<void>;
8014
type TailEventHandlerObject = {
8015
outcome?: TailEventHandler<Outcome>;
8016
spanOpen?: TailEventHandler<SpanOpen>;
8017
spanClose?: TailEventHandler<SpanClose>;
8018
diagnosticChannel?: TailEventHandler<DiagnosticChannelEvent>;
8019
exception?: TailEventHandler<Exception>;
8020
log?: TailEventHandler<Log>;
8021
return?: TailEventHandler<Return>;
8022
attributes?: TailEventHandler<Attributes>;
8023
};
8024
type TailEventHandlerType = TailEventHandler | TailEventHandlerObject;
8025
}
8026
// Copyright (c) 2022-2023 Cloudflare, Inc.
8027
// Licensed under the Apache 2.0 license found in the LICENSE file or at:
8028
// https://opensource.org/licenses/Apache-2.0
8029
/**
8030
* Data types supported for holding vector metadata.
8031
*/
8032
type VectorizeVectorMetadataValue = string | number | boolean | string[];
8033
/**
8034
* Additional information to associate with a vector.
8035
*/
8036
type VectorizeVectorMetadata = VectorizeVectorMetadataValue | Record<string, VectorizeVectorMetadataValue>;
8037
type VectorFloatArray = Float32Array | Float64Array;
8038
interface VectorizeError {
8039
code?: number;
8040
error: string;
8041
}
8042
/**
8043
* Comparison logic/operation to use for metadata filtering.
8044
*
8045
* This list is expected to grow as support for more operations are released.
8046
*/
8047
type VectorizeVectorMetadataFilterOp = "$eq" | "$ne";
8048
/**
8049
* Filter criteria for vector metadata used to limit the retrieved query result set.
8050
*/
8051
type VectorizeVectorMetadataFilter = {
8052
[field: string]: Exclude<VectorizeVectorMetadataValue, string[]> | null | {
8053
[Op in VectorizeVectorMetadataFilterOp]?: Exclude<VectorizeVectorMetadataValue, string[]> | null;
8054
};
8055
};
8056
/**
8057
* Supported distance metrics for an index.
8058
* Distance metrics determine how other "similar" vectors are determined.
8059
*/
8060
type VectorizeDistanceMetric = "euclidean" | "cosine" | "dot-product";
8061
/**
8062
* Metadata return levels for a Vectorize query.
8063
*
8064
* Default to "none".
8065
*
8066
* @property all Full metadata for the vector return set, including all fields (including those un-indexed) without truncation. This is a more expensive retrieval, as it requires additional fetching & reading of un-indexed data.
8067
* @property indexed Return all metadata fields configured for indexing in the vector return set. This level of retrieval is "free" in that no additional overhead is incurred returning this data. However, note that indexed metadata is subject to truncation (especially for larger strings).
8068
* @property none No indexed metadata will be returned.
8069
*/
8070
type VectorizeMetadataRetrievalLevel = "all" | "indexed" | "none";
8071
interface VectorizeQueryOptions {
8072
topK?: number;
8073
namespace?: string;
8074
returnValues?: boolean;
8075
returnMetadata?: boolean | VectorizeMetadataRetrievalLevel;
8076
filter?: VectorizeVectorMetadataFilter;
8077
}
8078
/**
8079
* Information about the configuration of an index.
8080
*/
8081
type VectorizeIndexConfig = {
8082
dimensions: number;
8083
metric: VectorizeDistanceMetric;
8084
} | {
8085
preset: string; // keep this generic, as we'll be adding more presets in the future and this is only in a read capacity
8086
};
8087
/**
8088
* Metadata about an existing index.
8089
*
8090
* This type is exclusively for the Vectorize **beta** and will be deprecated once Vectorize RC is released.
8091
* See {@link VectorizeIndexInfo} for its post-beta equivalent.
8092
*/
8093
interface VectorizeIndexDetails {
8094
/** The unique ID of the index */
8095
readonly id: string;
8096
/** The name of the index. */
8097
name: string;
8098
/** (optional) A human readable description for the index. */
8099
description?: string;
8100
/** The index configuration, including the dimension size and distance metric. */
8101
config: VectorizeIndexConfig;
8102
/** The number of records containing vectors within the index. */
8103
vectorsCount: number;
8104
}
8105
/**
8106
* Metadata about an existing index.
8107
*/
8108
interface VectorizeIndexInfo {
8109
/** The number of records containing vectors within the index. */
8110
vectorCount: number;
8111
/** Number of dimensions the index has been configured for. */
8112
dimensions: number;
8113
/** ISO 8601 datetime of the last processed mutation on in the index. All changes before this mutation will be reflected in the index state. */
8114
processedUpToDatetime: number;
8115
/** UUIDv4 of the last mutation processed by the index. All changes before this mutation will be reflected in the index state. */
8116
processedUpToMutation: number;
8117
}
8118
/**
8119
* Represents a single vector value set along with its associated metadata.
8120
*/
8121
interface VectorizeVector {
8122
/** 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. */
8123
id: string;
8124
/** The vector values */
8125
values: VectorFloatArray | number[];
8126
/** The namespace this vector belongs to. */
8127
namespace?: string;
8128
/** Metadata associated with the vector. Includes the values of other fields and potentially additional details. */
8129
metadata?: Record<string, VectorizeVectorMetadata>;
8130
}
8131
/**
8132
* Represents a matched vector for a query along with its score and (if specified) the matching vector information.
8133
*/
8134
type VectorizeMatch = Pick<Partial<VectorizeVector>, "values"> & Omit<VectorizeVector, "values"> & {
8135
/** The score or rank for similarity, when returned as a result */
8136
score: number;
8137
};
8138
/**
8139
* A set of matching {@link VectorizeMatch} for a particular query.
8140
*/
8141
interface VectorizeMatches {
8142
matches: VectorizeMatch[];
8143
count: number;
8144
}
8145
/**
8146
* Results of an operation that performed a mutation on a set of vectors.
8147
* Here, `ids` is a list of vectors that were successfully processed.
8148
*
8149
* This type is exclusively for the Vectorize **beta** and will be deprecated once Vectorize RC is released.
8150
* See {@link VectorizeAsyncMutation} for its post-beta equivalent.
8151
*/
8152
interface VectorizeVectorMutation {
8153
/* List of ids of vectors that were successfully processed. */
8154
ids: string[];
8155
/* Total count of the number of processed vectors. */
8156
count: number;
8157
}
8158
/**
8159
* Result type indicating a mutation on the Vectorize Index.
8160
* Actual mutations are processed async where the `mutationId` is the unique identifier for the operation.
8161
*/
8162
interface VectorizeAsyncMutation {
8163
/** The unique identifier for the async mutation operation containing the changeset. */
8164
mutationId: string;
8165
}
8166
/**
8167
* A Vectorize Vector Search Index for querying vectors/embeddings.
8168
*
8169
* This type is exclusively for the Vectorize **beta** and will be deprecated once Vectorize RC is released.
8170
* See {@link Vectorize} for its new implementation.
8171
*/
8172
declare abstract class VectorizeIndex {
8173
/**
8174
* Get information about the currently bound index.
8175
* @returns A promise that resolves with information about the current index.
8176
*/
8177
public describe(): Promise<VectorizeIndexDetails>;
8178
/**
8179
* Use the provided vector to perform a similarity search across the index.
8180
* @param vector Input vector that will be used to drive the similarity search.
8181
* @param options Configuration options to massage the returned data.
8182
* @returns A promise that resolves with matched and scored vectors.
8183
*/
8184
public query(vector: VectorFloatArray | number[], options?: VectorizeQueryOptions): Promise<VectorizeMatches>;
8185
/**
8186
* Insert a list of vectors into the index dataset. If a provided id exists, an error will be thrown.
8187
* @param vectors List of vectors that will be inserted.
8188
* @returns A promise that resolves with the ids & count of records that were successfully processed.
8189
*/
8190
public insert(vectors: VectorizeVector[]): Promise<VectorizeVectorMutation>;
8191
/**
8192
* Upsert a list of vectors into the index dataset. If a provided id exists, it will be replaced with the new values.
8193
* @param vectors List of vectors that will be upserted.
8194
* @returns A promise that resolves with the ids & count of records that were successfully processed.
8195
*/
8196
public upsert(vectors: VectorizeVector[]): Promise<VectorizeVectorMutation>;
8197
/**
8198
* Delete a list of vectors with a matching id.
8199
* @param ids List of vector ids that should be deleted.
8200
* @returns A promise that resolves with the ids & count of records that were successfully processed (and thus deleted).
8201
*/
8202
public deleteByIds(ids: string[]): Promise<VectorizeVectorMutation>;
8203
/**
8204
* Get a list of vectors with a matching id.
8205
* @param ids List of vector ids that should be returned.
8206
* @returns A promise that resolves with the raw unscored vectors matching the id set.
8207
*/
8208
public getByIds(ids: string[]): Promise<VectorizeVector[]>;
8209
}
8210
/**
8211
* A Vectorize Vector Search Index for querying vectors/embeddings.
8212
*
8213
* Mutations in this version are async, returning a mutation id.
8214
*/
8215
declare abstract class Vectorize {
8216
/**
8217
* Get information about the currently bound index.
8218
* @returns A promise that resolves with information about the current index.
8219
*/
8220
public describe(): Promise<VectorizeIndexInfo>;
8221
/**
8222
* Use the provided vector to perform a similarity search across the index.
8223
* @param vector Input vector that will be used to drive the similarity search.
8224
* @param options Configuration options to massage the returned data.
8225
* @returns A promise that resolves with matched and scored vectors.
8226
*/
8227
public query(vector: VectorFloatArray | number[], options?: VectorizeQueryOptions): Promise<VectorizeMatches>;
8228
/**
8229
* Use the provided vector-id to perform a similarity search across the index.
8230
* @param vectorId Id for a vector in the index against which the index should be queried.
8231
* @param options Configuration options to massage the returned data.
8232
* @returns A promise that resolves with matched and scored vectors.
8233
*/
8234
public queryById(vectorId: string, options?: VectorizeQueryOptions): Promise<VectorizeMatches>;
8235
/**
8236
* Insert a list of vectors into the index dataset. If a provided id exists, an error will be thrown.
8237
* @param vectors List of vectors that will be inserted.
8238
* @returns A promise that resolves with a unique identifier of a mutation containing the insert changeset.
8239
*/
8240
public insert(vectors: VectorizeVector[]): Promise<VectorizeAsyncMutation>;
8241
/**
8242
* Upsert a list of vectors into the index dataset. If a provided id exists, it will be replaced with the new values.
8243
* @param vectors List of vectors that will be upserted.
8244
* @returns A promise that resolves with a unique identifier of a mutation containing the upsert changeset.
8245
*/
8246
public upsert(vectors: VectorizeVector[]): Promise<VectorizeAsyncMutation>;
8247
/**
8248
* Delete a list of vectors with a matching id.
8249
* @param ids List of vector ids that should be deleted.
8250
* @returns A promise that resolves with a unique identifier of a mutation containing the delete changeset.
8251
*/
8252
public deleteByIds(ids: string[]): Promise<VectorizeAsyncMutation>;
8253
/**
8254
* Get a list of vectors with a matching id.
8255
* @param ids List of vector ids that should be returned.
8256
* @returns A promise that resolves with the raw unscored vectors matching the id set.
8257
*/
8258
public getByIds(ids: string[]): Promise<VectorizeVector[]>;
8259
}
8260
/**
8261
* The interface for "version_metadata" binding
8262
* providing metadata about the Worker Version using this binding.
8263
*/
8264
type WorkerVersionMetadata = {
8265
/** The ID of the Worker Version using this binding */
8266
id: string;
8267
/** The tag of the Worker Version using this binding */
8268
tag: string;
8269
/** The timestamp of when the Worker Version was uploaded */
8270
timestamp: string;
8271
};
8272
interface DynamicDispatchLimits {
8273
/**
8274
* Limit CPU time in milliseconds.
8275
*/
8276
cpuMs?: number;
8277
/**
8278
* Limit number of subrequests.
8279
*/
8280
subRequests?: number;
8281
}
8282
interface DynamicDispatchOptions {
8283
/**
8284
* Limit resources of invoked Worker script.
8285
*/
8286
limits?: DynamicDispatchLimits;
8287
/**
8288
* Arguments for outbound Worker script, if configured.
8289
*/
8290
outbound?: {
8291
[key: string]: any;
8292
};
8293
}
8294
interface DispatchNamespace {
8295
/**
8296
* @param name Name of the Worker script.
8297
* @param args Arguments to Worker script.
8298
* @param options Options for Dynamic Dispatch invocation.
8299
* @returns A Fetcher object that allows you to send requests to the Worker script.
8300
* @throws If the Worker script does not exist in this dispatch namespace, an error will be thrown.
8301
*/
8302
get(name: string, args?: {
8303
[key: string]: any;
8304
}, options?: DynamicDispatchOptions): Fetcher;
8305
}
8306
declare module 'cloudflare:workflows' {
8307
/**
8308
* NonRetryableError allows for a user to throw a fatal error
8309
* that makes a Workflow instance fail immediately without triggering a retry
8310
*/
8311
export class NonRetryableError extends Error {
8312
public constructor(message: string, name?: string);
8313
}
8314
}
8315
declare abstract class Workflow<PARAMS = unknown> {
8316
/**
8317
* Get a handle to an existing instance of the Workflow.
8318
* @param id Id for the instance of this Workflow
8319
* @returns A promise that resolves with a handle for the Instance
8320
*/
8321
public get(id: string): Promise<WorkflowInstance>;
8322
/**
8323
* Create a new instance and return a handle to it. If a provided id exists, an error will be thrown.
8324
* @param options Options when creating an instance including id and params
8325
* @returns A promise that resolves with a handle for the Instance
8326
*/
8327
public create(options?: WorkflowInstanceCreateOptions<PARAMS>): Promise<WorkflowInstance>;
8328
/**
8329
* Create a batch of instances and return handle for all of them. If a provided id exists, an error will be thrown.
8330
* `createBatch` is limited at 100 instances at a time or when the RPC limit for the batch (1MiB) is reached.
8331
* @param batch List of Options when creating an instance including name and params
8332
* @returns A promise that resolves with a list of handles for the created instances.
8333
*/
8334
public createBatch(batch: WorkflowInstanceCreateOptions<PARAMS>[]): Promise<WorkflowInstance[]>;
8335
}
8336
type WorkflowDurationLabel = 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year';
8337
type WorkflowSleepDuration = `${number} ${WorkflowDurationLabel}${'s' | ''}` | number;
8338
type WorkflowRetentionDuration = WorkflowSleepDuration;
8339
interface WorkflowInstanceCreateOptions<PARAMS = unknown> {
8340
/**
8341
* An id for your Workflow instance. Must be unique within the Workflow.
8342
*/
8343
id?: string;
8344
/**
8345
* The event payload the Workflow instance is triggered with
8346
*/
8347
params?: PARAMS;
8348
/**
8349
* The retention policy for Workflow instance.
8350
* Defaults to the maximum retention period available for the owner's account.
8351
*/
8352
retention?: {
8353
successRetention?: WorkflowRetentionDuration;
8354
errorRetention?: WorkflowRetentionDuration;
8355
};
8356
}
8357
type InstanceStatus = {
8358
status: 'queued' // means that instance is waiting to be started (see concurrency limits)
8359
| 'running' | 'paused' | 'errored' | 'terminated' // user terminated the instance while it was running
8360
| 'complete' | 'waiting' // instance is hibernating and waiting for sleep or event to finish
8361
| 'waitingForPause' // instance is finishing the current work to pause
8362
| 'unknown';
8363
error?: string;
8364
output?: object;
8365
};
8366
interface WorkflowError {
8367
code?: number;
8368
message: string;
8369
}
8370
declare abstract class WorkflowInstance {
8371
public id: string;
8372
/**
8373
* Pause the instance.
8374
*/
8375
public pause(): Promise<void>;
8376
/**
8377
* Resume the instance. If it is already running, an error will be thrown.
8378
*/
8379
public resume(): Promise<void>;
8380
/**
8381
* Terminate the instance. If it is errored, terminated or complete, an error will be thrown.
8382
*/
8383
public terminate(): Promise<void>;
8384
/**
8385
* Restart the instance.
8386
*/
8387
public restart(): Promise<void>;
8388
/**
8389
* Returns the current status of the instance.
8390
*/
8391
public status(): Promise<InstanceStatus>;
8392
/**
8393
* Send an event to this instance.
8394
*/
8395
public sendEvent({ type, payload, }: {
8396
type: string;
8397
payload: unknown;
8398
}): Promise<void>;
8399
}
8400
8401