@blue-labs/document-processor 1.21.0 → 1.22.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.
Files changed (78) hide show
  1. package/dist/index.js +5 -5
  2. package/dist/index.mjs +441 -588
  3. package/dist/processors/ChannelEventCheckpointProcessor.d.ts +1 -1
  4. package/dist/processors/CompositeTimelineChannelProcessor.d.ts +1 -1
  5. package/dist/processors/CompositeTimelineChannelProcessor.d.ts.map +1 -1
  6. package/dist/processors/DocumentUpdateChannelProcessor.d.ts +1 -1
  7. package/dist/processors/DocumentUpdateChannelProcessor.d.ts.map +1 -1
  8. package/dist/processors/EmbeddedNodeChannelProcessor.d.ts +1 -1
  9. package/dist/processors/EmbeddedNodeChannelProcessor.d.ts.map +1 -1
  10. package/dist/processors/MyOSAgentChannelProcessor.d.ts +1 -1
  11. package/dist/processors/MyOSAgentChannelProcessor.d.ts.map +1 -1
  12. package/dist/processors/MyOSTimelineChannelProcessor.d.ts +1 -1
  13. package/dist/processors/MyOSTimelineChannelProcessor.d.ts.map +1 -1
  14. package/dist/processors/OperationProcessor.d.ts +1 -1
  15. package/dist/processors/ProcessEmbeddedProcessor.d.ts +1 -1
  16. package/dist/processors/SequentialWorkflowOperationProcessor.d.ts +1 -1
  17. package/dist/processors/SequentialWorkflowOperationProcessor.d.ts.map +1 -1
  18. package/dist/processors/SequentialWorkflowProcessor/SequentialWorkflowProcessor.d.ts +1 -1
  19. package/dist/processors/SequentialWorkflowProcessor/SequentialWorkflowProcessor.d.ts.map +1 -1
  20. package/dist/processors/SequentialWorkflowProcessor/steps/TriggerEventExecutor.d.ts.map +1 -1
  21. package/dist/processors/TimelineChannelProcessor.d.ts +1 -1
  22. package/dist/processors/TimelineChannelProcessor.d.ts.map +1 -1
  23. package/dist/utils/checkpoint.d.ts.map +1 -1
  24. package/package.json +6 -13
  25. package/dist/repo/core/blue-ids/index.d.ts +0 -21
  26. package/dist/repo/core/blue-ids/index.d.ts.map +0 -1
  27. package/dist/repo/core/index.d.ts +0 -199
  28. package/dist/repo/core/index.d.ts.map +0 -1
  29. package/dist/repo/core/schema/Channel.d.ts +0 -13
  30. package/dist/repo/core/schema/Channel.d.ts.map +0 -1
  31. package/dist/repo/core/schema/CompositeTimelineChannel.d.ts +0 -17
  32. package/dist/repo/core/schema/CompositeTimelineChannel.d.ts.map +0 -1
  33. package/dist/repo/core/schema/DocumentUpdateChannel.d.ts +0 -17
  34. package/dist/repo/core/schema/DocumentUpdateChannel.d.ts.map +0 -1
  35. package/dist/repo/core/schema/EmbeddedNodeChannel.d.ts +0 -17
  36. package/dist/repo/core/schema/EmbeddedNodeChannel.d.ts.map +0 -1
  37. package/dist/repo/core/schema/JavaScriptCode.d.ts +0 -10
  38. package/dist/repo/core/schema/JavaScriptCode.d.ts.map +0 -1
  39. package/dist/repo/core/schema/JsonPatchEntry.d.ts +0 -22
  40. package/dist/repo/core/schema/JsonPatchEntry.d.ts.map +0 -1
  41. package/dist/repo/core/schema/Operation.d.ts +0 -16
  42. package/dist/repo/core/schema/Operation.d.ts.map +0 -1
  43. package/dist/repo/core/schema/OperationRequest.d.ts +0 -29
  44. package/dist/repo/core/schema/OperationRequest.d.ts.map +0 -1
  45. package/dist/repo/core/schema/ProcessEmbedded.d.ts +0 -10
  46. package/dist/repo/core/schema/ProcessEmbedded.d.ts.map +0 -1
  47. package/dist/repo/core/schema/SequentialWorkflow.d.ts +0 -13
  48. package/dist/repo/core/schema/SequentialWorkflow.d.ts.map +0 -1
  49. package/dist/repo/core/schema/SequentialWorkflowOperation.d.ts +0 -15
  50. package/dist/repo/core/schema/SequentialWorkflowOperation.d.ts.map +0 -1
  51. package/dist/repo/core/schema/SequentialWorkflowStep.d.ts +0 -13
  52. package/dist/repo/core/schema/SequentialWorkflowStep.d.ts.map +0 -1
  53. package/dist/repo/core/schema/TimelineChannel.d.ts +0 -17
  54. package/dist/repo/core/schema/TimelineChannel.d.ts.map +0 -1
  55. package/dist/repo/core/schema/TimelineEntry.d.ts +0 -25
  56. package/dist/repo/core/schema/TimelineEntry.d.ts.map +0 -1
  57. package/dist/repo/core/schema/TriggerEvent.d.ts +0 -10
  58. package/dist/repo/core/schema/TriggerEvent.d.ts.map +0 -1
  59. package/dist/repo/core/schema/UpdateDocument.d.ts +0 -40
  60. package/dist/repo/core/schema/UpdateDocument.d.ts.map +0 -1
  61. package/dist/repo/core/schema/index.d.ts +0 -15
  62. package/dist/repo/core/schema/index.d.ts.map +0 -1
  63. package/dist/repo/myos/blue-ids/index.d.ts +0 -8
  64. package/dist/repo/myos/blue-ids/index.d.ts.map +0 -1
  65. package/dist/repo/myos/index.d.ts +0 -101
  66. package/dist/repo/myos/index.d.ts.map +0 -1
  67. package/dist/repo/myos/schema/MyOSAgent.d.ts +0 -10
  68. package/dist/repo/myos/schema/MyOSAgent.d.ts.map +0 -1
  69. package/dist/repo/myos/schema/MyOSAgentChannel.d.ts +0 -30
  70. package/dist/repo/myos/schema/MyOSAgentChannel.d.ts.map +0 -1
  71. package/dist/repo/myos/schema/MyOSAgentEvent.d.ts +0 -19
  72. package/dist/repo/myos/schema/MyOSAgentEvent.d.ts.map +0 -1
  73. package/dist/repo/myos/schema/MyOSTimelineChannel.d.ts +0 -24
  74. package/dist/repo/myos/schema/MyOSTimelineChannel.d.ts.map +0 -1
  75. package/dist/repo/myos/schema/MyOSTimelineEntry.d.ts +0 -32
  76. package/dist/repo/myos/schema/MyOSTimelineEntry.d.ts.map +0 -1
  77. package/dist/repo/myos/schema/index.d.ts +0 -6
  78. package/dist/repo/myos/schema/index.d.ts.map +0 -1
package/dist/index.mjs CHANGED
@@ -1,30 +1,31 @@
1
- var he = Object.defineProperty;
2
- var de = (i, e, t) => e in i ? he(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
3
- var l = (i, e, t) => de(i, typeof e != "symbol" ? e + "" : e, t);
4
- import { z as u } from "zod";
5
- import { withTypeBlueId as m, blueNodeField as k, applyBlueNodePatch as pe, BlueNodeTypeSchema as P, BlueNode as me, isBigNumber as z } from "@blue-labs/language";
6
- import { deepFreeze as X, isNonNullable as D, deepContains as fe } from "@blue-labs/shared-utils";
7
- const ge = (i, e) => ({
1
+ var ae = Object.defineProperty;
2
+ var se = (c, e, t) => e in c ? ae(c, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : c[e] = t;
3
+ var l = (c, e, t) => se(c, typeof e != "symbol" ? e + "" : e, t);
4
+ import { ProcessEmbeddedSchema as I, ChannelEventCheckpointSchema as ce, blueIds as g, CompositeTimelineChannelSchema as ie, DocumentUpdateChannelSchema as le, EmbeddedNodeChannelSchema as A, OperationSchema as ue, TimelineEntrySchema as B, OperationRequestSchema as he, UpdateDocumentSchema as k, TriggerEventSchema as N, JavaScriptCodeSchema as O, SequentialWorkflowSchema as de, SequentialWorkflowOperationSchema as pe, TimelineChannelSchema as me } from "@blue-repository/core-dev";
5
+ import { applyBlueNodePatch as fe, BlueNodeTypeSchema as E, BlueNode as ye, isBigNumber as V } from "@blue-labs/language";
6
+ import { deepFreeze as L, isNonNullable as M, deepContains as ge } from "@blue-labs/shared-utils";
7
+ import { blueIds as H, MyOSTimelineEntrySchema as Ee, MyOSTimelineChannelSchema as we, MyOSAgentEventSchema as ve, MyOSAgentChannelSchema as Te } from "@blue-repository/myos-dev";
8
+ const be = (c, e) => ({
8
9
  on: (t, n) => ({ end: () => n(null) })
9
10
  });
10
- async function ye(i) {
11
+ async function Se(c) {
11
12
  return new Promise((e, t) => {
12
- ge().on("error", t).end();
13
+ be().on("error", t).end();
13
14
  });
14
15
  }
15
- const S = (...i) => i.map((e, t) => {
16
+ const T = (...c) => c.map((e, t) => {
16
17
  if (typeof e != "string") return "";
17
18
  if (t === 0 && e === "/") return "/";
18
19
  const n = t > 0 ? e.replace(/^\/+/, "") : e;
19
- return t < i.length - 1 ? n.replace(/\/+$/, "") : n;
20
+ return t < c.length - 1 ? n.replace(/\/+$/, "") : n;
20
21
  }).filter(Boolean).join("/").replace(/\/{2,}/g, "/");
21
- class Y {
22
+ class Q {
22
23
  constructor(e, t, n, o) {
23
24
  l(this, "actions", []);
24
25
  this.getDocument = e, this.taskInfo = t, this.blue = n, this.onFlush = o;
25
26
  }
26
27
  get(e) {
27
- const t = this.getDocument(), n = S(this.taskInfo.nodePath, e);
28
+ const t = this.getDocument(), n = T(this.taskInfo.nodePath, e);
28
29
  return t.get(n);
29
30
  }
30
31
  addPatch(e) {
@@ -32,7 +33,7 @@ class Y {
32
33
  kind: "patch",
33
34
  patch: {
34
35
  ...e,
35
- path: S(this.taskInfo.nodePath, e.path)
36
+ path: T(this.taskInfo.nodePath, e.path)
36
37
  }
37
38
  });
38
39
  }
@@ -55,7 +56,7 @@ class Y {
55
56
  return this.taskInfo.nodePath;
56
57
  }
57
58
  resolvePath(e) {
58
- return S(this.taskInfo.nodePath, e);
59
+ return T(this.taskInfo.nodePath, e);
59
60
  }
60
61
  getTaskInfo() {
61
62
  return this.taskInfo;
@@ -67,190 +68,76 @@ class Y {
67
68
  loadExternalModule(e) {
68
69
  if (!/^https?:\/\//.test(e))
69
70
  throw new Error("Only http/https URLs are allowed");
70
- return ye();
71
+ return Se();
71
72
  }
72
73
  loadBlueContent(e) {
73
74
  throw new Error("Not implemented");
74
75
  }
75
76
  }
76
- class G extends Error {
77
+ class K extends Error {
77
78
  constructor(e, t) {
78
79
  super(`Cannot apply patch ${JSON.stringify(e)}`), this.patch = e, this.cause = t, this.name = "PatchApplicationError";
79
80
  }
80
81
  }
81
- class ee extends Error {
82
+ class z extends Error {
82
83
  constructor(e, t, n) {
83
84
  super(
84
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}")`
85
86
  ), this.patch = e, this.offendingPath = t, this.contractNodePath = n, this.name = "EmbeddedDocumentModificationError";
86
87
  }
87
88
  }
88
- class W extends Error {
89
+ class x extends Error {
89
90
  constructor(e, t) {
90
91
  super(`Failed to evaluate expression "${e}"`), this.code = e, this.cause = t, this.name = "ExpressionEvaluationError";
91
92
  }
92
93
  }
93
- class Q extends Error {
94
+ class D extends Error {
94
95
  constructor(e, t) {
95
96
  super(`Failed to evaluate code block "${e}"`), this.code = e, this.cause = t, this.name = "CodeBlockEvaluationError";
96
97
  }
97
98
  }
98
- const p = {
99
- Channel: "2RMkKoutP5qxkh3uDxZ7dr6Eo27B7fuxQCS1VAptiCPc",
100
- "Timeline Channel": "RMkKoutP5qxkh3uDxZ7dr6Eo27B7fuxQCS1VAptiCPc2",
101
- "Composite Timeline Channel": "qxkh3uMkKoutP5DxZ7dr6Eo27B7fuxQCS1VAptiCPc2R",
102
- "Sequential Workflow": "h3uDxZ7dr6Eo27B7fuxMkKoutP5qxkQCS1VAptiCPc2R",
103
- "Process Embedded": "DxZ7dr6EoMkKoutP5qxkh3u27B7fuxQCS1VAptiCPc2R",
104
- "Embedded Node Channel": "MkKoutP5qxkh3uDxZ7dr6Eo27B7fuxQCS1VAptiCPc2",
105
- "Document Update Channel": "MkKoutP5qxkh3uDQCS1VAptiCPc2xZ7dr6Eo27B7fux",
106
- "Channel Event Checkpoint": "o27B7fuxMkKoutPh3uDxZ7dr6E5qxkQCS1VAptiCPc2R",
107
- "Update Document": "7fuxMkKoutPh3uDxZ7dr6E5qxkQCS1VAptiCPc2R",
108
- "Trigger Event": "kQCS1VAp7fuxMkKoutPh3uDxZ7dr6E5qxtiCPc2R",
109
- "Json Patch Entry": "EnUQeMiMa2wHFW3JbeSPvdgfpL6qZYCR29m3SfeHsKSY",
110
- "JavaScript Code": "MkKoutPDxZ7dr6Eo5qxkh3u27B7fuxQCS1VAptiCPc2R",
111
- "Timeline Entry": "uDxZ7dr6Eo27B7fMkKoutP5qxkh3uxQCS1VAptiCPc2R",
112
- Operation: "OpKoutP5qxkh3uDxZ7dr6Eo27B7fuxQCS1VAptiCPc2R",
113
- "Sequential Workflow Operation": "SeqOpKoutP5qxkh3uDxZ7dr6Eo27B7fuxQCS1VAptiC",
114
- "Operation Request": "OpReqKoutP5qxkh3uDxZ7dr6Eo27B7fuxQCS1VAptiC"
115
- }, N = m(p.Channel)(
116
- u.object({
117
- name: u.string().optional(),
118
- description: u.string().optional()
119
- })
120
- ), Ee = m(
121
- p["Composite Timeline Channel"]
122
- )(
123
- N.extend({
124
- channels: u.array(u.string()).optional()
125
- })
126
- ), Ce = m(
127
- p["Document Update Channel"]
128
- )(
129
- N.extend({
130
- path: u.string().optional()
131
- })
132
- ), K = m(
133
- p["Embedded Node Channel"]
134
- )(
135
- N.extend({
136
- path: u.string().optional()
137
- })
138
- ), M = m(p["JavaScript Code"])(
139
- u.object({
140
- code: u.string().optional()
141
- })
142
- ), we = m(p.Operation)(
143
- u.object({
144
- request: k().optional(),
145
- description: u.string().optional(),
146
- channel: u.string().optional()
147
- })
148
- ), ve = m(
149
- p["Operation Request"]
150
- )(
151
- u.object({
152
- operation: u.string().optional(),
153
- request: k(),
154
- document: u.object({
155
- blueId: u.string().optional()
156
- }).optional(),
157
- allowNewerVersion: u.boolean().optional()
158
- })
159
- ), $ = m(
160
- p["Process Embedded"]
161
- )(
162
- u.object({
163
- paths: u.array(u.string()).optional()
164
- })
165
- ), j = m(
166
- p["Sequential Workflow"]
167
- )(
168
- u.object({
169
- steps: u.array(k()).optional(),
170
- channel: u.string().optional()
171
- })
172
- ), Se = m(
173
- p["Sequential Workflow Operation"]
174
- )(
175
- j.omit({
176
- channel: !0
177
- }).extend({
178
- operation: u.string().optional()
179
- })
180
- ), te = m(
181
- p["Timeline Channel"]
182
- )(
183
- N.extend({
184
- timelineId: u.string().optional()
185
- })
186
- ), I = m(p["Timeline Entry"])(
187
- u.object({
188
- timelineId: u.string().optional(),
189
- timelinePrev: u.string().optional(),
190
- thread: u.string().optional(),
191
- threadPrev: u.string().optional(),
192
- message: k().optional(),
193
- signature: u.string().optional()
194
- })
195
- ), q = m(p["Trigger Event"])(
196
- u.object({
197
- event: k()
198
- })
199
- ), Pe = m(p["Json Patch Entry"])(
200
- u.object({
201
- name: u.string().optional(),
202
- description: u.string().optional(),
203
- val: k().optional(),
204
- op: u.string().optional(),
205
- path: u.string().optional()
206
- })
207
- ), A = m(p["Update Document"])(
208
- u.object({
209
- changeset: u.array(Pe)
210
- })
211
- );
212
- function V(i, e, t = "/", n = []) {
213
- const o = i.getContracts() ?? {};
214
- for (const [a, r] of Object.entries(o))
215
- if (P.isTypeOf(
216
- r,
217
- $
99
+ function q(c, e, t = "/", n = []) {
100
+ const o = c.getContracts() ?? {};
101
+ for (const [r, a] of Object.entries(o))
102
+ if (E.isTypeOf(
103
+ a,
104
+ I
218
105
  )) {
219
- const h = e.nodeToSchemaOutput(
220
- r,
221
- $
106
+ const u = e.nodeToSchemaOutput(
107
+ a,
108
+ I
222
109
  ).paths ?? [];
223
- for (const d of h)
110
+ for (const h of u)
224
111
  n.push({
225
- absPath: S(t, d),
226
- contractPath: S(t, `contracts/${a}`)
112
+ absPath: T(t, h),
113
+ contractPath: T(t, `contracts/${r}`)
227
114
  });
228
115
  }
229
- for (const [a, r] of Object.entries(i.getProperties() ?? {}))
230
- V(r, e, S(t, a), n);
116
+ for (const [r, a] of Object.entries(c.getProperties() ?? {}))
117
+ q(a, e, T(t, r), n);
231
118
  return n;
232
119
  }
233
- function F(i, e) {
234
- return i === e || i.startsWith(e.endsWith("/") ? e : e + "/");
120
+ function W(c, e) {
121
+ return c === e || c.startsWith(e.endsWith("/") ? e : e + "/");
235
122
  }
236
- function U(i, e) {
237
- if (!e.length) return i;
238
- let t = i.clone();
123
+ function j(c, e) {
124
+ if (!e.length) return c;
125
+ let t = c.clone();
239
126
  for (const n of e)
240
127
  try {
241
- t = pe(t, n, !0);
128
+ t = fe(t, n, !0);
242
129
  } catch (o) {
243
- throw new G(n, o);
130
+ throw new K(n, o);
244
131
  }
245
- return X(t);
132
+ return L(t);
246
133
  }
247
- function y(i) {
248
- return i != null;
134
+ function f(c) {
135
+ return c != null;
249
136
  }
250
- function x(i) {
251
- return i instanceof me;
137
+ function C(c) {
138
+ return c instanceof ye;
252
139
  }
253
- class ke {
140
+ class Pe {
254
141
  constructor(e = [], t = (n, o) => n < o ? -1 : n > o ? 1 : 0) {
255
142
  l(this, "data");
256
143
  l(this, "length");
@@ -272,45 +159,45 @@ class ke {
272
159
  _up(e) {
273
160
  const { data: t, compare: n } = this, o = t[e];
274
161
  for (; e > 0; ) {
275
- const a = e - 1 >> 1, r = t[a];
276
- if (n(o, r) >= 0) break;
277
- t[e] = r, e = a;
162
+ const r = e - 1 >> 1, a = t[r];
163
+ if (n(o, a) >= 0) break;
164
+ t[e] = a, e = r;
278
165
  }
279
166
  t[e] = o;
280
167
  }
281
168
  _down(e) {
282
- const { data: t, compare: n } = this, o = this.length >> 1, a = t[e];
169
+ const { data: t, compare: n } = this, o = this.length >> 1, r = t[e];
283
170
  for (; e < o; ) {
284
- let r = (e << 1) + 1;
285
- const s = r + 1;
286
- if (s < this.length && n(t[s], t[r]) < 0 && (r = s), n(t[r], a) >= 0) break;
287
- t[e] = t[r], e = r;
171
+ let a = (e << 1) + 1;
172
+ const s = a + 1;
173
+ if (s < this.length && n(t[s], t[a]) < 0 && (a = s), n(t[a], r) >= 0) break;
174
+ t[e] = t[a], e = a;
288
175
  }
289
- t[e] = a;
176
+ t[e] = r;
290
177
  }
291
178
  }
292
- const be = (i, e, t, n, o, a) => [
293
- -i,
179
+ const Ce = (c, e, t, n, o, r) => [
180
+ -c,
294
181
  e,
295
182
  t,
296
183
  n,
297
184
  o,
298
- a
299
- ], Te = (i, e) => {
300
- for (let t = 0; t < i.key.length; t++) {
301
- const n = i.key[t], o = e.key[t];
185
+ r
186
+ ], ke = (c, e) => {
187
+ for (let t = 0; t < c.key.length; t++) {
188
+ const n = c.key[t], o = e.key[t];
302
189
  if (n !== o)
303
190
  return typeof n == "number" && typeof o == "number" ? n - o : typeof n == "string" && typeof o == "string" ? n.localeCompare(o) : 0;
304
191
  }
305
192
  return 0;
306
193
  };
307
- class Oe {
194
+ class Ne {
308
195
  /**
309
196
  * Creates a new task queue with the task key comparator
310
197
  */
311
198
  constructor() {
312
199
  l(this, "queue");
313
- this.queue = new ke([], Te);
200
+ this.queue = new Pe([], ke);
314
201
  }
315
202
  /**
316
203
  * Adds a task to the queue
@@ -335,7 +222,7 @@ class Oe {
335
222
  return this.queue.length;
336
223
  }
337
224
  }
338
- class Be {
225
+ class Oe {
339
226
  /**
340
227
  * Creates a new contract registry
341
228
  *
@@ -390,7 +277,7 @@ class Be {
390
277
  return this.processors.values();
391
278
  }
392
279
  }
393
- class xe {
280
+ class Ie {
394
281
  constructor() {
395
282
  l(this, "isEnabled");
396
283
  this.isEnabled = process.env.TRACE_BLUE_ENABLED === "true";
@@ -457,8 +344,8 @@ class xe {
457
344
  return this.isEnabled;
458
345
  }
459
346
  }
460
- const Ne = 64;
461
- class Ie {
347
+ const Be = 64;
348
+ class Me {
462
349
  /**
463
350
  * Creates a new event router
464
351
  *
@@ -467,9 +354,9 @@ class Ie {
467
354
  * @param getNextTaskId - Function to get the next task ID
468
355
  * @param getNextEventSeq - Function to get the next event sequence number
469
356
  */
470
- constructor(e, t, n, o, a) {
357
+ constructor(e, t, n, o, r) {
471
358
  l(this, "traceManager");
472
- this.blue = e, this.registry = t, this.queue = n, this.getNextTaskId = o, this.getNextEventSeq = a, this.traceManager = new xe();
359
+ this.blue = e, this.registry = t, this.queue = n, this.getNextTaskId = o, this.getNextEventSeq = r, this.traceManager = new Ie();
473
360
  }
474
361
  /**
475
362
  * Routes an event to matching contracts in the document
@@ -480,27 +367,27 @@ class Ie {
480
367
  * @param afterTaskId - Minimum task ID to use
481
368
  * @param inlineDepth - Current adapter recursion depth
482
369
  */
483
- async route(e, t, n, o, a = 0) {
484
- var c;
370
+ async route(e, t, n, o, r = 0) {
371
+ var i;
485
372
  if (n.seq === void 0 && (n.seq = this.getNextEventSeq()), t.length === 0) {
486
373
  if (n.dispatchPath) {
487
- const h = n.dispatchPath.split("/").filter(Boolean), d = { ...n };
488
- return delete d.dispatchPath, this.route(e, h, d, o, a);
374
+ const u = n.dispatchPath.split("/").filter(Boolean), h = { ...n };
375
+ return delete h.dispatchPath, this.route(e, u, h, o, r);
489
376
  }
490
377
  if (n.source === "channel" && n.originNodePath && n.originNodePath !== "/") {
491
- const h = ((c = n.originNodePath) == null ? void 0 : c.split("/").filter(Boolean)) ?? [];
492
- return this.route(e, h, n, o, a);
378
+ const u = ((i = n.originNodePath) == null ? void 0 : i.split("/").filter(Boolean)) ?? [];
379
+ return this.route(e, u, n, o, r);
493
380
  }
494
381
  }
495
- const r = S("/", t.join("/")), s = e.get(r);
496
- x(s) && await this.traverseContracts({
382
+ const a = T("/", t.join("/")), s = e.get(a);
383
+ C(s) && await this.traverseContracts({
497
384
  doc: e,
498
385
  node: s,
499
- nodePath: r,
386
+ nodePath: a,
500
387
  event: n,
501
388
  afterTaskId: o,
502
389
  pathSegments: t,
503
- inlineDepth: a
390
+ inlineDepth: r
504
391
  });
505
392
  }
506
393
  /**
@@ -511,49 +398,49 @@ class Ie {
511
398
  doc: t,
512
399
  node: n,
513
400
  nodePath: o,
514
- event: a,
515
- afterTaskId: r,
401
+ event: r,
402
+ afterTaskId: a,
516
403
  pathSegments: s,
517
- inlineDepth: c
404
+ inlineDepth: i
518
405
  } = e;
519
- if (!this.shouldSkipForChannel(a, o))
520
- for (const [h, d] of Object.entries(
406
+ if (!this.shouldSkipForChannel(r, o))
407
+ for (const [u, h] of Object.entries(
521
408
  n.getContracts() ?? {}
522
409
  )) {
523
- if (!d.getType()) continue;
524
- const f = this.registry.get(d.getType());
525
- if (!f) {
526
- console.warn(`No processor registered for contract: ${h}`);
410
+ if (!h.getType()) continue;
411
+ const d = this.registry.get(h.getType());
412
+ if (!d) {
413
+ console.warn(`No processor registered for contract: ${u}`);
527
414
  continue;
528
415
  }
529
- const C = {
416
+ const p = {
530
417
  nodePath: o,
531
- contractName: h,
532
- contractNode: d,
533
- event: a
534
- }, g = new Y(() => t, C, this.blue);
535
- if (f.supports(a, d, g, h))
536
- switch (f.role) {
418
+ contractName: u,
419
+ contractNode: h,
420
+ event: r
421
+ }, m = new Q(() => t, p, this.blue);
422
+ if (d.supports(r, h, m, u))
423
+ switch (d.role) {
537
424
  case "adapter":
538
425
  await this.processAdapter({
539
- cp: f,
540
- event: a,
541
- contractNode: d,
542
- ctx: g,
543
- contractName: h,
426
+ cp: d,
427
+ event: r,
428
+ contractNode: h,
429
+ ctx: m,
430
+ contractName: u,
544
431
  doc: t,
545
- afterTaskId: r,
546
- inlineDepth: c
432
+ afterTaskId: a,
433
+ inlineDepth: i
547
434
  });
548
435
  break;
549
436
  case "handler":
550
437
  this.scheduleHandler({
551
- contractNode: d,
552
- contractName: h,
438
+ contractNode: h,
439
+ contractName: u,
553
440
  nodePath: o,
554
- event: a,
441
+ event: r,
555
442
  depth: s.length,
556
- afterTaskId: r
443
+ afterTaskId: a
557
444
  });
558
445
  break;
559
446
  }
@@ -568,48 +455,48 @@ class Ie {
568
455
  cp: t,
569
456
  event: n,
570
457
  contractNode: o,
571
- ctx: a,
572
- contractName: r,
458
+ ctx: r,
459
+ contractName: a,
573
460
  doc: s,
574
- afterTaskId: c,
575
- inlineDepth: h
461
+ afterTaskId: i,
462
+ inlineDepth: u
576
463
  } = e;
577
- if (h >= Ne)
464
+ if (u >= Be)
578
465
  throw new Error("Adapter recursion limit reached");
579
- const d = this.traceManager.addHop(
466
+ const h = this.traceManager.addHop(
580
467
  n,
581
- ((w = a.getTaskInfo()) == null ? void 0 : w.nodePath) ?? "",
582
- r
468
+ ((w = r.getTaskInfo()) == null ? void 0 : w.nodePath) ?? "",
469
+ a
583
470
  );
584
- await t.handle(d, o, a, r);
585
- const f = await a.flush();
586
- if (f.find((b) => b.kind === "patch"))
471
+ await t.handle(h, o, r, a);
472
+ const d = await r.flush();
473
+ if (d.find((b) => b.kind === "patch"))
587
474
  throw new Error(
588
- `Contract "${r}" (adapter) attempted to patch the document`
475
+ `Contract "${a}" (adapter) attempted to patch the document`
589
476
  );
590
- const g = f.filter((b) => b.kind === "event");
591
- for (const b of g)
592
- await this.route(s, [], b.event, c, h + 1);
477
+ const m = d.filter((b) => b.kind === "event");
478
+ for (const b of m)
479
+ await this.route(s, [], b.event, i, u + 1);
593
480
  }
594
481
  /**
595
482
  * Schedules a handler contract for future execution
596
483
  */
597
484
  scheduleHandler(e) {
598
- const { contractNode: t, contractName: n, nodePath: o, event: a, depth: r, afterTaskId: s } = e, c = t.getType();
599
- if (!c) {
485
+ const { contractNode: t, contractName: n, nodePath: o, event: r, depth: a, afterTaskId: s } = e, i = t.getType();
486
+ if (!i) {
600
487
  console.warn(`Contract node type is not defined for: ${n}`);
601
488
  return;
602
489
  }
603
- const h = this.registry.orderOf(c), d = t.get("/order"), f = z(d) ? d.toNumber() : 0, C = this.getNextTaskId() + s, g = be(
604
- r,
605
- a.seq,
606
- h,
607
- f,
490
+ const u = this.registry.orderOf(i), h = t.get("/order"), d = V(h) ? h.toNumber() : 0, p = this.getNextTaskId() + s, m = Ce(
491
+ a,
492
+ r.seq,
493
+ u,
494
+ d,
608
495
  n,
609
- C
610
- ), w = this.traceManager.addHop(a, o, n);
496
+ p
497
+ ), w = this.traceManager.addHop(r, o, n);
611
498
  this.queue.push({
612
- key: g,
499
+ key: m,
613
500
  nodePath: o,
614
501
  contractName: n,
615
502
  contractNode: t,
@@ -623,39 +510,41 @@ class Ie {
623
510
  return e.source === "channel" && !!e.originNodePath && e.originNodePath !== t;
624
511
  }
625
512
  }
626
- const Me = (i, e, t) => {
627
- (t instanceof G || t instanceof ee) && console.error(
628
- `[Blue] Failed to apply patches for contract "${i}" on event ${JSON.stringify(e)}`,
513
+ const qe = (c, e, t) => {
514
+ (t instanceof K || t instanceof z) && console.error(
515
+ `[Blue] Failed to apply patches for contract "${c}" on event ${JSON.stringify(e)}`,
629
516
  t
630
517
  );
631
518
  };
632
- function J(i, e) {
633
- const t = i.clone(), n = (o) => {
634
- var r;
635
- if (!x(o)) return;
636
- const a = o.getContracts();
637
- a && (!a.checkpoint || ((r = a.checkpoint.getType()) == null ? void 0 : r.getBlueId()) !== p["Channel Event Checkpoint"]) && o.addContract(
519
+ function F(c, e) {
520
+ const t = c.clone(), n = (o) => {
521
+ if (!C(o)) return;
522
+ const r = o.getContracts();
523
+ r && (!r.checkpoint || !E.isTypeOf(
524
+ r.checkpoint,
525
+ ce
526
+ )) && o.addContract(
638
527
  "checkpoint",
639
528
  e.jsonValueToNode({
640
529
  type: {
641
530
  name: "Channel Event Checkpoint",
642
- blueId: p["Channel Event Checkpoint"]
531
+ blueId: g["Channel Event Checkpoint"]
643
532
  },
644
533
  lastEvents: {}
645
534
  })
646
535
  );
647
536
  };
648
537
  n(t);
649
- for (const { absPath: o } of V(t, e)) {
650
- const a = t.get(o);
651
- x(a) && n(a);
538
+ for (const { absPath: o } of q(t, e)) {
539
+ const r = t.get(o);
540
+ C(r) && n(r);
652
541
  }
653
- return X(t);
542
+ return L(t);
654
543
  }
655
- class qe {
544
+ class $e {
656
545
  constructor(e) {
657
546
  l(this, "contractType", "Channel Event Checkpoint");
658
- l(this, "contractBlueId", p["Channel Event Checkpoint"]);
547
+ l(this, "contractBlueId", g["Channel Event Checkpoint"]);
659
548
  l(this, "role", "handler");
660
549
  this.cache = e;
661
550
  }
@@ -664,16 +553,16 @@ class qe {
664
553
  return e.source === "channel" && ((t = e.rootEvent) == null ? void 0 : t.payload) === e.payload && ((n = e.rootEvent) == null ? void 0 : n.source) === "external";
665
554
  }
666
555
  async handle(e, t, n) {
667
- var r;
668
- if (!e.channelName || !((r = e.rootEvent) != null && r.seq)) return;
669
- const o = await n.getBlue().calculateBlueId(e.rootEvent.payload), a = n.getNodePath().replace(/\/contracts\/checkpoint$/, "");
670
- this.cache.record(a, e, o);
556
+ var a;
557
+ if (!e.channelName || !((a = e.rootEvent) != null && a.seq)) return;
558
+ const o = await n.getBlue().calculateBlueId(e.rootEvent.payload), r = n.getNodePath().replace(/\/contracts\/checkpoint$/, "");
559
+ this.cache.record(r, e, o);
671
560
  }
672
561
  init() {
673
562
  return [];
674
563
  }
675
564
  }
676
- const Z = (i, e) => i.get(e) !== void 0;
565
+ const U = (c, e) => c.get(e) !== void 0;
677
566
  class Ae {
678
567
  constructor() {
679
568
  l(this, "firstSeen", /* @__PURE__ */ new Map());
@@ -685,21 +574,21 @@ class Ae {
685
574
  /** Turn cached data into JSON-Patch ops */
686
575
  flush(e) {
687
576
  const t = [];
688
- for (const { docBase: n, event: o, eventBlueId: a } of this.firstSeen.values()) {
577
+ for (const { docBase: n, event: o, eventBlueId: r } of this.firstSeen.values()) {
689
578
  if (!o.channelName) continue;
690
- const r = S(
579
+ const a = T(
691
580
  n,
692
581
  "contracts/checkpoint/lastEvents",
693
582
  o.channelName
694
- ), s = `${r}/blueId`;
695
- Z(e, r) ? t.push({
696
- op: Z(e, s) ? "replace" : "add",
583
+ ), s = `${a}/blueId`;
584
+ U(e, a) ? t.push({
585
+ op: U(e, s) ? "replace" : "add",
697
586
  path: s,
698
- val: a
587
+ val: r
699
588
  }) : t.push({
700
589
  op: "add",
701
- path: r,
702
- val: { blueId: a }
590
+ path: a,
591
+ val: { blueId: r }
703
592
  });
704
593
  }
705
594
  return t;
@@ -708,7 +597,7 @@ class Ae {
708
597
  this.firstSeen.clear();
709
598
  }
710
599
  }
711
- class B {
600
+ class P {
712
601
  constructor() {
713
602
  l(this, "role", "adapter");
714
603
  }
@@ -727,150 +616,113 @@ class B {
727
616
  return [];
728
617
  }
729
618
  }
730
- class De extends B {
619
+ class xe extends P {
731
620
  constructor() {
732
621
  super(...arguments);
733
622
  l(this, "contractType", "Composite Timeline Channel");
734
- l(this, "contractBlueId", p["Composite Timeline Channel"]);
623
+ l(this, "contractBlueId", g["Composite Timeline Channel"]);
735
624
  }
736
625
  supports(t, n, o) {
737
- const a = o.getBlue().nodeToSchemaOutput(n, Ee);
738
- return !a.channels || !t.channelName ? !1 : a.channels.includes(t.channelName);
626
+ const r = o.getBlue().nodeToSchemaOutput(n, ie);
627
+ return !r.channels || !t.channelName ? !1 : r.channels.includes(t.channelName);
739
628
  }
740
- handle(t, n, o, a) {
629
+ handle(t, n, o, r) {
741
630
  o.emitEvent({
742
631
  payload: t.payload,
743
- channelName: a,
632
+ channelName: r,
744
633
  source: "channel"
745
634
  });
746
635
  }
747
636
  }
748
- class $e extends B {
637
+ class De extends P {
749
638
  constructor() {
750
639
  super(...arguments);
751
640
  l(this, "contractType", "Document Update Channel");
752
- l(this, "contractBlueId", p["Document Update Channel"]);
641
+ l(this, "contractBlueId", g["Document Update Channel"]);
753
642
  }
754
- supports(t, n, o, a) {
643
+ supports(t, n, o, r) {
755
644
  if (!this.baseSupports(t)) return !1;
756
- const r = o.getBlue().nodeToSchemaOutput(n, Ce), s = t.payload.path;
757
- if (!s || t.channelName === a) return !1;
758
- const c = r.path;
759
- return D(c) && s === o.resolvePath(c);
760
- }
761
- handle(t, n, o, a) {
762
- const r = t.payload;
763
- r && o.emitEvent({
764
- payload: r,
765
- channelName: a,
645
+ const a = o.getBlue().nodeToSchemaOutput(n, le), s = t.payload.path;
646
+ if (!s || t.channelName === r) return !1;
647
+ const i = a.path;
648
+ return M(i) && s === o.resolvePath(i);
649
+ }
650
+ handle(t, n, o, r) {
651
+ const a = t.payload;
652
+ a && o.emitEvent({
653
+ payload: a,
654
+ channelName: r,
766
655
  source: "channel"
767
656
  });
768
657
  }
769
658
  }
770
- class je extends B {
659
+ class We extends P {
771
660
  constructor() {
772
661
  super(...arguments);
773
662
  l(this, "contractType", "Embedded Node Channel");
774
- l(this, "contractBlueId", p["Embedded Node Channel"]);
663
+ l(this, "contractBlueId", g["Embedded Node Channel"]);
775
664
  }
776
665
  supports(t, n, o) {
777
666
  if (!this.baseSupports(t)) return !1;
778
- const a = o.getBlue().nodeToSchemaOutput(n, K);
779
- return y(t.originNodePath) && y(a.path) && t.originNodePath === o.resolvePath(a.path);
780
- }
781
- handle(t, n, o, a) {
782
- const r = o.getBlue().nodeToSchemaOutput(n, K), { originNodePath: s, payload: c } = t;
783
- y(r.path) && s === o.resolvePath(r.path) && o.emitEvent({
784
- payload: c,
785
- channelName: a,
667
+ const r = o.getBlue().nodeToSchemaOutput(n, A);
668
+ return f(t.originNodePath) && f(r.path) && t.originNodePath === o.resolvePath(r.path);
669
+ }
670
+ handle(t, n, o, r) {
671
+ const a = o.getBlue().nodeToSchemaOutput(n, A), { originNodePath: s, payload: i } = t;
672
+ f(a.path) && s === o.resolvePath(a.path) && o.emitEvent({
673
+ payload: i,
674
+ channelName: r,
786
675
  source: "channel"
787
676
  });
788
677
  }
789
678
  }
790
- const T = {
791
- "MyOS Timeline Channel": "MkKoutP5qxkh3uDxZ7dr6Eo27B7fuxQCS1VAptiCPc2R",
792
- "MyOS Timeline Entry": "uDxZ7dr6Eo2MkKoutP5qxkh3uxQCS1VAptiCPc2R7B7f",
793
- "MyOS Agent": "AgentBlu3Id7dr6Eo2MkKoutP5qxkh3uxQCS1V",
794
- "MyOS Agent Channel": "AgentCh4nn3lBlu3Id7dr6Eo2MkKoutP5qxkh3uxQCS1V",
795
- "MyOS Agent Event": "AgentEv3ntBlu3Id7dr6Eo2MkKoutP5qxkh3uxQCS1V"
796
- }, Ve = m(
797
- T["MyOS Timeline Channel"]
798
- )(
799
- te.extend({
800
- account: u.string().optional(),
801
- email: u.string().optional()
802
- })
803
- ), Re = m(
804
- T["MyOS Timeline Entry"]
805
- )(
806
- I.extend({
807
- account: u.string().optional(),
808
- email: u.string().optional()
809
- })
810
- ), We = m(T["MyOS Agent"])(
811
- u.object({
812
- agentId: u.string().optional()
813
- })
814
- ), Qe = m(
815
- T["MyOS Agent Channel"]
816
- )(
817
- N.extend({
818
- agent: We.optional(),
819
- event: k().optional()
820
- })
821
- ), Ke = m(T["MyOS Agent Event"])(
822
- u.object({
823
- agentId: u.string().optional(),
824
- id: u.number().optional(),
825
- timestamp: u.number().optional(),
826
- event: k().optional()
827
- })
828
- ), _ = (i) => i.payload.type === "Timeline Entry" || i.payload.type === "MyOS Timeline Entry";
829
- class Fe extends B {
679
+ const _ = (c) => c.payload.type === "Timeline Entry" || c.payload.type === "MyOS Timeline Entry";
680
+ class je extends P {
830
681
  constructor() {
831
682
  super(...arguments);
832
683
  l(this, "contractType", "MyOS Timeline Channel");
833
- l(this, "contractBlueId", T["MyOS Timeline Channel"]);
684
+ l(this, "contractBlueId", H["MyOS Timeline Channel"]);
834
685
  }
835
686
  supports(t, n, o) {
687
+ var m;
836
688
  if (!this.baseSupports(t) || !_(t)) return !1;
837
- const a = o.getBlue(), r = a.jsonValueToNode(t.payload), s = a.nodeToSchemaOutput(
838
- r,
839
- Re
840
- ), c = o.getBlue().nodeToSchemaOutput(n, Ve), h = y(c.timelineId) && y(s.timelineId), d = y(c.account) && y(s.account), f = y(c.email) && y(s.email);
841
- return h && s.timelineId === c.timelineId || d && s.account === c.account || f && s.email === c.email;
689
+ const r = o.getBlue(), a = r.jsonValueToNode(t.payload), s = r.nodeToSchemaOutput(
690
+ a,
691
+ Ee
692
+ ), i = o.getBlue().nodeToSchemaOutput(n, we), u = (m = s.timeline) == null ? void 0 : m.getValue(), h = f(i.timelineId) && f(u), d = f(i.account) && f(s.account), p = f(i.email) && f(s.email);
693
+ return h && u === i.timelineId || d && s.account === i.account || p && s.email === i.email;
842
694
  }
843
- handle(t, n, o, a) {
695
+ handle(t, n, o, r) {
844
696
  _(t) && o.emitEvent({
845
697
  payload: t.payload,
846
- channelName: a,
698
+ channelName: r,
847
699
  source: "channel"
848
700
  });
849
701
  }
850
702
  }
851
- class Ue extends B {
703
+ class Fe extends P {
852
704
  constructor() {
853
705
  super(...arguments);
854
706
  l(this, "contractType", "MyOS Agent Channel");
855
- l(this, "contractBlueId", T["MyOS Agent Channel"]);
707
+ l(this, "contractBlueId", H["MyOS Agent Channel"]);
856
708
  }
857
709
  supports(t, n, o) {
858
710
  if (!this.baseSupports(t)) return !1;
859
711
  try {
860
- const { myosAgentEvent: a, myosAgentChannel: r } = this.parseEventAndChannel(
712
+ const { myosAgentEvent: r, myosAgentChannel: a } = this.parseEventAndChannel(
861
713
  t,
862
714
  n,
863
715
  o
864
716
  );
865
- return this.isAgentMatch(a, r) && this.isEventPatternMatch(a, r, o);
866
- } catch (a) {
867
- return console.warn("Error in MyOSAgentChannelProcessor.supports:", a), !1;
717
+ return this.isAgentMatch(r, a) && this.isEventPatternMatch(r, a, o);
718
+ } catch (r) {
719
+ return console.warn("Error in MyOSAgentChannelProcessor.supports:", r), !1;
868
720
  }
869
721
  }
870
- handle(t, n, o, a) {
722
+ handle(t, n, o, r) {
871
723
  o.emitEvent({
872
724
  payload: t.payload,
873
- channelName: a,
725
+ channelName: r,
874
726
  source: "channel"
875
727
  });
876
728
  }
@@ -879,14 +731,14 @@ class Ue extends B {
879
731
  * @throws {Error} If schema validation fails
880
732
  */
881
733
  parseEventAndChannel(t, n, o) {
882
- const a = o.getBlue(), r = a.jsonValueToNode(t.payload), s = a.nodeToSchemaOutput(
883
- r,
884
- Ke
885
- ), c = a.nodeToSchemaOutput(
734
+ const r = o.getBlue(), a = r.jsonValueToNode(t.payload), s = r.nodeToSchemaOutput(
735
+ a,
736
+ ve
737
+ ), i = r.nodeToSchemaOutput(
886
738
  n,
887
- Qe
739
+ Te
888
740
  );
889
- return { myosAgentEvent: s, myosAgentChannel: c };
741
+ return { myosAgentEvent: s, myosAgentChannel: i };
890
742
  }
891
743
  /**
892
744
  * Checks if the agent IDs match between event and channel
@@ -895,9 +747,9 @@ class Ue extends B {
895
747
  * @returns true if both have valid agent IDs and they match
896
748
  */
897
749
  isAgentMatch(t, n) {
898
- var r;
899
- const o = t.agentId, a = (r = n.agent) == null ? void 0 : r.agentId;
900
- return y(o) && y(a) && o === a;
750
+ var a;
751
+ const o = t.agentId, r = (a = n.agent) == null ? void 0 : a.agentId;
752
+ return f(o) && f(r) && o === r;
901
753
  }
902
754
  /**
903
755
  * Checks if the event pattern matches the channel's event filter
@@ -913,29 +765,29 @@ class Ue extends B {
913
765
  * - Otherwise → uses deep containment matching (event must contain all channel pattern fields)
914
766
  */
915
767
  isEventPatternMatch(t, n, o) {
916
- const a = n.event;
917
- if (!a)
918
- return !0;
919
- const r = t.event;
768
+ const r = n.event;
920
769
  if (!r)
770
+ return !0;
771
+ const a = t.event;
772
+ if (!a)
921
773
  return !1;
922
774
  try {
923
- const s = o.getBlue(), c = s.nodeToJson(r), h = s.nodeToJson(a);
924
- return fe(c, h);
775
+ const s = o.getBlue(), i = s.nodeToJson(a), u = s.nodeToJson(r);
776
+ return ge(i, u);
925
777
  } catch (s) {
926
778
  return console.warn("Error during event pattern matching:", s), !1;
927
779
  }
928
780
  }
929
781
  }
930
- class Je {
782
+ class Ue {
931
783
  constructor() {
932
784
  l(this, "contractType", "Operation");
933
- l(this, "contractBlueId", p.Operation);
785
+ l(this, "contractBlueId", g.Operation);
934
786
  l(this, "role", "adapter");
935
787
  }
936
788
  supports(e, t, n, o) {
937
- const r = n.getBlue().nodeToSchemaOutput(t, we), s = this.parseEventPayload(e, n);
938
- return y(s == null ? void 0 : s.operation) && s.operation === o && e.source === "channel" && e.channelName === r.channel;
789
+ const a = n.getBlue().nodeToSchemaOutput(t, ue), s = this.parseEventPayload(e, n);
790
+ return f(s == null ? void 0 : s.operation) && s.operation === o && e.source === "channel" && e.channelName === a.channel;
939
791
  }
940
792
  async handle(e, t, n, o) {
941
793
  n.emitEvent({
@@ -949,53 +801,53 @@ class Je {
949
801
  }
950
802
  parseEventPayload(e, t) {
951
803
  const n = t.getBlue(), o = n.jsonValueToNode(e.payload);
952
- if (P.isTypeOf(o, I)) {
953
- const a = n.nodeToSchemaOutput(
804
+ if (E.isTypeOf(o, B)) {
805
+ const r = n.nodeToSchemaOutput(
954
806
  o,
955
- I
807
+ B
956
808
  );
957
- if (a.message)
809
+ if (r.message)
958
810
  return n.nodeToSchemaOutput(
959
- a.message,
960
- ve
811
+ r.message,
812
+ he
961
813
  );
962
814
  }
963
815
  return null;
964
816
  }
965
817
  }
966
- class Ze {
818
+ class _e {
967
819
  constructor() {
968
820
  l(this, "contractType", "Process Embedded");
969
821
  l(this, "role", "adapter");
970
- l(this, "contractBlueId", p["Process Embedded"]);
822
+ l(this, "contractBlueId", g["Process Embedded"]);
971
823
  }
972
824
  supports(e) {
973
825
  return e.source !== "channel";
974
826
  }
975
827
  handle(e, t, n) {
976
- const o = n.getBlue().nodeToSchemaOutput(t, $);
977
- for (const a of o.paths ?? [])
828
+ const o = n.getBlue().nodeToSchemaOutput(t, I);
829
+ for (const r of o.paths ?? [])
978
830
  n.emitEvent({
979
831
  ...e,
980
- dispatchPath: n.resolvePath(a)
832
+ dispatchPath: n.resolvePath(r)
981
833
  });
982
834
  }
983
835
  init() {
984
836
  return [];
985
837
  }
986
838
  }
987
- const ne = !process.env.SKIP_ISOLATED_VM;
839
+ const X = !process.env.SKIP_ISOLATED_VM;
988
840
  let v = null;
989
- if (ne)
841
+ if (X)
990
842
  try {
991
843
  v = require("isolated-vm");
992
844
  } catch {
993
845
  console.warn("isolated-vm not available, using fallback evaluation method");
994
846
  }
995
- function L(i) {
996
- return /\bimport\s.+\sfrom\s+['"][^'"]+['"]/.test(i) || /\bexport\s+/.test(i);
847
+ function J(c) {
848
+ return /\bimport\s.+\sfrom\s+['"][^'"]+['"]/.test(c) || /\bexport\s+/.test(c);
997
849
  }
998
- class oe {
850
+ class G {
999
851
  /**
1000
852
  * Main evaluation method - chooses between secure and simple evaluation strategies
1001
853
  */
@@ -1005,14 +857,14 @@ class oe {
1005
857
  bindings: n = {},
1006
858
  options: o = {}
1007
859
  }) {
1008
- return !v || !ne ? this.evaluateSimple(e, n, o) : this.evaluateSecure(e, n, t, o);
860
+ return !v || !X ? this.evaluateSimple(e, n, o) : this.evaluateSecure(e, n, t, o);
1009
861
  }
1010
862
  /**
1011
863
  * Fallback evaluation using Node's Function constructor
1012
864
  * Used when isolated-vm is not available
1013
865
  */
1014
866
  static async evaluateSimple(e, t, n = {}) {
1015
- if (L(e))
867
+ if (J(e))
1016
868
  throw new Error(
1017
869
  "Static import/export syntax requires isolated-vm – start Node without SKIP_ISOLATED_VM."
1018
870
  );
@@ -1033,7 +885,7 @@ class oe {
1033
885
  `return ${e};`
1034
886
  )(...Object.values(t));
1035
887
  } catch (o) {
1036
- throw n.isCodeBlock ? new Q(e, o) : new W(e, o);
888
+ throw n.isCodeBlock ? new D(e, o) : new x(e, o);
1037
889
  }
1038
890
  }
1039
891
  /**
@@ -1041,32 +893,32 @@ class oe {
1041
893
  */
1042
894
  static async evaluateSecure(e, t, n, o = {}) {
1043
895
  if (!v) throw new Error("isolated-vm not available");
1044
- const a = new v.Isolate({ memoryLimit: 32 }), r = await a.createContext(), s = r.global;
896
+ const r = new v.Isolate({ memoryLimit: 32 }), a = await r.createContext(), s = a.global;
1045
897
  try {
1046
898
  await this.setupIsolateEnvironment(s, t);
1047
- const c = /* @__PURE__ */ new Map(), h = this.createModuleResolver(
1048
- a,
899
+ const i = /* @__PURE__ */ new Map(), u = this.createModuleResolver(
1049
900
  r,
1050
- c,
901
+ a,
902
+ i,
1051
903
  n
1052
904
  );
1053
- return L(e) ? await this.evaluateESModule(
1054
- a,
905
+ return J(e) ? await this.evaluateESModule(
1055
906
  r,
907
+ a,
1056
908
  e,
1057
909
  o,
1058
- h
910
+ u
1059
911
  ) : await this.evaluateSimpleScript(
1060
- a,
1061
912
  r,
913
+ a,
1062
914
  e,
1063
915
  t,
1064
916
  o
1065
917
  );
1066
- } catch (c) {
1067
- throw o.isCodeBlock ? new Q(e, c) : new W(e, c);
918
+ } catch (i) {
919
+ throw o.isCodeBlock ? new D(e, i) : new x(e, i);
1068
920
  } finally {
1069
- r.release(), a.dispose();
921
+ a.release(), r.dispose();
1070
922
  }
1071
923
  }
1072
924
  /**
@@ -1078,54 +930,54 @@ class oe {
1078
930
  (...o) => console.log(...o)
1079
931
  );
1080
932
  await e.set("log", n);
1081
- for (const [o, a] of Object.entries(t))
1082
- typeof a == "function" ? await e.set(
933
+ for (const [o, r] of Object.entries(t))
934
+ typeof r == "function" ? await e.set(
1083
935
  o,
1084
- new v.Callback(a)
1085
- ) : await e.set(o, new v.ExternalCopy(a).copyInto());
936
+ new v.Callback(r)
937
+ ) : await e.set(o, new v.ExternalCopy(r).copyInto());
1086
938
  }
1087
939
  /**
1088
940
  * Create module resolver function for handling imports
1089
941
  */
1090
942
  static createModuleResolver(e, t, n, o) {
1091
- return async (a) => {
1092
- if (n.has(a)) return n.get(a);
1093
- if (a.startsWith("blue:")) {
1094
- const r = a.slice(5), s = o.loadBlueContent;
943
+ return async (r) => {
944
+ if (n.has(r)) return n.get(r);
945
+ if (r.startsWith("blue:")) {
946
+ const a = r.slice(5), s = o.loadBlueContent;
1095
947
  if (typeof s != "function")
1096
948
  throw new Error(
1097
- `ProcessingContext is missing a loadBlueContent(blueId) implementation (needed for ${a})`
949
+ `ProcessingContext is missing a loadBlueContent(blueId) implementation (needed for ${r})`
1098
950
  );
1099
- const c = await s(r), h = await e.compileModule(c);
1100
- return n.set(a, h), await h.instantiate(
951
+ const i = await s(a), u = await e.compileModule(i);
952
+ return n.set(r, u), await u.instantiate(
1101
953
  t,
1102
954
  this.createModuleResolver(e, t, n, o)
1103
- ), h;
955
+ ), u;
1104
956
  }
1105
- if (/^https?:\/\//.test(a)) {
1106
- let r;
957
+ if (/^https?:\/\//.test(r)) {
958
+ let a;
1107
959
  if (typeof o.loadExternalModule == "function")
1108
- r = await o.loadExternalModule(a);
960
+ a = await o.loadExternalModule(r);
1109
961
  else
1110
962
  throw new Error(
1111
- `ProcessingContext is missing a loadExternalModule(url) implementation (needed for ${a})`
963
+ `ProcessingContext is missing a loadExternalModule(url) implementation (needed for ${r})`
1112
964
  );
1113
- const s = await e.compileModule(r);
1114
- return n.set(a, s), await s.instantiate(
965
+ const s = await e.compileModule(a);
966
+ return n.set(r, s), await s.instantiate(
1115
967
  t,
1116
968
  this.createModuleResolver(e, t, n, o)
1117
969
  ), s;
1118
970
  }
1119
- throw new Error(`Unsupported module specifier "${a}"`);
971
+ throw new Error(`Unsupported module specifier "${r}"`);
1120
972
  };
1121
973
  }
1122
974
  /**
1123
975
  * Evaluate code as a simple script (no imports/exports)
1124
976
  */
1125
- static async evaluateSimpleScript(e, t, n, o, a) {
1126
- const r = Object.keys(o).join(", "), s = Object.keys(o).map((d) => d), c = `(async (${r}) => { ${a.isCodeBlock ? n : `return (${n});`} })(${s.join(", ")})`;
1127
- return await (await e.compileScript(c)).run(t, {
1128
- timeout: a.timeout ?? 500,
977
+ static async evaluateSimpleScript(e, t, n, o, r) {
978
+ const a = Object.keys(o).join(", "), s = Object.keys(o).map((h) => h), i = `(async (${a}) => { ${r.isCodeBlock ? n : `return (${n});`} })(${s.join(", ")})`;
979
+ return await (await e.compileScript(i)).run(t, {
980
+ timeout: r.timeout ?? 500,
1129
981
  promise: !0,
1130
982
  copy: !0,
1131
983
  release: !0
@@ -1134,23 +986,23 @@ class oe {
1134
986
  /**
1135
987
  * Evaluate code as an ES module with import/export support
1136
988
  */
1137
- static async evaluateESModule(e, t, n, o, a) {
1138
- let r = n;
989
+ static async evaluateESModule(e, t, n, o, r) {
990
+ let a = n;
1139
991
  if (o.isCodeBlock) {
1140
- const h = /^\s*(import\s.+?;|export\s.+?;)/gm, d = (n.match(h) || []).join(
992
+ const u = /^\s*(import\s.+?;|export\s.+?;)/gm, h = (n.match(u) || []).join(
1141
993
  `
1142
994
  `
1143
- ), f = n.replace(h, "").trim();
1144
- r = `
1145
- ${d}
995
+ ), d = n.replace(u, "").trim();
996
+ a = `
997
+ ${h}
1146
998
  const run = function() {
1147
- ${f}
999
+ ${d}
1148
1000
  };
1149
1001
  export default run();
1150
1002
  `;
1151
1003
  }
1152
- const s = await e.compileModule(r);
1153
- return await s.instantiate(t, a), await s.evaluate({
1004
+ const s = await e.compileModule(a);
1005
+ return await s.instantiate(t, r), await s.evaluate({
1154
1006
  timeout: o.timeout ?? 500,
1155
1007
  promise: !0,
1156
1008
  reference: !0,
@@ -1163,37 +1015,37 @@ class oe {
1163
1015
  });
1164
1016
  }
1165
1017
  }
1166
- class ae {
1018
+ class Y {
1167
1019
  /**
1168
1020
  * Creates standard bindings for workflow step execution
1169
1021
  */
1170
1022
  static createStandardBindings(e, t, n) {
1171
1023
  const o = e.getBlue();
1172
1024
  return {
1173
- document: (a) => {
1174
- const r = e.get(a);
1175
- return z(r) ? r.toNumber() : x(r) ? o.nodeToJson(r, "original") : r;
1025
+ document: (r) => {
1026
+ const a = e.get(r);
1027
+ return V(a) ? a.toNumber() : C(a) ? o.nodeToJson(a, "original") : a;
1176
1028
  },
1177
1029
  event: t.payload,
1178
1030
  steps: n
1179
1031
  };
1180
1032
  }
1181
1033
  }
1182
- class _e {
1034
+ class Je {
1183
1035
  constructor() {
1184
1036
  l(this, "stepType", "Update Document");
1185
1037
  }
1186
1038
  supports(e) {
1187
- return P.isTypeOf(e, A);
1039
+ return E.isTypeOf(e, k);
1188
1040
  }
1189
1041
  async evaluateChangeValue(e, t, n, o) {
1190
- const a = e == null ? void 0 : e.getValue();
1191
- if (typeof a == "string" && a.startsWith("${") && a.endsWith("}")) {
1192
- const r = a.slice(2, -1);
1193
- return await oe.evaluate({
1194
- code: r,
1042
+ const r = e == null ? void 0 : e.getValue();
1043
+ if (typeof r == "string" && r.startsWith("${") && r.endsWith("}")) {
1044
+ const a = r.slice(2, -1);
1045
+ return await G.evaluate({
1046
+ code: a,
1195
1047
  ctx: t,
1196
- bindings: ae.createStandardBindings(
1048
+ bindings: Y.createStandardBindings(
1197
1049
  t,
1198
1050
  n,
1199
1051
  o
@@ -1202,28 +1054,28 @@ class _e {
1202
1054
  }
1203
1055
  return e;
1204
1056
  }
1205
- async execute(e, t, n, o, a) {
1206
- if (!P.isTypeOf(e, A)) return;
1207
- const r = n.getBlue().nodeToSchemaOutput(e, A);
1208
- for (const s of r.changeset ?? [])
1057
+ async execute(e, t, n, o, r) {
1058
+ if (!E.isTypeOf(e, k)) return;
1059
+ const a = n.getBlue().nodeToSchemaOutput(e, k);
1060
+ for (const s of a.changeset ?? [])
1209
1061
  if (s.path) {
1210
1062
  if (s.op === "replace" || s.op === "add") {
1211
- const c = await this.evaluateChangeValue(
1063
+ const i = await this.evaluateChangeValue(
1212
1064
  s.val,
1213
1065
  n,
1214
1066
  t,
1215
- a
1067
+ r
1216
1068
  );
1217
1069
  n.addPatch({
1218
1070
  op: s.op,
1219
1071
  path: s.path,
1220
- val: c
1072
+ val: i
1221
1073
  }), n.emitEvent({
1222
1074
  payload: {
1223
1075
  type: "Document Update",
1224
1076
  op: s.op,
1225
1077
  path: n.resolvePath(s.path),
1226
- val: c
1078
+ val: i
1227
1079
  }
1228
1080
  });
1229
1081
  }
@@ -1238,69 +1090,71 @@ class _e {
1238
1090
  }
1239
1091
  }
1240
1092
  }
1241
- class Le {
1093
+ class Re {
1242
1094
  constructor() {
1243
1095
  l(this, "stepType", "Trigger Event");
1244
1096
  }
1245
1097
  supports(e) {
1246
- return P.isTypeOf(e, q);
1098
+ return E.isTypeOf(e, N);
1247
1099
  }
1248
1100
  async execute(e, t, n) {
1249
1101
  const o = n.getBlue();
1250
- if (!P.isTypeOf(e, q)) return;
1251
- const a = o.nodeToSchemaOutput(e, q), r = o.nodeToJson(
1252
- a.event,
1102
+ if (!E.isTypeOf(e, N)) return;
1103
+ const r = o.nodeToSchemaOutput(e, N);
1104
+ if (!r.event) return;
1105
+ const a = o.nodeToJson(
1106
+ r.event,
1253
1107
  "original"
1254
1108
  );
1255
1109
  n.emitEvent({
1256
- payload: r
1110
+ payload: a
1257
1111
  });
1258
1112
  }
1259
1113
  }
1260
- class He {
1114
+ class Ve {
1261
1115
  constructor() {
1262
1116
  l(this, "stepType", "JavaScript Code");
1263
1117
  }
1264
1118
  supports(e) {
1265
- return P.isTypeOf(e, M);
1119
+ return E.isTypeOf(e, O);
1266
1120
  }
1267
- async execute(e, t, n, o, a) {
1268
- if (!P.isTypeOf(e, M)) return;
1121
+ async execute(e, t, n, o, r) {
1122
+ if (!E.isTypeOf(e, O)) return;
1269
1123
  const s = n.getBlue().nodeToSchemaOutput(
1270
1124
  e,
1271
- M
1125
+ O
1272
1126
  );
1273
1127
  if (!s.code)
1274
1128
  throw new Error("JavaScript code is required");
1275
- const c = await oe.evaluate({
1129
+ const i = await G.evaluate({
1276
1130
  code: s.code,
1277
1131
  ctx: n,
1278
- bindings: ae.createStandardBindings(n, t, a),
1132
+ bindings: Y.createStandardBindings(n, t, r),
1279
1133
  options: {
1280
1134
  isCodeBlock: !0,
1281
1135
  timeout: 500
1282
1136
  }
1283
1137
  });
1284
- if (c && typeof c == "object" && "events" in c) {
1285
- const h = c;
1286
- if (Array.isArray(h.events))
1287
- for (const d of h.events)
1138
+ if (i && typeof i == "object" && "events" in i) {
1139
+ const u = i;
1140
+ if (Array.isArray(u.events))
1141
+ for (const h of u.events)
1288
1142
  n.emitEvent({
1289
- payload: d
1143
+ payload: h
1290
1144
  });
1291
1145
  }
1292
- return c;
1146
+ return i;
1293
1147
  }
1294
1148
  }
1295
- const ze = [
1296
- new _e(),
1297
- new Le(),
1298
- new He()
1149
+ const Le = [
1150
+ new Je(),
1151
+ new Re(),
1152
+ new Ve()
1299
1153
  ];
1300
- class re {
1301
- constructor(e = ze) {
1154
+ class Z {
1155
+ constructor(e = Le) {
1302
1156
  l(this, "contractType", "Sequential Workflow");
1303
- l(this, "contractBlueId", p["Sequential Workflow"]);
1157
+ l(this, "contractBlueId", g["Sequential Workflow"]);
1304
1158
  l(this, "role", "handler");
1305
1159
  l(this, "executors", []);
1306
1160
  this.executors = e;
@@ -1310,31 +1164,29 @@ class re {
1310
1164
  this.executors.push(e);
1311
1165
  }
1312
1166
  supports(e, t, n) {
1313
- const r = n.getBlue().nodeToSchemaOutput(
1167
+ const a = n.getBlue().nodeToSchemaOutput(
1314
1168
  t,
1315
- j
1169
+ de
1316
1170
  ).channel;
1317
- return e.source === "channel" && e.channelName === r;
1171
+ return e.source === "channel" && e.channelName === a;
1318
1172
  }
1319
1173
  async handle(e, t, n, o) {
1320
- const r = n.getBlue().nodeToSchemaOutput(
1321
- t,
1322
- j
1323
- ), s = {}, c = r.steps;
1324
- for (const [h, d] of (c ?? []).entries()) {
1325
- const f = this.executors.find((g) => g.supports(d));
1326
- if (!f)
1327
- throw new Error(`Unsupported workflow step type "${d.getType()}"`);
1328
- const C = await f.execute(
1329
- d,
1174
+ var s;
1175
+ const r = {}, a = (s = t.getProperties()) == null ? void 0 : s.steps.getItems();
1176
+ for (const [i, u] of (a ?? []).entries()) {
1177
+ const h = this.executors.find((p) => p.supports(u));
1178
+ if (!h)
1179
+ throw new Error(`Unsupported workflow step type "${u.getType()}"`);
1180
+ const d = await h.execute(
1181
+ u,
1330
1182
  e,
1331
1183
  n,
1332
1184
  o,
1333
- s
1185
+ r
1334
1186
  );
1335
- if (C !== void 0) {
1336
- const g = d.getName(), w = typeof g == "string" ? g : `Step${h + 1}`;
1337
- s[w] = C;
1187
+ if (d !== void 0) {
1188
+ const p = u.getName(), m = typeof p == "string" ? p : `Step${i + 1}`;
1189
+ r[m] = d;
1338
1190
  }
1339
1191
  await n.flush();
1340
1192
  }
@@ -1343,90 +1195,91 @@ class re {
1343
1195
  return [];
1344
1196
  }
1345
1197
  }
1346
- class Xe {
1198
+ class He {
1347
1199
  constructor(e) {
1348
1200
  l(this, "contractType", "Sequential Workflow Operation");
1349
- l(this, "contractBlueId", p["Sequential Workflow Operation"]);
1201
+ l(this, "contractBlueId", g["Sequential Workflow Operation"]);
1350
1202
  l(this, "role", "handler");
1351
1203
  l(this, "sequentialWorkflowProcessor");
1352
- this.sequentialWorkflowProcessor = e || new re();
1204
+ this.sequentialWorkflowProcessor = e || new Z();
1353
1205
  }
1354
1206
  supports(e, t, n) {
1355
- const r = n.getBlue().nodeToSchemaOutput(
1207
+ const a = n.getBlue().nodeToSchemaOutput(
1356
1208
  t,
1357
- Se
1209
+ pe
1358
1210
  ).operation, s = e.channelName;
1359
- return e.source === "channel" && D(s) && D(r) && s === r;
1211
+ return e.source === "channel" && M(s) && M(a) && s === a;
1360
1212
  }
1361
1213
  async handle(e, t, n, o) {
1362
1214
  try {
1363
1215
  await this.sequentialWorkflowProcessor.handle(e, t, n, o);
1364
- } catch (a) {
1216
+ } catch (r) {
1365
1217
  throw console.error(
1366
1218
  "Error in SequentialWorkflowOperationProcessor.handle:",
1367
- a
1368
- ), a;
1219
+ r
1220
+ ), r;
1369
1221
  }
1370
1222
  }
1371
1223
  }
1372
- const H = (i) => i.payload.type === "Timeline Entry";
1373
- class Ye extends B {
1224
+ const R = (c) => c.payload.type === "Timeline Entry";
1225
+ class Qe extends P {
1374
1226
  constructor() {
1375
1227
  super(...arguments);
1376
1228
  l(this, "contractType", "Timeline Channel");
1377
- l(this, "contractBlueId", p["Timeline Channel"]);
1229
+ l(this, "contractBlueId", g["Timeline Channel"]);
1378
1230
  }
1379
1231
  supports(t, n, o) {
1380
- if (!this.baseSupports(t) || !H(t)) return !1;
1381
- const a = o.getBlue(), r = a.jsonValueToNode(t.payload), s = a.nodeToSchemaOutput(
1382
- r,
1383
- I
1384
- ), c = o.getBlue().nodeToSchemaOutput(n, te);
1385
- return y(c.timelineId) && y(s.timelineId) && s.timelineId === c.timelineId;
1386
- }
1387
- handle(t, n, o, a) {
1388
- H(t) && o.emitEvent({
1232
+ var h;
1233
+ if (!this.baseSupports(t) || !R(t)) return !1;
1234
+ const r = o.getBlue(), a = r.nodeToSchemaOutput(
1235
+ r.jsonValueToNode(t.payload),
1236
+ B
1237
+ ), s = o.getBlue().nodeToSchemaOutput(n, me), i = (h = a.timeline) == null ? void 0 : h.getValue();
1238
+ return f(s.timelineId) && f(i) && i === s.timelineId;
1239
+ }
1240
+ handle(t, n, o, r) {
1241
+ R(t) && o.emitEvent({
1389
1242
  payload: t.payload,
1390
- channelName: a,
1243
+ channelName: r,
1391
1244
  source: "channel"
1392
1245
  });
1393
1246
  }
1394
1247
  }
1395
- const Ge = [
1396
- new Ze(),
1248
+ const Ke = [
1249
+ new _e(),
1397
1250
  // channels
1251
+ new We(),
1252
+ new De(),
1253
+ new Qe(),
1398
1254
  new je(),
1399
- new $e(),
1400
- new Ye(),
1401
1255
  new Fe(),
1256
+ new xe(),
1402
1257
  new Ue(),
1403
- new De(),
1404
- new Je(),
1405
1258
  // sequential workflows
1406
- new re(),
1407
- new Xe()
1259
+ new Z(),
1260
+ new He()
1408
1261
  ];
1409
- class rt {
1262
+ class tt {
1410
1263
  /**
1411
1264
  * Creates a new document processor
1412
1265
  *
1413
1266
  * @param processors - Initial list of processors to register
1414
1267
  */
1415
- constructor(e, t = Ge) {
1268
+ constructor(e, t = Ke) {
1416
1269
  l(this, "taskCounter", 0);
1417
1270
  l(this, "eventCounter", 0);
1418
1271
  l(this, "registry");
1419
1272
  l(this, "queue");
1420
1273
  l(this, "router");
1421
1274
  l(this, "checkpointCache", new Ae());
1422
- this.blue = e, this.registry = new Be(t), this.queue = new Oe(), this.router = new Ie(
1275
+ this.blue = e, this.registry = new Oe(t), this.queue = new Ne(), this.router = new Me(
1423
1276
  this.blue,
1424
1277
  this.registry,
1425
1278
  this.queue,
1426
1279
  () => ++this.taskCounter,
1427
1280
  () => ++this.eventCounter
1428
1281
  ), this.register(
1429
- new qe(this.checkpointCache),
1282
+ new $e(this.checkpointCache),
1430
1283
  9999
1431
1284
  );
1432
1285
  }
@@ -1446,7 +1299,7 @@ class rt {
1446
1299
  * @returns Processing result with final state and emitted events
1447
1300
  */
1448
1301
  async initialise(e) {
1449
- e = J(e, this.blue);
1302
+ e = F(e, this.blue);
1450
1303
  const t = await this.bootstrapContracts(e);
1451
1304
  for (const n of t)
1452
1305
  await this.router.route(e, [], n, 0);
@@ -1460,16 +1313,16 @@ class rt {
1460
1313
  * @returns Processing result with final state and emitted events
1461
1314
  */
1462
1315
  async processEvents(e, t) {
1463
- let n = J(e, this.blue);
1316
+ let n = F(e, this.blue);
1464
1317
  const o = [];
1465
- for (const a of t)
1318
+ for (const r of t)
1466
1319
  try {
1467
- const r = { payload: a, source: "external" };
1468
- await this.router.route(n, [], r, 0);
1320
+ const a = { payload: r, source: "external" };
1321
+ await this.router.route(n, [], a, 0);
1469
1322
  const s = await this.drainQueue(n);
1470
1323
  n = s.state, o.push(...s.emitted);
1471
- const c = this.checkpointCache.flush(n);
1472
- c.length && (n = U(n, c));
1324
+ const i = this.checkpointCache.flush(n);
1325
+ i.length && (n = j(n, i));
1473
1326
  } finally {
1474
1327
  this.checkpointCache.clear();
1475
1328
  }
@@ -1483,8 +1336,8 @@ class rt {
1483
1336
  if (!n)
1484
1337
  return t;
1485
1338
  for (const [, o] of Object.entries(n)) {
1486
- const a = this.registry.get(o.getType());
1487
- a != null && a.init && t.push(...await a.init(o));
1339
+ const r = this.registry.get(o.getType());
1340
+ r != null && r.init && t.push(...await r.init(o));
1488
1341
  }
1489
1342
  return t;
1490
1343
  }
@@ -1492,66 +1345,66 @@ class rt {
1492
1345
  * Drains the task queue and applies all actions
1493
1346
  */
1494
1347
  async drainQueue(e) {
1495
- var r;
1348
+ var a;
1496
1349
  let t = e;
1497
1350
  const n = [], o = 1e4;
1498
- let a = 0;
1351
+ let r = 0;
1499
1352
  for (; this.queue.length; ) {
1500
- if (++a > o)
1353
+ if (++r > o)
1501
1354
  throw new Error("Possible cycle – too many iterations");
1502
- const s = this.queue.pop(), { nodePath: c, contractName: h, contractNode: d, event: f } = s, C = t.get(c);
1503
- if (!x(C) || !((r = C.getContracts()) != null && r[h]) || !d.getType()) continue;
1504
- const g = this.registry.get(d.getType());
1505
- if (!g) {
1506
- console.warn(`No processor registered for contract: ${h}`);
1355
+ const s = this.queue.pop(), { nodePath: i, contractName: u, contractNode: h, event: d } = s, p = t.get(i);
1356
+ if (!C(p) || !((a = p.getContracts()) != null && a[u]) || !h.getType()) continue;
1357
+ const m = this.registry.get(h.getType());
1358
+ if (!m) {
1359
+ console.warn(`No processor registered for contract: ${u}`);
1507
1360
  continue;
1508
1361
  }
1509
- const w = new Y(
1362
+ const w = new Q(
1510
1363
  () => t,
1511
1364
  s,
1512
1365
  this.blue,
1513
1366
  async (b) => {
1514
- for (const E of b)
1515
- if (E.kind === "patch") {
1516
- const se = V(t, this.blue);
1517
- for (const O of se) {
1518
- const ie = E.patch.op === "move" || E.patch.op === "copy" ? [E.patch.from, E.patch.path] : [E.patch.path], R = w.getNodePath(), ce = ie.some(
1519
- (ue) => F(ue, O.absPath)
1520
- ), le = F(
1521
- R,
1522
- O.absPath
1367
+ for (const y of b)
1368
+ if (y.kind === "patch") {
1369
+ const ee = q(t, this.blue);
1370
+ for (const S of ee) {
1371
+ const te = y.patch.op === "move" || y.patch.op === "copy" ? [y.patch.from, y.patch.path] : [y.patch.path], $ = w.getNodePath(), ne = te.some(
1372
+ (re) => W(re, S.absPath)
1373
+ ), oe = W(
1374
+ $,
1375
+ S.absPath
1523
1376
  );
1524
- if (ce && !le)
1525
- throw new ee(
1526
- E.patch,
1527
- O.absPath,
1528
- R
1377
+ if (ne && !oe)
1378
+ throw new z(
1379
+ y.patch,
1380
+ S.absPath,
1381
+ $
1529
1382
  );
1530
1383
  }
1531
1384
  try {
1532
- t = U(t, [E.patch]);
1533
- } catch (O) {
1534
- throw Me(h, f, O), O;
1385
+ t = j(t, [y.patch]);
1386
+ } catch (S) {
1387
+ throw qe(u, d, S), S;
1535
1388
  }
1536
- } else E.kind === "event" && (n.push(E.event.payload), await this.router.route(t, [], E.event, s.key[5]));
1389
+ } else y.kind === "event" && (n.push(y.event.payload), await this.router.route(t, [], y.event, s.key[5]));
1537
1390
  }
1538
1391
  );
1539
- await g.handle(f, d, w, h), await w.flush();
1392
+ await m.handle(d, h, w, u), await w.flush();
1540
1393
  }
1541
1394
  return { state: t, emitted: n };
1542
1395
  }
1543
1396
  }
1544
1397
  export {
1545
- rt as BlueDocumentProcessor,
1546
- qe as ChannelEventCheckpointProcessor,
1547
- De as CompositeTimelineChannelProcessor,
1548
- $e as DocumentUpdateChannelProcessor,
1549
- je as EmbeddedNodeChannelProcessor,
1550
- Ue as MyOSAgentChannelProcessor,
1551
- Fe as MyOSTimelineChannelProcessor,
1552
- Je as OperationProcessor,
1553
- Ze as ProcessEmbeddedProcessor,
1554
- Xe as SequentialWorkflowOperationProcessor,
1555
- re as SequentialWorkflowProcessor,
1556
- Ye as TimelineChannelProcessor
1398
+ tt as BlueDocumentProcessor,
1399
+ $e as ChannelEventCheckpointProcessor,
1400
+ xe as CompositeTimelineChannelProcessor,
1401
+ De as DocumentUpdateChannelProcessor,
1402
+ We as EmbeddedNodeChannelProcessor,
1403
+ Fe as MyOSAgentChannelProcessor,
1404
+ je as MyOSTimelineChannelProcessor,
1405
+ Ue as OperationProcessor,
1406
+ _e as ProcessEmbeddedProcessor,
1407
+ He as SequentialWorkflowOperationProcessor,
1408
+ Z as SequentialWorkflowProcessor,
1409
+ Qe as TimelineChannelProcessor
1557
1410
  };