@blue-labs/document-processor 1.33.1 → 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,17 +1,17 @@
|
|
|
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
|
|
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
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;
|
|
@@ -69,50 +69,50 @@ 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();
|
|
99
99
|
}
|
|
100
|
-
function
|
|
100
|
+
function U(a, e, t = "/", n = []) {
|
|
101
101
|
const o = a.getContracts() ?? {};
|
|
102
102
|
for (const [r, s] of Object.entries(o))
|
|
103
103
|
if (e.isTypeOf(s, W)) {
|
|
104
|
-
const
|
|
104
|
+
const h = e.nodeToSchemaOutput(
|
|
105
105
|
s,
|
|
106
106
|
W
|
|
107
107
|
).paths ?? [];
|
|
108
|
-
for (const u of
|
|
108
|
+
for (const u of h)
|
|
109
109
|
n.push({
|
|
110
110
|
absPath: b(t, u),
|
|
111
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),
|
|
@@ -120,27 +120,27 @@ function z(a, e, t = "/", 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 je {
|
|
|
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 xe = (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,12 +345,12 @@ const B = class B {
|
|
|
345
345
|
}
|
|
346
346
|
};
|
|
347
347
|
l(B, "MAX_TRACE_LENGTH", 128);
|
|
348
|
-
let
|
|
349
|
-
function
|
|
348
|
+
let F = B;
|
|
349
|
+
function Je(a) {
|
|
350
350
|
return Object.entries(a.getContracts() ?? {});
|
|
351
351
|
}
|
|
352
|
-
const
|
|
353
|
-
class
|
|
352
|
+
const Ue = 64;
|
|
353
|
+
class ze {
|
|
354
354
|
/**
|
|
355
355
|
* Creates a new event router
|
|
356
356
|
*
|
|
@@ -361,7 +361,7 @@ class Ue {
|
|
|
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
|
|
@@ -376,12 +376,12 @@ class Ue {
|
|
|
376
376
|
var c;
|
|
377
377
|
if (n.seq === void 0 && (n.seq = this.getNextEventSeq()), t.length === 0) {
|
|
378
378
|
if (n.dispatchPath) {
|
|
379
|
-
const
|
|
380
|
-
return delete u.dispatchPath, this.route(e,
|
|
379
|
+
const h = n.dispatchPath.split("/").filter(Boolean), u = { ...n };
|
|
380
|
+
return delete u.dispatchPath, this.route(e, h, u, o, r);
|
|
381
381
|
}
|
|
382
382
|
if (n.source === "channel" && n.originNodePath && n.originNodePath !== "/") {
|
|
383
|
-
const
|
|
384
|
-
return this.route(e,
|
|
383
|
+
const h = ((c = n.originNodePath) == null ? void 0 : c.split("/").filter(Boolean)) ?? [];
|
|
384
|
+
return this.route(e, h, n, o, r);
|
|
385
385
|
}
|
|
386
386
|
}
|
|
387
387
|
const s = b("/", t.join("/")), i = e.get(s);
|
|
@@ -409,28 +409,28 @@ class Ue {
|
|
|
409
409
|
inlineDepth: c
|
|
410
410
|
} = e;
|
|
411
411
|
if (!this.shouldSkipForChannel(r, o))
|
|
412
|
-
for (const [
|
|
412
|
+
for (const [h, u] of Je(n)) {
|
|
413
413
|
if (!u.getType()) continue;
|
|
414
|
-
const
|
|
415
|
-
if (!
|
|
416
|
-
console.warn(`No processor registered for contract: ${
|
|
414
|
+
const d = this.registry.get(u.getType());
|
|
415
|
+
if (!d) {
|
|
416
|
+
console.warn(`No processor registered for contract: ${h}`);
|
|
417
417
|
continue;
|
|
418
418
|
}
|
|
419
419
|
const p = {
|
|
420
420
|
nodePath: o,
|
|
421
|
-
contractName:
|
|
421
|
+
contractName: h,
|
|
422
422
|
contractNode: u,
|
|
423
423
|
event: r
|
|
424
|
-
}, m = new
|
|
425
|
-
if (
|
|
426
|
-
switch (
|
|
424
|
+
}, m = new ie(() => t, p, this.blue);
|
|
425
|
+
if (d.supports(r, u, m, h))
|
|
426
|
+
switch (d.role) {
|
|
427
427
|
case "adapter":
|
|
428
428
|
await this.processAdapter({
|
|
429
|
-
cp:
|
|
429
|
+
cp: d,
|
|
430
430
|
event: r,
|
|
431
431
|
contractNode: u,
|
|
432
432
|
ctx: m,
|
|
433
|
-
contractName:
|
|
433
|
+
contractName: h,
|
|
434
434
|
doc: t,
|
|
435
435
|
afterTaskId: s,
|
|
436
436
|
inlineDepth: c
|
|
@@ -439,7 +439,7 @@ class Ue {
|
|
|
439
439
|
case "handler":
|
|
440
440
|
this.scheduleHandler({
|
|
441
441
|
contractNode: u,
|
|
442
|
-
contractName:
|
|
442
|
+
contractName: h,
|
|
443
443
|
nodePath: o,
|
|
444
444
|
event: r,
|
|
445
445
|
depth: i.length,
|
|
@@ -453,7 +453,7 @@ class Ue {
|
|
|
453
453
|
* Processes an adapter contract and routes any emitted events
|
|
454
454
|
*/
|
|
455
455
|
async processAdapter(e) {
|
|
456
|
-
var
|
|
456
|
+
var v;
|
|
457
457
|
const {
|
|
458
458
|
cp: t,
|
|
459
459
|
event: n,
|
|
@@ -462,24 +462,24 @@ class Ue {
|
|
|
462
462
|
contractName: s,
|
|
463
463
|
doc: i,
|
|
464
464
|
afterTaskId: c,
|
|
465
|
-
inlineDepth:
|
|
465
|
+
inlineDepth: h
|
|
466
466
|
} = e;
|
|
467
|
-
if (
|
|
467
|
+
if (h >= Ue)
|
|
468
468
|
throw new Error("Adapter recursion limit reached");
|
|
469
469
|
const u = this.traceManager.addHop(
|
|
470
470
|
n,
|
|
471
|
-
((
|
|
471
|
+
((v = r.getTaskInfo()) == null ? void 0 : v.nodePath) ?? "",
|
|
472
472
|
s
|
|
473
473
|
);
|
|
474
474
|
await t.handle(u, o, r, s);
|
|
475
|
-
const
|
|
476
|
-
if (
|
|
475
|
+
const d = await r.flush();
|
|
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 m =
|
|
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,14 +490,14 @@ class Ue {
|
|
|
490
490
|
console.warn(`Contract node type is not defined for: ${n}`);
|
|
491
491
|
return;
|
|
492
492
|
}
|
|
493
|
-
const
|
|
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
494
|
if (m === void 0)
|
|
495
495
|
throw new Error("Event sequence missing");
|
|
496
|
-
const
|
|
496
|
+
const v = _e(
|
|
497
497
|
s,
|
|
498
498
|
m,
|
|
499
|
-
d,
|
|
500
499
|
h,
|
|
500
|
+
d,
|
|
501
501
|
n,
|
|
502
502
|
p
|
|
503
503
|
);
|
|
@@ -508,13 +508,13 @@ class Ue {
|
|
|
508
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
|
-
key:
|
|
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,61 +524,61 @@ class Ue {
|
|
|
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
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
|
})
|
|
549
549
|
);
|
|
550
550
|
};
|
|
551
551
|
n(t);
|
|
552
|
-
for (const { absPath: o } of
|
|
552
|
+
for (const { absPath: o } of U(t, e)) {
|
|
553
553
|
const r = t.get(o);
|
|
554
554
|
S(r) && n(r);
|
|
555
555
|
}
|
|
556
556
|
return I(t);
|
|
557
557
|
}
|
|
558
|
-
function
|
|
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 He {
|
|
|
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 He {
|
|
|
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
|
}
|
|
@@ -625,8 +625,8 @@ class Fe {
|
|
|
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 Fe {
|
|
|
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
|
|
@@ -865,24 +865,24 @@ class et extends C {
|
|
|
865
865
|
if (!s)
|
|
866
866
|
return !1;
|
|
867
867
|
try {
|
|
868
|
-
const i = o.getBlue(), c = i.nodeToJson(s),
|
|
869
|
-
return
|
|
868
|
+
const i = o.getBlue(), c = i.nodeToJson(s), h = i.nodeToJson(r);
|
|
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(
|
|
886
886
|
e,
|
|
887
887
|
s
|
|
888
888
|
), u = this.isRequestPatternMatch(
|
|
@@ -890,7 +890,7 @@ class tt {
|
|
|
890
890
|
s,
|
|
891
891
|
n
|
|
892
892
|
);
|
|
893
|
-
return c &&
|
|
893
|
+
return c && h && u;
|
|
894
894
|
}
|
|
895
895
|
async handle(e, t, n, o) {
|
|
896
896
|
n.emitEvent({
|
|
@@ -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,8 +952,15 @@ class nt {
|
|
|
952
952
|
});
|
|
953
953
|
}
|
|
954
954
|
}
|
|
955
|
-
|
|
956
|
-
|
|
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) {
|
|
957
964
|
return /\bimport\s.+\sfrom\s+['"][^'"]+['"]/.test(a) || /\bexport\s+/.test(a);
|
|
958
965
|
}
|
|
959
966
|
class A {
|
|
@@ -977,25 +984,8 @@ class A {
|
|
|
977
984
|
].join(`
|
|
978
985
|
`);
|
|
979
986
|
}
|
|
980
|
-
static async ensureIvmLoaded() {
|
|
981
|
-
var t;
|
|
982
|
-
if (!(y || !(typeof process < "u" && ((t = process.versions) != null && t.node)))) {
|
|
983
|
-
try {
|
|
984
|
-
if (typeof require == "function") {
|
|
985
|
-
y = require("isolated-vm");
|
|
986
|
-
return;
|
|
987
|
-
}
|
|
988
|
-
} catch {
|
|
989
|
-
}
|
|
990
|
-
try {
|
|
991
|
-
const r = await import("isolated-vm").catch(() => null);
|
|
992
|
-
y = (r == null ? void 0 : r.default) ?? r;
|
|
993
|
-
} catch {
|
|
994
|
-
}
|
|
995
|
-
}
|
|
996
|
-
}
|
|
997
987
|
/**
|
|
998
|
-
* Main evaluation method -
|
|
988
|
+
* Main evaluation method - chooses between secure and simple evaluation strategies
|
|
999
989
|
*/
|
|
1000
990
|
static async evaluate({
|
|
1001
991
|
code: e,
|
|
@@ -1003,31 +993,58 @@ class A {
|
|
|
1003
993
|
bindings: n = {},
|
|
1004
994
|
options: o = {}
|
|
1005
995
|
}) {
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
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
|
+
}
|
|
1009
1026
|
}
|
|
1010
1027
|
/**
|
|
1011
1028
|
* Secure evaluation using isolated-vm with support for ES modules
|
|
1012
1029
|
*/
|
|
1013
1030
|
static async evaluateSecure(e, t, n, o = {}) {
|
|
1014
|
-
if (!
|
|
1015
|
-
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;
|
|
1016
1033
|
try {
|
|
1017
1034
|
await this.setupIsolateEnvironment(i, t);
|
|
1018
|
-
const c = /* @__PURE__ */ new Map(),
|
|
1035
|
+
const c = /* @__PURE__ */ new Map(), h = this.createModuleResolver(
|
|
1019
1036
|
r,
|
|
1020
1037
|
s,
|
|
1021
1038
|
c,
|
|
1022
1039
|
n
|
|
1023
1040
|
);
|
|
1024
1041
|
let u;
|
|
1025
|
-
return
|
|
1042
|
+
return te(e) ? u = await this.evaluateESModule(
|
|
1026
1043
|
r,
|
|
1027
1044
|
s,
|
|
1028
1045
|
e,
|
|
1029
1046
|
o,
|
|
1030
|
-
|
|
1047
|
+
h
|
|
1031
1048
|
) : u = await this.evaluateSimpleScript(
|
|
1032
1049
|
r,
|
|
1033
1050
|
s,
|
|
@@ -1036,7 +1053,7 @@ class A {
|
|
|
1036
1053
|
o
|
|
1037
1054
|
), this.deepClone(u);
|
|
1038
1055
|
} catch (c) {
|
|
1039
|
-
throw o.isCodeBlock ? new
|
|
1056
|
+
throw o.isCodeBlock ? new Q(e, c) : new X(e, c);
|
|
1040
1057
|
} finally {
|
|
1041
1058
|
s.release(), r.dispose();
|
|
1042
1059
|
}
|
|
@@ -1045,18 +1062,18 @@ class A {
|
|
|
1045
1062
|
* Setup the isolated VM environment with necessary host functions and data
|
|
1046
1063
|
*/
|
|
1047
1064
|
static async setupIsolateEnvironment(e, t) {
|
|
1048
|
-
if (!
|
|
1049
|
-
const n = new
|
|
1065
|
+
if (!w) throw new Error("isolated-vm not available");
|
|
1066
|
+
const n = new w.Callback(
|
|
1050
1067
|
(...r) => console.log(...r)
|
|
1051
|
-
), o = new
|
|
1068
|
+
), o = new w.ExternalCopy({
|
|
1052
1069
|
log: n
|
|
1053
1070
|
}).copyInto();
|
|
1054
1071
|
await e.set("console", o);
|
|
1055
1072
|
for (const [r, s] of Object.entries(t))
|
|
1056
1073
|
typeof s == "function" ? await e.set(
|
|
1057
1074
|
r,
|
|
1058
|
-
new
|
|
1059
|
-
) : await e.set(r, new
|
|
1075
|
+
new w.Callback(s)
|
|
1076
|
+
) : await e.set(r, new w.ExternalCopy(s).copyInto());
|
|
1060
1077
|
}
|
|
1061
1078
|
/**
|
|
1062
1079
|
* Create module resolver function for handling imports
|
|
@@ -1070,11 +1087,11 @@ class A {
|
|
|
1070
1087
|
throw new Error(
|
|
1071
1088
|
`ProcessingContext is missing a loadBlueContent(blueId) implementation (needed for ${r})`
|
|
1072
1089
|
);
|
|
1073
|
-
const c = await i(s),
|
|
1074
|
-
return n.set(r,
|
|
1090
|
+
const c = await i(s), h = await e.compileModule(c);
|
|
1091
|
+
return n.set(r, h), await h.instantiate(
|
|
1075
1092
|
t,
|
|
1076
1093
|
this.createModuleResolver(e, t, n, o)
|
|
1077
|
-
),
|
|
1094
|
+
), h;
|
|
1078
1095
|
}
|
|
1079
1096
|
if (/^https?:\/\//.test(r)) {
|
|
1080
1097
|
let s;
|
|
@@ -1111,14 +1128,14 @@ class A {
|
|
|
1111
1128
|
static async evaluateESModule(e, t, n, o, r) {
|
|
1112
1129
|
let s = n;
|
|
1113
1130
|
if (o.isCodeBlock) {
|
|
1114
|
-
const
|
|
1131
|
+
const h = /^\s*(import\s.+?;|export\s.+?;)/gm, u = (n.match(h) || []).join(
|
|
1115
1132
|
`
|
|
1116
1133
|
`
|
|
1117
|
-
),
|
|
1134
|
+
), d = n.replace(h, "").trim();
|
|
1118
1135
|
s = `
|
|
1119
1136
|
${u}
|
|
1120
1137
|
const run = function() {
|
|
1121
|
-
${
|
|
1138
|
+
${d}
|
|
1122
1139
|
};
|
|
1123
1140
|
export default run();
|
|
1124
1141
|
`;
|
|
@@ -1144,7 +1161,7 @@ class A {
|
|
|
1144
1161
|
return typeof e > "u" ? e : JSON.parse(JSON.stringify(e));
|
|
1145
1162
|
}
|
|
1146
1163
|
}
|
|
1147
|
-
class
|
|
1164
|
+
class z {
|
|
1148
1165
|
/**
|
|
1149
1166
|
* Creates standard bindings for workflow step execution
|
|
1150
1167
|
*/
|
|
@@ -1160,26 +1177,26 @@ class R {
|
|
|
1160
1177
|
};
|
|
1161
1178
|
}
|
|
1162
1179
|
}
|
|
1163
|
-
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) => {
|
|
1164
1181
|
if (!T(a))
|
|
1165
1182
|
throw new Error(`Invalid expression: ${a}`);
|
|
1166
1183
|
return a.slice(2, -1);
|
|
1167
1184
|
};
|
|
1168
1185
|
class q {
|
|
1169
1186
|
static createBindings(e, t, n) {
|
|
1170
|
-
return
|
|
1187
|
+
return z.createStandardBindings(e, t, n);
|
|
1171
1188
|
}
|
|
1172
1189
|
static async evaluate(e, t, n, o) {
|
|
1173
1190
|
const { coerceToString: r } = o;
|
|
1174
1191
|
if (T(e)) {
|
|
1175
|
-
const s =
|
|
1192
|
+
const s = de(e), i = await A.evaluate({
|
|
1176
1193
|
code: s,
|
|
1177
1194
|
ctx: t,
|
|
1178
1195
|
bindings: n
|
|
1179
1196
|
});
|
|
1180
1197
|
return r ? String(i ?? "") : i;
|
|
1181
1198
|
}
|
|
1182
|
-
if (
|
|
1199
|
+
if (J(e)) {
|
|
1183
1200
|
const i = `\`${String(e).replace(/`/g, "\\`")}\``, c = await A.evaluate({
|
|
1184
1201
|
code: i,
|
|
1185
1202
|
ctx: t,
|
|
@@ -1190,7 +1207,7 @@ class q {
|
|
|
1190
1207
|
return r ? String(e) : e;
|
|
1191
1208
|
}
|
|
1192
1209
|
}
|
|
1193
|
-
function
|
|
1210
|
+
function ne(a, e) {
|
|
1194
1211
|
const { op: t, path: n, val: o, from: r } = a;
|
|
1195
1212
|
if ((t === "move" || t === "copy") && !r)
|
|
1196
1213
|
throw new Error(`${t} operation requires 'from' path`);
|
|
@@ -1203,12 +1220,12 @@ function Z(a, e) {
|
|
|
1203
1220
|
};
|
|
1204
1221
|
return o !== void 0 && (s.val = o), r !== void 0 && (s.from = r), e.jsonValueToNode(s);
|
|
1205
1222
|
}
|
|
1206
|
-
function
|
|
1223
|
+
function it(a) {
|
|
1207
1224
|
return a.jsonValueToNode({
|
|
1208
1225
|
type: "Document Processing Initiated"
|
|
1209
1226
|
});
|
|
1210
1227
|
}
|
|
1211
|
-
class
|
|
1228
|
+
class ct {
|
|
1212
1229
|
constructor() {
|
|
1213
1230
|
l(this, "stepType", "Update Document");
|
|
1214
1231
|
}
|
|
@@ -1223,14 +1240,14 @@ class it {
|
|
|
1223
1240
|
n,
|
|
1224
1241
|
t,
|
|
1225
1242
|
r
|
|
1226
|
-
), c =
|
|
1243
|
+
), c = re(e, {
|
|
1227
1244
|
op: "replace",
|
|
1228
1245
|
path: "/changeset",
|
|
1229
1246
|
val: i
|
|
1230
|
-
}),
|
|
1231
|
-
for (const u of
|
|
1247
|
+
}), h = n.getBlue().nodeToSchemaOutput(c, j);
|
|
1248
|
+
for (const u of h.changeset ?? []) {
|
|
1232
1249
|
if (!u.path) continue;
|
|
1233
|
-
const
|
|
1250
|
+
const d = await this.evaluateChangePath(
|
|
1234
1251
|
u.path,
|
|
1235
1252
|
n,
|
|
1236
1253
|
t,
|
|
@@ -1245,13 +1262,13 @@ class it {
|
|
|
1245
1262
|
);
|
|
1246
1263
|
n.addPatch({
|
|
1247
1264
|
op: u.op,
|
|
1248
|
-
path:
|
|
1265
|
+
path: d,
|
|
1249
1266
|
val: m
|
|
1250
1267
|
}), n.emitEvent({
|
|
1251
|
-
payload:
|
|
1268
|
+
payload: ne(
|
|
1252
1269
|
{
|
|
1253
1270
|
op: u.op,
|
|
1254
|
-
path: n.resolvePath(
|
|
1271
|
+
path: n.resolvePath(d),
|
|
1255
1272
|
val: s.nodeToJson(m, "original")
|
|
1256
1273
|
},
|
|
1257
1274
|
s
|
|
@@ -1259,11 +1276,11 @@ class it {
|
|
|
1259
1276
|
emissionType: "update"
|
|
1260
1277
|
});
|
|
1261
1278
|
}
|
|
1262
|
-
u.op === "remove" && (n.addPatch({ op: u.op, path:
|
|
1263
|
-
payload:
|
|
1279
|
+
u.op === "remove" && (n.addPatch({ op: u.op, path: d }), n.emitEvent({
|
|
1280
|
+
payload: ne(
|
|
1264
1281
|
{
|
|
1265
1282
|
op: u.op,
|
|
1266
|
-
path: n.resolvePath(
|
|
1283
|
+
path: n.resolvePath(d),
|
|
1267
1284
|
val: null
|
|
1268
1285
|
},
|
|
1269
1286
|
s
|
|
@@ -1275,10 +1292,10 @@ class it {
|
|
|
1275
1292
|
async evaluateChangeset(e, t, n, o) {
|
|
1276
1293
|
const r = t.getBlue();
|
|
1277
1294
|
if (T(e)) {
|
|
1278
|
-
const s =
|
|
1295
|
+
const s = de(e), i = await A.evaluate({
|
|
1279
1296
|
code: s,
|
|
1280
1297
|
ctx: t,
|
|
1281
|
-
bindings:
|
|
1298
|
+
bindings: z.createStandardBindings(
|
|
1282
1299
|
t,
|
|
1283
1300
|
n,
|
|
1284
1301
|
o
|
|
@@ -1292,7 +1309,7 @@ class it {
|
|
|
1292
1309
|
}
|
|
1293
1310
|
async evaluateChangeValue(e, t, n, o) {
|
|
1294
1311
|
const r = e.getValue(), s = t.getBlue();
|
|
1295
|
-
if (T(r) || typeof r == "string" &&
|
|
1312
|
+
if (T(r) || typeof r == "string" && J(r)) {
|
|
1296
1313
|
const i = q.createBindings(
|
|
1297
1314
|
t,
|
|
1298
1315
|
n,
|
|
@@ -1309,7 +1326,7 @@ class it {
|
|
|
1309
1326
|
}
|
|
1310
1327
|
async evaluateChangePath(e, t, n, o) {
|
|
1311
1328
|
const r = q.createBindings(t, n, o);
|
|
1312
|
-
if (T(e) ||
|
|
1329
|
+
if (T(e) || J(e)) {
|
|
1313
1330
|
const s = await q.evaluate(e, t, r, {
|
|
1314
1331
|
coerceToString: !0
|
|
1315
1332
|
});
|
|
@@ -1318,7 +1335,7 @@ class it {
|
|
|
1318
1335
|
return e;
|
|
1319
1336
|
}
|
|
1320
1337
|
}
|
|
1321
|
-
class
|
|
1338
|
+
class lt {
|
|
1322
1339
|
constructor() {
|
|
1323
1340
|
l(this, "stepType", "Trigger Event");
|
|
1324
1341
|
}
|
|
@@ -1335,7 +1352,7 @@ class ct {
|
|
|
1335
1352
|
});
|
|
1336
1353
|
}
|
|
1337
1354
|
}
|
|
1338
|
-
class
|
|
1355
|
+
class ut {
|
|
1339
1356
|
constructor() {
|
|
1340
1357
|
l(this, "stepType", "JavaScript Code");
|
|
1341
1358
|
}
|
|
@@ -1353,16 +1370,16 @@ class lt {
|
|
|
1353
1370
|
const c = await A.evaluate({
|
|
1354
1371
|
code: i.code,
|
|
1355
1372
|
ctx: n,
|
|
1356
|
-
bindings:
|
|
1373
|
+
bindings: z.createStandardBindings(n, t, r),
|
|
1357
1374
|
options: {
|
|
1358
1375
|
isCodeBlock: !0,
|
|
1359
1376
|
timeout: 500
|
|
1360
1377
|
}
|
|
1361
1378
|
});
|
|
1362
1379
|
if (c && typeof c == "object" && "events" in c) {
|
|
1363
|
-
const
|
|
1364
|
-
if (Array.isArray(
|
|
1365
|
-
for (const u of
|
|
1380
|
+
const h = c;
|
|
1381
|
+
if (Array.isArray(h.events))
|
|
1382
|
+
for (const u of h.events)
|
|
1366
1383
|
n.emitEvent({
|
|
1367
1384
|
payload: s.jsonValueToNode(u),
|
|
1368
1385
|
emissionType: "triggered"
|
|
@@ -1371,15 +1388,15 @@ class lt {
|
|
|
1371
1388
|
return c;
|
|
1372
1389
|
}
|
|
1373
1390
|
}
|
|
1374
|
-
const
|
|
1375
|
-
new it(),
|
|
1391
|
+
const ht = [
|
|
1376
1392
|
new ct(),
|
|
1377
|
-
new lt()
|
|
1393
|
+
new lt(),
|
|
1394
|
+
new ut()
|
|
1378
1395
|
];
|
|
1379
|
-
class
|
|
1380
|
-
constructor(e =
|
|
1396
|
+
class pe {
|
|
1397
|
+
constructor(e = ht) {
|
|
1381
1398
|
l(this, "contractType", "Sequential Workflow");
|
|
1382
|
-
l(this, "contractBlueId",
|
|
1399
|
+
l(this, "contractBlueId", y["Sequential Workflow"]);
|
|
1383
1400
|
l(this, "role", "handler");
|
|
1384
1401
|
l(this, "executors", []);
|
|
1385
1402
|
this.executors = e;
|
|
@@ -1391,27 +1408,27 @@ class le {
|
|
|
1391
1408
|
supports(e, t, n) {
|
|
1392
1409
|
const r = n.getBlue().nodeToSchemaOutput(
|
|
1393
1410
|
t,
|
|
1394
|
-
|
|
1411
|
+
Ie
|
|
1395
1412
|
), s = this.isChannelNameMatch(e, r), i = this.isEventPatternMatch(e, t, n);
|
|
1396
1413
|
return s && i;
|
|
1397
1414
|
}
|
|
1398
1415
|
async handle(e, t, n, o) {
|
|
1399
1416
|
var i;
|
|
1400
1417
|
const r = {}, s = (i = t.getProperties()) == null ? void 0 : i.steps.getItems();
|
|
1401
|
-
for (const [c,
|
|
1402
|
-
const u = this.executors.find((p) => p.supports(
|
|
1418
|
+
for (const [c, h] of (s ?? []).entries()) {
|
|
1419
|
+
const u = this.executors.find((p) => p.supports(h));
|
|
1403
1420
|
if (!u)
|
|
1404
|
-
throw new Error(`Unsupported workflow step type "${
|
|
1405
|
-
const
|
|
1406
|
-
|
|
1421
|
+
throw new Error(`Unsupported workflow step type "${h.getType()}"`);
|
|
1422
|
+
const d = await u.execute(
|
|
1423
|
+
h,
|
|
1407
1424
|
e,
|
|
1408
1425
|
n,
|
|
1409
1426
|
o,
|
|
1410
1427
|
r
|
|
1411
1428
|
);
|
|
1412
|
-
if (
|
|
1413
|
-
const p =
|
|
1414
|
-
r[m] =
|
|
1429
|
+
if (d !== void 0) {
|
|
1430
|
+
const p = h.getName(), m = typeof p == "string" ? p : `Step${c + 1}`;
|
|
1431
|
+
r[m] = d;
|
|
1415
1432
|
}
|
|
1416
1433
|
await n.flush();
|
|
1417
1434
|
}
|
|
@@ -1439,15 +1456,15 @@ class le {
|
|
|
1439
1456
|
class dt {
|
|
1440
1457
|
constructor(e) {
|
|
1441
1458
|
l(this, "contractType", "Sequential Workflow Operation");
|
|
1442
|
-
l(this, "contractBlueId",
|
|
1459
|
+
l(this, "contractBlueId", y["Sequential Workflow Operation"]);
|
|
1443
1460
|
l(this, "role", "handler");
|
|
1444
1461
|
l(this, "sequentialWorkflowProcessor");
|
|
1445
|
-
this.sequentialWorkflowProcessor = e || new
|
|
1462
|
+
this.sequentialWorkflowProcessor = e || new pe();
|
|
1446
1463
|
}
|
|
1447
1464
|
supports(e, t, n) {
|
|
1448
1465
|
const s = n.getBlue().nodeToSchemaOutput(
|
|
1449
1466
|
t,
|
|
1450
|
-
|
|
1467
|
+
Be
|
|
1451
1468
|
).operation, i = e.channelName;
|
|
1452
1469
|
return e.source === "channel" && M(i) && M(s) && i === s;
|
|
1453
1470
|
}
|
|
@@ -1462,35 +1479,35 @@ class dt {
|
|
|
1462
1479
|
}
|
|
1463
1480
|
}
|
|
1464
1481
|
}
|
|
1465
|
-
const
|
|
1466
|
-
class
|
|
1482
|
+
const oe = (a) => P.isTypeOf(a.payload, O);
|
|
1483
|
+
class pt extends C {
|
|
1467
1484
|
constructor() {
|
|
1468
1485
|
super(...arguments);
|
|
1469
1486
|
l(this, "contractType", "Timeline Channel");
|
|
1470
|
-
l(this, "contractBlueId",
|
|
1487
|
+
l(this, "contractBlueId", y["Timeline Channel"]);
|
|
1471
1488
|
}
|
|
1472
1489
|
supports(t, n, o) {
|
|
1473
1490
|
var u;
|
|
1474
|
-
if (!this.baseSupports(t) || !
|
|
1491
|
+
if (!this.baseSupports(t) || !oe(t)) return !1;
|
|
1475
1492
|
const s = o.getBlue().nodeToSchemaOutput(
|
|
1476
1493
|
t.payload,
|
|
1477
1494
|
O
|
|
1478
|
-
), i = o.getBlue().nodeToSchemaOutput(n,
|
|
1479
|
-
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;
|
|
1480
1497
|
}
|
|
1481
1498
|
handle(t, n, o, r) {
|
|
1482
|
-
|
|
1499
|
+
oe(t) && o.emitEvent({
|
|
1483
1500
|
payload: t.payload,
|
|
1484
1501
|
channelName: r,
|
|
1485
1502
|
source: "channel"
|
|
1486
1503
|
});
|
|
1487
1504
|
}
|
|
1488
1505
|
}
|
|
1489
|
-
class
|
|
1506
|
+
class mt extends C {
|
|
1490
1507
|
constructor() {
|
|
1491
1508
|
super(...arguments);
|
|
1492
1509
|
l(this, "contractType", "Triggered Event Channel");
|
|
1493
|
-
l(this, "contractBlueId",
|
|
1510
|
+
l(this, "contractBlueId", y["Triggered Event Channel"]);
|
|
1494
1511
|
}
|
|
1495
1512
|
supports(t) {
|
|
1496
1513
|
return this.baseSupports(t) ? t.emissionType === "triggered" : !1;
|
|
@@ -1503,45 +1520,45 @@ class pt extends C {
|
|
|
1503
1520
|
});
|
|
1504
1521
|
}
|
|
1505
1522
|
}
|
|
1506
|
-
const
|
|
1507
|
-
new
|
|
1523
|
+
const ft = [
|
|
1524
|
+
new rt(),
|
|
1508
1525
|
// channels
|
|
1509
|
-
new Ge(),
|
|
1510
|
-
new Qe(),
|
|
1511
|
-
new ht(),
|
|
1512
|
-
new Ze(),
|
|
1513
|
-
new et(),
|
|
1514
|
-
new Xe(),
|
|
1515
1526
|
new Ye(),
|
|
1527
|
+
new Ge(),
|
|
1516
1528
|
new pt(),
|
|
1517
1529
|
new tt(),
|
|
1530
|
+
new nt(),
|
|
1531
|
+
new Ke(),
|
|
1532
|
+
new et(),
|
|
1533
|
+
new mt(),
|
|
1534
|
+
new ot(),
|
|
1518
1535
|
// sequential workflows
|
|
1519
|
-
new
|
|
1536
|
+
new pe(),
|
|
1520
1537
|
new dt(),
|
|
1521
1538
|
// markers
|
|
1522
|
-
new
|
|
1539
|
+
new Ze()
|
|
1523
1540
|
];
|
|
1524
|
-
class
|
|
1541
|
+
class bt {
|
|
1525
1542
|
/**
|
|
1526
1543
|
* Creates a new document processor
|
|
1527
1544
|
*
|
|
1528
1545
|
* @param processors - Initial list of processors to register
|
|
1529
1546
|
*/
|
|
1530
|
-
constructor(e, t =
|
|
1547
|
+
constructor(e, t = ft) {
|
|
1531
1548
|
l(this, "taskCounter", 0);
|
|
1532
1549
|
l(this, "eventCounter", 0);
|
|
1533
1550
|
l(this, "registry");
|
|
1534
1551
|
l(this, "queue");
|
|
1535
1552
|
l(this, "router");
|
|
1536
|
-
l(this, "checkpointCache", new
|
|
1537
|
-
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(
|
|
1538
1555
|
this.blue,
|
|
1539
1556
|
this.registry,
|
|
1540
1557
|
this.queue,
|
|
1541
1558
|
() => ++this.taskCounter,
|
|
1542
1559
|
() => ++this.eventCounter
|
|
1543
1560
|
), this.register(
|
|
1544
|
-
new
|
|
1561
|
+
new Xe(this.checkpointCache),
|
|
1545
1562
|
9999
|
|
1546
1563
|
);
|
|
1547
1564
|
}
|
|
@@ -1561,15 +1578,15 @@ class Tt {
|
|
|
1561
1578
|
* @returns Processing result with final state and emitted events
|
|
1562
1579
|
*/
|
|
1563
1580
|
async initialize(e) {
|
|
1564
|
-
let t =
|
|
1581
|
+
let t = Y(I(e), this.blue);
|
|
1565
1582
|
const n = {
|
|
1566
|
-
payload:
|
|
1583
|
+
payload: it(this.blue),
|
|
1567
1584
|
source: "internal",
|
|
1568
1585
|
emissionType: "lifecycle"
|
|
1569
1586
|
}, o = [n.payload];
|
|
1570
1587
|
await this.router.route(t, [], n, 0);
|
|
1571
1588
|
const r = await this.drainQueue(t);
|
|
1572
|
-
return t = r.state, o.push(...r.emitted), t =
|
|
1589
|
+
return t = r.state, o.push(...r.emitted), t = He(t, this.blue), { state: $(t), emitted: o };
|
|
1573
1590
|
}
|
|
1574
1591
|
/**
|
|
1575
1592
|
* Processes a batch of events against the document
|
|
@@ -1579,9 +1596,9 @@ class Tt {
|
|
|
1579
1596
|
* @returns Processing result with final state and emitted events
|
|
1580
1597
|
*/
|
|
1581
1598
|
async processEvents(e, t) {
|
|
1582
|
-
let n =
|
|
1599
|
+
let n = Y(I(e), this.blue);
|
|
1583
1600
|
const o = [];
|
|
1584
|
-
if (!
|
|
1601
|
+
if (!ue(n, this.blue))
|
|
1585
1602
|
throw new Error("Document is not initialized");
|
|
1586
1603
|
for (const r of t)
|
|
1587
1604
|
try {
|
|
@@ -1590,7 +1607,7 @@ class Tt {
|
|
|
1590
1607
|
const i = await this.drainQueue(n);
|
|
1591
1608
|
n = i.state, o.push(...i.emitted);
|
|
1592
1609
|
const c = this.checkpointCache.flush(n);
|
|
1593
|
-
c.length && (n =
|
|
1610
|
+
c.length && (n = G(n, c));
|
|
1594
1611
|
} finally {
|
|
1595
1612
|
this.checkpointCache.clear();
|
|
1596
1613
|
}
|
|
@@ -1607,52 +1624,52 @@ class Tt {
|
|
|
1607
1624
|
for (; this.queue.length; ) {
|
|
1608
1625
|
if (++r > o)
|
|
1609
1626
|
throw new Error("Possible cycle – too many iterations");
|
|
1610
|
-
const i = this.queue.pop(), { nodePath: c, contractName:
|
|
1611
|
-
if (!S(p) || !((s = p.getContracts()) != null && s[
|
|
1627
|
+
const i = this.queue.pop(), { nodePath: c, contractName: h, contractNode: u, event: d } = i, p = t.get(c);
|
|
1628
|
+
if (!S(p) || !((s = p.getContracts()) != null && s[h]) || !u.getType()) continue;
|
|
1612
1629
|
const m = this.registry.get(u.getType());
|
|
1613
1630
|
if (!m) {
|
|
1614
|
-
console.warn(`No processor registered for contract: ${
|
|
1631
|
+
console.warn(`No processor registered for contract: ${h}`);
|
|
1615
1632
|
continue;
|
|
1616
1633
|
}
|
|
1617
|
-
const
|
|
1634
|
+
const v = new ie(
|
|
1618
1635
|
() => t,
|
|
1619
1636
|
i,
|
|
1620
1637
|
this.blue,
|
|
1621
|
-
async (
|
|
1622
|
-
for (const f of
|
|
1638
|
+
async (E) => {
|
|
1639
|
+
for (const f of E)
|
|
1623
1640
|
if (f.kind === "patch") {
|
|
1624
|
-
const D =
|
|
1641
|
+
const D = U(
|
|
1625
1642
|
t,
|
|
1626
1643
|
this.blue
|
|
1627
1644
|
);
|
|
1628
1645
|
for (const N of D) {
|
|
1629
|
-
const
|
|
1630
|
-
(
|
|
1631
|
-
),
|
|
1632
|
-
|
|
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,
|
|
1633
1650
|
N.absPath
|
|
1634
1651
|
);
|
|
1635
|
-
if (
|
|
1636
|
-
throw new
|
|
1652
|
+
if (ye && !ge)
|
|
1653
|
+
throw new le(
|
|
1637
1654
|
f.patch,
|
|
1638
1655
|
N.absPath,
|
|
1639
|
-
|
|
1656
|
+
R
|
|
1640
1657
|
);
|
|
1641
1658
|
}
|
|
1642
1659
|
try {
|
|
1643
|
-
t =
|
|
1660
|
+
t = G(t, [f.patch]);
|
|
1644
1661
|
} catch (N) {
|
|
1645
|
-
throw
|
|
1662
|
+
throw Re(h, d, N), N;
|
|
1646
1663
|
}
|
|
1647
1664
|
} else f.kind === "event" && (n.push(f.event.payload), await this.router.route(t, [], f.event, i.key[5]));
|
|
1648
1665
|
}
|
|
1649
1666
|
);
|
|
1650
|
-
await m.handle(
|
|
1667
|
+
await m.handle(d, u, v, h), await v.flush();
|
|
1651
1668
|
}
|
|
1652
1669
|
return { state: t, emitted: n };
|
|
1653
1670
|
}
|
|
1654
1671
|
}
|
|
1655
|
-
class
|
|
1672
|
+
class me {
|
|
1656
1673
|
process(e, t) {
|
|
1657
1674
|
const n = t.getValue();
|
|
1658
1675
|
if (T(n)) {
|
|
@@ -1673,14 +1690,14 @@ class ue {
|
|
|
1673
1690
|
return e;
|
|
1674
1691
|
}
|
|
1675
1692
|
}
|
|
1676
|
-
const
|
|
1693
|
+
const Pt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1677
1694
|
__proto__: null,
|
|
1678
|
-
ExpressionPreserver:
|
|
1695
|
+
ExpressionPreserver: me
|
|
1679
1696
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
1680
|
-
function
|
|
1697
|
+
function St() {
|
|
1681
1698
|
return new k.SequentialMergingProcessor([
|
|
1682
1699
|
new k.ValuePropagator(),
|
|
1683
|
-
new
|
|
1700
|
+
new me(),
|
|
1684
1701
|
new k.TypeAssigner(),
|
|
1685
1702
|
new k.ListProcessor(),
|
|
1686
1703
|
new k.DictionaryProcessor(),
|
|
@@ -1688,26 +1705,26 @@ function Pt() {
|
|
|
1688
1705
|
]);
|
|
1689
1706
|
}
|
|
1690
1707
|
export {
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
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,
|
|
1718
|
+
Pt as MergingProcessors,
|
|
1719
|
+
nt as MyOSAgentChannelProcessor,
|
|
1720
|
+
tt as MyOSTimelineChannelProcessor,
|
|
1721
|
+
ot as OperationProcessor,
|
|
1722
|
+
ce as PatchApplicationError,
|
|
1723
|
+
rt as ProcessEmbeddedProcessor,
|
|
1707
1724
|
dt as SequentialWorkflowOperationProcessor,
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1725
|
+
pe as SequentialWorkflowProcessor,
|
|
1726
|
+
pt as TimelineChannelProcessor,
|
|
1727
|
+
mt as TriggeredEventChannelProcessor,
|
|
1728
|
+
U as collectEmbeddedPathSpecs,
|
|
1729
|
+
St as createDefaultMergingProcessor
|
|
1713
1730
|
};
|