@blue-labs/document-processor 1.33.0 → 1.33.2
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/index.mjs
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var l = (a, e, t) =>
|
|
4
|
-
import { ProcessEmbeddedSchema as W, ChannelEventCheckpointSchema as
|
|
5
|
-
import { applyBlueNodePatch as
|
|
6
|
-
import { deepFreeze as
|
|
7
|
-
import { blueIds as
|
|
8
|
-
const
|
|
1
|
+
var we = Object.defineProperty;
|
|
2
|
+
var ve = (a, e, t) => e in a ? we(a, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[e] = t;
|
|
3
|
+
var l = (a, e, t) => ve(a, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { ProcessEmbeddedSchema as W, ChannelEventCheckpointSchema as Te, blueIds as y, InitializedMarkerSchema as be, CompositeTimelineChannelSchema as Pe, DocumentUpdateChannelSchema as Se, EmbeddedNodeChannelSchema as H, LifecycleEventSchema as Ce, TimelineEntrySchema as O, OperationSchema as Ne, OperationRequestSchema as ke, UpdateDocumentSchema as j, TriggerEventSchema as x, JavaScriptCodeSchema as V, SequentialWorkflowSchema as Ie, SequentialWorkflowOperationSchema as Be, TimelineChannelSchema as Oe } from "@blue-repository/core-dev";
|
|
5
|
+
import { applyBlueNodePatch as re, BlueNode as Me, isBigNumber as L, BlueNodeTypeSchema as P, ResolvedBlueNode as $e, MergingProcessors as k } from "@blue-labs/language";
|
|
6
|
+
import { deepFreeze as qe, isNonNullable as M, deepContains as Ae, isNullable as _ } from "@blue-labs/shared-utils";
|
|
7
|
+
import { blueIds as se, MyOSTimelineEntrySchema as ae, MyOSTimelineChannelSchema as De, MyOSAgentEventSchema as je, MyOSAgentChannelSchema as xe } from "@blue-repository/myos-dev";
|
|
8
|
+
const b = (...a) => a.map((e, t) => {
|
|
9
9
|
if (typeof e != "string") return "";
|
|
10
10
|
if (t === 0 && e === "/") return "/";
|
|
11
11
|
const n = t > 0 ? e.replace(/^\/+/, "") : e;
|
|
12
12
|
return t < a.length - 1 ? n.replace(/\/+$/, "") : n;
|
|
13
13
|
}).filter(Boolean).join("/").replace(/\/{2,}/g, "/");
|
|
14
|
-
class
|
|
14
|
+
class ie {
|
|
15
15
|
constructor(e, t, n, o) {
|
|
16
16
|
l(this, "actions", []);
|
|
17
17
|
this.getDocument = e, this.taskInfo = t, this.blue = n, this.onFlush = o;
|
|
18
18
|
}
|
|
19
19
|
get(e) {
|
|
20
|
-
const t = this.getDocument(), n =
|
|
20
|
+
const t = this.getDocument(), n = b(this.taskInfo.nodePath, e);
|
|
21
21
|
return t.get(n);
|
|
22
22
|
}
|
|
23
23
|
addPatch(e) {
|
|
@@ -25,7 +25,7 @@ class re {
|
|
|
25
25
|
kind: "patch",
|
|
26
26
|
patch: {
|
|
27
27
|
...e,
|
|
28
|
-
path:
|
|
28
|
+
path: b(this.taskInfo.nodePath, e.path)
|
|
29
29
|
}
|
|
30
30
|
});
|
|
31
31
|
}
|
|
@@ -50,7 +50,7 @@ class re {
|
|
|
50
50
|
return this.taskInfo.nodePath;
|
|
51
51
|
}
|
|
52
52
|
resolvePath(e) {
|
|
53
|
-
return
|
|
53
|
+
return b(this.taskInfo.nodePath, e);
|
|
54
54
|
}
|
|
55
55
|
getTaskInfo() {
|
|
56
56
|
return this.taskInfo;
|
|
@@ -69,30 +69,30 @@ class re {
|
|
|
69
69
|
return Promise.resolve(JSON.stringify(this.blue.nodeToJson(t)));
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
|
-
class
|
|
72
|
+
class ce extends Error {
|
|
73
73
|
constructor(e, t) {
|
|
74
74
|
super(`Cannot apply patch ${JSON.stringify(e)}`), this.patch = e, this.cause = t, this.name = "PatchApplicationError";
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
|
-
class
|
|
77
|
+
class le extends Error {
|
|
78
78
|
constructor(e, t, n) {
|
|
79
79
|
super(
|
|
80
80
|
`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}")`
|
|
81
81
|
), this.patch = e, this.offendingPath = t, this.contractNodePath = n, this.name = "EmbeddedDocumentModificationError";
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
|
-
class
|
|
84
|
+
class X extends Error {
|
|
85
85
|
constructor(e, t) {
|
|
86
86
|
super(`Failed to evaluate expression "${e}"`), this.code = e, this.cause = t, this.name = "ExpressionEvaluationError";
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
|
-
class
|
|
89
|
+
class Q extends Error {
|
|
90
90
|
constructor(e, t) {
|
|
91
91
|
super(`Failed to evaluate code block "${e}"`), this.code = e, this.cause = t, this.name = "CodeBlockEvaluationError";
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
function I(a) {
|
|
95
|
-
return
|
|
95
|
+
return qe(a);
|
|
96
96
|
}
|
|
97
97
|
function $(a) {
|
|
98
98
|
return a.clone();
|
|
@@ -107,40 +107,40 @@ function U(a, e, t = "/", n = []) {
|
|
|
107
107
|
).paths ?? [];
|
|
108
108
|
for (const u of h)
|
|
109
109
|
n.push({
|
|
110
|
-
absPath:
|
|
111
|
-
contractPath:
|
|
110
|
+
absPath: b(t, u),
|
|
111
|
+
contractPath: b(t, `contracts/${r}`)
|
|
112
112
|
});
|
|
113
113
|
}
|
|
114
114
|
for (const [r, s] of Object.entries(a.getProperties() ?? {}))
|
|
115
115
|
U(
|
|
116
116
|
s,
|
|
117
117
|
e,
|
|
118
|
-
|
|
118
|
+
b(t, r),
|
|
119
119
|
n
|
|
120
120
|
);
|
|
121
121
|
return n;
|
|
122
122
|
}
|
|
123
|
-
function
|
|
123
|
+
function K(a, e) {
|
|
124
124
|
return a === e || a.startsWith(e.endsWith("/") ? e : e + "/");
|
|
125
125
|
}
|
|
126
|
-
function
|
|
126
|
+
function G(a, e) {
|
|
127
127
|
if (!e.length) return a;
|
|
128
128
|
let t = $(a);
|
|
129
129
|
for (const n of e)
|
|
130
130
|
try {
|
|
131
|
-
t =
|
|
131
|
+
t = re(t, n, !0);
|
|
132
132
|
} catch (o) {
|
|
133
|
-
throw new
|
|
133
|
+
throw new ce(n, o);
|
|
134
134
|
}
|
|
135
135
|
return I(t);
|
|
136
136
|
}
|
|
137
|
-
function
|
|
137
|
+
function g(a) {
|
|
138
138
|
return a != null;
|
|
139
139
|
}
|
|
140
140
|
function S(a) {
|
|
141
|
-
return a instanceof
|
|
141
|
+
return a instanceof Me;
|
|
142
142
|
}
|
|
143
|
-
class
|
|
143
|
+
class Ve {
|
|
144
144
|
constructor(e = [], t = (n, o) => n < o ? -1 : n > o ? 1 : 0) {
|
|
145
145
|
l(this, "data");
|
|
146
146
|
l(this, "length");
|
|
@@ -179,14 +179,14 @@ class xe {
|
|
|
179
179
|
t[e] = r;
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
|
-
const
|
|
182
|
+
const _e = (a, e, t, n, o, r) => [
|
|
183
183
|
-a,
|
|
184
184
|
e,
|
|
185
185
|
t,
|
|
186
186
|
n,
|
|
187
187
|
o,
|
|
188
188
|
r
|
|
189
|
-
],
|
|
189
|
+
], We = (a, e) => {
|
|
190
190
|
for (let t = 0; t < a.key.length; t++) {
|
|
191
191
|
const n = a.key[t], o = e.key[t];
|
|
192
192
|
if (n !== o)
|
|
@@ -194,13 +194,13 @@ const je = (a, e, t, n, o, r) => [
|
|
|
194
194
|
}
|
|
195
195
|
return 0;
|
|
196
196
|
};
|
|
197
|
-
class
|
|
197
|
+
class Le {
|
|
198
198
|
/**
|
|
199
199
|
* Creates a new task queue with the task key comparator
|
|
200
200
|
*/
|
|
201
201
|
constructor() {
|
|
202
202
|
l(this, "queue");
|
|
203
|
-
this.queue = new
|
|
203
|
+
this.queue = new Ve([], We);
|
|
204
204
|
}
|
|
205
205
|
/**
|
|
206
206
|
* Adds a task to the queue
|
|
@@ -225,7 +225,7 @@ class _e {
|
|
|
225
225
|
return this.queue.length;
|
|
226
226
|
}
|
|
227
227
|
}
|
|
228
|
-
class
|
|
228
|
+
class Fe {
|
|
229
229
|
/**
|
|
230
230
|
* Creates a new contract registry
|
|
231
231
|
*
|
|
@@ -345,11 +345,11 @@ const B = class B {
|
|
|
345
345
|
}
|
|
346
346
|
};
|
|
347
347
|
l(B, "MAX_TRACE_LENGTH", 128);
|
|
348
|
-
let
|
|
348
|
+
let F = B;
|
|
349
349
|
function Je(a) {
|
|
350
350
|
return Object.entries(a.getContracts() ?? {});
|
|
351
351
|
}
|
|
352
|
-
const
|
|
352
|
+
const Ue = 64;
|
|
353
353
|
class ze {
|
|
354
354
|
/**
|
|
355
355
|
* Creates a new event router
|
|
@@ -361,7 +361,7 @@ class ze {
|
|
|
361
361
|
*/
|
|
362
362
|
constructor(e, t, n, o, r) {
|
|
363
363
|
l(this, "traceManager");
|
|
364
|
-
this.blue = e, this.registry = t, this.queue = n, this.getNextTaskId = o, this.getNextEventSeq = r, this.traceManager = new
|
|
364
|
+
this.blue = e, this.registry = t, this.queue = n, this.getNextTaskId = o, this.getNextEventSeq = r, this.traceManager = new F();
|
|
365
365
|
}
|
|
366
366
|
/**
|
|
367
367
|
* Routes an event to matching contracts in the document
|
|
@@ -384,7 +384,7 @@ class ze {
|
|
|
384
384
|
return this.route(e, h, n, o, r);
|
|
385
385
|
}
|
|
386
386
|
}
|
|
387
|
-
const s =
|
|
387
|
+
const s = b("/", t.join("/")), i = e.get(s);
|
|
388
388
|
S(i) && await this.traverseContracts({
|
|
389
389
|
doc: e,
|
|
390
390
|
node: i,
|
|
@@ -421,15 +421,15 @@ class ze {
|
|
|
421
421
|
contractName: h,
|
|
422
422
|
contractNode: u,
|
|
423
423
|
event: r
|
|
424
|
-
},
|
|
425
|
-
if (d.supports(r, u,
|
|
424
|
+
}, m = new ie(() => t, p, this.blue);
|
|
425
|
+
if (d.supports(r, u, m, h))
|
|
426
426
|
switch (d.role) {
|
|
427
427
|
case "adapter":
|
|
428
428
|
await this.processAdapter({
|
|
429
429
|
cp: d,
|
|
430
430
|
event: r,
|
|
431
431
|
contractNode: u,
|
|
432
|
-
ctx:
|
|
432
|
+
ctx: m,
|
|
433
433
|
contractName: h,
|
|
434
434
|
doc: t,
|
|
435
435
|
afterTaskId: s,
|
|
@@ -464,7 +464,7 @@ class ze {
|
|
|
464
464
|
afterTaskId: c,
|
|
465
465
|
inlineDepth: h
|
|
466
466
|
} = e;
|
|
467
|
-
if (h >=
|
|
467
|
+
if (h >= Ue)
|
|
468
468
|
throw new Error("Adapter recursion limit reached");
|
|
469
469
|
const u = this.traceManager.addHop(
|
|
470
470
|
n,
|
|
@@ -473,13 +473,13 @@ class ze {
|
|
|
473
473
|
);
|
|
474
474
|
await t.handle(u, o, r, s);
|
|
475
475
|
const d = await r.flush();
|
|
476
|
-
if (d.find((
|
|
476
|
+
if (d.find((E) => E.kind === "patch"))
|
|
477
477
|
throw new Error(
|
|
478
478
|
`Contract "${s}" (adapter) attempted to patch the document`
|
|
479
479
|
);
|
|
480
|
-
const
|
|
481
|
-
for (const
|
|
482
|
-
await this.route(i, [],
|
|
480
|
+
const m = d.filter((E) => E.kind === "event");
|
|
481
|
+
for (const E of m)
|
|
482
|
+
await this.route(i, [], E.event, c, h + 1);
|
|
483
483
|
}
|
|
484
484
|
/**
|
|
485
485
|
* Schedules a handler contract for future execution
|
|
@@ -490,31 +490,31 @@ class ze {
|
|
|
490
490
|
console.warn(`Contract node type is not defined for: ${n}`);
|
|
491
491
|
return;
|
|
492
492
|
}
|
|
493
|
-
const h = this.registry.orderOf(c), u = t.get("/order"), d =
|
|
494
|
-
if (
|
|
493
|
+
const h = this.registry.orderOf(c), u = t.get("/order"), d = L(u) ? u.toNumber() : 0, p = this.getNextTaskId() + i, m = r.seq;
|
|
494
|
+
if (m === void 0)
|
|
495
495
|
throw new Error("Event sequence missing");
|
|
496
|
-
const v =
|
|
496
|
+
const v = _e(
|
|
497
497
|
s,
|
|
498
|
-
|
|
498
|
+
m,
|
|
499
499
|
h,
|
|
500
500
|
d,
|
|
501
501
|
n,
|
|
502
502
|
p
|
|
503
503
|
);
|
|
504
504
|
{
|
|
505
|
-
const
|
|
506
|
-
if (r.source !== "external" && D.includes(
|
|
505
|
+
const f = `${o}#${n}`, D = r.trace ?? [];
|
|
506
|
+
if (r.source !== "external" && D.includes(f))
|
|
507
507
|
throw new Error(
|
|
508
|
-
`Loop detected: repeated hop ${
|
|
508
|
+
`Loop detected: repeated hop ${f} within the same event chain`
|
|
509
509
|
);
|
|
510
510
|
}
|
|
511
|
-
const
|
|
511
|
+
const E = this.traceManager.addHop(r, o, n);
|
|
512
512
|
this.queue.push({
|
|
513
513
|
key: v,
|
|
514
514
|
nodePath: o,
|
|
515
515
|
contractName: n,
|
|
516
516
|
contractNode: t,
|
|
517
|
-
event:
|
|
517
|
+
event: E
|
|
518
518
|
});
|
|
519
519
|
}
|
|
520
520
|
/**
|
|
@@ -524,25 +524,25 @@ class ze {
|
|
|
524
524
|
return e.source === "channel" && !!e.originNodePath && e.originNodePath !== t;
|
|
525
525
|
}
|
|
526
526
|
}
|
|
527
|
-
const
|
|
528
|
-
(t instanceof
|
|
527
|
+
const Re = (a, e, t) => {
|
|
528
|
+
(t instanceof ce || t instanceof le) && console.error(
|
|
529
529
|
`[Blue] Failed to apply patches for contract "${a}" on event ${JSON.stringify(e)}`,
|
|
530
530
|
t
|
|
531
531
|
);
|
|
532
532
|
};
|
|
533
|
-
function
|
|
533
|
+
function Y(a, e) {
|
|
534
534
|
const t = $(a), n = (o) => {
|
|
535
535
|
if (!S(o)) return;
|
|
536
536
|
const r = o.getContracts();
|
|
537
|
-
(!(r != null && r.checkpoint) || !
|
|
537
|
+
(!(r != null && r.checkpoint) || !P.isTypeOf(
|
|
538
538
|
r.checkpoint,
|
|
539
|
-
|
|
539
|
+
Te
|
|
540
540
|
)) && o.addContract(
|
|
541
541
|
"checkpoint",
|
|
542
542
|
e.jsonValueToNode({
|
|
543
543
|
type: {
|
|
544
544
|
name: "Channel Event Checkpoint",
|
|
545
|
-
blueId:
|
|
545
|
+
blueId: y["Channel Event Checkpoint"]
|
|
546
546
|
},
|
|
547
547
|
lastEvents: {}
|
|
548
548
|
})
|
|
@@ -557,28 +557,28 @@ function G(a, e) {
|
|
|
557
557
|
}
|
|
558
558
|
function He(a, e) {
|
|
559
559
|
const t = $(a);
|
|
560
|
-
return S(t) && (
|
|
560
|
+
return S(t) && (ue(t, e) || t.addContract(
|
|
561
561
|
"initialized",
|
|
562
562
|
e.jsonValueToNode({
|
|
563
563
|
type: {
|
|
564
564
|
name: "Initialized Marker",
|
|
565
|
-
blueId:
|
|
565
|
+
blueId: y["Initialized Marker"]
|
|
566
566
|
}
|
|
567
567
|
})
|
|
568
568
|
)), I(t);
|
|
569
569
|
}
|
|
570
|
-
function
|
|
570
|
+
function ue(a, e) {
|
|
571
571
|
const t = a.getContracts();
|
|
572
572
|
return Object.values(t ?? {}).some(
|
|
573
|
-
(n) => e.isTypeOf(n,
|
|
573
|
+
(n) => e.isTypeOf(n, be, {
|
|
574
574
|
checkSchemaExtensions: !0
|
|
575
575
|
})
|
|
576
576
|
);
|
|
577
577
|
}
|
|
578
|
-
class
|
|
578
|
+
class Xe {
|
|
579
579
|
constructor(e) {
|
|
580
580
|
l(this, "contractType", "Channel Event Checkpoint");
|
|
581
|
-
l(this, "contractBlueId",
|
|
581
|
+
l(this, "contractBlueId", y["Channel Event Checkpoint"]);
|
|
582
582
|
l(this, "role", "handler");
|
|
583
583
|
this.cache = e;
|
|
584
584
|
}
|
|
@@ -593,7 +593,7 @@ class Fe {
|
|
|
593
593
|
throw new Error(
|
|
594
594
|
"Cannot calculate blueId for checkpoint: missing root event payload"
|
|
595
595
|
);
|
|
596
|
-
if (n instanceof
|
|
596
|
+
if (n instanceof $e) {
|
|
597
597
|
const r = n.getMinimalNode();
|
|
598
598
|
return await t.getBlue().calculateBlueId(r);
|
|
599
599
|
}
|
|
@@ -606,8 +606,8 @@ class Fe {
|
|
|
606
606
|
this.cache.record(r, e, o);
|
|
607
607
|
}
|
|
608
608
|
}
|
|
609
|
-
const
|
|
610
|
-
class
|
|
609
|
+
const Z = (a, e) => a.get(e) !== void 0;
|
|
610
|
+
class Qe {
|
|
611
611
|
constructor() {
|
|
612
612
|
l(this, "firstSeen", /* @__PURE__ */ new Map());
|
|
613
613
|
}
|
|
@@ -620,13 +620,13 @@ class Re {
|
|
|
620
620
|
const t = [];
|
|
621
621
|
for (const { docBase: n, event: o, eventBlueId: r } of this.firstSeen.values()) {
|
|
622
622
|
if (!o.channelName) continue;
|
|
623
|
-
const s =
|
|
623
|
+
const s = b(
|
|
624
624
|
n,
|
|
625
625
|
"contracts/checkpoint/lastEvents",
|
|
626
626
|
o.channelName
|
|
627
627
|
), i = `${s}/blueId`;
|
|
628
|
-
|
|
629
|
-
op:
|
|
628
|
+
Z(e, s) ? t.push({
|
|
629
|
+
op: Z(e, i) ? "replace" : "add",
|
|
630
630
|
path: i,
|
|
631
631
|
val: r
|
|
632
632
|
}) : t.push({
|
|
@@ -641,14 +641,14 @@ class Re {
|
|
|
641
641
|
this.firstSeen.clear();
|
|
642
642
|
}
|
|
643
643
|
}
|
|
644
|
-
class
|
|
644
|
+
class Ke {
|
|
645
645
|
constructor() {
|
|
646
646
|
l(this, "contractType", "Composite Timeline Channel");
|
|
647
|
-
l(this, "contractBlueId",
|
|
647
|
+
l(this, "contractBlueId", y["Composite Timeline Channel"]);
|
|
648
648
|
l(this, "role", "adapter");
|
|
649
649
|
}
|
|
650
650
|
supports(e, t, n) {
|
|
651
|
-
const o = n.getBlue().nodeToSchemaOutput(t,
|
|
651
|
+
const o = n.getBlue().nodeToSchemaOutput(t, Pe);
|
|
652
652
|
return !o.channels || !e.channelName ? !1 : o.channels.includes(e.channelName);
|
|
653
653
|
}
|
|
654
654
|
handle(e, t, n, o) {
|
|
@@ -671,15 +671,15 @@ class C {
|
|
|
671
671
|
return e.source !== "channel";
|
|
672
672
|
}
|
|
673
673
|
}
|
|
674
|
-
class
|
|
674
|
+
class Ge extends C {
|
|
675
675
|
constructor() {
|
|
676
676
|
super(...arguments);
|
|
677
677
|
l(this, "contractType", "Document Update Channel");
|
|
678
|
-
l(this, "contractBlueId",
|
|
678
|
+
l(this, "contractBlueId", y["Document Update Channel"]);
|
|
679
679
|
}
|
|
680
680
|
supports(t, n, o) {
|
|
681
681
|
if (!this.baseSupports(t) || t.emissionType !== "update") return !1;
|
|
682
|
-
const r = o.getBlue().nodeToSchemaOutput(n,
|
|
682
|
+
const r = o.getBlue().nodeToSchemaOutput(n, Se), s = t.payload.get("/path");
|
|
683
683
|
if (!s) return !1;
|
|
684
684
|
const i = r.path;
|
|
685
685
|
return M(i) && s === o.resolvePath(i);
|
|
@@ -692,30 +692,30 @@ class Qe extends C {
|
|
|
692
692
|
});
|
|
693
693
|
}
|
|
694
694
|
}
|
|
695
|
-
class
|
|
695
|
+
class Ye extends C {
|
|
696
696
|
constructor() {
|
|
697
697
|
super(...arguments);
|
|
698
698
|
l(this, "contractType", "Embedded Node Channel");
|
|
699
|
-
l(this, "contractBlueId",
|
|
699
|
+
l(this, "contractBlueId", y["Embedded Node Channel"]);
|
|
700
700
|
}
|
|
701
701
|
supports(t, n, o) {
|
|
702
702
|
if (!this.baseSupports(t)) return !1;
|
|
703
|
-
const r = o.getBlue().nodeToSchemaOutput(n,
|
|
704
|
-
return
|
|
703
|
+
const r = o.getBlue().nodeToSchemaOutput(n, H);
|
|
704
|
+
return g(t.originNodePath) && g(r.path) && t.originNodePath === o.resolvePath(r.path);
|
|
705
705
|
}
|
|
706
706
|
handle(t, n, o, r) {
|
|
707
|
-
const s = o.getBlue().nodeToSchemaOutput(n,
|
|
708
|
-
|
|
707
|
+
const s = o.getBlue().nodeToSchemaOutput(n, H), { originNodePath: i, payload: c } = t;
|
|
708
|
+
g(s.path) && i === o.resolvePath(s.path) && o.emitEvent({
|
|
709
709
|
payload: c,
|
|
710
710
|
channelName: r,
|
|
711
711
|
source: "channel"
|
|
712
712
|
});
|
|
713
713
|
}
|
|
714
714
|
}
|
|
715
|
-
class
|
|
715
|
+
class Ze {
|
|
716
716
|
constructor() {
|
|
717
717
|
l(this, "contractType", "Initialized Marker");
|
|
718
|
-
l(this, "contractBlueId",
|
|
718
|
+
l(this, "contractBlueId", y["Initialized Marker"]);
|
|
719
719
|
l(this, "role", "marker");
|
|
720
720
|
}
|
|
721
721
|
supports() {
|
|
@@ -724,11 +724,11 @@ class Ke {
|
|
|
724
724
|
handle() {
|
|
725
725
|
}
|
|
726
726
|
}
|
|
727
|
-
class
|
|
727
|
+
class et extends C {
|
|
728
728
|
constructor() {
|
|
729
729
|
super(...arguments);
|
|
730
730
|
l(this, "contractType", "Lifecycle Event Channel");
|
|
731
|
-
l(this, "contractBlueId",
|
|
731
|
+
l(this, "contractBlueId", y["Lifecycle Event Channel"]);
|
|
732
732
|
}
|
|
733
733
|
supports(t, n, o) {
|
|
734
734
|
return !this.baseSupports(t) || t.emissionType !== "lifecycle" || !this.isLifecycleEvent(t, o) ? !1 : this.isEventPatternMatch(t, n, o);
|
|
@@ -746,7 +746,7 @@ class Ye extends C {
|
|
|
746
746
|
*/
|
|
747
747
|
isLifecycleEvent(t, n) {
|
|
748
748
|
const o = n.getBlue(), r = t.payload;
|
|
749
|
-
return o.isTypeOf(r,
|
|
749
|
+
return o.isTypeOf(r, Ce, {
|
|
750
750
|
checkSchemaExtensions: !0
|
|
751
751
|
});
|
|
752
752
|
}
|
|
@@ -766,38 +766,38 @@ class Ye extends C {
|
|
|
766
766
|
}
|
|
767
767
|
}
|
|
768
768
|
}
|
|
769
|
-
const
|
|
769
|
+
const ee = (a, e) => {
|
|
770
770
|
const t = e.getBlue();
|
|
771
|
-
return t.isTypeOf(a.payload, O) || t.isTypeOf(a.payload,
|
|
771
|
+
return t.isTypeOf(a.payload, O) || t.isTypeOf(a.payload, ae);
|
|
772
772
|
};
|
|
773
|
-
class
|
|
773
|
+
class tt extends C {
|
|
774
774
|
constructor() {
|
|
775
775
|
super(...arguments);
|
|
776
776
|
l(this, "contractType", "MyOS Timeline Channel");
|
|
777
|
-
l(this, "contractBlueId",
|
|
777
|
+
l(this, "contractBlueId", se["MyOS Timeline Channel"]);
|
|
778
778
|
}
|
|
779
779
|
supports(t, n, o) {
|
|
780
780
|
var u;
|
|
781
|
-
if (!this.baseSupports(t) || !
|
|
781
|
+
if (!this.baseSupports(t) || !ee(t, o)) return !1;
|
|
782
782
|
const s = o.getBlue().nodeToSchemaOutput(
|
|
783
783
|
t.payload,
|
|
784
|
-
|
|
785
|
-
), i = o.getBlue().nodeToSchemaOutput(n,
|
|
786
|
-
return
|
|
784
|
+
ae
|
|
785
|
+
), i = o.getBlue().nodeToSchemaOutput(n, De), c = (u = s.timeline) == null ? void 0 : u.timelineId;
|
|
786
|
+
return g(i.timelineId) && g(c) && c === i.timelineId;
|
|
787
787
|
}
|
|
788
788
|
handle(t, n, o, r) {
|
|
789
|
-
|
|
789
|
+
ee(t, o) && o.emitEvent({
|
|
790
790
|
payload: t.payload,
|
|
791
791
|
channelName: r,
|
|
792
792
|
source: "channel"
|
|
793
793
|
});
|
|
794
794
|
}
|
|
795
795
|
}
|
|
796
|
-
class
|
|
796
|
+
class nt extends C {
|
|
797
797
|
constructor() {
|
|
798
798
|
super(...arguments);
|
|
799
799
|
l(this, "contractType", "MyOS Agent Channel");
|
|
800
|
-
l(this, "contractBlueId",
|
|
800
|
+
l(this, "contractBlueId", se["MyOS Agent Channel"]);
|
|
801
801
|
}
|
|
802
802
|
supports(t, n, o) {
|
|
803
803
|
if (!this.baseSupports(t)) return !1;
|
|
@@ -826,10 +826,10 @@ class et extends C {
|
|
|
826
826
|
parseEventAndChannel(t, n, o) {
|
|
827
827
|
const r = o.getBlue(), s = r.nodeToSchemaOutput(
|
|
828
828
|
t.payload,
|
|
829
|
-
|
|
829
|
+
je
|
|
830
830
|
), i = r.nodeToSchemaOutput(
|
|
831
831
|
n,
|
|
832
|
-
|
|
832
|
+
xe
|
|
833
833
|
);
|
|
834
834
|
return { myosAgentEvent: s, myosAgentChannel: i };
|
|
835
835
|
}
|
|
@@ -842,7 +842,7 @@ class et extends C {
|
|
|
842
842
|
isAgentMatch(t, n) {
|
|
843
843
|
var s;
|
|
844
844
|
const o = t.agentId, r = (s = n.agent) == null ? void 0 : s.agentId;
|
|
845
|
-
return
|
|
845
|
+
return g(o) && g(r) && o === r;
|
|
846
846
|
}
|
|
847
847
|
/**
|
|
848
848
|
* Checks if the event pattern matches the channel's event filter
|
|
@@ -866,20 +866,20 @@ class et extends C {
|
|
|
866
866
|
return !1;
|
|
867
867
|
try {
|
|
868
868
|
const i = o.getBlue(), c = i.nodeToJson(s), h = i.nodeToJson(r);
|
|
869
|
-
return
|
|
869
|
+
return Ae(c, h);
|
|
870
870
|
} catch (i) {
|
|
871
871
|
return console.warn("Error during event pattern matching:", i), !1;
|
|
872
872
|
}
|
|
873
873
|
}
|
|
874
874
|
}
|
|
875
|
-
class
|
|
875
|
+
class ot {
|
|
876
876
|
constructor() {
|
|
877
877
|
l(this, "contractType", "Operation");
|
|
878
|
-
l(this, "contractBlueId",
|
|
878
|
+
l(this, "contractBlueId", y.Operation);
|
|
879
879
|
l(this, "role", "adapter");
|
|
880
880
|
}
|
|
881
881
|
supports(e, t, n, o) {
|
|
882
|
-
const s = n.getBlue().nodeToSchemaOutput(t,
|
|
882
|
+
const s = n.getBlue().nodeToSchemaOutput(t, Ne), i = this.parseEventPayload(e, n), c = this.isOperationNameMatch(
|
|
883
883
|
i,
|
|
884
884
|
o
|
|
885
885
|
), h = this.isOperationChannelMatch(
|
|
@@ -911,13 +911,13 @@ class tt {
|
|
|
911
911
|
if (o.message)
|
|
912
912
|
return n.nodeToSchemaOutput(
|
|
913
913
|
o.message,
|
|
914
|
-
|
|
914
|
+
ke
|
|
915
915
|
);
|
|
916
916
|
}
|
|
917
917
|
return null;
|
|
918
918
|
}
|
|
919
919
|
isOperationNameMatch(e, t) {
|
|
920
|
-
return
|
|
920
|
+
return g(e == null ? void 0 : e.operation) && (e == null ? void 0 : e.operation) === t;
|
|
921
921
|
}
|
|
922
922
|
isOperationChannelMatch(e, t) {
|
|
923
923
|
const n = t.channel;
|
|
@@ -934,11 +934,11 @@ class tt {
|
|
|
934
934
|
return r.isTypeOfNode(i, o);
|
|
935
935
|
}
|
|
936
936
|
}
|
|
937
|
-
class
|
|
937
|
+
class rt {
|
|
938
938
|
constructor() {
|
|
939
939
|
l(this, "contractType", "Process Embedded");
|
|
940
940
|
l(this, "role", "adapter");
|
|
941
|
-
l(this, "contractBlueId",
|
|
941
|
+
l(this, "contractBlueId", y["Process Embedded"]);
|
|
942
942
|
}
|
|
943
943
|
supports(e) {
|
|
944
944
|
return e.source !== "channel";
|
|
@@ -952,18 +952,40 @@ class nt {
|
|
|
952
952
|
});
|
|
953
953
|
}
|
|
954
954
|
}
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
}
|
|
961
|
-
|
|
955
|
+
const he = !process.env.SKIP_ISOLATED_VM;
|
|
956
|
+
let w = null;
|
|
957
|
+
if (he)
|
|
958
|
+
try {
|
|
959
|
+
w = require("isolated-vm");
|
|
960
|
+
} catch {
|
|
961
|
+
console.warn("isolated-vm not available, using fallback evaluation method");
|
|
962
|
+
}
|
|
963
|
+
function te(a) {
|
|
962
964
|
return /\bimport\s.+\sfrom\s+['"][^'"]+['"]/.test(a) || /\bexport\s+/.test(a);
|
|
963
965
|
}
|
|
964
966
|
class A {
|
|
967
|
+
static getIvmUnavailableMessage() {
|
|
968
|
+
const e = typeof process < "u" && process.version ? process.version : "unknown", t = typeof process < "u" && process.platform ? process.platform : "unknown", n = typeof process < "u" && process.arch ? process.arch : "unknown";
|
|
969
|
+
return [
|
|
970
|
+
"isolated-vm is required for expression evaluation but could not be loaded.",
|
|
971
|
+
"This feature only works in a Node.js environment with the native addon available.",
|
|
972
|
+
"",
|
|
973
|
+
`Detected environment: Node ${e} on ${t}/${n}.`,
|
|
974
|
+
"",
|
|
975
|
+
"Common causes:",
|
|
976
|
+
"- Running in a non-Node environment (browser, edge/runtime without Node).",
|
|
977
|
+
"- 'isolated-vm' is not installed, or failed to build its native addon.",
|
|
978
|
+
"- The module was bundled/stripped by a build tool.",
|
|
979
|
+
"",
|
|
980
|
+
"How to fix:",
|
|
981
|
+
"- Ensure 'isolated-vm' is listed in dependencies (not devDependencies) of the executing package.",
|
|
982
|
+
"- Reinstall or rebuild: npm ci && npm rebuild isolated-vm (or equivalent with your package manager).",
|
|
983
|
+
"- Run this code on a supported Node.js runtime (not browser/edge workers)."
|
|
984
|
+
].join(`
|
|
985
|
+
`);
|
|
986
|
+
}
|
|
965
987
|
/**
|
|
966
|
-
* Main evaluation method -
|
|
988
|
+
* Main evaluation method - chooses between secure and simple evaluation strategies
|
|
967
989
|
*/
|
|
968
990
|
static async evaluate({
|
|
969
991
|
code: e,
|
|
@@ -971,16 +993,43 @@ class A {
|
|
|
971
993
|
bindings: n = {},
|
|
972
994
|
options: o = {}
|
|
973
995
|
}) {
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
996
|
+
return !w || !he ? this.evaluateSimple(e, n, o) : this.evaluateSecure(e, n, t, o);
|
|
997
|
+
}
|
|
998
|
+
/**
|
|
999
|
+
* Fallback evaluation using Node's Function constructor
|
|
1000
|
+
* Used when isolated-vm is not available
|
|
1001
|
+
*/
|
|
1002
|
+
static async evaluateSimple(e, t, n = {}) {
|
|
1003
|
+
if (te(e))
|
|
1004
|
+
throw new Error(
|
|
1005
|
+
"Static import/export syntax requires isolated-vm – start Node without SKIP_ISOLATED_VM."
|
|
1006
|
+
);
|
|
1007
|
+
try {
|
|
1008
|
+
if (n.isCodeBlock) {
|
|
1009
|
+
const o = Object.keys(t);
|
|
1010
|
+
return await (await new Function(
|
|
1011
|
+
...o,
|
|
1012
|
+
`return async function codeBlock(${o.join(
|
|
1013
|
+
", "
|
|
1014
|
+
)}) { ${e} }`
|
|
1015
|
+
)(
|
|
1016
|
+
...o.map((i) => t[i])
|
|
1017
|
+
))(...o.map((i) => t[i]));
|
|
1018
|
+
} else
|
|
1019
|
+
return new Function(
|
|
1020
|
+
...Object.keys(t),
|
|
1021
|
+
`return ${e};`
|
|
1022
|
+
)(...Object.values(t));
|
|
1023
|
+
} catch (o) {
|
|
1024
|
+
throw n.isCodeBlock ? new Q(e, o) : new X(e, o);
|
|
1025
|
+
}
|
|
977
1026
|
}
|
|
978
1027
|
/**
|
|
979
1028
|
* Secure evaluation using isolated-vm with support for ES modules
|
|
980
1029
|
*/
|
|
981
1030
|
static async evaluateSecure(e, t, n, o = {}) {
|
|
982
|
-
if (!
|
|
983
|
-
const r = new
|
|
1031
|
+
if (!w) throw new Error(this.getIvmUnavailableMessage());
|
|
1032
|
+
const r = new w.Isolate({ memoryLimit: 32 }), s = await r.createContext(), i = s.global;
|
|
984
1033
|
try {
|
|
985
1034
|
await this.setupIsolateEnvironment(i, t);
|
|
986
1035
|
const c = /* @__PURE__ */ new Map(), h = this.createModuleResolver(
|
|
@@ -990,7 +1039,7 @@ class A {
|
|
|
990
1039
|
n
|
|
991
1040
|
);
|
|
992
1041
|
let u;
|
|
993
|
-
return
|
|
1042
|
+
return te(e) ? u = await this.evaluateESModule(
|
|
994
1043
|
r,
|
|
995
1044
|
s,
|
|
996
1045
|
e,
|
|
@@ -1004,7 +1053,7 @@ class A {
|
|
|
1004
1053
|
o
|
|
1005
1054
|
), this.deepClone(u);
|
|
1006
1055
|
} catch (c) {
|
|
1007
|
-
throw o.isCodeBlock ? new
|
|
1056
|
+
throw o.isCodeBlock ? new Q(e, c) : new X(e, c);
|
|
1008
1057
|
} finally {
|
|
1009
1058
|
s.release(), r.dispose();
|
|
1010
1059
|
}
|
|
@@ -1013,18 +1062,18 @@ class A {
|
|
|
1013
1062
|
* Setup the isolated VM environment with necessary host functions and data
|
|
1014
1063
|
*/
|
|
1015
1064
|
static async setupIsolateEnvironment(e, t) {
|
|
1016
|
-
if (!
|
|
1017
|
-
const n = new
|
|
1065
|
+
if (!w) throw new Error("isolated-vm not available");
|
|
1066
|
+
const n = new w.Callback(
|
|
1018
1067
|
(...r) => console.log(...r)
|
|
1019
|
-
), o = new
|
|
1068
|
+
), o = new w.ExternalCopy({
|
|
1020
1069
|
log: n
|
|
1021
1070
|
}).copyInto();
|
|
1022
1071
|
await e.set("console", o);
|
|
1023
1072
|
for (const [r, s] of Object.entries(t))
|
|
1024
1073
|
typeof s == "function" ? await e.set(
|
|
1025
1074
|
r,
|
|
1026
|
-
new
|
|
1027
|
-
) : await e.set(r, new
|
|
1075
|
+
new w.Callback(s)
|
|
1076
|
+
) : await e.set(r, new w.ExternalCopy(s).copyInto());
|
|
1028
1077
|
}
|
|
1029
1078
|
/**
|
|
1030
1079
|
* Create module resolver function for handling imports
|
|
@@ -1112,42 +1161,42 @@ class A {
|
|
|
1112
1161
|
return typeof e > "u" ? e : JSON.parse(JSON.stringify(e));
|
|
1113
1162
|
}
|
|
1114
1163
|
}
|
|
1115
|
-
class
|
|
1164
|
+
class z {
|
|
1116
1165
|
/**
|
|
1117
1166
|
* Creates standard bindings for workflow step execution
|
|
1118
1167
|
*/
|
|
1119
1168
|
static createStandardBindings(e, t, n) {
|
|
1120
|
-
const o = e.getBlue(), r = o.nodeToJson(t.payload, "simple"), s =
|
|
1169
|
+
const o = e.getBlue(), r = o.nodeToJson(t.payload, "simple"), s = L(r) ? r.toNumber() : r;
|
|
1121
1170
|
return {
|
|
1122
1171
|
document: (i) => {
|
|
1123
1172
|
const c = e.get(i);
|
|
1124
|
-
return
|
|
1173
|
+
return L(c) ? c.toNumber() : S(c) ? o.nodeToJson(c, "original") : c;
|
|
1125
1174
|
},
|
|
1126
1175
|
event: s,
|
|
1127
1176
|
steps: n
|
|
1128
1177
|
};
|
|
1129
1178
|
}
|
|
1130
1179
|
}
|
|
1131
|
-
const
|
|
1180
|
+
const st = /^\$\{([\s\S]*)\}$/, at = /\$\{([\s\S]*?)\}/, T = (a) => typeof a != "string" ? !1 : st.test(a), J = (a) => typeof a != "string" ? !1 : at.test(a), de = (a) => {
|
|
1132
1181
|
if (!T(a))
|
|
1133
1182
|
throw new Error(`Invalid expression: ${a}`);
|
|
1134
1183
|
return a.slice(2, -1);
|
|
1135
1184
|
};
|
|
1136
1185
|
class q {
|
|
1137
1186
|
static createBindings(e, t, n) {
|
|
1138
|
-
return
|
|
1187
|
+
return z.createStandardBindings(e, t, n);
|
|
1139
1188
|
}
|
|
1140
1189
|
static async evaluate(e, t, n, o) {
|
|
1141
1190
|
const { coerceToString: r } = o;
|
|
1142
1191
|
if (T(e)) {
|
|
1143
|
-
const s =
|
|
1192
|
+
const s = de(e), i = await A.evaluate({
|
|
1144
1193
|
code: s,
|
|
1145
1194
|
ctx: t,
|
|
1146
1195
|
bindings: n
|
|
1147
1196
|
});
|
|
1148
1197
|
return r ? String(i ?? "") : i;
|
|
1149
1198
|
}
|
|
1150
|
-
if (
|
|
1199
|
+
if (J(e)) {
|
|
1151
1200
|
const i = `\`${String(e).replace(/`/g, "\\`")}\``, c = await A.evaluate({
|
|
1152
1201
|
code: i,
|
|
1153
1202
|
ctx: t,
|
|
@@ -1158,7 +1207,7 @@ class q {
|
|
|
1158
1207
|
return r ? String(e) : e;
|
|
1159
1208
|
}
|
|
1160
1209
|
}
|
|
1161
|
-
function
|
|
1210
|
+
function ne(a, e) {
|
|
1162
1211
|
const { op: t, path: n, val: o, from: r } = a;
|
|
1163
1212
|
if ((t === "move" || t === "copy") && !r)
|
|
1164
1213
|
throw new Error(`${t} operation requires 'from' path`);
|
|
@@ -1171,31 +1220,31 @@ function Z(a, e) {
|
|
|
1171
1220
|
};
|
|
1172
1221
|
return o !== void 0 && (s.val = o), r !== void 0 && (s.from = r), e.jsonValueToNode(s);
|
|
1173
1222
|
}
|
|
1174
|
-
function
|
|
1223
|
+
function it(a) {
|
|
1175
1224
|
return a.jsonValueToNode({
|
|
1176
1225
|
type: "Document Processing Initiated"
|
|
1177
1226
|
});
|
|
1178
1227
|
}
|
|
1179
|
-
class
|
|
1228
|
+
class ct {
|
|
1180
1229
|
constructor() {
|
|
1181
1230
|
l(this, "stepType", "Update Document");
|
|
1182
1231
|
}
|
|
1183
1232
|
supports(e) {
|
|
1184
|
-
return
|
|
1233
|
+
return P.isTypeOf(e, j);
|
|
1185
1234
|
}
|
|
1186
1235
|
async execute(e, t, n, o, r) {
|
|
1187
1236
|
const s = n.getBlue();
|
|
1188
|
-
if (!
|
|
1237
|
+
if (!P.isTypeOf(e, j)) return;
|
|
1189
1238
|
const i = await this.evaluateChangeset(
|
|
1190
1239
|
e.get("/changeset"),
|
|
1191
1240
|
n,
|
|
1192
1241
|
t,
|
|
1193
1242
|
r
|
|
1194
|
-
), c =
|
|
1243
|
+
), c = re(e, {
|
|
1195
1244
|
op: "replace",
|
|
1196
1245
|
path: "/changeset",
|
|
1197
1246
|
val: i
|
|
1198
|
-
}), h = n.getBlue().nodeToSchemaOutput(c,
|
|
1247
|
+
}), h = n.getBlue().nodeToSchemaOutput(c, j);
|
|
1199
1248
|
for (const u of h.changeset ?? []) {
|
|
1200
1249
|
if (!u.path) continue;
|
|
1201
1250
|
const d = await this.evaluateChangePath(
|
|
@@ -1205,7 +1254,7 @@ class it {
|
|
|
1205
1254
|
r
|
|
1206
1255
|
), p = u.val;
|
|
1207
1256
|
if ((u.op === "replace" || u.op === "add") && M(p)) {
|
|
1208
|
-
const
|
|
1257
|
+
const m = await this.evaluateChangeValue(
|
|
1209
1258
|
p,
|
|
1210
1259
|
n,
|
|
1211
1260
|
t,
|
|
@@ -1214,13 +1263,13 @@ class it {
|
|
|
1214
1263
|
n.addPatch({
|
|
1215
1264
|
op: u.op,
|
|
1216
1265
|
path: d,
|
|
1217
|
-
val:
|
|
1266
|
+
val: m
|
|
1218
1267
|
}), n.emitEvent({
|
|
1219
|
-
payload:
|
|
1268
|
+
payload: ne(
|
|
1220
1269
|
{
|
|
1221
1270
|
op: u.op,
|
|
1222
1271
|
path: n.resolvePath(d),
|
|
1223
|
-
val: s.nodeToJson(
|
|
1272
|
+
val: s.nodeToJson(m, "original")
|
|
1224
1273
|
},
|
|
1225
1274
|
s
|
|
1226
1275
|
),
|
|
@@ -1228,7 +1277,7 @@ class it {
|
|
|
1228
1277
|
});
|
|
1229
1278
|
}
|
|
1230
1279
|
u.op === "remove" && (n.addPatch({ op: u.op, path: d }), n.emitEvent({
|
|
1231
|
-
payload:
|
|
1280
|
+
payload: ne(
|
|
1232
1281
|
{
|
|
1233
1282
|
op: u.op,
|
|
1234
1283
|
path: n.resolvePath(d),
|
|
@@ -1243,10 +1292,10 @@ class it {
|
|
|
1243
1292
|
async evaluateChangeset(e, t, n, o) {
|
|
1244
1293
|
const r = t.getBlue();
|
|
1245
1294
|
if (T(e)) {
|
|
1246
|
-
const s =
|
|
1295
|
+
const s = de(e), i = await A.evaluate({
|
|
1247
1296
|
code: s,
|
|
1248
1297
|
ctx: t,
|
|
1249
|
-
bindings:
|
|
1298
|
+
bindings: z.createStandardBindings(
|
|
1250
1299
|
t,
|
|
1251
1300
|
n,
|
|
1252
1301
|
o
|
|
@@ -1260,7 +1309,7 @@ class it {
|
|
|
1260
1309
|
}
|
|
1261
1310
|
async evaluateChangeValue(e, t, n, o) {
|
|
1262
1311
|
const r = e.getValue(), s = t.getBlue();
|
|
1263
|
-
if (T(r) || typeof r == "string" &&
|
|
1312
|
+
if (T(r) || typeof r == "string" && J(r)) {
|
|
1264
1313
|
const i = q.createBindings(
|
|
1265
1314
|
t,
|
|
1266
1315
|
n,
|
|
@@ -1277,7 +1326,7 @@ class it {
|
|
|
1277
1326
|
}
|
|
1278
1327
|
async evaluateChangePath(e, t, n, o) {
|
|
1279
1328
|
const r = q.createBindings(t, n, o);
|
|
1280
|
-
if (T(e) ||
|
|
1329
|
+
if (T(e) || J(e)) {
|
|
1281
1330
|
const s = await q.evaluate(e, t, r, {
|
|
1282
1331
|
coerceToString: !0
|
|
1283
1332
|
});
|
|
@@ -1286,32 +1335,32 @@ class it {
|
|
|
1286
1335
|
return e;
|
|
1287
1336
|
}
|
|
1288
1337
|
}
|
|
1289
|
-
class
|
|
1338
|
+
class lt {
|
|
1290
1339
|
constructor() {
|
|
1291
1340
|
l(this, "stepType", "Trigger Event");
|
|
1292
1341
|
}
|
|
1293
1342
|
supports(e) {
|
|
1294
|
-
return
|
|
1343
|
+
return P.isTypeOf(e, x);
|
|
1295
1344
|
}
|
|
1296
1345
|
async execute(e, t, n) {
|
|
1297
1346
|
const o = n.getBlue();
|
|
1298
|
-
if (!
|
|
1299
|
-
const r = o.nodeToSchemaOutput(e,
|
|
1347
|
+
if (!P.isTypeOf(e, x)) return;
|
|
1348
|
+
const r = o.nodeToSchemaOutput(e, x);
|
|
1300
1349
|
r.event && n.emitEvent({
|
|
1301
1350
|
payload: r.event,
|
|
1302
1351
|
emissionType: "triggered"
|
|
1303
1352
|
});
|
|
1304
1353
|
}
|
|
1305
1354
|
}
|
|
1306
|
-
class
|
|
1355
|
+
class ut {
|
|
1307
1356
|
constructor() {
|
|
1308
1357
|
l(this, "stepType", "JavaScript Code");
|
|
1309
1358
|
}
|
|
1310
1359
|
supports(e) {
|
|
1311
|
-
return
|
|
1360
|
+
return P.isTypeOf(e, V);
|
|
1312
1361
|
}
|
|
1313
1362
|
async execute(e, t, n, o, r) {
|
|
1314
|
-
if (!
|
|
1363
|
+
if (!P.isTypeOf(e, V)) return;
|
|
1315
1364
|
const s = n.getBlue(), i = s.nodeToSchemaOutput(
|
|
1316
1365
|
e,
|
|
1317
1366
|
V
|
|
@@ -1321,7 +1370,7 @@ class lt {
|
|
|
1321
1370
|
const c = await A.evaluate({
|
|
1322
1371
|
code: i.code,
|
|
1323
1372
|
ctx: n,
|
|
1324
|
-
bindings:
|
|
1373
|
+
bindings: z.createStandardBindings(n, t, r),
|
|
1325
1374
|
options: {
|
|
1326
1375
|
isCodeBlock: !0,
|
|
1327
1376
|
timeout: 500
|
|
@@ -1339,15 +1388,15 @@ class lt {
|
|
|
1339
1388
|
return c;
|
|
1340
1389
|
}
|
|
1341
1390
|
}
|
|
1342
|
-
const
|
|
1343
|
-
new it(),
|
|
1391
|
+
const ht = [
|
|
1344
1392
|
new ct(),
|
|
1345
|
-
new lt()
|
|
1393
|
+
new lt(),
|
|
1394
|
+
new ut()
|
|
1346
1395
|
];
|
|
1347
|
-
class
|
|
1348
|
-
constructor(e =
|
|
1396
|
+
class pe {
|
|
1397
|
+
constructor(e = ht) {
|
|
1349
1398
|
l(this, "contractType", "Sequential Workflow");
|
|
1350
|
-
l(this, "contractBlueId",
|
|
1399
|
+
l(this, "contractBlueId", y["Sequential Workflow"]);
|
|
1351
1400
|
l(this, "role", "handler");
|
|
1352
1401
|
l(this, "executors", []);
|
|
1353
1402
|
this.executors = e;
|
|
@@ -1359,7 +1408,7 @@ class le {
|
|
|
1359
1408
|
supports(e, t, n) {
|
|
1360
1409
|
const r = n.getBlue().nodeToSchemaOutput(
|
|
1361
1410
|
t,
|
|
1362
|
-
|
|
1411
|
+
Ie
|
|
1363
1412
|
), s = this.isChannelNameMatch(e, r), i = this.isEventPatternMatch(e, t, n);
|
|
1364
1413
|
return s && i;
|
|
1365
1414
|
}
|
|
@@ -1378,8 +1427,8 @@ class le {
|
|
|
1378
1427
|
r
|
|
1379
1428
|
);
|
|
1380
1429
|
if (d !== void 0) {
|
|
1381
|
-
const p = h.getName(),
|
|
1382
|
-
r[
|
|
1430
|
+
const p = h.getName(), m = typeof p == "string" ? p : `Step${c + 1}`;
|
|
1431
|
+
r[m] = d;
|
|
1383
1432
|
}
|
|
1384
1433
|
await n.flush();
|
|
1385
1434
|
}
|
|
@@ -1404,18 +1453,18 @@ class le {
|
|
|
1404
1453
|
}
|
|
1405
1454
|
}
|
|
1406
1455
|
}
|
|
1407
|
-
class
|
|
1456
|
+
class dt {
|
|
1408
1457
|
constructor(e) {
|
|
1409
1458
|
l(this, "contractType", "Sequential Workflow Operation");
|
|
1410
|
-
l(this, "contractBlueId",
|
|
1459
|
+
l(this, "contractBlueId", y["Sequential Workflow Operation"]);
|
|
1411
1460
|
l(this, "role", "handler");
|
|
1412
1461
|
l(this, "sequentialWorkflowProcessor");
|
|
1413
|
-
this.sequentialWorkflowProcessor = e || new
|
|
1462
|
+
this.sequentialWorkflowProcessor = e || new pe();
|
|
1414
1463
|
}
|
|
1415
1464
|
supports(e, t, n) {
|
|
1416
1465
|
const s = n.getBlue().nodeToSchemaOutput(
|
|
1417
1466
|
t,
|
|
1418
|
-
|
|
1467
|
+
Be
|
|
1419
1468
|
).operation, i = e.channelName;
|
|
1420
1469
|
return e.source === "channel" && M(i) && M(s) && i === s;
|
|
1421
1470
|
}
|
|
@@ -1430,35 +1479,35 @@ class ht {
|
|
|
1430
1479
|
}
|
|
1431
1480
|
}
|
|
1432
1481
|
}
|
|
1433
|
-
const
|
|
1434
|
-
class
|
|
1482
|
+
const oe = (a) => P.isTypeOf(a.payload, O);
|
|
1483
|
+
class pt extends C {
|
|
1435
1484
|
constructor() {
|
|
1436
1485
|
super(...arguments);
|
|
1437
1486
|
l(this, "contractType", "Timeline Channel");
|
|
1438
|
-
l(this, "contractBlueId",
|
|
1487
|
+
l(this, "contractBlueId", y["Timeline Channel"]);
|
|
1439
1488
|
}
|
|
1440
1489
|
supports(t, n, o) {
|
|
1441
1490
|
var u;
|
|
1442
|
-
if (!this.baseSupports(t) || !
|
|
1491
|
+
if (!this.baseSupports(t) || !oe(t)) return !1;
|
|
1443
1492
|
const s = o.getBlue().nodeToSchemaOutput(
|
|
1444
1493
|
t.payload,
|
|
1445
1494
|
O
|
|
1446
|
-
), i = o.getBlue().nodeToSchemaOutput(n,
|
|
1447
|
-
return
|
|
1495
|
+
), i = o.getBlue().nodeToSchemaOutput(n, Oe), c = (u = s.timeline) == null ? void 0 : u.timelineId;
|
|
1496
|
+
return g(i.timelineId) && g(c) && c === i.timelineId;
|
|
1448
1497
|
}
|
|
1449
1498
|
handle(t, n, o, r) {
|
|
1450
|
-
|
|
1499
|
+
oe(t) && o.emitEvent({
|
|
1451
1500
|
payload: t.payload,
|
|
1452
1501
|
channelName: r,
|
|
1453
1502
|
source: "channel"
|
|
1454
1503
|
});
|
|
1455
1504
|
}
|
|
1456
1505
|
}
|
|
1457
|
-
class
|
|
1506
|
+
class mt extends C {
|
|
1458
1507
|
constructor() {
|
|
1459
1508
|
super(...arguments);
|
|
1460
1509
|
l(this, "contractType", "Triggered Event Channel");
|
|
1461
|
-
l(this, "contractBlueId",
|
|
1510
|
+
l(this, "contractBlueId", y["Triggered Event Channel"]);
|
|
1462
1511
|
}
|
|
1463
1512
|
supports(t) {
|
|
1464
1513
|
return this.baseSupports(t) ? t.emissionType === "triggered" : !1;
|
|
@@ -1472,24 +1521,24 @@ class pt extends C {
|
|
|
1472
1521
|
}
|
|
1473
1522
|
}
|
|
1474
1523
|
const ft = [
|
|
1475
|
-
new
|
|
1524
|
+
new rt(),
|
|
1476
1525
|
// channels
|
|
1477
|
-
new Ge(),
|
|
1478
|
-
new Qe(),
|
|
1479
|
-
new dt(),
|
|
1480
|
-
new Ze(),
|
|
1481
|
-
new et(),
|
|
1482
|
-
new Xe(),
|
|
1483
1526
|
new Ye(),
|
|
1527
|
+
new Ge(),
|
|
1484
1528
|
new pt(),
|
|
1485
1529
|
new tt(),
|
|
1530
|
+
new nt(),
|
|
1531
|
+
new Ke(),
|
|
1532
|
+
new et(),
|
|
1533
|
+
new mt(),
|
|
1534
|
+
new ot(),
|
|
1486
1535
|
// sequential workflows
|
|
1487
|
-
new
|
|
1488
|
-
new
|
|
1536
|
+
new pe(),
|
|
1537
|
+
new dt(),
|
|
1489
1538
|
// markers
|
|
1490
|
-
new
|
|
1539
|
+
new Ze()
|
|
1491
1540
|
];
|
|
1492
|
-
class
|
|
1541
|
+
class bt {
|
|
1493
1542
|
/**
|
|
1494
1543
|
* Creates a new document processor
|
|
1495
1544
|
*
|
|
@@ -1501,15 +1550,15 @@ class Tt {
|
|
|
1501
1550
|
l(this, "registry");
|
|
1502
1551
|
l(this, "queue");
|
|
1503
1552
|
l(this, "router");
|
|
1504
|
-
l(this, "checkpointCache", new
|
|
1505
|
-
this.blue = e, this.registry = new
|
|
1553
|
+
l(this, "checkpointCache", new Qe());
|
|
1554
|
+
this.blue = e, this.registry = new Fe(t), this.queue = new Le(), this.router = new ze(
|
|
1506
1555
|
this.blue,
|
|
1507
1556
|
this.registry,
|
|
1508
1557
|
this.queue,
|
|
1509
1558
|
() => ++this.taskCounter,
|
|
1510
1559
|
() => ++this.eventCounter
|
|
1511
1560
|
), this.register(
|
|
1512
|
-
new
|
|
1561
|
+
new Xe(this.checkpointCache),
|
|
1513
1562
|
9999
|
|
1514
1563
|
);
|
|
1515
1564
|
}
|
|
@@ -1529,9 +1578,9 @@ class Tt {
|
|
|
1529
1578
|
* @returns Processing result with final state and emitted events
|
|
1530
1579
|
*/
|
|
1531
1580
|
async initialize(e) {
|
|
1532
|
-
let t =
|
|
1581
|
+
let t = Y(I(e), this.blue);
|
|
1533
1582
|
const n = {
|
|
1534
|
-
payload:
|
|
1583
|
+
payload: it(this.blue),
|
|
1535
1584
|
source: "internal",
|
|
1536
1585
|
emissionType: "lifecycle"
|
|
1537
1586
|
}, o = [n.payload];
|
|
@@ -1547,9 +1596,9 @@ class Tt {
|
|
|
1547
1596
|
* @returns Processing result with final state and emitted events
|
|
1548
1597
|
*/
|
|
1549
1598
|
async processEvents(e, t) {
|
|
1550
|
-
let n =
|
|
1599
|
+
let n = Y(I(e), this.blue);
|
|
1551
1600
|
const o = [];
|
|
1552
|
-
if (!
|
|
1601
|
+
if (!ue(n, this.blue))
|
|
1553
1602
|
throw new Error("Document is not initialized");
|
|
1554
1603
|
for (const r of t)
|
|
1555
1604
|
try {
|
|
@@ -1558,7 +1607,7 @@ class Tt {
|
|
|
1558
1607
|
const i = await this.drainQueue(n);
|
|
1559
1608
|
n = i.state, o.push(...i.emitted);
|
|
1560
1609
|
const c = this.checkpointCache.flush(n);
|
|
1561
|
-
c.length && (n =
|
|
1610
|
+
c.length && (n = G(n, c));
|
|
1562
1611
|
} finally {
|
|
1563
1612
|
this.checkpointCache.clear();
|
|
1564
1613
|
}
|
|
@@ -1577,50 +1626,50 @@ class Tt {
|
|
|
1577
1626
|
throw new Error("Possible cycle – too many iterations");
|
|
1578
1627
|
const i = this.queue.pop(), { nodePath: c, contractName: h, contractNode: u, event: d } = i, p = t.get(c);
|
|
1579
1628
|
if (!S(p) || !((s = p.getContracts()) != null && s[h]) || !u.getType()) continue;
|
|
1580
|
-
const
|
|
1581
|
-
if (!
|
|
1629
|
+
const m = this.registry.get(u.getType());
|
|
1630
|
+
if (!m) {
|
|
1582
1631
|
console.warn(`No processor registered for contract: ${h}`);
|
|
1583
1632
|
continue;
|
|
1584
1633
|
}
|
|
1585
|
-
const v = new
|
|
1634
|
+
const v = new ie(
|
|
1586
1635
|
() => t,
|
|
1587
1636
|
i,
|
|
1588
1637
|
this.blue,
|
|
1589
|
-
async (
|
|
1590
|
-
for (const
|
|
1591
|
-
if (
|
|
1638
|
+
async (E) => {
|
|
1639
|
+
for (const f of E)
|
|
1640
|
+
if (f.kind === "patch") {
|
|
1592
1641
|
const D = U(
|
|
1593
1642
|
t,
|
|
1594
1643
|
this.blue
|
|
1595
1644
|
);
|
|
1596
1645
|
for (const N of D) {
|
|
1597
|
-
const
|
|
1598
|
-
(
|
|
1599
|
-
),
|
|
1600
|
-
|
|
1646
|
+
const fe = f.patch.op === "move" || f.patch.op === "copy" ? [f.patch.from, f.patch.path] : [f.patch.path], R = v.getNodePath(), ye = fe.some(
|
|
1647
|
+
(Ee) => K(Ee, N.absPath)
|
|
1648
|
+
), ge = K(
|
|
1649
|
+
R,
|
|
1601
1650
|
N.absPath
|
|
1602
1651
|
);
|
|
1603
|
-
if (
|
|
1604
|
-
throw new
|
|
1605
|
-
|
|
1652
|
+
if (ye && !ge)
|
|
1653
|
+
throw new le(
|
|
1654
|
+
f.patch,
|
|
1606
1655
|
N.absPath,
|
|
1607
|
-
|
|
1656
|
+
R
|
|
1608
1657
|
);
|
|
1609
1658
|
}
|
|
1610
1659
|
try {
|
|
1611
|
-
t =
|
|
1660
|
+
t = G(t, [f.patch]);
|
|
1612
1661
|
} catch (N) {
|
|
1613
|
-
throw
|
|
1662
|
+
throw Re(h, d, N), N;
|
|
1614
1663
|
}
|
|
1615
|
-
} else
|
|
1664
|
+
} else f.kind === "event" && (n.push(f.event.payload), await this.router.route(t, [], f.event, i.key[5]));
|
|
1616
1665
|
}
|
|
1617
1666
|
);
|
|
1618
|
-
await
|
|
1667
|
+
await m.handle(d, u, v, h), await v.flush();
|
|
1619
1668
|
}
|
|
1620
1669
|
return { state: t, emitted: n };
|
|
1621
1670
|
}
|
|
1622
1671
|
}
|
|
1623
|
-
class
|
|
1672
|
+
class me {
|
|
1624
1673
|
process(e, t) {
|
|
1625
1674
|
const n = t.getValue();
|
|
1626
1675
|
if (T(n)) {
|
|
@@ -1643,12 +1692,12 @@ class ue {
|
|
|
1643
1692
|
}
|
|
1644
1693
|
const Pt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1645
1694
|
__proto__: null,
|
|
1646
|
-
ExpressionPreserver:
|
|
1695
|
+
ExpressionPreserver: me
|
|
1647
1696
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
1648
|
-
function
|
|
1697
|
+
function St() {
|
|
1649
1698
|
return new k.SequentialMergingProcessor([
|
|
1650
1699
|
new k.ValuePropagator(),
|
|
1651
|
-
new
|
|
1700
|
+
new me(),
|
|
1652
1701
|
new k.TypeAssigner(),
|
|
1653
1702
|
new k.ListProcessor(),
|
|
1654
1703
|
new k.DictionaryProcessor(),
|
|
@@ -1656,26 +1705,26 @@ function bt() {
|
|
|
1656
1705
|
]);
|
|
1657
1706
|
}
|
|
1658
1707
|
export {
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1708
|
+
bt as BlueDocumentProcessor,
|
|
1709
|
+
Xe as ChannelEventCheckpointProcessor,
|
|
1710
|
+
Q as CodeBlockEvaluationError,
|
|
1711
|
+
Ke as CompositeTimelineChannelProcessor,
|
|
1712
|
+
Ge as DocumentUpdateChannelProcessor,
|
|
1713
|
+
le as EmbeddedDocumentModificationError,
|
|
1714
|
+
Ye as EmbeddedNodeChannelProcessor,
|
|
1715
|
+
X as ExpressionEvaluationError,
|
|
1716
|
+
Ze as InitializedMarkerProcessor,
|
|
1717
|
+
et as LifecycleEventChannelProcessor,
|
|
1669
1718
|
Pt as MergingProcessors,
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1719
|
+
nt as MyOSAgentChannelProcessor,
|
|
1720
|
+
tt as MyOSTimelineChannelProcessor,
|
|
1721
|
+
ot as OperationProcessor,
|
|
1722
|
+
ce as PatchApplicationError,
|
|
1723
|
+
rt as ProcessEmbeddedProcessor,
|
|
1724
|
+
dt as SequentialWorkflowOperationProcessor,
|
|
1725
|
+
pe as SequentialWorkflowProcessor,
|
|
1726
|
+
pt as TimelineChannelProcessor,
|
|
1727
|
+
mt as TriggeredEventChannelProcessor,
|
|
1679
1728
|
U as collectEmbeddedPathSpecs,
|
|
1680
|
-
|
|
1729
|
+
St as createDefaultMergingProcessor
|
|
1681
1730
|
};
|