@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.
- package/dist/index.js +5 -5
- package/dist/index.mjs +441 -588
- package/dist/processors/ChannelEventCheckpointProcessor.d.ts +1 -1
- package/dist/processors/CompositeTimelineChannelProcessor.d.ts +1 -1
- package/dist/processors/CompositeTimelineChannelProcessor.d.ts.map +1 -1
- package/dist/processors/DocumentUpdateChannelProcessor.d.ts +1 -1
- package/dist/processors/DocumentUpdateChannelProcessor.d.ts.map +1 -1
- package/dist/processors/EmbeddedNodeChannelProcessor.d.ts +1 -1
- package/dist/processors/EmbeddedNodeChannelProcessor.d.ts.map +1 -1
- package/dist/processors/MyOSAgentChannelProcessor.d.ts +1 -1
- package/dist/processors/MyOSAgentChannelProcessor.d.ts.map +1 -1
- package/dist/processors/MyOSTimelineChannelProcessor.d.ts +1 -1
- package/dist/processors/MyOSTimelineChannelProcessor.d.ts.map +1 -1
- package/dist/processors/OperationProcessor.d.ts +1 -1
- package/dist/processors/ProcessEmbeddedProcessor.d.ts +1 -1
- package/dist/processors/SequentialWorkflowOperationProcessor.d.ts +1 -1
- package/dist/processors/SequentialWorkflowOperationProcessor.d.ts.map +1 -1
- package/dist/processors/SequentialWorkflowProcessor/SequentialWorkflowProcessor.d.ts +1 -1
- package/dist/processors/SequentialWorkflowProcessor/SequentialWorkflowProcessor.d.ts.map +1 -1
- package/dist/processors/SequentialWorkflowProcessor/steps/TriggerEventExecutor.d.ts.map +1 -1
- package/dist/processors/TimelineChannelProcessor.d.ts +1 -1
- package/dist/processors/TimelineChannelProcessor.d.ts.map +1 -1
- package/dist/utils/checkpoint.d.ts.map +1 -1
- package/package.json +6 -13
- package/dist/repo/core/blue-ids/index.d.ts +0 -21
- package/dist/repo/core/blue-ids/index.d.ts.map +0 -1
- package/dist/repo/core/index.d.ts +0 -199
- package/dist/repo/core/index.d.ts.map +0 -1
- package/dist/repo/core/schema/Channel.d.ts +0 -13
- package/dist/repo/core/schema/Channel.d.ts.map +0 -1
- package/dist/repo/core/schema/CompositeTimelineChannel.d.ts +0 -17
- package/dist/repo/core/schema/CompositeTimelineChannel.d.ts.map +0 -1
- package/dist/repo/core/schema/DocumentUpdateChannel.d.ts +0 -17
- package/dist/repo/core/schema/DocumentUpdateChannel.d.ts.map +0 -1
- package/dist/repo/core/schema/EmbeddedNodeChannel.d.ts +0 -17
- package/dist/repo/core/schema/EmbeddedNodeChannel.d.ts.map +0 -1
- package/dist/repo/core/schema/JavaScriptCode.d.ts +0 -10
- package/dist/repo/core/schema/JavaScriptCode.d.ts.map +0 -1
- package/dist/repo/core/schema/JsonPatchEntry.d.ts +0 -22
- package/dist/repo/core/schema/JsonPatchEntry.d.ts.map +0 -1
- package/dist/repo/core/schema/Operation.d.ts +0 -16
- package/dist/repo/core/schema/Operation.d.ts.map +0 -1
- package/dist/repo/core/schema/OperationRequest.d.ts +0 -29
- package/dist/repo/core/schema/OperationRequest.d.ts.map +0 -1
- package/dist/repo/core/schema/ProcessEmbedded.d.ts +0 -10
- package/dist/repo/core/schema/ProcessEmbedded.d.ts.map +0 -1
- package/dist/repo/core/schema/SequentialWorkflow.d.ts +0 -13
- package/dist/repo/core/schema/SequentialWorkflow.d.ts.map +0 -1
- package/dist/repo/core/schema/SequentialWorkflowOperation.d.ts +0 -15
- package/dist/repo/core/schema/SequentialWorkflowOperation.d.ts.map +0 -1
- package/dist/repo/core/schema/SequentialWorkflowStep.d.ts +0 -13
- package/dist/repo/core/schema/SequentialWorkflowStep.d.ts.map +0 -1
- package/dist/repo/core/schema/TimelineChannel.d.ts +0 -17
- package/dist/repo/core/schema/TimelineChannel.d.ts.map +0 -1
- package/dist/repo/core/schema/TimelineEntry.d.ts +0 -25
- package/dist/repo/core/schema/TimelineEntry.d.ts.map +0 -1
- package/dist/repo/core/schema/TriggerEvent.d.ts +0 -10
- package/dist/repo/core/schema/TriggerEvent.d.ts.map +0 -1
- package/dist/repo/core/schema/UpdateDocument.d.ts +0 -40
- package/dist/repo/core/schema/UpdateDocument.d.ts.map +0 -1
- package/dist/repo/core/schema/index.d.ts +0 -15
- package/dist/repo/core/schema/index.d.ts.map +0 -1
- package/dist/repo/myos/blue-ids/index.d.ts +0 -8
- package/dist/repo/myos/blue-ids/index.d.ts.map +0 -1
- package/dist/repo/myos/index.d.ts +0 -101
- package/dist/repo/myos/index.d.ts.map +0 -1
- package/dist/repo/myos/schema/MyOSAgent.d.ts +0 -10
- package/dist/repo/myos/schema/MyOSAgent.d.ts.map +0 -1
- package/dist/repo/myos/schema/MyOSAgentChannel.d.ts +0 -30
- package/dist/repo/myos/schema/MyOSAgentChannel.d.ts.map +0 -1
- package/dist/repo/myos/schema/MyOSAgentEvent.d.ts +0 -19
- package/dist/repo/myos/schema/MyOSAgentEvent.d.ts.map +0 -1
- package/dist/repo/myos/schema/MyOSTimelineChannel.d.ts +0 -24
- package/dist/repo/myos/schema/MyOSTimelineChannel.d.ts.map +0 -1
- package/dist/repo/myos/schema/MyOSTimelineEntry.d.ts +0 -32
- package/dist/repo/myos/schema/MyOSTimelineEntry.d.ts.map +0 -1
- package/dist/repo/myos/schema/index.d.ts +0 -6
- package/dist/repo/myos/schema/index.d.ts.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1,30 +1,31 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var l = (
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { deepFreeze as
|
|
7
|
-
|
|
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
|
|
11
|
+
async function Se(c) {
|
|
11
12
|
return new Promise((e, t) => {
|
|
12
|
-
|
|
13
|
+
be().on("error", t).end();
|
|
13
14
|
});
|
|
14
15
|
}
|
|
15
|
-
const
|
|
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 <
|
|
20
|
+
return t < c.length - 1 ? n.replace(/\/+$/, "") : n;
|
|
20
21
|
}).filter(Boolean).join("/").replace(/\/{2,}/g, "/");
|
|
21
|
-
class
|
|
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 =
|
|
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:
|
|
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
|
|
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
|
|
71
|
+
return Se();
|
|
71
72
|
}
|
|
72
73
|
loadBlueContent(e) {
|
|
73
74
|
throw new Error("Not implemented");
|
|
74
75
|
}
|
|
75
76
|
}
|
|
76
|
-
class
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
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
|
|
220
|
-
|
|
221
|
-
|
|
106
|
+
const u = e.nodeToSchemaOutput(
|
|
107
|
+
a,
|
|
108
|
+
I
|
|
222
109
|
).paths ?? [];
|
|
223
|
-
for (const
|
|
110
|
+
for (const h of u)
|
|
224
111
|
n.push({
|
|
225
|
-
absPath:
|
|
226
|
-
contractPath:
|
|
112
|
+
absPath: T(t, h),
|
|
113
|
+
contractPath: T(t, `contracts/${r}`)
|
|
227
114
|
});
|
|
228
115
|
}
|
|
229
|
-
for (const [
|
|
230
|
-
|
|
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
|
|
234
|
-
return
|
|
120
|
+
function W(c, e) {
|
|
121
|
+
return c === e || c.startsWith(e.endsWith("/") ? e : e + "/");
|
|
235
122
|
}
|
|
236
|
-
function
|
|
237
|
-
if (!e.length) return
|
|
238
|
-
let t =
|
|
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 =
|
|
128
|
+
t = fe(t, n, !0);
|
|
242
129
|
} catch (o) {
|
|
243
|
-
throw new
|
|
130
|
+
throw new K(n, o);
|
|
244
131
|
}
|
|
245
|
-
return
|
|
132
|
+
return L(t);
|
|
246
133
|
}
|
|
247
|
-
function
|
|
248
|
-
return
|
|
134
|
+
function f(c) {
|
|
135
|
+
return c != null;
|
|
249
136
|
}
|
|
250
|
-
function
|
|
251
|
-
return
|
|
137
|
+
function C(c) {
|
|
138
|
+
return c instanceof ye;
|
|
252
139
|
}
|
|
253
|
-
class
|
|
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
|
|
276
|
-
if (n(o,
|
|
277
|
-
t[e] =
|
|
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,
|
|
169
|
+
const { data: t, compare: n } = this, o = this.length >> 1, r = t[e];
|
|
283
170
|
for (; e < o; ) {
|
|
284
|
-
let
|
|
285
|
-
const s =
|
|
286
|
-
if (s < this.length && n(t[s], t[
|
|
287
|
-
t[e] = t[
|
|
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] =
|
|
176
|
+
t[e] = r;
|
|
290
177
|
}
|
|
291
178
|
}
|
|
292
|
-
const
|
|
293
|
-
-
|
|
179
|
+
const Ce = (c, e, t, n, o, r) => [
|
|
180
|
+
-c,
|
|
294
181
|
e,
|
|
295
182
|
t,
|
|
296
183
|
n,
|
|
297
184
|
o,
|
|
298
|
-
|
|
299
|
-
],
|
|
300
|
-
for (let t = 0; t <
|
|
301
|
-
const n =
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
461
|
-
class
|
|
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,
|
|
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 =
|
|
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,
|
|
484
|
-
var
|
|
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
|
|
488
|
-
return delete
|
|
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
|
|
492
|
-
return this.route(e,
|
|
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
|
|
496
|
-
|
|
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:
|
|
386
|
+
nodePath: a,
|
|
500
387
|
event: n,
|
|
501
388
|
afterTaskId: o,
|
|
502
389
|
pathSegments: t,
|
|
503
|
-
inlineDepth:
|
|
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:
|
|
515
|
-
afterTaskId:
|
|
401
|
+
event: r,
|
|
402
|
+
afterTaskId: a,
|
|
516
403
|
pathSegments: s,
|
|
517
|
-
inlineDepth:
|
|
404
|
+
inlineDepth: i
|
|
518
405
|
} = e;
|
|
519
|
-
if (!this.shouldSkipForChannel(
|
|
520
|
-
for (const [
|
|
406
|
+
if (!this.shouldSkipForChannel(r, o))
|
|
407
|
+
for (const [u, h] of Object.entries(
|
|
521
408
|
n.getContracts() ?? {}
|
|
522
409
|
)) {
|
|
523
|
-
if (!
|
|
524
|
-
const
|
|
525
|
-
if (!
|
|
526
|
-
console.warn(`No processor registered for contract: ${
|
|
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
|
|
416
|
+
const p = {
|
|
530
417
|
nodePath: o,
|
|
531
|
-
contractName:
|
|
532
|
-
contractNode:
|
|
533
|
-
event:
|
|
534
|
-
},
|
|
535
|
-
if (
|
|
536
|
-
switch (
|
|
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:
|
|
540
|
-
event:
|
|
541
|
-
contractNode:
|
|
542
|
-
ctx:
|
|
543
|
-
contractName:
|
|
426
|
+
cp: d,
|
|
427
|
+
event: r,
|
|
428
|
+
contractNode: h,
|
|
429
|
+
ctx: m,
|
|
430
|
+
contractName: u,
|
|
544
431
|
doc: t,
|
|
545
|
-
afterTaskId:
|
|
546
|
-
inlineDepth:
|
|
432
|
+
afterTaskId: a,
|
|
433
|
+
inlineDepth: i
|
|
547
434
|
});
|
|
548
435
|
break;
|
|
549
436
|
case "handler":
|
|
550
437
|
this.scheduleHandler({
|
|
551
|
-
contractNode:
|
|
552
|
-
contractName:
|
|
438
|
+
contractNode: h,
|
|
439
|
+
contractName: u,
|
|
553
440
|
nodePath: o,
|
|
554
|
-
event:
|
|
441
|
+
event: r,
|
|
555
442
|
depth: s.length,
|
|
556
|
-
afterTaskId:
|
|
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:
|
|
572
|
-
contractName:
|
|
458
|
+
ctx: r,
|
|
459
|
+
contractName: a,
|
|
573
460
|
doc: s,
|
|
574
|
-
afterTaskId:
|
|
575
|
-
inlineDepth:
|
|
461
|
+
afterTaskId: i,
|
|
462
|
+
inlineDepth: u
|
|
576
463
|
} = e;
|
|
577
|
-
if (
|
|
464
|
+
if (u >= Be)
|
|
578
465
|
throw new Error("Adapter recursion limit reached");
|
|
579
|
-
const
|
|
466
|
+
const h = this.traceManager.addHop(
|
|
580
467
|
n,
|
|
581
|
-
((w =
|
|
582
|
-
|
|
468
|
+
((w = r.getTaskInfo()) == null ? void 0 : w.nodePath) ?? "",
|
|
469
|
+
a
|
|
583
470
|
);
|
|
584
|
-
await t.handle(
|
|
585
|
-
const
|
|
586
|
-
if (
|
|
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 "${
|
|
475
|
+
`Contract "${a}" (adapter) attempted to patch the document`
|
|
589
476
|
);
|
|
590
|
-
const
|
|
591
|
-
for (const b of
|
|
592
|
-
await this.route(s, [], b.event,
|
|
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:
|
|
599
|
-
if (!
|
|
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
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
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
|
-
|
|
610
|
-
), w = this.traceManager.addHop(
|
|
496
|
+
p
|
|
497
|
+
), w = this.traceManager.addHop(r, o, n);
|
|
611
498
|
this.queue.push({
|
|
612
|
-
key:
|
|
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
|
|
627
|
-
(t instanceof
|
|
628
|
-
`[Blue] Failed to apply patches for contract "${
|
|
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
|
|
633
|
-
const t =
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
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:
|
|
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
|
|
650
|
-
const
|
|
651
|
-
|
|
538
|
+
for (const { absPath: o } of q(t, e)) {
|
|
539
|
+
const r = t.get(o);
|
|
540
|
+
C(r) && n(r);
|
|
652
541
|
}
|
|
653
|
-
return
|
|
542
|
+
return L(t);
|
|
654
543
|
}
|
|
655
|
-
class
|
|
544
|
+
class $e {
|
|
656
545
|
constructor(e) {
|
|
657
546
|
l(this, "contractType", "Channel Event Checkpoint");
|
|
658
|
-
l(this, "contractBlueId",
|
|
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
|
|
668
|
-
if (!e.channelName || !((
|
|
669
|
-
const o = await n.getBlue().calculateBlueId(e.rootEvent.payload),
|
|
670
|
-
this.cache.record(
|
|
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
|
|
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:
|
|
577
|
+
for (const { docBase: n, event: o, eventBlueId: r } of this.firstSeen.values()) {
|
|
689
578
|
if (!o.channelName) continue;
|
|
690
|
-
const
|
|
579
|
+
const a = T(
|
|
691
580
|
n,
|
|
692
581
|
"contracts/checkpoint/lastEvents",
|
|
693
582
|
o.channelName
|
|
694
|
-
), s = `${
|
|
695
|
-
|
|
696
|
-
op:
|
|
583
|
+
), s = `${a}/blueId`;
|
|
584
|
+
U(e, a) ? t.push({
|
|
585
|
+
op: U(e, s) ? "replace" : "add",
|
|
697
586
|
path: s,
|
|
698
|
-
val:
|
|
587
|
+
val: r
|
|
699
588
|
}) : t.push({
|
|
700
589
|
op: "add",
|
|
701
|
-
path:
|
|
702
|
-
val: { blueId:
|
|
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
|
|
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
|
|
619
|
+
class xe extends P {
|
|
731
620
|
constructor() {
|
|
732
621
|
super(...arguments);
|
|
733
622
|
l(this, "contractType", "Composite Timeline Channel");
|
|
734
|
-
l(this, "contractBlueId",
|
|
623
|
+
l(this, "contractBlueId", g["Composite Timeline Channel"]);
|
|
735
624
|
}
|
|
736
625
|
supports(t, n, o) {
|
|
737
|
-
const
|
|
738
|
-
return !
|
|
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,
|
|
629
|
+
handle(t, n, o, r) {
|
|
741
630
|
o.emitEvent({
|
|
742
631
|
payload: t.payload,
|
|
743
|
-
channelName:
|
|
632
|
+
channelName: r,
|
|
744
633
|
source: "channel"
|
|
745
634
|
});
|
|
746
635
|
}
|
|
747
636
|
}
|
|
748
|
-
class
|
|
637
|
+
class De extends P {
|
|
749
638
|
constructor() {
|
|
750
639
|
super(...arguments);
|
|
751
640
|
l(this, "contractType", "Document Update Channel");
|
|
752
|
-
l(this, "contractBlueId",
|
|
641
|
+
l(this, "contractBlueId", g["Document Update Channel"]);
|
|
753
642
|
}
|
|
754
|
-
supports(t, n, o,
|
|
643
|
+
supports(t, n, o, r) {
|
|
755
644
|
if (!this.baseSupports(t)) return !1;
|
|
756
|
-
const
|
|
757
|
-
if (!s || t.channelName ===
|
|
758
|
-
const
|
|
759
|
-
return
|
|
760
|
-
}
|
|
761
|
-
handle(t, n, o,
|
|
762
|
-
const
|
|
763
|
-
|
|
764
|
-
payload:
|
|
765
|
-
channelName:
|
|
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
|
|
659
|
+
class We extends P {
|
|
771
660
|
constructor() {
|
|
772
661
|
super(...arguments);
|
|
773
662
|
l(this, "contractType", "Embedded Node Channel");
|
|
774
|
-
l(this, "contractBlueId",
|
|
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
|
|
779
|
-
return
|
|
780
|
-
}
|
|
781
|
-
handle(t, n, o,
|
|
782
|
-
const
|
|
783
|
-
|
|
784
|
-
payload:
|
|
785
|
-
channelName:
|
|
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
|
|
791
|
-
|
|
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",
|
|
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
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
),
|
|
841
|
-
return h &&
|
|
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,
|
|
695
|
+
handle(t, n, o, r) {
|
|
844
696
|
_(t) && o.emitEvent({
|
|
845
697
|
payload: t.payload,
|
|
846
|
-
channelName:
|
|
698
|
+
channelName: r,
|
|
847
699
|
source: "channel"
|
|
848
700
|
});
|
|
849
701
|
}
|
|
850
702
|
}
|
|
851
|
-
class
|
|
703
|
+
class Fe extends P {
|
|
852
704
|
constructor() {
|
|
853
705
|
super(...arguments);
|
|
854
706
|
l(this, "contractType", "MyOS Agent Channel");
|
|
855
|
-
l(this, "contractBlueId",
|
|
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:
|
|
712
|
+
const { myosAgentEvent: r, myosAgentChannel: a } = this.parseEventAndChannel(
|
|
861
713
|
t,
|
|
862
714
|
n,
|
|
863
715
|
o
|
|
864
716
|
);
|
|
865
|
-
return this.isAgentMatch(
|
|
866
|
-
} catch (
|
|
867
|
-
return console.warn("Error in MyOSAgentChannelProcessor.supports:",
|
|
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,
|
|
722
|
+
handle(t, n, o, r) {
|
|
871
723
|
o.emitEvent({
|
|
872
724
|
payload: t.payload,
|
|
873
|
-
channelName:
|
|
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
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
),
|
|
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
|
-
|
|
739
|
+
Te
|
|
888
740
|
);
|
|
889
|
-
return { myosAgentEvent: s, myosAgentChannel:
|
|
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
|
|
899
|
-
const o = t.agentId,
|
|
900
|
-
return
|
|
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
|
|
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(),
|
|
924
|
-
return
|
|
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
|
|
782
|
+
class Ue {
|
|
931
783
|
constructor() {
|
|
932
784
|
l(this, "contractType", "Operation");
|
|
933
|
-
l(this, "contractBlueId",
|
|
785
|
+
l(this, "contractBlueId", g.Operation);
|
|
934
786
|
l(this, "role", "adapter");
|
|
935
787
|
}
|
|
936
788
|
supports(e, t, n, o) {
|
|
937
|
-
const
|
|
938
|
-
return
|
|
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 (
|
|
953
|
-
const
|
|
804
|
+
if (E.isTypeOf(o, B)) {
|
|
805
|
+
const r = n.nodeToSchemaOutput(
|
|
954
806
|
o,
|
|
955
|
-
|
|
807
|
+
B
|
|
956
808
|
);
|
|
957
|
-
if (
|
|
809
|
+
if (r.message)
|
|
958
810
|
return n.nodeToSchemaOutput(
|
|
959
|
-
|
|
960
|
-
|
|
811
|
+
r.message,
|
|
812
|
+
he
|
|
961
813
|
);
|
|
962
814
|
}
|
|
963
815
|
return null;
|
|
964
816
|
}
|
|
965
817
|
}
|
|
966
|
-
class
|
|
818
|
+
class _e {
|
|
967
819
|
constructor() {
|
|
968
820
|
l(this, "contractType", "Process Embedded");
|
|
969
821
|
l(this, "role", "adapter");
|
|
970
|
-
l(this, "contractBlueId",
|
|
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
|
|
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(
|
|
832
|
+
dispatchPath: n.resolvePath(r)
|
|
981
833
|
});
|
|
982
834
|
}
|
|
983
835
|
init() {
|
|
984
836
|
return [];
|
|
985
837
|
}
|
|
986
838
|
}
|
|
987
|
-
const
|
|
839
|
+
const X = !process.env.SKIP_ISOLATED_VM;
|
|
988
840
|
let v = null;
|
|
989
|
-
if (
|
|
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
|
|
996
|
-
return /\bimport\s.+\sfrom\s+['"][^'"]+['"]/.test(
|
|
847
|
+
function J(c) {
|
|
848
|
+
return /\bimport\s.+\sfrom\s+['"][^'"]+['"]/.test(c) || /\bexport\s+/.test(c);
|
|
997
849
|
}
|
|
998
|
-
class
|
|
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 || !
|
|
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 (
|
|
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
|
|
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
|
|
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
|
|
1048
|
-
a,
|
|
899
|
+
const i = /* @__PURE__ */ new Map(), u = this.createModuleResolver(
|
|
1049
900
|
r,
|
|
1050
|
-
|
|
901
|
+
a,
|
|
902
|
+
i,
|
|
1051
903
|
n
|
|
1052
904
|
);
|
|
1053
|
-
return
|
|
1054
|
-
a,
|
|
905
|
+
return J(e) ? await this.evaluateESModule(
|
|
1055
906
|
r,
|
|
907
|
+
a,
|
|
1056
908
|
e,
|
|
1057
909
|
o,
|
|
1058
|
-
|
|
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 (
|
|
1067
|
-
throw o.isCodeBlock ? new
|
|
918
|
+
} catch (i) {
|
|
919
|
+
throw o.isCodeBlock ? new D(e, i) : new x(e, i);
|
|
1068
920
|
} finally {
|
|
1069
|
-
|
|
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,
|
|
1082
|
-
typeof
|
|
933
|
+
for (const [o, r] of Object.entries(t))
|
|
934
|
+
typeof r == "function" ? await e.set(
|
|
1083
935
|
o,
|
|
1084
|
-
new v.Callback(
|
|
1085
|
-
) : await e.set(o, new v.ExternalCopy(
|
|
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 (
|
|
1092
|
-
if (n.has(
|
|
1093
|
-
if (
|
|
1094
|
-
const
|
|
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 ${
|
|
949
|
+
`ProcessingContext is missing a loadBlueContent(blueId) implementation (needed for ${r})`
|
|
1098
950
|
);
|
|
1099
|
-
const
|
|
1100
|
-
return n.set(
|
|
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
|
-
),
|
|
955
|
+
), u;
|
|
1104
956
|
}
|
|
1105
|
-
if (/^https?:\/\//.test(
|
|
1106
|
-
let
|
|
957
|
+
if (/^https?:\/\//.test(r)) {
|
|
958
|
+
let a;
|
|
1107
959
|
if (typeof o.loadExternalModule == "function")
|
|
1108
|
-
|
|
960
|
+
a = await o.loadExternalModule(r);
|
|
1109
961
|
else
|
|
1110
962
|
throw new Error(
|
|
1111
|
-
`ProcessingContext is missing a loadExternalModule(url) implementation (needed for ${
|
|
963
|
+
`ProcessingContext is missing a loadExternalModule(url) implementation (needed for ${r})`
|
|
1112
964
|
);
|
|
1113
|
-
const s = await e.compileModule(
|
|
1114
|
-
return n.set(
|
|
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 "${
|
|
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,
|
|
1126
|
-
const
|
|
1127
|
-
return await (await e.compileScript(
|
|
1128
|
-
timeout:
|
|
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,
|
|
1138
|
-
let
|
|
989
|
+
static async evaluateESModule(e, t, n, o, r) {
|
|
990
|
+
let a = n;
|
|
1139
991
|
if (o.isCodeBlock) {
|
|
1140
|
-
const
|
|
992
|
+
const u = /^\s*(import\s.+?;|export\s.+?;)/gm, h = (n.match(u) || []).join(
|
|
1141
993
|
`
|
|
1142
994
|
`
|
|
1143
|
-
),
|
|
1144
|
-
|
|
1145
|
-
${
|
|
995
|
+
), d = n.replace(u, "").trim();
|
|
996
|
+
a = `
|
|
997
|
+
${h}
|
|
1146
998
|
const run = function() {
|
|
1147
|
-
${
|
|
999
|
+
${d}
|
|
1148
1000
|
};
|
|
1149
1001
|
export default run();
|
|
1150
1002
|
`;
|
|
1151
1003
|
}
|
|
1152
|
-
const s = await e.compileModule(
|
|
1153
|
-
return await s.instantiate(t,
|
|
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
|
|
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: (
|
|
1174
|
-
const
|
|
1175
|
-
return
|
|
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
|
|
1034
|
+
class Je {
|
|
1183
1035
|
constructor() {
|
|
1184
1036
|
l(this, "stepType", "Update Document");
|
|
1185
1037
|
}
|
|
1186
1038
|
supports(e) {
|
|
1187
|
-
return
|
|
1039
|
+
return E.isTypeOf(e, k);
|
|
1188
1040
|
}
|
|
1189
1041
|
async evaluateChangeValue(e, t, n, o) {
|
|
1190
|
-
const
|
|
1191
|
-
if (typeof
|
|
1192
|
-
const
|
|
1193
|
-
return await
|
|
1194
|
-
code:
|
|
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:
|
|
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,
|
|
1206
|
-
if (!
|
|
1207
|
-
const
|
|
1208
|
-
for (const s of
|
|
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
|
|
1063
|
+
const i = await this.evaluateChangeValue(
|
|
1212
1064
|
s.val,
|
|
1213
1065
|
n,
|
|
1214
1066
|
t,
|
|
1215
|
-
|
|
1067
|
+
r
|
|
1216
1068
|
);
|
|
1217
1069
|
n.addPatch({
|
|
1218
1070
|
op: s.op,
|
|
1219
1071
|
path: s.path,
|
|
1220
|
-
val:
|
|
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:
|
|
1078
|
+
val: i
|
|
1227
1079
|
}
|
|
1228
1080
|
});
|
|
1229
1081
|
}
|
|
@@ -1238,69 +1090,71 @@ class _e {
|
|
|
1238
1090
|
}
|
|
1239
1091
|
}
|
|
1240
1092
|
}
|
|
1241
|
-
class
|
|
1093
|
+
class Re {
|
|
1242
1094
|
constructor() {
|
|
1243
1095
|
l(this, "stepType", "Trigger Event");
|
|
1244
1096
|
}
|
|
1245
1097
|
supports(e) {
|
|
1246
|
-
return
|
|
1098
|
+
return E.isTypeOf(e, N);
|
|
1247
1099
|
}
|
|
1248
1100
|
async execute(e, t, n) {
|
|
1249
1101
|
const o = n.getBlue();
|
|
1250
|
-
if (!
|
|
1251
|
-
const
|
|
1252
|
-
|
|
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:
|
|
1110
|
+
payload: a
|
|
1257
1111
|
});
|
|
1258
1112
|
}
|
|
1259
1113
|
}
|
|
1260
|
-
class
|
|
1114
|
+
class Ve {
|
|
1261
1115
|
constructor() {
|
|
1262
1116
|
l(this, "stepType", "JavaScript Code");
|
|
1263
1117
|
}
|
|
1264
1118
|
supports(e) {
|
|
1265
|
-
return
|
|
1119
|
+
return E.isTypeOf(e, O);
|
|
1266
1120
|
}
|
|
1267
|
-
async execute(e, t, n, o,
|
|
1268
|
-
if (!
|
|
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
|
-
|
|
1125
|
+
O
|
|
1272
1126
|
);
|
|
1273
1127
|
if (!s.code)
|
|
1274
1128
|
throw new Error("JavaScript code is required");
|
|
1275
|
-
const
|
|
1129
|
+
const i = await G.evaluate({
|
|
1276
1130
|
code: s.code,
|
|
1277
1131
|
ctx: n,
|
|
1278
|
-
bindings:
|
|
1132
|
+
bindings: Y.createStandardBindings(n, t, r),
|
|
1279
1133
|
options: {
|
|
1280
1134
|
isCodeBlock: !0,
|
|
1281
1135
|
timeout: 500
|
|
1282
1136
|
}
|
|
1283
1137
|
});
|
|
1284
|
-
if (
|
|
1285
|
-
const
|
|
1286
|
-
if (Array.isArray(
|
|
1287
|
-
for (const
|
|
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:
|
|
1143
|
+
payload: h
|
|
1290
1144
|
});
|
|
1291
1145
|
}
|
|
1292
|
-
return
|
|
1146
|
+
return i;
|
|
1293
1147
|
}
|
|
1294
1148
|
}
|
|
1295
|
-
const
|
|
1296
|
-
new
|
|
1297
|
-
new
|
|
1298
|
-
new
|
|
1149
|
+
const Le = [
|
|
1150
|
+
new Je(),
|
|
1151
|
+
new Re(),
|
|
1152
|
+
new Ve()
|
|
1299
1153
|
];
|
|
1300
|
-
class
|
|
1301
|
-
constructor(e =
|
|
1154
|
+
class Z {
|
|
1155
|
+
constructor(e = Le) {
|
|
1302
1156
|
l(this, "contractType", "Sequential Workflow");
|
|
1303
|
-
l(this, "contractBlueId",
|
|
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
|
|
1167
|
+
const a = n.getBlue().nodeToSchemaOutput(
|
|
1314
1168
|
t,
|
|
1315
|
-
|
|
1169
|
+
de
|
|
1316
1170
|
).channel;
|
|
1317
|
-
return e.source === "channel" && e.channelName ===
|
|
1171
|
+
return e.source === "channel" && e.channelName === a;
|
|
1318
1172
|
}
|
|
1319
1173
|
async handle(e, t, n, o) {
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
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
|
-
|
|
1185
|
+
r
|
|
1334
1186
|
);
|
|
1335
|
-
if (
|
|
1336
|
-
const
|
|
1337
|
-
|
|
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
|
|
1198
|
+
class He {
|
|
1347
1199
|
constructor(e) {
|
|
1348
1200
|
l(this, "contractType", "Sequential Workflow Operation");
|
|
1349
|
-
l(this, "contractBlueId",
|
|
1201
|
+
l(this, "contractBlueId", g["Sequential Workflow Operation"]);
|
|
1350
1202
|
l(this, "role", "handler");
|
|
1351
1203
|
l(this, "sequentialWorkflowProcessor");
|
|
1352
|
-
this.sequentialWorkflowProcessor = e || new
|
|
1204
|
+
this.sequentialWorkflowProcessor = e || new Z();
|
|
1353
1205
|
}
|
|
1354
1206
|
supports(e, t, n) {
|
|
1355
|
-
const
|
|
1207
|
+
const a = n.getBlue().nodeToSchemaOutput(
|
|
1356
1208
|
t,
|
|
1357
|
-
|
|
1209
|
+
pe
|
|
1358
1210
|
).operation, s = e.channelName;
|
|
1359
|
-
return e.source === "channel" &&
|
|
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 (
|
|
1216
|
+
} catch (r) {
|
|
1365
1217
|
throw console.error(
|
|
1366
1218
|
"Error in SequentialWorkflowOperationProcessor.handle:",
|
|
1367
|
-
|
|
1368
|
-
),
|
|
1219
|
+
r
|
|
1220
|
+
), r;
|
|
1369
1221
|
}
|
|
1370
1222
|
}
|
|
1371
1223
|
}
|
|
1372
|
-
const
|
|
1373
|
-
class
|
|
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",
|
|
1229
|
+
l(this, "contractBlueId", g["Timeline Channel"]);
|
|
1378
1230
|
}
|
|
1379
1231
|
supports(t, n, o) {
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
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:
|
|
1243
|
+
channelName: r,
|
|
1391
1244
|
source: "channel"
|
|
1392
1245
|
});
|
|
1393
1246
|
}
|
|
1394
1247
|
}
|
|
1395
|
-
const
|
|
1396
|
-
new
|
|
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
|
|
1407
|
-
new
|
|
1259
|
+
new Z(),
|
|
1260
|
+
new He()
|
|
1408
1261
|
];
|
|
1409
|
-
class
|
|
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 =
|
|
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
|
|
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
|
|
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 =
|
|
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 =
|
|
1316
|
+
let n = F(e, this.blue);
|
|
1464
1317
|
const o = [];
|
|
1465
|
-
for (const
|
|
1318
|
+
for (const r of t)
|
|
1466
1319
|
try {
|
|
1467
|
-
const
|
|
1468
|
-
await this.router.route(n, [],
|
|
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
|
|
1472
|
-
|
|
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
|
|
1487
|
-
|
|
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
|
|
1348
|
+
var a;
|
|
1496
1349
|
let t = e;
|
|
1497
1350
|
const n = [], o = 1e4;
|
|
1498
|
-
let
|
|
1351
|
+
let r = 0;
|
|
1499
1352
|
for (; this.queue.length; ) {
|
|
1500
|
-
if (++
|
|
1353
|
+
if (++r > o)
|
|
1501
1354
|
throw new Error("Possible cycle – too many iterations");
|
|
1502
|
-
const s = this.queue.pop(), { nodePath:
|
|
1503
|
-
if (!
|
|
1504
|
-
const
|
|
1505
|
-
if (!
|
|
1506
|
-
console.warn(`No processor registered for contract: ${
|
|
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
|
|
1362
|
+
const w = new Q(
|
|
1510
1363
|
() => t,
|
|
1511
1364
|
s,
|
|
1512
1365
|
this.blue,
|
|
1513
1366
|
async (b) => {
|
|
1514
|
-
for (const
|
|
1515
|
-
if (
|
|
1516
|
-
const
|
|
1517
|
-
for (const
|
|
1518
|
-
const
|
|
1519
|
-
(
|
|
1520
|
-
),
|
|
1521
|
-
|
|
1522
|
-
|
|
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 (
|
|
1525
|
-
throw new
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1377
|
+
if (ne && !oe)
|
|
1378
|
+
throw new z(
|
|
1379
|
+
y.patch,
|
|
1380
|
+
S.absPath,
|
|
1381
|
+
$
|
|
1529
1382
|
);
|
|
1530
1383
|
}
|
|
1531
1384
|
try {
|
|
1532
|
-
t =
|
|
1533
|
-
} catch (
|
|
1534
|
-
throw
|
|
1385
|
+
t = j(t, [y.patch]);
|
|
1386
|
+
} catch (S) {
|
|
1387
|
+
throw qe(u, d, S), S;
|
|
1535
1388
|
}
|
|
1536
|
-
} else
|
|
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
|
|
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
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
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
|
};
|