@cloudflare/workers-types 4.20240903.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.
- package/2021-11-03/index.d.ts +114 -6
- package/2021-11-03/index.ts +101 -6
- package/2022-01-31/index.d.ts +114 -6
- package/2022-01-31/index.ts +101 -6
- package/2022-03-21/index.d.ts +114 -6
- package/2022-03-21/index.ts +101 -6
- package/2022-08-04/index.d.ts +114 -6
- package/2022-08-04/index.ts +101 -6
- package/2022-10-31/index.d.ts +114 -6
- package/2022-10-31/index.ts +101 -6
- package/2022-11-30/index.d.ts +114 -6
- package/2022-11-30/index.ts +101 -6
- package/2023-03-01/index.d.ts +114 -6
- package/2023-03-01/index.ts +101 -6
- package/2023-07-01/index.d.ts +114 -6
- package/2023-07-01/index.ts +101 -6
- package/experimental/index.d.ts +99 -12
- package/experimental/index.ts +86 -12
- package/index.d.ts +114 -6
- package/index.ts +101 -6
- package/oldest/index.d.ts +114 -6
- package/oldest/index.ts +101 -6
- package/package.json +1 -1
package/2023-07-01/index.ts
CHANGED
|
@@ -566,6 +566,7 @@ export interface DurableObjectState {
|
|
|
566
566
|
setHibernatableWebSocketEventTimeout(timeoutMs?: number): void;
|
|
567
567
|
getHibernatableWebSocketEventTimeout(): number | null;
|
|
568
568
|
getTags(ws: WebSocket): string[];
|
|
569
|
+
abort(reason?: string): void;
|
|
569
570
|
}
|
|
570
571
|
export interface DurableObjectTransaction {
|
|
571
572
|
get<T = unknown>(
|
|
@@ -632,7 +633,11 @@ export interface DurableObjectStorage {
|
|
|
632
633
|
): Promise<void>;
|
|
633
634
|
deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise<void>;
|
|
634
635
|
sync(): Promise<void>;
|
|
636
|
+
sql: SqlStorage;
|
|
635
637
|
transactionSync<T>(closure: () => T): T;
|
|
638
|
+
getCurrentBookmark(): Promise<string>;
|
|
639
|
+
getBookmarkForTime(timestamp: number | Date): Promise<string>;
|
|
640
|
+
onNextSessionRestoreBookmark(bookmark: string): Promise<string>;
|
|
636
641
|
}
|
|
637
642
|
export interface DurableObjectListOptions {
|
|
638
643
|
start?: string;
|
|
@@ -1548,7 +1553,11 @@ export declare abstract class Body {
|
|
|
1548
1553
|
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response)
|
|
1549
1554
|
*/
|
|
1550
1555
|
export declare class Response extends Body {
|
|
1551
|
-
constructor(
|
|
1556
|
+
constructor(
|
|
1557
|
+
body?: BodyInit | null,
|
|
1558
|
+
init?: ResponseInit,
|
|
1559
|
+
webSocket?: WebSocket,
|
|
1560
|
+
);
|
|
1552
1561
|
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/redirect_static) */
|
|
1553
1562
|
static redirect(url: string, status?: number): Response;
|
|
1554
1563
|
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/json_static) */
|
|
@@ -1575,7 +1584,7 @@ export interface ResponseInit {
|
|
|
1575
1584
|
statusText?: string;
|
|
1576
1585
|
headers?: HeadersInit;
|
|
1577
1586
|
cf?: any;
|
|
1578
|
-
webSocket?: WebSocket
|
|
1587
|
+
webSocket?: WebSocket;
|
|
1579
1588
|
encodeBody?: "automatic" | "manual";
|
|
1580
1589
|
}
|
|
1581
1590
|
export type RequestInfo<
|
|
@@ -2284,15 +2293,15 @@ export declare class TransformStream<I = any, O = any> {
|
|
|
2284
2293
|
}
|
|
2285
2294
|
export declare class FixedLengthStream extends IdentityTransformStream {
|
|
2286
2295
|
constructor(
|
|
2287
|
-
|
|
2288
|
-
|
|
2296
|
+
expectedLength: number | bigint,
|
|
2297
|
+
queuingStrategy?: IdentityTransformStreamQueuingStrategy,
|
|
2289
2298
|
);
|
|
2290
2299
|
}
|
|
2291
2300
|
export declare class IdentityTransformStream extends TransformStream<
|
|
2292
2301
|
ArrayBuffer | ArrayBufferView,
|
|
2293
2302
|
Uint8Array
|
|
2294
2303
|
> {
|
|
2295
|
-
constructor(
|
|
2304
|
+
constructor(queuingStrategy?: IdentityTransformStreamQueuingStrategy);
|
|
2296
2305
|
}
|
|
2297
2306
|
export interface IdentityTransformStreamQueuingStrategy {
|
|
2298
2307
|
highWaterMark?: number | bigint;
|
|
@@ -2772,6 +2781,26 @@ export declare const WebSocketPair: {
|
|
|
2772
2781
|
1: WebSocket;
|
|
2773
2782
|
};
|
|
2774
2783
|
};
|
|
2784
|
+
export interface SqlStorage {
|
|
2785
|
+
exec<T extends Record<string, SqlStorageValue>>(
|
|
2786
|
+
query: string,
|
|
2787
|
+
...bindings: any[]
|
|
2788
|
+
): SqlStorageCursor<T>;
|
|
2789
|
+
get databaseSize(): number;
|
|
2790
|
+
Cursor: typeof SqlStorageCursor;
|
|
2791
|
+
Statement: typeof SqlStorageStatement;
|
|
2792
|
+
}
|
|
2793
|
+
export declare abstract class SqlStorageStatement {}
|
|
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>;
|
|
2799
|
+
get columnNames(): string[];
|
|
2800
|
+
get rowsRead(): number;
|
|
2801
|
+
get rowsWritten(): number;
|
|
2802
|
+
[Symbol.iterator](): IterableIterator<T>;
|
|
2803
|
+
}
|
|
2775
2804
|
export interface Socket {
|
|
2776
2805
|
get readable(): ReadableStream;
|
|
2777
2806
|
get writable(): WritableStream;
|
|
@@ -3309,7 +3338,7 @@ export interface GPUOrigin3DDict {
|
|
|
3309
3338
|
z?: number;
|
|
3310
3339
|
}
|
|
3311
3340
|
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource) */
|
|
3312
|
-
export declare class EventSource {
|
|
3341
|
+
export declare class EventSource extends EventTarget {
|
|
3313
3342
|
constructor(url: string, init?: EventSourceEventSourceInit);
|
|
3314
3343
|
/**
|
|
3315
3344
|
* Aborts any instances of the fetch algorithm started for this EventSource object, and sets the readyState attribute to CLOSED.
|
|
@@ -4971,6 +5000,18 @@ export declare abstract class PipelineTransform {
|
|
|
4971
5000
|
*/
|
|
4972
5001
|
public transformJson(data: object[]): Promise<object[]>;
|
|
4973
5002
|
}
|
|
5003
|
+
// Copyright (c) 2022-2023 Cloudflare, Inc.
|
|
5004
|
+
// Licensed under the Apache 2.0 license found in the LICENSE file or at:
|
|
5005
|
+
// https://opensource.org/licenses/Apache-2.0
|
|
5006
|
+
export interface Pipeline {
|
|
5007
|
+
/**
|
|
5008
|
+
* send takes an array of javascript objects which are
|
|
5009
|
+
* then received by the pipeline for processing
|
|
5010
|
+
*
|
|
5011
|
+
* @param data The data to be sent
|
|
5012
|
+
*/
|
|
5013
|
+
send(data: object[]): Promise<void>;
|
|
5014
|
+
}
|
|
4974
5015
|
// PubSubMessage represents an incoming PubSub message.
|
|
4975
5016
|
// The message includes metadata about the broker, the client, and the payload
|
|
4976
5017
|
// itself.
|
|
@@ -5467,3 +5508,57 @@ export interface DispatchNamespace {
|
|
|
5467
5508
|
options?: DynamicDispatchOptions,
|
|
5468
5509
|
): Fetcher;
|
|
5469
5510
|
}
|
|
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>;
|
|
5564
|
+
}
|
package/experimental/index.d.ts
CHANGED
|
@@ -1553,7 +1553,11 @@ declare abstract class Body {
|
|
|
1553
1553
|
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response)
|
|
1554
1554
|
*/
|
|
1555
1555
|
declare class Response extends Body {
|
|
1556
|
-
constructor(
|
|
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 @@ interface ResponseInit {
|
|
|
1580
1584
|
statusText?: string;
|
|
1581
1585
|
headers?: HeadersInit;
|
|
1582
1586
|
cf?: any;
|
|
1583
|
-
webSocket?: WebSocket
|
|
1587
|
+
webSocket?: WebSocket;
|
|
1584
1588
|
encodeBody?: "automatic" | "manual";
|
|
1585
1589
|
}
|
|
1586
1590
|
type RequestInfo<CfHostMetadata = unknown, Cf = CfProperties<CfHostMetadata>> =
|
|
@@ -2337,15 +2341,15 @@ declare class TransformStream<I = any, O = any> {
|
|
|
2337
2341
|
}
|
|
2338
2342
|
declare class FixedLengthStream extends IdentityTransformStream {
|
|
2339
2343
|
constructor(
|
|
2340
|
-
|
|
2341
|
-
|
|
2344
|
+
expectedLength: number | bigint,
|
|
2345
|
+
queuingStrategy?: IdentityTransformStreamQueuingStrategy,
|
|
2342
2346
|
);
|
|
2343
2347
|
}
|
|
2344
2348
|
declare class IdentityTransformStream extends TransformStream<
|
|
2345
2349
|
ArrayBuffer | ArrayBufferView,
|
|
2346
2350
|
Uint8Array
|
|
2347
2351
|
> {
|
|
2348
|
-
constructor(
|
|
2352
|
+
constructor(queuingStrategy?: IdentityTransformStreamQueuingStrategy);
|
|
2349
2353
|
}
|
|
2350
2354
|
interface IdentityTransformStreamQueuingStrategy {
|
|
2351
2355
|
highWaterMark?: number | bigint;
|
|
@@ -2823,7 +2827,10 @@ declare const WebSocketPair: {
|
|
|
2823
2827
|
};
|
|
2824
2828
|
};
|
|
2825
2829
|
interface SqlStorage {
|
|
2826
|
-
exec
|
|
2830
|
+
exec<T extends Record<string, SqlStorageValue>>(
|
|
2831
|
+
query: string,
|
|
2832
|
+
...bindings: any[]
|
|
2833
|
+
): SqlStorageCursor<T>;
|
|
2827
2834
|
prepare(query: string): SqlStorageStatement;
|
|
2828
2835
|
ingest(query: string): SqlStorageIngestResult;
|
|
2829
2836
|
get databaseSize(): number;
|
|
@@ -2831,14 +2838,15 @@ interface SqlStorage {
|
|
|
2831
2838
|
Statement: typeof SqlStorageStatement;
|
|
2832
2839
|
}
|
|
2833
2840
|
declare abstract class SqlStorageStatement {}
|
|
2834
|
-
|
|
2835
|
-
|
|
2841
|
+
type SqlStorageValue = ArrayBuffer | string | number | null;
|
|
2842
|
+
declare abstract class SqlStorageCursor<
|
|
2843
|
+
T extends Record<string, SqlStorageValue>,
|
|
2844
|
+
> {
|
|
2845
|
+
raw<U extends SqlStorageValue[]>(): IterableIterator<U>;
|
|
2836
2846
|
get columnNames(): string[];
|
|
2837
2847
|
get rowsRead(): number;
|
|
2838
2848
|
get rowsWritten(): number;
|
|
2839
|
-
[Symbol.iterator](): IterableIterator<
|
|
2840
|
-
Record<string, (ArrayBuffer | string | number) | null>
|
|
2841
|
-
>;
|
|
2849
|
+
[Symbol.iterator](): IterableIterator<T>;
|
|
2842
2850
|
}
|
|
2843
2851
|
interface SqlStorageIngestResult {
|
|
2844
2852
|
remainder: string;
|
|
@@ -3383,7 +3391,7 @@ interface GPUOrigin3DDict {
|
|
|
3383
3391
|
z?: number;
|
|
3384
3392
|
}
|
|
3385
3393
|
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource) */
|
|
3386
|
-
declare class EventSource {
|
|
3394
|
+
declare class EventSource extends EventTarget {
|
|
3387
3395
|
constructor(url: string, init?: EventSourceEventSourceInit);
|
|
3388
3396
|
/**
|
|
3389
3397
|
* Aborts any instances of the fetch algorithm started for this EventSource object, and sets the readyState attribute to CLOSED.
|
|
@@ -5042,6 +5050,18 @@ declare abstract class PipelineTransform {
|
|
|
5042
5050
|
*/
|
|
5043
5051
|
public transformJson(data: object[]): Promise<object[]>;
|
|
5044
5052
|
}
|
|
5053
|
+
// Copyright (c) 2022-2023 Cloudflare, Inc.
|
|
5054
|
+
// Licensed under the Apache 2.0 license found in the LICENSE file or at:
|
|
5055
|
+
// https://opensource.org/licenses/Apache-2.0
|
|
5056
|
+
interface Pipeline {
|
|
5057
|
+
/**
|
|
5058
|
+
* send takes an array of javascript objects which are
|
|
5059
|
+
* then received by the pipeline for processing
|
|
5060
|
+
*
|
|
5061
|
+
* @param data The data to be sent
|
|
5062
|
+
*/
|
|
5063
|
+
send(data: object[]): Promise<void>;
|
|
5064
|
+
}
|
|
5045
5065
|
// PubSubMessage represents an incoming PubSub message.
|
|
5046
5066
|
// The message includes metadata about the broker, the client, and the payload
|
|
5047
5067
|
// itself.
|
|
@@ -5635,3 +5655,70 @@ interface DispatchNamespace {
|
|
|
5635
5655
|
options?: DynamicDispatchOptions,
|
|
5636
5656
|
): Fetcher;
|
|
5637
5657
|
}
|
|
5658
|
+
/**
|
|
5659
|
+
* NonRetryableError allows for a user to throw a fatal error
|
|
5660
|
+
* that makes a Workflow instance fail immediately without triggering a retry
|
|
5661
|
+
*/
|
|
5662
|
+
declare module "cloudflare:workflows" {
|
|
5663
|
+
export abstract class NonRetryableError extends Error {
|
|
5664
|
+
/**
|
|
5665
|
+
* `__brand` is used to differentiate between `NonRetryableError` and `Error`
|
|
5666
|
+
* and is omitted from the constructor because users should not set it
|
|
5667
|
+
*/
|
|
5668
|
+
public constructor(message: string, name?: string);
|
|
5669
|
+
}
|
|
5670
|
+
}
|
|
5671
|
+
declare abstract class Workflow {
|
|
5672
|
+
/**
|
|
5673
|
+
* Get a handle to an existing instance of the Workflow.
|
|
5674
|
+
* @param id Id for the instance of this Workflow
|
|
5675
|
+
* @returns A promise that resolves with a handle for the Instance
|
|
5676
|
+
*/
|
|
5677
|
+
public get(id: string): Promise<Instance>;
|
|
5678
|
+
/**
|
|
5679
|
+
* Create a new instance and return a handle to it. If a provided id exists, an error will be thrown.
|
|
5680
|
+
* @param id Id to create the instance of this Workflow with
|
|
5681
|
+
* @param params The payload to send over to this instance
|
|
5682
|
+
* @returns A promise that resolves with a handle for the Instance
|
|
5683
|
+
*/
|
|
5684
|
+
public create(id: string, params: object): Promise<Instance>;
|
|
5685
|
+
}
|
|
5686
|
+
type InstanceStatus = {
|
|
5687
|
+
status:
|
|
5688
|
+
| "queued"
|
|
5689
|
+
| "running"
|
|
5690
|
+
| "paused"
|
|
5691
|
+
| "errored"
|
|
5692
|
+
| "terminated"
|
|
5693
|
+
| "complete"
|
|
5694
|
+
| "unknown";
|
|
5695
|
+
error?: string;
|
|
5696
|
+
output?: object;
|
|
5697
|
+
};
|
|
5698
|
+
interface WorkflowError {
|
|
5699
|
+
code?: number;
|
|
5700
|
+
message: string;
|
|
5701
|
+
}
|
|
5702
|
+
declare abstract class Instance {
|
|
5703
|
+
public id: string;
|
|
5704
|
+
/**
|
|
5705
|
+
* Pause the instance.
|
|
5706
|
+
*/
|
|
5707
|
+
public pause(): Promise<void>;
|
|
5708
|
+
/**
|
|
5709
|
+
* Resume the instance. If it is already running, an error will be thrown.
|
|
5710
|
+
*/
|
|
5711
|
+
public resume(): Promise<void>;
|
|
5712
|
+
/**
|
|
5713
|
+
* Abort the instance. If it is errored, terminated or complete, an error will be thrown.
|
|
5714
|
+
*/
|
|
5715
|
+
public abort(): Promise<void>;
|
|
5716
|
+
/**
|
|
5717
|
+
* Restart the instance.
|
|
5718
|
+
*/
|
|
5719
|
+
public restart(): Promise<void>;
|
|
5720
|
+
/**
|
|
5721
|
+
* Returns the current status of the instance.
|
|
5722
|
+
*/
|
|
5723
|
+
public status(): Promise<InstanceStatus>;
|
|
5724
|
+
}
|
package/experimental/index.ts
CHANGED
|
@@ -1558,7 +1558,11 @@ export declare abstract class Body {
|
|
|
1558
1558
|
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response)
|
|
1559
1559
|
*/
|
|
1560
1560
|
export declare class Response extends Body {
|
|
1561
|
-
constructor(
|
|
1561
|
+
constructor(
|
|
1562
|
+
body?: BodyInit | null,
|
|
1563
|
+
init?: ResponseInit,
|
|
1564
|
+
webSocket?: WebSocket,
|
|
1565
|
+
);
|
|
1562
1566
|
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/redirect_static) */
|
|
1563
1567
|
static redirect(url: string, status?: number): Response;
|
|
1564
1568
|
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/json_static) */
|
|
@@ -1585,7 +1589,7 @@ export interface ResponseInit {
|
|
|
1585
1589
|
statusText?: string;
|
|
1586
1590
|
headers?: HeadersInit;
|
|
1587
1591
|
cf?: any;
|
|
1588
|
-
webSocket?: WebSocket
|
|
1592
|
+
webSocket?: WebSocket;
|
|
1589
1593
|
encodeBody?: "automatic" | "manual";
|
|
1590
1594
|
}
|
|
1591
1595
|
export type RequestInfo<
|
|
@@ -2343,15 +2347,15 @@ export declare class TransformStream<I = any, O = any> {
|
|
|
2343
2347
|
}
|
|
2344
2348
|
export declare class FixedLengthStream extends IdentityTransformStream {
|
|
2345
2349
|
constructor(
|
|
2346
|
-
|
|
2347
|
-
|
|
2350
|
+
expectedLength: number | bigint,
|
|
2351
|
+
queuingStrategy?: IdentityTransformStreamQueuingStrategy,
|
|
2348
2352
|
);
|
|
2349
2353
|
}
|
|
2350
2354
|
export declare class IdentityTransformStream extends TransformStream<
|
|
2351
2355
|
ArrayBuffer | ArrayBufferView,
|
|
2352
2356
|
Uint8Array
|
|
2353
2357
|
> {
|
|
2354
|
-
constructor(
|
|
2358
|
+
constructor(queuingStrategy?: IdentityTransformStreamQueuingStrategy);
|
|
2355
2359
|
}
|
|
2356
2360
|
export interface IdentityTransformStreamQueuingStrategy {
|
|
2357
2361
|
highWaterMark?: number | bigint;
|
|
@@ -2832,7 +2836,10 @@ export declare const WebSocketPair: {
|
|
|
2832
2836
|
};
|
|
2833
2837
|
};
|
|
2834
2838
|
export interface SqlStorage {
|
|
2835
|
-
exec
|
|
2839
|
+
exec<T extends Record<string, SqlStorageValue>>(
|
|
2840
|
+
query: string,
|
|
2841
|
+
...bindings: any[]
|
|
2842
|
+
): SqlStorageCursor<T>;
|
|
2836
2843
|
prepare(query: string): SqlStorageStatement;
|
|
2837
2844
|
ingest(query: string): SqlStorageIngestResult;
|
|
2838
2845
|
get databaseSize(): number;
|
|
@@ -2840,14 +2847,15 @@ export interface SqlStorage {
|
|
|
2840
2847
|
Statement: typeof SqlStorageStatement;
|
|
2841
2848
|
}
|
|
2842
2849
|
export declare abstract class SqlStorageStatement {}
|
|
2843
|
-
export
|
|
2844
|
-
|
|
2850
|
+
export type SqlStorageValue = ArrayBuffer | string | number | null;
|
|
2851
|
+
export declare abstract class SqlStorageCursor<
|
|
2852
|
+
T extends Record<string, SqlStorageValue>,
|
|
2853
|
+
> {
|
|
2854
|
+
raw<U extends SqlStorageValue[]>(): IterableIterator<U>;
|
|
2845
2855
|
get columnNames(): string[];
|
|
2846
2856
|
get rowsRead(): number;
|
|
2847
2857
|
get rowsWritten(): number;
|
|
2848
|
-
[Symbol.iterator](): IterableIterator<
|
|
2849
|
-
Record<string, (ArrayBuffer | string | number) | null>
|
|
2850
|
-
>;
|
|
2858
|
+
[Symbol.iterator](): IterableIterator<T>;
|
|
2851
2859
|
}
|
|
2852
2860
|
export interface SqlStorageIngestResult {
|
|
2853
2861
|
remainder: string;
|
|
@@ -3392,7 +3400,7 @@ export interface GPUOrigin3DDict {
|
|
|
3392
3400
|
z?: number;
|
|
3393
3401
|
}
|
|
3394
3402
|
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource) */
|
|
3395
|
-
export declare class EventSource {
|
|
3403
|
+
export declare class EventSource extends EventTarget {
|
|
3396
3404
|
constructor(url: string, init?: EventSourceEventSourceInit);
|
|
3397
3405
|
/**
|
|
3398
3406
|
* Aborts any instances of the fetch algorithm started for this EventSource object, and sets the readyState attribute to CLOSED.
|
|
@@ -5054,6 +5062,18 @@ export declare abstract class PipelineTransform {
|
|
|
5054
5062
|
*/
|
|
5055
5063
|
public transformJson(data: object[]): Promise<object[]>;
|
|
5056
5064
|
}
|
|
5065
|
+
// Copyright (c) 2022-2023 Cloudflare, Inc.
|
|
5066
|
+
// Licensed under the Apache 2.0 license found in the LICENSE file or at:
|
|
5067
|
+
// https://opensource.org/licenses/Apache-2.0
|
|
5068
|
+
export interface Pipeline {
|
|
5069
|
+
/**
|
|
5070
|
+
* send takes an array of javascript objects which are
|
|
5071
|
+
* then received by the pipeline for processing
|
|
5072
|
+
*
|
|
5073
|
+
* @param data The data to be sent
|
|
5074
|
+
*/
|
|
5075
|
+
send(data: object[]): Promise<void>;
|
|
5076
|
+
}
|
|
5057
5077
|
// PubSubMessage represents an incoming PubSub message.
|
|
5058
5078
|
// The message includes metadata about the broker, the client, and the payload
|
|
5059
5079
|
// itself.
|
|
@@ -5550,3 +5570,57 @@ export interface DispatchNamespace {
|
|
|
5550
5570
|
options?: DynamicDispatchOptions,
|
|
5551
5571
|
): Fetcher;
|
|
5552
5572
|
}
|
|
5573
|
+
export declare abstract class Workflow {
|
|
5574
|
+
/**
|
|
5575
|
+
* Get a handle to an existing instance of the Workflow.
|
|
5576
|
+
* @param id Id for the instance of this Workflow
|
|
5577
|
+
* @returns A promise that resolves with a handle for the Instance
|
|
5578
|
+
*/
|
|
5579
|
+
public get(id: string): Promise<Instance>;
|
|
5580
|
+
/**
|
|
5581
|
+
* Create a new instance and return a handle to it. If a provided id exists, an error will be thrown.
|
|
5582
|
+
* @param id Id to create the instance of this Workflow with
|
|
5583
|
+
* @param params The payload to send over to this instance
|
|
5584
|
+
* @returns A promise that resolves with a handle for the Instance
|
|
5585
|
+
*/
|
|
5586
|
+
public create(id: string, params: object): Promise<Instance>;
|
|
5587
|
+
}
|
|
5588
|
+
export type InstanceStatus = {
|
|
5589
|
+
status:
|
|
5590
|
+
| "queued"
|
|
5591
|
+
| "running"
|
|
5592
|
+
| "paused"
|
|
5593
|
+
| "errored"
|
|
5594
|
+
| "terminated"
|
|
5595
|
+
| "complete"
|
|
5596
|
+
| "unknown";
|
|
5597
|
+
error?: string;
|
|
5598
|
+
output?: object;
|
|
5599
|
+
};
|
|
5600
|
+
export interface WorkflowError {
|
|
5601
|
+
code?: number;
|
|
5602
|
+
message: string;
|
|
5603
|
+
}
|
|
5604
|
+
export declare abstract class Instance {
|
|
5605
|
+
public id: string;
|
|
5606
|
+
/**
|
|
5607
|
+
* Pause the instance.
|
|
5608
|
+
*/
|
|
5609
|
+
public pause(): Promise<void>;
|
|
5610
|
+
/**
|
|
5611
|
+
* Resume the instance. If it is already running, an error will be thrown.
|
|
5612
|
+
*/
|
|
5613
|
+
public resume(): Promise<void>;
|
|
5614
|
+
/**
|
|
5615
|
+
* Abort the instance. If it is errored, terminated or complete, an error will be thrown.
|
|
5616
|
+
*/
|
|
5617
|
+
public abort(): Promise<void>;
|
|
5618
|
+
/**
|
|
5619
|
+
* Restart the instance.
|
|
5620
|
+
*/
|
|
5621
|
+
public restart(): Promise<void>;
|
|
5622
|
+
/**
|
|
5623
|
+
* Returns the current status of the instance.
|
|
5624
|
+
*/
|
|
5625
|
+
public status(): Promise<InstanceStatus>;
|
|
5626
|
+
}
|
package/index.d.ts
CHANGED
|
@@ -539,6 +539,7 @@ interface DurableObjectState {
|
|
|
539
539
|
setHibernatableWebSocketEventTimeout(timeoutMs?: number): void;
|
|
540
540
|
getHibernatableWebSocketEventTimeout(): number | null;
|
|
541
541
|
getTags(ws: WebSocket): string[];
|
|
542
|
+
abort(reason?: string): void;
|
|
542
543
|
}
|
|
543
544
|
interface DurableObjectTransaction {
|
|
544
545
|
get<T = unknown>(
|
|
@@ -605,7 +606,11 @@ interface DurableObjectStorage {
|
|
|
605
606
|
): Promise<void>;
|
|
606
607
|
deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise<void>;
|
|
607
608
|
sync(): Promise<void>;
|
|
609
|
+
sql: SqlStorage;
|
|
608
610
|
transactionSync<T>(closure: () => T): T;
|
|
611
|
+
getCurrentBookmark(): Promise<string>;
|
|
612
|
+
getBookmarkForTime(timestamp: number | Date): Promise<string>;
|
|
613
|
+
onNextSessionRestoreBookmark(bookmark: string): Promise<string>;
|
|
609
614
|
}
|
|
610
615
|
interface DurableObjectListOptions {
|
|
611
616
|
start?: string;
|
|
@@ -1513,7 +1518,11 @@ declare abstract class Body {
|
|
|
1513
1518
|
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response)
|
|
1514
1519
|
*/
|
|
1515
1520
|
declare class Response extends Body {
|
|
1516
|
-
constructor(
|
|
1521
|
+
constructor(
|
|
1522
|
+
body?: BodyInit | null,
|
|
1523
|
+
init?: ResponseInit,
|
|
1524
|
+
webSocket?: WebSocket,
|
|
1525
|
+
);
|
|
1517
1526
|
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/redirect_static) */
|
|
1518
1527
|
static redirect(url: string, status?: number): Response;
|
|
1519
1528
|
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/json_static) */
|
|
@@ -1540,7 +1549,7 @@ interface ResponseInit {
|
|
|
1540
1549
|
statusText?: string;
|
|
1541
1550
|
headers?: HeadersInit;
|
|
1542
1551
|
cf?: any;
|
|
1543
|
-
webSocket?: WebSocket
|
|
1552
|
+
webSocket?: WebSocket;
|
|
1544
1553
|
encodeBody?: "automatic" | "manual";
|
|
1545
1554
|
}
|
|
1546
1555
|
type RequestInfo<CfHostMetadata = unknown, Cf = CfProperties<CfHostMetadata>> =
|
|
@@ -2247,15 +2256,15 @@ declare class TransformStream<I = any, O = any> {
|
|
|
2247
2256
|
}
|
|
2248
2257
|
declare class FixedLengthStream extends IdentityTransformStream {
|
|
2249
2258
|
constructor(
|
|
2250
|
-
|
|
2251
|
-
|
|
2259
|
+
expectedLength: number | bigint,
|
|
2260
|
+
queuingStrategy?: IdentityTransformStreamQueuingStrategy,
|
|
2252
2261
|
);
|
|
2253
2262
|
}
|
|
2254
2263
|
declare class IdentityTransformStream extends TransformStream<
|
|
2255
2264
|
ArrayBuffer | ArrayBufferView,
|
|
2256
2265
|
Uint8Array
|
|
2257
2266
|
> {
|
|
2258
|
-
constructor(
|
|
2267
|
+
constructor(queuingStrategy?: IdentityTransformStreamQueuingStrategy);
|
|
2259
2268
|
}
|
|
2260
2269
|
interface IdentityTransformStreamQueuingStrategy {
|
|
2261
2270
|
highWaterMark?: number | bigint;
|
|
@@ -2713,6 +2722,26 @@ declare const WebSocketPair: {
|
|
|
2713
2722
|
1: WebSocket;
|
|
2714
2723
|
};
|
|
2715
2724
|
};
|
|
2725
|
+
interface SqlStorage {
|
|
2726
|
+
exec<T extends Record<string, SqlStorageValue>>(
|
|
2727
|
+
query: string,
|
|
2728
|
+
...bindings: any[]
|
|
2729
|
+
): SqlStorageCursor<T>;
|
|
2730
|
+
get databaseSize(): number;
|
|
2731
|
+
Cursor: typeof SqlStorageCursor;
|
|
2732
|
+
Statement: typeof SqlStorageStatement;
|
|
2733
|
+
}
|
|
2734
|
+
declare abstract class SqlStorageStatement {}
|
|
2735
|
+
type SqlStorageValue = ArrayBuffer | string | number | null;
|
|
2736
|
+
declare abstract class SqlStorageCursor<
|
|
2737
|
+
T extends Record<string, SqlStorageValue>,
|
|
2738
|
+
> {
|
|
2739
|
+
raw<U extends SqlStorageValue[]>(): IterableIterator<U>;
|
|
2740
|
+
get columnNames(): string[];
|
|
2741
|
+
get rowsRead(): number;
|
|
2742
|
+
get rowsWritten(): number;
|
|
2743
|
+
[Symbol.iterator](): IterableIterator<T>;
|
|
2744
|
+
}
|
|
2716
2745
|
interface Socket {
|
|
2717
2746
|
get readable(): ReadableStream;
|
|
2718
2747
|
get writable(): WritableStream;
|
|
@@ -3243,7 +3272,7 @@ interface GPUOrigin3DDict {
|
|
|
3243
3272
|
z?: number;
|
|
3244
3273
|
}
|
|
3245
3274
|
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource) */
|
|
3246
|
-
declare class EventSource {
|
|
3275
|
+
declare class EventSource extends EventTarget {
|
|
3247
3276
|
constructor(url: string, init?: EventSourceEventSourceInit);
|
|
3248
3277
|
/**
|
|
3249
3278
|
* Aborts any instances of the fetch algorithm started for this EventSource object, and sets the readyState attribute to CLOSED.
|
|
@@ -4902,6 +4931,18 @@ declare abstract class PipelineTransform {
|
|
|
4902
4931
|
*/
|
|
4903
4932
|
public transformJson(data: object[]): Promise<object[]>;
|
|
4904
4933
|
}
|
|
4934
|
+
// Copyright (c) 2022-2023 Cloudflare, Inc.
|
|
4935
|
+
// Licensed under the Apache 2.0 license found in the LICENSE file or at:
|
|
4936
|
+
// https://opensource.org/licenses/Apache-2.0
|
|
4937
|
+
interface Pipeline {
|
|
4938
|
+
/**
|
|
4939
|
+
* send takes an array of javascript objects which are
|
|
4940
|
+
* then received by the pipeline for processing
|
|
4941
|
+
*
|
|
4942
|
+
* @param data The data to be sent
|
|
4943
|
+
*/
|
|
4944
|
+
send(data: object[]): Promise<void>;
|
|
4945
|
+
}
|
|
4905
4946
|
// PubSubMessage represents an incoming PubSub message.
|
|
4906
4947
|
// The message includes metadata about the broker, the client, and the payload
|
|
4907
4948
|
// itself.
|
|
@@ -5495,3 +5536,70 @@ interface DispatchNamespace {
|
|
|
5495
5536
|
options?: DynamicDispatchOptions,
|
|
5496
5537
|
): Fetcher;
|
|
5497
5538
|
}
|
|
5539
|
+
/**
|
|
5540
|
+
* NonRetryableError allows for a user to throw a fatal error
|
|
5541
|
+
* that makes a Workflow instance fail immediately without triggering a retry
|
|
5542
|
+
*/
|
|
5543
|
+
declare module "cloudflare:workflows" {
|
|
5544
|
+
export abstract class NonRetryableError extends Error {
|
|
5545
|
+
/**
|
|
5546
|
+
* `__brand` is used to differentiate between `NonRetryableError` and `Error`
|
|
5547
|
+
* and is omitted from the constructor because users should not set it
|
|
5548
|
+
*/
|
|
5549
|
+
public constructor(message: string, name?: string);
|
|
5550
|
+
}
|
|
5551
|
+
}
|
|
5552
|
+
declare abstract class Workflow {
|
|
5553
|
+
/**
|
|
5554
|
+
* Get a handle to an existing instance of the Workflow.
|
|
5555
|
+
* @param id Id for the instance of this Workflow
|
|
5556
|
+
* @returns A promise that resolves with a handle for the Instance
|
|
5557
|
+
*/
|
|
5558
|
+
public get(id: string): Promise<Instance>;
|
|
5559
|
+
/**
|
|
5560
|
+
* Create a new instance and return a handle to it. If a provided id exists, an error will be thrown.
|
|
5561
|
+
* @param id Id to create the instance of this Workflow with
|
|
5562
|
+
* @param params The payload to send over to this instance
|
|
5563
|
+
* @returns A promise that resolves with a handle for the Instance
|
|
5564
|
+
*/
|
|
5565
|
+
public create(id: string, params: object): Promise<Instance>;
|
|
5566
|
+
}
|
|
5567
|
+
type InstanceStatus = {
|
|
5568
|
+
status:
|
|
5569
|
+
| "queued"
|
|
5570
|
+
| "running"
|
|
5571
|
+
| "paused"
|
|
5572
|
+
| "errored"
|
|
5573
|
+
| "terminated"
|
|
5574
|
+
| "complete"
|
|
5575
|
+
| "unknown";
|
|
5576
|
+
error?: string;
|
|
5577
|
+
output?: object;
|
|
5578
|
+
};
|
|
5579
|
+
interface WorkflowError {
|
|
5580
|
+
code?: number;
|
|
5581
|
+
message: string;
|
|
5582
|
+
}
|
|
5583
|
+
declare abstract class Instance {
|
|
5584
|
+
public id: string;
|
|
5585
|
+
/**
|
|
5586
|
+
* Pause the instance.
|
|
5587
|
+
*/
|
|
5588
|
+
public pause(): Promise<void>;
|
|
5589
|
+
/**
|
|
5590
|
+
* Resume the instance. If it is already running, an error will be thrown.
|
|
5591
|
+
*/
|
|
5592
|
+
public resume(): Promise<void>;
|
|
5593
|
+
/**
|
|
5594
|
+
* Abort the instance. If it is errored, terminated or complete, an error will be thrown.
|
|
5595
|
+
*/
|
|
5596
|
+
public abort(): Promise<void>;
|
|
5597
|
+
/**
|
|
5598
|
+
* Restart the instance.
|
|
5599
|
+
*/
|
|
5600
|
+
public restart(): Promise<void>;
|
|
5601
|
+
/**
|
|
5602
|
+
* Returns the current status of the instance.
|
|
5603
|
+
*/
|
|
5604
|
+
public status(): Promise<InstanceStatus>;
|
|
5605
|
+
}
|