@pgflow/client 0.0.0-array-map-steps-fixed-types-38a198ae-20251011160533 → 0.0.0-control-plane-a947cb71-20251121164755
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 +75 -3
- package/README.md +5 -1
- package/dist/client/src/browser.d.ts +7 -0
- package/dist/client/src/browser.d.ts.map +1 -0
- package/dist/client/src/index.d.ts +6 -0
- package/dist/client/src/index.d.ts.map +1 -0
- package/dist/client/src/lib/FlowRun.d.ts +125 -0
- package/dist/client/src/lib/FlowRun.d.ts.map +1 -0
- package/dist/client/src/lib/FlowStep.d.ts +90 -0
- package/dist/client/src/lib/FlowStep.d.ts.map +1 -0
- package/dist/client/src/lib/PgflowClient.d.ts +76 -0
- package/dist/client/src/lib/PgflowClient.d.ts.map +1 -0
- package/dist/client/src/lib/SupabaseBroadcastAdapter.d.ts +66 -0
- package/dist/client/src/lib/SupabaseBroadcastAdapter.d.ts.map +1 -0
- package/dist/client/src/lib/eventAdapters.d.ts +21 -0
- package/dist/client/src/lib/eventAdapters.d.ts.map +1 -0
- package/dist/client/src/lib/types.d.ts +308 -0
- package/dist/client/src/lib/types.d.ts.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +401 -446
- package/dist/index.js.map +1 -1
- package/dist/package.json +3 -3
- package/dist/pgflow-client.browser.js +1 -1
- package/dist/pgflow-client.browser.js.map +1 -1
- package/dist/src/browser.d.ts +3 -3
- package/dist/src/browser.d.ts.map +1 -1
- package/dist/src/browser.js +10 -0
- package/dist/src/index.js +7 -0
- package/dist/src/lib/FlowRun.d.ts +11 -3
- package/dist/src/lib/FlowRun.d.ts.map +1 -1
- package/dist/src/lib/FlowRun.js +368 -0
- package/dist/src/lib/FlowStep.d.ts +11 -3
- package/dist/src/lib/FlowStep.d.ts.map +1 -1
- package/dist/src/lib/FlowStep.js +244 -0
- package/dist/src/lib/PgflowClient.d.ts +12 -10
- package/dist/src/lib/PgflowClient.d.ts.map +1 -1
- package/dist/src/lib/PgflowClient.js +227 -0
- package/dist/src/lib/SupabaseBroadcastAdapter.d.ts +4 -4
- package/dist/src/lib/SupabaseBroadcastAdapter.d.ts.map +1 -1
- package/dist/src/lib/SupabaseBroadcastAdapter.js +332 -0
- package/dist/src/lib/eventAdapters.d.ts +3 -4
- package/dist/src/lib/eventAdapters.js +142 -0
- package/dist/src/lib/types.d.ts +3 -4
- package/dist/src/lib/types.js +91 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -0
- package/package.json +5 -5
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { FlowStepStatus, FlowRunStatus, } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Convert a broadcast run event to a typed run event
|
|
4
|
+
*/
|
|
5
|
+
export function toTypedRunEvent(evt) {
|
|
6
|
+
switch (evt.status) {
|
|
7
|
+
case FlowRunStatus.Started:
|
|
8
|
+
return {
|
|
9
|
+
event_type: 'run:started',
|
|
10
|
+
run_id: evt.run_id,
|
|
11
|
+
flow_slug: evt.flow_slug,
|
|
12
|
+
status: FlowRunStatus.Started,
|
|
13
|
+
started_at: evt.started_at,
|
|
14
|
+
remaining_steps: evt.remaining_steps,
|
|
15
|
+
input: evt.input,
|
|
16
|
+
};
|
|
17
|
+
case FlowRunStatus.Completed:
|
|
18
|
+
return {
|
|
19
|
+
event_type: 'run:completed',
|
|
20
|
+
run_id: evt.run_id,
|
|
21
|
+
flow_slug: evt.flow_slug,
|
|
22
|
+
status: FlowRunStatus.Completed,
|
|
23
|
+
completed_at: evt.completed_at,
|
|
24
|
+
output: evt.output,
|
|
25
|
+
};
|
|
26
|
+
case FlowRunStatus.Failed:
|
|
27
|
+
return {
|
|
28
|
+
event_type: 'run:failed',
|
|
29
|
+
run_id: evt.run_id,
|
|
30
|
+
flow_slug: evt.flow_slug,
|
|
31
|
+
status: FlowRunStatus.Failed,
|
|
32
|
+
failed_at: evt.failed_at,
|
|
33
|
+
error_message: evt.error_message,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Convert a broadcast step event to a typed step event
|
|
39
|
+
*/
|
|
40
|
+
export function toTypedStepEvent(evt) {
|
|
41
|
+
switch (evt.status) {
|
|
42
|
+
case FlowStepStatus.Started:
|
|
43
|
+
return {
|
|
44
|
+
event_type: 'step:started',
|
|
45
|
+
run_id: evt.run_id,
|
|
46
|
+
step_slug: evt.step_slug,
|
|
47
|
+
status: FlowStepStatus.Started,
|
|
48
|
+
started_at: evt.started_at,
|
|
49
|
+
};
|
|
50
|
+
case FlowStepStatus.Completed:
|
|
51
|
+
return {
|
|
52
|
+
event_type: 'step:completed',
|
|
53
|
+
run_id: evt.run_id,
|
|
54
|
+
step_slug: evt.step_slug,
|
|
55
|
+
status: FlowStepStatus.Completed,
|
|
56
|
+
completed_at: evt.completed_at,
|
|
57
|
+
output: evt.output,
|
|
58
|
+
};
|
|
59
|
+
case FlowStepStatus.Failed:
|
|
60
|
+
return {
|
|
61
|
+
event_type: 'step:failed',
|
|
62
|
+
run_id: evt.run_id,
|
|
63
|
+
step_slug: evt.step_slug,
|
|
64
|
+
status: FlowStepStatus.Failed,
|
|
65
|
+
failed_at: evt.failed_at,
|
|
66
|
+
error_message: evt.error_message,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Convert a database run row to a typed run event
|
|
72
|
+
*/
|
|
73
|
+
export function runRowToTypedEvent(row) {
|
|
74
|
+
switch (row.status) {
|
|
75
|
+
case 'started':
|
|
76
|
+
return {
|
|
77
|
+
event_type: 'run:started',
|
|
78
|
+
run_id: row.run_id,
|
|
79
|
+
flow_slug: row.flow_slug,
|
|
80
|
+
status: FlowRunStatus.Started,
|
|
81
|
+
started_at: row.started_at,
|
|
82
|
+
remaining_steps: row.remaining_steps,
|
|
83
|
+
input: row.input,
|
|
84
|
+
};
|
|
85
|
+
case 'completed':
|
|
86
|
+
return {
|
|
87
|
+
event_type: 'run:completed',
|
|
88
|
+
run_id: row.run_id,
|
|
89
|
+
flow_slug: row.flow_slug,
|
|
90
|
+
status: FlowRunStatus.Completed,
|
|
91
|
+
completed_at: row.completed_at,
|
|
92
|
+
output: row.output,
|
|
93
|
+
};
|
|
94
|
+
case 'failed':
|
|
95
|
+
return {
|
|
96
|
+
event_type: 'run:failed',
|
|
97
|
+
run_id: row.run_id,
|
|
98
|
+
flow_slug: row.flow_slug,
|
|
99
|
+
status: FlowRunStatus.Failed,
|
|
100
|
+
failed_at: row.failed_at,
|
|
101
|
+
error_message: 'Flow failed', // Database doesn't have error_message for runs
|
|
102
|
+
};
|
|
103
|
+
default:
|
|
104
|
+
throw new Error(`Unknown run status: ${row.status}`);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Convert a database step state row to a typed step event
|
|
109
|
+
*/
|
|
110
|
+
export function stepStateRowToTypedEvent(row) {
|
|
111
|
+
switch (row.status) {
|
|
112
|
+
case 'created':
|
|
113
|
+
case 'started':
|
|
114
|
+
return {
|
|
115
|
+
event_type: 'step:started',
|
|
116
|
+
run_id: row.run_id,
|
|
117
|
+
step_slug: row.step_slug,
|
|
118
|
+
status: FlowStepStatus.Started,
|
|
119
|
+
started_at: row.started_at,
|
|
120
|
+
};
|
|
121
|
+
case 'completed':
|
|
122
|
+
return {
|
|
123
|
+
event_type: 'step:completed',
|
|
124
|
+
run_id: row.run_id,
|
|
125
|
+
step_slug: row.step_slug,
|
|
126
|
+
status: FlowStepStatus.Completed,
|
|
127
|
+
completed_at: row.completed_at,
|
|
128
|
+
output: {}, // Database doesn't have output in step_states
|
|
129
|
+
};
|
|
130
|
+
case 'failed':
|
|
131
|
+
return {
|
|
132
|
+
event_type: 'step:failed',
|
|
133
|
+
run_id: row.run_id,
|
|
134
|
+
step_slug: row.step_slug,
|
|
135
|
+
status: FlowStepStatus.Failed,
|
|
136
|
+
failed_at: row.failed_at,
|
|
137
|
+
error_message: row.error_message || 'Step failed',
|
|
138
|
+
};
|
|
139
|
+
default:
|
|
140
|
+
throw new Error(`Unknown step status: ${row.status}`);
|
|
141
|
+
}
|
|
142
|
+
}
|
package/dist/src/lib/types.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Json, RunRow, StepStateRow, FlowRow, StepRow } from '
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import type { AnyFlow, ExtractFlowInput, ExtractFlowOutput, ExtractFlowSteps, StepOutput } from '@pgflow/dsl';
|
|
2
|
+
import type { Json, RunRow, StepStateRow, FlowRow, StepRow } from '@pgflow/core';
|
|
3
|
+
import type { FlowRun } from './FlowRun.js';
|
|
5
4
|
/**
|
|
6
5
|
* Flow run status enum
|
|
7
6
|
*/
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flow run status enum
|
|
3
|
+
*/
|
|
4
|
+
export var FlowRunStatus;
|
|
5
|
+
(function (FlowRunStatus) {
|
|
6
|
+
FlowRunStatus["Started"] = "started";
|
|
7
|
+
FlowRunStatus["Completed"] = "completed";
|
|
8
|
+
FlowRunStatus["Failed"] = "failed";
|
|
9
|
+
})(FlowRunStatus || (FlowRunStatus = {}));
|
|
10
|
+
/**
|
|
11
|
+
* Type guard to check if an unknown value is a valid FlowRunEvent
|
|
12
|
+
*/
|
|
13
|
+
export function isFlowRunEvent(value) {
|
|
14
|
+
return (!!value &&
|
|
15
|
+
typeof value === 'object' &&
|
|
16
|
+
'run_id' in value &&
|
|
17
|
+
'flow_slug' in value &&
|
|
18
|
+
!('step_slug' in value) &&
|
|
19
|
+
'status' in value &&
|
|
20
|
+
(value.status === FlowRunStatus.Started ||
|
|
21
|
+
value.status === FlowRunStatus.Completed ||
|
|
22
|
+
value.status === FlowRunStatus.Failed));
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Type guard for started events
|
|
26
|
+
*/
|
|
27
|
+
export function isFlowRunStartedEvent(event) {
|
|
28
|
+
return event.status === FlowRunStatus.Started;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Type guard for completed events
|
|
32
|
+
*/
|
|
33
|
+
export function isFlowRunCompletedEvent(event) {
|
|
34
|
+
return event.status === FlowRunStatus.Completed;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Type guard for failed events
|
|
38
|
+
*/
|
|
39
|
+
export function isFlowRunFailedEvent(event) {
|
|
40
|
+
return event.status === FlowRunStatus.Failed;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Flow step status enum
|
|
44
|
+
*/
|
|
45
|
+
export var FlowStepStatus;
|
|
46
|
+
(function (FlowStepStatus) {
|
|
47
|
+
FlowStepStatus["Created"] = "created";
|
|
48
|
+
FlowStepStatus["Started"] = "started";
|
|
49
|
+
FlowStepStatus["Completed"] = "completed";
|
|
50
|
+
FlowStepStatus["Failed"] = "failed";
|
|
51
|
+
})(FlowStepStatus || (FlowStepStatus = {}));
|
|
52
|
+
/**
|
|
53
|
+
* Type guard to check if an unknown value is a valid StepEvent
|
|
54
|
+
*/
|
|
55
|
+
export function isStepEvent(value) {
|
|
56
|
+
return (!!value &&
|
|
57
|
+
typeof value === 'object' &&
|
|
58
|
+
'run_id' in value &&
|
|
59
|
+
'step_slug' in value &&
|
|
60
|
+
'status' in value &&
|
|
61
|
+
(value.status === FlowStepStatus.Started ||
|
|
62
|
+
value.status === FlowStepStatus.Completed ||
|
|
63
|
+
value.status === FlowStepStatus.Failed));
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Type guard for started step events
|
|
67
|
+
*/
|
|
68
|
+
export function isStepStartedEvent(event) {
|
|
69
|
+
return (isStepEvent(event) &&
|
|
70
|
+
event.status === FlowStepStatus.Started &&
|
|
71
|
+
'event_type' in event &&
|
|
72
|
+
event.event_type === 'step:started');
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Type guard for completed step events
|
|
76
|
+
*/
|
|
77
|
+
export function isStepCompletedEvent(event) {
|
|
78
|
+
return (isStepEvent(event) &&
|
|
79
|
+
event.status === FlowStepStatus.Completed &&
|
|
80
|
+
'event_type' in event &&
|
|
81
|
+
event.event_type === 'step:completed');
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Type guard for failed step events
|
|
85
|
+
*/
|
|
86
|
+
export function isStepFailedEvent(event) {
|
|
87
|
+
return (isStepEvent(event) &&
|
|
88
|
+
event.status === FlowStepStatus.Failed &&
|
|
89
|
+
'event_type' in event &&
|
|
90
|
+
event.event_type === 'step:failed');
|
|
91
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":"5.8.3"}
|
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pgflow/client",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-control-plane-a947cb71-20251121164755",
|
|
4
|
+
"license": "Apache-2.0",
|
|
4
5
|
"type": "module",
|
|
5
6
|
"dependencies": {
|
|
6
7
|
"@supabase/supabase-js": "^2.49.4",
|
|
7
8
|
"nanoevents": "^7.0.1",
|
|
8
9
|
"uuid": "^9.0.0",
|
|
9
|
-
"@pgflow/core": "0.0.0-
|
|
10
|
-
"@pgflow/dsl": "0.0.0-
|
|
10
|
+
"@pgflow/core": "0.0.0-control-plane-a947cb71-20251121164755",
|
|
11
|
+
"@pgflow/dsl": "0.0.0-control-plane-a947cb71-20251121164755"
|
|
11
12
|
},
|
|
12
13
|
"main": "./dist/index.js",
|
|
13
14
|
"module": "./dist/index.js",
|
|
@@ -39,11 +40,10 @@
|
|
|
39
40
|
"devDependencies": {
|
|
40
41
|
"@types/uuid": "^10.0.0",
|
|
41
42
|
"postgres": "^3.4.5",
|
|
42
|
-
"supabase": "2.21.1",
|
|
43
43
|
"terser": "^5.43.0",
|
|
44
44
|
"vite-plugin-dts": "~3.8.1",
|
|
45
45
|
"vitest": "1.3.1",
|
|
46
|
-
"@pgflow/dsl": "0.0.0-
|
|
46
|
+
"@pgflow/dsl": "0.0.0-control-plane-a947cb71-20251121164755"
|
|
47
47
|
},
|
|
48
48
|
"scripts": {
|
|
49
49
|
"verify-exports": "node scripts/verify-exports.js"
|