From f41843aeafcfe6311d8e627098a392847fcf4ec5 Mon Sep 17 00:00:00 2001 From: Matt Johnson-Pint Date: Sat, 15 Aug 2026 11:16:22 -0700 Subject: [PATCH] Regenerate worker types Also prevent future updates from passing CI without this. --- .github/workflows/test.yml | 2 + package.json | 3 +- worker-configuration.d.ts | 134 +++++++++++++++++++++++++++++++++---- 3 files changed, 125 insertions(+), 14 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 51c7db7..d2d16f1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -23,6 +23,8 @@ jobs: cache: "pnpm" - run: pnpm install + - name: Check worker types are up to date + run: pnpm run generate-types:check - run: pnpm run typecheck - run: pnpm run lint - run: pnpm run format:check diff --git a/package.json b/package.json index 06321a9..398dcd4 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,8 @@ "deploy": "wrangler deploy --minify --env production", "dev:miniflare": "wrangler dev --env dev --port 9999 --live-reload", "generate-types": "wrangler types --config test/wrangler.test.jsonc --include-env=false", - "typecheck": "pnpm run generate-types && tsc --noEmit && tsc --noEmit --project test/tsconfig.json && tsc --noEmit --project push/tsconfig.json", + "generate-types:check": "wrangler types --config test/wrangler.test.jsonc --include-env=false --check", + "typecheck": "tsc --noEmit && tsc --noEmit --project test/tsconfig.json && tsc --noEmit --project push/tsconfig.json", "lint": "eslint .", "format": "prettier --write .", "format:check": "prettier --check .", diff --git a/worker-configuration.d.ts b/worker-configuration.d.ts index a6c3b52..72dc832 100644 --- a/worker-configuration.d.ts +++ b/worker-configuration.d.ts @@ -1,5 +1,5 @@ /* eslint-disable */ -// Runtime types generated with workerd@1.20260730.1 2024-09-09 nodejs_compat +// Runtime types generated with workerd@1.20260811.1 2024-09-09 nodejs_compat // Begin runtime types /*! ***************************************************************************** Copyright (c) Cloudflare. All rights reserved. @@ -422,6 +422,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; @@ -2744,6 +2745,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; @@ -3283,18 +3290,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; @@ -3341,6 +3356,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. * @@ -3461,11 +3481,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; } /** @@ -4105,6 +4127,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[]; @@ -12393,6 +12422,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. */ @@ -13079,6 +13117,26 @@ declare namespace CloudflareWorkersModule { 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. */ @@ -13116,23 +13174,35 @@ declare namespace CloudflareWorkersModule { 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; - do, const C extends WorkflowStepConfig>(name: string, config: C, 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; waitForEvent>(name: string, options: { @@ -13907,11 +13977,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; } | { @@ -13928,7 +13999,11 @@ type EmbeddedImageConversionOptions = ImageConversionOptions & { convert?: boolean; maxConvertedImages?: number; }; +type ConversionOutputOptions = { + format?: OutputFormat; +}; type ConversionOptions = { + output?: ConversionOutputOptions; html?: { images?: EmbeddedImageConversionOptions & { convertOGImage?: boolean; @@ -14077,11 +14152,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; @@ -14559,7 +14645,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; @@ -14646,6 +14750,10 @@ declare abstract class WorkflowInstance { * @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. */