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