@blue-labs/document-processor 1.35.1 → 1.37.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,23 +1,20 @@
1
- var me = Object.defineProperty;
2
- var ge = (a, e, t) => e in a ? me(a, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[e] = t;
3
- var l = (a, e, t) => ge(a, typeof e != "symbol" ? e + "" : e, t);
4
- import { ProcessEmbeddedSchema as W, ChannelEventCheckpointSchema as ye, blueIds as y, InitializedMarkerSchema as Ee, CompositeTimelineChannelSchema as we, DocumentUpdateChannelSchema as ve, EmbeddedNodeChannelSchema as F, LifecycleEventSchema as Te, TimelineEntrySchema as O, OperationSchema as be, OperationRequestSchema as Pe, UpdateDocumentSchema as j, TriggerEventSchema as x, JavaScriptCodeSchema as V, SequentialWorkflowSchema as Se, SequentialWorkflowOperationSchema as Ce, TimelineChannelSchema as Ne } from "@blue-repository/core-dev";
5
- import { applyBlueNodePatch as te, BlueNode as ke, isBigNumber as J, BlueNodeTypeSchema as P, ResolvedBlueNode as Ie, MergingProcessors as k } from "@blue-labs/language";
6
- import { deepFreeze as Be, isNonNullable as M, deepContains as Oe, isNullable as _ } from "@blue-labs/shared-utils";
7
- import { blueIds as ne, MyOSTimelineEntrySchema as oe, MyOSTimelineChannelSchema as Me, MyOSAgentEventSchema as $e, MyOSAgentChannelSchema as qe } from "@blue-repository/myos-dev";
8
- const b = (...a) => a.map((e, t) => {
1
+ import { ProcessEmbeddedSchema as V, ChannelEventCheckpointSchema as de, blueIds as f, InitializedMarkerSchema as pe, CompositeTimelineChannelSchema as fe, DocumentUpdateChannelSchema as me, EmbeddedNodeChannelSchema as U, LifecycleEventSchema as ge, TimelineEntrySchema as k, OperationSchema as ye, OperationRequestSchema as Ee, UpdateDocumentSchema as A, TriggerEventSchema as D, JavaScriptCodeSchema as j, SequentialWorkflowSchema as ve, SequentialWorkflowOperationSchema as we, TimelineChannelSchema as Te } from "@blue-repository/core-dev";
2
+ import { applyBlueNodePatch as Y, BlueNode as be, isBigNumber as _, BlueNodeTypeSchema as b, ResolvedBlueNode as Pe, MergingProcessors as C } from "@blue-labs/language";
3
+ import { deepFreeze as Se, isNonNullable as I, deepContains as Ce, isNullable as x } from "@blue-labs/shared-utils";
4
+ import { blueIds as Z, MyOSTimelineEntrySchema as ee, MyOSTimelineChannelSchema as Ne, MyOSAgentEventSchema as ke, MyOSAgentChannelSchema as Ie } from "@blue-repository/myos-dev";
5
+ const T = (...a) => a.map((e, t) => {
9
6
  if (typeof e != "string") return "";
10
7
  if (t === 0 && e === "/") return "/";
11
8
  const n = t > 0 ? e.replace(/^\/+/, "") : e;
12
9
  return t < a.length - 1 ? n.replace(/\/+$/, "") : n;
13
10
  }).filter(Boolean).join("/").replace(/\/{2,}/g, "/");
14
- class re {
11
+ class te {
15
12
  constructor(e, t, n, o) {
16
- l(this, "actions", []);
17
13
  this.getDocument = e, this.taskInfo = t, this.blue = n, this.onFlush = o;
18
14
  }
15
+ actions = [];
19
16
  get(e) {
20
- const t = this.getDocument(), n = b(this.taskInfo.nodePath, e);
17
+ const t = this.getDocument(), n = T(this.taskInfo.nodePath, e);
21
18
  return t.get(n);
22
19
  }
23
20
  addPatch(e) {
@@ -25,7 +22,7 @@ class re {
25
22
  kind: "patch",
26
23
  patch: {
27
24
  ...e,
28
- path: b(this.taskInfo.nodePath, e.path)
25
+ path: T(this.taskInfo.nodePath, e.path)
29
26
  }
30
27
  });
31
28
  }
@@ -41,16 +38,15 @@ class re {
41
38
  this.actions.push({ kind: "event", event: o });
42
39
  }
43
40
  async flush() {
44
- var t;
45
41
  if (!this.actions.length) return [];
46
42
  const e = [...this.actions];
47
- return this.actions.length = 0, await ((t = this.onFlush) == null ? void 0 : t.call(this, e)), e;
43
+ return this.actions.length = 0, await this.onFlush?.(e), e;
48
44
  }
49
45
  getNodePath() {
50
46
  return this.taskInfo.nodePath;
51
47
  }
52
48
  resolvePath(e) {
53
- return b(this.taskInfo.nodePath, e);
49
+ return T(this.taskInfo.nodePath, e);
54
50
  }
55
51
  getTaskInfo() {
56
52
  return this.taskInfo;
@@ -69,82 +65,82 @@ class re {
69
65
  return Promise.resolve(JSON.stringify(this.blue.nodeToJson(t)));
70
66
  }
71
67
  }
72
- class se extends Error {
68
+ class ne extends Error {
73
69
  constructor(e, t) {
74
70
  super(`Cannot apply patch ${JSON.stringify(e)}`), this.patch = e, this.cause = t, this.name = "PatchApplicationError";
75
71
  }
76
72
  }
77
- class ae extends Error {
73
+ class oe extends Error {
78
74
  constructor(e, t, n) {
79
75
  super(
80
76
  `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
77
  ), this.patch = e, this.offendingPath = t, this.contractNodePath = n, this.name = "EmbeddedDocumentModificationError";
82
78
  }
83
79
  }
84
- class Ae extends Error {
80
+ class Be extends Error {
85
81
  constructor(e, t) {
86
82
  super(`Failed to evaluate expression "${e}"`), this.code = e, this.cause = t, this.name = "ExpressionEvaluationError";
87
83
  }
88
84
  }
89
- class De extends Error {
85
+ class Oe extends Error {
90
86
  constructor(e, t) {
91
87
  super(`Failed to evaluate code block "${e}"`), this.code = e, this.cause = t, this.name = "CodeBlockEvaluationError";
92
88
  }
93
89
  }
94
- function I(a) {
95
- return Be(a);
90
+ function N(a) {
91
+ return Se(a);
96
92
  }
97
- function $(a) {
93
+ function B(a) {
98
94
  return a.clone();
99
95
  }
100
- function z(a, e, t = "/", n = []) {
96
+ function W(a, e, t = "/", n = []) {
101
97
  const o = a.getContracts() ?? {};
102
98
  for (const [r, s] of Object.entries(o))
103
- if (e.isTypeOf(s, W)) {
104
- const h = e.nodeToSchemaOutput(
99
+ if (e.isTypeOf(s, V)) {
100
+ const u = e.nodeToSchemaOutput(
105
101
  s,
106
- W
102
+ V
107
103
  ).paths ?? [];
108
- for (const u of h)
104
+ for (const l of u)
109
105
  n.push({
110
- absPath: b(t, u),
111
- contractPath: b(t, `contracts/${r}`)
106
+ absPath: T(t, l),
107
+ contractPath: T(t, `contracts/${r}`)
112
108
  });
113
109
  }
114
110
  for (const [r, s] of Object.entries(a.getProperties() ?? {}))
115
- z(
111
+ W(
116
112
  s,
117
113
  e,
118
- b(t, r),
114
+ T(t, r),
119
115
  n
120
116
  );
121
117
  return n;
122
118
  }
123
- function X(a, e) {
119
+ function z(a, e) {
124
120
  return a === e || a.startsWith(e.endsWith("/") ? e : e + "/");
125
121
  }
126
- function Q(a, e) {
122
+ function H(a, e) {
127
123
  if (!e.length) return a;
128
- let t = $(a);
124
+ let t = B(a);
129
125
  for (const n of e)
130
126
  try {
131
- t = te(t, n, !0);
127
+ t = Y(t, n, !0);
132
128
  } catch (o) {
133
- throw new se(n, o);
129
+ throw new ne(n, o);
134
130
  }
135
- return I(t);
131
+ return N(t);
136
132
  }
137
- function E(a) {
133
+ function y(a) {
138
134
  return a != null;
139
135
  }
140
- function S(a) {
141
- return a instanceof ke;
136
+ function P(a) {
137
+ return a instanceof be;
142
138
  }
143
- class je {
139
+ class Me {
140
+ data;
141
+ length;
142
+ compare;
144
143
  constructor(e = [], t = (n, o) => n < o ? -1 : n > o ? 1 : 0) {
145
- l(this, "data");
146
- l(this, "length");
147
- l(this, "compare");
148
144
  if (this.data = e, this.length = this.data.length, this.compare = t, this.length > 0)
149
145
  for (let n = (this.length >> 1) - 1; n >= 0; n--) this._down(n);
150
146
  }
@@ -179,14 +175,14 @@ class je {
179
175
  t[e] = r;
180
176
  }
181
177
  }
182
- const xe = (a, e, t, n, o, r) => [
178
+ const qe = (a, e, t, n, o, r) => [
183
179
  -a,
184
180
  e,
185
181
  t,
186
182
  n,
187
183
  o,
188
184
  r
189
- ], Ve = (a, e) => {
185
+ ], $e = (a, e) => {
190
186
  for (let t = 0; t < a.key.length; t++) {
191
187
  const n = a.key[t], o = e.key[t];
192
188
  if (n !== o)
@@ -194,13 +190,13 @@ const xe = (a, e, t, n, o, r) => [
194
190
  }
195
191
  return 0;
196
192
  };
197
- class _e {
193
+ class Ae {
194
+ queue;
198
195
  /**
199
196
  * Creates a new task queue with the task key comparator
200
197
  */
201
198
  constructor() {
202
- l(this, "queue");
203
- this.queue = new je([], Ve);
199
+ this.queue = new Me([], $e);
204
200
  }
205
201
  /**
206
202
  * Adds a task to the queue
@@ -225,15 +221,15 @@ class _e {
225
221
  return this.queue.length;
226
222
  }
227
223
  }
228
- class We {
224
+ class De {
225
+ processors = /* @__PURE__ */ new Map();
226
+ typeOrder = /* @__PURE__ */ new Map();
229
227
  /**
230
228
  * Creates a new contract registry
231
229
  *
232
230
  * @param list - Initial list of processors to register
233
231
  */
234
232
  constructor(e = []) {
235
- l(this, "processors", /* @__PURE__ */ new Map());
236
- l(this, "typeOrder", /* @__PURE__ */ new Map());
237
233
  e.forEach((t, n) => this.register(t, n));
238
234
  }
239
235
  /**
@@ -280,9 +276,10 @@ class We {
280
276
  return this.processors.values();
281
277
  }
282
278
  }
283
- const B = class B {
279
+ class q {
280
+ isEnabled;
281
+ static MAX_TRACE_LENGTH = 128;
284
282
  constructor() {
285
- l(this, "isEnabled");
286
283
  this.isEnabled = process.env.TRACE_BLUE_ENABLED !== "false";
287
284
  }
288
285
  /**
@@ -311,7 +308,7 @@ const B = class B {
311
308
  addHop(e, t, n) {
312
309
  if (!this.shouldTrace())
313
310
  return { ...e };
314
- const o = e.trace ?? [], s = [...o.length >= B.MAX_TRACE_LENGTH ? o.slice(o.length - (B.MAX_TRACE_LENGTH - 1)) : o, this.makeHop(t, n)];
311
+ const o = e.trace ?? [], s = [...o.length >= q.MAX_TRACE_LENGTH ? o.slice(o.length - (q.MAX_TRACE_LENGTH - 1)) : o, this.makeHop(t, n)];
315
312
  return {
316
313
  ...e,
317
314
  trace: s
@@ -343,14 +340,12 @@ const B = class B {
343
340
  isTracingEnabled() {
344
341
  return this.isEnabled;
345
342
  }
346
- };
347
- l(B, "MAX_TRACE_LENGTH", 128);
348
- let L = B;
349
- function Je(a) {
343
+ }
344
+ function je(a) {
350
345
  return Object.entries(a.getContracts() ?? {});
351
346
  }
352
- const Le = 64;
353
- class Ue {
347
+ const xe = 64;
348
+ class Ve {
354
349
  /**
355
350
  * Creates a new event router
356
351
  *
@@ -360,9 +355,9 @@ class Ue {
360
355
  * @param getNextEventSeq - Function to get the next event sequence number
361
356
  */
362
357
  constructor(e, t, n, o, r) {
363
- l(this, "traceManager");
364
- this.blue = e, this.registry = t, this.queue = n, this.getNextTaskId = o, this.getNextEventSeq = r, this.traceManager = new L();
358
+ this.blue = e, this.registry = t, this.queue = n, this.getNextTaskId = o, this.getNextEventSeq = r, this.traceManager = new q();
365
359
  }
360
+ traceManager;
366
361
  /**
367
362
  * Routes an event to matching contracts in the document
368
363
  *
@@ -373,19 +368,18 @@ class Ue {
373
368
  * @param inlineDepth - Current adapter recursion depth
374
369
  */
375
370
  async route(e, t, n, o, r = 0) {
376
- var c;
377
371
  if (n.seq === void 0 && (n.seq = this.getNextEventSeq()), t.length === 0) {
378
372
  if (n.dispatchPath) {
379
- const h = n.dispatchPath.split("/").filter(Boolean), u = { ...n };
380
- return delete u.dispatchPath, this.route(e, h, u, o, r);
373
+ const c = n.dispatchPath.split("/").filter(Boolean), u = { ...n };
374
+ return delete u.dispatchPath, this.route(e, c, u, o, r);
381
375
  }
382
376
  if (n.source === "channel" && n.originNodePath && n.originNodePath !== "/") {
383
- const h = ((c = n.originNodePath) == null ? void 0 : c.split("/").filter(Boolean)) ?? [];
384
- return this.route(e, h, n, o, r);
377
+ const c = n.originNodePath?.split("/").filter(Boolean) ?? [];
378
+ return this.route(e, c, n, o, r);
385
379
  }
386
380
  }
387
- const s = b("/", t.join("/")), i = e.get(s);
388
- S(i) && await this.traverseContracts({
381
+ const s = T("/", t.join("/")), i = e.get(s);
382
+ P(i) && await this.traverseContracts({
389
383
  doc: e,
390
384
  node: i,
391
385
  nodePath: s,
@@ -409,28 +403,28 @@ class Ue {
409
403
  inlineDepth: c
410
404
  } = e;
411
405
  if (!this.shouldSkipForChannel(r, o))
412
- for (const [h, u] of Je(n)) {
413
- if (!u.getType()) continue;
414
- const d = this.registry.get(u.getType());
415
- if (!d) {
416
- console.warn(`No processor registered for contract: ${h}`);
406
+ for (const [u, l] of je(n)) {
407
+ if (!l.getType()) continue;
408
+ const h = this.registry.get(l.getType());
409
+ if (!h) {
410
+ console.warn(`No processor registered for contract: ${u}`);
417
411
  continue;
418
412
  }
419
- const p = {
413
+ const g = {
420
414
  nodePath: o,
421
- contractName: h,
422
- contractNode: u,
415
+ contractName: u,
416
+ contractNode: l,
423
417
  event: r
424
- }, f = new re(() => t, p, this.blue);
425
- if (d.supports(r, u, f, h))
426
- switch (d.role) {
418
+ }, p = new te(() => t, g, this.blue);
419
+ if (h.supports(r, l, p, u))
420
+ switch (h.role) {
427
421
  case "adapter":
428
422
  await this.processAdapter({
429
- cp: d,
423
+ cp: h,
430
424
  event: r,
431
- contractNode: u,
432
- ctx: f,
433
- contractName: h,
425
+ contractNode: l,
426
+ ctx: p,
427
+ contractName: u,
434
428
  doc: t,
435
429
  afterTaskId: s,
436
430
  inlineDepth: c
@@ -438,8 +432,8 @@ class Ue {
438
432
  break;
439
433
  case "handler":
440
434
  this.scheduleHandler({
441
- contractNode: u,
442
- contractName: h,
435
+ contractNode: l,
436
+ contractName: u,
443
437
  nodePath: o,
444
438
  event: r,
445
439
  depth: i.length,
@@ -453,7 +447,6 @@ class Ue {
453
447
  * Processes an adapter contract and routes any emitted events
454
448
  */
455
449
  async processAdapter(e) {
456
- var v;
457
450
  const {
458
451
  cp: t,
459
452
  event: n,
@@ -462,24 +455,24 @@ class Ue {
462
455
  contractName: s,
463
456
  doc: i,
464
457
  afterTaskId: c,
465
- inlineDepth: h
458
+ inlineDepth: u
466
459
  } = e;
467
- if (h >= Le)
460
+ if (u >= xe)
468
461
  throw new Error("Adapter recursion limit reached");
469
- const u = this.traceManager.addHop(
462
+ const l = this.traceManager.addHop(
470
463
  n,
471
- ((v = r.getTaskInfo()) == null ? void 0 : v.nodePath) ?? "",
464
+ r.getTaskInfo()?.nodePath ?? "",
472
465
  s
473
466
  );
474
- await t.handle(u, o, r, s);
475
- const d = await r.flush();
476
- if (d.find((w) => w.kind === "patch"))
467
+ await t.handle(l, o, r, s);
468
+ const h = await r.flush();
469
+ if (h.find((E) => E.kind === "patch"))
477
470
  throw new Error(
478
471
  `Contract "${s}" (adapter) attempted to patch the document`
479
472
  );
480
- const f = d.filter((w) => w.kind === "event");
481
- for (const w of f)
482
- await this.route(i, [], w.event, c, h + 1);
473
+ const p = h.filter((E) => E.kind === "event");
474
+ for (const E of p)
475
+ await this.route(i, [], E.event, c, u + 1);
483
476
  }
484
477
  /**
485
478
  * Schedules a handler contract for future execution
@@ -490,31 +483,31 @@ class Ue {
490
483
  console.warn(`Contract node type is not defined for: ${n}`);
491
484
  return;
492
485
  }
493
- const h = this.registry.orderOf(c), u = t.get("/order"), d = J(u) ? u.toNumber() : 0, p = this.getNextTaskId() + i, f = r.seq;
494
- if (f === void 0)
486
+ const u = this.registry.orderOf(c), l = t.get("/order"), h = _(l) ? l.toNumber() : 0, g = this.getNextTaskId() + i, p = r.seq;
487
+ if (p === void 0)
495
488
  throw new Error("Event sequence missing");
496
- const v = xe(
489
+ const E = qe(
497
490
  s,
498
- f,
491
+ p,
492
+ u,
499
493
  h,
500
- d,
501
494
  n,
502
- p
495
+ g
503
496
  );
504
497
  {
505
- const g = `${o}#${n}`, D = r.trace ?? [];
506
- if (r.source !== "external" && D.includes(g))
498
+ const O = `${o}#${n}`, v = r.trace ?? [];
499
+ if (r.source !== "external" && v.includes(O))
507
500
  throw new Error(
508
- `Loop detected: repeated hop ${g} within the same event chain`
501
+ `Loop detected: repeated hop ${O} within the same event chain`
509
502
  );
510
503
  }
511
- const w = this.traceManager.addHop(r, o, n);
504
+ const m = this.traceManager.addHop(r, o, n);
512
505
  this.queue.push({
513
- key: v,
506
+ key: E,
514
507
  nodePath: o,
515
508
  contractName: n,
516
509
  contractNode: t,
517
- event: w
510
+ event: m
518
511
  });
519
512
  }
520
513
  /**
@@ -524,93 +517,88 @@ class Ue {
524
517
  return e.source === "channel" && !!e.originNodePath && e.originNodePath !== t;
525
518
  }
526
519
  }
527
- const ze = (a, e, t) => {
528
- (t instanceof se || t instanceof ae) && console.error(
520
+ const _e = (a, e, t) => {
521
+ (t instanceof ne || t instanceof oe) && console.error(
529
522
  `[Blue] Failed to apply patches for contract "${a}" on event ${JSON.stringify(e)}`,
530
523
  t
531
524
  );
532
525
  };
533
- function G(a, e) {
534
- const t = $(a), n = (o) => {
535
- if (!S(o)) return;
526
+ function F(a, e) {
527
+ const t = B(a), n = (o) => {
528
+ if (!P(o)) return;
536
529
  const r = o.getContracts();
537
- (!(r != null && r.checkpoint) || !P.isTypeOf(
530
+ (!r?.checkpoint || !b.isTypeOf(
538
531
  r.checkpoint,
539
- ye
532
+ de
540
533
  )) && o.addContract(
541
534
  "checkpoint",
542
535
  e.jsonValueToNode({
543
536
  type: {
544
537
  name: "Channel Event Checkpoint",
545
- blueId: y["Channel Event Checkpoint"]
538
+ blueId: f["Channel Event Checkpoint"]
546
539
  },
547
540
  lastEvents: {}
548
541
  })
549
542
  );
550
543
  };
551
544
  n(t);
552
- for (const { absPath: o } of z(t, e)) {
545
+ for (const { absPath: o } of W(t, e)) {
553
546
  const r = t.get(o);
554
- S(r) && n(r);
547
+ P(r) && n(r);
555
548
  }
556
- return I(t);
549
+ return N(t);
557
550
  }
558
551
  function Re(a, e) {
559
- const t = $(a);
560
- return S(t) && (ie(t, e) || t.addContract(
552
+ const t = B(a);
553
+ return P(t) && (re(t, e) || t.addContract(
561
554
  "initialized",
562
555
  e.jsonValueToNode({
563
556
  type: {
564
557
  name: "Initialized Marker",
565
- blueId: y["Initialized Marker"]
558
+ blueId: f["Initialized Marker"]
566
559
  }
567
560
  })
568
- )), I(t);
561
+ )), N(t);
569
562
  }
570
- function ie(a, e) {
563
+ function re(a, e) {
571
564
  const t = a.getContracts();
572
565
  return Object.values(t ?? {}).some(
573
- (n) => e.isTypeOf(n, Ee, {
566
+ (n) => e.isTypeOf(n, pe, {
574
567
  checkSchemaExtensions: !0
575
568
  })
576
569
  );
577
570
  }
578
- class He {
571
+ class We {
579
572
  constructor(e) {
580
- l(this, "contractType", "Channel Event Checkpoint");
581
- l(this, "contractBlueId", y["Channel Event Checkpoint"]);
582
- l(this, "role", "handler");
583
573
  this.cache = e;
584
574
  }
575
+ contractType = "Channel Event Checkpoint";
576
+ contractBlueId = f["Channel Event Checkpoint"];
577
+ role = "handler";
585
578
  supports(e) {
586
- var t, n;
587
- return e.source === "channel" && ((t = e.rootEvent) == null ? void 0 : t.payload) === e.payload && ((n = e.rootEvent) == null ? void 0 : n.source) === "external";
579
+ return e.source === "channel" && e.rootEvent?.payload === e.payload && e.rootEvent?.source === "external";
588
580
  }
589
581
  async getEventBlueId(e, t) {
590
- var o;
591
- const n = (o = e.rootEvent) == null ? void 0 : o.payload;
582
+ const n = e.rootEvent?.payload;
592
583
  if (!n)
593
584
  throw new Error(
594
585
  "Cannot calculate blueId for checkpoint: missing root event payload"
595
586
  );
596
- if (n instanceof Ie) {
597
- const r = n.getMinimalNode();
598
- return await t.getBlue().calculateBlueId(r);
587
+ if (n instanceof Pe) {
588
+ const o = n.getMinimalNode();
589
+ return await t.getBlue().calculateBlueId(o);
599
590
  }
600
591
  return await t.getBlue().calculateBlueId(n);
601
592
  }
602
593
  async handle(e, t, n) {
603
- var s;
604
- if (!e.channelName || !((s = e.rootEvent) != null && s.seq)) return;
594
+ if (!e.channelName || !e.rootEvent?.seq) return;
605
595
  const o = await this.getEventBlueId(e, n), r = n.getNodePath().replace(/\/contracts\/checkpoint$/, "");
606
596
  this.cache.record(r, e, o);
607
597
  }
608
598
  }
609
- const K = (a, e) => a.get(e) !== void 0;
610
- class Fe {
611
- constructor() {
612
- l(this, "firstSeen", /* @__PURE__ */ new Map());
613
- }
599
+ const X = (a, e) => a.get(e) !== void 0;
600
+ class Je {
601
+ firstSeen = /* @__PURE__ */ new Map();
614
602
  record(e, t, n) {
615
603
  const o = e;
616
604
  this.firstSeen.has(o) || this.firstSeen.set(o, { docBase: e, event: t, eventBlueId: n });
@@ -620,13 +608,13 @@ class Fe {
620
608
  const t = [];
621
609
  for (const { docBase: n, event: o, eventBlueId: r } of this.firstSeen.values()) {
622
610
  if (!o.channelName) continue;
623
- const s = b(
611
+ const s = T(
624
612
  n,
625
613
  "contracts/checkpoint/lastEvents",
626
614
  o.channelName
627
615
  ), i = `${s}/blueId`;
628
- K(e, s) ? t.push({
629
- op: K(e, i) ? "replace" : "add",
616
+ X(e, s) ? t.push({
617
+ op: X(e, i) ? "replace" : "add",
630
618
  path: i,
631
619
  val: r
632
620
  }) : t.push({
@@ -641,14 +629,12 @@ class Fe {
641
629
  this.firstSeen.clear();
642
630
  }
643
631
  }
644
- class Xe {
645
- constructor() {
646
- l(this, "contractType", "Composite Timeline Channel");
647
- l(this, "contractBlueId", y["Composite Timeline Channel"]);
648
- l(this, "role", "adapter");
649
- }
632
+ class Le {
633
+ contractType = "Composite Timeline Channel";
634
+ contractBlueId = f["Composite Timeline Channel"];
635
+ role = "adapter";
650
636
  supports(e, t, n) {
651
- const o = n.getBlue().nodeToSchemaOutput(t, we);
637
+ const o = n.getBlue().nodeToSchemaOutput(t, fe);
652
638
  return !o.channels || !e.channelName ? !1 : o.channels.includes(e.channelName);
653
639
  }
654
640
  handle(e, t, n, o) {
@@ -659,10 +645,8 @@ class Xe {
659
645
  });
660
646
  }
661
647
  }
662
- class C {
663
- constructor() {
664
- l(this, "role", "adapter");
665
- }
648
+ class S {
649
+ role = "adapter";
666
650
  /**
667
651
  * Base implementation of supports that checks if the event is not from a channel
668
652
  * Derived classes should call this method first in their supports implementation
@@ -671,151 +655,132 @@ class C {
671
655
  return e.source !== "channel";
672
656
  }
673
657
  }
674
- class Qe extends C {
675
- constructor() {
676
- super(...arguments);
677
- l(this, "contractType", "Document Update Channel");
678
- l(this, "contractBlueId", y["Document Update Channel"]);
679
- }
680
- supports(t, n, o) {
681
- if (!this.baseSupports(t) || t.emissionType !== "update") return !1;
682
- const r = o.getBlue().nodeToSchemaOutput(n, ve), s = t.payload.get("/path");
683
- if (!s) return !1;
684
- const i = r.path;
685
- return M(i) && s === o.resolvePath(i);
686
- }
687
- handle(t, n, o, r) {
688
- o.emitEvent({
689
- payload: t.payload,
690
- channelName: r,
658
+ class Ue extends S {
659
+ contractType = "Document Update Channel";
660
+ contractBlueId = f["Document Update Channel"];
661
+ supports(e, t, n) {
662
+ if (!this.baseSupports(e) || e.emissionType !== "update") return !1;
663
+ const o = n.getBlue().nodeToSchemaOutput(t, me), r = e.payload.get("/path");
664
+ if (!r) return !1;
665
+ const s = o.path;
666
+ return I(s) && r === n.resolvePath(s);
667
+ }
668
+ handle(e, t, n, o) {
669
+ n.emitEvent({
670
+ payload: e.payload,
671
+ channelName: o,
691
672
  source: "channel"
692
673
  });
693
674
  }
694
675
  }
695
- class Ge extends C {
696
- constructor() {
697
- super(...arguments);
698
- l(this, "contractType", "Embedded Node Channel");
699
- l(this, "contractBlueId", y["Embedded Node Channel"]);
700
- }
701
- supports(t, n, o) {
702
- if (!this.baseSupports(t)) return !1;
703
- const r = o.getBlue().nodeToSchemaOutput(n, F);
704
- return E(t.originNodePath) && E(r.path) && t.originNodePath === o.resolvePath(r.path);
705
- }
706
- handle(t, n, o, r) {
707
- const s = o.getBlue().nodeToSchemaOutput(n, F), { originNodePath: i, payload: c } = t;
708
- E(s.path) && i === o.resolvePath(s.path) && o.emitEvent({
709
- payload: c,
710
- channelName: r,
676
+ class ze extends S {
677
+ contractType = "Embedded Node Channel";
678
+ contractBlueId = f["Embedded Node Channel"];
679
+ supports(e, t, n) {
680
+ if (!this.baseSupports(e)) return !1;
681
+ const o = n.getBlue().nodeToSchemaOutput(t, U);
682
+ return y(e.originNodePath) && y(o.path) && e.originNodePath === n.resolvePath(o.path);
683
+ }
684
+ handle(e, t, n, o) {
685
+ const r = n.getBlue().nodeToSchemaOutput(t, U), { originNodePath: s, payload: i } = e;
686
+ y(r.path) && s === n.resolvePath(r.path) && n.emitEvent({
687
+ payload: i,
688
+ channelName: o,
711
689
  source: "channel"
712
690
  });
713
691
  }
714
692
  }
715
- class Ke {
716
- constructor() {
717
- l(this, "contractType", "Initialized Marker");
718
- l(this, "contractBlueId", y["Initialized Marker"]);
719
- l(this, "role", "marker");
720
- }
693
+ class He {
694
+ contractType = "Initialized Marker";
695
+ contractBlueId = f["Initialized Marker"];
696
+ role = "marker";
721
697
  supports() {
722
698
  return !1;
723
699
  }
724
700
  handle() {
725
701
  }
726
702
  }
727
- class Ye extends C {
728
- constructor() {
729
- super(...arguments);
730
- l(this, "contractType", "Lifecycle Event Channel");
731
- l(this, "contractBlueId", y["Lifecycle Event Channel"]);
732
- }
733
- supports(t, n, o) {
734
- return !this.baseSupports(t) || t.emissionType !== "lifecycle" || !this.isLifecycleEvent(t, o) ? !1 : this.isEventPatternMatch(t, n, o);
703
+ class Fe extends S {
704
+ contractType = "Lifecycle Event Channel";
705
+ contractBlueId = f["Lifecycle Event Channel"];
706
+ supports(e, t, n) {
707
+ return !this.baseSupports(e) || e.emissionType !== "lifecycle" || !this.isLifecycleEvent(e, n) ? !1 : this.isEventPatternMatch(e, t, n);
735
708
  }
736
- handle(t, n, o, r) {
737
- o.emitEvent({
738
- payload: t.payload,
739
- channelName: r,
709
+ handle(e, t, n, o) {
710
+ n.emitEvent({
711
+ payload: e.payload,
712
+ channelName: o,
740
713
  source: "channel",
741
- emissionType: t.emissionType
714
+ emissionType: e.emissionType
742
715
  });
743
716
  }
744
717
  /**
745
718
  * Checks if the event is a supported lifecycle event type
746
719
  */
747
- isLifecycleEvent(t, n) {
748
- const o = n.getBlue(), r = t.payload;
749
- return o.isTypeOf(r, Te, {
720
+ isLifecycleEvent(e, t) {
721
+ const n = t.getBlue(), o = e.payload;
722
+ return n.isTypeOf(o, ge, {
750
723
  checkSchemaExtensions: !0
751
724
  });
752
725
  }
753
726
  /**
754
727
  * Checks if the event matches the channel's event pattern (if specified)
755
728
  */
756
- isEventPatternMatch(t, n, o) {
757
- var s;
758
- const r = (s = n.getProperties()) == null ? void 0 : s.event;
759
- if (!r)
729
+ isEventPatternMatch(e, t, n) {
730
+ const o = t.getProperties()?.event;
731
+ if (!o)
760
732
  return !0;
761
733
  try {
762
- const i = o.getBlue(), c = i.resolve(t.payload);
763
- return i.isTypeOfNode(c, r);
764
- } catch (i) {
765
- return console.warn("Error during lifecycle event pattern matching:", i), !1;
734
+ const r = n.getBlue(), s = r.resolve(e.payload);
735
+ return r.isTypeOfNode(s, o);
736
+ } catch (r) {
737
+ return console.warn("Error during lifecycle event pattern matching:", r), !1;
766
738
  }
767
739
  }
768
740
  }
769
- const Y = (a, e) => {
741
+ const Q = (a, e) => {
770
742
  const t = e.getBlue();
771
- return t.isTypeOf(a.payload, O) || t.isTypeOf(a.payload, oe);
743
+ return t.isTypeOf(a.payload, k) || t.isTypeOf(a.payload, ee);
772
744
  };
773
- class Ze extends C {
774
- constructor() {
775
- super(...arguments);
776
- l(this, "contractType", "MyOS Timeline Channel");
777
- l(this, "contractBlueId", ne["MyOS Timeline Channel"]);
778
- }
779
- supports(t, n, o) {
780
- var u;
781
- if (!this.baseSupports(t) || !Y(t, o)) return !1;
782
- const s = o.getBlue().nodeToSchemaOutput(
783
- t.payload,
784
- oe
785
- ), i = o.getBlue().nodeToSchemaOutput(n, Me), c = (u = s.timeline) == null ? void 0 : u.timelineId;
786
- return E(i.timelineId) && E(c) && c === i.timelineId;
787
- }
788
- handle(t, n, o, r) {
789
- Y(t, o) && o.emitEvent({
790
- payload: t.payload,
791
- channelName: r,
745
+ class Xe extends S {
746
+ contractType = "MyOS Timeline Channel";
747
+ contractBlueId = Z["MyOS Timeline Channel"];
748
+ supports(e, t, n) {
749
+ if (!this.baseSupports(e) || !Q(e, n)) return !1;
750
+ const r = n.getBlue().nodeToSchemaOutput(
751
+ e.payload,
752
+ ee
753
+ ), s = n.getBlue().nodeToSchemaOutput(t, Ne), i = r.timeline?.timelineId;
754
+ return y(s.timelineId) && y(i) && i === s.timelineId;
755
+ }
756
+ handle(e, t, n, o) {
757
+ Q(e, n) && n.emitEvent({
758
+ payload: e.payload,
759
+ channelName: o,
792
760
  source: "channel"
793
761
  });
794
762
  }
795
763
  }
796
- class et extends C {
797
- constructor() {
798
- super(...arguments);
799
- l(this, "contractType", "MyOS Agent Channel");
800
- l(this, "contractBlueId", ne["MyOS Agent Channel"]);
801
- }
802
- supports(t, n, o) {
803
- if (!this.baseSupports(t)) return !1;
764
+ class Qe extends S {
765
+ contractType = "MyOS Agent Channel";
766
+ contractBlueId = Z["MyOS Agent Channel"];
767
+ supports(e, t, n) {
768
+ if (!this.baseSupports(e)) return !1;
804
769
  try {
805
- const { myosAgentEvent: r, myosAgentChannel: s } = this.parseEventAndChannel(
770
+ const { myosAgentEvent: o, myosAgentChannel: r } = this.parseEventAndChannel(
771
+ e,
806
772
  t,
807
- n,
808
- o
773
+ n
809
774
  );
810
- return this.isAgentMatch(r, s) && this.isEventPatternMatch(r, s, o);
811
- } catch (r) {
812
- return console.warn("Error in MyOSAgentChannelProcessor.supports:", r), !1;
775
+ return this.isAgentMatch(o, r) && this.isEventPatternMatch(o, r, n);
776
+ } catch (o) {
777
+ return console.warn("Error in MyOSAgentChannelProcessor.supports:", o), !1;
813
778
  }
814
779
  }
815
- handle(t, n, o, r) {
816
- o.emitEvent({
817
- payload: t.payload,
818
- channelName: r,
780
+ handle(e, t, n, o) {
781
+ n.emitEvent({
782
+ payload: e.payload,
783
+ channelName: o,
819
784
  source: "channel"
820
785
  });
821
786
  }
@@ -823,15 +788,15 @@ class et extends C {
823
788
  * Parses and validates the event payload and channel configuration
824
789
  * @throws {Error} If schema validation fails
825
790
  */
826
- parseEventAndChannel(t, n, o) {
827
- const r = o.getBlue(), s = r.nodeToSchemaOutput(
828
- t.payload,
829
- $e
830
- ), i = r.nodeToSchemaOutput(
831
- n,
832
- qe
791
+ parseEventAndChannel(e, t, n) {
792
+ const o = n.getBlue(), r = o.nodeToSchemaOutput(
793
+ e.payload,
794
+ ke
795
+ ), s = o.nodeToSchemaOutput(
796
+ t,
797
+ Ie
833
798
  );
834
- return { myosAgentEvent: s, myosAgentChannel: i };
799
+ return { myosAgentEvent: r, myosAgentChannel: s };
835
800
  }
836
801
  /**
837
802
  * Checks if the agent IDs match between event and channel
@@ -839,10 +804,9 @@ class et extends C {
839
804
  * @param myosAgentChannel - The parsed agent channel configuration
840
805
  * @returns true if both have valid agent IDs and they match
841
806
  */
842
- isAgentMatch(t, n) {
843
- var s;
844
- const o = t.agentId, r = (s = n.agent) == null ? void 0 : s.agentId;
845
- return E(o) && E(r) && o === r;
807
+ isAgentMatch(e, t) {
808
+ const n = e.agentId, o = t.agent?.agentId;
809
+ return y(n) && y(o) && n === o;
846
810
  }
847
811
  /**
848
812
  * Checks if the event pattern matches the channel's event filter
@@ -857,40 +821,38 @@ class et extends C {
857
821
  * - If channel has event pattern but incoming event has no event data → no match
858
822
  * - Otherwise → uses deep containment matching (event must contain all channel pattern fields)
859
823
  */
860
- isEventPatternMatch(t, n, o) {
861
- const r = n.event;
862
- if (!r)
824
+ isEventPatternMatch(e, t, n) {
825
+ const o = t.event;
826
+ if (!o)
863
827
  return !0;
864
- const s = t.event;
865
- if (!s)
828
+ const r = e.event;
829
+ if (!r)
866
830
  return !1;
867
831
  try {
868
- const i = o.getBlue(), c = i.nodeToJson(s), h = i.nodeToJson(r);
869
- return Oe(c, h);
870
- } catch (i) {
871
- return console.warn("Error during event pattern matching:", i), !1;
832
+ const s = n.getBlue(), i = s.nodeToJson(r), c = s.nodeToJson(o);
833
+ return Ce(i, c);
834
+ } catch (s) {
835
+ return console.warn("Error during event pattern matching:", s), !1;
872
836
  }
873
837
  }
874
838
  }
875
- class tt {
876
- constructor() {
877
- l(this, "contractType", "Operation");
878
- l(this, "contractBlueId", y.Operation);
879
- l(this, "role", "adapter");
880
- }
839
+ class Ge {
840
+ contractType = "Operation";
841
+ contractBlueId = f.Operation;
842
+ role = "adapter";
881
843
  supports(e, t, n, o) {
882
- const s = n.getBlue().nodeToSchemaOutput(t, be), i = this.parseEventPayload(e, n), c = this.isOperationNameMatch(
844
+ const s = n.getBlue().nodeToSchemaOutput(t, ye), i = this.parseEventPayload(e, n), c = this.isOperationNameMatch(
883
845
  i,
884
846
  o
885
- ), h = this.isOperationChannelMatch(
847
+ ), u = this.isOperationChannelMatch(
886
848
  e,
887
849
  s
888
- ), u = this.isRequestPatternMatch(
850
+ ), l = this.isRequestPatternMatch(
889
851
  i,
890
852
  s,
891
853
  n
892
854
  );
893
- return c && h && u;
855
+ return c && u && l;
894
856
  }
895
857
  async handle(e, t, n, o) {
896
858
  n.emitEvent({
@@ -901,50 +863,48 @@ class tt {
901
863
  }
902
864
  parseEventPayload(e, t) {
903
865
  const n = t.getBlue();
904
- if (n.isTypeOf(e.payload, O, {
866
+ if (n.isTypeOf(e.payload, k, {
905
867
  checkSchemaExtensions: !0
906
868
  })) {
907
869
  const o = n.nodeToSchemaOutput(
908
870
  e.payload,
909
- O
871
+ k
910
872
  );
911
873
  if (o.message)
912
874
  return n.nodeToSchemaOutput(
913
875
  o.message,
914
- Pe
876
+ Ee
915
877
  );
916
878
  }
917
879
  return null;
918
880
  }
919
881
  isOperationNameMatch(e, t) {
920
- return E(e == null ? void 0 : e.operation) && (e == null ? void 0 : e.operation) === t;
882
+ return y(e?.operation) && e?.operation === t;
921
883
  }
922
884
  isOperationChannelMatch(e, t) {
923
885
  const n = t.channel;
924
- return _(n) ? !0 : e.source === "channel" && e.channelName === n;
886
+ return x(n) ? !0 : e.source === "channel" && e.channelName === n;
925
887
  }
926
888
  isRequestPatternMatch(e, t, n) {
927
889
  const o = t.request;
928
- if (_(o))
890
+ if (x(o))
929
891
  return !0;
930
- const r = n.getBlue(), s = e == null ? void 0 : e.request;
931
- if (_(s))
892
+ const r = n.getBlue(), s = e?.request;
893
+ if (x(s))
932
894
  return !1;
933
895
  const i = r.resolve(s);
934
896
  return r.isTypeOfNode(i, o);
935
897
  }
936
898
  }
937
- class nt {
938
- constructor() {
939
- l(this, "contractType", "Process Embedded");
940
- l(this, "role", "adapter");
941
- l(this, "contractBlueId", y["Process Embedded"]);
942
- }
899
+ class Ke {
900
+ contractType = "Process Embedded";
901
+ role = "adapter";
902
+ contractBlueId = f["Process Embedded"];
943
903
  supports(e) {
944
904
  return e.source !== "channel";
945
905
  }
946
906
  handle(e, t, n) {
947
- const o = n.getBlue().nodeToSchemaOutput(t, W);
907
+ const o = n.getBlue().nodeToSchemaOutput(t, V);
948
908
  for (const r of o.paths ?? [])
949
909
  n.emitEvent({
950
910
  ...e,
@@ -952,18 +912,18 @@ class nt {
952
912
  });
953
913
  }
954
914
  }
955
- const ot = !process.env.SKIP_ISOLATED_VM;
956
- let m = null;
957
- if (ot)
915
+ const Ye = !process.env.SKIP_ISOLATED_VM;
916
+ let d = null;
917
+ if (Ye)
958
918
  try {
959
- m = require("isolated-vm");
919
+ d = require("isolated-vm");
960
920
  } catch {
961
921
  console.warn("isolated-vm not available, using fallback evaluation method");
962
922
  }
963
- function rt(a) {
923
+ function Ze(a) {
964
924
  return /\bimport\s.+\sfrom\s+['"][^'"]+['"]/.test(a) || /\bexport\s+/.test(a);
965
925
  }
966
- class A {
926
+ class $ {
967
927
  static getIvmUnavailableMessage() {
968
928
  const e = typeof process < "u" && process.version ? process.version : "unknown", t = typeof process < "u" && process.platform ? process.platform : "unknown", n = typeof process < "u" && process.arch ? process.arch : "unknown";
969
929
  return [
@@ -985,14 +945,14 @@ class A {
985
945
  `);
986
946
  }
987
947
  static async ensureIvm() {
988
- if (m)
989
- return m;
948
+ if (d)
949
+ return d;
990
950
  try {
991
- typeof require == "function" ? m = require("isolated-vm") : m = (await import("isolated-vm")).default ?? await import("isolated-vm");
951
+ typeof require == "function" ? d = require("isolated-vm") : d = (await import("isolated-vm")).default ?? await import("isolated-vm");
992
952
  } catch (e) {
993
- console.error(e), m = null;
953
+ console.error(e), d = null;
994
954
  }
995
- return m;
955
+ return d;
996
956
  }
997
957
  /**
998
958
  * Main evaluation method - chooses between secure and simple evaluation strategies
@@ -1003,7 +963,7 @@ class A {
1003
963
  bindings: n = {},
1004
964
  options: o = {}
1005
965
  }) {
1006
- if (await this.ensureIvm(), !m)
966
+ if (await this.ensureIvm(), !d)
1007
967
  throw new Error(this.getIvmUnavailableMessage());
1008
968
  return this.evaluateSecure(e, n, t, o);
1009
969
  }
@@ -1011,32 +971,32 @@ class A {
1011
971
  * Secure evaluation using isolated-vm with support for ES modules
1012
972
  */
1013
973
  static async evaluateSecure(e, t, n, o = {}) {
1014
- if (!m) throw new Error(this.getIvmUnavailableMessage());
1015
- const r = new m.Isolate({ memoryLimit: 32 }), s = await r.createContext(), i = s.global;
974
+ if (!d) throw new Error(this.getIvmUnavailableMessage());
975
+ const r = new d.Isolate({ memoryLimit: 32 }), s = await r.createContext(), i = s.global;
1016
976
  try {
1017
977
  await this.setupIsolateEnvironment(i, t);
1018
- const c = /* @__PURE__ */ new Map(), h = this.createModuleResolver(
978
+ const c = /* @__PURE__ */ new Map(), u = this.createModuleResolver(
1019
979
  r,
1020
980
  s,
1021
981
  c,
1022
982
  n
1023
983
  );
1024
- let u;
1025
- return rt(e) ? u = await this.evaluateESModule(
984
+ let l;
985
+ return Ze(e) ? l = await this.evaluateESModule(
1026
986
  r,
1027
987
  s,
1028
988
  e,
1029
989
  o,
1030
- h
1031
- ) : u = await this.evaluateSimpleScript(
990
+ u
991
+ ) : l = await this.evaluateSimpleScript(
1032
992
  r,
1033
993
  s,
1034
994
  e,
1035
995
  t,
1036
996
  o
1037
- ), this.deepClone(u);
997
+ ), this.deepClone(l);
1038
998
  } catch (c) {
1039
- throw o.isCodeBlock ? new De(e, c) : new Ae(e, c);
999
+ throw o.isCodeBlock ? new Oe(e, c) : new Be(e, c);
1040
1000
  } finally {
1041
1001
  s.release(), r.dispose();
1042
1002
  }
@@ -1045,18 +1005,18 @@ class A {
1045
1005
  * Setup the isolated VM environment with necessary host functions and data
1046
1006
  */
1047
1007
  static async setupIsolateEnvironment(e, t) {
1048
- if (!m) throw new Error("isolated-vm not available");
1049
- const n = new m.Callback(
1008
+ if (!d) throw new Error("isolated-vm not available");
1009
+ const n = new d.Callback(
1050
1010
  (...r) => console.log(...r)
1051
- ), o = new m.ExternalCopy({
1011
+ ), o = new d.ExternalCopy({
1052
1012
  log: n
1053
1013
  }).copyInto();
1054
1014
  await e.set("console", o);
1055
1015
  for (const [r, s] of Object.entries(t))
1056
1016
  typeof s == "function" ? await e.set(
1057
1017
  r,
1058
- new m.Callback(s)
1059
- ) : await e.set(r, new m.ExternalCopy(s).copyInto());
1018
+ new d.Callback(s)
1019
+ ) : await e.set(r, new d.ExternalCopy(s).copyInto());
1060
1020
  }
1061
1021
  /**
1062
1022
  * Create module resolver function for handling imports
@@ -1070,11 +1030,11 @@ class A {
1070
1030
  throw new Error(
1071
1031
  `ProcessingContext is missing a loadBlueContent(blueId) implementation (needed for ${r})`
1072
1032
  );
1073
- const c = await i(s), h = await e.compileModule(c);
1074
- return n.set(r, h), await h.instantiate(
1033
+ const c = await i(s), u = await e.compileModule(c);
1034
+ return n.set(r, u), await u.instantiate(
1075
1035
  t,
1076
1036
  this.createModuleResolver(e, t, n, o)
1077
- ), h;
1037
+ ), u;
1078
1038
  }
1079
1039
  if (/^https?:\/\//.test(r)) {
1080
1040
  let s;
@@ -1097,7 +1057,7 @@ class A {
1097
1057
  * Evaluate code as a simple script (no imports/exports)
1098
1058
  */
1099
1059
  static async evaluateSimpleScript(e, t, n, o, r) {
1100
- const s = Object.keys(o).join(", "), i = Object.keys(o).map((u) => u), c = `(async (${s}) => { ${r.isCodeBlock ? n : `return (${n});`} })(${i.join(", ")})`;
1060
+ const s = Object.keys(o).join(", "), i = Object.keys(o).map((l) => l), c = `(async (${s}) => { ${r.isCodeBlock ? n : `return (${n});`} })(${i.join(", ")})`;
1101
1061
  return await (await e.compileScript(c)).run(t, {
1102
1062
  timeout: r.timeout ?? 500,
1103
1063
  promise: !0,
@@ -1111,14 +1071,14 @@ class A {
1111
1071
  static async evaluateESModule(e, t, n, o, r) {
1112
1072
  let s = n;
1113
1073
  if (o.isCodeBlock) {
1114
- const h = /^\s*(import\s.+?;|export\s.+?;)/gm, u = (n.match(h) || []).join(
1074
+ const u = /^\s*(import\s.+?;|export\s.+?;)/gm, l = (n.match(u) || []).join(
1115
1075
  `
1116
1076
  `
1117
- ), d = n.replace(h, "").trim();
1077
+ ), h = n.replace(u, "").trim();
1118
1078
  s = `
1119
- ${u}
1079
+ ${l}
1120
1080
  const run = function() {
1121
- ${d}
1081
+ ${h}
1122
1082
  };
1123
1083
  export default run();
1124
1084
  `;
@@ -1144,43 +1104,43 @@ class A {
1144
1104
  return typeof e > "u" ? e : JSON.parse(JSON.stringify(e));
1145
1105
  }
1146
1106
  }
1147
- class R {
1107
+ class J {
1148
1108
  /**
1149
1109
  * Creates standard bindings for workflow step execution
1150
1110
  */
1151
1111
  static createStandardBindings(e, t, n) {
1152
- const o = e.getBlue(), r = o.nodeToJson(t.payload, "simple"), s = J(r) ? r.toNumber() : r;
1112
+ const o = e.getBlue(), r = o.nodeToJson(t.payload, "simple"), s = _(r) ? r.toNumber() : r;
1153
1113
  return {
1154
1114
  document: (i) => {
1155
1115
  const c = e.get(i);
1156
- return J(c) ? c.toNumber() : S(c) ? o.nodeToJson(c, "original") : c;
1116
+ return _(c) ? c.toNumber() : P(c) ? o.nodeToJson(c, "original") : c;
1157
1117
  },
1158
1118
  event: s,
1159
1119
  steps: n
1160
1120
  };
1161
1121
  }
1162
1122
  }
1163
- const st = /^\$\{([\s\S]*)\}$/, at = /\$\{([\s\S]*?)\}/, T = (a) => typeof a != "string" ? !1 : st.test(a), U = (a) => typeof a != "string" ? !1 : at.test(a), ce = (a) => {
1164
- if (!T(a))
1123
+ const et = /^\$\{([\s\S]*)\}$/, tt = /\$\{([\s\S]*?)\}/, w = (a) => typeof a != "string" ? !1 : et.test(a), R = (a) => typeof a != "string" ? !1 : tt.test(a), se = (a) => {
1124
+ if (!w(a))
1165
1125
  throw new Error(`Invalid expression: ${a}`);
1166
1126
  return a.slice(2, -1);
1167
1127
  };
1168
- class q {
1128
+ class M {
1169
1129
  static createBindings(e, t, n) {
1170
- return R.createStandardBindings(e, t, n);
1130
+ return J.createStandardBindings(e, t, n);
1171
1131
  }
1172
1132
  static async evaluate(e, t, n, o) {
1173
1133
  const { coerceToString: r } = o;
1174
- if (T(e)) {
1175
- const s = ce(e), i = await A.evaluate({
1134
+ if (w(e)) {
1135
+ const s = se(e), i = await $.evaluate({
1176
1136
  code: s,
1177
1137
  ctx: t,
1178
1138
  bindings: n
1179
1139
  });
1180
1140
  return r ? String(i ?? "") : i;
1181
1141
  }
1182
- if (U(e)) {
1183
- const i = `\`${String(e).replace(/`/g, "\\`")}\``, c = await A.evaluate({
1142
+ if (R(e)) {
1143
+ const i = `\`${String(e).replace(/`/g, "\\`")}\``, c = await $.evaluate({
1184
1144
  code: i,
1185
1145
  ctx: t,
1186
1146
  bindings: n
@@ -1190,7 +1150,7 @@ class q {
1190
1150
  return r ? String(e) : e;
1191
1151
  }
1192
1152
  }
1193
- function Z(a, e) {
1153
+ function G(a, e) {
1194
1154
  const { op: t, path: n, val: o, from: r } = a;
1195
1155
  if ((t === "move" || t === "copy") && !r)
1196
1156
  throw new Error(`${t} operation requires 'from' path`);
@@ -1203,67 +1163,65 @@ function Z(a, e) {
1203
1163
  };
1204
1164
  return o !== void 0 && (s.val = o), r !== void 0 && (s.from = r), e.jsonValueToNode(s);
1205
1165
  }
1206
- function it(a) {
1166
+ function nt(a) {
1207
1167
  return a.jsonValueToNode({
1208
1168
  type: "Document Processing Initiated"
1209
1169
  });
1210
1170
  }
1211
- class ct {
1212
- constructor() {
1213
- l(this, "stepType", "Update Document");
1214
- }
1171
+ class ot {
1172
+ stepType = "Update Document";
1215
1173
  supports(e) {
1216
- return P.isTypeOf(e, j);
1174
+ return b.isTypeOf(e, A);
1217
1175
  }
1218
1176
  async execute(e, t, n, o, r) {
1219
1177
  const s = n.getBlue();
1220
- if (!P.isTypeOf(e, j)) return;
1178
+ if (!b.isTypeOf(e, A)) return;
1221
1179
  const i = await this.evaluateChangeset(
1222
1180
  e.get("/changeset"),
1223
1181
  n,
1224
1182
  t,
1225
1183
  r
1226
- ), c = te(e, {
1184
+ ), c = Y(e, {
1227
1185
  op: "replace",
1228
1186
  path: "/changeset",
1229
1187
  val: i
1230
- }), h = n.getBlue().nodeToSchemaOutput(c, j);
1231
- for (const u of h.changeset ?? []) {
1232
- if (!u.path) continue;
1233
- const d = await this.evaluateChangePath(
1234
- u.path,
1188
+ }), u = n.getBlue().nodeToSchemaOutput(c, A);
1189
+ for (const l of u.changeset ?? []) {
1190
+ if (!l.path) continue;
1191
+ const h = await this.evaluateChangePath(
1192
+ l.path,
1235
1193
  n,
1236
1194
  t,
1237
1195
  r
1238
- ), p = u.val;
1239
- if ((u.op === "replace" || u.op === "add") && M(p)) {
1240
- const f = await this.evaluateChangeValue(
1241
- p,
1196
+ ), g = l.val;
1197
+ if ((l.op === "replace" || l.op === "add") && I(g)) {
1198
+ const p = await this.evaluateChangeValue(
1199
+ g,
1242
1200
  n,
1243
1201
  t,
1244
1202
  r
1245
1203
  );
1246
1204
  n.addPatch({
1247
- op: u.op,
1248
- path: d,
1249
- val: f
1205
+ op: l.op,
1206
+ path: h,
1207
+ val: p
1250
1208
  }), n.emitEvent({
1251
- payload: Z(
1209
+ payload: G(
1252
1210
  {
1253
- op: u.op,
1254
- path: n.resolvePath(d),
1255
- val: s.nodeToJson(f, "original")
1211
+ op: l.op,
1212
+ path: n.resolvePath(h),
1213
+ val: s.nodeToJson(p, "original")
1256
1214
  },
1257
1215
  s
1258
1216
  ),
1259
1217
  emissionType: "update"
1260
1218
  });
1261
1219
  }
1262
- u.op === "remove" && (n.addPatch({ op: u.op, path: d }), n.emitEvent({
1263
- payload: Z(
1220
+ l.op === "remove" && (n.addPatch({ op: l.op, path: h }), n.emitEvent({
1221
+ payload: G(
1264
1222
  {
1265
- op: u.op,
1266
- path: n.resolvePath(d),
1223
+ op: l.op,
1224
+ path: n.resolvePath(h),
1267
1225
  val: null
1268
1226
  },
1269
1227
  s
@@ -1274,11 +1232,11 @@ class ct {
1274
1232
  }
1275
1233
  async evaluateChangeset(e, t, n, o) {
1276
1234
  const r = t.getBlue();
1277
- if (T(e)) {
1278
- const s = ce(e), i = await A.evaluate({
1235
+ if (w(e)) {
1236
+ const s = se(e), i = await $.evaluate({
1279
1237
  code: s,
1280
1238
  ctx: t,
1281
- bindings: R.createStandardBindings(
1239
+ bindings: J.createStandardBindings(
1282
1240
  t,
1283
1241
  n,
1284
1242
  o
@@ -1286,31 +1244,31 @@ class ct {
1286
1244
  });
1287
1245
  return r.jsonValueToNode(i ?? null);
1288
1246
  }
1289
- if (S(e))
1247
+ if (P(e))
1290
1248
  return e;
1291
1249
  throw new Error("Invalid changeset: expected a string or document node");
1292
1250
  }
1293
1251
  async evaluateChangeValue(e, t, n, o) {
1294
1252
  const r = e.getValue(), s = t.getBlue();
1295
- if (T(r) || typeof r == "string" && U(r)) {
1296
- const i = q.createBindings(
1253
+ if (w(r) || typeof r == "string" && R(r)) {
1254
+ const i = M.createBindings(
1297
1255
  t,
1298
1256
  n,
1299
1257
  o
1300
- ), c = await q.evaluate(
1258
+ ), c = await M.evaluate(
1301
1259
  String(r),
1302
1260
  t,
1303
1261
  i,
1304
- { coerceToString: !T(r) }
1262
+ { coerceToString: !w(r) }
1305
1263
  );
1306
1264
  return s.jsonValueToNode(c ?? null);
1307
1265
  }
1308
1266
  return e;
1309
1267
  }
1310
1268
  async evaluateChangePath(e, t, n, o) {
1311
- const r = q.createBindings(t, n, o);
1312
- if (T(e) || U(e)) {
1313
- const s = await q.evaluate(e, t, r, {
1269
+ const r = M.createBindings(t, n, o);
1270
+ if (w(e) || R(e)) {
1271
+ const s = await M.evaluate(e, t, r, {
1314
1272
  coerceToString: !0
1315
1273
  });
1316
1274
  return String(s ?? "");
@@ -1318,70 +1276,66 @@ class ct {
1318
1276
  return e;
1319
1277
  }
1320
1278
  }
1321
- class lt {
1322
- constructor() {
1323
- l(this, "stepType", "Trigger Event");
1324
- }
1279
+ class rt {
1280
+ stepType = "Trigger Event";
1325
1281
  supports(e) {
1326
- return P.isTypeOf(e, x);
1282
+ return b.isTypeOf(e, D);
1327
1283
  }
1328
1284
  async execute(e, t, n) {
1329
1285
  const o = n.getBlue();
1330
- if (!P.isTypeOf(e, x)) return;
1331
- const r = o.nodeToSchemaOutput(e, x);
1286
+ if (!b.isTypeOf(e, D)) return;
1287
+ const r = o.nodeToSchemaOutput(e, D);
1332
1288
  r.event && n.emitEvent({
1333
1289
  payload: r.event,
1334
1290
  emissionType: "triggered"
1335
1291
  });
1336
1292
  }
1337
1293
  }
1338
- class ut {
1339
- constructor() {
1340
- l(this, "stepType", "JavaScript Code");
1341
- }
1294
+ class st {
1295
+ stepType = "JavaScript Code";
1342
1296
  supports(e) {
1343
- return P.isTypeOf(e, V);
1297
+ return b.isTypeOf(e, j);
1344
1298
  }
1345
1299
  async execute(e, t, n, o, r) {
1346
- if (!P.isTypeOf(e, V)) return;
1300
+ if (!b.isTypeOf(e, j)) return;
1347
1301
  const s = n.getBlue(), i = s.nodeToSchemaOutput(
1348
1302
  e,
1349
- V
1303
+ j
1350
1304
  );
1351
1305
  if (!i.code)
1352
1306
  throw new Error("JavaScript code is required");
1353
- const c = await A.evaluate({
1307
+ const c = await $.evaluate({
1354
1308
  code: i.code,
1355
1309
  ctx: n,
1356
- bindings: R.createStandardBindings(n, t, r),
1310
+ bindings: J.createStandardBindings(n, t, r),
1357
1311
  options: {
1358
1312
  isCodeBlock: !0,
1359
1313
  timeout: 500
1360
1314
  }
1361
1315
  });
1362
1316
  if (c && typeof c == "object" && "events" in c) {
1363
- const h = c;
1364
- if (Array.isArray(h.events))
1365
- for (const u of h.events)
1317
+ const u = c;
1318
+ if (Array.isArray(u.events))
1319
+ for (const l of u.events)
1366
1320
  n.emitEvent({
1367
- payload: s.jsonValueToNode(u),
1321
+ payload: s.jsonValueToNode(l),
1368
1322
  emissionType: "triggered"
1369
1323
  });
1370
1324
  }
1371
1325
  return c;
1372
1326
  }
1373
1327
  }
1374
- const ht = [
1375
- new ct(),
1376
- new lt(),
1377
- new ut()
1328
+ const at = [
1329
+ new ot(),
1330
+ new rt(),
1331
+ new st()
1378
1332
  ];
1379
- class le {
1380
- constructor(e = ht) {
1381
- l(this, "contractType", "Sequential Workflow");
1382
- l(this, "contractBlueId", y["Sequential Workflow"]);
1383
- l(this, "role", "handler");
1384
- l(this, "executors", []);
1333
+ class ae {
1334
+ contractType = "Sequential Workflow";
1335
+ contractBlueId = f["Sequential Workflow"];
1336
+ role = "handler";
1337
+ executors = [];
1338
+ constructor(e = at) {
1385
1339
  this.executors = e;
1386
1340
  }
1387
1341
  /** allow registering custom step executors */
@@ -1391,65 +1345,63 @@ class le {
1391
1345
  supports(e, t, n) {
1392
1346
  const r = n.getBlue().nodeToSchemaOutput(
1393
1347
  t,
1394
- Se
1348
+ ve
1395
1349
  ), s = this.isChannelNameMatch(e, r), i = this.isEventPatternMatch(e, t, n);
1396
1350
  return s && i;
1397
1351
  }
1398
1352
  async handle(e, t, n, o) {
1399
- var i;
1400
- const r = {}, s = (i = t.getProperties()) == null ? void 0 : i.steps.getItems();
1401
- for (const [c, h] of (s ?? []).entries()) {
1402
- const u = this.executors.find((p) => p.supports(h));
1353
+ const r = {}, s = t.getProperties()?.steps.getItems();
1354
+ for (const [i, c] of (s ?? []).entries()) {
1355
+ const u = this.executors.find((h) => h.supports(c));
1403
1356
  if (!u)
1404
- throw new Error(`Unsupported workflow step type "${h.getType()}"`);
1405
- const d = await u.execute(
1406
- h,
1357
+ throw new Error(`Unsupported workflow step type "${c.getType()}"`);
1358
+ const l = await u.execute(
1359
+ c,
1407
1360
  e,
1408
1361
  n,
1409
1362
  o,
1410
1363
  r
1411
1364
  );
1412
- if (d !== void 0) {
1413
- const p = h.getName(), f = typeof p == "string" ? p : `Step${c + 1}`;
1414
- r[f] = d;
1365
+ if (l !== void 0) {
1366
+ const h = c.getName(), g = typeof h == "string" ? h : `Step${i + 1}`;
1367
+ r[g] = l;
1415
1368
  }
1416
1369
  await n.flush();
1417
1370
  }
1418
1371
  }
1419
1372
  isChannelNameMatch(e, t) {
1420
1373
  const n = t.channel;
1421
- return M(n) && e.source === "channel" && e.channelName === n;
1374
+ return I(n) && e.source === "channel" && e.channelName === n;
1422
1375
  }
1423
1376
  /**
1424
1377
  * Checks if the event matches the channel's event pattern (if specified)
1425
1378
  */
1426
1379
  isEventPatternMatch(e, t, n) {
1427
- var r;
1428
- const o = (r = t.getProperties()) == null ? void 0 : r.event;
1380
+ const o = t.getProperties()?.event;
1429
1381
  if (!o)
1430
1382
  return !0;
1431
1383
  try {
1432
- const s = n.getBlue(), i = s.resolve(e.payload);
1433
- return s.isTypeOfNode(i, o);
1434
- } catch (s) {
1435
- return console.warn("Error during event pattern matching:", s), !1;
1384
+ const r = n.getBlue(), s = r.resolve(e.payload);
1385
+ return r.isTypeOfNode(s, o);
1386
+ } catch (r) {
1387
+ return console.warn("Error during event pattern matching:", r), !1;
1436
1388
  }
1437
1389
  }
1438
1390
  }
1439
- class dt {
1391
+ class it {
1392
+ contractType = "Sequential Workflow Operation";
1393
+ contractBlueId = f["Sequential Workflow Operation"];
1394
+ role = "handler";
1395
+ sequentialWorkflowProcessor;
1440
1396
  constructor(e) {
1441
- l(this, "contractType", "Sequential Workflow Operation");
1442
- l(this, "contractBlueId", y["Sequential Workflow Operation"]);
1443
- l(this, "role", "handler");
1444
- l(this, "sequentialWorkflowProcessor");
1445
- this.sequentialWorkflowProcessor = e || new le();
1397
+ this.sequentialWorkflowProcessor = e || new ae();
1446
1398
  }
1447
1399
  supports(e, t, n) {
1448
1400
  const s = n.getBlue().nodeToSchemaOutput(
1449
1401
  t,
1450
- Ce
1402
+ we
1451
1403
  ).operation, i = e.channelName;
1452
- return e.source === "channel" && M(i) && M(s) && i === s;
1404
+ return e.source === "channel" && I(i) && I(s) && i === s;
1453
1405
  }
1454
1406
  async handle(e, t, n, o) {
1455
1407
  try {
@@ -1462,89 +1414,82 @@ class dt {
1462
1414
  }
1463
1415
  }
1464
1416
  }
1465
- const ee = (a) => P.isTypeOf(a.payload, O);
1466
- class pt extends C {
1467
- constructor() {
1468
- super(...arguments);
1469
- l(this, "contractType", "Timeline Channel");
1470
- l(this, "contractBlueId", y["Timeline Channel"]);
1471
- }
1472
- supports(t, n, o) {
1473
- var u;
1474
- if (!this.baseSupports(t) || !ee(t)) return !1;
1475
- const s = o.getBlue().nodeToSchemaOutput(
1476
- t.payload,
1477
- O
1478
- ), i = o.getBlue().nodeToSchemaOutput(n, Ne), c = (u = s.timeline) == null ? void 0 : u.timelineId;
1479
- return E(i.timelineId) && E(c) && c === i.timelineId;
1480
- }
1481
- handle(t, n, o, r) {
1482
- ee(t) && o.emitEvent({
1483
- payload: t.payload,
1484
- channelName: r,
1417
+ const K = (a) => b.isTypeOf(a.payload, k);
1418
+ class ct extends S {
1419
+ contractType = "Timeline Channel";
1420
+ contractBlueId = f["Timeline Channel"];
1421
+ supports(e, t, n) {
1422
+ if (!this.baseSupports(e) || !K(e)) return !1;
1423
+ const r = n.getBlue().nodeToSchemaOutput(
1424
+ e.payload,
1425
+ k
1426
+ ), s = n.getBlue().nodeToSchemaOutput(t, Te), i = r.timeline?.timelineId;
1427
+ return y(s.timelineId) && y(i) && i === s.timelineId;
1428
+ }
1429
+ handle(e, t, n, o) {
1430
+ K(e) && n.emitEvent({
1431
+ payload: e.payload,
1432
+ channelName: o,
1485
1433
  source: "channel"
1486
1434
  });
1487
1435
  }
1488
1436
  }
1489
- class ft extends C {
1490
- constructor() {
1491
- super(...arguments);
1492
- l(this, "contractType", "Triggered Event Channel");
1493
- l(this, "contractBlueId", y["Triggered Event Channel"]);
1494
- }
1495
- supports(t) {
1496
- return this.baseSupports(t) ? t.emissionType === "triggered" : !1;
1437
+ class lt extends S {
1438
+ contractType = "Triggered Event Channel";
1439
+ contractBlueId = f["Triggered Event Channel"];
1440
+ supports(e) {
1441
+ return this.baseSupports(e) ? e.emissionType === "triggered" : !1;
1497
1442
  }
1498
- handle(t, n, o, r) {
1499
- o.emitEvent({
1500
- payload: t.payload,
1501
- channelName: r,
1443
+ handle(e, t, n, o) {
1444
+ n.emitEvent({
1445
+ payload: e.payload,
1446
+ channelName: o,
1502
1447
  source: "channel"
1503
1448
  });
1504
1449
  }
1505
1450
  }
1506
- const mt = [
1507
- new nt(),
1451
+ const ut = [
1452
+ new Ke(),
1508
1453
  // channels
1509
- new Ge(),
1510
- new Qe(),
1511
- new pt(),
1512
- new Ze(),
1513
- new et(),
1454
+ new ze(),
1455
+ new Ue(),
1456
+ new ct(),
1514
1457
  new Xe(),
1515
- new Ye(),
1516
- new ft(),
1517
- new tt(),
1458
+ new Qe(),
1459
+ new Le(),
1460
+ new Fe(),
1461
+ new lt(),
1462
+ new Ge(),
1518
1463
  // sequential workflows
1519
- new le(),
1520
- new dt(),
1464
+ new ae(),
1465
+ new it(),
1521
1466
  // markers
1522
- new Ke()
1467
+ new He()
1523
1468
  ];
1524
- class bt {
1469
+ class gt {
1525
1470
  /**
1526
1471
  * Creates a new document processor
1527
1472
  *
1528
1473
  * @param processors - Initial list of processors to register
1529
1474
  */
1530
- constructor(e, t = mt) {
1531
- l(this, "taskCounter", 0);
1532
- l(this, "eventCounter", 0);
1533
- l(this, "registry");
1534
- l(this, "queue");
1535
- l(this, "router");
1536
- l(this, "checkpointCache", new Fe());
1537
- this.blue = e, this.registry = new We(t), this.queue = new _e(), this.router = new Ue(
1475
+ constructor(e, t = ut) {
1476
+ this.blue = e, this.registry = new De(t), this.queue = new Ae(), this.router = new Ve(
1538
1477
  this.blue,
1539
1478
  this.registry,
1540
1479
  this.queue,
1541
1480
  () => ++this.taskCounter,
1542
1481
  () => ++this.eventCounter
1543
1482
  ), this.register(
1544
- new He(this.checkpointCache),
1483
+ new We(this.checkpointCache),
1545
1484
  9999
1546
1485
  );
1547
1486
  }
1487
+ taskCounter = 0;
1488
+ eventCounter = 0;
1489
+ registry;
1490
+ queue;
1491
+ router;
1492
+ checkpointCache = new Je();
1548
1493
  /**
1549
1494
  * Registers a new contract processor
1550
1495
  *
@@ -1561,15 +1506,15 @@ class bt {
1561
1506
  * @returns Processing result with final state and emitted events
1562
1507
  */
1563
1508
  async initialize(e) {
1564
- let t = G(I(e), this.blue);
1509
+ let t = F(N(e), this.blue);
1565
1510
  const n = {
1566
- payload: it(this.blue),
1511
+ payload: nt(this.blue),
1567
1512
  source: "internal",
1568
1513
  emissionType: "lifecycle"
1569
1514
  }, o = [n.payload];
1570
1515
  await this.router.route(t, [], n, 0);
1571
1516
  const r = await this.drainQueue(t);
1572
- return t = r.state, o.push(...r.emitted), t = Re(t, this.blue), { state: $(t), emitted: o };
1517
+ return t = r.state, o.push(...r.emitted), t = Re(t, this.blue), { state: B(t), emitted: o };
1573
1518
  }
1574
1519
  /**
1575
1520
  * Processes a batch of events against the document
@@ -1579,9 +1524,9 @@ class bt {
1579
1524
  * @returns Processing result with final state and emitted events
1580
1525
  */
1581
1526
  async processEvents(e, t) {
1582
- let n = G(I(e), this.blue);
1527
+ let n = F(N(e), this.blue);
1583
1528
  const o = [];
1584
- if (!ie(n, this.blue))
1529
+ if (!re(n, this.blue))
1585
1530
  throw new Error("Document is not initialized");
1586
1531
  for (const r of t)
1587
1532
  try {
@@ -1590,72 +1535,71 @@ class bt {
1590
1535
  const i = await this.drainQueue(n);
1591
1536
  n = i.state, o.push(...i.emitted);
1592
1537
  const c = this.checkpointCache.flush(n);
1593
- c.length && (n = Q(n, c));
1538
+ c.length && (n = H(n, c));
1594
1539
  } finally {
1595
1540
  this.checkpointCache.clear();
1596
1541
  }
1597
- return { state: $(n), emitted: o };
1542
+ return { state: B(n), emitted: o };
1598
1543
  }
1599
1544
  /**
1600
1545
  * Drains the task queue and applies all actions
1601
1546
  */
1602
1547
  async drainQueue(e) {
1603
- var s;
1604
1548
  let t = e;
1605
1549
  const n = [], o = 1e4;
1606
1550
  let r = 0;
1607
1551
  for (; this.queue.length; ) {
1608
1552
  if (++r > o)
1609
1553
  throw new Error("Possible cycle – too many iterations");
1610
- const i = this.queue.pop(), { nodePath: c, contractName: h, contractNode: u, event: d } = i, p = t.get(c);
1611
- if (!S(p) || !((s = p.getContracts()) != null && s[h]) || !u.getType()) continue;
1612
- const f = this.registry.get(u.getType());
1613
- if (!f) {
1614
- console.warn(`No processor registered for contract: ${h}`);
1554
+ const s = this.queue.pop(), { nodePath: i, contractName: c, contractNode: u, event: l } = s, h = t.get(i);
1555
+ if (!P(h) || !h.getContracts()?.[c] || !u.getType()) continue;
1556
+ const g = this.registry.get(u.getType());
1557
+ if (!g) {
1558
+ console.warn(`No processor registered for contract: ${c}`);
1615
1559
  continue;
1616
1560
  }
1617
- const v = new re(
1561
+ const p = new te(
1618
1562
  () => t,
1619
- i,
1563
+ s,
1620
1564
  this.blue,
1621
- async (w) => {
1622
- for (const g of w)
1623
- if (g.kind === "patch") {
1624
- const D = z(
1565
+ async (E) => {
1566
+ for (const m of E)
1567
+ if (m.kind === "patch") {
1568
+ const O = W(
1625
1569
  t,
1626
1570
  this.blue
1627
1571
  );
1628
- for (const N of D) {
1629
- const he = g.patch.op === "move" || g.patch.op === "copy" ? [g.patch.from, g.patch.path] : [g.patch.path], H = v.getNodePath(), de = he.some(
1630
- (fe) => X(fe, N.absPath)
1631
- ), pe = X(
1632
- H,
1633
- N.absPath
1572
+ for (const v of O) {
1573
+ const ce = m.patch.op === "move" || m.patch.op === "copy" ? [m.patch.from, m.patch.path] : [m.patch.path], L = p.getNodePath(), le = ce.some(
1574
+ (he) => z(he, v.absPath)
1575
+ ), ue = z(
1576
+ L,
1577
+ v.absPath
1634
1578
  );
1635
- if (de && !pe)
1636
- throw new ae(
1637
- g.patch,
1638
- N.absPath,
1639
- H
1579
+ if (le && !ue)
1580
+ throw new oe(
1581
+ m.patch,
1582
+ v.absPath,
1583
+ L
1640
1584
  );
1641
1585
  }
1642
1586
  try {
1643
- t = Q(t, [g.patch]);
1644
- } catch (N) {
1645
- throw ze(h, d, N), N;
1587
+ t = H(t, [m.patch]);
1588
+ } catch (v) {
1589
+ throw _e(c, l, v), v;
1646
1590
  }
1647
- } else g.kind === "event" && (n.push(g.event.payload), await this.router.route(t, [], g.event, i.key[5]));
1591
+ } else m.kind === "event" && (n.push(m.event.payload), await this.router.route(t, [], m.event, s.key[5]));
1648
1592
  }
1649
1593
  );
1650
- await f.handle(d, u, v, h), await v.flush();
1594
+ await g.handle(l, u, p, c), await p.flush();
1651
1595
  }
1652
1596
  return { state: t, emitted: n };
1653
1597
  }
1654
1598
  }
1655
- class ue {
1599
+ class ie {
1656
1600
  process(e, t) {
1657
1601
  const n = t.getValue();
1658
- if (T(n)) {
1602
+ if (w(n)) {
1659
1603
  const o = t.clone();
1660
1604
  return o.setValue(n), o.setProperties(void 0), o.setItems(void 0), o.setType(void 0), o;
1661
1605
  }
@@ -1666,48 +1610,48 @@ class ue {
1666
1610
  */
1667
1611
  postProcess(e, t) {
1668
1612
  const n = t.getValue();
1669
- if (T(n) && e.getValue() !== n && n !== void 0) {
1613
+ if (w(n) && e.getValue() !== n && n !== void 0) {
1670
1614
  const o = e.clone();
1671
1615
  return o.setValue(n), o;
1672
1616
  }
1673
1617
  return e;
1674
1618
  }
1675
1619
  }
1676
- const Pt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1620
+ const yt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1677
1621
  __proto__: null,
1678
- ExpressionPreserver: ue
1622
+ ExpressionPreserver: ie
1679
1623
  }, Symbol.toStringTag, { value: "Module" }));
1680
- function St() {
1681
- return new k.SequentialMergingProcessor([
1682
- new k.ValuePropagator(),
1683
- new ue(),
1684
- new k.TypeAssigner(),
1685
- new k.ListProcessor(),
1686
- new k.DictionaryProcessor(),
1687
- new k.BasicTypesVerifier()
1624
+ function Et() {
1625
+ return new C.SequentialMergingProcessor([
1626
+ new C.ValuePropagator(),
1627
+ new ie(),
1628
+ new C.TypeAssigner(),
1629
+ new C.ListProcessor(),
1630
+ new C.DictionaryProcessor(),
1631
+ new C.BasicTypesVerifier()
1688
1632
  ]);
1689
1633
  }
1690
1634
  export {
1691
- bt as BlueDocumentProcessor,
1692
- He as ChannelEventCheckpointProcessor,
1693
- De as CodeBlockEvaluationError,
1694
- Xe as CompositeTimelineChannelProcessor,
1695
- Qe as DocumentUpdateChannelProcessor,
1696
- ae as EmbeddedDocumentModificationError,
1697
- Ge as EmbeddedNodeChannelProcessor,
1698
- Ae as ExpressionEvaluationError,
1699
- Ke as InitializedMarkerProcessor,
1700
- Ye as LifecycleEventChannelProcessor,
1701
- Pt as MergingProcessors,
1702
- et as MyOSAgentChannelProcessor,
1703
- Ze as MyOSTimelineChannelProcessor,
1704
- tt as OperationProcessor,
1705
- se as PatchApplicationError,
1706
- nt as ProcessEmbeddedProcessor,
1707
- dt as SequentialWorkflowOperationProcessor,
1708
- le as SequentialWorkflowProcessor,
1709
- pt as TimelineChannelProcessor,
1710
- ft as TriggeredEventChannelProcessor,
1711
- z as collectEmbeddedPathSpecs,
1712
- St as createDefaultMergingProcessor
1635
+ gt as BlueDocumentProcessor,
1636
+ We as ChannelEventCheckpointProcessor,
1637
+ Oe as CodeBlockEvaluationError,
1638
+ Le as CompositeTimelineChannelProcessor,
1639
+ Ue as DocumentUpdateChannelProcessor,
1640
+ oe as EmbeddedDocumentModificationError,
1641
+ ze as EmbeddedNodeChannelProcessor,
1642
+ Be as ExpressionEvaluationError,
1643
+ He as InitializedMarkerProcessor,
1644
+ Fe as LifecycleEventChannelProcessor,
1645
+ yt as MergingProcessors,
1646
+ Qe as MyOSAgentChannelProcessor,
1647
+ Xe as MyOSTimelineChannelProcessor,
1648
+ Ge as OperationProcessor,
1649
+ ne as PatchApplicationError,
1650
+ Ke as ProcessEmbeddedProcessor,
1651
+ it as SequentialWorkflowOperationProcessor,
1652
+ ae as SequentialWorkflowProcessor,
1653
+ ct as TimelineChannelProcessor,
1654
+ lt as TriggeredEventChannelProcessor,
1655
+ W as collectEmbeddedPathSpecs,
1656
+ Et as createDefaultMergingProcessor
1713
1657
  };