@blue-labs/document-processor 1.27.1 → 1.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,25 +1,25 @@
1
- var he = Object.defineProperty;
2
- var de = (c, e, t) => e in c ? he(c, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : c[e] = t;
3
- var l = (c, e, t) => de(c, typeof e != "symbol" ? e + "" : e, t);
4
- import { ProcessEmbeddedSchema as q, ChannelEventCheckpointSchema as pe, blueIds as f, InitializedMarkerSchema as me, CompositeTimelineChannelSchema as fe, DocumentUpdateChannelSchema as ye, EmbeddedNodeChannelSchema as J, LifecycleEventSchema as ge, TimelineEntrySchema as I, OperationSchema as Ee, OperationRequestSchema as we, UpdateDocumentSchema as B, TriggerEventSchema as M, JavaScriptCodeSchema as $, SequentialWorkflowSchema as ve, SequentialWorkflowOperationSchema as be, TimelineChannelSchema as Te } from "@blue-repository/core-dev";
5
- import { applyBlueNodePatch as X, BlueNodeTypeSchema as E, BlueNode as Se, isBigNumber as A } from "@blue-labs/language";
6
- import { deepFreeze as Pe, isNonNullable as O, deepContains as Y } from "@blue-labs/shared-utils";
7
- import { blueIds as Z, MyOSTimelineEntrySchema as G, MyOSTimelineChannelSchema as Ce, MyOSAgentEventSchema as ke, MyOSAgentChannelSchema as Ie } from "@blue-repository/myos-dev";
8
- const Ne = (c, e) => ({
1
+ var me = Object.defineProperty;
2
+ var ye = (s, e, t) => e in s ? me(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
+ var l = (s, e, t) => ye(s, typeof e != "symbol" ? e + "" : e, t);
4
+ import { ProcessEmbeddedSchema as D, ChannelEventCheckpointSchema as ge, blueIds as m, InitializedMarkerSchema as Ee, CompositeTimelineChannelSchema as we, DocumentUpdateChannelSchema as ve, EmbeddedNodeChannelSchema as _, LifecycleEventSchema as be, TimelineEntrySchema as N, OperationSchema as Te, OperationRequestSchema as Pe, UpdateDocumentSchema as $, TriggerEventSchema as q, JavaScriptCodeSchema as A, SequentialWorkflowSchema as Se, SequentialWorkflowOperationSchema as Ce, TimelineChannelSchema as ke } from "@blue-repository/core-dev";
5
+ import { applyBlueNodePatch as G, BlueNodeTypeSchema as w, BlueNode as Ie, isBigNumber as x, MergingProcessors as k } from "@blue-labs/language";
6
+ import { deepFreeze as Ne, isNonNullable as M, deepContains as ee } from "@blue-labs/shared-utils";
7
+ import { blueIds as te, MyOSTimelineEntrySchema as ne, MyOSTimelineChannelSchema as Oe, MyOSAgentEventSchema as Be, MyOSAgentChannelSchema as Me } from "@blue-repository/myos-dev";
8
+ const $e = (s, e) => ({
9
9
  on: (t, n) => ({ end: () => n(null) })
10
10
  });
11
- async function Oe(c) {
11
+ async function qe(s) {
12
12
  return new Promise((e, t) => {
13
- Ne().on("error", t).end();
13
+ $e().on("error", t).end();
14
14
  });
15
15
  }
16
- const b = (...c) => c.map((e, t) => {
16
+ const b = (...s) => s.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
- return t < c.length - 1 ? n.replace(/\/+$/, "") : n;
20
+ return t < s.length - 1 ? n.replace(/\/+$/, "") : n;
21
21
  }).filter(Boolean).join("/").replace(/\/{2,}/g, "/");
22
- class ee {
22
+ class oe {
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;
@@ -68,50 +68,50 @@ class ee {
68
68
  loadExternalModule(e) {
69
69
  if (!/^https?:\/\//.test(e))
70
70
  throw new Error("Only http/https URLs are allowed");
71
- return Oe();
71
+ return qe();
72
72
  }
73
73
  loadBlueContent(e) {
74
74
  throw new Error("Not implemented");
75
75
  }
76
76
  }
77
- class te extends Error {
77
+ class re 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 ne extends Error {
82
+ class ae 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 V extends Error {
89
+ class F 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 F extends Error {
94
+ class L 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 k(c) {
100
- return Pe(c);
99
+ function I(s) {
100
+ return Ne(s);
101
101
  }
102
- function N(c) {
103
- return c.clone();
102
+ function O(s) {
103
+ return s.clone();
104
104
  }
105
- function j(c, e, t = "/", n = []) {
106
- const o = c.getContracts() ?? {};
105
+ function W(s, e, t = "/", n = []) {
106
+ const o = s.getContracts() ?? {};
107
107
  for (const [r, a] of Object.entries(o))
108
- if (E.isTypeOf(
108
+ if (w.isTypeOf(
109
109
  a,
110
- q
110
+ D
111
111
  )) {
112
112
  const h = e.nodeToSchemaOutput(
113
113
  a,
114
- q
114
+ D
115
115
  ).paths ?? [];
116
116
  for (const u of h)
117
117
  n.push({
@@ -119,31 +119,31 @@ function j(c, e, t = "/", n = []) {
119
119
  contractPath: b(t, `contracts/${r}`)
120
120
  });
121
121
  }
122
- for (const [r, a] of Object.entries(c.getProperties() ?? {}))
123
- j(a, e, b(t, r), n);
122
+ for (const [r, a] of Object.entries(s.getProperties() ?? {}))
123
+ W(a, e, b(t, r), n);
124
124
  return n;
125
125
  }
126
- function L(c, e) {
127
- return c === e || c.startsWith(e.endsWith("/") ? e : e + "/");
126
+ function z(s, e) {
127
+ return s === e || s.startsWith(e.endsWith("/") ? e : e + "/");
128
128
  }
129
- function U(c, e) {
130
- if (!e.length) return c;
131
- let t = N(c);
129
+ function U(s, e) {
130
+ if (!e.length) return s;
131
+ let t = O(s);
132
132
  for (const n of e)
133
133
  try {
134
- t = X(t, n, !0);
134
+ t = G(t, n, !0);
135
135
  } catch (o) {
136
- throw new te(n, o);
136
+ throw new re(n, o);
137
137
  }
138
- return k(t);
138
+ return I(t);
139
139
  }
140
- function m(c) {
141
- return c != null;
140
+ function f(s) {
141
+ return s != null;
142
142
  }
143
- function S(c) {
144
- return c instanceof Se;
143
+ function P(s) {
144
+ return s instanceof Ie;
145
145
  }
146
- class Be {
146
+ class Ae {
147
147
  constructor(e = [], t = (n, o) => n < o ? -1 : n > o ? 1 : 0) {
148
148
  l(this, "data");
149
149
  l(this, "length");
@@ -175,35 +175,35 @@ class Be {
175
175
  const { data: t, compare: n } = this, o = this.length >> 1, r = t[e];
176
176
  for (; e < o; ) {
177
177
  let a = (e << 1) + 1;
178
- const s = a + 1;
179
- if (s < this.length && n(t[s], t[a]) < 0 && (a = s), n(t[a], r) >= 0) break;
178
+ const c = a + 1;
179
+ if (c < this.length && n(t[c], t[a]) < 0 && (a = c), n(t[a], r) >= 0) break;
180
180
  t[e] = t[a], e = a;
181
181
  }
182
182
  t[e] = r;
183
183
  }
184
184
  }
185
- const Me = (c, e, t, n, o, r) => [
186
- -c,
185
+ const De = (s, e, t, n, o, r) => [
186
+ -s,
187
187
  e,
188
188
  t,
189
189
  n,
190
190
  o,
191
191
  r
192
- ], $e = (c, e) => {
193
- for (let t = 0; t < c.key.length; t++) {
194
- const n = c.key[t], o = e.key[t];
192
+ ], xe = (s, e) => {
193
+ for (let t = 0; t < s.key.length; t++) {
194
+ const n = s.key[t], o = e.key[t];
195
195
  if (n !== o)
196
196
  return typeof n == "number" && typeof o == "number" ? n - o : typeof n == "string" && typeof o == "string" ? n.localeCompare(o) : 0;
197
197
  }
198
198
  return 0;
199
199
  };
200
- class qe {
200
+ class je {
201
201
  /**
202
202
  * Creates a new task queue with the task key comparator
203
203
  */
204
204
  constructor() {
205
205
  l(this, "queue");
206
- this.queue = new Be([], $e);
206
+ this.queue = new Ae([], xe);
207
207
  }
208
208
  /**
209
209
  * Adds a task to the queue
@@ -228,7 +228,7 @@ class qe {
228
228
  return this.queue.length;
229
229
  }
230
230
  }
231
- class Ae {
231
+ class Ve {
232
232
  /**
233
233
  * Creates a new contract registry
234
234
  *
@@ -283,7 +283,7 @@ class Ae {
283
283
  return this.processors.values();
284
284
  }
285
285
  }
286
- class De {
286
+ class We {
287
287
  constructor() {
288
288
  l(this, "isEnabled");
289
289
  this.isEnabled = process.env.TRACE_BLUE_ENABLED === "true";
@@ -350,8 +350,8 @@ class De {
350
350
  return this.isEnabled;
351
351
  }
352
352
  }
353
- const We = 64;
354
- class je {
353
+ const Je = 64;
354
+ class _e {
355
355
  /**
356
356
  * Creates a new event router
357
357
  *
@@ -362,7 +362,7 @@ class je {
362
362
  */
363
363
  constructor(e, t, n, o, r) {
364
364
  l(this, "traceManager");
365
- this.blue = e, this.registry = t, this.queue = n, this.getNextTaskId = o, this.getNextEventSeq = r, this.traceManager = new De();
365
+ this.blue = e, this.registry = t, this.queue = n, this.getNextTaskId = o, this.getNextEventSeq = r, this.traceManager = new We();
366
366
  }
367
367
  /**
368
368
  * Routes an event to matching contracts in the document
@@ -385,10 +385,10 @@ class je {
385
385
  return this.route(e, h, n, o, r);
386
386
  }
387
387
  }
388
- const a = b("/", t.join("/")), s = e.get(a);
389
- S(s) && await this.traverseContracts({
388
+ const a = b("/", t.join("/")), c = e.get(a);
389
+ P(c) && await this.traverseContracts({
390
390
  doc: e,
391
- node: s,
391
+ node: c,
392
392
  nodePath: a,
393
393
  event: n,
394
394
  afterTaskId: o,
@@ -406,7 +406,7 @@ class je {
406
406
  nodePath: o,
407
407
  event: r,
408
408
  afterTaskId: a,
409
- pathSegments: s,
409
+ pathSegments: c,
410
410
  inlineDepth: i
411
411
  } = e;
412
412
  if (!this.shouldSkipForChannel(r, o))
@@ -424,7 +424,7 @@ class je {
424
424
  contractName: h,
425
425
  contractNode: u,
426
426
  event: r
427
- }, y = new ee(() => t, p, this.blue);
427
+ }, y = new oe(() => t, p, this.blue);
428
428
  if (d.supports(r, u, y, h))
429
429
  switch (d.role) {
430
430
  case "adapter":
@@ -445,7 +445,7 @@ class je {
445
445
  contractName: h,
446
446
  nodePath: o,
447
447
  event: r,
448
- depth: s.length,
448
+ depth: c.length,
449
449
  afterTaskId: a
450
450
  });
451
451
  break;
@@ -456,22 +456,22 @@ class je {
456
456
  * Processes an adapter contract and routes any emitted events
457
457
  */
458
458
  async processAdapter(e) {
459
- var w;
459
+ var v;
460
460
  const {
461
461
  cp: t,
462
462
  event: n,
463
463
  contractNode: o,
464
464
  ctx: r,
465
465
  contractName: a,
466
- doc: s,
466
+ doc: c,
467
467
  afterTaskId: i,
468
468
  inlineDepth: h
469
469
  } = e;
470
- if (h >= We)
470
+ if (h >= Je)
471
471
  throw new Error("Adapter recursion limit reached");
472
472
  const u = this.traceManager.addHop(
473
473
  n,
474
- ((w = r.getTaskInfo()) == null ? void 0 : w.nodePath) ?? "",
474
+ ((v = r.getTaskInfo()) == null ? void 0 : v.nodePath) ?? "",
475
475
  a
476
476
  );
477
477
  await t.handle(u, o, r, a);
@@ -482,31 +482,31 @@ class je {
482
482
  );
483
483
  const y = d.filter((T) => T.kind === "event");
484
484
  for (const T of y)
485
- await this.route(s, [], T.event, i, h + 1);
485
+ await this.route(c, [], T.event, i, h + 1);
486
486
  }
487
487
  /**
488
488
  * Schedules a handler contract for future execution
489
489
  */
490
490
  scheduleHandler(e) {
491
- const { contractNode: t, contractName: n, nodePath: o, event: r, depth: a, afterTaskId: s } = e, i = t.getType();
491
+ const { contractNode: t, contractName: n, nodePath: o, event: r, depth: a, afterTaskId: c } = e, i = t.getType();
492
492
  if (!i) {
493
493
  console.warn(`Contract node type is not defined for: ${n}`);
494
494
  return;
495
495
  }
496
- const h = this.registry.orderOf(i), u = t.get("/order"), d = A(u) ? u.toNumber() : 0, p = this.getNextTaskId() + s, y = Me(
496
+ const h = this.registry.orderOf(i), u = t.get("/order"), d = x(u) ? u.toNumber() : 0, p = this.getNextTaskId() + c, y = De(
497
497
  a,
498
498
  r.seq,
499
499
  h,
500
500
  d,
501
501
  n,
502
502
  p
503
- ), w = this.traceManager.addHop(r, o, n);
503
+ ), v = this.traceManager.addHop(r, o, n);
504
504
  this.queue.push({
505
505
  key: y,
506
506
  nodePath: o,
507
507
  contractName: n,
508
508
  contractNode: t,
509
- event: w
509
+ event: v
510
510
  });
511
511
  }
512
512
  /**
@@ -516,61 +516,61 @@ class je {
516
516
  return e.source === "channel" && !!e.originNodePath && e.originNodePath !== t;
517
517
  }
518
518
  }
519
- const xe = (c, e, t) => {
520
- (t instanceof te || t instanceof ne) && console.error(
521
- `[Blue] Failed to apply patches for contract "${c}" on event ${JSON.stringify(e)}`,
519
+ const Fe = (s, e, t) => {
520
+ (t instanceof re || t instanceof ae) && console.error(
521
+ `[Blue] Failed to apply patches for contract "${s}" on event ${JSON.stringify(e)}`,
522
522
  t
523
523
  );
524
524
  };
525
- function _(c, e) {
526
- const t = N(c), n = (o) => {
527
- if (!S(o)) return;
525
+ function R(s, e) {
526
+ const t = O(s), n = (o) => {
527
+ if (!P(o)) return;
528
528
  const r = o.getContracts();
529
- (!(r != null && r.checkpoint) || !E.isTypeOf(
529
+ (!(r != null && r.checkpoint) || !w.isTypeOf(
530
530
  r.checkpoint,
531
- pe
531
+ ge
532
532
  )) && o.addContract(
533
533
  "checkpoint",
534
534
  e.jsonValueToNode({
535
535
  type: {
536
536
  name: "Channel Event Checkpoint",
537
- blueId: f["Channel Event Checkpoint"]
537
+ blueId: m["Channel Event Checkpoint"]
538
538
  },
539
539
  lastEvents: {}
540
540
  })
541
541
  );
542
542
  };
543
543
  n(t);
544
- for (const { absPath: o } of j(t, e)) {
544
+ for (const { absPath: o } of W(t, e)) {
545
545
  const r = t.get(o);
546
- S(r) && n(r);
546
+ P(r) && n(r);
547
547
  }
548
- return k(t);
548
+ return I(t);
549
549
  }
550
- function Je(c, e) {
551
- const t = N(c);
552
- return S(t) && (oe(t, e) || t.addContract(
550
+ function Le(s, e) {
551
+ const t = O(s);
552
+ return P(t) && (se(t, e) || t.addContract(
553
553
  "initialized",
554
554
  e.jsonValueToNode({
555
555
  type: {
556
556
  name: "Initialized Marker",
557
- blueId: f["Initialized Marker"]
557
+ blueId: m["Initialized Marker"]
558
558
  }
559
559
  })
560
- )), k(t);
560
+ )), I(t);
561
561
  }
562
- function oe(c, e) {
563
- const t = c.getContracts();
562
+ function se(s, e) {
563
+ const t = s.getContracts();
564
564
  return Object.values(t ?? {}).some(
565
- (n) => e.isTypeOf(n, me, {
565
+ (n) => e.isTypeOf(n, Ee, {
566
566
  checkSchemaExtensions: !0
567
567
  })
568
568
  );
569
569
  }
570
- class Ve {
570
+ class ze {
571
571
  constructor(e) {
572
572
  l(this, "contractType", "Channel Event Checkpoint");
573
- l(this, "contractBlueId", f["Channel Event Checkpoint"]);
573
+ l(this, "contractBlueId", m["Channel Event Checkpoint"]);
574
574
  l(this, "role", "handler");
575
575
  this.cache = e;
576
576
  }
@@ -585,8 +585,8 @@ class Ve {
585
585
  this.cache.record(r, e, o);
586
586
  }
587
587
  }
588
- const z = (c, e) => c.get(e) !== void 0;
589
- class Fe {
588
+ const H = (s, e) => s.get(e) !== void 0;
589
+ class Ue {
590
590
  constructor() {
591
591
  l(this, "firstSeen", /* @__PURE__ */ new Map());
592
592
  }
@@ -603,10 +603,10 @@ class Fe {
603
603
  n,
604
604
  "contracts/checkpoint/lastEvents",
605
605
  o.channelName
606
- ), s = `${a}/blueId`;
607
- z(e, a) ? t.push({
608
- op: z(e, s) ? "replace" : "add",
609
- path: s,
606
+ ), c = `${a}/blueId`;
607
+ H(e, a) ? t.push({
608
+ op: H(e, c) ? "replace" : "add",
609
+ path: c,
610
610
  val: r
611
611
  }) : t.push({
612
612
  op: "add",
@@ -620,7 +620,7 @@ class Fe {
620
620
  this.firstSeen.clear();
621
621
  }
622
622
  }
623
- class P {
623
+ class S {
624
624
  constructor() {
625
625
  l(this, "role", "adapter");
626
626
  }
@@ -632,14 +632,14 @@ class P {
632
632
  return e.source !== "channel";
633
633
  }
634
634
  }
635
- class Le extends P {
635
+ class Re extends S {
636
636
  constructor() {
637
637
  super(...arguments);
638
638
  l(this, "contractType", "Composite Timeline Channel");
639
- l(this, "contractBlueId", f["Composite Timeline Channel"]);
639
+ l(this, "contractBlueId", m["Composite Timeline Channel"]);
640
640
  }
641
641
  supports(t, n, o) {
642
- const r = o.getBlue().nodeToSchemaOutput(n, fe);
642
+ const r = o.getBlue().nodeToSchemaOutput(n, we);
643
643
  return !r.channels || !t.channelName ? !1 : r.channels.includes(t.channelName);
644
644
  }
645
645
  handle(t, n, o, r) {
@@ -650,18 +650,18 @@ class Le extends P {
650
650
  });
651
651
  }
652
652
  }
653
- class Ue extends P {
653
+ class He extends S {
654
654
  constructor() {
655
655
  super(...arguments);
656
656
  l(this, "contractType", "Document Update Channel");
657
- l(this, "contractBlueId", f["Document Update Channel"]);
657
+ l(this, "contractBlueId", m["Document Update Channel"]);
658
658
  }
659
659
  supports(t, n, o, r) {
660
660
  if (!this.baseSupports(t)) return !1;
661
- const a = o.getBlue().nodeToSchemaOutput(n, ye), s = t.payload.get("/path");
662
- if (!s || t.channelName === r) return !1;
661
+ const a = o.getBlue().nodeToSchemaOutput(n, ve), c = t.payload.get("/path");
662
+ if (!c || t.channelName === r) return !1;
663
663
  const i = a.path;
664
- return O(i) && s === o.resolvePath(i);
664
+ return M(i) && c === o.resolvePath(i);
665
665
  }
666
666
  handle(t, n, o, r) {
667
667
  const a = t.payload;
@@ -672,30 +672,30 @@ class Ue extends P {
672
672
  });
673
673
  }
674
674
  }
675
- class _e extends P {
675
+ class Qe extends S {
676
676
  constructor() {
677
677
  super(...arguments);
678
678
  l(this, "contractType", "Embedded Node Channel");
679
- l(this, "contractBlueId", f["Embedded Node Channel"]);
679
+ l(this, "contractBlueId", m["Embedded Node Channel"]);
680
680
  }
681
681
  supports(t, n, o) {
682
682
  if (!this.baseSupports(t)) return !1;
683
- const r = o.getBlue().nodeToSchemaOutput(n, J);
684
- return m(t.originNodePath) && m(r.path) && t.originNodePath === o.resolvePath(r.path);
683
+ const r = o.getBlue().nodeToSchemaOutput(n, _);
684
+ return f(t.originNodePath) && f(r.path) && t.originNodePath === o.resolvePath(r.path);
685
685
  }
686
686
  handle(t, n, o, r) {
687
- const a = o.getBlue().nodeToSchemaOutput(n, J), { originNodePath: s, payload: i } = t;
688
- m(a.path) && s === o.resolvePath(a.path) && o.emitEvent({
687
+ const a = o.getBlue().nodeToSchemaOutput(n, _), { originNodePath: c, payload: i } = t;
688
+ f(a.path) && c === o.resolvePath(a.path) && o.emitEvent({
689
689
  payload: i,
690
690
  channelName: r,
691
691
  source: "channel"
692
692
  });
693
693
  }
694
694
  }
695
- class ze {
695
+ class Ke {
696
696
  constructor() {
697
697
  l(this, "contractType", "Initialized Marker");
698
- l(this, "contractBlueId", f["Initialized Marker"]);
698
+ l(this, "contractBlueId", m["Initialized Marker"]);
699
699
  l(this, "role", "marker");
700
700
  }
701
701
  supports() {
@@ -704,11 +704,11 @@ class ze {
704
704
  handle() {
705
705
  }
706
706
  }
707
- class He extends P {
707
+ class Xe extends S {
708
708
  constructor() {
709
709
  super(...arguments);
710
710
  l(this, "contractType", "Lifecycle Event Channel");
711
- l(this, "contractBlueId", f["Lifecycle Event Channel"]);
711
+ l(this, "contractBlueId", m["Lifecycle Event Channel"]);
712
712
  }
713
713
  supports(t, n, o) {
714
714
  return !this.baseSupports(t) || !this.isLifecycleEvent(t, o) ? !1 : this.isEventPatternMatch(t, n, o);
@@ -725,7 +725,7 @@ class He extends P {
725
725
  */
726
726
  isLifecycleEvent(t, n) {
727
727
  const o = n.getBlue(), r = t.payload;
728
- return o.isTypeOf(r, ge, {
728
+ return o.isTypeOf(r, be, {
729
729
  checkSchemaExtensions: !0
730
730
  });
731
731
  }
@@ -738,45 +738,45 @@ class He extends P {
738
738
  if (!r)
739
739
  return !0;
740
740
  try {
741
- const s = o.getBlue(), i = s.nodeToJson(t.payload), h = s.nodeToJson(r);
742
- return Y(i, h);
743
- } catch (s) {
744
- return console.warn("Error during lifecycle event pattern matching:", s), !1;
741
+ const c = o.getBlue(), i = c.nodeToJson(t.payload), h = c.nodeToJson(r);
742
+ return ee(i, h);
743
+ } catch (c) {
744
+ return console.warn("Error during lifecycle event pattern matching:", c), !1;
745
745
  }
746
746
  }
747
747
  }
748
- const H = (c, e) => {
748
+ const Q = (s, e) => {
749
749
  const t = e.getBlue();
750
- return t.isTypeOf(c.payload, I) || t.isTypeOf(c.payload, G);
750
+ return t.isTypeOf(s.payload, N) || t.isTypeOf(s.payload, ne);
751
751
  };
752
- class Re extends P {
752
+ class Ye extends S {
753
753
  constructor() {
754
754
  super(...arguments);
755
755
  l(this, "contractType", "MyOS Timeline Channel");
756
- l(this, "contractBlueId", Z["MyOS Timeline Channel"]);
756
+ l(this, "contractBlueId", te["MyOS Timeline Channel"]);
757
757
  }
758
758
  supports(t, n, o) {
759
759
  var p;
760
- if (!this.baseSupports(t) || !H(t, o)) return !1;
760
+ if (!this.baseSupports(t) || !Q(t, o)) return !1;
761
761
  const a = o.getBlue().nodeToSchemaOutput(
762
762
  t.payload,
763
- G
764
- ), s = o.getBlue().nodeToSchemaOutput(n, Ce), i = (p = a.timeline) == null ? void 0 : p.timelineId, h = m(s.timelineId) && m(i), u = m(s.account) && m(a.account), d = m(s.email) && m(a.email);
765
- return h && i === s.timelineId || u && a.account === s.account || d && a.email === s.email;
763
+ ne
764
+ ), c = o.getBlue().nodeToSchemaOutput(n, Oe), i = (p = a.timeline) == null ? void 0 : p.timelineId, h = f(c.timelineId) && f(i), u = f(c.account) && f(a.account), d = f(c.email) && f(a.email);
765
+ return h && i === c.timelineId || u && a.account === c.account || d && a.email === c.email;
766
766
  }
767
767
  handle(t, n, o, r) {
768
- H(t, o) && o.emitEvent({
768
+ Q(t, o) && o.emitEvent({
769
769
  payload: t.payload,
770
770
  channelName: r,
771
771
  source: "channel"
772
772
  });
773
773
  }
774
774
  }
775
- class Qe extends P {
775
+ class Ze extends S {
776
776
  constructor() {
777
777
  super(...arguments);
778
778
  l(this, "contractType", "MyOS Agent Channel");
779
- l(this, "contractBlueId", Z["MyOS Agent Channel"]);
779
+ l(this, "contractBlueId", te["MyOS Agent Channel"]);
780
780
  }
781
781
  supports(t, n, o) {
782
782
  if (!this.baseSupports(t)) return !1;
@@ -805,12 +805,12 @@ class Qe extends P {
805
805
  parseEventAndChannel(t, n, o) {
806
806
  const r = o.getBlue(), a = r.nodeToSchemaOutput(
807
807
  t.payload,
808
- ke
809
- ), s = r.nodeToSchemaOutput(
808
+ Be
809
+ ), c = r.nodeToSchemaOutput(
810
810
  n,
811
- Ie
811
+ Me
812
812
  );
813
- return { myosAgentEvent: a, myosAgentChannel: s };
813
+ return { myosAgentEvent: a, myosAgentChannel: c };
814
814
  }
815
815
  /**
816
816
  * Checks if the agent IDs match between event and channel
@@ -821,7 +821,7 @@ class Qe extends P {
821
821
  isAgentMatch(t, n) {
822
822
  var a;
823
823
  const o = t.agentId, r = (a = n.agent) == null ? void 0 : a.agentId;
824
- return m(o) && m(r) && o === r;
824
+ return f(o) && f(r) && o === r;
825
825
  }
826
826
  /**
827
827
  * Checks if the event pattern matches the channel's event filter
@@ -844,22 +844,22 @@ class Qe extends P {
844
844
  if (!a)
845
845
  return !1;
846
846
  try {
847
- const s = o.getBlue(), i = s.nodeToJson(a), h = s.nodeToJson(r);
848
- return Y(i, h);
849
- } catch (s) {
850
- return console.warn("Error during event pattern matching:", s), !1;
847
+ const c = o.getBlue(), i = c.nodeToJson(a), h = c.nodeToJson(r);
848
+ return ee(i, h);
849
+ } catch (c) {
850
+ return console.warn("Error during event pattern matching:", c), !1;
851
851
  }
852
852
  }
853
853
  }
854
- class Ke {
854
+ class Ge {
855
855
  constructor() {
856
856
  l(this, "contractType", "Operation");
857
- l(this, "contractBlueId", f.Operation);
857
+ l(this, "contractBlueId", m.Operation);
858
858
  l(this, "role", "adapter");
859
859
  }
860
860
  supports(e, t, n, o) {
861
- const a = n.getBlue().nodeToSchemaOutput(t, Ee), s = this.parseEventPayload(e, n);
862
- return m(s == null ? void 0 : s.operation) && s.operation === o && e.source === "channel" && e.channelName === a.channel;
861
+ const a = n.getBlue().nodeToSchemaOutput(t, Te), c = this.parseEventPayload(e, n);
862
+ return f(c == null ? void 0 : c.operation) && c.operation === o && e.source === "channel" && e.channelName === a.channel;
863
863
  }
864
864
  async handle(e, t, n, o) {
865
865
  n.emitEvent({
@@ -870,33 +870,33 @@ class Ke {
870
870
  }
871
871
  parseEventPayload(e, t) {
872
872
  const n = t.getBlue();
873
- if (n.isTypeOf(e.payload, I, {
873
+ if (n.isTypeOf(e.payload, N, {
874
874
  checkSchemaExtensions: !0
875
875
  })) {
876
876
  const o = n.nodeToSchemaOutput(
877
877
  e.payload,
878
- I
878
+ N
879
879
  );
880
880
  if (o.message)
881
881
  return n.nodeToSchemaOutput(
882
882
  o.message,
883
- we
883
+ Pe
884
884
  );
885
885
  }
886
886
  return null;
887
887
  }
888
888
  }
889
- class Xe {
889
+ class et {
890
890
  constructor() {
891
891
  l(this, "contractType", "Process Embedded");
892
892
  l(this, "role", "adapter");
893
- l(this, "contractBlueId", f["Process Embedded"]);
893
+ l(this, "contractBlueId", m["Process Embedded"]);
894
894
  }
895
895
  supports(e) {
896
896
  return e.source !== "channel";
897
897
  }
898
898
  handle(e, t, n) {
899
- const o = n.getBlue().nodeToSchemaOutput(t, q);
899
+ const o = n.getBlue().nodeToSchemaOutput(t, D);
900
900
  for (const r of o.paths ?? [])
901
901
  n.emitEvent({
902
902
  ...e,
@@ -904,18 +904,18 @@ class Xe {
904
904
  });
905
905
  }
906
906
  }
907
- const re = !process.env.SKIP_ISOLATED_VM;
908
- let v = null;
909
- if (re)
907
+ const ce = !process.env.SKIP_ISOLATED_VM;
908
+ let E = null;
909
+ if (ce)
910
910
  try {
911
- v = require("isolated-vm");
911
+ E = require("isolated-vm");
912
912
  } catch {
913
913
  console.warn("isolated-vm not available, using fallback evaluation method");
914
914
  }
915
- function R(c) {
916
- return /\bimport\s.+\sfrom\s+['"][^'"]+['"]/.test(c) || /\bexport\s+/.test(c);
915
+ function K(s) {
916
+ return /\bimport\s.+\sfrom\s+['"][^'"]+['"]/.test(s) || /\bexport\s+/.test(s);
917
917
  }
918
- class D {
918
+ class j {
919
919
  /**
920
920
  * Main evaluation method - chooses between secure and simple evaluation strategies
921
921
  */
@@ -925,14 +925,14 @@ class D {
925
925
  bindings: n = {},
926
926
  options: o = {}
927
927
  }) {
928
- return !v || !re ? this.evaluateSimple(e, n, o) : this.evaluateSecure(e, n, t, o);
928
+ return !E || !ce ? this.evaluateSimple(e, n, o) : this.evaluateSecure(e, n, t, o);
929
929
  }
930
930
  /**
931
931
  * Fallback evaluation using Node's Function constructor
932
932
  * Used when isolated-vm is not available
933
933
  */
934
934
  static async evaluateSimple(e, t, n = {}) {
935
- if (R(e))
935
+ if (K(e))
936
936
  throw new Error(
937
937
  "Static import/export syntax requires isolated-vm – start Node without SKIP_ISOLATED_VM."
938
938
  );
@@ -945,25 +945,25 @@ class D {
945
945
  ", "
946
946
  )}) { ${e} }`
947
947
  )(
948
- ...o.map((s) => t[s])
949
- ))(...o.map((s) => t[s]));
948
+ ...o.map((c) => t[c])
949
+ ))(...o.map((c) => t[c]));
950
950
  } else
951
951
  return new Function(
952
952
  ...Object.keys(t),
953
953
  `return ${e};`
954
954
  )(...Object.values(t));
955
955
  } catch (o) {
956
- throw n.isCodeBlock ? new F(e, o) : new V(e, o);
956
+ throw n.isCodeBlock ? new L(e, o) : new F(e, o);
957
957
  }
958
958
  }
959
959
  /**
960
960
  * Secure evaluation using isolated-vm with support for ES modules
961
961
  */
962
962
  static async evaluateSecure(e, t, n, o = {}) {
963
- if (!v) throw new Error("isolated-vm not available");
964
- const r = new v.Isolate({ memoryLimit: 32 }), a = await r.createContext(), s = a.global;
963
+ if (!E) throw new Error("isolated-vm not available");
964
+ const r = new E.Isolate({ memoryLimit: 32 }), a = await r.createContext(), c = a.global;
965
965
  try {
966
- await this.setupIsolateEnvironment(s, t);
966
+ await this.setupIsolateEnvironment(c, t);
967
967
  const i = /* @__PURE__ */ new Map(), h = this.createModuleResolver(
968
968
  r,
969
969
  a,
@@ -971,7 +971,7 @@ class D {
971
971
  n
972
972
  );
973
973
  let u;
974
- return R(e) ? u = await this.evaluateESModule(
974
+ return K(e) ? u = await this.evaluateESModule(
975
975
  r,
976
976
  a,
977
977
  e,
@@ -985,7 +985,7 @@ class D {
985
985
  o
986
986
  ), this.deepClone(u);
987
987
  } catch (i) {
988
- throw o.isCodeBlock ? new F(e, i) : new V(e, i);
988
+ throw o.isCodeBlock ? new L(e, i) : new F(e, i);
989
989
  } finally {
990
990
  a.release(), r.dispose();
991
991
  }
@@ -994,16 +994,18 @@ class D {
994
994
  * Setup the isolated VM environment with necessary host functions and data
995
995
  */
996
996
  static async setupIsolateEnvironment(e, t) {
997
- if (!v) throw new Error("isolated-vm not available");
998
- const n = new v.Callback(
999
- (...o) => console.log(...o)
1000
- );
1001
- await e.set("log", n);
1002
- for (const [o, r] of Object.entries(t))
1003
- typeof r == "function" ? await e.set(
1004
- o,
1005
- new v.Callback(r)
1006
- ) : await e.set(o, new v.ExternalCopy(r).copyInto());
997
+ if (!E) throw new Error("isolated-vm not available");
998
+ const n = new E.Callback(
999
+ (...r) => console.log(...r)
1000
+ ), o = new E.ExternalCopy({
1001
+ log: n
1002
+ }).copyInto();
1003
+ await e.set("console", o);
1004
+ for (const [r, a] of Object.entries(t))
1005
+ typeof a == "function" ? await e.set(
1006
+ r,
1007
+ new E.Callback(a)
1008
+ ) : await e.set(r, new E.ExternalCopy(a).copyInto());
1007
1009
  }
1008
1010
  /**
1009
1011
  * Create module resolver function for handling imports
@@ -1012,12 +1014,12 @@ class D {
1012
1014
  return async (r) => {
1013
1015
  if (n.has(r)) return n.get(r);
1014
1016
  if (r.startsWith("blue:")) {
1015
- const a = r.slice(5), s = o.loadBlueContent;
1016
- if (typeof s != "function")
1017
+ const a = r.slice(5), c = o.loadBlueContent;
1018
+ if (typeof c != "function")
1017
1019
  throw new Error(
1018
1020
  `ProcessingContext is missing a loadBlueContent(blueId) implementation (needed for ${r})`
1019
1021
  );
1020
- const i = await s(a), h = await e.compileModule(i);
1022
+ const i = await c(a), h = await e.compileModule(i);
1021
1023
  return n.set(r, h), await h.instantiate(
1022
1024
  t,
1023
1025
  this.createModuleResolver(e, t, n, o)
@@ -1031,11 +1033,11 @@ class D {
1031
1033
  throw new Error(
1032
1034
  `ProcessingContext is missing a loadExternalModule(url) implementation (needed for ${r})`
1033
1035
  );
1034
- const s = await e.compileModule(a);
1035
- return n.set(r, s), await s.instantiate(
1036
+ const c = await e.compileModule(a);
1037
+ return n.set(r, c), await c.instantiate(
1036
1038
  t,
1037
1039
  this.createModuleResolver(e, t, n, o)
1038
- ), s;
1040
+ ), c;
1039
1041
  }
1040
1042
  throw new Error(`Unsupported module specifier "${r}"`);
1041
1043
  };
@@ -1044,7 +1046,7 @@ class D {
1044
1046
  * Evaluate code as a simple script (no imports/exports)
1045
1047
  */
1046
1048
  static async evaluateSimpleScript(e, t, n, o, r) {
1047
- const a = Object.keys(o).join(", "), s = Object.keys(o).map((u) => u), i = `(async (${a}) => { ${r.isCodeBlock ? n : `return (${n});`} })(${s.join(", ")})`;
1049
+ const a = Object.keys(o).join(", "), c = Object.keys(o).map((u) => u), i = `(async (${a}) => { ${r.isCodeBlock ? n : `return (${n});`} })(${c.join(", ")})`;
1048
1050
  return await (await e.compileScript(i)).run(t, {
1049
1051
  timeout: r.timeout ?? 500,
1050
1052
  promise: !0,
@@ -1070,13 +1072,13 @@ class D {
1070
1072
  export default run();
1071
1073
  `;
1072
1074
  }
1073
- const s = await e.compileModule(a);
1074
- return await s.instantiate(t, r), await s.evaluate({
1075
+ const c = await e.compileModule(a);
1076
+ return await c.instantiate(t, r), await c.evaluate({
1075
1077
  timeout: o.timeout ?? 500,
1076
1078
  promise: !0,
1077
1079
  reference: !0,
1078
1080
  release: !0
1079
- }), await s.namespace.get("default", {
1081
+ }), await c.namespace.get("default", {
1080
1082
  timeout: o.timeout ?? 500,
1081
1083
  promise: !0,
1082
1084
  copy: !0,
@@ -1091,24 +1093,24 @@ class D {
1091
1093
  return typeof e > "u" ? e : JSON.parse(JSON.stringify(e));
1092
1094
  }
1093
1095
  }
1094
- class W {
1096
+ class V {
1095
1097
  /**
1096
1098
  * Creates standard bindings for workflow step execution
1097
1099
  */
1098
1100
  static createStandardBindings(e, t, n) {
1099
- const o = e.getBlue(), r = o.nodeToJson(t.payload, "simple"), a = A(r) ? r.toNumber() : r;
1101
+ const o = e.getBlue(), r = o.nodeToJson(t.payload, "simple"), a = x(r) ? r.toNumber() : r;
1100
1102
  return {
1101
- document: (s) => {
1102
- const i = e.get(s);
1103
- return A(i) ? i.toNumber() : S(i) ? o.nodeToJson(i, "original") : i;
1103
+ document: (c) => {
1104
+ const i = e.get(c);
1105
+ return x(i) ? i.toNumber() : P(i) ? o.nodeToJson(i, "original") : i;
1104
1106
  },
1105
1107
  event: a,
1106
1108
  steps: n
1107
1109
  };
1108
1110
  }
1109
1111
  }
1110
- function Q(c, e) {
1111
- const { op: t, path: n, val: o, from: r } = c;
1112
+ function X(s, e) {
1113
+ const { op: t, path: n, val: o, from: r } = s;
1112
1114
  if ((t === "move" || t === "copy") && !r)
1113
1115
  throw new Error(`${t} operation requires 'from' path`);
1114
1116
  if ((t === "add" || t === "replace") && o === void 0)
@@ -1120,35 +1122,40 @@ function Q(c, e) {
1120
1122
  };
1121
1123
  return o !== void 0 && (a.val = o), r !== void 0 && (a.from = r), e.jsonValueToNode(a);
1122
1124
  }
1123
- function Ye(c) {
1124
- return c.jsonValueToNode({
1125
+ function tt(s) {
1126
+ return s.jsonValueToNode({
1125
1127
  type: "Document Processing Initiated"
1126
1128
  });
1127
1129
  }
1128
- class Ze {
1130
+ const nt = /^\$\{(.*)\}$/, B = (s) => typeof s != "string" ? !1 : nt.test(s), Y = (s) => {
1131
+ if (!B(s))
1132
+ throw new Error(`Invalid expression: ${s}`);
1133
+ return s.slice(2, -1);
1134
+ };
1135
+ class ot {
1129
1136
  constructor() {
1130
1137
  l(this, "stepType", "Update Document");
1131
1138
  }
1132
1139
  supports(e) {
1133
- return E.isTypeOf(e, B);
1140
+ return w.isTypeOf(e, $);
1134
1141
  }
1135
1142
  async execute(e, t, n, o, r) {
1136
1143
  const a = n.getBlue();
1137
- if (!E.isTypeOf(e, B)) return;
1138
- const s = await this.evaluateChangeset(
1144
+ if (!w.isTypeOf(e, $)) return;
1145
+ const c = await this.evaluateChangeset(
1139
1146
  e.get("/changeset"),
1140
1147
  n,
1141
1148
  t,
1142
1149
  r
1143
- ), i = X(e, {
1150
+ ), i = G(e, {
1144
1151
  op: "replace",
1145
1152
  path: "/changeset",
1146
- val: s
1147
- }), h = n.getBlue().nodeToSchemaOutput(i, B);
1153
+ val: c
1154
+ }), h = n.getBlue().nodeToSchemaOutput(i, $);
1148
1155
  for (const u of h.changeset ?? []) {
1149
1156
  if (!u.path) continue;
1150
1157
  const d = u.val;
1151
- if ((u.op === "replace" || u.op === "add") && O(d)) {
1158
+ if ((u.op === "replace" || u.op === "add") && M(d)) {
1152
1159
  const p = await this.evaluateChangeValue(
1153
1160
  d,
1154
1161
  n,
@@ -1160,7 +1167,7 @@ class Ze {
1160
1167
  path: u.path,
1161
1168
  val: p
1162
1169
  }), n.emitEvent({
1163
- payload: Q(
1170
+ payload: X(
1164
1171
  {
1165
1172
  op: u.op,
1166
1173
  path: n.resolvePath(u.path),
@@ -1171,7 +1178,7 @@ class Ze {
1171
1178
  });
1172
1179
  }
1173
1180
  u.op === "remove" && (n.addPatch({ op: u.op, path: u.path }), n.emitEvent({
1174
- payload: Q(
1181
+ payload: X(
1175
1182
  {
1176
1183
  op: u.op,
1177
1184
  path: n.resolvePath(u.path),
@@ -1184,29 +1191,29 @@ class Ze {
1184
1191
  }
1185
1192
  async evaluateChangeset(e, t, n, o) {
1186
1193
  const r = t.getBlue();
1187
- if (typeof e == "string" && e.startsWith("${") && e.endsWith("}")) {
1188
- const a = e.slice(2, -1), s = await D.evaluate({
1194
+ if (B(e)) {
1195
+ const a = Y(e), c = await j.evaluate({
1189
1196
  code: a,
1190
1197
  ctx: t,
1191
- bindings: W.createStandardBindings(
1198
+ bindings: V.createStandardBindings(
1192
1199
  t,
1193
1200
  n,
1194
1201
  o
1195
1202
  )
1196
1203
  });
1197
- return r.jsonValueToNode(s ?? null);
1204
+ return r.jsonValueToNode(c ?? null);
1198
1205
  }
1199
- if (S(e))
1206
+ if (P(e))
1200
1207
  return e;
1201
1208
  throw new Error("Invalid changeset: expected a string or document node");
1202
1209
  }
1203
1210
  async evaluateChangeValue(e, t, n, o) {
1204
1211
  const r = e.getValue(), a = t.getBlue();
1205
- if (typeof r == "string" && r.startsWith("${") && r.endsWith("}")) {
1206
- const s = r.slice(2, -1), i = await D.evaluate({
1207
- code: s,
1212
+ if (B(r)) {
1213
+ const c = Y(r), i = await j.evaluate({
1214
+ code: c,
1208
1215
  ctx: t,
1209
- bindings: W.createStandardBindings(
1216
+ bindings: V.createStandardBindings(
1210
1217
  t,
1211
1218
  n,
1212
1219
  o
@@ -1217,41 +1224,41 @@ class Ze {
1217
1224
  return e;
1218
1225
  }
1219
1226
  }
1220
- class Ge {
1227
+ class rt {
1221
1228
  constructor() {
1222
1229
  l(this, "stepType", "Trigger Event");
1223
1230
  }
1224
1231
  supports(e) {
1225
- return E.isTypeOf(e, M);
1232
+ return w.isTypeOf(e, q);
1226
1233
  }
1227
1234
  async execute(e, t, n) {
1228
1235
  const o = n.getBlue();
1229
- if (!E.isTypeOf(e, M)) return;
1230
- const r = o.nodeToSchemaOutput(e, M);
1236
+ if (!w.isTypeOf(e, q)) return;
1237
+ const r = o.nodeToSchemaOutput(e, q);
1231
1238
  r.event && n.emitEvent({
1232
1239
  payload: r.event
1233
1240
  });
1234
1241
  }
1235
1242
  }
1236
- class et {
1243
+ class at {
1237
1244
  constructor() {
1238
1245
  l(this, "stepType", "JavaScript Code");
1239
1246
  }
1240
1247
  supports(e) {
1241
- return E.isTypeOf(e, $);
1248
+ return w.isTypeOf(e, A);
1242
1249
  }
1243
1250
  async execute(e, t, n, o, r) {
1244
- if (!E.isTypeOf(e, $)) return;
1245
- const a = n.getBlue(), s = a.nodeToSchemaOutput(
1251
+ if (!w.isTypeOf(e, A)) return;
1252
+ const a = n.getBlue(), c = a.nodeToSchemaOutput(
1246
1253
  e,
1247
- $
1254
+ A
1248
1255
  );
1249
- if (!s.code)
1256
+ if (!c.code)
1250
1257
  throw new Error("JavaScript code is required");
1251
- const i = await D.evaluate({
1252
- code: s.code,
1258
+ const i = await j.evaluate({
1259
+ code: c.code,
1253
1260
  ctx: n,
1254
- bindings: W.createStandardBindings(n, t, r),
1261
+ bindings: V.createStandardBindings(n, t, r),
1255
1262
  options: {
1256
1263
  isCodeBlock: !0,
1257
1264
  timeout: 500
@@ -1268,15 +1275,15 @@ class et {
1268
1275
  return i;
1269
1276
  }
1270
1277
  }
1271
- const tt = [
1272
- new Ze(),
1273
- new Ge(),
1274
- new et()
1278
+ const st = [
1279
+ new ot(),
1280
+ new rt(),
1281
+ new at()
1275
1282
  ];
1276
- class ae {
1277
- constructor(e = tt) {
1283
+ class ie {
1284
+ constructor(e = st) {
1278
1285
  l(this, "contractType", "Sequential Workflow");
1279
- l(this, "contractBlueId", f["Sequential Workflow"]);
1286
+ l(this, "contractBlueId", m["Sequential Workflow"]);
1280
1287
  l(this, "role", "handler");
1281
1288
  l(this, "executors", []);
1282
1289
  this.executors = e;
@@ -1288,13 +1295,13 @@ class ae {
1288
1295
  supports(e, t, n) {
1289
1296
  const a = n.getBlue().nodeToSchemaOutput(
1290
1297
  t,
1291
- ve
1298
+ Se
1292
1299
  ).channel;
1293
1300
  return e.source === "channel" && e.channelName === a;
1294
1301
  }
1295
1302
  async handle(e, t, n, o) {
1296
- var s;
1297
- const r = {}, a = (s = t.getProperties()) == null ? void 0 : s.steps.getItems();
1303
+ var c;
1304
+ const r = {}, a = (c = t.getProperties()) == null ? void 0 : c.steps.getItems();
1298
1305
  for (const [i, h] of (a ?? []).entries()) {
1299
1306
  const u = this.executors.find((p) => p.supports(h));
1300
1307
  if (!u)
@@ -1314,20 +1321,20 @@ class ae {
1314
1321
  }
1315
1322
  }
1316
1323
  }
1317
- class nt {
1324
+ class ct {
1318
1325
  constructor(e) {
1319
1326
  l(this, "contractType", "Sequential Workflow Operation");
1320
- l(this, "contractBlueId", f["Sequential Workflow Operation"]);
1327
+ l(this, "contractBlueId", m["Sequential Workflow Operation"]);
1321
1328
  l(this, "role", "handler");
1322
1329
  l(this, "sequentialWorkflowProcessor");
1323
- this.sequentialWorkflowProcessor = e || new ae();
1330
+ this.sequentialWorkflowProcessor = e || new ie();
1324
1331
  }
1325
1332
  supports(e, t, n) {
1326
1333
  const a = n.getBlue().nodeToSchemaOutput(
1327
1334
  t,
1328
- be
1329
- ).operation, s = e.channelName;
1330
- return e.source === "channel" && O(s) && O(a) && s === a;
1335
+ Ce
1336
+ ).operation, c = e.channelName;
1337
+ return e.source === "channel" && M(c) && M(a) && c === a;
1331
1338
  }
1332
1339
  async handle(e, t, n, o) {
1333
1340
  try {
@@ -1340,68 +1347,68 @@ class nt {
1340
1347
  }
1341
1348
  }
1342
1349
  }
1343
- const K = (c) => E.isTypeOf(c.payload, I);
1344
- class ot extends P {
1350
+ const Z = (s) => w.isTypeOf(s.payload, N);
1351
+ class it extends S {
1345
1352
  constructor() {
1346
1353
  super(...arguments);
1347
1354
  l(this, "contractType", "Timeline Channel");
1348
- l(this, "contractBlueId", f["Timeline Channel"]);
1355
+ l(this, "contractBlueId", m["Timeline Channel"]);
1349
1356
  }
1350
1357
  supports(t, n, o) {
1351
1358
  var u;
1352
- if (!this.baseSupports(t) || !K(t)) return !1;
1359
+ if (!this.baseSupports(t) || !Z(t)) return !1;
1353
1360
  const a = o.getBlue().nodeToSchemaOutput(
1354
1361
  t.payload,
1355
- I
1356
- ), s = o.getBlue().nodeToSchemaOutput(n, Te), i = (u = a.timeline) == null ? void 0 : u.timelineId;
1357
- return m(s.timelineId) && m(i) && i === s.timelineId;
1362
+ N
1363
+ ), c = o.getBlue().nodeToSchemaOutput(n, ke), i = (u = a.timeline) == null ? void 0 : u.timelineId;
1364
+ return f(c.timelineId) && f(i) && i === c.timelineId;
1358
1365
  }
1359
1366
  handle(t, n, o, r) {
1360
- K(t) && o.emitEvent({
1367
+ Z(t) && o.emitEvent({
1361
1368
  payload: t.payload,
1362
1369
  channelName: r,
1363
1370
  source: "channel"
1364
1371
  });
1365
1372
  }
1366
1373
  }
1367
- const rt = [
1368
- new Xe(),
1374
+ const lt = [
1375
+ new et(),
1369
1376
  // channels
1370
- new _e(),
1371
- new Ue(),
1372
- new ot(),
1373
- new Re(),
1374
1377
  new Qe(),
1375
- new Le(),
1376
1378
  new He(),
1377
- new Ke(),
1379
+ new it(),
1380
+ new Ye(),
1381
+ new Ze(),
1382
+ new Re(),
1383
+ new Xe(),
1384
+ new Ge(),
1378
1385
  // sequential workflows
1379
- new ae(),
1380
- new nt(),
1386
+ new ie(),
1387
+ new ct(),
1381
1388
  // markers
1382
- new ze()
1389
+ new Ke()
1383
1390
  ];
1384
- class ht {
1391
+ class yt {
1385
1392
  /**
1386
1393
  * Creates a new document processor
1387
1394
  *
1388
1395
  * @param processors - Initial list of processors to register
1389
1396
  */
1390
- constructor(e, t = rt) {
1397
+ constructor(e, t = lt) {
1391
1398
  l(this, "taskCounter", 0);
1392
1399
  l(this, "eventCounter", 0);
1393
1400
  l(this, "registry");
1394
1401
  l(this, "queue");
1395
1402
  l(this, "router");
1396
- l(this, "checkpointCache", new Fe());
1397
- this.blue = e, this.registry = new Ae(t), this.queue = new qe(), this.router = new je(
1403
+ l(this, "checkpointCache", new Ue());
1404
+ this.blue = e, this.registry = new Ve(t), this.queue = new je(), this.router = new _e(
1398
1405
  this.blue,
1399
1406
  this.registry,
1400
1407
  this.queue,
1401
1408
  () => ++this.taskCounter,
1402
1409
  () => ++this.eventCounter
1403
1410
  ), this.register(
1404
- new Ve(this.checkpointCache),
1411
+ new ze(this.checkpointCache),
1405
1412
  9999
1406
1413
  );
1407
1414
  }
@@ -1421,13 +1428,13 @@ class ht {
1421
1428
  * @returns Processing result with final state and emitted events
1422
1429
  */
1423
1430
  async initialize(e) {
1424
- let t = _(k(e), this.blue);
1431
+ let t = R(I(e), this.blue);
1425
1432
  const n = {
1426
- payload: Ye(this.blue)
1433
+ payload: tt(this.blue)
1427
1434
  }, o = [n.payload];
1428
1435
  await this.router.route(t, [], n, 0);
1429
1436
  const r = await this.drainQueue(t);
1430
- return t = r.state, o.push(...r.emitted), t = Je(t, this.blue), { state: N(t), emitted: o };
1437
+ return t = r.state, o.push(...r.emitted), t = Le(t, this.blue), { state: O(t), emitted: o };
1431
1438
  }
1432
1439
  /**
1433
1440
  * Processes a batch of events against the document
@@ -1437,22 +1444,22 @@ class ht {
1437
1444
  * @returns Processing result with final state and emitted events
1438
1445
  */
1439
1446
  async processEvents(e, t) {
1440
- let n = _(k(e), this.blue);
1447
+ let n = R(I(e), this.blue);
1441
1448
  const o = [];
1442
- if (!oe(n, this.blue))
1449
+ if (!se(n, this.blue))
1443
1450
  throw new Error("Document is not initialized");
1444
1451
  for (const r of t)
1445
1452
  try {
1446
1453
  const a = { payload: r, source: "external" };
1447
1454
  await this.router.route(n, [], a, 0);
1448
- const s = await this.drainQueue(n);
1449
- n = s.state, o.push(...s.emitted);
1455
+ const c = await this.drainQueue(n);
1456
+ n = c.state, o.push(...c.emitted);
1450
1457
  const i = this.checkpointCache.flush(n);
1451
1458
  i.length && (n = U(n, i));
1452
1459
  } finally {
1453
1460
  this.checkpointCache.clear();
1454
1461
  }
1455
- return { state: N(n), emitted: o };
1462
+ return { state: O(n), emitted: o };
1456
1463
  }
1457
1464
  /**
1458
1465
  * Drains the task queue and applies all actions
@@ -1465,61 +1472,102 @@ class ht {
1465
1472
  for (; this.queue.length; ) {
1466
1473
  if (++r > o)
1467
1474
  throw new Error("Possible cycle – too many iterations");
1468
- const s = this.queue.pop(), { nodePath: i, contractName: h, contractNode: u, event: d } = s, p = t.get(i);
1469
- if (!S(p) || !((a = p.getContracts()) != null && a[h]) || !u.getType()) continue;
1475
+ const c = this.queue.pop(), { nodePath: i, contractName: h, contractNode: u, event: d } = c, p = t.get(i);
1476
+ if (!P(p) || !((a = p.getContracts()) != null && a[h]) || !u.getType()) continue;
1470
1477
  const y = this.registry.get(u.getType());
1471
1478
  if (!y) {
1472
1479
  console.warn(`No processor registered for contract: ${h}`);
1473
1480
  continue;
1474
1481
  }
1475
- const w = new ee(
1482
+ const v = new oe(
1476
1483
  () => t,
1477
- s,
1484
+ c,
1478
1485
  this.blue,
1479
1486
  async (T) => {
1480
1487
  for (const g of T)
1481
1488
  if (g.kind === "patch") {
1482
- const se = j(t, this.blue);
1483
- for (const C of se) {
1484
- const ce = g.patch.op === "move" || g.patch.op === "copy" ? [g.patch.from, g.patch.path] : [g.patch.path], x = w.getNodePath(), ie = ce.some(
1485
- (ue) => L(ue, C.absPath)
1486
- ), le = L(
1487
- x,
1489
+ const ue = W(t, this.blue);
1490
+ for (const C of ue) {
1491
+ const he = g.patch.op === "move" || g.patch.op === "copy" ? [g.patch.from, g.patch.path] : [g.patch.path], J = v.getNodePath(), de = he.some(
1492
+ (fe) => z(fe, C.absPath)
1493
+ ), pe = z(
1494
+ J,
1488
1495
  C.absPath
1489
1496
  );
1490
- if (ie && !le)
1491
- throw new ne(
1497
+ if (de && !pe)
1498
+ throw new ae(
1492
1499
  g.patch,
1493
1500
  C.absPath,
1494
- x
1501
+ J
1495
1502
  );
1496
1503
  }
1497
1504
  try {
1498
1505
  t = U(t, [g.patch]);
1499
1506
  } catch (C) {
1500
- throw xe(h, d, C), C;
1507
+ throw Fe(h, d, C), C;
1501
1508
  }
1502
- } else g.kind === "event" && (n.push(g.event.payload), await this.router.route(t, [], g.event, s.key[5]));
1509
+ } else g.kind === "event" && (n.push(g.event.payload), await this.router.route(t, [], g.event, c.key[5]));
1503
1510
  }
1504
1511
  );
1505
- await y.handle(d, u, w, h), await w.flush();
1512
+ await y.handle(d, u, v, h), await v.flush();
1506
1513
  }
1507
1514
  return { state: t, emitted: n };
1508
1515
  }
1509
1516
  }
1517
+ class le {
1518
+ process(e, t) {
1519
+ const n = t.getValue();
1520
+ if (B(n)) {
1521
+ const o = t.clone();
1522
+ return o.setValue(n), o.setProperties(void 0), o.setItems(void 0), o.setType(void 0), o;
1523
+ }
1524
+ return e;
1525
+ }
1526
+ /**
1527
+ * Post-process to ensure expressions aren't overridden by subsequent processors
1528
+ */
1529
+ postProcess(e, t) {
1530
+ const n = t.getValue();
1531
+ if (B(n) && e.getValue() !== n && n !== void 0) {
1532
+ const o = e.clone();
1533
+ return o.setValue(n), o;
1534
+ }
1535
+ return e;
1536
+ }
1537
+ }
1538
+ const gt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1539
+ __proto__: null,
1540
+ ExpressionPreserver: le
1541
+ }, Symbol.toStringTag, { value: "Module" }));
1542
+ function Et() {
1543
+ return new k.SequentialMergingProcessor([
1544
+ new k.ValuePropagator(),
1545
+ new le(),
1546
+ new k.TypeAssigner(),
1547
+ new k.ListProcessor(),
1548
+ new k.DictionaryProcessor(),
1549
+ new k.BasicTypesVerifier()
1550
+ ]);
1551
+ }
1510
1552
  export {
1511
- ht as BlueDocumentProcessor,
1512
- Ve as ChannelEventCheckpointProcessor,
1513
- Le as CompositeTimelineChannelProcessor,
1514
- Ue as DocumentUpdateChannelProcessor,
1515
- _e as EmbeddedNodeChannelProcessor,
1516
- ze as InitializedMarkerProcessor,
1517
- He as LifecycleEventChannelProcessor,
1518
- Qe as MyOSAgentChannelProcessor,
1519
- Re as MyOSTimelineChannelProcessor,
1520
- Ke as OperationProcessor,
1521
- Xe as ProcessEmbeddedProcessor,
1522
- nt as SequentialWorkflowOperationProcessor,
1523
- ae as SequentialWorkflowProcessor,
1524
- ot as TimelineChannelProcessor
1553
+ yt as BlueDocumentProcessor,
1554
+ ze as ChannelEventCheckpointProcessor,
1555
+ L as CodeBlockEvaluationError,
1556
+ Re as CompositeTimelineChannelProcessor,
1557
+ He as DocumentUpdateChannelProcessor,
1558
+ ae as EmbeddedDocumentModificationError,
1559
+ Qe as EmbeddedNodeChannelProcessor,
1560
+ F as ExpressionEvaluationError,
1561
+ Ke as InitializedMarkerProcessor,
1562
+ Xe as LifecycleEventChannelProcessor,
1563
+ gt as MergingProcessors,
1564
+ Ze as MyOSAgentChannelProcessor,
1565
+ Ye as MyOSTimelineChannelProcessor,
1566
+ Ge as OperationProcessor,
1567
+ re as PatchApplicationError,
1568
+ et as ProcessEmbeddedProcessor,
1569
+ ct as SequentialWorkflowOperationProcessor,
1570
+ ie as SequentialWorkflowProcessor,
1571
+ it as TimelineChannelProcessor,
1572
+ Et as createDefaultMergingProcessor
1525
1573
  };