Skip to content

Instantly share code, notes, and snippets.

@penalosa
Created October 28, 2022 09:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save penalosa/204f40ba0719fb815db75ba28239f4fd to your computer and use it in GitHub Desktop.
Save penalosa/204f40ba0719fb815db75ba28239f4fd to your computer and use it in GitHub Desktop.
/* eslint-disable */
// noinspection JSUnusedGlobalSymbols
/** An abnormal event (called an exception) which occurs as a result of calling a method or accessing a property of a web API. */
declare class DOMException extends Error {
constructor(param0?: string, param1?: string);
readonly message: string;
readonly name: string;
readonly code: number;
readonly stack: any;
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;
}
/** This Web Workers API interface is an interface representing the scope of any worker. Workers have no browsing context; this scope contains the information usually conveyed by Window objects — in this case event handlers, the console or the associated WorkerNavigator object. Each WorkerGlobalScope has its own event loop. */
declare abstract class WorkerGlobalScope extends EventTarget<WorkerGlobalScopeEventMap> {
EventTarget: typeof EventTarget;
}
declare abstract class PromiseRejectionEvent extends Event {
readonly promise: Promise<any>;
readonly reason: any;
}
declare abstract class Navigator {
readonly userAgent: string;
}
/** An event which takes place in the DOM. */
declare class Event {
constructor(param0: string, param1?: EventInit);
/** Returns the type of event, e.g. "click", "hashchange", or "submit". */
get type(): string;
/** Returns the event's phase, which is one of NONE, CAPTURING_PHASE, AT_TARGET, and BUBBLING_PHASE. */
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. */
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. */
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. */
get cancelable(): boolean;
/** Returns true if preventDefault() was invoked successfully to indicate cancelation, and false otherwise. */
get defaultPrevented(): boolean;
/** @deprecated */
get returnValue(): boolean;
/** Returns the object whose event listener's callback is currently being invoked. */
get currentTarget(): EventTarget | undefined;
/** @deprecated */
get srcElement(): EventTarget | undefined;
/** Returns the event's timestamp as the number of milliseconds measured relative to the time origin. */
get timeStamp(): number;
/** Returns true if event was dispatched by the user agent, and false otherwise. */
get isTrusted(): boolean;
get cancelBubble(): boolean;
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. */
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. */
preventDefault(): void;
/** When dispatched in a tree, invoking this method prevents event from reaching any objects other than the current object. */
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. */
composedPath(): EventTarget[];
static readonly NONE: number;
static readonly CAPTURING_PHASE: number;
static readonly AT_TARGET: number;
static readonly BUBBLING_PHASE: number;
}
/** EventTarget is a DOM interface implemented by objects that can receive events and may have listeners for them. */
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.
*/
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. */
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. */
dispatchEvent(event: EventMap[keyof EventMap]): boolean;
}
/** A controller object that allows you to abort one or more DOM requests as and when desired. */
declare class AbortController {
constructor();
/** Returns the AbortSignal object associated with this object. */
get signal(): AbortSignal;
abort(param0?: any): void;
}
/** 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. */
declare abstract class AbortSignal extends EventTarget {
static abort(param0?: any): AbortSignal;
static timeout(param0: number): AbortSignal;
/** Returns true if this AbortSignal's AbortController has signaled to abort, and false otherwise. */
get aborted(): boolean;
get reason(): any;
throwIfAborted(): void;
}
/** 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. */
declare abstract class ExtendableEvent extends Event {
waitUntil(param0: void | Promise<void>): void;
}
/** 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. */
declare class Blob {
constructor(
param0?: ((ArrayBuffer | ArrayBufferView) | string | Blob)[],
param1?: BlobOptions
);
get size(): number;
get type(): string;
slice(param0?: number, param1?: number, param2?: string): Blob;
arrayBuffer(): Promise<ArrayBuffer>;
text(): Promise<string>;
stream(): ReadableStream;
}
/** Provides information about files and allows JavaScript in a web page to access their content. */
declare class File extends Blob {
constructor(
param0: ((ArrayBuffer | ArrayBufferView) | string | Blob)[] | undefined,
param1: string,
param2?: FileOptions
);
get name(): string;
get lastModified(): number;
}
/**
* The storage for Cache objects.
* Available only in secure contexts.
*/
declare abstract class CacheStorage {
open(param0: string): Promise<Cache>;
readonly default: Cache;
}
/**
* Provides a storage mechanism for Request / Response object pairs that are cached, for example as part of the ServiceWorker life cycle. Note that the Cache interface is exposed to windowed scopes as well as workers. You don't have to use it in conjunction with service workers, even though it is defined in the service worker spec.
* Available only in secure contexts.
*/
declare abstract class Cache {
delete(
param0: Request | string,
param1?: CacheQueryOptions
): Promise<boolean>;
match(
param0: Request | string,
param1?: CacheQueryOptions
): Promise<Response | undefined>;
put(param0: Request | string, param1: Response): Promise<void>;
}
/** Basic cryptography features available in the current context. It allows access to a cryptographically strong random number generator and to cryptographic primitives. */
declare abstract class Crypto {
/** Available only in secure contexts. */
get subtle(): SubtleCrypto;
getRandomValues<
T extends
| Int8Array
| Uint8Array
| Int16Array
| Uint16Array
| Int32Array
| Uint32Array
| BigInt64Array
| BigUint64Array
>(buffer: T): T;
/** Available only in secure contexts. */
randomUUID(): string;
DigestStream: typeof DigestStream;
}
/**
* 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.
*/
declare abstract class SubtleCrypto {
encrypt(
param0: string | SubtleCryptoEncryptAlgorithm,
param1: CryptoKey,
param2: ArrayBuffer | ArrayBufferView
): Promise<ArrayBuffer>;
decrypt(
param0: string | SubtleCryptoEncryptAlgorithm,
param1: CryptoKey,
param2: ArrayBuffer | ArrayBufferView
): Promise<ArrayBuffer>;
sign(
param0: string | SubtleCryptoSignAlgorithm,
param1: CryptoKey,
param2: ArrayBuffer | ArrayBufferView
): Promise<ArrayBuffer>;
verify(
param0: string | SubtleCryptoSignAlgorithm,
param1: CryptoKey,
param2: ArrayBuffer | ArrayBufferView,
param3: ArrayBuffer | ArrayBufferView
): Promise<boolean>;
digest(
param0: string | SubtleCryptoHashAlgorithm,
param1: ArrayBuffer | ArrayBufferView
): Promise<ArrayBuffer>;
generateKey(
param0: string | SubtleCryptoGenerateKeyAlgorithm,
param1: boolean,
param2: string[]
): Promise<CryptoKey | CryptoKeyPair>;
deriveKey(
param0: string | SubtleCryptoDeriveKeyAlgorithm,
param1: CryptoKey,
param2: string | SubtleCryptoImportKeyAlgorithm,
param3: boolean,
param4: string[]
): Promise<CryptoKey>;
deriveBits(
param0: string | SubtleCryptoDeriveKeyAlgorithm,
param1: CryptoKey,
param2: number | null
): Promise<ArrayBuffer>;
importKey(
param0: string,
param1: (ArrayBuffer | ArrayBufferView) | JsonWebKey,
param2: string | SubtleCryptoImportKeyAlgorithm,
param3: boolean,
param4: string[]
): Promise<CryptoKey>;
exportKey(
param0: string,
param1: CryptoKey
): Promise<ArrayBuffer | JsonWebKey>;
wrapKey(
param0: string,
param1: CryptoKey,
param2: CryptoKey,
param3: string | SubtleCryptoEncryptAlgorithm
): Promise<ArrayBuffer>;
unwrapKey(
param0: string,
param1: ArrayBuffer | ArrayBufferView,
param2: CryptoKey,
param3: string | SubtleCryptoEncryptAlgorithm,
param4: string | SubtleCryptoImportKeyAlgorithm,
param5: boolean,
param6: string[]
): Promise<CryptoKey>;
timingSafeEqual(
param0: ArrayBuffer | ArrayBufferView,
param1: ArrayBuffer | ArrayBufferView
): boolean;
}
/**
* The CryptoKey dictionary of the Web Crypto API represents a cryptographic key.
* Available only in secure contexts.
*/
declare abstract class CryptoKey {
readonly type: string;
readonly extractable: boolean;
readonly algorithm:
| CryptoKeyKeyAlgorithm
| CryptoKeyAesKeyAlgorithm
| CryptoKeyHmacKeyAlgorithm
| CryptoKeyRsaKeyAlgorithm
| CryptoKeyEllipticKeyAlgorithm
| CryptoKeyArbitraryKeyAlgorithm;
readonly usages: string[];
}
declare class DigestStream extends WritableStream<
ArrayBuffer | ArrayBufferView
> {
constructor(param0: string | SubtleCryptoHashAlgorithm);
get digest(): Promise<ArrayBuffer>;
}
/** 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. */
declare class TextDecoder {
constructor(param0?: string, param1?: 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.
*/
decode(
param0?: ArrayBuffer | ArrayBufferView,
param1?: TextDecoderDecodeOptions
): string;
get encoding(): string;
get fatal(): boolean;
get ignoreBOM(): boolean;
}
/** 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. */
declare class TextEncoder {
constructor();
/** Returns the result of running UTF-8's encoder. */
encode(param0?: 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. */
encodeInto(param0: string, param1: Uint8Array): TextEncoderEncodeIntoResult;
get encoding(): string;
}
/** 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". */
declare class FormData {
constructor();
append(name: string, value: string): void;
append(name: string, value: Blob, filename?: string): void;
delete(param0: string): void;
get(param0: string): (File | string) | null;
getAll(param0: string): (File | string)[];
has(param0: string): boolean;
set(name: string, value: string): void;
set(name: string, value: Blob, filename?: string): void;
entries(): IterableIterator<[key: string, value: File | string]>;
keys(): IterableIterator<string>;
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]>;
}
declare class HTMLRewriter {
constructor();
on(param0: string, param1: HTMLRewriterElementContentHandlers): HTMLRewriter;
onDocument(param0: HTMLRewriterDocumentContentHandlers): HTMLRewriter;
transform(param0: Response): Response;
}
/** 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. */
declare abstract class FetchEvent extends ExtendableEvent {
readonly request: Request;
respondWith(param0: Response | Promise<Response>): void;
passThroughOnException(): void;
}
/** 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. */
declare class Headers {
constructor(
init?: Headers | Record<string, string> | [key: string, value: string][]
);
get(param0: string): string | null;
getAll(param0: string): string[];
has(param0: string): boolean;
set(param0: string, param1: string): void;
append(param0: string, param1: string): void;
delete(param0: string): void;
forEach<This = unknown>(
callback: (this: This, value: string, key: string, parent: Headers) => void,
thisArg?: This
): void;
entries(): IterableIterator<[key: string, value: string]>;
keys(): IterableIterator<string>;
values(): IterableIterator<string>;
[Symbol.iterator](): IterableIterator<[key: string, value: string]>;
}
declare abstract class Body {
get body(): ReadableStream | null;
get bodyUsed(): boolean;
arrayBuffer(): Promise<ArrayBuffer>;
text(): Promise<string>;
json<T>(): Promise<T>;
formData(): Promise<FormData>;
blob(): Promise<Blob>;
}
/** This Fetch API interface represents the response to a request. */
declare class Response extends Body {
constructor(
param0?:
| (
| ReadableStream
| string
| (ArrayBuffer | ArrayBufferView)
| Blob
| URLSearchParams
| FormData
)
| null,
param1?: ResponseInit | Response
);
static redirect(param0: string, param1?: number): Response;
static json(param0: any, param1?: ResponseInit | Response): Response;
clone(): Response;
get status(): number;
get statusText(): string;
get headers(): Headers;
get ok(): boolean;
get redirected(): boolean;
get url(): string;
get webSocket(): WebSocket | null;
get cf(): any | undefined;
}
/** This Fetch API interface represents a resource request. */
declare class Request extends Body {
constructor(param0: Request | string, param1?: RequestInit | Request);
clone(): Request;
/** Returns request's HTTP method, which is "GET" by default. */
get method(): string;
/** Returns the URL of request as a string. */
get 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. */
get 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. */
get redirect(): string;
get 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. */
get signal(): AbortSignal;
get cf(): any | undefined;
}
declare abstract class Fetcher {
fetch(
param0: Request | string,
param1?: RequestInit | Request
): Promise<Response>;
}
declare abstract class R2Bucket {
head(param0: 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
): Promise<R2Object>;
delete(param0: string | string[]): Promise<void>;
list(param0?: R2ListOptions): Promise<R2Objects>;
}
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?: R2BucketHttpMetadata;
readonly customMetadata?: Record<string, string>;
readonly range?: R2Range;
writeHttpMetadata(param0: Headers): void;
}
declare abstract class ScheduledEvent extends ExtendableEvent {
readonly scheduledTime: number;
readonly cron: string;
noRetry(): void;
}
declare class ReadableStreamDefaultReader<R = any> {
constructor(param0: ReadableStream);
get closed(): Promise<void>;
cancel(param0?: any): Promise<void>;
read(): Promise<ReadableStreamReadResult<R>>;
releaseLock(): void;
}
declare class ReadableStreamBYOBReader {
constructor(param0: ReadableStream);
get closed(): Promise<void>;
cancel(param0?: any): Promise<void>;
read<T extends ArrayBufferView>(
view: T
): Promise<ReadableStreamReadResult<T>>;
releaseLock(): void;
readAtLeast(
minBytes: number,
view: Uint8Array
): Promise<ReadableStreamReadResult<Uint8Array>>;
}
declare abstract class ReadableStreamBYOBRequest {
readonly view: Uint8Array | null;
respond(param0: number): void;
respondWithNewView(param0: ArrayBuffer | ArrayBufferView): void;
readonly atLeast: number | null;
}
declare abstract class ReadableStreamDefaultController<R = any> {
readonly desiredSize: number | null;
close(): void;
enqueue(chunk?: R): void;
error(param0: any): void;
}
declare abstract class ReadableByteStreamController {
readonly byobRequest: ReadableStreamBYOBRequest | null;
readonly desiredSize: number | null;
close(): void;
enqueue(param0: ArrayBuffer | ArrayBufferView): void;
error(param0: any): void;
}
/** 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. */
declare abstract class WritableStreamDefaultController {
readonly signal: AbortSignal;
error(param0?: any): void;
}
/** 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. */
declare class WritableStream<W = any> {
constructor(param0?: UnderlyingSink, param1?: QueuingStrategy);
get locked(): boolean;
abort(param0?: any): Promise<void>;
close(): Promise<void>;
getWriter(): WritableStreamDefaultWriter<W>;
}
/** 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. */
declare class WritableStreamDefaultWriter<W = any> {
constructor(param0: WritableStream);
get closed(): Promise<void>;
get ready(): Promise<void>;
get desiredSize(): number | null;
abort(param0?: any): Promise<void>;
close(): Promise<void>;
write(chunk?: W): Promise<void>;
releaseLock(): void;
}
declare class TransformStream<I = any, O = any> {
constructor(
transformer?: Transformer<I, O>,
writableStrategy?: QueuingStrategy<I>,
readableStrategy?: QueuingStrategy<O>
);
get readable(): ReadableStream<O>;
get writable(): WritableStream<I>;
}
declare class FixedLengthStream extends IdentityTransformStream {
constructor(param0: number | bigint);
}
declare class IdentityTransformStream extends TransformStream<
ArrayBuffer | ArrayBufferView,
Uint8Array
> {
constructor();
}
declare class CompressionStream extends TransformStream<
ArrayBuffer | ArrayBufferView,
Uint8Array
> {
constructor(format: "gzip" | "deflate");
}
declare class DecompressionStream extends TransformStream<
ArrayBuffer | ArrayBufferView,
Uint8Array
> {
constructor(format: "gzip" | "deflate");
}
declare class TextEncoderStream extends TransformStream<string, Uint8Array> {
constructor();
}
declare class TextDecoderStream extends TransformStream<
ArrayBuffer | ArrayBufferView,
string
> {
constructor(param0?: string, param1?: TextDecoderStreamTextDecoderStreamInit);
}
/** This Streams API interface provides a built-in byte length queuing strategy that can be used when constructing streams. */
declare class ByteLengthQueuingStrategy
implements QueuingStrategy<ArrayBufferView>
{
constructor(param0: QueuingStrategyInit);
get highWaterMark(): number;
get size(): (chunk?: any) => number;
}
/** This Streams API interface provides a built-in byte length queuing strategy that can be used when constructing streams. */
declare class CountQueuingStrategy implements QueuingStrategy {
constructor(param0: QueuingStrategyInit);
get highWaterMark(): number;
get size(): (chunk?: any) => number;
}
declare abstract class TraceEvent extends ExtendableEvent {
readonly traces: TraceItem[];
}
/** The URL interface represents an object providing static methods used for creating object URLs. */
declare class URL {
constructor(param0: string, param1?: string);
get origin(): string;
get href(): string;
set href(value: string);
get protocol(): string;
set protocol(value: string);
get username(): string;
set username(value: string);
get password(): string;
set password(value: string);
get host(): string;
set host(value: string);
get hostname(): string;
set hostname(value: string);
get port(): string;
set port(value: string);
get pathname(): string;
set pathname(value: string);
get search(): string;
set search(value: string);
get hash(): string;
set hash(value: string);
get searchParams(): URLSearchParams;
toJSON(): string;
toString(): string;
}
declare class URLSearchParams {
constructor(
param0?: Iterable<Iterable<string>> | Record<string, string> | string
);
/** Appends a specified key/value pair as a new search parameter. */
append(param0: string, param1: string): void;
/** Deletes the given search parameter, and its associated value, from the list of all search parameters. */
delete(param0: string): void;
/** Returns the first value associated to the given search parameter. */
get(param0: string): string | null;
/** Returns all the values association with a given search parameter. */
getAll(param0: string): string[];
/** Returns a Boolean indicating if such a search parameter exists. */
has(param0: string): boolean;
/** Sets the value associated to a given search parameter to the given value. If there were several values, delete the others. */
set(param0: string, param1: string): void;
sort(): void;
entries(): IterableIterator<[key: string, value: string]>;
keys(): IterableIterator<string>;
values(): IterableIterator<string>;
forEach<This = unknown>(
callback: (
this: This,
value: string,
key: string,
parent: URLSearchParams
) => void,
thisArg?: This
): void;
/** 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]>;
}
declare class URLPattern {
constructor(param0?: string | URLPatternURLPatternInit, param1?: string);
get protocol(): string;
get username(): string;
get password(): string;
get hostname(): string;
get port(): string;
get pathname(): string;
get search(): string;
get hash(): string;
test(param0?: string | URLPatternURLPatternInit, param1?: string): boolean;
exec(
param0?: string | URLPatternURLPatternInit,
param1?: string
): URLPatternURLPatternResult | null;
}
/** 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. */
declare class CloseEvent extends Event {
constructor(param0: string, param1: CloseEventInit);
/** Returns the WebSocket connection close code provided by the server. */
readonly code: number;
/** Returns the WebSocket connection close reason provided by the server. */
readonly reason: string;
/** Returns true if the connection closed cleanly; false otherwise. */
readonly wasClean: boolean;
}
/** A message received by a target object. */
declare class MessageEvent extends Event {
constructor(param0: string, param1: MessageEventInit);
/** Returns the data of the message. */
readonly data: ArrayBuffer | string;
}
/** Provides the API for creating and managing a WebSocket connection to a server, as well as for sending and receiving data on the connection. */
declare class WebSocket extends EventTarget<WebSocketEventMap> {
constructor(param0: string, param1?: string[] | string);
accept(): void;
/** Transmits data using the WebSocket connection. data can be a string, a Blob, an ArrayBuffer, or an ArrayBufferView. */
send(param0: (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. */
close(param0?: number, param1?: string): void;
static readonly READY_STATE_CONNECTING: number;
static readonly READY_STATE_OPEN: number;
static readonly READY_STATE_CLOSING: number;
static readonly READY_STATE_CLOSED: number;
/** Returns the state of the WebSocket object's connection. It can have the values described below. */
get readyState(): number;
/** Returns the URL that was used to establish the WebSocket connection. */
get 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. */
get protocol(): string | null;
/** Returns the extensions selected by the server, if any. */
get extensions(): string | null;
}
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;
/** 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. */
declare function dispatchEvent(
event: WorkerGlobalScopeEventMap[keyof WorkerGlobalScopeEventMap]
): boolean;
declare function btoa(data: string): string;
declare function atob(param0: string): string;
declare function setTimeout<Args extends any[]>(
callback: (...args: Args) => void,
msDelay?: number,
...args: Args
): number;
declare function clearTimeout(param0: number | null): void;
declare function setInterval<Args extends any[]>(
callback: (...args: Args) => void,
msDelay?: number,
...args: Args
): number;
declare function clearInterval(param0: number | null): void;
declare function queueMicrotask(param0: Function): void;
declare function structuredClone(
param0: any,
param1?: ServiceWorkerGlobalScopeStructuredCloneOptions
): any;
declare function fetch(
param0: Request | string,
param1?: RequestInit | Request
): Promise<Response>;
declare type WorkerGlobalScopeEventMap = {
fetch: FetchEvent;
scheduled: ScheduledEvent;
unhandledrejection: PromiseRejectionEvent;
rejectionhandled: PromiseRejectionEvent;
};
declare type ExportedHandlerFetchHandler<Env = unknown> = (
request: Request,
env: Env,
ctx: ExecutionContext
) => Response | Promise<Response>;
declare type ExportedHandlerTraceHandler<Env = unknown> = (
traces: TraceItem[],
env: Env,
ctx: ExecutionContext
) => void | Promise<void>;
declare type ExportedHandlerScheduledHandler<Env = unknown> = (
controller: ScheduledController,
env: Env,
ctx: ExecutionContext
) => void | Promise<void>;
declare type EventListener<EventType extends Event = Event> = (
event: EventType
) => void;
declare type EventListenerOrEventListenerObject<
EventType extends Event = Event
> = EventListener<EventType> | EventListenerObject<EventType>;
declare type R2Range =
| {
offset: number;
length?: number;
}
| {
offset?: number;
length: number;
}
| {
suffix: number;
};
declare type ReadableStreamReadResult<R = any> =
| {
done: false;
value: R;
}
| {
done: true;
value?: undefined;
};
declare type WebSocketEventMap = {
close: CloseEvent;
message: MessageEvent;
open: Event;
error: ErrorEvent;
};
declare interface Console {
"assert"(condition?: boolean, ...data: any[]): void;
clear(): void;
count(label?: string): void;
countReset(label?: string): void;
debug(...data: any[]): void;
dir(item?: any, options?: any): void;
dirxml(...data: any[]): void;
error(...data: any[]): void;
group(...data: any[]): void;
groupCollapsed(...data: any[]): void;
groupEnd(): void;
info(...data: any[]): void;
log(...data: any[]): void;
table(tabularData?: any, properties?: string[]): void;
time(label?: string): void;
timeEnd(label?: string): void;
timeLog(label?: string, ...data: any[]): void;
timeStamp(label?: string): void;
trace(...data: any[]): void;
warn(...data: any[]): void;
}
/** This ServiceWorker API interface represents the global execution context of a service worker. */
declare interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
DOMException: typeof DOMException;
WorkerGlobalScope: typeof WorkerGlobalScope;
btoa(data: string): string;
atob(param0: string): string;
setTimeout(callback: (...args: any[]) => void, msDelay?: number): number;
setTimeout<Args extends any[]>(
callback: (...args: Args) => void,
msDelay?: number,
...args: Args
): number;
clearTimeout(param0: 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(param0: number | null): void;
queueMicrotask(param0: Function): void;
structuredClone(
param0: any,
param1?: ServiceWorkerGlobalScopeStructuredCloneOptions
): any;
fetch(
param0: Request | string,
param1?: RequestInit | Request
): Promise<Response>;
self: ServiceWorkerGlobalScope;
crypto: Crypto;
caches: CacheStorage;
scheduler: Scheduler;
Event: typeof Event;
ExtendableEvent: typeof ExtendableEvent;
PromiseRejectionEvent: typeof PromiseRejectionEvent;
FetchEvent: typeof FetchEvent;
TraceEvent: typeof TraceEvent;
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;
ReadableStreamBYOBRequest: typeof ReadableStreamBYOBRequest;
ReadableStreamDefaultController: typeof ReadableStreamDefaultController;
ReadableByteStreamController: typeof ReadableByteStreamController;
WritableStreamDefaultController: typeof WritableStreamDefaultController;
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;
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;
}
declare interface ExecutionContext {
waitUntil(param0: void | Promise<void>): void;
passThroughOnException(): void;
}
declare interface ExportedHandler<Env = unknown> {
fetch?: ExportedHandlerFetchHandler<Env>;
trace?: ExportedHandlerTraceHandler<Env>;
scheduled?: ExportedHandlerScheduledHandler<Env>;
}
declare interface ServiceWorkerGlobalScopeStructuredCloneOptions {
transfer?: any[];
}
declare interface DurableObject {
fetch(request: Request): Response | Promise<Response>;
alarm?(): void | Promise<void>;
}
declare interface DurableObjectStub extends Fetcher {
readonly id: DurableObjectId;
readonly name?: string;
}
declare interface DurableObjectId {
toString(): string;
equals(param0: DurableObjectId): boolean;
readonly name?: string;
}
declare interface DurableObjectNamespace {
newUniqueId(
param0?: DurableObjectNamespaceNewUniqueIdOptions
): DurableObjectId;
idFromName(param0: string): DurableObjectId;
idFromString(param0: string): DurableObjectId;
get(param0: DurableObjectId): DurableObjectStub;
}
declare interface DurableObjectNamespaceNewUniqueIdOptions {
jurisdiction?: string;
}
declare interface ActorState {
readonly id: DurableObjectId | string;
readonly transient?: any;
readonly persistent?: DurableObjectStorage;
}
declare interface DurableObjectState {
waitUntil(param0: void | Promise<void>): void;
readonly id: DurableObjectId;
readonly storage: DurableObjectStorage;
blockConcurrencyWhile<T>(callback: () => Promise<T>): Promise<T>;
}
declare 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(
param0?: DurableObjectStorageOperationsGetAlarmOptions
): Promise<number | null>;
setAlarm(
param0: Date,
param1?: DurableObjectStorageOperationsSetAlarmOptions
): Promise<void>;
deleteAlarm(
param0?: DurableObjectStorageOperationsSetAlarmOptions
): Promise<void>;
}
declare 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(param0?: DurableObjectPutOptions): Promise<void>;
transaction<T>(
closure: (txn: DurableObjectTransaction) => Promise<T>
): Promise<T>;
getAlarm(
param0?: DurableObjectStorageOperationsGetAlarmOptions
): Promise<number | null>;
setAlarm(
param0: Date,
param1?: DurableObjectStorageOperationsSetAlarmOptions
): Promise<void>;
deleteAlarm(
param0?: DurableObjectStorageOperationsSetAlarmOptions
): Promise<void>;
sync(): Promise<void>;
}
declare interface DurableObjectListOptions {
start?: string;
startAfter?: string;
end?: string;
prefix?: string;
reverse?: boolean;
limit?: number;
allowConcurrency?: boolean;
noCache?: boolean;
}
declare interface DurableObjectGetOptions {
allowConcurrency?: boolean;
noCache?: boolean;
}
declare interface DurableObjectStorageOperationsGetAlarmOptions {
allowConcurrency?: boolean;
}
declare interface DurableObjectPutOptions {
allowConcurrency?: boolean;
allowUnconfirmed?: boolean;
noCache?: boolean;
}
declare interface DurableObjectStorageOperationsSetAlarmOptions {
allowConcurrency?: boolean;
allowUnconfirmed?: boolean;
}
declare interface AnalyticsEngine {
writeDataPoint(param0?: AnalyticsEngineAnalyticsEngineEvent): void;
}
declare interface AnalyticsEngineAnalyticsEngineEvent {
indexes?: ((ArrayBuffer | string) | null)[];
doubles?: number[];
blobs?: ((ArrayBuffer | string) | null)[];
}
declare interface EventInit {
bubbles?: boolean;
cancelable?: boolean;
composed?: boolean;
}
declare interface EventListenerObject<EventType extends Event = Event> {
handleEvent(event: EventType): void;
}
declare interface EventTargetEventListenerOptions {
capture?: boolean;
}
declare interface EventTargetAddEventListenerOptions {
capture?: boolean;
passive?: boolean;
once?: boolean;
signal?: AbortSignal;
}
declare interface EventTargetHandlerObject {
handleEvent: (param0: Event) => any | undefined;
}
declare interface Scheduler {
wait(param0: number, param1?: SchedulerWaitOptions): Promise<void>;
}
declare interface SchedulerWaitOptions {
signal?: AbortSignal;
}
declare interface BlobOptions {
type?: string;
}
declare interface FileOptions {
type?: string;
lastModified?: number;
}
declare interface CacheQueryOptions {
ignoreMethod?: boolean;
}
declare interface CryptoKeyPair {
publicKey: CryptoKey;
privateKey: CryptoKey;
}
declare 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;
}
declare interface RsaOtherPrimesInfo {
r?: string;
d?: string;
t?: string;
}
declare interface SubtleCryptoDeriveKeyAlgorithm {
name: string;
salt?: ArrayBuffer;
iterations?: number;
hash?: string | SubtleCryptoHashAlgorithm;
$public?: CryptoKey;
info?: ArrayBuffer;
}
declare interface SubtleCryptoEncryptAlgorithm {
name: string;
iv?: ArrayBuffer;
additionalData?: ArrayBuffer;
tagLength?: number;
counter?: ArrayBuffer;
length?: number;
label?: ArrayBuffer;
}
declare interface SubtleCryptoGenerateKeyAlgorithm {
name: string;
hash?: string | SubtleCryptoHashAlgorithm;
modulusLength?: number;
publicExponent?: ArrayBuffer;
length?: number;
namedCurve?: string;
}
declare interface SubtleCryptoHashAlgorithm {
name: string;
}
declare interface SubtleCryptoImportKeyAlgorithm {
name: string;
hash?: string | SubtleCryptoHashAlgorithm;
length?: number;
namedCurve?: string;
compressed?: boolean;
}
declare interface SubtleCryptoSignAlgorithm {
name: string;
hash?: string | SubtleCryptoHashAlgorithm;
dataLength?: number;
saltLength?: number;
}
declare interface CryptoKeyKeyAlgorithm {
name: string;
}
declare interface CryptoKeyAesKeyAlgorithm {
name: string;
length: number;
}
declare interface CryptoKeyHmacKeyAlgorithm {
name: string;
hash: CryptoKeyKeyAlgorithm;
length: number;
}
declare interface CryptoKeyRsaKeyAlgorithm {
name: string;
modulusLength: number;
publicExponent: ArrayBuffer;
hash?: CryptoKeyKeyAlgorithm;
}
declare interface CryptoKeyEllipticKeyAlgorithm {
name: string;
namedCurve: string;
}
declare interface CryptoKeyArbitraryKeyAlgorithm {
name: string;
hash?: CryptoKeyKeyAlgorithm;
namedCurve?: string;
length?: number;
}
declare interface TextDecoderConstructorOptions {
fatal: boolean;
ignoreBOM: boolean;
}
declare interface TextDecoderDecodeOptions {
stream: boolean;
}
declare interface TextEncoderEncodeIntoResult {
read: number;
written: number;
}
declare interface ContentOptions {
html?: boolean;
}
declare interface HTMLRewriterElementContentHandlers {
element?(element: Element): void | Promise<void>;
comments?(comment: Comment): void | Promise<void>;
text?(element: Text): void | Promise<void>;
}
declare 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>;
}
declare interface Doctype {
readonly name: string | null;
readonly publicId: string | null;
readonly systemId: string | null;
}
declare interface Element {
tagName: string;
readonly attributes: IterableIterator<string[]>;
readonly removed: boolean;
readonly namespaceURI: string;
getAttribute(param0: string): string | null;
hasAttribute(param0: string): boolean;
setAttribute(param0: string, param1: string): Element;
removeAttribute(param0: string): Element;
before(content: string, options?: ContentOptions): Element;
after(content: string, options?: ContentOptions): Element;
prepend(content: string, options?: ContentOptions): Element;
append(content: string, options?: ContentOptions): Element;
replace(content: string, options?: ContentOptions): Element;
remove(): Element;
removeAndKeepContent(): Element;
setInnerContent(content: string, options?: ContentOptions): Element;
onEndTag(handler: (tag: EndTag) => void | Promise<void>): void;
}
declare interface EndTag {
name: string;
before(content: string, options?: ContentOptions): EndTag;
after(content: string, options?: ContentOptions): EndTag;
remove(): EndTag;
}
declare 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;
}
declare interface Text {
readonly text: string;
readonly lastInTextNode: boolean;
readonly removed: boolean;
before(content: string, options?: ContentOptions): Text;
after(content: string, options?: ContentOptions): Text;
replace(content: string, options?: ContentOptions): Text;
remove(): Text;
}
declare interface DocumentEnd {
append(content: string, options?: ContentOptions): DocumentEnd;
}
declare interface ResponseInit {
status?: number;
statusText?: string;
headers?: Headers | string[][] | Record<string, string>;
cf?: any;
webSocket?: WebSocket | null;
encodeBody?: string;
}
declare interface RequestInit {
/** 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?: Headers | string[][] | Record<string, string>;
/** A BodyInit object or null to set request's body. */
body?:
| (
| ReadableStream
| string
| ArrayBuffer
| Blob
| URLSearchParams
| FormData
)
| 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?: any;
/** An AbortSignal to set request's signal. */
signal?: AbortSignal | null;
}
declare interface FetcherPutOptions {
expiration?: number;
expirationTtl?: number;
}
declare interface KVNamespaceListKey<Metadata, Key extends string = string> {
name: Key;
expiration?: number;
metadata?: Metadata;
}
declare interface KVNamespaceListResult<Metadata, Key extends string = string> {
keys: KVNamespaceListKey<Metadata, Key>[];
list_complete: boolean;
cursor?: string;
}
declare 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<string | null>;
get(
key: Key,
options?: KVNamespaceGetOptions<"stream">
): Promise<string | 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>>;
delete(key: Key): Promise<void>;
}
declare interface KVNamespaceListOptions {
limit?: number;
prefix?: string | null;
cursor?: string | null;
}
declare interface KVNamespaceGetOptions<Type> {
type: Type;
cacheTtl?: number;
}
declare interface KVNamespacePutOptions {
expiration?: number;
expirationTtl?: number;
metadata?: any | null;
}
declare interface KVNamespaceGetWithMetadataResult<Value, Metadata> {
value: Value;
metadata?: Metadata;
}
declare interface R2Error extends Error {
readonly name: string;
readonly code: number;
readonly message: string;
readonly action: string;
readonly stack: any;
}
declare interface R2ObjectBody extends R2Object {
get body(): ReadableStream;
get bodyUsed(): boolean;
arrayBuffer(): Promise<ArrayBuffer>;
text(): Promise<string>;
json<T>(): Promise<T>;
blob(): Promise<Blob>;
}
declare interface R2Conditional {
etagMatches?: string;
etagDoesNotMatch?: string;
uploadedBefore?: Date;
uploadedAfter?: Date;
secondsGranularity?: boolean;
}
declare interface R2GetOptions {
onlyIf?: R2Conditional | Headers;
range?: R2Range | Headers;
}
declare interface R2PutOptions {
onlyIf?: R2Conditional | Headers;
httpMetadata?: R2BucketHttpMetadata | Headers;
customMetadata?: Record<string, string>;
md5?: ArrayBuffer | string;
sha1?: ArrayBuffer | string;
sha256?: ArrayBuffer | string;
sha384?: ArrayBuffer | string;
sha512?: ArrayBuffer | string;
}
declare interface R2Checksums {
readonly md5?: ArrayBuffer;
readonly sha1?: ArrayBuffer;
readonly sha256?: ArrayBuffer;
readonly sha384?: ArrayBuffer;
readonly sha512?: ArrayBuffer;
toJSON(): R2StringChecksums;
}
declare interface R2StringChecksums {
md5?: string;
sha1?: string;
sha256?: string;
sha384?: string;
sha512?: string;
}
declare interface R2BucketHttpMetadata {
contentType?: string;
contentLanguage?: string;
contentDisposition?: string;
contentEncoding?: string;
cacheControl?: string;
cacheExpiry?: Date;
}
declare interface R2ListOptions {
limit?: number;
prefix?: string;
cursor?: string;
delimiter?: string;
startAfter?: string;
include?: ("httpMetadata" | "customMetadata")[];
}
declare interface R2Objects {
objects: R2Object[];
truncated: boolean;
cursor?: string;
delimitedPrefixes: string[];
}
declare interface ScheduledController {
readonly scheduledTime: number;
readonly cron: string;
noRetry(): void;
}
declare interface QueuingStrategy<T = any> {
highWaterMark?: number | bigint;
size?: (chunk: T) => number | bigint;
}
declare interface UnderlyingSink<W = any> {
type?: string;
start?: (param0: WritableStreamDefaultController) => void | Promise<void>;
write?: (
chunk: W,
controller: WritableStreamDefaultController
) => void | Promise<void>;
abort?: (param0: any) => void | Promise<void>;
close?: () => void | Promise<void>;
}
declare interface UnderlyingByteSource {
type: "bytes";
autoAllocateChunkSize?: number;
start?: (controller: ReadableByteStreamController) => void | Promise<void>;
pull?: (controller: ReadableByteStreamController) => void | Promise<void>;
cancel?: (param0: any) => void | Promise<void>;
}
declare interface UnderlyingSource<R = any> {
type?: "" | undefined;
start?: (
controller: ReadableStreamDefaultController<R>
) => void | Promise<void>;
pull?: (
controller: ReadableStreamDefaultController<R>
) => void | Promise<void>;
cancel?: (param0: any) => void | Promise<void>;
}
declare 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>;
}
declare 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;
}
/** 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. */
declare interface ReadableStream<R = any> {
cancel(reason?: any): Promise<void>;
getReader(): ReadableStreamDefaultReader<R>;
getReader(options: ReadableStreamGetReaderOptions): ReadableStreamBYOBReader;
pipeThrough<T>(
transform: ReadableWritablePair<T, R>,
options?: StreamPipeOptions
): ReadableStream<T>;
pipeTo(
destination: WritableStream<R>,
options?: StreamPipeOptions
): Promise<void>;
tee(): [ReadableStream<R>, ReadableStream<R>];
values(options?: ReadableStreamValuesOptions): AsyncIterableIterator<R>;
[Symbol.asyncIterator](
options?: ReadableStreamValuesOptions
): AsyncIterableIterator<R>;
}
declare interface ReadableStreamGetReaderOptions {
mode: "byob";
}
declare interface TransformStreamDefaultController<O = any> {
get desiredSize(): number | null;
enqueue(chunk?: O): void;
error(param0: any): void;
terminate(): void;
}
declare 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>;
}
declare interface ReadableStreamValuesOptions {
preventCancel?: boolean;
}
declare interface TextDecoderStreamTextDecoderStreamInit {
fatal?: boolean;
}
declare 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;
}
declare interface TraceItem {
readonly event:
| (
| TraceItemFetchEventInfo
| TraceItemScheduledEventInfo
| TraceItemAlarmEventInfo
)
| null;
readonly eventTimestamp: number | null;
readonly logs: TraceLog[];
readonly exceptions: TraceException[];
readonly scriptName: string | null;
readonly dispatchNamespace?: string;
readonly outcome: string;
}
declare interface TraceItemAlarmEventInfo {
readonly scheduledTime: Date;
}
declare interface TraceItemScheduledEventInfo {
readonly scheduledTime: number;
readonly cron: string;
}
declare interface TraceItemFetchEventInfo {
readonly response?: TraceItemFetchEventInfoResponse;
readonly request: TraceItemFetchEventInfoRequest;
}
declare interface TraceItemFetchEventInfoRequest {
readonly cf?: any;
readonly headers: Record<string, string>;
readonly method: string;
readonly url: string;
getUnredacted(): TraceItemFetchEventInfoRequest;
}
declare interface TraceItemFetchEventInfoResponse {
readonly status: number;
}
declare interface TraceLog {
readonly timestamp: number;
readonly level: string;
readonly message: any;
}
declare interface TraceException {
readonly timestamp: number;
readonly message: string;
readonly name: string;
}
declare interface TraceMetrics {
readonly cpuTime: number;
readonly wallTime: number;
}
declare interface UnsafeTraceMetrics {
fromTrace(param0: TraceItem): TraceMetrics;
}
declare interface URLPatternURLPatternInit {
protocol?: string;
username?: string;
password?: string;
hostname?: string;
port?: string;
pathname?: string;
search?: string;
hash?: string;
baseURL?: string;
}
declare interface URLPatternURLPatternComponentResult {
input: string;
groups: Record<string, string>;
}
declare interface URLPatternURLPatternResult {
inputs: (string | URLPatternURLPatternInit)[];
protocol: URLPatternURLPatternComponentResult;
username: URLPatternURLPatternComponentResult;
password: URLPatternURLPatternComponentResult;
hostname: URLPatternURLPatternComponentResult;
port: URLPatternURLPatternComponentResult;
pathname: URLPatternURLPatternComponentResult;
search: URLPatternURLPatternComponentResult;
hash: URLPatternURLPatternComponentResult;
}
declare interface CloseEventInit {
code?: number;
reason?: string;
wasClean?: boolean;
}
declare interface MessageEventInit {
data: ArrayBuffer | string;
}
/** Events providing information related to errors in scripts or in files. */
declare interface ErrorEvent extends Event {
readonly filename: string;
readonly message: string;
readonly lineno: number;
readonly colno: number;
readonly error: any;
}
declare var console: Console;
declare var self: ServiceWorkerGlobalScope;
declare var crypto: Crypto;
declare var caches: CacheStorage;
declare var scheduler: Scheduler;
declare var navigator: Navigator;
declare var ReadableStream: {
prototype: ReadableStream;
new (
underlyingSource: UnderlyingByteSource,
strategy?: QueuingStrategy<Uint8Array>
): ReadableStream<Uint8Array>;
new <R = any>(
underlyingSource?: UnderlyingSource<R>,
strategy?: QueuingStrategy<R>
): ReadableStream<R>;
};
declare var WebSocketPair: {
new (): {
0: WebSocket;
1: WebSocket;
};
};
/* eslint-disable */
// noinspection JSUnusedGlobalSymbols
/** An abnormal event (called an exception) which occurs as a result of calling a method or accessing a property of a web API. */
export declare class DOMException extends Error {
constructor(param0?: string, param1?: string);
readonly message: string;
readonly name: string;
readonly code: number;
readonly stack: any;
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;
}
/** This Web Workers API interface is an interface representing the scope of any worker. Workers have no browsing context; this scope contains the information usually conveyed by Window objects — in this case event handlers, the console or the associated WorkerNavigator object. Each WorkerGlobalScope has its own event loop. */
export declare abstract class WorkerGlobalScope extends EventTarget<WorkerGlobalScopeEventMap> {
EventTarget: typeof EventTarget;
}
export declare abstract class PromiseRejectionEvent extends Event {
readonly promise: Promise<any>;
readonly reason: any;
}
export declare abstract class Navigator {
readonly userAgent: string;
}
/** An event which takes place in the DOM. */
export declare class Event {
constructor(param0: string, param1?: EventInit);
/** Returns the type of event, e.g. "click", "hashchange", or "submit". */
get type(): string;
/** Returns the event's phase, which is one of NONE, CAPTURING_PHASE, AT_TARGET, and BUBBLING_PHASE. */
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. */
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. */
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. */
get cancelable(): boolean;
/** Returns true if preventDefault() was invoked successfully to indicate cancelation, and false otherwise. */
get defaultPrevented(): boolean;
/** @deprecated */
get returnValue(): boolean;
/** Returns the object whose event listener's callback is currently being invoked. */
get currentTarget(): EventTarget | undefined;
/** @deprecated */
get srcElement(): EventTarget | undefined;
/** Returns the event's timestamp as the number of milliseconds measured relative to the time origin. */
get timeStamp(): number;
/** Returns true if event was dispatched by the user agent, and false otherwise. */
get isTrusted(): boolean;
get cancelBubble(): boolean;
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. */
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. */
preventDefault(): void;
/** When dispatched in a tree, invoking this method prevents event from reaching any objects other than the current object. */
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. */
composedPath(): EventTarget[];
static readonly NONE: number;
static readonly CAPTURING_PHASE: number;
static readonly AT_TARGET: number;
static readonly BUBBLING_PHASE: number;
}
/** EventTarget is a DOM interface implemented by objects that can receive events and may have listeners for them. */
export 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.
*/
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. */
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. */
dispatchEvent(event: EventMap[keyof EventMap]): boolean;
}
/** A controller object that allows you to abort one or more DOM requests as and when desired. */
export declare class AbortController {
constructor();
/** Returns the AbortSignal object associated with this object. */
get signal(): AbortSignal;
abort(param0?: any): void;
}
/** 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. */
export declare abstract class AbortSignal extends EventTarget {
static abort(param0?: any): AbortSignal;
static timeout(param0: number): AbortSignal;
/** Returns true if this AbortSignal's AbortController has signaled to abort, and false otherwise. */
get aborted(): boolean;
get reason(): any;
throwIfAborted(): void;
}
/** 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. */
export declare abstract class ExtendableEvent extends Event {
waitUntil(param0: void | Promise<void>): void;
}
/** 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. */
export declare class Blob {
constructor(
param0?: ((ArrayBuffer | ArrayBufferView) | string | Blob)[],
param1?: BlobOptions
);
get size(): number;
get type(): string;
slice(param0?: number, param1?: number, param2?: string): Blob;
arrayBuffer(): Promise<ArrayBuffer>;
text(): Promise<string>;
stream(): ReadableStream;
}
/** Provides information about files and allows JavaScript in a web page to access their content. */
export declare class File extends Blob {
constructor(
param0: ((ArrayBuffer | ArrayBufferView) | string | Blob)[] | undefined,
param1: string,
param2?: FileOptions
);
get name(): string;
get lastModified(): number;
}
/**
* The storage for Cache objects.
* Available only in secure contexts.
*/
export declare abstract class CacheStorage {
open(param0: string): Promise<Cache>;
readonly default: Cache;
}
/**
* Provides a storage mechanism for Request / Response object pairs that are cached, for example as part of the ServiceWorker life cycle. Note that the Cache interface is exposed to windowed scopes as well as workers. You don't have to use it in conjunction with service workers, even though it is defined in the service worker spec.
* Available only in secure contexts.
*/
export declare abstract class Cache {
delete(
param0: Request | string,
param1?: CacheQueryOptions
): Promise<boolean>;
match(
param0: Request | string,
param1?: CacheQueryOptions
): Promise<Response | undefined>;
put(param0: Request | string, param1: Response): Promise<void>;
}
/** Basic cryptography features available in the current context. It allows access to a cryptographically strong random number generator and to cryptographic primitives. */
export declare abstract class Crypto {
/** Available only in secure contexts. */
get subtle(): SubtleCrypto;
getRandomValues<
T extends
| Int8Array
| Uint8Array
| Int16Array
| Uint16Array
| Int32Array
| Uint32Array
| BigInt64Array
| BigUint64Array
>(buffer: T): T;
/** Available only in secure contexts. */
randomUUID(): string;
DigestStream: typeof DigestStream;
}
/**
* 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.
*/
export declare abstract class SubtleCrypto {
encrypt(
param0: string | SubtleCryptoEncryptAlgorithm,
param1: CryptoKey,
param2: ArrayBuffer | ArrayBufferView
): Promise<ArrayBuffer>;
decrypt(
param0: string | SubtleCryptoEncryptAlgorithm,
param1: CryptoKey,
param2: ArrayBuffer | ArrayBufferView
): Promise<ArrayBuffer>;
sign(
param0: string | SubtleCryptoSignAlgorithm,
param1: CryptoKey,
param2: ArrayBuffer | ArrayBufferView
): Promise<ArrayBuffer>;
verify(
param0: string | SubtleCryptoSignAlgorithm,
param1: CryptoKey,
param2: ArrayBuffer | ArrayBufferView,
param3: ArrayBuffer | ArrayBufferView
): Promise<boolean>;
digest(
param0: string | SubtleCryptoHashAlgorithm,
param1: ArrayBuffer | ArrayBufferView
): Promise<ArrayBuffer>;
generateKey(
param0: string | SubtleCryptoGenerateKeyAlgorithm,
param1: boolean,
param2: string[]
): Promise<CryptoKey | CryptoKeyPair>;
deriveKey(
param0: string | SubtleCryptoDeriveKeyAlgorithm,
param1: CryptoKey,
param2: string | SubtleCryptoImportKeyAlgorithm,
param3: boolean,
param4: string[]
): Promise<CryptoKey>;
deriveBits(
param0: string | SubtleCryptoDeriveKeyAlgorithm,
param1: CryptoKey,
param2: number | null
): Promise<ArrayBuffer>;
importKey(
param0: string,
param1: (ArrayBuffer | ArrayBufferView) | JsonWebKey,
param2: string | SubtleCryptoImportKeyAlgorithm,
param3: boolean,
param4: string[]
): Promise<CryptoKey>;
exportKey(
param0: string,
param1: CryptoKey
): Promise<ArrayBuffer | JsonWebKey>;
wrapKey(
param0: string,
param1: CryptoKey,
param2: CryptoKey,
param3: string | SubtleCryptoEncryptAlgorithm
): Promise<ArrayBuffer>;
unwrapKey(
param0: string,
param1: ArrayBuffer | ArrayBufferView,
param2: CryptoKey,
param3: string | SubtleCryptoEncryptAlgorithm,
param4: string | SubtleCryptoImportKeyAlgorithm,
param5: boolean,
param6: string[]
): Promise<CryptoKey>;
timingSafeEqual(
param0: ArrayBuffer | ArrayBufferView,
param1: ArrayBuffer | ArrayBufferView
): boolean;
}
/**
* The CryptoKey dictionary of the Web Crypto API represents a cryptographic key.
* Available only in secure contexts.
*/
export declare abstract class CryptoKey {
readonly type: string;
readonly extractable: boolean;
readonly algorithm:
| CryptoKeyKeyAlgorithm
| CryptoKeyAesKeyAlgorithm
| CryptoKeyHmacKeyAlgorithm
| CryptoKeyRsaKeyAlgorithm
| CryptoKeyEllipticKeyAlgorithm
| CryptoKeyArbitraryKeyAlgorithm;
readonly usages: string[];
}
export declare class DigestStream extends WritableStream<
ArrayBuffer | ArrayBufferView
> {
constructor(param0: string | SubtleCryptoHashAlgorithm);
get digest(): Promise<ArrayBuffer>;
}
/** 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. */
export declare class TextDecoder {
constructor(param0?: string, param1?: 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.
*/
decode(
param0?: ArrayBuffer | ArrayBufferView,
param1?: TextDecoderDecodeOptions
): string;
get encoding(): string;
get fatal(): boolean;
get ignoreBOM(): boolean;
}
/** 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. */
export declare class TextEncoder {
constructor();
/** Returns the result of running UTF-8's encoder. */
encode(param0?: 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. */
encodeInto(param0: string, param1: Uint8Array): TextEncoderEncodeIntoResult;
get encoding(): string;
}
/** 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". */
export declare class FormData {
constructor();
append(name: string, value: string): void;
append(name: string, value: Blob, filename?: string): void;
delete(param0: string): void;
get(param0: string): (File | string) | null;
getAll(param0: string): (File | string)[];
has(param0: string): boolean;
set(name: string, value: string): void;
set(name: string, value: Blob, filename?: string): void;
entries(): IterableIterator<[key: string, value: File | string]>;
keys(): IterableIterator<string>;
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]>;
}
export declare class HTMLRewriter {
constructor();
on(param0: string, param1: HTMLRewriterElementContentHandlers): HTMLRewriter;
onDocument(param0: HTMLRewriterDocumentContentHandlers): HTMLRewriter;
transform(param0: Response): Response;
}
/** 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. */
export declare abstract class FetchEvent extends ExtendableEvent {
readonly request: Request;
respondWith(param0: Response | Promise<Response>): void;
passThroughOnException(): void;
}
/** 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. */
export declare class Headers {
constructor(
init?: Headers | Record<string, string> | [key: string, value: string][]
);
get(param0: string): string | null;
getAll(param0: string): string[];
has(param0: string): boolean;
set(param0: string, param1: string): void;
append(param0: string, param1: string): void;
delete(param0: string): void;
forEach<This = unknown>(
callback: (this: This, value: string, key: string, parent: Headers) => void,
thisArg?: This
): void;
entries(): IterableIterator<[key: string, value: string]>;
keys(): IterableIterator<string>;
values(): IterableIterator<string>;
[Symbol.iterator](): IterableIterator<[key: string, value: string]>;
}
export declare abstract class Body {
get body(): ReadableStream | null;
get bodyUsed(): boolean;
arrayBuffer(): Promise<ArrayBuffer>;
text(): Promise<string>;
json<T>(): Promise<T>;
formData(): Promise<FormData>;
blob(): Promise<Blob>;
}
/** This Fetch API interface represents the response to a request. */
export declare class Response extends Body {
constructor(
param0?:
| (
| ReadableStream
| string
| (ArrayBuffer | ArrayBufferView)
| Blob
| URLSearchParams
| FormData
)
| null,
param1?: ResponseInit | Response
);
static redirect(param0: string, param1?: number): Response;
static json(param0: any, param1?: ResponseInit | Response): Response;
clone(): Response;
get status(): number;
get statusText(): string;
get headers(): Headers;
get ok(): boolean;
get redirected(): boolean;
get url(): string;
get webSocket(): WebSocket | null;
get cf(): any | undefined;
}
/** This Fetch API interface represents a resource request. */
export declare class Request extends Body {
constructor(param0: Request | string, param1?: RequestInit | Request);
clone(): Request;
/** Returns request's HTTP method, which is "GET" by default. */
get method(): string;
/** Returns the URL of request as a string. */
get 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. */
get 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. */
get redirect(): string;
get 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. */
get signal(): AbortSignal;
get cf(): any | undefined;
}
export declare abstract class Fetcher {
fetch(
param0: Request | string,
param1?: RequestInit | Request
): Promise<Response>;
}
export declare abstract class R2Bucket {
head(param0: 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
): Promise<R2Object>;
delete(param0: string | string[]): Promise<void>;
list(param0?: R2ListOptions): Promise<R2Objects>;
}
export 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?: R2BucketHttpMetadata;
readonly customMetadata?: Record<string, string>;
readonly range?: R2Range;
writeHttpMetadata(param0: Headers): void;
}
export declare abstract class ScheduledEvent extends ExtendableEvent {
readonly scheduledTime: number;
readonly cron: string;
noRetry(): void;
}
export declare class ReadableStreamDefaultReader<R = any> {
constructor(param0: ReadableStream);
get closed(): Promise<void>;
cancel(param0?: any): Promise<void>;
read(): Promise<ReadableStreamReadResult<R>>;
releaseLock(): void;
}
export declare class ReadableStreamBYOBReader {
constructor(param0: ReadableStream);
get closed(): Promise<void>;
cancel(param0?: any): Promise<void>;
read<T extends ArrayBufferView>(
view: T
): Promise<ReadableStreamReadResult<T>>;
releaseLock(): void;
readAtLeast(
minBytes: number,
view: Uint8Array
): Promise<ReadableStreamReadResult<Uint8Array>>;
}
export declare abstract class ReadableStreamBYOBRequest {
readonly view: Uint8Array | null;
respond(param0: number): void;
respondWithNewView(param0: ArrayBuffer | ArrayBufferView): void;
readonly atLeast: number | null;
}
export declare abstract class ReadableStreamDefaultController<R = any> {
readonly desiredSize: number | null;
close(): void;
enqueue(chunk?: R): void;
error(param0: any): void;
}
export declare abstract class ReadableByteStreamController {
readonly byobRequest: ReadableStreamBYOBRequest | null;
readonly desiredSize: number | null;
close(): void;
enqueue(param0: ArrayBuffer | ArrayBufferView): void;
error(param0: any): void;
}
/** 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. */
export declare abstract class WritableStreamDefaultController {
readonly signal: AbortSignal;
error(param0?: any): void;
}
/** 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. */
export declare class WritableStream<W = any> {
constructor(param0?: UnderlyingSink, param1?: QueuingStrategy);
get locked(): boolean;
abort(param0?: any): Promise<void>;
close(): Promise<void>;
getWriter(): WritableStreamDefaultWriter<W>;
}
/** 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. */
export declare class WritableStreamDefaultWriter<W = any> {
constructor(param0: WritableStream);
get closed(): Promise<void>;
get ready(): Promise<void>;
get desiredSize(): number | null;
abort(param0?: any): Promise<void>;
close(): Promise<void>;
write(chunk?: W): Promise<void>;
releaseLock(): void;
}
export declare class TransformStream<I = any, O = any> {
constructor(
transformer?: Transformer<I, O>,
writableStrategy?: QueuingStrategy<I>,
readableStrategy?: QueuingStrategy<O>
);
get readable(): ReadableStream<O>;
get writable(): WritableStream<I>;
}
export declare class FixedLengthStream extends IdentityTransformStream {
constructor(param0: number | bigint);
}
export declare class IdentityTransformStream extends TransformStream<
ArrayBuffer | ArrayBufferView,
Uint8Array
> {
constructor();
}
export declare class CompressionStream extends TransformStream<
ArrayBuffer | ArrayBufferView,
Uint8Array
> {
constructor(format: "gzip" | "deflate");
}
export declare class DecompressionStream extends TransformStream<
ArrayBuffer | ArrayBufferView,
Uint8Array
> {
constructor(format: "gzip" | "deflate");
}
export declare class TextEncoderStream extends TransformStream<
string,
Uint8Array
> {
constructor();
}
export declare class TextDecoderStream extends TransformStream<
ArrayBuffer | ArrayBufferView,
string
> {
constructor(param0?: string, param1?: TextDecoderStreamTextDecoderStreamInit);
}
/** This Streams API interface provides a built-in byte length queuing strategy that can be used when constructing streams. */
export declare class ByteLengthQueuingStrategy
implements QueuingStrategy<ArrayBufferView>
{
constructor(param0: QueuingStrategyInit);
get highWaterMark(): number;
get size(): (chunk?: any) => number;
}
/** This Streams API interface provides a built-in byte length queuing strategy that can be used when constructing streams. */
export declare class CountQueuingStrategy implements QueuingStrategy {
constructor(param0: QueuingStrategyInit);
get highWaterMark(): number;
get size(): (chunk?: any) => number;
}
export declare abstract class TraceEvent extends ExtendableEvent {
readonly traces: TraceItem[];
}
/** The URL interface represents an object providing static methods used for creating object URLs. */
export declare class URL {
constructor(param0: string, param1?: string);
get origin(): string;
get href(): string;
set href(value: string);
get protocol(): string;
set protocol(value: string);
get username(): string;
set username(value: string);
get password(): string;
set password(value: string);
get host(): string;
set host(value: string);
get hostname(): string;
set hostname(value: string);
get port(): string;
set port(value: string);
get pathname(): string;
set pathname(value: string);
get search(): string;
set search(value: string);
get hash(): string;
set hash(value: string);
get searchParams(): URLSearchParams;
toJSON(): string;
toString(): string;
}
export declare class URLSearchParams {
constructor(
param0?: Iterable<Iterable<string>> | Record<string, string> | string
);
/** Appends a specified key/value pair as a new search parameter. */
append(param0: string, param1: string): void;
/** Deletes the given search parameter, and its associated value, from the list of all search parameters. */
delete(param0: string): void;
/** Returns the first value associated to the given search parameter. */
get(param0: string): string | null;
/** Returns all the values association with a given search parameter. */
getAll(param0: string): string[];
/** Returns a Boolean indicating if such a search parameter exists. */
has(param0: string): boolean;
/** Sets the value associated to a given search parameter to the given value. If there were several values, delete the others. */
set(param0: string, param1: string): void;
sort(): void;
entries(): IterableIterator<[key: string, value: string]>;
keys(): IterableIterator<string>;
values(): IterableIterator<string>;
forEach<This = unknown>(
callback: (
this: This,
value: string,
key: string,
parent: URLSearchParams
) => void,
thisArg?: This
): void;
/** 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]>;
}
export declare class URLPattern {
constructor(param0?: string | URLPatternURLPatternInit, param1?: string);
get protocol(): string;
get username(): string;
get password(): string;
get hostname(): string;
get port(): string;
get pathname(): string;
get search(): string;
get hash(): string;
test(param0?: string | URLPatternURLPatternInit, param1?: string): boolean;
exec(
param0?: string | URLPatternURLPatternInit,
param1?: string
): URLPatternURLPatternResult | null;
}
/** 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. */
export declare class CloseEvent extends Event {
constructor(param0: string, param1: CloseEventInit);
/** Returns the WebSocket connection close code provided by the server. */
readonly code: number;
/** Returns the WebSocket connection close reason provided by the server. */
readonly reason: string;
/** Returns true if the connection closed cleanly; false otherwise. */
readonly wasClean: boolean;
}
/** A message received by a target object. */
export declare class MessageEvent extends Event {
constructor(param0: string, param1: MessageEventInit);
/** Returns the data of the message. */
readonly data: ArrayBuffer | string;
}
/** Provides the API for creating and managing a WebSocket connection to a server, as well as for sending and receiving data on the connection. */
export declare class WebSocket extends EventTarget<WebSocketEventMap> {
constructor(param0: string, param1?: string[] | string);
accept(): void;
/** Transmits data using the WebSocket connection. data can be a string, a Blob, an ArrayBuffer, or an ArrayBufferView. */
send(param0: (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. */
close(param0?: number, param1?: string): void;
static readonly READY_STATE_CONNECTING: number;
static readonly READY_STATE_OPEN: number;
static readonly READY_STATE_CLOSING: number;
static readonly READY_STATE_CLOSED: number;
/** Returns the state of the WebSocket object's connection. It can have the values described below. */
get readyState(): number;
/** Returns the URL that was used to establish the WebSocket connection. */
get 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. */
get protocol(): string | null;
/** Returns the extensions selected by the server, if any. */
get extensions(): string | null;
}
export declare function addEventListener<
Type extends keyof WorkerGlobalScopeEventMap
>(
type: Type,
handler: EventListenerOrEventListenerObject<WorkerGlobalScopeEventMap[Type]>,
options?: EventTargetAddEventListenerOptions | boolean
): void;
export declare function removeEventListener<
Type extends keyof WorkerGlobalScopeEventMap
>(
type: Type,
handler: EventListenerOrEventListenerObject<WorkerGlobalScopeEventMap[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. */
export declare function dispatchEvent(
event: WorkerGlobalScopeEventMap[keyof WorkerGlobalScopeEventMap]
): boolean;
export declare function btoa(data: string): string;
export declare function atob(param0: string): string;
export declare function setTimeout<Args extends any[]>(
callback: (...args: Args) => void,
msDelay?: number,
...args: Args
): number;
export declare function clearTimeout(param0: number | null): void;
export declare function setInterval<Args extends any[]>(
callback: (...args: Args) => void,
msDelay?: number,
...args: Args
): number;
export declare function clearInterval(param0: number | null): void;
export declare function queueMicrotask(param0: Function): void;
export declare function structuredClone(
param0: any,
param1?: ServiceWorkerGlobalScopeStructuredCloneOptions
): any;
export declare function fetch(
param0: Request | string,
param1?: RequestInit | Request
): Promise<Response>;
export declare type WorkerGlobalScopeEventMap = {
fetch: FetchEvent;
scheduled: ScheduledEvent;
unhandledrejection: PromiseRejectionEvent;
rejectionhandled: PromiseRejectionEvent;
};
export declare type ExportedHandlerFetchHandler<Env = unknown> = (
request: Request,
env: Env,
ctx: ExecutionContext
) => Response | Promise<Response>;
export declare type ExportedHandlerTraceHandler<Env = unknown> = (
traces: TraceItem[],
env: Env,
ctx: ExecutionContext
) => void | Promise<void>;
export declare type ExportedHandlerScheduledHandler<Env = unknown> = (
controller: ScheduledController,
env: Env,
ctx: ExecutionContext
) => void | Promise<void>;
export declare type EventListener<EventType extends Event = Event> = (
event: EventType
) => void;
export declare type EventListenerOrEventListenerObject<
EventType extends Event = Event
> = EventListener<EventType> | EventListenerObject<EventType>;
export declare type R2Range =
| {
offset: number;
length?: number;
}
| {
offset?: number;
length: number;
}
| {
suffix: number;
};
export declare type ReadableStreamReadResult<R = any> =
| {
done: false;
value: R;
}
| {
done: true;
value?: undefined;
};
export declare type WebSocketEventMap = {
close: CloseEvent;
message: MessageEvent;
open: Event;
error: ErrorEvent;
};
export interface Console {
"assert"(condition?: boolean, ...data: any[]): void;
clear(): void;
count(label?: string): void;
countReset(label?: string): void;
debug(...data: any[]): void;
dir(item?: any, options?: any): void;
dirxml(...data: any[]): void;
error(...data: any[]): void;
group(...data: any[]): void;
groupCollapsed(...data: any[]): void;
groupEnd(): void;
info(...data: any[]): void;
log(...data: any[]): void;
table(tabularData?: any, properties?: string[]): void;
time(label?: string): void;
timeEnd(label?: string): void;
timeLog(label?: string, ...data: any[]): void;
timeStamp(label?: string): void;
trace(...data: any[]): void;
warn(...data: any[]): void;
}
/** This ServiceWorker API interface represents the global execution context of a service worker. */
export interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
DOMException: typeof DOMException;
WorkerGlobalScope: typeof WorkerGlobalScope;
btoa(data: string): string;
atob(param0: string): string;
setTimeout(callback: (...args: any[]) => void, msDelay?: number): number;
setTimeout<Args extends any[]>(
callback: (...args: Args) => void,
msDelay?: number,
...args: Args
): number;
clearTimeout(param0: 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(param0: number | null): void;
queueMicrotask(param0: Function): void;
structuredClone(
param0: any,
param1?: ServiceWorkerGlobalScopeStructuredCloneOptions
): any;
fetch(
param0: Request | string,
param1?: RequestInit | Request
): Promise<Response>;
self: ServiceWorkerGlobalScope;
crypto: Crypto;
caches: CacheStorage;
scheduler: Scheduler;
Event: typeof Event;
ExtendableEvent: typeof ExtendableEvent;
PromiseRejectionEvent: typeof PromiseRejectionEvent;
FetchEvent: typeof FetchEvent;
TraceEvent: typeof TraceEvent;
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;
ReadableStreamBYOBRequest: typeof ReadableStreamBYOBRequest;
ReadableStreamDefaultController: typeof ReadableStreamDefaultController;
ReadableByteStreamController: typeof ReadableByteStreamController;
WritableStreamDefaultController: typeof WritableStreamDefaultController;
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;
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;
}
export interface ExecutionContext {
waitUntil(param0: void | Promise<void>): void;
passThroughOnException(): void;
}
export interface ExportedHandler<Env = unknown> {
fetch?: ExportedHandlerFetchHandler<Env>;
trace?: ExportedHandlerTraceHandler<Env>;
scheduled?: ExportedHandlerScheduledHandler<Env>;
}
export interface ServiceWorkerGlobalScopeStructuredCloneOptions {
transfer?: any[];
}
export interface DurableObject {
fetch(request: Request): Response | Promise<Response>;
alarm?(): void | Promise<void>;
}
export interface DurableObjectStub extends Fetcher {
readonly id: DurableObjectId;
readonly name?: string;
}
export interface DurableObjectId {
toString(): string;
equals(param0: DurableObjectId): boolean;
readonly name?: string;
}
export interface DurableObjectNamespace {
newUniqueId(
param0?: DurableObjectNamespaceNewUniqueIdOptions
): DurableObjectId;
idFromName(param0: string): DurableObjectId;
idFromString(param0: string): DurableObjectId;
get(param0: DurableObjectId): DurableObjectStub;
}
export interface DurableObjectNamespaceNewUniqueIdOptions {
jurisdiction?: string;
}
export interface ActorState {
readonly id: DurableObjectId | string;
readonly transient?: any;
readonly persistent?: DurableObjectStorage;
}
export interface DurableObjectState {
waitUntil(param0: void | Promise<void>): void;
readonly id: DurableObjectId;
readonly storage: DurableObjectStorage;
blockConcurrencyWhile<T>(callback: () => Promise<T>): Promise<T>;
}
export 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(
param0?: DurableObjectStorageOperationsGetAlarmOptions
): Promise<number | null>;
setAlarm(
param0: Date,
param1?: DurableObjectStorageOperationsSetAlarmOptions
): Promise<void>;
deleteAlarm(
param0?: DurableObjectStorageOperationsSetAlarmOptions
): Promise<void>;
}
export 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(param0?: DurableObjectPutOptions): Promise<void>;
transaction<T>(
closure: (txn: DurableObjectTransaction) => Promise<T>
): Promise<T>;
getAlarm(
param0?: DurableObjectStorageOperationsGetAlarmOptions
): Promise<number | null>;
setAlarm(
param0: Date,
param1?: DurableObjectStorageOperationsSetAlarmOptions
): Promise<void>;
deleteAlarm(
param0?: DurableObjectStorageOperationsSetAlarmOptions
): Promise<void>;
sync(): Promise<void>;
}
export interface DurableObjectListOptions {
start?: string;
startAfter?: string;
end?: string;
prefix?: string;
reverse?: boolean;
limit?: number;
allowConcurrency?: boolean;
noCache?: boolean;
}
export interface DurableObjectGetOptions {
allowConcurrency?: boolean;
noCache?: boolean;
}
export interface DurableObjectStorageOperationsGetAlarmOptions {
allowConcurrency?: boolean;
}
export interface DurableObjectPutOptions {
allowConcurrency?: boolean;
allowUnconfirmed?: boolean;
noCache?: boolean;
}
export interface DurableObjectStorageOperationsSetAlarmOptions {
allowConcurrency?: boolean;
allowUnconfirmed?: boolean;
}
export interface AnalyticsEngine {
writeDataPoint(param0?: AnalyticsEngineAnalyticsEngineEvent): void;
}
export interface AnalyticsEngineAnalyticsEngineEvent {
indexes?: ((ArrayBuffer | string) | null)[];
doubles?: number[];
blobs?: ((ArrayBuffer | string) | null)[];
}
export interface EventInit {
bubbles?: boolean;
cancelable?: boolean;
composed?: boolean;
}
export interface EventListenerObject<EventType extends Event = Event> {
handleEvent(event: EventType): void;
}
export interface EventTargetEventListenerOptions {
capture?: boolean;
}
export interface EventTargetAddEventListenerOptions {
capture?: boolean;
passive?: boolean;
once?: boolean;
signal?: AbortSignal;
}
export interface EventTargetHandlerObject {
handleEvent: (param0: Event) => any | undefined;
}
export interface Scheduler {
wait(param0: number, param1?: SchedulerWaitOptions): Promise<void>;
}
export interface SchedulerWaitOptions {
signal?: AbortSignal;
}
export interface BlobOptions {
type?: string;
}
export interface FileOptions {
type?: string;
lastModified?: number;
}
export interface CacheQueryOptions {
ignoreMethod?: boolean;
}
export interface CryptoKeyPair {
publicKey: CryptoKey;
privateKey: CryptoKey;
}
export 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;
}
export interface RsaOtherPrimesInfo {
r?: string;
d?: string;
t?: string;
}
export interface SubtleCryptoDeriveKeyAlgorithm {
name: string;
salt?: ArrayBuffer;
iterations?: number;
hash?: string | SubtleCryptoHashAlgorithm;
$public?: CryptoKey;
info?: ArrayBuffer;
}
export interface SubtleCryptoEncryptAlgorithm {
name: string;
iv?: ArrayBuffer;
additionalData?: ArrayBuffer;
tagLength?: number;
counter?: ArrayBuffer;
length?: number;
label?: ArrayBuffer;
}
export interface SubtleCryptoGenerateKeyAlgorithm {
name: string;
hash?: string | SubtleCryptoHashAlgorithm;
modulusLength?: number;
publicExponent?: ArrayBuffer;
length?: number;
namedCurve?: string;
}
export interface SubtleCryptoHashAlgorithm {
name: string;
}
export interface SubtleCryptoImportKeyAlgorithm {
name: string;
hash?: string | SubtleCryptoHashAlgorithm;
length?: number;
namedCurve?: string;
compressed?: boolean;
}
export interface SubtleCryptoSignAlgorithm {
name: string;
hash?: string | SubtleCryptoHashAlgorithm;
dataLength?: number;
saltLength?: number;
}
export interface CryptoKeyKeyAlgorithm {
name: string;
}
export interface CryptoKeyAesKeyAlgorithm {
name: string;
length: number;
}
export interface CryptoKeyHmacKeyAlgorithm {
name: string;
hash: CryptoKeyKeyAlgorithm;
length: number;
}
export interface CryptoKeyRsaKeyAlgorithm {
name: string;
modulusLength: number;
publicExponent: ArrayBuffer;
hash?: CryptoKeyKeyAlgorithm;
}
export interface CryptoKeyEllipticKeyAlgorithm {
name: string;
namedCurve: string;
}
export interface CryptoKeyArbitraryKeyAlgorithm {
name: string;
hash?: CryptoKeyKeyAlgorithm;
namedCurve?: string;
length?: number;
}
export interface TextDecoderConstructorOptions {
fatal: boolean;
ignoreBOM: boolean;
}
export interface TextDecoderDecodeOptions {
stream: boolean;
}
export interface TextEncoderEncodeIntoResult {
read: number;
written: number;
}
export interface ContentOptions {
html?: boolean;
}
export interface HTMLRewriterElementContentHandlers {
element?(element: Element): void | Promise<void>;
comments?(comment: Comment): void | Promise<void>;
text?(element: Text): void | Promise<void>;
}
export 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>;
}
export interface Doctype {
readonly name: string | null;
readonly publicId: string | null;
readonly systemId: string | null;
}
export interface Element {
tagName: string;
readonly attributes: IterableIterator<string[]>;
readonly removed: boolean;
readonly namespaceURI: string;
getAttribute(param0: string): string | null;
hasAttribute(param0: string): boolean;
setAttribute(param0: string, param1: string): Element;
removeAttribute(param0: string): Element;
before(content: string, options?: ContentOptions): Element;
after(content: string, options?: ContentOptions): Element;
prepend(content: string, options?: ContentOptions): Element;
append(content: string, options?: ContentOptions): Element;
replace(content: string, options?: ContentOptions): Element;
remove(): Element;
removeAndKeepContent(): Element;
setInnerContent(content: string, options?: ContentOptions): Element;
onEndTag(handler: (tag: EndTag) => void | Promise<void>): void;
}
export interface EndTag {
name: string;
before(content: string, options?: ContentOptions): EndTag;
after(content: string, options?: ContentOptions): EndTag;
remove(): EndTag;
}
export 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;
}
export interface Text {
readonly text: string;
readonly lastInTextNode: boolean;
readonly removed: boolean;
before(content: string, options?: ContentOptions): Text;
after(content: string, options?: ContentOptions): Text;
replace(content: string, options?: ContentOptions): Text;
remove(): Text;
}
export interface DocumentEnd {
append(content: string, options?: ContentOptions): DocumentEnd;
}
export interface ResponseInit {
status?: number;
statusText?: string;
headers?: Headers | string[][] | Record<string, string>;
cf?: any;
webSocket?: WebSocket | null;
encodeBody?: string;
}
export interface RequestInit {
/** 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?: Headers | string[][] | Record<string, string>;
/** A BodyInit object or null to set request's body. */
body?:
| (
| ReadableStream
| string
| ArrayBuffer
| Blob
| URLSearchParams
| FormData
)
| 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?: any;
/** An AbortSignal to set request's signal. */
signal?: AbortSignal | null;
}
export interface FetcherPutOptions {
expiration?: number;
expirationTtl?: number;
}
export interface KVNamespaceListKey<Metadata, Key extends string = string> {
name: Key;
expiration?: number;
metadata?: Metadata;
}
export interface KVNamespaceListResult<Metadata, Key extends string = string> {
keys: KVNamespaceListKey<Metadata, Key>[];
list_complete: boolean;
cursor?: string;
}
export 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<string | null>;
get(
key: Key,
options?: KVNamespaceGetOptions<"stream">
): Promise<string | 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>>;
delete(key: Key): Promise<void>;
}
export interface KVNamespaceListOptions {
limit?: number;
prefix?: string | null;
cursor?: string | null;
}
export interface KVNamespaceGetOptions<Type> {
type: Type;
cacheTtl?: number;
}
export interface KVNamespacePutOptions {
expiration?: number;
expirationTtl?: number;
metadata?: any | null;
}
export interface KVNamespaceGetWithMetadataResult<Value, Metadata> {
value: Value;
metadata?: Metadata;
}
export interface R2Error extends Error {
readonly name: string;
readonly code: number;
readonly message: string;
readonly action: string;
readonly stack: any;
}
export interface R2ObjectBody extends R2Object {
get body(): ReadableStream;
get bodyUsed(): boolean;
arrayBuffer(): Promise<ArrayBuffer>;
text(): Promise<string>;
json<T>(): Promise<T>;
blob(): Promise<Blob>;
}
export interface R2Conditional {
etagMatches?: string;
etagDoesNotMatch?: string;
uploadedBefore?: Date;
uploadedAfter?: Date;
secondsGranularity?: boolean;
}
export interface R2GetOptions {
onlyIf?: R2Conditional | Headers;
range?: R2Range | Headers;
}
export interface R2PutOptions {
onlyIf?: R2Conditional | Headers;
httpMetadata?: R2BucketHttpMetadata | Headers;
customMetadata?: Record<string, string>;
md5?: ArrayBuffer | string;
sha1?: ArrayBuffer | string;
sha256?: ArrayBuffer | string;
sha384?: ArrayBuffer | string;
sha512?: ArrayBuffer | string;
}
export interface R2Checksums {
readonly md5?: ArrayBuffer;
readonly sha1?: ArrayBuffer;
readonly sha256?: ArrayBuffer;
readonly sha384?: ArrayBuffer;
readonly sha512?: ArrayBuffer;
toJSON(): R2StringChecksums;
}
export interface R2StringChecksums {
md5?: string;
sha1?: string;
sha256?: string;
sha384?: string;
sha512?: string;
}
export interface R2BucketHttpMetadata {
contentType?: string;
contentLanguage?: string;
contentDisposition?: string;
contentEncoding?: string;
cacheControl?: string;
cacheExpiry?: Date;
}
export interface R2ListOptions {
limit?: number;
prefix?: string;
cursor?: string;
delimiter?: string;
startAfter?: string;
include?: ("httpMetadata" | "customMetadata")[];
}
export interface R2Objects {
objects: R2Object[];
truncated: boolean;
cursor?: string;
delimitedPrefixes: string[];
}
export interface ScheduledController {
readonly scheduledTime: number;
readonly cron: string;
noRetry(): void;
}
export interface QueuingStrategy<T = any> {
highWaterMark?: number | bigint;
size?: (chunk: T) => number | bigint;
}
export interface UnderlyingSink<W = any> {
type?: string;
start?: (param0: WritableStreamDefaultController) => void | Promise<void>;
write?: (
chunk: W,
controller: WritableStreamDefaultController
) => void | Promise<void>;
abort?: (param0: any) => void | Promise<void>;
close?: () => void | Promise<void>;
}
export interface UnderlyingByteSource {
type: "bytes";
autoAllocateChunkSize?: number;
start?: (controller: ReadableByteStreamController) => void | Promise<void>;
pull?: (controller: ReadableByteStreamController) => void | Promise<void>;
cancel?: (param0: any) => void | Promise<void>;
}
export interface UnderlyingSource<R = any> {
type?: "" | undefined;
start?: (
controller: ReadableStreamDefaultController<R>
) => void | Promise<void>;
pull?: (
controller: ReadableStreamDefaultController<R>
) => void | Promise<void>;
cancel?: (param0: any) => void | Promise<void>;
}
export 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>;
}
export 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;
}
/** 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. */
export interface ReadableStream<R = any> {
cancel(reason?: any): Promise<void>;
getReader(): ReadableStreamDefaultReader<R>;
getReader(options: ReadableStreamGetReaderOptions): ReadableStreamBYOBReader;
pipeThrough<T>(
transform: ReadableWritablePair<T, R>,
options?: StreamPipeOptions
): ReadableStream<T>;
pipeTo(
destination: WritableStream<R>,
options?: StreamPipeOptions
): Promise<void>;
tee(): [ReadableStream<R>, ReadableStream<R>];
values(options?: ReadableStreamValuesOptions): AsyncIterableIterator<R>;
[Symbol.asyncIterator](
options?: ReadableStreamValuesOptions
): AsyncIterableIterator<R>;
}
export interface ReadableStreamGetReaderOptions {
mode: "byob";
}
export interface TransformStreamDefaultController<O = any> {
get desiredSize(): number | null;
enqueue(chunk?: O): void;
error(param0: any): void;
terminate(): void;
}
export 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>;
}
export interface ReadableStreamValuesOptions {
preventCancel?: boolean;
}
export interface TextDecoderStreamTextDecoderStreamInit {
fatal?: boolean;
}
export 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;
}
export interface TraceItem {
readonly event:
| (
| TraceItemFetchEventInfo
| TraceItemScheduledEventInfo
| TraceItemAlarmEventInfo
)
| null;
readonly eventTimestamp: number | null;
readonly logs: TraceLog[];
readonly exceptions: TraceException[];
readonly scriptName: string | null;
readonly dispatchNamespace?: string;
readonly outcome: string;
}
export interface TraceItemAlarmEventInfo {
readonly scheduledTime: Date;
}
export interface TraceItemScheduledEventInfo {
readonly scheduledTime: number;
readonly cron: string;
}
export interface TraceItemFetchEventInfo {
readonly response?: TraceItemFetchEventInfoResponse;
readonly request: TraceItemFetchEventInfoRequest;
}
export interface TraceItemFetchEventInfoRequest {
readonly cf?: any;
readonly headers: Record<string, string>;
readonly method: string;
readonly url: string;
getUnredacted(): TraceItemFetchEventInfoRequest;
}
export interface TraceItemFetchEventInfoResponse {
readonly status: number;
}
export interface TraceLog {
readonly timestamp: number;
readonly level: string;
readonly message: any;
}
export interface TraceException {
readonly timestamp: number;
readonly message: string;
readonly name: string;
}
export interface TraceMetrics {
readonly cpuTime: number;
readonly wallTime: number;
}
export interface UnsafeTraceMetrics {
fromTrace(param0: TraceItem): TraceMetrics;
}
export interface URLPatternURLPatternInit {
protocol?: string;
username?: string;
password?: string;
hostname?: string;
port?: string;
pathname?: string;
search?: string;
hash?: string;
baseURL?: string;
}
export interface URLPatternURLPatternComponentResult {
input: string;
groups: Record<string, string>;
}
export interface URLPatternURLPatternResult {
inputs: (string | URLPatternURLPatternInit)[];
protocol: URLPatternURLPatternComponentResult;
username: URLPatternURLPatternComponentResult;
password: URLPatternURLPatternComponentResult;
hostname: URLPatternURLPatternComponentResult;
port: URLPatternURLPatternComponentResult;
pathname: URLPatternURLPatternComponentResult;
search: URLPatternURLPatternComponentResult;
hash: URLPatternURLPatternComponentResult;
}
export interface CloseEventInit {
code?: number;
reason?: string;
wasClean?: boolean;
}
export interface MessageEventInit {
data: ArrayBuffer | string;
}
/** Events providing information related to errors in scripts or in files. */
export interface ErrorEvent extends Event {
readonly filename: string;
readonly message: string;
readonly lineno: number;
readonly colno: number;
readonly error: any;
}
export declare var console: Console;
export declare var self: ServiceWorkerGlobalScope;
export declare var crypto: Crypto;
export declare var caches: CacheStorage;
export declare var scheduler: Scheduler;
export declare var navigator: Navigator;
export declare var ReadableStream: {
prototype: ReadableStream;
new (
underlyingSource: UnderlyingByteSource,
strategy?: QueuingStrategy<Uint8Array>
): ReadableStream<Uint8Array>;
new <R = any>(
underlyingSource?: UnderlyingSource<R>,
strategy?: QueuingStrategy<R>
): ReadableStream<R>;
};
export declare var WebSocketPair: {
new (): {
0: WebSocket;
1: WebSocket;
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment