@blue-labs/document-processor 1.21.1 → 1.23.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/BlueDocumentProcessor.d.ts +2 -6
- package/dist/BlueDocumentProcessor.d.ts.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/index.js +5 -5
- package/dist/index.mjs +483 -533
- package/dist/mocks/blueIds.d.ts +5 -0
- package/dist/mocks/blueIds.d.ts.map +1 -0
- package/dist/processors/BaseChannelProcessor.d.ts +0 -5
- package/dist/processors/BaseChannelProcessor.d.ts.map +1 -1
- package/dist/processors/ChannelEventCheckpointProcessor.d.ts +1 -2
- package/dist/processors/ChannelEventCheckpointProcessor.d.ts.map +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/InitializedMarkerProcessor.d.ts +9 -0
- package/dist/processors/InitializedMarkerProcessor.d.ts.map +1 -0
- package/dist/processors/LifecycleEventChannelProcessor.d.ts +33 -0
- package/dist/processors/LifecycleEventChannelProcessor.d.ts.map +1 -0
- 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 -2
- package/dist/processors/OperationProcessor.d.ts.map +1 -1
- package/dist/processors/ProcessEmbeddedProcessor.d.ts +1 -2
- package/dist/processors/ProcessEmbeddedProcessor.d.ts.map +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 -2
- package/dist/processors/SequentialWorkflowProcessor/SequentialWorkflowProcessor.d.ts.map +1 -1
- package/dist/processors/SequentialWorkflowProcessor/steps/TriggerEventExecutor.d.ts.map +1 -1
- package/dist/processors/SequentialWorkflowProcessor/steps/UpdateDocumentExecutor.d.ts +2 -1
- package/dist/processors/SequentialWorkflowProcessor/steps/UpdateDocumentExecutor.d.ts.map +1 -1
- package/dist/processors/TimelineChannelProcessor.d.ts +1 -1
- package/dist/processors/TimelineChannelProcessor.d.ts.map +1 -1
- package/dist/processors/index.d.ts +2 -0
- package/dist/processors/index.d.ts.map +1 -1
- package/dist/routing/EventRouter.d.ts.map +1 -1
- package/dist/types.d.ts +1 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/checkpoint.d.ts.map +1 -1
- package/dist/utils/eventFactories.d.ts +37 -0
- package/dist/utils/eventFactories.d.ts.map +1 -0
- package/dist/utils/initialized.d.ts +4 -0
- package/dist/utils/initialized.d.ts.map +1 -0
- package/package.json +5 -6
- 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 le = Object.defineProperty;
|
|
2
|
+
var ue = (c, e, t) => e in c ? le(c, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : c[e] = t;
|
|
3
|
+
var l = (c, e, t) => ue(c, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { ProcessEmbeddedSchema as $, ChannelEventCheckpointSchema as he, blueIds as g, CompositeTimelineChannelSchema as de, DocumentUpdateChannelSchema as pe, EmbeddedNodeChannelSchema as x, OperationSchema as me, TimelineEntrySchema as q, OperationRequestSchema as fe, UpdateDocumentSchema as B, TriggerEventSchema as O, JavaScriptCodeSchema as M, SequentialWorkflowSchema as ye, SequentialWorkflowOperationSchema as ge, TimelineChannelSchema as Ee } from "@blue-repository/core-dev";
|
|
5
|
+
import { applyBlueNodePatch as K, BlueNodeTypeSchema as E, BlueNode as ve, isBigNumber as X } from "@blue-labs/language";
|
|
6
|
+
import { deepFreeze as I, isNonNullable as N, deepContains as Y } from "@blue-labs/shared-utils";
|
|
7
|
+
import { blueIds as Z, MyOSTimelineEntrySchema as we, MyOSTimelineChannelSchema as Te, MyOSAgentEventSchema as Pe, MyOSAgentChannelSchema as be } from "@blue-repository/myos-dev";
|
|
8
|
+
const Ce = (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
|
+
Ce().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 G {
|
|
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,188 +68,74 @@ 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 ee 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 te 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 V 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 L 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
|
-
"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() ?? {};
|
|
99
|
+
function j(c, e, t = "/", n = []) {
|
|
100
|
+
const o = c.getContracts() ?? {};
|
|
214
101
|
for (const [a, r] of Object.entries(o))
|
|
215
|
-
if (
|
|
102
|
+
if (E.isTypeOf(
|
|
216
103
|
r,
|
|
217
104
|
$
|
|
218
105
|
)) {
|
|
219
|
-
const
|
|
106
|
+
const u = e.nodeToSchemaOutput(
|
|
220
107
|
r,
|
|
221
108
|
$
|
|
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/${a}`)
|
|
227
114
|
});
|
|
228
115
|
}
|
|
229
|
-
for (const [a, r] of Object.entries(
|
|
230
|
-
|
|
116
|
+
for (const [a, r] of Object.entries(c.getProperties() ?? {}))
|
|
117
|
+
j(r, e, T(t, a), n);
|
|
231
118
|
return n;
|
|
232
119
|
}
|
|
233
|
-
function F(
|
|
234
|
-
return
|
|
120
|
+
function F(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 = K(t, n, !0);
|
|
242
129
|
} catch (o) {
|
|
243
|
-
throw new
|
|
130
|
+
throw new ee(n, o);
|
|
244
131
|
}
|
|
245
|
-
return
|
|
132
|
+
return I(t);
|
|
246
133
|
}
|
|
247
|
-
function
|
|
248
|
-
return
|
|
134
|
+
function f(c) {
|
|
135
|
+
return c != null;
|
|
249
136
|
}
|
|
250
|
-
function
|
|
251
|
-
return
|
|
137
|
+
function b(c) {
|
|
138
|
+
return c instanceof ve;
|
|
252
139
|
}
|
|
253
140
|
class ke {
|
|
254
141
|
constructor(e = [], t = (n, o) => n < o ? -1 : n > o ? 1 : 0) {
|
|
@@ -289,28 +176,28 @@ class ke {
|
|
|
289
176
|
t[e] = a;
|
|
290
177
|
}
|
|
291
178
|
}
|
|
292
|
-
const
|
|
293
|
-
-
|
|
179
|
+
const Ie = (c, e, t, n, o, a) => [
|
|
180
|
+
-c,
|
|
294
181
|
e,
|
|
295
182
|
t,
|
|
296
183
|
n,
|
|
297
184
|
o,
|
|
298
185
|
a
|
|
299
|
-
],
|
|
300
|
-
for (let t = 0; t <
|
|
301
|
-
const n =
|
|
186
|
+
], Ne = (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 Be {
|
|
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([],
|
|
200
|
+
this.queue = new ke([], Ne);
|
|
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 Me {
|
|
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 $e = 64;
|
|
348
|
+
class qe {
|
|
462
349
|
/**
|
|
463
350
|
* Creates a new event router
|
|
464
351
|
*
|
|
@@ -469,7 +356,7 @@ class Ie {
|
|
|
469
356
|
*/
|
|
470
357
|
constructor(e, t, n, o, a) {
|
|
471
358
|
l(this, "traceManager");
|
|
472
|
-
this.blue = e, this.registry = t, this.queue = n, this.getNextTaskId = o, this.getNextEventSeq = a, this.traceManager = new
|
|
359
|
+
this.blue = e, this.registry = t, this.queue = n, this.getNextTaskId = o, this.getNextEventSeq = a, this.traceManager = new Me();
|
|
473
360
|
}
|
|
474
361
|
/**
|
|
475
362
|
* Routes an event to matching contracts in the document
|
|
@@ -481,19 +368,19 @@ class Ie {
|
|
|
481
368
|
* @param inlineDepth - Current adapter recursion depth
|
|
482
369
|
*/
|
|
483
370
|
async route(e, t, n, o, a = 0) {
|
|
484
|
-
var
|
|
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, a);
|
|
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, a);
|
|
493
380
|
}
|
|
494
381
|
}
|
|
495
|
-
const r =
|
|
496
|
-
|
|
382
|
+
const r = T("/", t.join("/")), s = e.get(r);
|
|
383
|
+
b(s) && await this.traverseContracts({
|
|
497
384
|
doc: e,
|
|
498
385
|
node: s,
|
|
499
386
|
nodePath: r,
|
|
@@ -514,42 +401,42 @@ class Ie {
|
|
|
514
401
|
event: a,
|
|
515
402
|
afterTaskId: r,
|
|
516
403
|
pathSegments: s,
|
|
517
|
-
inlineDepth:
|
|
404
|
+
inlineDepth: i
|
|
518
405
|
} = e;
|
|
519
406
|
if (!this.shouldSkipForChannel(a, o))
|
|
520
|
-
for (const [
|
|
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:
|
|
418
|
+
contractName: u,
|
|
419
|
+
contractNode: h,
|
|
533
420
|
event: a
|
|
534
|
-
},
|
|
535
|
-
if (
|
|
536
|
-
switch (
|
|
421
|
+
}, m = new G(() => t, p, this.blue);
|
|
422
|
+
if (d.supports(a, h, m, u))
|
|
423
|
+
switch (d.role) {
|
|
537
424
|
case "adapter":
|
|
538
425
|
await this.processAdapter({
|
|
539
|
-
cp:
|
|
426
|
+
cp: d,
|
|
540
427
|
event: a,
|
|
541
|
-
contractNode:
|
|
542
|
-
ctx:
|
|
543
|
-
contractName:
|
|
428
|
+
contractNode: h,
|
|
429
|
+
ctx: m,
|
|
430
|
+
contractName: u,
|
|
544
431
|
doc: t,
|
|
545
432
|
afterTaskId: r,
|
|
546
|
-
inlineDepth:
|
|
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
441
|
event: a,
|
|
555
442
|
depth: s.length,
|
|
@@ -563,7 +450,7 @@ class Ie {
|
|
|
563
450
|
* Processes an adapter contract and routes any emitted events
|
|
564
451
|
*/
|
|
565
452
|
async processAdapter(e) {
|
|
566
|
-
var
|
|
453
|
+
var v;
|
|
567
454
|
const {
|
|
568
455
|
cp: t,
|
|
569
456
|
event: n,
|
|
@@ -571,49 +458,49 @@ class Ie {
|
|
|
571
458
|
ctx: a,
|
|
572
459
|
contractName: r,
|
|
573
460
|
doc: s,
|
|
574
|
-
afterTaskId:
|
|
575
|
-
inlineDepth:
|
|
461
|
+
afterTaskId: i,
|
|
462
|
+
inlineDepth: u
|
|
576
463
|
} = e;
|
|
577
|
-
if (
|
|
464
|
+
if (u >= $e)
|
|
578
465
|
throw new Error("Adapter recursion limit reached");
|
|
579
|
-
const
|
|
466
|
+
const h = this.traceManager.addHop(
|
|
580
467
|
n,
|
|
581
|
-
((
|
|
468
|
+
((v = a.getTaskInfo()) == null ? void 0 : v.nodePath) ?? "",
|
|
582
469
|
r
|
|
583
470
|
);
|
|
584
|
-
await t.handle(
|
|
585
|
-
const
|
|
586
|
-
if (
|
|
471
|
+
await t.handle(h, o, a, r);
|
|
472
|
+
const d = await a.flush();
|
|
473
|
+
if (d.find((P) => P.kind === "patch"))
|
|
587
474
|
throw new Error(
|
|
588
475
|
`Contract "${r}" (adapter) attempted to patch the document`
|
|
589
476
|
);
|
|
590
|
-
const
|
|
591
|
-
for (const
|
|
592
|
-
await this.route(s, [],
|
|
477
|
+
const m = d.filter((P) => P.kind === "event");
|
|
478
|
+
for (const P of m)
|
|
479
|
+
await this.route(s, [], P.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,
|
|
599
|
-
if (!
|
|
485
|
+
const { contractNode: t, contractName: n, nodePath: o, event: a, depth: r, 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
|
|
490
|
+
const u = this.registry.orderOf(i), h = t.get("/order"), d = X(h) ? h.toNumber() : 0, p = this.getNextTaskId() + s, m = Ie(
|
|
604
491
|
r,
|
|
605
492
|
a.seq,
|
|
606
|
-
|
|
607
|
-
|
|
493
|
+
u,
|
|
494
|
+
d,
|
|
608
495
|
n,
|
|
609
|
-
|
|
610
|
-
),
|
|
496
|
+
p
|
|
497
|
+
), v = this.traceManager.addHop(a, o, n);
|
|
611
498
|
this.queue.push({
|
|
612
|
-
key:
|
|
499
|
+
key: m,
|
|
613
500
|
nodePath: o,
|
|
614
501
|
contractName: n,
|
|
615
502
|
contractNode: t,
|
|
616
|
-
event:
|
|
503
|
+
event: v
|
|
617
504
|
});
|
|
618
505
|
}
|
|
619
506
|
/**
|
|
@@ -623,39 +510,60 @@ 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 Ae = (c, e, t) => {
|
|
514
|
+
(t instanceof ee || t instanceof te) && 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
|
-
if (!x(o)) return;
|
|
519
|
+
function _(c, e) {
|
|
520
|
+
const t = c.clone(), n = (o) => {
|
|
521
|
+
if (!b(o)) return;
|
|
636
522
|
const a = o.getContracts();
|
|
637
|
-
|
|
523
|
+
(!(a != null && a.checkpoint) || !E.isTypeOf(
|
|
524
|
+
a.checkpoint,
|
|
525
|
+
he
|
|
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
|
|
538
|
+
for (const { absPath: o } of j(t, e)) {
|
|
650
539
|
const a = t.get(o);
|
|
651
|
-
|
|
540
|
+
b(a) && n(a);
|
|
652
541
|
}
|
|
653
|
-
return
|
|
542
|
+
return I(t);
|
|
654
543
|
}
|
|
655
|
-
|
|
544
|
+
const k = {
|
|
545
|
+
"Lifecycle Event Channel": "LifecycleEventChannelPlaceholderId1234567890ABC",
|
|
546
|
+
"Initialized Marker": "InitializedMarkerPlaceholderId1234567890ABC"
|
|
547
|
+
};
|
|
548
|
+
function De(c, e) {
|
|
549
|
+
const t = c.clone();
|
|
550
|
+
if (!b(t))
|
|
551
|
+
return I(t);
|
|
552
|
+
const n = t.getContracts();
|
|
553
|
+
return n != null && n.initialized || t.addContract(
|
|
554
|
+
"initialized",
|
|
555
|
+
e.jsonValueToNode({
|
|
556
|
+
type: {
|
|
557
|
+
name: "Initialized Marker",
|
|
558
|
+
blueId: k["Initialized Marker"]
|
|
559
|
+
}
|
|
560
|
+
})
|
|
561
|
+
), I(t);
|
|
562
|
+
}
|
|
563
|
+
class je {
|
|
656
564
|
constructor(e) {
|
|
657
565
|
l(this, "contractType", "Channel Event Checkpoint");
|
|
658
|
-
l(this, "contractBlueId",
|
|
566
|
+
l(this, "contractBlueId", g["Channel Event Checkpoint"]);
|
|
659
567
|
l(this, "role", "handler");
|
|
660
568
|
this.cache = e;
|
|
661
569
|
}
|
|
@@ -669,12 +577,9 @@ class qe {
|
|
|
669
577
|
const o = await n.getBlue().calculateBlueId(e.rootEvent.payload), a = n.getNodePath().replace(/\/contracts\/checkpoint$/, "");
|
|
670
578
|
this.cache.record(a, e, o);
|
|
671
579
|
}
|
|
672
|
-
init() {
|
|
673
|
-
return [];
|
|
674
|
-
}
|
|
675
580
|
}
|
|
676
|
-
const
|
|
677
|
-
class
|
|
581
|
+
const z = (c, e) => c.get(e) !== void 0;
|
|
582
|
+
class We {
|
|
678
583
|
constructor() {
|
|
679
584
|
l(this, "firstSeen", /* @__PURE__ */ new Map());
|
|
680
585
|
}
|
|
@@ -687,13 +592,13 @@ class Ae {
|
|
|
687
592
|
const t = [];
|
|
688
593
|
for (const { docBase: n, event: o, eventBlueId: a } of this.firstSeen.values()) {
|
|
689
594
|
if (!o.channelName) continue;
|
|
690
|
-
const r =
|
|
595
|
+
const r = T(
|
|
691
596
|
n,
|
|
692
597
|
"contracts/checkpoint/lastEvents",
|
|
693
598
|
o.channelName
|
|
694
599
|
), s = `${r}/blueId`;
|
|
695
|
-
|
|
696
|
-
op:
|
|
600
|
+
z(e, r) ? t.push({
|
|
601
|
+
op: z(e, s) ? "replace" : "add",
|
|
697
602
|
path: s,
|
|
698
603
|
val: a
|
|
699
604
|
}) : t.push({
|
|
@@ -708,7 +613,7 @@ class Ae {
|
|
|
708
613
|
this.firstSeen.clear();
|
|
709
614
|
}
|
|
710
615
|
}
|
|
711
|
-
class
|
|
616
|
+
class C {
|
|
712
617
|
constructor() {
|
|
713
618
|
l(this, "role", "adapter");
|
|
714
619
|
}
|
|
@@ -719,22 +624,15 @@ class B {
|
|
|
719
624
|
baseSupports(e) {
|
|
720
625
|
return e.source !== "channel";
|
|
721
626
|
}
|
|
722
|
-
/**
|
|
723
|
-
* Base implementation that returns empty array
|
|
724
|
-
* Can be overridden by derived classes if needed
|
|
725
|
-
*/
|
|
726
|
-
init() {
|
|
727
|
-
return [];
|
|
728
|
-
}
|
|
729
627
|
}
|
|
730
|
-
class
|
|
628
|
+
class xe extends C {
|
|
731
629
|
constructor() {
|
|
732
630
|
super(...arguments);
|
|
733
631
|
l(this, "contractType", "Composite Timeline Channel");
|
|
734
|
-
l(this, "contractBlueId",
|
|
632
|
+
l(this, "contractBlueId", g["Composite Timeline Channel"]);
|
|
735
633
|
}
|
|
736
634
|
supports(t, n, o) {
|
|
737
|
-
const a = o.getBlue().nodeToSchemaOutput(n,
|
|
635
|
+
const a = o.getBlue().nodeToSchemaOutput(n, de);
|
|
738
636
|
return !a.channels || !t.channelName ? !1 : a.channels.includes(t.channelName);
|
|
739
637
|
}
|
|
740
638
|
handle(t, n, o, a) {
|
|
@@ -745,18 +643,18 @@ class De extends B {
|
|
|
745
643
|
});
|
|
746
644
|
}
|
|
747
645
|
}
|
|
748
|
-
class
|
|
646
|
+
class Ve extends C {
|
|
749
647
|
constructor() {
|
|
750
648
|
super(...arguments);
|
|
751
649
|
l(this, "contractType", "Document Update Channel");
|
|
752
|
-
l(this, "contractBlueId",
|
|
650
|
+
l(this, "contractBlueId", g["Document Update Channel"]);
|
|
753
651
|
}
|
|
754
652
|
supports(t, n, o, a) {
|
|
755
653
|
if (!this.baseSupports(t)) return !1;
|
|
756
|
-
const r = o.getBlue().nodeToSchemaOutput(n,
|
|
654
|
+
const r = o.getBlue().nodeToSchemaOutput(n, pe), s = t.payload.path;
|
|
757
655
|
if (!s || t.channelName === a) return !1;
|
|
758
|
-
const
|
|
759
|
-
return
|
|
656
|
+
const i = r.path;
|
|
657
|
+
return N(i) && s === o.resolvePath(i);
|
|
760
658
|
}
|
|
761
659
|
handle(t, n, o, a) {
|
|
762
660
|
const r = t.payload;
|
|
@@ -767,92 +665,114 @@ class $e extends B {
|
|
|
767
665
|
});
|
|
768
666
|
}
|
|
769
667
|
}
|
|
770
|
-
class
|
|
668
|
+
class Le extends C {
|
|
771
669
|
constructor() {
|
|
772
670
|
super(...arguments);
|
|
773
671
|
l(this, "contractType", "Embedded Node Channel");
|
|
774
|
-
l(this, "contractBlueId",
|
|
672
|
+
l(this, "contractBlueId", g["Embedded Node Channel"]);
|
|
775
673
|
}
|
|
776
674
|
supports(t, n, o) {
|
|
777
675
|
if (!this.baseSupports(t)) return !1;
|
|
778
|
-
const a = o.getBlue().nodeToSchemaOutput(n,
|
|
779
|
-
return
|
|
676
|
+
const a = o.getBlue().nodeToSchemaOutput(n, x);
|
|
677
|
+
return f(t.originNodePath) && f(a.path) && t.originNodePath === o.resolvePath(a.path);
|
|
780
678
|
}
|
|
781
679
|
handle(t, n, o, a) {
|
|
782
|
-
const r = o.getBlue().nodeToSchemaOutput(n,
|
|
783
|
-
|
|
784
|
-
payload:
|
|
680
|
+
const r = o.getBlue().nodeToSchemaOutput(n, x), { originNodePath: s, payload: i } = t;
|
|
681
|
+
f(r.path) && s === o.resolvePath(r.path) && o.emitEvent({
|
|
682
|
+
payload: i,
|
|
785
683
|
channelName: a,
|
|
786
684
|
source: "channel"
|
|
787
685
|
});
|
|
788
686
|
}
|
|
789
687
|
}
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
)(
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
688
|
+
class Fe {
|
|
689
|
+
constructor() {
|
|
690
|
+
l(this, "contractType", "Initialized Marker");
|
|
691
|
+
l(this, "contractBlueId", k["Initialized Marker"]);
|
|
692
|
+
l(this, "role", "marker");
|
|
693
|
+
}
|
|
694
|
+
supports() {
|
|
695
|
+
return !1;
|
|
696
|
+
}
|
|
697
|
+
handle() {
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
const Je = /* @__PURE__ */ new Set([
|
|
701
|
+
"Document Processing Initiated"
|
|
702
|
+
// Add more lifecycle events here as needed
|
|
703
|
+
// 'Document Processing Completed',
|
|
704
|
+
// 'Document Processing Failed',
|
|
705
|
+
]);
|
|
706
|
+
class _e extends C {
|
|
707
|
+
constructor() {
|
|
708
|
+
super(...arguments);
|
|
709
|
+
l(this, "contractType", "Lifecycle Event Channel");
|
|
710
|
+
// TODO: Add proper blueId when available in schema - using placeholder for now
|
|
711
|
+
l(this, "contractBlueId", k["Lifecycle Event Channel"]);
|
|
712
|
+
}
|
|
713
|
+
supports(t, n, o) {
|
|
714
|
+
return !this.baseSupports(t) || !this.isLifecycleEvent(t) ? !1 : this.isEventPatternMatch(t, n, o);
|
|
715
|
+
}
|
|
716
|
+
handle(t, n, o, a) {
|
|
717
|
+
o.emitEvent({
|
|
718
|
+
payload: t.payload,
|
|
719
|
+
channelName: a,
|
|
720
|
+
source: "channel"
|
|
721
|
+
});
|
|
722
|
+
}
|
|
723
|
+
/**
|
|
724
|
+
* Checks if the event is a supported lifecycle event type
|
|
725
|
+
*/
|
|
726
|
+
isLifecycleEvent(t) {
|
|
727
|
+
return Je.has(t.payload.type);
|
|
728
|
+
}
|
|
729
|
+
/**
|
|
730
|
+
* Checks if the event matches the channel's event pattern (if specified)
|
|
731
|
+
*/
|
|
732
|
+
isEventPatternMatch(t, n, o) {
|
|
733
|
+
var r;
|
|
734
|
+
const a = (r = n.getProperties()) == null ? void 0 : r.event;
|
|
735
|
+
if (!a)
|
|
736
|
+
return !0;
|
|
737
|
+
try {
|
|
738
|
+
const s = o.getBlue(), i = s.nodeToJson(
|
|
739
|
+
s.jsonValueToNode(t.payload)
|
|
740
|
+
), u = s.nodeToJson(a);
|
|
741
|
+
return Y(i, u);
|
|
742
|
+
} catch (s) {
|
|
743
|
+
return console.warn("Error during lifecycle event pattern matching:", s), !1;
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
const U = (c) => c.payload.type === "Timeline Entry" || c.payload.type === "MyOS Timeline Entry";
|
|
748
|
+
class ze extends C {
|
|
830
749
|
constructor() {
|
|
831
750
|
super(...arguments);
|
|
832
751
|
l(this, "contractType", "MyOS Timeline Channel");
|
|
833
|
-
l(this, "contractBlueId",
|
|
752
|
+
l(this, "contractBlueId", Z["MyOS Timeline Channel"]);
|
|
834
753
|
}
|
|
835
754
|
supports(t, n, o) {
|
|
836
|
-
|
|
755
|
+
var m;
|
|
756
|
+
if (!this.baseSupports(t) || !U(t)) return !1;
|
|
837
757
|
const a = o.getBlue(), r = a.jsonValueToNode(t.payload), s = a.nodeToSchemaOutput(
|
|
838
758
|
r,
|
|
839
|
-
|
|
840
|
-
),
|
|
841
|
-
return h &&
|
|
759
|
+
we
|
|
760
|
+
), i = o.getBlue().nodeToSchemaOutput(n, Te), u = (m = s.timeline) == null ? void 0 : m.timelineId, h = f(i.timelineId) && f(u), d = f(i.account) && f(s.account), p = f(i.email) && f(s.email);
|
|
761
|
+
return h && u === i.timelineId || d && s.account === i.account || p && s.email === i.email;
|
|
842
762
|
}
|
|
843
763
|
handle(t, n, o, a) {
|
|
844
|
-
|
|
764
|
+
U(t) && o.emitEvent({
|
|
845
765
|
payload: t.payload,
|
|
846
766
|
channelName: a,
|
|
847
767
|
source: "channel"
|
|
848
768
|
});
|
|
849
769
|
}
|
|
850
770
|
}
|
|
851
|
-
class Ue extends
|
|
771
|
+
class Ue extends C {
|
|
852
772
|
constructor() {
|
|
853
773
|
super(...arguments);
|
|
854
774
|
l(this, "contractType", "MyOS Agent Channel");
|
|
855
|
-
l(this, "contractBlueId",
|
|
775
|
+
l(this, "contractBlueId", Z["MyOS Agent Channel"]);
|
|
856
776
|
}
|
|
857
777
|
supports(t, n, o) {
|
|
858
778
|
if (!this.baseSupports(t)) return !1;
|
|
@@ -881,12 +801,12 @@ class Ue extends B {
|
|
|
881
801
|
parseEventAndChannel(t, n, o) {
|
|
882
802
|
const a = o.getBlue(), r = a.jsonValueToNode(t.payload), s = a.nodeToSchemaOutput(
|
|
883
803
|
r,
|
|
884
|
-
|
|
885
|
-
),
|
|
804
|
+
Pe
|
|
805
|
+
), i = a.nodeToSchemaOutput(
|
|
886
806
|
n,
|
|
887
|
-
|
|
807
|
+
be
|
|
888
808
|
);
|
|
889
|
-
return { myosAgentEvent: s, myosAgentChannel:
|
|
809
|
+
return { myosAgentEvent: s, myosAgentChannel: i };
|
|
890
810
|
}
|
|
891
811
|
/**
|
|
892
812
|
* Checks if the agent IDs match between event and channel
|
|
@@ -897,7 +817,7 @@ class Ue extends B {
|
|
|
897
817
|
isAgentMatch(t, n) {
|
|
898
818
|
var r;
|
|
899
819
|
const o = t.agentId, a = (r = n.agent) == null ? void 0 : r.agentId;
|
|
900
|
-
return
|
|
820
|
+
return f(o) && f(a) && o === a;
|
|
901
821
|
}
|
|
902
822
|
/**
|
|
903
823
|
* Checks if the event pattern matches the channel's event filter
|
|
@@ -920,22 +840,22 @@ class Ue extends B {
|
|
|
920
840
|
if (!r)
|
|
921
841
|
return !1;
|
|
922
842
|
try {
|
|
923
|
-
const s = o.getBlue(),
|
|
924
|
-
return
|
|
843
|
+
const s = o.getBlue(), i = s.nodeToJson(r), u = s.nodeToJson(a);
|
|
844
|
+
return Y(i, u);
|
|
925
845
|
} catch (s) {
|
|
926
846
|
return console.warn("Error during event pattern matching:", s), !1;
|
|
927
847
|
}
|
|
928
848
|
}
|
|
929
849
|
}
|
|
930
|
-
class
|
|
850
|
+
class He {
|
|
931
851
|
constructor() {
|
|
932
852
|
l(this, "contractType", "Operation");
|
|
933
|
-
l(this, "contractBlueId",
|
|
853
|
+
l(this, "contractBlueId", g.Operation);
|
|
934
854
|
l(this, "role", "adapter");
|
|
935
855
|
}
|
|
936
856
|
supports(e, t, n, o) {
|
|
937
|
-
const r = n.getBlue().nodeToSchemaOutput(t,
|
|
938
|
-
return
|
|
857
|
+
const r = n.getBlue().nodeToSchemaOutput(t, me), s = this.parseEventPayload(e, n);
|
|
858
|
+
return f(s == null ? void 0 : s.operation) && s.operation === o && e.source === "channel" && e.channelName === r.channel;
|
|
939
859
|
}
|
|
940
860
|
async handle(e, t, n, o) {
|
|
941
861
|
n.emitEvent({
|
|
@@ -944,30 +864,27 @@ class Je {
|
|
|
944
864
|
source: "channel"
|
|
945
865
|
});
|
|
946
866
|
}
|
|
947
|
-
init() {
|
|
948
|
-
return [];
|
|
949
|
-
}
|
|
950
867
|
parseEventPayload(e, t) {
|
|
951
868
|
const n = t.getBlue(), o = n.jsonValueToNode(e.payload);
|
|
952
|
-
if (
|
|
869
|
+
if (E.isTypeOf(o, q)) {
|
|
953
870
|
const a = n.nodeToSchemaOutput(
|
|
954
871
|
o,
|
|
955
|
-
|
|
872
|
+
q
|
|
956
873
|
);
|
|
957
874
|
if (a.message)
|
|
958
875
|
return n.nodeToSchemaOutput(
|
|
959
876
|
a.message,
|
|
960
|
-
|
|
877
|
+
fe
|
|
961
878
|
);
|
|
962
879
|
}
|
|
963
880
|
return null;
|
|
964
881
|
}
|
|
965
882
|
}
|
|
966
|
-
class
|
|
883
|
+
class Re {
|
|
967
884
|
constructor() {
|
|
968
885
|
l(this, "contractType", "Process Embedded");
|
|
969
886
|
l(this, "role", "adapter");
|
|
970
|
-
l(this, "contractBlueId",
|
|
887
|
+
l(this, "contractBlueId", g["Process Embedded"]);
|
|
971
888
|
}
|
|
972
889
|
supports(e) {
|
|
973
890
|
return e.source !== "channel";
|
|
@@ -980,22 +897,19 @@ class Ze {
|
|
|
980
897
|
dispatchPath: n.resolvePath(a)
|
|
981
898
|
});
|
|
982
899
|
}
|
|
983
|
-
init() {
|
|
984
|
-
return [];
|
|
985
|
-
}
|
|
986
900
|
}
|
|
987
901
|
const ne = !process.env.SKIP_ISOLATED_VM;
|
|
988
|
-
let
|
|
902
|
+
let w = null;
|
|
989
903
|
if (ne)
|
|
990
904
|
try {
|
|
991
|
-
|
|
905
|
+
w = require("isolated-vm");
|
|
992
906
|
} catch {
|
|
993
907
|
console.warn("isolated-vm not available, using fallback evaluation method");
|
|
994
908
|
}
|
|
995
|
-
function
|
|
996
|
-
return /\bimport\s.+\sfrom\s+['"][^'"]+['"]/.test(
|
|
909
|
+
function H(c) {
|
|
910
|
+
return /\bimport\s.+\sfrom\s+['"][^'"]+['"]/.test(c) || /\bexport\s+/.test(c);
|
|
997
911
|
}
|
|
998
|
-
class
|
|
912
|
+
class A {
|
|
999
913
|
/**
|
|
1000
914
|
* Main evaluation method - chooses between secure and simple evaluation strategies
|
|
1001
915
|
*/
|
|
@@ -1005,14 +919,14 @@ class oe {
|
|
|
1005
919
|
bindings: n = {},
|
|
1006
920
|
options: o = {}
|
|
1007
921
|
}) {
|
|
1008
|
-
return !
|
|
922
|
+
return !w || !ne ? this.evaluateSimple(e, n, o) : this.evaluateSecure(e, n, t, o);
|
|
1009
923
|
}
|
|
1010
924
|
/**
|
|
1011
925
|
* Fallback evaluation using Node's Function constructor
|
|
1012
926
|
* Used when isolated-vm is not available
|
|
1013
927
|
*/
|
|
1014
928
|
static async evaluateSimple(e, t, n = {}) {
|
|
1015
|
-
if (
|
|
929
|
+
if (H(e))
|
|
1016
930
|
throw new Error(
|
|
1017
931
|
"Static import/export syntax requires isolated-vm – start Node without SKIP_ISOLATED_VM."
|
|
1018
932
|
);
|
|
@@ -1033,29 +947,29 @@ class oe {
|
|
|
1033
947
|
`return ${e};`
|
|
1034
948
|
)(...Object.values(t));
|
|
1035
949
|
} catch (o) {
|
|
1036
|
-
throw n.isCodeBlock ? new
|
|
950
|
+
throw n.isCodeBlock ? new L(e, o) : new V(e, o);
|
|
1037
951
|
}
|
|
1038
952
|
}
|
|
1039
953
|
/**
|
|
1040
954
|
* Secure evaluation using isolated-vm with support for ES modules
|
|
1041
955
|
*/
|
|
1042
956
|
static async evaluateSecure(e, t, n, o = {}) {
|
|
1043
|
-
if (!
|
|
1044
|
-
const a = new
|
|
957
|
+
if (!w) throw new Error("isolated-vm not available");
|
|
958
|
+
const a = new w.Isolate({ memoryLimit: 32 }), r = await a.createContext(), s = r.global;
|
|
1045
959
|
try {
|
|
1046
960
|
await this.setupIsolateEnvironment(s, t);
|
|
1047
|
-
const
|
|
961
|
+
const i = /* @__PURE__ */ new Map(), u = this.createModuleResolver(
|
|
1048
962
|
a,
|
|
1049
963
|
r,
|
|
1050
|
-
|
|
964
|
+
i,
|
|
1051
965
|
n
|
|
1052
966
|
);
|
|
1053
|
-
return
|
|
967
|
+
return H(e) ? await this.evaluateESModule(
|
|
1054
968
|
a,
|
|
1055
969
|
r,
|
|
1056
970
|
e,
|
|
1057
971
|
o,
|
|
1058
|
-
|
|
972
|
+
u
|
|
1059
973
|
) : await this.evaluateSimpleScript(
|
|
1060
974
|
a,
|
|
1061
975
|
r,
|
|
@@ -1063,8 +977,8 @@ class oe {
|
|
|
1063
977
|
t,
|
|
1064
978
|
o
|
|
1065
979
|
);
|
|
1066
|
-
} catch (
|
|
1067
|
-
throw o.isCodeBlock ? new
|
|
980
|
+
} catch (i) {
|
|
981
|
+
throw o.isCodeBlock ? new L(e, i) : new V(e, i);
|
|
1068
982
|
} finally {
|
|
1069
983
|
r.release(), a.dispose();
|
|
1070
984
|
}
|
|
@@ -1073,16 +987,16 @@ class oe {
|
|
|
1073
987
|
* Setup the isolated VM environment with necessary host functions and data
|
|
1074
988
|
*/
|
|
1075
989
|
static async setupIsolateEnvironment(e, t) {
|
|
1076
|
-
if (!
|
|
1077
|
-
const n = new
|
|
990
|
+
if (!w) throw new Error("isolated-vm not available");
|
|
991
|
+
const n = new w.Callback(
|
|
1078
992
|
(...o) => console.log(...o)
|
|
1079
993
|
);
|
|
1080
994
|
await e.set("log", n);
|
|
1081
995
|
for (const [o, a] of Object.entries(t))
|
|
1082
996
|
typeof a == "function" ? await e.set(
|
|
1083
997
|
o,
|
|
1084
|
-
new
|
|
1085
|
-
) : await e.set(o, new
|
|
998
|
+
new w.Callback(a)
|
|
999
|
+
) : await e.set(o, new w.ExternalCopy(a).copyInto());
|
|
1086
1000
|
}
|
|
1087
1001
|
/**
|
|
1088
1002
|
* Create module resolver function for handling imports
|
|
@@ -1096,11 +1010,11 @@ class oe {
|
|
|
1096
1010
|
throw new Error(
|
|
1097
1011
|
`ProcessingContext is missing a loadBlueContent(blueId) implementation (needed for ${a})`
|
|
1098
1012
|
);
|
|
1099
|
-
const
|
|
1100
|
-
return n.set(a,
|
|
1013
|
+
const i = await s(r), u = await e.compileModule(i);
|
|
1014
|
+
return n.set(a, u), await u.instantiate(
|
|
1101
1015
|
t,
|
|
1102
1016
|
this.createModuleResolver(e, t, n, o)
|
|
1103
|
-
),
|
|
1017
|
+
), u;
|
|
1104
1018
|
}
|
|
1105
1019
|
if (/^https?:\/\//.test(a)) {
|
|
1106
1020
|
let r;
|
|
@@ -1123,8 +1037,8 @@ class oe {
|
|
|
1123
1037
|
* Evaluate code as a simple script (no imports/exports)
|
|
1124
1038
|
*/
|
|
1125
1039
|
static async evaluateSimpleScript(e, t, n, o, a) {
|
|
1126
|
-
const r = Object.keys(o).join(", "), s = Object.keys(o).map((
|
|
1127
|
-
return await (await e.compileScript(
|
|
1040
|
+
const r = Object.keys(o).join(", "), s = Object.keys(o).map((h) => h), i = `(async (${r}) => { ${a.isCodeBlock ? n : `return (${n});`} })(${s.join(", ")})`;
|
|
1041
|
+
return await (await e.compileScript(i)).run(t, {
|
|
1128
1042
|
timeout: a.timeout ?? 500,
|
|
1129
1043
|
promise: !0,
|
|
1130
1044
|
copy: !0,
|
|
@@ -1137,14 +1051,14 @@ class oe {
|
|
|
1137
1051
|
static async evaluateESModule(e, t, n, o, a) {
|
|
1138
1052
|
let r = n;
|
|
1139
1053
|
if (o.isCodeBlock) {
|
|
1140
|
-
const
|
|
1054
|
+
const u = /^\s*(import\s.+?;|export\s.+?;)/gm, h = (n.match(u) || []).join(
|
|
1141
1055
|
`
|
|
1142
1056
|
`
|
|
1143
|
-
),
|
|
1057
|
+
), d = n.replace(u, "").trim();
|
|
1144
1058
|
r = `
|
|
1145
|
-
${
|
|
1059
|
+
${h}
|
|
1146
1060
|
const run = function() {
|
|
1147
|
-
${
|
|
1061
|
+
${d}
|
|
1148
1062
|
};
|
|
1149
1063
|
export default run();
|
|
1150
1064
|
`;
|
|
@@ -1163,7 +1077,7 @@ class oe {
|
|
|
1163
1077
|
});
|
|
1164
1078
|
}
|
|
1165
1079
|
}
|
|
1166
|
-
class
|
|
1080
|
+
class D {
|
|
1167
1081
|
/**
|
|
1168
1082
|
* Creates standard bindings for workflow step execution
|
|
1169
1083
|
*/
|
|
@@ -1172,83 +1086,126 @@ class ae {
|
|
|
1172
1086
|
return {
|
|
1173
1087
|
document: (a) => {
|
|
1174
1088
|
const r = e.get(a);
|
|
1175
|
-
return
|
|
1089
|
+
return X(r) ? r.toNumber() : b(r) ? o.nodeToJson(r, "original") : r;
|
|
1176
1090
|
},
|
|
1177
1091
|
event: t.payload,
|
|
1178
1092
|
steps: n
|
|
1179
1093
|
};
|
|
1180
1094
|
}
|
|
1181
1095
|
}
|
|
1182
|
-
|
|
1096
|
+
function R(c) {
|
|
1097
|
+
const { op: e, path: t, val: n, from: o } = c;
|
|
1098
|
+
if ((e === "move" || e === "copy") && !o)
|
|
1099
|
+
throw new Error(`${e} operation requires 'from' path`);
|
|
1100
|
+
if ((e === "add" || e === "replace") && n === void 0)
|
|
1101
|
+
throw new Error(`${e} operation requires 'val' property`);
|
|
1102
|
+
const a = { type: "Document Update", op: e, path: t };
|
|
1103
|
+
return n !== void 0 && (a.val = n), o !== void 0 && (a.from = o), a;
|
|
1104
|
+
}
|
|
1105
|
+
function Qe() {
|
|
1106
|
+
return {
|
|
1107
|
+
type: "Document Processing Initiated"
|
|
1108
|
+
};
|
|
1109
|
+
}
|
|
1110
|
+
class Ke {
|
|
1183
1111
|
constructor() {
|
|
1184
1112
|
l(this, "stepType", "Update Document");
|
|
1185
1113
|
}
|
|
1186
1114
|
supports(e) {
|
|
1187
|
-
return
|
|
1115
|
+
return E.isTypeOf(e, B);
|
|
1116
|
+
}
|
|
1117
|
+
async execute(e, t, n, o, a) {
|
|
1118
|
+
const r = n.getBlue();
|
|
1119
|
+
if (!E.isTypeOf(e, B)) return;
|
|
1120
|
+
const s = await this.evaluateChangeset(
|
|
1121
|
+
e.get("/changeset"),
|
|
1122
|
+
n,
|
|
1123
|
+
t,
|
|
1124
|
+
a
|
|
1125
|
+
), i = K(e, {
|
|
1126
|
+
op: "replace",
|
|
1127
|
+
path: "/changeset",
|
|
1128
|
+
val: s
|
|
1129
|
+
}), u = n.getBlue().nodeToSchemaOutput(i, B);
|
|
1130
|
+
for (const h of u.changeset ?? []) {
|
|
1131
|
+
if (!h.path) continue;
|
|
1132
|
+
const d = h.val;
|
|
1133
|
+
if ((h.op === "replace" || h.op === "add") && N(d)) {
|
|
1134
|
+
const p = await this.evaluateChangeValue(
|
|
1135
|
+
d,
|
|
1136
|
+
n,
|
|
1137
|
+
t,
|
|
1138
|
+
a
|
|
1139
|
+
);
|
|
1140
|
+
n.addPatch({
|
|
1141
|
+
op: h.op,
|
|
1142
|
+
path: h.path,
|
|
1143
|
+
val: p
|
|
1144
|
+
}), n.emitEvent({
|
|
1145
|
+
payload: R({
|
|
1146
|
+
op: h.op,
|
|
1147
|
+
path: n.resolvePath(h.path),
|
|
1148
|
+
val: r.nodeToJson(p, "original")
|
|
1149
|
+
})
|
|
1150
|
+
});
|
|
1151
|
+
}
|
|
1152
|
+
h.op === "remove" && (n.addPatch({ op: h.op, path: h.path }), n.emitEvent({
|
|
1153
|
+
payload: R({
|
|
1154
|
+
op: h.op,
|
|
1155
|
+
path: n.resolvePath(h.path),
|
|
1156
|
+
val: null
|
|
1157
|
+
})
|
|
1158
|
+
}));
|
|
1159
|
+
}
|
|
1160
|
+
}
|
|
1161
|
+
async evaluateChangeset(e, t, n, o) {
|
|
1162
|
+
const a = t.getBlue();
|
|
1163
|
+
if (typeof e == "string" && e.startsWith("${") && e.endsWith("}")) {
|
|
1164
|
+
const r = e.slice(2, -1), s = await A.evaluate({
|
|
1165
|
+
code: r,
|
|
1166
|
+
ctx: t,
|
|
1167
|
+
bindings: D.createStandardBindings(
|
|
1168
|
+
t,
|
|
1169
|
+
n,
|
|
1170
|
+
o
|
|
1171
|
+
)
|
|
1172
|
+
});
|
|
1173
|
+
return a.jsonValueToNode(s ?? null);
|
|
1174
|
+
}
|
|
1175
|
+
if (b(e))
|
|
1176
|
+
return e;
|
|
1177
|
+
throw new Error("Invalid changeset: expected a string or document node");
|
|
1188
1178
|
}
|
|
1189
1179
|
async evaluateChangeValue(e, t, n, o) {
|
|
1190
|
-
const a = e
|
|
1180
|
+
const a = e.getValue(), r = t.getBlue();
|
|
1191
1181
|
if (typeof a == "string" && a.startsWith("${") && a.endsWith("}")) {
|
|
1192
|
-
const
|
|
1193
|
-
|
|
1194
|
-
code: r,
|
|
1182
|
+
const s = a.slice(2, -1), i = await A.evaluate({
|
|
1183
|
+
code: s,
|
|
1195
1184
|
ctx: t,
|
|
1196
|
-
bindings:
|
|
1185
|
+
bindings: D.createStandardBindings(
|
|
1197
1186
|
t,
|
|
1198
1187
|
n,
|
|
1199
1188
|
o
|
|
1200
1189
|
)
|
|
1201
1190
|
});
|
|
1191
|
+
return r.jsonValueToNode(i ?? null);
|
|
1202
1192
|
}
|
|
1203
1193
|
return e;
|
|
1204
1194
|
}
|
|
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 ?? [])
|
|
1209
|
-
if (s.path) {
|
|
1210
|
-
if (s.op === "replace" || s.op === "add") {
|
|
1211
|
-
const c = await this.evaluateChangeValue(
|
|
1212
|
-
s.val,
|
|
1213
|
-
n,
|
|
1214
|
-
t,
|
|
1215
|
-
a
|
|
1216
|
-
);
|
|
1217
|
-
n.addPatch({
|
|
1218
|
-
op: s.op,
|
|
1219
|
-
path: s.path,
|
|
1220
|
-
val: c
|
|
1221
|
-
}), n.emitEvent({
|
|
1222
|
-
payload: {
|
|
1223
|
-
type: "Document Update",
|
|
1224
|
-
op: s.op,
|
|
1225
|
-
path: n.resolvePath(s.path),
|
|
1226
|
-
val: c
|
|
1227
|
-
}
|
|
1228
|
-
});
|
|
1229
|
-
}
|
|
1230
|
-
s.op === "remove" && (n.addPatch({ op: s.op, path: s.path }), n.emitEvent({
|
|
1231
|
-
payload: {
|
|
1232
|
-
type: "Document Update",
|
|
1233
|
-
op: s.op,
|
|
1234
|
-
path: n.resolvePath(s.path),
|
|
1235
|
-
val: null
|
|
1236
|
-
}
|
|
1237
|
-
}));
|
|
1238
|
-
}
|
|
1239
|
-
}
|
|
1240
1195
|
}
|
|
1241
|
-
class
|
|
1196
|
+
class Xe {
|
|
1242
1197
|
constructor() {
|
|
1243
1198
|
l(this, "stepType", "Trigger Event");
|
|
1244
1199
|
}
|
|
1245
1200
|
supports(e) {
|
|
1246
|
-
return
|
|
1201
|
+
return E.isTypeOf(e, O);
|
|
1247
1202
|
}
|
|
1248
1203
|
async execute(e, t, n) {
|
|
1249
1204
|
const o = n.getBlue();
|
|
1250
|
-
if (!
|
|
1251
|
-
const a = o.nodeToSchemaOutput(e,
|
|
1205
|
+
if (!E.isTypeOf(e, O)) return;
|
|
1206
|
+
const a = o.nodeToSchemaOutput(e, O);
|
|
1207
|
+
if (!a.event) return;
|
|
1208
|
+
const r = o.nodeToJson(
|
|
1252
1209
|
a.event,
|
|
1253
1210
|
"original"
|
|
1254
1211
|
);
|
|
@@ -1257,50 +1214,50 @@ class Le {
|
|
|
1257
1214
|
});
|
|
1258
1215
|
}
|
|
1259
1216
|
}
|
|
1260
|
-
class
|
|
1217
|
+
class Ye {
|
|
1261
1218
|
constructor() {
|
|
1262
1219
|
l(this, "stepType", "JavaScript Code");
|
|
1263
1220
|
}
|
|
1264
1221
|
supports(e) {
|
|
1265
|
-
return
|
|
1222
|
+
return E.isTypeOf(e, M);
|
|
1266
1223
|
}
|
|
1267
1224
|
async execute(e, t, n, o, a) {
|
|
1268
|
-
if (!
|
|
1225
|
+
if (!E.isTypeOf(e, M)) return;
|
|
1269
1226
|
const s = n.getBlue().nodeToSchemaOutput(
|
|
1270
1227
|
e,
|
|
1271
1228
|
M
|
|
1272
1229
|
);
|
|
1273
1230
|
if (!s.code)
|
|
1274
1231
|
throw new Error("JavaScript code is required");
|
|
1275
|
-
const
|
|
1232
|
+
const i = await A.evaluate({
|
|
1276
1233
|
code: s.code,
|
|
1277
1234
|
ctx: n,
|
|
1278
|
-
bindings:
|
|
1235
|
+
bindings: D.createStandardBindings(n, t, a),
|
|
1279
1236
|
options: {
|
|
1280
1237
|
isCodeBlock: !0,
|
|
1281
1238
|
timeout: 500
|
|
1282
1239
|
}
|
|
1283
1240
|
});
|
|
1284
|
-
if (
|
|
1285
|
-
const
|
|
1286
|
-
if (Array.isArray(
|
|
1287
|
-
for (const
|
|
1241
|
+
if (i && typeof i == "object" && "events" in i) {
|
|
1242
|
+
const u = i;
|
|
1243
|
+
if (Array.isArray(u.events))
|
|
1244
|
+
for (const h of u.events)
|
|
1288
1245
|
n.emitEvent({
|
|
1289
|
-
payload:
|
|
1246
|
+
payload: h
|
|
1290
1247
|
});
|
|
1291
1248
|
}
|
|
1292
|
-
return
|
|
1249
|
+
return i;
|
|
1293
1250
|
}
|
|
1294
1251
|
}
|
|
1295
|
-
const
|
|
1296
|
-
new
|
|
1297
|
-
new
|
|
1298
|
-
new
|
|
1252
|
+
const Ze = [
|
|
1253
|
+
new Ke(),
|
|
1254
|
+
new Xe(),
|
|
1255
|
+
new Ye()
|
|
1299
1256
|
];
|
|
1300
|
-
class
|
|
1301
|
-
constructor(e =
|
|
1257
|
+
class oe {
|
|
1258
|
+
constructor(e = Ze) {
|
|
1302
1259
|
l(this, "contractType", "Sequential Workflow");
|
|
1303
|
-
l(this, "contractBlueId",
|
|
1260
|
+
l(this, "contractBlueId", g["Sequential Workflow"]);
|
|
1304
1261
|
l(this, "role", "handler");
|
|
1305
1262
|
l(this, "executors", []);
|
|
1306
1263
|
this.executors = e;
|
|
@@ -1312,51 +1269,46 @@ class re {
|
|
|
1312
1269
|
supports(e, t, n) {
|
|
1313
1270
|
const r = n.getBlue().nodeToSchemaOutput(
|
|
1314
1271
|
t,
|
|
1315
|
-
|
|
1272
|
+
ye
|
|
1316
1273
|
).channel;
|
|
1317
1274
|
return e.source === "channel" && e.channelName === r;
|
|
1318
1275
|
}
|
|
1319
1276
|
async handle(e, t, n, o) {
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
const C = await f.execute(
|
|
1329
|
-
d,
|
|
1277
|
+
var s;
|
|
1278
|
+
const a = {}, r = (s = t.getProperties()) == null ? void 0 : s.steps.getItems();
|
|
1279
|
+
for (const [i, u] of (r ?? []).entries()) {
|
|
1280
|
+
const h = this.executors.find((p) => p.supports(u));
|
|
1281
|
+
if (!h)
|
|
1282
|
+
throw new Error(`Unsupported workflow step type "${u.getType()}"`);
|
|
1283
|
+
const d = await h.execute(
|
|
1284
|
+
u,
|
|
1330
1285
|
e,
|
|
1331
1286
|
n,
|
|
1332
1287
|
o,
|
|
1333
|
-
|
|
1288
|
+
a
|
|
1334
1289
|
);
|
|
1335
|
-
if (
|
|
1336
|
-
const
|
|
1337
|
-
|
|
1290
|
+
if (d !== void 0) {
|
|
1291
|
+
const p = u.getName(), m = typeof p == "string" ? p : `Step${i + 1}`;
|
|
1292
|
+
a[m] = d;
|
|
1338
1293
|
}
|
|
1339
1294
|
await n.flush();
|
|
1340
1295
|
}
|
|
1341
1296
|
}
|
|
1342
|
-
init() {
|
|
1343
|
-
return [];
|
|
1344
|
-
}
|
|
1345
1297
|
}
|
|
1346
|
-
class
|
|
1298
|
+
class Ge {
|
|
1347
1299
|
constructor(e) {
|
|
1348
1300
|
l(this, "contractType", "Sequential Workflow Operation");
|
|
1349
|
-
l(this, "contractBlueId",
|
|
1301
|
+
l(this, "contractBlueId", g["Sequential Workflow Operation"]);
|
|
1350
1302
|
l(this, "role", "handler");
|
|
1351
1303
|
l(this, "sequentialWorkflowProcessor");
|
|
1352
|
-
this.sequentialWorkflowProcessor = e || new
|
|
1304
|
+
this.sequentialWorkflowProcessor = e || new oe();
|
|
1353
1305
|
}
|
|
1354
1306
|
supports(e, t, n) {
|
|
1355
1307
|
const r = n.getBlue().nodeToSchemaOutput(
|
|
1356
1308
|
t,
|
|
1357
|
-
|
|
1309
|
+
ge
|
|
1358
1310
|
).operation, s = e.channelName;
|
|
1359
|
-
return e.source === "channel" &&
|
|
1311
|
+
return e.source === "channel" && N(s) && N(r) && s === r;
|
|
1360
1312
|
}
|
|
1361
1313
|
async handle(e, t, n, o) {
|
|
1362
1314
|
try {
|
|
@@ -1369,66 +1321,73 @@ class Xe {
|
|
|
1369
1321
|
}
|
|
1370
1322
|
}
|
|
1371
1323
|
}
|
|
1372
|
-
const
|
|
1373
|
-
class
|
|
1324
|
+
const Q = (c) => c.payload.type === "Timeline Entry";
|
|
1325
|
+
class et extends C {
|
|
1374
1326
|
constructor() {
|
|
1375
1327
|
super(...arguments);
|
|
1376
1328
|
l(this, "contractType", "Timeline Channel");
|
|
1377
|
-
l(this, "contractBlueId",
|
|
1329
|
+
l(this, "contractBlueId", g["Timeline Channel"]);
|
|
1378
1330
|
}
|
|
1379
1331
|
supports(t, n, o) {
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1332
|
+
var h;
|
|
1333
|
+
if (!this.baseSupports(t) || !Q(t)) return !1;
|
|
1334
|
+
const a = o.getBlue(), r = a.nodeToSchemaOutput(
|
|
1335
|
+
a.jsonValueToNode(t.payload),
|
|
1336
|
+
q
|
|
1337
|
+
), s = o.getBlue().nodeToSchemaOutput(n, Ee), i = (h = r.timeline) == null ? void 0 : h.timelineId;
|
|
1338
|
+
return f(s.timelineId) && f(i) && i === s.timelineId;
|
|
1386
1339
|
}
|
|
1387
1340
|
handle(t, n, o, a) {
|
|
1388
|
-
|
|
1341
|
+
Q(t) && o.emitEvent({
|
|
1389
1342
|
payload: t.payload,
|
|
1390
1343
|
channelName: a,
|
|
1391
1344
|
source: "channel"
|
|
1392
1345
|
});
|
|
1393
1346
|
}
|
|
1394
1347
|
}
|
|
1395
|
-
const
|
|
1396
|
-
new
|
|
1348
|
+
const tt = [
|
|
1349
|
+
new Re(),
|
|
1397
1350
|
// channels
|
|
1398
|
-
new
|
|
1399
|
-
new
|
|
1400
|
-
new
|
|
1401
|
-
new
|
|
1351
|
+
new Le(),
|
|
1352
|
+
new Ve(),
|
|
1353
|
+
new et(),
|
|
1354
|
+
new ze(),
|
|
1402
1355
|
new Ue(),
|
|
1403
|
-
new
|
|
1404
|
-
new
|
|
1356
|
+
new xe(),
|
|
1357
|
+
new _e(),
|
|
1358
|
+
new He(),
|
|
1405
1359
|
// sequential workflows
|
|
1406
|
-
new
|
|
1407
|
-
new
|
|
1360
|
+
new oe(),
|
|
1361
|
+
new Ge(),
|
|
1362
|
+
// markers
|
|
1363
|
+
new Fe()
|
|
1408
1364
|
];
|
|
1409
|
-
class
|
|
1365
|
+
class it {
|
|
1410
1366
|
/**
|
|
1411
1367
|
* Creates a new document processor
|
|
1412
1368
|
*
|
|
1413
1369
|
* @param processors - Initial list of processors to register
|
|
1414
1370
|
*/
|
|
1415
|
-
constructor(e, t =
|
|
1371
|
+
constructor(e, t = tt) {
|
|
1416
1372
|
l(this, "taskCounter", 0);
|
|
1417
1373
|
l(this, "eventCounter", 0);
|
|
1418
1374
|
l(this, "registry");
|
|
1419
1375
|
l(this, "queue");
|
|
1420
1376
|
l(this, "router");
|
|
1421
|
-
l(this, "checkpointCache", new
|
|
1422
|
-
this.blue = e, this.registry = new
|
|
1377
|
+
l(this, "checkpointCache", new We());
|
|
1378
|
+
this.blue = e, this.registry = new Oe(t), this.queue = new Be(), this.router = new qe(
|
|
1423
1379
|
this.blue,
|
|
1424
1380
|
this.registry,
|
|
1425
1381
|
this.queue,
|
|
1426
1382
|
() => ++this.taskCounter,
|
|
1427
1383
|
() => ++this.eventCounter
|
|
1428
1384
|
), this.register(
|
|
1429
|
-
new
|
|
1385
|
+
new je(this.checkpointCache),
|
|
1430
1386
|
9999
|
|
1431
|
-
)
|
|
1387
|
+
), this.blue.registerBlueIds({
|
|
1388
|
+
"Lifecycle Event Channel": k["Lifecycle Event Channel"],
|
|
1389
|
+
"Initialized Marker": k["Initialized Marker"]
|
|
1390
|
+
});
|
|
1432
1391
|
}
|
|
1433
1392
|
/**
|
|
1434
1393
|
* Registers a new contract processor
|
|
@@ -1440,17 +1399,19 @@ class rt {
|
|
|
1440
1399
|
this.registry.register(e, t);
|
|
1441
1400
|
}
|
|
1442
1401
|
/**
|
|
1443
|
-
* Initializes a document
|
|
1402
|
+
* Initializes a document by emitting a Document Processing Initiated event
|
|
1444
1403
|
*
|
|
1445
1404
|
* @param document - The document to initialize
|
|
1446
1405
|
* @returns Processing result with final state and emitted events
|
|
1447
1406
|
*/
|
|
1448
|
-
async
|
|
1449
|
-
|
|
1450
|
-
const
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1407
|
+
async initialize(e) {
|
|
1408
|
+
let t = _(e, this.blue);
|
|
1409
|
+
const n = {
|
|
1410
|
+
payload: Qe()
|
|
1411
|
+
}, o = [n.payload];
|
|
1412
|
+
await this.router.route(t, [], n, 0);
|
|
1413
|
+
const a = await this.drainQueue(t);
|
|
1414
|
+
return t = a.state, o.push(...a.emitted), t = De(t, this.blue), { state: t, emitted: o };
|
|
1454
1415
|
}
|
|
1455
1416
|
/**
|
|
1456
1417
|
* Processes a batch of events against the document
|
|
@@ -1460,7 +1421,7 @@ class rt {
|
|
|
1460
1421
|
* @returns Processing result with final state and emitted events
|
|
1461
1422
|
*/
|
|
1462
1423
|
async processEvents(e, t) {
|
|
1463
|
-
let n =
|
|
1424
|
+
let n = _(e, this.blue);
|
|
1464
1425
|
const o = [];
|
|
1465
1426
|
for (const a of t)
|
|
1466
1427
|
try {
|
|
@@ -1468,26 +1429,13 @@ class rt {
|
|
|
1468
1429
|
await this.router.route(n, [], r, 0);
|
|
1469
1430
|
const s = await this.drainQueue(n);
|
|
1470
1431
|
n = s.state, o.push(...s.emitted);
|
|
1471
|
-
const
|
|
1472
|
-
|
|
1432
|
+
const i = this.checkpointCache.flush(n);
|
|
1433
|
+
i.length && (n = J(n, i));
|
|
1473
1434
|
} finally {
|
|
1474
1435
|
this.checkpointCache.clear();
|
|
1475
1436
|
}
|
|
1476
1437
|
return { state: n, emitted: o };
|
|
1477
1438
|
}
|
|
1478
|
-
/**
|
|
1479
|
-
* Collects initialization events from contract processors
|
|
1480
|
-
*/
|
|
1481
|
-
async bootstrapContracts(e) {
|
|
1482
|
-
const t = [], n = e.getContracts();
|
|
1483
|
-
if (!n)
|
|
1484
|
-
return t;
|
|
1485
|
-
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));
|
|
1488
|
-
}
|
|
1489
|
-
return t;
|
|
1490
|
-
}
|
|
1491
1439
|
/**
|
|
1492
1440
|
* Drains the task queue and applies all actions
|
|
1493
1441
|
*/
|
|
@@ -1499,59 +1447,61 @@ class rt {
|
|
|
1499
1447
|
for (; this.queue.length; ) {
|
|
1500
1448
|
if (++a > o)
|
|
1501
1449
|
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: ${
|
|
1450
|
+
const s = this.queue.pop(), { nodePath: i, contractName: u, contractNode: h, event: d } = s, p = t.get(i);
|
|
1451
|
+
if (!b(p) || !((r = p.getContracts()) != null && r[u]) || !h.getType()) continue;
|
|
1452
|
+
const m = this.registry.get(h.getType());
|
|
1453
|
+
if (!m) {
|
|
1454
|
+
console.warn(`No processor registered for contract: ${u}`);
|
|
1507
1455
|
continue;
|
|
1508
1456
|
}
|
|
1509
|
-
const
|
|
1457
|
+
const v = new G(
|
|
1510
1458
|
() => t,
|
|
1511
1459
|
s,
|
|
1512
1460
|
this.blue,
|
|
1513
|
-
async (
|
|
1514
|
-
for (const
|
|
1515
|
-
if (
|
|
1516
|
-
const
|
|
1517
|
-
for (const
|
|
1518
|
-
const
|
|
1519
|
-
(
|
|
1520
|
-
),
|
|
1521
|
-
|
|
1522
|
-
|
|
1461
|
+
async (P) => {
|
|
1462
|
+
for (const y of P)
|
|
1463
|
+
if (y.kind === "patch") {
|
|
1464
|
+
const ae = j(t, this.blue);
|
|
1465
|
+
for (const S of ae) {
|
|
1466
|
+
const re = y.patch.op === "move" || y.patch.op === "copy" ? [y.patch.from, y.patch.path] : [y.patch.path], W = v.getNodePath(), se = re.some(
|
|
1467
|
+
(ie) => F(ie, S.absPath)
|
|
1468
|
+
), ce = F(
|
|
1469
|
+
W,
|
|
1470
|
+
S.absPath
|
|
1523
1471
|
);
|
|
1524
|
-
if (
|
|
1525
|
-
throw new
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1472
|
+
if (se && !ce)
|
|
1473
|
+
throw new te(
|
|
1474
|
+
y.patch,
|
|
1475
|
+
S.absPath,
|
|
1476
|
+
W
|
|
1529
1477
|
);
|
|
1530
1478
|
}
|
|
1531
1479
|
try {
|
|
1532
|
-
t =
|
|
1533
|
-
} catch (
|
|
1534
|
-
throw
|
|
1480
|
+
t = J(t, [y.patch]);
|
|
1481
|
+
} catch (S) {
|
|
1482
|
+
throw Ae(u, d, S), S;
|
|
1535
1483
|
}
|
|
1536
|
-
} else
|
|
1484
|
+
} else y.kind === "event" && (n.push(y.event.payload), await this.router.route(t, [], y.event, s.key[5]));
|
|
1537
1485
|
}
|
|
1538
1486
|
);
|
|
1539
|
-
await
|
|
1487
|
+
await m.handle(d, h, v, u), await v.flush();
|
|
1540
1488
|
}
|
|
1541
1489
|
return { state: t, emitted: n };
|
|
1542
1490
|
}
|
|
1543
1491
|
}
|
|
1544
1492
|
export {
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1493
|
+
it as BlueDocumentProcessor,
|
|
1494
|
+
je as ChannelEventCheckpointProcessor,
|
|
1495
|
+
xe as CompositeTimelineChannelProcessor,
|
|
1496
|
+
Ve as DocumentUpdateChannelProcessor,
|
|
1497
|
+
Le as EmbeddedNodeChannelProcessor,
|
|
1498
|
+
Fe as InitializedMarkerProcessor,
|
|
1499
|
+
_e as LifecycleEventChannelProcessor,
|
|
1550
1500
|
Ue as MyOSAgentChannelProcessor,
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1501
|
+
ze as MyOSTimelineChannelProcessor,
|
|
1502
|
+
He as OperationProcessor,
|
|
1503
|
+
Re as ProcessEmbeddedProcessor,
|
|
1504
|
+
Ge as SequentialWorkflowOperationProcessor,
|
|
1505
|
+
oe as SequentialWorkflowProcessor,
|
|
1506
|
+
et as TimelineChannelProcessor
|
|
1557
1507
|
};
|