From 1a7197c9cf27cd332f3d3d59ff3b93dff405b345 Mon Sep 17 00:00:00 2001 From: Xi Xu Date: Mon, 17 Aug 2026 10:56:47 +0800 Subject: [PATCH] chore: refresh Wrangler types --- worker-configuration.d.ts | 217 +++++++++++++++++++++++++++++++++----- 1 file changed, 190 insertions(+), 27 deletions(-) diff --git a/worker-configuration.d.ts b/worker-configuration.d.ts index 72d7697..e2345d7 100644 --- a/worker-configuration.d.ts +++ b/worker-configuration.d.ts @@ -1,6 +1,6 @@ /* eslint-disable */ // 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 { PASTES_BUCKET: R2Bucket; DB: D1Database; @@ -458,6 +458,7 @@ interface ExecutionContext { cache?: CacheContext; readonly access?: CloudflareAccessContext; tracing: Tracing; + abort(reason?: any): void; } type ExportedHandlerFetchHandler = (request: Request>, env: Env, ctx: ExecutionContext) => Response | Promise; type ExportedHandlerConnectHandler = (socket: Socket, env: Env, ctx: ExecutionContext) => void | Promise; @@ -546,7 +547,7 @@ declare abstract class DurableObjectNamespace; jurisdiction(jurisdiction: DurableObjectJurisdiction): DurableObjectNamespace; } -type DurableObjectJurisdiction = "eu" | "fedramp" | "fedramp-high"; +type DurableObjectJurisdiction = "eu" | "fedramp" | "fedramp-high" | "us"; interface DurableObjectNamespaceNewUniqueIdOptions { jurisdiction?: DurableObjectJurisdiction; } @@ -2791,6 +2792,12 @@ interface TraceLog { readonly timestamp: number; readonly level: string; readonly message: any; + readonly errorInfo?: (TraceLogErrorInfo | null)[]; +} +interface TraceLogErrorInfo { + name: string; + message: string; + stack?: string; } interface TraceException { readonly timestamp: number; @@ -3331,18 +3338,26 @@ interface ContainerExecOptions { cwd?: string; env?: Record; user?: string; + signal?: AbortSignal; + pty?: boolean | ContainerExecPtyOptions; stdin?: ReadableStream | "pipe"; stdout?: "pipe" | "ignore"; stderr?: "pipe" | "ignore" | "combined"; } +interface ContainerExecPtyOptions { + cols?: number; + rows?: number; +} interface ExecProcess { readonly stdin: WritableStream | null; readonly stdout: ReadableStream | null; readonly stderr: ReadableStream | null; readonly pid: number; + readonly isPty: boolean; readonly exitCode: Promise; output(): Promise; kill(signal?: number): void; + resize(cols: number, rows: number): void; } interface Container { get running(): boolean; @@ -3389,6 +3404,11 @@ interface ContainerStartupOptions { directorySnapshots?: ContainerDirectorySnapshotRestoreParams[]; 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. * @@ -3529,11 +3549,13 @@ declare abstract class Performance { interface Tracing { enterSpan(name: string, callback: (span: Span, ...args: A) => T, ...args: A): T; startActiveSpan(name: string, callback: (span: Span, ...args: A) => T, ...args: A): T; + startSpan(name: string): Span; Span: typeof Span; } declare abstract class Span { get isTraced(): boolean; - setAttribute(key: string, value?: (boolean | number | string)): void; + setAttribute(key: string, value: boolean | number | string): this; + setAttributes(attributes: Record): this; end(): void; } /** @@ -4173,6 +4195,13 @@ type AiSearchListItemsParams = { source?: string; /** JSON-encoded Vectorize filter for metadata filtering. */ 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 = { result: AiSearchItemInfo[]; @@ -12241,6 +12270,13 @@ interface ForwardableEmailMessage extends EmailMessage { * @returns A promise that resolves when the email message is replied. */ reply(message: EmailMessage): Promise; + /** + * 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; } /** A file attachment for an email message */ type EmailAttachment = { @@ -12261,23 +12297,46 @@ interface EmailAddress { name: string; email: string; } +/** + * Recipient fields for `SendEmail.send()`. At least one of `to`, `cc`, or + * `bcc` must be provided. + */ +type EmailDestinations = { + to?: string | EmailAddress | (string | EmailAddress)[]; + cc?: 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; + text?: string; + html?: string; + attachments?: EmailAttachment[]; +} +/** + * 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; - send(builder: { - from: string | EmailAddress; - to: string | EmailAddress | (string | EmailAddress)[]; - subject: string; - replyTo?: string | EmailAddress; - cc?: string | EmailAddress | (string | EmailAddress)[]; - bcc?: string | EmailAddress | (string | EmailAddress)[]; - headers?: Record; - text?: string; - html?: string; - attachments?: EmailAttachment[]; - }): Promise; + send(builder: EmailMessageBuilder): Promise; } declare abstract class EmailEvent extends ExtendableEvent { readonly message: ForwardableEmailMessage; @@ -12431,6 +12490,15 @@ interface Hyperdrive { * for your database. */ 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. */ @@ -13099,6 +13167,11 @@ declare namespace CloudflareWorkersModule { export type WorkflowDurationLabel = 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year'; export type WorkflowSleepDuration = `${number} ${WorkflowDurationLabel}${'s' | ''}` | number; export type WorkflowDelayDuration = WorkflowSleepDuration; + export type WorkflowDynamicDelayContext = { + ctx: WorkflowStepContext; + error: Error; + }; + export type WorkflowDelayFunction = (input: WorkflowDynamicDelayContext) => WorkflowDelayDuration | Promise; export type WorkflowTimeoutDuration = WorkflowSleepDuration; export type WorkflowRetentionDuration = WorkflowSleepDuration; export type WorkflowBackoff = 'constant' | 'linear' | 'exponential'; @@ -13106,12 +13179,32 @@ declare namespace CloudflareWorkersModule { export type WorkflowStepConfig = { retries?: { limit: number; - delay: WorkflowDelayDuration | number; + delay: WorkflowDelayDuration | number | WorkflowDelayFunction; backoff?: WorkflowBackoff; }; timeout?: WorkflowTimeoutDuration | number; 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 & { + retries?: { + limit: number; + delay: WorkflowDelayDuration | number; + backoff?: WorkflowBackoff; + }; + }; + type WorkflowStepConfigWithDelayFunction = Omit & { + retries: { + limit: number; + delay: WorkflowDelayFunction; + backoff?: WorkflowBackoff; + }; + }; export type WorkflowStepRollbackConfig = Pick; export type WorkflowCronSchedule = { /** Cron expression that triggered this event. */ @@ -13132,28 +13225,51 @@ declare namespace CloudflareWorkersModule { type: string; sensitive?: WorkflowStepSensitivity; }; - export type WorkflowStepContext = { + export type WorkflowStepContext = { step: { name: string; count: 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 = { - 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 = { + ctx: WorkflowStepContext; error: Error; output: T | undefined; /** @deprecated Use `ctx.step.name` and `ctx.step.count` instead. */ stepName: string; }; - export type WorkflowRollbackHandler = (ctx: WorkflowRollbackContext) => Promise; - export type WorkflowStepRollbackOptions = { - rollback: WorkflowRollbackHandler; + export type WorkflowRollbackHandler = (ctx: WorkflowRollbackContext) => Promise; + export type WorkflowStepRollbackOptions = { + rollback: WorkflowRollbackHandler; rollbackConfig?: WorkflowStepRollbackConfig; }; export abstract class WorkflowStep { do>(name: string, callback: (ctx: WorkflowStepContext) => Promise, rollbackOptions?: WorkflowStepRollbackOptions): Promise; + // 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(...)`) 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>(name: string, config: WorkflowStepConfigWithDelayFunction, callback: (ctx: WorkflowStepContext) => Promise, rollbackOptions?: WorkflowStepRollbackOptions): Promise; + do>(name: string, config: WorkflowStepConfigWithStaticDelay, callback: (ctx: WorkflowStepContext) => Promise, rollbackOptions?: WorkflowStepRollbackOptions): Promise; do>(name: string, config: WorkflowStepConfig, callback: (ctx: WorkflowStepContext) => Promise, rollbackOptions?: WorkflowStepRollbackOptions): Promise; sleep: (name: string, duration: WorkflowSleepDuration) => Promise; sleepUntil: (name: string, timestamp: Date | number) => Promise; @@ -13929,11 +14045,12 @@ type MarkdownDocument = { name: string; blob: Blob; }; +type OutputFormat = 'markdown' | 'text'; type ConversionResponse = { id: string; name: string; mimeType: string; - format: 'markdown'; + format: OutputFormat; tokens: number; data: string; } | { @@ -13950,7 +14067,11 @@ type EmbeddedImageConversionOptions = ImageConversionOptions & { convert?: boolean; maxConvertedImages?: number; }; +type ConversionOutputOptions = { + format?: OutputFormat; +}; type ConversionOptions = { + output?: ConversionOutputOptions; html?: { images?: EmbeddedImageConversionOptions & { convertOGImage?: boolean; @@ -14064,6 +14185,7 @@ declare namespace TailStream { readonly dispatchNamespace?: string; readonly entrypoint?: string; readonly executionModel: string; + readonly durableObjectId?: string; readonly scriptName?: string; readonly scriptTags?: string[]; readonly scriptVersion?: ScriptVersion; @@ -14098,11 +14220,22 @@ declare namespace TailStream { readonly message: string; readonly stack?: string; } - interface Log { + interface TailStreamErrorInfo { + readonly name: string; + readonly message: string; + readonly stack?: string; + } + type Log = { readonly type: "log"; readonly level: "debug" | "error" | "info" | "log" | "warn"; + readonly errorInfo?: readonly (TailStreamErrorInfo | null)[]; + } & ({ readonly message: object; - } + readonly truncated?: false; + } | { + readonly message: string; + readonly truncated: true; + }); interface DroppedEventsDiagnostic { readonly diagnosticsType: "droppedEvents"; readonly count: number; @@ -14580,7 +14713,25 @@ declare abstract class Workflow { * @returns A promise that resolves with a list of handles for the created instances. */ public createBatch(batch: WorkflowInstanceCreateOptions[]): Promise; + /** + * 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; } +type WorkflowBatchDeleteResult = { + deleted: { + id: string; + }[]; + errors: { + id: string; + code: number; + message: string; + }[]; +}; type WorkflowDurationLabel = 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year'; type WorkflowSleepDuration = `${number} ${WorkflowDurationLabel}${'s' | ''}` | number; type WorkflowRetentionDuration = WorkflowSleepDuration; @@ -14618,6 +14769,13 @@ interface WorkflowError { code?: number; 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 { /** * Restart from a specific step. If omitted, the instance restarts from the beginning. @@ -14651,14 +14809,19 @@ declare abstract class WorkflowInstance { public resume(): Promise; /** * 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; + public terminate(options?: WorkflowInstanceTerminateOptions): Promise; /** * Restart the instance. Optionally restart from a specific step, preserving * cached results for all steps before it. * @param options Options for the restart, including an optional step to restart from. */ public restart(options?: WorkflowInstanceRestartOptions): Promise; + /** + * Delete the instance and its stored state. + */ + public delete(): Promise; /** * Returns the current status of the instance. */