@pgflow/client 0.13.2 → 0.14.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/CHANGELOG.md +16 -0
- package/dist/client/src/lib/FlowRun.d.ts.map +1 -1
- package/dist/client/src/lib/FlowStep.d.ts +10 -2
- package/dist/client/src/lib/FlowStep.d.ts.map +1 -1
- package/dist/client/src/lib/eventAdapters.d.ts.map +1 -1
- package/dist/client/src/lib/types.d.ts +31 -2
- package/dist/client/src/lib/types.d.ts.map +1 -1
- package/dist/index.js +259 -213
- package/dist/index.js.map +1 -1
- package/dist/package.json +1 -1
- package/dist/pgflow-client.browser.js +1 -1
- package/dist/pgflow-client.browser.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
var Q = (s) => {
|
|
2
2
|
throw TypeError(s);
|
|
3
3
|
};
|
|
4
|
-
var
|
|
5
|
-
var e = (s, t, r) => (
|
|
6
|
-
var
|
|
4
|
+
var H = (s, t, r) => t.has(s) || Q("Cannot " + r);
|
|
5
|
+
var e = (s, t, r) => (H(s, t, "read from private field"), r ? r.call(s) : t.get(s)), d = (s, t, r) => t.has(s) ? Q("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(s) : t.set(s, r), _ = (s, t, r, i) => (H(s, t, "write to private field"), i ? i.call(s, r) : t.set(s, r), r), m = (s, t, r) => (H(s, t, "access private method"), r);
|
|
6
|
+
var j = (s, t, r, i) => ({
|
|
7
7
|
set _(n) {
|
|
8
|
-
|
|
8
|
+
_(s, t, n, r);
|
|
9
9
|
},
|
|
10
10
|
get _() {
|
|
11
11
|
return e(s, t, i);
|
|
@@ -13,33 +13,36 @@ var H = (s, t, r, i) => ({
|
|
|
13
13
|
});
|
|
14
14
|
import { v4 as st } from "uuid";
|
|
15
15
|
import { createNanoEvents as L } from "nanoevents";
|
|
16
|
-
var
|
|
17
|
-
function
|
|
16
|
+
var h = /* @__PURE__ */ ((s) => (s.Started = "started", s.Completed = "completed", s.Failed = "failed", s))(h || {});
|
|
17
|
+
function pt(s) {
|
|
18
18
|
return !!s && typeof s == "object" && "run_id" in s && "flow_slug" in s && !("step_slug" in s) && "status" in s && (s.status === "started" || s.status === "completed" || s.status === "failed");
|
|
19
19
|
}
|
|
20
|
-
function
|
|
20
|
+
function dt(s) {
|
|
21
21
|
return s.status === "started";
|
|
22
22
|
}
|
|
23
|
-
function
|
|
23
|
+
function ct(s) {
|
|
24
24
|
return s.status === "completed";
|
|
25
25
|
}
|
|
26
26
|
function ht(s) {
|
|
27
27
|
return s.status === "failed";
|
|
28
28
|
}
|
|
29
|
-
var
|
|
30
|
-
function
|
|
31
|
-
return !!s && typeof s == "object" && "run_id" in s && "step_slug" in s && "status" in s && (s.status === "started" || s.status === "completed" || s.status === "failed");
|
|
32
|
-
}
|
|
33
|
-
function ft(s) {
|
|
34
|
-
return N(s) && s.status === "started" && "event_type" in s && s.event_type === "step:started";
|
|
29
|
+
var u = /* @__PURE__ */ ((s) => (s.Created = "created", s.Started = "started", s.Completed = "completed", s.Failed = "failed", s.Skipped = "skipped", s))(u || {});
|
|
30
|
+
function O(s) {
|
|
31
|
+
return !!s && typeof s == "object" && "run_id" in s && "step_slug" in s && "status" in s && (s.status === "started" || s.status === "completed" || s.status === "failed" || s.status === "skipped");
|
|
35
32
|
}
|
|
36
33
|
function _t(s) {
|
|
37
|
-
return
|
|
34
|
+
return O(s) && s.status === "started" && "event_type" in s && s.event_type === "step:started";
|
|
35
|
+
}
|
|
36
|
+
function ft(s) {
|
|
37
|
+
return O(s) && s.status === "completed" && "event_type" in s && s.event_type === "step:completed";
|
|
38
38
|
}
|
|
39
39
|
function mt(s) {
|
|
40
|
-
return
|
|
40
|
+
return O(s) && s.status === "failed" && "event_type" in s && s.event_type === "step:failed";
|
|
41
41
|
}
|
|
42
|
-
|
|
42
|
+
function gt(s) {
|
|
43
|
+
return O(s) && s.status === "skipped" && "event_type" in s && s.event_type === "step:skipped";
|
|
44
|
+
}
|
|
45
|
+
var E, k, C, I, W, A, f, G, X, K, Y, Z, v, M, N;
|
|
43
46
|
class rt {
|
|
44
47
|
/**
|
|
45
48
|
* Creates a new instance of SupabaseBroadcastAdapter
|
|
@@ -47,16 +50,16 @@ class rt {
|
|
|
47
50
|
* @param supabase - Supabase client instance
|
|
48
51
|
*/
|
|
49
52
|
constructor(t, r = {}) {
|
|
50
|
-
d(this,
|
|
51
|
-
d(this,
|
|
52
|
-
d(this,
|
|
53
|
-
d(this,
|
|
53
|
+
d(this, f);
|
|
54
|
+
d(this, E);
|
|
55
|
+
d(this, k, /* @__PURE__ */ new Map());
|
|
56
|
+
d(this, C, L());
|
|
54
57
|
d(this, I);
|
|
55
58
|
d(this, W);
|
|
56
|
-
d(this,
|
|
59
|
+
d(this, A);
|
|
57
60
|
// Store unsubscribe functions per run ID for reference equality
|
|
58
|
-
d(this,
|
|
59
|
-
|
|
61
|
+
d(this, M, /* @__PURE__ */ new Map());
|
|
62
|
+
_(this, E, t), _(this, I, r.reconnectDelayMs ?? 2e3), _(this, W, r.stabilizationDelayMs ?? 300), _(this, A, r.schedule ?? setTimeout.bind(globalThis));
|
|
60
63
|
}
|
|
61
64
|
/**
|
|
62
65
|
* Fetches flow definition metadata from the database
|
|
@@ -65,8 +68,8 @@ class rt {
|
|
|
65
68
|
*/
|
|
66
69
|
async fetchFlowDefinition(t) {
|
|
67
70
|
const [r, i] = await Promise.all([
|
|
68
|
-
e(this,
|
|
69
|
-
e(this,
|
|
71
|
+
e(this, E).schema("pgflow").from("flows").select("*").eq("flow_slug", t).single(),
|
|
72
|
+
e(this, E).schema("pgflow").from("steps").select("*").eq("flow_slug", t).order("step_index", { ascending: !0 })
|
|
70
73
|
]);
|
|
71
74
|
if (r.error) throw r.error;
|
|
72
75
|
if (!r.data) throw new Error(`Flow "${t}" not found`);
|
|
@@ -84,7 +87,7 @@ class rt {
|
|
|
84
87
|
* @returns Function to unsubscribe from the event
|
|
85
88
|
*/
|
|
86
89
|
onRunEvent(t) {
|
|
87
|
-
const r = e(this,
|
|
90
|
+
const r = e(this, C).on("runEvent", t);
|
|
88
91
|
return () => {
|
|
89
92
|
try {
|
|
90
93
|
r();
|
|
@@ -100,7 +103,7 @@ class rt {
|
|
|
100
103
|
* @returns Function to unsubscribe from the event
|
|
101
104
|
*/
|
|
102
105
|
onStepEvent(t) {
|
|
103
|
-
const r = e(this,
|
|
106
|
+
const r = e(this, C).on("stepEvent", t);
|
|
104
107
|
return () => {
|
|
105
108
|
try {
|
|
106
109
|
r();
|
|
@@ -117,27 +120,27 @@ class rt {
|
|
|
117
120
|
*/
|
|
118
121
|
async subscribeToRun(t) {
|
|
119
122
|
const r = `pgflow:run:${t}`;
|
|
120
|
-
if (e(this,
|
|
121
|
-
const c = e(this,
|
|
123
|
+
if (e(this, k).has(t)) {
|
|
124
|
+
const c = e(this, M).get(t);
|
|
122
125
|
if (c)
|
|
123
126
|
return c;
|
|
124
|
-
m(this,
|
|
127
|
+
m(this, f, N).call(this, t);
|
|
125
128
|
}
|
|
126
|
-
const i = e(this,
|
|
127
|
-
i.on("broadcast", { event: "*" }, m(this,
|
|
129
|
+
const i = e(this, E).channel(r);
|
|
130
|
+
i.on("broadcast", { event: "*" }, m(this, f, G).bind(this)), i.on("system", { event: "closed" }, () => {
|
|
128
131
|
console.log(`Channel ${r} closed`);
|
|
129
132
|
}), i.on("system", { event: "error" }, (c) => {
|
|
130
|
-
console.log(`Channel ${r} error:`, c), m(this,
|
|
131
|
-
}), console.log(`Subscribing to channel ${r}...`), await new Promise((c,
|
|
132
|
-
const
|
|
133
|
-
|
|
133
|
+
console.log(`Channel ${r} error:`, c), m(this, f, K).call(this, t, r, i, c.error);
|
|
134
|
+
}), console.log(`Subscribing to channel ${r}...`), await new Promise((c, l) => {
|
|
135
|
+
const p = setTimeout(() => {
|
|
136
|
+
l(new Error(`Subscription timeout for channel ${r}`));
|
|
134
137
|
}, 2e4);
|
|
135
138
|
i.subscribe((b) => {
|
|
136
|
-
console.log(`Channel ${r} subscription status:`, b), b === "SUBSCRIBED" && (clearTimeout(
|
|
139
|
+
console.log(`Channel ${r} subscription status:`, b), b === "SUBSCRIBED" && (clearTimeout(p), c());
|
|
137
140
|
});
|
|
138
|
-
}), await new Promise((c) => e(this,
|
|
141
|
+
}), await new Promise((c) => e(this, A).call(this, c, e(this, W))), e(this, k).set(t, i);
|
|
139
142
|
const g = () => this.unsubscribe(t);
|
|
140
|
-
return e(this,
|
|
143
|
+
return e(this, M).set(t, g), g;
|
|
141
144
|
}
|
|
142
145
|
/**
|
|
143
146
|
* Unsubscribes from a run's events
|
|
@@ -145,7 +148,7 @@ class rt {
|
|
|
145
148
|
* @param run_id - Run ID to unsubscribe from
|
|
146
149
|
*/
|
|
147
150
|
unsubscribe(t) {
|
|
148
|
-
m(this,
|
|
151
|
+
m(this, f, N).call(this, t);
|
|
149
152
|
}
|
|
150
153
|
/**
|
|
151
154
|
* Fetches current state of a run and its steps
|
|
@@ -153,19 +156,19 @@ class rt {
|
|
|
153
156
|
* @param run_id - Run ID to fetch
|
|
154
157
|
*/
|
|
155
158
|
async getRunWithStates(t) {
|
|
156
|
-
const { data: r, error: i } = await e(this,
|
|
159
|
+
const { data: r, error: i } = await e(this, E).schema("pgflow").rpc("get_run_with_states", { run_id: t });
|
|
157
160
|
if (i) throw i;
|
|
158
161
|
if (!r) throw new Error(`No data returned for run ${t}`);
|
|
159
162
|
return r;
|
|
160
163
|
}
|
|
161
164
|
}
|
|
162
|
-
|
|
165
|
+
E = new WeakMap(), k = new WeakMap(), C = new WeakMap(), I = new WeakMap(), W = new WeakMap(), A = new WeakMap(), f = new WeakSet(), /**
|
|
163
166
|
* Handle broadcast messages from Supabase
|
|
164
167
|
* @param payload - The message payload
|
|
165
168
|
*/
|
|
166
|
-
|
|
169
|
+
G = function(t) {
|
|
167
170
|
const { event: r, payload: i } = t, n = i;
|
|
168
|
-
m(this,
|
|
171
|
+
m(this, f, X).call(this, n), r.startsWith("run:") ? e(this, C).emit("runEvent", n) : r.startsWith("step:") && e(this, C).emit("stepEvent", n);
|
|
169
172
|
}, /**
|
|
170
173
|
* Parse JSON string fields in broadcast event data
|
|
171
174
|
* @param eventData - The event data object to parse
|
|
@@ -181,9 +184,9 @@ X = function(t) {
|
|
|
181
184
|
t.input = JSON.parse(t.input);
|
|
182
185
|
} catch {
|
|
183
186
|
}
|
|
184
|
-
},
|
|
185
|
-
console.error(`Channel ${r} error:`, n), e(this,
|
|
186
|
-
e(this,
|
|
187
|
+
}, K = async function(t, r, i, n) {
|
|
188
|
+
console.error(`Channel ${r} error:`, n), e(this, A).call(this, async () => {
|
|
189
|
+
e(this, k).has(t) && await m(this, f, Z).call(this, t, r);
|
|
187
190
|
}, e(this, I));
|
|
188
191
|
}, /**
|
|
189
192
|
* Creates and configures a channel for a run
|
|
@@ -192,14 +195,14 @@ X = function(t) {
|
|
|
192
195
|
* @returns The configured RealtimeChannel
|
|
193
196
|
*/
|
|
194
197
|
Y = function(t, r) {
|
|
195
|
-
const i = e(this,
|
|
196
|
-
return i.on("broadcast", { event: "*" }, m(this,
|
|
198
|
+
const i = e(this, E).channel(r);
|
|
199
|
+
return i.on("broadcast", { event: "*" }, m(this, f, G).bind(this)), i;
|
|
197
200
|
}, Z = async function(t, r) {
|
|
198
201
|
console.log(`Attempting to reconnect to ${r}`);
|
|
199
202
|
try {
|
|
200
203
|
const i = await this.getRunWithStates(t);
|
|
201
|
-
m(this,
|
|
202
|
-
const n = m(this,
|
|
204
|
+
m(this, f, v).call(this, t, i);
|
|
205
|
+
const n = m(this, f, Y).call(this, t, r);
|
|
203
206
|
n.on("system", { event: "subscribed" }, () => {
|
|
204
207
|
console.log(`Reconnected and subscribed to channel ${r}`);
|
|
205
208
|
}), n.on("system", { event: "closed" }, () => {
|
|
@@ -207,8 +210,8 @@ Y = function(t, r) {
|
|
|
207
210
|
}), n.on(
|
|
208
211
|
"system",
|
|
209
212
|
{ event: "error" },
|
|
210
|
-
(g) => m(this,
|
|
211
|
-
), n.subscribe(), e(this,
|
|
213
|
+
(g) => m(this, f, K).call(this, t, r, n, g.error)
|
|
214
|
+
), n.subscribe(), e(this, k).set(t, n);
|
|
212
215
|
} catch (i) {
|
|
213
216
|
console.error(`Failed to reconnect to ${r}:`, i);
|
|
214
217
|
}
|
|
@@ -223,109 +226,122 @@ v = function(t, r) {
|
|
|
223
226
|
event_type: `run:${r.run.status}`,
|
|
224
227
|
...r.run
|
|
225
228
|
};
|
|
226
|
-
if (e(this,
|
|
229
|
+
if (e(this, C).emit("runEvent", i), r.steps && Array.isArray(r.steps))
|
|
227
230
|
for (const n of r.steps) {
|
|
228
231
|
const g = {
|
|
229
232
|
event_type: `step:${n.status}`,
|
|
230
233
|
...n
|
|
231
234
|
};
|
|
232
|
-
e(this,
|
|
235
|
+
e(this, C).emit("stepEvent", g);
|
|
233
236
|
}
|
|
234
|
-
},
|
|
237
|
+
}, M = new WeakMap(), /**
|
|
235
238
|
* Unsubscribes from a run's events
|
|
236
239
|
*
|
|
237
240
|
* @param run_id - Run ID to unsubscribe from
|
|
238
241
|
*/
|
|
239
|
-
|
|
240
|
-
const r = e(this,
|
|
241
|
-
r && (r.unsubscribe(), e(this,
|
|
242
|
+
N = function(t) {
|
|
243
|
+
const r = e(this, k).get(t);
|
|
244
|
+
r && (r.unsubscribe(), e(this, k).delete(t), e(this, M).delete(t));
|
|
242
245
|
};
|
|
243
|
-
var
|
|
246
|
+
var a, F, x, J, tt;
|
|
244
247
|
class it {
|
|
245
248
|
/**
|
|
246
249
|
* Creates a new FlowStep instance
|
|
247
|
-
*
|
|
250
|
+
*
|
|
248
251
|
* @param initialState - Initial state for the step
|
|
249
252
|
*/
|
|
250
253
|
constructor(t) {
|
|
251
254
|
d(this, J);
|
|
252
|
-
d(this,
|
|
253
|
-
d(this,
|
|
255
|
+
d(this, a);
|
|
256
|
+
d(this, F, L());
|
|
254
257
|
d(this, x, {
|
|
255
|
-
[
|
|
256
|
-
[
|
|
257
|
-
[
|
|
258
|
-
[
|
|
258
|
+
[u.Created]: 0,
|
|
259
|
+
[u.Started]: 1,
|
|
260
|
+
[u.Completed]: 2,
|
|
261
|
+
[u.Failed]: 3,
|
|
262
|
+
[u.Skipped]: 4
|
|
259
263
|
});
|
|
260
|
-
|
|
264
|
+
_(this, a, t);
|
|
261
265
|
}
|
|
262
266
|
/**
|
|
263
267
|
* Get the run ID this step belongs to
|
|
264
268
|
*/
|
|
265
269
|
get run_id() {
|
|
266
|
-
return e(this,
|
|
270
|
+
return e(this, a).run_id;
|
|
267
271
|
}
|
|
268
272
|
/**
|
|
269
273
|
* Get the step slug
|
|
270
274
|
*/
|
|
271
275
|
get step_slug() {
|
|
272
|
-
return e(this,
|
|
276
|
+
return e(this, a).step_slug;
|
|
273
277
|
}
|
|
274
278
|
/**
|
|
275
279
|
* Get the current status
|
|
276
280
|
*/
|
|
277
281
|
get status() {
|
|
278
|
-
return e(this,
|
|
282
|
+
return e(this, a).status;
|
|
279
283
|
}
|
|
280
284
|
/**
|
|
281
285
|
* Get the started_at timestamp
|
|
282
286
|
*/
|
|
283
287
|
get started_at() {
|
|
284
|
-
return e(this,
|
|
288
|
+
return e(this, a).started_at;
|
|
285
289
|
}
|
|
286
290
|
/**
|
|
287
291
|
* Get the completed_at timestamp
|
|
288
292
|
*/
|
|
289
293
|
get completed_at() {
|
|
290
|
-
return e(this,
|
|
294
|
+
return e(this, a).completed_at;
|
|
291
295
|
}
|
|
292
296
|
/**
|
|
293
297
|
* Get the failed_at timestamp
|
|
294
298
|
*/
|
|
295
299
|
get failed_at() {
|
|
296
|
-
return e(this,
|
|
300
|
+
return e(this, a).failed_at;
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Get the skipped_at timestamp
|
|
304
|
+
*/
|
|
305
|
+
get skipped_at() {
|
|
306
|
+
return e(this, a).skipped_at;
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Get the skip reason
|
|
310
|
+
*/
|
|
311
|
+
get skip_reason() {
|
|
312
|
+
return e(this, a).skip_reason;
|
|
297
313
|
}
|
|
298
314
|
/**
|
|
299
315
|
* Get the step output
|
|
300
316
|
*/
|
|
301
317
|
get output() {
|
|
302
|
-
return e(this,
|
|
318
|
+
return e(this, a).output;
|
|
303
319
|
}
|
|
304
320
|
/**
|
|
305
321
|
* Get the error object
|
|
306
322
|
*/
|
|
307
323
|
get error() {
|
|
308
|
-
return e(this,
|
|
324
|
+
return e(this, a).error;
|
|
309
325
|
}
|
|
310
326
|
/**
|
|
311
327
|
* Get the error message
|
|
312
328
|
*/
|
|
313
329
|
get error_message() {
|
|
314
|
-
return e(this,
|
|
330
|
+
return e(this, a).error_message;
|
|
315
331
|
}
|
|
316
332
|
/**
|
|
317
333
|
* Register an event handler for a step event
|
|
318
|
-
*
|
|
334
|
+
*
|
|
319
335
|
* @param event - Event type to listen for
|
|
320
336
|
* @param callback - Callback function to execute when event is emitted
|
|
321
337
|
* @returns Function to unsubscribe from the event
|
|
322
338
|
*/
|
|
323
339
|
on(t, r) {
|
|
324
|
-
return e(this,
|
|
340
|
+
return e(this, F).on(t, r);
|
|
325
341
|
}
|
|
326
342
|
/**
|
|
327
343
|
* Wait for the step to reach a specific status
|
|
328
|
-
*
|
|
344
|
+
*
|
|
329
345
|
* @param targetStatus - The status to wait for
|
|
330
346
|
* @param options - Optional timeout and abort signal
|
|
331
347
|
* @returns Promise that resolves with the step instance when the status is reached
|
|
@@ -333,23 +349,31 @@ class it {
|
|
|
333
349
|
waitForStatus(t, r) {
|
|
334
350
|
const i = (r == null ? void 0 : r.timeoutMs) ?? 3e5, { signal: n } = r || {};
|
|
335
351
|
return this.status === t ? Promise.resolve(this) : new Promise((g, c) => {
|
|
336
|
-
let
|
|
337
|
-
i > 0 && (
|
|
338
|
-
|
|
352
|
+
let l, p = !1;
|
|
353
|
+
i > 0 && (l = setTimeout(() => {
|
|
354
|
+
p || (p = !0, $(), c(
|
|
355
|
+
new Error(
|
|
356
|
+
`Timeout waiting for step ${this.step_slug} to reach status '${t}'`
|
|
357
|
+
)
|
|
358
|
+
));
|
|
339
359
|
}, i));
|
|
340
360
|
let b;
|
|
341
361
|
if (n) {
|
|
342
|
-
const
|
|
343
|
-
|
|
362
|
+
const S = () => {
|
|
363
|
+
p || (p = !0, l && clearTimeout(l), $(), c(
|
|
364
|
+
new Error(
|
|
365
|
+
`Aborted waiting for step ${this.step_slug} to reach status '${t}'`
|
|
366
|
+
)
|
|
367
|
+
));
|
|
344
368
|
};
|
|
345
|
-
n.addEventListener("abort",
|
|
346
|
-
n.removeEventListener("abort",
|
|
369
|
+
n.addEventListener("abort", S), b = () => {
|
|
370
|
+
n.removeEventListener("abort", S);
|
|
347
371
|
};
|
|
348
372
|
}
|
|
349
|
-
const
|
|
350
|
-
if (
|
|
351
|
-
if (
|
|
352
|
-
|
|
373
|
+
const $ = this.on("*", (S) => {
|
|
374
|
+
if (S.status === t) {
|
|
375
|
+
if (p) return;
|
|
376
|
+
p = !0, l && clearTimeout(l), b && b(), $(), g(this);
|
|
353
377
|
}
|
|
354
378
|
});
|
|
355
379
|
});
|
|
@@ -362,7 +386,7 @@ class it {
|
|
|
362
386
|
* Applications should not call this directly.
|
|
363
387
|
*/
|
|
364
388
|
applySnapshot(t) {
|
|
365
|
-
e(this,
|
|
389
|
+
e(this, a).status = t.status, e(this, a).started_at = t.started_at ? new Date(t.started_at) : null, e(this, a).completed_at = t.completed_at ? new Date(t.completed_at) : null, e(this, a).failed_at = t.failed_at ? new Date(t.failed_at) : null, e(this, a).error_message = t.error_message, e(this, a).error = t.error_message ? new Error(t.error_message) : null, e(this, a).skipped_at = t.skipped_at ? new Date(t.skipped_at) : null, e(this, a).skip_reason = t.skip_reason;
|
|
366
390
|
}
|
|
367
391
|
/**
|
|
368
392
|
* Updates the step state based on an event
|
|
@@ -375,53 +399,63 @@ class it {
|
|
|
375
399
|
* with event emission instead of direct state manipulation.
|
|
376
400
|
*/
|
|
377
401
|
updateState(t) {
|
|
378
|
-
if (t.step_slug !== e(this,
|
|
402
|
+
if (t.step_slug !== e(this, a).step_slug || t.run_id !== e(this, a).run_id || !m(this, J, tt).call(this, e(this, a).status, t.status))
|
|
379
403
|
return !1;
|
|
380
404
|
switch (t.status) {
|
|
381
|
-
case
|
|
382
|
-
|
|
383
|
-
...e(this,
|
|
384
|
-
status:
|
|
405
|
+
case u.Started:
|
|
406
|
+
_(this, a, {
|
|
407
|
+
...e(this, a),
|
|
408
|
+
status: u.Started,
|
|
385
409
|
started_at: typeof t.started_at == "string" ? new Date(t.started_at) : /* @__PURE__ */ new Date()
|
|
386
|
-
}), e(this,
|
|
410
|
+
}), e(this, F).emit("started", t);
|
|
387
411
|
break;
|
|
388
|
-
case
|
|
389
|
-
|
|
390
|
-
...e(this,
|
|
391
|
-
status:
|
|
412
|
+
case u.Completed:
|
|
413
|
+
_(this, a, {
|
|
414
|
+
...e(this, a),
|
|
415
|
+
status: u.Completed,
|
|
392
416
|
completed_at: typeof t.completed_at == "string" ? new Date(t.completed_at) : /* @__PURE__ */ new Date(),
|
|
393
417
|
output: t.output
|
|
394
|
-
}), e(this,
|
|
418
|
+
}), e(this, F).emit("completed", t);
|
|
395
419
|
break;
|
|
396
|
-
case
|
|
397
|
-
|
|
398
|
-
...e(this,
|
|
399
|
-
status:
|
|
420
|
+
case u.Failed:
|
|
421
|
+
_(this, a, {
|
|
422
|
+
...e(this, a),
|
|
423
|
+
status: u.Failed,
|
|
400
424
|
failed_at: typeof t.failed_at == "string" ? new Date(t.failed_at) : /* @__PURE__ */ new Date(),
|
|
401
425
|
error_message: typeof t.error_message == "string" ? t.error_message : "Unknown error",
|
|
402
|
-
error: new Error(
|
|
403
|
-
|
|
426
|
+
error: new Error(
|
|
427
|
+
typeof t.error_message == "string" ? t.error_message : "Unknown error"
|
|
428
|
+
)
|
|
429
|
+
}), e(this, F).emit("failed", t);
|
|
430
|
+
break;
|
|
431
|
+
case u.Skipped:
|
|
432
|
+
_(this, a, {
|
|
433
|
+
...e(this, a),
|
|
434
|
+
status: u.Skipped,
|
|
435
|
+
skipped_at: typeof t.skipped_at == "string" ? new Date(t.skipped_at) : /* @__PURE__ */ new Date(),
|
|
436
|
+
skip_reason: t.skip_reason
|
|
437
|
+
}), e(this, F).emit("skipped", t);
|
|
404
438
|
break;
|
|
405
439
|
default:
|
|
406
440
|
return !1;
|
|
407
441
|
}
|
|
408
|
-
return e(this,
|
|
442
|
+
return e(this, F).emit("*", t), !0;
|
|
409
443
|
}
|
|
410
444
|
}
|
|
411
|
-
|
|
445
|
+
a = new WeakMap(), F = new WeakMap(), x = new WeakMap(), J = new WeakSet(), /**
|
|
412
446
|
* Determines if a status should be updated based on precedence
|
|
413
|
-
*
|
|
447
|
+
*
|
|
414
448
|
* @param currentStatus - Current status
|
|
415
449
|
* @param newStatus - New status
|
|
416
450
|
* @returns true if the status should be updated, false otherwise
|
|
417
451
|
*/
|
|
418
452
|
tt = function(t, r) {
|
|
419
|
-
if (t ===
|
|
453
|
+
if (t === u.Completed || t === u.Failed || t === u.Skipped)
|
|
420
454
|
return !1;
|
|
421
455
|
const i = e(this, x)[t];
|
|
422
456
|
return e(this, x)[r] > i;
|
|
423
457
|
};
|
|
424
|
-
var
|
|
458
|
+
var o, D, T, q, U, P, R, B, et;
|
|
425
459
|
class V {
|
|
426
460
|
/**
|
|
427
461
|
* Creates a new FlowRun instance
|
|
@@ -429,85 +463,85 @@ class V {
|
|
|
429
463
|
* @param initialState - Initial state for the run
|
|
430
464
|
*/
|
|
431
465
|
constructor(t) {
|
|
432
|
-
d(this,
|
|
433
|
-
d(this,
|
|
434
|
-
d(this,
|
|
435
|
-
d(this,
|
|
466
|
+
d(this, R);
|
|
467
|
+
d(this, o);
|
|
468
|
+
d(this, D, L());
|
|
469
|
+
d(this, T, /* @__PURE__ */ new Map());
|
|
436
470
|
d(this, q, {
|
|
437
|
-
[
|
|
438
|
-
[
|
|
439
|
-
[
|
|
471
|
+
[h.Started]: 0,
|
|
472
|
+
[h.Completed]: 1,
|
|
473
|
+
[h.Failed]: 2
|
|
440
474
|
});
|
|
441
475
|
d(this, U, !1);
|
|
442
476
|
// Track number of listeners
|
|
443
|
-
d(this,
|
|
444
|
-
|
|
477
|
+
d(this, P, 0);
|
|
478
|
+
_(this, o, t);
|
|
445
479
|
}
|
|
446
480
|
/**
|
|
447
481
|
* Get the run ID
|
|
448
482
|
*/
|
|
449
483
|
get run_id() {
|
|
450
|
-
return e(this,
|
|
484
|
+
return e(this, o).run_id;
|
|
451
485
|
}
|
|
452
486
|
/**
|
|
453
487
|
* Get the flow slug
|
|
454
488
|
*/
|
|
455
489
|
get flow_slug() {
|
|
456
|
-
return e(this,
|
|
490
|
+
return e(this, o).flow_slug;
|
|
457
491
|
}
|
|
458
492
|
/**
|
|
459
493
|
* Get the current status
|
|
460
494
|
*/
|
|
461
495
|
get status() {
|
|
462
|
-
return e(this,
|
|
496
|
+
return e(this, o).status;
|
|
463
497
|
}
|
|
464
498
|
/**
|
|
465
499
|
* Get the started_at timestamp
|
|
466
500
|
*/
|
|
467
501
|
get started_at() {
|
|
468
|
-
return e(this,
|
|
502
|
+
return e(this, o).started_at;
|
|
469
503
|
}
|
|
470
504
|
/**
|
|
471
505
|
* Get the completed_at timestamp
|
|
472
506
|
*/
|
|
473
507
|
get completed_at() {
|
|
474
|
-
return e(this,
|
|
508
|
+
return e(this, o).completed_at;
|
|
475
509
|
}
|
|
476
510
|
/**
|
|
477
511
|
* Get the failed_at timestamp
|
|
478
512
|
*/
|
|
479
513
|
get failed_at() {
|
|
480
|
-
return e(this,
|
|
514
|
+
return e(this, o).failed_at;
|
|
481
515
|
}
|
|
482
516
|
/**
|
|
483
517
|
* Get the flow input
|
|
484
518
|
*/
|
|
485
519
|
get input() {
|
|
486
|
-
return e(this,
|
|
520
|
+
return e(this, o).input;
|
|
487
521
|
}
|
|
488
522
|
/**
|
|
489
523
|
* Get the flow output
|
|
490
524
|
*/
|
|
491
525
|
get output() {
|
|
492
|
-
return e(this,
|
|
526
|
+
return e(this, o).output;
|
|
493
527
|
}
|
|
494
528
|
/**
|
|
495
529
|
* Get the error object
|
|
496
530
|
*/
|
|
497
531
|
get error() {
|
|
498
|
-
return e(this,
|
|
532
|
+
return e(this, o).error;
|
|
499
533
|
}
|
|
500
534
|
/**
|
|
501
535
|
* Get the error message
|
|
502
536
|
*/
|
|
503
537
|
get error_message() {
|
|
504
|
-
return e(this,
|
|
538
|
+
return e(this, o).error_message;
|
|
505
539
|
}
|
|
506
540
|
/**
|
|
507
541
|
* Get the number of remaining steps
|
|
508
542
|
*/
|
|
509
543
|
get remaining_steps() {
|
|
510
|
-
return e(this,
|
|
544
|
+
return e(this, o).remaining_steps;
|
|
511
545
|
}
|
|
512
546
|
/**
|
|
513
547
|
* Register an event handler for a run event
|
|
@@ -517,10 +551,10 @@ class V {
|
|
|
517
551
|
* @returns Function to unsubscribe from the event
|
|
518
552
|
*/
|
|
519
553
|
on(t, r) {
|
|
520
|
-
|
|
521
|
-
const i = e(this,
|
|
554
|
+
j(this, P)._++;
|
|
555
|
+
const i = e(this, D).on(t, r);
|
|
522
556
|
return () => {
|
|
523
|
-
i(),
|
|
557
|
+
i(), j(this, P)._--, m(this, R, B).call(this);
|
|
524
558
|
};
|
|
525
559
|
}
|
|
526
560
|
/**
|
|
@@ -530,21 +564,23 @@ class V {
|
|
|
530
564
|
* @returns FlowStep instance for the specified step
|
|
531
565
|
*/
|
|
532
566
|
step(t) {
|
|
533
|
-
const r = e(this,
|
|
567
|
+
const r = e(this, T).get(t);
|
|
534
568
|
if (r)
|
|
535
569
|
return r;
|
|
536
570
|
const i = new it({
|
|
537
571
|
run_id: this.run_id,
|
|
538
572
|
step_slug: t,
|
|
539
|
-
status:
|
|
573
|
+
status: u.Created,
|
|
540
574
|
output: null,
|
|
541
575
|
error: null,
|
|
542
576
|
error_message: null,
|
|
543
577
|
started_at: null,
|
|
544
578
|
completed_at: null,
|
|
545
|
-
failed_at: null
|
|
579
|
+
failed_at: null,
|
|
580
|
+
skipped_at: null,
|
|
581
|
+
skip_reason: null
|
|
546
582
|
});
|
|
547
|
-
return e(this,
|
|
583
|
+
return e(this, T).set(
|
|
548
584
|
t,
|
|
549
585
|
i
|
|
550
586
|
), i;
|
|
@@ -556,7 +592,7 @@ class V {
|
|
|
556
592
|
* @returns true if the step exists, false otherwise
|
|
557
593
|
*/
|
|
558
594
|
hasStep(t) {
|
|
559
|
-
return e(this,
|
|
595
|
+
return e(this, T).has(t);
|
|
560
596
|
}
|
|
561
597
|
/**
|
|
562
598
|
* Wait for the run to reach a specific status
|
|
@@ -568,9 +604,9 @@ class V {
|
|
|
568
604
|
waitForStatus(t, r) {
|
|
569
605
|
const i = (r == null ? void 0 : r.timeoutMs) ?? 3e5, { signal: n } = r || {};
|
|
570
606
|
return this.status === t ? Promise.resolve(this) : new Promise((g, c) => {
|
|
571
|
-
let
|
|
572
|
-
i > 0 && (
|
|
573
|
-
|
|
607
|
+
let l, p = !1;
|
|
608
|
+
i > 0 && (l = setTimeout(() => {
|
|
609
|
+
p || (p = !0, $(), c(
|
|
574
610
|
new Error(
|
|
575
611
|
`Timeout waiting for run ${this.run_id} to reach status '${t}'`
|
|
576
612
|
)
|
|
@@ -578,21 +614,21 @@ class V {
|
|
|
578
614
|
}, i));
|
|
579
615
|
let b;
|
|
580
616
|
if (n) {
|
|
581
|
-
const
|
|
582
|
-
|
|
617
|
+
const S = () => {
|
|
618
|
+
p || (p = !0, l && clearTimeout(l), $(), c(
|
|
583
619
|
new Error(
|
|
584
620
|
`Aborted waiting for run ${this.run_id} to reach status '${t}'`
|
|
585
621
|
)
|
|
586
622
|
));
|
|
587
623
|
};
|
|
588
|
-
n.addEventListener("abort",
|
|
589
|
-
n.removeEventListener("abort",
|
|
624
|
+
n.addEventListener("abort", S), b = () => {
|
|
625
|
+
n.removeEventListener("abort", S);
|
|
590
626
|
};
|
|
591
627
|
}
|
|
592
|
-
const
|
|
593
|
-
if (
|
|
594
|
-
if (
|
|
595
|
-
|
|
628
|
+
const $ = this.on("*", (S) => {
|
|
629
|
+
if (S.status === t) {
|
|
630
|
+
if (p) return;
|
|
631
|
+
p = !0, l && clearTimeout(l), b && b(), $(), g(this);
|
|
596
632
|
}
|
|
597
633
|
});
|
|
598
634
|
});
|
|
@@ -605,7 +641,7 @@ class V {
|
|
|
605
641
|
* Applications should not call this directly.
|
|
606
642
|
*/
|
|
607
643
|
applySnapshot(t) {
|
|
608
|
-
e(this,
|
|
644
|
+
e(this, o).status = t.status, e(this, o).input = t.input, e(this, o).output = t.output, e(this, o).started_at = t.started_at ? new Date(t.started_at) : null, e(this, o).completed_at = t.completed_at ? new Date(t.completed_at) : null, e(this, o).failed_at = t.failed_at ? new Date(t.failed_at) : null, e(this, o).remaining_steps = t.remaining_steps, e(this, o).error_message = null, e(this, o).error = null;
|
|
609
645
|
}
|
|
610
646
|
/**
|
|
611
647
|
* Updates the run state based on an event
|
|
@@ -618,41 +654,41 @@ class V {
|
|
|
618
654
|
* with event emission instead of direct state manipulation.
|
|
619
655
|
*/
|
|
620
656
|
updateState(t) {
|
|
621
|
-
if (t.run_id !== e(this,
|
|
657
|
+
if (t.run_id !== e(this, o).run_id || !m(this, R, et).call(this, e(this, o).status, t.status))
|
|
622
658
|
return !1;
|
|
623
659
|
switch (t.status) {
|
|
624
|
-
case
|
|
625
|
-
|
|
626
|
-
...e(this,
|
|
627
|
-
status:
|
|
660
|
+
case h.Started:
|
|
661
|
+
_(this, o, {
|
|
662
|
+
...e(this, o),
|
|
663
|
+
status: h.Started,
|
|
628
664
|
started_at: typeof t.started_at == "string" ? new Date(t.started_at) : /* @__PURE__ */ new Date(),
|
|
629
|
-
remaining_steps: "remaining_steps" in t ? Number(t.remaining_steps) : e(this,
|
|
630
|
-
}), e(this,
|
|
665
|
+
remaining_steps: "remaining_steps" in t ? Number(t.remaining_steps) : e(this, o).remaining_steps
|
|
666
|
+
}), e(this, D).emit("started", t);
|
|
631
667
|
break;
|
|
632
|
-
case
|
|
633
|
-
|
|
634
|
-
...e(this,
|
|
635
|
-
status:
|
|
668
|
+
case h.Completed:
|
|
669
|
+
_(this, o, {
|
|
670
|
+
...e(this, o),
|
|
671
|
+
status: h.Completed,
|
|
636
672
|
completed_at: typeof t.completed_at == "string" ? new Date(t.completed_at) : /* @__PURE__ */ new Date(),
|
|
637
673
|
output: t.output,
|
|
638
674
|
remaining_steps: 0
|
|
639
|
-
}), e(this,
|
|
675
|
+
}), e(this, D).emit("completed", t), m(this, R, B).call(this);
|
|
640
676
|
break;
|
|
641
|
-
case
|
|
642
|
-
|
|
643
|
-
...e(this,
|
|
644
|
-
status:
|
|
677
|
+
case h.Failed:
|
|
678
|
+
_(this, o, {
|
|
679
|
+
...e(this, o),
|
|
680
|
+
status: h.Failed,
|
|
645
681
|
failed_at: typeof t.failed_at == "string" ? new Date(t.failed_at) : /* @__PURE__ */ new Date(),
|
|
646
682
|
error_message: typeof t.error_message == "string" ? t.error_message : "Unknown error",
|
|
647
683
|
error: new Error(
|
|
648
684
|
typeof t.error_message == "string" ? t.error_message : "Unknown error"
|
|
649
685
|
)
|
|
650
|
-
}), e(this,
|
|
686
|
+
}), e(this, D).emit("failed", t), m(this, R, B).call(this);
|
|
651
687
|
break;
|
|
652
688
|
default:
|
|
653
689
|
return !1;
|
|
654
690
|
}
|
|
655
|
-
return e(this,
|
|
691
|
+
return e(this, D).emit("*", t), !0;
|
|
656
692
|
}
|
|
657
693
|
/**
|
|
658
694
|
* Updates a step state based on an event
|
|
@@ -668,14 +704,14 @@ class V {
|
|
|
668
704
|
* Clean up all resources held by this run
|
|
669
705
|
*/
|
|
670
706
|
dispose() {
|
|
671
|
-
e(this, U) || (e(this,
|
|
707
|
+
e(this, U) || (e(this, T).clear(), _(this, D, L()), _(this, P, 0), _(this, U, !0));
|
|
672
708
|
}
|
|
673
709
|
}
|
|
674
|
-
|
|
710
|
+
o = new WeakMap(), D = new WeakMap(), T = new WeakMap(), q = new WeakMap(), U = new WeakMap(), P = new WeakMap(), R = new WeakSet(), /**
|
|
675
711
|
* Checks if auto-dispose should be triggered (when in terminal state with no listeners)
|
|
676
712
|
*/
|
|
677
713
|
B = function() {
|
|
678
|
-
e(this, U) || this.status !==
|
|
714
|
+
e(this, U) || this.status !== h.Completed && this.status !== h.Failed || e(this, P) === 0 && this.dispose();
|
|
679
715
|
}, /**
|
|
680
716
|
* Determines if a status should be updated based on precedence
|
|
681
717
|
*
|
|
@@ -684,38 +720,38 @@ B = function() {
|
|
|
684
720
|
* @returns true if the status should be updated, false otherwise
|
|
685
721
|
*/
|
|
686
722
|
et = function(t, r) {
|
|
687
|
-
if (t ===
|
|
723
|
+
if (t === h.Completed || t === h.Failed)
|
|
688
724
|
return !1;
|
|
689
725
|
const i = e(this, q)[t];
|
|
690
726
|
return e(this, q)[r] > i;
|
|
691
727
|
};
|
|
692
728
|
function nt(s) {
|
|
693
729
|
switch (s.status) {
|
|
694
|
-
case
|
|
730
|
+
case h.Started:
|
|
695
731
|
return {
|
|
696
732
|
event_type: "run:started",
|
|
697
733
|
run_id: s.run_id,
|
|
698
734
|
flow_slug: s.flow_slug,
|
|
699
|
-
status:
|
|
735
|
+
status: h.Started,
|
|
700
736
|
started_at: s.started_at,
|
|
701
737
|
remaining_steps: s.remaining_steps,
|
|
702
738
|
input: s.input
|
|
703
739
|
};
|
|
704
|
-
case
|
|
740
|
+
case h.Completed:
|
|
705
741
|
return {
|
|
706
742
|
event_type: "run:completed",
|
|
707
743
|
run_id: s.run_id,
|
|
708
744
|
flow_slug: s.flow_slug,
|
|
709
|
-
status:
|
|
745
|
+
status: h.Completed,
|
|
710
746
|
completed_at: s.completed_at,
|
|
711
747
|
output: s.output
|
|
712
748
|
};
|
|
713
|
-
case
|
|
749
|
+
case h.Failed:
|
|
714
750
|
return {
|
|
715
751
|
event_type: "run:failed",
|
|
716
752
|
run_id: s.run_id,
|
|
717
753
|
flow_slug: s.flow_slug,
|
|
718
|
-
status:
|
|
754
|
+
status: h.Failed,
|
|
719
755
|
failed_at: s.failed_at,
|
|
720
756
|
error_message: s.error_message
|
|
721
757
|
};
|
|
@@ -723,36 +759,45 @@ function nt(s) {
|
|
|
723
759
|
}
|
|
724
760
|
function at(s) {
|
|
725
761
|
switch (s.status) {
|
|
726
|
-
case
|
|
762
|
+
case u.Started:
|
|
727
763
|
return {
|
|
728
764
|
event_type: "step:started",
|
|
729
765
|
run_id: s.run_id,
|
|
730
766
|
step_slug: s.step_slug,
|
|
731
|
-
status:
|
|
767
|
+
status: u.Started,
|
|
732
768
|
started_at: s.started_at
|
|
733
769
|
};
|
|
734
|
-
case
|
|
770
|
+
case u.Completed:
|
|
735
771
|
return {
|
|
736
772
|
event_type: "step:completed",
|
|
737
773
|
run_id: s.run_id,
|
|
738
774
|
step_slug: s.step_slug,
|
|
739
|
-
status:
|
|
775
|
+
status: u.Completed,
|
|
740
776
|
completed_at: s.completed_at,
|
|
741
777
|
output: s.output
|
|
742
778
|
};
|
|
743
|
-
case
|
|
779
|
+
case u.Failed:
|
|
744
780
|
return {
|
|
745
781
|
event_type: "step:failed",
|
|
746
782
|
run_id: s.run_id,
|
|
747
783
|
step_slug: s.step_slug,
|
|
748
|
-
status:
|
|
784
|
+
status: u.Failed,
|
|
749
785
|
failed_at: s.failed_at,
|
|
750
786
|
error_message: s.error_message
|
|
751
787
|
};
|
|
788
|
+
case u.Skipped:
|
|
789
|
+
return {
|
|
790
|
+
event_type: "step:skipped",
|
|
791
|
+
run_id: s.run_id,
|
|
792
|
+
step_slug: s.step_slug,
|
|
793
|
+
status: u.Skipped,
|
|
794
|
+
skipped_at: s.skipped_at,
|
|
795
|
+
skip_reason: s.skip_reason
|
|
796
|
+
};
|
|
752
797
|
}
|
|
753
798
|
}
|
|
754
799
|
var z, w, y;
|
|
755
|
-
class
|
|
800
|
+
class wt {
|
|
756
801
|
/**
|
|
757
802
|
* Creates a new PgflowClient instance
|
|
758
803
|
*
|
|
@@ -765,7 +810,7 @@ class gt {
|
|
|
765
810
|
// Use the widest event type - keeps the compiler happy but
|
|
766
811
|
// still provides the structural API we need (updateState/step/...)
|
|
767
812
|
d(this, y, /* @__PURE__ */ new Map());
|
|
768
|
-
|
|
813
|
+
_(this, z, t), _(this, w, new rt(t, {
|
|
769
814
|
stabilizationDelayMs: r.realtimeStabilizationDelayMs,
|
|
770
815
|
schedule: r.schedule
|
|
771
816
|
})), e(this, w).onRunEvent((i) => {
|
|
@@ -791,7 +836,7 @@ class gt {
|
|
|
791
836
|
const n = i || st(), g = {
|
|
792
837
|
run_id: n,
|
|
793
838
|
flow_slug: t,
|
|
794
|
-
status:
|
|
839
|
+
status: h.Started,
|
|
795
840
|
input: r,
|
|
796
841
|
output: null,
|
|
797
842
|
error: null,
|
|
@@ -803,15 +848,15 @@ class gt {
|
|
|
803
848
|
// Use -1 to indicate unknown until first snapshot arrives
|
|
804
849
|
}, c = new V(g);
|
|
805
850
|
e(this, y).set(n, c), await e(this, w).subscribeToRun(n);
|
|
806
|
-
const { data:
|
|
851
|
+
const { data: l, error: p } = await e(this, z).schema("pgflow").rpc("start_flow_with_states", {
|
|
807
852
|
flow_slug: t,
|
|
808
853
|
input: r,
|
|
809
854
|
run_id: n
|
|
810
855
|
});
|
|
811
|
-
if (
|
|
812
|
-
throw this.dispose(n),
|
|
813
|
-
if (
|
|
814
|
-
for (const b of
|
|
856
|
+
if (p)
|
|
857
|
+
throw this.dispose(n), p;
|
|
858
|
+
if (l.run && c.applySnapshot(l.run), l.steps && Array.isArray(l.steps))
|
|
859
|
+
for (const b of l.steps)
|
|
815
860
|
c.step(b.step_slug).applySnapshot(b);
|
|
816
861
|
return c;
|
|
817
862
|
}
|
|
@@ -880,7 +925,7 @@ class gt {
|
|
|
880
925
|
return null;
|
|
881
926
|
if (!i.run_id || !i.flow_slug || !i.status)
|
|
882
927
|
throw new Error("Invalid run data: missing required fields");
|
|
883
|
-
if (!Object.values(
|
|
928
|
+
if (!Object.values(h).includes(i.status))
|
|
884
929
|
throw new Error(`Invalid run data: invalid status '${i.status}'`);
|
|
885
930
|
const c = {
|
|
886
931
|
run_id: i.run_id,
|
|
@@ -894,14 +939,14 @@ class gt {
|
|
|
894
939
|
completed_at: null,
|
|
895
940
|
failed_at: null,
|
|
896
941
|
remaining_steps: 0
|
|
897
|
-
},
|
|
898
|
-
if (
|
|
899
|
-
for (const
|
|
900
|
-
if (!
|
|
942
|
+
}, l = new V(c);
|
|
943
|
+
if (l.applySnapshot(i), e(this, y).set(t, l), await e(this, w).subscribeToRun(t), n && Array.isArray(n))
|
|
944
|
+
for (const p of n) {
|
|
945
|
+
if (!p.step_slug || !p.status)
|
|
901
946
|
throw new Error("Invalid step data: missing required fields");
|
|
902
|
-
|
|
947
|
+
l.step(p.step_slug).applySnapshot(p);
|
|
903
948
|
}
|
|
904
|
-
return
|
|
949
|
+
return l;
|
|
905
950
|
} catch (i) {
|
|
906
951
|
if (console.error("Error getting run:", i), i instanceof Error && (i.message.includes("Invalid run data") || i.message.includes("Invalid step data")))
|
|
907
952
|
throw i;
|
|
@@ -912,17 +957,18 @@ class gt {
|
|
|
912
957
|
z = new WeakMap(), w = new WeakMap(), y = new WeakMap();
|
|
913
958
|
export {
|
|
914
959
|
V as FlowRun,
|
|
915
|
-
|
|
960
|
+
h as FlowRunStatus,
|
|
916
961
|
it as FlowStep,
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
962
|
+
u as FlowStepStatus,
|
|
963
|
+
wt as PgflowClient,
|
|
964
|
+
ct as isFlowRunCompletedEvent,
|
|
965
|
+
pt as isFlowRunEvent,
|
|
921
966
|
ht as isFlowRunFailedEvent,
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
967
|
+
dt as isFlowRunStartedEvent,
|
|
968
|
+
ft as isStepCompletedEvent,
|
|
969
|
+
O as isStepEvent,
|
|
925
970
|
mt as isStepFailedEvent,
|
|
926
|
-
|
|
971
|
+
gt as isStepSkippedEvent,
|
|
972
|
+
_t as isStepStartedEvent
|
|
927
973
|
};
|
|
928
974
|
//# sourceMappingURL=index.js.map
|