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