1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732 |
- /// <reference types="node" />
- import { Blob as Blob_2 } from 'buffer';
- import { ConnectionOptions } from 'tls';
- import { Duplex } from 'stream';
- import { EventEmitter } from 'events';
- import { IpcNetConnectOpts } from 'net';
- import type { Json } from 'miniflare';
- import { Readable } from 'stream';
- import { ReadableStream as ReadableStream_2 } from 'stream/web';
- import { Socket as Socket_2 } from 'net';
- import { TcpNetConnectOpts } from 'net';
- import { TlsOptions } from 'tls';
- import { TLSSocket } from 'tls';
- import { URL as URL_2 } from 'url';
- import { URLSearchParams as URLSearchParams_2 } from 'url';
- import { Writable } from 'stream';
- declare type AbortSignal_2 = unknown;
- declare interface BlobPropertyBag {
- type?: string
- endings?: 'native' | 'transparent'
- }
- declare type BodyInit_2 =
- | ArrayBuffer
- | AsyncIterable<Uint8Array>
- | Blob_2
- | FormData_2
- | Iterable<Uint8Array>
- | NodeJS.ArrayBufferView
- | URLSearchParams_2
- | null
- | string
- declare interface BodyMixin {
- readonly body: ReadableStream_2 | null
- readonly bodyUsed: boolean
- readonly arrayBuffer: () => Promise<ArrayBuffer>
- readonly blob: () => Promise<Blob_2>
- readonly formData: () => Promise<FormData_2>
- readonly json: () => Promise<unknown>
- readonly text: () => Promise<string>
- }
- declare class BodyReadable extends Readable {
- constructor(
- resume?: (this: Readable, size: number) => void | null,
- abort?: () => void | null,
- contentType?: string
- )
- /** Consumes and returns the body as a string
- * https://fetch.spec.whatwg.org/#dom-body-text
- */
- text(): Promise<string>
- /** Consumes and returns the body as a JavaScript Object
- * https://fetch.spec.whatwg.org/#dom-body-json
- */
- json(): Promise<any>
- /** Consumes and returns the body as a Blob
- * https://fetch.spec.whatwg.org/#dom-body-blob
- */
- blob(): Promise<Blob_2>
- /** Consumes and returns the body as an ArrayBuffer
- * https://fetch.spec.whatwg.org/#dom-body-arraybuffer
- */
- arrayBuffer(): Promise<ArrayBuffer>
- /** Not implemented
- *
- * https://fetch.spec.whatwg.org/#dom-body-formdata
- */
- formData(): Promise<never>
- /** Returns true if the body is not null and the body has been consumed
- *
- * Otherwise, returns false
- *
- * https://fetch.spec.whatwg.org/#dom-body-bodyused
- */
- readonly bodyUsed: boolean
- /** Throws on node 16.6.0
- *
- * If body is null, it should return null as the body
- *
- * If body is not null, should return the body as a ReadableStream
- *
- * https://fetch.spec.whatwg.org/#dom-body-body
- */
- readonly body: never | undefined
- /** Dumps the response body by reading `limit` number of bytes.
- * @param opts.limit Number of bytes to read (optional) - Default: 262144
- */
- dump(opts?: { limit: number }): Promise<void>
- }
- declare function buildConnector (options?: buildConnector.BuildOptions): buildConnector.connector
- declare namespace buildConnector {
- type BuildOptions = (ConnectionOptions | TcpNetConnectOpts | IpcNetConnectOpts) & {
- maxCachedSessions?: number | null;
- socketPath?: string | null;
- timeout?: number | null;
- port?: number;
- keepAlive?: boolean | null;
- keepAliveInitialDelay?: number | null;
- }
- interface Options {
- hostname: string
- host?: string
- protocol: string
- port: string
- servername?: string
- localAddress?: string | null
- httpSocket?: Socket_2
- }
- type Callback = (...args: CallbackArgs) => void
- type CallbackArgs = [null, Socket_2 | TLSSocket] | [Error, null]
- type connector = connectorAsync | connectorSync
- interface connectorSync {
- (options: buildConnector.Options): Socket_2 | TLSSocket
- }
- interface connectorAsync {
- (options: buildConnector.Options, callback: buildConnector.Callback): void
- }
- }
- /**
- * An imported module.
- */
- declare interface CfModule {
- /**
- * The module name.
- *
- * @example
- * './src/index.js'
- */
- name: string;
- /**
- * The module content, usually JavaScript or WASM code.
- *
- * @example
- * export default {
- * async fetch(request) {
- * return new Response('Ok')
- * }
- * }
- */
- content: string | Buffer;
- /**
- * The module type.
- *
- * If absent, will default to the main module's type.
- */
- type?: CfModuleType;
- }
- /**
- * A module type.
- */
- declare type CfModuleType = "esm" | "commonjs" | "compiled-wasm" | "text" | "buffer";
- /** A basic HTTP/1.1 client, mapped on top a single TCP/TLS connection. Pipelining is disabled by default. */
- declare class Client extends Dispatcher {
- constructor(url: string | URL_2, options?: Client.Options);
- /** Property to get and set the pipelining factor. */
- pipelining: number;
- /** `true` after `client.close()` has been called. */
- closed: boolean;
- /** `true` after `client.destroyed()` has been called or `client.close()` has been called and the client shutdown has completed. */
- destroyed: boolean;
- }
- declare namespace Client {
- interface Options {
- /** the timeout after which a socket without active requests will time out. Monitors time between activity on a connected socket. This value may be overridden by *keep-alive* hints from the server. Default: `4e3` milliseconds (4s). */
- keepAliveTimeout?: number | null;
- /** the maximum allowed `idleTimeout` when overridden by *keep-alive* hints from the server. Default: `600e3` milliseconds (10min). */
- keepAliveMaxTimeout?: number | null;
- /** A number subtracted from server *keep-alive* hints when overriding `idleTimeout` to account for timing inaccuracies caused by e.g. transport latency. Default: `1e3` milliseconds (1s). */
- keepAliveTimeoutThreshold?: number | null;
- /** The amount of concurrent requests to be sent over the single TCP/TLS connection according to [RFC7230](https://tools.ietf.org/html/rfc7230#section-6.3.2). Default: `1`. */
- pipelining?: number | null;
- /** **/
- connect?: buildConnector.BuildOptions | buildConnector.connector | null;
- /** The maximum length of request headers in bytes. Default: `16384` (16KiB). */
- maxHeaderSize?: number | null;
- /** The timeout after which a request will time out, in milliseconds. Monitors time between receiving body data. Use `0` to disable it entirely. Default: `300e3` milliseconds (300s). */
- bodyTimeout?: number | null;
- /** The amount of time the parser will wait to receive the complete HTTP headers (Node 14 and above only). Default: `300e3` milliseconds (300s). */
- headersTimeout?: number | null;
- /** If `true`, an error is thrown when the request content-length header doesn't match the length of the request body. Default: `true`. */
- strictContentLength?: boolean;
- /** @deprecated use the connect option instead */
- tls?: TlsOptions | null;
- /** */
- maxRequestsPerClient?: number;
- /** Max response body size in bytes, -1 is disabled */
- maxResponseSize?: number | null;
- /** Enables a family autodetection algorithm that loosely implements section 5 of RFC 8305. */
- autoSelectFamily?: boolean;
- /** The amount of time in milliseconds to wait for a connection attempt to finish before trying the next address when using the `autoSelectFamily` option. */
- autoSelectFamilyAttemptTimeout?: number;
- interceptors?: {Client: readonly Dispatcher[] | undefined}
- }
- interface SocketInfo {
- localAddress?: string
- localPort?: number
- remoteAddress?: string
- remotePort?: number
- remoteFamily?: string
- timeout?: number
- bytesWritten?: number
- bytesRead?: number
- }
- }
- /**
- * The possible types for a `Rule`.
- */
- declare type ConfigModuleRuleType = "ESModule" | "CommonJS" | "CompiledWasm" | "Text" | "Data";
- declare type CustomDomainRoute = {
- pattern: string;
- custom_domain: boolean;
- };
- export declare function deleteMTlsCertificate(accountId: string, certificateId: string): Promise<unknown>;
- /**
- * Publish a directory to an account/project.
- * NOTE: You will need the `CLOUDFLARE_API_KEY` environment
- * variable set
- */
- declare function deploy({ directory, accountId, projectName, branch, skipCaching, commitMessage, commitHash, commitDirty, functionsDirectory: customFunctionsDirectory, bundle, }: PagesDeployOptions): Promise<{
- url: string;
- environment: "production" | "preview";
- id: string;
- project_id: string;
- project_name: string;
- build_config: {
- build_command: string;
- destination_dir: string;
- root_dir: string;
- web_analytics_tag?: string | undefined;
- web_analytics_token?: string | undefined;
- fast_builds?: boolean | undefined;
- };
- created_on: string;
- production_branch: string;
- deployment_trigger: {
- type: string;
- metadata: {
- branch: string;
- commit_hash: string;
- commit_message: string;
- };
- };
- latest_stage: {
- name: "build" | "deploy" | "queued" | "initialize" | "clone_repo";
- status: "active" | "idle" | "canceled" | "success" | "failure" | "skipped";
- started_on: string | null;
- ended_on: string | null;
- };
- stages: {
- name: "build" | "deploy" | "queued" | "initialize" | "clone_repo";
- status: "active" | "idle" | "canceled" | "success" | "failure" | "skipped";
- started_on: string | null;
- ended_on: string | null;
- }[];
- aliases: string[];
- modified_on: string;
- short_id: string;
- build_image_major_version: number;
- kv_namespaces?: any;
- source?: {
- type: "github" | "gitlab";
- config: {
- owner: string;
- repo_name: string;
- production_branch?: string | undefined;
- pr_comments_enabled?: boolean | undefined;
- deployments_enabled?: boolean | undefined;
- production_deployments_enabled?: boolean | undefined;
- preview_deployment_setting?: "none" | "all" | "custom" | undefined;
- preview_branch_includes?: string[] | undefined;
- preview_branch_excludes?: string[] | undefined;
- };
- } | undefined;
- env_vars?: any;
- durable_object_namespaces?: any;
- is_skipped?: boolean | undefined;
- files?: {
- [x: string]: string | undefined;
- } | undefined;
- }>;
- /**
- * Deprecated upload configuration.
- */
- declare interface DeprecatedUpload {
- /**
- * The format of the Worker script.
- *
- * @deprecated We infer the format automatically now.
- */
- format?: "modules" | "service-worker";
- /**
- * The directory you wish to upload your worker from,
- * relative to the wrangler.toml file.
- *
- * Defaults to the directory containing the wrangler.toml file.
- *
- * @deprecated
- */
- dir?: string;
- /**
- * The path to the Worker script, relative to `upload.dir`.
- *
- * @deprecated This will be replaced by a command line argument.
- */
- main?: string;
- /**
- * @deprecated This is now defined at the top level `rules` field.
- */
- rules?: Environment["rules"];
- }
- /** Dispatcher is the core API used to dispatch requests. */
- declare class Dispatcher extends EventEmitter {
- /** Dispatches a request. This API is expected to evolve through semver-major versions and is less stable than the preceding higher level APIs. It is primarily intended for library developers who implement higher level APIs on top of this. */
- dispatch(options: Dispatcher.DispatchOptions, handler: Dispatcher.DispatchHandlers): boolean;
- /** Starts two-way communications with the requested resource. */
- connect(options: Dispatcher.ConnectOptions): Promise<Dispatcher.ConnectData>;
- connect(options: Dispatcher.ConnectOptions, callback: (err: Error | null, data: Dispatcher.ConnectData) => void): void;
- /** Performs an HTTP request. */
- request(options: Dispatcher.RequestOptions): Promise<Dispatcher.ResponseData>;
- request(options: Dispatcher.RequestOptions, callback: (err: Error | null, data: Dispatcher.ResponseData) => void): void;
- /** For easy use with `stream.pipeline`. */
- pipeline(options: Dispatcher.PipelineOptions, handler: Dispatcher.PipelineHandler): Duplex;
- /** A faster version of `Dispatcher.request`. */
- stream(options: Dispatcher.RequestOptions, factory: Dispatcher.StreamFactory): Promise<Dispatcher.StreamData>;
- stream(options: Dispatcher.RequestOptions, factory: Dispatcher.StreamFactory, callback: (err: Error | null, data: Dispatcher.StreamData) => void): void;
- /** Upgrade to a different protocol. */
- upgrade(options: Dispatcher.UpgradeOptions): Promise<Dispatcher.UpgradeData>;
- upgrade(options: Dispatcher.UpgradeOptions, callback: (err: Error | null, data: Dispatcher.UpgradeData) => void): void;
- /** Closes the client and gracefully waits for enqueued requests to complete before invoking the callback (or returning a promise if no callback is provided). */
- close(): Promise<void>;
- close(callback: () => void): void;
- /** Destroy the client abruptly with the given err. All the pending and running requests will be asynchronously aborted and error. Waits until socket is closed before invoking the callback (or returning a promise if no callback is provided). Since this operation is asynchronously dispatched there might still be some progress on dispatched requests. */
- destroy(): Promise<void>;
- destroy(err: Error | null): Promise<void>;
- destroy(callback: () => void): void;
- destroy(err: Error | null, callback: () => void): void;
- on(eventName: 'connect', callback: (origin: URL_2, targets: readonly Dispatcher[]) => void): this;
- on(eventName: 'disconnect', callback: (origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
- on(eventName: 'connectionError', callback: (origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
- on(eventName: 'drain', callback: (origin: URL_2) => void): this;
- once(eventName: 'connect', callback: (origin: URL_2, targets: readonly Dispatcher[]) => void): this;
- once(eventName: 'disconnect', callback: (origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
- once(eventName: 'connectionError', callback: (origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
- once(eventName: 'drain', callback: (origin: URL_2) => void): this;
- off(eventName: 'connect', callback: (origin: URL_2, targets: readonly Dispatcher[]) => void): this;
- off(eventName: 'disconnect', callback: (origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
- off(eventName: 'connectionError', callback: (origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
- off(eventName: 'drain', callback: (origin: URL_2) => void): this;
- addListener(eventName: 'connect', callback: (origin: URL_2, targets: readonly Dispatcher[]) => void): this;
- addListener(eventName: 'disconnect', callback: (origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
- addListener(eventName: 'connectionError', callback: (origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
- addListener(eventName: 'drain', callback: (origin: URL_2) => void): this;
- removeListener(eventName: 'connect', callback: (origin: URL_2, targets: readonly Dispatcher[]) => void): this;
- removeListener(eventName: 'disconnect', callback: (origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
- removeListener(eventName: 'connectionError', callback: (origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
- removeListener(eventName: 'drain', callback: (origin: URL_2) => void): this;
- prependListener(eventName: 'connect', callback: (origin: URL_2, targets: readonly Dispatcher[]) => void): this;
- prependListener(eventName: 'disconnect', callback: (origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
- prependListener(eventName: 'connectionError', callback: (origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
- prependListener(eventName: 'drain', callback: (origin: URL_2) => void): this;
- prependOnceListener(eventName: 'connect', callback: (origin: URL_2, targets: readonly Dispatcher[]) => void): this;
- prependOnceListener(eventName: 'disconnect', callback: (origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
- prependOnceListener(eventName: 'connectionError', callback: (origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
- prependOnceListener(eventName: 'drain', callback: (origin: URL_2) => void): this;
- listeners(eventName: 'connect'): ((origin: URL_2, targets: readonly Dispatcher[]) => void)[]
- listeners(eventName: 'disconnect'): ((origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void)[];
- listeners(eventName: 'connectionError'): ((origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void)[];
- listeners(eventName: 'drain'): ((origin: URL_2) => void)[];
- rawListeners(eventName: 'connect'): ((origin: URL_2, targets: readonly Dispatcher[]) => void)[]
- rawListeners(eventName: 'disconnect'): ((origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void)[];
- rawListeners(eventName: 'connectionError'): ((origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError) => void)[];
- rawListeners(eventName: 'drain'): ((origin: URL_2) => void)[];
- emit(eventName: 'connect', origin: URL_2, targets: readonly Dispatcher[]): boolean;
- emit(eventName: 'disconnect', origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError): boolean;
- emit(eventName: 'connectionError', origin: URL_2, targets: readonly Dispatcher[], error: Errors.UndiciError): boolean;
- emit(eventName: 'drain', origin: URL_2): boolean;
- }
- declare namespace Dispatcher {
- interface DispatchOptions {
- origin?: string | URL_2;
- path: string;
- method: HttpMethod;
- /** Default: `null` */
- body?: string | Buffer | Uint8Array | Readable | null | FormData_2;
- /** Default: `null` */
- headers?: IncomingHttpHeaders | string[] | null;
- /** Query string params to be embedded in the request URL. Default: `null` */
- query?: Record<string, any>;
- /** Whether the requests can be safely retried or not. If `false` the request won't be sent until all preceding requests in the pipeline have completed. Default: `true` if `method` is `HEAD` or `GET`. */
- idempotent?: boolean;
- /** Whether the response is expected to take a long time and would end up blocking the pipeline. When this is set to `true` further pipelining will be avoided on the same connection until headers have been received. */
- blocking?: boolean;
- /** Upgrade the request. Should be used to specify the kind of upgrade i.e. `'Websocket'`. Default: `method === 'CONNECT' || null`. */
- upgrade?: boolean | string | null;
- /** The amount of time the parser will wait to receive the complete HTTP headers. Defaults to 300 seconds. */
- headersTimeout?: number | null;
- /** The timeout after which a request will time out, in milliseconds. Monitors time between receiving body data. Use 0 to disable it entirely. Defaults to 300 seconds. */
- bodyTimeout?: number | null;
- /** Whether the request should stablish a keep-alive or not. Default `false` */
- reset?: boolean;
- /** Whether Undici should throw an error upon receiving a 4xx or 5xx response from the server. Defaults to false */
- throwOnError?: boolean;
- }
- interface ConnectOptions {
- path: string;
- /** Default: `null` */
- headers?: IncomingHttpHeaders | string[] | null;
- /** Default: `null` */
- signal?: AbortSignal_2 | EventEmitter | null;
- /** This argument parameter is passed through to `ConnectData` */
- opaque?: unknown;
- /** Default: 0 */
- maxRedirections?: number;
- /** Default: `null` */
- responseHeader?: 'raw' | null;
- }
- interface RequestOptions extends DispatchOptions {
- /** Default: `null` */
- opaque?: unknown;
- /** Default: `null` */
- signal?: AbortSignal_2 | EventEmitter | null;
- /** Default: 0 */
- maxRedirections?: number;
- /** Default: `null` */
- onInfo?: (info: { statusCode: number, headers: Record<string, string | string[]> }) => void;
- /** Default: `null` */
- responseHeader?: 'raw' | null;
- }
- interface PipelineOptions extends RequestOptions {
- /** `true` if the `handler` will return an object stream. Default: `false` */
- objectMode?: boolean;
- }
- interface UpgradeOptions {
- path: string;
- /** Default: `'GET'` */
- method?: string;
- /** Default: `null` */
- headers?: IncomingHttpHeaders | string[] | null;
- /** A string of comma separated protocols, in descending preference order. Default: `'Websocket'` */
- protocol?: string;
- /** Default: `null` */
- signal?: AbortSignal_2 | EventEmitter | null;
- /** Default: 0 */
- maxRedirections?: number;
- /** Default: `null` */
- responseHeader?: 'raw' | null;
- }
- interface ConnectData {
- statusCode: number;
- headers: IncomingHttpHeaders;
- socket: Duplex;
- opaque: unknown;
- }
- interface ResponseData {
- statusCode: number;
- headers: IncomingHttpHeaders;
- body: BodyReadable & BodyMixin;
- trailers: Record<string, string>;
- opaque: unknown;
- context: object;
- }
- interface PipelineHandlerData {
- statusCode: number;
- headers: IncomingHttpHeaders;
- opaque: unknown;
- body: BodyReadable;
- context: object;
- }
- interface StreamData {
- opaque: unknown;
- trailers: Record<string, string>;
- }
- interface UpgradeData {
- headers: IncomingHttpHeaders;
- socket: Duplex;
- opaque: unknown;
- }
- interface StreamFactoryData {
- statusCode: number;
- headers: IncomingHttpHeaders;
- opaque: unknown;
- context: object;
- }
- type StreamFactory = (data: StreamFactoryData) => Writable;
- interface DispatchHandlers {
- /** Invoked before request is dispatched on socket. May be invoked multiple times when a request is retried when the request at the head of the pipeline fails. */
- onConnect?(abort: () => void): void;
- /** Invoked when an error has occurred. */
- onError?(err: Error): void;
- /** Invoked when request is upgraded either due to a `Upgrade` header or `CONNECT` method. */
- onUpgrade?(statusCode: number, headers: Buffer[] | string[] | null, socket: Duplex): void;
- /** Invoked when statusCode and headers have been received. May be invoked multiple times due to 1xx informational headers. */
- onHeaders?(statusCode: number, headers: Buffer[] | string[] | null, resume: () => void): boolean;
- /** Invoked when response payload data is received. */
- onData?(chunk: Buffer): boolean;
- /** Invoked when response payload and trailers have been received and the request has completed. */
- onComplete?(trailers: string[] | null): void;
- /** Invoked when a body chunk is sent to the server. May be invoked multiple times for chunked requests */
- onBodySent?(chunkSize: number, totalBytesSent: number): void;
- }
- type PipelineHandler = (data: PipelineHandlerData) => Readable;
- type HttpMethod = 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'CONNECT' | 'OPTIONS' | 'TRACE' | 'PATCH';
- /**
- * @link https://fetch.spec.whatwg.org/#body-mixin
- */
- interface BodyMixin {
- readonly body?: never; // throws on node v16.6.0
- readonly bodyUsed: boolean;
- arrayBuffer(): Promise<ArrayBuffer>;
- blob(): Promise<Blob_2>;
- formData(): Promise<never>;
- json(): Promise<any>;
- text(): Promise<string>;
- }
- interface DispatchInterceptor {
- (dispatch: Dispatcher['dispatch']): Dispatcher['dispatch']
- }
- }
- declare interface DispatchNamespaceOutbound {
- /** Name of the service handling the outbound requests */
- service: string;
- /** (Optional) Name of the environment handling the outbound requests. */
- environment?: string;
- /** (Optional) List of parameter names, for sending context from your dispatch worker to the outbound handler */
- parameters?: string[];
- }
- declare type DurableObjectBindings = {
- /** The name of the binding used to refer to the Durable Object */
- name: string;
- /** The exported class name of the Durable Object */
- class_name: string;
- /** The script where the Durable Object is defined (if it's external to this worker) */
- script_name?: string;
- /** The service environment of the script_name to bind to */
- environment?: string;
- }[];
- declare interface EnablePagesAssetsServiceBindingOptions {
- proxyPort?: number;
- directory?: string;
- }
- /**
- * The `Environment` interface declares all the configuration fields that
- * can be specified for an environment.
- *
- * This could be the top-level default environment, or a specific named environment.
- */
- declare interface Environment extends EnvironmentInheritable, EnvironmentNonInheritable {
- }
- /**
- * The `EnvironmentInheritable` interface declares all the configuration fields for an environment
- * that can be inherited (and overridden) from the top-level environment.
- */
- declare interface EnvironmentInheritable {
- /**
- * The name of your worker. Alphanumeric + dashes only.
- *
- * @inheritable
- */
- name: string | undefined;
- /**
- * This is the ID of the account associated with your zone.
- * You might have more than one account, so make sure to use
- * the ID of the account associated with the zone/route you
- * provide, if you provide one. It can also be specified through
- * the CLOUDFLARE_ACCOUNT_ID environment variable.
- *
- * @inheritable
- */
- account_id: string | undefined;
- /**
- * A date in the form yyyy-mm-dd, which will be used to determine
- * which version of the Workers runtime is used.
- *
- * More details at https://developers.cloudflare.com/workers/platform/compatibility-dates
- *
- * @inheritable
- */
- compatibility_date: string | undefined;
- /**
- * A list of flags that enable features from upcoming features of
- * the Workers runtime, usually used together with compatibility_flags.
- *
- * More details at https://developers.cloudflare.com/workers/platform/compatibility-dates
- *
- * @inheritable
- */
- compatibility_flags: string[];
- /**
- * The entrypoint/path to the JavaScript file that will be executed.
- */
- main: string | undefined;
- /**
- * The directory in which module rules should be evaluated in a `--no-bundle` worker
- * This defaults to dirname(main) when left undefined
- */
- base_dir: string | undefined;
- /**
- * Whether we use <name>.<subdomain>.workers.dev to
- * test and deploy your worker.
- *
- * @default `true` (This is a breaking change from Wrangler v1)
- * @breaking
- * @inheritable
- */
- workers_dev: boolean | undefined;
- /**
- * A list of routes that your worker should be published to.
- * Only one of `routes` or `route` is required.
- *
- * Only required when workers_dev is false, and there's no scheduled worker (see `triggers`)
- *
- * @inheritable
- */
- routes: Route[] | undefined;
- /**
- * A route that your worker should be published to. Literally
- * the same as routes, but only one.
- * Only one of `routes` or `route` is required.
- *
- * Only required when workers_dev is false, and there's no scheduled worker
- *
- * @inheritable
- */
- route: Route | undefined;
- /**
- * Path to a custom tsconfig
- */
- tsconfig: string | undefined;
- /**
- * The function to use to replace jsx syntax.
- *
- * @default `"React.createElement"`
- * @inheritable
- */
- jsx_factory: string;
- /**
- * The function to use to replace jsx fragment syntax.
- *
- * @default `"React.Fragment"`
- * @inheritable
- */
- jsx_fragment: string;
- /**
- * "Cron" definitions to trigger a worker's "scheduled" function.
- *
- * Lets you call workers periodically, much like a cron job.
- *
- * More details here https://developers.cloudflare.com/workers/platform/cron-triggers
- *
- * @default `{crons:[]}`
- * @inheritable
- */
- triggers: {
- crons: string[];
- };
- /**
- * Specifies the Usage Model for your Worker. There are two options -
- * [bundled](https://developers.cloudflare.com/workers/platform/limits#bundled-usage-model) and
- * [unbound](https://developers.cloudflare.com/workers/platform/limits#unbound-usage-model).
- * For newly created Workers, if the Usage Model is omitted
- * it will be set to the [default Usage Model set on the account](https://dash.cloudflare.com/?account=workers/default-usage-model).
- * For existing Workers, if the Usage Model is omitted, it will be
- * set to the Usage Model configured in the dashboard for that Worker.
- *
- * @inheritable
- */
- usage_model: "bundled" | "unbound" | undefined;
- /**
- * An ordered list of rules that define which modules to import,
- * and what type to import them as. You will need to specify rules
- * to use Text, Data, and CompiledWasm modules, or when you wish to
- * have a .js file be treated as an ESModule instead of CommonJS.
- *
- * @inheritable
- */
- rules: Rule[];
- /**
- * Configures a custom build step to be run by Wrangler when building your Worker.
- *
- * Refer to the [custom builds documentation](https://developers.cloudflare.com/workers/cli-wrangler/configuration#build)
- * for more details.
- *
- * @default {}
- */
- build: {
- /** The command used to build your Worker. On Linux and macOS, the command is executed in the `sh` shell and the `cmd` shell for Windows. The `&&` and `||` shell operators may be used. */
- command?: string;
- /** The directory in which the command is executed. */
- cwd?: string;
- /** The directory to watch for changes while using wrangler dev, defaults to the current working directory */
- watch_dir?: string | string[];
- /**
- * Deprecated field previously used to configure the build and upload of the script.
- * @deprecated
- */
- upload?: DeprecatedUpload;
- };
- /**
- * Skip internal build steps and directly deploy script
- * @inheritable
- */
- no_bundle: boolean | undefined;
- /**
- * Minify the script before uploading.
- * @inheritable
- */
- minify: boolean | undefined;
- /**
- * Add polyfills for node builtin modules and globals
- * @inheritable
- */
- node_compat: boolean | undefined;
- /**
- * Specifies namespace bindings that are bound to this Worker environment.
- *
- * NOTE: This field is not automatically inherited from the top level environment,
- * and so must be specified in every named environment.
- *
- * @default `[]`
- * @nonInheritable
- */
- dispatch_namespaces: {
- /** The binding name used to refer to the bound service. */
- binding: string;
- /** The namespace to bind to. */
- namespace: string;
- /** Details about the outbound worker which will handle outbound requests from your namespace */
- outbound?: DispatchNamespaceOutbound;
- }[];
- /**
- * Designates this worker as an internal-only "first-party" worker.
- */
- first_party_worker: boolean | undefined;
- /**
- * TODO: remove this as it has been deprecated.
- *
- * This is just here for now because the `route` commands use it.
- * So we need to include it in this type so it is available.
- */
- zone_id?: string;
- /**
- * List of bindings that you will send to logfwdr
- *
- * @default `{bindings:[]}`
- * @inheritable
- */
- logfwdr: {
- bindings: {
- /** The binding name used to refer to logfwdr */
- name: string;
- /** The destination for this logged message */
- destination: string;
- }[];
- };
- /**
- * Send Trace Events from this worker to Workers Logpush.
- *
- * This will not configure a corresponding Logpush job automatically.
- *
- * For more information about Workers Logpush, see:
- * https://blog.cloudflare.com/logpush-for-workers/
- *
- * @inheritable
- */
- logpush: boolean | undefined;
- /**
- * Specify how the worker should be located to minimize round-trip time.
- *
- * More details: https://developers.cloudflare.com/workers/platform/smart-placement/
- */
- placement: {
- mode: "off" | "smart";
- } | undefined;
- }
- /**
- * The `EnvironmentNonInheritable` interface declares all the configuration fields for an environment
- * that cannot be inherited from the top-level environment, and must be defined specifically.
- *
- * If any of these fields are defined at the top-level then they should also be specifically defined
- * for each named environment.
- */
- declare interface EnvironmentNonInheritable {
- /**
- * A map of values to substitute when deploying your worker.
- *
- * NOTE: This field is not automatically inherited from the top level environment,
- * and so must be specified in every named environment.
- *
- * @default `{}`
- * @nonInheritable
- */
- define: Record<string, string>;
- /**
- * A map of environment variables to set when deploying your worker.
- *
- * NOTE: This field is not automatically inherited from the top level environment,
- * and so must be specified in every named environment.
- *
- * @default `{}`
- * @nonInheritable
- */
- vars: Record<string, string | Json>;
- /**
- * A list of durable objects that your worker should be bound to.
- *
- * For more information about Durable Objects, see the documentation at
- * https://developers.cloudflare.com/workers/learning/using-durable-objects
- *
- * NOTE: This field is not automatically inherited from the top level environment,
- * and so must be specified in every named environment.
- *
- * @default `{bindings:[]}`
- * @nonInheritable
- */
- durable_objects: {
- bindings: DurableObjectBindings;
- };
- /**
- * These specify any Workers KV Namespaces you want to
- * access from inside your Worker.
- *
- * To learn more about KV Namespaces,
- * see the documentation at https://developers.cloudflare.com/workers/learning/how-kv-works
- *
- * NOTE: This field is not automatically inherited from the top level environment,
- * and so must be specified in every named environment.
- *
- * @default `[]`
- * @nonInheritable
- */
- kv_namespaces: {
- /** The binding name used to refer to the KV Namespace */
- binding: string;
- /** The ID of the KV namespace */
- id: string;
- /** The ID of the KV namespace used during `wrangler dev` */
- preview_id?: string;
- }[];
- /**
- * These specify bindings to send email from inside your Worker.
- *
- * NOTE: This field is not automatically inherited from the top level environment,
- * and so must be specified in every named environment.
- *
- * @default `[]`
- * @nonInheritable
- */
- send_email: {
- /** The binding name used to refer to the this binding */
- name: string;
- /** If this binding should be restricted to a specific verified address */
- destination_address?: string;
- /** If this binding should be restricted to a set of verified addresses */
- allowed_destination_addresses?: string[];
- }[];
- /**
- * Specifies Queues that are bound to this Worker environment.
- *
- * NOTE: This field is not automatically inherited from the top level environment,
- * and so must be specified in every named environment.
- *
- * @default `{}`
- * @nonInheritable
- */
- queues: {
- /** Producer bindings */
- producers?: {
- /** The binding name used to refer to the Queue in the worker. */
- binding: string;
- /** The name of this Queue. */
- queue: string;
- }[];
- /** Consumer configuration */
- consumers?: {
- /** The name of the queue from which this script should consume. */
- queue: string;
- /** The maximum number of messages per batch */
- max_batch_size?: number;
- /** The maximum number of seconds to wait to fill a batch with messages. */
- max_batch_timeout?: number;
- /** The maximum number of retries for each message. */
- max_retries?: number;
- /** The queue to send messages that failed to be consumed. */
- dead_letter_queue?: string;
- /** The maximum number of concurrent consumer Worker invocations. Leaving this unset will allow your consumer to scale to the maximum concurrency needed to keep up with the message backlog. */
- max_concurrency?: number | null;
- }[];
- };
- /**
- * Specifies R2 buckets that are bound to this Worker environment.
- *
- * NOTE: This field is not automatically inherited from the top level environment,
- * and so must be specified in every named environment.
- *
- * @default `[]`
- * @nonInheritable
- */
- r2_buckets: {
- /** The binding name used to refer to the R2 bucket in the worker. */
- binding: string;
- /** The name of this R2 bucket at the edge. */
- bucket_name: string;
- /** The preview name of this R2 bucket at the edge. */
- preview_bucket_name?: string;
- }[];
- /**
- * Specifies D1 databases that are bound to this Worker environment.
- *
- * NOTE: This field is not automatically inherited from the top level environment,
- * and so must be specified in every named environment.
- *
- * @default `[]`
- * @nonInheritable
- */
- d1_databases: {
- /** The binding name used to refer to the D1 database in the worker. */
- binding: string;
- /** The name of this D1 database. */
- database_name: string;
- /** The UUID of this D1 database (not required). */
- database_id: string;
- /** The UUID of this D1 database for Wrangler Dev (if specified). */
- preview_database_id?: string;
- /** The name of the migrations table for this D1 database (defaults to 'd1_migrations'). */
- migrations_table?: string;
- /** The path to the directory of migrations for this D1 database (defaults to './migrations'). */
- migrations_dir?: string;
- /** Internal use only. */
- database_internal_env?: string;
- }[];
- /**
- * Specifies Constellation projects that are bound to this Worker environment.
- *
- * NOTE: This field is not automatically inherited from the top level environment,
- * and so must be specified in every named environment.
- *
- * @default `[]`
- * @nonInheritable
- */
- constellation: {
- /** The binding name used to refer to the project in the worker. */
- binding: string;
- /** The id of the project. */
- project_id: string;
- }[];
- /**
- * Specifies service bindings (worker-to-worker) that are bound to this Worker environment.
- *
- * NOTE: This field is not automatically inherited from the top level environment,
- * and so must be specified in every named environment.
- *
- * @default `[]`
- * @nonInheritable
- */
- services: {
- /** The binding name used to refer to the bound service. */
- binding: string;
- /** The name of the service. */
- service: string;
- /** The environment of the service (e.g. production, staging, etc). */
- environment?: string;
- }[] | undefined;
- /**
- * Specifies analytics engine datasets that are bound to this Worker environment.
- *
- * NOTE: This field is not automatically inherited from the top level environment,
- * and so must be specified in every named environment.
- *
- * @default `[]`
- * @nonInheritable
- */
- analytics_engine_datasets: {
- /** The binding name used to refer to the dataset in the worker. */
- binding: string;
- /** The name of this dataset to write to. */
- dataset?: string;
- }[];
- /**
- * A browser that will be usable from the worker.
- */
- browser: {
- binding: string;
- } | undefined;
- /**
- * "Unsafe" tables for features that aren't directly supported by wrangler.
- *
- * NOTE: This field is not automatically inherited from the top level environment,
- * and so must be specified in every named environment.
- *
- * @nonInheritable
- */
- unsafe: {
- /**
- * A set of bindings that should be put into a Worker's upload metadata without changes. These
- * can be used to implement bindings for features that haven't released and aren't supported
- * directly by wrangler or miniflare.
- */
- bindings?: {
- name: string;
- type: string;
- [key: string]: unknown;
- }[];
- /**
- * Arbitrary key/value pairs that will be included in the uploaded metadata. Values specified
- * here will always be applied to metadata last, so can add new or override existing fields.
- */
- metadata?: {
- [key: string]: string;
- };
- /**
- * Used for internal capnp uploads for the Workers runtime
- */
- capnp?: {
- base_path: string;
- source_schemas: string[];
- compiled_schema?: never;
- } | {
- base_path?: never;
- source_schemas?: never;
- compiled_schema: string;
- };
- };
- mtls_certificates: {
- /** The binding name used to refer to the certificate in the worker */
- binding: string;
- /** The uuid of the uploaded mTLS certificate */
- certificate_id: string;
- }[];
- tail_consumers?: TailConsumer[];
- }
- declare namespace Errors {
- class UndiciError extends Error { }
- /** Connect timeout error. */
- class ConnectTimeoutError extends UndiciError {
- name: 'ConnectTimeoutError';
- code: 'UND_ERR_CONNECT_TIMEOUT';
- }
- /** A header exceeds the `headersTimeout` option. */
- class HeadersTimeoutError extends UndiciError {
- name: 'HeadersTimeoutError';
- code: 'UND_ERR_HEADERS_TIMEOUT';
- }
- /** Headers overflow error. */
- class HeadersOverflowError extends UndiciError {
- name: 'HeadersOverflowError'
- code: 'UND_ERR_HEADERS_OVERFLOW'
- }
- /** A body exceeds the `bodyTimeout` option. */
- class BodyTimeoutError extends UndiciError {
- name: 'BodyTimeoutError';
- code: 'UND_ERR_BODY_TIMEOUT';
- }
- class ResponseStatusCodeError extends UndiciError {
- name: 'ResponseStatusCodeError';
- code: 'UND_ERR_RESPONSE_STATUS_CODE';
- body: null | Record<string, any> | string
- status: number
- statusCode: number
- headers: IncomingHttpHeaders | string[] | null;
- }
- /** Passed an invalid argument. */
- class InvalidArgumentError extends UndiciError {
- name: 'InvalidArgumentError';
- code: 'UND_ERR_INVALID_ARG';
- }
- /** Returned an invalid value. */
- class InvalidReturnValueError extends UndiciError {
- name: 'InvalidReturnValueError';
- code: 'UND_ERR_INVALID_RETURN_VALUE';
- }
- /** The request has been aborted by the user. */
- class RequestAbortedError extends UndiciError {
- name: 'AbortError';
- code: 'UND_ERR_ABORTED';
- }
- /** Expected error with reason. */
- class InformationalError extends UndiciError {
- name: 'InformationalError';
- code: 'UND_ERR_INFO';
- }
- /** Request body length does not match content-length header. */
- class RequestContentLengthMismatchError extends UndiciError {
- name: 'RequestContentLengthMismatchError';
- code: 'UND_ERR_REQ_CONTENT_LENGTH_MISMATCH';
- }
- /** Response body length does not match content-length header. */
- class ResponseContentLengthMismatchError extends UndiciError {
- name: 'ResponseContentLengthMismatchError';
- code: 'UND_ERR_RES_CONTENT_LENGTH_MISMATCH';
- }
- /** Trying to use a destroyed client. */
- class ClientDestroyedError extends UndiciError {
- name: 'ClientDestroyedError';
- code: 'UND_ERR_DESTROYED';
- }
- /** Trying to use a closed client. */
- class ClientClosedError extends UndiciError {
- name: 'ClientClosedError';
- code: 'UND_ERR_CLOSED';
- }
- /** There is an error with the socket. */
- class SocketError extends UndiciError {
- name: 'SocketError';
- code: 'UND_ERR_SOCKET';
- socket: Client.SocketInfo | null
- }
- /** Encountered unsupported functionality. */
- class NotSupportedError extends UndiciError {
- name: 'NotSupportedError';
- code: 'UND_ERR_NOT_SUPPORTED';
- }
- /** No upstream has been added to the BalancedPool. */
- class BalancedPoolMissingUpstreamError extends UndiciError {
- name: 'MissingUpstreamError';
- code: 'UND_ERR_BPL_MISSING_UPSTREAM';
- }
- class HTTPParserError extends UndiciError {
- name: 'HTTPParserError';
- code: string;
- }
- /** The response exceed the length allowed. */
- class ResponseExceededMaxSizeError extends UndiciError {
- name: 'ResponseExceededMaxSizeError';
- code: 'UND_ERR_RES_EXCEEDED_MAX_SIZE';
- }
- }
- declare class File_2 extends Blob_2 {
- /**
- * Creates a new File instance.
- *
- * @param fileBits An `Array` strings, or [`ArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer), [`ArrayBufferView`](https://developer.mozilla.org/en-US/docs/Web/API/ArrayBufferView), [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob) objects, or a mix of any of such objects, that will be put inside the [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File).
- * @param fileName The name of the file.
- * @param options An options object containing optional attributes for the file.
- */
- constructor(fileBits: ReadonlyArray<string | NodeJS.ArrayBufferView | Blob_2>, fileName: string, options?: FilePropertyBag)
- /**
- * Name of the file referenced by the File object.
- */
- readonly name: string
- /**
- * The last modified date of the file as the number of milliseconds since the Unix epoch (January 1, 1970 at midnight). Files without a known last modified date return the current date.
- */
- readonly lastModified: number
- readonly [Symbol.toStringTag]: string
- }
- declare interface FilePropertyBag extends BlobPropertyBag {
- /**
- * The last modified date of the file as the number of milliseconds since the Unix epoch (January 1, 1970 at midnight). Files without a known last modified date return the current date.
- */
- lastModified?: number
- }
- /**
- * 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 fetch().
- */
- declare class FormData_2 {
- /**
- * Appends a new value onto an existing key inside a FormData object,
- * or adds the key if it does not already exist.
- *
- * The difference between `set()` and `append()` is that if the specified key already exists, `set()` will overwrite all existing values with the new one, whereas `append()` will append the new value onto the end of the existing set of values.
- *
- * @param name The name of the field whose data is contained in `value`.
- * @param value The field's value. This can be [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob)
- or [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File). If none of these are specified the value is converted to a string.
- * @param fileName The filename reported to the server, when a Blob or File is passed as the second parameter. The default filename for Blob objects is "blob". The default filename for File objects is the file's filename.
- */
- append(name: string, value: unknown, fileName?: string): void
- /**
- * Set a new value for an existing key inside FormData,
- * or add the new field if it does not already exist.
- *
- * @param name The name of the field whose data is contained in `value`.
- * @param value The field's value. This can be [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob)
- or [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File). If none of these are specified the value is converted to a string.
- * @param fileName The filename reported to the server, when a Blob or File is passed as the second parameter. The default filename for Blob objects is "blob". The default filename for File objects is the file's filename.
- *
- */
- set(name: string, value: unknown, fileName?: string): void
- /**
- * Returns the first value associated with a given key from within a `FormData` object.
- * If you expect multiple values and want all of them, use the `getAll()` method instead.
- *
- * @param {string} name A name of the value you want to retrieve.
- *
- * @returns A `FormDataEntryValue` containing the value. If the key doesn't exist, the method returns null.
- */
- get(name: string): FormDataEntryValue | null
- /**
- * Returns all the values associated with a given key from within a `FormData` object.
- *
- * @param {string} name A name of the value you want to retrieve.
- *
- * @returns An array of `FormDataEntryValue` whose key matches the value passed in the `name` parameter. If the key doesn't exist, the method returns an empty list.
- */
- getAll(name: string): FormDataEntryValue[]
- /**
- * Returns a boolean stating whether a `FormData` object contains a certain key.
- *
- * @param name A string representing the name of the key you want to test for.
- *
- * @return A boolean value.
- */
- has(name: string): boolean
- /**
- * Deletes a key and its value(s) from a `FormData` object.
- *
- * @param name The name of the key you want to delete.
- */
- delete(name: string): void
- /**
- * Executes given callback function for each field of the FormData instance
- */
- forEach: (
- callbackfn: (value: FormDataEntryValue, key: string, iterable: FormData_2) => void,
- thisArg?: unknown
- ) => void
- /**
- * Returns an [`iterator`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) allowing to go through all keys contained in this `FormData` object.
- * Each key is a `string`.
- */
- keys: () => SpecIterableIterator<string>
- /**
- * Returns an [`iterator`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) allowing to go through all values contained in this object `FormData` object.
- * Each value is a [`FormDataValue`](https://developer.mozilla.org/en-US/docs/Web/API/FormDataEntryValue).
- */
- values: () => SpecIterableIterator<FormDataEntryValue>
- /**
- * Returns an [`iterator`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) allowing to go through the `FormData` key/value pairs.
- * The key of each pair is a string; the value is a [`FormDataValue`](https://developer.mozilla.org/en-US/docs/Web/API/FormDataEntryValue).
- */
- entries: () => SpecIterableIterator<[string, FormDataEntryValue]>
- /**
- * An alias for FormData#entries()
- */
- [Symbol.iterator]: () => SpecIterableIterator<[string, FormDataEntryValue]>
- readonly [Symbol.toStringTag]: string
- }
- /**
- * A `string` or `File` that represents a single value from a set of `FormData` key-value pairs.
- */
- declare type FormDataEntryValue = string | File_2
- /**
- * fetches an mTLS certificate from the account mTLS certificate store by ID
- */
- export declare function getMTlsCertificate(accountId: string, id: string): Promise<MTlsCertificateResponse>;
- /**
- * fetches an mTLS certificate from the account mTLS certificate store by name. will throw an error if no certificates are found, or multiple are found with that name
- */
- export declare function getMTlsCertificateByName(accountId: string, name: string): Promise<MTlsCertificateResponse>;
- declare class Headers_2 implements SpecIterable<[string, string]> {
- constructor (init?: HeadersInit_2)
- readonly append: (name: string, value: string) => void
- readonly delete: (name: string) => void
- readonly get: (name: string) => string | null
- readonly has: (name: string) => boolean
- readonly set: (name: string, value: string) => void
- readonly getSetCookie: () => string[]
- readonly forEach: (
- callbackfn: (value: string, key: string, iterable: Headers_2) => void,
- thisArg?: unknown
- ) => void
- readonly keys: () => SpecIterableIterator<string>
- readonly values: () => SpecIterableIterator<string>
- readonly entries: () => SpecIterableIterator<[string, string]>
- readonly [Symbol.iterator]: () => SpecIterator<[string, string]>
- }
- declare type HeadersInit_2 = string[][] | Record<string, string | ReadonlyArray<string>> | Headers_2
- /**
- * The header type declaration of `undici`.
- */
- declare type IncomingHttpHeaders = Record<string, string | string[] | undefined>;
- /**
- * lists mTLS certificates for an account. filtering by name is supported
- */
- export declare function listMTlsCertificates(accountId: string, filter: MTlsCertificateListFilter): Promise<MTlsCertificateResponse[]>;
- /**
- * details for uploading an mTLS certificate via the ssl api
- */
- declare interface MTlsCertificateBody {
- certificateChain: string;
- privateKey: string;
- name?: string;
- }
- /**
- * supported filters for listing mTLS certificates via the ssl api
- */
- declare interface MTlsCertificateListFilter {
- name?: string;
- }
- /**
- * the representation of an mTLS certificate in the account certificate store
- */
- declare interface MTlsCertificateResponse {
- id: string;
- name?: string;
- ca: boolean;
- certificates: string;
- expires_on: string;
- issuer: string;
- serial_number: string;
- signature: string;
- uploaded_on: string;
- }
- /**
- * details for uploading an mTLS certificate from disk
- */
- declare interface MTlsCertificateUploadDetails {
- certificateChainFilename: string;
- privateKeyFilename: string;
- name?: string;
- }
- declare interface PagesDeployOptions {
- /**
- * Path to static assets to deploy to Pages
- */
- directory: string;
- /**
- * The Cloudflare Account ID that owns the project that's
- * being published
- */
- accountId: string;
- /**
- * The name of the project to be published
- */
- projectName: string;
- /**
- * Branch name to use. Defaults to production branch
- */
- branch?: string;
- /**
- * Whether or not to skip local file upload result caching
- */
- skipCaching?: boolean;
- /**
- * Commit message associated to deployment
- */
- commitMessage?: string;
- /**
- * Commit hash associated to deployment
- */
- commitHash?: string;
- /**
- * Whether or not the deployment should be considered to be
- * in a dirty commit state
- */
- commitDirty?: boolean;
- /**
- * Path to the project's functions directory. Default uses
- * the current working directory + /functions since this is
- * typically called in a CLI
- */
- functionsDirectory?: string;
- /**
- * Whether to run bundling on `_worker.js` before deploying.
- * Default: true
- */
- bundle?: boolean;
- }
- declare type ReferrerPolicy =
- | ''
- | 'no-referrer'
- | 'no-referrer-when-downgrade'
- | 'origin'
- | 'origin-when-cross-origin'
- | 'same-origin'
- | 'strict-origin'
- | 'strict-origin-when-cross-origin'
- | 'unsafe-url';
- declare class Request_2 implements BodyMixin {
- constructor (input: RequestInfo_2, init?: RequestInit_2)
- readonly cache: RequestCache
- readonly credentials: RequestCredentials
- readonly destination: RequestDestination
- readonly headers: Headers_2
- readonly integrity: string
- readonly method: string
- readonly mode: RequestMode
- readonly redirect: RequestRedirect
- readonly referrerPolicy: string
- readonly url: string
- readonly keepalive: boolean
- readonly signal: AbortSignal
- readonly duplex: RequestDuplex
- readonly body: ReadableStream_2 | null
- readonly bodyUsed: boolean
- readonly arrayBuffer: () => Promise<ArrayBuffer>
- readonly blob: () => Promise<Blob_2>
- readonly formData: () => Promise<FormData_2>
- readonly json: () => Promise<unknown>
- readonly text: () => Promise<string>
- readonly clone: () => Request_2
- }
- declare type RequestCache =
- | 'default'
- | 'force-cache'
- | 'no-cache'
- | 'no-store'
- | 'only-if-cached'
- | 'reload'
- declare type RequestCredentials = 'omit' | 'include' | 'same-origin'
- declare type RequestDestination =
- | ''
- | 'audio'
- | 'audioworklet'
- | 'document'
- | 'embed'
- | 'font'
- | 'image'
- | 'manifest'
- | 'object'
- | 'paintworklet'
- | 'report'
- | 'script'
- | 'sharedworker'
- | 'style'
- | 'track'
- | 'video'
- | 'worker'
- | 'xslt'
- declare type RequestDuplex = 'half'
- declare type RequestInfo_2 = string | URL_2 | Request_2
- declare interface RequestInit_2 {
- method?: string
- keepalive?: boolean
- headers?: HeadersInit_2
- body?: BodyInit_2
- redirect?: RequestRedirect
- integrity?: string
- signal?: AbortSignal
- credentials?: RequestCredentials
- mode?: RequestMode
- referrer?: string
- referrerPolicy?: ReferrerPolicy
- window?: null
- dispatcher?: Dispatcher
- duplex?: RequestDuplex
- }
- declare type RequestMode = 'cors' | 'navigate' | 'no-cors' | 'same-origin'
- declare type RequestRedirect = 'error' | 'follow' | 'manual'
- declare class Response_2 implements BodyMixin {
- constructor (body?: BodyInit_2, init?: ResponseInit_2)
- readonly headers: Headers_2
- readonly ok: boolean
- readonly status: number
- readonly statusText: string
- readonly type: ResponseType
- readonly url: string
- readonly redirected: boolean
- readonly body: ReadableStream_2 | null
- readonly bodyUsed: boolean
- readonly arrayBuffer: () => Promise<ArrayBuffer>
- readonly blob: () => Promise<Blob_2>
- readonly formData: () => Promise<FormData_2>
- readonly json: () => Promise<unknown>
- readonly text: () => Promise<string>
- readonly clone: () => Response_2
- static error (): Response_2
- static json(data: any, init?: ResponseInit_2): Response_2
- static redirect (url: string | URL_2, status: ResponseRedirectStatus): Response_2
- }
- declare interface ResponseInit_2 {
- readonly status?: number
- readonly statusText?: string
- readonly headers?: HeadersInit_2
- }
- declare type ResponseRedirectStatus = 301 | 302 | 303 | 307 | 308
- declare type ResponseType =
- | 'basic'
- | 'cors'
- | 'default'
- | 'error'
- | 'opaque'
- | 'opaqueredirect'
- declare type Route = SimpleRoute | ZoneIdRoute | ZoneNameRoute | CustomDomainRoute;
- /**
- * A bundling resolver rule, defining the modules type for paths that match the specified globs.
- */
- declare type Rule = {
- type: ConfigModuleRuleType;
- globs: string[];
- fallthrough?: boolean;
- };
- declare type SimpleRoute = string;
- declare interface SpecIterable<T> {
- [Symbol.iterator](): SpecIterator<T>;
- }
- declare interface SpecIterableIterator<T> extends SpecIterator<T> {
- [Symbol.iterator](): SpecIterableIterator<T>;
- }
- declare interface SpecIterator<T, TReturn = any, TNext = undefined> {
- next(...args: [] | [TNext]): IteratorResult<T, TReturn>;
- }
- declare type TailConsumer = {
- /** The name of the service tail events will be forwarded to. */
- service: string;
- /** (Optional) The environt of the service. */
- environment?: string;
- };
- /**
- * unstable_dev starts a wrangler dev server, and returns a promise that resolves with utility functions to interact with it.
- */
- export declare function unstable_dev(script: string, options?: UnstableDevOptions, apiOptions?: unknown): Promise<UnstableDevWorker>;
- export declare const unstable_pages: {
- deploy: typeof deploy;
- };
- export declare interface UnstableDevOptions {
- config?: string;
- env?: string;
- ip?: string;
- port?: number;
- bundle?: boolean;
- inspectorPort?: number;
- localProtocol?: "http" | "https";
- assets?: string;
- site?: string;
- siteInclude?: string[];
- siteExclude?: string[];
- nodeCompat?: boolean;
- compatibilityDate?: string;
- compatibilityFlags?: string[];
- persist?: boolean;
- persistTo?: string;
- vars?: Record<string, string | Json>;
- kv?: {
- binding: string;
- id: string;
- preview_id?: string;
- }[];
- durableObjects?: {
- name: string;
- class_name: string;
- script_name?: string | undefined;
- environment?: string | undefined;
- }[];
- r2?: {
- binding: string;
- bucket_name: string;
- preview_bucket_name?: string;
- }[];
- moduleRoot?: string;
- rules?: Rule[];
- logLevel?: "none" | "info" | "error" | "log" | "warn" | "debug";
- inspect?: boolean;
- local?: boolean;
- accountId?: string;
- experimental?: {
- processEntrypoint?: boolean;
- additionalModules?: CfModule[];
- d1Databases?: Environment["d1_databases"];
- disableExperimentalWarning?: boolean;
- disableDevRegistry?: boolean;
- enablePagesAssetsServiceBinding?: EnablePagesAssetsServiceBindingOptions;
- forceLocal?: boolean;
- liveReload?: boolean;
- showInteractiveDevSession?: boolean;
- testMode?: boolean;
- testScheduled?: boolean;
- watch?: boolean;
- };
- }
- export declare interface UnstableDevWorker {
- port: number;
- address: string;
- stop: () => Promise<void>;
- fetch: (input?: RequestInfo_2, init?: RequestInit_2) => Promise<Response_2>;
- waitUntilExit: () => Promise<void>;
- }
- /**
- * uploads an mTLS certificate and private key pair to the account mTLS certificate store
- */
- export declare function uploadMTlsCertificate(accountId: string, body: MTlsCertificateBody): Promise<MTlsCertificateResponse>;
- /**
- * reads an mTLS certificate and private key pair from disk and uploads it to the account mTLS certificate store
- */
- export declare function uploadMTlsCertificateFromFs(accountId: string, details: MTlsCertificateUploadDetails): Promise<MTlsCertificateResponse>;
- declare type ZoneIdRoute = {
- pattern: string;
- zone_id: string;
- custom_domain?: boolean;
- };
- declare type ZoneNameRoute = {
- pattern: string;
- zone_name: string;
- custom_domain?: boolean;
- };
- export { }
|