chore: refresh Wrangler types

This commit is contained in:
xixu-me committed 2026-08-17 10:56:47 +08:00
1 parent c2c169a61d
commit 1a7197c9cf
1 file changed
+187 -24
+187 -24
View File
@@ -1,6 +1,6 @@
/* eslint-disable */ /* eslint-disable */
// Generated by Wrangler by running `wrangler types` (hash: 0c6962cb0ba4ddc8c608c52059e64907) // Generated by Wrangler by running `wrangler types` (hash: 0c6962cb0ba4ddc8c608c52059e64907)
// Runtime types generated with workerd@1.20260701.1 2026-03-19 nodejs_compat // Runtime types generated with workerd@1.20260811.1 2026-03-19 nodejs_compat
interface __BaseEnv_Env { interface __BaseEnv_Env {
PASTES_BUCKET: R2Bucket; PASTES_BUCKET: R2Bucket;
DB: D1Database; DB: D1Database;
@@ -458,6 +458,7 @@ interface ExecutionContext<Props = unknown> {
cache?: CacheContext; cache?: CacheContext;
readonly access?: CloudflareAccessContext; readonly access?: CloudflareAccessContext;
tracing: Tracing; tracing: Tracing;
abort(reason?: any): void;
} }
type ExportedHandlerFetchHandler<Env = unknown, CfHostMetadata = unknown, Props = unknown> = (request: Request<CfHostMetadata, IncomingRequestCfProperties<CfHostMetadata>>, env: Env, ctx: ExecutionContext<Props>) => Response | Promise<Response>; type ExportedHandlerFetchHandler<Env = unknown, CfHostMetadata = unknown, Props = unknown> = (request: Request<CfHostMetadata, IncomingRequestCfProperties<CfHostMetadata>>, env: Env, ctx: ExecutionContext<Props>) => Response | Promise<Response>;
type ExportedHandlerConnectHandler<Env = unknown, Props = unknown> = (socket: Socket, env: Env, ctx: ExecutionContext<Props>) => void | Promise<void>; type ExportedHandlerConnectHandler<Env = unknown, Props = unknown> = (socket: Socket, env: Env, ctx: ExecutionContext<Props>) => void | Promise<void>;
@@ -546,7 +547,7 @@ declare abstract class DurableObjectNamespace<T extends Rpc.DurableObjectBranded
getByName(name: string, options?: DurableObjectNamespaceGetDurableObjectOptions): DurableObjectStub<T>; getByName(name: string, options?: DurableObjectNamespaceGetDurableObjectOptions): DurableObjectStub<T>;
jurisdiction(jurisdiction: DurableObjectJurisdiction): DurableObjectNamespace<T>; jurisdiction(jurisdiction: DurableObjectJurisdiction): DurableObjectNamespace<T>;
} }
type DurableObjectJurisdiction = "eu" | "fedramp" | "fedramp-high"; type DurableObjectJurisdiction = "eu" | "fedramp" | "fedramp-high" | "us";
interface DurableObjectNamespaceNewUniqueIdOptions { interface DurableObjectNamespaceNewUniqueIdOptions {
jurisdiction?: DurableObjectJurisdiction; jurisdiction?: DurableObjectJurisdiction;
} }
@@ -2791,6 +2792,12 @@ interface TraceLog {
readonly timestamp: number; readonly timestamp: number;
readonly level: string; readonly level: string;
readonly message: any; readonly message: any;
readonly errorInfo?: (TraceLogErrorInfo | null)[];
}
interface TraceLogErrorInfo {
name: string;
message: string;
stack?: string;
} }
interface TraceException { interface TraceException {
readonly timestamp: number; readonly timestamp: number;
@@ -3331,18 +3338,26 @@ interface ContainerExecOptions {
cwd?: string; cwd?: string;
env?: Record<string, string>; env?: Record<string, string>;
user?: string; user?: string;
signal?: AbortSignal;
pty?: boolean | ContainerExecPtyOptions;
stdin?: ReadableStream | "pipe"; stdin?: ReadableStream | "pipe";
stdout?: "pipe" | "ignore"; stdout?: "pipe" | "ignore";
stderr?: "pipe" | "ignore" | "combined"; stderr?: "pipe" | "ignore" | "combined";
} }
interface ContainerExecPtyOptions {
cols?: number;
rows?: number;
}
interface ExecProcess { interface ExecProcess {
readonly stdin: WritableStream | null; readonly stdin: WritableStream | null;
readonly stdout: ReadableStream | null; readonly stdout: ReadableStream | null;
readonly stderr: ReadableStream | null; readonly stderr: ReadableStream | null;
readonly pid: number; readonly pid: number;
readonly isPty: boolean;
readonly exitCode: Promise<number>; readonly exitCode: Promise<number>;
output(): Promise<ExecOutput>; output(): Promise<ExecOutput>;
kill(signal?: number): void; kill(signal?: number): void;
resize(cols: number, rows: number): void;
} }
interface Container { interface Container {
get running(): boolean; get running(): boolean;
@@ -3389,6 +3404,11 @@ interface ContainerStartupOptions {
directorySnapshots?: ContainerDirectorySnapshotRestoreParams[]; directorySnapshots?: ContainerDirectorySnapshotRestoreParams[];
containerSnapshot?: ContainerSnapshot; containerSnapshot?: ContainerSnapshot;
} }
interface ContainerStartResources {
vcpu: number;
memoryMib: number;
diskMb: number;
}
/** /**
* The **`MessagePort`** interface of the Channel Messaging API represents one of the two ports of a MessageChannel, allowing messages to be sent from one port and listening out for them arriving at the other. * The **`MessagePort`** interface of the Channel Messaging API represents one of the two ports of a MessageChannel, allowing messages to be sent from one port and listening out for them arriving at the other.
* *
@@ -3529,11 +3549,13 @@ declare abstract class Performance {
interface Tracing { interface Tracing {
enterSpan<T, A extends unknown[]>(name: string, callback: (span: Span, ...args: A) => T, ...args: A): T; enterSpan<T, A extends unknown[]>(name: string, callback: (span: Span, ...args: A) => T, ...args: A): T;
startActiveSpan<T, A extends unknown[]>(name: string, callback: (span: Span, ...args: A) => T, ...args: A): T; startActiveSpan<T, A extends unknown[]>(name: string, callback: (span: Span, ...args: A) => T, ...args: A): T;
startSpan(name: string): Span;
Span: typeof Span; Span: typeof Span;
} }
declare abstract class Span { declare abstract class Span {
get isTraced(): boolean; get isTraced(): boolean;
setAttribute(key: string, value?: (boolean | number | string)): void; setAttribute(key: string, value: boolean | number | string): this;
setAttributes(attributes: Record<string, boolean | number | string | undefined>): this;
end(): void; end(): void;
} }
/** /**
@@ -4173,6 +4195,13 @@ type AiSearchListItemsParams = {
source?: string; source?: string;
/** JSON-encoded Vectorize filter for metadata filtering. */ /** JSON-encoded Vectorize filter for metadata filtering. */
metadata_filter?: string; metadata_filter?: string;
/** Filter items by their unique ID. Returns at most one item. */
item_id?: string;
/**
* Filter items by their exact key (object key / filename). Keys are unique
* per source, so combine with `source` to disambiguate across data sources.
*/
key?: string;
}; };
type AiSearchListItemsResponse = { type AiSearchListItemsResponse = {
result: AiSearchItemInfo[]; result: AiSearchItemInfo[];
@@ -12241,6 +12270,13 @@ interface ForwardableEmailMessage extends EmailMessage {
* @returns A promise that resolves when the email message is replied. * @returns A promise that resolves when the email message is replied.
*/ */
reply(message: EmailMessage): Promise<EmailSendResult>; reply(message: EmailMessage): Promise<EmailSendResult>;
/**
* Reply to the sender of this email message with a message built from the given
* fields. Threading headers (In-Reply-To/References) are set automatically.
* @param builder The reply message contents.
* @returns A promise that resolves when the email message is replied.
*/
reply(builder: EmailReplyMessageBuilder): Promise<EmailSendResult>;
} }
/** A file attachment for an email message */ /** A file attachment for an email message */
type EmailAttachment = { type EmailAttachment = {
@@ -12262,22 +12298,45 @@ interface EmailAddress {
email: string; email: string;
} }
/** /**
* A binding that allows a Worker to send email messages. * Recipient fields for `SendEmail.send()`. At least one of `to`, `cc`, or
* `bcc` must be provided.
*/ */
interface SendEmail { type EmailDestinations = {
send(message: EmailMessage): Promise<EmailSendResult>; to?: string | EmailAddress | (string | EmailAddress)[];
send(builder: {
from: string | EmailAddress;
to: string | EmailAddress | (string | EmailAddress)[];
subject: string;
replyTo?: string | EmailAddress;
cc?: string | EmailAddress | (string | EmailAddress)[]; cc?: string | EmailAddress | (string | EmailAddress)[];
bcc?: string | EmailAddress | (string | EmailAddress)[]; bcc?: string | EmailAddress | (string | EmailAddress)[];
} & ({
to: string | EmailAddress | (string | EmailAddress)[];
} | {
cc: string | EmailAddress | (string | EmailAddress)[];
} | {
bcc: string | EmailAddress | (string | EmailAddress)[];
});
/**
* Fields shared by all composed emails (no recipients). Used directly by
* `ForwardableEmailMessage.reply()`, which always replies to the original
* sender, and extended by `EmailMessageBuilder` for `SendEmail.send()`.
*/
interface EmailReplyMessageBuilder {
from: string | EmailAddress;
subject: string;
replyTo?: string | EmailAddress;
headers?: Record<string, string>; headers?: Record<string, string>;
text?: string; text?: string;
html?: string; html?: string;
attachments?: EmailAttachment[]; attachments?: EmailAttachment[];
}): Promise<EmailSendResult>; }
/**
* Fields for composing an email without constructing raw MIME, for
* `SendEmail.send()`. Requires at least one of `to`, `cc`, or `bcc`.
*/
type EmailMessageBuilder = EmailReplyMessageBuilder & EmailDestinations;
/**
* A binding that allows a Worker to send email messages.
*/
interface SendEmail {
send(message: EmailMessage): Promise<EmailSendResult>;
send(builder: EmailMessageBuilder): Promise<EmailSendResult>;
} }
declare abstract class EmailEvent extends ExtendableEvent { declare abstract class EmailEvent extends ExtendableEvent {
readonly message: ForwardableEmailMessage; readonly message: ForwardableEmailMessage;
@@ -12431,6 +12490,15 @@ interface Hyperdrive {
* for your database. * for your database.
*/ */
readonly host: string; readonly host: string;
/*
* A synthetic IPv4 address (in the reserved 240.0.0.0/4 range) that, like the
* host field, is only valid within the context of the currently running
* Worker and, when passed into the `connect()` function from the
* "cloudflare:sockets" module, will connect to the Hyperdrive instance for
* your database. This is provided for database drivers that require the host
* to be an IP literal rather than a hostname.
*/
readonly ip: string;
/* /*
* The port that must be paired the the host field when connecting. * The port that must be paired the the host field when connecting.
*/ */
@@ -13099,6 +13167,11 @@ declare namespace CloudflareWorkersModule {
export type WorkflowDurationLabel = 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year'; export type WorkflowDurationLabel = 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year';
export type WorkflowSleepDuration = `${number} ${WorkflowDurationLabel}${'s' | ''}` | number; export type WorkflowSleepDuration = `${number} ${WorkflowDurationLabel}${'s' | ''}` | number;
export type WorkflowDelayDuration = WorkflowSleepDuration; export type WorkflowDelayDuration = WorkflowSleepDuration;
export type WorkflowDynamicDelayContext = {
ctx: WorkflowStepContext<WorkflowDelayFunction>;
error: Error;
};
export type WorkflowDelayFunction = (input: WorkflowDynamicDelayContext) => WorkflowDelayDuration | Promise<WorkflowDelayDuration>;
export type WorkflowTimeoutDuration = WorkflowSleepDuration; export type WorkflowTimeoutDuration = WorkflowSleepDuration;
export type WorkflowRetentionDuration = WorkflowSleepDuration; export type WorkflowRetentionDuration = WorkflowSleepDuration;
export type WorkflowBackoff = 'constant' | 'linear' | 'exponential'; export type WorkflowBackoff = 'constant' | 'linear' | 'exponential';
@@ -13106,12 +13179,32 @@ declare namespace CloudflareWorkersModule {
export type WorkflowStepConfig = { export type WorkflowStepConfig = {
retries?: { retries?: {
limit: number; limit: number;
delay: WorkflowDelayDuration | number; delay: WorkflowDelayDuration | number | WorkflowDelayFunction;
backoff?: WorkflowBackoff; backoff?: WorkflowBackoff;
}; };
timeout?: WorkflowTimeoutDuration | number; timeout?: WorkflowTimeoutDuration | number;
sensitive?: WorkflowStepSensitivity; sensitive?: WorkflowStepSensitivity;
}; };
// Internal discriminators used only for `WorkflowStep.do` overload
// resolution. They mirror `WorkflowStepConfig` but pin `retries.delay` to a
// single kind so the callback context can be narrowed based on the shape of
// the config argument (rather than on an inferred type parameter, which is
// lost when the caller supplies an explicit return-type argument). Not
// exported: they must not widen the public type surface.
type WorkflowStepConfigWithStaticDelay = Omit<WorkflowStepConfig, 'retries'> & {
retries?: {
limit: number;
delay: WorkflowDelayDuration | number;
backoff?: WorkflowBackoff;
};
};
type WorkflowStepConfigWithDelayFunction = Omit<WorkflowStepConfig, 'retries'> & {
retries: {
limit: number;
delay: WorkflowDelayFunction;
backoff?: WorkflowBackoff;
};
};
export type WorkflowStepRollbackConfig = Pick<WorkflowStepConfig, 'retries' | 'timeout'>; export type WorkflowStepRollbackConfig = Pick<WorkflowStepConfig, 'retries' | 'timeout'>;
export type WorkflowCronSchedule = { export type WorkflowCronSchedule = {
/** Cron expression that triggered this event. */ /** Cron expression that triggered this event. */
@@ -13132,28 +13225,51 @@ declare namespace CloudflareWorkersModule {
type: string; type: string;
sensitive?: WorkflowStepSensitivity; sensitive?: WorkflowStepSensitivity;
}; };
export type WorkflowStepContext = { export type WorkflowStepContext<Delay = WorkflowDelayDuration | number> = {
step: { step: {
name: string; name: string;
count: number; count: number;
}; };
attempt: number; attempt: number;
config: WorkflowStepConfig; config: {
retries?: {
limit: number;
backoff?: WorkflowBackoff;
} & (Delay extends WorkflowDelayFunction ? {} : {
delay: WorkflowDelayDuration | number;
});
timeout?: WorkflowTimeoutDuration | number;
sensitive?: WorkflowStepSensitivity;
}; };
export type WorkflowRollbackContext<T = unknown> = { };
ctx: WorkflowStepContext; // The rollback handler receives the step context, so it mirrors the same
// delay discriminant as the step callback: when the step was configured with
// a dynamic delay function the resolved `config.retries.delay` is omitted,
// otherwise it is present. `Delay` is threaded from the `WorkflowStep.do`
// overload that matched the step config.
export type WorkflowRollbackContext<T = unknown, Delay = WorkflowDelayDuration | number> = {
ctx: WorkflowStepContext<Delay>;
error: Error; error: Error;
output: T | undefined; output: T | undefined;
/** @deprecated Use `ctx.step.name` and `ctx.step.count` instead. */ /** @deprecated Use `ctx.step.name` and `ctx.step.count` instead. */
stepName: string; stepName: string;
}; };
export type WorkflowRollbackHandler<T = unknown> = (ctx: WorkflowRollbackContext<T>) => Promise<void>; export type WorkflowRollbackHandler<T = unknown, Delay = WorkflowDelayDuration | number> = (ctx: WorkflowRollbackContext<T, Delay>) => Promise<void>;
export type WorkflowStepRollbackOptions<T = unknown> = { export type WorkflowStepRollbackOptions<T = unknown, Delay = WorkflowDelayDuration | number> = {
rollback: WorkflowRollbackHandler<T>; rollback: WorkflowRollbackHandler<T, Delay>;
rollbackConfig?: WorkflowStepRollbackConfig; rollbackConfig?: WorkflowStepRollbackConfig;
}; };
export abstract class WorkflowStep { export abstract class WorkflowStep {
do<T extends Rpc.Serializable<T>>(name: string, callback: (ctx: WorkflowStepContext) => Promise<T>, rollbackOptions?: WorkflowStepRollbackOptions<T>): Promise<T>; do<T extends Rpc.Serializable<T>>(name: string, callback: (ctx: WorkflowStepContext) => Promise<T>, rollbackOptions?: WorkflowStepRollbackOptions<T>): Promise<T>;
// The config overloads discriminate on the shape of `config.retries.delay`
// so the callback context reflects whether the resolved delay is present
// (static delay) or omitted (dynamic delay function). Each has a single
// type parameter, so an explicit return-type argument (`do<T>(...)`) still
// resolves here. ORDERING IS LOAD-BEARING: the broad `WorkflowStepConfig`
// fallback MUST remain last, otherwise it shadows the discriminating
// overloads and narrowing is silently lost.
do<T extends Rpc.Serializable<T>>(name: string, config: WorkflowStepConfigWithDelayFunction, callback: (ctx: WorkflowStepContext<WorkflowDelayFunction>) => Promise<T>, rollbackOptions?: WorkflowStepRollbackOptions<T, WorkflowDelayFunction>): Promise<T>;
do<T extends Rpc.Serializable<T>>(name: string, config: WorkflowStepConfigWithStaticDelay, callback: (ctx: WorkflowStepContext<WorkflowDelayDuration | number>) => Promise<T>, rollbackOptions?: WorkflowStepRollbackOptions<T, WorkflowDelayDuration | number>): Promise<T>;
do<T extends Rpc.Serializable<T>>(name: string, config: WorkflowStepConfig, callback: (ctx: WorkflowStepContext) => Promise<T>, rollbackOptions?: WorkflowStepRollbackOptions<T>): Promise<T>; do<T extends Rpc.Serializable<T>>(name: string, config: WorkflowStepConfig, callback: (ctx: WorkflowStepContext) => Promise<T>, rollbackOptions?: WorkflowStepRollbackOptions<T>): Promise<T>;
sleep: (name: string, duration: WorkflowSleepDuration) => Promise<void>; sleep: (name: string, duration: WorkflowSleepDuration) => Promise<void>;
sleepUntil: (name: string, timestamp: Date | number) => Promise<void>; sleepUntil: (name: string, timestamp: Date | number) => Promise<void>;
@@ -13929,11 +14045,12 @@ type MarkdownDocument = {
name: string; name: string;
blob: Blob; blob: Blob;
}; };
type OutputFormat = 'markdown' | 'text';
type ConversionResponse = { type ConversionResponse = {
id: string; id: string;
name: string; name: string;
mimeType: string; mimeType: string;
format: 'markdown'; format: OutputFormat;
tokens: number; tokens: number;
data: string; data: string;
} | { } | {
@@ -13950,7 +14067,11 @@ type EmbeddedImageConversionOptions = ImageConversionOptions & {
convert?: boolean; convert?: boolean;
maxConvertedImages?: number; maxConvertedImages?: number;
}; };
type ConversionOutputOptions = {
format?: OutputFormat;
};
type ConversionOptions = { type ConversionOptions = {
output?: ConversionOutputOptions;
html?: { html?: {
images?: EmbeddedImageConversionOptions & { images?: EmbeddedImageConversionOptions & {
convertOGImage?: boolean; convertOGImage?: boolean;
@@ -14064,6 +14185,7 @@ declare namespace TailStream {
readonly dispatchNamespace?: string; readonly dispatchNamespace?: string;
readonly entrypoint?: string; readonly entrypoint?: string;
readonly executionModel: string; readonly executionModel: string;
readonly durableObjectId?: string;
readonly scriptName?: string; readonly scriptName?: string;
readonly scriptTags?: string[]; readonly scriptTags?: string[];
readonly scriptVersion?: ScriptVersion; readonly scriptVersion?: ScriptVersion;
@@ -14098,11 +14220,22 @@ declare namespace TailStream {
readonly message: string; readonly message: string;
readonly stack?: string; readonly stack?: string;
} }
interface Log { interface TailStreamErrorInfo {
readonly name: string;
readonly message: string;
readonly stack?: string;
}
type Log = {
readonly type: "log"; readonly type: "log";
readonly level: "debug" | "error" | "info" | "log" | "warn"; readonly level: "debug" | "error" | "info" | "log" | "warn";
readonly errorInfo?: readonly (TailStreamErrorInfo | null)[];
} & ({
readonly message: object; readonly message: object;
} readonly truncated?: false;
} | {
readonly message: string;
readonly truncated: true;
});
interface DroppedEventsDiagnostic { interface DroppedEventsDiagnostic {
readonly diagnosticsType: "droppedEvents"; readonly diagnosticsType: "droppedEvents";
readonly count: number; readonly count: number;
@@ -14580,7 +14713,25 @@ declare abstract class Workflow<PARAMS = unknown> {
* @returns A promise that resolves with a list of handles for the created instances. * @returns A promise that resolves with a list of handles for the created instances.
*/ */
public createBatch(batch: WorkflowInstanceCreateOptions<PARAMS>[]): Promise<WorkflowInstance[]>; public createBatch(batch: WorkflowInstanceCreateOptions<PARAMS>[]): Promise<WorkflowInstance[]>;
/**
* Delete a batch of Workflow instances and their stored state.
* `deleteBatch` is limited to 100 instances at a time. Duplicate IDs are deleted once.
* The result contains one entry for each input position; IDs that do not exist are returned as per-instance errors.
* @param instanceIds IDs of the Workflow instances to delete
* @returns A promise that resolves with the successfully deleted instances and any per-instance errors.
*/
public deleteBatch(instanceIds: string[]): Promise<WorkflowBatchDeleteResult>;
} }
type WorkflowBatchDeleteResult = {
deleted: {
id: string;
}[];
errors: {
id: string;
code: number;
message: string;
}[];
};
type WorkflowDurationLabel = 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year'; type WorkflowDurationLabel = 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year';
type WorkflowSleepDuration = `${number} ${WorkflowDurationLabel}${'s' | ''}` | number; type WorkflowSleepDuration = `${number} ${WorkflowDurationLabel}${'s' | ''}` | number;
type WorkflowRetentionDuration = WorkflowSleepDuration; type WorkflowRetentionDuration = WorkflowSleepDuration;
@@ -14618,6 +14769,13 @@ interface WorkflowError {
code?: number; code?: number;
message: string; message: string;
} }
interface WorkflowInstanceTerminateOptions {
/**
* If true, run registered rollback handlers before terminating the instance.
* Only steps that registered rollback handlers are rolled back.
*/
rollback?: boolean;
}
interface WorkflowInstanceRestartOptions { interface WorkflowInstanceRestartOptions {
/** /**
* Restart from a specific step. If omitted, the instance restarts from the beginning. * Restart from a specific step. If omitted, the instance restarts from the beginning.
@@ -14651,14 +14809,19 @@ declare abstract class WorkflowInstance {
public resume(): Promise<void>; public resume(): Promise<void>;
/** /**
* Terminate the instance. If it is errored, terminated or complete, an error will be thrown. * Terminate the instance. If it is errored, terminated or complete, an error will be thrown.
* @param options Options for termination, including whether registered rollback handlers should run.
*/ */
public terminate(): Promise<void>; public terminate(options?: WorkflowInstanceTerminateOptions): Promise<void>;
/** /**
* Restart the instance. Optionally restart from a specific step, preserving * Restart the instance. Optionally restart from a specific step, preserving
* cached results for all steps before it. * cached results for all steps before it.
* @param options Options for the restart, including an optional step to restart from. * @param options Options for the restart, including an optional step to restart from.
*/ */
public restart(options?: WorkflowInstanceRestartOptions): Promise<void>; public restart(options?: WorkflowInstanceRestartOptions): Promise<void>;
/**
* Delete the instance and its stored state.
*/
public delete(): Promise<void>;
/** /**
* Returns the current status of the instance. * Returns the current status of the instance.
*/ */