@pgflow/client 0.0.0-test-snapshot-releases2-8d5d9bc1-20250922101158 → 0.0.0-update-supabase-868977e5-20251119071021

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 CHANGED
@@ -1,12 +1,80 @@
1
1
  # @pgflow/client
2
2
 
3
- ## 0.0.0-test-snapshot-releases2-8d5d9bc1-20250922101158
3
+ ## 0.0.0-update-supabase-868977e5-20251119071021
4
+
5
+ ### Minor Changes
6
+
7
+ - 3d8b13b: BREAKING CHANGE: pgflow 0.8.0 requires pgmq 1.5.0+, PostgreSQL 17, and Supabase CLI 2.34.3+
8
+
9
+ This version modernizes infrastructure dependencies and will NOT work with pgmq 1.4.x or earlier. The migration includes a compatibility check that aborts with a clear error message if requirements are not met.
10
+
11
+ **Requirements:**
12
+
13
+ - pgmq 1.5.0 or higher (previously supported 1.4.x)
14
+ - PostgreSQL 17 (from 15)
15
+ - Supabase CLI 2.34.3 or higher (includes pgmq 1.5.0+)
16
+
17
+ **For Supabase users:** Upgrade your Supabase CLI to 2.34.3+ which includes pgmq 1.5.0 by default.
18
+
19
+ **For self-hosted users:** Upgrade pgmq to 1.5.0+ and PostgreSQL to 17 before upgrading pgflow.
20
+
21
+ **If you cannot upgrade immediately:** Stay on pgflow 0.7.x until your infrastructure is ready. The migration safety check ensures you cannot accidentally upgrade to an incompatible version.
22
+
23
+ ### Patch Changes
24
+
25
+ - Updated dependencies [3d8b13b]
26
+ - @pgflow/core@0.0.0-update-supabase-868977e5-20251119071021
27
+ - @pgflow/dsl@0.0.0-update-supabase-868977e5-20251119071021
28
+
29
+ ## 0.7.3
30
+
31
+ ### Patch Changes
32
+
33
+ - bde6bed: Add `realtimeStabilizationDelayMs` option to PgflowClient for improved Supabase Realtime reliability
34
+ - @pgflow/core@0.7.3
35
+ - @pgflow/dsl@0.7.3
36
+
37
+ ## 0.7.2
38
+
39
+ ### Patch Changes
40
+
41
+ - c22a1e5: Fix missing realtime broadcasts for step:started and step:completed events
42
+
43
+ **Critical bug fix:** Clients were not receiving `step:started` events when steps transitioned to Started status, and `step:completed` events for empty map steps and cascade completions were also missing.
44
+
45
+ **Root cause:** PostgreSQL query optimizer was eliminating CTEs containing `realtime.send()` calls because they were not referenced by subsequent operations or the final RETURN statement.
46
+
47
+ **Solution:** Moved `realtime.send()` calls directly into RETURNING clauses of UPDATE statements, ensuring they execute atomically with state changes and cannot be optimized away.
48
+
49
+ **Changes:**
50
+
51
+ - `start_ready_steps()`: Broadcasts step:started and step:completed events in RETURNING clauses
52
+ - `cascade_complete_taskless_steps()`: Broadcasts step:completed events atomically with cascade completion
53
+ - `complete_task()`: Added PERFORM statements for run:failed and step:failed broadcasts
54
+ - Client: Added `applySnapshot()` methods to FlowRun and FlowStep for proper initial state hydration without event emission
55
+
56
+ - Updated dependencies [c22a1e5]
57
+ - @pgflow/core@0.7.2
58
+ - @pgflow/dsl@0.7.2
59
+
60
+ ## 0.7.1
61
+
62
+ ### Patch Changes
63
+
64
+ - Updated dependencies [a71b371]
65
+ - @pgflow/core@0.7.1
66
+ - @pgflow/dsl@0.7.1
67
+
68
+ ## 0.7.0
4
69
 
5
70
  ### Patch Changes
6
71
 
7
- - Updated dependencies
8
- - @pgflow/core@0.0.0-test-snapshot-releases2-8d5d9bc1-20250922101158
9
- - @pgflow/dsl@0.0.0-test-snapshot-releases2-8d5d9bc1-20250922101158
72
+ - Updated dependencies [524db03]
73
+ - Updated dependencies [524db03]
74
+ - Updated dependencies [524db03]
75
+ - Updated dependencies [524db03]
76
+ - @pgflow/dsl@0.7.0
77
+ - @pgflow/core@0.7.0
10
78
 
11
79
  ## 0.6.1
12
80
 
package/README.md CHANGED
@@ -28,6 +28,9 @@ Key features:
28
28
  npm install @pgflow/client
29
29
  ```
30
30
 
31
+ > [!NOTE]
32
+ > Real-time updates use Supabase broadcast channels. Ensure real-time is enabled in your Supabase project.
33
+
31
34
  ## Quick Start
32
35
 
33
36
  ```typescript
@@ -376,5 +379,6 @@ See [BUILD_AND_RELEASE.md](./BUILD_AND_RELEASE.md#browser-via-cdn) for full CDN
376
379
  For more detailed documentation, visit:
377
380
 
378
381
  - [pgflow Documentation](https://pgflow.dev)
379
- - [Client Library Guide](https://pgflow.dev/how-to/monitor-flow-execution)
382
+ - [Start Flows from TypeScript Client](https://pgflow.dev/build/starting-flows/typescript-client/)
383
+ - [Client API Reference](https://pgflow.dev/reference/pgflow-client/)
380
384
 
@@ -0,0 +1,7 @@
1
+ import { SupabaseClient } from '@supabase/supabase-js';
2
+ import { PgflowClient } from './lib/PgflowClient.js';
3
+ export { PgflowClient } from './lib/PgflowClient.js';
4
+ export { FlowRunStatus, FlowStepStatus } from './lib/types.js';
5
+ export * from './lib/types.js';
6
+ export declare function createClient(supabaseClient: SupabaseClient): PgflowClient<import('../../dsl/src/index.ts').AnyFlow>;
7
+ //# sourceMappingURL=browser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../../src/browser.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAC/D,cAAc,gBAAgB,CAAC;AAG/B,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAG5D,wBAAgB,YAAY,CAAC,cAAc,EAAE,cAAc,+CAE1D"}
@@ -0,0 +1,6 @@
1
+ export * from './lib/types.js';
2
+ export { PgflowClient } from './lib/PgflowClient.js';
3
+ export { FlowRun } from './lib/FlowRun.js';
4
+ export { FlowStep } from './lib/FlowStep.js';
5
+ export type { Unsubscribe } from './lib/types.js';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AACA,cAAc,gBAAgB,CAAC;AAG/B,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAGrD,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAG7C,YAAY,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,125 @@
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
+ * Apply state from database snapshot (no events emitted)
95
+ * Used when initializing state from start_flow_with_states() or get_run_with_states()
96
+ *
97
+ * @internal This method is only intended for use by PgflowClient.
98
+ * Applications should not call this directly.
99
+ */
100
+ applySnapshot(row: import('../../../core/src/index.ts').RunRow): void;
101
+ /**
102
+ * Updates the run state based on an event
103
+ *
104
+ * @internal This method is only intended for use by PgflowClient and tests.
105
+ * Applications should not call this directly - state updates should come from
106
+ * database events through the PgflowClient.
107
+ *
108
+ * TODO: After v1.0, make this method private and refactor tests to use PgflowClient
109
+ * with event emission instead of direct state manipulation.
110
+ */
111
+ updateState(event: FlowRunEvent<TFlow>): boolean;
112
+ /**
113
+ * Updates a step state based on an event
114
+ *
115
+ * @param stepSlug - Step slug to update
116
+ * @param event - Event data to update the step with
117
+ * @returns true if the state was updated, false otherwise
118
+ */
119
+ updateStepState<TStepSlug extends keyof ExtractFlowSteps<TFlow> & string>(stepSlug: TStepSlug, event: StepEvent<TFlow, TStepSlug>): boolean;
120
+ /**
121
+ * Clean up all resources held by this run
122
+ */
123
+ dispose(): void;
124
+ }
125
+ //# 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;;OAEG;IACH,IAAI,KAAK,IAAI,gBAAgB,CAAC,KAAK,CAAC,CAEnC;IAED;;OAEG;IACH,IAAI,MAAM,IAAI,iBAAiB,CAAC,KAAK,CAAC,GAAG,IAAI,CAE5C;IAED;;OAEG;IACH,IAAI,KAAK,IAAI,KAAK,GAAG,IAAI,CAExB;IAED;;OAEG;IACH,IAAI,aAAa,IAAI,MAAM,GAAG,IAAI,CAEjC;IAED;;OAEG;IACH,IAAI,eAAe,IAAI,MAAM,CAE5B;IAED;;;;;;OAMG;IACH,EAAE,CAAC,CAAC,SAAS,MAAM,aAAa,CAAC,KAAK,CAAC,EACrC,KAAK,EAAE,CAAC,EACR,QAAQ,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAChC,WAAW;IAad;;;;;OAKG;IACH,IAAI,CAAC,SAAS,SAAS,MAAM,gBAAgB,CAAC,KAAK,CAAC,GAAG,MAAM,EAC3D,QAAQ,EAAE,SAAS,GAClB,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;IA8B7B;;;;;OAKG;IACH,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAKlC;;;;;;OAMG;IACH,aAAa,CACX,YAAY,EAAE,aAAa,CAAC,SAAS,GAAG,aAAa,CAAC,MAAM,EAC5D,OAAO,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE,GACrD,OAAO,CAAC,IAAI,CAAC;IA+DhB;;;;;;OAMG;IACH,aAAa,CAAC,GAAG,EAAE,OAAO,cAAc,EAAE,MAAM,GAAG,IAAI;IAavD;;;;;;;;;OASG;IACH,WAAW,CAAC,KAAK,EAAE,YAAY,CAAC,KAAK,CAAC,GAAG,OAAO;IAmFhD;;;;;;OAMG;IACH,eAAe,CAAC,SAAS,SAAS,MAAM,gBAAgB,CAAC,KAAK,CAAC,GAAG,MAAM,EACtE,QAAQ,EAAE,SAAS,EACnB,KAAK,EAAE,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,GACjC,OAAO;IAyDV;;OAEG;IACH,OAAO,IAAI,IAAI;CAgBhB"}
@@ -0,0 +1,90 @@
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
+ * Apply state from database snapshot (no events emitted)
72
+ * Used when initializing state from start_flow_with_states() or get_run_with_states()
73
+ *
74
+ * @internal This method is only intended for use by PgflowClient.
75
+ * Applications should not call this directly.
76
+ */
77
+ applySnapshot(row: import('../../../core/src/index.ts').StepStateRow): void;
78
+ /**
79
+ * Updates the step state based on an event
80
+ *
81
+ * @internal This method is only intended for use by FlowRun and tests.
82
+ * Applications should not call this directly - state updates should come from
83
+ * database events through the PgflowClient.
84
+ *
85
+ * TODO: After v1.0, make this method private and refactor tests to use PgflowClient
86
+ * with event emission instead of direct state manipulation.
87
+ */
88
+ updateState(event: StepEvent<TFlow, TStepSlug>): boolean;
89
+ }
90
+ //# 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,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,KAAK,EACV,aAAa,EACb,UAAU,EACV,WAAW,EACX,YAAY,EACZ,SAAS,EACV,MAAM,YAAY,CAAC;AAEpB;;GAEG;AACH,qBAAa,QAAQ,CACnB,KAAK,SAAS,OAAO,EACrB,SAAS,SAAS,MAAM,gBAAgB,CAAC,KAAK,CAAC,GAAG,MAAM,CACxD,YAAW,YAAY,CAAC,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;;IAUpD;;;;OAIG;gBACS,YAAY,EAAE,aAAa,CAAC,KAAK,EAAE,SAAS,CAAC;IAIzD;;OAEG;IACH,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED;;OAEG;IACH,IAAI,SAAS,IAAI,SAAS,CAEzB;IAED;;OAEG;IACH,IAAI,MAAM,IAAI,cAAc,CAE3B;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;;OAEG;IACH,IAAI,MAAM,IAAI,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC,GAAG,IAAI,CAEhD;IAED;;OAEG;IACH,IAAI,KAAK,IAAI,KAAK,GAAG,IAAI,CAExB;IAED;;OAEG;IACH,IAAI,aAAa,IAAI,MAAM,GAAG,IAAI,CAEjC;IAED;;;;;;OAMG;IACH,EAAE,CAAC,CAAC,SAAS,MAAM,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC,EAC7C,KAAK,EAAE,CAAC,EACR,QAAQ,EAAE,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,GACxC,WAAW;IAId;;;;;;OAMG;IACH,aAAa,CACX,YAAY,EAAE,cAAc,CAAC,OAAO,GAAG,cAAc,CAAC,SAAS,GAAG,cAAc,CAAC,MAAM,EACvF,OAAO,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE,GACrD,OAAO,CAAC,IAAI,CAAC;IAuDhB;;;;;;OAMG;IACH,aAAa,CAAC,GAAG,EAAE,OAAO,cAAc,EAAE,YAAY,GAAG,IAAI;IAW7D;;;;;;;;;OASG;IACH,WAAW,CAAC,KAAK,EAAE,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,GAAG,OAAO;CAgFzD"}
@@ -0,0 +1,76 @@
1
+ import { FlowRun } from './FlowRun.js';
2
+ import { IFlowClient, BroadcastRunEvent, BroadcastStepEvent, Unsubscribe } from './types.js';
3
+ import { AnyFlow, ExtractFlowInput } from '../../../dsl/src/index.ts';
4
+ import { SupabaseClient } from '@supabase/supabase-js';
5
+
6
+ /**
7
+ * Client for interacting with pgflow
8
+ */
9
+ export declare class PgflowClient<TFlow extends AnyFlow = AnyFlow> implements IFlowClient<TFlow> {
10
+ #private;
11
+ /**
12
+ * Creates a new PgflowClient instance
13
+ *
14
+ * @param supabaseClient - Supabase client instance
15
+ * @param opts - Optional configuration
16
+ */
17
+ constructor(supabaseClient: SupabaseClient, opts?: {
18
+ realtimeStabilizationDelayMs?: number;
19
+ schedule?: typeof setTimeout;
20
+ });
21
+ /**
22
+ * Start a flow with optional run_id
23
+ *
24
+ * @param flow_slug - Flow slug to start
25
+ * @param input - Input data for the flow
26
+ * @param run_id - Optional run ID (will be generated if not provided)
27
+ * @returns Promise that resolves with the FlowRun instance
28
+ */
29
+ startFlow<TSpecificFlow extends TFlow>(flow_slug: string, input: ExtractFlowInput<TSpecificFlow>, run_id?: string): Promise<FlowRun<TSpecificFlow>>;
30
+ /**
31
+ * Dispose a specific flow run
32
+ *
33
+ * @param runId - Run ID to dispose
34
+ */
35
+ dispose(runId: string): void;
36
+ /**
37
+ * Dispose all flow runs
38
+ */
39
+ disposeAll(): void;
40
+ /**
41
+ * Fetch flow definition metadata
42
+ */
43
+ fetchFlowDefinition(flow_slug: string): Promise<{
44
+ flow: import('../../../core/src/index.ts').FlowRow;
45
+ steps: import('../../../core/src/index.ts').StepRow[];
46
+ }>;
47
+ /**
48
+ * Register a callback for run events
49
+ * @returns Function to unsubscribe from the event
50
+ */
51
+ onRunEvent(callback: (event: BroadcastRunEvent) => void): Unsubscribe;
52
+ /**
53
+ * Register a callback for step events
54
+ * @returns Function to unsubscribe from the event
55
+ */
56
+ onStepEvent(callback: (event: BroadcastStepEvent) => void): Unsubscribe;
57
+ /**
58
+ * Subscribe to a flow run's events
59
+ */
60
+ subscribeToRun(run_id: string): Promise<() => void>;
61
+ /**
62
+ * Fetch current state of a run and its steps
63
+ */
64
+ getRunWithStates(run_id: string): Promise<{
65
+ run: import('../../../core/src/index.ts').RunRow;
66
+ steps: import('../../../core/src/index.ts').StepStateRow[];
67
+ }>;
68
+ /**
69
+ * Get a flow run by ID
70
+ *
71
+ * @param run_id - ID of the run to get
72
+ * @returns Promise that resolves with the FlowRun instance or null if not found
73
+ */
74
+ getRun<TSpecificFlow extends TFlow = TFlow>(run_id: string): Promise<FlowRun<TSpecificFlow> | null>;
75
+ }
76
+ //# sourceMappingURL=PgflowClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PgflowClient.d.ts","sourceRoot":"","sources":["../../../../src/lib/PgflowClient.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE7D,OAAO,KAAK,EACV,WAAW,EAEX,iBAAiB,EACjB,kBAAkB,EAClB,WAAW,EAEZ,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAGvC;;GAEG;AACH,qBAAa,YAAY,CAAC,KAAK,SAAS,OAAO,GAAG,OAAO,CAAE,YAAW,WAAW,CAAC,KAAK,CAAC;;IAOtF;;;;;OAKG;gBAED,cAAc,EAAE,cAAc,EAC9B,IAAI,GAAE;QACJ,4BAA4B,CAAC,EAAE,MAAM,CAAC;QACtC,QAAQ,CAAC,EAAE,OAAO,UAAU,CAAC;KACzB;IA4BR;;;;;;;OAOG;IACG,SAAS,CAAC,aAAa,SAAS,KAAK,EACzC,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,gBAAgB,CAAC,aAAa,CAAC,EACtC,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IAwDlC;;;;OAIG;IACH,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAc5B;;OAEG;IACH,UAAU,IAAI,IAAI;IAQlB;;OAEG;IACG,mBAAmB,CAAC,SAAS,EAAE,MAAM;;;;IAI3C;;;OAGG;IACH,UAAU,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,IAAI,GAAG,WAAW;IAIrE;;;OAGG;IACH,WAAW,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,kBAAkB,KAAK,IAAI,GAAG,WAAW;IAIvE;;OAEG;IACG,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,CAAC;IAIzD;;OAEG;IACG,gBAAgB,CAAC,MAAM,EAAE,MAAM;;;;IAIrC;;;;;OAKG;IACG,MAAM,CAAC,aAAa,SAAS,KAAK,GAAG,KAAK,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC;CA6E1G"}
@@ -0,0 +1,66 @@
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
+ stabilizationDelayMs?: number;
18
+ schedule?: typeof setTimeout;
19
+ });
20
+ /**
21
+ * Fetches flow definition metadata from the database
22
+ *
23
+ * @param flow_slug - Flow slug to fetch
24
+ */
25
+ fetchFlowDefinition(flow_slug: string): Promise<{
26
+ flow: FlowRow;
27
+ steps: StepRow[];
28
+ }>;
29
+ /**
30
+ * Registers a callback for run events
31
+ *
32
+ * @param callback - Function to call when run events are received
33
+ * @returns Function to unsubscribe from the event
34
+ */
35
+ onRunEvent(callback: (event: BroadcastRunEvent) => void): Unsubscribe;
36
+ /**
37
+ * Registers a callback for step events
38
+ *
39
+ * @param callback - Function to call when step events are received
40
+ * @returns Function to unsubscribe from the event
41
+ */
42
+ onStepEvent(callback: (event: BroadcastStepEvent) => void): Unsubscribe;
43
+ /**
44
+ * Subscribes to a flow run's events
45
+ *
46
+ * @param run_id - Run ID to subscribe to
47
+ * @returns Function to unsubscribe
48
+ */
49
+ subscribeToRun(run_id: string): Promise<() => void>;
50
+ /**
51
+ * Unsubscribes from a run's events
52
+ *
53
+ * @param run_id - Run ID to unsubscribe from
54
+ */
55
+ unsubscribe(run_id: string): void;
56
+ /**
57
+ * Fetches current state of a run and its steps
58
+ *
59
+ * @param run_id - Run ID to fetch
60
+ */
61
+ getRunWithStates(run_id: string): Promise<{
62
+ run: RunRow;
63
+ steps: StepStateRow[];
64
+ }>;
65
+ }
66
+ //# 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;;IAS5D;;;;OAIG;gBAED,QAAQ,EAAE,cAAc,EACxB,IAAI,GAAE;QACJ,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,oBAAoB,CAAC,EAAE,MAAM,CAAC;QAC9B,QAAQ,CAAC,EAAE,OAAO,UAAU,CAAC;KACzB;IAmLR;;;;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;IAgEzD;;;;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"}