@cloudflare/workers-types 4.20240909.0 → 4.20240919.0

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.
@@ -1548,7 +1548,11 @@ declare abstract class Body {
1548
1548
  * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response)
1549
1549
  */
1550
1550
  declare class Response extends Body {
1551
- constructor(body?: BodyInit | null, init?: ResponseInit);
1551
+ constructor(
1552
+ body?: BodyInit | null,
1553
+ init?: ResponseInit,
1554
+ webSocket?: WebSocket,
1555
+ );
1552
1556
  /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/redirect_static) */
1553
1557
  static redirect(url: string, status?: number): Response;
1554
1558
  /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/json_static) */
@@ -1575,7 +1579,7 @@ interface ResponseInit {
1575
1579
  statusText?: string;
1576
1580
  headers?: HeadersInit;
1577
1581
  cf?: any;
1578
- webSocket?: WebSocket | null;
1582
+ webSocket?: WebSocket;
1579
1583
  encodeBody?: "automatic" | "manual";
1580
1584
  }
1581
1585
  type RequestInfo<CfHostMetadata = unknown, Cf = CfProperties<CfHostMetadata>> =
@@ -2283,15 +2287,15 @@ declare class TransformStream<I = any, O = any> {
2283
2287
  }
2284
2288
  declare class FixedLengthStream extends IdentityTransformStream {
2285
2289
  constructor(
2286
- param1: number | bigint,
2287
- param2?: IdentityTransformStreamQueuingStrategy,
2290
+ expectedLength: number | bigint,
2291
+ queuingStrategy?: IdentityTransformStreamQueuingStrategy,
2288
2292
  );
2289
2293
  }
2290
2294
  declare class IdentityTransformStream extends TransformStream<
2291
2295
  ArrayBuffer | ArrayBufferView,
2292
2296
  Uint8Array
2293
2297
  > {
2294
- constructor(param1?: IdentityTransformStreamQueuingStrategy);
2298
+ constructor(queuingStrategy?: IdentityTransformStreamQueuingStrategy);
2295
2299
  }
2296
2300
  interface IdentityTransformStreamQueuingStrategy {
2297
2301
  highWaterMark?: number | bigint;
@@ -2769,21 +2773,24 @@ declare const WebSocketPair: {
2769
2773
  };
2770
2774
  };
2771
2775
  interface SqlStorage {
2772
- exec(query: string, ...bindings: any[]): SqlStorageCursor;
2773
- prepare(query: string): SqlStorageStatement;
2776
+ exec<T extends Record<string, SqlStorageValue>>(
2777
+ query: string,
2778
+ ...bindings: any[]
2779
+ ): SqlStorageCursor<T>;
2774
2780
  get databaseSize(): number;
2775
2781
  Cursor: typeof SqlStorageCursor;
2776
2782
  Statement: typeof SqlStorageStatement;
2777
2783
  }
2778
2784
  declare abstract class SqlStorageStatement {}
2779
- declare abstract class SqlStorageCursor {
2780
- raw(): IterableIterator<((ArrayBuffer | string | number) | null)[]>;
2785
+ type SqlStorageValue = ArrayBuffer | string | number | null;
2786
+ declare abstract class SqlStorageCursor<
2787
+ T extends Record<string, SqlStorageValue>,
2788
+ > {
2789
+ raw<U extends SqlStorageValue[]>(): IterableIterator<U>;
2781
2790
  get columnNames(): string[];
2782
2791
  get rowsRead(): number;
2783
2792
  get rowsWritten(): number;
2784
- [Symbol.iterator](): IterableIterator<
2785
- Record<string, (ArrayBuffer | string | number) | null>
2786
- >;
2793
+ [Symbol.iterator](): IterableIterator<T>;
2787
2794
  }
2788
2795
  interface Socket {
2789
2796
  get readable(): ReadableStream;
@@ -3322,7 +3329,7 @@ interface GPUOrigin3DDict {
3322
3329
  z?: number;
3323
3330
  }
3324
3331
  /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource) */
3325
- declare class EventSource {
3332
+ declare class EventSource extends EventTarget {
3326
3333
  constructor(url: string, init?: EventSourceEventSourceInit);
3327
3334
  /**
3328
3335
  * Aborts any instances of the fetch algorithm started for this EventSource object, and sets the readyState attribute to CLOSED.
@@ -5587,12 +5594,69 @@ interface DispatchNamespace {
5587
5594
  ): Fetcher;
5588
5595
  }
5589
5596
  /**
5590
- * NonRetryableError allows for a Workflow to throw a "fatal" error as in,
5591
- * an error that makes the instance fail immediately without triggering a retry.
5597
+ * NonRetryableError allows for a user to throw a fatal error
5598
+ * that makes a Workflow instance fail immediately without triggering a retry
5592
5599
  */
5593
- declare class NonRetryableError extends Error {
5594
- // __brand has been explicity omitted because it's a internal brand used for
5595
- // the Workflows' engine and user's shouldn't be able to override it
5596
- // (at least, in a direct way)
5597
- public constructor(message: string, name?: string);
5600
+ declare module "cloudflare:workflows" {
5601
+ export abstract class NonRetryableError extends Error {
5602
+ /**
5603
+ * `__brand` is used to differentiate between `NonRetryableError` and `Error`
5604
+ * and is omitted from the constructor because users should not set it
5605
+ */
5606
+ public constructor(message: string, name?: string);
5607
+ }
5608
+ }
5609
+ declare abstract class Workflow {
5610
+ /**
5611
+ * Get a handle to an existing instance of the Workflow.
5612
+ * @param id Id for the instance of this Workflow
5613
+ * @returns A promise that resolves with a handle for the Instance
5614
+ */
5615
+ public get(id: string): Promise<Instance>;
5616
+ /**
5617
+ * Create a new instance and return a handle to it. If a provided id exists, an error will be thrown.
5618
+ * @param id Id to create the instance of this Workflow with
5619
+ * @param params The payload to send over to this instance
5620
+ * @returns A promise that resolves with a handle for the Instance
5621
+ */
5622
+ public create(id: string, params: object): Promise<Instance>;
5623
+ }
5624
+ type InstanceStatus = {
5625
+ status:
5626
+ | "queued"
5627
+ | "running"
5628
+ | "paused"
5629
+ | "errored"
5630
+ | "terminated"
5631
+ | "complete"
5632
+ | "unknown";
5633
+ error?: string;
5634
+ output?: object;
5635
+ };
5636
+ interface WorkflowError {
5637
+ code?: number;
5638
+ message: string;
5639
+ }
5640
+ declare abstract class Instance {
5641
+ public id: string;
5642
+ /**
5643
+ * Pause the instance.
5644
+ */
5645
+ public pause(): Promise<void>;
5646
+ /**
5647
+ * Resume the instance. If it is already running, an error will be thrown.
5648
+ */
5649
+ public resume(): Promise<void>;
5650
+ /**
5651
+ * Abort the instance. If it is errored, terminated or complete, an error will be thrown.
5652
+ */
5653
+ public abort(): Promise<void>;
5654
+ /**
5655
+ * Restart the instance.
5656
+ */
5657
+ public restart(): Promise<void>;
5658
+ /**
5659
+ * Returns the current status of the instance.
5660
+ */
5661
+ public status(): Promise<InstanceStatus>;
5598
5662
  }
@@ -1553,7 +1553,11 @@ export declare abstract class Body {
1553
1553
  * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response)
1554
1554
  */
1555
1555
  export declare class Response extends Body {
1556
- constructor(body?: BodyInit | null, init?: ResponseInit);
1556
+ constructor(
1557
+ body?: BodyInit | null,
1558
+ init?: ResponseInit,
1559
+ webSocket?: WebSocket,
1560
+ );
1557
1561
  /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/redirect_static) */
1558
1562
  static redirect(url: string, status?: number): Response;
1559
1563
  /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/json_static) */
@@ -1580,7 +1584,7 @@ export interface ResponseInit {
1580
1584
  statusText?: string;
1581
1585
  headers?: HeadersInit;
1582
1586
  cf?: any;
1583
- webSocket?: WebSocket | null;
1587
+ webSocket?: WebSocket;
1584
1588
  encodeBody?: "automatic" | "manual";
1585
1589
  }
1586
1590
  export type RequestInfo<
@@ -2289,15 +2293,15 @@ export declare class TransformStream<I = any, O = any> {
2289
2293
  }
2290
2294
  export declare class FixedLengthStream extends IdentityTransformStream {
2291
2295
  constructor(
2292
- param1: number | bigint,
2293
- param2?: IdentityTransformStreamQueuingStrategy,
2296
+ expectedLength: number | bigint,
2297
+ queuingStrategy?: IdentityTransformStreamQueuingStrategy,
2294
2298
  );
2295
2299
  }
2296
2300
  export declare class IdentityTransformStream extends TransformStream<
2297
2301
  ArrayBuffer | ArrayBufferView,
2298
2302
  Uint8Array
2299
2303
  > {
2300
- constructor(param1?: IdentityTransformStreamQueuingStrategy);
2304
+ constructor(queuingStrategy?: IdentityTransformStreamQueuingStrategy);
2301
2305
  }
2302
2306
  export interface IdentityTransformStreamQueuingStrategy {
2303
2307
  highWaterMark?: number | bigint;
@@ -2778,21 +2782,24 @@ export declare const WebSocketPair: {
2778
2782
  };
2779
2783
  };
2780
2784
  export interface SqlStorage {
2781
- exec(query: string, ...bindings: any[]): SqlStorageCursor;
2782
- prepare(query: string): SqlStorageStatement;
2785
+ exec<T extends Record<string, SqlStorageValue>>(
2786
+ query: string,
2787
+ ...bindings: any[]
2788
+ ): SqlStorageCursor<T>;
2783
2789
  get databaseSize(): number;
2784
2790
  Cursor: typeof SqlStorageCursor;
2785
2791
  Statement: typeof SqlStorageStatement;
2786
2792
  }
2787
2793
  export declare abstract class SqlStorageStatement {}
2788
- export declare abstract class SqlStorageCursor {
2789
- raw(): IterableIterator<((ArrayBuffer | string | number) | null)[]>;
2794
+ export type SqlStorageValue = ArrayBuffer | string | number | null;
2795
+ export declare abstract class SqlStorageCursor<
2796
+ T extends Record<string, SqlStorageValue>,
2797
+ > {
2798
+ raw<U extends SqlStorageValue[]>(): IterableIterator<U>;
2790
2799
  get columnNames(): string[];
2791
2800
  get rowsRead(): number;
2792
2801
  get rowsWritten(): number;
2793
- [Symbol.iterator](): IterableIterator<
2794
- Record<string, (ArrayBuffer | string | number) | null>
2795
- >;
2802
+ [Symbol.iterator](): IterableIterator<T>;
2796
2803
  }
2797
2804
  export interface Socket {
2798
2805
  get readable(): ReadableStream;
@@ -3331,7 +3338,7 @@ export interface GPUOrigin3DDict {
3331
3338
  z?: number;
3332
3339
  }
3333
3340
  /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource) */
3334
- export declare class EventSource {
3341
+ export declare class EventSource extends EventTarget {
3335
3342
  constructor(url: string, init?: EventSourceEventSourceInit);
3336
3343
  /**
3337
3344
  * Aborts any instances of the fetch algorithm started for this EventSource object, and sets the readyState attribute to CLOSED.
@@ -5501,13 +5508,57 @@ export interface DispatchNamespace {
5501
5508
  options?: DynamicDispatchOptions,
5502
5509
  ): Fetcher;
5503
5510
  }
5504
- /**
5505
- * NonRetryableError allows for a Workflow to throw a "fatal" error as in,
5506
- * an error that makes the instance fail immediately without triggering a retry.
5507
- */
5508
- export declare class NonRetryableError extends Error {
5509
- // __brand has been explicity omitted because it's a internal brand used for
5510
- // the Workflows' engine and user's shouldn't be able to override it
5511
- // (at least, in a direct way)
5512
- public constructor(message: string, name?: string);
5511
+ export declare abstract class Workflow {
5512
+ /**
5513
+ * Get a handle to an existing instance of the Workflow.
5514
+ * @param id Id for the instance of this Workflow
5515
+ * @returns A promise that resolves with a handle for the Instance
5516
+ */
5517
+ public get(id: string): Promise<Instance>;
5518
+ /**
5519
+ * Create a new instance and return a handle to it. If a provided id exists, an error will be thrown.
5520
+ * @param id Id to create the instance of this Workflow with
5521
+ * @param params The payload to send over to this instance
5522
+ * @returns A promise that resolves with a handle for the Instance
5523
+ */
5524
+ public create(id: string, params: object): Promise<Instance>;
5525
+ }
5526
+ export type InstanceStatus = {
5527
+ status:
5528
+ | "queued"
5529
+ | "running"
5530
+ | "paused"
5531
+ | "errored"
5532
+ | "terminated"
5533
+ | "complete"
5534
+ | "unknown";
5535
+ error?: string;
5536
+ output?: object;
5537
+ };
5538
+ export interface WorkflowError {
5539
+ code?: number;
5540
+ message: string;
5541
+ }
5542
+ export declare abstract class Instance {
5543
+ public id: string;
5544
+ /**
5545
+ * Pause the instance.
5546
+ */
5547
+ public pause(): Promise<void>;
5548
+ /**
5549
+ * Resume the instance. If it is already running, an error will be thrown.
5550
+ */
5551
+ public resume(): Promise<void>;
5552
+ /**
5553
+ * Abort the instance. If it is errored, terminated or complete, an error will be thrown.
5554
+ */
5555
+ public abort(): Promise<void>;
5556
+ /**
5557
+ * Restart the instance.
5558
+ */
5559
+ public restart(): Promise<void>;
5560
+ /**
5561
+ * Returns the current status of the instance.
5562
+ */
5563
+ public status(): Promise<InstanceStatus>;
5513
5564
  }
@@ -1548,7 +1548,11 @@ declare abstract class Body {
1548
1548
  * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response)
1549
1549
  */
1550
1550
  declare class Response extends Body {
1551
- constructor(body?: BodyInit | null, init?: ResponseInit);
1551
+ constructor(
1552
+ body?: BodyInit | null,
1553
+ init?: ResponseInit,
1554
+ webSocket?: WebSocket,
1555
+ );
1552
1556
  /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/redirect_static) */
1553
1557
  static redirect(url: string, status?: number): Response;
1554
1558
  /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/json_static) */
@@ -1575,7 +1579,7 @@ interface ResponseInit {
1575
1579
  statusText?: string;
1576
1580
  headers?: HeadersInit;
1577
1581
  cf?: any;
1578
- webSocket?: WebSocket | null;
1582
+ webSocket?: WebSocket;
1579
1583
  encodeBody?: "automatic" | "manual";
1580
1584
  }
1581
1585
  type RequestInfo<CfHostMetadata = unknown, Cf = CfProperties<CfHostMetadata>> =
@@ -2283,15 +2287,15 @@ declare class TransformStream<I = any, O = any> {
2283
2287
  }
2284
2288
  declare class FixedLengthStream extends IdentityTransformStream {
2285
2289
  constructor(
2286
- param1: number | bigint,
2287
- param2?: IdentityTransformStreamQueuingStrategy,
2290
+ expectedLength: number | bigint,
2291
+ queuingStrategy?: IdentityTransformStreamQueuingStrategy,
2288
2292
  );
2289
2293
  }
2290
2294
  declare class IdentityTransformStream extends TransformStream<
2291
2295
  ArrayBuffer | ArrayBufferView,
2292
2296
  Uint8Array
2293
2297
  > {
2294
- constructor(param1?: IdentityTransformStreamQueuingStrategy);
2298
+ constructor(queuingStrategy?: IdentityTransformStreamQueuingStrategy);
2295
2299
  }
2296
2300
  interface IdentityTransformStreamQueuingStrategy {
2297
2301
  highWaterMark?: number | bigint;
@@ -2769,21 +2773,24 @@ declare const WebSocketPair: {
2769
2773
  };
2770
2774
  };
2771
2775
  interface SqlStorage {
2772
- exec(query: string, ...bindings: any[]): SqlStorageCursor;
2773
- prepare(query: string): SqlStorageStatement;
2776
+ exec<T extends Record<string, SqlStorageValue>>(
2777
+ query: string,
2778
+ ...bindings: any[]
2779
+ ): SqlStorageCursor<T>;
2774
2780
  get databaseSize(): number;
2775
2781
  Cursor: typeof SqlStorageCursor;
2776
2782
  Statement: typeof SqlStorageStatement;
2777
2783
  }
2778
2784
  declare abstract class SqlStorageStatement {}
2779
- declare abstract class SqlStorageCursor {
2780
- raw(): IterableIterator<((ArrayBuffer | string | number) | null)[]>;
2785
+ type SqlStorageValue = ArrayBuffer | string | number | null;
2786
+ declare abstract class SqlStorageCursor<
2787
+ T extends Record<string, SqlStorageValue>,
2788
+ > {
2789
+ raw<U extends SqlStorageValue[]>(): IterableIterator<U>;
2781
2790
  get columnNames(): string[];
2782
2791
  get rowsRead(): number;
2783
2792
  get rowsWritten(): number;
2784
- [Symbol.iterator](): IterableIterator<
2785
- Record<string, (ArrayBuffer | string | number) | null>
2786
- >;
2793
+ [Symbol.iterator](): IterableIterator<T>;
2787
2794
  }
2788
2795
  interface Socket {
2789
2796
  get readable(): ReadableStream;
@@ -3322,7 +3329,7 @@ interface GPUOrigin3DDict {
3322
3329
  z?: number;
3323
3330
  }
3324
3331
  /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource) */
3325
- declare class EventSource {
3332
+ declare class EventSource extends EventTarget {
3326
3333
  constructor(url: string, init?: EventSourceEventSourceInit);
3327
3334
  /**
3328
3335
  * Aborts any instances of the fetch algorithm started for this EventSource object, and sets the readyState attribute to CLOSED.
@@ -5587,12 +5594,69 @@ interface DispatchNamespace {
5587
5594
  ): Fetcher;
5588
5595
  }
5589
5596
  /**
5590
- * NonRetryableError allows for a Workflow to throw a "fatal" error as in,
5591
- * an error that makes the instance fail immediately without triggering a retry.
5597
+ * NonRetryableError allows for a user to throw a fatal error
5598
+ * that makes a Workflow instance fail immediately without triggering a retry
5592
5599
  */
5593
- declare class NonRetryableError extends Error {
5594
- // __brand has been explicity omitted because it's a internal brand used for
5595
- // the Workflows' engine and user's shouldn't be able to override it
5596
- // (at least, in a direct way)
5597
- public constructor(message: string, name?: string);
5600
+ declare module "cloudflare:workflows" {
5601
+ export abstract class NonRetryableError extends Error {
5602
+ /**
5603
+ * `__brand` is used to differentiate between `NonRetryableError` and `Error`
5604
+ * and is omitted from the constructor because users should not set it
5605
+ */
5606
+ public constructor(message: string, name?: string);
5607
+ }
5608
+ }
5609
+ declare abstract class Workflow {
5610
+ /**
5611
+ * Get a handle to an existing instance of the Workflow.
5612
+ * @param id Id for the instance of this Workflow
5613
+ * @returns A promise that resolves with a handle for the Instance
5614
+ */
5615
+ public get(id: string): Promise<Instance>;
5616
+ /**
5617
+ * Create a new instance and return a handle to it. If a provided id exists, an error will be thrown.
5618
+ * @param id Id to create the instance of this Workflow with
5619
+ * @param params The payload to send over to this instance
5620
+ * @returns A promise that resolves with a handle for the Instance
5621
+ */
5622
+ public create(id: string, params: object): Promise<Instance>;
5623
+ }
5624
+ type InstanceStatus = {
5625
+ status:
5626
+ | "queued"
5627
+ | "running"
5628
+ | "paused"
5629
+ | "errored"
5630
+ | "terminated"
5631
+ | "complete"
5632
+ | "unknown";
5633
+ error?: string;
5634
+ output?: object;
5635
+ };
5636
+ interface WorkflowError {
5637
+ code?: number;
5638
+ message: string;
5639
+ }
5640
+ declare abstract class Instance {
5641
+ public id: string;
5642
+ /**
5643
+ * Pause the instance.
5644
+ */
5645
+ public pause(): Promise<void>;
5646
+ /**
5647
+ * Resume the instance. If it is already running, an error will be thrown.
5648
+ */
5649
+ public resume(): Promise<void>;
5650
+ /**
5651
+ * Abort the instance. If it is errored, terminated or complete, an error will be thrown.
5652
+ */
5653
+ public abort(): Promise<void>;
5654
+ /**
5655
+ * Restart the instance.
5656
+ */
5657
+ public restart(): Promise<void>;
5658
+ /**
5659
+ * Returns the current status of the instance.
5660
+ */
5661
+ public status(): Promise<InstanceStatus>;
5598
5662
  }
@@ -1553,7 +1553,11 @@ export declare abstract class Body {
1553
1553
  * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response)
1554
1554
  */
1555
1555
  export declare class Response extends Body {
1556
- constructor(body?: BodyInit | null, init?: ResponseInit);
1556
+ constructor(
1557
+ body?: BodyInit | null,
1558
+ init?: ResponseInit,
1559
+ webSocket?: WebSocket,
1560
+ );
1557
1561
  /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/redirect_static) */
1558
1562
  static redirect(url: string, status?: number): Response;
1559
1563
  /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/json_static) */
@@ -1580,7 +1584,7 @@ export interface ResponseInit {
1580
1584
  statusText?: string;
1581
1585
  headers?: HeadersInit;
1582
1586
  cf?: any;
1583
- webSocket?: WebSocket | null;
1587
+ webSocket?: WebSocket;
1584
1588
  encodeBody?: "automatic" | "manual";
1585
1589
  }
1586
1590
  export type RequestInfo<
@@ -2289,15 +2293,15 @@ export declare class TransformStream<I = any, O = any> {
2289
2293
  }
2290
2294
  export declare class FixedLengthStream extends IdentityTransformStream {
2291
2295
  constructor(
2292
- param1: number | bigint,
2293
- param2?: IdentityTransformStreamQueuingStrategy,
2296
+ expectedLength: number | bigint,
2297
+ queuingStrategy?: IdentityTransformStreamQueuingStrategy,
2294
2298
  );
2295
2299
  }
2296
2300
  export declare class IdentityTransformStream extends TransformStream<
2297
2301
  ArrayBuffer | ArrayBufferView,
2298
2302
  Uint8Array
2299
2303
  > {
2300
- constructor(param1?: IdentityTransformStreamQueuingStrategy);
2304
+ constructor(queuingStrategy?: IdentityTransformStreamQueuingStrategy);
2301
2305
  }
2302
2306
  export interface IdentityTransformStreamQueuingStrategy {
2303
2307
  highWaterMark?: number | bigint;
@@ -2778,21 +2782,24 @@ export declare const WebSocketPair: {
2778
2782
  };
2779
2783
  };
2780
2784
  export interface SqlStorage {
2781
- exec(query: string, ...bindings: any[]): SqlStorageCursor;
2782
- prepare(query: string): SqlStorageStatement;
2785
+ exec<T extends Record<string, SqlStorageValue>>(
2786
+ query: string,
2787
+ ...bindings: any[]
2788
+ ): SqlStorageCursor<T>;
2783
2789
  get databaseSize(): number;
2784
2790
  Cursor: typeof SqlStorageCursor;
2785
2791
  Statement: typeof SqlStorageStatement;
2786
2792
  }
2787
2793
  export declare abstract class SqlStorageStatement {}
2788
- export declare abstract class SqlStorageCursor {
2789
- raw(): IterableIterator<((ArrayBuffer | string | number) | null)[]>;
2794
+ export type SqlStorageValue = ArrayBuffer | string | number | null;
2795
+ export declare abstract class SqlStorageCursor<
2796
+ T extends Record<string, SqlStorageValue>,
2797
+ > {
2798
+ raw<U extends SqlStorageValue[]>(): IterableIterator<U>;
2790
2799
  get columnNames(): string[];
2791
2800
  get rowsRead(): number;
2792
2801
  get rowsWritten(): number;
2793
- [Symbol.iterator](): IterableIterator<
2794
- Record<string, (ArrayBuffer | string | number) | null>
2795
- >;
2802
+ [Symbol.iterator](): IterableIterator<T>;
2796
2803
  }
2797
2804
  export interface Socket {
2798
2805
  get readable(): ReadableStream;
@@ -3331,7 +3338,7 @@ export interface GPUOrigin3DDict {
3331
3338
  z?: number;
3332
3339
  }
3333
3340
  /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource) */
3334
- export declare class EventSource {
3341
+ export declare class EventSource extends EventTarget {
3335
3342
  constructor(url: string, init?: EventSourceEventSourceInit);
3336
3343
  /**
3337
3344
  * Aborts any instances of the fetch algorithm started for this EventSource object, and sets the readyState attribute to CLOSED.
@@ -5501,13 +5508,57 @@ export interface DispatchNamespace {
5501
5508
  options?: DynamicDispatchOptions,
5502
5509
  ): Fetcher;
5503
5510
  }
5504
- /**
5505
- * NonRetryableError allows for a Workflow to throw a "fatal" error as in,
5506
- * an error that makes the instance fail immediately without triggering a retry.
5507
- */
5508
- export declare class NonRetryableError extends Error {
5509
- // __brand has been explicity omitted because it's a internal brand used for
5510
- // the Workflows' engine and user's shouldn't be able to override it
5511
- // (at least, in a direct way)
5512
- public constructor(message: string, name?: string);
5511
+ export declare abstract class Workflow {
5512
+ /**
5513
+ * Get a handle to an existing instance of the Workflow.
5514
+ * @param id Id for the instance of this Workflow
5515
+ * @returns A promise that resolves with a handle for the Instance
5516
+ */
5517
+ public get(id: string): Promise<Instance>;
5518
+ /**
5519
+ * Create a new instance and return a handle to it. If a provided id exists, an error will be thrown.
5520
+ * @param id Id to create the instance of this Workflow with
5521
+ * @param params The payload to send over to this instance
5522
+ * @returns A promise that resolves with a handle for the Instance
5523
+ */
5524
+ public create(id: string, params: object): Promise<Instance>;
5525
+ }
5526
+ export type InstanceStatus = {
5527
+ status:
5528
+ | "queued"
5529
+ | "running"
5530
+ | "paused"
5531
+ | "errored"
5532
+ | "terminated"
5533
+ | "complete"
5534
+ | "unknown";
5535
+ error?: string;
5536
+ output?: object;
5537
+ };
5538
+ export interface WorkflowError {
5539
+ code?: number;
5540
+ message: string;
5541
+ }
5542
+ export declare abstract class Instance {
5543
+ public id: string;
5544
+ /**
5545
+ * Pause the instance.
5546
+ */
5547
+ public pause(): Promise<void>;
5548
+ /**
5549
+ * Resume the instance. If it is already running, an error will be thrown.
5550
+ */
5551
+ public resume(): Promise<void>;
5552
+ /**
5553
+ * Abort the instance. If it is errored, terminated or complete, an error will be thrown.
5554
+ */
5555
+ public abort(): Promise<void>;
5556
+ /**
5557
+ * Restart the instance.
5558
+ */
5559
+ public restart(): Promise<void>;
5560
+ /**
5561
+ * Returns the current status of the instance.
5562
+ */
5563
+ public status(): Promise<InstanceStatus>;
5513
5564
  }