@cloudflare/workers-types 5.20260819.1 → 5.20260821.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts CHANGED
@@ -706,7 +706,7 @@ interface DurableObjectState<Props = unknown> {
706
706
  setHibernatableWebSocketEventTimeout(timeoutMs?: number): void;
707
707
  getHibernatableWebSocketEventTimeout(): number | null;
708
708
  getTags(ws: WebSocket): string[];
709
- abort(reason?: string): void;
709
+ abort(reason?: string, options?: DurableObjectAbortOptions): void;
710
710
  }
711
711
  interface DurableObjectTransaction {
712
712
  get<T = unknown>(
@@ -780,6 +780,9 @@ interface DurableObjectStorage {
780
780
  getBookmarkForTime(timestamp: number | Date): Promise<string>;
781
781
  onNextSessionRestoreBookmark(bookmark: string): Promise<string>;
782
782
  }
783
+ interface DurableObjectAbortOptions {
784
+ retryAlarm?: boolean;
785
+ }
783
786
  interface DurableObjectListOptions {
784
787
  start?: string;
785
788
  startAfter?: string;
@@ -3988,10 +3991,15 @@ interface ContainerDirectorySnapshotOptions {
3988
3991
  dir: string;
3989
3992
  name?: string;
3990
3993
  }
3991
- interface ContainerDirectorySnapshotRestoreParams {
3992
- snapshot: ContainerDirectorySnapshot;
3993
- mountPoint?: string;
3994
- }
3994
+ type ContainerDirectorySnapshotRestoreParams =
3995
+ | {
3996
+ snapshot: ContainerDirectorySnapshot;
3997
+ mountPoint?: string;
3998
+ }
3999
+ | {
4000
+ snapshot?: undefined;
4001
+ mountPoint: string;
4002
+ };
3995
4003
  interface ContainerSnapshot {
3996
4004
  id: string;
3997
4005
  size: number;
@@ -12435,10 +12443,30 @@ type BrowserRunLinksOptions = BrowserRunCommonOptions & {
12435
12443
  /** When true, exclude links pointing to external domains. @default false */
12436
12444
  excludeExternalLinks?: boolean;
12437
12445
  };
12446
+ type BrowserRunSnapshotFormat =
12447
+ "content" | "screenshot" | "markdown" | "accessibilityTree";
12438
12448
  type BrowserRunSnapshotOptions = BrowserRunCommonOptions & {
12449
+ /** Which representations of the page to return. At least two distinct formats
12450
+ * are required; request a single format from its dedicated action instead.
12451
+ * @default ["content","screenshot"]
12452
+ */
12453
+ formats?: BrowserRunSnapshotFormat[];
12439
12454
  /** @see https://pptr.dev/api/puppeteer.screenshotoptions */
12440
12455
  screenshotOptions?: Omit<BrowserRunPuppeteerScreenshotOptions, "encoding">;
12441
12456
  };
12457
+ /** Options for the `accessibilityTree` quick action. */
12458
+ type BrowserRunAccessibilityTreeOptions = BrowserRunCommonOptions & {
12459
+ /** When true, prune nodes that carry no semantic meaning, such as generic
12460
+ * containers. Defaults to true, or to false when `root` is set so that the
12461
+ * requested subtree is returned as-is.
12462
+ */
12463
+ interestingOnly?: boolean;
12464
+ /** CSS selector limiting the tree to the matching element's subtree.
12465
+ * A selector that matches nothing yields `accessibilityTree: null` with
12466
+ * HTTP 200; a malformed selector is an error.
12467
+ */
12468
+ root?: string;
12469
+ };
12442
12470
  interface BrowserRunJsonBaseOptions {
12443
12471
  /** Custom AI models to try in order. Max 3. Falls back to next on error. */
12444
12472
  custom_ai?: Array<{
@@ -12476,6 +12504,58 @@ type BrowserRunResponseMeta = {
12476
12504
  /** Page title */
12477
12505
  title: string;
12478
12506
  };
12507
+ /**
12508
+ * A node in the page's accessibility tree, as exposed to assistive technology.
12509
+ * `role` is the only field always present; the rest are populated when the
12510
+ * underlying element defines them.
12511
+ * @see https://pptr.dev/api/puppeteer.serializedaxnode
12512
+ */
12513
+ interface BrowserRunSerializedAXNode {
12514
+ /** The ARIA role, e.g. `"button"`, `"heading"`, `"RootWebArea"`. */
12515
+ role: string;
12516
+ /** The `aria-autocomplete` value. */
12517
+ autocomplete?: string;
12518
+ /** Checked state of a checkbox, radio, or menu item. */
12519
+ checked?: boolean | "mixed";
12520
+ /** Accessible description, typically from `aria-describedby` or `title`. */
12521
+ description?: string;
12522
+ disabled?: boolean;
12523
+ expanded?: boolean;
12524
+ /** Whether the element currently holds keyboard focus. */
12525
+ focused?: boolean;
12526
+ /** The kind of popup the element triggers, e.g. `"menu"`, `"dialog"`. */
12527
+ haspopup?: string;
12528
+ /** The `aria-invalid` value. */
12529
+ invalid?: string;
12530
+ /** Keyboard shortcuts bound to the element, from `aria-keyshortcuts`. */
12531
+ keyshortcuts?: string;
12532
+ /** Hierarchical level, e.g. the heading level of an `<h2>`. */
12533
+ level?: number;
12534
+ /** Whether the element is a modal dialog. */
12535
+ modal?: boolean;
12536
+ /** Whether a text input accepts multiple lines. */
12537
+ multiline?: boolean;
12538
+ /** Whether more than one option can be selected. */
12539
+ multiselectable?: boolean;
12540
+ /** Accessible name, e.g. a button's label or an image's alt text. */
12541
+ name?: string;
12542
+ orientation?: string;
12543
+ /** Pressed state of a toggle button. */
12544
+ pressed?: boolean | "mixed";
12545
+ readonly?: boolean;
12546
+ required?: boolean;
12547
+ /** Author-supplied role description, from `aria-roledescription`. */
12548
+ roledescription?: string;
12549
+ selected?: boolean;
12550
+ /** Current value of an input or range element. */
12551
+ value?: string | number;
12552
+ valuemax?: number;
12553
+ valuemin?: number;
12554
+ /** Human-readable form of `value`, from `aria-valuetext`. */
12555
+ valuetext?: string;
12556
+ /** Child nodes. Absent for leaf nodes. */
12557
+ children?: BrowserRunSerializedAXNode[];
12558
+ }
12479
12559
  /** Success response for `content` action. */
12480
12560
  type BrowserRunContentSuccessResponse = {
12481
12561
  success: true;
@@ -12519,14 +12599,31 @@ type BrowserRunScrapeSuccessResponse = {
12519
12599
  }>;
12520
12600
  }>;
12521
12601
  };
12522
- /** Success response for `snapshot` action. */
12602
+ /** Success response for `snapshot` action. Each field is present only when the
12603
+ * corresponding entry was requested in `formats`.
12604
+ */
12523
12605
  type BrowserRunSnapshotSuccessResponse = {
12524
12606
  success: true;
12525
12607
  result: {
12526
12608
  /** HTML content of the page. */
12527
- content: string;
12609
+ content?: string;
12528
12610
  /** Base64-encoded screenshot image. */
12529
- screenshot: string;
12611
+ screenshot?: string;
12612
+ /** Markdown content. Prefixed with YAML frontmatter (e.g. `title`) when the
12613
+ * page provides that metadata.
12614
+ */
12615
+ markdown?: string;
12616
+ /** Root of the page's accessibility tree. */
12617
+ accessibilityTree?: BrowserRunSerializedAXNode;
12618
+ };
12619
+ meta: BrowserRunResponseMeta;
12620
+ };
12621
+ /** Success response for `accessibilityTree` action. */
12622
+ type BrowserRunAccessibilityTreeSuccessResponse = {
12623
+ success: true;
12624
+ result: {
12625
+ /** Root of the accessibility tree, or `null` when `root` matched no element. */
12626
+ accessibilityTree: BrowserRunSerializedAXNode | null;
12530
12627
  };
12531
12628
  meta: BrowserRunResponseMeta;
12532
12629
  };
@@ -12662,9 +12759,10 @@ declare abstract class BrowserRun {
12662
12759
  options: BrowserRunLinksOptions,
12663
12760
  ): Promise<Response>;
12664
12761
  /**
12665
- * Get both the HTML content and a base64-encoded screenshot of a web page.
12762
+ * Get several representations of a web page in one request.
12666
12763
  * @param action - Must be `'snapshot'`.
12667
- * @param options - Snapshot options including screenshot settings (encoding is always base64).
12764
+ * @param options - Snapshot options including the `formats` to return and
12765
+ * screenshot settings (encoding is always base64).
12668
12766
  * @returns A `Response` containing one of:
12669
12767
  *
12670
12768
  * **Success (HTTP 200):**
@@ -12721,6 +12819,29 @@ declare abstract class BrowserRun {
12721
12819
  action: "markdown",
12722
12820
  options: BrowserRunMarkdownOptions,
12723
12821
  ): Promise<Response>;
12822
+ /**
12823
+ * Get the accessibility tree of a web page.
12824
+ * @param action - Must be `'accessibilityTree'`.
12825
+ * @param options - Options to scope the tree to a subtree and to control
12826
+ * whether semantically uninteresting nodes are pruned.
12827
+ * @returns A `Response` containing one of:
12828
+ *
12829
+ * **Success (HTTP 200):**
12830
+ * - `BrowserRunAccessibilityTreeSuccessResponse` JSON with `Content-Type: application/json`
12831
+ * - `result.accessibilityTree` is `null` when `root` matched no element
12832
+ *
12833
+ * **Error:**
12834
+ * - `BrowserRunErrorResponse` JSON with appropriate HTTP status code (400, 422, 429, 500, 503)
12835
+ * - HTTP 422 for a malformed `root` selector
12836
+ * - HTTP 500 with code `2017` or `2018` when the tree could not be built
12837
+ *
12838
+ * **Headers:**
12839
+ * - `X-Browser-Ms-Used`: Browser time consumed in milliseconds (set when status < 500)
12840
+ */
12841
+ quickAction(
12842
+ action: "accessibilityTree",
12843
+ options: BrowserRunAccessibilityTreeOptions,
12844
+ ): Promise<Response>;
12724
12845
  }
12725
12846
  /**
12726
12847
  * In addition to the properties you can set in the RequestInit dict
@@ -14392,6 +14513,27 @@ type ImageInfoResponse =
14392
14513
  width: number;
14393
14514
  height: number;
14394
14515
  };
14516
+ /**
14517
+ * Parameters for rasterizing text into an image.
14518
+ */
14519
+ type TextRasterize = {
14520
+ /** The text content to render */
14521
+ content: string;
14522
+ /** rasterization options for the text **/
14523
+ options: TextOptions;
14524
+ };
14525
+ type TextOptions = {
14526
+ /** Font configuration */
14527
+ font: {
14528
+ /** URL to a font file in TrueType (.ttf), OpenType (.otf), WOFF (.woff), or WOFF2 (.woff2) format */
14529
+ url: string;
14530
+ };
14531
+ /** Font size in points (pt) */
14532
+ size?: number;
14533
+ /** Text color in CSS format: hex (#RRGGBB or #RRGGBBAA), rgb(r,g,b), rgba(r,g,b,a), or named colors */
14534
+ color?: string;
14535
+ };
14536
+ type ImageSource = ReadableStream<Uint8Array> | TextRasterize;
14395
14537
  type ImageTransform = {
14396
14538
  width?: number;
14397
14539
  height?: number;
@@ -14503,6 +14645,9 @@ interface ImageUploadOptions {
14503
14645
  requireSignedURLs?: boolean;
14504
14646
  metadata?: Record<string, unknown>;
14505
14647
  creator?: string;
14648
+ /**
14649
+ * If 'base64', the input data will be decoded from base64 before processing
14650
+ */
14506
14651
  encoding?: "base64";
14507
14652
  }
14508
14653
  interface ImageUpdateOptions {
@@ -14510,11 +14655,41 @@ interface ImageUpdateOptions {
14510
14655
  metadata?: Record<string, unknown>;
14511
14656
  creator?: string;
14512
14657
  }
14658
+ type ImageMetadataFilterOperators = {
14659
+ eq?: string | number | boolean;
14660
+ in?: string[] | number[];
14661
+ gt?: number;
14662
+ gte?: number;
14663
+ lt?: number;
14664
+ lte?: number;
14665
+ };
14666
+ type ImageMetadataFilterValue =
14667
+ string | number | boolean | ImageMetadataFilterOperators;
14668
+ interface ImageListFilter {
14669
+ metadata?: Record<string, ImageMetadataFilterValue>;
14670
+ }
14513
14671
  interface ImageListOptions {
14514
14672
  limit?: number;
14515
14673
  cursor?: string;
14516
14674
  sortOrder?: "asc" | "desc";
14517
14675
  creator?: string;
14676
+ filter?: ImageListFilter;
14677
+ }
14678
+ interface ImageSignedUrlOptions {
14679
+ variant: string;
14680
+ expiresIn?: number;
14681
+ keyName?: string;
14682
+ }
14683
+ interface ImageDirectUploadOptions {
14684
+ id?: string;
14685
+ requireSignedURLs?: boolean;
14686
+ metadata?: Record<string, unknown>;
14687
+ creator?: string;
14688
+ expiresIn?: number;
14689
+ }
14690
+ interface ImageDirectUploadResult {
14691
+ id: string;
14692
+ uploadURL: string;
14518
14693
  }
14519
14694
  interface ImageList {
14520
14695
  images: ImageMetadata[];
@@ -14532,6 +14707,13 @@ interface ImageHandle {
14532
14707
  * @returns ReadableStream of image bytes, or null if not found
14533
14708
  */
14534
14709
  bytes(): Promise<ReadableStream<Uint8Array> | null>;
14710
+ /**
14711
+ * Generate a signed delivery URL for this hosted image.
14712
+ * @param options Signing configuration
14713
+ * @returns A signed image delivery URL
14714
+ * @throws {@link ImagesError} if signing fails
14715
+ */
14716
+ signedUrl(options: ImageSignedUrlOptions): Promise<string>;
14535
14717
  /**
14536
14718
  * Update hosted image metadata
14537
14719
  * @param options Properties to update
@@ -14570,6 +14752,16 @@ interface HostedImagesBinding {
14570
14752
  * @throws {@link ImagesError} if list fails
14571
14753
  */
14572
14754
  list(options?: ImageListOptions): Promise<ImageList>;
14755
+ /**
14756
+ * Create a Direct Creator Upload link, letting an end user upload an
14757
+ * image straight to Cloudflare without exposing an API token
14758
+ * @param options Upload link configuration
14759
+ * @returns The new image ID and the upload URL to hand to the end user
14760
+ * @throws {@link ImagesError} if creation fails
14761
+ */
14762
+ createDirectUpload(
14763
+ options?: ImageDirectUploadOptions,
14764
+ ): Promise<ImageDirectUploadResult>;
14573
14765
  }
14574
14766
  interface ImagesBinding {
14575
14767
  /**
@@ -14590,6 +14782,13 @@ interface ImagesBinding {
14590
14782
  stream: ReadableStream<Uint8Array>,
14591
14783
  options?: ImageInputOptions,
14592
14784
  ): ImageTransformer;
14785
+ /**
14786
+ * Begin applying a series of transformations to text
14787
+ * @param content string to be rendered
14788
+ * @param options font, optional color and size to use in rendering text
14789
+ * @returns A transform handle
14790
+ */
14791
+ text(content: string, options: TextOptions): ImageTransformer;
14593
14792
  /**
14594
14793
  * Access hosted images CRUD operations
14595
14794
  */
@@ -16278,7 +16477,8 @@ declare namespace TailStream {
16278
16477
  | "responseStreamDisconnected"
16279
16478
  | "scriptNotFound"
16280
16479
  | "internalError"
16281
- | "exceededWallTime";
16480
+ | "exceededWallTime"
16481
+ | "aborted";
16282
16482
  interface ScriptVersion {
16283
16483
  readonly id: string;
16284
16484
  readonly tag?: string;
@@ -16914,6 +17114,20 @@ type WorkflowDurationLabel =
16914
17114
  type WorkflowSleepDuration =
16915
17115
  `${number} ${WorkflowDurationLabel}${"s" | ""}` | number;
16916
17116
  type WorkflowRetentionDuration = WorkflowSleepDuration;
17117
+ /** Geographic regions supported when creating a Workflow instance.
17118
+ * Location hints are best-effort placement preferences. */
17119
+ type WorkflowInstanceLocationHint =
17120
+ | "wnam"
17121
+ | "enam"
17122
+ | "sam"
17123
+ | "weur"
17124
+ | "eeur"
17125
+ | "apac"
17126
+ | "apac-ne"
17127
+ | "apac-se"
17128
+ | "oc"
17129
+ | "afr"
17130
+ | "me";
16917
17131
  interface WorkflowInstanceCreateOptions<PARAMS = unknown> {
16918
17132
  /**
16919
17133
  * An id for your Workflow instance. Must be unique within the Workflow.
@@ -16931,6 +17145,9 @@ interface WorkflowInstanceCreateOptions<PARAMS = unknown> {
16931
17145
  successRetention?: WorkflowRetentionDuration;
16932
17146
  errorRetention?: WorkflowRetentionDuration;
16933
17147
  };
17148
+ /** A best-effort geographic placement preference for the Workflow instance.
17149
+ * See `WorkflowInstanceLocationHint` for supported regions. */
17150
+ locationHint?: WorkflowInstanceLocationHint;
16934
17151
  }
16935
17152
  type InstanceStatus = {
16936
17153
  status: