@cloudflare/workers-types 5.20260911.1 → 5.20260915.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/experimental/index.d.ts +208 -1
- package/experimental/index.ts +177 -0
- package/index.d.ts +208 -1
- package/index.ts +177 -0
- package/package.json +1 -1
package/experimental/index.d.ts
CHANGED
|
@@ -15555,11 +15555,41 @@ declare module "cloudflare:node" {
|
|
|
15555
15555
|
listen(...args: unknown[]): this;
|
|
15556
15556
|
address(): {
|
|
15557
15557
|
port?: number | null | undefined;
|
|
15558
|
-
};
|
|
15558
|
+
} | null;
|
|
15559
15559
|
}
|
|
15560
15560
|
export function httpServerHandler(port: number): ExportedHandler;
|
|
15561
15561
|
export function httpServerHandler(options: { port: number }): ExportedHandler;
|
|
15562
15562
|
export function httpServerHandler(server: NodeStyleServer): ExportedHandler;
|
|
15563
|
+
/**
|
|
15564
|
+
* Dispatches a request to the `http.Server` listening on the given port and
|
|
15565
|
+
* resolves with its response. The direct form of `httpServerHandler()`.
|
|
15566
|
+
*/
|
|
15567
|
+
export function handleAsNodeRequest(
|
|
15568
|
+
port:
|
|
15569
|
+
| number
|
|
15570
|
+
| {
|
|
15571
|
+
port: number;
|
|
15572
|
+
},
|
|
15573
|
+
request: Request,
|
|
15574
|
+
env?: unknown,
|
|
15575
|
+
ctx?: ExecutionContext,
|
|
15576
|
+
): Promise<Response>;
|
|
15577
|
+
/**
|
|
15578
|
+
* Routes inbound sockets to the `net.Server` listening on the port each
|
|
15579
|
+
* socket arrived on.
|
|
15580
|
+
*/
|
|
15581
|
+
export function connectHandler(): ExportedHandler;
|
|
15582
|
+
/**
|
|
15583
|
+
* Dispatches an inbound socket to the `net.Server` listening on the port it
|
|
15584
|
+
* arrived on, resolving when the connection has closed. The direct form of
|
|
15585
|
+
* `connectHandler()`, for use inside a `connect()` handler, such as a
|
|
15586
|
+
* Durable Object's.
|
|
15587
|
+
*/
|
|
15588
|
+
export function handleAsNodeConnection(
|
|
15589
|
+
socket: Socket,
|
|
15590
|
+
env?: unknown,
|
|
15591
|
+
ctx?: ExecutionContext,
|
|
15592
|
+
): Promise<void>;
|
|
15563
15593
|
}
|
|
15564
15594
|
type Params<P extends string = any> = Record<P, string | string[]>;
|
|
15565
15595
|
type EventContext<Env, P extends string, Data> = {
|
|
@@ -17752,6 +17782,7 @@ type InstanceStatus = {
|
|
|
17752
17782
|
| "complete"
|
|
17753
17783
|
| "waiting" // instance is hibernating and waiting for sleep or event to finish
|
|
17754
17784
|
| "waitingForPause" // instance is finishing the current work to pause
|
|
17785
|
+
| "rollingBack"
|
|
17755
17786
|
| "unknown";
|
|
17756
17787
|
error?: {
|
|
17757
17788
|
name: string;
|
|
@@ -17791,6 +17822,176 @@ interface WorkflowInstanceRestartOptions {
|
|
|
17791
17822
|
type?: "do" | "sleep" | "waitForEvent";
|
|
17792
17823
|
};
|
|
17793
17824
|
}
|
|
17825
|
+
/** An event emitted by a Workflow instance. */
|
|
17826
|
+
type WorkflowInstanceEvent = {
|
|
17827
|
+
instanceId: string;
|
|
17828
|
+
eventId: number;
|
|
17829
|
+
timestamp: number;
|
|
17830
|
+
} & (
|
|
17831
|
+
| {
|
|
17832
|
+
type: "workflow_queued";
|
|
17833
|
+
}
|
|
17834
|
+
| {
|
|
17835
|
+
type: "workflow_started";
|
|
17836
|
+
params?: unknown;
|
|
17837
|
+
}
|
|
17838
|
+
| {
|
|
17839
|
+
type: "workflow_running";
|
|
17840
|
+
}
|
|
17841
|
+
| {
|
|
17842
|
+
type: "workflow_paused";
|
|
17843
|
+
}
|
|
17844
|
+
| {
|
|
17845
|
+
type: "workflow_waiting_for_pause";
|
|
17846
|
+
}
|
|
17847
|
+
| {
|
|
17848
|
+
type: "workflow_waiting";
|
|
17849
|
+
}
|
|
17850
|
+
| {
|
|
17851
|
+
type: "workflow_completed";
|
|
17852
|
+
output?: unknown;
|
|
17853
|
+
}
|
|
17854
|
+
| {
|
|
17855
|
+
type: "workflow_errored";
|
|
17856
|
+
error: {
|
|
17857
|
+
name: string;
|
|
17858
|
+
message: string;
|
|
17859
|
+
};
|
|
17860
|
+
}
|
|
17861
|
+
| {
|
|
17862
|
+
type: "workflow_terminated";
|
|
17863
|
+
}
|
|
17864
|
+
| {
|
|
17865
|
+
type: "step_started";
|
|
17866
|
+
stepName: string;
|
|
17867
|
+
config?: {
|
|
17868
|
+
retries: {
|
|
17869
|
+
limit: number;
|
|
17870
|
+
delay: WorkflowSleepDuration | "[dynamic]";
|
|
17871
|
+
backoff?: "constant" | "linear" | "exponential";
|
|
17872
|
+
};
|
|
17873
|
+
timeout: WorkflowSleepDuration;
|
|
17874
|
+
sensitive?: "output";
|
|
17875
|
+
};
|
|
17876
|
+
}
|
|
17877
|
+
| {
|
|
17878
|
+
type: "step_completed";
|
|
17879
|
+
stepName: string;
|
|
17880
|
+
output?: unknown;
|
|
17881
|
+
}
|
|
17882
|
+
| {
|
|
17883
|
+
type: "step_errored";
|
|
17884
|
+
stepName: string;
|
|
17885
|
+
}
|
|
17886
|
+
| {
|
|
17887
|
+
type: "attempt_started";
|
|
17888
|
+
stepName: string;
|
|
17889
|
+
attempt: number;
|
|
17890
|
+
}
|
|
17891
|
+
| {
|
|
17892
|
+
type: "attempt_completed";
|
|
17893
|
+
stepName: string;
|
|
17894
|
+
attempt: number;
|
|
17895
|
+
}
|
|
17896
|
+
| {
|
|
17897
|
+
type: "attempt_errored";
|
|
17898
|
+
stepName: string;
|
|
17899
|
+
attempt: number;
|
|
17900
|
+
retryDelayMs?: number;
|
|
17901
|
+
error: {
|
|
17902
|
+
name: string;
|
|
17903
|
+
message: string;
|
|
17904
|
+
};
|
|
17905
|
+
}
|
|
17906
|
+
| {
|
|
17907
|
+
type: "sleep_started";
|
|
17908
|
+
stepName: string;
|
|
17909
|
+
durationMs: number;
|
|
17910
|
+
}
|
|
17911
|
+
| {
|
|
17912
|
+
type: "sleep_completed";
|
|
17913
|
+
stepName: string;
|
|
17914
|
+
}
|
|
17915
|
+
| {
|
|
17916
|
+
type: "wait_started";
|
|
17917
|
+
stepName: string;
|
|
17918
|
+
eventType: string;
|
|
17919
|
+
}
|
|
17920
|
+
| {
|
|
17921
|
+
type: "wait_completed";
|
|
17922
|
+
stepName: string;
|
|
17923
|
+
}
|
|
17924
|
+
| {
|
|
17925
|
+
type: "wait_timed_out";
|
|
17926
|
+
stepName: string;
|
|
17927
|
+
}
|
|
17928
|
+
| {
|
|
17929
|
+
type: "rollback_started";
|
|
17930
|
+
}
|
|
17931
|
+
| {
|
|
17932
|
+
type: "rollback_step_started";
|
|
17933
|
+
stepName: string;
|
|
17934
|
+
config?: {
|
|
17935
|
+
retries: {
|
|
17936
|
+
limit: number;
|
|
17937
|
+
delay: WorkflowSleepDuration | "[dynamic]";
|
|
17938
|
+
backoff?: "constant" | "linear" | "exponential";
|
|
17939
|
+
};
|
|
17940
|
+
timeout: WorkflowSleepDuration;
|
|
17941
|
+
sensitive?: "output";
|
|
17942
|
+
};
|
|
17943
|
+
}
|
|
17944
|
+
| {
|
|
17945
|
+
type: "rollback_step_completed";
|
|
17946
|
+
stepName: string;
|
|
17947
|
+
}
|
|
17948
|
+
| {
|
|
17949
|
+
type: "rollback_step_errored";
|
|
17950
|
+
stepName: string;
|
|
17951
|
+
error: {
|
|
17952
|
+
name: string;
|
|
17953
|
+
message: string;
|
|
17954
|
+
};
|
|
17955
|
+
}
|
|
17956
|
+
| {
|
|
17957
|
+
type: "rollback_attempt_started";
|
|
17958
|
+
stepName: string;
|
|
17959
|
+
attempt: number;
|
|
17960
|
+
}
|
|
17961
|
+
| {
|
|
17962
|
+
type: "rollback_attempt_completed";
|
|
17963
|
+
stepName: string;
|
|
17964
|
+
attempt: number;
|
|
17965
|
+
}
|
|
17966
|
+
| {
|
|
17967
|
+
type: "rollback_attempt_errored";
|
|
17968
|
+
stepName: string;
|
|
17969
|
+
attempt: number;
|
|
17970
|
+
retryDelayMs?: number;
|
|
17971
|
+
error: {
|
|
17972
|
+
name: string;
|
|
17973
|
+
message: string;
|
|
17974
|
+
};
|
|
17975
|
+
}
|
|
17976
|
+
| {
|
|
17977
|
+
type: "rollback_completed";
|
|
17978
|
+
}
|
|
17979
|
+
| {
|
|
17980
|
+
type: "rollback_errored";
|
|
17981
|
+
}
|
|
17982
|
+
);
|
|
17983
|
+
type WorkflowInstanceEventType = WorkflowInstanceEvent["type"];
|
|
17984
|
+
/** Options available for a Workflow instance subscription. */
|
|
17985
|
+
type WorkflowInstanceSubscribeOptions = {
|
|
17986
|
+
/** The value from which to start the subscription. */
|
|
17987
|
+
cursor?: number;
|
|
17988
|
+
/** The event types to include in the subscription. */
|
|
17989
|
+
filter?: WorkflowInstanceEventType[];
|
|
17990
|
+
};
|
|
17991
|
+
/** A disposable subscription to a Workflow instance's events. */
|
|
17992
|
+
interface WorkflowInstanceSubscription extends Disposable {
|
|
17993
|
+
next(): Promise<IteratorResult<WorkflowInstanceEvent, void>>;
|
|
17994
|
+
}
|
|
17794
17995
|
declare abstract class WorkflowInstance {
|
|
17795
17996
|
public id: string;
|
|
17796
17997
|
/**
|
|
@@ -17830,4 +18031,10 @@ declare abstract class WorkflowInstance {
|
|
|
17830
18031
|
type: string;
|
|
17831
18032
|
payload: unknown;
|
|
17832
18033
|
}): Promise<void>;
|
|
18034
|
+
/**
|
|
18035
|
+
* Subscribe to events emitted by this instance.
|
|
18036
|
+
*/
|
|
18037
|
+
public subscribe(
|
|
18038
|
+
options?: WorkflowInstanceSubscribeOptions,
|
|
18039
|
+
): Promise<WorkflowInstanceSubscription>;
|
|
17833
18040
|
}
|
package/experimental/index.ts
CHANGED
|
@@ -17701,6 +17701,7 @@ export type InstanceStatus = {
|
|
|
17701
17701
|
| "complete"
|
|
17702
17702
|
| "waiting" // instance is hibernating and waiting for sleep or event to finish
|
|
17703
17703
|
| "waitingForPause" // instance is finishing the current work to pause
|
|
17704
|
+
| "rollingBack"
|
|
17704
17705
|
| "unknown";
|
|
17705
17706
|
error?: {
|
|
17706
17707
|
name: string;
|
|
@@ -17740,6 +17741,176 @@ export interface WorkflowInstanceRestartOptions {
|
|
|
17740
17741
|
type?: "do" | "sleep" | "waitForEvent";
|
|
17741
17742
|
};
|
|
17742
17743
|
}
|
|
17744
|
+
/** An event emitted by a Workflow instance. */
|
|
17745
|
+
export type WorkflowInstanceEvent = {
|
|
17746
|
+
instanceId: string;
|
|
17747
|
+
eventId: number;
|
|
17748
|
+
timestamp: number;
|
|
17749
|
+
} & (
|
|
17750
|
+
| {
|
|
17751
|
+
type: "workflow_queued";
|
|
17752
|
+
}
|
|
17753
|
+
| {
|
|
17754
|
+
type: "workflow_started";
|
|
17755
|
+
params?: unknown;
|
|
17756
|
+
}
|
|
17757
|
+
| {
|
|
17758
|
+
type: "workflow_running";
|
|
17759
|
+
}
|
|
17760
|
+
| {
|
|
17761
|
+
type: "workflow_paused";
|
|
17762
|
+
}
|
|
17763
|
+
| {
|
|
17764
|
+
type: "workflow_waiting_for_pause";
|
|
17765
|
+
}
|
|
17766
|
+
| {
|
|
17767
|
+
type: "workflow_waiting";
|
|
17768
|
+
}
|
|
17769
|
+
| {
|
|
17770
|
+
type: "workflow_completed";
|
|
17771
|
+
output?: unknown;
|
|
17772
|
+
}
|
|
17773
|
+
| {
|
|
17774
|
+
type: "workflow_errored";
|
|
17775
|
+
error: {
|
|
17776
|
+
name: string;
|
|
17777
|
+
message: string;
|
|
17778
|
+
};
|
|
17779
|
+
}
|
|
17780
|
+
| {
|
|
17781
|
+
type: "workflow_terminated";
|
|
17782
|
+
}
|
|
17783
|
+
| {
|
|
17784
|
+
type: "step_started";
|
|
17785
|
+
stepName: string;
|
|
17786
|
+
config?: {
|
|
17787
|
+
retries: {
|
|
17788
|
+
limit: number;
|
|
17789
|
+
delay: WorkflowSleepDuration | "[dynamic]";
|
|
17790
|
+
backoff?: "constant" | "linear" | "exponential";
|
|
17791
|
+
};
|
|
17792
|
+
timeout: WorkflowSleepDuration;
|
|
17793
|
+
sensitive?: "output";
|
|
17794
|
+
};
|
|
17795
|
+
}
|
|
17796
|
+
| {
|
|
17797
|
+
type: "step_completed";
|
|
17798
|
+
stepName: string;
|
|
17799
|
+
output?: unknown;
|
|
17800
|
+
}
|
|
17801
|
+
| {
|
|
17802
|
+
type: "step_errored";
|
|
17803
|
+
stepName: string;
|
|
17804
|
+
}
|
|
17805
|
+
| {
|
|
17806
|
+
type: "attempt_started";
|
|
17807
|
+
stepName: string;
|
|
17808
|
+
attempt: number;
|
|
17809
|
+
}
|
|
17810
|
+
| {
|
|
17811
|
+
type: "attempt_completed";
|
|
17812
|
+
stepName: string;
|
|
17813
|
+
attempt: number;
|
|
17814
|
+
}
|
|
17815
|
+
| {
|
|
17816
|
+
type: "attempt_errored";
|
|
17817
|
+
stepName: string;
|
|
17818
|
+
attempt: number;
|
|
17819
|
+
retryDelayMs?: number;
|
|
17820
|
+
error: {
|
|
17821
|
+
name: string;
|
|
17822
|
+
message: string;
|
|
17823
|
+
};
|
|
17824
|
+
}
|
|
17825
|
+
| {
|
|
17826
|
+
type: "sleep_started";
|
|
17827
|
+
stepName: string;
|
|
17828
|
+
durationMs: number;
|
|
17829
|
+
}
|
|
17830
|
+
| {
|
|
17831
|
+
type: "sleep_completed";
|
|
17832
|
+
stepName: string;
|
|
17833
|
+
}
|
|
17834
|
+
| {
|
|
17835
|
+
type: "wait_started";
|
|
17836
|
+
stepName: string;
|
|
17837
|
+
eventType: string;
|
|
17838
|
+
}
|
|
17839
|
+
| {
|
|
17840
|
+
type: "wait_completed";
|
|
17841
|
+
stepName: string;
|
|
17842
|
+
}
|
|
17843
|
+
| {
|
|
17844
|
+
type: "wait_timed_out";
|
|
17845
|
+
stepName: string;
|
|
17846
|
+
}
|
|
17847
|
+
| {
|
|
17848
|
+
type: "rollback_started";
|
|
17849
|
+
}
|
|
17850
|
+
| {
|
|
17851
|
+
type: "rollback_step_started";
|
|
17852
|
+
stepName: string;
|
|
17853
|
+
config?: {
|
|
17854
|
+
retries: {
|
|
17855
|
+
limit: number;
|
|
17856
|
+
delay: WorkflowSleepDuration | "[dynamic]";
|
|
17857
|
+
backoff?: "constant" | "linear" | "exponential";
|
|
17858
|
+
};
|
|
17859
|
+
timeout: WorkflowSleepDuration;
|
|
17860
|
+
sensitive?: "output";
|
|
17861
|
+
};
|
|
17862
|
+
}
|
|
17863
|
+
| {
|
|
17864
|
+
type: "rollback_step_completed";
|
|
17865
|
+
stepName: string;
|
|
17866
|
+
}
|
|
17867
|
+
| {
|
|
17868
|
+
type: "rollback_step_errored";
|
|
17869
|
+
stepName: string;
|
|
17870
|
+
error: {
|
|
17871
|
+
name: string;
|
|
17872
|
+
message: string;
|
|
17873
|
+
};
|
|
17874
|
+
}
|
|
17875
|
+
| {
|
|
17876
|
+
type: "rollback_attempt_started";
|
|
17877
|
+
stepName: string;
|
|
17878
|
+
attempt: number;
|
|
17879
|
+
}
|
|
17880
|
+
| {
|
|
17881
|
+
type: "rollback_attempt_completed";
|
|
17882
|
+
stepName: string;
|
|
17883
|
+
attempt: number;
|
|
17884
|
+
}
|
|
17885
|
+
| {
|
|
17886
|
+
type: "rollback_attempt_errored";
|
|
17887
|
+
stepName: string;
|
|
17888
|
+
attempt: number;
|
|
17889
|
+
retryDelayMs?: number;
|
|
17890
|
+
error: {
|
|
17891
|
+
name: string;
|
|
17892
|
+
message: string;
|
|
17893
|
+
};
|
|
17894
|
+
}
|
|
17895
|
+
| {
|
|
17896
|
+
type: "rollback_completed";
|
|
17897
|
+
}
|
|
17898
|
+
| {
|
|
17899
|
+
type: "rollback_errored";
|
|
17900
|
+
}
|
|
17901
|
+
);
|
|
17902
|
+
export type WorkflowInstanceEventType = WorkflowInstanceEvent["type"];
|
|
17903
|
+
/** Options available for a Workflow instance subscription. */
|
|
17904
|
+
export type WorkflowInstanceSubscribeOptions = {
|
|
17905
|
+
/** The value from which to start the subscription. */
|
|
17906
|
+
cursor?: number;
|
|
17907
|
+
/** The event types to include in the subscription. */
|
|
17908
|
+
filter?: WorkflowInstanceEventType[];
|
|
17909
|
+
};
|
|
17910
|
+
/** A disposable subscription to a Workflow instance's events. */
|
|
17911
|
+
export interface WorkflowInstanceSubscription extends Disposable {
|
|
17912
|
+
next(): Promise<IteratorResult<WorkflowInstanceEvent, void>>;
|
|
17913
|
+
}
|
|
17743
17914
|
export declare abstract class WorkflowInstance {
|
|
17744
17915
|
public id: string;
|
|
17745
17916
|
/**
|
|
@@ -17779,4 +17950,10 @@ export declare abstract class WorkflowInstance {
|
|
|
17779
17950
|
type: string;
|
|
17780
17951
|
payload: unknown;
|
|
17781
17952
|
}): Promise<void>;
|
|
17953
|
+
/**
|
|
17954
|
+
* Subscribe to events emitted by this instance.
|
|
17955
|
+
*/
|
|
17956
|
+
public subscribe(
|
|
17957
|
+
options?: WorkflowInstanceSubscribeOptions,
|
|
17958
|
+
): Promise<WorkflowInstanceSubscription>;
|
|
17782
17959
|
}
|
package/index.d.ts
CHANGED
|
@@ -15278,11 +15278,41 @@ declare module "cloudflare:node" {
|
|
|
15278
15278
|
listen(...args: unknown[]): this;
|
|
15279
15279
|
address(): {
|
|
15280
15280
|
port?: number | null | undefined;
|
|
15281
|
-
};
|
|
15281
|
+
} | null;
|
|
15282
15282
|
}
|
|
15283
15283
|
export function httpServerHandler(port: number): ExportedHandler;
|
|
15284
15284
|
export function httpServerHandler(options: { port: number }): ExportedHandler;
|
|
15285
15285
|
export function httpServerHandler(server: NodeStyleServer): ExportedHandler;
|
|
15286
|
+
/**
|
|
15287
|
+
* Dispatches a request to the `http.Server` listening on the given port and
|
|
15288
|
+
* resolves with its response. The direct form of `httpServerHandler()`.
|
|
15289
|
+
*/
|
|
15290
|
+
export function handleAsNodeRequest(
|
|
15291
|
+
port:
|
|
15292
|
+
| number
|
|
15293
|
+
| {
|
|
15294
|
+
port: number;
|
|
15295
|
+
},
|
|
15296
|
+
request: Request,
|
|
15297
|
+
env?: unknown,
|
|
15298
|
+
ctx?: ExecutionContext,
|
|
15299
|
+
): Promise<Response>;
|
|
15300
|
+
/**
|
|
15301
|
+
* Routes inbound sockets to the `net.Server` listening on the port each
|
|
15302
|
+
* socket arrived on.
|
|
15303
|
+
*/
|
|
15304
|
+
export function connectHandler(): ExportedHandler;
|
|
15305
|
+
/**
|
|
15306
|
+
* Dispatches an inbound socket to the `net.Server` listening on the port it
|
|
15307
|
+
* arrived on, resolving when the connection has closed. The direct form of
|
|
15308
|
+
* `connectHandler()`, for use inside a `connect()` handler, such as a
|
|
15309
|
+
* Durable Object's.
|
|
15310
|
+
*/
|
|
15311
|
+
export function handleAsNodeConnection(
|
|
15312
|
+
socket: Socket,
|
|
15313
|
+
env?: unknown,
|
|
15314
|
+
ctx?: ExecutionContext,
|
|
15315
|
+
): Promise<void>;
|
|
15286
15316
|
}
|
|
15287
15317
|
type Params<P extends string = any> = Record<P, string | string[]>;
|
|
15288
15318
|
type EventContext<Env, P extends string, Data> = {
|
|
@@ -17475,6 +17505,7 @@ type InstanceStatus = {
|
|
|
17475
17505
|
| "complete"
|
|
17476
17506
|
| "waiting" // instance is hibernating and waiting for sleep or event to finish
|
|
17477
17507
|
| "waitingForPause" // instance is finishing the current work to pause
|
|
17508
|
+
| "rollingBack"
|
|
17478
17509
|
| "unknown";
|
|
17479
17510
|
error?: {
|
|
17480
17511
|
name: string;
|
|
@@ -17514,6 +17545,176 @@ interface WorkflowInstanceRestartOptions {
|
|
|
17514
17545
|
type?: "do" | "sleep" | "waitForEvent";
|
|
17515
17546
|
};
|
|
17516
17547
|
}
|
|
17548
|
+
/** An event emitted by a Workflow instance. */
|
|
17549
|
+
type WorkflowInstanceEvent = {
|
|
17550
|
+
instanceId: string;
|
|
17551
|
+
eventId: number;
|
|
17552
|
+
timestamp: number;
|
|
17553
|
+
} & (
|
|
17554
|
+
| {
|
|
17555
|
+
type: "workflow_queued";
|
|
17556
|
+
}
|
|
17557
|
+
| {
|
|
17558
|
+
type: "workflow_started";
|
|
17559
|
+
params?: unknown;
|
|
17560
|
+
}
|
|
17561
|
+
| {
|
|
17562
|
+
type: "workflow_running";
|
|
17563
|
+
}
|
|
17564
|
+
| {
|
|
17565
|
+
type: "workflow_paused";
|
|
17566
|
+
}
|
|
17567
|
+
| {
|
|
17568
|
+
type: "workflow_waiting_for_pause";
|
|
17569
|
+
}
|
|
17570
|
+
| {
|
|
17571
|
+
type: "workflow_waiting";
|
|
17572
|
+
}
|
|
17573
|
+
| {
|
|
17574
|
+
type: "workflow_completed";
|
|
17575
|
+
output?: unknown;
|
|
17576
|
+
}
|
|
17577
|
+
| {
|
|
17578
|
+
type: "workflow_errored";
|
|
17579
|
+
error: {
|
|
17580
|
+
name: string;
|
|
17581
|
+
message: string;
|
|
17582
|
+
};
|
|
17583
|
+
}
|
|
17584
|
+
| {
|
|
17585
|
+
type: "workflow_terminated";
|
|
17586
|
+
}
|
|
17587
|
+
| {
|
|
17588
|
+
type: "step_started";
|
|
17589
|
+
stepName: string;
|
|
17590
|
+
config?: {
|
|
17591
|
+
retries: {
|
|
17592
|
+
limit: number;
|
|
17593
|
+
delay: WorkflowSleepDuration | "[dynamic]";
|
|
17594
|
+
backoff?: "constant" | "linear" | "exponential";
|
|
17595
|
+
};
|
|
17596
|
+
timeout: WorkflowSleepDuration;
|
|
17597
|
+
sensitive?: "output";
|
|
17598
|
+
};
|
|
17599
|
+
}
|
|
17600
|
+
| {
|
|
17601
|
+
type: "step_completed";
|
|
17602
|
+
stepName: string;
|
|
17603
|
+
output?: unknown;
|
|
17604
|
+
}
|
|
17605
|
+
| {
|
|
17606
|
+
type: "step_errored";
|
|
17607
|
+
stepName: string;
|
|
17608
|
+
}
|
|
17609
|
+
| {
|
|
17610
|
+
type: "attempt_started";
|
|
17611
|
+
stepName: string;
|
|
17612
|
+
attempt: number;
|
|
17613
|
+
}
|
|
17614
|
+
| {
|
|
17615
|
+
type: "attempt_completed";
|
|
17616
|
+
stepName: string;
|
|
17617
|
+
attempt: number;
|
|
17618
|
+
}
|
|
17619
|
+
| {
|
|
17620
|
+
type: "attempt_errored";
|
|
17621
|
+
stepName: string;
|
|
17622
|
+
attempt: number;
|
|
17623
|
+
retryDelayMs?: number;
|
|
17624
|
+
error: {
|
|
17625
|
+
name: string;
|
|
17626
|
+
message: string;
|
|
17627
|
+
};
|
|
17628
|
+
}
|
|
17629
|
+
| {
|
|
17630
|
+
type: "sleep_started";
|
|
17631
|
+
stepName: string;
|
|
17632
|
+
durationMs: number;
|
|
17633
|
+
}
|
|
17634
|
+
| {
|
|
17635
|
+
type: "sleep_completed";
|
|
17636
|
+
stepName: string;
|
|
17637
|
+
}
|
|
17638
|
+
| {
|
|
17639
|
+
type: "wait_started";
|
|
17640
|
+
stepName: string;
|
|
17641
|
+
eventType: string;
|
|
17642
|
+
}
|
|
17643
|
+
| {
|
|
17644
|
+
type: "wait_completed";
|
|
17645
|
+
stepName: string;
|
|
17646
|
+
}
|
|
17647
|
+
| {
|
|
17648
|
+
type: "wait_timed_out";
|
|
17649
|
+
stepName: string;
|
|
17650
|
+
}
|
|
17651
|
+
| {
|
|
17652
|
+
type: "rollback_started";
|
|
17653
|
+
}
|
|
17654
|
+
| {
|
|
17655
|
+
type: "rollback_step_started";
|
|
17656
|
+
stepName: string;
|
|
17657
|
+
config?: {
|
|
17658
|
+
retries: {
|
|
17659
|
+
limit: number;
|
|
17660
|
+
delay: WorkflowSleepDuration | "[dynamic]";
|
|
17661
|
+
backoff?: "constant" | "linear" | "exponential";
|
|
17662
|
+
};
|
|
17663
|
+
timeout: WorkflowSleepDuration;
|
|
17664
|
+
sensitive?: "output";
|
|
17665
|
+
};
|
|
17666
|
+
}
|
|
17667
|
+
| {
|
|
17668
|
+
type: "rollback_step_completed";
|
|
17669
|
+
stepName: string;
|
|
17670
|
+
}
|
|
17671
|
+
| {
|
|
17672
|
+
type: "rollback_step_errored";
|
|
17673
|
+
stepName: string;
|
|
17674
|
+
error: {
|
|
17675
|
+
name: string;
|
|
17676
|
+
message: string;
|
|
17677
|
+
};
|
|
17678
|
+
}
|
|
17679
|
+
| {
|
|
17680
|
+
type: "rollback_attempt_started";
|
|
17681
|
+
stepName: string;
|
|
17682
|
+
attempt: number;
|
|
17683
|
+
}
|
|
17684
|
+
| {
|
|
17685
|
+
type: "rollback_attempt_completed";
|
|
17686
|
+
stepName: string;
|
|
17687
|
+
attempt: number;
|
|
17688
|
+
}
|
|
17689
|
+
| {
|
|
17690
|
+
type: "rollback_attempt_errored";
|
|
17691
|
+
stepName: string;
|
|
17692
|
+
attempt: number;
|
|
17693
|
+
retryDelayMs?: number;
|
|
17694
|
+
error: {
|
|
17695
|
+
name: string;
|
|
17696
|
+
message: string;
|
|
17697
|
+
};
|
|
17698
|
+
}
|
|
17699
|
+
| {
|
|
17700
|
+
type: "rollback_completed";
|
|
17701
|
+
}
|
|
17702
|
+
| {
|
|
17703
|
+
type: "rollback_errored";
|
|
17704
|
+
}
|
|
17705
|
+
);
|
|
17706
|
+
type WorkflowInstanceEventType = WorkflowInstanceEvent["type"];
|
|
17707
|
+
/** Options available for a Workflow instance subscription. */
|
|
17708
|
+
type WorkflowInstanceSubscribeOptions = {
|
|
17709
|
+
/** The value from which to start the subscription. */
|
|
17710
|
+
cursor?: number;
|
|
17711
|
+
/** The event types to include in the subscription. */
|
|
17712
|
+
filter?: WorkflowInstanceEventType[];
|
|
17713
|
+
};
|
|
17714
|
+
/** A disposable subscription to a Workflow instance's events. */
|
|
17715
|
+
interface WorkflowInstanceSubscription extends Disposable {
|
|
17716
|
+
next(): Promise<IteratorResult<WorkflowInstanceEvent, void>>;
|
|
17717
|
+
}
|
|
17517
17718
|
declare abstract class WorkflowInstance {
|
|
17518
17719
|
public id: string;
|
|
17519
17720
|
/**
|
|
@@ -17553,4 +17754,10 @@ declare abstract class WorkflowInstance {
|
|
|
17553
17754
|
type: string;
|
|
17554
17755
|
payload: unknown;
|
|
17555
17756
|
}): Promise<void>;
|
|
17757
|
+
/**
|
|
17758
|
+
* Subscribe to events emitted by this instance.
|
|
17759
|
+
*/
|
|
17760
|
+
public subscribe(
|
|
17761
|
+
options?: WorkflowInstanceSubscribeOptions,
|
|
17762
|
+
): Promise<WorkflowInstanceSubscription>;
|
|
17556
17763
|
}
|
package/index.ts
CHANGED
|
@@ -17424,6 +17424,7 @@ export type InstanceStatus = {
|
|
|
17424
17424
|
| "complete"
|
|
17425
17425
|
| "waiting" // instance is hibernating and waiting for sleep or event to finish
|
|
17426
17426
|
| "waitingForPause" // instance is finishing the current work to pause
|
|
17427
|
+
| "rollingBack"
|
|
17427
17428
|
| "unknown";
|
|
17428
17429
|
error?: {
|
|
17429
17430
|
name: string;
|
|
@@ -17463,6 +17464,176 @@ export interface WorkflowInstanceRestartOptions {
|
|
|
17463
17464
|
type?: "do" | "sleep" | "waitForEvent";
|
|
17464
17465
|
};
|
|
17465
17466
|
}
|
|
17467
|
+
/** An event emitted by a Workflow instance. */
|
|
17468
|
+
export type WorkflowInstanceEvent = {
|
|
17469
|
+
instanceId: string;
|
|
17470
|
+
eventId: number;
|
|
17471
|
+
timestamp: number;
|
|
17472
|
+
} & (
|
|
17473
|
+
| {
|
|
17474
|
+
type: "workflow_queued";
|
|
17475
|
+
}
|
|
17476
|
+
| {
|
|
17477
|
+
type: "workflow_started";
|
|
17478
|
+
params?: unknown;
|
|
17479
|
+
}
|
|
17480
|
+
| {
|
|
17481
|
+
type: "workflow_running";
|
|
17482
|
+
}
|
|
17483
|
+
| {
|
|
17484
|
+
type: "workflow_paused";
|
|
17485
|
+
}
|
|
17486
|
+
| {
|
|
17487
|
+
type: "workflow_waiting_for_pause";
|
|
17488
|
+
}
|
|
17489
|
+
| {
|
|
17490
|
+
type: "workflow_waiting";
|
|
17491
|
+
}
|
|
17492
|
+
| {
|
|
17493
|
+
type: "workflow_completed";
|
|
17494
|
+
output?: unknown;
|
|
17495
|
+
}
|
|
17496
|
+
| {
|
|
17497
|
+
type: "workflow_errored";
|
|
17498
|
+
error: {
|
|
17499
|
+
name: string;
|
|
17500
|
+
message: string;
|
|
17501
|
+
};
|
|
17502
|
+
}
|
|
17503
|
+
| {
|
|
17504
|
+
type: "workflow_terminated";
|
|
17505
|
+
}
|
|
17506
|
+
| {
|
|
17507
|
+
type: "step_started";
|
|
17508
|
+
stepName: string;
|
|
17509
|
+
config?: {
|
|
17510
|
+
retries: {
|
|
17511
|
+
limit: number;
|
|
17512
|
+
delay: WorkflowSleepDuration | "[dynamic]";
|
|
17513
|
+
backoff?: "constant" | "linear" | "exponential";
|
|
17514
|
+
};
|
|
17515
|
+
timeout: WorkflowSleepDuration;
|
|
17516
|
+
sensitive?: "output";
|
|
17517
|
+
};
|
|
17518
|
+
}
|
|
17519
|
+
| {
|
|
17520
|
+
type: "step_completed";
|
|
17521
|
+
stepName: string;
|
|
17522
|
+
output?: unknown;
|
|
17523
|
+
}
|
|
17524
|
+
| {
|
|
17525
|
+
type: "step_errored";
|
|
17526
|
+
stepName: string;
|
|
17527
|
+
}
|
|
17528
|
+
| {
|
|
17529
|
+
type: "attempt_started";
|
|
17530
|
+
stepName: string;
|
|
17531
|
+
attempt: number;
|
|
17532
|
+
}
|
|
17533
|
+
| {
|
|
17534
|
+
type: "attempt_completed";
|
|
17535
|
+
stepName: string;
|
|
17536
|
+
attempt: number;
|
|
17537
|
+
}
|
|
17538
|
+
| {
|
|
17539
|
+
type: "attempt_errored";
|
|
17540
|
+
stepName: string;
|
|
17541
|
+
attempt: number;
|
|
17542
|
+
retryDelayMs?: number;
|
|
17543
|
+
error: {
|
|
17544
|
+
name: string;
|
|
17545
|
+
message: string;
|
|
17546
|
+
};
|
|
17547
|
+
}
|
|
17548
|
+
| {
|
|
17549
|
+
type: "sleep_started";
|
|
17550
|
+
stepName: string;
|
|
17551
|
+
durationMs: number;
|
|
17552
|
+
}
|
|
17553
|
+
| {
|
|
17554
|
+
type: "sleep_completed";
|
|
17555
|
+
stepName: string;
|
|
17556
|
+
}
|
|
17557
|
+
| {
|
|
17558
|
+
type: "wait_started";
|
|
17559
|
+
stepName: string;
|
|
17560
|
+
eventType: string;
|
|
17561
|
+
}
|
|
17562
|
+
| {
|
|
17563
|
+
type: "wait_completed";
|
|
17564
|
+
stepName: string;
|
|
17565
|
+
}
|
|
17566
|
+
| {
|
|
17567
|
+
type: "wait_timed_out";
|
|
17568
|
+
stepName: string;
|
|
17569
|
+
}
|
|
17570
|
+
| {
|
|
17571
|
+
type: "rollback_started";
|
|
17572
|
+
}
|
|
17573
|
+
| {
|
|
17574
|
+
type: "rollback_step_started";
|
|
17575
|
+
stepName: string;
|
|
17576
|
+
config?: {
|
|
17577
|
+
retries: {
|
|
17578
|
+
limit: number;
|
|
17579
|
+
delay: WorkflowSleepDuration | "[dynamic]";
|
|
17580
|
+
backoff?: "constant" | "linear" | "exponential";
|
|
17581
|
+
};
|
|
17582
|
+
timeout: WorkflowSleepDuration;
|
|
17583
|
+
sensitive?: "output";
|
|
17584
|
+
};
|
|
17585
|
+
}
|
|
17586
|
+
| {
|
|
17587
|
+
type: "rollback_step_completed";
|
|
17588
|
+
stepName: string;
|
|
17589
|
+
}
|
|
17590
|
+
| {
|
|
17591
|
+
type: "rollback_step_errored";
|
|
17592
|
+
stepName: string;
|
|
17593
|
+
error: {
|
|
17594
|
+
name: string;
|
|
17595
|
+
message: string;
|
|
17596
|
+
};
|
|
17597
|
+
}
|
|
17598
|
+
| {
|
|
17599
|
+
type: "rollback_attempt_started";
|
|
17600
|
+
stepName: string;
|
|
17601
|
+
attempt: number;
|
|
17602
|
+
}
|
|
17603
|
+
| {
|
|
17604
|
+
type: "rollback_attempt_completed";
|
|
17605
|
+
stepName: string;
|
|
17606
|
+
attempt: number;
|
|
17607
|
+
}
|
|
17608
|
+
| {
|
|
17609
|
+
type: "rollback_attempt_errored";
|
|
17610
|
+
stepName: string;
|
|
17611
|
+
attempt: number;
|
|
17612
|
+
retryDelayMs?: number;
|
|
17613
|
+
error: {
|
|
17614
|
+
name: string;
|
|
17615
|
+
message: string;
|
|
17616
|
+
};
|
|
17617
|
+
}
|
|
17618
|
+
| {
|
|
17619
|
+
type: "rollback_completed";
|
|
17620
|
+
}
|
|
17621
|
+
| {
|
|
17622
|
+
type: "rollback_errored";
|
|
17623
|
+
}
|
|
17624
|
+
);
|
|
17625
|
+
export type WorkflowInstanceEventType = WorkflowInstanceEvent["type"];
|
|
17626
|
+
/** Options available for a Workflow instance subscription. */
|
|
17627
|
+
export type WorkflowInstanceSubscribeOptions = {
|
|
17628
|
+
/** The value from which to start the subscription. */
|
|
17629
|
+
cursor?: number;
|
|
17630
|
+
/** The event types to include in the subscription. */
|
|
17631
|
+
filter?: WorkflowInstanceEventType[];
|
|
17632
|
+
};
|
|
17633
|
+
/** A disposable subscription to a Workflow instance's events. */
|
|
17634
|
+
export interface WorkflowInstanceSubscription extends Disposable {
|
|
17635
|
+
next(): Promise<IteratorResult<WorkflowInstanceEvent, void>>;
|
|
17636
|
+
}
|
|
17466
17637
|
export declare abstract class WorkflowInstance {
|
|
17467
17638
|
public id: string;
|
|
17468
17639
|
/**
|
|
@@ -17502,4 +17673,10 @@ export declare abstract class WorkflowInstance {
|
|
|
17502
17673
|
type: string;
|
|
17503
17674
|
payload: unknown;
|
|
17504
17675
|
}): Promise<void>;
|
|
17676
|
+
/**
|
|
17677
|
+
* Subscribe to events emitted by this instance.
|
|
17678
|
+
*/
|
|
17679
|
+
public subscribe(
|
|
17680
|
+
options?: WorkflowInstanceSubscribeOptions,
|
|
17681
|
+
): Promise<WorkflowInstanceSubscription>;
|
|
17505
17682
|
}
|
package/package.json
CHANGED