@blue-labs/document-processor 1.23.0 → 1.24.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/BlueDocumentProcessor.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.mjs +215 -214
- package/dist/processors/InitializedMarkerProcessor.d.ts +1 -1
- package/dist/processors/InitializedMarkerProcessor.d.ts.map +1 -1
- package/dist/processors/LifecycleEventChannelProcessor.d.ts +1 -1
- package/dist/processors/LifecycleEventChannelProcessor.d.ts.map +1 -1
- package/dist/processors/OperationProcessor.d.ts.map +1 -1
- package/dist/processors/TimelineChannelProcessor.d.ts.map +1 -1
- package/dist/testUtils.d.ts +15 -0
- package/dist/testUtils.d.ts.map +1 -0
- package/dist/utils/initialized.d.ts +1 -0
- package/dist/utils/initialized.d.ts.map +1 -1
- package/package.json +5 -5
- package/dist/mocks/blueIds.d.ts +0 -5
- package/dist/mocks/blueIds.d.ts.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
var le = Object.defineProperty;
|
|
2
2
|
var ue = (c, e, t) => e in c ? le(c, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : c[e] = t;
|
|
3
3
|
var l = (c, e, t) => ue(c, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
-
import { ProcessEmbeddedSchema as
|
|
5
|
-
import { applyBlueNodePatch as
|
|
6
|
-
import { deepFreeze as
|
|
7
|
-
import { blueIds as
|
|
4
|
+
import { ProcessEmbeddedSchema as M, ChannelEventCheckpointSchema as he, blueIds as y, InitializedMarkerSchema as de, CompositeTimelineChannelSchema as pe, DocumentUpdateChannelSchema as me, EmbeddedNodeChannelSchema as x, OperationSchema as fe, TimelineEntrySchema as $, OperationRequestSchema as ye, UpdateDocumentSchema as N, TriggerEventSchema as B, JavaScriptCodeSchema as O, SequentialWorkflowSchema as ge, SequentialWorkflowOperationSchema as Ee, TimelineChannelSchema as we } from "@blue-repository/core-dev";
|
|
5
|
+
import { applyBlueNodePatch as Q, BlueNodeTypeSchema as T, BlueNode as ve, isBigNumber as K } from "@blue-labs/language";
|
|
6
|
+
import { deepFreeze as k, isNonNullable as I, deepContains as X } from "@blue-labs/shared-utils";
|
|
7
|
+
import { blueIds as Y, MyOSTimelineEntrySchema as Te, MyOSTimelineChannelSchema as be, MyOSAgentEventSchema as Pe, MyOSAgentChannelSchema as Se } from "@blue-repository/myos-dev";
|
|
8
8
|
const Ce = (c, e) => ({
|
|
9
9
|
on: (t, n) => ({ end: () => n(null) })
|
|
10
10
|
});
|
|
11
|
-
async function
|
|
11
|
+
async function ke(c) {
|
|
12
12
|
return new Promise((e, t) => {
|
|
13
13
|
Ce().on("error", t).end();
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
|
-
const
|
|
16
|
+
const v = (...c) => c.map((e, t) => {
|
|
17
17
|
if (typeof e != "string") return "";
|
|
18
18
|
if (t === 0 && e === "/") return "/";
|
|
19
19
|
const n = t > 0 ? e.replace(/^\/+/, "") : e;
|
|
20
20
|
return t < c.length - 1 ? n.replace(/\/+$/, "") : n;
|
|
21
21
|
}).filter(Boolean).join("/").replace(/\/{2,}/g, "/");
|
|
22
|
-
class
|
|
22
|
+
class Z {
|
|
23
23
|
constructor(e, t, n, o) {
|
|
24
24
|
l(this, "actions", []);
|
|
25
25
|
this.getDocument = e, this.taskInfo = t, this.blue = n, this.onFlush = o;
|
|
26
26
|
}
|
|
27
27
|
get(e) {
|
|
28
|
-
const t = this.getDocument(), n =
|
|
28
|
+
const t = this.getDocument(), n = v(this.taskInfo.nodePath, e);
|
|
29
29
|
return t.get(n);
|
|
30
30
|
}
|
|
31
31
|
addPatch(e) {
|
|
@@ -33,7 +33,7 @@ class G {
|
|
|
33
33
|
kind: "patch",
|
|
34
34
|
patch: {
|
|
35
35
|
...e,
|
|
36
|
-
path:
|
|
36
|
+
path: v(this.taskInfo.nodePath, e.path)
|
|
37
37
|
}
|
|
38
38
|
});
|
|
39
39
|
}
|
|
@@ -56,7 +56,7 @@ class G {
|
|
|
56
56
|
return this.taskInfo.nodePath;
|
|
57
57
|
}
|
|
58
58
|
resolvePath(e) {
|
|
59
|
-
return
|
|
59
|
+
return v(this.taskInfo.nodePath, e);
|
|
60
60
|
}
|
|
61
61
|
getTaskInfo() {
|
|
62
62
|
return this.taskInfo;
|
|
@@ -68,53 +68,53 @@ class G {
|
|
|
68
68
|
loadExternalModule(e) {
|
|
69
69
|
if (!/^https?:\/\//.test(e))
|
|
70
70
|
throw new Error("Only http/https URLs are allowed");
|
|
71
|
-
return
|
|
71
|
+
return ke();
|
|
72
72
|
}
|
|
73
73
|
loadBlueContent(e) {
|
|
74
74
|
throw new Error("Not implemented");
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
|
-
class
|
|
77
|
+
class G extends Error {
|
|
78
78
|
constructor(e, t) {
|
|
79
79
|
super(`Cannot apply patch ${JSON.stringify(e)}`), this.patch = e, this.cause = t, this.name = "PatchApplicationError";
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
|
-
class
|
|
82
|
+
class ee extends Error {
|
|
83
83
|
constructor(e, t, n) {
|
|
84
84
|
super(
|
|
85
85
|
`Patch ${JSON.stringify(e)} touches "${e.op === "move" || e.op === "copy" ? `${e.from} → ${e.path}` : e.path}" which is inside embedded document "${t}" (Process Embedded @ "${n}")`
|
|
86
86
|
), this.patch = e, this.offendingPath = t, this.contractNodePath = n, this.name = "EmbeddedDocumentModificationError";
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
|
-
class
|
|
89
|
+
class W extends Error {
|
|
90
90
|
constructor(e, t) {
|
|
91
91
|
super(`Failed to evaluate expression "${e}"`), this.code = e, this.cause = t, this.name = "ExpressionEvaluationError";
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
|
-
class
|
|
94
|
+
class V extends Error {
|
|
95
95
|
constructor(e, t) {
|
|
96
96
|
super(`Failed to evaluate code block "${e}"`), this.code = e, this.cause = t, this.name = "CodeBlockEvaluationError";
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
|
-
function
|
|
99
|
+
function D(c, e, t = "/", n = []) {
|
|
100
100
|
const o = c.getContracts() ?? {};
|
|
101
101
|
for (const [a, r] of Object.entries(o))
|
|
102
|
-
if (
|
|
102
|
+
if (T.isTypeOf(
|
|
103
103
|
r,
|
|
104
|
-
|
|
104
|
+
M
|
|
105
105
|
)) {
|
|
106
106
|
const u = e.nodeToSchemaOutput(
|
|
107
107
|
r,
|
|
108
|
-
|
|
108
|
+
M
|
|
109
109
|
).paths ?? [];
|
|
110
110
|
for (const h of u)
|
|
111
111
|
n.push({
|
|
112
|
-
absPath:
|
|
113
|
-
contractPath:
|
|
112
|
+
absPath: v(t, h),
|
|
113
|
+
contractPath: v(t, `contracts/${a}`)
|
|
114
114
|
});
|
|
115
115
|
}
|
|
116
116
|
for (const [a, r] of Object.entries(c.getProperties() ?? {}))
|
|
117
|
-
|
|
117
|
+
D(r, e, v(t, a), n);
|
|
118
118
|
return n;
|
|
119
119
|
}
|
|
120
120
|
function F(c, e) {
|
|
@@ -125,19 +125,19 @@ function J(c, e) {
|
|
|
125
125
|
let t = c.clone();
|
|
126
126
|
for (const n of e)
|
|
127
127
|
try {
|
|
128
|
-
t =
|
|
128
|
+
t = Q(t, n, !0);
|
|
129
129
|
} catch (o) {
|
|
130
|
-
throw new
|
|
130
|
+
throw new G(n, o);
|
|
131
131
|
}
|
|
132
|
-
return
|
|
132
|
+
return k(t);
|
|
133
133
|
}
|
|
134
134
|
function f(c) {
|
|
135
135
|
return c != null;
|
|
136
136
|
}
|
|
137
|
-
function
|
|
137
|
+
function P(c) {
|
|
138
138
|
return c instanceof ve;
|
|
139
139
|
}
|
|
140
|
-
class
|
|
140
|
+
class Ie {
|
|
141
141
|
constructor(e = [], t = (n, o) => n < o ? -1 : n > o ? 1 : 0) {
|
|
142
142
|
l(this, "data");
|
|
143
143
|
l(this, "length");
|
|
@@ -176,14 +176,14 @@ class ke {
|
|
|
176
176
|
t[e] = a;
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
|
-
const
|
|
179
|
+
const Ne = (c, e, t, n, o, a) => [
|
|
180
180
|
-c,
|
|
181
181
|
e,
|
|
182
182
|
t,
|
|
183
183
|
n,
|
|
184
184
|
o,
|
|
185
185
|
a
|
|
186
|
-
],
|
|
186
|
+
], Be = (c, e) => {
|
|
187
187
|
for (let t = 0; t < c.key.length; t++) {
|
|
188
188
|
const n = c.key[t], o = e.key[t];
|
|
189
189
|
if (n !== o)
|
|
@@ -191,13 +191,13 @@ const Ie = (c, e, t, n, o, a) => [
|
|
|
191
191
|
}
|
|
192
192
|
return 0;
|
|
193
193
|
};
|
|
194
|
-
class
|
|
194
|
+
class Oe {
|
|
195
195
|
/**
|
|
196
196
|
* Creates a new task queue with the task key comparator
|
|
197
197
|
*/
|
|
198
198
|
constructor() {
|
|
199
199
|
l(this, "queue");
|
|
200
|
-
this.queue = new
|
|
200
|
+
this.queue = new Ie([], Be);
|
|
201
201
|
}
|
|
202
202
|
/**
|
|
203
203
|
* Adds a task to the queue
|
|
@@ -222,7 +222,7 @@ class Be {
|
|
|
222
222
|
return this.queue.length;
|
|
223
223
|
}
|
|
224
224
|
}
|
|
225
|
-
class
|
|
225
|
+
class Me {
|
|
226
226
|
/**
|
|
227
227
|
* Creates a new contract registry
|
|
228
228
|
*
|
|
@@ -277,7 +277,7 @@ class Oe {
|
|
|
277
277
|
return this.processors.values();
|
|
278
278
|
}
|
|
279
279
|
}
|
|
280
|
-
class
|
|
280
|
+
class $e {
|
|
281
281
|
constructor() {
|
|
282
282
|
l(this, "isEnabled");
|
|
283
283
|
this.isEnabled = process.env.TRACE_BLUE_ENABLED === "true";
|
|
@@ -344,8 +344,8 @@ class Me {
|
|
|
344
344
|
return this.isEnabled;
|
|
345
345
|
}
|
|
346
346
|
}
|
|
347
|
-
const
|
|
348
|
-
class
|
|
347
|
+
const qe = 64;
|
|
348
|
+
class Ae {
|
|
349
349
|
/**
|
|
350
350
|
* Creates a new event router
|
|
351
351
|
*
|
|
@@ -356,7 +356,7 @@ class qe {
|
|
|
356
356
|
*/
|
|
357
357
|
constructor(e, t, n, o, a) {
|
|
358
358
|
l(this, "traceManager");
|
|
359
|
-
this.blue = e, this.registry = t, this.queue = n, this.getNextTaskId = o, this.getNextEventSeq = a, this.traceManager = new
|
|
359
|
+
this.blue = e, this.registry = t, this.queue = n, this.getNextTaskId = o, this.getNextEventSeq = a, this.traceManager = new $e();
|
|
360
360
|
}
|
|
361
361
|
/**
|
|
362
362
|
* Routes an event to matching contracts in the document
|
|
@@ -379,8 +379,8 @@ class qe {
|
|
|
379
379
|
return this.route(e, u, n, o, a);
|
|
380
380
|
}
|
|
381
381
|
}
|
|
382
|
-
const r =
|
|
383
|
-
|
|
382
|
+
const r = v("/", t.join("/")), s = e.get(r);
|
|
383
|
+
P(s) && await this.traverseContracts({
|
|
384
384
|
doc: e,
|
|
385
385
|
node: s,
|
|
386
386
|
nodePath: r,
|
|
@@ -418,7 +418,7 @@ class qe {
|
|
|
418
418
|
contractName: u,
|
|
419
419
|
contractNode: h,
|
|
420
420
|
event: a
|
|
421
|
-
}, m = new
|
|
421
|
+
}, m = new Z(() => t, p, this.blue);
|
|
422
422
|
if (d.supports(a, h, m, u))
|
|
423
423
|
switch (d.role) {
|
|
424
424
|
case "adapter":
|
|
@@ -450,7 +450,7 @@ class qe {
|
|
|
450
450
|
* Processes an adapter contract and routes any emitted events
|
|
451
451
|
*/
|
|
452
452
|
async processAdapter(e) {
|
|
453
|
-
var
|
|
453
|
+
var E;
|
|
454
454
|
const {
|
|
455
455
|
cp: t,
|
|
456
456
|
event: n,
|
|
@@ -461,22 +461,22 @@ class qe {
|
|
|
461
461
|
afterTaskId: i,
|
|
462
462
|
inlineDepth: u
|
|
463
463
|
} = e;
|
|
464
|
-
if (u >=
|
|
464
|
+
if (u >= qe)
|
|
465
465
|
throw new Error("Adapter recursion limit reached");
|
|
466
466
|
const h = this.traceManager.addHop(
|
|
467
467
|
n,
|
|
468
|
-
((
|
|
468
|
+
((E = a.getTaskInfo()) == null ? void 0 : E.nodePath) ?? "",
|
|
469
469
|
r
|
|
470
470
|
);
|
|
471
471
|
await t.handle(h, o, a, r);
|
|
472
472
|
const d = await a.flush();
|
|
473
|
-
if (d.find((
|
|
473
|
+
if (d.find((b) => b.kind === "patch"))
|
|
474
474
|
throw new Error(
|
|
475
475
|
`Contract "${r}" (adapter) attempted to patch the document`
|
|
476
476
|
);
|
|
477
|
-
const m = d.filter((
|
|
478
|
-
for (const
|
|
479
|
-
await this.route(s, [],
|
|
477
|
+
const m = d.filter((b) => b.kind === "event");
|
|
478
|
+
for (const b of m)
|
|
479
|
+
await this.route(s, [], b.event, i, u + 1);
|
|
480
480
|
}
|
|
481
481
|
/**
|
|
482
482
|
* Schedules a handler contract for future execution
|
|
@@ -487,20 +487,20 @@ class qe {
|
|
|
487
487
|
console.warn(`Contract node type is not defined for: ${n}`);
|
|
488
488
|
return;
|
|
489
489
|
}
|
|
490
|
-
const u = this.registry.orderOf(i), h = t.get("/order"), d =
|
|
490
|
+
const u = this.registry.orderOf(i), h = t.get("/order"), d = K(h) ? h.toNumber() : 0, p = this.getNextTaskId() + s, m = Ne(
|
|
491
491
|
r,
|
|
492
492
|
a.seq,
|
|
493
493
|
u,
|
|
494
494
|
d,
|
|
495
495
|
n,
|
|
496
496
|
p
|
|
497
|
-
),
|
|
497
|
+
), E = this.traceManager.addHop(a, o, n);
|
|
498
498
|
this.queue.push({
|
|
499
499
|
key: m,
|
|
500
500
|
nodePath: o,
|
|
501
501
|
contractName: n,
|
|
502
502
|
contractNode: t,
|
|
503
|
-
event:
|
|
503
|
+
event: E
|
|
504
504
|
});
|
|
505
505
|
}
|
|
506
506
|
/**
|
|
@@ -510,17 +510,17 @@ class qe {
|
|
|
510
510
|
return e.source === "channel" && !!e.originNodePath && e.originNodePath !== t;
|
|
511
511
|
}
|
|
512
512
|
}
|
|
513
|
-
const
|
|
514
|
-
(t instanceof
|
|
513
|
+
const De = (c, e, t) => {
|
|
514
|
+
(t instanceof G || t instanceof ee) && console.error(
|
|
515
515
|
`[Blue] Failed to apply patches for contract "${c}" on event ${JSON.stringify(e)}`,
|
|
516
516
|
t
|
|
517
517
|
);
|
|
518
518
|
};
|
|
519
|
-
function
|
|
519
|
+
function L(c, e) {
|
|
520
520
|
const t = c.clone(), n = (o) => {
|
|
521
|
-
if (!
|
|
521
|
+
if (!P(o)) return;
|
|
522
522
|
const a = o.getContracts();
|
|
523
|
-
(!(a != null && a.checkpoint) || !
|
|
523
|
+
(!(a != null && a.checkpoint) || !T.isTypeOf(
|
|
524
524
|
a.checkpoint,
|
|
525
525
|
he
|
|
526
526
|
)) && o.addContract(
|
|
@@ -528,42 +528,43 @@ function _(c, e) {
|
|
|
528
528
|
e.jsonValueToNode({
|
|
529
529
|
type: {
|
|
530
530
|
name: "Channel Event Checkpoint",
|
|
531
|
-
blueId:
|
|
531
|
+
blueId: y["Channel Event Checkpoint"]
|
|
532
532
|
},
|
|
533
533
|
lastEvents: {}
|
|
534
534
|
})
|
|
535
535
|
);
|
|
536
536
|
};
|
|
537
537
|
n(t);
|
|
538
|
-
for (const { absPath: o } of
|
|
538
|
+
for (const { absPath: o } of D(t, e)) {
|
|
539
539
|
const a = t.get(o);
|
|
540
|
-
|
|
540
|
+
P(a) && n(a);
|
|
541
541
|
}
|
|
542
|
-
return
|
|
542
|
+
return k(t);
|
|
543
543
|
}
|
|
544
|
-
|
|
545
|
-
"Lifecycle Event Channel": "LifecycleEventChannelPlaceholderId1234567890ABC",
|
|
546
|
-
"Initialized Marker": "InitializedMarkerPlaceholderId1234567890ABC"
|
|
547
|
-
};
|
|
548
|
-
function De(c, e) {
|
|
544
|
+
function je(c, e) {
|
|
549
545
|
const t = c.clone();
|
|
550
|
-
|
|
551
|
-
return I(t);
|
|
552
|
-
const n = t.getContracts();
|
|
553
|
-
return n != null && n.initialized || t.addContract(
|
|
546
|
+
return P(t) ? (te(t, e) || t.addContract(
|
|
554
547
|
"initialized",
|
|
555
548
|
e.jsonValueToNode({
|
|
556
549
|
type: {
|
|
557
550
|
name: "Initialized Marker",
|
|
558
|
-
blueId:
|
|
551
|
+
blueId: y["Initialized Marker"]
|
|
559
552
|
}
|
|
560
553
|
})
|
|
561
|
-
),
|
|
554
|
+
), k(t)) : k(t);
|
|
555
|
+
}
|
|
556
|
+
function te(c, e) {
|
|
557
|
+
const t = c.getContracts();
|
|
558
|
+
return Object.values(t ?? {}).some(
|
|
559
|
+
(n) => e.isTypeOf(n, de, {
|
|
560
|
+
checkSchemaExtensions: !0
|
|
561
|
+
})
|
|
562
|
+
);
|
|
562
563
|
}
|
|
563
|
-
class
|
|
564
|
+
class xe {
|
|
564
565
|
constructor(e) {
|
|
565
566
|
l(this, "contractType", "Channel Event Checkpoint");
|
|
566
|
-
l(this, "contractBlueId",
|
|
567
|
+
l(this, "contractBlueId", y["Channel Event Checkpoint"]);
|
|
567
568
|
l(this, "role", "handler");
|
|
568
569
|
this.cache = e;
|
|
569
570
|
}
|
|
@@ -578,7 +579,7 @@ class je {
|
|
|
578
579
|
this.cache.record(a, e, o);
|
|
579
580
|
}
|
|
580
581
|
}
|
|
581
|
-
const
|
|
582
|
+
const _ = (c, e) => c.get(e) !== void 0;
|
|
582
583
|
class We {
|
|
583
584
|
constructor() {
|
|
584
585
|
l(this, "firstSeen", /* @__PURE__ */ new Map());
|
|
@@ -592,13 +593,13 @@ class We {
|
|
|
592
593
|
const t = [];
|
|
593
594
|
for (const { docBase: n, event: o, eventBlueId: a } of this.firstSeen.values()) {
|
|
594
595
|
if (!o.channelName) continue;
|
|
595
|
-
const r =
|
|
596
|
+
const r = v(
|
|
596
597
|
n,
|
|
597
598
|
"contracts/checkpoint/lastEvents",
|
|
598
599
|
o.channelName
|
|
599
600
|
), s = `${r}/blueId`;
|
|
600
|
-
|
|
601
|
-
op:
|
|
601
|
+
_(e, r) ? t.push({
|
|
602
|
+
op: _(e, s) ? "replace" : "add",
|
|
602
603
|
path: s,
|
|
603
604
|
val: a
|
|
604
605
|
}) : t.push({
|
|
@@ -613,7 +614,7 @@ class We {
|
|
|
613
614
|
this.firstSeen.clear();
|
|
614
615
|
}
|
|
615
616
|
}
|
|
616
|
-
class
|
|
617
|
+
class S {
|
|
617
618
|
constructor() {
|
|
618
619
|
l(this, "role", "adapter");
|
|
619
620
|
}
|
|
@@ -625,14 +626,14 @@ class C {
|
|
|
625
626
|
return e.source !== "channel";
|
|
626
627
|
}
|
|
627
628
|
}
|
|
628
|
-
class
|
|
629
|
+
class Ve extends S {
|
|
629
630
|
constructor() {
|
|
630
631
|
super(...arguments);
|
|
631
632
|
l(this, "contractType", "Composite Timeline Channel");
|
|
632
|
-
l(this, "contractBlueId",
|
|
633
|
+
l(this, "contractBlueId", y["Composite Timeline Channel"]);
|
|
633
634
|
}
|
|
634
635
|
supports(t, n, o) {
|
|
635
|
-
const a = o.getBlue().nodeToSchemaOutput(n,
|
|
636
|
+
const a = o.getBlue().nodeToSchemaOutput(n, pe);
|
|
636
637
|
return !a.channels || !t.channelName ? !1 : a.channels.includes(t.channelName);
|
|
637
638
|
}
|
|
638
639
|
handle(t, n, o, a) {
|
|
@@ -643,18 +644,18 @@ class xe extends C {
|
|
|
643
644
|
});
|
|
644
645
|
}
|
|
645
646
|
}
|
|
646
|
-
class
|
|
647
|
+
class Fe extends S {
|
|
647
648
|
constructor() {
|
|
648
649
|
super(...arguments);
|
|
649
650
|
l(this, "contractType", "Document Update Channel");
|
|
650
|
-
l(this, "contractBlueId",
|
|
651
|
+
l(this, "contractBlueId", y["Document Update Channel"]);
|
|
651
652
|
}
|
|
652
653
|
supports(t, n, o, a) {
|
|
653
654
|
if (!this.baseSupports(t)) return !1;
|
|
654
|
-
const r = o.getBlue().nodeToSchemaOutput(n,
|
|
655
|
+
const r = o.getBlue().nodeToSchemaOutput(n, me), s = t.payload.path;
|
|
655
656
|
if (!s || t.channelName === a) return !1;
|
|
656
657
|
const i = r.path;
|
|
657
|
-
return
|
|
658
|
+
return I(i) && s === o.resolvePath(i);
|
|
658
659
|
}
|
|
659
660
|
handle(t, n, o, a) {
|
|
660
661
|
const r = t.payload;
|
|
@@ -665,11 +666,11 @@ class Ve extends C {
|
|
|
665
666
|
});
|
|
666
667
|
}
|
|
667
668
|
}
|
|
668
|
-
class
|
|
669
|
+
class Je extends S {
|
|
669
670
|
constructor() {
|
|
670
671
|
super(...arguments);
|
|
671
672
|
l(this, "contractType", "Embedded Node Channel");
|
|
672
|
-
l(this, "contractBlueId",
|
|
673
|
+
l(this, "contractBlueId", y["Embedded Node Channel"]);
|
|
673
674
|
}
|
|
674
675
|
supports(t, n, o) {
|
|
675
676
|
if (!this.baseSupports(t)) return !1;
|
|
@@ -685,10 +686,10 @@ class Le extends C {
|
|
|
685
686
|
});
|
|
686
687
|
}
|
|
687
688
|
}
|
|
688
|
-
class
|
|
689
|
+
class Le {
|
|
689
690
|
constructor() {
|
|
690
691
|
l(this, "contractType", "Initialized Marker");
|
|
691
|
-
l(this, "contractBlueId",
|
|
692
|
+
l(this, "contractBlueId", y["Initialized Marker"]);
|
|
692
693
|
l(this, "role", "marker");
|
|
693
694
|
}
|
|
694
695
|
supports() {
|
|
@@ -697,18 +698,17 @@ class Fe {
|
|
|
697
698
|
handle() {
|
|
698
699
|
}
|
|
699
700
|
}
|
|
700
|
-
const
|
|
701
|
+
const _e = /* @__PURE__ */ new Set([
|
|
701
702
|
"Document Processing Initiated"
|
|
702
703
|
// Add more lifecycle events here as needed
|
|
703
704
|
// 'Document Processing Completed',
|
|
704
705
|
// 'Document Processing Failed',
|
|
705
706
|
]);
|
|
706
|
-
class
|
|
707
|
+
class Ue extends S {
|
|
707
708
|
constructor() {
|
|
708
709
|
super(...arguments);
|
|
709
710
|
l(this, "contractType", "Lifecycle Event Channel");
|
|
710
|
-
|
|
711
|
-
l(this, "contractBlueId", k["Lifecycle Event Channel"]);
|
|
711
|
+
l(this, "contractBlueId", y["Lifecycle Event Channel"]);
|
|
712
712
|
}
|
|
713
713
|
supports(t, n, o) {
|
|
714
714
|
return !this.baseSupports(t) || !this.isLifecycleEvent(t) ? !1 : this.isEventPatternMatch(t, n, o);
|
|
@@ -724,7 +724,7 @@ class _e extends C {
|
|
|
724
724
|
* Checks if the event is a supported lifecycle event type
|
|
725
725
|
*/
|
|
726
726
|
isLifecycleEvent(t) {
|
|
727
|
-
return
|
|
727
|
+
return _e.has(t.payload.type);
|
|
728
728
|
}
|
|
729
729
|
/**
|
|
730
730
|
* Checks if the event matches the channel's event pattern (if specified)
|
|
@@ -738,26 +738,26 @@ class _e extends C {
|
|
|
738
738
|
const s = o.getBlue(), i = s.nodeToJson(
|
|
739
739
|
s.jsonValueToNode(t.payload)
|
|
740
740
|
), u = s.nodeToJson(a);
|
|
741
|
-
return
|
|
741
|
+
return X(i, u);
|
|
742
742
|
} catch (s) {
|
|
743
743
|
return console.warn("Error during lifecycle event pattern matching:", s), !1;
|
|
744
744
|
}
|
|
745
745
|
}
|
|
746
746
|
}
|
|
747
747
|
const U = (c) => c.payload.type === "Timeline Entry" || c.payload.type === "MyOS Timeline Entry";
|
|
748
|
-
class ze extends
|
|
748
|
+
class ze extends S {
|
|
749
749
|
constructor() {
|
|
750
750
|
super(...arguments);
|
|
751
751
|
l(this, "contractType", "MyOS Timeline Channel");
|
|
752
|
-
l(this, "contractBlueId",
|
|
752
|
+
l(this, "contractBlueId", Y["MyOS Timeline Channel"]);
|
|
753
753
|
}
|
|
754
754
|
supports(t, n, o) {
|
|
755
755
|
var m;
|
|
756
756
|
if (!this.baseSupports(t) || !U(t)) return !1;
|
|
757
757
|
const a = o.getBlue(), r = a.jsonValueToNode(t.payload), s = a.nodeToSchemaOutput(
|
|
758
758
|
r,
|
|
759
|
-
|
|
760
|
-
), i = o.getBlue().nodeToSchemaOutput(n,
|
|
759
|
+
Te
|
|
760
|
+
), i = o.getBlue().nodeToSchemaOutput(n, be), u = (m = s.timeline) == null ? void 0 : m.timelineId, h = f(i.timelineId) && f(u), d = f(i.account) && f(s.account), p = f(i.email) && f(s.email);
|
|
761
761
|
return h && u === i.timelineId || d && s.account === i.account || p && s.email === i.email;
|
|
762
762
|
}
|
|
763
763
|
handle(t, n, o, a) {
|
|
@@ -768,11 +768,11 @@ class ze extends C {
|
|
|
768
768
|
});
|
|
769
769
|
}
|
|
770
770
|
}
|
|
771
|
-
class
|
|
771
|
+
class He extends S {
|
|
772
772
|
constructor() {
|
|
773
773
|
super(...arguments);
|
|
774
774
|
l(this, "contractType", "MyOS Agent Channel");
|
|
775
|
-
l(this, "contractBlueId",
|
|
775
|
+
l(this, "contractBlueId", Y["MyOS Agent Channel"]);
|
|
776
776
|
}
|
|
777
777
|
supports(t, n, o) {
|
|
778
778
|
if (!this.baseSupports(t)) return !1;
|
|
@@ -804,7 +804,7 @@ class Ue extends C {
|
|
|
804
804
|
Pe
|
|
805
805
|
), i = a.nodeToSchemaOutput(
|
|
806
806
|
n,
|
|
807
|
-
|
|
807
|
+
Se
|
|
808
808
|
);
|
|
809
809
|
return { myosAgentEvent: s, myosAgentChannel: i };
|
|
810
810
|
}
|
|
@@ -841,20 +841,20 @@ class Ue extends C {
|
|
|
841
841
|
return !1;
|
|
842
842
|
try {
|
|
843
843
|
const s = o.getBlue(), i = s.nodeToJson(r), u = s.nodeToJson(a);
|
|
844
|
-
return
|
|
844
|
+
return X(i, u);
|
|
845
845
|
} catch (s) {
|
|
846
846
|
return console.warn("Error during event pattern matching:", s), !1;
|
|
847
847
|
}
|
|
848
848
|
}
|
|
849
849
|
}
|
|
850
|
-
class
|
|
850
|
+
class Re {
|
|
851
851
|
constructor() {
|
|
852
852
|
l(this, "contractType", "Operation");
|
|
853
|
-
l(this, "contractBlueId",
|
|
853
|
+
l(this, "contractBlueId", y.Operation);
|
|
854
854
|
l(this, "role", "adapter");
|
|
855
855
|
}
|
|
856
856
|
supports(e, t, n, o) {
|
|
857
|
-
const r = n.getBlue().nodeToSchemaOutput(t,
|
|
857
|
+
const r = n.getBlue().nodeToSchemaOutput(t, fe), s = this.parseEventPayload(e, n);
|
|
858
858
|
return f(s == null ? void 0 : s.operation) && s.operation === o && e.source === "channel" && e.channelName === r.channel;
|
|
859
859
|
}
|
|
860
860
|
async handle(e, t, n, o) {
|
|
@@ -866,31 +866,33 @@ class He {
|
|
|
866
866
|
}
|
|
867
867
|
parseEventPayload(e, t) {
|
|
868
868
|
const n = t.getBlue(), o = n.jsonValueToNode(e.payload);
|
|
869
|
-
if (
|
|
869
|
+
if (n.isTypeOf(o, $, {
|
|
870
|
+
checkSchemaExtensions: !0
|
|
871
|
+
})) {
|
|
870
872
|
const a = n.nodeToSchemaOutput(
|
|
871
873
|
o,
|
|
872
|
-
|
|
874
|
+
$
|
|
873
875
|
);
|
|
874
876
|
if (a.message)
|
|
875
877
|
return n.nodeToSchemaOutput(
|
|
876
878
|
a.message,
|
|
877
|
-
|
|
879
|
+
ye
|
|
878
880
|
);
|
|
879
881
|
}
|
|
880
882
|
return null;
|
|
881
883
|
}
|
|
882
884
|
}
|
|
883
|
-
class
|
|
885
|
+
class Qe {
|
|
884
886
|
constructor() {
|
|
885
887
|
l(this, "contractType", "Process Embedded");
|
|
886
888
|
l(this, "role", "adapter");
|
|
887
|
-
l(this, "contractBlueId",
|
|
889
|
+
l(this, "contractBlueId", y["Process Embedded"]);
|
|
888
890
|
}
|
|
889
891
|
supports(e) {
|
|
890
892
|
return e.source !== "channel";
|
|
891
893
|
}
|
|
892
894
|
handle(e, t, n) {
|
|
893
|
-
const o = n.getBlue().nodeToSchemaOutput(t,
|
|
895
|
+
const o = n.getBlue().nodeToSchemaOutput(t, M);
|
|
894
896
|
for (const a of o.paths ?? [])
|
|
895
897
|
n.emitEvent({
|
|
896
898
|
...e,
|
|
@@ -906,10 +908,10 @@ if (ne)
|
|
|
906
908
|
} catch {
|
|
907
909
|
console.warn("isolated-vm not available, using fallback evaluation method");
|
|
908
910
|
}
|
|
909
|
-
function
|
|
911
|
+
function z(c) {
|
|
910
912
|
return /\bimport\s.+\sfrom\s+['"][^'"]+['"]/.test(c) || /\bexport\s+/.test(c);
|
|
911
913
|
}
|
|
912
|
-
class
|
|
914
|
+
class q {
|
|
913
915
|
/**
|
|
914
916
|
* Main evaluation method - chooses between secure and simple evaluation strategies
|
|
915
917
|
*/
|
|
@@ -926,7 +928,7 @@ class A {
|
|
|
926
928
|
* Used when isolated-vm is not available
|
|
927
929
|
*/
|
|
928
930
|
static async evaluateSimple(e, t, n = {}) {
|
|
929
|
-
if (
|
|
931
|
+
if (z(e))
|
|
930
932
|
throw new Error(
|
|
931
933
|
"Static import/export syntax requires isolated-vm – start Node without SKIP_ISOLATED_VM."
|
|
932
934
|
);
|
|
@@ -947,7 +949,7 @@ class A {
|
|
|
947
949
|
`return ${e};`
|
|
948
950
|
)(...Object.values(t));
|
|
949
951
|
} catch (o) {
|
|
950
|
-
throw n.isCodeBlock ? new
|
|
952
|
+
throw n.isCodeBlock ? new V(e, o) : new W(e, o);
|
|
951
953
|
}
|
|
952
954
|
}
|
|
953
955
|
/**
|
|
@@ -964,7 +966,7 @@ class A {
|
|
|
964
966
|
i,
|
|
965
967
|
n
|
|
966
968
|
);
|
|
967
|
-
return
|
|
969
|
+
return z(e) ? await this.evaluateESModule(
|
|
968
970
|
a,
|
|
969
971
|
r,
|
|
970
972
|
e,
|
|
@@ -978,7 +980,7 @@ class A {
|
|
|
978
980
|
o
|
|
979
981
|
);
|
|
980
982
|
} catch (i) {
|
|
981
|
-
throw o.isCodeBlock ? new
|
|
983
|
+
throw o.isCodeBlock ? new V(e, i) : new W(e, i);
|
|
982
984
|
} finally {
|
|
983
985
|
r.release(), a.dispose();
|
|
984
986
|
}
|
|
@@ -1077,7 +1079,7 @@ class A {
|
|
|
1077
1079
|
});
|
|
1078
1080
|
}
|
|
1079
1081
|
}
|
|
1080
|
-
class
|
|
1082
|
+
class A {
|
|
1081
1083
|
/**
|
|
1082
1084
|
* Creates standard bindings for workflow step execution
|
|
1083
1085
|
*/
|
|
@@ -1086,14 +1088,14 @@ class D {
|
|
|
1086
1088
|
return {
|
|
1087
1089
|
document: (a) => {
|
|
1088
1090
|
const r = e.get(a);
|
|
1089
|
-
return
|
|
1091
|
+
return K(r) ? r.toNumber() : P(r) ? o.nodeToJson(r, "original") : r;
|
|
1090
1092
|
},
|
|
1091
1093
|
event: t.payload,
|
|
1092
1094
|
steps: n
|
|
1093
1095
|
};
|
|
1094
1096
|
}
|
|
1095
1097
|
}
|
|
1096
|
-
function
|
|
1098
|
+
function H(c) {
|
|
1097
1099
|
const { op: e, path: t, val: n, from: o } = c;
|
|
1098
1100
|
if ((e === "move" || e === "copy") && !o)
|
|
1099
1101
|
throw new Error(`${e} operation requires 'from' path`);
|
|
@@ -1102,35 +1104,35 @@ function R(c) {
|
|
|
1102
1104
|
const a = { type: "Document Update", op: e, path: t };
|
|
1103
1105
|
return n !== void 0 && (a.val = n), o !== void 0 && (a.from = o), a;
|
|
1104
1106
|
}
|
|
1105
|
-
function
|
|
1107
|
+
function Ke() {
|
|
1106
1108
|
return {
|
|
1107
1109
|
type: "Document Processing Initiated"
|
|
1108
1110
|
};
|
|
1109
1111
|
}
|
|
1110
|
-
class
|
|
1112
|
+
class Xe {
|
|
1111
1113
|
constructor() {
|
|
1112
1114
|
l(this, "stepType", "Update Document");
|
|
1113
1115
|
}
|
|
1114
1116
|
supports(e) {
|
|
1115
|
-
return
|
|
1117
|
+
return T.isTypeOf(e, N);
|
|
1116
1118
|
}
|
|
1117
1119
|
async execute(e, t, n, o, a) {
|
|
1118
1120
|
const r = n.getBlue();
|
|
1119
|
-
if (!
|
|
1121
|
+
if (!T.isTypeOf(e, N)) return;
|
|
1120
1122
|
const s = await this.evaluateChangeset(
|
|
1121
1123
|
e.get("/changeset"),
|
|
1122
1124
|
n,
|
|
1123
1125
|
t,
|
|
1124
1126
|
a
|
|
1125
|
-
), i =
|
|
1127
|
+
), i = Q(e, {
|
|
1126
1128
|
op: "replace",
|
|
1127
1129
|
path: "/changeset",
|
|
1128
1130
|
val: s
|
|
1129
|
-
}), u = n.getBlue().nodeToSchemaOutput(i,
|
|
1131
|
+
}), u = n.getBlue().nodeToSchemaOutput(i, N);
|
|
1130
1132
|
for (const h of u.changeset ?? []) {
|
|
1131
1133
|
if (!h.path) continue;
|
|
1132
1134
|
const d = h.val;
|
|
1133
|
-
if ((h.op === "replace" || h.op === "add") &&
|
|
1135
|
+
if ((h.op === "replace" || h.op === "add") && I(d)) {
|
|
1134
1136
|
const p = await this.evaluateChangeValue(
|
|
1135
1137
|
d,
|
|
1136
1138
|
n,
|
|
@@ -1142,7 +1144,7 @@ class Ke {
|
|
|
1142
1144
|
path: h.path,
|
|
1143
1145
|
val: p
|
|
1144
1146
|
}), n.emitEvent({
|
|
1145
|
-
payload:
|
|
1147
|
+
payload: H({
|
|
1146
1148
|
op: h.op,
|
|
1147
1149
|
path: n.resolvePath(h.path),
|
|
1148
1150
|
val: r.nodeToJson(p, "original")
|
|
@@ -1150,7 +1152,7 @@ class Ke {
|
|
|
1150
1152
|
});
|
|
1151
1153
|
}
|
|
1152
1154
|
h.op === "remove" && (n.addPatch({ op: h.op, path: h.path }), n.emitEvent({
|
|
1153
|
-
payload:
|
|
1155
|
+
payload: H({
|
|
1154
1156
|
op: h.op,
|
|
1155
1157
|
path: n.resolvePath(h.path),
|
|
1156
1158
|
val: null
|
|
@@ -1161,10 +1163,10 @@ class Ke {
|
|
|
1161
1163
|
async evaluateChangeset(e, t, n, o) {
|
|
1162
1164
|
const a = t.getBlue();
|
|
1163
1165
|
if (typeof e == "string" && e.startsWith("${") && e.endsWith("}")) {
|
|
1164
|
-
const r = e.slice(2, -1), s = await
|
|
1166
|
+
const r = e.slice(2, -1), s = await q.evaluate({
|
|
1165
1167
|
code: r,
|
|
1166
1168
|
ctx: t,
|
|
1167
|
-
bindings:
|
|
1169
|
+
bindings: A.createStandardBindings(
|
|
1168
1170
|
t,
|
|
1169
1171
|
n,
|
|
1170
1172
|
o
|
|
@@ -1172,17 +1174,17 @@ class Ke {
|
|
|
1172
1174
|
});
|
|
1173
1175
|
return a.jsonValueToNode(s ?? null);
|
|
1174
1176
|
}
|
|
1175
|
-
if (
|
|
1177
|
+
if (P(e))
|
|
1176
1178
|
return e;
|
|
1177
1179
|
throw new Error("Invalid changeset: expected a string or document node");
|
|
1178
1180
|
}
|
|
1179
1181
|
async evaluateChangeValue(e, t, n, o) {
|
|
1180
1182
|
const a = e.getValue(), r = t.getBlue();
|
|
1181
1183
|
if (typeof a == "string" && a.startsWith("${") && a.endsWith("}")) {
|
|
1182
|
-
const s = a.slice(2, -1), i = await
|
|
1184
|
+
const s = a.slice(2, -1), i = await q.evaluate({
|
|
1183
1185
|
code: s,
|
|
1184
1186
|
ctx: t,
|
|
1185
|
-
bindings:
|
|
1187
|
+
bindings: A.createStandardBindings(
|
|
1186
1188
|
t,
|
|
1187
1189
|
n,
|
|
1188
1190
|
o
|
|
@@ -1193,17 +1195,17 @@ class Ke {
|
|
|
1193
1195
|
return e;
|
|
1194
1196
|
}
|
|
1195
1197
|
}
|
|
1196
|
-
class
|
|
1198
|
+
class Ye {
|
|
1197
1199
|
constructor() {
|
|
1198
1200
|
l(this, "stepType", "Trigger Event");
|
|
1199
1201
|
}
|
|
1200
1202
|
supports(e) {
|
|
1201
|
-
return
|
|
1203
|
+
return T.isTypeOf(e, B);
|
|
1202
1204
|
}
|
|
1203
1205
|
async execute(e, t, n) {
|
|
1204
1206
|
const o = n.getBlue();
|
|
1205
|
-
if (!
|
|
1206
|
-
const a = o.nodeToSchemaOutput(e,
|
|
1207
|
+
if (!T.isTypeOf(e, B)) return;
|
|
1208
|
+
const a = o.nodeToSchemaOutput(e, B);
|
|
1207
1209
|
if (!a.event) return;
|
|
1208
1210
|
const r = o.nodeToJson(
|
|
1209
1211
|
a.event,
|
|
@@ -1214,25 +1216,25 @@ class Xe {
|
|
|
1214
1216
|
});
|
|
1215
1217
|
}
|
|
1216
1218
|
}
|
|
1217
|
-
class
|
|
1219
|
+
class Ze {
|
|
1218
1220
|
constructor() {
|
|
1219
1221
|
l(this, "stepType", "JavaScript Code");
|
|
1220
1222
|
}
|
|
1221
1223
|
supports(e) {
|
|
1222
|
-
return
|
|
1224
|
+
return T.isTypeOf(e, O);
|
|
1223
1225
|
}
|
|
1224
1226
|
async execute(e, t, n, o, a) {
|
|
1225
|
-
if (!
|
|
1227
|
+
if (!T.isTypeOf(e, O)) return;
|
|
1226
1228
|
const s = n.getBlue().nodeToSchemaOutput(
|
|
1227
1229
|
e,
|
|
1228
|
-
|
|
1230
|
+
O
|
|
1229
1231
|
);
|
|
1230
1232
|
if (!s.code)
|
|
1231
1233
|
throw new Error("JavaScript code is required");
|
|
1232
|
-
const i = await
|
|
1234
|
+
const i = await q.evaluate({
|
|
1233
1235
|
code: s.code,
|
|
1234
1236
|
ctx: n,
|
|
1235
|
-
bindings:
|
|
1237
|
+
bindings: A.createStandardBindings(n, t, a),
|
|
1236
1238
|
options: {
|
|
1237
1239
|
isCodeBlock: !0,
|
|
1238
1240
|
timeout: 500
|
|
@@ -1249,15 +1251,15 @@ class Ye {
|
|
|
1249
1251
|
return i;
|
|
1250
1252
|
}
|
|
1251
1253
|
}
|
|
1252
|
-
const
|
|
1253
|
-
new Ke(),
|
|
1254
|
+
const Ge = [
|
|
1254
1255
|
new Xe(),
|
|
1255
|
-
new Ye()
|
|
1256
|
+
new Ye(),
|
|
1257
|
+
new Ze()
|
|
1256
1258
|
];
|
|
1257
1259
|
class oe {
|
|
1258
|
-
constructor(e =
|
|
1260
|
+
constructor(e = Ge) {
|
|
1259
1261
|
l(this, "contractType", "Sequential Workflow");
|
|
1260
|
-
l(this, "contractBlueId",
|
|
1262
|
+
l(this, "contractBlueId", y["Sequential Workflow"]);
|
|
1261
1263
|
l(this, "role", "handler");
|
|
1262
1264
|
l(this, "executors", []);
|
|
1263
1265
|
this.executors = e;
|
|
@@ -1269,7 +1271,7 @@ class oe {
|
|
|
1269
1271
|
supports(e, t, n) {
|
|
1270
1272
|
const r = n.getBlue().nodeToSchemaOutput(
|
|
1271
1273
|
t,
|
|
1272
|
-
|
|
1274
|
+
ge
|
|
1273
1275
|
).channel;
|
|
1274
1276
|
return e.source === "channel" && e.channelName === r;
|
|
1275
1277
|
}
|
|
@@ -1295,10 +1297,10 @@ class oe {
|
|
|
1295
1297
|
}
|
|
1296
1298
|
}
|
|
1297
1299
|
}
|
|
1298
|
-
class
|
|
1300
|
+
class et {
|
|
1299
1301
|
constructor(e) {
|
|
1300
1302
|
l(this, "contractType", "Sequential Workflow Operation");
|
|
1301
|
-
l(this, "contractBlueId",
|
|
1303
|
+
l(this, "contractBlueId", y["Sequential Workflow Operation"]);
|
|
1302
1304
|
l(this, "role", "handler");
|
|
1303
1305
|
l(this, "sequentialWorkflowProcessor");
|
|
1304
1306
|
this.sequentialWorkflowProcessor = e || new oe();
|
|
@@ -1306,9 +1308,9 @@ class Ge {
|
|
|
1306
1308
|
supports(e, t, n) {
|
|
1307
1309
|
const r = n.getBlue().nodeToSchemaOutput(
|
|
1308
1310
|
t,
|
|
1309
|
-
|
|
1311
|
+
Ee
|
|
1310
1312
|
).operation, s = e.channelName;
|
|
1311
|
-
return e.source === "channel" &&
|
|
1313
|
+
return e.source === "channel" && I(s) && I(r) && s === r;
|
|
1312
1314
|
}
|
|
1313
1315
|
async handle(e, t, n, o) {
|
|
1314
1316
|
try {
|
|
@@ -1321,73 +1323,70 @@ class Ge {
|
|
|
1321
1323
|
}
|
|
1322
1324
|
}
|
|
1323
1325
|
}
|
|
1324
|
-
const
|
|
1325
|
-
class
|
|
1326
|
+
const R = (c) => c.payload.type === "Timeline Entry";
|
|
1327
|
+
class tt extends S {
|
|
1326
1328
|
constructor() {
|
|
1327
1329
|
super(...arguments);
|
|
1328
1330
|
l(this, "contractType", "Timeline Channel");
|
|
1329
|
-
l(this, "contractBlueId",
|
|
1331
|
+
l(this, "contractBlueId", y["Timeline Channel"]);
|
|
1330
1332
|
}
|
|
1331
1333
|
supports(t, n, o) {
|
|
1332
1334
|
var h;
|
|
1333
|
-
if (!this.baseSupports(t) || !
|
|
1335
|
+
if (!this.baseSupports(t) || !R(t)) return !1;
|
|
1334
1336
|
const a = o.getBlue(), r = a.nodeToSchemaOutput(
|
|
1335
1337
|
a.jsonValueToNode(t.payload),
|
|
1336
|
-
|
|
1337
|
-
), s = o.getBlue().nodeToSchemaOutput(n,
|
|
1338
|
+
$
|
|
1339
|
+
), s = o.getBlue().nodeToSchemaOutput(n, we), i = (h = r.timeline) == null ? void 0 : h.timelineId;
|
|
1338
1340
|
return f(s.timelineId) && f(i) && i === s.timelineId;
|
|
1339
1341
|
}
|
|
1340
1342
|
handle(t, n, o, a) {
|
|
1341
|
-
|
|
1343
|
+
R(t) && o.emitEvent({
|
|
1342
1344
|
payload: t.payload,
|
|
1343
1345
|
channelName: a,
|
|
1344
1346
|
source: "channel"
|
|
1345
1347
|
});
|
|
1346
1348
|
}
|
|
1347
1349
|
}
|
|
1348
|
-
const
|
|
1349
|
-
new
|
|
1350
|
+
const nt = [
|
|
1351
|
+
new Qe(),
|
|
1350
1352
|
// channels
|
|
1351
|
-
new
|
|
1352
|
-
new
|
|
1353
|
-
new
|
|
1353
|
+
new Je(),
|
|
1354
|
+
new Fe(),
|
|
1355
|
+
new tt(),
|
|
1354
1356
|
new ze(),
|
|
1355
|
-
new Ue(),
|
|
1356
|
-
new xe(),
|
|
1357
|
-
new _e(),
|
|
1358
1357
|
new He(),
|
|
1358
|
+
new Ve(),
|
|
1359
|
+
new Ue(),
|
|
1360
|
+
new Re(),
|
|
1359
1361
|
// sequential workflows
|
|
1360
1362
|
new oe(),
|
|
1361
|
-
new
|
|
1363
|
+
new et(),
|
|
1362
1364
|
// markers
|
|
1363
|
-
new
|
|
1365
|
+
new Le()
|
|
1364
1366
|
];
|
|
1365
|
-
class
|
|
1367
|
+
class lt {
|
|
1366
1368
|
/**
|
|
1367
1369
|
* Creates a new document processor
|
|
1368
1370
|
*
|
|
1369
1371
|
* @param processors - Initial list of processors to register
|
|
1370
1372
|
*/
|
|
1371
|
-
constructor(e, t =
|
|
1373
|
+
constructor(e, t = nt) {
|
|
1372
1374
|
l(this, "taskCounter", 0);
|
|
1373
1375
|
l(this, "eventCounter", 0);
|
|
1374
1376
|
l(this, "registry");
|
|
1375
1377
|
l(this, "queue");
|
|
1376
1378
|
l(this, "router");
|
|
1377
1379
|
l(this, "checkpointCache", new We());
|
|
1378
|
-
this.blue = e, this.registry = new
|
|
1380
|
+
this.blue = e, this.registry = new Me(t), this.queue = new Oe(), this.router = new Ae(
|
|
1379
1381
|
this.blue,
|
|
1380
1382
|
this.registry,
|
|
1381
1383
|
this.queue,
|
|
1382
1384
|
() => ++this.taskCounter,
|
|
1383
1385
|
() => ++this.eventCounter
|
|
1384
1386
|
), this.register(
|
|
1385
|
-
new
|
|
1387
|
+
new xe(this.checkpointCache),
|
|
1386
1388
|
9999
|
|
1387
|
-
)
|
|
1388
|
-
"Lifecycle Event Channel": k["Lifecycle Event Channel"],
|
|
1389
|
-
"Initialized Marker": k["Initialized Marker"]
|
|
1390
|
-
});
|
|
1389
|
+
);
|
|
1391
1390
|
}
|
|
1392
1391
|
/**
|
|
1393
1392
|
* Registers a new contract processor
|
|
@@ -1405,13 +1404,13 @@ class it {
|
|
|
1405
1404
|
* @returns Processing result with final state and emitted events
|
|
1406
1405
|
*/
|
|
1407
1406
|
async initialize(e) {
|
|
1408
|
-
let t =
|
|
1407
|
+
let t = L(e, this.blue);
|
|
1409
1408
|
const n = {
|
|
1410
|
-
payload:
|
|
1409
|
+
payload: Ke()
|
|
1411
1410
|
}, o = [n.payload];
|
|
1412
1411
|
await this.router.route(t, [], n, 0);
|
|
1413
1412
|
const a = await this.drainQueue(t);
|
|
1414
|
-
return t = a.state, o.push(...a.emitted), t =
|
|
1413
|
+
return t = a.state, o.push(...a.emitted), t = je(t, this.blue), { state: t, emitted: o };
|
|
1415
1414
|
}
|
|
1416
1415
|
/**
|
|
1417
1416
|
* Processes a batch of events against the document
|
|
@@ -1421,8 +1420,10 @@ class it {
|
|
|
1421
1420
|
* @returns Processing result with final state and emitted events
|
|
1422
1421
|
*/
|
|
1423
1422
|
async processEvents(e, t) {
|
|
1424
|
-
let n =
|
|
1423
|
+
let n = L(e, this.blue);
|
|
1425
1424
|
const o = [];
|
|
1425
|
+
if (!te(n, this.blue))
|
|
1426
|
+
throw new Error("Document is not initialized");
|
|
1426
1427
|
for (const a of t)
|
|
1427
1428
|
try {
|
|
1428
1429
|
const r = { payload: a, source: "external" };
|
|
@@ -1448,60 +1449,60 @@ class it {
|
|
|
1448
1449
|
if (++a > o)
|
|
1449
1450
|
throw new Error("Possible cycle – too many iterations");
|
|
1450
1451
|
const s = this.queue.pop(), { nodePath: i, contractName: u, contractNode: h, event: d } = s, p = t.get(i);
|
|
1451
|
-
if (!
|
|
1452
|
+
if (!P(p) || !((r = p.getContracts()) != null && r[u]) || !h.getType()) continue;
|
|
1452
1453
|
const m = this.registry.get(h.getType());
|
|
1453
1454
|
if (!m) {
|
|
1454
1455
|
console.warn(`No processor registered for contract: ${u}`);
|
|
1455
1456
|
continue;
|
|
1456
1457
|
}
|
|
1457
|
-
const
|
|
1458
|
+
const E = new Z(
|
|
1458
1459
|
() => t,
|
|
1459
1460
|
s,
|
|
1460
1461
|
this.blue,
|
|
1461
|
-
async (
|
|
1462
|
-
for (const
|
|
1463
|
-
if (
|
|
1464
|
-
const ae =
|
|
1465
|
-
for (const
|
|
1466
|
-
const re =
|
|
1467
|
-
(ie) => F(ie,
|
|
1462
|
+
async (b) => {
|
|
1463
|
+
for (const g of b)
|
|
1464
|
+
if (g.kind === "patch") {
|
|
1465
|
+
const ae = D(t, this.blue);
|
|
1466
|
+
for (const C of ae) {
|
|
1467
|
+
const re = g.patch.op === "move" || g.patch.op === "copy" ? [g.patch.from, g.patch.path] : [g.patch.path], j = E.getNodePath(), se = re.some(
|
|
1468
|
+
(ie) => F(ie, C.absPath)
|
|
1468
1469
|
), ce = F(
|
|
1469
|
-
|
|
1470
|
-
|
|
1470
|
+
j,
|
|
1471
|
+
C.absPath
|
|
1471
1472
|
);
|
|
1472
1473
|
if (se && !ce)
|
|
1473
|
-
throw new
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1474
|
+
throw new ee(
|
|
1475
|
+
g.patch,
|
|
1476
|
+
C.absPath,
|
|
1477
|
+
j
|
|
1477
1478
|
);
|
|
1478
1479
|
}
|
|
1479
1480
|
try {
|
|
1480
|
-
t = J(t, [
|
|
1481
|
-
} catch (
|
|
1482
|
-
throw
|
|
1481
|
+
t = J(t, [g.patch]);
|
|
1482
|
+
} catch (C) {
|
|
1483
|
+
throw De(u, d, C), C;
|
|
1483
1484
|
}
|
|
1484
|
-
} else
|
|
1485
|
+
} else g.kind === "event" && (n.push(g.event.payload), await this.router.route(t, [], g.event, s.key[5]));
|
|
1485
1486
|
}
|
|
1486
1487
|
);
|
|
1487
|
-
await m.handle(d, h,
|
|
1488
|
+
await m.handle(d, h, E, u), await E.flush();
|
|
1488
1489
|
}
|
|
1489
1490
|
return { state: t, emitted: n };
|
|
1490
1491
|
}
|
|
1491
1492
|
}
|
|
1492
1493
|
export {
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1494
|
+
lt as BlueDocumentProcessor,
|
|
1495
|
+
xe as ChannelEventCheckpointProcessor,
|
|
1496
|
+
Ve as CompositeTimelineChannelProcessor,
|
|
1497
|
+
Fe as DocumentUpdateChannelProcessor,
|
|
1498
|
+
Je as EmbeddedNodeChannelProcessor,
|
|
1499
|
+
Le as InitializedMarkerProcessor,
|
|
1500
|
+
Ue as LifecycleEventChannelProcessor,
|
|
1501
|
+
He as MyOSAgentChannelProcessor,
|
|
1501
1502
|
ze as MyOSTimelineChannelProcessor,
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1503
|
+
Re as OperationProcessor,
|
|
1504
|
+
Qe as ProcessEmbeddedProcessor,
|
|
1505
|
+
et as SequentialWorkflowOperationProcessor,
|
|
1505
1506
|
oe as SequentialWorkflowProcessor,
|
|
1506
|
-
|
|
1507
|
+
tt as TimelineChannelProcessor
|
|
1507
1508
|
};
|