Files
url-cleaner/worker-configuration.d.ts
T

8313 lines
274 KiB
TypeScript
Raw Normal View History

2025-09-20 09:21:41 +02:00
/* eslint-disable */
// Generated by Wrangler by running `wrangler types` (hash: 4a70bb3de59040ae241fce16f715fe58)
// Runtime types generated with workerd@1.20250917.0 2025-09-20
2025-09-20 09:21:41 +02:00
declare namespace Cloudflare {
interface GlobalProps {
mainModule: typeof import("./src/index");
durableNamespaces: "RulesCache";
2025-09-20 09:21:41 +02:00
}
interface Env {
RULES_CACHE: DurableObjectNamespace<import("./src/index").RulesCache>;
2025-09-20 09:21:41 +02:00
}
}
interface Env extends Cloudflare.Env {}
// Begin runtime types
/*! *****************************************************************************
Copyright (c) Cloudflare. All rights reserved.
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/* eslint-disable */
// noinspection JSUnusedGlobalSymbols
declare var onmessage: never;
/**
* An abnormal event (called an exception) which occurs as a result of calling a method or accessing a property of a web API.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException)
*/
declare class DOMException extends Error {
constructor(message?: string, name?: string);
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException/message) */
readonly message: string;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException/name) */
readonly name: string;
/**
* @deprecated
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException/code)
*/
readonly code: number;
static readonly INDEX_SIZE_ERR: number;
static readonly DOMSTRING_SIZE_ERR: number;
static readonly HIERARCHY_REQUEST_ERR: number;
static readonly WRONG_DOCUMENT_ERR: number;
static readonly INVALID_CHARACTER_ERR: number;
static readonly NO_DATA_ALLOWED_ERR: number;
static readonly NO_MODIFICATION_ALLOWED_ERR: number;
static readonly NOT_FOUND_ERR: number;
static readonly NOT_SUPPORTED_ERR: number;
static readonly INUSE_ATTRIBUTE_ERR: number;
static readonly INVALID_STATE_ERR: number;
static readonly SYNTAX_ERR: number;
static readonly INVALID_MODIFICATION_ERR: number;
static readonly NAMESPACE_ERR: number;
static readonly INVALID_ACCESS_ERR: number;
static readonly VALIDATION_ERR: number;
static readonly TYPE_MISMATCH_ERR: number;
static readonly SECURITY_ERR: number;
static readonly NETWORK_ERR: number;
static readonly ABORT_ERR: number;
static readonly URL_MISMATCH_ERR: number;
static readonly QUOTA_EXCEEDED_ERR: number;
static readonly TIMEOUT_ERR: number;
static readonly INVALID_NODE_TYPE_ERR: number;
static readonly DATA_CLONE_ERR: number;
get stack(): any;
set stack(value: any);
2025-09-20 09:21:41 +02:00
}
type WorkerGlobalScopeEventMap = {
fetch: FetchEvent;
scheduled: ScheduledEvent;
queue: QueueEvent;
unhandledrejection: PromiseRejectionEvent;
rejectionhandled: PromiseRejectionEvent;
2025-09-20 09:21:41 +02:00
};
declare abstract class WorkerGlobalScope extends EventTarget<WorkerGlobalScopeEventMap> {
EventTarget: typeof EventTarget;
2025-09-20 09:21:41 +02:00
}
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console) */
interface Console {
"assert"(condition?: boolean, ...data: any[]): void;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/clear_static) */
clear(): void;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/count_static) */
count(label?: string): void;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/countReset_static) */
countReset(label?: string): void;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/debug_static) */
debug(...data: any[]): void;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/dir_static) */
dir(item?: any, options?: any): void;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/dirxml_static) */
dirxml(...data: any[]): void;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/error_static) */
error(...data: any[]): void;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/group_static) */
group(...data: any[]): void;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/groupCollapsed_static) */
groupCollapsed(...data: any[]): void;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/groupEnd_static) */
groupEnd(): void;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/info_static) */
info(...data: any[]): void;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/log_static) */
log(...data: any[]): void;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/table_static) */
table(tabularData?: any, properties?: string[]): void;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/time_static) */
time(label?: string): void;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/timeEnd_static) */
timeEnd(label?: string): void;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/timeLog_static) */
timeLog(label?: string, ...data: any[]): void;
timeStamp(label?: string): void;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/trace_static) */
trace(...data: any[]): void;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/warn_static) */
warn(...data: any[]): void;
2025-09-20 09:21:41 +02:00
}
declare const console: Console;
type BufferSource = ArrayBufferView | ArrayBuffer;
type TypedArray =
| Int8Array
| Uint8Array
| Uint8ClampedArray
| Int16Array
| Uint16Array
| Int32Array
| Uint32Array
| Float32Array
| Float64Array
| BigInt64Array
| BigUint64Array;
2025-09-20 09:21:41 +02:00
declare namespace WebAssembly {
class CompileError extends Error {
constructor(message?: string);
}
class RuntimeError extends Error {
constructor(message?: string);
}
type ValueType = "anyfunc" | "externref" | "f32" | "f64" | "i32" | "i64" | "v128";
interface GlobalDescriptor {
value: ValueType;
mutable?: boolean;
}
class Global {
constructor(descriptor: GlobalDescriptor, value?: any);
value: any;
valueOf(): any;
}
type ImportValue = ExportValue | number;
type ModuleImports = Record<string, ImportValue>;
type Imports = Record<string, ModuleImports>;
type ExportValue = Function | Global | Memory | Table;
type Exports = Record<string, ExportValue>;
class Instance {
constructor(module: Module, imports?: Imports);
readonly exports: Exports;
}
interface MemoryDescriptor {
initial: number;
maximum?: number;
shared?: boolean;
}
class Memory {
constructor(descriptor: MemoryDescriptor);
readonly buffer: ArrayBuffer;
grow(delta: number): number;
}
type ImportExportKind = "function" | "global" | "memory" | "table";
interface ModuleExportDescriptor {
kind: ImportExportKind;
name: string;
}
interface ModuleImportDescriptor {
kind: ImportExportKind;
module: string;
name: string;
}
abstract class Module {
static customSections(module: Module, sectionName: string): ArrayBuffer[];
static exports(module: Module): ModuleExportDescriptor[];
static imports(module: Module): ModuleImportDescriptor[];
}
type TableKind = "anyfunc" | "externref";
interface TableDescriptor {
element: TableKind;
initial: number;
maximum?: number;
}
class Table {
constructor(descriptor: TableDescriptor, value?: any);
readonly length: number;
get(index: number): any;
grow(delta: number, value?: any): number;
set(index: number, value?: any): void;
}
function instantiate(module: Module, imports?: Imports): Promise<Instance>;
function validate(bytes: BufferSource): boolean;
2025-09-20 09:21:41 +02:00
}
/**
* This ServiceWorker API interface represents the global execution context of a service worker.
* Available only in secure contexts.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ServiceWorkerGlobalScope)
*/
interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
DOMException: typeof DOMException;
WorkerGlobalScope: typeof WorkerGlobalScope;
btoa(data: string): string;
atob(data: string): string;
setTimeout(callback: (...args: any[]) => void, msDelay?: number): number;
setTimeout<Args extends any[]>(callback: (...args: Args) => void, msDelay?: number, ...args: Args): number;
clearTimeout(timeoutId: number | null): void;
setInterval(callback: (...args: any[]) => void, msDelay?: number): number;
setInterval<Args extends any[]>(callback: (...args: Args) => void, msDelay?: number, ...args: Args): number;
clearInterval(timeoutId: number | null): void;
queueMicrotask(task: Function): void;
structuredClone<T>(value: T, options?: StructuredSerializeOptions): T;
reportError(error: any): void;
fetch(input: RequestInfo | URL, init?: RequestInit<RequestInitCfProperties>): Promise<Response>;
self: ServiceWorkerGlobalScope;
crypto: Crypto;
caches: CacheStorage;
scheduler: Scheduler;
performance: Performance;
Cloudflare: Cloudflare;
readonly origin: string;
Event: typeof Event;
ExtendableEvent: typeof ExtendableEvent;
CustomEvent: typeof CustomEvent;
PromiseRejectionEvent: typeof PromiseRejectionEvent;
FetchEvent: typeof FetchEvent;
TailEvent: typeof TailEvent;
TraceEvent: typeof TailEvent;
ScheduledEvent: typeof ScheduledEvent;
MessageEvent: typeof MessageEvent;
CloseEvent: typeof CloseEvent;
ReadableStreamDefaultReader: typeof ReadableStreamDefaultReader;
ReadableStreamBYOBReader: typeof ReadableStreamBYOBReader;
ReadableStream: typeof ReadableStream;
WritableStream: typeof WritableStream;
WritableStreamDefaultWriter: typeof WritableStreamDefaultWriter;
TransformStream: typeof TransformStream;
ByteLengthQueuingStrategy: typeof ByteLengthQueuingStrategy;
CountQueuingStrategy: typeof CountQueuingStrategy;
ErrorEvent: typeof ErrorEvent;
MessageChannel: typeof MessageChannel;
MessagePort: typeof MessagePort;
EventSource: typeof EventSource;
ReadableStreamBYOBRequest: typeof ReadableStreamBYOBRequest;
ReadableStreamDefaultController: typeof ReadableStreamDefaultController;
ReadableByteStreamController: typeof ReadableByteStreamController;
WritableStreamDefaultController: typeof WritableStreamDefaultController;
TransformStreamDefaultController: typeof TransformStreamDefaultController;
CompressionStream: typeof CompressionStream;
DecompressionStream: typeof DecompressionStream;
TextEncoderStream: typeof TextEncoderStream;
TextDecoderStream: typeof TextDecoderStream;
Headers: typeof Headers;
Body: typeof Body;
Request: typeof Request;
Response: typeof Response;
WebSocket: typeof WebSocket;
WebSocketPair: typeof WebSocketPair;
WebSocketRequestResponsePair: typeof WebSocketRequestResponsePair;
AbortController: typeof AbortController;
AbortSignal: typeof AbortSignal;
TextDecoder: typeof TextDecoder;
TextEncoder: typeof TextEncoder;
navigator: Navigator;
Navigator: typeof Navigator;
URL: typeof URL;
URLSearchParams: typeof URLSearchParams;
URLPattern: typeof URLPattern;
Blob: typeof Blob;
File: typeof File;
FormData: typeof FormData;
Crypto: typeof Crypto;
SubtleCrypto: typeof SubtleCrypto;
CryptoKey: typeof CryptoKey;
CacheStorage: typeof CacheStorage;
Cache: typeof Cache;
FixedLengthStream: typeof FixedLengthStream;
IdentityTransformStream: typeof IdentityTransformStream;
HTMLRewriter: typeof HTMLRewriter;
2025-09-20 09:21:41 +02:00
}
declare function addEventListener<Type extends keyof WorkerGlobalScopeEventMap>(
type: Type,
handler: EventListenerOrEventListenerObject<WorkerGlobalScopeEventMap[Type]>,
options?: EventTargetAddEventListenerOptions | boolean,
): void;
declare function removeEventListener<Type extends keyof WorkerGlobalScopeEventMap>(
type: Type,
handler: EventListenerOrEventListenerObject<WorkerGlobalScopeEventMap[Type]>,
options?: EventTargetEventListenerOptions | boolean,
): void;
2025-09-20 09:21:41 +02:00
/**
* 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.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/dispatchEvent)
*/
declare function dispatchEvent(event: WorkerGlobalScopeEventMap[keyof WorkerGlobalScopeEventMap]): boolean;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/btoa) */
declare function btoa(data: string): string;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/atob) */
declare function atob(data: string): string;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/setTimeout) */
declare function setTimeout(callback: (...args: any[]) => void, msDelay?: number): number;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/setTimeout) */
declare function setTimeout<Args extends any[]>(callback: (...args: Args) => void, msDelay?: number, ...args: Args): number;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/clearTimeout) */
declare function clearTimeout(timeoutId: number | null): void;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/setInterval) */
declare function setInterval(callback: (...args: any[]) => void, msDelay?: number): number;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/setInterval) */
declare function setInterval<Args extends any[]>(callback: (...args: Args) => void, msDelay?: number, ...args: Args): number;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/clearInterval) */
declare function clearInterval(timeoutId: number | null): void;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/queueMicrotask) */
declare function queueMicrotask(task: Function): void;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/structuredClone) */
declare function structuredClone<T>(value: T, options?: StructuredSerializeOptions): T;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/reportError) */
declare function reportError(error: any): void;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/fetch) */
declare function fetch(input: RequestInfo | URL, init?: RequestInit<RequestInitCfProperties>): Promise<Response>;
declare const self: ServiceWorkerGlobalScope;
/**
* The Web Crypto API provides a set of low-level functions for common cryptographic tasks.
* The Workers runtime implements the full surface of this API, but with some differences in
* the [supported algorithms](https://developers.cloudflare.com/workers/runtime-apis/web-crypto/#supported-algorithms)
* compared to those implemented in most browsers.
*
* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/web-crypto/)
*/
2025-09-20 09:21:41 +02:00
declare const crypto: Crypto;
/**
* The Cache API allows fine grained control of reading and writing from the Cloudflare global network cache.
*
* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/)
*/
2025-09-20 09:21:41 +02:00
declare const caches: CacheStorage;
declare const scheduler: Scheduler;
/**
* The Workers runtime supports a subset of the Performance API, used to measure timing and performance,
* as well as timing of subrequests and other operations.
*
* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/)
*/
2025-09-20 09:21:41 +02:00
declare const performance: Performance;
declare const Cloudflare: Cloudflare;
declare const origin: string;
declare const navigator: Navigator;
interface TestController {}
2025-09-20 09:21:41 +02:00
interface ExecutionContext<Props = unknown> {
waitUntil(promise: Promise<any>): void;
passThroughOnException(): void;
readonly props: Props;
2025-09-20 09:21:41 +02:00
}
type ExportedHandlerFetchHandler<Env = unknown, CfHostMetadata = unknown> = (
request: Request<CfHostMetadata, IncomingRequestCfProperties<CfHostMetadata>>,
env: Env,
ctx: ExecutionContext,
) => Response | Promise<Response>;
2025-09-20 09:21:41 +02:00
type ExportedHandlerTailHandler<Env = unknown> = (events: TraceItem[], env: Env, ctx: ExecutionContext) => void | Promise<void>;
type ExportedHandlerTraceHandler<Env = unknown> = (traces: TraceItem[], env: Env, ctx: ExecutionContext) => void | Promise<void>;
type ExportedHandlerTailStreamHandler<Env = unknown> = (
event: TailStream.TailEvent<TailStream.Onset>,
env: Env,
ctx: ExecutionContext,
) => TailStream.TailEventHandlerType | Promise<TailStream.TailEventHandlerType>;
type ExportedHandlerScheduledHandler<Env = unknown> = (
controller: ScheduledController,
env: Env,
ctx: ExecutionContext,
) => void | Promise<void>;
type ExportedHandlerQueueHandler<Env = unknown, Message = unknown> = (
batch: MessageBatch<Message>,
env: Env,
ctx: ExecutionContext,
) => void | Promise<void>;
2025-09-20 09:21:41 +02:00
type ExportedHandlerTestHandler<Env = unknown> = (controller: TestController, env: Env, ctx: ExecutionContext) => void | Promise<void>;
interface ExportedHandler<Env = unknown, QueueHandlerMessage = unknown, CfHostMetadata = unknown> {
fetch?: ExportedHandlerFetchHandler<Env, CfHostMetadata>;
tail?: ExportedHandlerTailHandler<Env>;
trace?: ExportedHandlerTraceHandler<Env>;
tailStream?: ExportedHandlerTailStreamHandler<Env>;
scheduled?: ExportedHandlerScheduledHandler<Env>;
test?: ExportedHandlerTestHandler<Env>;
email?: EmailExportedHandler<Env>;
queue?: ExportedHandlerQueueHandler<Env, QueueHandlerMessage>;
2025-09-20 09:21:41 +02:00
}
interface StructuredSerializeOptions {
transfer?: any[];
2025-09-20 09:21:41 +02:00
}
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/PromiseRejectionEvent) */
declare abstract class PromiseRejectionEvent extends Event {
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/PromiseRejectionEvent/promise) */
readonly promise: Promise<any>;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/PromiseRejectionEvent/reason) */
readonly reason: any;
2025-09-20 09:21:41 +02:00
}
declare abstract class Navigator {
sendBeacon(
url: string,
body?: ReadableStream | string | (ArrayBuffer | ArrayBufferView) | Blob | FormData | URLSearchParams | URLSearchParams,
): boolean;
readonly userAgent: string;
readonly hardwareConcurrency: number;
readonly language: string;
readonly languages: string[];
2025-09-20 09:21:41 +02:00
}
/**
* The Workers runtime supports a subset of the Performance API, used to measure timing and performance,
* as well as timing of subrequests and other operations.
*
* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/)
*/
2025-09-20 09:21:41 +02:00
interface Performance {
/* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/#performancetimeorigin) */
readonly timeOrigin: number;
/* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/#performancenow) */
now(): number;
2025-09-20 09:21:41 +02:00
}
interface AlarmInvocationInfo {
readonly isRetry: boolean;
readonly retryCount: number;
2025-09-20 09:21:41 +02:00
}
interface Cloudflare {
readonly compatibilityFlags: Record<string, boolean>;
2025-09-20 09:21:41 +02:00
}
interface DurableObject {
fetch(request: Request): Response | Promise<Response>;
alarm?(alarmInfo?: AlarmInvocationInfo): void | Promise<void>;
webSocketMessage?(ws: WebSocket, message: string | ArrayBuffer): void | Promise<void>;
webSocketClose?(ws: WebSocket, code: number, reason: string, wasClean: boolean): void | Promise<void>;
webSocketError?(ws: WebSocket, error: unknown): void | Promise<void>;
2025-09-20 09:21:41 +02:00
}
type DurableObjectStub<T extends Rpc.DurableObjectBranded | undefined = undefined> = Fetcher<
T,
"alarm" | "webSocketMessage" | "webSocketClose" | "webSocketError"
> & {
readonly id: DurableObjectId;
readonly name?: string;
2025-09-20 09:21:41 +02:00
};
interface DurableObjectId {
toString(): string;
equals(other: DurableObjectId): boolean;
readonly name?: string;
2025-09-20 09:21:41 +02:00
}
declare abstract class DurableObjectNamespace<T extends Rpc.DurableObjectBranded | undefined = undefined> {
newUniqueId(options?: DurableObjectNamespaceNewUniqueIdOptions): DurableObjectId;
idFromName(name: string): DurableObjectId;
idFromString(id: string): DurableObjectId;
get(id: DurableObjectId, options?: DurableObjectNamespaceGetDurableObjectOptions): DurableObjectStub<T>;
getByName(name: string, options?: DurableObjectNamespaceGetDurableObjectOptions): DurableObjectStub<T>;
jurisdiction(jurisdiction: DurableObjectJurisdiction): DurableObjectNamespace<T>;
2025-09-20 09:21:41 +02:00
}
type DurableObjectJurisdiction = "eu" | "fedramp" | "fedramp-high";
interface DurableObjectNamespaceNewUniqueIdOptions {
jurisdiction?: DurableObjectJurisdiction;
2025-09-20 09:21:41 +02:00
}
type DurableObjectLocationHint = "wnam" | "enam" | "sam" | "weur" | "eeur" | "apac" | "oc" | "afr" | "me";
interface DurableObjectNamespaceGetDurableObjectOptions {
locationHint?: DurableObjectLocationHint;
2025-09-20 09:21:41 +02:00
}
interface DurableObjectClass<_T extends Rpc.DurableObjectBranded | undefined = undefined> {}
2025-09-20 09:21:41 +02:00
interface DurableObjectState<Props = unknown> {
waitUntil(promise: Promise<any>): void;
readonly props: Props;
readonly id: DurableObjectId;
readonly storage: DurableObjectStorage;
container?: Container;
blockConcurrencyWhile<T>(callback: () => Promise<T>): Promise<T>;
acceptWebSocket(ws: WebSocket, tags?: string[]): void;
getWebSockets(tag?: string): WebSocket[];
setWebSocketAutoResponse(maybeReqResp?: WebSocketRequestResponsePair): void;
getWebSocketAutoResponse(): WebSocketRequestResponsePair | null;
getWebSocketAutoResponseTimestamp(ws: WebSocket): Date | null;
setHibernatableWebSocketEventTimeout(timeoutMs?: number): void;
getHibernatableWebSocketEventTimeout(): number | null;
getTags(ws: WebSocket): string[];
abort(reason?: string): void;
2025-09-20 09:21:41 +02:00
}
interface DurableObjectTransaction {
get<T = unknown>(key: string, options?: DurableObjectGetOptions): Promise<T | undefined>;
get<T = unknown>(keys: string[], options?: DurableObjectGetOptions): Promise<Map<string, T>>;
list<T = unknown>(options?: DurableObjectListOptions): Promise<Map<string, T>>;
put<T>(key: string, value: T, options?: DurableObjectPutOptions): Promise<void>;
put<T>(entries: Record<string, T>, options?: DurableObjectPutOptions): Promise<void>;
delete(key: string, options?: DurableObjectPutOptions): Promise<boolean>;
delete(keys: string[], options?: DurableObjectPutOptions): Promise<number>;
rollback(): void;
getAlarm(options?: DurableObjectGetAlarmOptions): Promise<number | null>;
setAlarm(scheduledTime: number | Date, options?: DurableObjectSetAlarmOptions): Promise<void>;
deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise<void>;
2025-09-20 09:21:41 +02:00
}
interface DurableObjectStorage {
get<T = unknown>(key: string, options?: DurableObjectGetOptions): Promise<T | undefined>;
get<T = unknown>(keys: string[], options?: DurableObjectGetOptions): Promise<Map<string, T>>;
list<T = unknown>(options?: DurableObjectListOptions): Promise<Map<string, T>>;
put<T>(key: string, value: T, options?: DurableObjectPutOptions): Promise<void>;
put<T>(entries: Record<string, T>, options?: DurableObjectPutOptions): Promise<void>;
delete(key: string, options?: DurableObjectPutOptions): Promise<boolean>;
delete(keys: string[], options?: DurableObjectPutOptions): Promise<number>;
deleteAll(options?: DurableObjectPutOptions): Promise<void>;
transaction<T>(closure: (txn: DurableObjectTransaction) => Promise<T>): Promise<T>;
getAlarm(options?: DurableObjectGetAlarmOptions): Promise<number | null>;
setAlarm(scheduledTime: number | Date, options?: DurableObjectSetAlarmOptions): Promise<void>;
deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise<void>;
sync(): Promise<void>;
sql: SqlStorage;
kv: SyncKvStorage;
transactionSync<T>(closure: () => T): T;
getCurrentBookmark(): Promise<string>;
getBookmarkForTime(timestamp: number | Date): Promise<string>;
onNextSessionRestoreBookmark(bookmark: string): Promise<string>;
2025-09-20 09:21:41 +02:00
}
interface DurableObjectListOptions {
start?: string;
startAfter?: string;
end?: string;
prefix?: string;
reverse?: boolean;
limit?: number;
allowConcurrency?: boolean;
noCache?: boolean;
2025-09-20 09:21:41 +02:00
}
interface DurableObjectGetOptions {
allowConcurrency?: boolean;
noCache?: boolean;
2025-09-20 09:21:41 +02:00
}
interface DurableObjectGetAlarmOptions {
allowConcurrency?: boolean;
2025-09-20 09:21:41 +02:00
}
interface DurableObjectPutOptions {
allowConcurrency?: boolean;
allowUnconfirmed?: boolean;
noCache?: boolean;
2025-09-20 09:21:41 +02:00
}
interface DurableObjectSetAlarmOptions {
allowConcurrency?: boolean;
allowUnconfirmed?: boolean;
2025-09-20 09:21:41 +02:00
}
declare class WebSocketRequestResponsePair {
constructor(request: string, response: string);
get request(): string;
get response(): string;
2025-09-20 09:21:41 +02:00
}
interface AnalyticsEngineDataset {
writeDataPoint(event?: AnalyticsEngineDataPoint): void;
2025-09-20 09:21:41 +02:00
}
interface AnalyticsEngineDataPoint {
indexes?: ((ArrayBuffer | string) | null)[];
doubles?: number[];
blobs?: ((ArrayBuffer | string) | null)[];
2025-09-20 09:21:41 +02:00
}
/**
* An event which takes place in the DOM.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event)
*/
declare class Event {
constructor(type: string, init?: EventInit);
/**
* Returns the type of event, e.g. "click", "hashchange", or "submit".
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/type)
*/
get type(): string;
/**
* Returns the event's phase, which is one of NONE, CAPTURING_PHASE, AT_TARGET, and BUBBLING_PHASE.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/eventPhase)
*/
get eventPhase(): number;
/**
* 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.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/composed)
*/
get composed(): boolean;
/**
* 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.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/bubbles)
*/
get bubbles(): boolean;
/**
* 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.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/cancelable)
*/
get cancelable(): boolean;
/**
* Returns true if preventDefault() was invoked successfully to indicate cancelation, and false otherwise.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/defaultPrevented)
*/
get defaultPrevented(): boolean;
/**
* @deprecated
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/returnValue)
*/
get returnValue(): boolean;
/**
* Returns the object whose event listener's callback is currently being invoked.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/currentTarget)
*/
get currentTarget(): EventTarget | undefined;
/**
* Returns the object to which event is dispatched (its target).
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/target)
*/
get target(): EventTarget | undefined;
/**
* @deprecated
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/srcElement)
*/
get srcElement(): EventTarget | undefined;
/**
* Returns the event's timestamp as the number of milliseconds measured relative to the time origin.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/timeStamp)
*/
get timeStamp(): number;
/**
* Returns true if event was dispatched by the user agent, and false otherwise.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/isTrusted)
*/
get isTrusted(): boolean;
/**
* @deprecated
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/cancelBubble)
*/
get cancelBubble(): boolean;
/**
* @deprecated
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/cancelBubble)
*/
set cancelBubble(value: boolean);
/**
* 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.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/stopImmediatePropagation)
*/
stopImmediatePropagation(): void;
/**
* 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.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/preventDefault)
*/
preventDefault(): void;
/**
* When dispatched in a tree, invoking this method prevents event from reaching any objects other than the current object.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/stopPropagation)
*/
stopPropagation(): void;
/**
* 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.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/composedPath)
*/
composedPath(): EventTarget[];
static readonly NONE: number;
static readonly CAPTURING_PHASE: number;
static readonly AT_TARGET: number;
static readonly BUBBLING_PHASE: number;
2025-09-20 09:21:41 +02:00
}
interface EventInit {
bubbles?: boolean;
cancelable?: boolean;
composed?: boolean;
2025-09-20 09:21:41 +02:00
}
type EventListener<EventType extends Event = Event> = (event: EventType) => void;
interface EventListenerObject<EventType extends Event = Event> {
handleEvent(event: EventType): void;
2025-09-20 09:21:41 +02:00
}
type EventListenerOrEventListenerObject<EventType extends Event = Event> = EventListener<EventType> | EventListenerObject<EventType>;
/**
* EventTarget is a DOM interface implemented by objects that can receive events and may have listeners for them.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget)
*/
declare class EventTarget<EventMap extends Record<string, Event> = Record<string, Event>> {
constructor();
/**
* 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.
*
* 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.
*
* 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.
*
* 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.
*
* When set to true, options's once indicates that the callback will only be invoked once after which the event listener will be removed.
*
* If an AbortSignal is passed for options's signal, then the event listener will be removed when signal is aborted.
*
* The event listener is appended to target's event listener list and is not appended if it has the same type, callback, and capture.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/addEventListener)
*/
addEventListener<Type extends keyof EventMap>(
type: Type,
handler: EventListenerOrEventListenerObject<EventMap[Type]>,
options?: EventTargetAddEventListenerOptions | boolean,
): void;
/**
* Removes the event listener in target's event listener list with the same type, callback, and options.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/removeEventListener)
*/
removeEventListener<Type extends keyof EventMap>(
type: Type,
handler: EventListenerOrEventListenerObject<EventMap[Type]>,
options?: EventTargetEventListenerOptions | boolean,
): void;
/**
* 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.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/dispatchEvent)
*/
dispatchEvent(event: EventMap[keyof EventMap]): boolean;
2025-09-20 09:21:41 +02:00
}
interface EventTargetEventListenerOptions {
capture?: boolean;
2025-09-20 09:21:41 +02:00
}
interface EventTargetAddEventListenerOptions {
capture?: boolean;
passive?: boolean;
once?: boolean;
signal?: AbortSignal;
2025-09-20 09:21:41 +02:00
}
interface EventTargetHandlerObject {
handleEvent: (event: Event) => any | undefined;
2025-09-20 09:21:41 +02:00
}
/**
* A controller object that allows you to abort one or more DOM requests as and when desired.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortController)
*/
declare class AbortController {
constructor();
/**
* Returns the AbortSignal object associated with this object.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortController/signal)
*/
get signal(): AbortSignal;
/**
* 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.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortController/abort)
*/
abort(reason?: any): void;
2025-09-20 09:21:41 +02:00
}
/**
* 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.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal)
*/
declare abstract class AbortSignal extends EventTarget {
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/abort_static) */
static abort(reason?: any): AbortSignal;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/timeout_static) */
static timeout(delay: number): AbortSignal;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/any_static) */
static any(signals: AbortSignal[]): AbortSignal;
/**
* Returns true if this AbortSignal's AbortController has signaled to abort, and false otherwise.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/aborted)
*/
get aborted(): boolean;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/reason) */
get reason(): any;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/abort_event) */
get onabort(): any | null;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/abort_event) */
set onabort(value: any | null);
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/throwIfAborted) */
throwIfAborted(): void;
2025-09-20 09:21:41 +02:00
}
interface Scheduler {
wait(delay: number, maybeOptions?: SchedulerWaitOptions): Promise<void>;
2025-09-20 09:21:41 +02:00
}
interface SchedulerWaitOptions {
signal?: AbortSignal;
2025-09-20 09:21:41 +02:00
}
/**
* 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.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ExtendableEvent)
*/
declare abstract class ExtendableEvent extends Event {
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ExtendableEvent/waitUntil) */
waitUntil(promise: Promise<any>): void;
2025-09-20 09:21:41 +02:00
}
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CustomEvent) */
declare class CustomEvent<T = any> extends Event {
constructor(type: string, init?: CustomEventCustomEventInit);
/**
* Returns any custom data event was created with. Typically used for synthetic events.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CustomEvent/detail)
*/
get detail(): T;
2025-09-20 09:21:41 +02:00
}
interface CustomEventCustomEventInit {
bubbles?: boolean;
cancelable?: boolean;
composed?: boolean;
detail?: any;
2025-09-20 09:21:41 +02:00
}
/**
* 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.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob)
*/
declare class Blob {
constructor(type?: ((ArrayBuffer | ArrayBufferView) | string | Blob)[], options?: BlobOptions);
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/size) */
get size(): number;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/type) */
get type(): string;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/slice) */
slice(start?: number, end?: number, type?: string): Blob;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/arrayBuffer) */
arrayBuffer(): Promise<ArrayBuffer>;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/bytes) */
bytes(): Promise<Uint8Array>;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/text) */
text(): Promise<string>;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/stream) */
stream(): ReadableStream;
2025-09-20 09:21:41 +02:00
}
interface BlobOptions {
type?: string;
2025-09-20 09:21:41 +02:00
}
/**
* Provides information about files and allows JavaScript in a web page to access their content.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/File)
*/
declare class File extends Blob {
constructor(bits: ((ArrayBuffer | ArrayBufferView) | string | Blob)[] | undefined, name: string, options?: FileOptions);
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/File/name) */
get name(): string;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/File/lastModified) */
get lastModified(): number;
2025-09-20 09:21:41 +02:00
}
interface FileOptions {
type?: string;
lastModified?: number;
2025-09-20 09:21:41 +02:00
}
/**
* The Cache API allows fine grained control of reading and writing from the Cloudflare global network cache.
*
* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/)
*/
2025-09-20 09:21:41 +02:00
declare abstract class CacheStorage {
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CacheStorage/open) */
open(cacheName: string): Promise<Cache>;
readonly default: Cache;
2025-09-20 09:21:41 +02:00
}
/**
* The Cache API allows fine grained control of reading and writing from the Cloudflare global network cache.
*
* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/)
*/
2025-09-20 09:21:41 +02:00
declare abstract class Cache {
/* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/#delete) */
delete(request: RequestInfo | URL, options?: CacheQueryOptions): Promise<boolean>;
/* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/#match) */
match(request: RequestInfo | URL, options?: CacheQueryOptions): Promise<Response | undefined>;
/* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/#put) */
put(request: RequestInfo | URL, response: Response): Promise<void>;
2025-09-20 09:21:41 +02:00
}
interface CacheQueryOptions {
ignoreMethod?: boolean;
2025-09-20 09:21:41 +02:00
}
/**
* The Web Crypto API provides a set of low-level functions for common cryptographic tasks.
* The Workers runtime implements the full surface of this API, but with some differences in
* the [supported algorithms](https://developers.cloudflare.com/workers/runtime-apis/web-crypto/#supported-algorithms)
* compared to those implemented in most browsers.
*
* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/web-crypto/)
*/
2025-09-20 09:21:41 +02:00
declare abstract class Crypto {
/**
* Available only in secure contexts.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Crypto/subtle)
*/
get subtle(): SubtleCrypto;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Crypto/getRandomValues) */
getRandomValues<T extends Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | BigInt64Array | BigUint64Array>(
buffer: T,
): T;
/**
* Available only in secure contexts.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Crypto/randomUUID)
*/
randomUUID(): string;
DigestStream: typeof DigestStream;
2025-09-20 09:21:41 +02:00
}
/**
* 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).
* Available only in secure contexts.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto)
*/
declare abstract class SubtleCrypto {
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/encrypt) */
encrypt(algorithm: string | SubtleCryptoEncryptAlgorithm, key: CryptoKey, plainText: ArrayBuffer | ArrayBufferView): Promise<ArrayBuffer>;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/decrypt) */
decrypt(
algorithm: string | SubtleCryptoEncryptAlgorithm,
key: CryptoKey,
cipherText: ArrayBuffer | ArrayBufferView,
): Promise<ArrayBuffer>;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/sign) */
sign(algorithm: string | SubtleCryptoSignAlgorithm, key: CryptoKey, data: ArrayBuffer | ArrayBufferView): Promise<ArrayBuffer>;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/verify) */
verify(
algorithm: string | SubtleCryptoSignAlgorithm,
key: CryptoKey,
signature: ArrayBuffer | ArrayBufferView,
data: ArrayBuffer | ArrayBufferView,
): Promise<boolean>;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/digest) */
digest(algorithm: string | SubtleCryptoHashAlgorithm, data: ArrayBuffer | ArrayBufferView): Promise<ArrayBuffer>;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/generateKey) */
generateKey(
algorithm: string | SubtleCryptoGenerateKeyAlgorithm,
extractable: boolean,
keyUsages: string[],
): Promise<CryptoKey | CryptoKeyPair>;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/deriveKey) */
deriveKey(
algorithm: string | SubtleCryptoDeriveKeyAlgorithm,
baseKey: CryptoKey,
derivedKeyAlgorithm: string | SubtleCryptoImportKeyAlgorithm,
extractable: boolean,
keyUsages: string[],
): Promise<CryptoKey>;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/deriveBits) */
deriveBits(algorithm: string | SubtleCryptoDeriveKeyAlgorithm, baseKey: CryptoKey, length?: number | null): Promise<ArrayBuffer>;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/importKey) */
importKey(
format: string,
keyData: (ArrayBuffer | ArrayBufferView) | JsonWebKey,
algorithm: string | SubtleCryptoImportKeyAlgorithm,
extractable: boolean,
keyUsages: string[],
): Promise<CryptoKey>;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/exportKey) */
exportKey(format: string, key: CryptoKey): Promise<ArrayBuffer | JsonWebKey>;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/wrapKey) */
wrapKey(
format: string,
key: CryptoKey,
wrappingKey: CryptoKey,
wrapAlgorithm: string | SubtleCryptoEncryptAlgorithm,
): Promise<ArrayBuffer>;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/unwrapKey) */
unwrapKey(
format: string,
wrappedKey: ArrayBuffer | ArrayBufferView,
unwrappingKey: CryptoKey,
unwrapAlgorithm: string | SubtleCryptoEncryptAlgorithm,
unwrappedKeyAlgorithm: string | SubtleCryptoImportKeyAlgorithm,
extractable: boolean,
keyUsages: string[],
): Promise<CryptoKey>;
timingSafeEqual(a: ArrayBuffer | ArrayBufferView, b: ArrayBuffer | ArrayBufferView): boolean;
2025-09-20 09:21:41 +02:00
}
/**
* The CryptoKey dictionary of the Web Crypto API represents a cryptographic key.
* Available only in secure contexts.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey)
*/
declare abstract class CryptoKey {
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/type) */
readonly type: string;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/extractable) */
readonly extractable: boolean;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/algorithm) */
readonly algorithm:
| CryptoKeyKeyAlgorithm
| CryptoKeyAesKeyAlgorithm
| CryptoKeyHmacKeyAlgorithm
| CryptoKeyRsaKeyAlgorithm
| CryptoKeyEllipticKeyAlgorithm
| CryptoKeyArbitraryKeyAlgorithm;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/usages) */
readonly usages: string[];
2025-09-20 09:21:41 +02:00
}
interface CryptoKeyPair {
publicKey: CryptoKey;
privateKey: CryptoKey;
2025-09-20 09:21:41 +02:00
}
interface JsonWebKey {
kty: string;
use?: string;
key_ops?: string[];
alg?: string;
ext?: boolean;
crv?: string;
x?: string;
y?: string;
d?: string;
n?: string;
e?: string;
p?: string;
q?: string;
dp?: string;
dq?: string;
qi?: string;
oth?: RsaOtherPrimesInfo[];
k?: string;
2025-09-20 09:21:41 +02:00
}
interface RsaOtherPrimesInfo {
r?: string;
d?: string;
t?: string;
2025-09-20 09:21:41 +02:00
}
interface SubtleCryptoDeriveKeyAlgorithm {
name: string;
salt?: ArrayBuffer | ArrayBufferView;
iterations?: number;
hash?: string | SubtleCryptoHashAlgorithm;
$public?: CryptoKey;
info?: ArrayBuffer | ArrayBufferView;
2025-09-20 09:21:41 +02:00
}
interface SubtleCryptoEncryptAlgorithm {
name: string;
iv?: ArrayBuffer | ArrayBufferView;
additionalData?: ArrayBuffer | ArrayBufferView;
tagLength?: number;
counter?: ArrayBuffer | ArrayBufferView;
length?: number;
label?: ArrayBuffer | ArrayBufferView;
2025-09-20 09:21:41 +02:00
}
interface SubtleCryptoGenerateKeyAlgorithm {
name: string;
hash?: string | SubtleCryptoHashAlgorithm;
modulusLength?: number;
publicExponent?: ArrayBuffer | ArrayBufferView;
length?: number;
namedCurve?: string;
2025-09-20 09:21:41 +02:00
}
interface SubtleCryptoHashAlgorithm {
name: string;
2025-09-20 09:21:41 +02:00
}
interface SubtleCryptoImportKeyAlgorithm {
name: string;
hash?: string | SubtleCryptoHashAlgorithm;
length?: number;
namedCurve?: string;
compressed?: boolean;
2025-09-20 09:21:41 +02:00
}
interface SubtleCryptoSignAlgorithm {
name: string;
hash?: string | SubtleCryptoHashAlgorithm;
dataLength?: number;
saltLength?: number;
2025-09-20 09:21:41 +02:00
}
interface CryptoKeyKeyAlgorithm {
name: string;
2025-09-20 09:21:41 +02:00
}
interface CryptoKeyAesKeyAlgorithm {
name: string;
length: number;
2025-09-20 09:21:41 +02:00
}
interface CryptoKeyHmacKeyAlgorithm {
name: string;
hash: CryptoKeyKeyAlgorithm;
length: number;
2025-09-20 09:21:41 +02:00
}
interface CryptoKeyRsaKeyAlgorithm {
name: string;
modulusLength: number;
publicExponent: ArrayBuffer | ArrayBufferView;
hash?: CryptoKeyKeyAlgorithm;
2025-09-20 09:21:41 +02:00
}
interface CryptoKeyEllipticKeyAlgorithm {
name: string;
namedCurve: string;
2025-09-20 09:21:41 +02:00
}
interface CryptoKeyArbitraryKeyAlgorithm {
name: string;
hash?: CryptoKeyKeyAlgorithm;
namedCurve?: string;
length?: number;
2025-09-20 09:21:41 +02:00
}
declare class DigestStream extends WritableStream<ArrayBuffer | ArrayBufferView> {
constructor(algorithm: string | SubtleCryptoHashAlgorithm);
readonly digest: Promise<ArrayBuffer>;
get bytesWritten(): number | bigint;
2025-09-20 09:21:41 +02:00
}
/**
* 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.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextDecoder)
*/
declare class TextDecoder {
constructor(label?: string, options?: TextDecoderConstructorOptions);
/**
* 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.
*
* ```
* var string = "", decoder = new TextDecoder(encoding), buffer;
* while(buffer = next_chunk()) {
* string += decoder.decode(buffer, {stream:true});
* }
* string += decoder.decode(); // end-of-queue
* ```
*
* If the error mode is "fatal" and encoding's decoder returns error, throws a TypeError.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextDecoder/decode)
*/
decode(input?: ArrayBuffer | ArrayBufferView, options?: TextDecoderDecodeOptions): string;
get encoding(): string;
get fatal(): boolean;
get ignoreBOM(): boolean;
2025-09-20 09:21:41 +02:00
}
/**
* 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.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextEncoder)
*/
declare class TextEncoder {
constructor();
/**
* Returns the result of running UTF-8's encoder.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextEncoder/encode)
*/
encode(input?: string): Uint8Array;
/**
* 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.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextEncoder/encodeInto)
*/
encodeInto(input: string, buffer: ArrayBuffer | ArrayBufferView): TextEncoderEncodeIntoResult;
get encoding(): string;
2025-09-20 09:21:41 +02:00
}
interface TextDecoderConstructorOptions {
fatal: boolean;
ignoreBOM: boolean;
2025-09-20 09:21:41 +02:00
}
interface TextDecoderDecodeOptions {
stream: boolean;
2025-09-20 09:21:41 +02:00
}
interface TextEncoderEncodeIntoResult {
read: number;
written: number;
2025-09-20 09:21:41 +02:00
}
/**
* Events providing information related to errors in scripts or in files.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent)
*/
declare class ErrorEvent extends Event {
constructor(type: string, init?: ErrorEventErrorEventInit);
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/filename) */
get filename(): string;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/message) */
get message(): string;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/lineno) */
get lineno(): number;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/colno) */
get colno(): number;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/error) */
get error(): any;
2025-09-20 09:21:41 +02:00
}
interface ErrorEventErrorEventInit {
message?: string;
filename?: string;
lineno?: number;
colno?: number;
error?: any;
2025-09-20 09:21:41 +02:00
}
/**
* A message received by a target object.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent)
*/
declare class MessageEvent extends Event {
constructor(type: string, initializer: MessageEventInit);
/**
* Returns the data of the message.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/data)
*/
readonly data: any;
/**
* Returns the origin of the message, for server-sent events and cross-document messaging.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/origin)
*/
readonly origin: string | null;
/**
* Returns the last event ID string, for server-sent events.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/lastEventId)
*/
readonly lastEventId: string;
/**
* Returns the WindowProxy of the source window, for cross-document messaging, and the MessagePort being attached, in the connect event fired at SharedWorkerGlobalScope objects.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/source)
*/
readonly source: MessagePort | null;
/**
* Returns the MessagePort array sent with the message, for cross-document messaging and channel messaging.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/ports)
*/
readonly ports: MessagePort[];
2025-09-20 09:21:41 +02:00
}
interface MessageEventInit {
data: ArrayBuffer | string;
2025-09-20 09:21:41 +02:00
}
/**
* 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".
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData)
*/
declare class FormData {
constructor();
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/append) */
append(name: string, value: string): void;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/append) */
append(name: string, value: Blob, filename?: string): void;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/delete) */
delete(name: string): void;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/get) */
get(name: string): (File | string) | null;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/getAll) */
getAll(name: string): (File | string)[];
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/has) */
has(name: string): boolean;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/set) */
set(name: string, value: string): void;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/set) */
set(name: string, value: Blob, filename?: string): void;
/* Returns an array of key, value pairs for every entry in the list. */
entries(): IterableIterator<[key: string, value: File | string]>;
/* Returns a list of keys in the list. */
keys(): IterableIterator<string>;
/* Returns a list of values in the list. */
values(): IterableIterator<File | string>;
forEach<This = unknown>(callback: (this: This, value: File | string, key: string, parent: FormData) => void, thisArg?: This): void;
[Symbol.iterator](): IterableIterator<[key: string, value: File | string]>;
2025-09-20 09:21:41 +02:00
}
interface ContentOptions {
html?: boolean;
2025-09-20 09:21:41 +02:00
}
declare class HTMLRewriter {
constructor();
on(selector: string, handlers: HTMLRewriterElementContentHandlers): HTMLRewriter;
onDocument(handlers: HTMLRewriterDocumentContentHandlers): HTMLRewriter;
transform(response: Response): Response;
2025-09-20 09:21:41 +02:00
}
interface HTMLRewriterElementContentHandlers {
element?(element: Element): void | Promise<void>;
comments?(comment: Comment): void | Promise<void>;
text?(element: Text): void | Promise<void>;
2025-09-20 09:21:41 +02:00
}
interface HTMLRewriterDocumentContentHandlers {
doctype?(doctype: Doctype): void | Promise<void>;
comments?(comment: Comment): void | Promise<void>;
text?(text: Text): void | Promise<void>;
end?(end: DocumentEnd): void | Promise<void>;
2025-09-20 09:21:41 +02:00
}
interface Doctype {
readonly name: string | null;
readonly publicId: string | null;
readonly systemId: string | null;
2025-09-20 09:21:41 +02:00
}
interface Element {
tagName: string;
readonly attributes: IterableIterator<string[]>;
readonly removed: boolean;
readonly namespaceURI: string;
getAttribute(name: string): string | null;
hasAttribute(name: string): boolean;
setAttribute(name: string, value: string): Element;
removeAttribute(name: string): Element;
before(content: string | ReadableStream | Response, options?: ContentOptions): Element;
after(content: string | ReadableStream | Response, options?: ContentOptions): Element;
prepend(content: string | ReadableStream | Response, options?: ContentOptions): Element;
append(content: string | ReadableStream | Response, options?: ContentOptions): Element;
replace(content: string | ReadableStream | Response, options?: ContentOptions): Element;
remove(): Element;
removeAndKeepContent(): Element;
setInnerContent(content: string | ReadableStream | Response, options?: ContentOptions): Element;
onEndTag(handler: (tag: EndTag) => void | Promise<void>): void;
2025-09-20 09:21:41 +02:00
}
interface EndTag {
name: string;
before(content: string | ReadableStream | Response, options?: ContentOptions): EndTag;
after(content: string | ReadableStream | Response, options?: ContentOptions): EndTag;
remove(): EndTag;
2025-09-20 09:21:41 +02:00
}
interface Comment {
text: string;
readonly removed: boolean;
before(content: string, options?: ContentOptions): Comment;
after(content: string, options?: ContentOptions): Comment;
replace(content: string, options?: ContentOptions): Comment;
remove(): Comment;
2025-09-20 09:21:41 +02:00
}
interface Text {
readonly text: string;
readonly lastInTextNode: boolean;
readonly removed: boolean;
before(content: string | ReadableStream | Response, options?: ContentOptions): Text;
after(content: string | ReadableStream | Response, options?: ContentOptions): Text;
replace(content: string | ReadableStream | Response, options?: ContentOptions): Text;
remove(): Text;
2025-09-20 09:21:41 +02:00
}
interface DocumentEnd {
append(content: string, options?: ContentOptions): DocumentEnd;
2025-09-20 09:21:41 +02:00
}
/**
* 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.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FetchEvent)
*/
declare abstract class FetchEvent extends ExtendableEvent {
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FetchEvent/request) */
readonly request: Request;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FetchEvent/respondWith) */
respondWith(promise: Response | Promise<Response>): void;
passThroughOnException(): void;
2025-09-20 09:21:41 +02:00
}
type HeadersInit = Headers | Iterable<Iterable<string>> | Record<string, string>;
/**
* 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.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers)
*/
declare class Headers {
constructor(init?: HeadersInit);
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/get) */
get(name: string): string | null;
getAll(name: string): string[];
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/getSetCookie) */
getSetCookie(): string[];
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/has) */
has(name: string): boolean;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/set) */
set(name: string, value: string): void;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/append) */
append(name: string, value: string): void;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/delete) */
delete(name: string): void;
forEach<This = unknown>(callback: (this: This, value: string, key: string, parent: Headers) => void, thisArg?: This): void;
/* Returns an iterator allowing to go through all key/value pairs contained in this object. */
entries(): IterableIterator<[key: string, value: string]>;
/* Returns an iterator allowing to go through all keys of the key/value pairs contained in this object. */
keys(): IterableIterator<string>;
/* Returns an iterator allowing to go through all values of the key/value pairs contained in this object. */
values(): IterableIterator<string>;
[Symbol.iterator](): IterableIterator<[key: string, value: string]>;
2025-09-20 09:21:41 +02:00
}
type BodyInit = ReadableStream<Uint8Array> | string | ArrayBuffer | ArrayBufferView | Blob | URLSearchParams | FormData;
declare abstract class Body {
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/body) */
get body(): ReadableStream | null;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/bodyUsed) */
get bodyUsed(): boolean;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/arrayBuffer) */
arrayBuffer(): Promise<ArrayBuffer>;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/bytes) */
bytes(): Promise<Uint8Array>;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/text) */
text(): Promise<string>;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/json) */
json<T>(): Promise<T>;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/formData) */
formData(): Promise<FormData>;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/blob) */
blob(): Promise<Blob>;
2025-09-20 09:21:41 +02:00
}
/**
* This Fetch API interface represents the response to a request.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response)
*/
declare var Response: {
prototype: Response;
new (body?: BodyInit | null, init?: ResponseInit): Response;
error(): Response;
redirect(url: string, status?: number): Response;
json(any: any, maybeInit?: ResponseInit | Response): Response;
2025-09-20 09:21:41 +02:00
};
/**
* This Fetch API interface represents the response to a request.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response)
*/
interface Response extends Body {
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/clone) */
clone(): Response;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/status) */
status: number;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/statusText) */
statusText: string;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/headers) */
headers: Headers;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/ok) */
ok: boolean;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/redirected) */
redirected: boolean;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/url) */
url: string;
webSocket: WebSocket | null;
cf: any | undefined;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/type) */
type: "default" | "error";
2025-09-20 09:21:41 +02:00
}
interface ResponseInit {
status?: number;
statusText?: string;
headers?: HeadersInit;
cf?: any;
webSocket?: WebSocket | null;
encodeBody?: "automatic" | "manual";
2025-09-20 09:21:41 +02:00
}
type RequestInfo<CfHostMetadata = unknown, Cf = CfProperties<CfHostMetadata>> = Request<CfHostMetadata, Cf> | string;
/**
* This Fetch API interface represents a resource request.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request)
*/
declare var Request: {
prototype: Request;
new <CfHostMetadata = unknown, Cf = CfProperties<CfHostMetadata>>(
input: RequestInfo<CfProperties> | URL,
init?: RequestInit<Cf>,
): Request<CfHostMetadata, Cf>;
2025-09-20 09:21:41 +02:00
};
/**
* This Fetch API interface represents a resource request.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request)
*/
interface Request<CfHostMetadata = unknown, Cf = CfProperties<CfHostMetadata>> extends Body {
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/clone) */
clone(): Request<CfHostMetadata, Cf>;
/**
* Returns request's HTTP method, which is "GET" by default.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/method)
*/
method: string;
/**
* Returns the URL of request as a string.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/url)
*/
url: string;
/**
* 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.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/headers)
*/
headers: Headers;
/**
* 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.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/redirect)
*/
redirect: string;
fetcher: Fetcher | null;
/**
* Returns the signal associated with request, which is an AbortSignal object indicating whether or not request has been aborted, and its abort event handler.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/signal)
*/
signal: AbortSignal;
cf: Cf | undefined;
/**
* 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]
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/integrity)
*/
integrity: string;
/**
* Returns a boolean indicating whether or not request can outlive the global in which it was created.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/keepalive)
*/
keepalive: boolean;
/**
* Returns the cache mode associated with request, which is a string indicating how the request will interact with the browser's cache when fetching.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/cache)
*/
cache?: "no-store" | "no-cache";
2025-09-20 09:21:41 +02:00
}
interface RequestInit<Cf = CfProperties> {
/* A string to set request's method. */
method?: string;
/* A Headers object, an object literal, or an array of two-item arrays to set request's headers. */
headers?: HeadersInit;
/* A BodyInit object or null to set request's body. */
body?: BodyInit | null;
/* 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. */
redirect?: string;
fetcher?: Fetcher | null;
cf?: Cf;
/* A string indicating how the request will interact with the browser's cache to set request's cache. */
cache?: "no-store" | "no-cache";
/* A cryptographic hash of the resource to be fetched by request. Sets request's integrity. */
integrity?: string;
/* An AbortSignal to set request's signal. */
signal?: AbortSignal | null;
encodeResponseBody?: "automatic" | "manual";
2025-09-20 09:21:41 +02:00
}
type Service<
T extends
| (new (...args: any[]) => Rpc.WorkerEntrypointBranded)
| Rpc.WorkerEntrypointBranded
| ExportedHandler<any, any, any>
| undefined = undefined,
> = T extends new (...args: any[]) => Rpc.WorkerEntrypointBranded
? Fetcher<InstanceType<T>>
: T extends Rpc.WorkerEntrypointBranded
? Fetcher<T>
: T extends Exclude<Rpc.EntrypointBranded, Rpc.WorkerEntrypointBranded>
? never
: Fetcher<undefined>;
type Fetcher<T extends Rpc.EntrypointBranded | undefined = undefined, Reserved extends string = never> = (T extends Rpc.EntrypointBranded
? Rpc.Provider<T, Reserved | "fetch" | "connect">
: unknown) & {
fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
connect(address: SocketAddress | string, options?: SocketOptions): Socket;
2025-09-20 09:21:41 +02:00
};
interface KVNamespaceListKey<Metadata, Key extends string = string> {
name: Key;
expiration?: number;
metadata?: Metadata;
2025-09-20 09:21:41 +02:00
}
type KVNamespaceListResult<Metadata, Key extends string = string> =
| {
list_complete: false;
keys: KVNamespaceListKey<Metadata, Key>[];
cursor: string;
cacheStatus: string | null;
}
| {
list_complete: true;
keys: KVNamespaceListKey<Metadata, Key>[];
cacheStatus: string | null;
};
2025-09-20 09:21:41 +02:00
interface KVNamespace<Key extends string = string> {
get(key: Key, options?: Partial<KVNamespaceGetOptions<undefined>>): Promise<string | null>;
get(key: Key, type: "text"): Promise<string | null>;
get<ExpectedValue = unknown>(key: Key, type: "json"): Promise<ExpectedValue | null>;
get(key: Key, type: "arrayBuffer"): Promise<ArrayBuffer | null>;
get(key: Key, type: "stream"): Promise<ReadableStream | null>;
get(key: Key, options?: KVNamespaceGetOptions<"text">): Promise<string | null>;
get<ExpectedValue = unknown>(key: Key, options?: KVNamespaceGetOptions<"json">): Promise<ExpectedValue | null>;
get(key: Key, options?: KVNamespaceGetOptions<"arrayBuffer">): Promise<ArrayBuffer | null>;
get(key: Key, options?: KVNamespaceGetOptions<"stream">): Promise<ReadableStream | null>;
get(key: Array<Key>, type: "text"): Promise<Map<string, string | null>>;
get<ExpectedValue = unknown>(key: Array<Key>, type: "json"): Promise<Map<string, ExpectedValue | null>>;
get(key: Array<Key>, options?: Partial<KVNamespaceGetOptions<undefined>>): Promise<Map<string, string | null>>;
get(key: Array<Key>, options?: KVNamespaceGetOptions<"text">): Promise<Map<string, string | null>>;
get<ExpectedValue = unknown>(key: Array<Key>, options?: KVNamespaceGetOptions<"json">): Promise<Map<string, ExpectedValue | null>>;
list<Metadata = unknown>(options?: KVNamespaceListOptions): Promise<KVNamespaceListResult<Metadata, Key>>;
put(key: Key, value: string | ArrayBuffer | ArrayBufferView | ReadableStream, options?: KVNamespacePutOptions): Promise<void>;
getWithMetadata<Metadata = unknown>(
key: Key,
options?: Partial<KVNamespaceGetOptions<undefined>>,
): Promise<KVNamespaceGetWithMetadataResult<string, Metadata>>;
getWithMetadata<Metadata = unknown>(key: Key, type: "text"): Promise<KVNamespaceGetWithMetadataResult<string, Metadata>>;
getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(
key: Key,
type: "json",
): Promise<KVNamespaceGetWithMetadataResult<ExpectedValue, Metadata>>;
getWithMetadata<Metadata = unknown>(key: Key, type: "arrayBuffer"): Promise<KVNamespaceGetWithMetadataResult<ArrayBuffer, Metadata>>;
getWithMetadata<Metadata = unknown>(key: Key, type: "stream"): Promise<KVNamespaceGetWithMetadataResult<ReadableStream, Metadata>>;
getWithMetadata<Metadata = unknown>(
key: Key,
options: KVNamespaceGetOptions<"text">,
): Promise<KVNamespaceGetWithMetadataResult<string, Metadata>>;
getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(
key: Key,
options: KVNamespaceGetOptions<"json">,
): Promise<KVNamespaceGetWithMetadataResult<ExpectedValue, Metadata>>;
getWithMetadata<Metadata = unknown>(
key: Key,
options: KVNamespaceGetOptions<"arrayBuffer">,
): Promise<KVNamespaceGetWithMetadataResult<ArrayBuffer, Metadata>>;
getWithMetadata<Metadata = unknown>(
key: Key,
options: KVNamespaceGetOptions<"stream">,
): Promise<KVNamespaceGetWithMetadataResult<ReadableStream, Metadata>>;
getWithMetadata<Metadata = unknown>(
key: Array<Key>,
type: "text",
): Promise<Map<string, KVNamespaceGetWithMetadataResult<string, Metadata>>>;
getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(
key: Array<Key>,
type: "json",
): Promise<Map<string, KVNamespaceGetWithMetadataResult<ExpectedValue, Metadata>>>;
getWithMetadata<Metadata = unknown>(
key: Array<Key>,
options?: Partial<KVNamespaceGetOptions<undefined>>,
): Promise<Map<string, KVNamespaceGetWithMetadataResult<string, Metadata>>>;
getWithMetadata<Metadata = unknown>(
key: Array<Key>,
options?: KVNamespaceGetOptions<"text">,
): Promise<Map<string, KVNamespaceGetWithMetadataResult<string, Metadata>>>;
getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(
key: Array<Key>,
options?: KVNamespaceGetOptions<"json">,
): Promise<Map<string, KVNamespaceGetWithMetadataResult<ExpectedValue, Metadata>>>;
delete(key: Key): Promise<void>;
2025-09-20 09:21:41 +02:00
}
interface KVNamespaceListOptions {
limit?: number;
prefix?: string | null;
cursor?: string | null;
2025-09-20 09:21:41 +02:00
}
interface KVNamespaceGetOptions<Type> {
type: Type;
cacheTtl?: number;
2025-09-20 09:21:41 +02:00
}
interface KVNamespacePutOptions {
expiration?: number;
expirationTtl?: number;
metadata?: any | null;
2025-09-20 09:21:41 +02:00
}
interface KVNamespaceGetWithMetadataResult<Value, Metadata> {
value: Value | null;
metadata: Metadata | null;
cacheStatus: string | null;
2025-09-20 09:21:41 +02:00
}
type QueueContentType = "text" | "bytes" | "json" | "v8";
interface Queue<Body = unknown> {
send(message: Body, options?: QueueSendOptions): Promise<void>;
sendBatch(messages: Iterable<MessageSendRequest<Body>>, options?: QueueSendBatchOptions): Promise<void>;
2025-09-20 09:21:41 +02:00
}
interface QueueSendOptions {
contentType?: QueueContentType;
delaySeconds?: number;
2025-09-20 09:21:41 +02:00
}
interface QueueSendBatchOptions {
delaySeconds?: number;
2025-09-20 09:21:41 +02:00
}
interface MessageSendRequest<Body = unknown> {
body: Body;
contentType?: QueueContentType;
delaySeconds?: number;
2025-09-20 09:21:41 +02:00
}
interface QueueRetryOptions {
delaySeconds?: number;
2025-09-20 09:21:41 +02:00
}
interface Message<Body = unknown> {
readonly id: string;
readonly timestamp: Date;
readonly body: Body;
readonly attempts: number;
retry(options?: QueueRetryOptions): void;
ack(): void;
2025-09-20 09:21:41 +02:00
}
interface QueueEvent<Body = unknown> extends ExtendableEvent {
readonly messages: readonly Message<Body>[];
readonly queue: string;
retryAll(options?: QueueRetryOptions): void;
ackAll(): void;
2025-09-20 09:21:41 +02:00
}
interface MessageBatch<Body = unknown> {
readonly messages: readonly Message<Body>[];
readonly queue: string;
retryAll(options?: QueueRetryOptions): void;
ackAll(): void;
2025-09-20 09:21:41 +02:00
}
interface R2Error extends Error {
readonly name: string;
readonly code: number;
readonly message: string;
readonly action: string;
readonly stack: any;
2025-09-20 09:21:41 +02:00
}
interface R2ListOptions {
limit?: number;
prefix?: string;
cursor?: string;
delimiter?: string;
startAfter?: string;
include?: ("httpMetadata" | "customMetadata")[];
2025-09-20 09:21:41 +02:00
}
declare abstract class R2Bucket {
head(key: string): Promise<R2Object | null>;
get(
key: string,
options: R2GetOptions & {
onlyIf: R2Conditional | Headers;
},
): Promise<R2ObjectBody | R2Object | null>;
get(key: string, options?: R2GetOptions): Promise<R2ObjectBody | null>;
put(
key: string,
value: ReadableStream | ArrayBuffer | ArrayBufferView | string | null | Blob,
options?: R2PutOptions & {
onlyIf: R2Conditional | Headers;
},
): Promise<R2Object | null>;
put(key: string, value: ReadableStream | ArrayBuffer | ArrayBufferView | string | null | Blob, options?: R2PutOptions): Promise<R2Object>;
createMultipartUpload(key: string, options?: R2MultipartOptions): Promise<R2MultipartUpload>;
resumeMultipartUpload(key: string, uploadId: string): R2MultipartUpload;
delete(keys: string | string[]): Promise<void>;
list(options?: R2ListOptions): Promise<R2Objects>;
2025-09-20 09:21:41 +02:00
}
interface R2MultipartUpload {
readonly key: string;
readonly uploadId: string;
uploadPart(
partNumber: number,
value: ReadableStream | (ArrayBuffer | ArrayBufferView) | string | Blob,
options?: R2UploadPartOptions,
): Promise<R2UploadedPart>;
abort(): Promise<void>;
complete(uploadedParts: R2UploadedPart[]): Promise<R2Object>;
2025-09-20 09:21:41 +02:00
}
interface R2UploadedPart {
partNumber: number;
etag: string;
2025-09-20 09:21:41 +02:00
}
declare abstract class R2Object {
readonly key: string;
readonly version: string;
readonly size: number;
readonly etag: string;
readonly httpEtag: string;
readonly checksums: R2Checksums;
readonly uploaded: Date;
readonly httpMetadata?: R2HTTPMetadata;
readonly customMetadata?: Record<string, string>;
readonly range?: R2Range;
readonly storageClass: string;
readonly ssecKeyMd5?: string;
writeHttpMetadata(headers: Headers): void;
2025-09-20 09:21:41 +02:00
}
interface R2ObjectBody extends R2Object {
get body(): ReadableStream;
get bodyUsed(): boolean;
arrayBuffer(): Promise<ArrayBuffer>;
bytes(): Promise<Uint8Array>;
text(): Promise<string>;
json<T>(): Promise<T>;
blob(): Promise<Blob>;
2025-09-20 09:21:41 +02:00
}
type R2Range =
| {
offset: number;
length?: number;
}
| {
offset?: number;
length: number;
}
| {
suffix: number;
};
2025-09-20 09:21:41 +02:00
interface R2Conditional {
etagMatches?: string;
etagDoesNotMatch?: string;
uploadedBefore?: Date;
uploadedAfter?: Date;
secondsGranularity?: boolean;
2025-09-20 09:21:41 +02:00
}
interface R2GetOptions {
onlyIf?: R2Conditional | Headers;
range?: R2Range | Headers;
ssecKey?: ArrayBuffer | string;
2025-09-20 09:21:41 +02:00
}
interface R2PutOptions {
onlyIf?: R2Conditional | Headers;
httpMetadata?: R2HTTPMetadata | Headers;
customMetadata?: Record<string, string>;
md5?: (ArrayBuffer | ArrayBufferView) | string;
sha1?: (ArrayBuffer | ArrayBufferView) | string;
sha256?: (ArrayBuffer | ArrayBufferView) | string;
sha384?: (ArrayBuffer | ArrayBufferView) | string;
sha512?: (ArrayBuffer | ArrayBufferView) | string;
storageClass?: string;
ssecKey?: ArrayBuffer | string;
2025-09-20 09:21:41 +02:00
}
interface R2MultipartOptions {
httpMetadata?: R2HTTPMetadata | Headers;
customMetadata?: Record<string, string>;
storageClass?: string;
ssecKey?: ArrayBuffer | string;
2025-09-20 09:21:41 +02:00
}
interface R2Checksums {
readonly md5?: ArrayBuffer;
readonly sha1?: ArrayBuffer;
readonly sha256?: ArrayBuffer;
readonly sha384?: ArrayBuffer;
readonly sha512?: ArrayBuffer;
toJSON(): R2StringChecksums;
2025-09-20 09:21:41 +02:00
}
interface R2StringChecksums {
md5?: string;
sha1?: string;
sha256?: string;
sha384?: string;
sha512?: string;
2025-09-20 09:21:41 +02:00
}
interface R2HTTPMetadata {
contentType?: string;
contentLanguage?: string;
contentDisposition?: string;
contentEncoding?: string;
cacheControl?: string;
cacheExpiry?: Date;
2025-09-20 09:21:41 +02:00
}
type R2Objects = {
objects: R2Object[];
delimitedPrefixes: string[];
} & (
| {
truncated: true;
cursor: string;
}
| {
truncated: false;
}
);
2025-09-20 09:21:41 +02:00
interface R2UploadPartOptions {
ssecKey?: ArrayBuffer | string;
2025-09-20 09:21:41 +02:00
}
declare abstract class ScheduledEvent extends ExtendableEvent {
readonly scheduledTime: number;
readonly cron: string;
noRetry(): void;
2025-09-20 09:21:41 +02:00
}
interface ScheduledController {
readonly scheduledTime: number;
readonly cron: string;
noRetry(): void;
2025-09-20 09:21:41 +02:00
}
interface QueuingStrategy<T = any> {
highWaterMark?: number | bigint;
size?: (chunk: T) => number | bigint;
2025-09-20 09:21:41 +02:00
}
interface UnderlyingSink<W = any> {
type?: string;
start?: (controller: WritableStreamDefaultController) => void | Promise<void>;
write?: (chunk: W, controller: WritableStreamDefaultController) => void | Promise<void>;
abort?: (reason: any) => void | Promise<void>;
close?: () => void | Promise<void>;
2025-09-20 09:21:41 +02:00
}
interface UnderlyingByteSource {
type: "bytes";
autoAllocateChunkSize?: number;
start?: (controller: ReadableByteStreamController) => void | Promise<void>;
pull?: (controller: ReadableByteStreamController) => void | Promise<void>;
cancel?: (reason: any) => void | Promise<void>;
2025-09-20 09:21:41 +02:00
}
interface UnderlyingSource<R = any> {
type?: "" | undefined;
start?: (controller: ReadableStreamDefaultController<R>) => void | Promise<void>;
pull?: (controller: ReadableStreamDefaultController<R>) => void | Promise<void>;
cancel?: (reason: any) => void | Promise<void>;
expectedLength?: number | bigint;
2025-09-20 09:21:41 +02:00
}
interface Transformer<I = any, O = any> {
readableType?: string;
writableType?: string;
start?: (controller: TransformStreamDefaultController<O>) => void | Promise<void>;
transform?: (chunk: I, controller: TransformStreamDefaultController<O>) => void | Promise<void>;
flush?: (controller: TransformStreamDefaultController<O>) => void | Promise<void>;
cancel?: (reason: any) => void | Promise<void>;
expectedLength?: number;
2025-09-20 09:21:41 +02:00
}
interface StreamPipeOptions {
/**
* 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.
*
* Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader.
*
* Errors and closures of the source and destination streams propagate as follows:
*
* 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.
*
* 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.
*
* 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.
*
* 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.
*
* 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.
*/
preventClose?: boolean;
preventAbort?: boolean;
preventCancel?: boolean;
signal?: AbortSignal;
2025-09-20 09:21:41 +02:00
}
type ReadableStreamReadResult<R = any> =
| {
done: false;
value: R;
}
| {
done: true;
value?: undefined;
};
2025-09-20 09:21:41 +02:00
/**
* 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.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream)
*/
interface ReadableStream<R = any> {
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/locked) */
get locked(): boolean;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/cancel) */
cancel(reason?: any): Promise<void>;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/getReader) */
getReader(): ReadableStreamDefaultReader<R>;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/getReader) */
getReader(options: ReadableStreamGetReaderOptions): ReadableStreamBYOBReader;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/pipeThrough) */
pipeThrough<T>(transform: ReadableWritablePair<T, R>, options?: StreamPipeOptions): ReadableStream<T>;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/pipeTo) */
pipeTo(destination: WritableStream<R>, options?: StreamPipeOptions): Promise<void>;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/tee) */
tee(): [ReadableStream<R>, ReadableStream<R>];
values(options?: ReadableStreamValuesOptions): AsyncIterableIterator<R>;
[Symbol.asyncIterator](options?: ReadableStreamValuesOptions): AsyncIterableIterator<R>;
2025-09-20 09:21:41 +02:00
}
/**
* 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.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream)
*/
declare const ReadableStream: {
prototype: ReadableStream;
new (underlyingSource: UnderlyingByteSource, strategy?: QueuingStrategy<Uint8Array>): ReadableStream<Uint8Array>;
new <R = any>(underlyingSource?: UnderlyingSource<R>, strategy?: QueuingStrategy<R>): ReadableStream<R>;
2025-09-20 09:21:41 +02:00
};
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultReader) */
declare class ReadableStreamDefaultReader<R = any> {
constructor(stream: ReadableStream);
get closed(): Promise<void>;
cancel(reason?: any): Promise<void>;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultReader/read) */
read(): Promise<ReadableStreamReadResult<R>>;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultReader/releaseLock) */
releaseLock(): void;
2025-09-20 09:21:41 +02:00
}
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader) */
declare class ReadableStreamBYOBReader {
constructor(stream: ReadableStream);
get closed(): Promise<void>;
cancel(reason?: any): Promise<void>;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader/read) */
read<T extends ArrayBufferView>(view: T): Promise<ReadableStreamReadResult<T>>;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader/releaseLock) */
releaseLock(): void;
readAtLeast<T extends ArrayBufferView>(minElements: number, view: T): Promise<ReadableStreamReadResult<T>>;
2025-09-20 09:21:41 +02:00
}
interface ReadableStreamBYOBReaderReadableStreamBYOBReaderReadOptions {
min?: number;
2025-09-20 09:21:41 +02:00
}
interface ReadableStreamGetReaderOptions {
/**
* Creates a ReadableStreamBYOBReader and locks the stream to the new reader.
*
* 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.
*/
mode: "byob";
2025-09-20 09:21:41 +02:00
}
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest) */
declare abstract class ReadableStreamBYOBRequest {
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest/view) */
get view(): Uint8Array | null;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest/respond) */
respond(bytesWritten: number): void;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest/respondWithNewView) */
respondWithNewView(view: ArrayBuffer | ArrayBufferView): void;
get atLeast(): number | null;
2025-09-20 09:21:41 +02:00
}
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController) */
declare abstract class ReadableStreamDefaultController<R = any> {
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController/desiredSize) */
get desiredSize(): number | null;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController/close) */
close(): void;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController/enqueue) */
enqueue(chunk?: R): void;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController/error) */
error(reason: any): void;
2025-09-20 09:21:41 +02:00
}
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController) */
declare abstract class ReadableByteStreamController {
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/byobRequest) */
get byobRequest(): ReadableStreamBYOBRequest | null;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/desiredSize) */
get desiredSize(): number | null;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/close) */
close(): void;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/enqueue) */
enqueue(chunk: ArrayBuffer | ArrayBufferView): void;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/error) */
error(reason: any): void;
2025-09-20 09:21:41 +02:00
}
/**
* 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.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultController)
*/
declare abstract class WritableStreamDefaultController {
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultController/signal) */
get signal(): AbortSignal;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultController/error) */
error(reason?: any): void;
2025-09-20 09:21:41 +02:00
}
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController) */
declare abstract class TransformStreamDefaultController<O = any> {
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController/desiredSize) */
get desiredSize(): number | null;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController/enqueue) */
enqueue(chunk?: O): void;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController/error) */
error(reason: any): void;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController/terminate) */
terminate(): void;
2025-09-20 09:21:41 +02:00
}
interface ReadableWritablePair<R = any, W = any> {
/**
* 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.
*
* Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader.
*/
writable: WritableStream<W>;
readable: ReadableStream<R>;
2025-09-20 09:21:41 +02:00
}
/**
* 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.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream)
*/
declare class WritableStream<W = any> {
constructor(underlyingSink?: UnderlyingSink, queuingStrategy?: QueuingStrategy);
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream/locked) */
get locked(): boolean;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream/abort) */
abort(reason?: any): Promise<void>;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream/close) */
close(): Promise<void>;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream/getWriter) */
getWriter(): WritableStreamDefaultWriter<W>;
2025-09-20 09:21:41 +02:00
}
/**
* 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.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter)
*/
declare class WritableStreamDefaultWriter<W = any> {
constructor(stream: WritableStream);
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/closed) */
get closed(): Promise<void>;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/ready) */
get ready(): Promise<void>;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/desiredSize) */
get desiredSize(): number | null;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/abort) */
abort(reason?: any): Promise<void>;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/close) */
close(): Promise<void>;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/write) */
write(chunk?: W): Promise<void>;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/releaseLock) */
releaseLock(): void;
2025-09-20 09:21:41 +02:00
}
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStream) */
declare class TransformStream<I = any, O = any> {
constructor(transformer?: Transformer<I, O>, writableStrategy?: QueuingStrategy<I>, readableStrategy?: QueuingStrategy<O>);
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStream/readable) */
get readable(): ReadableStream<O>;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStream/writable) */
get writable(): WritableStream<I>;
2025-09-20 09:21:41 +02:00
}
declare class FixedLengthStream extends IdentityTransformStream {
constructor(expectedLength: number | bigint, queuingStrategy?: IdentityTransformStreamQueuingStrategy);
2025-09-20 09:21:41 +02:00
}
declare class IdentityTransformStream extends TransformStream<ArrayBuffer | ArrayBufferView, Uint8Array> {
constructor(queuingStrategy?: IdentityTransformStreamQueuingStrategy);
2025-09-20 09:21:41 +02:00
}
interface IdentityTransformStreamQueuingStrategy {
highWaterMark?: number | bigint;
2025-09-20 09:21:41 +02:00
}
interface ReadableStreamValuesOptions {
preventCancel?: boolean;
2025-09-20 09:21:41 +02:00
}
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CompressionStream) */
declare class CompressionStream extends TransformStream<ArrayBuffer | ArrayBufferView, Uint8Array> {
constructor(format: "gzip" | "deflate" | "deflate-raw");
2025-09-20 09:21:41 +02:00
}
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/DecompressionStream) */
declare class DecompressionStream extends TransformStream<ArrayBuffer | ArrayBufferView, Uint8Array> {
constructor(format: "gzip" | "deflate" | "deflate-raw");
2025-09-20 09:21:41 +02:00
}
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextEncoderStream) */
declare class TextEncoderStream extends TransformStream<string, Uint8Array> {
constructor();
get encoding(): string;
2025-09-20 09:21:41 +02:00
}
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextDecoderStream) */
declare class TextDecoderStream extends TransformStream<ArrayBuffer | ArrayBufferView, string> {
constructor(label?: string, options?: TextDecoderStreamTextDecoderStreamInit);
get encoding(): string;
get fatal(): boolean;
get ignoreBOM(): boolean;
2025-09-20 09:21:41 +02:00
}
interface TextDecoderStreamTextDecoderStreamInit {
fatal?: boolean;
ignoreBOM?: boolean;
2025-09-20 09:21:41 +02:00
}
/**
* This Streams API interface provides a built-in byte length queuing strategy that can be used when constructing streams.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ByteLengthQueuingStrategy)
*/
declare class ByteLengthQueuingStrategy implements QueuingStrategy<ArrayBufferView> {
constructor(init: QueuingStrategyInit);
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ByteLengthQueuingStrategy/highWaterMark) */
get highWaterMark(): number;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ByteLengthQueuingStrategy/size) */
get size(): (chunk?: any) => number;
2025-09-20 09:21:41 +02:00
}
/**
* This Streams API interface provides a built-in byte length queuing strategy that can be used when constructing streams.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CountQueuingStrategy)
*/
declare class CountQueuingStrategy implements QueuingStrategy {
constructor(init: QueuingStrategyInit);
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CountQueuingStrategy/highWaterMark) */
get highWaterMark(): number;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CountQueuingStrategy/size) */
get size(): (chunk?: any) => number;
2025-09-20 09:21:41 +02:00
}
interface QueuingStrategyInit {
/**
* Creates a new ByteLengthQueuingStrategy with the provided high water mark.
*
* 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.
*/
highWaterMark: number;
2025-09-20 09:21:41 +02:00
}
interface ScriptVersion {
id?: string;
tag?: string;
message?: string;
2025-09-20 09:21:41 +02:00
}
declare abstract class TailEvent extends ExtendableEvent {
readonly events: TraceItem[];
readonly traces: TraceItem[];
2025-09-20 09:21:41 +02:00
}
interface TraceItem {
readonly event:
| (
| TraceItemFetchEventInfo
| TraceItemJsRpcEventInfo
| TraceItemScheduledEventInfo
| TraceItemAlarmEventInfo
| TraceItemQueueEventInfo
| TraceItemEmailEventInfo
| TraceItemTailEventInfo
| TraceItemCustomEventInfo
| TraceItemHibernatableWebSocketEventInfo
)
| null;
readonly eventTimestamp: number | null;
readonly logs: TraceLog[];
readonly exceptions: TraceException[];
readonly diagnosticsChannelEvents: TraceDiagnosticChannelEvent[];
readonly scriptName: string | null;
readonly entrypoint?: string;
readonly scriptVersion?: ScriptVersion;
readonly dispatchNamespace?: string;
readonly scriptTags?: string[];
readonly durableObjectId?: string;
readonly outcome: string;
readonly executionModel: string;
readonly truncated: boolean;
readonly cpuTime: number;
readonly wallTime: number;
2025-09-20 09:21:41 +02:00
}
interface TraceItemAlarmEventInfo {
readonly scheduledTime: Date;
2025-09-20 09:21:41 +02:00
}
interface TraceItemCustomEventInfo {}
2025-09-20 09:21:41 +02:00
interface TraceItemScheduledEventInfo {
readonly scheduledTime: number;
readonly cron: string;
2025-09-20 09:21:41 +02:00
}
interface TraceItemQueueEventInfo {
readonly queue: string;
readonly batchSize: number;
2025-09-20 09:21:41 +02:00
}
interface TraceItemEmailEventInfo {
readonly mailFrom: string;
readonly rcptTo: string;
readonly rawSize: number;
2025-09-20 09:21:41 +02:00
}
interface TraceItemTailEventInfo {
readonly consumedEvents: TraceItemTailEventInfoTailItem[];
2025-09-20 09:21:41 +02:00
}
interface TraceItemTailEventInfoTailItem {
readonly scriptName: string | null;
2025-09-20 09:21:41 +02:00
}
interface TraceItemFetchEventInfo {
readonly response?: TraceItemFetchEventInfoResponse;
readonly request: TraceItemFetchEventInfoRequest;
2025-09-20 09:21:41 +02:00
}
interface TraceItemFetchEventInfoRequest {
readonly cf?: any;
readonly headers: Record<string, string>;
readonly method: string;
readonly url: string;
getUnredacted(): TraceItemFetchEventInfoRequest;
2025-09-20 09:21:41 +02:00
}
interface TraceItemFetchEventInfoResponse {
readonly status: number;
2025-09-20 09:21:41 +02:00
}
interface TraceItemJsRpcEventInfo {
readonly rpcMethod: string;
2025-09-20 09:21:41 +02:00
}
interface TraceItemHibernatableWebSocketEventInfo {
readonly getWebSocketEvent:
| TraceItemHibernatableWebSocketEventInfoMessage
| TraceItemHibernatableWebSocketEventInfoClose
| TraceItemHibernatableWebSocketEventInfoError;
2025-09-20 09:21:41 +02:00
}
interface TraceItemHibernatableWebSocketEventInfoMessage {
readonly webSocketEventType: string;
2025-09-20 09:21:41 +02:00
}
interface TraceItemHibernatableWebSocketEventInfoClose {
readonly webSocketEventType: string;
readonly code: number;
readonly wasClean: boolean;
2025-09-20 09:21:41 +02:00
}
interface TraceItemHibernatableWebSocketEventInfoError {
readonly webSocketEventType: string;
2025-09-20 09:21:41 +02:00
}
interface TraceLog {
readonly timestamp: number;
readonly level: string;
readonly message: any;
2025-09-20 09:21:41 +02:00
}
interface TraceException {
readonly timestamp: number;
readonly message: string;
readonly name: string;
readonly stack?: string;
2025-09-20 09:21:41 +02:00
}
interface TraceDiagnosticChannelEvent {
readonly timestamp: number;
readonly channel: string;
readonly message: any;
2025-09-20 09:21:41 +02:00
}
interface TraceMetrics {
readonly cpuTime: number;
readonly wallTime: number;
2025-09-20 09:21:41 +02:00
}
interface UnsafeTraceMetrics {
fromTrace(item: TraceItem): TraceMetrics;
2025-09-20 09:21:41 +02:00
}
/**
* The URL interface represents an object providing static methods used for creating object URLs.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL)
*/
declare class URL {
constructor(url: string | URL, base?: string | URL);
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/origin) */
get origin(): string;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/href) */
get href(): string;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/href) */
set href(value: string);
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/protocol) */
get protocol(): string;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/protocol) */
set protocol(value: string);
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/username) */
get username(): string;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/username) */
set username(value: string);
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/password) */
get password(): string;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/password) */
set password(value: string);
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/host) */
get host(): string;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/host) */
set host(value: string);
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hostname) */
get hostname(): string;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hostname) */
set hostname(value: string);
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/port) */
get port(): string;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/port) */
set port(value: string);
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/pathname) */
get pathname(): string;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/pathname) */
set pathname(value: string);
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/search) */
get search(): string;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/search) */
set search(value: string);
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hash) */
get hash(): string;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hash) */
set hash(value: string);
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/searchParams) */
get searchParams(): URLSearchParams;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/toJSON) */
toJSON(): string;
/*function toString() { [native code] }*/
toString(): string;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/canParse_static) */
static canParse(url: string, base?: string): boolean;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/parse_static) */
static parse(url: string, base?: string): URL | null;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/createObjectURL_static) */
static createObjectURL(object: File | Blob): string;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/revokeObjectURL_static) */
static revokeObjectURL(object_url: string): void;
2025-09-20 09:21:41 +02:00
}
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams) */
declare class URLSearchParams {
constructor(init?: Iterable<Iterable<string>> | Record<string, string> | string);
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/size) */
get size(): number;
/**
* Appends a specified key/value pair as a new search parameter.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/append)
*/
append(name: string, value: string): void;
/**
* Deletes the given search parameter, and its associated value, from the list of all search parameters.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/delete)
*/
delete(name: string, value?: string): void;
/**
* Returns the first value associated to the given search parameter.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/get)
*/
get(name: string): string | null;
/**
* Returns all the values association with a given search parameter.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/getAll)
*/
getAll(name: string): string[];
/**
* Returns a Boolean indicating if such a search parameter exists.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/has)
*/
has(name: string, value?: string): boolean;
/**
* Sets the value associated to a given search parameter to the given value. If there were several values, delete the others.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/set)
*/
set(name: string, value: string): void;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/sort) */
sort(): void;
/* Returns an array of key, value pairs for every entry in the search params. */
entries(): IterableIterator<[key: string, value: string]>;
/* Returns a list of keys in the search params. */
keys(): IterableIterator<string>;
/* Returns a list of values in the search params. */
values(): IterableIterator<string>;
forEach<This = unknown>(callback: (this: This, value: string, key: string, parent: URLSearchParams) => void, thisArg?: This): void;
/*function toString() { [native code] } Returns a string containing a query string suitable for use in a URL. Does not include the question mark. */
toString(): string;
[Symbol.iterator](): IterableIterator<[key: string, value: string]>;
2025-09-20 09:21:41 +02:00
}
declare class URLPattern {
constructor(input?: string | URLPatternInit, baseURL?: string | URLPatternOptions, patternOptions?: URLPatternOptions);
get protocol(): string;
get username(): string;
get password(): string;
get hostname(): string;
get port(): string;
get pathname(): string;
get search(): string;
get hash(): string;
get hasRegExpGroups(): boolean;
test(input?: string | URLPatternInit, baseURL?: string): boolean;
exec(input?: string | URLPatternInit, baseURL?: string): URLPatternResult | null;
2025-09-20 09:21:41 +02:00
}
interface URLPatternInit {
protocol?: string;
username?: string;
password?: string;
hostname?: string;
port?: string;
pathname?: string;
search?: string;
hash?: string;
baseURL?: string;
2025-09-20 09:21:41 +02:00
}
interface URLPatternComponentResult {
input: string;
groups: Record<string, string>;
2025-09-20 09:21:41 +02:00
}
interface URLPatternResult {
inputs: (string | URLPatternInit)[];
protocol: URLPatternComponentResult;
username: URLPatternComponentResult;
password: URLPatternComponentResult;
hostname: URLPatternComponentResult;
port: URLPatternComponentResult;
pathname: URLPatternComponentResult;
search: URLPatternComponentResult;
hash: URLPatternComponentResult;
2025-09-20 09:21:41 +02:00
}
interface URLPatternOptions {
ignoreCase?: boolean;
2025-09-20 09:21:41 +02:00
}
/**
* 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.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent)
*/
declare class CloseEvent extends Event {
constructor(type: string, initializer?: CloseEventInit);
/**
* Returns the WebSocket connection close code provided by the server.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent/code)
*/
readonly code: number;
/**
* Returns the WebSocket connection close reason provided by the server.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent/reason)
*/
readonly reason: string;
/**
* Returns true if the connection closed cleanly; false otherwise.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent/wasClean)
*/
readonly wasClean: boolean;
2025-09-20 09:21:41 +02:00
}
interface CloseEventInit {
code?: number;
reason?: string;
wasClean?: boolean;
2025-09-20 09:21:41 +02:00
}
type WebSocketEventMap = {
close: CloseEvent;
message: MessageEvent;
open: Event;
error: ErrorEvent;
2025-09-20 09:21:41 +02:00
};
/**
* Provides the API for creating and managing a WebSocket connection to a server, as well as for sending and receiving data on the connection.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket)
*/
declare var WebSocket: {
prototype: WebSocket;
new (url: string, protocols?: string[] | string): WebSocket;
readonly READY_STATE_CONNECTING: number;
readonly CONNECTING: number;
readonly READY_STATE_OPEN: number;
readonly OPEN: number;
readonly READY_STATE_CLOSING: number;
readonly CLOSING: number;
readonly READY_STATE_CLOSED: number;
readonly CLOSED: number;
2025-09-20 09:21:41 +02:00
};
/**
* Provides the API for creating and managing a WebSocket connection to a server, as well as for sending and receiving data on the connection.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket)
*/
interface WebSocket extends EventTarget<WebSocketEventMap> {
accept(): void;
/**
* Transmits data using the WebSocket connection. data can be a string, a Blob, an ArrayBuffer, or an ArrayBufferView.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/send)
*/
send(message: (ArrayBuffer | ArrayBufferView) | string): void;
/**
* Closes the WebSocket connection, optionally using code as the the WebSocket connection close code and reason as the the WebSocket connection close reason.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/close)
*/
close(code?: number, reason?: string): void;
serializeAttachment(attachment: any): void;
deserializeAttachment(): any | null;
/**
* Returns the state of the WebSocket object's connection. It can have the values described below.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/readyState)
*/
readyState: number;
/**
* Returns the URL that was used to establish the WebSocket connection.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/url)
*/
url: string | null;
/**
* 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.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/protocol)
*/
protocol: string | null;
/**
* Returns the extensions selected by the server, if any.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/extensions)
*/
extensions: string | null;
2025-09-20 09:21:41 +02:00
}
declare const WebSocketPair: {
new (): {
0: WebSocket;
1: WebSocket;
};
2025-09-20 09:21:41 +02:00
};
interface SqlStorage {
exec<T extends Record<string, SqlStorageValue>>(query: string, ...bindings: any[]): SqlStorageCursor<T>;
get databaseSize(): number;
Cursor: typeof SqlStorageCursor;
Statement: typeof SqlStorageStatement;
2025-09-20 09:21:41 +02:00
}
declare abstract class SqlStorageStatement {}
2025-09-20 09:21:41 +02:00
type SqlStorageValue = ArrayBuffer | string | number | null;
declare abstract class SqlStorageCursor<T extends Record<string, SqlStorageValue>> {
next():
| {
done?: false;
value: T;
}
| {
done: true;
value?: never;
};
toArray(): T[];
one(): T;
raw<U extends SqlStorageValue[]>(): IterableIterator<U>;
columnNames: string[];
get rowsRead(): number;
get rowsWritten(): number;
[Symbol.iterator](): IterableIterator<T>;
2025-09-20 09:21:41 +02:00
}
interface Socket {
get readable(): ReadableStream;
get writable(): WritableStream;
get closed(): Promise<void>;
get opened(): Promise<SocketInfo>;
get upgraded(): boolean;
get secureTransport(): "on" | "off" | "starttls";
close(): Promise<void>;
startTls(options?: TlsOptions): Socket;
2025-09-20 09:21:41 +02:00
}
interface SocketOptions {
secureTransport?: string;
allowHalfOpen: boolean;
highWaterMark?: number | bigint;
2025-09-20 09:21:41 +02:00
}
interface SocketAddress {
hostname: string;
port: number;
2025-09-20 09:21:41 +02:00
}
interface TlsOptions {
expectedServerHostname?: string;
2025-09-20 09:21:41 +02:00
}
interface SocketInfo {
remoteAddress?: string;
localAddress?: string;
2025-09-20 09:21:41 +02:00
}
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource) */
declare class EventSource extends EventTarget {
constructor(url: string, init?: EventSourceEventSourceInit);
/**
* Aborts any instances of the fetch algorithm started for this EventSource object, and sets the readyState attribute to CLOSED.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/close)
*/
close(): void;
/**
* Returns the URL providing the event stream.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/url)
*/
get url(): string;
/**
* Returns true if the credentials mode for connection requests to the URL providing the event stream is set to "include", and false otherwise.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/withCredentials)
*/
get withCredentials(): boolean;
/**
* Returns the state of this EventSource object's connection. It can have the values described below.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/readyState)
*/
get readyState(): number;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */
get onopen(): any | null;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */
set onopen(value: any | null);
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */
get onmessage(): any | null;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */
set onmessage(value: any | null);
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */
get onerror(): any | null;
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */
set onerror(value: any | null);
static readonly CONNECTING: number;
static readonly OPEN: number;
static readonly CLOSED: number;
static from(stream: ReadableStream): EventSource;
2025-09-20 09:21:41 +02:00
}
interface EventSourceEventSourceInit {
withCredentials?: boolean;
fetcher?: Fetcher;
2025-09-20 09:21:41 +02:00
}
interface Container {
get running(): boolean;
start(options?: ContainerStartupOptions): void;
monitor(): Promise<void>;
destroy(error?: any): Promise<void>;
signal(signo: number): void;
getTcpPort(port: number): Fetcher;
2025-09-20 09:21:41 +02:00
}
interface ContainerStartupOptions {
entrypoint?: string[];
enableInternet: boolean;
env?: Record<string, string>;
2025-09-20 09:21:41 +02:00
}
/**
* This Channel Messaging API interface represents one of the two ports of a MessageChannel, allowing messages to be sent from one port and listening out for them arriving at the other.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort)
*/
declare abstract class MessagePort extends EventTarget {
/**
* Posts a message through the channel. Objects listed in transfer are transferred, not just cloned, meaning that they are no longer usable on the sending side.
*
* Throws a "DataCloneError" DOMException if transfer contains duplicate objects or port, or if message could not be cloned.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/postMessage)
*/
postMessage(data?: any, options?: any[] | MessagePortPostMessageOptions): void;
/**
* Disconnects the port, so that it is no longer active.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/close)
*/
close(): void;
/**
* Begins dispatching messages received on the port.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/start)
*/
start(): void;
get onmessage(): any | null;
set onmessage(value: any | null);
2025-09-20 09:21:41 +02:00
}
/**
* This Channel Messaging API interface allows us to create a new message channel and send data through it via its two MessagePort properties.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel)
*/
declare class MessageChannel {
constructor();
/**
* Returns the first MessagePort object.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel/port1)
*/
readonly port1: MessagePort;
/**
* Returns the second MessagePort object.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel/port2)
*/
readonly port2: MessagePort;
2025-09-20 09:21:41 +02:00
}
interface MessagePortPostMessageOptions {
transfer?: any[];
2025-09-20 09:21:41 +02:00
}
type LoopbackForExport<T extends (new (...args: any[]) => Rpc.EntrypointBranded) | ExportedHandler<any, any, any> | undefined = undefined> =
T extends new (...args: any[]) => Rpc.WorkerEntrypointBranded
? LoopbackServiceStub<InstanceType<T>>
: T extends new (...args: any[]) => Rpc.DurableObjectBranded
? LoopbackDurableObjectClass<InstanceType<T>>
: T extends ExportedHandler<any, any, any>
? LoopbackServiceStub<undefined>
: undefined;
type LoopbackServiceStub<T extends Rpc.WorkerEntrypointBranded | undefined = undefined> = Fetcher<T> &
(T extends CloudflareWorkersModule.WorkerEntrypoint<any, infer Props>
? (opts: { props?: Props }) => Fetcher<T>
: (opts: { props?: any }) => Fetcher<T>);
type LoopbackDurableObjectClass<T extends Rpc.DurableObjectBranded | undefined = undefined> = DurableObjectClass<T> &
(T extends CloudflareWorkersModule.DurableObject<any, infer Props>
? (opts: { props?: Props }) => DurableObjectClass<T>
: (opts: { props?: any }) => DurableObjectClass<T>);
2025-09-20 09:21:41 +02:00
interface SyncKvStorage {
get<T = unknown>(key: string): T | undefined;
list<T = unknown>(options?: SyncKvListOptions): Iterable<[string, T]>;
put<T>(key: string, value: T): void;
delete(key: string): boolean;
2025-09-20 09:21:41 +02:00
}
interface SyncKvListOptions {
start?: string;
startAfter?: string;
end?: string;
prefix?: string;
reverse?: boolean;
limit?: number;
2025-09-20 09:21:41 +02:00
}
interface WorkerStub {
getEntrypoint<T extends Rpc.WorkerEntrypointBranded | undefined>(name?: string, options?: WorkerStubEntrypointOptions): Fetcher<T>;
2025-09-20 09:21:41 +02:00
}
interface WorkerStubEntrypointOptions {
props?: any;
2025-09-20 09:21:41 +02:00
}
interface WorkerLoader {
get(name: string, getCode: () => WorkerLoaderWorkerCode | Promise<WorkerLoaderWorkerCode>): WorkerStub;
2025-09-20 09:21:41 +02:00
}
interface WorkerLoaderModule {
js?: string;
cjs?: string;
text?: string;
data?: ArrayBuffer;
json?: any;
py?: string;
2025-09-20 09:21:41 +02:00
}
interface WorkerLoaderWorkerCode {
compatibilityDate: string;
compatibilityFlags?: string[];
allowExperimental?: boolean;
mainModule: string;
modules: Record<string, WorkerLoaderModule | string>;
env?: any;
globalOutbound?: Fetcher | null;
tails?: Fetcher[];
streamingTails?: Fetcher[];
2025-09-20 09:21:41 +02:00
}
type AiImageClassificationInput = {
image: number[];
2025-09-20 09:21:41 +02:00
};
type AiImageClassificationOutput = {
score?: number;
label?: string;
2025-09-20 09:21:41 +02:00
}[];
declare abstract class BaseAiImageClassification {
inputs: AiImageClassificationInput;
postProcessedOutputs: AiImageClassificationOutput;
2025-09-20 09:21:41 +02:00
}
type AiImageToTextInput = {
image: number[];
prompt?: string;
max_tokens?: number;
temperature?: number;
top_p?: number;
top_k?: number;
seed?: number;
repetition_penalty?: number;
frequency_penalty?: number;
presence_penalty?: number;
raw?: boolean;
messages?: RoleScopedChatInput[];
2025-09-20 09:21:41 +02:00
};
type AiImageToTextOutput = {
description: string;
2025-09-20 09:21:41 +02:00
};
declare abstract class BaseAiImageToText {
inputs: AiImageToTextInput;
postProcessedOutputs: AiImageToTextOutput;
2025-09-20 09:21:41 +02:00
}
type AiImageTextToTextInput = {
image: string;
prompt?: string;
max_tokens?: number;
temperature?: number;
ignore_eos?: boolean;
top_p?: number;
top_k?: number;
seed?: number;
repetition_penalty?: number;
frequency_penalty?: number;
presence_penalty?: number;
raw?: boolean;
messages?: RoleScopedChatInput[];
2025-09-20 09:21:41 +02:00
};
type AiImageTextToTextOutput = {
description: string;
2025-09-20 09:21:41 +02:00
};
declare abstract class BaseAiImageTextToText {
inputs: AiImageTextToTextInput;
postProcessedOutputs: AiImageTextToTextOutput;
2025-09-20 09:21:41 +02:00
}
type AiObjectDetectionInput = {
image: number[];
2025-09-20 09:21:41 +02:00
};
type AiObjectDetectionOutput = {
score?: number;
label?: string;
2025-09-20 09:21:41 +02:00
}[];
declare abstract class BaseAiObjectDetection {
inputs: AiObjectDetectionInput;
postProcessedOutputs: AiObjectDetectionOutput;
2025-09-20 09:21:41 +02:00
}
type AiSentenceSimilarityInput = {
source: string;
sentences: string[];
2025-09-20 09:21:41 +02:00
};
type AiSentenceSimilarityOutput = number[];
declare abstract class BaseAiSentenceSimilarity {
inputs: AiSentenceSimilarityInput;
postProcessedOutputs: AiSentenceSimilarityOutput;
2025-09-20 09:21:41 +02:00
}
type AiAutomaticSpeechRecognitionInput = {
audio: number[];
2025-09-20 09:21:41 +02:00
};
type AiAutomaticSpeechRecognitionOutput = {
text?: string;
words?: {
word: string;
start: number;
end: number;
}[];
vtt?: string;
2025-09-20 09:21:41 +02:00
};
declare abstract class BaseAiAutomaticSpeechRecognition {
inputs: AiAutomaticSpeechRecognitionInput;
postProcessedOutputs: AiAutomaticSpeechRecognitionOutput;
2025-09-20 09:21:41 +02:00
}
type AiSummarizationInput = {
input_text: string;
max_length?: number;
2025-09-20 09:21:41 +02:00
};
type AiSummarizationOutput = {
summary: string;
2025-09-20 09:21:41 +02:00
};
declare abstract class BaseAiSummarization {
inputs: AiSummarizationInput;
postProcessedOutputs: AiSummarizationOutput;
2025-09-20 09:21:41 +02:00
}
type AiTextClassificationInput = {
text: string;
2025-09-20 09:21:41 +02:00
};
type AiTextClassificationOutput = {
score?: number;
label?: string;
2025-09-20 09:21:41 +02:00
}[];
declare abstract class BaseAiTextClassification {
inputs: AiTextClassificationInput;
postProcessedOutputs: AiTextClassificationOutput;
2025-09-20 09:21:41 +02:00
}
type AiTextEmbeddingsInput = {
text: string | string[];
2025-09-20 09:21:41 +02:00
};
type AiTextEmbeddingsOutput = {
shape: number[];
data: number[][];
2025-09-20 09:21:41 +02:00
};
declare abstract class BaseAiTextEmbeddings {
inputs: AiTextEmbeddingsInput;
postProcessedOutputs: AiTextEmbeddingsOutput;
2025-09-20 09:21:41 +02:00
}
type RoleScopedChatInput = {
role: "user" | "assistant" | "system" | "tool" | (string & NonNullable<unknown>);
content: string;
name?: string;
2025-09-20 09:21:41 +02:00
};
type AiTextGenerationToolLegacyInput = {
name: string;
description: string;
parameters?: {
type: "object" | (string & NonNullable<unknown>);
properties: {
[key: string]: {
type: string;
description?: string;
};
};
required: string[];
};
2025-09-20 09:21:41 +02:00
};
type AiTextGenerationToolInput = {
type: "function" | (string & NonNullable<unknown>);
function: {
name: string;
description: string;
parameters?: {
type: "object" | (string & NonNullable<unknown>);
properties: {
[key: string]: {
type: string;
description?: string;
};
};
required: string[];
};
};
2025-09-20 09:21:41 +02:00
};
type AiTextGenerationFunctionsInput = {
name: string;
code: string;
2025-09-20 09:21:41 +02:00
};
type AiTextGenerationResponseFormat = {
type: string;
json_schema?: any;
2025-09-20 09:21:41 +02:00
};
type AiTextGenerationInput = {
prompt?: string;
raw?: boolean;
stream?: boolean;
max_tokens?: number;
temperature?: number;
top_p?: number;
top_k?: number;
seed?: number;
repetition_penalty?: number;
frequency_penalty?: number;
presence_penalty?: number;
messages?: RoleScopedChatInput[];
response_format?: AiTextGenerationResponseFormat;
tools?: AiTextGenerationToolInput[] | AiTextGenerationToolLegacyInput[] | (object & NonNullable<unknown>);
functions?: AiTextGenerationFunctionsInput[];
2025-09-20 09:21:41 +02:00
};
type AiTextGenerationOutput = {
response?: string;
tool_calls?: {
name: string;
arguments: unknown;
}[];
2025-09-20 09:21:41 +02:00
};
declare abstract class BaseAiTextGeneration {
inputs: AiTextGenerationInput;
postProcessedOutputs: AiTextGenerationOutput;
2025-09-20 09:21:41 +02:00
}
type AiTextToSpeechInput = {
prompt: string;
lang?: string;
2025-09-20 09:21:41 +02:00
};
type AiTextToSpeechOutput =
| Uint8Array
| {
audio: string;
};
2025-09-20 09:21:41 +02:00
declare abstract class BaseAiTextToSpeech {
inputs: AiTextToSpeechInput;
postProcessedOutputs: AiTextToSpeechOutput;
2025-09-20 09:21:41 +02:00
}
type AiTextToImageInput = {
prompt: string;
negative_prompt?: string;
height?: number;
width?: number;
image?: number[];
image_b64?: string;
mask?: number[];
num_steps?: number;
strength?: number;
guidance?: number;
seed?: number;
2025-09-20 09:21:41 +02:00
};
type AiTextToImageOutput = ReadableStream<Uint8Array>;
declare abstract class BaseAiTextToImage {
inputs: AiTextToImageInput;
postProcessedOutputs: AiTextToImageOutput;
2025-09-20 09:21:41 +02:00
}
type AiTranslationInput = {
text: string;
target_lang: string;
source_lang?: string;
2025-09-20 09:21:41 +02:00
};
type AiTranslationOutput = {
translated_text?: string;
2025-09-20 09:21:41 +02:00
};
declare abstract class BaseAiTranslation {
inputs: AiTranslationInput;
postProcessedOutputs: AiTranslationOutput;
2025-09-20 09:21:41 +02:00
}
type Ai_Cf_Baai_Bge_Base_En_V1_5_Input =
| {
text: string | string[];
/**
* 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.
*/
pooling?: "mean" | "cls";
}
| {
/**
* Batch of the embeddings requests to run using async-queue
*/
requests: {
text: string | string[];
/**
* 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.
*/
pooling?: "mean" | "cls";
}[];
};
type Ai_Cf_Baai_Bge_Base_En_V1_5_Output =
| {
shape?: number[];
/**
* Embeddings of the requested text values
*/
data?: number[][];
/**
* The pooling method used in the embedding process.
*/
pooling?: "mean" | "cls";
}
| AsyncResponse;
2025-09-20 09:21:41 +02:00
interface AsyncResponse {
/**
* The async request id that can be used to obtain the results.
*/
request_id?: string;
2025-09-20 09:21:41 +02:00
}
declare abstract class Base_Ai_Cf_Baai_Bge_Base_En_V1_5 {
inputs: Ai_Cf_Baai_Bge_Base_En_V1_5_Input;
postProcessedOutputs: Ai_Cf_Baai_Bge_Base_En_V1_5_Output;
2025-09-20 09:21:41 +02:00
}
type Ai_Cf_Openai_Whisper_Input =
| string
| {
/**
* An array of integers that represent the audio data constrained to 8-bit unsigned integer values
*/
audio: number[];
};
2025-09-20 09:21:41 +02:00
interface Ai_Cf_Openai_Whisper_Output {
/**
* The transcription
*/
text: string;
word_count?: number;
words?: {
word?: string;
/**
* The second this word begins in the recording
*/
start?: number;
/**
* The ending second when the word completes
*/
end?: number;
}[];
vtt?: string;
2025-09-20 09:21:41 +02:00
}
declare abstract class Base_Ai_Cf_Openai_Whisper {
inputs: Ai_Cf_Openai_Whisper_Input;
postProcessedOutputs: Ai_Cf_Openai_Whisper_Output;
2025-09-20 09:21:41 +02:00
}
type Ai_Cf_Meta_M2M100_1_2B_Input =
| {
/**
* The text to be translated
*/
text: string;
/**
* The language code of the source text (e.g., 'en' for English). Defaults to 'en' if not specified
*/
source_lang?: string;
/**
* The language code to translate the text into (e.g., 'es' for Spanish)
*/
target_lang: string;
}
| {
/**
* Batch of the embeddings requests to run using async-queue
*/
requests: {
/**
* The text to be translated
*/
text: string;
/**
* The language code of the source text (e.g., 'en' for English). Defaults to 'en' if not specified
*/
source_lang?: string;
/**
* The language code to translate the text into (e.g., 'es' for Spanish)
*/
target_lang: string;
}[];
};
type Ai_Cf_Meta_M2M100_1_2B_Output =
| {
/**
* The translated text in the target language
*/
translated_text?: string;
}
| AsyncResponse;
2025-09-20 09:21:41 +02:00
declare abstract class Base_Ai_Cf_Meta_M2M100_1_2B {
inputs: Ai_Cf_Meta_M2M100_1_2B_Input;
postProcessedOutputs: Ai_Cf_Meta_M2M100_1_2B_Output;
2025-09-20 09:21:41 +02:00
}
type Ai_Cf_Baai_Bge_Small_En_V1_5_Input =
| {
text: string | string[];
/**
* 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.
*/
pooling?: "mean" | "cls";
}
| {
/**
* Batch of the embeddings requests to run using async-queue
*/
requests: {
text: string | string[];
/**
* 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.
*/
pooling?: "mean" | "cls";
}[];
};
type Ai_Cf_Baai_Bge_Small_En_V1_5_Output =
| {
shape?: number[];
/**
* Embeddings of the requested text values
*/
data?: number[][];
/**
* The pooling method used in the embedding process.
*/
pooling?: "mean" | "cls";
}
| AsyncResponse;
2025-09-20 09:21:41 +02:00
declare abstract class Base_Ai_Cf_Baai_Bge_Small_En_V1_5 {
inputs: Ai_Cf_Baai_Bge_Small_En_V1_5_Input;
postProcessedOutputs: Ai_Cf_Baai_Bge_Small_En_V1_5_Output;
2025-09-20 09:21:41 +02:00
}
type Ai_Cf_Baai_Bge_Large_En_V1_5_Input =
| {
text: string | string[];
/**
* 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.
*/
pooling?: "mean" | "cls";
}
| {
/**
* Batch of the embeddings requests to run using async-queue
*/
requests: {
text: string | string[];
/**
* 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.
*/
pooling?: "mean" | "cls";
}[];
};
type Ai_Cf_Baai_Bge_Large_En_V1_5_Output =
| {
shape?: number[];
/**
* Embeddings of the requested text values
*/
data?: number[][];
/**
* The pooling method used in the embedding process.
*/
pooling?: "mean" | "cls";
}
| AsyncResponse;
2025-09-20 09:21:41 +02:00
declare abstract class Base_Ai_Cf_Baai_Bge_Large_En_V1_5 {
inputs: Ai_Cf_Baai_Bge_Large_En_V1_5_Input;
postProcessedOutputs: Ai_Cf_Baai_Bge_Large_En_V1_5_Output;
2025-09-20 09:21:41 +02:00
}
type Ai_Cf_Unum_Uform_Gen2_Qwen_500M_Input =
| string
| {
/**
* The input text prompt for the model to generate a response.
*/
prompt?: string;
/**
* If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
*/
raw?: boolean;
/**
* 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.
*/
top_p?: number;
/**
* 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.
*/
top_k?: number;
/**
* Random seed for reproducibility of the generation.
*/
seed?: number;
/**
* Penalty for repeated tokens; higher values discourage repetition.
*/
repetition_penalty?: number;
/**
* Decreases the likelihood of the model repeating the same lines verbatim.
*/
frequency_penalty?: number;
/**
* Increases the likelihood of the model introducing new topics.
*/
presence_penalty?: number;
image: number[] | (string & NonNullable<unknown>);
/**
* The maximum number of tokens to generate in the response.
*/
max_tokens?: number;
};
2025-09-20 09:21:41 +02:00
interface Ai_Cf_Unum_Uform_Gen2_Qwen_500M_Output {
description?: string;
2025-09-20 09:21:41 +02:00
}
declare abstract class Base_Ai_Cf_Unum_Uform_Gen2_Qwen_500M {
inputs: Ai_Cf_Unum_Uform_Gen2_Qwen_500M_Input;
postProcessedOutputs: Ai_Cf_Unum_Uform_Gen2_Qwen_500M_Output;
2025-09-20 09:21:41 +02:00
}
type Ai_Cf_Openai_Whisper_Tiny_En_Input =
| string
| {
/**
* An array of integers that represent the audio data constrained to 8-bit unsigned integer values
*/
audio: number[];
};
2025-09-20 09:21:41 +02:00
interface Ai_Cf_Openai_Whisper_Tiny_En_Output {
/**
* The transcription
*/
text: string;
word_count?: number;
words?: {
word?: string;
/**
* The second this word begins in the recording
*/
start?: number;
/**
* The ending second when the word completes
*/
end?: number;
}[];
vtt?: string;
2025-09-20 09:21:41 +02:00
}
declare abstract class Base_Ai_Cf_Openai_Whisper_Tiny_En {
inputs: Ai_Cf_Openai_Whisper_Tiny_En_Input;
postProcessedOutputs: Ai_Cf_Openai_Whisper_Tiny_En_Output;
2025-09-20 09:21:41 +02:00
}
interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input {
/**
* Base64 encoded value of the audio data.
*/
audio: string;
/**
* Supported tasks are 'translate' or 'transcribe'.
*/
task?: string;
/**
* The language of the audio being transcribed or translated.
*/
language?: string;
/**
* Preprocess the audio with a voice activity detection model.
*/
vad_filter?: boolean;
/**
* A text prompt to help provide context to the model on the contents of the audio.
*/
initial_prompt?: string;
/**
* The prefix it appended the the beginning of the output of the transcription and can guide the transcription result.
*/
prefix?: string;
2025-09-20 09:21:41 +02:00
}
interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Output {
transcription_info?: {
/**
* The language of the audio being transcribed or translated.
*/
language?: string;
/**
* The confidence level or probability of the detected language being accurate, represented as a decimal between 0 and 1.
*/
language_probability?: number;
/**
* The total duration of the original audio file, in seconds.
*/
duration?: number;
/**
* The duration of the audio after applying Voice Activity Detection (VAD) to remove silent or irrelevant sections, in seconds.
*/
duration_after_vad?: number;
};
/**
* The complete transcription of the audio.
*/
text: string;
/**
* The total number of words in the transcription.
*/
word_count?: number;
segments?: {
/**
* The starting time of the segment within the audio, in seconds.
*/
start?: number;
/**
* The ending time of the segment within the audio, in seconds.
*/
end?: number;
/**
* The transcription of the segment.
*/
text?: string;
/**
* The temperature used in the decoding process, controlling randomness in predictions. Lower values result in more deterministic outputs.
*/
temperature?: number;
/**
* The average log probability of the predictions for the words in this segment, indicating overall confidence.
*/
avg_logprob?: number;
/**
* The compression ratio of the input to the output, measuring how much the text was compressed during the transcription process.
*/
compression_ratio?: number;
/**
* The probability that the segment contains no speech, represented as a decimal between 0 and 1.
*/
no_speech_prob?: number;
words?: {
/**
* The individual word transcribed from the audio.
*/
word?: string;
/**
* The starting time of the word within the audio, in seconds.
*/
start?: number;
/**
* The ending time of the word within the audio, in seconds.
*/
end?: number;
}[];
}[];
/**
* The transcription in WebVTT format, which includes timing and text information for use in subtitles.
*/
vtt?: string;
2025-09-20 09:21:41 +02:00
}
declare abstract class Base_Ai_Cf_Openai_Whisper_Large_V3_Turbo {
inputs: Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input;
postProcessedOutputs: Ai_Cf_Openai_Whisper_Large_V3_Turbo_Output;
2025-09-20 09:21:41 +02:00
}
type Ai_Cf_Baai_Bge_M3_Input =
| BGEM3InputQueryAndContexts
| BGEM3InputEmbedding
| {
/**
* Batch of the embeddings requests to run using async-queue
*/
requests: (BGEM3InputQueryAndContexts1 | BGEM3InputEmbedding1)[];
};
2025-09-20 09:21:41 +02:00
interface BGEM3InputQueryAndContexts {
/**
* A query you wish to perform against the provided contexts. If no query is provided the model with respond with embeddings for contexts
*/
query?: string;
/**
* List of provided contexts. Note that the index in this array is important, as the response will refer to it.
*/
contexts: {
/**
* One of the provided context content
*/
text?: string;
}[];
/**
* When provided with too long context should the model error out or truncate the context to fit?
*/
truncate_inputs?: boolean;
2025-09-20 09:21:41 +02:00
}
interface BGEM3InputEmbedding {
text: string | string[];
/**
* When provided with too long context should the model error out or truncate the context to fit?
*/
truncate_inputs?: boolean;
2025-09-20 09:21:41 +02:00
}
interface BGEM3InputQueryAndContexts1 {
/**
* A query you wish to perform against the provided contexts. If no query is provided the model with respond with embeddings for contexts
*/
query?: string;
/**
* List of provided contexts. Note that the index in this array is important, as the response will refer to it.
*/
contexts: {
/**
* One of the provided context content
*/
text?: string;
}[];
/**
* When provided with too long context should the model error out or truncate the context to fit?
*/
truncate_inputs?: boolean;
2025-09-20 09:21:41 +02:00
}
interface BGEM3InputEmbedding1 {
text: string | string[];
/**
* When provided with too long context should the model error out or truncate the context to fit?
*/
truncate_inputs?: boolean;
2025-09-20 09:21:41 +02:00
}
type Ai_Cf_Baai_Bge_M3_Output = BGEM3OuputQuery | BGEM3OutputEmbeddingForContexts | BGEM3OuputEmbedding | AsyncResponse;
interface BGEM3OuputQuery {
response?: {
/**
* Index of the context in the request
*/
id?: number;
/**
* Score of the context under the index.
*/
score?: number;
}[];
2025-09-20 09:21:41 +02:00
}
interface BGEM3OutputEmbeddingForContexts {
response?: number[][];
shape?: number[];
/**
* The pooling method used in the embedding process.
*/
pooling?: "mean" | "cls";
2025-09-20 09:21:41 +02:00
}
interface BGEM3OuputEmbedding {
shape?: number[];
/**
* Embeddings of the requested text values
*/
data?: number[][];
/**
* The pooling method used in the embedding process.
*/
pooling?: "mean" | "cls";
2025-09-20 09:21:41 +02:00
}
declare abstract class Base_Ai_Cf_Baai_Bge_M3 {
inputs: Ai_Cf_Baai_Bge_M3_Input;
postProcessedOutputs: Ai_Cf_Baai_Bge_M3_Output;
2025-09-20 09:21:41 +02:00
}
interface Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Input {
/**
* A text description of the image you want to generate.
*/
prompt: string;
/**
* The number of diffusion steps; higher values can improve quality but take longer.
*/
steps?: number;
2025-09-20 09:21:41 +02:00
}
interface Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Output {
/**
* The generated image in Base64 format.
*/
image?: string;
2025-09-20 09:21:41 +02:00
}
declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_1_Schnell {
inputs: Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Input;
postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Output;
2025-09-20 09:21:41 +02:00
}
type Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Input = Prompt | Messages;
interface Prompt {
/**
* The input text prompt for the model to generate a response.
*/
prompt: string;
image?: number[] | (string & NonNullable<unknown>);
/**
* If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
*/
raw?: boolean;
/**
* If true, the response will be streamed back incrementally using SSE, Server Sent Events.
*/
stream?: boolean;
/**
* The maximum number of tokens to generate in the response.
*/
max_tokens?: number;
/**
* Controls the randomness of the output; higher values produce more random results.
*/
temperature?: number;
/**
* 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.
*/
top_p?: number;
/**
* 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.
*/
top_k?: number;
/**
* Random seed for reproducibility of the generation.
*/
seed?: number;
/**
* Penalty for repeated tokens; higher values discourage repetition.
*/
repetition_penalty?: number;
/**
* Decreases the likelihood of the model repeating the same lines verbatim.
*/
frequency_penalty?: number;
/**
* Increases the likelihood of the model introducing new topics.
*/
presence_penalty?: number;
/**
* Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.
*/
lora?: string;
2025-09-20 09:21:41 +02:00
}
interface Messages {
/**
* An array of message objects representing the conversation history.
*/
messages: {
/**
* The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
*/
role?: string;
/**
* 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
*/
tool_call_id?: string;
content?:
| string
| {
/**
* Type of the content provided
*/
type?: string;
text?: string;
image_url?: {
/**
* image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
*/
url?: string;
};
}[]
| {
/**
* Type of the content provided
*/
type?: string;
text?: string;
image_url?: {
/**
* image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
*/
url?: string;
};
};
}[];
image?: number[] | (string & NonNullable<unknown>);
functions?: {
name: string;
code: string;
}[];
/**
* A list of tools available for the assistant to use.
*/
tools?: (
| {
/**
* The name of the tool. More descriptive the better.
*/
name: string;
/**
* A brief description of what the tool does.
*/
description: string;
/**
* Schema defining the parameters accepted by the tool.
*/
parameters: {
/**
* The type of the parameters object (usually 'object').
*/
type: string;
/**
* List of required parameter names.
*/
required?: string[];
/**
* Definitions of each parameter.
*/
properties: {
[k: string]: {
/**
* The data type of the parameter.
*/
type: string;
/**
* A description of the expected parameter.
*/
description: string;
};
};
};
}
| {
/**
* Specifies the type of tool (e.g., 'function').
*/
type: string;
/**
* Details of the function tool.
*/
function: {
/**
* The name of the function.
*/
name: string;
/**
* A brief description of what the function does.
*/
description: string;
/**
* Schema defining the parameters accepted by the function.
*/
parameters: {
/**
* The type of the parameters object (usually 'object').
*/
type: string;
/**
* List of required parameter names.
*/
required?: string[];
/**
* Definitions of each parameter.
*/
properties: {
[k: string]: {
/**
* The data type of the parameter.
*/
type: string;
/**
* A description of the expected parameter.
*/
description: string;
};
};
};
};
}
)[];
/**
* If true, the response will be streamed back incrementally.
*/
stream?: boolean;
/**
* The maximum number of tokens to generate in the response.
*/
max_tokens?: number;
/**
* Controls the randomness of the output; higher values produce more random results.
*/
temperature?: number;
/**
* 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.
*/
top_p?: number;
/**
* 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.
*/
top_k?: number;
/**
* Random seed for reproducibility of the generation.
*/
seed?: number;
/**
* Penalty for repeated tokens; higher values discourage repetition.
*/
repetition_penalty?: number;
/**
* Decreases the likelihood of the model repeating the same lines verbatim.
*/
frequency_penalty?: number;
/**
* Increases the likelihood of the model introducing new topics.
*/
presence_penalty?: number;
2025-09-20 09:21:41 +02:00
}
type Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Output = {
/**
* The generated text response from the model
*/
response?: string;
/**
* An array of tool calls requests made during the response generation
*/
tool_calls?: {
/**
* The arguments passed to be passed to the tool call request
*/
arguments?: object;
/**
* The name of the tool to be called
*/
name?: string;
}[];
2025-09-20 09:21:41 +02:00
};
declare abstract class Base_Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct {
inputs: Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Input;
postProcessedOutputs: Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Output;
2025-09-20 09:21:41 +02:00
}
type Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Input =
| Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Prompt
| Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Messages
| AsyncBatch;
2025-09-20 09:21:41 +02:00
interface Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Prompt {
/**
* The input text prompt for the model to generate a response.
*/
prompt: string;
/**
* Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.
*/
lora?: string;
response_format?: JSONMode;
/**
* If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
*/
raw?: boolean;
/**
* If true, the response will be streamed back incrementally using SSE, Server Sent Events.
*/
stream?: boolean;
/**
* The maximum number of tokens to generate in the response.
*/
max_tokens?: number;
/**
* Controls the randomness of the output; higher values produce more random results.
*/
temperature?: number;
/**
* 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.
*/
top_p?: number;
/**
* 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.
*/
top_k?: number;
/**
* Random seed for reproducibility of the generation.
*/
seed?: number;
/**
* Penalty for repeated tokens; higher values discourage repetition.
*/
repetition_penalty?: number;
/**
* Decreases the likelihood of the model repeating the same lines verbatim.
*/
frequency_penalty?: number;
/**
* Increases the likelihood of the model introducing new topics.
*/
presence_penalty?: number;
2025-09-20 09:21:41 +02:00
}
interface JSONMode {
type?: "json_object" | "json_schema";
json_schema?: unknown;
2025-09-20 09:21:41 +02:00
}
interface Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Messages {
/**
* An array of message objects representing the conversation history.
*/
messages: {
/**
* The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
*/
role: string;
/**
* The content of the message as a string.
*/
content: string;
}[];
functions?: {
name: string;
code: string;
}[];
/**
* A list of tools available for the assistant to use.
*/
tools?: (
| {
/**
* The name of the tool. More descriptive the better.
*/
name: string;
/**
* A brief description of what the tool does.
*/
description: string;
/**
* Schema defining the parameters accepted by the tool.
*/
parameters: {
/**
* The type of the parameters object (usually 'object').
*/
type: string;
/**
* List of required parameter names.
*/
required?: string[];
/**
* Definitions of each parameter.
*/
properties: {
[k: string]: {
/**
* The data type of the parameter.
*/
type: string;
/**
* A description of the expected parameter.
*/
description: string;
};
};
};
}
| {
/**
* Specifies the type of tool (e.g., 'function').
*/
type: string;
/**
* Details of the function tool.
*/
function: {
/**
* The name of the function.
*/
name: string;
/**
* A brief description of what the function does.
*/
description: string;
/**
* Schema defining the parameters accepted by the function.
*/
parameters: {
/**
* The type of the parameters object (usually 'object').
*/
type: string;
/**
* List of required parameter names.
*/
required?: string[];
/**
* Definitions of each parameter.
*/
properties: {
[k: string]: {
/**
* The data type of the parameter.
*/
type: string;
/**
* A description of the expected parameter.
*/
description: string;
};
};
};
};
}
)[];
response_format?: JSONMode;
/**
* If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
*/
raw?: boolean;
/**
* If true, the response will be streamed back incrementally using SSE, Server Sent Events.
*/
stream?: boolean;
/**
* The maximum number of tokens to generate in the response.
*/
max_tokens?: number;
/**
* Controls the randomness of the output; higher values produce more random results.
*/
temperature?: number;
/**
* 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.
*/
top_p?: number;
/**
* 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.
*/
top_k?: number;
/**
* Random seed for reproducibility of the generation.
*/
seed?: number;
/**
* Penalty for repeated tokens; higher values discourage repetition.
*/
repetition_penalty?: number;
/**
* Decreases the likelihood of the model repeating the same lines verbatim.
*/
frequency_penalty?: number;
/**
* Increases the likelihood of the model introducing new topics.
*/
presence_penalty?: number;
2025-09-20 09:21:41 +02:00
}
interface AsyncBatch {
requests?: {
/**
* 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.
*/
external_reference?: string;
/**
* Prompt for the text generation model
*/
prompt?: string;
/**
* If true, the response will be streamed back incrementally using SSE, Server Sent Events.
*/
stream?: boolean;
/**
* The maximum number of tokens to generate in the response.
*/
max_tokens?: number;
/**
* Controls the randomness of the output; higher values produce more random results.
*/
temperature?: number;
/**
* 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.
*/
top_p?: number;
/**
* Random seed for reproducibility of the generation.
*/
seed?: number;
/**
* Penalty for repeated tokens; higher values discourage repetition.
*/
repetition_penalty?: number;
/**
* Decreases the likelihood of the model repeating the same lines verbatim.
*/
frequency_penalty?: number;
/**
* Increases the likelihood of the model introducing new topics.
*/
presence_penalty?: number;
response_format?: JSONMode;
}[];
2025-09-20 09:21:41 +02:00
}
type Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Output =
| {
/**
* The generated text response from the model
*/
response: string;
/**
* Usage statistics for the inference request
*/
usage?: {
/**
* Total number of tokens in input
*/
prompt_tokens?: number;
/**
* Total number of tokens in output
*/
completion_tokens?: number;
/**
* Total number of input and output tokens
*/
total_tokens?: number;
};
/**
* An array of tool calls requests made during the response generation
*/
tool_calls?: {
/**
* The arguments passed to be passed to the tool call request
*/
arguments?: object;
/**
* The name of the tool to be called
*/
name?: string;
}[];
}
| AsyncResponse;
2025-09-20 09:21:41 +02:00
declare abstract class Base_Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast {
inputs: Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Input;
postProcessedOutputs: Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Output;
2025-09-20 09:21:41 +02:00
}
interface Ai_Cf_Meta_Llama_Guard_3_8B_Input {
/**
* An array of message objects representing the conversation history.
*/
messages: {
/**
* The role of the message sender must alternate between 'user' and 'assistant'.
*/
role: "user" | "assistant";
/**
* The content of the message as a string.
*/
content: string;
}[];
/**
* The maximum number of tokens to generate in the response.
*/
max_tokens?: number;
/**
* Controls the randomness of the output; higher values produce more random results.
*/
temperature?: number;
/**
* Dictate the output format of the generated response.
*/
response_format?: {
/**
* Set to json_object to process and output generated text as JSON.
*/
type?: string;
};
2025-09-20 09:21:41 +02:00
}
interface Ai_Cf_Meta_Llama_Guard_3_8B_Output {
response?:
| string
| {
/**
* Whether the conversation is safe or not.
*/
safe?: boolean;
/**
* A list of what hazard categories predicted for the conversation, if the conversation is deemed unsafe.
*/
categories?: string[];
};
/**
* Usage statistics for the inference request
*/
usage?: {
/**
* Total number of tokens in input
*/
prompt_tokens?: number;
/**
* Total number of tokens in output
*/
completion_tokens?: number;
/**
* Total number of input and output tokens
*/
total_tokens?: number;
};
2025-09-20 09:21:41 +02:00
}
declare abstract class Base_Ai_Cf_Meta_Llama_Guard_3_8B {
inputs: Ai_Cf_Meta_Llama_Guard_3_8B_Input;
postProcessedOutputs: Ai_Cf_Meta_Llama_Guard_3_8B_Output;
2025-09-20 09:21:41 +02:00
}
interface Ai_Cf_Baai_Bge_Reranker_Base_Input {
/**
* A query you wish to perform against the provided contexts.
*/
query: string;
/**
* Number of returned results starting with the best score.
*/
top_k?: number;
/**
* List of provided contexts. Note that the index in this array is important, as the response will refer to it.
*/
contexts: {
/**
* One of the provided context content
*/
text?: string;
}[];
2025-09-20 09:21:41 +02:00
}
interface Ai_Cf_Baai_Bge_Reranker_Base_Output {
response?: {
/**
* Index of the context in the request
*/
id?: number;
/**
* Score of the context under the index.
*/
score?: number;
}[];
2025-09-20 09:21:41 +02:00
}
declare abstract class Base_Ai_Cf_Baai_Bge_Reranker_Base {
inputs: Ai_Cf_Baai_Bge_Reranker_Base_Input;
postProcessedOutputs: Ai_Cf_Baai_Bge_Reranker_Base_Output;
2025-09-20 09:21:41 +02:00
}
type Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Input = Qwen2_5_Coder_32B_Instruct_Prompt | Qwen2_5_Coder_32B_Instruct_Messages;
interface Qwen2_5_Coder_32B_Instruct_Prompt {
/**
* The input text prompt for the model to generate a response.
*/
prompt: string;
/**
* Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.
*/
lora?: string;
response_format?: JSONMode;
/**
* If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
*/
raw?: boolean;
/**
* If true, the response will be streamed back incrementally using SSE, Server Sent Events.
*/
stream?: boolean;
/**
* The maximum number of tokens to generate in the response.
*/
max_tokens?: number;
/**
* Controls the randomness of the output; higher values produce more random results.
*/
temperature?: number;
/**
* 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.
*/
top_p?: number;
/**
* 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.
*/
top_k?: number;
/**
* Random seed for reproducibility of the generation.
*/
seed?: number;
/**
* Penalty for repeated tokens; higher values discourage repetition.
*/
repetition_penalty?: number;
/**
* Decreases the likelihood of the model repeating the same lines verbatim.
*/
frequency_penalty?: number;
/**
* Increases the likelihood of the model introducing new topics.
*/
presence_penalty?: number;
2025-09-20 09:21:41 +02:00
}
interface Qwen2_5_Coder_32B_Instruct_Messages {
/**
* An array of message objects representing the conversation history.
*/
messages: {
/**
* The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
*/
role: string;
/**
* The content of the message as a string.
*/
content: string;
}[];
functions?: {
name: string;
code: string;
}[];
/**
* A list of tools available for the assistant to use.
*/
tools?: (
| {
/**
* The name of the tool. More descriptive the better.
*/
name: string;
/**
* A brief description of what the tool does.
*/
description: string;
/**
* Schema defining the parameters accepted by the tool.
*/
parameters: {
/**
* The type of the parameters object (usually 'object').
*/
type: string;
/**
* List of required parameter names.
*/
required?: string[];
/**
* Definitions of each parameter.
*/
properties: {
[k: string]: {
/**
* The data type of the parameter.
*/
type: string;
/**
* A description of the expected parameter.
*/
description: string;
};
};
};
}
| {
/**
* Specifies the type of tool (e.g., 'function').
*/
type: string;
/**
* Details of the function tool.
*/
function: {
/**
* The name of the function.
*/
name: string;
/**
* A brief description of what the function does.
*/
description: string;
/**
* Schema defining the parameters accepted by the function.
*/
parameters: {
/**
* The type of the parameters object (usually 'object').
*/
type: string;
/**
* List of required parameter names.
*/
required?: string[];
/**
* Definitions of each parameter.
*/
properties: {
[k: string]: {
/**
* The data type of the parameter.
*/
type: string;
/**
* A description of the expected parameter.
*/
description: string;
};
};
};
};
}
)[];
response_format?: JSONMode;
/**
* If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
*/
raw?: boolean;
/**
* If true, the response will be streamed back incrementally using SSE, Server Sent Events.
*/
stream?: boolean;
/**
* The maximum number of tokens to generate in the response.
*/
max_tokens?: number;
/**
* Controls the randomness of the output; higher values produce more random results.
*/
temperature?: number;
/**
* 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.
*/
top_p?: number;
/**
* 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.
*/
top_k?: number;
/**
* Random seed for reproducibility of the generation.
*/
seed?: number;
/**
* Penalty for repeated tokens; higher values discourage repetition.
*/
repetition_penalty?: number;
/**
* Decreases the likelihood of the model repeating the same lines verbatim.
*/
frequency_penalty?: number;
/**
* Increases the likelihood of the model introducing new topics.
*/
presence_penalty?: number;
2025-09-20 09:21:41 +02:00
}
type Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Output = {
/**
* The generated text response from the model
*/
response: string;
/**
* Usage statistics for the inference request
*/
usage?: {
/**
* Total number of tokens in input
*/
prompt_tokens?: number;
/**
* Total number of tokens in output
*/
completion_tokens?: number;
/**
* Total number of input and output tokens
*/
total_tokens?: number;
};
/**
* An array of tool calls requests made during the response generation
*/
tool_calls?: {
/**
* The arguments passed to be passed to the tool call request
*/
arguments?: object;
/**
* The name of the tool to be called
*/
name?: string;
}[];
2025-09-20 09:21:41 +02:00
};
declare abstract class Base_Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct {
inputs: Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Input;
postProcessedOutputs: Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Output;
2025-09-20 09:21:41 +02:00
}
type Ai_Cf_Qwen_Qwq_32B_Input = Qwen_Qwq_32B_Prompt | Qwen_Qwq_32B_Messages;
interface Qwen_Qwq_32B_Prompt {
/**
* The input text prompt for the model to generate a response.
*/
prompt: string;
/**
* JSON schema that should be fulfilled for the response.
*/
guided_json?: object;
/**
* If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
*/
raw?: boolean;
/**
* If true, the response will be streamed back incrementally using SSE, Server Sent Events.
*/
stream?: boolean;
/**
* The maximum number of tokens to generate in the response.
*/
max_tokens?: number;
/**
* Controls the randomness of the output; higher values produce more random results.
*/
temperature?: number;
/**
* 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.
*/
top_p?: number;
/**
* 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.
*/
top_k?: number;
/**
* Random seed for reproducibility of the generation.
*/
seed?: number;
/**
* Penalty for repeated tokens; higher values discourage repetition.
*/
repetition_penalty?: number;
/**
* Decreases the likelihood of the model repeating the same lines verbatim.
*/
frequency_penalty?: number;
/**
* Increases the likelihood of the model introducing new topics.
*/
presence_penalty?: number;
2025-09-20 09:21:41 +02:00
}
interface Qwen_Qwq_32B_Messages {
/**
* An array of message objects representing the conversation history.
*/
messages: {
/**
* The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
*/
role?: string;
/**
* 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
*/
tool_call_id?: string;
content?:
| string
| {
/**
* Type of the content provided
*/
type?: string;
text?: string;
image_url?: {
/**
* image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
*/
url?: string;
};
}[]
| {
/**
* Type of the content provided
*/
type?: string;
text?: string;
image_url?: {
/**
* image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
*/
url?: string;
};
};
}[];
functions?: {
name: string;
code: string;
}[];
/**
* A list of tools available for the assistant to use.
*/
tools?: (
| {
/**
* The name of the tool. More descriptive the better.
*/
name: string;
/**
* A brief description of what the tool does.
*/
description: string;
/**
* Schema defining the parameters accepted by the tool.
*/
parameters: {
/**
* The type of the parameters object (usually 'object').
*/
type: string;
/**
* List of required parameter names.
*/
required?: string[];
/**
* Definitions of each parameter.
*/
properties: {
[k: string]: {
/**
* The data type of the parameter.
*/
type: string;
/**
* A description of the expected parameter.
*/
description: string;
};
};
};
}
| {
/**
* Specifies the type of tool (e.g., 'function').
*/
type: string;
/**
* Details of the function tool.
*/
function: {
/**
* The name of the function.
*/
name: string;
/**
* A brief description of what the function does.
*/
description: string;
/**
* Schema defining the parameters accepted by the function.
*/
parameters: {
/**
* The type of the parameters object (usually 'object').
*/
type: string;
/**
* List of required parameter names.
*/
required?: string[];
/**
* Definitions of each parameter.
*/
properties: {
[k: string]: {
/**
* The data type of the parameter.
*/
type: string;
/**
* A description of the expected parameter.
*/
description: string;
};
};
};
};
}
)[];
/**
* JSON schema that should be fufilled for the response.
*/
guided_json?: object;
/**
* If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
*/
raw?: boolean;
/**
* If true, the response will be streamed back incrementally using SSE, Server Sent Events.
*/
stream?: boolean;
/**
* The maximum number of tokens to generate in the response.
*/
max_tokens?: number;
/**
* Controls the randomness of the output; higher values produce more random results.
*/
temperature?: number;
/**
* 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.
*/
top_p?: number;
/**
* 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.
*/
top_k?: number;
/**
* Random seed for reproducibility of the generation.
*/
seed?: number;
/**
* Penalty for repeated tokens; higher values discourage repetition.
*/
repetition_penalty?: number;
/**
* Decreases the likelihood of the model repeating the same lines verbatim.
*/
frequency_penalty?: number;
/**
* Increases the likelihood of the model introducing new topics.
*/
presence_penalty?: number;
2025-09-20 09:21:41 +02:00
}
type Ai_Cf_Qwen_Qwq_32B_Output = {
/**
* The generated text response from the model
*/
response: string;
/**
* Usage statistics for the inference request
*/
usage?: {
/**
* Total number of tokens in input
*/
prompt_tokens?: number;
/**
* Total number of tokens in output
*/
completion_tokens?: number;
/**
* Total number of input and output tokens
*/
total_tokens?: number;
};
/**
* An array of tool calls requests made during the response generation
*/
tool_calls?: {
/**
* The arguments passed to be passed to the tool call request
*/
arguments?: object;
/**
* The name of the tool to be called
*/
name?: string;
}[];
2025-09-20 09:21:41 +02:00
};
declare abstract class Base_Ai_Cf_Qwen_Qwq_32B {
inputs: Ai_Cf_Qwen_Qwq_32B_Input;
postProcessedOutputs: Ai_Cf_Qwen_Qwq_32B_Output;
2025-09-20 09:21:41 +02:00
}
type Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Input = Mistral_Small_3_1_24B_Instruct_Prompt | Mistral_Small_3_1_24B_Instruct_Messages;
interface Mistral_Small_3_1_24B_Instruct_Prompt {
/**
* The input text prompt for the model to generate a response.
*/
prompt: string;
/**
* JSON schema that should be fulfilled for the response.
*/
guided_json?: object;
/**
* If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
*/
raw?: boolean;
/**
* If true, the response will be streamed back incrementally using SSE, Server Sent Events.
*/
stream?: boolean;
/**
* The maximum number of tokens to generate in the response.
*/
max_tokens?: number;
/**
* Controls the randomness of the output; higher values produce more random results.
*/
temperature?: number;
/**
* 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.
*/
top_p?: number;
/**
* 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.
*/
top_k?: number;
/**
* Random seed for reproducibility of the generation.
*/
seed?: number;
/**
* Penalty for repeated tokens; higher values discourage repetition.
*/
repetition_penalty?: number;
/**
* Decreases the likelihood of the model repeating the same lines verbatim.
*/
frequency_penalty?: number;
/**
* Increases the likelihood of the model introducing new topics.
*/
presence_penalty?: number;
2025-09-20 09:21:41 +02:00
}
interface Mistral_Small_3_1_24B_Instruct_Messages {
/**
* An array of message objects representing the conversation history.
*/
messages: {
/**
* The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
*/
role?: string;
/**
* 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
*/
tool_call_id?: string;
content?:
| string
| {
/**
* Type of the content provided
*/
type?: string;
text?: string;
image_url?: {
/**
* image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
*/
url?: string;
};
}[]
| {
/**
* Type of the content provided
*/
type?: string;
text?: string;
image_url?: {
/**
* image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
*/
url?: string;
};
};
}[];
functions?: {
name: string;
code: string;
}[];
/**
* A list of tools available for the assistant to use.
*/
tools?: (
| {
/**
* The name of the tool. More descriptive the better.
*/
name: string;
/**
* A brief description of what the tool does.
*/
description: string;
/**
* Schema defining the parameters accepted by the tool.
*/
parameters: {
/**
* The type of the parameters object (usually 'object').
*/
type: string;
/**
* List of required parameter names.
*/
required?: string[];
/**
* Definitions of each parameter.
*/
properties: {
[k: string]: {
/**
* The data type of the parameter.
*/
type: string;
/**
* A description of the expected parameter.
*/
description: string;
};
};
};
}
| {
/**
* Specifies the type of tool (e.g., 'function').
*/
type: string;
/**
* Details of the function tool.
*/
function: {
/**
* The name of the function.
*/
name: string;
/**
* A brief description of what the function does.
*/
description: string;
/**
* Schema defining the parameters accepted by the function.
*/
parameters: {
/**
* The type of the parameters object (usually 'object').
*/
type: string;
/**
* List of required parameter names.
*/
required?: string[];
/**
* Definitions of each parameter.
*/
properties: {
[k: string]: {
/**
* The data type of the parameter.
*/
type: string;
/**
* A description of the expected parameter.
*/
description: string;
};
};
};
};
}
)[];
/**
* JSON schema that should be fufilled for the response.
*/
guided_json?: object;
/**
* If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
*/
raw?: boolean;
/**
* If true, the response will be streamed back incrementally using SSE, Server Sent Events.
*/
stream?: boolean;
/**
* The maximum number of tokens to generate in the response.
*/
max_tokens?: number;
/**
* Controls the randomness of the output; higher values produce more random results.
*/
temperature?: number;
/**
* 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.
*/
top_p?: number;
/**
* 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.
*/
top_k?: number;
/**
* Random seed for reproducibility of the generation.
*/
seed?: number;
/**
* Penalty for repeated tokens; higher values discourage repetition.
*/
repetition_penalty?: number;
/**
* Decreases the likelihood of the model repeating the same lines verbatim.
*/
frequency_penalty?: number;
/**
* Increases the likelihood of the model introducing new topics.
*/
presence_penalty?: number;
2025-09-20 09:21:41 +02:00
}
type Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Output = {
/**
* The generated text response from the model
*/
response: string;
/**
* Usage statistics for the inference request
*/
usage?: {
/**
* Total number of tokens in input
*/
prompt_tokens?: number;
/**
* Total number of tokens in output
*/
completion_tokens?: number;
/**
* Total number of input and output tokens
*/
total_tokens?: number;
};
/**
* An array of tool calls requests made during the response generation
*/
tool_calls?: {
/**
* The arguments passed to be passed to the tool call request
*/
arguments?: object;
/**
* The name of the tool to be called
*/
name?: string;
}[];
2025-09-20 09:21:41 +02:00
};
declare abstract class Base_Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct {
inputs: Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Input;
postProcessedOutputs: Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Output;
2025-09-20 09:21:41 +02:00
}
type Ai_Cf_Google_Gemma_3_12B_It_Input = Google_Gemma_3_12B_It_Prompt | Google_Gemma_3_12B_It_Messages;
interface Google_Gemma_3_12B_It_Prompt {
/**
* The input text prompt for the model to generate a response.
*/
prompt: string;
/**
* JSON schema that should be fufilled for the response.
*/
guided_json?: object;
/**
* If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
*/
raw?: boolean;
/**
* If true, the response will be streamed back incrementally using SSE, Server Sent Events.
*/
stream?: boolean;
/**
* The maximum number of tokens to generate in the response.
*/
max_tokens?: number;
/**
* Controls the randomness of the output; higher values produce more random results.
*/
temperature?: number;
/**
* 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.
*/
top_p?: number;
/**