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