@pgflow/client 0.4.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/CHANGELOG.md +108 -0
- package/LICENSE +202 -0
- package/README.md +380 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +971 -0
- package/dist/index.js.map +1 -0
- package/dist/package.json +46 -0
- package/dist/pgflow-client.browser.js +2 -0
- package/dist/pgflow-client.browser.js.map +1 -0
- package/dist/src/browser.d.ts +7 -0
- package/dist/src/browser.d.ts.map +1 -0
- package/dist/src/index.d.ts +6 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/lib/FlowRun.d.ts +117 -0
- package/dist/src/lib/FlowRun.d.ts.map +1 -0
- package/dist/src/lib/FlowStep.d.ts +82 -0
- package/dist/src/lib/FlowStep.d.ts.map +1 -0
- package/dist/src/lib/PgflowClient.d.ts +73 -0
- package/dist/src/lib/PgflowClient.d.ts.map +1 -0
- package/dist/src/lib/SupabaseBroadcastAdapter.d.ts +65 -0
- package/dist/src/lib/SupabaseBroadcastAdapter.d.ts.map +1 -0
- package/dist/src/lib/eventAdapters.d.ts +21 -0
- package/dist/src/lib/eventAdapters.d.ts.map +1 -0
- package/dist/src/lib/types.d.ts +308 -0
- package/dist/src/lib/types.d.ts.map +1 -0
- package/package.json +46 -0
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { FlowStep } from './FlowStep.js';
|
|
2
|
+
import { FlowRunStatus, FlowRunState, FlowRunEvents, Unsubscribe, FlowRunBase, FlowRunEvent, StepEvent } from './types.js';
|
|
3
|
+
import { AnyFlow, ExtractFlowInput, ExtractFlowOutput, ExtractFlowSteps } from '../../../dsl/src/index.ts';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Represents a single execution of a flow
|
|
7
|
+
*/
|
|
8
|
+
export declare class FlowRun<TFlow extends AnyFlow> implements FlowRunBase<FlowRunEvent<TFlow>> {
|
|
9
|
+
#private;
|
|
10
|
+
/**
|
|
11
|
+
* Creates a new FlowRun instance
|
|
12
|
+
*
|
|
13
|
+
* @param initialState - Initial state for the run
|
|
14
|
+
*/
|
|
15
|
+
constructor(initialState: FlowRunState<TFlow>);
|
|
16
|
+
/**
|
|
17
|
+
* Get the run ID
|
|
18
|
+
*/
|
|
19
|
+
get run_id(): string;
|
|
20
|
+
/**
|
|
21
|
+
* Get the flow slug
|
|
22
|
+
*/
|
|
23
|
+
get flow_slug(): string;
|
|
24
|
+
/**
|
|
25
|
+
* Get the current status
|
|
26
|
+
*/
|
|
27
|
+
get status(): FlowRunStatus;
|
|
28
|
+
/**
|
|
29
|
+
* Get the started_at timestamp
|
|
30
|
+
*/
|
|
31
|
+
get started_at(): Date | null;
|
|
32
|
+
/**
|
|
33
|
+
* Get the completed_at timestamp
|
|
34
|
+
*/
|
|
35
|
+
get completed_at(): Date | null;
|
|
36
|
+
/**
|
|
37
|
+
* Get the failed_at timestamp
|
|
38
|
+
*/
|
|
39
|
+
get failed_at(): Date | null;
|
|
40
|
+
/**
|
|
41
|
+
* Get the flow input
|
|
42
|
+
*/
|
|
43
|
+
get input(): ExtractFlowInput<TFlow>;
|
|
44
|
+
/**
|
|
45
|
+
* Get the flow output
|
|
46
|
+
*/
|
|
47
|
+
get output(): ExtractFlowOutput<TFlow> | null;
|
|
48
|
+
/**
|
|
49
|
+
* Get the error object
|
|
50
|
+
*/
|
|
51
|
+
get error(): Error | null;
|
|
52
|
+
/**
|
|
53
|
+
* Get the error message
|
|
54
|
+
*/
|
|
55
|
+
get error_message(): string | null;
|
|
56
|
+
/**
|
|
57
|
+
* Get the number of remaining steps
|
|
58
|
+
*/
|
|
59
|
+
get remaining_steps(): number;
|
|
60
|
+
/**
|
|
61
|
+
* Register an event handler for a run event
|
|
62
|
+
*
|
|
63
|
+
* @param event - Event type to listen for
|
|
64
|
+
* @param callback - Callback function to execute when event is emitted
|
|
65
|
+
* @returns Function to unsubscribe from the event
|
|
66
|
+
*/
|
|
67
|
+
on<E extends keyof FlowRunEvents<TFlow>>(event: E, callback: FlowRunEvents<TFlow>[E]): Unsubscribe;
|
|
68
|
+
/**
|
|
69
|
+
* Get a FlowStep instance for a specific step
|
|
70
|
+
*
|
|
71
|
+
* @param stepSlug - Step slug to get
|
|
72
|
+
* @returns FlowStep instance for the specified step
|
|
73
|
+
*/
|
|
74
|
+
step<TStepSlug extends keyof ExtractFlowSteps<TFlow> & string>(stepSlug: TStepSlug): FlowStep<TFlow, TStepSlug>;
|
|
75
|
+
/**
|
|
76
|
+
* Check if this run has a specific step
|
|
77
|
+
*
|
|
78
|
+
* @param stepSlug - Step slug to check
|
|
79
|
+
* @returns true if the step exists, false otherwise
|
|
80
|
+
*/
|
|
81
|
+
hasStep(stepSlug: string): boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Wait for the run to reach a specific status
|
|
84
|
+
*
|
|
85
|
+
* @param targetStatus - The status to wait for
|
|
86
|
+
* @param options - Optional timeout and abort signal
|
|
87
|
+
* @returns Promise that resolves with the run instance when the status is reached
|
|
88
|
+
*/
|
|
89
|
+
waitForStatus(targetStatus: FlowRunStatus.Completed | FlowRunStatus.Failed, options?: {
|
|
90
|
+
timeoutMs?: number;
|
|
91
|
+
signal?: AbortSignal;
|
|
92
|
+
}): Promise<this>;
|
|
93
|
+
/**
|
|
94
|
+
* Updates the run state based on an event
|
|
95
|
+
*
|
|
96
|
+
* @internal This method is only intended for use by PgflowClient and tests.
|
|
97
|
+
* Applications should not call this directly - state updates should come from
|
|
98
|
+
* database events through the PgflowClient.
|
|
99
|
+
*
|
|
100
|
+
* TODO: After v1.0, make this method private and refactor tests to use PgflowClient
|
|
101
|
+
* with event emission instead of direct state manipulation.
|
|
102
|
+
*/
|
|
103
|
+
updateState(event: FlowRunEvent<TFlow>): boolean;
|
|
104
|
+
/**
|
|
105
|
+
* Updates a step state based on an event
|
|
106
|
+
*
|
|
107
|
+
* @param stepSlug - Step slug to update
|
|
108
|
+
* @param event - Event data to update the step with
|
|
109
|
+
* @returns true if the state was updated, false otherwise
|
|
110
|
+
*/
|
|
111
|
+
updateStepState<TStepSlug extends keyof ExtractFlowSteps<TFlow> & string>(stepSlug: TStepSlug, event: StepEvent<TFlow, TStepSlug>): boolean;
|
|
112
|
+
/**
|
|
113
|
+
* Clean up all resources held by this run
|
|
114
|
+
*/
|
|
115
|
+
dispose(): void;
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=FlowRun.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FlowRun.d.ts","sourceRoot":"","sources":["../../../src/lib/FlowRun.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,OAAO,EACP,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,aAAa,EAAkB,MAAM,YAAY,CAAC;AAC3D,OAAO,KAAK,EACV,YAAY,EACZ,aAAa,EACb,WAAW,EACX,WAAW,EAEX,YAAY,EACZ,SAAS,EACV,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC;;GAEG;AACH,qBAAa,OAAO,CAAC,KAAK,SAAS,OAAO,CACxC,YAAW,WAAW,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;;IAY3C;;;;OAIG;gBACS,YAAY,EAAE,YAAY,CAAC,KAAK,CAAC;IAI7C;;OAEG;IACH,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED;;OAEG;IACH,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED;;OAEG;IACH,IAAI,MAAM,IAAI,aAAa,CAE1B;IAED;;OAEG;IACH,IAAI,UAAU,IAAI,IAAI,GAAG,IAAI,CAE5B;IAED;;OAEG;IACH,IAAI,YAAY,IAAI,IAAI,GAAG,IAAI,CAE9B;IAED;;OAEG;IACH,IAAI,SAAS,IAAI,IAAI,GAAG,IAAI,CAE3B;IAED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IAAI,IAAI;CAgBhB"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { FlowStepStatus, FlowStepState, StepEvents, Unsubscribe, FlowStepBase, StepEvent } from './types.js';
|
|
2
|
+
import { AnyFlow, ExtractFlowSteps, StepOutput } from '../../../dsl/src/index.ts';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Represents a single step in a flow run
|
|
6
|
+
*/
|
|
7
|
+
export declare class FlowStep<TFlow extends AnyFlow, TStepSlug extends keyof ExtractFlowSteps<TFlow> & string> implements FlowStepBase<StepEvent<TFlow, TStepSlug>> {
|
|
8
|
+
#private;
|
|
9
|
+
/**
|
|
10
|
+
* Creates a new FlowStep instance
|
|
11
|
+
*
|
|
12
|
+
* @param initialState - Initial state for the step
|
|
13
|
+
*/
|
|
14
|
+
constructor(initialState: FlowStepState<TFlow, TStepSlug>);
|
|
15
|
+
/**
|
|
16
|
+
* Get the run ID this step belongs to
|
|
17
|
+
*/
|
|
18
|
+
get run_id(): string;
|
|
19
|
+
/**
|
|
20
|
+
* Get the step slug
|
|
21
|
+
*/
|
|
22
|
+
get step_slug(): TStepSlug;
|
|
23
|
+
/**
|
|
24
|
+
* Get the current status
|
|
25
|
+
*/
|
|
26
|
+
get status(): FlowStepStatus;
|
|
27
|
+
/**
|
|
28
|
+
* Get the started_at timestamp
|
|
29
|
+
*/
|
|
30
|
+
get started_at(): Date | null;
|
|
31
|
+
/**
|
|
32
|
+
* Get the completed_at timestamp
|
|
33
|
+
*/
|
|
34
|
+
get completed_at(): Date | null;
|
|
35
|
+
/**
|
|
36
|
+
* Get the failed_at timestamp
|
|
37
|
+
*/
|
|
38
|
+
get failed_at(): Date | null;
|
|
39
|
+
/**
|
|
40
|
+
* Get the step output
|
|
41
|
+
*/
|
|
42
|
+
get output(): StepOutput<TFlow, TStepSlug> | null;
|
|
43
|
+
/**
|
|
44
|
+
* Get the error object
|
|
45
|
+
*/
|
|
46
|
+
get error(): Error | null;
|
|
47
|
+
/**
|
|
48
|
+
* Get the error message
|
|
49
|
+
*/
|
|
50
|
+
get error_message(): string | null;
|
|
51
|
+
/**
|
|
52
|
+
* Register an event handler for a step event
|
|
53
|
+
*
|
|
54
|
+
* @param event - Event type to listen for
|
|
55
|
+
* @param callback - Callback function to execute when event is emitted
|
|
56
|
+
* @returns Function to unsubscribe from the event
|
|
57
|
+
*/
|
|
58
|
+
on<E extends keyof StepEvents<TFlow, TStepSlug>>(event: E, callback: StepEvents<TFlow, TStepSlug>[E]): Unsubscribe;
|
|
59
|
+
/**
|
|
60
|
+
* Wait for the step to reach a specific status
|
|
61
|
+
*
|
|
62
|
+
* @param targetStatus - The status to wait for
|
|
63
|
+
* @param options - Optional timeout and abort signal
|
|
64
|
+
* @returns Promise that resolves with the step instance when the status is reached
|
|
65
|
+
*/
|
|
66
|
+
waitForStatus(targetStatus: FlowStepStatus.Started | FlowStepStatus.Completed | FlowStepStatus.Failed, options?: {
|
|
67
|
+
timeoutMs?: number;
|
|
68
|
+
signal?: AbortSignal;
|
|
69
|
+
}): Promise<this>;
|
|
70
|
+
/**
|
|
71
|
+
* Updates the step state based on an event
|
|
72
|
+
*
|
|
73
|
+
* @internal This method is only intended for use by FlowRun and tests.
|
|
74
|
+
* Applications should not call this directly - state updates should come from
|
|
75
|
+
* database events through the PgflowClient.
|
|
76
|
+
*
|
|
77
|
+
* TODO: After v1.0, make this method private and refactor tests to use PgflowClient
|
|
78
|
+
* with event emission instead of direct state manipulation.
|
|
79
|
+
*/
|
|
80
|
+
updateState(event: StepEvent<TFlow, TStepSlug>): boolean;
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=FlowStep.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FlowStep.d.ts","sourceRoot":"","sources":["../../../src/lib/FlowStep.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzE,OAAO,E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AM,EACvF,OAAO,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE,GACrD,OAAO,CAAC,IAAI,CAAC;IAuDhB;;;;;;;;;OASG;IACH,WAAW,CAAC,KAAK,EAAE,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,GAAG,OAAO;CAkFzD"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { FlowRun } from './FlowRun.js';
|
|
2
|
+
import { IFlowClient, BroadcastRunEvent, BroadcastStepEvent, Unsubscribe } from './types.js';
|
|
3
|
+
import { RunRow } from '../../../core/src/index.ts';
|
|
4
|
+
import { AnyFlow, ExtractFlowInput } from '../../../dsl/src/index.ts';
|
|
5
|
+
import { SupabaseClient } from '@supabase/supabase-js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Client for interacting with pgflow
|
|
9
|
+
*/
|
|
10
|
+
export declare class PgflowClient<TFlow extends AnyFlow = AnyFlow> implements IFlowClient<TFlow> {
|
|
11
|
+
#private;
|
|
12
|
+
/**
|
|
13
|
+
* Creates a new PgflowClient instance
|
|
14
|
+
*
|
|
15
|
+
* @param supabaseClient - Supabase client instance
|
|
16
|
+
*/
|
|
17
|
+
constructor(supabaseClient: SupabaseClient);
|
|
18
|
+
/**
|
|
19
|
+
* Start a flow with optional run_id
|
|
20
|
+
*
|
|
21
|
+
* @param flow_slug - Flow slug to start
|
|
22
|
+
* @param input - Input data for the flow
|
|
23
|
+
* @param run_id - Optional run ID (will be generated if not provided)
|
|
24
|
+
* @returns Promise that resolves with the FlowRun instance
|
|
25
|
+
*/
|
|
26
|
+
startFlow<TSpecificFlow extends TFlow>(flow_slug: string, input: ExtractFlowInput<TSpecificFlow>, run_id?: string): Promise<FlowRun<TSpecificFlow>>;
|
|
27
|
+
/**
|
|
28
|
+
* Dispose a specific flow run
|
|
29
|
+
*
|
|
30
|
+
* @param runId - Run ID to dispose
|
|
31
|
+
*/
|
|
32
|
+
dispose(runId: string): void;
|
|
33
|
+
/**
|
|
34
|
+
* Dispose all flow runs
|
|
35
|
+
*/
|
|
36
|
+
disposeAll(): void;
|
|
37
|
+
/**
|
|
38
|
+
* Fetch flow definition metadata
|
|
39
|
+
*/
|
|
40
|
+
fetchFlowDefinition(flow_slug: string): Promise<{
|
|
41
|
+
flow: import('../../../core/src/index.ts').FlowRow;
|
|
42
|
+
steps: import('../../../core/src/index.ts').StepRow[];
|
|
43
|
+
}>;
|
|
44
|
+
/**
|
|
45
|
+
* Register a callback for run events
|
|
46
|
+
* @returns Function to unsubscribe from the event
|
|
47
|
+
*/
|
|
48
|
+
onRunEvent(callback: (event: BroadcastRunEvent) => void): Unsubscribe;
|
|
49
|
+
/**
|
|
50
|
+
* Register a callback for step events
|
|
51
|
+
* @returns Function to unsubscribe from the event
|
|
52
|
+
*/
|
|
53
|
+
onStepEvent(callback: (event: BroadcastStepEvent) => void): Unsubscribe;
|
|
54
|
+
/**
|
|
55
|
+
* Subscribe to a flow run's events
|
|
56
|
+
*/
|
|
57
|
+
subscribeToRun(run_id: string): Promise<() => void>;
|
|
58
|
+
/**
|
|
59
|
+
* Fetch current state of a run and its steps
|
|
60
|
+
*/
|
|
61
|
+
getRunWithStates(run_id: string): Promise<{
|
|
62
|
+
run: RunRow;
|
|
63
|
+
steps: import('../../../core/src/index.ts').StepStateRow[];
|
|
64
|
+
}>;
|
|
65
|
+
/**
|
|
66
|
+
* Get a flow run by ID
|
|
67
|
+
*
|
|
68
|
+
* @param run_id - ID of the run to get
|
|
69
|
+
* @returns Promise that resolves with the FlowRun instance or null if not found
|
|
70
|
+
*/
|
|
71
|
+
getRun<TSpecificFlow extends TFlow = TFlow>(run_id: string): Promise<FlowRun<TSpecificFlow> | null>;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=PgflowClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PgflowClient.d.ts","sourceRoot":"","sources":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CAAC,aAAa,SAAS,KAAK,GAAG,KAAK,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC;CA6E1G"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { IFlowRealtime, BroadcastRunEvent, BroadcastStepEvent, Unsubscribe } from './types.js';
|
|
2
|
+
import { FlowRow, StepRow, RunRow, StepStateRow } from '../../../core/src/index.ts';
|
|
3
|
+
import { SupabaseClient } from '@supabase/supabase-js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Adapter to handle realtime communication with Supabase
|
|
7
|
+
*/
|
|
8
|
+
export declare class SupabaseBroadcastAdapter implements IFlowRealtime {
|
|
9
|
+
#private;
|
|
10
|
+
/**
|
|
11
|
+
* Creates a new instance of SupabaseBroadcastAdapter
|
|
12
|
+
*
|
|
13
|
+
* @param supabase - Supabase client instance
|
|
14
|
+
*/
|
|
15
|
+
constructor(supabase: SupabaseClient, opts?: {
|
|
16
|
+
reconnectDelayMs?: number;
|
|
17
|
+
schedule?: typeof setTimeout;
|
|
18
|
+
});
|
|
19
|
+
/**
|
|
20
|
+
* Fetches flow definition metadata from the database
|
|
21
|
+
*
|
|
22
|
+
* @param flow_slug - Flow slug to fetch
|
|
23
|
+
*/
|
|
24
|
+
fetchFlowDefinition(flow_slug: string): Promise<{
|
|
25
|
+
flow: FlowRow;
|
|
26
|
+
steps: StepRow[];
|
|
27
|
+
}>;
|
|
28
|
+
/**
|
|
29
|
+
* Registers a callback for run events
|
|
30
|
+
*
|
|
31
|
+
* @param callback - Function to call when run events are received
|
|
32
|
+
* @returns Function to unsubscribe from the event
|
|
33
|
+
*/
|
|
34
|
+
onRunEvent(callback: (event: BroadcastRunEvent) => void): Unsubscribe;
|
|
35
|
+
/**
|
|
36
|
+
* Registers a callback for step events
|
|
37
|
+
*
|
|
38
|
+
* @param callback - Function to call when step events are received
|
|
39
|
+
* @returns Function to unsubscribe from the event
|
|
40
|
+
*/
|
|
41
|
+
onStepEvent(callback: (event: BroadcastStepEvent) => void): Unsubscribe;
|
|
42
|
+
/**
|
|
43
|
+
* Subscribes to a flow run's events
|
|
44
|
+
*
|
|
45
|
+
* @param run_id - Run ID to subscribe to
|
|
46
|
+
* @returns Function to unsubscribe
|
|
47
|
+
*/
|
|
48
|
+
subscribeToRun(run_id: string): Promise<() => void>;
|
|
49
|
+
/**
|
|
50
|
+
* Unsubscribes from a run's events
|
|
51
|
+
*
|
|
52
|
+
* @param run_id - Run ID to unsubscribe from
|
|
53
|
+
*/
|
|
54
|
+
unsubscribe(run_id: string): void;
|
|
55
|
+
/**
|
|
56
|
+
* Fetches current state of a run and its steps
|
|
57
|
+
*
|
|
58
|
+
* @param run_id - Run ID to fetch
|
|
59
|
+
*/
|
|
60
|
+
getRunWithStates(run_id: string): Promise<{
|
|
61
|
+
run: RunRow;
|
|
62
|
+
steps: StepStateRow[];
|
|
63
|
+
}>;
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=SupabaseBroadcastAdapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SupabaseBroadcastAdapter.d.ts","sourceRoot":"","sources":["../../../src/lib/SupabaseBroadcastAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAmB,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC7E,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE3E,OAAO,KAAK,EACV,aAAa,EACb,iBAAiB,EACjB,kBAAkB,EAClB,WAAW,EACZ,MAAM,YAAY,CAAC;AAQpB;;GAEG;AACH,qBAAa,wBAAyB,YAAW,aAAa;;IAQ5D;;;;OAIG;gBAED,QAAQ,EAAE,cAAc,EACxB,IAAI,GAAE;QAAE,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,OAAO,UAAU,CAAA;KAAO;IAkLxE;;;;OAIG;IACG,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC;QACpD,IAAI,EAAE,OAAO,CAAC;QACd,KAAK,EAAE,OAAO,EAAE,CAAC;KAClB,CAAC;IAiCF;;;;;OAKG;IACH,UAAU,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,IAAI,GAAG,WAAW;IAYrE;;;;;OAKG;IACH,WAAW,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,kBAAkB,KAAK,IAAI,GAAG,WAAW;IAevE;;;;;OAKG;IACG,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,CAAC;IA0DzD;;;;OAIG;IACH,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAIjC;;;;OAIG;IACG,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;QAC9C,GAAG,EAAE,MAAM,CAAC;QACZ,KAAK,EAAE,YAAY,EAAE,CAAC;KACvB,CAAC;CAiCH"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { BroadcastRunEvent, BroadcastStepEvent, FlowRunEvent, StepEvent } from './types.js';
|
|
2
|
+
import { RunRow, StepStateRow } from '../../../core/src/index.ts';
|
|
3
|
+
import { AnyFlow, ExtractFlowSteps } from '../../../dsl/src/index.ts';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Convert a broadcast run event to a typed run event
|
|
7
|
+
*/
|
|
8
|
+
export declare function toTypedRunEvent<TFlow extends AnyFlow>(evt: BroadcastRunEvent): FlowRunEvent<TFlow>;
|
|
9
|
+
/**
|
|
10
|
+
* Convert a broadcast step event to a typed step event
|
|
11
|
+
*/
|
|
12
|
+
export declare function toTypedStepEvent<TFlow extends AnyFlow, TStepSlug extends keyof ExtractFlowSteps<TFlow> & string>(evt: BroadcastStepEvent): StepEvent<TFlow, TStepSlug>;
|
|
13
|
+
/**
|
|
14
|
+
* Convert a database run row to a typed run event
|
|
15
|
+
*/
|
|
16
|
+
export declare function runRowToTypedEvent<TFlow extends AnyFlow>(row: RunRow): FlowRunEvent<TFlow>;
|
|
17
|
+
/**
|
|
18
|
+
* Convert a database step state row to a typed step event
|
|
19
|
+
*/
|
|
20
|
+
export declare function stepStateRowToTypedEvent<TFlow extends AnyFlow, TStepSlug extends keyof ExtractFlowSteps<TFlow> & string>(row: StepStateRow): StepEvent<TFlow, TStepSlug>;
|
|
21
|
+
//# sourceMappingURL=eventAdapters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eventAdapters.d.ts","sourceRoot":"","sources":["../../../src/lib/eventAdapters.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EAGP,gBAAgB,EAEjB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAKzD,OAAO,KAAK,EACV,iBAAiB,EACjB,kBAAkB,EAClB,YAAY,EACZ,SAAS,EACV,MAAM,YAAY,CAAC;AAEpB;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,SAAS,OAAO,EACnD,GAAG,EAAE,iBAAiB,GACrB,YAAY,CAAC,KAAK,CAAC,CA+BrB;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,SAAS,OAAO,EACrB,SAAS,SAAS,MAAM,gBAAgB,CAAC,KAAK,CAAC,GAAG,MAAM,EACxD,GAAG,EAAE,kBAAkB,GAAG,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,CA6BtD;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,SAAS,OAAO,EACtD,GAAG,EAAE,MAAM,GACV,YAAY,CAAC,KAAK,CAAC,CAiCrB;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,KAAK,SAAS,OAAO,EACrB,SAAS,SAAS,MAAM,gBAAgB,CAAC,KAAK,CAAC,GAAG,MAAM,EACxD,GAAG,EAAE,YAAY,GAAG,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,CAgChD"}
|