A Cloudflare Worker which works in conjunction with https://github.com/indexxing/bsky-alt-text
1/* eslint-disable */
2// Generated by Wrangler by running `wrangler types` (hash: 869ac3b4ce0f52ba3b2e0bc70c49089e)
3// Runtime types generated with workerd@1.20250525.0 2025-06-07
4declare namespace Cloudflare {
5 interface Env {
6 }
7}
8interface Env extends Cloudflare.Env {}
9
10// Begin runtime types
11/*! *****************************************************************************
12Copyright (c) Cloudflare. All rights reserved.
13Copyright (c) Microsoft Corporation. All rights reserved.
14
15Licensed under the Apache License, Version 2.0 (the "License"); you may not use
16this file except in compliance with the License. You may obtain a copy of the
17License at http://www.apache.org/licenses/LICENSE-2.0
18THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
20WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
21MERCHANTABLITY OR NON-INFRINGEMENT.
22See the Apache Version 2.0 License for specific language governing permissions
23and limitations under the License.
24***************************************************************************** */
25/* eslint-disable */
26// noinspection JSUnusedGlobalSymbols
27declare var onmessage: never;
28/**
29 * An abnormal event (called an exception) which occurs as a result of calling a method or accessing a property of a web API.
30 *
31 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException)
32 */
33declare class DOMException extends Error {
34 constructor(message?: string, name?: string);
35 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException/message) */
36 readonly message: string;
37 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException/name) */
38 readonly name: string;
39 /**
40 * @deprecated
41 *
42 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException/code)
43 */
44 readonly code: number;
45 static readonly INDEX_SIZE_ERR: number;
46 static readonly DOMSTRING_SIZE_ERR: number;
47 static readonly HIERARCHY_REQUEST_ERR: number;
48 static readonly WRONG_DOCUMENT_ERR: number;
49 static readonly INVALID_CHARACTER_ERR: number;
50 static readonly NO_DATA_ALLOWED_ERR: number;
51 static readonly NO_MODIFICATION_ALLOWED_ERR: number;
52 static readonly NOT_FOUND_ERR: number;
53 static readonly NOT_SUPPORTED_ERR: number;
54 static readonly INUSE_ATTRIBUTE_ERR: number;
55 static readonly INVALID_STATE_ERR: number;
56 static readonly SYNTAX_ERR: number;
57 static readonly INVALID_MODIFICATION_ERR: number;
58 static readonly NAMESPACE_ERR: number;
59 static readonly INVALID_ACCESS_ERR: number;
60 static readonly VALIDATION_ERR: number;
61 static readonly TYPE_MISMATCH_ERR: number;
62 static readonly SECURITY_ERR: number;
63 static readonly NETWORK_ERR: number;
64 static readonly ABORT_ERR: number;
65 static readonly URL_MISMATCH_ERR: number;
66 static readonly QUOTA_EXCEEDED_ERR: number;
67 static readonly TIMEOUT_ERR: number;
68 static readonly INVALID_NODE_TYPE_ERR: number;
69 static readonly DATA_CLONE_ERR: number;
70 get stack(): any;
71 set stack(value: any);
72}
73type WorkerGlobalScopeEventMap = {
74 fetch: FetchEvent;
75 scheduled: ScheduledEvent;
76 queue: QueueEvent;
77 unhandledrejection: PromiseRejectionEvent;
78 rejectionhandled: PromiseRejectionEvent;
79};
80declare abstract class WorkerGlobalScope extends EventTarget<WorkerGlobalScopeEventMap> {
81 EventTarget: typeof EventTarget;
82}
83/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console) */
84interface Console {
85 "assert"(condition?: boolean, ...data: any[]): void;
86 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/clear_static) */
87 clear(): void;
88 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/count_static) */
89 count(label?: string): void;
90 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/countReset_static) */
91 countReset(label?: string): void;
92 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/debug_static) */
93 debug(...data: any[]): void;
94 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/dir_static) */
95 dir(item?: any, options?: any): void;
96 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/dirxml_static) */
97 dirxml(...data: any[]): void;
98 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/error_static) */
99 error(...data: any[]): void;
100 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/group_static) */
101 group(...data: any[]): void;
102 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/groupCollapsed_static) */
103 groupCollapsed(...data: any[]): void;
104 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/groupEnd_static) */
105 groupEnd(): void;
106 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/info_static) */
107 info(...data: any[]): void;
108 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/log_static) */
109 log(...data: any[]): void;
110 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/table_static) */
111 table(tabularData?: any, properties?: string[]): void;
112 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/time_static) */
113 time(label?: string): void;
114 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/timeEnd_static) */
115 timeEnd(label?: string): void;
116 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/timeLog_static) */
117 timeLog(label?: string, ...data: any[]): void;
118 timeStamp(label?: string): void;
119 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/trace_static) */
120 trace(...data: any[]): void;
121 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/warn_static) */
122 warn(...data: any[]): void;
123}
124declare const console: Console;
125type BufferSource = ArrayBufferView | ArrayBuffer;
126type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array;
127declare namespace WebAssembly {
128 class CompileError extends Error {
129 constructor(message?: string);
130 }
131 class RuntimeError extends Error {
132 constructor(message?: string);
133 }
134 type ValueType = "anyfunc" | "externref" | "f32" | "f64" | "i32" | "i64" | "v128";
135 interface GlobalDescriptor {
136 value: ValueType;
137 mutable?: boolean;
138 }
139 class Global {
140 constructor(descriptor: GlobalDescriptor, value?: any);
141 value: any;
142 valueOf(): any;
143 }
144 type ImportValue = ExportValue | number;
145 type ModuleImports = Record<string, ImportValue>;
146 type Imports = Record<string, ModuleImports>;
147 type ExportValue = Function | Global | Memory | Table;
148 type Exports = Record<string, ExportValue>;
149 class Instance {
150 constructor(module: Module, imports?: Imports);
151 readonly exports: Exports;
152 }
153 interface MemoryDescriptor {
154 initial: number;
155 maximum?: number;
156 shared?: boolean;
157 }
158 class Memory {
159 constructor(descriptor: MemoryDescriptor);
160 readonly buffer: ArrayBuffer;
161 grow(delta: number): number;
162 }
163 type ImportExportKind = "function" | "global" | "memory" | "table";
164 interface ModuleExportDescriptor {
165 kind: ImportExportKind;
166 name: string;
167 }
168 interface ModuleImportDescriptor {
169 kind: ImportExportKind;
170 module: string;
171 name: string;
172 }
173 abstract class Module {
174 static customSections(module: Module, sectionName: string): ArrayBuffer[];
175 static exports(module: Module): ModuleExportDescriptor[];
176 static imports(module: Module): ModuleImportDescriptor[];
177 }
178 type TableKind = "anyfunc" | "externref";
179 interface TableDescriptor {
180 element: TableKind;
181 initial: number;
182 maximum?: number;
183 }
184 class Table {
185 constructor(descriptor: TableDescriptor, value?: any);
186 readonly length: number;
187 get(index: number): any;
188 grow(delta: number, value?: any): number;
189 set(index: number, value?: any): void;
190 }
191 function instantiate(module: Module, imports?: Imports): Promise<Instance>;
192 function validate(bytes: BufferSource): boolean;
193}
194/**
195 * This ServiceWorker API interface represents the global execution context of a service worker.
196 * Available only in secure contexts.
197 *
198 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ServiceWorkerGlobalScope)
199 */
200interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
201 DOMException: typeof DOMException;
202 WorkerGlobalScope: typeof WorkerGlobalScope;
203 btoa(data: string): string;
204 atob(data: string): string;
205 setTimeout(callback: (...args: any[]) => void, msDelay?: number): number;
206 setTimeout<Args extends any[]>(callback: (...args: Args) => void, msDelay?: number, ...args: Args): number;
207 clearTimeout(timeoutId: number | null): void;
208 setInterval(callback: (...args: any[]) => void, msDelay?: number): number;
209 setInterval<Args extends any[]>(callback: (...args: Args) => void, msDelay?: number, ...args: Args): number;
210 clearInterval(timeoutId: number | null): void;
211 queueMicrotask(task: Function): void;
212 structuredClone<T>(value: T, options?: StructuredSerializeOptions): T;
213 reportError(error: any): void;
214 fetch(input: RequestInfo | URL, init?: RequestInit<RequestInitCfProperties>): Promise<Response>;
215 self: ServiceWorkerGlobalScope;
216 crypto: Crypto;
217 caches: CacheStorage;
218 scheduler: Scheduler;
219 performance: Performance;
220 Cloudflare: Cloudflare;
221 readonly origin: string;
222 Event: typeof Event;
223 ExtendableEvent: typeof ExtendableEvent;
224 CustomEvent: typeof CustomEvent;
225 PromiseRejectionEvent: typeof PromiseRejectionEvent;
226 FetchEvent: typeof FetchEvent;
227 TailEvent: typeof TailEvent;
228 TraceEvent: typeof TailEvent;
229 ScheduledEvent: typeof ScheduledEvent;
230 MessageEvent: typeof MessageEvent;
231 CloseEvent: typeof CloseEvent;
232 ReadableStreamDefaultReader: typeof ReadableStreamDefaultReader;
233 ReadableStreamBYOBReader: typeof ReadableStreamBYOBReader;
234 ReadableStream: typeof ReadableStream;
235 WritableStream: typeof WritableStream;
236 WritableStreamDefaultWriter: typeof WritableStreamDefaultWriter;
237 TransformStream: typeof TransformStream;
238 ByteLengthQueuingStrategy: typeof ByteLengthQueuingStrategy;
239 CountQueuingStrategy: typeof CountQueuingStrategy;
240 ErrorEvent: typeof ErrorEvent;
241 EventSource: typeof EventSource;
242 ReadableStreamBYOBRequest: typeof ReadableStreamBYOBRequest;
243 ReadableStreamDefaultController: typeof ReadableStreamDefaultController;
244 ReadableByteStreamController: typeof ReadableByteStreamController;
245 WritableStreamDefaultController: typeof WritableStreamDefaultController;
246 TransformStreamDefaultController: typeof TransformStreamDefaultController;
247 CompressionStream: typeof CompressionStream;
248 DecompressionStream: typeof DecompressionStream;
249 TextEncoderStream: typeof TextEncoderStream;
250 TextDecoderStream: typeof TextDecoderStream;
251 Headers: typeof Headers;
252 Body: typeof Body;
253 Request: typeof Request;
254 Response: typeof Response;
255 WebSocket: typeof WebSocket;
256 WebSocketPair: typeof WebSocketPair;
257 WebSocketRequestResponsePair: typeof WebSocketRequestResponsePair;
258 AbortController: typeof AbortController;
259 AbortSignal: typeof AbortSignal;
260 TextDecoder: typeof TextDecoder;
261 TextEncoder: typeof TextEncoder;
262 navigator: Navigator;
263 Navigator: typeof Navigator;
264 URL: typeof URL;
265 URLSearchParams: typeof URLSearchParams;
266 URLPattern: typeof URLPattern;
267 Blob: typeof Blob;
268 File: typeof File;
269 FormData: typeof FormData;
270 Crypto: typeof Crypto;
271 SubtleCrypto: typeof SubtleCrypto;
272 CryptoKey: typeof CryptoKey;
273 CacheStorage: typeof CacheStorage;
274 Cache: typeof Cache;
275 FixedLengthStream: typeof FixedLengthStream;
276 IdentityTransformStream: typeof IdentityTransformStream;
277 HTMLRewriter: typeof HTMLRewriter;
278}
279declare function addEventListener<Type extends keyof WorkerGlobalScopeEventMap>(type: Type, handler: EventListenerOrEventListenerObject<WorkerGlobalScopeEventMap[Type]>, options?: EventTargetAddEventListenerOptions | boolean): void;
280declare function removeEventListener<Type extends keyof WorkerGlobalScopeEventMap>(type: Type, handler: EventListenerOrEventListenerObject<WorkerGlobalScopeEventMap[Type]>, options?: EventTargetEventListenerOptions | boolean): void;
281/**
282 * 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.
283 *
284 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/dispatchEvent)
285 */
286declare function dispatchEvent(event: WorkerGlobalScopeEventMap[keyof WorkerGlobalScopeEventMap]): boolean;
287/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/btoa) */
288declare function btoa(data: string): string;
289/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/atob) */
290declare function atob(data: string): string;
291/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/setTimeout) */
292declare function setTimeout(callback: (...args: any[]) => void, msDelay?: number): number;
293/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/setTimeout) */
294declare function setTimeout<Args extends any[]>(callback: (...args: Args) => void, msDelay?: number, ...args: Args): number;
295/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/clearTimeout) */
296declare function clearTimeout(timeoutId: number | null): void;
297/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/setInterval) */
298declare function setInterval(callback: (...args: any[]) => void, msDelay?: number): number;
299/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/setInterval) */
300declare function setInterval<Args extends any[]>(callback: (...args: Args) => void, msDelay?: number, ...args: Args): number;
301/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/clearInterval) */
302declare function clearInterval(timeoutId: number | null): void;
303/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/queueMicrotask) */
304declare function queueMicrotask(task: Function): void;
305/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/structuredClone) */
306declare function structuredClone<T>(value: T, options?: StructuredSerializeOptions): T;
307/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/reportError) */
308declare function reportError(error: any): void;
309/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/fetch) */
310declare function fetch(input: RequestInfo | URL, init?: RequestInit<RequestInitCfProperties>): Promise<Response>;
311declare const self: ServiceWorkerGlobalScope;
312/**
313* The Web Crypto API provides a set of low-level functions for common cryptographic tasks.
314* The Workers runtime implements the full surface of this API, but with some differences in
315* the [supported algorithms](https://developers.cloudflare.com/workers/runtime-apis/web-crypto/#supported-algorithms)
316* compared to those implemented in most browsers.
317*
318* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/web-crypto/)
319*/
320declare const crypto: Crypto;
321/**
322* The Cache API allows fine grained control of reading and writing from the Cloudflare global network cache.
323*
324* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/)
325*/
326declare const caches: CacheStorage;
327declare const scheduler: Scheduler;
328/**
329* The Workers runtime supports a subset of the Performance API, used to measure timing and performance,
330* as well as timing of subrequests and other operations.
331*
332* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/)
333*/
334declare const performance: Performance;
335declare const Cloudflare: Cloudflare;
336declare const origin: string;
337declare const navigator: Navigator;
338interface TestController {
339}
340interface ExecutionContext {
341 waitUntil(promise: Promise<any>): void;
342 passThroughOnException(): void;
343 props: any;
344}
345type ExportedHandlerFetchHandler<Env = unknown, CfHostMetadata = unknown> = (request: Request<CfHostMetadata, IncomingRequestCfProperties<CfHostMetadata>>, env: Env, ctx: ExecutionContext) => Response | Promise<Response>;
346type ExportedHandlerTailHandler<Env = unknown> = (events: TraceItem[], env: Env, ctx: ExecutionContext) => void | Promise<void>;
347type ExportedHandlerTraceHandler<Env = unknown> = (traces: TraceItem[], env: Env, ctx: ExecutionContext) => void | Promise<void>;
348type ExportedHandlerTailStreamHandler<Env = unknown> = (event: TailStream.TailEvent, env: Env, ctx: ExecutionContext) => TailStream.TailEventHandlerType | Promise<TailStream.TailEventHandlerType>;
349type ExportedHandlerScheduledHandler<Env = unknown> = (controller: ScheduledController, env: Env, ctx: ExecutionContext) => void | Promise<void>;
350type ExportedHandlerQueueHandler<Env = unknown, Message = unknown> = (batch: MessageBatch<Message>, env: Env, ctx: ExecutionContext) => void | Promise<void>;
351type ExportedHandlerTestHandler<Env = unknown> = (controller: TestController, env: Env, ctx: ExecutionContext) => void | Promise<void>;
352interface ExportedHandler<Env = unknown, QueueHandlerMessage = unknown, CfHostMetadata = unknown> {
353 fetch?: ExportedHandlerFetchHandler<Env, CfHostMetadata>;
354 tail?: ExportedHandlerTailHandler<Env>;
355 trace?: ExportedHandlerTraceHandler<Env>;
356 tailStream?: ExportedHandlerTailStreamHandler<Env>;
357 scheduled?: ExportedHandlerScheduledHandler<Env>;
358 test?: ExportedHandlerTestHandler<Env>;
359 email?: EmailExportedHandler<Env>;
360 queue?: ExportedHandlerQueueHandler<Env, QueueHandlerMessage>;
361}
362interface StructuredSerializeOptions {
363 transfer?: any[];
364}
365/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/PromiseRejectionEvent) */
366declare abstract class PromiseRejectionEvent extends Event {
367 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/PromiseRejectionEvent/promise) */
368 readonly promise: Promise<any>;
369 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/PromiseRejectionEvent/reason) */
370 readonly reason: any;
371}
372declare abstract class Navigator {
373 sendBeacon(url: string, body?: (ReadableStream | string | (ArrayBuffer | ArrayBufferView) | Blob | FormData | URLSearchParams | URLSearchParams)): boolean;
374 readonly userAgent: string;
375 readonly hardwareConcurrency: number;
376 readonly language: string;
377 readonly languages: string[];
378}
379/**
380* The Workers runtime supports a subset of the Performance API, used to measure timing and performance,
381* as well as timing of subrequests and other operations.
382*
383* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/)
384*/
385interface Performance {
386 /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/#performancetimeorigin) */
387 readonly timeOrigin: number;
388 /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/#performancenow) */
389 now(): number;
390}
391interface AlarmInvocationInfo {
392 readonly isRetry: boolean;
393 readonly retryCount: number;
394}
395interface Cloudflare {
396 readonly compatibilityFlags: Record<string, boolean>;
397}
398interface DurableObject {
399 fetch(request: Request): Response | Promise<Response>;
400 alarm?(alarmInfo?: AlarmInvocationInfo): void | Promise<void>;
401 webSocketMessage?(ws: WebSocket, message: string | ArrayBuffer): void | Promise<void>;
402 webSocketClose?(ws: WebSocket, code: number, reason: string, wasClean: boolean): void | Promise<void>;
403 webSocketError?(ws: WebSocket, error: unknown): void | Promise<void>;
404}
405type DurableObjectStub<T extends Rpc.DurableObjectBranded | undefined = undefined> = Fetcher<T, "alarm" | "webSocketMessage" | "webSocketClose" | "webSocketError"> & {
406 readonly id: DurableObjectId;
407 readonly name?: string;
408};
409interface DurableObjectId {
410 toString(): string;
411 equals(other: DurableObjectId): boolean;
412 readonly name?: string;
413}
414interface DurableObjectNamespace<T extends Rpc.DurableObjectBranded | undefined = undefined> {
415 newUniqueId(options?: DurableObjectNamespaceNewUniqueIdOptions): DurableObjectId;
416 idFromName(name: string): DurableObjectId;
417 idFromString(id: string): DurableObjectId;
418 get(id: DurableObjectId, options?: DurableObjectNamespaceGetDurableObjectOptions): DurableObjectStub<T>;
419 jurisdiction(jurisdiction: DurableObjectJurisdiction): DurableObjectNamespace<T>;
420}
421type DurableObjectJurisdiction = "eu" | "fedramp";
422interface DurableObjectNamespaceNewUniqueIdOptions {
423 jurisdiction?: DurableObjectJurisdiction;
424}
425type DurableObjectLocationHint = "wnam" | "enam" | "sam" | "weur" | "eeur" | "apac" | "oc" | "afr" | "me";
426interface DurableObjectNamespaceGetDurableObjectOptions {
427 locationHint?: DurableObjectLocationHint;
428}
429interface DurableObjectState {
430 waitUntil(promise: Promise<any>): void;
431 readonly id: DurableObjectId;
432 readonly storage: DurableObjectStorage;
433 container?: Container;
434 blockConcurrencyWhile<T>(callback: () => Promise<T>): Promise<T>;
435 acceptWebSocket(ws: WebSocket, tags?: string[]): void;
436 getWebSockets(tag?: string): WebSocket[];
437 setWebSocketAutoResponse(maybeReqResp?: WebSocketRequestResponsePair): void;
438 getWebSocketAutoResponse(): WebSocketRequestResponsePair | null;
439 getWebSocketAutoResponseTimestamp(ws: WebSocket): Date | null;
440 setHibernatableWebSocketEventTimeout(timeoutMs?: number): void;
441 getHibernatableWebSocketEventTimeout(): number | null;
442 getTags(ws: WebSocket): string[];
443 abort(reason?: string): void;
444}
445interface DurableObjectTransaction {
446 get<T = unknown>(key: string, options?: DurableObjectGetOptions): Promise<T | undefined>;
447 get<T = unknown>(keys: string[], options?: DurableObjectGetOptions): Promise<Map<string, T>>;
448 list<T = unknown>(options?: DurableObjectListOptions): Promise<Map<string, T>>;
449 put<T>(key: string, value: T, options?: DurableObjectPutOptions): Promise<void>;
450 put<T>(entries: Record<string, T>, options?: DurableObjectPutOptions): Promise<void>;
451 delete(key: string, options?: DurableObjectPutOptions): Promise<boolean>;
452 delete(keys: string[], options?: DurableObjectPutOptions): Promise<number>;
453 rollback(): void;
454 getAlarm(options?: DurableObjectGetAlarmOptions): Promise<number | null>;
455 setAlarm(scheduledTime: number | Date, options?: DurableObjectSetAlarmOptions): Promise<void>;
456 deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise<void>;
457}
458interface DurableObjectStorage {
459 get<T = unknown>(key: string, options?: DurableObjectGetOptions): Promise<T | undefined>;
460 get<T = unknown>(keys: string[], options?: DurableObjectGetOptions): Promise<Map<string, T>>;
461 list<T = unknown>(options?: DurableObjectListOptions): Promise<Map<string, T>>;
462 put<T>(key: string, value: T, options?: DurableObjectPutOptions): Promise<void>;
463 put<T>(entries: Record<string, T>, options?: DurableObjectPutOptions): Promise<void>;
464 delete(key: string, options?: DurableObjectPutOptions): Promise<boolean>;
465 delete(keys: string[], options?: DurableObjectPutOptions): Promise<number>;
466 deleteAll(options?: DurableObjectPutOptions): Promise<void>;
467 transaction<T>(closure: (txn: DurableObjectTransaction) => Promise<T>): Promise<T>;
468 getAlarm(options?: DurableObjectGetAlarmOptions): Promise<number | null>;
469 setAlarm(scheduledTime: number | Date, options?: DurableObjectSetAlarmOptions): Promise<void>;
470 deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise<void>;
471 sync(): Promise<void>;
472 sql: SqlStorage;
473 transactionSync<T>(closure: () => T): T;
474 getCurrentBookmark(): Promise<string>;
475 getBookmarkForTime(timestamp: number | Date): Promise<string>;
476 onNextSessionRestoreBookmark(bookmark: string): Promise<string>;
477}
478interface DurableObjectListOptions {
479 start?: string;
480 startAfter?: string;
481 end?: string;
482 prefix?: string;
483 reverse?: boolean;
484 limit?: number;
485 allowConcurrency?: boolean;
486 noCache?: boolean;
487}
488interface DurableObjectGetOptions {
489 allowConcurrency?: boolean;
490 noCache?: boolean;
491}
492interface DurableObjectGetAlarmOptions {
493 allowConcurrency?: boolean;
494}
495interface DurableObjectPutOptions {
496 allowConcurrency?: boolean;
497 allowUnconfirmed?: boolean;
498 noCache?: boolean;
499}
500interface DurableObjectSetAlarmOptions {
501 allowConcurrency?: boolean;
502 allowUnconfirmed?: boolean;
503}
504declare class WebSocketRequestResponsePair {
505 constructor(request: string, response: string);
506 get request(): string;
507 get response(): string;
508}
509interface AnalyticsEngineDataset {
510 writeDataPoint(event?: AnalyticsEngineDataPoint): void;
511}
512interface AnalyticsEngineDataPoint {
513 indexes?: ((ArrayBuffer | string) | null)[];
514 doubles?: number[];
515 blobs?: ((ArrayBuffer | string) | null)[];
516}
517/**
518 * An event which takes place in the DOM.
519 *
520 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event)
521 */
522declare class Event {
523 constructor(type: string, init?: EventInit);
524 /**
525 * Returns the type of event, e.g. "click", "hashchange", or "submit".
526 *
527 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/type)
528 */
529 get type(): string;
530 /**
531 * Returns the event's phase, which is one of NONE, CAPTURING_PHASE, AT_TARGET, and BUBBLING_PHASE.
532 *
533 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/eventPhase)
534 */
535 get eventPhase(): number;
536 /**
537 * 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.
538 *
539 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/composed)
540 */
541 get composed(): boolean;
542 /**
543 * 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.
544 *
545 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/bubbles)
546 */
547 get bubbles(): boolean;
548 /**
549 * 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.
550 *
551 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/cancelable)
552 */
553 get cancelable(): boolean;
554 /**
555 * Returns true if preventDefault() was invoked successfully to indicate cancelation, and false otherwise.
556 *
557 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/defaultPrevented)
558 */
559 get defaultPrevented(): boolean;
560 /**
561 * @deprecated
562 *
563 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/returnValue)
564 */
565 get returnValue(): boolean;
566 /**
567 * Returns the object whose event listener's callback is currently being invoked.
568 *
569 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/currentTarget)
570 */
571 get currentTarget(): EventTarget | undefined;
572 /**
573 * Returns the object to which event is dispatched (its target).
574 *
575 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/target)
576 */
577 get target(): EventTarget | undefined;
578 /**
579 * @deprecated
580 *
581 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/srcElement)
582 */
583 get srcElement(): EventTarget | undefined;
584 /**
585 * Returns the event's timestamp as the number of milliseconds measured relative to the time origin.
586 *
587 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/timeStamp)
588 */
589 get timeStamp(): number;
590 /**
591 * Returns true if event was dispatched by the user agent, and false otherwise.
592 *
593 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/isTrusted)
594 */
595 get isTrusted(): boolean;
596 /**
597 * @deprecated
598 *
599 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/cancelBubble)
600 */
601 get cancelBubble(): boolean;
602 /**
603 * @deprecated
604 *
605 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/cancelBubble)
606 */
607 set cancelBubble(value: boolean);
608 /**
609 * 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.
610 *
611 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/stopImmediatePropagation)
612 */
613 stopImmediatePropagation(): void;
614 /**
615 * 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.
616 *
617 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/preventDefault)
618 */
619 preventDefault(): void;
620 /**
621 * When dispatched in a tree, invoking this method prevents event from reaching any objects other than the current object.
622 *
623 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/stopPropagation)
624 */
625 stopPropagation(): void;
626 /**
627 * 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.
628 *
629 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/composedPath)
630 */
631 composedPath(): EventTarget[];
632 static readonly NONE: number;
633 static readonly CAPTURING_PHASE: number;
634 static readonly AT_TARGET: number;
635 static readonly BUBBLING_PHASE: number;
636}
637interface EventInit {
638 bubbles?: boolean;
639 cancelable?: boolean;
640 composed?: boolean;
641}
642type EventListener<EventType extends Event = Event> = (event: EventType) => void;
643interface EventListenerObject<EventType extends Event = Event> {
644 handleEvent(event: EventType): void;
645}
646type EventListenerOrEventListenerObject<EventType extends Event = Event> = EventListener<EventType> | EventListenerObject<EventType>;
647/**
648 * EventTarget is a DOM interface implemented by objects that can receive events and may have listeners for them.
649 *
650 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget)
651 */
652declare class EventTarget<EventMap extends Record<string, Event> = Record<string, Event>> {
653 constructor();
654 /**
655 * 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.
656 *
657 * 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.
658 *
659 * 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.
660 *
661 * 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.
662 *
663 * When set to true, options's once indicates that the callback will only be invoked once after which the event listener will be removed.
664 *
665 * If an AbortSignal is passed for options's signal, then the event listener will be removed when signal is aborted.
666 *
667 * The event listener is appended to target's event listener list and is not appended if it has the same type, callback, and capture.
668 *
669 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/addEventListener)
670 */
671 addEventListener<Type extends keyof EventMap>(type: Type, handler: EventListenerOrEventListenerObject<EventMap[Type]>, options?: EventTargetAddEventListenerOptions | boolean): void;
672 /**
673 * Removes the event listener in target's event listener list with the same type, callback, and options.
674 *
675 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/removeEventListener)
676 */
677 removeEventListener<Type extends keyof EventMap>(type: Type, handler: EventListenerOrEventListenerObject<EventMap[Type]>, options?: EventTargetEventListenerOptions | boolean): void;
678 /**
679 * 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.
680 *
681 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/dispatchEvent)
682 */
683 dispatchEvent(event: EventMap[keyof EventMap]): boolean;
684}
685interface EventTargetEventListenerOptions {
686 capture?: boolean;
687}
688interface EventTargetAddEventListenerOptions {
689 capture?: boolean;
690 passive?: boolean;
691 once?: boolean;
692 signal?: AbortSignal;
693}
694interface EventTargetHandlerObject {
695 handleEvent: (event: Event) => any | undefined;
696}
697/**
698 * A controller object that allows you to abort one or more DOM requests as and when desired.
699 *
700 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortController)
701 */
702declare class AbortController {
703 constructor();
704 /**
705 * Returns the AbortSignal object associated with this object.
706 *
707 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortController/signal)
708 */
709 get signal(): AbortSignal;
710 /**
711 * 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.
712 *
713 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortController/abort)
714 */
715 abort(reason?: any): void;
716}
717/**
718 * 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.
719 *
720 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal)
721 */
722declare abstract class AbortSignal extends EventTarget {
723 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/abort_static) */
724 static abort(reason?: any): AbortSignal;
725 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/timeout_static) */
726 static timeout(delay: number): AbortSignal;
727 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/any_static) */
728 static any(signals: AbortSignal[]): AbortSignal;
729 /**
730 * Returns true if this AbortSignal's AbortController has signaled to abort, and false otherwise.
731 *
732 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/aborted)
733 */
734 get aborted(): boolean;
735 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/reason) */
736 get reason(): any;
737 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/abort_event) */
738 get onabort(): any | null;
739 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/abort_event) */
740 set onabort(value: any | null);
741 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/throwIfAborted) */
742 throwIfAborted(): void;
743}
744interface Scheduler {
745 wait(delay: number, maybeOptions?: SchedulerWaitOptions): Promise<void>;
746}
747interface SchedulerWaitOptions {
748 signal?: AbortSignal;
749}
750/**
751 * 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.
752 *
753 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ExtendableEvent)
754 */
755declare abstract class ExtendableEvent extends Event {
756 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ExtendableEvent/waitUntil) */
757 waitUntil(promise: Promise<any>): void;
758}
759/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CustomEvent) */
760declare class CustomEvent<T = any> extends Event {
761 constructor(type: string, init?: CustomEventCustomEventInit);
762 /**
763 * Returns any custom data event was created with. Typically used for synthetic events.
764 *
765 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CustomEvent/detail)
766 */
767 get detail(): T;
768}
769interface CustomEventCustomEventInit {
770 bubbles?: boolean;
771 cancelable?: boolean;
772 composed?: boolean;
773 detail?: any;
774}
775/**
776 * 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.
777 *
778 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob)
779 */
780declare class Blob {
781 constructor(type?: ((ArrayBuffer | ArrayBufferView) | string | Blob)[], options?: BlobOptions);
782 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/size) */
783 get size(): number;
784 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/type) */
785 get type(): string;
786 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/slice) */
787 slice(start?: number, end?: number, type?: string): Blob;
788 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/arrayBuffer) */
789 arrayBuffer(): Promise<ArrayBuffer>;
790 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/bytes) */
791 bytes(): Promise<Uint8Array>;
792 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/text) */
793 text(): Promise<string>;
794 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/stream) */
795 stream(): ReadableStream;
796}
797interface BlobOptions {
798 type?: string;
799}
800/**
801 * Provides information about files and allows JavaScript in a web page to access their content.
802 *
803 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/File)
804 */
805declare class File extends Blob {
806 constructor(bits: ((ArrayBuffer | ArrayBufferView) | string | Blob)[] | undefined, name: string, options?: FileOptions);
807 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/File/name) */
808 get name(): string;
809 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/File/lastModified) */
810 get lastModified(): number;
811}
812interface FileOptions {
813 type?: string;
814 lastModified?: number;
815}
816/**
817* The Cache API allows fine grained control of reading and writing from the Cloudflare global network cache.
818*
819* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/)
820*/
821declare abstract class CacheStorage {
822 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CacheStorage/open) */
823 open(cacheName: string): Promise<Cache>;
824 readonly default: Cache;
825}
826/**
827* The Cache API allows fine grained control of reading and writing from the Cloudflare global network cache.
828*
829* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/)
830*/
831declare abstract class Cache {
832 /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/#delete) */
833 delete(request: RequestInfo | URL, options?: CacheQueryOptions): Promise<boolean>;
834 /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/#match) */
835 match(request: RequestInfo | URL, options?: CacheQueryOptions): Promise<Response | undefined>;
836 /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/#put) */
837 put(request: RequestInfo | URL, response: Response): Promise<void>;
838}
839interface CacheQueryOptions {
840 ignoreMethod?: boolean;
841}
842/**
843* The Web Crypto API provides a set of low-level functions for common cryptographic tasks.
844* The Workers runtime implements the full surface of this API, but with some differences in
845* the [supported algorithms](https://developers.cloudflare.com/workers/runtime-apis/web-crypto/#supported-algorithms)
846* compared to those implemented in most browsers.
847*
848* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/web-crypto/)
849*/
850declare abstract class Crypto {
851 /**
852 * Available only in secure contexts.
853 *
854 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Crypto/subtle)
855 */
856 get subtle(): SubtleCrypto;
857 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Crypto/getRandomValues) */
858 getRandomValues<T extends Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | BigInt64Array | BigUint64Array>(buffer: T): T;
859 /**
860 * Available only in secure contexts.
861 *
862 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Crypto/randomUUID)
863 */
864 randomUUID(): string;
865 DigestStream: typeof DigestStream;
866}
867/**
868 * 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).
869 * Available only in secure contexts.
870 *
871 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto)
872 */
873declare abstract class SubtleCrypto {
874 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/encrypt) */
875 encrypt(algorithm: string | SubtleCryptoEncryptAlgorithm, key: CryptoKey, plainText: ArrayBuffer | ArrayBufferView): Promise<ArrayBuffer>;
876 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/decrypt) */
877 decrypt(algorithm: string | SubtleCryptoEncryptAlgorithm, key: CryptoKey, cipherText: ArrayBuffer | ArrayBufferView): Promise<ArrayBuffer>;
878 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/sign) */
879 sign(algorithm: string | SubtleCryptoSignAlgorithm, key: CryptoKey, data: ArrayBuffer | ArrayBufferView): Promise<ArrayBuffer>;
880 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/verify) */
881 verify(algorithm: string | SubtleCryptoSignAlgorithm, key: CryptoKey, signature: ArrayBuffer | ArrayBufferView, data: ArrayBuffer | ArrayBufferView): Promise<boolean>;
882 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/digest) */
883 digest(algorithm: string | SubtleCryptoHashAlgorithm, data: ArrayBuffer | ArrayBufferView): Promise<ArrayBuffer>;
884 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/generateKey) */
885 generateKey(algorithm: string | SubtleCryptoGenerateKeyAlgorithm, extractable: boolean, keyUsages: string[]): Promise<CryptoKey | CryptoKeyPair>;
886 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/deriveKey) */
887 deriveKey(algorithm: string | SubtleCryptoDeriveKeyAlgorithm, baseKey: CryptoKey, derivedKeyAlgorithm: string | SubtleCryptoImportKeyAlgorithm, extractable: boolean, keyUsages: string[]): Promise<CryptoKey>;
888 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/deriveBits) */
889 deriveBits(algorithm: string | SubtleCryptoDeriveKeyAlgorithm, baseKey: CryptoKey, length?: number | null): Promise<ArrayBuffer>;
890 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/importKey) */
891 importKey(format: string, keyData: (ArrayBuffer | ArrayBufferView) | JsonWebKey, algorithm: string | SubtleCryptoImportKeyAlgorithm, extractable: boolean, keyUsages: string[]): Promise<CryptoKey>;
892 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/exportKey) */
893 exportKey(format: string, key: CryptoKey): Promise<ArrayBuffer | JsonWebKey>;
894 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/wrapKey) */
895 wrapKey(format: string, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: string | SubtleCryptoEncryptAlgorithm): Promise<ArrayBuffer>;
896 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/unwrapKey) */
897 unwrapKey(format: string, wrappedKey: ArrayBuffer | ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: string | SubtleCryptoEncryptAlgorithm, unwrappedKeyAlgorithm: string | SubtleCryptoImportKeyAlgorithm, extractable: boolean, keyUsages: string[]): Promise<CryptoKey>;
898 timingSafeEqual(a: ArrayBuffer | ArrayBufferView, b: ArrayBuffer | ArrayBufferView): boolean;
899}
900/**
901 * The CryptoKey dictionary of the Web Crypto API represents a cryptographic key.
902 * Available only in secure contexts.
903 *
904 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey)
905 */
906declare abstract class CryptoKey {
907 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/type) */
908 readonly type: string;
909 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/extractable) */
910 readonly extractable: boolean;
911 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/algorithm) */
912 readonly algorithm: CryptoKeyKeyAlgorithm | CryptoKeyAesKeyAlgorithm | CryptoKeyHmacKeyAlgorithm | CryptoKeyRsaKeyAlgorithm | CryptoKeyEllipticKeyAlgorithm | CryptoKeyArbitraryKeyAlgorithm;
913 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/usages) */
914 readonly usages: string[];
915}
916interface CryptoKeyPair {
917 publicKey: CryptoKey;
918 privateKey: CryptoKey;
919}
920interface JsonWebKey {
921 kty: string;
922 use?: string;
923 key_ops?: string[];
924 alg?: string;
925 ext?: boolean;
926 crv?: string;
927 x?: string;
928 y?: string;
929 d?: string;
930 n?: string;
931 e?: string;
932 p?: string;
933 q?: string;
934 dp?: string;
935 dq?: string;
936 qi?: string;
937 oth?: RsaOtherPrimesInfo[];
938 k?: string;
939}
940interface RsaOtherPrimesInfo {
941 r?: string;
942 d?: string;
943 t?: string;
944}
945interface SubtleCryptoDeriveKeyAlgorithm {
946 name: string;
947 salt?: (ArrayBuffer | ArrayBufferView);
948 iterations?: number;
949 hash?: (string | SubtleCryptoHashAlgorithm);
950 $public?: CryptoKey;
951 info?: (ArrayBuffer | ArrayBufferView);
952}
953interface SubtleCryptoEncryptAlgorithm {
954 name: string;
955 iv?: (ArrayBuffer | ArrayBufferView);
956 additionalData?: (ArrayBuffer | ArrayBufferView);
957 tagLength?: number;
958 counter?: (ArrayBuffer | ArrayBufferView);
959 length?: number;
960 label?: (ArrayBuffer | ArrayBufferView);
961}
962interface SubtleCryptoGenerateKeyAlgorithm {
963 name: string;
964 hash?: (string | SubtleCryptoHashAlgorithm);
965 modulusLength?: number;
966 publicExponent?: (ArrayBuffer | ArrayBufferView);
967 length?: number;
968 namedCurve?: string;
969}
970interface SubtleCryptoHashAlgorithm {
971 name: string;
972}
973interface SubtleCryptoImportKeyAlgorithm {
974 name: string;
975 hash?: (string | SubtleCryptoHashAlgorithm);
976 length?: number;
977 namedCurve?: string;
978 compressed?: boolean;
979}
980interface SubtleCryptoSignAlgorithm {
981 name: string;
982 hash?: (string | SubtleCryptoHashAlgorithm);
983 dataLength?: number;
984 saltLength?: number;
985}
986interface CryptoKeyKeyAlgorithm {
987 name: string;
988}
989interface CryptoKeyAesKeyAlgorithm {
990 name: string;
991 length: number;
992}
993interface CryptoKeyHmacKeyAlgorithm {
994 name: string;
995 hash: CryptoKeyKeyAlgorithm;
996 length: number;
997}
998interface CryptoKeyRsaKeyAlgorithm {
999 name: string;
1000 modulusLength: number;
1001 publicExponent: ArrayBuffer | ArrayBufferView;
1002 hash?: CryptoKeyKeyAlgorithm;
1003}
1004interface CryptoKeyEllipticKeyAlgorithm {
1005 name: string;
1006 namedCurve: string;
1007}
1008interface CryptoKeyArbitraryKeyAlgorithm {
1009 name: string;
1010 hash?: CryptoKeyKeyAlgorithm;
1011 namedCurve?: string;
1012 length?: number;
1013}
1014declare class DigestStream extends WritableStream<ArrayBuffer | ArrayBufferView> {
1015 constructor(algorithm: string | SubtleCryptoHashAlgorithm);
1016 readonly digest: Promise<ArrayBuffer>;
1017 get bytesWritten(): number | bigint;
1018}
1019/**
1020 * 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.
1021 *
1022 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextDecoder)
1023 */
1024declare class TextDecoder {
1025 constructor(label?: string, options?: TextDecoderConstructorOptions);
1026 /**
1027 * 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.
1028 *
1029 * ```
1030 * var string = "", decoder = new TextDecoder(encoding), buffer;
1031 * while(buffer = next_chunk()) {
1032 * string += decoder.decode(buffer, {stream:true});
1033 * }
1034 * string += decoder.decode(); // end-of-queue
1035 * ```
1036 *
1037 * If the error mode is "fatal" and encoding's decoder returns error, throws a TypeError.
1038 *
1039 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextDecoder/decode)
1040 */
1041 decode(input?: (ArrayBuffer | ArrayBufferView), options?: TextDecoderDecodeOptions): string;
1042 get encoding(): string;
1043 get fatal(): boolean;
1044 get ignoreBOM(): boolean;
1045}
1046/**
1047 * 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.
1048 *
1049 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextEncoder)
1050 */
1051declare class TextEncoder {
1052 constructor();
1053 /**
1054 * Returns the result of running UTF-8's encoder.
1055 *
1056 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextEncoder/encode)
1057 */
1058 encode(input?: string): Uint8Array;
1059 /**
1060 * 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.
1061 *
1062 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextEncoder/encodeInto)
1063 */
1064 encodeInto(input: string, buffer: ArrayBuffer | ArrayBufferView): TextEncoderEncodeIntoResult;
1065 get encoding(): string;
1066}
1067interface TextDecoderConstructorOptions {
1068 fatal: boolean;
1069 ignoreBOM: boolean;
1070}
1071interface TextDecoderDecodeOptions {
1072 stream: boolean;
1073}
1074interface TextEncoderEncodeIntoResult {
1075 read: number;
1076 written: number;
1077}
1078/**
1079 * Events providing information related to errors in scripts or in files.
1080 *
1081 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent)
1082 */
1083declare class ErrorEvent extends Event {
1084 constructor(type: string, init?: ErrorEventErrorEventInit);
1085 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/filename) */
1086 get filename(): string;
1087 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/message) */
1088 get message(): string;
1089 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/lineno) */
1090 get lineno(): number;
1091 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/colno) */
1092 get colno(): number;
1093 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/error) */
1094 get error(): any;
1095}
1096interface ErrorEventErrorEventInit {
1097 message?: string;
1098 filename?: string;
1099 lineno?: number;
1100 colno?: number;
1101 error?: any;
1102}
1103/**
1104 * 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".
1105 *
1106 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData)
1107 */
1108declare class FormData {
1109 constructor();
1110 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/append) */
1111 append(name: string, value: string): void;
1112 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/append) */
1113 append(name: string, value: Blob, filename?: string): void;
1114 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/delete) */
1115 delete(name: string): void;
1116 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/get) */
1117 get(name: string): (File | string) | null;
1118 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/getAll) */
1119 getAll(name: string): (File | string)[];
1120 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/has) */
1121 has(name: string): boolean;
1122 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/set) */
1123 set(name: string, value: string): void;
1124 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/set) */
1125 set(name: string, value: Blob, filename?: string): void;
1126 /* Returns an array of key, value pairs for every entry in the list. */
1127 entries(): IterableIterator<[
1128 key: string,
1129 value: File | string
1130 ]>;
1131 /* Returns a list of keys in the list. */
1132 keys(): IterableIterator<string>;
1133 /* Returns a list of values in the list. */
1134 values(): IterableIterator<(File | string)>;
1135 forEach<This = unknown>(callback: (this: This, value: File | string, key: string, parent: FormData) => void, thisArg?: This): void;
1136 [Symbol.iterator](): IterableIterator<[
1137 key: string,
1138 value: File | string
1139 ]>;
1140}
1141interface ContentOptions {
1142 html?: boolean;
1143}
1144declare class HTMLRewriter {
1145 constructor();
1146 on(selector: string, handlers: HTMLRewriterElementContentHandlers): HTMLRewriter;
1147 onDocument(handlers: HTMLRewriterDocumentContentHandlers): HTMLRewriter;
1148 transform(response: Response): Response;
1149}
1150interface HTMLRewriterElementContentHandlers {
1151 element?(element: Element): void | Promise<void>;
1152 comments?(comment: Comment): void | Promise<void>;
1153 text?(element: Text): void | Promise<void>;
1154}
1155interface HTMLRewriterDocumentContentHandlers {
1156 doctype?(doctype: Doctype): void | Promise<void>;
1157 comments?(comment: Comment): void | Promise<void>;
1158 text?(text: Text): void | Promise<void>;
1159 end?(end: DocumentEnd): void | Promise<void>;
1160}
1161interface Doctype {
1162 readonly name: string | null;
1163 readonly publicId: string | null;
1164 readonly systemId: string | null;
1165}
1166interface Element {
1167 tagName: string;
1168 readonly attributes: IterableIterator<string[]>;
1169 readonly removed: boolean;
1170 readonly namespaceURI: string;
1171 getAttribute(name: string): string | null;
1172 hasAttribute(name: string): boolean;
1173 setAttribute(name: string, value: string): Element;
1174 removeAttribute(name: string): Element;
1175 before(content: string | ReadableStream | Response, options?: ContentOptions): Element;
1176 after(content: string | ReadableStream | Response, options?: ContentOptions): Element;
1177 prepend(content: string | ReadableStream | Response, options?: ContentOptions): Element;
1178 append(content: string | ReadableStream | Response, options?: ContentOptions): Element;
1179 replace(content: string | ReadableStream | Response, options?: ContentOptions): Element;
1180 remove(): Element;
1181 removeAndKeepContent(): Element;
1182 setInnerContent(content: string | ReadableStream | Response, options?: ContentOptions): Element;
1183 onEndTag(handler: (tag: EndTag) => void | Promise<void>): void;
1184}
1185interface EndTag {
1186 name: string;
1187 before(content: string | ReadableStream | Response, options?: ContentOptions): EndTag;
1188 after(content: string | ReadableStream | Response, options?: ContentOptions): EndTag;
1189 remove(): EndTag;
1190}
1191interface Comment {
1192 text: string;
1193 readonly removed: boolean;
1194 before(content: string, options?: ContentOptions): Comment;
1195 after(content: string, options?: ContentOptions): Comment;
1196 replace(content: string, options?: ContentOptions): Comment;
1197 remove(): Comment;
1198}
1199interface Text {
1200 readonly text: string;
1201 readonly lastInTextNode: boolean;
1202 readonly removed: boolean;
1203 before(content: string | ReadableStream | Response, options?: ContentOptions): Text;
1204 after(content: string | ReadableStream | Response, options?: ContentOptions): Text;
1205 replace(content: string | ReadableStream | Response, options?: ContentOptions): Text;
1206 remove(): Text;
1207}
1208interface DocumentEnd {
1209 append(content: string, options?: ContentOptions): DocumentEnd;
1210}
1211/**
1212 * 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.
1213 *
1214 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FetchEvent)
1215 */
1216declare abstract class FetchEvent extends ExtendableEvent {
1217 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FetchEvent/request) */
1218 readonly request: Request;
1219 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FetchEvent/respondWith) */
1220 respondWith(promise: Response | Promise<Response>): void;
1221 passThroughOnException(): void;
1222}
1223type HeadersInit = Headers | Iterable<Iterable<string>> | Record<string, string>;
1224/**
1225 * 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.
1226 *
1227 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers)
1228 */
1229declare class Headers {
1230 constructor(init?: HeadersInit);
1231 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/get) */
1232 get(name: string): string | null;
1233 getAll(name: string): string[];
1234 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/getSetCookie) */
1235 getSetCookie(): string[];
1236 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/has) */
1237 has(name: string): boolean;
1238 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/set) */
1239 set(name: string, value: string): void;
1240 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/append) */
1241 append(name: string, value: string): void;
1242 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/delete) */
1243 delete(name: string): void;
1244 forEach<This = unknown>(callback: (this: This, value: string, key: string, parent: Headers) => void, thisArg?: This): void;
1245 /* Returns an iterator allowing to go through all key/value pairs contained in this object. */
1246 entries(): IterableIterator<[
1247 key: string,
1248 value: string
1249 ]>;
1250 /* Returns an iterator allowing to go through all keys of the key/value pairs contained in this object. */
1251 keys(): IterableIterator<string>;
1252 /* Returns an iterator allowing to go through all values of the key/value pairs contained in this object. */
1253 values(): IterableIterator<string>;
1254 [Symbol.iterator](): IterableIterator<[
1255 key: string,
1256 value: string
1257 ]>;
1258}
1259type BodyInit = ReadableStream<Uint8Array> | string | ArrayBuffer | ArrayBufferView | Blob | URLSearchParams | FormData;
1260declare abstract class Body {
1261 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/body) */
1262 get body(): ReadableStream | null;
1263 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/bodyUsed) */
1264 get bodyUsed(): boolean;
1265 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/arrayBuffer) */
1266 arrayBuffer(): Promise<ArrayBuffer>;
1267 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/bytes) */
1268 bytes(): Promise<Uint8Array>;
1269 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/text) */
1270 text(): Promise<string>;
1271 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/json) */
1272 json<T>(): Promise<T>;
1273 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/formData) */
1274 formData(): Promise<FormData>;
1275 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/blob) */
1276 blob(): Promise<Blob>;
1277}
1278/**
1279 * This Fetch API interface represents the response to a request.
1280 *
1281 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response)
1282 */
1283declare var Response: {
1284 prototype: Response;
1285 new (body?: BodyInit | null, init?: ResponseInit): Response;
1286 error(): Response;
1287 redirect(url: string, status?: number): Response;
1288 json(any: any, maybeInit?: (ResponseInit | Response)): Response;
1289};
1290/**
1291 * This Fetch API interface represents the response to a request.
1292 *
1293 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response)
1294 */
1295interface Response extends Body {
1296 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/clone) */
1297 clone(): Response;
1298 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/status) */
1299 status: number;
1300 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/statusText) */
1301 statusText: string;
1302 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/headers) */
1303 headers: Headers;
1304 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/ok) */
1305 ok: boolean;
1306 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/redirected) */
1307 redirected: boolean;
1308 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/url) */
1309 url: string;
1310 webSocket: WebSocket | null;
1311 cf: any | undefined;
1312 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/type) */
1313 type: "default" | "error";
1314}
1315interface ResponseInit {
1316 status?: number;
1317 statusText?: string;
1318 headers?: HeadersInit;
1319 cf?: any;
1320 webSocket?: (WebSocket | null);
1321 encodeBody?: "automatic" | "manual";
1322}
1323type RequestInfo<CfHostMetadata = unknown, Cf = CfProperties<CfHostMetadata>> = Request<CfHostMetadata, Cf> | string;
1324/**
1325 * This Fetch API interface represents a resource request.
1326 *
1327 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request)
1328 */
1329declare var Request: {
1330 prototype: Request;
1331 new <CfHostMetadata = unknown, Cf = CfProperties<CfHostMetadata>>(input: RequestInfo<CfProperties> | URL, init?: RequestInit<Cf>): Request<CfHostMetadata, Cf>;
1332};
1333/**
1334 * This Fetch API interface represents a resource request.
1335 *
1336 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request)
1337 */
1338interface Request<CfHostMetadata = unknown, Cf = CfProperties<CfHostMetadata>> extends Body {
1339 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/clone) */
1340 clone(): Request<CfHostMetadata, Cf>;
1341 /**
1342 * Returns request's HTTP method, which is "GET" by default.
1343 *
1344 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/method)
1345 */
1346 method: string;
1347 /**
1348 * Returns the URL of request as a string.
1349 *
1350 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/url)
1351 */
1352 url: string;
1353 /**
1354 * 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.
1355 *
1356 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/headers)
1357 */
1358 headers: Headers;
1359 /**
1360 * 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.
1361 *
1362 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/redirect)
1363 */
1364 redirect: string;
1365 fetcher: Fetcher | null;
1366 /**
1367 * Returns the signal associated with request, which is an AbortSignal object indicating whether or not request has been aborted, and its abort event handler.
1368 *
1369 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/signal)
1370 */
1371 signal: AbortSignal;
1372 cf: Cf | undefined;
1373 /**
1374 * 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]
1375 *
1376 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/integrity)
1377 */
1378 integrity: string;
1379 /**
1380 * Returns a boolean indicating whether or not request can outlive the global in which it was created.
1381 *
1382 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/keepalive)
1383 */
1384 keepalive: boolean;
1385 /**
1386 * Returns the cache mode associated with request, which is a string indicating how the request will interact with the browser's cache when fetching.
1387 *
1388 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/cache)
1389 */
1390 cache?: "no-store";
1391}
1392interface RequestInit<Cf = CfProperties> {
1393 /* A string to set request's method. */
1394 method?: string;
1395 /* A Headers object, an object literal, or an array of two-item arrays to set request's headers. */
1396 headers?: HeadersInit;
1397 /* A BodyInit object or null to set request's body. */
1398 body?: BodyInit | null;
1399 /* 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. */
1400 redirect?: string;
1401 fetcher?: (Fetcher | null);
1402 cf?: Cf;
1403 /* A string indicating how the request will interact with the browser's cache to set request's cache. */
1404 cache?: "no-store";
1405 /* A cryptographic hash of the resource to be fetched by request. Sets request's integrity. */
1406 integrity?: string;
1407 /* An AbortSignal to set request's signal. */
1408 signal?: (AbortSignal | null);
1409 encodeResponseBody?: "automatic" | "manual";
1410}
1411type Service<T extends Rpc.WorkerEntrypointBranded | undefined = undefined> = Fetcher<T>;
1412type Fetcher<T extends Rpc.EntrypointBranded | undefined = undefined, Reserved extends string = never> = (T extends Rpc.EntrypointBranded ? Rpc.Provider<T, Reserved | "fetch" | "connect"> : unknown) & {
1413 fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
1414 connect(address: SocketAddress | string, options?: SocketOptions): Socket;
1415};
1416interface KVNamespaceListKey<Metadata, Key extends string = string> {
1417 name: Key;
1418 expiration?: number;
1419 metadata?: Metadata;
1420}
1421type KVNamespaceListResult<Metadata, Key extends string = string> = {
1422 list_complete: false;
1423 keys: KVNamespaceListKey<Metadata, Key>[];
1424 cursor: string;
1425 cacheStatus: string | null;
1426} | {
1427 list_complete: true;
1428 keys: KVNamespaceListKey<Metadata, Key>[];
1429 cacheStatus: string | null;
1430};
1431interface KVNamespace<Key extends string = string> {
1432 get(key: Key, options?: Partial<KVNamespaceGetOptions<undefined>>): Promise<string | null>;
1433 get(key: Key, type: "text"): Promise<string | null>;
1434 get<ExpectedValue = unknown>(key: Key, type: "json"): Promise<ExpectedValue | null>;
1435 get(key: Key, type: "arrayBuffer"): Promise<ArrayBuffer | null>;
1436 get(key: Key, type: "stream"): Promise<ReadableStream | null>;
1437 get(key: Key, options?: KVNamespaceGetOptions<"text">): Promise<string | null>;
1438 get<ExpectedValue = unknown>(key: Key, options?: KVNamespaceGetOptions<"json">): Promise<ExpectedValue | null>;
1439 get(key: Key, options?: KVNamespaceGetOptions<"arrayBuffer">): Promise<ArrayBuffer | null>;
1440 get(key: Key, options?: KVNamespaceGetOptions<"stream">): Promise<ReadableStream | null>;
1441 get(key: Array<Key>, type: "text"): Promise<Map<string, string | null>>;
1442 get<ExpectedValue = unknown>(key: Array<Key>, type: "json"): Promise<Map<string, ExpectedValue | null>>;
1443 get(key: Array<Key>, options?: Partial<KVNamespaceGetOptions<undefined>>): Promise<Map<string, string | null>>;
1444 get(key: Array<Key>, options?: KVNamespaceGetOptions<"text">): Promise<Map<string, string | null>>;
1445 get<ExpectedValue = unknown>(key: Array<Key>, options?: KVNamespaceGetOptions<"json">): Promise<Map<string, ExpectedValue | null>>;
1446 list<Metadata = unknown>(options?: KVNamespaceListOptions): Promise<KVNamespaceListResult<Metadata, Key>>;
1447 put(key: Key, value: string | ArrayBuffer | ArrayBufferView | ReadableStream, options?: KVNamespacePutOptions): Promise<void>;
1448 getWithMetadata<Metadata = unknown>(key: Key, options?: Partial<KVNamespaceGetOptions<undefined>>): Promise<KVNamespaceGetWithMetadataResult<string, Metadata>>;
1449 getWithMetadata<Metadata = unknown>(key: Key, type: "text"): Promise<KVNamespaceGetWithMetadataResult<string, Metadata>>;
1450 getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(key: Key, type: "json"): Promise<KVNamespaceGetWithMetadataResult<ExpectedValue, Metadata>>;
1451 getWithMetadata<Metadata = unknown>(key: Key, type: "arrayBuffer"): Promise<KVNamespaceGetWithMetadataResult<ArrayBuffer, Metadata>>;
1452 getWithMetadata<Metadata = unknown>(key: Key, type: "stream"): Promise<KVNamespaceGetWithMetadataResult<ReadableStream, Metadata>>;
1453 getWithMetadata<Metadata = unknown>(key: Key, options: KVNamespaceGetOptions<"text">): Promise<KVNamespaceGetWithMetadataResult<string, Metadata>>;
1454 getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(key: Key, options: KVNamespaceGetOptions<"json">): Promise<KVNamespaceGetWithMetadataResult<ExpectedValue, Metadata>>;
1455 getWithMetadata<Metadata = unknown>(key: Key, options: KVNamespaceGetOptions<"arrayBuffer">): Promise<KVNamespaceGetWithMetadataResult<ArrayBuffer, Metadata>>;
1456 getWithMetadata<Metadata = unknown>(key: Key, options: KVNamespaceGetOptions<"stream">): Promise<KVNamespaceGetWithMetadataResult<ReadableStream, Metadata>>;
1457 getWithMetadata<Metadata = unknown>(key: Array<Key>, type: "text"): Promise<Map<string, KVNamespaceGetWithMetadataResult<string, Metadata>>>;
1458 getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(key: Array<Key>, type: "json"): Promise<Map<string, KVNamespaceGetWithMetadataResult<ExpectedValue, Metadata>>>;
1459 getWithMetadata<Metadata = unknown>(key: Array<Key>, options?: Partial<KVNamespaceGetOptions<undefined>>): Promise<Map<string, KVNamespaceGetWithMetadataResult<string, Metadata>>>;
1460 getWithMetadata<Metadata = unknown>(key: Array<Key>, options?: KVNamespaceGetOptions<"text">): Promise<Map<string, KVNamespaceGetWithMetadataResult<string, Metadata>>>;
1461 getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(key: Array<Key>, options?: KVNamespaceGetOptions<"json">): Promise<Map<string, KVNamespaceGetWithMetadataResult<ExpectedValue, Metadata>>>;
1462 delete(key: Key): Promise<void>;
1463}
1464interface KVNamespaceListOptions {
1465 limit?: number;
1466 prefix?: (string | null);
1467 cursor?: (string | null);
1468}
1469interface KVNamespaceGetOptions<Type> {
1470 type: Type;
1471 cacheTtl?: number;
1472}
1473interface KVNamespacePutOptions {
1474 expiration?: number;
1475 expirationTtl?: number;
1476 metadata?: (any | null);
1477}
1478interface KVNamespaceGetWithMetadataResult<Value, Metadata> {
1479 value: Value | null;
1480 metadata: Metadata | null;
1481 cacheStatus: string | null;
1482}
1483type QueueContentType = "text" | "bytes" | "json" | "v8";
1484interface Queue<Body = unknown> {
1485 send(message: Body, options?: QueueSendOptions): Promise<void>;
1486 sendBatch(messages: Iterable<MessageSendRequest<Body>>, options?: QueueSendBatchOptions): Promise<void>;
1487}
1488interface QueueSendOptions {
1489 contentType?: QueueContentType;
1490 delaySeconds?: number;
1491}
1492interface QueueSendBatchOptions {
1493 delaySeconds?: number;
1494}
1495interface MessageSendRequest<Body = unknown> {
1496 body: Body;
1497 contentType?: QueueContentType;
1498 delaySeconds?: number;
1499}
1500interface QueueRetryOptions {
1501 delaySeconds?: number;
1502}
1503interface Message<Body = unknown> {
1504 readonly id: string;
1505 readonly timestamp: Date;
1506 readonly body: Body;
1507 readonly attempts: number;
1508 retry(options?: QueueRetryOptions): void;
1509 ack(): void;
1510}
1511interface QueueEvent<Body = unknown> extends ExtendableEvent {
1512 readonly messages: readonly Message<Body>[];
1513 readonly queue: string;
1514 retryAll(options?: QueueRetryOptions): void;
1515 ackAll(): void;
1516}
1517interface MessageBatch<Body = unknown> {
1518 readonly messages: readonly Message<Body>[];
1519 readonly queue: string;
1520 retryAll(options?: QueueRetryOptions): void;
1521 ackAll(): void;
1522}
1523interface R2Error extends Error {
1524 readonly name: string;
1525 readonly code: number;
1526 readonly message: string;
1527 readonly action: string;
1528 readonly stack: any;
1529}
1530interface R2ListOptions {
1531 limit?: number;
1532 prefix?: string;
1533 cursor?: string;
1534 delimiter?: string;
1535 startAfter?: string;
1536 include?: ("httpMetadata" | "customMetadata")[];
1537}
1538declare abstract class R2Bucket {
1539 head(key: string): Promise<R2Object | null>;
1540 get(key: string, options: R2GetOptions & {
1541 onlyIf: R2Conditional | Headers;
1542 }): Promise<R2ObjectBody | R2Object | null>;
1543 get(key: string, options?: R2GetOptions): Promise<R2ObjectBody | null>;
1544 put(key: string, value: ReadableStream | ArrayBuffer | ArrayBufferView | string | null | Blob, options?: R2PutOptions & {
1545 onlyIf: R2Conditional | Headers;
1546 }): Promise<R2Object | null>;
1547 put(key: string, value: ReadableStream | ArrayBuffer | ArrayBufferView | string | null | Blob, options?: R2PutOptions): Promise<R2Object>;
1548 createMultipartUpload(key: string, options?: R2MultipartOptions): Promise<R2MultipartUpload>;
1549 resumeMultipartUpload(key: string, uploadId: string): R2MultipartUpload;
1550 delete(keys: string | string[]): Promise<void>;
1551 list(options?: R2ListOptions): Promise<R2Objects>;
1552}
1553interface R2MultipartUpload {
1554 readonly key: string;
1555 readonly uploadId: string;
1556 uploadPart(partNumber: number, value: ReadableStream | (ArrayBuffer | ArrayBufferView) | string | Blob, options?: R2UploadPartOptions): Promise<R2UploadedPart>;
1557 abort(): Promise<void>;
1558 complete(uploadedParts: R2UploadedPart[]): Promise<R2Object>;
1559}
1560interface R2UploadedPart {
1561 partNumber: number;
1562 etag: string;
1563}
1564declare abstract class R2Object {
1565 readonly key: string;
1566 readonly version: string;
1567 readonly size: number;
1568 readonly etag: string;
1569 readonly httpEtag: string;
1570 readonly checksums: R2Checksums;
1571 readonly uploaded: Date;
1572 readonly httpMetadata?: R2HTTPMetadata;
1573 readonly customMetadata?: Record<string, string>;
1574 readonly range?: R2Range;
1575 readonly storageClass: string;
1576 readonly ssecKeyMd5?: string;
1577 writeHttpMetadata(headers: Headers): void;
1578}
1579interface R2ObjectBody extends R2Object {
1580 get body(): ReadableStream;
1581 get bodyUsed(): boolean;
1582 arrayBuffer(): Promise<ArrayBuffer>;
1583 bytes(): Promise<Uint8Array>;
1584 text(): Promise<string>;
1585 json<T>(): Promise<T>;
1586 blob(): Promise<Blob>;
1587}
1588type R2Range = {
1589 offset: number;
1590 length?: number;
1591} | {
1592 offset?: number;
1593 length: number;
1594} | {
1595 suffix: number;
1596};
1597interface R2Conditional {
1598 etagMatches?: string;
1599 etagDoesNotMatch?: string;
1600 uploadedBefore?: Date;
1601 uploadedAfter?: Date;
1602 secondsGranularity?: boolean;
1603}
1604interface R2GetOptions {
1605 onlyIf?: (R2Conditional | Headers);
1606 range?: (R2Range | Headers);
1607 ssecKey?: (ArrayBuffer | string);
1608}
1609interface R2PutOptions {
1610 onlyIf?: (R2Conditional | Headers);
1611 httpMetadata?: (R2HTTPMetadata | Headers);
1612 customMetadata?: Record<string, string>;
1613 md5?: ((ArrayBuffer | ArrayBufferView) | string);
1614 sha1?: ((ArrayBuffer | ArrayBufferView) | string);
1615 sha256?: ((ArrayBuffer | ArrayBufferView) | string);
1616 sha384?: ((ArrayBuffer | ArrayBufferView) | string);
1617 sha512?: ((ArrayBuffer | ArrayBufferView) | string);
1618 storageClass?: string;
1619 ssecKey?: (ArrayBuffer | string);
1620}
1621interface R2MultipartOptions {
1622 httpMetadata?: (R2HTTPMetadata | Headers);
1623 customMetadata?: Record<string, string>;
1624 storageClass?: string;
1625 ssecKey?: (ArrayBuffer | string);
1626}
1627interface R2Checksums {
1628 readonly md5?: ArrayBuffer;
1629 readonly sha1?: ArrayBuffer;
1630 readonly sha256?: ArrayBuffer;
1631 readonly sha384?: ArrayBuffer;
1632 readonly sha512?: ArrayBuffer;
1633 toJSON(): R2StringChecksums;
1634}
1635interface R2StringChecksums {
1636 md5?: string;
1637 sha1?: string;
1638 sha256?: string;
1639 sha384?: string;
1640 sha512?: string;
1641}
1642interface R2HTTPMetadata {
1643 contentType?: string;
1644 contentLanguage?: string;
1645 contentDisposition?: string;
1646 contentEncoding?: string;
1647 cacheControl?: string;
1648 cacheExpiry?: Date;
1649}
1650type R2Objects = {
1651 objects: R2Object[];
1652 delimitedPrefixes: string[];
1653} & ({
1654 truncated: true;
1655 cursor: string;
1656} | {
1657 truncated: false;
1658});
1659interface R2UploadPartOptions {
1660 ssecKey?: (ArrayBuffer | string);
1661}
1662declare abstract class ScheduledEvent extends ExtendableEvent {
1663 readonly scheduledTime: number;
1664 readonly cron: string;
1665 noRetry(): void;
1666}
1667interface ScheduledController {
1668 readonly scheduledTime: number;
1669 readonly cron: string;
1670 noRetry(): void;
1671}
1672interface QueuingStrategy<T = any> {
1673 highWaterMark?: (number | bigint);
1674 size?: (chunk: T) => number | bigint;
1675}
1676interface UnderlyingSink<W = any> {
1677 type?: string;
1678 start?: (controller: WritableStreamDefaultController) => void | Promise<void>;
1679 write?: (chunk: W, controller: WritableStreamDefaultController) => void | Promise<void>;
1680 abort?: (reason: any) => void | Promise<void>;
1681 close?: () => void | Promise<void>;
1682}
1683interface UnderlyingByteSource {
1684 type: "bytes";
1685 autoAllocateChunkSize?: number;
1686 start?: (controller: ReadableByteStreamController) => void | Promise<void>;
1687 pull?: (controller: ReadableByteStreamController) => void | Promise<void>;
1688 cancel?: (reason: any) => void | Promise<void>;
1689}
1690interface UnderlyingSource<R = any> {
1691 type?: "" | undefined;
1692 start?: (controller: ReadableStreamDefaultController<R>) => void | Promise<void>;
1693 pull?: (controller: ReadableStreamDefaultController<R>) => void | Promise<void>;
1694 cancel?: (reason: any) => void | Promise<void>;
1695 expectedLength?: (number | bigint);
1696}
1697interface Transformer<I = any, O = any> {
1698 readableType?: string;
1699 writableType?: string;
1700 start?: (controller: TransformStreamDefaultController<O>) => void | Promise<void>;
1701 transform?: (chunk: I, controller: TransformStreamDefaultController<O>) => void | Promise<void>;
1702 flush?: (controller: TransformStreamDefaultController<O>) => void | Promise<void>;
1703 cancel?: (reason: any) => void | Promise<void>;
1704 expectedLength?: number;
1705}
1706interface StreamPipeOptions {
1707 /**
1708 * 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.
1709 *
1710 * Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader.
1711 *
1712 * Errors and closures of the source and destination streams propagate as follows:
1713 *
1714 * 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.
1715 *
1716 * 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.
1717 *
1718 * 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.
1719 *
1720 * 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.
1721 *
1722 * 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.
1723 */
1724 preventClose?: boolean;
1725 preventAbort?: boolean;
1726 preventCancel?: boolean;
1727 signal?: AbortSignal;
1728}
1729type ReadableStreamReadResult<R = any> = {
1730 done: false;
1731 value: R;
1732} | {
1733 done: true;
1734 value?: undefined;
1735};
1736/**
1737 * 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.
1738 *
1739 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream)
1740 */
1741interface ReadableStream<R = any> {
1742 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/locked) */
1743 get locked(): boolean;
1744 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/cancel) */
1745 cancel(reason?: any): Promise<void>;
1746 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/getReader) */
1747 getReader(): ReadableStreamDefaultReader<R>;
1748 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/getReader) */
1749 getReader(options: ReadableStreamGetReaderOptions): ReadableStreamBYOBReader;
1750 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/pipeThrough) */
1751 pipeThrough<T>(transform: ReadableWritablePair<T, R>, options?: StreamPipeOptions): ReadableStream<T>;
1752 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/pipeTo) */
1753 pipeTo(destination: WritableStream<R>, options?: StreamPipeOptions): Promise<void>;
1754 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/tee) */
1755 tee(): [
1756 ReadableStream<R>,
1757 ReadableStream<R>
1758 ];
1759 values(options?: ReadableStreamValuesOptions): AsyncIterableIterator<R>;
1760 [Symbol.asyncIterator](options?: ReadableStreamValuesOptions): AsyncIterableIterator<R>;
1761}
1762/**
1763 * 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.
1764 *
1765 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream)
1766 */
1767declare const ReadableStream: {
1768 prototype: ReadableStream;
1769 new (underlyingSource: UnderlyingByteSource, strategy?: QueuingStrategy<Uint8Array>): ReadableStream<Uint8Array>;
1770 new <R = any>(underlyingSource?: UnderlyingSource<R>, strategy?: QueuingStrategy<R>): ReadableStream<R>;
1771};
1772/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultReader) */
1773declare class ReadableStreamDefaultReader<R = any> {
1774 constructor(stream: ReadableStream);
1775 get closed(): Promise<void>;
1776 cancel(reason?: any): Promise<void>;
1777 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultReader/read) */
1778 read(): Promise<ReadableStreamReadResult<R>>;
1779 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultReader/releaseLock) */
1780 releaseLock(): void;
1781}
1782/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader) */
1783declare class ReadableStreamBYOBReader {
1784 constructor(stream: ReadableStream);
1785 get closed(): Promise<void>;
1786 cancel(reason?: any): Promise<void>;
1787 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader/read) */
1788 read<T extends ArrayBufferView>(view: T): Promise<ReadableStreamReadResult<T>>;
1789 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader/releaseLock) */
1790 releaseLock(): void;
1791 readAtLeast<T extends ArrayBufferView>(minElements: number, view: T): Promise<ReadableStreamReadResult<T>>;
1792}
1793interface ReadableStreamBYOBReaderReadableStreamBYOBReaderReadOptions {
1794 min?: number;
1795}
1796interface ReadableStreamGetReaderOptions {
1797 /**
1798 * Creates a ReadableStreamBYOBReader and locks the stream to the new reader.
1799 *
1800 * 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.
1801 */
1802 mode: "byob";
1803}
1804/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest) */
1805declare abstract class ReadableStreamBYOBRequest {
1806 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest/view) */
1807 get view(): Uint8Array | null;
1808 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest/respond) */
1809 respond(bytesWritten: number): void;
1810 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest/respondWithNewView) */
1811 respondWithNewView(view: ArrayBuffer | ArrayBufferView): void;
1812 get atLeast(): number | null;
1813}
1814/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController) */
1815declare abstract class ReadableStreamDefaultController<R = any> {
1816 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController/desiredSize) */
1817 get desiredSize(): number | null;
1818 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController/close) */
1819 close(): void;
1820 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController/enqueue) */
1821 enqueue(chunk?: R): void;
1822 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController/error) */
1823 error(reason: any): void;
1824}
1825/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController) */
1826declare abstract class ReadableByteStreamController {
1827 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/byobRequest) */
1828 get byobRequest(): ReadableStreamBYOBRequest | null;
1829 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/desiredSize) */
1830 get desiredSize(): number | null;
1831 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/close) */
1832 close(): void;
1833 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/enqueue) */
1834 enqueue(chunk: ArrayBuffer | ArrayBufferView): void;
1835 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/error) */
1836 error(reason: any): void;
1837}
1838/**
1839 * 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.
1840 *
1841 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultController)
1842 */
1843declare abstract class WritableStreamDefaultController {
1844 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultController/signal) */
1845 get signal(): AbortSignal;
1846 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultController/error) */
1847 error(reason?: any): void;
1848}
1849/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController) */
1850declare abstract class TransformStreamDefaultController<O = any> {
1851 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController/desiredSize) */
1852 get desiredSize(): number | null;
1853 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController/enqueue) */
1854 enqueue(chunk?: O): void;
1855 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController/error) */
1856 error(reason: any): void;
1857 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController/terminate) */
1858 terminate(): void;
1859}
1860interface ReadableWritablePair<R = any, W = any> {
1861 /**
1862 * 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.
1863 *
1864 * Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader.
1865 */
1866 writable: WritableStream<W>;
1867 readable: ReadableStream<R>;
1868}
1869/**
1870 * 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.
1871 *
1872 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream)
1873 */
1874declare class WritableStream<W = any> {
1875 constructor(underlyingSink?: UnderlyingSink, queuingStrategy?: QueuingStrategy);
1876 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream/locked) */
1877 get locked(): boolean;
1878 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream/abort) */
1879 abort(reason?: any): Promise<void>;
1880 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream/close) */
1881 close(): Promise<void>;
1882 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream/getWriter) */
1883 getWriter(): WritableStreamDefaultWriter<W>;
1884}
1885/**
1886 * 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.
1887 *
1888 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter)
1889 */
1890declare class WritableStreamDefaultWriter<W = any> {
1891 constructor(stream: WritableStream);
1892 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/closed) */
1893 get closed(): Promise<void>;
1894 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/ready) */
1895 get ready(): Promise<void>;
1896 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/desiredSize) */
1897 get desiredSize(): number | null;
1898 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/abort) */
1899 abort(reason?: any): Promise<void>;
1900 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/close) */
1901 close(): Promise<void>;
1902 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/write) */
1903 write(chunk?: W): Promise<void>;
1904 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/releaseLock) */
1905 releaseLock(): void;
1906}
1907/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStream) */
1908declare class TransformStream<I = any, O = any> {
1909 constructor(transformer?: Transformer<I, O>, writableStrategy?: QueuingStrategy<I>, readableStrategy?: QueuingStrategy<O>);
1910 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStream/readable) */
1911 get readable(): ReadableStream<O>;
1912 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStream/writable) */
1913 get writable(): WritableStream<I>;
1914}
1915declare class FixedLengthStream extends IdentityTransformStream {
1916 constructor(expectedLength: number | bigint, queuingStrategy?: IdentityTransformStreamQueuingStrategy);
1917}
1918declare class IdentityTransformStream extends TransformStream<ArrayBuffer | ArrayBufferView, Uint8Array> {
1919 constructor(queuingStrategy?: IdentityTransformStreamQueuingStrategy);
1920}
1921interface IdentityTransformStreamQueuingStrategy {
1922 highWaterMark?: (number | bigint);
1923}
1924interface ReadableStreamValuesOptions {
1925 preventCancel?: boolean;
1926}
1927/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CompressionStream) */
1928declare class CompressionStream extends TransformStream<ArrayBuffer | ArrayBufferView, Uint8Array> {
1929 constructor(format: "gzip" | "deflate" | "deflate-raw");
1930}
1931/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/DecompressionStream) */
1932declare class DecompressionStream extends TransformStream<ArrayBuffer | ArrayBufferView, Uint8Array> {
1933 constructor(format: "gzip" | "deflate" | "deflate-raw");
1934}
1935/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextEncoderStream) */
1936declare class TextEncoderStream extends TransformStream<string, Uint8Array> {
1937 constructor();
1938 get encoding(): string;
1939}
1940/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextDecoderStream) */
1941declare class TextDecoderStream extends TransformStream<ArrayBuffer | ArrayBufferView, string> {
1942 constructor(label?: string, options?: TextDecoderStreamTextDecoderStreamInit);
1943 get encoding(): string;
1944 get fatal(): boolean;
1945 get ignoreBOM(): boolean;
1946}
1947interface TextDecoderStreamTextDecoderStreamInit {
1948 fatal?: boolean;
1949 ignoreBOM?: boolean;
1950}
1951/**
1952 * This Streams API interface provides a built-in byte length queuing strategy that can be used when constructing streams.
1953 *
1954 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ByteLengthQueuingStrategy)
1955 */
1956declare class ByteLengthQueuingStrategy implements QueuingStrategy<ArrayBufferView> {
1957 constructor(init: QueuingStrategyInit);
1958 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ByteLengthQueuingStrategy/highWaterMark) */
1959 get highWaterMark(): number;
1960 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ByteLengthQueuingStrategy/size) */
1961 get size(): (chunk?: any) => number;
1962}
1963/**
1964 * This Streams API interface provides a built-in byte length queuing strategy that can be used when constructing streams.
1965 *
1966 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CountQueuingStrategy)
1967 */
1968declare class CountQueuingStrategy implements QueuingStrategy {
1969 constructor(init: QueuingStrategyInit);
1970 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CountQueuingStrategy/highWaterMark) */
1971 get highWaterMark(): number;
1972 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CountQueuingStrategy/size) */
1973 get size(): (chunk?: any) => number;
1974}
1975interface QueuingStrategyInit {
1976 /**
1977 * Creates a new ByteLengthQueuingStrategy with the provided high water mark.
1978 *
1979 * 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.
1980 */
1981 highWaterMark: number;
1982}
1983interface ScriptVersion {
1984 id?: string;
1985 tag?: string;
1986 message?: string;
1987}
1988declare abstract class TailEvent extends ExtendableEvent {
1989 readonly events: TraceItem[];
1990 readonly traces: TraceItem[];
1991}
1992interface TraceItem {
1993 readonly event: (TraceItemFetchEventInfo | TraceItemJsRpcEventInfo | TraceItemScheduledEventInfo | TraceItemAlarmEventInfo | TraceItemQueueEventInfo | TraceItemEmailEventInfo | TraceItemTailEventInfo | TraceItemCustomEventInfo | TraceItemHibernatableWebSocketEventInfo) | null;
1994 readonly eventTimestamp: number | null;
1995 readonly logs: TraceLog[];
1996 readonly exceptions: TraceException[];
1997 readonly diagnosticsChannelEvents: TraceDiagnosticChannelEvent[];
1998 readonly scriptName: string | null;
1999 readonly entrypoint?: string;
2000 readonly scriptVersion?: ScriptVersion;
2001 readonly dispatchNamespace?: string;
2002 readonly scriptTags?: string[];
2003 readonly outcome: string;
2004 readonly executionModel: string;
2005 readonly truncated: boolean;
2006 readonly cpuTime: number;
2007 readonly wallTime: number;
2008}
2009interface TraceItemAlarmEventInfo {
2010 readonly scheduledTime: Date;
2011}
2012interface TraceItemCustomEventInfo {
2013}
2014interface TraceItemScheduledEventInfo {
2015 readonly scheduledTime: number;
2016 readonly cron: string;
2017}
2018interface TraceItemQueueEventInfo {
2019 readonly queue: string;
2020 readonly batchSize: number;
2021}
2022interface TraceItemEmailEventInfo {
2023 readonly mailFrom: string;
2024 readonly rcptTo: string;
2025 readonly rawSize: number;
2026}
2027interface TraceItemTailEventInfo {
2028 readonly consumedEvents: TraceItemTailEventInfoTailItem[];
2029}
2030interface TraceItemTailEventInfoTailItem {
2031 readonly scriptName: string | null;
2032}
2033interface TraceItemFetchEventInfo {
2034 readonly response?: TraceItemFetchEventInfoResponse;
2035 readonly request: TraceItemFetchEventInfoRequest;
2036}
2037interface TraceItemFetchEventInfoRequest {
2038 readonly cf?: any;
2039 readonly headers: Record<string, string>;
2040 readonly method: string;
2041 readonly url: string;
2042 getUnredacted(): TraceItemFetchEventInfoRequest;
2043}
2044interface TraceItemFetchEventInfoResponse {
2045 readonly status: number;
2046}
2047interface TraceItemJsRpcEventInfo {
2048 readonly rpcMethod: string;
2049}
2050interface TraceItemHibernatableWebSocketEventInfo {
2051 readonly getWebSocketEvent: TraceItemHibernatableWebSocketEventInfoMessage | TraceItemHibernatableWebSocketEventInfoClose | TraceItemHibernatableWebSocketEventInfoError;
2052}
2053interface TraceItemHibernatableWebSocketEventInfoMessage {
2054 readonly webSocketEventType: string;
2055}
2056interface TraceItemHibernatableWebSocketEventInfoClose {
2057 readonly webSocketEventType: string;
2058 readonly code: number;
2059 readonly wasClean: boolean;
2060}
2061interface TraceItemHibernatableWebSocketEventInfoError {
2062 readonly webSocketEventType: string;
2063}
2064interface TraceLog {
2065 readonly timestamp: number;
2066 readonly level: string;
2067 readonly message: any;
2068}
2069interface TraceException {
2070 readonly timestamp: number;
2071 readonly message: string;
2072 readonly name: string;
2073 readonly stack?: string;
2074}
2075interface TraceDiagnosticChannelEvent {
2076 readonly timestamp: number;
2077 readonly channel: string;
2078 readonly message: any;
2079}
2080interface TraceMetrics {
2081 readonly cpuTime: number;
2082 readonly wallTime: number;
2083}
2084interface UnsafeTraceMetrics {
2085 fromTrace(item: TraceItem): TraceMetrics;
2086}
2087/**
2088 * The URL interface represents an object providing static methods used for creating object URLs.
2089 *
2090 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL)
2091 */
2092declare class URL {
2093 constructor(url: string | URL, base?: string | URL);
2094 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/origin) */
2095 get origin(): string;
2096 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/href) */
2097 get href(): string;
2098 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/href) */
2099 set href(value: string);
2100 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/protocol) */
2101 get protocol(): string;
2102 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/protocol) */
2103 set protocol(value: string);
2104 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/username) */
2105 get username(): string;
2106 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/username) */
2107 set username(value: string);
2108 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/password) */
2109 get password(): string;
2110 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/password) */
2111 set password(value: string);
2112 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/host) */
2113 get host(): string;
2114 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/host) */
2115 set host(value: string);
2116 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hostname) */
2117 get hostname(): string;
2118 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hostname) */
2119 set hostname(value: string);
2120 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/port) */
2121 get port(): string;
2122 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/port) */
2123 set port(value: string);
2124 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/pathname) */
2125 get pathname(): string;
2126 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/pathname) */
2127 set pathname(value: string);
2128 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/search) */
2129 get search(): string;
2130 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/search) */
2131 set search(value: string);
2132 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hash) */
2133 get hash(): string;
2134 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hash) */
2135 set hash(value: string);
2136 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/searchParams) */
2137 get searchParams(): URLSearchParams;
2138 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/toJSON) */
2139 toJSON(): string;
2140 /*function toString() { [native code] }*/
2141 toString(): string;
2142 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/canParse_static) */
2143 static canParse(url: string, base?: string): boolean;
2144 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/parse_static) */
2145 static parse(url: string, base?: string): URL | null;
2146 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/createObjectURL_static) */
2147 static createObjectURL(object: File | Blob): string;
2148 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/revokeObjectURL_static) */
2149 static revokeObjectURL(object_url: string): void;
2150}
2151/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams) */
2152declare class URLSearchParams {
2153 constructor(init?: (Iterable<Iterable<string>> | Record<string, string> | string));
2154 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/size) */
2155 get size(): number;
2156 /**
2157 * Appends a specified key/value pair as a new search parameter.
2158 *
2159 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/append)
2160 */
2161 append(name: string, value: string): void;
2162 /**
2163 * Deletes the given search parameter, and its associated value, from the list of all search parameters.
2164 *
2165 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/delete)
2166 */
2167 delete(name: string, value?: string): void;
2168 /**
2169 * Returns the first value associated to the given search parameter.
2170 *
2171 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/get)
2172 */
2173 get(name: string): string | null;
2174 /**
2175 * Returns all the values association with a given search parameter.
2176 *
2177 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/getAll)
2178 */
2179 getAll(name: string): string[];
2180 /**
2181 * Returns a Boolean indicating if such a search parameter exists.
2182 *
2183 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/has)
2184 */
2185 has(name: string, value?: string): boolean;
2186 /**
2187 * Sets the value associated to a given search parameter to the given value. If there were several values, delete the others.
2188 *
2189 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/set)
2190 */
2191 set(name: string, value: string): void;
2192 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/sort) */
2193 sort(): void;
2194 /* Returns an array of key, value pairs for every entry in the search params. */
2195 entries(): IterableIterator<[
2196 key: string,
2197 value: string
2198 ]>;
2199 /* Returns a list of keys in the search params. */
2200 keys(): IterableIterator<string>;
2201 /* Returns a list of values in the search params. */
2202 values(): IterableIterator<string>;
2203 forEach<This = unknown>(callback: (this: This, value: string, key: string, parent: URLSearchParams) => void, thisArg?: This): void;
2204 /*function toString() { [native code] } Returns a string containing a query string suitable for use in a URL. Does not include the question mark. */
2205 toString(): string;
2206 [Symbol.iterator](): IterableIterator<[
2207 key: string,
2208 value: string
2209 ]>;
2210}
2211declare class URLPattern {
2212 constructor(input?: (string | URLPatternInit), baseURL?: (string | URLPatternOptions), patternOptions?: URLPatternOptions);
2213 get protocol(): string;
2214 get username(): string;
2215 get password(): string;
2216 get hostname(): string;
2217 get port(): string;
2218 get pathname(): string;
2219 get search(): string;
2220 get hash(): string;
2221 get hasRegExpGroups(): boolean;
2222 test(input?: (string | URLPatternInit), baseURL?: string): boolean;
2223 exec(input?: (string | URLPatternInit), baseURL?: string): URLPatternResult | null;
2224}
2225interface URLPatternInit {
2226 protocol?: string;
2227 username?: string;
2228 password?: string;
2229 hostname?: string;
2230 port?: string;
2231 pathname?: string;
2232 search?: string;
2233 hash?: string;
2234 baseURL?: string;
2235}
2236interface URLPatternComponentResult {
2237 input: string;
2238 groups: Record<string, string>;
2239}
2240interface URLPatternResult {
2241 inputs: (string | URLPatternInit)[];
2242 protocol: URLPatternComponentResult;
2243 username: URLPatternComponentResult;
2244 password: URLPatternComponentResult;
2245 hostname: URLPatternComponentResult;
2246 port: URLPatternComponentResult;
2247 pathname: URLPatternComponentResult;
2248 search: URLPatternComponentResult;
2249 hash: URLPatternComponentResult;
2250}
2251interface URLPatternOptions {
2252 ignoreCase?: boolean;
2253}
2254/**
2255 * 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.
2256 *
2257 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent)
2258 */
2259declare class CloseEvent extends Event {
2260 constructor(type: string, initializer?: CloseEventInit);
2261 /**
2262 * Returns the WebSocket connection close code provided by the server.
2263 *
2264 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent/code)
2265 */
2266 readonly code: number;
2267 /**
2268 * Returns the WebSocket connection close reason provided by the server.
2269 *
2270 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent/reason)
2271 */
2272 readonly reason: string;
2273 /**
2274 * Returns true if the connection closed cleanly; false otherwise.
2275 *
2276 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent/wasClean)
2277 */
2278 readonly wasClean: boolean;
2279}
2280interface CloseEventInit {
2281 code?: number;
2282 reason?: string;
2283 wasClean?: boolean;
2284}
2285/**
2286 * A message received by a target object.
2287 *
2288 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent)
2289 */
2290declare class MessageEvent extends Event {
2291 constructor(type: string, initializer: MessageEventInit);
2292 /**
2293 * Returns the data of the message.
2294 *
2295 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/data)
2296 */
2297 readonly data: ArrayBuffer | string;
2298}
2299interface MessageEventInit {
2300 data: ArrayBuffer | string;
2301}
2302type WebSocketEventMap = {
2303 close: CloseEvent;
2304 message: MessageEvent;
2305 open: Event;
2306 error: ErrorEvent;
2307};
2308/**
2309 * Provides the API for creating and managing a WebSocket connection to a server, as well as for sending and receiving data on the connection.
2310 *
2311 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket)
2312 */
2313declare var WebSocket: {
2314 prototype: WebSocket;
2315 new (url: string, protocols?: (string[] | string)): WebSocket;
2316 readonly READY_STATE_CONNECTING: number;
2317 readonly CONNECTING: number;
2318 readonly READY_STATE_OPEN: number;
2319 readonly OPEN: number;
2320 readonly READY_STATE_CLOSING: number;
2321 readonly CLOSING: number;
2322 readonly READY_STATE_CLOSED: number;
2323 readonly CLOSED: number;
2324};
2325/**
2326 * Provides the API for creating and managing a WebSocket connection to a server, as well as for sending and receiving data on the connection.
2327 *
2328 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket)
2329 */
2330interface WebSocket extends EventTarget<WebSocketEventMap> {
2331 accept(): void;
2332 /**
2333 * Transmits data using the WebSocket connection. data can be a string, a Blob, an ArrayBuffer, or an ArrayBufferView.
2334 *
2335 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/send)
2336 */
2337 send(message: (ArrayBuffer | ArrayBufferView) | string): void;
2338 /**
2339 * Closes the WebSocket connection, optionally using code as the the WebSocket connection close code and reason as the the WebSocket connection close reason.
2340 *
2341 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/close)
2342 */
2343 close(code?: number, reason?: string): void;
2344 serializeAttachment(attachment: any): void;
2345 deserializeAttachment(): any | null;
2346 /**
2347 * Returns the state of the WebSocket object's connection. It can have the values described below.
2348 *
2349 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/readyState)
2350 */
2351 readyState: number;
2352 /**
2353 * Returns the URL that was used to establish the WebSocket connection.
2354 *
2355 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/url)
2356 */
2357 url: string | null;
2358 /**
2359 * 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.
2360 *
2361 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/protocol)
2362 */
2363 protocol: string | null;
2364 /**
2365 * Returns the extensions selected by the server, if any.
2366 *
2367 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/extensions)
2368 */
2369 extensions: string | null;
2370}
2371declare const WebSocketPair: {
2372 new (): {
2373 0: WebSocket;
2374 1: WebSocket;
2375 };
2376};
2377interface SqlStorage {
2378 exec<T extends Record<string, SqlStorageValue>>(query: string, ...bindings: any[]): SqlStorageCursor<T>;
2379 get databaseSize(): number;
2380 Cursor: typeof SqlStorageCursor;
2381 Statement: typeof SqlStorageStatement;
2382}
2383declare abstract class SqlStorageStatement {
2384}
2385type SqlStorageValue = ArrayBuffer | string | number | null;
2386declare abstract class SqlStorageCursor<T extends Record<string, SqlStorageValue>> {
2387 next(): {
2388 done?: false;
2389 value: T;
2390 } | {
2391 done: true;
2392 value?: never;
2393 };
2394 toArray(): T[];
2395 one(): T;
2396 raw<U extends SqlStorageValue[]>(): IterableIterator<U>;
2397 columnNames: string[];
2398 get rowsRead(): number;
2399 get rowsWritten(): number;
2400 [Symbol.iterator](): IterableIterator<T>;
2401}
2402interface Socket {
2403 get readable(): ReadableStream;
2404 get writable(): WritableStream;
2405 get closed(): Promise<void>;
2406 get opened(): Promise<SocketInfo>;
2407 get upgraded(): boolean;
2408 get secureTransport(): "on" | "off" | "starttls";
2409 close(): Promise<void>;
2410 startTls(options?: TlsOptions): Socket;
2411}
2412interface SocketOptions {
2413 secureTransport?: string;
2414 allowHalfOpen: boolean;
2415 highWaterMark?: (number | bigint);
2416}
2417interface SocketAddress {
2418 hostname: string;
2419 port: number;
2420}
2421interface TlsOptions {
2422 expectedServerHostname?: string;
2423}
2424interface SocketInfo {
2425 remoteAddress?: string;
2426 localAddress?: string;
2427}
2428/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource) */
2429declare class EventSource extends EventTarget {
2430 constructor(url: string, init?: EventSourceEventSourceInit);
2431 /**
2432 * Aborts any instances of the fetch algorithm started for this EventSource object, and sets the readyState attribute to CLOSED.
2433 *
2434 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/close)
2435 */
2436 close(): void;
2437 /**
2438 * Returns the URL providing the event stream.
2439 *
2440 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/url)
2441 */
2442 get url(): string;
2443 /**
2444 * Returns true if the credentials mode for connection requests to the URL providing the event stream is set to "include", and false otherwise.
2445 *
2446 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/withCredentials)
2447 */
2448 get withCredentials(): boolean;
2449 /**
2450 * Returns the state of this EventSource object's connection. It can have the values described below.
2451 *
2452 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/readyState)
2453 */
2454 get readyState(): number;
2455 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */
2456 get onopen(): any | null;
2457 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */
2458 set onopen(value: any | null);
2459 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */
2460 get onmessage(): any | null;
2461 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */
2462 set onmessage(value: any | null);
2463 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */
2464 get onerror(): any | null;
2465 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */
2466 set onerror(value: any | null);
2467 static readonly CONNECTING: number;
2468 static readonly OPEN: number;
2469 static readonly CLOSED: number;
2470 static from(stream: ReadableStream): EventSource;
2471}
2472interface EventSourceEventSourceInit {
2473 withCredentials?: boolean;
2474 fetcher?: Fetcher;
2475}
2476interface Container {
2477 get running(): boolean;
2478 start(options?: ContainerStartupOptions): void;
2479 monitor(): Promise<void>;
2480 destroy(error?: any): Promise<void>;
2481 signal(signo: number): void;
2482 getTcpPort(port: number): Fetcher;
2483}
2484interface ContainerStartupOptions {
2485 entrypoint?: string[];
2486 enableInternet: boolean;
2487 env?: Record<string, string>;
2488}
2489type AiImageClassificationInput = {
2490 image: number[];
2491};
2492type AiImageClassificationOutput = {
2493 score?: number;
2494 label?: string;
2495}[];
2496declare abstract class BaseAiImageClassification {
2497 inputs: AiImageClassificationInput;
2498 postProcessedOutputs: AiImageClassificationOutput;
2499}
2500type AiImageToTextInput = {
2501 image: number[];
2502 prompt?: string;
2503 max_tokens?: number;
2504 temperature?: number;
2505 top_p?: number;
2506 top_k?: number;
2507 seed?: number;
2508 repetition_penalty?: number;
2509 frequency_penalty?: number;
2510 presence_penalty?: number;
2511 raw?: boolean;
2512 messages?: RoleScopedChatInput[];
2513};
2514type AiImageToTextOutput = {
2515 description: string;
2516};
2517declare abstract class BaseAiImageToText {
2518 inputs: AiImageToTextInput;
2519 postProcessedOutputs: AiImageToTextOutput;
2520}
2521type AiImageTextToTextInput = {
2522 image: string;
2523 prompt?: string;
2524 max_tokens?: number;
2525 temperature?: number;
2526 ignore_eos?: boolean;
2527 top_p?: number;
2528 top_k?: number;
2529 seed?: number;
2530 repetition_penalty?: number;
2531 frequency_penalty?: number;
2532 presence_penalty?: number;
2533 raw?: boolean;
2534 messages?: RoleScopedChatInput[];
2535};
2536type AiImageTextToTextOutput = {
2537 description: string;
2538};
2539declare abstract class BaseAiImageTextToText {
2540 inputs: AiImageTextToTextInput;
2541 postProcessedOutputs: AiImageTextToTextOutput;
2542}
2543type AiObjectDetectionInput = {
2544 image: number[];
2545};
2546type AiObjectDetectionOutput = {
2547 score?: number;
2548 label?: string;
2549}[];
2550declare abstract class BaseAiObjectDetection {
2551 inputs: AiObjectDetectionInput;
2552 postProcessedOutputs: AiObjectDetectionOutput;
2553}
2554type AiSentenceSimilarityInput = {
2555 source: string;
2556 sentences: string[];
2557};
2558type AiSentenceSimilarityOutput = number[];
2559declare abstract class BaseAiSentenceSimilarity {
2560 inputs: AiSentenceSimilarityInput;
2561 postProcessedOutputs: AiSentenceSimilarityOutput;
2562}
2563type AiAutomaticSpeechRecognitionInput = {
2564 audio: number[];
2565};
2566type AiAutomaticSpeechRecognitionOutput = {
2567 text?: string;
2568 words?: {
2569 word: string;
2570 start: number;
2571 end: number;
2572 }[];
2573 vtt?: string;
2574};
2575declare abstract class BaseAiAutomaticSpeechRecognition {
2576 inputs: AiAutomaticSpeechRecognitionInput;
2577 postProcessedOutputs: AiAutomaticSpeechRecognitionOutput;
2578}
2579type AiSummarizationInput = {
2580 input_text: string;
2581 max_length?: number;
2582};
2583type AiSummarizationOutput = {
2584 summary: string;
2585};
2586declare abstract class BaseAiSummarization {
2587 inputs: AiSummarizationInput;
2588 postProcessedOutputs: AiSummarizationOutput;
2589}
2590type AiTextClassificationInput = {
2591 text: string;
2592};
2593type AiTextClassificationOutput = {
2594 score?: number;
2595 label?: string;
2596}[];
2597declare abstract class BaseAiTextClassification {
2598 inputs: AiTextClassificationInput;
2599 postProcessedOutputs: AiTextClassificationOutput;
2600}
2601type AiTextEmbeddingsInput = {
2602 text: string | string[];
2603};
2604type AiTextEmbeddingsOutput = {
2605 shape: number[];
2606 data: number[][];
2607};
2608declare abstract class BaseAiTextEmbeddings {
2609 inputs: AiTextEmbeddingsInput;
2610 postProcessedOutputs: AiTextEmbeddingsOutput;
2611}
2612type RoleScopedChatInput = {
2613 role: "user" | "assistant" | "system" | "tool" | (string & NonNullable<unknown>);
2614 content: string;
2615 name?: string;
2616};
2617type AiTextGenerationToolLegacyInput = {
2618 name: string;
2619 description: string;
2620 parameters?: {
2621 type: "object" | (string & NonNullable<unknown>);
2622 properties: {
2623 [key: string]: {
2624 type: string;
2625 description?: string;
2626 };
2627 };
2628 required: string[];
2629 };
2630};
2631type AiTextGenerationToolInput = {
2632 type: "function" | (string & NonNullable<unknown>);
2633 function: {
2634 name: string;
2635 description: string;
2636 parameters?: {
2637 type: "object" | (string & NonNullable<unknown>);
2638 properties: {
2639 [key: string]: {
2640 type: string;
2641 description?: string;
2642 };
2643 };
2644 required: string[];
2645 };
2646 };
2647};
2648type AiTextGenerationFunctionsInput = {
2649 name: string;
2650 code: string;
2651};
2652type AiTextGenerationResponseFormat = {
2653 type: string;
2654 json_schema?: any;
2655};
2656type AiTextGenerationInput = {
2657 prompt?: string;
2658 raw?: boolean;
2659 stream?: boolean;
2660 max_tokens?: number;
2661 temperature?: number;
2662 top_p?: number;
2663 top_k?: number;
2664 seed?: number;
2665 repetition_penalty?: number;
2666 frequency_penalty?: number;
2667 presence_penalty?: number;
2668 messages?: RoleScopedChatInput[];
2669 response_format?: AiTextGenerationResponseFormat;
2670 tools?: AiTextGenerationToolInput[] | AiTextGenerationToolLegacyInput[] | (object & NonNullable<unknown>);
2671 functions?: AiTextGenerationFunctionsInput[];
2672};
2673type AiTextGenerationOutput = {
2674 response?: string;
2675 tool_calls?: {
2676 name: string;
2677 arguments: unknown;
2678 }[];
2679} | ReadableStream;
2680declare abstract class BaseAiTextGeneration {
2681 inputs: AiTextGenerationInput;
2682 postProcessedOutputs: AiTextGenerationOutput;
2683}
2684type AiTextToSpeechInput = {
2685 prompt: string;
2686 lang?: string;
2687};
2688type AiTextToSpeechOutput = Uint8Array | {
2689 audio: string;
2690};
2691declare abstract class BaseAiTextToSpeech {
2692 inputs: AiTextToSpeechInput;
2693 postProcessedOutputs: AiTextToSpeechOutput;
2694}
2695type AiTextToImageInput = {
2696 prompt: string;
2697 negative_prompt?: string;
2698 height?: number;
2699 width?: number;
2700 image?: number[];
2701 image_b64?: string;
2702 mask?: number[];
2703 num_steps?: number;
2704 strength?: number;
2705 guidance?: number;
2706 seed?: number;
2707};
2708type AiTextToImageOutput = ReadableStream<Uint8Array>;
2709declare abstract class BaseAiTextToImage {
2710 inputs: AiTextToImageInput;
2711 postProcessedOutputs: AiTextToImageOutput;
2712}
2713type AiTranslationInput = {
2714 text: string;
2715 target_lang: string;
2716 source_lang?: string;
2717};
2718type AiTranslationOutput = {
2719 translated_text?: string;
2720};
2721declare abstract class BaseAiTranslation {
2722 inputs: AiTranslationInput;
2723 postProcessedOutputs: AiTranslationOutput;
2724}
2725type Ai_Cf_Openai_Whisper_Input = string | {
2726 /**
2727 * An array of integers that represent the audio data constrained to 8-bit unsigned integer values
2728 */
2729 audio: number[];
2730};
2731interface Ai_Cf_Openai_Whisper_Output {
2732 /**
2733 * The transcription
2734 */
2735 text: string;
2736 word_count?: number;
2737 words?: {
2738 word?: string;
2739 /**
2740 * The second this word begins in the recording
2741 */
2742 start?: number;
2743 /**
2744 * The ending second when the word completes
2745 */
2746 end?: number;
2747 }[];
2748 vtt?: string;
2749}
2750declare abstract class Base_Ai_Cf_Openai_Whisper {
2751 inputs: Ai_Cf_Openai_Whisper_Input;
2752 postProcessedOutputs: Ai_Cf_Openai_Whisper_Output;
2753}
2754type Ai_Cf_Unum_Uform_Gen2_Qwen_500M_Input = string | {
2755 /**
2756 * The input text prompt for the model to generate a response.
2757 */
2758 prompt?: string;
2759 /**
2760 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
2761 */
2762 raw?: boolean;
2763 /**
2764 * 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.
2765 */
2766 top_p?: number;
2767 /**
2768 * 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.
2769 */
2770 top_k?: number;
2771 /**
2772 * Random seed for reproducibility of the generation.
2773 */
2774 seed?: number;
2775 /**
2776 * Penalty for repeated tokens; higher values discourage repetition.
2777 */
2778 repetition_penalty?: number;
2779 /**
2780 * Decreases the likelihood of the model repeating the same lines verbatim.
2781 */
2782 frequency_penalty?: number;
2783 /**
2784 * Increases the likelihood of the model introducing new topics.
2785 */
2786 presence_penalty?: number;
2787 image: number[] | (string & NonNullable<unknown>);
2788 /**
2789 * The maximum number of tokens to generate in the response.
2790 */
2791 max_tokens?: number;
2792};
2793interface Ai_Cf_Unum_Uform_Gen2_Qwen_500M_Output {
2794 description?: string;
2795}
2796declare abstract class Base_Ai_Cf_Unum_Uform_Gen2_Qwen_500M {
2797 inputs: Ai_Cf_Unum_Uform_Gen2_Qwen_500M_Input;
2798 postProcessedOutputs: Ai_Cf_Unum_Uform_Gen2_Qwen_500M_Output;
2799}
2800type Ai_Cf_Openai_Whisper_Tiny_En_Input = string | {
2801 /**
2802 * An array of integers that represent the audio data constrained to 8-bit unsigned integer values
2803 */
2804 audio: number[];
2805};
2806interface Ai_Cf_Openai_Whisper_Tiny_En_Output {
2807 /**
2808 * The transcription
2809 */
2810 text: string;
2811 word_count?: number;
2812 words?: {
2813 word?: string;
2814 /**
2815 * The second this word begins in the recording
2816 */
2817 start?: number;
2818 /**
2819 * The ending second when the word completes
2820 */
2821 end?: number;
2822 }[];
2823 vtt?: string;
2824}
2825declare abstract class Base_Ai_Cf_Openai_Whisper_Tiny_En {
2826 inputs: Ai_Cf_Openai_Whisper_Tiny_En_Input;
2827 postProcessedOutputs: Ai_Cf_Openai_Whisper_Tiny_En_Output;
2828}
2829interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input {
2830 /**
2831 * Base64 encoded value of the audio data.
2832 */
2833 audio: string;
2834 /**
2835 * Supported tasks are 'translate' or 'transcribe'.
2836 */
2837 task?: string;
2838 /**
2839 * The language of the audio being transcribed or translated.
2840 */
2841 language?: string;
2842 /**
2843 * Preprocess the audio with a voice activity detection model.
2844 */
2845 vad_filter?: string;
2846 /**
2847 * A text prompt to help provide context to the model on the contents of the audio.
2848 */
2849 initial_prompt?: string;
2850 /**
2851 * The prefix it appended the the beginning of the output of the transcription and can guide the transcription result.
2852 */
2853 prefix?: string;
2854}
2855interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Output {
2856 transcription_info?: {
2857 /**
2858 * The language of the audio being transcribed or translated.
2859 */
2860 language?: string;
2861 /**
2862 * The confidence level or probability of the detected language being accurate, represented as a decimal between 0 and 1.
2863 */
2864 language_probability?: number;
2865 /**
2866 * The total duration of the original audio file, in seconds.
2867 */
2868 duration?: number;
2869 /**
2870 * The duration of the audio after applying Voice Activity Detection (VAD) to remove silent or irrelevant sections, in seconds.
2871 */
2872 duration_after_vad?: number;
2873 };
2874 /**
2875 * The complete transcription of the audio.
2876 */
2877 text: string;
2878 /**
2879 * The total number of words in the transcription.
2880 */
2881 word_count?: number;
2882 segments?: {
2883 /**
2884 * The starting time of the segment within the audio, in seconds.
2885 */
2886 start?: number;
2887 /**
2888 * The ending time of the segment within the audio, in seconds.
2889 */
2890 end?: number;
2891 /**
2892 * The transcription of the segment.
2893 */
2894 text?: string;
2895 /**
2896 * The temperature used in the decoding process, controlling randomness in predictions. Lower values result in more deterministic outputs.
2897 */
2898 temperature?: number;
2899 /**
2900 * The average log probability of the predictions for the words in this segment, indicating overall confidence.
2901 */
2902 avg_logprob?: number;
2903 /**
2904 * The compression ratio of the input to the output, measuring how much the text was compressed during the transcription process.
2905 */
2906 compression_ratio?: number;
2907 /**
2908 * The probability that the segment contains no speech, represented as a decimal between 0 and 1.
2909 */
2910 no_speech_prob?: number;
2911 words?: {
2912 /**
2913 * The individual word transcribed from the audio.
2914 */
2915 word?: string;
2916 /**
2917 * The starting time of the word within the audio, in seconds.
2918 */
2919 start?: number;
2920 /**
2921 * The ending time of the word within the audio, in seconds.
2922 */
2923 end?: number;
2924 }[];
2925 }[];
2926 /**
2927 * The transcription in WebVTT format, which includes timing and text information for use in subtitles.
2928 */
2929 vtt?: string;
2930}
2931declare abstract class Base_Ai_Cf_Openai_Whisper_Large_V3_Turbo {
2932 inputs: Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input;
2933 postProcessedOutputs: Ai_Cf_Openai_Whisper_Large_V3_Turbo_Output;
2934}
2935type Ai_Cf_Baai_Bge_M3_Input = BGEM3InputQueryAndContexts | BGEM3InputEmbedding;
2936interface BGEM3InputQueryAndContexts {
2937 /**
2938 * A query you wish to perform against the provided contexts. If no query is provided the model with respond with embeddings for contexts
2939 */
2940 query?: string;
2941 /**
2942 * List of provided contexts. Note that the index in this array is important, as the response will refer to it.
2943 */
2944 contexts: {
2945 /**
2946 * One of the provided context content
2947 */
2948 text?: string;
2949 }[];
2950 /**
2951 * When provided with too long context should the model error out or truncate the context to fit?
2952 */
2953 truncate_inputs?: boolean;
2954}
2955interface BGEM3InputEmbedding {
2956 text: string | string[];
2957 /**
2958 * When provided with too long context should the model error out or truncate the context to fit?
2959 */
2960 truncate_inputs?: boolean;
2961}
2962type Ai_Cf_Baai_Bge_M3_Output = BGEM3OuputQuery | BGEM3OutputEmbeddingForContexts | BGEM3OuputEmbedding;
2963interface BGEM3OuputQuery {
2964 response?: {
2965 /**
2966 * Index of the context in the request
2967 */
2968 id?: number;
2969 /**
2970 * Score of the context under the index.
2971 */
2972 score?: number;
2973 }[];
2974}
2975interface BGEM3OutputEmbeddingForContexts {
2976 response?: number[][];
2977 shape?: number[];
2978 /**
2979 * The pooling method used in the embedding process.
2980 */
2981 pooling?: "mean" | "cls";
2982}
2983interface BGEM3OuputEmbedding {
2984 shape?: number[];
2985 /**
2986 * Embeddings of the requested text values
2987 */
2988 data?: number[][];
2989 /**
2990 * The pooling method used in the embedding process.
2991 */
2992 pooling?: "mean" | "cls";
2993}
2994declare abstract class Base_Ai_Cf_Baai_Bge_M3 {
2995 inputs: Ai_Cf_Baai_Bge_M3_Input;
2996 postProcessedOutputs: Ai_Cf_Baai_Bge_M3_Output;
2997}
2998interface Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Input {
2999 /**
3000 * A text description of the image you want to generate.
3001 */
3002 prompt: string;
3003 /**
3004 * The number of diffusion steps; higher values can improve quality but take longer.
3005 */
3006 steps?: number;
3007}
3008interface Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Output {
3009 /**
3010 * The generated image in Base64 format.
3011 */
3012 image?: string;
3013}
3014declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_1_Schnell {
3015 inputs: Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Input;
3016 postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Output;
3017}
3018type Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Input = Prompt | Messages;
3019interface Prompt {
3020 /**
3021 * The input text prompt for the model to generate a response.
3022 */
3023 prompt: string;
3024 image?: number[] | (string & NonNullable<unknown>);
3025 /**
3026 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
3027 */
3028 raw?: boolean;
3029 /**
3030 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
3031 */
3032 stream?: boolean;
3033 /**
3034 * The maximum number of tokens to generate in the response.
3035 */
3036 max_tokens?: number;
3037 /**
3038 * Controls the randomness of the output; higher values produce more random results.
3039 */
3040 temperature?: number;
3041 /**
3042 * 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.
3043 */
3044 top_p?: number;
3045 /**
3046 * 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.
3047 */
3048 top_k?: number;
3049 /**
3050 * Random seed for reproducibility of the generation.
3051 */
3052 seed?: number;
3053 /**
3054 * Penalty for repeated tokens; higher values discourage repetition.
3055 */
3056 repetition_penalty?: number;
3057 /**
3058 * Decreases the likelihood of the model repeating the same lines verbatim.
3059 */
3060 frequency_penalty?: number;
3061 /**
3062 * Increases the likelihood of the model introducing new topics.
3063 */
3064 presence_penalty?: number;
3065 /**
3066 * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.
3067 */
3068 lora?: string;
3069}
3070interface Messages {
3071 /**
3072 * An array of message objects representing the conversation history.
3073 */
3074 messages: {
3075 /**
3076 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
3077 */
3078 role: string;
3079 /**
3080 * The content of the message as a string.
3081 */
3082 content: string;
3083 }[];
3084 image?: number[] | string;
3085 functions?: {
3086 name: string;
3087 code: string;
3088 }[];
3089 /**
3090 * A list of tools available for the assistant to use.
3091 */
3092 tools?: ({
3093 /**
3094 * The name of the tool. More descriptive the better.
3095 */
3096 name: string;
3097 /**
3098 * A brief description of what the tool does.
3099 */
3100 description: string;
3101 /**
3102 * Schema defining the parameters accepted by the tool.
3103 */
3104 parameters: {
3105 /**
3106 * The type of the parameters object (usually 'object').
3107 */
3108 type: string;
3109 /**
3110 * List of required parameter names.
3111 */
3112 required?: string[];
3113 /**
3114 * Definitions of each parameter.
3115 */
3116 properties: {
3117 [k: string]: {
3118 /**
3119 * The data type of the parameter.
3120 */
3121 type: string;
3122 /**
3123 * A description of the expected parameter.
3124 */
3125 description: string;
3126 };
3127 };
3128 };
3129 } | {
3130 /**
3131 * Specifies the type of tool (e.g., 'function').
3132 */
3133 type: string;
3134 /**
3135 * Details of the function tool.
3136 */
3137 function: {
3138 /**
3139 * The name of the function.
3140 */
3141 name: string;
3142 /**
3143 * A brief description of what the function does.
3144 */
3145 description: string;
3146 /**
3147 * Schema defining the parameters accepted by the function.
3148 */
3149 parameters: {
3150 /**
3151 * The type of the parameters object (usually 'object').
3152 */
3153 type: string;
3154 /**
3155 * List of required parameter names.
3156 */
3157 required?: string[];
3158 /**
3159 * Definitions of each parameter.
3160 */
3161 properties: {
3162 [k: string]: {
3163 /**
3164 * The data type of the parameter.
3165 */
3166 type: string;
3167 /**
3168 * A description of the expected parameter.
3169 */
3170 description: string;
3171 };
3172 };
3173 };
3174 };
3175 })[];
3176 /**
3177 * If true, the response will be streamed back incrementally.
3178 */
3179 stream?: boolean;
3180 /**
3181 * The maximum number of tokens to generate in the response.
3182 */
3183 max_tokens?: number;
3184 /**
3185 * Controls the randomness of the output; higher values produce more random results.
3186 */
3187 temperature?: number;
3188 /**
3189 * 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.
3190 */
3191 top_p?: number;
3192 /**
3193 * 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.
3194 */
3195 top_k?: number;
3196 /**
3197 * Random seed for reproducibility of the generation.
3198 */
3199 seed?: number;
3200 /**
3201 * Penalty for repeated tokens; higher values discourage repetition.
3202 */
3203 repetition_penalty?: number;
3204 /**
3205 * Decreases the likelihood of the model repeating the same lines verbatim.
3206 */
3207 frequency_penalty?: number;
3208 /**
3209 * Increases the likelihood of the model introducing new topics.
3210 */
3211 presence_penalty?: number;
3212}
3213type Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Output = {
3214 /**
3215 * The generated text response from the model
3216 */
3217 response?: string;
3218 /**
3219 * An array of tool calls requests made during the response generation
3220 */
3221 tool_calls?: {
3222 /**
3223 * The arguments passed to be passed to the tool call request
3224 */
3225 arguments?: object;
3226 /**
3227 * The name of the tool to be called
3228 */
3229 name?: string;
3230 }[];
3231} | ReadableStream;
3232declare abstract class Base_Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct {
3233 inputs: Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Input;
3234 postProcessedOutputs: Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Output;
3235}
3236interface Ai_Cf_Meta_Llama_Guard_3_8B_Input {
3237 /**
3238 * An array of message objects representing the conversation history.
3239 */
3240 messages: {
3241 /**
3242 * The role of the message sender must alternate between 'user' and 'assistant'.
3243 */
3244 role: "user" | "assistant";
3245 /**
3246 * The content of the message as a string.
3247 */
3248 content: string;
3249 }[];
3250 /**
3251 * The maximum number of tokens to generate in the response.
3252 */
3253 max_tokens?: number;
3254 /**
3255 * Controls the randomness of the output; higher values produce more random results.
3256 */
3257 temperature?: number;
3258 /**
3259 * Dictate the output format of the generated response.
3260 */
3261 response_format?: {
3262 /**
3263 * Set to json_object to process and output generated text as JSON.
3264 */
3265 type?: string;
3266 };
3267}
3268interface Ai_Cf_Meta_Llama_Guard_3_8B_Output {
3269 response?: string | {
3270 /**
3271 * Whether the conversation is safe or not.
3272 */
3273 safe?: boolean;
3274 /**
3275 * A list of what hazard categories predicted for the conversation, if the conversation is deemed unsafe.
3276 */
3277 categories?: string[];
3278 };
3279 /**
3280 * Usage statistics for the inference request
3281 */
3282 usage?: {
3283 /**
3284 * Total number of tokens in input
3285 */
3286 prompt_tokens?: number;
3287 /**
3288 * Total number of tokens in output
3289 */
3290 completion_tokens?: number;
3291 /**
3292 * Total number of input and output tokens
3293 */
3294 total_tokens?: number;
3295 };
3296}
3297declare abstract class Base_Ai_Cf_Meta_Llama_Guard_3_8B {
3298 inputs: Ai_Cf_Meta_Llama_Guard_3_8B_Input;
3299 postProcessedOutputs: Ai_Cf_Meta_Llama_Guard_3_8B_Output;
3300}
3301interface Ai_Cf_Baai_Bge_Reranker_Base_Input {
3302 /**
3303 * A query you wish to perform against the provided contexts.
3304 */
3305 /**
3306 * Number of returned results starting with the best score.
3307 */
3308 top_k?: number;
3309 /**
3310 * List of provided contexts. Note that the index in this array is important, as the response will refer to it.
3311 */
3312 contexts: {
3313 /**
3314 * One of the provided context content
3315 */
3316 text?: string;
3317 }[];
3318}
3319interface Ai_Cf_Baai_Bge_Reranker_Base_Output {
3320 response?: {
3321 /**
3322 * Index of the context in the request
3323 */
3324 id?: number;
3325 /**
3326 * Score of the context under the index.
3327 */
3328 score?: number;
3329 }[];
3330}
3331declare abstract class Base_Ai_Cf_Baai_Bge_Reranker_Base {
3332 inputs: Ai_Cf_Baai_Bge_Reranker_Base_Input;
3333 postProcessedOutputs: Ai_Cf_Baai_Bge_Reranker_Base_Output;
3334}
3335type Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Input = Ai_Cf_Meta_Llama_4_Prompt | Ai_Cf_Meta_Llama_4_Messages;
3336interface Ai_Cf_Meta_Llama_4_Prompt {
3337 /**
3338 * The input text prompt for the model to generate a response.
3339 */
3340 prompt: string;
3341 /**
3342 * JSON schema that should be fulfilled for the response.
3343 */
3344 guided_json?: object;
3345 /**
3346 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
3347 */
3348 raw?: boolean;
3349 /**
3350 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
3351 */
3352 stream?: boolean;
3353 /**
3354 * The maximum number of tokens to generate in the response.
3355 */
3356 max_tokens?: number;
3357 /**
3358 * Controls the randomness of the output; higher values produce more random results.
3359 */
3360 temperature?: number;
3361 /**
3362 * 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.
3363 */
3364 top_p?: number;
3365 /**
3366 * 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.
3367 */
3368 top_k?: number;
3369 /**
3370 * Random seed for reproducibility of the generation.
3371 */
3372 seed?: number;
3373 /**
3374 * Penalty for repeated tokens; higher values discourage repetition.
3375 */
3376 repetition_penalty?: number;
3377 /**
3378 * Decreases the likelihood of the model repeating the same lines verbatim.
3379 */
3380 frequency_penalty?: number;
3381 /**
3382 * Increases the likelihood of the model introducing new topics.
3383 */
3384 presence_penalty?: number;
3385}
3386interface Ai_Cf_Meta_Llama_4_Messages {
3387 /**
3388 * An array of message objects representing the conversation history.
3389 */
3390 messages: {
3391 /**
3392 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
3393 */
3394 role?: string;
3395 /**
3396 * 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
3397 */
3398 tool_call_id?: string;
3399 content?: string | {
3400 /**
3401 * Type of the content provided
3402 */
3403 type?: string;
3404 text?: string;
3405 image_url?: {
3406 /**
3407 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
3408 */
3409 url?: string;
3410 };
3411 }[] | {
3412 /**
3413 * Type of the content provided
3414 */
3415 type?: string;
3416 text?: string;
3417 image_url?: {
3418 /**
3419 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
3420 */
3421 url?: string;
3422 };
3423 };
3424 }[];
3425 functions?: {
3426 name: string;
3427 code: string;
3428 }[];
3429 /**
3430 * A list of tools available for the assistant to use.
3431 */
3432 tools?: ({
3433 /**
3434 * The name of the tool. More descriptive the better.
3435 */
3436 name: string;
3437 /**
3438 * A brief description of what the tool does.
3439 */
3440 description: string;
3441 /**
3442 * Schema defining the parameters accepted by the tool.
3443 */
3444 parameters: {
3445 /**
3446 * The type of the parameters object (usually 'object').
3447 */
3448 type: string;
3449 /**
3450 * List of required parameter names.
3451 */
3452 required?: string[];
3453 /**
3454 * Definitions of each parameter.
3455 */
3456 properties: {
3457 [k: string]: {
3458 /**
3459 * The data type of the parameter.
3460 */
3461 type: string;
3462 /**
3463 * A description of the expected parameter.
3464 */
3465 description: string;
3466 };
3467 };
3468 };
3469 } | {
3470 /**
3471 * Specifies the type of tool (e.g., 'function').
3472 */
3473 type: string;
3474 /**
3475 * Details of the function tool.
3476 */
3477 function: {
3478 /**
3479 * The name of the function.
3480 */
3481 name: string;
3482 /**
3483 * A brief description of what the function does.
3484 */
3485 description: string;
3486 /**
3487 * Schema defining the parameters accepted by the function.
3488 */
3489 parameters: {
3490 /**
3491 * The type of the parameters object (usually 'object').
3492 */
3493 type: string;
3494 /**
3495 * List of required parameter names.
3496 */
3497 required?: string[];
3498 /**
3499 * Definitions of each parameter.
3500 */
3501 properties: {
3502 [k: string]: {
3503 /**
3504 * The data type of the parameter.
3505 */
3506 type: string;
3507 /**
3508 * A description of the expected parameter.
3509 */
3510 description: string;
3511 };
3512 };
3513 };
3514 };
3515 })[];
3516 /**
3517 * JSON schema that should be fufilled for the response.
3518 */
3519 guided_json?: object;
3520 /**
3521 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
3522 */
3523 raw?: boolean;
3524 /**
3525 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
3526 */
3527 stream?: boolean;
3528 /**
3529 * The maximum number of tokens to generate in the response.
3530 */
3531 max_tokens?: number;
3532 /**
3533 * Controls the randomness of the output; higher values produce more random results.
3534 */
3535 temperature?: number;
3536 /**
3537 * 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.
3538 */
3539 top_p?: number;
3540 /**
3541 * 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.
3542 */
3543 top_k?: number;
3544 /**
3545 * Random seed for reproducibility of the generation.
3546 */
3547 seed?: number;
3548 /**
3549 * Penalty for repeated tokens; higher values discourage repetition.
3550 */
3551 repetition_penalty?: number;
3552 /**
3553 * Decreases the likelihood of the model repeating the same lines verbatim.
3554 */
3555 frequency_penalty?: number;
3556 /**
3557 * Increases the likelihood of the model introducing new topics.
3558 */
3559 presence_penalty?: number;
3560}
3561type Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Output = {
3562 /**
3563 * The generated text response from the model
3564 */
3565 response: string;
3566 /**
3567 * Usage statistics for the inference request
3568 */
3569 usage?: {
3570 /**
3571 * Total number of tokens in input
3572 */
3573 prompt_tokens?: number;
3574 /**
3575 * Total number of tokens in output
3576 */
3577 completion_tokens?: number;
3578 /**
3579 * Total number of input and output tokens
3580 */
3581 total_tokens?: number;
3582 };
3583 /**
3584 * An array of tool calls requests made during the response generation
3585 */
3586 tool_calls?: {
3587 /**
3588 * The arguments passed to be passed to the tool call request
3589 */
3590 arguments?: object;
3591 /**
3592 * The name of the tool to be called
3593 */
3594 name?: string;
3595 }[];
3596} | string;
3597declare abstract class Base_Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct {
3598 inputs: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Input;
3599 postProcessedOutputs: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Output;
3600}
3601interface AiModels {
3602 "@cf/huggingface/distilbert-sst-2-int8": BaseAiTextClassification;
3603 "@cf/stabilityai/stable-diffusion-xl-base-1.0": BaseAiTextToImage;
3604 "@cf/runwayml/stable-diffusion-v1-5-inpainting": BaseAiTextToImage;
3605 "@cf/runwayml/stable-diffusion-v1-5-img2img": BaseAiTextToImage;
3606 "@cf/lykon/dreamshaper-8-lcm": BaseAiTextToImage;
3607 "@cf/bytedance/stable-diffusion-xl-lightning": BaseAiTextToImage;
3608 "@cf/myshell-ai/melotts": BaseAiTextToSpeech;
3609 "@cf/baai/bge-base-en-v1.5": BaseAiTextEmbeddings;
3610 "@cf/baai/bge-small-en-v1.5": BaseAiTextEmbeddings;
3611 "@cf/baai/bge-large-en-v1.5": BaseAiTextEmbeddings;
3612 "@cf/microsoft/resnet-50": BaseAiImageClassification;
3613 "@cf/facebook/detr-resnet-50": BaseAiObjectDetection;
3614 "@cf/meta/llama-2-7b-chat-int8": BaseAiTextGeneration;
3615 "@cf/mistral/mistral-7b-instruct-v0.1": BaseAiTextGeneration;
3616 "@cf/meta/llama-2-7b-chat-fp16": BaseAiTextGeneration;
3617 "@hf/thebloke/llama-2-13b-chat-awq": BaseAiTextGeneration;
3618 "@hf/thebloke/mistral-7b-instruct-v0.1-awq": BaseAiTextGeneration;
3619 "@hf/thebloke/zephyr-7b-beta-awq": BaseAiTextGeneration;
3620 "@hf/thebloke/openhermes-2.5-mistral-7b-awq": BaseAiTextGeneration;
3621 "@hf/thebloke/neural-chat-7b-v3-1-awq": BaseAiTextGeneration;
3622 "@hf/thebloke/llamaguard-7b-awq": BaseAiTextGeneration;
3623 "@hf/thebloke/deepseek-coder-6.7b-base-awq": BaseAiTextGeneration;
3624 "@hf/thebloke/deepseek-coder-6.7b-instruct-awq": BaseAiTextGeneration;
3625 "@cf/deepseek-ai/deepseek-math-7b-instruct": BaseAiTextGeneration;
3626 "@cf/defog/sqlcoder-7b-2": BaseAiTextGeneration;
3627 "@cf/openchat/openchat-3.5-0106": BaseAiTextGeneration;
3628 "@cf/tiiuae/falcon-7b-instruct": BaseAiTextGeneration;
3629 "@cf/thebloke/discolm-german-7b-v1-awq": BaseAiTextGeneration;
3630 "@cf/qwen/qwen1.5-0.5b-chat": BaseAiTextGeneration;
3631 "@cf/qwen/qwen1.5-7b-chat-awq": BaseAiTextGeneration;
3632 "@cf/qwen/qwen1.5-14b-chat-awq": BaseAiTextGeneration;
3633 "@cf/tinyllama/tinyllama-1.1b-chat-v1.0": BaseAiTextGeneration;
3634 "@cf/microsoft/phi-2": BaseAiTextGeneration;
3635 "@cf/qwen/qwen1.5-1.8b-chat": BaseAiTextGeneration;
3636 "@cf/mistral/mistral-7b-instruct-v0.2-lora": BaseAiTextGeneration;
3637 "@hf/nousresearch/hermes-2-pro-mistral-7b": BaseAiTextGeneration;
3638 "@hf/nexusflow/starling-lm-7b-beta": BaseAiTextGeneration;
3639 "@hf/google/gemma-7b-it": BaseAiTextGeneration;
3640 "@cf/meta-llama/llama-2-7b-chat-hf-lora": BaseAiTextGeneration;
3641 "@cf/google/gemma-2b-it-lora": BaseAiTextGeneration;
3642 "@cf/google/gemma-7b-it-lora": BaseAiTextGeneration;
3643 "@hf/mistral/mistral-7b-instruct-v0.2": BaseAiTextGeneration;
3644 "@cf/meta/llama-3-8b-instruct": BaseAiTextGeneration;
3645 "@cf/fblgit/una-cybertron-7b-v2-bf16": BaseAiTextGeneration;
3646 "@cf/meta/llama-3-8b-instruct-awq": BaseAiTextGeneration;
3647 "@hf/meta-llama/meta-llama-3-8b-instruct": BaseAiTextGeneration;
3648 "@cf/meta/llama-3.1-8b-instruct": BaseAiTextGeneration;
3649 "@cf/meta/llama-3.1-8b-instruct-fp8": BaseAiTextGeneration;
3650 "@cf/meta/llama-3.1-8b-instruct-awq": BaseAiTextGeneration;
3651 "@cf/meta/llama-3.2-3b-instruct": BaseAiTextGeneration;
3652 "@cf/meta/llama-3.2-1b-instruct": BaseAiTextGeneration;
3653 "@cf/meta/llama-3.3-70b-instruct-fp8-fast": BaseAiTextGeneration;
3654 "@cf/deepseek-ai/deepseek-r1-distill-qwen-32b": BaseAiTextGeneration;
3655 "@cf/meta/m2m100-1.2b": BaseAiTranslation;
3656 "@cf/facebook/bart-large-cnn": BaseAiSummarization;
3657 "@cf/llava-hf/llava-1.5-7b-hf": BaseAiImageToText;
3658 "@cf/openai/whisper": Base_Ai_Cf_Openai_Whisper;
3659 "@cf/unum/uform-gen2-qwen-500m": Base_Ai_Cf_Unum_Uform_Gen2_Qwen_500M;
3660 "@cf/openai/whisper-tiny-en": Base_Ai_Cf_Openai_Whisper_Tiny_En;
3661 "@cf/openai/whisper-large-v3-turbo": Base_Ai_Cf_Openai_Whisper_Large_V3_Turbo;
3662 "@cf/baai/bge-m3": Base_Ai_Cf_Baai_Bge_M3;
3663 "@cf/black-forest-labs/flux-1-schnell": Base_Ai_Cf_Black_Forest_Labs_Flux_1_Schnell;
3664 "@cf/meta/llama-3.2-11b-vision-instruct": Base_Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct;
3665 "@cf/meta/llama-guard-3-8b": Base_Ai_Cf_Meta_Llama_Guard_3_8B;
3666 "@cf/baai/bge-reranker-base": Base_Ai_Cf_Baai_Bge_Reranker_Base;
3667 "@cf/meta/llama-4-scout-17b-16e-instruct": Base_Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct;
3668}
3669type AiOptions = {
3670 gateway?: GatewayOptions;
3671 returnRawResponse?: boolean;
3672 prefix?: string;
3673 extraHeaders?: object;
3674};
3675type ConversionResponse = {
3676 name: string;
3677 mimeType: string;
3678 format: "markdown";
3679 tokens: number;
3680 data: string;
3681};
3682type AiModelsSearchParams = {
3683 author?: string;
3684 hide_experimental?: boolean;
3685 page?: number;
3686 per_page?: number;
3687 search?: string;
3688 source?: number;
3689 task?: string;
3690};
3691type AiModelsSearchObject = {
3692 id: string;
3693 source: number;
3694 name: string;
3695 description: string;
3696 task: {
3697 id: string;
3698 name: string;
3699 description: string;
3700 };
3701 tags: string[];
3702 properties: {
3703 property_id: string;
3704 value: string;
3705 }[];
3706};
3707interface InferenceUpstreamError extends Error {
3708}
3709interface AiInternalError extends Error {
3710}
3711type AiModelListType = Record<string, any>;
3712declare abstract class Ai<AiModelList extends AiModelListType = AiModels> {
3713 aiGatewayLogId: string | null;
3714 gateway(gatewayId: string): AiGateway;
3715 autorag(autoragId: string): AutoRAG;
3716 run<Name extends keyof AiModelList, Options extends AiOptions>(model: Name, inputs: AiModelList[Name]["inputs"], options?: Options): Promise<Options extends {
3717 returnRawResponse: true;
3718 } ? Response : AiModelList[Name]["postProcessedOutputs"]>;
3719 models(params?: AiModelsSearchParams): Promise<AiModelsSearchObject[]>;
3720 toMarkdown(files: {
3721 name: string;
3722 blob: Blob;
3723 }[], options?: {
3724 gateway?: GatewayOptions;
3725 extraHeaders?: object;
3726 }): Promise<ConversionResponse[]>;
3727 toMarkdown(files: {
3728 name: string;
3729 blob: Blob;
3730 }, options?: {
3731 gateway?: GatewayOptions;
3732 extraHeaders?: object;
3733 }): Promise<ConversionResponse>;
3734}
3735type GatewayRetries = {
3736 maxAttempts?: 1 | 2 | 3 | 4 | 5;
3737 retryDelayMs?: number;
3738 backoff?: 'constant' | 'linear' | 'exponential';
3739};
3740type GatewayOptions = {
3741 id: string;
3742 cacheKey?: string;
3743 cacheTtl?: number;
3744 skipCache?: boolean;
3745 metadata?: Record<string, number | string | boolean | null | bigint>;
3746 collectLog?: boolean;
3747 eventId?: string;
3748 requestTimeoutMs?: number;
3749 retries?: GatewayRetries;
3750};
3751type AiGatewayPatchLog = {
3752 score?: number | null;
3753 feedback?: -1 | 1 | null;
3754 metadata?: Record<string, number | string | boolean | null | bigint> | null;
3755};
3756type AiGatewayLog = {
3757 id: string;
3758 provider: string;
3759 model: string;
3760 model_type?: string;
3761 path: string;
3762 duration: number;
3763 request_type?: string;
3764 request_content_type?: string;
3765 status_code: number;
3766 response_content_type?: string;
3767 success: boolean;
3768 cached: boolean;
3769 tokens_in?: number;
3770 tokens_out?: number;
3771 metadata?: Record<string, number | string | boolean | null | bigint>;
3772 step?: number;
3773 cost?: number;
3774 custom_cost?: boolean;
3775 request_size: number;
3776 request_head?: string;
3777 request_head_complete: boolean;
3778 response_size: number;
3779 response_head?: string;
3780 response_head_complete: boolean;
3781 created_at: Date;
3782};
3783type 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';
3784type AIGatewayHeaders = {
3785 'cf-aig-metadata': Record<string, number | string | boolean | null | bigint> | string;
3786 'cf-aig-custom-cost': {
3787 per_token_in?: number;
3788 per_token_out?: number;
3789 } | {
3790 total_cost?: number;
3791 } | string;
3792 'cf-aig-cache-ttl': number | string;
3793 'cf-aig-skip-cache': boolean | string;
3794 'cf-aig-cache-key': string;
3795 'cf-aig-event-id': string;
3796 'cf-aig-request-timeout': number | string;
3797 'cf-aig-max-attempts': number | string;
3798 'cf-aig-retry-delay': number | string;
3799 'cf-aig-backoff': string;
3800 'cf-aig-collect-log': boolean | string;
3801 Authorization: string;
3802 'Content-Type': string;
3803 [key: string]: string | number | boolean | object;
3804};
3805type AIGatewayUniversalRequest = {
3806 provider: AIGatewayProviders | string; // eslint-disable-line
3807 endpoint: string;
3808 headers: Partial<AIGatewayHeaders>;
3809 query: unknown;
3810};
3811interface AiGatewayInternalError extends Error {
3812}
3813interface AiGatewayLogNotFound extends Error {
3814}
3815declare abstract class AiGateway {
3816 patchLog(logId: string, data: AiGatewayPatchLog): Promise<void>;
3817 getLog(logId: string): Promise<AiGatewayLog>;
3818 run(data: AIGatewayUniversalRequest | AIGatewayUniversalRequest[], options?: {
3819 gateway?: GatewayOptions;
3820 extraHeaders?: object;
3821 }): Promise<Response>;
3822 getUrl(provider?: AIGatewayProviders | string): Promise<string>; // eslint-disable-line
3823}
3824interface AutoRAGInternalError extends Error {
3825}
3826interface AutoRAGNotFoundError extends Error {
3827}
3828interface AutoRAGUnauthorizedError extends Error {
3829}
3830type ComparisonFilter = {
3831 key: string;
3832 type: 'eq' | 'ne' | 'gt' | 'gte' | 'lt' | 'lte';
3833 value: string | number | boolean;
3834};
3835type CompoundFilter = {
3836 type: 'and' | 'or';
3837 filters: ComparisonFilter[];
3838};
3839type AutoRagSearchRequest = {
3840 query: string;
3841 filters?: CompoundFilter | ComparisonFilter;
3842 max_num_results?: number;
3843 ranking_options?: {
3844 ranker?: string;
3845 score_threshold?: number;
3846 };
3847 rewrite_query?: boolean;
3848};
3849type AutoRagAiSearchRequest = AutoRagSearchRequest & {
3850 stream?: boolean;
3851};
3852type AutoRagAiSearchRequestStreaming = Omit<AutoRagAiSearchRequest, 'stream'> & {
3853 stream: true;
3854};
3855type AutoRagSearchResponse = {
3856 object: 'vector_store.search_results.page';
3857 search_query: string;
3858 data: {
3859 file_id: string;
3860 filename: string;
3861 score: number;
3862 attributes: Record<string, string | number | boolean | null>;
3863 content: {
3864 type: 'text';
3865 text: string;
3866 }[];
3867 }[];
3868 has_more: boolean;
3869 next_page: string | null;
3870};
3871type AutoRagAiSearchResponse = AutoRagSearchResponse & {
3872 response: string;
3873};
3874declare abstract class AutoRAG {
3875 search(params: AutoRagSearchRequest): Promise<AutoRagSearchResponse>;
3876 aiSearch(params: AutoRagAiSearchRequestStreaming): Promise<Response>;
3877 aiSearch(params: AutoRagAiSearchRequest): Promise<AutoRagAiSearchResponse>;
3878 aiSearch(params: AutoRagAiSearchRequest): Promise<AutoRagAiSearchResponse | Response>;
3879}
3880interface BasicImageTransformations {
3881 /**
3882 * Maximum width in image pixels. The value must be an integer.
3883 */
3884 width?: number;
3885 /**
3886 * Maximum height in image pixels. The value must be an integer.
3887 */
3888 height?: number;
3889 /**
3890 * Resizing mode as a string. It affects interpretation of width and height
3891 * options:
3892 * - scale-down: Similar to contain, but the image is never enlarged. If
3893 * the image is larger than given width or height, it will be resized.
3894 * Otherwise its original size will be kept.
3895 * - contain: Resizes to maximum size that fits within the given width and
3896 * height. If only a single dimension is given (e.g. only width), the
3897 * image will be shrunk or enlarged to exactly match that dimension.
3898 * Aspect ratio is always preserved.
3899 * - cover: Resizes (shrinks or enlarges) to fill the entire area of width
3900 * and height. If the image has an aspect ratio different from the ratio
3901 * of width and height, it will be cropped to fit.
3902 * - crop: The image will be shrunk and cropped to fit within the area
3903 * specified by width and height. The image will not be enlarged. For images
3904 * smaller than the given dimensions it's the same as scale-down. For
3905 * images larger than the given dimensions, it's the same as cover.
3906 * See also trim.
3907 * - pad: Resizes to the maximum size that fits within the given width and
3908 * height, and then fills the remaining area with a background color
3909 * (white by default). Use of this mode is not recommended, as the same
3910 * effect can be more efficiently achieved with the contain mode and the
3911 * CSS object-fit: contain property.
3912 * - squeeze: Stretches and deforms to the width and height given, even if it
3913 * breaks aspect ratio
3914 */
3915 fit?: "scale-down" | "contain" | "cover" | "crop" | "pad" | "squeeze";
3916 /**
3917 * When cropping with fit: "cover", this defines the side or point that should
3918 * be left uncropped. The value is either a string
3919 * "left", "right", "top", "bottom", "auto", or "center" (the default),
3920 * or an object {x, y} containing focal point coordinates in the original
3921 * image expressed as fractions ranging from 0.0 (top or left) to 1.0
3922 * (bottom or right), 0.5 being the center. {fit: "cover", gravity: "top"} will
3923 * crop bottom or left and right sides as necessary, but won’t crop anything
3924 * from the top. {fit: "cover", gravity: {x:0.5, y:0.2}} will crop each side to
3925 * preserve as much as possible around a point at 20% of the height of the
3926 * source image.
3927 */
3928 gravity?: 'left' | 'right' | 'top' | 'bottom' | 'center' | 'auto' | 'entropy' | BasicImageTransformationsGravityCoordinates;
3929 /**
3930 * Background color to add underneath the image. Applies only to images with
3931 * transparency (such as PNG). Accepts any CSS color (#RRGGBB, rgba(…),
3932 * hsl(…), etc.)
3933 */
3934 background?: string;
3935 /**
3936 * Number of degrees (90, 180, 270) to rotate the image by. width and height
3937 * options refer to axes after rotation.
3938 */
3939 rotate?: 0 | 90 | 180 | 270 | 360;
3940}
3941interface BasicImageTransformationsGravityCoordinates {
3942 x?: number;
3943 y?: number;
3944 mode?: 'remainder' | 'box-center';
3945}
3946/**
3947 * In addition to the properties you can set in the RequestInit dict
3948 * that you pass as an argument to the Request constructor, you can
3949 * set certain properties of a `cf` object to control how Cloudflare
3950 * features are applied to that new Request.
3951 *
3952 * Note: Currently, these properties cannot be tested in the
3953 * playground.
3954 */
3955interface RequestInitCfProperties extends Record<string, unknown> {
3956 cacheEverything?: boolean;
3957 /**
3958 * A request's cache key is what determines if two requests are
3959 * "the same" for caching purposes. If a request has the same cache key
3960 * as some previous request, then we can serve the same cached response for
3961 * both. (e.g. 'some-key')
3962 *
3963 * Only available for Enterprise customers.
3964 */
3965 cacheKey?: string;
3966 /**
3967 * This allows you to append additional Cache-Tag response headers
3968 * to the origin response without modifications to the origin server.
3969 * This will allow for greater control over the Purge by Cache Tag feature
3970 * utilizing changes only in the Workers process.
3971 *
3972 * Only available for Enterprise customers.
3973 */
3974 cacheTags?: string[];
3975 /**
3976 * Force response to be cached for a given number of seconds. (e.g. 300)
3977 */
3978 cacheTtl?: number;
3979 /**
3980 * Force response to be cached for a given number of seconds based on the Origin status code.
3981 * (e.g. { '200-299': 86400, '404': 1, '500-599': 0 })
3982 */
3983 cacheTtlByStatus?: Record<string, number>;
3984 scrapeShield?: boolean;
3985 apps?: boolean;
3986 image?: RequestInitCfPropertiesImage;
3987 minify?: RequestInitCfPropertiesImageMinify;
3988 mirage?: boolean;
3989 polish?: "lossy" | "lossless" | "off";
3990 r2?: RequestInitCfPropertiesR2;
3991 /**
3992 * Redirects the request to an alternate origin server. You can use this,
3993 * for example, to implement load balancing across several origins.
3994 * (e.g.us-east.example.com)
3995 *
3996 * Note - For security reasons, the hostname set in resolveOverride must
3997 * be proxied on the same Cloudflare zone of the incoming request.
3998 * Otherwise, the setting is ignored. CNAME hosts are allowed, so to
3999 * resolve to a host under a different domain or a DNS only domain first
4000 * declare a CNAME record within your own zone’s DNS mapping to the
4001 * external hostname, set proxy on Cloudflare, then set resolveOverride
4002 * to point to that CNAME record.
4003 */
4004 resolveOverride?: string;
4005}
4006interface RequestInitCfPropertiesImageDraw extends BasicImageTransformations {
4007 /**
4008 * Absolute URL of the image file to use for the drawing. It can be any of
4009 * the supported file formats. For drawing of watermarks or non-rectangular
4010 * overlays we recommend using PNG or WebP images.
4011 */
4012 url: string;
4013 /**
4014 * Floating-point number between 0 (transparent) and 1 (opaque).
4015 * For example, opacity: 0.5 makes overlay semitransparent.
4016 */
4017 opacity?: number;
4018 /**
4019 * - If set to true, the overlay image will be tiled to cover the entire
4020 * area. This is useful for stock-photo-like watermarks.
4021 * - If set to "x", the overlay image will be tiled horizontally only
4022 * (form a line).
4023 * - If set to "y", the overlay image will be tiled vertically only
4024 * (form a line).
4025 */
4026 repeat?: true | "x" | "y";
4027 /**
4028 * Position of the overlay image relative to a given edge. Each property is
4029 * an offset in pixels. 0 aligns exactly to the edge. For example, left: 10
4030 * positions left side of the overlay 10 pixels from the left edge of the
4031 * image it's drawn over. bottom: 0 aligns bottom of the overlay with bottom
4032 * of the background image.
4033 *
4034 * Setting both left & right, or both top & bottom is an error.
4035 *
4036 * If no position is specified, the image will be centered.
4037 */
4038 top?: number;
4039 left?: number;
4040 bottom?: number;
4041 right?: number;
4042}
4043interface RequestInitCfPropertiesImage extends BasicImageTransformations {
4044 /**
4045 * Device Pixel Ratio. Default 1. Multiplier for width/height that makes it
4046 * easier to specify higher-DPI sizes in <img srcset>.
4047 */
4048 dpr?: number;
4049 /**
4050 * Allows you to trim your image. Takes dpr into account and is performed before
4051 * resizing or rotation.
4052 *
4053 * It can be used as:
4054 * - left, top, right, bottom - it will specify the number of pixels to cut
4055 * off each side
4056 * - width, height - the width/height you'd like to end up with - can be used
4057 * in combination with the properties above
4058 * - border - this will automatically trim the surroundings of an image based on
4059 * it's color. It consists of three properties:
4060 * - color: rgb or hex representation of the color you wish to trim (todo: verify the rgba bit)
4061 * - tolerance: difference from color to treat as color
4062 * - keep: the number of pixels of border to keep
4063 */
4064 trim?: "border" | {
4065 top?: number;
4066 bottom?: number;
4067 left?: number;
4068 right?: number;
4069 width?: number;
4070 height?: number;
4071 border?: boolean | {
4072 color?: string;
4073 tolerance?: number;
4074 keep?: number;
4075 };
4076 };
4077 /**
4078 * Quality setting from 1-100 (useful values are in 60-90 range). Lower values
4079 * make images look worse, but load faster. The default is 85. It applies only
4080 * to JPEG and WebP images. It doesn’t have any effect on PNG.
4081 */
4082 quality?: number | "low" | "medium-low" | "medium-high" | "high";
4083 /**
4084 * Output format to generate. It can be:
4085 * - avif: generate images in AVIF format.
4086 * - webp: generate images in Google WebP format. Set quality to 100 to get
4087 * the WebP-lossless format.
4088 * - json: instead of generating an image, outputs information about the
4089 * image, in JSON format. The JSON object will contain image size
4090 * (before and after resizing), source image’s MIME type, file size, etc.
4091 * - jpeg: generate images in JPEG format.
4092 * - png: generate images in PNG format.
4093 */
4094 format?: "avif" | "webp" | "json" | "jpeg" | "png" | "baseline-jpeg" | "png-force" | "svg";
4095 /**
4096 * Whether to preserve animation frames from input files. Default is true.
4097 * Setting it to false reduces animations to still images. This setting is
4098 * recommended when enlarging images or processing arbitrary user content,
4099 * because large GIF animations can weigh tens or even hundreds of megabytes.
4100 * It is also useful to set anim:false when using format:"json" to get the
4101 * response quicker without the number of frames.
4102 */
4103 anim?: boolean;
4104 /**
4105 * What EXIF data should be preserved in the output image. Note that EXIF
4106 * rotation and embedded color profiles are always applied ("baked in" into
4107 * the image), and aren't affected by this option. Note that if the Polish
4108 * feature is enabled, all metadata may have been removed already and this
4109 * option may have no effect.
4110 * - keep: Preserve most of EXIF metadata, including GPS location if there's
4111 * any.
4112 * - copyright: Only keep the copyright tag, and discard everything else.
4113 * This is the default behavior for JPEG files.
4114 * - none: Discard all invisible EXIF metadata. Currently WebP and PNG
4115 * output formats always discard metadata.
4116 */
4117 metadata?: "keep" | "copyright" | "none";
4118 /**
4119 * Strength of sharpening filter to apply to the image. Floating-point
4120 * number between 0 (no sharpening, default) and 10 (maximum). 1.0 is a
4121 * recommended value for downscaled images.
4122 */
4123 sharpen?: number;
4124 /**
4125 * Radius of a blur filter (approximate gaussian). Maximum supported radius
4126 * is 250.
4127 */
4128 blur?: number;
4129 /**
4130 * Overlays are drawn in the order they appear in the array (last array
4131 * entry is the topmost layer).
4132 */
4133 draw?: RequestInitCfPropertiesImageDraw[];
4134 /**
4135 * Fetching image from authenticated origin. Setting this property will
4136 * pass authentication headers (Authorization, Cookie, etc.) through to
4137 * the origin.
4138 */
4139 "origin-auth"?: "share-publicly";
4140 /**
4141 * Adds a border around the image. The border is added after resizing. Border
4142 * width takes dpr into account, and can be specified either using a single
4143 * width property, or individually for each side.
4144 */
4145 border?: {
4146 color: string;
4147 width: number;
4148 } | {
4149 color: string;
4150 top: number;
4151 right: number;
4152 bottom: number;
4153 left: number;
4154 };
4155 /**
4156 * Increase brightness by a factor. A value of 1.0 equals no change, a value
4157 * of 0.5 equals half brightness, and a value of 2.0 equals twice as bright.
4158 * 0 is ignored.
4159 */
4160 brightness?: number;
4161 /**
4162 * Increase contrast by a factor. A value of 1.0 equals no change, a value of
4163 * 0.5 equals low contrast, and a value of 2.0 equals high contrast. 0 is
4164 * ignored.
4165 */
4166 contrast?: number;
4167 /**
4168 * Increase exposure by a factor. A value of 1.0 equals no change, a value of
4169 * 0.5 darkens the image, and a value of 2.0 lightens the image. 0 is ignored.
4170 */
4171 gamma?: number;
4172 /**
4173 * Increase contrast by a factor. A value of 1.0 equals no change, a value of
4174 * 0.5 equals low contrast, and a value of 2.0 equals high contrast. 0 is
4175 * ignored.
4176 */
4177 saturation?: number;
4178 /**
4179 * Flips the images horizontally, vertically, or both. Flipping is applied before
4180 * rotation, so if you apply flip=h,rotate=90 then the image will be flipped
4181 * horizontally, then rotated by 90 degrees.
4182 */
4183 flip?: 'h' | 'v' | 'hv';
4184 /**
4185 * Slightly reduces latency on a cache miss by selecting a
4186 * quickest-to-compress file format, at a cost of increased file size and
4187 * lower image quality. It will usually override the format option and choose
4188 * JPEG over WebP or AVIF. We do not recommend using this option, except in
4189 * unusual circumstances like resizing uncacheable dynamically-generated
4190 * images.
4191 */
4192 compression?: "fast";
4193}
4194interface RequestInitCfPropertiesImageMinify {
4195 javascript?: boolean;
4196 css?: boolean;
4197 html?: boolean;
4198}
4199interface RequestInitCfPropertiesR2 {
4200 /**
4201 * Colo id of bucket that an object is stored in
4202 */
4203 bucketColoId?: number;
4204}
4205/**
4206 * Request metadata provided by Cloudflare's edge.
4207 */
4208type IncomingRequestCfProperties<HostMetadata = unknown> = IncomingRequestCfPropertiesBase & IncomingRequestCfPropertiesBotManagementEnterprise & IncomingRequestCfPropertiesCloudflareForSaaSEnterprise<HostMetadata> & IncomingRequestCfPropertiesGeographicInformation & IncomingRequestCfPropertiesCloudflareAccessOrApiShield;
4209interface IncomingRequestCfPropertiesBase extends Record<string, unknown> {
4210 /**
4211 * [ASN](https://www.iana.org/assignments/as-numbers/as-numbers.xhtml) of the incoming request.
4212 *
4213 * @example 395747
4214 */
4215 asn: number;
4216 /**
4217 * The organization which owns the ASN of the incoming request.
4218 *
4219 * @example "Google Cloud"
4220 */
4221 asOrganization: string;
4222 /**
4223 * The original value of the `Accept-Encoding` header if Cloudflare modified it.
4224 *
4225 * @example "gzip, deflate, br"
4226 */
4227 clientAcceptEncoding?: string;
4228 /**
4229 * The number of milliseconds it took for the request to reach your worker.
4230 *
4231 * @example 22
4232 */
4233 clientTcpRtt?: number;
4234 /**
4235 * The three-letter [IATA](https://en.wikipedia.org/wiki/IATA_airport_code)
4236 * airport code of the data center that the request hit.
4237 *
4238 * @example "DFW"
4239 */
4240 colo: string;
4241 /**
4242 * Represents the upstream's response to a
4243 * [TCP `keepalive` message](https://tldp.org/HOWTO/TCP-Keepalive-HOWTO/overview.html)
4244 * from cloudflare.
4245 *
4246 * For workers with no upstream, this will always be `1`.
4247 *
4248 * @example 3
4249 */
4250 edgeRequestKeepAliveStatus: IncomingRequestCfPropertiesEdgeRequestKeepAliveStatus;
4251 /**
4252 * The HTTP Protocol the request used.
4253 *
4254 * @example "HTTP/2"
4255 */
4256 httpProtocol: string;
4257 /**
4258 * The browser-requested prioritization information in the request object.
4259 *
4260 * If no information was set, defaults to the empty string `""`
4261 *
4262 * @example "weight=192;exclusive=0;group=3;group-weight=127"
4263 * @default ""
4264 */
4265 requestPriority: string;
4266 /**
4267 * The TLS version of the connection to Cloudflare.
4268 * In requests served over plaintext (without TLS), this property is the empty string `""`.
4269 *
4270 * @example "TLSv1.3"
4271 */
4272 tlsVersion: string;
4273 /**
4274 * The cipher for the connection to Cloudflare.
4275 * In requests served over plaintext (without TLS), this property is the empty string `""`.
4276 *
4277 * @example "AEAD-AES128-GCM-SHA256"
4278 */
4279 tlsCipher: string;
4280 /**
4281 * 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.
4282 *
4283 * If the incoming request was served over plaintext (without TLS) this field is undefined.
4284 */
4285 tlsExportedAuthenticator?: IncomingRequestCfPropertiesExportedAuthenticatorMetadata;
4286}
4287interface IncomingRequestCfPropertiesBotManagementBase {
4288 /**
4289 * Cloudflare’s [level of certainty](https://developers.cloudflare.com/bots/concepts/bot-score/) that a request comes from a bot,
4290 * represented as an integer percentage between `1` (almost certainly a bot) and `99` (almost certainly human).
4291 *
4292 * @example 54
4293 */
4294 score: number;
4295 /**
4296 * A boolean value that is true if the request comes from a good bot, like Google or Bing.
4297 * 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).
4298 */
4299 verifiedBot: boolean;
4300 /**
4301 * A boolean value that is true if the request originates from a
4302 * Cloudflare-verified proxy service.
4303 */
4304 corporateProxy: boolean;
4305 /**
4306 * 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.
4307 */
4308 staticResource: boolean;
4309 /**
4310 * 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).
4311 */
4312 detectionIds: number[];
4313}
4314interface IncomingRequestCfPropertiesBotManagement {
4315 /**
4316 * Results of Cloudflare's Bot Management analysis
4317 */
4318 botManagement: IncomingRequestCfPropertiesBotManagementBase;
4319 /**
4320 * Duplicate of `botManagement.score`.
4321 *
4322 * @deprecated
4323 */
4324 clientTrustScore: number;
4325}
4326interface IncomingRequestCfPropertiesBotManagementEnterprise extends IncomingRequestCfPropertiesBotManagement {
4327 /**
4328 * Results of Cloudflare's Bot Management analysis
4329 */
4330 botManagement: IncomingRequestCfPropertiesBotManagementBase & {
4331 /**
4332 * A [JA3 Fingerprint](https://developers.cloudflare.com/bots/concepts/ja3-fingerprint/) to help profile specific SSL/TLS clients
4333 * across different destination IPs, Ports, and X509 certificates.
4334 */
4335 ja3Hash: string;
4336 };
4337}
4338interface IncomingRequestCfPropertiesCloudflareForSaaSEnterprise<HostMetadata> {
4339 /**
4340 * Custom metadata set per-host in [Cloudflare for SaaS](https://developers.cloudflare.com/cloudflare-for-platforms/cloudflare-for-saas/).
4341 *
4342 * This field is only present if you have Cloudflare for SaaS enabled on your account
4343 * and you have followed the [required steps to enable it]((https://developers.cloudflare.com/cloudflare-for-platforms/cloudflare-for-saas/domain-support/custom-metadata/)).
4344 */
4345 hostMetadata: HostMetadata;
4346}
4347interface IncomingRequestCfPropertiesCloudflareAccessOrApiShield {
4348 /**
4349 * Information about the client certificate presented to Cloudflare.
4350 *
4351 * This is populated when the incoming request is served over TLS using
4352 * either Cloudflare Access or API Shield (mTLS)
4353 * and the presented SSL certificate has a valid
4354 * [Certificate Serial Number](https://ldapwiki.com/wiki/Certificate%20Serial%20Number)
4355 * (i.e., not `null` or `""`).
4356 *
4357 * Otherwise, a set of placeholder values are used.
4358 *
4359 * The property `certPresented` will be set to `"1"` when
4360 * the object is populated (i.e. the above conditions were met).
4361 */
4362 tlsClientAuth: IncomingRequestCfPropertiesTLSClientAuth | IncomingRequestCfPropertiesTLSClientAuthPlaceholder;
4363}
4364/**
4365 * Metadata about the request's TLS handshake
4366 */
4367interface IncomingRequestCfPropertiesExportedAuthenticatorMetadata {
4368 /**
4369 * The client's [`HELLO` message](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.1.2), encoded in hexadecimal
4370 *
4371 * @example "44372ba35fa1270921d318f34c12f155dc87b682cf36a790cfaa3ba8737a1b5d"
4372 */
4373 clientHandshake: string;
4374 /**
4375 * The server's [`HELLO` message](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.1.2), encoded in hexadecimal
4376 *
4377 * @example "44372ba35fa1270921d318f34c12f155dc87b682cf36a790cfaa3ba8737a1b5d"
4378 */
4379 serverHandshake: string;
4380 /**
4381 * The client's [`FINISHED` message](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.9), encoded in hexadecimal
4382 *
4383 * @example "084ee802fe1348f688220e2a6040a05b2199a761f33cf753abb1b006792d3f8b"
4384 */
4385 clientFinished: string;
4386 /**
4387 * The server's [`FINISHED` message](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.9), encoded in hexadecimal
4388 *
4389 * @example "084ee802fe1348f688220e2a6040a05b2199a761f33cf753abb1b006792d3f8b"
4390 */
4391 serverFinished: string;
4392}
4393/**
4394 * Geographic data about the request's origin.
4395 */
4396interface IncomingRequestCfPropertiesGeographicInformation {
4397 /**
4398 * The [ISO 3166-1 Alpha 2](https://www.iso.org/iso-3166-country-codes.html) country code the request originated from.
4399 *
4400 * 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.
4401 *
4402 * If Cloudflare is unable to determine where the request originated this property is omitted.
4403 *
4404 * The country code `"T1"` is used for requests originating on TOR.
4405 *
4406 * @example "GB"
4407 */
4408 country?: Iso3166Alpha2Code | "T1";
4409 /**
4410 * If present, this property indicates that the request originated in the EU
4411 *
4412 * @example "1"
4413 */
4414 isEUCountry?: "1";
4415 /**
4416 * A two-letter code indicating the continent the request originated from.
4417 *
4418 * @example "AN"
4419 */
4420 continent?: ContinentCode;
4421 /**
4422 * The city the request originated from
4423 *
4424 * @example "Austin"
4425 */
4426 city?: string;
4427 /**
4428 * Postal code of the incoming request
4429 *
4430 * @example "78701"
4431 */
4432 postalCode?: string;
4433 /**
4434 * Latitude of the incoming request
4435 *
4436 * @example "30.27130"
4437 */
4438 latitude?: string;
4439 /**
4440 * Longitude of the incoming request
4441 *
4442 * @example "-97.74260"
4443 */
4444 longitude?: string;
4445 /**
4446 * Timezone of the incoming request
4447 *
4448 * @example "America/Chicago"
4449 */
4450 timezone?: string;
4451 /**
4452 * If known, the ISO 3166-2 name for the first level region associated with
4453 * the IP address of the incoming request
4454 *
4455 * @example "Texas"
4456 */
4457 region?: string;
4458 /**
4459 * If known, the ISO 3166-2 code for the first-level region associated with
4460 * the IP address of the incoming request
4461 *
4462 * @example "TX"
4463 */
4464 regionCode?: string;
4465 /**
4466 * Metro code (DMA) of the incoming request
4467 *
4468 * @example "635"
4469 */
4470 metroCode?: string;
4471}
4472/** Data about the incoming request's TLS certificate */
4473interface IncomingRequestCfPropertiesTLSClientAuth {
4474 /** Always `"1"`, indicating that the certificate was presented */
4475 certPresented: "1";
4476 /**
4477 * Result of certificate verification.
4478 *
4479 * @example "FAILED:self signed certificate"
4480 */
4481 certVerified: Exclude<CertVerificationStatus, "NONE">;
4482 /** The presented certificate's revokation status.
4483 *
4484 * - A value of `"1"` indicates the certificate has been revoked
4485 * - A value of `"0"` indicates the certificate has not been revoked
4486 */
4487 certRevoked: "1" | "0";
4488 /**
4489 * The certificate issuer's [distinguished name](https://knowledge.digicert.com/generalinformation/INFO1745.html)
4490 *
4491 * @example "CN=cloudflareaccess.com, C=US, ST=Texas, L=Austin, O=Cloudflare"
4492 */
4493 certIssuerDN: string;
4494 /**
4495 * The certificate subject's [distinguished name](https://knowledge.digicert.com/generalinformation/INFO1745.html)
4496 *
4497 * @example "CN=*.cloudflareaccess.com, C=US, ST=Texas, L=Austin, O=Cloudflare"
4498 */
4499 certSubjectDN: string;
4500 /**
4501 * The certificate issuer's [distinguished name](https://knowledge.digicert.com/generalinformation/INFO1745.html) ([RFC 2253](https://www.rfc-editor.org/rfc/rfc2253.html) formatted)
4502 *
4503 * @example "CN=cloudflareaccess.com, C=US, ST=Texas, L=Austin, O=Cloudflare"
4504 */
4505 certIssuerDNRFC2253: string;
4506 /**
4507 * The certificate subject's [distinguished name](https://knowledge.digicert.com/generalinformation/INFO1745.html) ([RFC 2253](https://www.rfc-editor.org/rfc/rfc2253.html) formatted)
4508 *
4509 * @example "CN=*.cloudflareaccess.com, C=US, ST=Texas, L=Austin, O=Cloudflare"
4510 */
4511 certSubjectDNRFC2253: string;
4512 /** The certificate issuer's distinguished name (legacy policies) */
4513 certIssuerDNLegacy: string;
4514 /** The certificate subject's distinguished name (legacy policies) */
4515 certSubjectDNLegacy: string;
4516 /**
4517 * The certificate's serial number
4518 *
4519 * @example "00936EACBE07F201DF"
4520 */
4521 certSerial: string;
4522 /**
4523 * The certificate issuer's serial number
4524 *
4525 * @example "2489002934BDFEA34"
4526 */
4527 certIssuerSerial: string;
4528 /**
4529 * The certificate's Subject Key Identifier
4530 *
4531 * @example "BB:AF:7E:02:3D:FA:A6:F1:3C:84:8E:AD:EE:38:98:EC:D9:32:32:D4"
4532 */
4533 certSKI: string;
4534 /**
4535 * The certificate issuer's Subject Key Identifier
4536 *
4537 * @example "BB:AF:7E:02:3D:FA:A6:F1:3C:84:8E:AD:EE:38:98:EC:D9:32:32:D4"
4538 */
4539 certIssuerSKI: string;
4540 /**
4541 * The certificate's SHA-1 fingerprint
4542 *
4543 * @example "6b9109f323999e52259cda7373ff0b4d26bd232e"
4544 */
4545 certFingerprintSHA1: string;
4546 /**
4547 * The certificate's SHA-256 fingerprint
4548 *
4549 * @example "acf77cf37b4156a2708e34c4eb755f9b5dbbe5ebb55adfec8f11493438d19e6ad3f157f81fa3b98278453d5652b0c1fd1d71e5695ae4d709803a4d3f39de9dea"
4550 */
4551 certFingerprintSHA256: string;
4552 /**
4553 * The effective starting date of the certificate
4554 *
4555 * @example "Dec 22 19:39:00 2018 GMT"
4556 */
4557 certNotBefore: string;
4558 /**
4559 * The effective expiration date of the certificate
4560 *
4561 * @example "Dec 22 19:39:00 2018 GMT"
4562 */
4563 certNotAfter: string;
4564}
4565/** Placeholder values for TLS Client Authorization */
4566interface IncomingRequestCfPropertiesTLSClientAuthPlaceholder {
4567 certPresented: "0";
4568 certVerified: "NONE";
4569 certRevoked: "0";
4570 certIssuerDN: "";
4571 certSubjectDN: "";
4572 certIssuerDNRFC2253: "";
4573 certSubjectDNRFC2253: "";
4574 certIssuerDNLegacy: "";
4575 certSubjectDNLegacy: "";
4576 certSerial: "";
4577 certIssuerSerial: "";
4578 certSKI: "";
4579 certIssuerSKI: "";
4580 certFingerprintSHA1: "";
4581 certFingerprintSHA256: "";
4582 certNotBefore: "";
4583 certNotAfter: "";
4584}
4585/** Possible outcomes of TLS verification */
4586declare type CertVerificationStatus =
4587/** Authentication succeeded */
4588"SUCCESS"
4589/** No certificate was presented */
4590 | "NONE"
4591/** Failed because the certificate was self-signed */
4592 | "FAILED:self signed certificate"
4593/** Failed because the certificate failed a trust chain check */
4594 | "FAILED:unable to verify the first certificate"
4595/** Failed because the certificate not yet valid */
4596 | "FAILED:certificate is not yet valid"
4597/** Failed because the certificate is expired */
4598 | "FAILED:certificate has expired"
4599/** Failed for another unspecified reason */
4600 | "FAILED";
4601/**
4602 * An upstream endpoint's response to a TCP `keepalive` message from Cloudflare.
4603 */
4604declare 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 */
4605/** ISO 3166-1 Alpha-2 codes */
4606declare 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";
4607/** The 2-letter continent codes Cloudflare uses */
4608declare type ContinentCode = "AF" | "AN" | "AS" | "EU" | "NA" | "OC" | "SA";
4609type CfProperties<HostMetadata = unknown> = IncomingRequestCfProperties<HostMetadata> | RequestInitCfProperties;
4610interface D1Meta {
4611 duration: number;
4612 size_after: number;
4613 rows_read: number;
4614 rows_written: number;
4615 last_row_id: number;
4616 changed_db: boolean;
4617 changes: number;
4618 /**
4619 * The region of the database instance that executed the query.
4620 */
4621 served_by_region?: string;
4622 /**
4623 * True if-and-only-if the database instance that executed the query was the primary.
4624 */
4625 served_by_primary?: boolean;
4626 timings?: {
4627 /**
4628 * The duration of the SQL query execution by the database instance. It doesn't include any network time.
4629 */
4630 sql_duration_ms: number;
4631 };
4632}
4633interface D1Response {
4634 success: true;
4635 meta: D1Meta & Record<string, unknown>;
4636 error?: never;
4637}
4638type D1Result<T = unknown> = D1Response & {
4639 results: T[];
4640};
4641interface D1ExecResult {
4642 count: number;
4643 duration: number;
4644}
4645type D1SessionConstraint =
4646// Indicates that the first query should go to the primary, and the rest queries
4647// using the same D1DatabaseSession will go to any replica that is consistent with
4648// the bookmark maintained by the session (returned by the first query).
4649"first-primary"
4650// Indicates that the first query can go anywhere (primary or replica), and the rest queries
4651// using the same D1DatabaseSession will go to any replica that is consistent with
4652// the bookmark maintained by the session (returned by the first query).
4653 | "first-unconstrained";
4654type D1SessionBookmark = string;
4655declare abstract class D1Database {
4656 prepare(query: string): D1PreparedStatement;
4657 batch<T = unknown>(statements: D1PreparedStatement[]): Promise<D1Result<T>[]>;
4658 exec(query: string): Promise<D1ExecResult>;
4659 /**
4660 * Creates a new D1 Session anchored at the given constraint or the bookmark.
4661 * All queries executed using the created session will have sequential consistency,
4662 * meaning that all writes done through the session will be visible in subsequent reads.
4663 *
4664 * @param constraintOrBookmark Either the session constraint or the explicit bookmark to anchor the created session.
4665 */
4666 withSession(constraintOrBookmark?: D1SessionBookmark | D1SessionConstraint): D1DatabaseSession;
4667 /**
4668 * @deprecated dump() will be removed soon, only applies to deprecated alpha v1 databases.
4669 */
4670 dump(): Promise<ArrayBuffer>;
4671}
4672declare abstract class D1DatabaseSession {
4673 prepare(query: string): D1PreparedStatement;
4674 batch<T = unknown>(statements: D1PreparedStatement[]): Promise<D1Result<T>[]>;
4675 /**
4676 * @returns The latest session bookmark across all executed queries on the session.
4677 * If no query has been executed yet, `null` is returned.
4678 */
4679 getBookmark(): D1SessionBookmark | null;
4680}
4681declare abstract class D1PreparedStatement {
4682 bind(...values: unknown[]): D1PreparedStatement;
4683 first<T = unknown>(colName: string): Promise<T | null>;
4684 first<T = Record<string, unknown>>(): Promise<T | null>;
4685 run<T = Record<string, unknown>>(): Promise<D1Result<T>>;
4686 all<T = Record<string, unknown>>(): Promise<D1Result<T>>;
4687 raw<T = unknown[]>(options: {
4688 columnNames: true;
4689 }): Promise<[
4690 string[],
4691 ...T[]
4692 ]>;
4693 raw<T = unknown[]>(options?: {
4694 columnNames?: false;
4695 }): Promise<T[]>;
4696}
4697// `Disposable` was added to TypeScript's standard lib types in version 5.2.
4698// To support older TypeScript versions, define an empty `Disposable` interface.
4699// Users won't be able to use `using`/`Symbol.dispose` without upgrading to 5.2,
4700// but this will ensure type checking on older versions still passes.
4701// TypeScript's interface merging will ensure our empty interface is effectively
4702// ignored when `Disposable` is included in the standard lib.
4703interface Disposable {
4704}
4705/**
4706 * An email message that can be sent from a Worker.
4707 */
4708interface EmailMessage {
4709 /**
4710 * Envelope From attribute of the email message.
4711 */
4712 readonly from: string;
4713 /**
4714 * Envelope To attribute of the email message.
4715 */
4716 readonly to: string;
4717}
4718/**
4719 * An email message that is sent to a consumer Worker and can be rejected/forwarded.
4720 */
4721interface ForwardableEmailMessage extends EmailMessage {
4722 /**
4723 * Stream of the email message content.
4724 */
4725 readonly raw: ReadableStream<Uint8Array>;
4726 /**
4727 * An [Headers object](https://developer.mozilla.org/en-US/docs/Web/API/Headers).
4728 */
4729 readonly headers: Headers;
4730 /**
4731 * Size of the email message content.
4732 */
4733 readonly rawSize: number;
4734 /**
4735 * Reject this email message by returning a permanent SMTP error back to the connecting client including the given reason.
4736 * @param reason The reject reason.
4737 * @returns void
4738 */
4739 setReject(reason: string): void;
4740 /**
4741 * Forward this email message to a verified destination address of the account.
4742 * @param rcptTo Verified destination address.
4743 * @param headers A [Headers object](https://developer.mozilla.org/en-US/docs/Web/API/Headers).
4744 * @returns A promise that resolves when the email message is forwarded.
4745 */
4746 forward(rcptTo: string, headers?: Headers): Promise<void>;
4747 /**
4748 * Reply to the sender of this email message with a new EmailMessage object.
4749 * @param message The reply message.
4750 * @returns A promise that resolves when the email message is replied.
4751 */
4752 reply(message: EmailMessage): Promise<void>;
4753}
4754/**
4755 * A binding that allows a Worker to send email messages.
4756 */
4757interface SendEmail {
4758 send(message: EmailMessage): Promise<void>;
4759}
4760declare abstract class EmailEvent extends ExtendableEvent {
4761 readonly message: ForwardableEmailMessage;
4762}
4763declare type EmailExportedHandler<Env = unknown> = (message: ForwardableEmailMessage, env: Env, ctx: ExecutionContext) => void | Promise<void>;
4764declare module "cloudflare:email" {
4765 let _EmailMessage: {
4766 prototype: EmailMessage;
4767 new (from: string, to: string, raw: ReadableStream | string): EmailMessage;
4768 };
4769 export { _EmailMessage as EmailMessage };
4770}
4771interface Hyperdrive {
4772 /**
4773 * Connect directly to Hyperdrive as if it's your database, returning a TCP socket.
4774 *
4775 * Calling this method returns an idential socket to if you call
4776 * `connect("host:port")` using the `host` and `port` fields from this object.
4777 * Pick whichever approach works better with your preferred DB client library.
4778 *
4779 * Note that this socket is not yet authenticated -- it's expected that your
4780 * code (or preferably, the client library of your choice) will authenticate
4781 * using the information in this class's readonly fields.
4782 */
4783 connect(): Socket;
4784 /**
4785 * A valid DB connection string that can be passed straight into the typical
4786 * client library/driver/ORM. This will typically be the easiest way to use
4787 * Hyperdrive.
4788 */
4789 readonly connectionString: string;
4790 /*
4791 * A randomly generated hostname that is only valid within the context of the
4792 * currently running Worker which, when passed into `connect()` function from
4793 * the "cloudflare:sockets" module, will connect to the Hyperdrive instance
4794 * for your database.
4795 */
4796 readonly host: string;
4797 /*
4798 * The port that must be paired the the host field when connecting.
4799 */
4800 readonly port: number;
4801 /*
4802 * The username to use when authenticating to your database via Hyperdrive.
4803 * Unlike the host and password, this will be the same every time
4804 */
4805 readonly user: string;
4806 /*
4807 * The randomly generated password to use when authenticating to your
4808 * database via Hyperdrive. Like the host field, this password is only valid
4809 * within the context of the currently running Worker instance from which
4810 * it's read.
4811 */
4812 readonly password: string;
4813 /*
4814 * The name of the database to connect to.
4815 */
4816 readonly database: string;
4817}
4818// Copyright (c) 2024 Cloudflare, Inc.
4819// Licensed under the Apache 2.0 license found in the LICENSE file or at:
4820// https://opensource.org/licenses/Apache-2.0
4821type ImageInfoResponse = {
4822 format: 'image/svg+xml';
4823} | {
4824 format: string;
4825 fileSize: number;
4826 width: number;
4827 height: number;
4828};
4829type ImageTransform = {
4830 width?: number;
4831 height?: number;
4832 background?: string;
4833 blur?: number;
4834 border?: {
4835 color?: string;
4836 width?: number;
4837 } | {
4838 top?: number;
4839 bottom?: number;
4840 left?: number;
4841 right?: number;
4842 };
4843 brightness?: number;
4844 contrast?: number;
4845 fit?: 'scale-down' | 'contain' | 'pad' | 'squeeze' | 'cover' | 'crop';
4846 flip?: 'h' | 'v' | 'hv';
4847 gamma?: number;
4848 gravity?: 'left' | 'right' | 'top' | 'bottom' | 'center' | 'auto' | 'entropy' | {
4849 x?: number;
4850 y?: number;
4851 mode: 'remainder' | 'box-center';
4852 };
4853 rotate?: 0 | 90 | 180 | 270;
4854 saturation?: number;
4855 sharpen?: number;
4856 trim?: "border" | {
4857 top?: number;
4858 bottom?: number;
4859 left?: number;
4860 right?: number;
4861 width?: number;
4862 height?: number;
4863 border?: boolean | {
4864 color?: string;
4865 tolerance?: number;
4866 keep?: number;
4867 };
4868 };
4869};
4870type ImageDrawOptions = {
4871 opacity?: number;
4872 repeat?: boolean | string;
4873 top?: number;
4874 left?: number;
4875 bottom?: number;
4876 right?: number;
4877};
4878type ImageOutputOptions = {
4879 format: 'image/jpeg' | 'image/png' | 'image/gif' | 'image/webp' | 'image/avif' | 'rgb' | 'rgba';
4880 quality?: number;
4881 background?: string;
4882};
4883interface ImagesBinding {
4884 /**
4885 * Get image metadata (type, width and height)
4886 * @throws {@link ImagesError} with code 9412 if input is not an image
4887 * @param stream The image bytes
4888 */
4889 info(stream: ReadableStream<Uint8Array>): Promise<ImageInfoResponse>;
4890 /**
4891 * Begin applying a series of transformations to an image
4892 * @param stream The image bytes
4893 * @returns A transform handle
4894 */
4895 input(stream: ReadableStream<Uint8Array>): ImageTransformer;
4896}
4897interface ImageTransformer {
4898 /**
4899 * Apply transform next, returning a transform handle.
4900 * You can then apply more transformations, draw, or retrieve the output.
4901 * @param transform
4902 */
4903 transform(transform: ImageTransform): ImageTransformer;
4904 /**
4905 * Draw an image on this transformer, returning a transform handle.
4906 * You can then apply more transformations, draw, or retrieve the output.
4907 * @param image The image (or transformer that will give the image) to draw
4908 * @param options The options configuring how to draw the image
4909 */
4910 draw(image: ReadableStream<Uint8Array> | ImageTransformer, options?: ImageDrawOptions): ImageTransformer;
4911 /**
4912 * Retrieve the image that results from applying the transforms to the
4913 * provided input
4914 * @param options Options that apply to the output e.g. output format
4915 */
4916 output(options: ImageOutputOptions): Promise<ImageTransformationResult>;
4917}
4918interface ImageTransformationResult {
4919 /**
4920 * The image as a response, ready to store in cache or return to users
4921 */
4922 response(): Response;
4923 /**
4924 * The content type of the returned image
4925 */
4926 contentType(): string;
4927 /**
4928 * The bytes of the response
4929 */
4930 image(): ReadableStream<Uint8Array>;
4931}
4932interface ImagesError extends Error {
4933 readonly code: number;
4934 readonly message: string;
4935 readonly stack?: string;
4936}
4937type Params<P extends string = any> = Record<P, string | string[]>;
4938type EventContext<Env, P extends string, Data> = {
4939 request: Request<unknown, IncomingRequestCfProperties<unknown>>;
4940 functionPath: string;
4941 waitUntil: (promise: Promise<any>) => void;
4942 passThroughOnException: () => void;
4943 next: (input?: Request | string, init?: RequestInit) => Promise<Response>;
4944 env: Env & {
4945 ASSETS: {
4946 fetch: typeof fetch;
4947 };
4948 };
4949 params: Params<P>;
4950 data: Data;
4951};
4952type PagesFunction<Env = unknown, Params extends string = any, Data extends Record<string, unknown> = Record<string, unknown>> = (context: EventContext<Env, Params, Data>) => Response | Promise<Response>;
4953type EventPluginContext<Env, P extends string, Data, PluginArgs> = {
4954 request: Request<unknown, IncomingRequestCfProperties<unknown>>;
4955 functionPath: string;
4956 waitUntil: (promise: Promise<any>) => void;
4957 passThroughOnException: () => void;
4958 next: (input?: Request | string, init?: RequestInit) => Promise<Response>;
4959 env: Env & {
4960 ASSETS: {
4961 fetch: typeof fetch;
4962 };
4963 };
4964 params: Params<P>;
4965 data: Data;
4966 pluginArgs: PluginArgs;
4967};
4968type 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>;
4969declare module "assets:*" {
4970 export const onRequest: PagesFunction;
4971}
4972// Copyright (c) 2022-2023 Cloudflare, Inc.
4973// Licensed under the Apache 2.0 license found in the LICENSE file or at:
4974// https://opensource.org/licenses/Apache-2.0
4975declare module "cloudflare:pipelines" {
4976 export abstract class PipelineTransformationEntrypoint<Env = unknown, I extends PipelineRecord = PipelineRecord, O extends PipelineRecord = PipelineRecord> {
4977 protected env: Env;
4978 protected ctx: ExecutionContext;
4979 constructor(ctx: ExecutionContext, env: Env);
4980 /**
4981 * run recieves an array of PipelineRecord which can be
4982 * transformed and returned to the pipeline
4983 * @param records Incoming records from the pipeline to be transformed
4984 * @param metadata Information about the specific pipeline calling the transformation entrypoint
4985 * @returns A promise containing the transformed PipelineRecord array
4986 */
4987 public run(records: I[], metadata: PipelineBatchMetadata): Promise<O[]>;
4988 }
4989 export type PipelineRecord = Record<string, unknown>;
4990 export type PipelineBatchMetadata = {
4991 pipelineId: string;
4992 pipelineName: string;
4993 };
4994 export interface Pipeline<T extends PipelineRecord = PipelineRecord> {
4995 /**
4996 * The Pipeline interface represents the type of a binding to a Pipeline
4997 *
4998 * @param records The records to send to the pipeline
4999 */
5000 send(records: T[]): Promise<void>;
5001 }
5002}
5003// PubSubMessage represents an incoming PubSub message.
5004// The message includes metadata about the broker, the client, and the payload
5005// itself.
5006// https://developers.cloudflare.com/pub-sub/
5007interface PubSubMessage {
5008 // Message ID
5009 readonly mid: number;
5010 // MQTT broker FQDN in the form mqtts://BROKER.NAMESPACE.cloudflarepubsub.com:PORT
5011 readonly broker: string;
5012 // The MQTT topic the message was sent on.
5013 readonly topic: string;
5014 // The client ID of the client that published this message.
5015 readonly clientId: string;
5016 // The unique identifier (JWT ID) used by the client to authenticate, if token
5017 // auth was used.
5018 readonly jti?: string;
5019 // A Unix timestamp (seconds from Jan 1, 1970), set when the Pub/Sub Broker
5020 // received the message from the client.
5021 readonly receivedAt: number;
5022 // An (optional) string with the MIME type of the payload, if set by the
5023 // client.
5024 readonly contentType: string;
5025 // Set to 1 when the payload is a UTF-8 string
5026 // https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901063
5027 readonly payloadFormatIndicator: number;
5028 // Pub/Sub (MQTT) payloads can be UTF-8 strings, or byte arrays.
5029 // You can use payloadFormatIndicator to inspect this before decoding.
5030 payload: string | Uint8Array;
5031}
5032// JsonWebKey extended by kid parameter
5033interface JsonWebKeyWithKid extends JsonWebKey {
5034 // Key Identifier of the JWK
5035 readonly kid: string;
5036}
5037interface RateLimitOptions {
5038 key: string;
5039}
5040interface RateLimitOutcome {
5041 success: boolean;
5042}
5043interface RateLimit {
5044 /**
5045 * Rate limit a request based on the provided options.
5046 * @see https://developers.cloudflare.com/workers/runtime-apis/bindings/rate-limit/
5047 * @returns A promise that resolves with the outcome of the rate limit.
5048 */
5049 limit(options: RateLimitOptions): Promise<RateLimitOutcome>;
5050}
5051// Namespace for RPC utility types. Unfortunately, we can't use a `module` here as these types need
5052// to referenced by `Fetcher`. This is included in the "importable" version of the types which
5053// strips all `module` blocks.
5054declare namespace Rpc {
5055 // Branded types for identifying `WorkerEntrypoint`/`DurableObject`/`Target`s.
5056 // TypeScript uses *structural* typing meaning anything with the same shape as type `T` is a `T`.
5057 // For the classes exported by `cloudflare:workers` we want *nominal* typing (i.e. we only want to
5058 // accept `WorkerEntrypoint` from `cloudflare:workers`, not any other class with the same shape)
5059 export const __RPC_STUB_BRAND: '__RPC_STUB_BRAND';
5060 export const __RPC_TARGET_BRAND: '__RPC_TARGET_BRAND';
5061 export const __WORKER_ENTRYPOINT_BRAND: '__WORKER_ENTRYPOINT_BRAND';
5062 export const __DURABLE_OBJECT_BRAND: '__DURABLE_OBJECT_BRAND';
5063 export const __WORKFLOW_ENTRYPOINT_BRAND: '__WORKFLOW_ENTRYPOINT_BRAND';
5064 export interface RpcTargetBranded {
5065 [__RPC_TARGET_BRAND]: never;
5066 }
5067 export interface WorkerEntrypointBranded {
5068 [__WORKER_ENTRYPOINT_BRAND]: never;
5069 }
5070 export interface DurableObjectBranded {
5071 [__DURABLE_OBJECT_BRAND]: never;
5072 }
5073 export interface WorkflowEntrypointBranded {
5074 [__WORKFLOW_ENTRYPOINT_BRAND]: never;
5075 }
5076 export type EntrypointBranded = WorkerEntrypointBranded | DurableObjectBranded | WorkflowEntrypointBranded;
5077 // Types that can be used through `Stub`s
5078 export type Stubable = RpcTargetBranded | ((...args: any[]) => any);
5079 // Types that can be passed over RPC
5080 // The reason for using a generic type here is to build a serializable subset of structured
5081 // cloneable composite types. This allows types defined with the "interface" keyword to pass the
5082 // serializable check as well. Otherwise, only types defined with the "type" keyword would pass.
5083 type Serializable<T> =
5084 // Structured cloneables
5085 BaseType
5086 // Structured cloneable composites
5087 | 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> | {
5088 [K in keyof T]: K extends number | string ? Serializable<T[K]> : never;
5089 }
5090 // Special types
5091 | Stub<Stubable>
5092 // Serialized as stubs, see `Stubify`
5093 | Stubable;
5094 // Base type for all RPC stubs, including common memory management methods.
5095 // `T` is used as a marker type for unwrapping `Stub`s later.
5096 interface StubBase<T extends Stubable> extends Disposable {
5097 [__RPC_STUB_BRAND]: T;
5098 dup(): this;
5099 }
5100 export type Stub<T extends Stubable> = Provider<T> & StubBase<T>;
5101 // This represents all the types that can be sent as-is over an RPC boundary
5102 type BaseType = void | undefined | null | boolean | number | bigint | string | TypedArray | ArrayBuffer | DataView | Date | Error | RegExp | ReadableStream<Uint8Array> | WritableStream<Uint8Array> | Request | Response | Headers;
5103 // Recursively rewrite all `Stubable` types with `Stub`s
5104 // prettier-ignore
5105 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 {
5106 [key: string | number]: any;
5107 } ? {
5108 [K in keyof T]: Stubify<T[K]>;
5109 } : T;
5110 // Recursively rewrite all `Stub<T>`s with the corresponding `T`s.
5111 // Note we use `StubBase` instead of `Stub` here to avoid circular dependencies:
5112 // `Stub` depends on `Provider`, which depends on `Unstubify`, which would depend on `Stub`.
5113 // prettier-ignore
5114 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 {
5115 [key: string | number]: unknown;
5116 } ? {
5117 [K in keyof T]: Unstubify<T[K]>;
5118 } : T;
5119 type UnstubifyAll<A extends any[]> = {
5120 [I in keyof A]: Unstubify<A[I]>;
5121 };
5122 // Utility type for adding `Provider`/`Disposable`s to `object` types only.
5123 // Note `unknown & T` is equivalent to `T`.
5124 type MaybeProvider<T> = T extends object ? Provider<T> : unknown;
5125 type MaybeDisposable<T> = T extends object ? Disposable : unknown;
5126 // Type for method return or property on an RPC interface.
5127 // - Stubable types are replaced by stubs.
5128 // - Serializable types are passed by value, with stubable types replaced by stubs
5129 // and a top-level `Disposer`.
5130 // Everything else can't be passed over PRC.
5131 // Technically, we use custom thenables here, but they quack like `Promise`s.
5132 // Intersecting with `(Maybe)Provider` allows pipelining.
5133 // prettier-ignore
5134 type Result<R> = R extends Stubable ? Promise<Stub<R>> & Provider<R> : R extends Serializable<R> ? Promise<Stubify<R> & MaybeDisposable<R>> & MaybeProvider<R> : never;
5135 // Type for method or property on an RPC interface.
5136 // For methods, unwrap `Stub`s in parameters, and rewrite returns to be `Result`s.
5137 // Unwrapping `Stub`s allows calling with `Stubable` arguments.
5138 // For properties, rewrite types to be `Result`s.
5139 // In each case, unwrap `Promise`s.
5140 type MethodOrProperty<V> = V extends (...args: infer P) => infer R ? (...args: UnstubifyAll<P>) => Result<Awaited<R>> : Result<Awaited<V>>;
5141 // Type for the callable part of an `Provider` if `T` is callable.
5142 // This is intersected with methods/properties.
5143 type MaybeCallableProvider<T> = T extends (...args: any[]) => any ? MethodOrProperty<T> : unknown;
5144 // Base type for all other types providing RPC-like interfaces.
5145 // Rewrites all methods/properties to be `MethodOrProperty`s, while preserving callable types.
5146 // `Reserved` names (e.g. stub method names like `dup()`) and symbols can't be accessed over RPC.
5147 export type Provider<T extends object, Reserved extends string = never> = MaybeCallableProvider<T> & {
5148 [K in Exclude<keyof T, Reserved | symbol | keyof StubBase<never>>]: MethodOrProperty<T[K]>;
5149 };
5150}
5151declare namespace Cloudflare {
5152 interface Env {
5153 }
5154}
5155declare module 'cloudflare:workers' {
5156 export type RpcStub<T extends Rpc.Stubable> = Rpc.Stub<T>;
5157 export const RpcStub: {
5158 new <T extends Rpc.Stubable>(value: T): Rpc.Stub<T>;
5159 };
5160 export abstract class RpcTarget implements Rpc.RpcTargetBranded {
5161 [Rpc.__RPC_TARGET_BRAND]: never;
5162 }
5163 // `protected` fields don't appear in `keyof`s, so can't be accessed over RPC
5164 export abstract class WorkerEntrypoint<Env = unknown> implements Rpc.WorkerEntrypointBranded {
5165 [Rpc.__WORKER_ENTRYPOINT_BRAND]: never;
5166 protected ctx: ExecutionContext;
5167 protected env: Env;
5168 constructor(ctx: ExecutionContext, env: Env);
5169 fetch?(request: Request): Response | Promise<Response>;
5170 tail?(events: TraceItem[]): void | Promise<void>;
5171 trace?(traces: TraceItem[]): void | Promise<void>;
5172 scheduled?(controller: ScheduledController): void | Promise<void>;
5173 queue?(batch: MessageBatch<unknown>): void | Promise<void>;
5174 test?(controller: TestController): void | Promise<void>;
5175 }
5176 export abstract class DurableObject<Env = unknown> implements Rpc.DurableObjectBranded {
5177 [Rpc.__DURABLE_OBJECT_BRAND]: never;
5178 protected ctx: DurableObjectState;
5179 protected env: Env;
5180 constructor(ctx: DurableObjectState, env: Env);
5181 fetch?(request: Request): Response | Promise<Response>;
5182 alarm?(alarmInfo?: AlarmInvocationInfo): void | Promise<void>;
5183 webSocketMessage?(ws: WebSocket, message: string | ArrayBuffer): void | Promise<void>;
5184 webSocketClose?(ws: WebSocket, code: number, reason: string, wasClean: boolean): void | Promise<void>;
5185 webSocketError?(ws: WebSocket, error: unknown): void | Promise<void>;
5186 }
5187 export type WorkflowDurationLabel = 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year';
5188 export type WorkflowSleepDuration = `${number} ${WorkflowDurationLabel}${'s' | ''}` | number;
5189 export type WorkflowDelayDuration = WorkflowSleepDuration;
5190 export type WorkflowTimeoutDuration = WorkflowSleepDuration;
5191 export type WorkflowBackoff = 'constant' | 'linear' | 'exponential';
5192 export type WorkflowStepConfig = {
5193 retries?: {
5194 limit: number;
5195 delay: WorkflowDelayDuration | number;
5196 backoff?: WorkflowBackoff;
5197 };
5198 timeout?: WorkflowTimeoutDuration | number;
5199 };
5200 export type WorkflowEvent<T> = {
5201 payload: Readonly<T>;
5202 timestamp: Date;
5203 instanceId: string;
5204 };
5205 export type WorkflowStepEvent<T> = {
5206 payload: Readonly<T>;
5207 timestamp: Date;
5208 type: string;
5209 };
5210 export abstract class WorkflowStep {
5211 do<T extends Rpc.Serializable<T>>(name: string, callback: () => Promise<T>): Promise<T>;
5212 do<T extends Rpc.Serializable<T>>(name: string, config: WorkflowStepConfig, callback: () => Promise<T>): Promise<T>;
5213 sleep: (name: string, duration: WorkflowSleepDuration) => Promise<void>;
5214 sleepUntil: (name: string, timestamp: Date | number) => Promise<void>;
5215 waitForEvent<T extends Rpc.Serializable<T>>(name: string, options: {
5216 type: string;
5217 timeout?: WorkflowTimeoutDuration | number;
5218 }): Promise<WorkflowStepEvent<T>>;
5219 }
5220 export abstract class WorkflowEntrypoint<Env = unknown, T extends Rpc.Serializable<T> | unknown = unknown> implements Rpc.WorkflowEntrypointBranded {
5221 [Rpc.__WORKFLOW_ENTRYPOINT_BRAND]: never;
5222 protected ctx: ExecutionContext;
5223 protected env: Env;
5224 constructor(ctx: ExecutionContext, env: Env);
5225 run(event: Readonly<WorkflowEvent<T>>, step: WorkflowStep): Promise<unknown>;
5226 }
5227 export const env: Cloudflare.Env;
5228}
5229interface SecretsStoreSecret {
5230 /**
5231 * Get a secret from the Secrets Store, returning a string of the secret value
5232 * if it exists, or throws an error if it does not exist
5233 */
5234 get(): Promise<string>;
5235}
5236declare module "cloudflare:sockets" {
5237 function _connect(address: string | SocketAddress, options?: SocketOptions): Socket;
5238 export { _connect as connect };
5239}
5240declare namespace TailStream {
5241 interface Header {
5242 readonly name: string;
5243 readonly value: string;
5244 }
5245 interface FetchEventInfo {
5246 readonly type: "fetch";
5247 readonly method: string;
5248 readonly url: string;
5249 readonly cfJson: string;
5250 readonly headers: Header[];
5251 }
5252 interface JsRpcEventInfo {
5253 readonly type: "jsrpc";
5254 readonly methodName: string;
5255 }
5256 interface ScheduledEventInfo {
5257 readonly type: "scheduled";
5258 readonly scheduledTime: Date;
5259 readonly cron: string;
5260 }
5261 interface AlarmEventInfo {
5262 readonly type: "alarm";
5263 readonly scheduledTime: Date;
5264 }
5265 interface QueueEventInfo {
5266 readonly type: "queue";
5267 readonly queueName: string;
5268 readonly batchSize: number;
5269 }
5270 interface EmailEventInfo {
5271 readonly type: "email";
5272 readonly mailFrom: string;
5273 readonly rcptTo: string;
5274 readonly rawSize: number;
5275 }
5276 interface TraceEventInfo {
5277 readonly type: "trace";
5278 readonly traces: (string | null)[];
5279 }
5280 interface HibernatableWebSocketEventInfoMessage {
5281 readonly type: "message";
5282 }
5283 interface HibernatableWebSocketEventInfoError {
5284 readonly type: "error";
5285 }
5286 interface HibernatableWebSocketEventInfoClose {
5287 readonly type: "close";
5288 readonly code: number;
5289 readonly wasClean: boolean;
5290 }
5291 interface HibernatableWebSocketEventInfo {
5292 readonly type: "hibernatableWebSocket";
5293 readonly info: HibernatableWebSocketEventInfoClose | HibernatableWebSocketEventInfoError | HibernatableWebSocketEventInfoMessage;
5294 }
5295 interface Resume {
5296 readonly type: "resume";
5297 readonly attachment?: any;
5298 }
5299 interface CustomEventInfo {
5300 readonly type: "custom";
5301 }
5302 interface FetchResponseInfo {
5303 readonly type: "fetch";
5304 readonly statusCode: number;
5305 }
5306 type EventOutcome = "ok" | "canceled" | "exception" | "unknown" | "killSwitch" | "daemonDown" | "exceededCpu" | "exceededMemory" | "loadShed" | "responseStreamDisconnected" | "scriptNotFound";
5307 interface ScriptVersion {
5308 readonly id: string;
5309 readonly tag?: string;
5310 readonly message?: string;
5311 }
5312 interface Trigger {
5313 readonly traceId: string;
5314 readonly invocationId: string;
5315 readonly spanId: string;
5316 }
5317 interface Onset {
5318 readonly type: "onset";
5319 readonly dispatchNamespace?: string;
5320 readonly entrypoint?: string;
5321 readonly scriptName?: string;
5322 readonly scriptTags?: string[];
5323 readonly scriptVersion?: ScriptVersion;
5324 readonly trigger?: Trigger;
5325 readonly info: FetchEventInfo | JsRpcEventInfo | ScheduledEventInfo | AlarmEventInfo | QueueEventInfo | EmailEventInfo | TraceEventInfo | HibernatableWebSocketEventInfo | Resume | CustomEventInfo;
5326 }
5327 interface Outcome {
5328 readonly type: "outcome";
5329 readonly outcome: EventOutcome;
5330 readonly cpuTime: number;
5331 readonly wallTime: number;
5332 }
5333 interface Hibernate {
5334 readonly type: "hibernate";
5335 }
5336 interface SpanOpen {
5337 readonly type: "spanOpen";
5338 readonly name: string;
5339 readonly info?: FetchEventInfo | JsRpcEventInfo | Attributes;
5340 }
5341 interface SpanClose {
5342 readonly type: "spanClose";
5343 readonly outcome: EventOutcome;
5344 }
5345 interface DiagnosticChannelEvent {
5346 readonly type: "diagnosticChannel";
5347 readonly channel: string;
5348 readonly message: any;
5349 }
5350 interface Exception {
5351 readonly type: "exception";
5352 readonly name: string;
5353 readonly message: string;
5354 readonly stack?: string;
5355 }
5356 interface Log {
5357 readonly type: "log";
5358 readonly level: "debug" | "error" | "info" | "log" | "warn";
5359 readonly message: string;
5360 }
5361 interface Return {
5362 readonly type: "return";
5363 readonly info?: FetchResponseInfo | Attributes;
5364 }
5365 interface Link {
5366 readonly type: "link";
5367 readonly label?: string;
5368 readonly traceId: string;
5369 readonly invocationId: string;
5370 readonly spanId: string;
5371 }
5372 interface Attribute {
5373 readonly name: string;
5374 readonly value: string | string[] | boolean | boolean[] | number | number[] | bigint | bigint[];
5375 }
5376 interface Attributes {
5377 readonly type: "attributes";
5378 readonly info: Attribute[];
5379 }
5380 interface TailEvent {
5381 readonly traceId: string;
5382 readonly invocationId: string;
5383 readonly spanId: string;
5384 readonly timestamp: Date;
5385 readonly sequence: number;
5386 readonly event: Onset | Outcome | Hibernate | SpanOpen | SpanClose | DiagnosticChannelEvent | Exception | Log | Return | Link | Attributes;
5387 }
5388 type TailEventHandler = (event: TailEvent) => void | Promise<void>;
5389 type TailEventHandlerName = "outcome" | "hibernate" | "spanOpen" | "spanClose" | "diagnosticChannel" | "exception" | "log" | "return" | "link" | "attributes";
5390 type TailEventHandlerObject = Record<TailEventHandlerName, TailEventHandler>;
5391 type TailEventHandlerType = TailEventHandler | TailEventHandlerObject;
5392}
5393// Copyright (c) 2022-2023 Cloudflare, Inc.
5394// Licensed under the Apache 2.0 license found in the LICENSE file or at:
5395// https://opensource.org/licenses/Apache-2.0
5396/**
5397 * Data types supported for holding vector metadata.
5398 */
5399type VectorizeVectorMetadataValue = string | number | boolean | string[];
5400/**
5401 * Additional information to associate with a vector.
5402 */
5403type VectorizeVectorMetadata = VectorizeVectorMetadataValue | Record<string, VectorizeVectorMetadataValue>;
5404type VectorFloatArray = Float32Array | Float64Array;
5405interface VectorizeError {
5406 code?: number;
5407 error: string;
5408}
5409/**
5410 * Comparison logic/operation to use for metadata filtering.
5411 *
5412 * This list is expected to grow as support for more operations are released.
5413 */
5414type VectorizeVectorMetadataFilterOp = "$eq" | "$ne";
5415/**
5416 * Filter criteria for vector metadata used to limit the retrieved query result set.
5417 */
5418type VectorizeVectorMetadataFilter = {
5419 [field: string]: Exclude<VectorizeVectorMetadataValue, string[]> | null | {
5420 [Op in VectorizeVectorMetadataFilterOp]?: Exclude<VectorizeVectorMetadataValue, string[]> | null;
5421 };
5422};
5423/**
5424 * Supported distance metrics for an index.
5425 * Distance metrics determine how other "similar" vectors are determined.
5426 */
5427type VectorizeDistanceMetric = "euclidean" | "cosine" | "dot-product";
5428/**
5429 * Metadata return levels for a Vectorize query.
5430 *
5431 * Default to "none".
5432 *
5433 * @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.
5434 * @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).
5435 * @property none No indexed metadata will be returned.
5436 */
5437type VectorizeMetadataRetrievalLevel = "all" | "indexed" | "none";
5438interface VectorizeQueryOptions {
5439 topK?: number;
5440 namespace?: string;
5441 returnValues?: boolean;
5442 returnMetadata?: boolean | VectorizeMetadataRetrievalLevel;
5443 filter?: VectorizeVectorMetadataFilter;
5444}
5445/**
5446 * Information about the configuration of an index.
5447 */
5448type VectorizeIndexConfig = {
5449 dimensions: number;
5450 metric: VectorizeDistanceMetric;
5451} | {
5452 preset: string; // keep this generic, as we'll be adding more presets in the future and this is only in a read capacity
5453};
5454/**
5455 * Metadata about an existing index.
5456 *
5457 * This type is exclusively for the Vectorize **beta** and will be deprecated once Vectorize RC is released.
5458 * See {@link VectorizeIndexInfo} for its post-beta equivalent.
5459 */
5460interface VectorizeIndexDetails {
5461 /** The unique ID of the index */
5462 readonly id: string;
5463 /** The name of the index. */
5464 name: string;
5465 /** (optional) A human readable description for the index. */
5466 description?: string;
5467 /** The index configuration, including the dimension size and distance metric. */
5468 config: VectorizeIndexConfig;
5469 /** The number of records containing vectors within the index. */
5470 vectorsCount: number;
5471}
5472/**
5473 * Metadata about an existing index.
5474 */
5475interface VectorizeIndexInfo {
5476 /** The number of records containing vectors within the index. */
5477 vectorCount: number;
5478 /** Number of dimensions the index has been configured for. */
5479 dimensions: number;
5480 /** ISO 8601 datetime of the last processed mutation on in the index. All changes before this mutation will be reflected in the index state. */
5481 processedUpToDatetime: number;
5482 /** UUIDv4 of the last mutation processed by the index. All changes before this mutation will be reflected in the index state. */
5483 processedUpToMutation: number;
5484}
5485/**
5486 * Represents a single vector value set along with its associated metadata.
5487 */
5488interface VectorizeVector {
5489 /** 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. */
5490 id: string;
5491 /** The vector values */
5492 values: VectorFloatArray | number[];
5493 /** The namespace this vector belongs to. */
5494 namespace?: string;
5495 /** Metadata associated with the vector. Includes the values of other fields and potentially additional details. */
5496 metadata?: Record<string, VectorizeVectorMetadata>;
5497}
5498/**
5499 * Represents a matched vector for a query along with its score and (if specified) the matching vector information.
5500 */
5501type VectorizeMatch = Pick<Partial<VectorizeVector>, "values"> & Omit<VectorizeVector, "values"> & {
5502 /** The score or rank for similarity, when returned as a result */
5503 score: number;
5504};
5505/**
5506 * A set of matching {@link VectorizeMatch} for a particular query.
5507 */
5508interface VectorizeMatches {
5509 matches: VectorizeMatch[];
5510 count: number;
5511}
5512/**
5513 * Results of an operation that performed a mutation on a set of vectors.
5514 * Here, `ids` is a list of vectors that were successfully processed.
5515 *
5516 * This type is exclusively for the Vectorize **beta** and will be deprecated once Vectorize RC is released.
5517 * See {@link VectorizeAsyncMutation} for its post-beta equivalent.
5518 */
5519interface VectorizeVectorMutation {
5520 /* List of ids of vectors that were successfully processed. */
5521 ids: string[];
5522 /* Total count of the number of processed vectors. */
5523 count: number;
5524}
5525/**
5526 * Result type indicating a mutation on the Vectorize Index.
5527 * Actual mutations are processed async where the `mutationId` is the unique identifier for the operation.
5528 */
5529interface VectorizeAsyncMutation {
5530 /** The unique identifier for the async mutation operation containing the changeset. */
5531 mutationId: string;
5532}
5533/**
5534 * A Vectorize Vector Search Index for querying vectors/embeddings.
5535 *
5536 * This type is exclusively for the Vectorize **beta** and will be deprecated once Vectorize RC is released.
5537 * See {@link Vectorize} for its new implementation.
5538 */
5539declare abstract class VectorizeIndex {
5540 /**
5541 * Get information about the currently bound index.
5542 * @returns A promise that resolves with information about the current index.
5543 */
5544 public describe(): Promise<VectorizeIndexDetails>;
5545 /**
5546 * Use the provided vector to perform a similarity search across the index.
5547 * @param vector Input vector that will be used to drive the similarity search.
5548 * @param options Configuration options to massage the returned data.
5549 * @returns A promise that resolves with matched and scored vectors.
5550 */
5551 public query(vector: VectorFloatArray | number[], options?: VectorizeQueryOptions): Promise<VectorizeMatches>;
5552 /**
5553 * Insert a list of vectors into the index dataset. If a provided id exists, an error will be thrown.
5554 * @param vectors List of vectors that will be inserted.
5555 * @returns A promise that resolves with the ids & count of records that were successfully processed.
5556 */
5557 public insert(vectors: VectorizeVector[]): Promise<VectorizeVectorMutation>;
5558 /**
5559 * Upsert a list of vectors into the index dataset. If a provided id exists, it will be replaced with the new values.
5560 * @param vectors List of vectors that will be upserted.
5561 * @returns A promise that resolves with the ids & count of records that were successfully processed.
5562 */
5563 public upsert(vectors: VectorizeVector[]): Promise<VectorizeVectorMutation>;
5564 /**
5565 * Delete a list of vectors with a matching id.
5566 * @param ids List of vector ids that should be deleted.
5567 * @returns A promise that resolves with the ids & count of records that were successfully processed (and thus deleted).
5568 */
5569 public deleteByIds(ids: string[]): Promise<VectorizeVectorMutation>;
5570 /**
5571 * Get a list of vectors with a matching id.
5572 * @param ids List of vector ids that should be returned.
5573 * @returns A promise that resolves with the raw unscored vectors matching the id set.
5574 */
5575 public getByIds(ids: string[]): Promise<VectorizeVector[]>;
5576}
5577/**
5578 * A Vectorize Vector Search Index for querying vectors/embeddings.
5579 *
5580 * Mutations in this version are async, returning a mutation id.
5581 */
5582declare abstract class Vectorize {
5583 /**
5584 * Get information about the currently bound index.
5585 * @returns A promise that resolves with information about the current index.
5586 */
5587 public describe(): Promise<VectorizeIndexInfo>;
5588 /**
5589 * Use the provided vector to perform a similarity search across the index.
5590 * @param vector Input vector that will be used to drive the similarity search.
5591 * @param options Configuration options to massage the returned data.
5592 * @returns A promise that resolves with matched and scored vectors.
5593 */
5594 public query(vector: VectorFloatArray | number[], options?: VectorizeQueryOptions): Promise<VectorizeMatches>;
5595 /**
5596 * Use the provided vector-id to perform a similarity search across the index.
5597 * @param vectorId Id for a vector in the index against which the index should be queried.
5598 * @param options Configuration options to massage the returned data.
5599 * @returns A promise that resolves with matched and scored vectors.
5600 */
5601 public queryById(vectorId: string, options?: VectorizeQueryOptions): Promise<VectorizeMatches>;
5602 /**
5603 * Insert a list of vectors into the index dataset. If a provided id exists, an error will be thrown.
5604 * @param vectors List of vectors that will be inserted.
5605 * @returns A promise that resolves with a unique identifier of a mutation containing the insert changeset.
5606 */
5607 public insert(vectors: VectorizeVector[]): Promise<VectorizeAsyncMutation>;
5608 /**
5609 * Upsert a list of vectors into the index dataset. If a provided id exists, it will be replaced with the new values.
5610 * @param vectors List of vectors that will be upserted.
5611 * @returns A promise that resolves with a unique identifier of a mutation containing the upsert changeset.
5612 */
5613 public upsert(vectors: VectorizeVector[]): Promise<VectorizeAsyncMutation>;
5614 /**
5615 * Delete a list of vectors with a matching id.
5616 * @param ids List of vector ids that should be deleted.
5617 * @returns A promise that resolves with a unique identifier of a mutation containing the delete changeset.
5618 */
5619 public deleteByIds(ids: string[]): Promise<VectorizeAsyncMutation>;
5620 /**
5621 * Get a list of vectors with a matching id.
5622 * @param ids List of vector ids that should be returned.
5623 * @returns A promise that resolves with the raw unscored vectors matching the id set.
5624 */
5625 public getByIds(ids: string[]): Promise<VectorizeVector[]>;
5626}
5627/**
5628 * The interface for "version_metadata" binding
5629 * providing metadata about the Worker Version using this binding.
5630 */
5631type WorkerVersionMetadata = {
5632 /** The ID of the Worker Version using this binding */
5633 id: string;
5634 /** The tag of the Worker Version using this binding */
5635 tag: string;
5636 /** The timestamp of when the Worker Version was uploaded */
5637 timestamp: string;
5638};
5639interface DynamicDispatchLimits {
5640 /**
5641 * Limit CPU time in milliseconds.
5642 */
5643 cpuMs?: number;
5644 /**
5645 * Limit number of subrequests.
5646 */
5647 subRequests?: number;
5648}
5649interface DynamicDispatchOptions {
5650 /**
5651 * Limit resources of invoked Worker script.
5652 */
5653 limits?: DynamicDispatchLimits;
5654 /**
5655 * Arguments for outbound Worker script, if configured.
5656 */
5657 outbound?: {
5658 [key: string]: any;
5659 };
5660}
5661interface DispatchNamespace {
5662 /**
5663 * @param name Name of the Worker script.
5664 * @param args Arguments to Worker script.
5665 * @param options Options for Dynamic Dispatch invocation.
5666 * @returns A Fetcher object that allows you to send requests to the Worker script.
5667 * @throws If the Worker script does not exist in this dispatch namespace, an error will be thrown.
5668 */
5669 get(name: string, args?: {
5670 [key: string]: any;
5671 }, options?: DynamicDispatchOptions): Fetcher;
5672}
5673declare module 'cloudflare:workflows' {
5674 /**
5675 * NonRetryableError allows for a user to throw a fatal error
5676 * that makes a Workflow instance fail immediately without triggering a retry
5677 */
5678 export class NonRetryableError extends Error {
5679 public constructor(message: string, name?: string);
5680 }
5681}
5682declare abstract class Workflow<PARAMS = unknown> {
5683 /**
5684 * Get a handle to an existing instance of the Workflow.
5685 * @param id Id for the instance of this Workflow
5686 * @returns A promise that resolves with a handle for the Instance
5687 */
5688 public get(id: string): Promise<WorkflowInstance>;
5689 /**
5690 * Create a new instance and return a handle to it. If a provided id exists, an error will be thrown.
5691 * @param options Options when creating an instance including id and params
5692 * @returns A promise that resolves with a handle for the Instance
5693 */
5694 public create(options?: WorkflowInstanceCreateOptions<PARAMS>): Promise<WorkflowInstance>;
5695 /**
5696 * Create a batch of instances and return handle for all of them. If a provided id exists, an error will be thrown.
5697 * `createBatch` is limited at 100 instances at a time or when the RPC limit for the batch (1MiB) is reached.
5698 * @param batch List of Options when creating an instance including name and params
5699 * @returns A promise that resolves with a list of handles for the created instances.
5700 */
5701 public createBatch(batch: WorkflowInstanceCreateOptions<PARAMS>[]): Promise<WorkflowInstance[]>;
5702}
5703interface WorkflowInstanceCreateOptions<PARAMS = unknown> {
5704 /**
5705 * An id for your Workflow instance. Must be unique within the Workflow.
5706 */
5707 id?: string;
5708 /**
5709 * The event payload the Workflow instance is triggered with
5710 */
5711 params?: PARAMS;
5712}
5713type InstanceStatus = {
5714 status: 'queued' // means that instance is waiting to be started (see concurrency limits)
5715 | 'running' | 'paused' | 'errored' | 'terminated' // user terminated the instance while it was running
5716 | 'complete' | 'waiting' // instance is hibernating and waiting for sleep or event to finish
5717 | 'waitingForPause' // instance is finishing the current work to pause
5718 | 'unknown';
5719 error?: string;
5720 output?: object;
5721};
5722interface WorkflowError {
5723 code?: number;
5724 message: string;
5725}
5726declare abstract class WorkflowInstance {
5727 public id: string;
5728 /**
5729 * Pause the instance.
5730 */
5731 public pause(): Promise<void>;
5732 /**
5733 * Resume the instance. If it is already running, an error will be thrown.
5734 */
5735 public resume(): Promise<void>;
5736 /**
5737 * Terminate the instance. If it is errored, terminated or complete, an error will be thrown.
5738 */
5739 public terminate(): Promise<void>;
5740 /**
5741 * Restart the instance.
5742 */
5743 public restart(): Promise<void>;
5744 /**
5745 * Returns the current status of the instance.
5746 */
5747 public status(): Promise<InstanceStatus>;
5748 /**
5749 * Send an event to this instance.
5750 */
5751 public sendEvent({ type, payload, }: {
5752 type: string;
5753 payload: unknown;
5754 }): Promise<void>;
5755}