@blue-labs/document-processor 1.26.1 → 1.27.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/dist/BlueDocumentProcessor.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.mjs +282 -271
- package/dist/processors/SequentialWorkflowProcessor/utils/ExpressionEvaluator.d.ts +5 -0
- package/dist/processors/SequentialWorkflowProcessor/utils/ExpressionEvaluator.d.ts.map +1 -1
- package/dist/testUtils.d.ts.map +1 -1
- package/dist/utils/checkpoint.d.ts.map +1 -1
- package/dist/utils/document.d.ts +8 -5
- package/dist/utils/document.d.ts.map +1 -1
- package/dist/utils/initialized.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var l = (c, e, t) =>
|
|
4
|
-
import { ProcessEmbeddedSchema as
|
|
5
|
-
import { applyBlueNodePatch as
|
|
6
|
-
import { deepFreeze as
|
|
7
|
-
import { blueIds as
|
|
8
|
-
const
|
|
1
|
+
var he = Object.defineProperty;
|
|
2
|
+
var de = (c, e, t) => e in c ? he(c, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : c[e] = t;
|
|
3
|
+
var l = (c, e, t) => de(c, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { ProcessEmbeddedSchema as q, ChannelEventCheckpointSchema as pe, blueIds as f, InitializedMarkerSchema as me, CompositeTimelineChannelSchema as fe, DocumentUpdateChannelSchema as ye, EmbeddedNodeChannelSchema as J, LifecycleEventSchema as ge, TimelineEntrySchema as I, OperationSchema as Ee, OperationRequestSchema as we, UpdateDocumentSchema as B, TriggerEventSchema as M, JavaScriptCodeSchema as $, SequentialWorkflowSchema as ve, SequentialWorkflowOperationSchema as be, TimelineChannelSchema as Te } from "@blue-repository/core-dev";
|
|
5
|
+
import { applyBlueNodePatch as X, BlueNodeTypeSchema as E, BlueNode as Se, isBigNumber as A } from "@blue-labs/language";
|
|
6
|
+
import { deepFreeze as Pe, isNonNullable as O, deepContains as Y } from "@blue-labs/shared-utils";
|
|
7
|
+
import { blueIds as Z, MyOSTimelineEntrySchema as G, MyOSTimelineChannelSchema as Ce, MyOSAgentEventSchema as ke, MyOSAgentChannelSchema as Ie } from "@blue-repository/myos-dev";
|
|
8
|
+
const Ne = (c, e) => ({
|
|
9
9
|
on: (t, n) => ({ end: () => n(null) })
|
|
10
10
|
});
|
|
11
|
-
async function
|
|
11
|
+
async function Oe(c) {
|
|
12
12
|
return new Promise((e, t) => {
|
|
13
|
-
|
|
13
|
+
Ne().on("error", t).end();
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
|
-
const
|
|
16
|
+
const b = (...c) => c.map((e, t) => {
|
|
17
17
|
if (typeof e != "string") return "";
|
|
18
18
|
if (t === 0 && e === "/") return "/";
|
|
19
19
|
const n = t > 0 ? e.replace(/^\/+/, "") : e;
|
|
20
20
|
return t < c.length - 1 ? n.replace(/\/+$/, "") : n;
|
|
21
21
|
}).filter(Boolean).join("/").replace(/\/{2,}/g, "/");
|
|
22
|
-
class
|
|
22
|
+
class ee {
|
|
23
23
|
constructor(e, t, n, o) {
|
|
24
24
|
l(this, "actions", []);
|
|
25
25
|
this.getDocument = e, this.taskInfo = t, this.blue = n, this.onFlush = o;
|
|
26
26
|
}
|
|
27
27
|
get(e) {
|
|
28
|
-
const t = this.getDocument(), n =
|
|
28
|
+
const t = this.getDocument(), n = b(this.taskInfo.nodePath, e);
|
|
29
29
|
return t.get(n);
|
|
30
30
|
}
|
|
31
31
|
addPatch(e) {
|
|
@@ -33,7 +33,7 @@ class G {
|
|
|
33
33
|
kind: "patch",
|
|
34
34
|
patch: {
|
|
35
35
|
...e,
|
|
36
|
-
path:
|
|
36
|
+
path: b(this.taskInfo.nodePath, e.path)
|
|
37
37
|
}
|
|
38
38
|
});
|
|
39
39
|
}
|
|
@@ -56,7 +56,7 @@ class G {
|
|
|
56
56
|
return this.taskInfo.nodePath;
|
|
57
57
|
}
|
|
58
58
|
resolvePath(e) {
|
|
59
|
-
return
|
|
59
|
+
return b(this.taskInfo.nodePath, e);
|
|
60
60
|
}
|
|
61
61
|
getTaskInfo() {
|
|
62
62
|
return this.taskInfo;
|
|
@@ -68,76 +68,82 @@ class G {
|
|
|
68
68
|
loadExternalModule(e) {
|
|
69
69
|
if (!/^https?:\/\//.test(e))
|
|
70
70
|
throw new Error("Only http/https URLs are allowed");
|
|
71
|
-
return
|
|
71
|
+
return Oe();
|
|
72
72
|
}
|
|
73
73
|
loadBlueContent(e) {
|
|
74
74
|
throw new Error("Not implemented");
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
|
-
class
|
|
77
|
+
class te extends Error {
|
|
78
78
|
constructor(e, t) {
|
|
79
79
|
super(`Cannot apply patch ${JSON.stringify(e)}`), this.patch = e, this.cause = t, this.name = "PatchApplicationError";
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
|
-
class
|
|
82
|
+
class ne extends Error {
|
|
83
83
|
constructor(e, t, n) {
|
|
84
84
|
super(
|
|
85
85
|
`Patch ${JSON.stringify(e)} touches "${e.op === "move" || e.op === "copy" ? `${e.from} → ${e.path}` : e.path}" which is inside embedded document "${t}" (Process Embedded @ "${n}")`
|
|
86
86
|
), this.patch = e, this.offendingPath = t, this.contractNodePath = n, this.name = "EmbeddedDocumentModificationError";
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
|
-
class
|
|
89
|
+
class V extends Error {
|
|
90
90
|
constructor(e, t) {
|
|
91
91
|
super(`Failed to evaluate expression "${e}"`), this.code = e, this.cause = t, this.name = "ExpressionEvaluationError";
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
|
-
class
|
|
94
|
+
class F extends Error {
|
|
95
95
|
constructor(e, t) {
|
|
96
96
|
super(`Failed to evaluate code block "${e}"`), this.code = e, this.cause = t, this.name = "CodeBlockEvaluationError";
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
|
-
function
|
|
99
|
+
function k(c) {
|
|
100
|
+
return Pe(c);
|
|
101
|
+
}
|
|
102
|
+
function N(c) {
|
|
103
|
+
return c.clone();
|
|
104
|
+
}
|
|
105
|
+
function j(c, e, t = "/", n = []) {
|
|
100
106
|
const o = c.getContracts() ?? {};
|
|
101
107
|
for (const [r, a] of Object.entries(o))
|
|
102
108
|
if (E.isTypeOf(
|
|
103
109
|
a,
|
|
104
|
-
|
|
110
|
+
q
|
|
105
111
|
)) {
|
|
106
|
-
const
|
|
112
|
+
const h = e.nodeToSchemaOutput(
|
|
107
113
|
a,
|
|
108
|
-
|
|
114
|
+
q
|
|
109
115
|
).paths ?? [];
|
|
110
|
-
for (const
|
|
116
|
+
for (const u of h)
|
|
111
117
|
n.push({
|
|
112
|
-
absPath:
|
|
113
|
-
contractPath:
|
|
118
|
+
absPath: b(t, u),
|
|
119
|
+
contractPath: b(t, `contracts/${r}`)
|
|
114
120
|
});
|
|
115
121
|
}
|
|
116
122
|
for (const [r, a] of Object.entries(c.getProperties() ?? {}))
|
|
117
|
-
|
|
123
|
+
j(a, e, b(t, r), n);
|
|
118
124
|
return n;
|
|
119
125
|
}
|
|
120
|
-
function
|
|
126
|
+
function L(c, e) {
|
|
121
127
|
return c === e || c.startsWith(e.endsWith("/") ? e : e + "/");
|
|
122
128
|
}
|
|
123
|
-
function
|
|
129
|
+
function U(c, e) {
|
|
124
130
|
if (!e.length) return c;
|
|
125
|
-
let t = c
|
|
131
|
+
let t = N(c);
|
|
126
132
|
for (const n of e)
|
|
127
133
|
try {
|
|
128
|
-
t =
|
|
134
|
+
t = X(t, n, !0);
|
|
129
135
|
} catch (o) {
|
|
130
|
-
throw new
|
|
136
|
+
throw new te(n, o);
|
|
131
137
|
}
|
|
132
|
-
return
|
|
138
|
+
return k(t);
|
|
133
139
|
}
|
|
134
140
|
function m(c) {
|
|
135
141
|
return c != null;
|
|
136
142
|
}
|
|
137
143
|
function S(c) {
|
|
138
|
-
return c instanceof
|
|
144
|
+
return c instanceof Se;
|
|
139
145
|
}
|
|
140
|
-
class
|
|
146
|
+
class Be {
|
|
141
147
|
constructor(e = [], t = (n, o) => n < o ? -1 : n > o ? 1 : 0) {
|
|
142
148
|
l(this, "data");
|
|
143
149
|
l(this, "length");
|
|
@@ -176,14 +182,14 @@ class Ne {
|
|
|
176
182
|
t[e] = r;
|
|
177
183
|
}
|
|
178
184
|
}
|
|
179
|
-
const
|
|
185
|
+
const Me = (c, e, t, n, o, r) => [
|
|
180
186
|
-c,
|
|
181
187
|
e,
|
|
182
188
|
t,
|
|
183
189
|
n,
|
|
184
190
|
o,
|
|
185
191
|
r
|
|
186
|
-
],
|
|
192
|
+
], $e = (c, e) => {
|
|
187
193
|
for (let t = 0; t < c.key.length; t++) {
|
|
188
194
|
const n = c.key[t], o = e.key[t];
|
|
189
195
|
if (n !== o)
|
|
@@ -191,13 +197,13 @@ const Oe = (c, e, t, n, o, r) => [
|
|
|
191
197
|
}
|
|
192
198
|
return 0;
|
|
193
199
|
};
|
|
194
|
-
class
|
|
200
|
+
class qe {
|
|
195
201
|
/**
|
|
196
202
|
* Creates a new task queue with the task key comparator
|
|
197
203
|
*/
|
|
198
204
|
constructor() {
|
|
199
205
|
l(this, "queue");
|
|
200
|
-
this.queue = new
|
|
206
|
+
this.queue = new Be([], $e);
|
|
201
207
|
}
|
|
202
208
|
/**
|
|
203
209
|
* Adds a task to the queue
|
|
@@ -222,7 +228,7 @@ class Me {
|
|
|
222
228
|
return this.queue.length;
|
|
223
229
|
}
|
|
224
230
|
}
|
|
225
|
-
class
|
|
231
|
+
class Ae {
|
|
226
232
|
/**
|
|
227
233
|
* Creates a new contract registry
|
|
228
234
|
*
|
|
@@ -277,7 +283,7 @@ class $e {
|
|
|
277
283
|
return this.processors.values();
|
|
278
284
|
}
|
|
279
285
|
}
|
|
280
|
-
class
|
|
286
|
+
class De {
|
|
281
287
|
constructor() {
|
|
282
288
|
l(this, "isEnabled");
|
|
283
289
|
this.isEnabled = process.env.TRACE_BLUE_ENABLED === "true";
|
|
@@ -344,8 +350,8 @@ class qe {
|
|
|
344
350
|
return this.isEnabled;
|
|
345
351
|
}
|
|
346
352
|
}
|
|
347
|
-
const
|
|
348
|
-
class
|
|
353
|
+
const We = 64;
|
|
354
|
+
class je {
|
|
349
355
|
/**
|
|
350
356
|
* Creates a new event router
|
|
351
357
|
*
|
|
@@ -356,7 +362,7 @@ class De {
|
|
|
356
362
|
*/
|
|
357
363
|
constructor(e, t, n, o, r) {
|
|
358
364
|
l(this, "traceManager");
|
|
359
|
-
this.blue = e, this.registry = t, this.queue = n, this.getNextTaskId = o, this.getNextEventSeq = r, this.traceManager = new
|
|
365
|
+
this.blue = e, this.registry = t, this.queue = n, this.getNextTaskId = o, this.getNextEventSeq = r, this.traceManager = new De();
|
|
360
366
|
}
|
|
361
367
|
/**
|
|
362
368
|
* Routes an event to matching contracts in the document
|
|
@@ -371,15 +377,15 @@ class De {
|
|
|
371
377
|
var i;
|
|
372
378
|
if (n.seq === void 0 && (n.seq = this.getNextEventSeq()), t.length === 0) {
|
|
373
379
|
if (n.dispatchPath) {
|
|
374
|
-
const
|
|
375
|
-
return delete
|
|
380
|
+
const h = n.dispatchPath.split("/").filter(Boolean), u = { ...n };
|
|
381
|
+
return delete u.dispatchPath, this.route(e, h, u, o, r);
|
|
376
382
|
}
|
|
377
383
|
if (n.source === "channel" && n.originNodePath && n.originNodePath !== "/") {
|
|
378
|
-
const
|
|
379
|
-
return this.route(e,
|
|
384
|
+
const h = ((i = n.originNodePath) == null ? void 0 : i.split("/").filter(Boolean)) ?? [];
|
|
385
|
+
return this.route(e, h, n, o, r);
|
|
380
386
|
}
|
|
381
387
|
}
|
|
382
|
-
const a =
|
|
388
|
+
const a = b("/", t.join("/")), s = e.get(a);
|
|
383
389
|
S(s) && await this.traverseContracts({
|
|
384
390
|
doc: e,
|
|
385
391
|
node: s,
|
|
@@ -404,30 +410,30 @@ class De {
|
|
|
404
410
|
inlineDepth: i
|
|
405
411
|
} = e;
|
|
406
412
|
if (!this.shouldSkipForChannel(r, o))
|
|
407
|
-
for (const [
|
|
413
|
+
for (const [h, u] of Object.entries(
|
|
408
414
|
n.getContracts() ?? {}
|
|
409
415
|
)) {
|
|
410
|
-
if (!
|
|
411
|
-
const d = this.registry.get(
|
|
416
|
+
if (!u.getType()) continue;
|
|
417
|
+
const d = this.registry.get(u.getType());
|
|
412
418
|
if (!d) {
|
|
413
|
-
console.warn(`No processor registered for contract: ${
|
|
419
|
+
console.warn(`No processor registered for contract: ${h}`);
|
|
414
420
|
continue;
|
|
415
421
|
}
|
|
416
422
|
const p = {
|
|
417
423
|
nodePath: o,
|
|
418
|
-
contractName:
|
|
419
|
-
contractNode:
|
|
424
|
+
contractName: h,
|
|
425
|
+
contractNode: u,
|
|
420
426
|
event: r
|
|
421
|
-
}, y = new
|
|
422
|
-
if (d.supports(r,
|
|
427
|
+
}, y = new ee(() => t, p, this.blue);
|
|
428
|
+
if (d.supports(r, u, y, h))
|
|
423
429
|
switch (d.role) {
|
|
424
430
|
case "adapter":
|
|
425
431
|
await this.processAdapter({
|
|
426
432
|
cp: d,
|
|
427
433
|
event: r,
|
|
428
|
-
contractNode:
|
|
434
|
+
contractNode: u,
|
|
429
435
|
ctx: y,
|
|
430
|
-
contractName:
|
|
436
|
+
contractName: h,
|
|
431
437
|
doc: t,
|
|
432
438
|
afterTaskId: a,
|
|
433
439
|
inlineDepth: i
|
|
@@ -435,8 +441,8 @@ class De {
|
|
|
435
441
|
break;
|
|
436
442
|
case "handler":
|
|
437
443
|
this.scheduleHandler({
|
|
438
|
-
contractNode:
|
|
439
|
-
contractName:
|
|
444
|
+
contractNode: u,
|
|
445
|
+
contractName: h,
|
|
440
446
|
nodePath: o,
|
|
441
447
|
event: r,
|
|
442
448
|
depth: s.length,
|
|
@@ -459,24 +465,24 @@ class De {
|
|
|
459
465
|
contractName: a,
|
|
460
466
|
doc: s,
|
|
461
467
|
afterTaskId: i,
|
|
462
|
-
inlineDepth:
|
|
468
|
+
inlineDepth: h
|
|
463
469
|
} = e;
|
|
464
|
-
if (
|
|
470
|
+
if (h >= We)
|
|
465
471
|
throw new Error("Adapter recursion limit reached");
|
|
466
|
-
const
|
|
472
|
+
const u = this.traceManager.addHop(
|
|
467
473
|
n,
|
|
468
474
|
((w = r.getTaskInfo()) == null ? void 0 : w.nodePath) ?? "",
|
|
469
475
|
a
|
|
470
476
|
);
|
|
471
|
-
await t.handle(
|
|
477
|
+
await t.handle(u, o, r, a);
|
|
472
478
|
const d = await r.flush();
|
|
473
|
-
if (d.find((
|
|
479
|
+
if (d.find((T) => T.kind === "patch"))
|
|
474
480
|
throw new Error(
|
|
475
481
|
`Contract "${a}" (adapter) attempted to patch the document`
|
|
476
482
|
);
|
|
477
|
-
const y = d.filter((
|
|
478
|
-
for (const
|
|
479
|
-
await this.route(s, [],
|
|
483
|
+
const y = d.filter((T) => T.kind === "event");
|
|
484
|
+
for (const T of y)
|
|
485
|
+
await this.route(s, [], T.event, i, h + 1);
|
|
480
486
|
}
|
|
481
487
|
/**
|
|
482
488
|
* Schedules a handler contract for future execution
|
|
@@ -487,10 +493,10 @@ class De {
|
|
|
487
493
|
console.warn(`Contract node type is not defined for: ${n}`);
|
|
488
494
|
return;
|
|
489
495
|
}
|
|
490
|
-
const
|
|
496
|
+
const h = this.registry.orderOf(i), u = t.get("/order"), d = A(u) ? u.toNumber() : 0, p = this.getNextTaskId() + s, y = Me(
|
|
491
497
|
a,
|
|
492
498
|
r.seq,
|
|
493
|
-
|
|
499
|
+
h,
|
|
494
500
|
d,
|
|
495
501
|
n,
|
|
496
502
|
p
|
|
@@ -510,19 +516,19 @@ class De {
|
|
|
510
516
|
return e.source === "channel" && !!e.originNodePath && e.originNodePath !== t;
|
|
511
517
|
}
|
|
512
518
|
}
|
|
513
|
-
const
|
|
514
|
-
(t instanceof
|
|
519
|
+
const xe = (c, e, t) => {
|
|
520
|
+
(t instanceof te || t instanceof ne) && console.error(
|
|
515
521
|
`[Blue] Failed to apply patches for contract "${c}" on event ${JSON.stringify(e)}`,
|
|
516
522
|
t
|
|
517
523
|
);
|
|
518
524
|
};
|
|
519
|
-
function
|
|
520
|
-
const t = c
|
|
525
|
+
function _(c, e) {
|
|
526
|
+
const t = N(c), n = (o) => {
|
|
521
527
|
if (!S(o)) return;
|
|
522
528
|
const r = o.getContracts();
|
|
523
529
|
(!(r != null && r.checkpoint) || !E.isTypeOf(
|
|
524
530
|
r.checkpoint,
|
|
525
|
-
|
|
531
|
+
pe
|
|
526
532
|
)) && o.addContract(
|
|
527
533
|
"checkpoint",
|
|
528
534
|
e.jsonValueToNode({
|
|
@@ -535,15 +541,15 @@ function U(c, e) {
|
|
|
535
541
|
);
|
|
536
542
|
};
|
|
537
543
|
n(t);
|
|
538
|
-
for (const { absPath: o } of
|
|
544
|
+
for (const { absPath: o } of j(t, e)) {
|
|
539
545
|
const r = t.get(o);
|
|
540
546
|
S(r) && n(r);
|
|
541
547
|
}
|
|
542
|
-
return
|
|
548
|
+
return k(t);
|
|
543
549
|
}
|
|
544
|
-
function
|
|
545
|
-
const t = c
|
|
546
|
-
return S(t)
|
|
550
|
+
function Je(c, e) {
|
|
551
|
+
const t = N(c);
|
|
552
|
+
return S(t) && (oe(t, e) || t.addContract(
|
|
547
553
|
"initialized",
|
|
548
554
|
e.jsonValueToNode({
|
|
549
555
|
type: {
|
|
@@ -551,17 +557,17 @@ function je(c, e) {
|
|
|
551
557
|
blueId: f["Initialized Marker"]
|
|
552
558
|
}
|
|
553
559
|
})
|
|
554
|
-
),
|
|
560
|
+
)), k(t);
|
|
555
561
|
}
|
|
556
|
-
function
|
|
562
|
+
function oe(c, e) {
|
|
557
563
|
const t = c.getContracts();
|
|
558
564
|
return Object.values(t ?? {}).some(
|
|
559
|
-
(n) => e.isTypeOf(n,
|
|
565
|
+
(n) => e.isTypeOf(n, me, {
|
|
560
566
|
checkSchemaExtensions: !0
|
|
561
567
|
})
|
|
562
568
|
);
|
|
563
569
|
}
|
|
564
|
-
class
|
|
570
|
+
class Ve {
|
|
565
571
|
constructor(e) {
|
|
566
572
|
l(this, "contractType", "Channel Event Checkpoint");
|
|
567
573
|
l(this, "contractBlueId", f["Channel Event Checkpoint"]);
|
|
@@ -579,8 +585,8 @@ class xe {
|
|
|
579
585
|
this.cache.record(r, e, o);
|
|
580
586
|
}
|
|
581
587
|
}
|
|
582
|
-
const
|
|
583
|
-
class
|
|
588
|
+
const z = (c, e) => c.get(e) !== void 0;
|
|
589
|
+
class Fe {
|
|
584
590
|
constructor() {
|
|
585
591
|
l(this, "firstSeen", /* @__PURE__ */ new Map());
|
|
586
592
|
}
|
|
@@ -593,13 +599,13 @@ class Je {
|
|
|
593
599
|
const t = [];
|
|
594
600
|
for (const { docBase: n, event: o, eventBlueId: r } of this.firstSeen.values()) {
|
|
595
601
|
if (!o.channelName) continue;
|
|
596
|
-
const a =
|
|
602
|
+
const a = b(
|
|
597
603
|
n,
|
|
598
604
|
"contracts/checkpoint/lastEvents",
|
|
599
605
|
o.channelName
|
|
600
606
|
), s = `${a}/blueId`;
|
|
601
|
-
|
|
602
|
-
op:
|
|
607
|
+
z(e, a) ? t.push({
|
|
608
|
+
op: z(e, s) ? "replace" : "add",
|
|
603
609
|
path: s,
|
|
604
610
|
val: r
|
|
605
611
|
}) : t.push({
|
|
@@ -626,14 +632,14 @@ class P {
|
|
|
626
632
|
return e.source !== "channel";
|
|
627
633
|
}
|
|
628
634
|
}
|
|
629
|
-
class
|
|
635
|
+
class Le extends P {
|
|
630
636
|
constructor() {
|
|
631
637
|
super(...arguments);
|
|
632
638
|
l(this, "contractType", "Composite Timeline Channel");
|
|
633
639
|
l(this, "contractBlueId", f["Composite Timeline Channel"]);
|
|
634
640
|
}
|
|
635
641
|
supports(t, n, o) {
|
|
636
|
-
const r = o.getBlue().nodeToSchemaOutput(n,
|
|
642
|
+
const r = o.getBlue().nodeToSchemaOutput(n, fe);
|
|
637
643
|
return !r.channels || !t.channelName ? !1 : r.channels.includes(t.channelName);
|
|
638
644
|
}
|
|
639
645
|
handle(t, n, o, r) {
|
|
@@ -644,7 +650,7 @@ class Ve extends P {
|
|
|
644
650
|
});
|
|
645
651
|
}
|
|
646
652
|
}
|
|
647
|
-
class
|
|
653
|
+
class Ue extends P {
|
|
648
654
|
constructor() {
|
|
649
655
|
super(...arguments);
|
|
650
656
|
l(this, "contractType", "Document Update Channel");
|
|
@@ -652,10 +658,10 @@ class Fe extends P {
|
|
|
652
658
|
}
|
|
653
659
|
supports(t, n, o, r) {
|
|
654
660
|
if (!this.baseSupports(t)) return !1;
|
|
655
|
-
const a = o.getBlue().nodeToSchemaOutput(n,
|
|
661
|
+
const a = o.getBlue().nodeToSchemaOutput(n, ye), s = t.payload.get("/path");
|
|
656
662
|
if (!s || t.channelName === r) return !1;
|
|
657
663
|
const i = a.path;
|
|
658
|
-
return
|
|
664
|
+
return O(i) && s === o.resolvePath(i);
|
|
659
665
|
}
|
|
660
666
|
handle(t, n, o, r) {
|
|
661
667
|
const a = t.payload;
|
|
@@ -666,7 +672,7 @@ class Fe extends P {
|
|
|
666
672
|
});
|
|
667
673
|
}
|
|
668
674
|
}
|
|
669
|
-
class
|
|
675
|
+
class _e extends P {
|
|
670
676
|
constructor() {
|
|
671
677
|
super(...arguments);
|
|
672
678
|
l(this, "contractType", "Embedded Node Channel");
|
|
@@ -674,11 +680,11 @@ class Le extends P {
|
|
|
674
680
|
}
|
|
675
681
|
supports(t, n, o) {
|
|
676
682
|
if (!this.baseSupports(t)) return !1;
|
|
677
|
-
const r = o.getBlue().nodeToSchemaOutput(n,
|
|
683
|
+
const r = o.getBlue().nodeToSchemaOutput(n, J);
|
|
678
684
|
return m(t.originNodePath) && m(r.path) && t.originNodePath === o.resolvePath(r.path);
|
|
679
685
|
}
|
|
680
686
|
handle(t, n, o, r) {
|
|
681
|
-
const a = o.getBlue().nodeToSchemaOutput(n,
|
|
687
|
+
const a = o.getBlue().nodeToSchemaOutput(n, J), { originNodePath: s, payload: i } = t;
|
|
682
688
|
m(a.path) && s === o.resolvePath(a.path) && o.emitEvent({
|
|
683
689
|
payload: i,
|
|
684
690
|
channelName: r,
|
|
@@ -686,7 +692,7 @@ class Le extends P {
|
|
|
686
692
|
});
|
|
687
693
|
}
|
|
688
694
|
}
|
|
689
|
-
class
|
|
695
|
+
class ze {
|
|
690
696
|
constructor() {
|
|
691
697
|
l(this, "contractType", "Initialized Marker");
|
|
692
698
|
l(this, "contractBlueId", f["Initialized Marker"]);
|
|
@@ -698,7 +704,7 @@ class Ue {
|
|
|
698
704
|
handle() {
|
|
699
705
|
}
|
|
700
706
|
}
|
|
701
|
-
class
|
|
707
|
+
class He extends P {
|
|
702
708
|
constructor() {
|
|
703
709
|
super(...arguments);
|
|
704
710
|
l(this, "contractType", "Lifecycle Event Channel");
|
|
@@ -719,7 +725,7 @@ class _e extends P {
|
|
|
719
725
|
*/
|
|
720
726
|
isLifecycleEvent(t, n) {
|
|
721
727
|
const o = n.getBlue(), r = t.payload;
|
|
722
|
-
return o.isTypeOf(r,
|
|
728
|
+
return o.isTypeOf(r, ge, {
|
|
723
729
|
checkSchemaExtensions: !0
|
|
724
730
|
});
|
|
725
731
|
}
|
|
@@ -732,45 +738,45 @@ class _e extends P {
|
|
|
732
738
|
if (!r)
|
|
733
739
|
return !0;
|
|
734
740
|
try {
|
|
735
|
-
const s = o.getBlue(), i = s.nodeToJson(t.payload),
|
|
736
|
-
return
|
|
741
|
+
const s = o.getBlue(), i = s.nodeToJson(t.payload), h = s.nodeToJson(r);
|
|
742
|
+
return Y(i, h);
|
|
737
743
|
} catch (s) {
|
|
738
744
|
return console.warn("Error during lifecycle event pattern matching:", s), !1;
|
|
739
745
|
}
|
|
740
746
|
}
|
|
741
747
|
}
|
|
742
|
-
const
|
|
748
|
+
const H = (c, e) => {
|
|
743
749
|
const t = e.getBlue();
|
|
744
|
-
return t.isTypeOf(c.payload,
|
|
750
|
+
return t.isTypeOf(c.payload, I) || t.isTypeOf(c.payload, G);
|
|
745
751
|
};
|
|
746
|
-
class
|
|
752
|
+
class Re extends P {
|
|
747
753
|
constructor() {
|
|
748
754
|
super(...arguments);
|
|
749
755
|
l(this, "contractType", "MyOS Timeline Channel");
|
|
750
|
-
l(this, "contractBlueId",
|
|
756
|
+
l(this, "contractBlueId", Z["MyOS Timeline Channel"]);
|
|
751
757
|
}
|
|
752
758
|
supports(t, n, o) {
|
|
753
759
|
var p;
|
|
754
|
-
if (!this.baseSupports(t) || !
|
|
760
|
+
if (!this.baseSupports(t) || !H(t, o)) return !1;
|
|
755
761
|
const a = o.getBlue().nodeToSchemaOutput(
|
|
756
762
|
t.payload,
|
|
757
|
-
|
|
758
|
-
), s = o.getBlue().nodeToSchemaOutput(n,
|
|
759
|
-
return
|
|
763
|
+
G
|
|
764
|
+
), s = o.getBlue().nodeToSchemaOutput(n, Ce), i = (p = a.timeline) == null ? void 0 : p.timelineId, h = m(s.timelineId) && m(i), u = m(s.account) && m(a.account), d = m(s.email) && m(a.email);
|
|
765
|
+
return h && i === s.timelineId || u && a.account === s.account || d && a.email === s.email;
|
|
760
766
|
}
|
|
761
767
|
handle(t, n, o, r) {
|
|
762
|
-
|
|
768
|
+
H(t, o) && o.emitEvent({
|
|
763
769
|
payload: t.payload,
|
|
764
770
|
channelName: r,
|
|
765
771
|
source: "channel"
|
|
766
772
|
});
|
|
767
773
|
}
|
|
768
774
|
}
|
|
769
|
-
class
|
|
775
|
+
class Qe extends P {
|
|
770
776
|
constructor() {
|
|
771
777
|
super(...arguments);
|
|
772
778
|
l(this, "contractType", "MyOS Agent Channel");
|
|
773
|
-
l(this, "contractBlueId",
|
|
779
|
+
l(this, "contractBlueId", Z["MyOS Agent Channel"]);
|
|
774
780
|
}
|
|
775
781
|
supports(t, n, o) {
|
|
776
782
|
if (!this.baseSupports(t)) return !1;
|
|
@@ -799,10 +805,10 @@ class He extends P {
|
|
|
799
805
|
parseEventAndChannel(t, n, o) {
|
|
800
806
|
const r = o.getBlue(), a = r.nodeToSchemaOutput(
|
|
801
807
|
t.payload,
|
|
802
|
-
|
|
808
|
+
ke
|
|
803
809
|
), s = r.nodeToSchemaOutput(
|
|
804
810
|
n,
|
|
805
|
-
|
|
811
|
+
Ie
|
|
806
812
|
);
|
|
807
813
|
return { myosAgentEvent: a, myosAgentChannel: s };
|
|
808
814
|
}
|
|
@@ -838,21 +844,21 @@ class He extends P {
|
|
|
838
844
|
if (!a)
|
|
839
845
|
return !1;
|
|
840
846
|
try {
|
|
841
|
-
const s = o.getBlue(), i = s.nodeToJson(a),
|
|
842
|
-
return
|
|
847
|
+
const s = o.getBlue(), i = s.nodeToJson(a), h = s.nodeToJson(r);
|
|
848
|
+
return Y(i, h);
|
|
843
849
|
} catch (s) {
|
|
844
850
|
return console.warn("Error during event pattern matching:", s), !1;
|
|
845
851
|
}
|
|
846
852
|
}
|
|
847
853
|
}
|
|
848
|
-
class
|
|
854
|
+
class Ke {
|
|
849
855
|
constructor() {
|
|
850
856
|
l(this, "contractType", "Operation");
|
|
851
857
|
l(this, "contractBlueId", f.Operation);
|
|
852
858
|
l(this, "role", "adapter");
|
|
853
859
|
}
|
|
854
860
|
supports(e, t, n, o) {
|
|
855
|
-
const a = n.getBlue().nodeToSchemaOutput(t,
|
|
861
|
+
const a = n.getBlue().nodeToSchemaOutput(t, Ee), s = this.parseEventPayload(e, n);
|
|
856
862
|
return m(s == null ? void 0 : s.operation) && s.operation === o && e.source === "channel" && e.channelName === a.channel;
|
|
857
863
|
}
|
|
858
864
|
async handle(e, t, n, o) {
|
|
@@ -864,23 +870,23 @@ class Re {
|
|
|
864
870
|
}
|
|
865
871
|
parseEventPayload(e, t) {
|
|
866
872
|
const n = t.getBlue();
|
|
867
|
-
if (n.isTypeOf(e.payload,
|
|
873
|
+
if (n.isTypeOf(e.payload, I, {
|
|
868
874
|
checkSchemaExtensions: !0
|
|
869
875
|
})) {
|
|
870
876
|
const o = n.nodeToSchemaOutput(
|
|
871
877
|
e.payload,
|
|
872
|
-
|
|
878
|
+
I
|
|
873
879
|
);
|
|
874
880
|
if (o.message)
|
|
875
881
|
return n.nodeToSchemaOutput(
|
|
876
882
|
o.message,
|
|
877
|
-
|
|
883
|
+
we
|
|
878
884
|
);
|
|
879
885
|
}
|
|
880
886
|
return null;
|
|
881
887
|
}
|
|
882
888
|
}
|
|
883
|
-
class
|
|
889
|
+
class Xe {
|
|
884
890
|
constructor() {
|
|
885
891
|
l(this, "contractType", "Process Embedded");
|
|
886
892
|
l(this, "role", "adapter");
|
|
@@ -890,7 +896,7 @@ class Qe {
|
|
|
890
896
|
return e.source !== "channel";
|
|
891
897
|
}
|
|
892
898
|
handle(e, t, n) {
|
|
893
|
-
const o = n.getBlue().nodeToSchemaOutput(t,
|
|
899
|
+
const o = n.getBlue().nodeToSchemaOutput(t, q);
|
|
894
900
|
for (const r of o.paths ?? [])
|
|
895
901
|
n.emitEvent({
|
|
896
902
|
...e,
|
|
@@ -898,18 +904,18 @@ class Qe {
|
|
|
898
904
|
});
|
|
899
905
|
}
|
|
900
906
|
}
|
|
901
|
-
const
|
|
907
|
+
const re = !process.env.SKIP_ISOLATED_VM;
|
|
902
908
|
let v = null;
|
|
903
|
-
if (
|
|
909
|
+
if (re)
|
|
904
910
|
try {
|
|
905
911
|
v = require("isolated-vm");
|
|
906
912
|
} catch {
|
|
907
913
|
console.warn("isolated-vm not available, using fallback evaluation method");
|
|
908
914
|
}
|
|
909
|
-
function
|
|
915
|
+
function R(c) {
|
|
910
916
|
return /\bimport\s.+\sfrom\s+['"][^'"]+['"]/.test(c) || /\bexport\s+/.test(c);
|
|
911
917
|
}
|
|
912
|
-
class
|
|
918
|
+
class D {
|
|
913
919
|
/**
|
|
914
920
|
* Main evaluation method - chooses between secure and simple evaluation strategies
|
|
915
921
|
*/
|
|
@@ -919,14 +925,14 @@ class A {
|
|
|
919
925
|
bindings: n = {},
|
|
920
926
|
options: o = {}
|
|
921
927
|
}) {
|
|
922
|
-
return !v || !
|
|
928
|
+
return !v || !re ? this.evaluateSimple(e, n, o) : this.evaluateSecure(e, n, t, o);
|
|
923
929
|
}
|
|
924
930
|
/**
|
|
925
931
|
* Fallback evaluation using Node's Function constructor
|
|
926
932
|
* Used when isolated-vm is not available
|
|
927
933
|
*/
|
|
928
934
|
static async evaluateSimple(e, t, n = {}) {
|
|
929
|
-
if (
|
|
935
|
+
if (R(e))
|
|
930
936
|
throw new Error(
|
|
931
937
|
"Static import/export syntax requires isolated-vm – start Node without SKIP_ISOLATED_VM."
|
|
932
938
|
);
|
|
@@ -947,7 +953,7 @@ class A {
|
|
|
947
953
|
`return ${e};`
|
|
948
954
|
)(...Object.values(t));
|
|
949
955
|
} catch (o) {
|
|
950
|
-
throw n.isCodeBlock ? new
|
|
956
|
+
throw n.isCodeBlock ? new F(e, o) : new V(e, o);
|
|
951
957
|
}
|
|
952
958
|
}
|
|
953
959
|
/**
|
|
@@ -958,27 +964,28 @@ class A {
|
|
|
958
964
|
const r = new v.Isolate({ memoryLimit: 32 }), a = await r.createContext(), s = a.global;
|
|
959
965
|
try {
|
|
960
966
|
await this.setupIsolateEnvironment(s, t);
|
|
961
|
-
const i = /* @__PURE__ */ new Map(),
|
|
967
|
+
const i = /* @__PURE__ */ new Map(), h = this.createModuleResolver(
|
|
962
968
|
r,
|
|
963
969
|
a,
|
|
964
970
|
i,
|
|
965
971
|
n
|
|
966
972
|
);
|
|
967
|
-
|
|
973
|
+
let u;
|
|
974
|
+
return R(e) ? u = await this.evaluateESModule(
|
|
968
975
|
r,
|
|
969
976
|
a,
|
|
970
977
|
e,
|
|
971
978
|
o,
|
|
972
|
-
|
|
973
|
-
) : await this.evaluateSimpleScript(
|
|
979
|
+
h
|
|
980
|
+
) : u = await this.evaluateSimpleScript(
|
|
974
981
|
r,
|
|
975
982
|
a,
|
|
976
983
|
e,
|
|
977
984
|
t,
|
|
978
985
|
o
|
|
979
|
-
);
|
|
986
|
+
), this.deepClone(u);
|
|
980
987
|
} catch (i) {
|
|
981
|
-
throw o.isCodeBlock ? new
|
|
988
|
+
throw o.isCodeBlock ? new F(e, i) : new V(e, i);
|
|
982
989
|
} finally {
|
|
983
990
|
a.release(), r.dispose();
|
|
984
991
|
}
|
|
@@ -1010,11 +1017,11 @@ class A {
|
|
|
1010
1017
|
throw new Error(
|
|
1011
1018
|
`ProcessingContext is missing a loadBlueContent(blueId) implementation (needed for ${r})`
|
|
1012
1019
|
);
|
|
1013
|
-
const i = await s(a),
|
|
1014
|
-
return n.set(r,
|
|
1020
|
+
const i = await s(a), h = await e.compileModule(i);
|
|
1021
|
+
return n.set(r, h), await h.instantiate(
|
|
1015
1022
|
t,
|
|
1016
1023
|
this.createModuleResolver(e, t, n, o)
|
|
1017
|
-
),
|
|
1024
|
+
), h;
|
|
1018
1025
|
}
|
|
1019
1026
|
if (/^https?:\/\//.test(r)) {
|
|
1020
1027
|
let a;
|
|
@@ -1037,7 +1044,7 @@ class A {
|
|
|
1037
1044
|
* Evaluate code as a simple script (no imports/exports)
|
|
1038
1045
|
*/
|
|
1039
1046
|
static async evaluateSimpleScript(e, t, n, o, r) {
|
|
1040
|
-
const a = Object.keys(o).join(", "), s = Object.keys(o).map((
|
|
1047
|
+
const a = Object.keys(o).join(", "), s = Object.keys(o).map((u) => u), i = `(async (${a}) => { ${r.isCodeBlock ? n : `return (${n});`} })(${s.join(", ")})`;
|
|
1041
1048
|
return await (await e.compileScript(i)).run(t, {
|
|
1042
1049
|
timeout: r.timeout ?? 500,
|
|
1043
1050
|
promise: !0,
|
|
@@ -1051,12 +1058,12 @@ class A {
|
|
|
1051
1058
|
static async evaluateESModule(e, t, n, o, r) {
|
|
1052
1059
|
let a = n;
|
|
1053
1060
|
if (o.isCodeBlock) {
|
|
1054
|
-
const
|
|
1061
|
+
const h = /^\s*(import\s.+?;|export\s.+?;)/gm, u = (n.match(h) || []).join(
|
|
1055
1062
|
`
|
|
1056
1063
|
`
|
|
1057
|
-
), d = n.replace(
|
|
1064
|
+
), d = n.replace(h, "").trim();
|
|
1058
1065
|
a = `
|
|
1059
|
-
${
|
|
1066
|
+
${u}
|
|
1060
1067
|
const run = function() {
|
|
1061
1068
|
${d}
|
|
1062
1069
|
};
|
|
@@ -1076,24 +1083,31 @@ class A {
|
|
|
1076
1083
|
release: !0
|
|
1077
1084
|
});
|
|
1078
1085
|
}
|
|
1086
|
+
/**
|
|
1087
|
+
* Deep clones a value by serializing and deserializing it to/from JSON,
|
|
1088
|
+
* which strips any isolate-specific object references.
|
|
1089
|
+
*/
|
|
1090
|
+
static deepClone(e) {
|
|
1091
|
+
return typeof e > "u" ? e : JSON.parse(JSON.stringify(e));
|
|
1092
|
+
}
|
|
1079
1093
|
}
|
|
1080
|
-
class
|
|
1094
|
+
class W {
|
|
1081
1095
|
/**
|
|
1082
1096
|
* Creates standard bindings for workflow step execution
|
|
1083
1097
|
*/
|
|
1084
1098
|
static createStandardBindings(e, t, n) {
|
|
1085
|
-
const o = e.getBlue(), r = o.nodeToJson(t.payload, "simple"), a =
|
|
1099
|
+
const o = e.getBlue(), r = o.nodeToJson(t.payload, "simple"), a = A(r) ? r.toNumber() : r;
|
|
1086
1100
|
return {
|
|
1087
1101
|
document: (s) => {
|
|
1088
1102
|
const i = e.get(s);
|
|
1089
|
-
return
|
|
1103
|
+
return A(i) ? i.toNumber() : S(i) ? o.nodeToJson(i, "original") : i;
|
|
1090
1104
|
},
|
|
1091
1105
|
event: a,
|
|
1092
1106
|
steps: n
|
|
1093
1107
|
};
|
|
1094
1108
|
}
|
|
1095
1109
|
}
|
|
1096
|
-
function
|
|
1110
|
+
function Q(c, e) {
|
|
1097
1111
|
const { op: t, path: n, val: o, from: r } = c;
|
|
1098
1112
|
if ((t === "move" || t === "copy") && !r)
|
|
1099
1113
|
throw new Error(`${t} operation requires 'from' path`);
|
|
@@ -1106,35 +1120,35 @@ function R(c, e) {
|
|
|
1106
1120
|
};
|
|
1107
1121
|
return o !== void 0 && (a.val = o), r !== void 0 && (a.from = r), e.jsonValueToNode(a);
|
|
1108
1122
|
}
|
|
1109
|
-
function
|
|
1123
|
+
function Ye(c) {
|
|
1110
1124
|
return c.jsonValueToNode({
|
|
1111
1125
|
type: "Document Processing Initiated"
|
|
1112
1126
|
});
|
|
1113
1127
|
}
|
|
1114
|
-
class
|
|
1128
|
+
class Ze {
|
|
1115
1129
|
constructor() {
|
|
1116
1130
|
l(this, "stepType", "Update Document");
|
|
1117
1131
|
}
|
|
1118
1132
|
supports(e) {
|
|
1119
|
-
return E.isTypeOf(e,
|
|
1133
|
+
return E.isTypeOf(e, B);
|
|
1120
1134
|
}
|
|
1121
1135
|
async execute(e, t, n, o, r) {
|
|
1122
1136
|
const a = n.getBlue();
|
|
1123
|
-
if (!E.isTypeOf(e,
|
|
1137
|
+
if (!E.isTypeOf(e, B)) return;
|
|
1124
1138
|
const s = await this.evaluateChangeset(
|
|
1125
1139
|
e.get("/changeset"),
|
|
1126
1140
|
n,
|
|
1127
1141
|
t,
|
|
1128
1142
|
r
|
|
1129
|
-
), i =
|
|
1143
|
+
), i = X(e, {
|
|
1130
1144
|
op: "replace",
|
|
1131
1145
|
path: "/changeset",
|
|
1132
1146
|
val: s
|
|
1133
|
-
}),
|
|
1134
|
-
for (const
|
|
1135
|
-
if (!
|
|
1136
|
-
const d =
|
|
1137
|
-
if ((
|
|
1147
|
+
}), h = n.getBlue().nodeToSchemaOutput(i, B);
|
|
1148
|
+
for (const u of h.changeset ?? []) {
|
|
1149
|
+
if (!u.path) continue;
|
|
1150
|
+
const d = u.val;
|
|
1151
|
+
if ((u.op === "replace" || u.op === "add") && O(d)) {
|
|
1138
1152
|
const p = await this.evaluateChangeValue(
|
|
1139
1153
|
d,
|
|
1140
1154
|
n,
|
|
@@ -1142,25 +1156,25 @@ class Xe {
|
|
|
1142
1156
|
r
|
|
1143
1157
|
);
|
|
1144
1158
|
n.addPatch({
|
|
1145
|
-
op:
|
|
1146
|
-
path:
|
|
1159
|
+
op: u.op,
|
|
1160
|
+
path: u.path,
|
|
1147
1161
|
val: p
|
|
1148
1162
|
}), n.emitEvent({
|
|
1149
|
-
payload:
|
|
1163
|
+
payload: Q(
|
|
1150
1164
|
{
|
|
1151
|
-
op:
|
|
1152
|
-
path: n.resolvePath(
|
|
1165
|
+
op: u.op,
|
|
1166
|
+
path: n.resolvePath(u.path),
|
|
1153
1167
|
val: a.nodeToJson(p, "original")
|
|
1154
1168
|
},
|
|
1155
1169
|
a
|
|
1156
1170
|
)
|
|
1157
1171
|
});
|
|
1158
1172
|
}
|
|
1159
|
-
|
|
1160
|
-
payload:
|
|
1173
|
+
u.op === "remove" && (n.addPatch({ op: u.op, path: u.path }), n.emitEvent({
|
|
1174
|
+
payload: Q(
|
|
1161
1175
|
{
|
|
1162
|
-
op:
|
|
1163
|
-
path: n.resolvePath(
|
|
1176
|
+
op: u.op,
|
|
1177
|
+
path: n.resolvePath(u.path),
|
|
1164
1178
|
val: null
|
|
1165
1179
|
},
|
|
1166
1180
|
a
|
|
@@ -1171,10 +1185,10 @@ class Xe {
|
|
|
1171
1185
|
async evaluateChangeset(e, t, n, o) {
|
|
1172
1186
|
const r = t.getBlue();
|
|
1173
1187
|
if (typeof e == "string" && e.startsWith("${") && e.endsWith("}")) {
|
|
1174
|
-
const a = e.slice(2, -1), s = await
|
|
1188
|
+
const a = e.slice(2, -1), s = await D.evaluate({
|
|
1175
1189
|
code: a,
|
|
1176
1190
|
ctx: t,
|
|
1177
|
-
bindings:
|
|
1191
|
+
bindings: W.createStandardBindings(
|
|
1178
1192
|
t,
|
|
1179
1193
|
n,
|
|
1180
1194
|
o
|
|
@@ -1189,10 +1203,10 @@ class Xe {
|
|
|
1189
1203
|
async evaluateChangeValue(e, t, n, o) {
|
|
1190
1204
|
const r = e.getValue(), a = t.getBlue();
|
|
1191
1205
|
if (typeof r == "string" && r.startsWith("${") && r.endsWith("}")) {
|
|
1192
|
-
const s = r.slice(2, -1), i = await
|
|
1206
|
+
const s = r.slice(2, -1), i = await D.evaluate({
|
|
1193
1207
|
code: s,
|
|
1194
1208
|
ctx: t,
|
|
1195
|
-
bindings:
|
|
1209
|
+
bindings: W.createStandardBindings(
|
|
1196
1210
|
t,
|
|
1197
1211
|
n,
|
|
1198
1212
|
o
|
|
@@ -1203,67 +1217,64 @@ class Xe {
|
|
|
1203
1217
|
return e;
|
|
1204
1218
|
}
|
|
1205
1219
|
}
|
|
1206
|
-
class
|
|
1220
|
+
class Ge {
|
|
1207
1221
|
constructor() {
|
|
1208
1222
|
l(this, "stepType", "Trigger Event");
|
|
1209
1223
|
}
|
|
1210
1224
|
supports(e) {
|
|
1211
|
-
return E.isTypeOf(e,
|
|
1225
|
+
return E.isTypeOf(e, M);
|
|
1212
1226
|
}
|
|
1213
1227
|
async execute(e, t, n) {
|
|
1214
1228
|
const o = n.getBlue();
|
|
1215
|
-
if (!E.isTypeOf(e,
|
|
1216
|
-
const r = o.nodeToSchemaOutput(e,
|
|
1229
|
+
if (!E.isTypeOf(e, M)) return;
|
|
1230
|
+
const r = o.nodeToSchemaOutput(e, M);
|
|
1217
1231
|
r.event && n.emitEvent({
|
|
1218
1232
|
payload: r.event
|
|
1219
1233
|
});
|
|
1220
1234
|
}
|
|
1221
1235
|
}
|
|
1222
|
-
class
|
|
1236
|
+
class et {
|
|
1223
1237
|
constructor() {
|
|
1224
1238
|
l(this, "stepType", "JavaScript Code");
|
|
1225
1239
|
}
|
|
1226
1240
|
supports(e) {
|
|
1227
|
-
return E.isTypeOf(e,
|
|
1241
|
+
return E.isTypeOf(e, $);
|
|
1228
1242
|
}
|
|
1229
1243
|
async execute(e, t, n, o, r) {
|
|
1230
|
-
if (!E.isTypeOf(e,
|
|
1244
|
+
if (!E.isTypeOf(e, $)) return;
|
|
1231
1245
|
const a = n.getBlue(), s = a.nodeToSchemaOutput(
|
|
1232
1246
|
e,
|
|
1233
|
-
|
|
1247
|
+
$
|
|
1234
1248
|
);
|
|
1235
1249
|
if (!s.code)
|
|
1236
1250
|
throw new Error("JavaScript code is required");
|
|
1237
|
-
const i = await
|
|
1251
|
+
const i = await D.evaluate({
|
|
1238
1252
|
code: s.code,
|
|
1239
1253
|
ctx: n,
|
|
1240
|
-
bindings:
|
|
1254
|
+
bindings: W.createStandardBindings(n, t, r),
|
|
1241
1255
|
options: {
|
|
1242
1256
|
isCodeBlock: !0,
|
|
1243
1257
|
timeout: 500
|
|
1244
1258
|
}
|
|
1245
1259
|
});
|
|
1246
1260
|
if (i && typeof i == "object" && "events" in i) {
|
|
1247
|
-
const
|
|
1248
|
-
if (Array.isArray(
|
|
1249
|
-
for (const
|
|
1261
|
+
const h = i;
|
|
1262
|
+
if (Array.isArray(h.events))
|
|
1263
|
+
for (const u of h.events)
|
|
1250
1264
|
n.emitEvent({
|
|
1251
|
-
payload: a.jsonValueToNode(
|
|
1265
|
+
payload: a.jsonValueToNode(u)
|
|
1252
1266
|
});
|
|
1253
1267
|
}
|
|
1254
1268
|
return i;
|
|
1255
1269
|
}
|
|
1256
1270
|
}
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
new Xe(),
|
|
1262
|
-
new Ye(),
|
|
1263
|
-
new Ze()
|
|
1271
|
+
const tt = [
|
|
1272
|
+
new Ze(),
|
|
1273
|
+
new Ge(),
|
|
1274
|
+
new et()
|
|
1264
1275
|
];
|
|
1265
|
-
class
|
|
1266
|
-
constructor(e =
|
|
1276
|
+
class ae {
|
|
1277
|
+
constructor(e = tt) {
|
|
1267
1278
|
l(this, "contractType", "Sequential Workflow");
|
|
1268
1279
|
l(this, "contractBlueId", f["Sequential Workflow"]);
|
|
1269
1280
|
l(this, "role", "handler");
|
|
@@ -1277,46 +1288,46 @@ class re {
|
|
|
1277
1288
|
supports(e, t, n) {
|
|
1278
1289
|
const a = n.getBlue().nodeToSchemaOutput(
|
|
1279
1290
|
t,
|
|
1280
|
-
|
|
1291
|
+
ve
|
|
1281
1292
|
).channel;
|
|
1282
1293
|
return e.source === "channel" && e.channelName === a;
|
|
1283
1294
|
}
|
|
1284
1295
|
async handle(e, t, n, o) {
|
|
1285
1296
|
var s;
|
|
1286
1297
|
const r = {}, a = (s = t.getProperties()) == null ? void 0 : s.steps.getItems();
|
|
1287
|
-
for (const [i,
|
|
1288
|
-
const
|
|
1289
|
-
if (!
|
|
1290
|
-
throw new Error(`Unsupported workflow step type "${
|
|
1291
|
-
const d = await
|
|
1292
|
-
|
|
1298
|
+
for (const [i, h] of (a ?? []).entries()) {
|
|
1299
|
+
const u = this.executors.find((p) => p.supports(h));
|
|
1300
|
+
if (!u)
|
|
1301
|
+
throw new Error(`Unsupported workflow step type "${h.getType()}"`);
|
|
1302
|
+
const d = await u.execute(
|
|
1303
|
+
h,
|
|
1293
1304
|
e,
|
|
1294
1305
|
n,
|
|
1295
1306
|
o,
|
|
1296
1307
|
r
|
|
1297
1308
|
);
|
|
1298
1309
|
if (d !== void 0) {
|
|
1299
|
-
const p =
|
|
1310
|
+
const p = h.getName(), y = typeof p == "string" ? p : `Step${i + 1}`;
|
|
1300
1311
|
r[y] = d;
|
|
1301
1312
|
}
|
|
1302
1313
|
await n.flush();
|
|
1303
1314
|
}
|
|
1304
1315
|
}
|
|
1305
1316
|
}
|
|
1306
|
-
class
|
|
1317
|
+
class nt {
|
|
1307
1318
|
constructor(e) {
|
|
1308
1319
|
l(this, "contractType", "Sequential Workflow Operation");
|
|
1309
1320
|
l(this, "contractBlueId", f["Sequential Workflow Operation"]);
|
|
1310
1321
|
l(this, "role", "handler");
|
|
1311
1322
|
l(this, "sequentialWorkflowProcessor");
|
|
1312
|
-
this.sequentialWorkflowProcessor = e || new
|
|
1323
|
+
this.sequentialWorkflowProcessor = e || new ae();
|
|
1313
1324
|
}
|
|
1314
1325
|
supports(e, t, n) {
|
|
1315
1326
|
const a = n.getBlue().nodeToSchemaOutput(
|
|
1316
1327
|
t,
|
|
1317
|
-
|
|
1328
|
+
be
|
|
1318
1329
|
).operation, s = e.channelName;
|
|
1319
|
-
return e.source === "channel" &&
|
|
1330
|
+
return e.source === "channel" && O(s) && O(a) && s === a;
|
|
1320
1331
|
}
|
|
1321
1332
|
async handle(e, t, n, o) {
|
|
1322
1333
|
try {
|
|
@@ -1329,68 +1340,68 @@ class tt {
|
|
|
1329
1340
|
}
|
|
1330
1341
|
}
|
|
1331
1342
|
}
|
|
1332
|
-
const
|
|
1333
|
-
class
|
|
1343
|
+
const K = (c) => E.isTypeOf(c.payload, I);
|
|
1344
|
+
class ot extends P {
|
|
1334
1345
|
constructor() {
|
|
1335
1346
|
super(...arguments);
|
|
1336
1347
|
l(this, "contractType", "Timeline Channel");
|
|
1337
1348
|
l(this, "contractBlueId", f["Timeline Channel"]);
|
|
1338
1349
|
}
|
|
1339
1350
|
supports(t, n, o) {
|
|
1340
|
-
var
|
|
1341
|
-
if (!this.baseSupports(t) || !
|
|
1351
|
+
var u;
|
|
1352
|
+
if (!this.baseSupports(t) || !K(t)) return !1;
|
|
1342
1353
|
const a = o.getBlue().nodeToSchemaOutput(
|
|
1343
1354
|
t.payload,
|
|
1344
|
-
|
|
1345
|
-
), s = o.getBlue().nodeToSchemaOutput(n, Te), i = (
|
|
1355
|
+
I
|
|
1356
|
+
), s = o.getBlue().nodeToSchemaOutput(n, Te), i = (u = a.timeline) == null ? void 0 : u.timelineId;
|
|
1346
1357
|
return m(s.timelineId) && m(i) && i === s.timelineId;
|
|
1347
1358
|
}
|
|
1348
1359
|
handle(t, n, o, r) {
|
|
1349
|
-
|
|
1360
|
+
K(t) && o.emitEvent({
|
|
1350
1361
|
payload: t.payload,
|
|
1351
1362
|
channelName: r,
|
|
1352
1363
|
source: "channel"
|
|
1353
1364
|
});
|
|
1354
1365
|
}
|
|
1355
1366
|
}
|
|
1356
|
-
const
|
|
1357
|
-
new
|
|
1367
|
+
const rt = [
|
|
1368
|
+
new Xe(),
|
|
1358
1369
|
// channels
|
|
1359
|
-
new Le(),
|
|
1360
|
-
new Fe(),
|
|
1361
|
-
new nt(),
|
|
1362
|
-
new ze(),
|
|
1363
|
-
new He(),
|
|
1364
|
-
new Ve(),
|
|
1365
1370
|
new _e(),
|
|
1371
|
+
new Ue(),
|
|
1372
|
+
new ot(),
|
|
1366
1373
|
new Re(),
|
|
1374
|
+
new Qe(),
|
|
1375
|
+
new Le(),
|
|
1376
|
+
new He(),
|
|
1377
|
+
new Ke(),
|
|
1367
1378
|
// sequential workflows
|
|
1368
|
-
new
|
|
1369
|
-
new
|
|
1379
|
+
new ae(),
|
|
1380
|
+
new nt(),
|
|
1370
1381
|
// markers
|
|
1371
|
-
new
|
|
1382
|
+
new ze()
|
|
1372
1383
|
];
|
|
1373
|
-
class
|
|
1384
|
+
class ht {
|
|
1374
1385
|
/**
|
|
1375
1386
|
* Creates a new document processor
|
|
1376
1387
|
*
|
|
1377
1388
|
* @param processors - Initial list of processors to register
|
|
1378
1389
|
*/
|
|
1379
|
-
constructor(e, t =
|
|
1390
|
+
constructor(e, t = rt) {
|
|
1380
1391
|
l(this, "taskCounter", 0);
|
|
1381
1392
|
l(this, "eventCounter", 0);
|
|
1382
1393
|
l(this, "registry");
|
|
1383
1394
|
l(this, "queue");
|
|
1384
1395
|
l(this, "router");
|
|
1385
|
-
l(this, "checkpointCache", new
|
|
1386
|
-
this.blue = e, this.registry = new
|
|
1396
|
+
l(this, "checkpointCache", new Fe());
|
|
1397
|
+
this.blue = e, this.registry = new Ae(t), this.queue = new qe(), this.router = new je(
|
|
1387
1398
|
this.blue,
|
|
1388
1399
|
this.registry,
|
|
1389
1400
|
this.queue,
|
|
1390
1401
|
() => ++this.taskCounter,
|
|
1391
1402
|
() => ++this.eventCounter
|
|
1392
1403
|
), this.register(
|
|
1393
|
-
new
|
|
1404
|
+
new Ve(this.checkpointCache),
|
|
1394
1405
|
9999
|
|
1395
1406
|
);
|
|
1396
1407
|
}
|
|
@@ -1410,13 +1421,13 @@ class ut {
|
|
|
1410
1421
|
* @returns Processing result with final state and emitted events
|
|
1411
1422
|
*/
|
|
1412
1423
|
async initialize(e) {
|
|
1413
|
-
let t =
|
|
1424
|
+
let t = _(k(e), this.blue);
|
|
1414
1425
|
const n = {
|
|
1415
|
-
payload:
|
|
1426
|
+
payload: Ye(this.blue)
|
|
1416
1427
|
}, o = [n.payload];
|
|
1417
1428
|
await this.router.route(t, [], n, 0);
|
|
1418
1429
|
const r = await this.drainQueue(t);
|
|
1419
|
-
return t = r.state, o.push(...r.emitted), t =
|
|
1430
|
+
return t = r.state, o.push(...r.emitted), t = Je(t, this.blue), { state: N(t), emitted: o };
|
|
1420
1431
|
}
|
|
1421
1432
|
/**
|
|
1422
1433
|
* Processes a batch of events against the document
|
|
@@ -1426,9 +1437,9 @@ class ut {
|
|
|
1426
1437
|
* @returns Processing result with final state and emitted events
|
|
1427
1438
|
*/
|
|
1428
1439
|
async processEvents(e, t) {
|
|
1429
|
-
let n =
|
|
1440
|
+
let n = _(k(e), this.blue);
|
|
1430
1441
|
const o = [];
|
|
1431
|
-
if (!
|
|
1442
|
+
if (!oe(n, this.blue))
|
|
1432
1443
|
throw new Error("Document is not initialized");
|
|
1433
1444
|
for (const r of t)
|
|
1434
1445
|
try {
|
|
@@ -1437,11 +1448,11 @@ class ut {
|
|
|
1437
1448
|
const s = await this.drainQueue(n);
|
|
1438
1449
|
n = s.state, o.push(...s.emitted);
|
|
1439
1450
|
const i = this.checkpointCache.flush(n);
|
|
1440
|
-
i.length && (n =
|
|
1451
|
+
i.length && (n = U(n, i));
|
|
1441
1452
|
} finally {
|
|
1442
1453
|
this.checkpointCache.clear();
|
|
1443
1454
|
}
|
|
1444
|
-
return { state: n, emitted: o };
|
|
1455
|
+
return { state: N(n), emitted: o };
|
|
1445
1456
|
}
|
|
1446
1457
|
/**
|
|
1447
1458
|
* Drains the task queue and applies all actions
|
|
@@ -1454,61 +1465,61 @@ class ut {
|
|
|
1454
1465
|
for (; this.queue.length; ) {
|
|
1455
1466
|
if (++r > o)
|
|
1456
1467
|
throw new Error("Possible cycle – too many iterations");
|
|
1457
|
-
const s = this.queue.pop(), { nodePath: i, contractName:
|
|
1458
|
-
if (!S(p) || !((a = p.getContracts()) != null && a[
|
|
1459
|
-
const y = this.registry.get(
|
|
1468
|
+
const s = this.queue.pop(), { nodePath: i, contractName: h, contractNode: u, event: d } = s, p = t.get(i);
|
|
1469
|
+
if (!S(p) || !((a = p.getContracts()) != null && a[h]) || !u.getType()) continue;
|
|
1470
|
+
const y = this.registry.get(u.getType());
|
|
1460
1471
|
if (!y) {
|
|
1461
|
-
console.warn(`No processor registered for contract: ${
|
|
1472
|
+
console.warn(`No processor registered for contract: ${h}`);
|
|
1462
1473
|
continue;
|
|
1463
1474
|
}
|
|
1464
|
-
const w = new
|
|
1475
|
+
const w = new ee(
|
|
1465
1476
|
() => t,
|
|
1466
1477
|
s,
|
|
1467
1478
|
this.blue,
|
|
1468
|
-
async (
|
|
1469
|
-
for (const g of
|
|
1479
|
+
async (T) => {
|
|
1480
|
+
for (const g of T)
|
|
1470
1481
|
if (g.kind === "patch") {
|
|
1471
|
-
const
|
|
1472
|
-
for (const C of
|
|
1473
|
-
const
|
|
1474
|
-
(
|
|
1475
|
-
),
|
|
1476
|
-
|
|
1482
|
+
const se = j(t, this.blue);
|
|
1483
|
+
for (const C of se) {
|
|
1484
|
+
const ce = g.patch.op === "move" || g.patch.op === "copy" ? [g.patch.from, g.patch.path] : [g.patch.path], x = w.getNodePath(), ie = ce.some(
|
|
1485
|
+
(ue) => L(ue, C.absPath)
|
|
1486
|
+
), le = L(
|
|
1487
|
+
x,
|
|
1477
1488
|
C.absPath
|
|
1478
1489
|
);
|
|
1479
|
-
if (
|
|
1480
|
-
throw new
|
|
1490
|
+
if (ie && !le)
|
|
1491
|
+
throw new ne(
|
|
1481
1492
|
g.patch,
|
|
1482
1493
|
C.absPath,
|
|
1483
|
-
|
|
1494
|
+
x
|
|
1484
1495
|
);
|
|
1485
1496
|
}
|
|
1486
1497
|
try {
|
|
1487
|
-
t =
|
|
1498
|
+
t = U(t, [g.patch]);
|
|
1488
1499
|
} catch (C) {
|
|
1489
|
-
throw
|
|
1500
|
+
throw xe(h, d, C), C;
|
|
1490
1501
|
}
|
|
1491
1502
|
} else g.kind === "event" && (n.push(g.event.payload), await this.router.route(t, [], g.event, s.key[5]));
|
|
1492
1503
|
}
|
|
1493
1504
|
);
|
|
1494
|
-
await y.handle(d,
|
|
1505
|
+
await y.handle(d, u, w, h), await w.flush();
|
|
1495
1506
|
}
|
|
1496
1507
|
return { state: t, emitted: n };
|
|
1497
1508
|
}
|
|
1498
1509
|
}
|
|
1499
1510
|
export {
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1511
|
+
ht as BlueDocumentProcessor,
|
|
1512
|
+
Ve as ChannelEventCheckpointProcessor,
|
|
1513
|
+
Le as CompositeTimelineChannelProcessor,
|
|
1514
|
+
Ue as DocumentUpdateChannelProcessor,
|
|
1515
|
+
_e as EmbeddedNodeChannelProcessor,
|
|
1516
|
+
ze as InitializedMarkerProcessor,
|
|
1517
|
+
He as LifecycleEventChannelProcessor,
|
|
1518
|
+
Qe as MyOSAgentChannelProcessor,
|
|
1519
|
+
Re as MyOSTimelineChannelProcessor,
|
|
1520
|
+
Ke as OperationProcessor,
|
|
1521
|
+
Xe as ProcessEmbeddedProcessor,
|
|
1522
|
+
nt as SequentialWorkflowOperationProcessor,
|
|
1523
|
+
ae as SequentialWorkflowProcessor,
|
|
1524
|
+
ot as TimelineChannelProcessor
|
|
1514
1525
|
};
|