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