@blue-labs/language 1.25.0 → 1.26.1
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 +8 -8
- package/dist/index.mjs +1518 -782
- package/dist/lib/Blue.d.ts +12 -5
- package/dist/lib/Blue.d.ts.map +1 -1
- package/dist/lib/index.d.ts +1 -0
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/merge/Merger.d.ts +55 -0
- package/dist/lib/merge/Merger.d.ts.map +1 -0
- package/dist/lib/merge/MergingProcessor.d.ts +30 -0
- package/dist/lib/merge/MergingProcessor.d.ts.map +1 -0
- package/dist/lib/merge/NodeResolver.d.ts +28 -0
- package/dist/lib/merge/NodeResolver.d.ts.map +1 -0
- package/dist/lib/merge/createDefaultNodeProcessor.d.ts +7 -0
- package/dist/lib/merge/createDefaultNodeProcessor.d.ts.map +1 -0
- package/dist/lib/merge/index.d.ts +6 -0
- package/dist/lib/merge/index.d.ts.map +1 -0
- package/dist/lib/merge/processors/BasicTypesVerifier.d.ts +11 -0
- package/dist/lib/merge/processors/BasicTypesVerifier.d.ts.map +1 -0
- package/dist/lib/merge/processors/DictionaryProcessor.d.ts +15 -0
- package/dist/lib/merge/processors/DictionaryProcessor.d.ts.map +1 -0
- package/dist/lib/merge/processors/ListProcessor.d.ts +10 -0
- package/dist/lib/merge/processors/ListProcessor.d.ts.map +1 -0
- package/dist/lib/merge/processors/SequentialMergingProcessor.d.ts +24 -0
- package/dist/lib/merge/processors/SequentialMergingProcessor.d.ts.map +1 -0
- package/dist/lib/merge/processors/TypeAssigner.d.ts +10 -0
- package/dist/lib/merge/processors/TypeAssigner.d.ts.map +1 -0
- package/dist/lib/merge/processors/Types.d.ts +43 -0
- package/dist/lib/merge/processors/Types.d.ts.map +1 -0
- package/dist/lib/merge/processors/ValuePropagator.d.ts +9 -0
- package/dist/lib/merge/processors/ValuePropagator.d.ts.map +1 -0
- package/dist/lib/merge/processors/index.d.ts +8 -0
- package/dist/lib/merge/processors/index.d.ts.map +1 -0
- package/dist/lib/provider/AbstractNodeProvider.d.ts +13 -0
- package/dist/lib/provider/AbstractNodeProvider.d.ts.map +1 -0
- package/dist/lib/provider/BasicNodeProvider.d.ts +59 -0
- package/dist/lib/provider/BasicNodeProvider.d.ts.map +1 -0
- package/dist/lib/provider/InMemoryNodeProvider.d.ts +6 -0
- package/dist/lib/provider/InMemoryNodeProvider.d.ts.map +1 -1
- package/dist/lib/provider/NodeContentHandler.d.ts +18 -0
- package/dist/lib/provider/NodeContentHandler.d.ts.map +1 -0
- package/dist/lib/provider/PreloadedNodeProvider.d.ts +24 -0
- package/dist/lib/provider/PreloadedNodeProvider.d.ts.map +1 -0
- package/dist/lib/provider/RepositoryBasedNodeProvider.d.ts +27 -0
- package/dist/lib/provider/RepositoryBasedNodeProvider.d.ts.map +1 -0
- package/dist/lib/provider/index.d.ts +5 -0
- package/dist/lib/provider/index.d.ts.map +1 -1
- package/dist/lib/types/BlueRepository.d.ts +9 -0
- package/dist/lib/types/BlueRepository.d.ts.map +1 -0
- package/dist/lib/types/index.d.ts +2 -0
- package/dist/lib/types/index.d.ts.map +1 -0
- package/dist/lib/utils/NodeExtender.d.ts.map +1 -1
- package/dist/lib/utils/NodeProviderWrapper.d.ts +5 -3
- package/dist/lib/utils/NodeProviderWrapper.d.ts.map +1 -1
- package/dist/lib/utils/Nodes.d.ts +67 -0
- package/dist/lib/utils/Nodes.d.ts.map +1 -0
- package/dist/lib/utils/index.d.ts +1 -0
- package/dist/lib/utils/index.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var u = (r, e, t) =>
|
|
4
|
-
import { isNullable as
|
|
5
|
-
import { z as
|
|
6
|
-
import
|
|
1
|
+
var _t = Object.defineProperty;
|
|
2
|
+
var Zt = (r, e, t) => e in r ? _t(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
|
|
3
|
+
var u = (r, e, t) => Zt(r, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { isNullable as N, isNonNullable as f, jsonPrimitiveSchema as kt, isReadonlyArray as ie, isJsonPrimitive as Ke, isPreciseNumberString as ft } from "@blue-labs/shared-utils";
|
|
5
|
+
import { z as d, ZodOptional as ht, ZodNullable as pt, ZodReadonly as yt, ZodBranded as gt, ZodEffects as me, ZodLazy as Ie, ZodString as k, ZodEnum as Jt, ZodNativeEnum as Gt, ZodNumber as J, ZodBoolean as pe, ZodBigInt as ye, ZodAny as mt, ZodObject as Ue, ZodRecord as Le, ZodMap as It, ZodUnknown as Tt, ZodIntersection as Yt, ZodUnion as zt } from "zod";
|
|
6
|
+
import oe from "bs58";
|
|
7
7
|
import x from "big.js";
|
|
8
|
-
import { isObject as
|
|
9
|
-
import { sha256 as
|
|
10
|
-
import
|
|
11
|
-
import
|
|
8
|
+
import { isObject as _e, isArray as Ne, isString as We, omit as bt, pascal as Kt, map as Wt } from "radash";
|
|
9
|
+
import { sha256 as Ht } from "js-sha256";
|
|
10
|
+
import Oe from "crypto";
|
|
11
|
+
import Xt from "base32.js";
|
|
12
12
|
import Z from "js-yaml";
|
|
13
|
-
class
|
|
13
|
+
class qt {
|
|
14
14
|
static get(e, t, n, s = !0) {
|
|
15
|
-
if (
|
|
15
|
+
if (N(t) || !t.startsWith("/"))
|
|
16
16
|
throw new Error(`Invalid path: ${t}`);
|
|
17
17
|
if (t === "/") {
|
|
18
18
|
const o = e.getValue();
|
|
@@ -36,8 +36,8 @@ class Zt {
|
|
|
36
36
|
!1
|
|
37
37
|
);
|
|
38
38
|
if (n === t.length) {
|
|
39
|
-
const
|
|
40
|
-
return i &&
|
|
39
|
+
const l = e.getValue();
|
|
40
|
+
return i && l !== void 0 ? l : e;
|
|
41
41
|
}
|
|
42
42
|
const o = t[n], c = this.getNodeForSegment(
|
|
43
43
|
e,
|
|
@@ -63,34 +63,34 @@ class Zt {
|
|
|
63
63
|
switch (t) {
|
|
64
64
|
case "name": {
|
|
65
65
|
const c = e.getName();
|
|
66
|
-
i =
|
|
66
|
+
i = f(c) ? new a().setValue(c) : new a();
|
|
67
67
|
break;
|
|
68
68
|
}
|
|
69
69
|
case "description": {
|
|
70
70
|
const c = e.getDescription();
|
|
71
|
-
i =
|
|
71
|
+
i = f(c) ? new a().setValue(c) : new a();
|
|
72
72
|
break;
|
|
73
73
|
}
|
|
74
74
|
case "type":
|
|
75
|
-
i = e.getType() ?? new
|
|
75
|
+
i = e.getType() ?? new a();
|
|
76
76
|
break;
|
|
77
77
|
case "itemType":
|
|
78
|
-
i = e.getItemType() ?? new
|
|
78
|
+
i = e.getItemType() ?? new a();
|
|
79
79
|
break;
|
|
80
80
|
case "keyType":
|
|
81
|
-
i = e.getKeyType() ?? new
|
|
81
|
+
i = e.getKeyType() ?? new a();
|
|
82
82
|
break;
|
|
83
83
|
case "valueType":
|
|
84
|
-
i = e.getValueType() ?? new
|
|
84
|
+
i = e.getValueType() ?? new a();
|
|
85
85
|
break;
|
|
86
86
|
case "value": {
|
|
87
87
|
const c = e.getValue();
|
|
88
|
-
i = new
|
|
88
|
+
i = new a().setValue(c ?? null);
|
|
89
89
|
break;
|
|
90
90
|
}
|
|
91
91
|
case "blueId": {
|
|
92
92
|
const c = e.getBlueId();
|
|
93
|
-
i =
|
|
93
|
+
i = f(c) ? new a().setValue(c) : new a();
|
|
94
94
|
break;
|
|
95
95
|
}
|
|
96
96
|
case "blue":
|
|
@@ -98,23 +98,23 @@ class Zt {
|
|
|
98
98
|
break;
|
|
99
99
|
case "items": {
|
|
100
100
|
const c = e.getItems();
|
|
101
|
-
i = new
|
|
101
|
+
i = new a().setItems(c);
|
|
102
102
|
break;
|
|
103
103
|
}
|
|
104
104
|
case "properties": {
|
|
105
105
|
const c = e.getProperties();
|
|
106
|
-
i = new
|
|
106
|
+
i = new a().setProperties(c);
|
|
107
107
|
break;
|
|
108
108
|
}
|
|
109
109
|
case "contracts": {
|
|
110
110
|
const c = e.getContracts();
|
|
111
|
-
i = new
|
|
111
|
+
i = new a().setContracts(c);
|
|
112
112
|
break;
|
|
113
113
|
}
|
|
114
114
|
default: {
|
|
115
115
|
if (/^\d+$/.test(t)) {
|
|
116
|
-
const c = parseInt(t, 10),
|
|
117
|
-
|
|
116
|
+
const c = parseInt(t, 10), l = e.getItems();
|
|
117
|
+
l && c >= 0 && c < l.length ? i = l[c] : i = void 0;
|
|
118
118
|
} else
|
|
119
119
|
i = void 0;
|
|
120
120
|
break;
|
|
@@ -125,53 +125,52 @@ class Zt {
|
|
|
125
125
|
}
|
|
126
126
|
static link(e, t) {
|
|
127
127
|
const n = t(e);
|
|
128
|
-
return
|
|
128
|
+
return f(n) ? n : e;
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
|
-
class
|
|
131
|
+
class S extends x {
|
|
132
132
|
constructor(e) {
|
|
133
133
|
super(e);
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
|
-
class
|
|
136
|
+
class C extends x {
|
|
137
137
|
constructor(e) {
|
|
138
138
|
super(e);
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
|
-
const Y = "name",
|
|
141
|
+
const Y = "name", z = "description", Te = "type", He = "itemType", Xe = "keyType", qe = "valueType", Se = "value", Qe = "items", _ = "blueId", et = "blue", Pe = "contracts", Qt = [
|
|
142
142
|
Y,
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
Ye,
|
|
146
|
-
Ge,
|
|
147
|
-
ze,
|
|
148
|
-
we,
|
|
149
|
-
Je,
|
|
150
|
-
L,
|
|
143
|
+
z,
|
|
144
|
+
Te,
|
|
151
145
|
He,
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
146
|
+
Xe,
|
|
147
|
+
qe,
|
|
148
|
+
Se,
|
|
149
|
+
Qe,
|
|
150
|
+
_,
|
|
151
|
+
et,
|
|
152
|
+
Pe
|
|
153
|
+
], er = "Text", tr = "Double", rr = "Integer", nr = "Boolean", sr = "List", ir = "Dictionary", tt = [
|
|
154
|
+
er,
|
|
155
|
+
tr,
|
|
156
|
+
rr,
|
|
157
|
+
nr
|
|
158
|
+
], wt = [...tt, sr, ir], H = "F92yo19rCcbBoBSpUA5LRxpfDejJDAaP1PRxxbWAraVP", X = "68ryJtnmui4j5rCZWUnkZ3DChtmEb7Z9F8atn1mBSM3L", q = "DHmxTkFbXePZHCHCYmQr2dSzcNLcryFVjXVHkdQrrZr8", Q = "EL6AjrbJsxTWRTPzY8WR8Y2zAMXRbydQj83PcZwuAHbo", vt = "G8wmfjEqugPEEXByMYWJXiEdbLToPRWNQEekNxrxfQWB", Bt = "294NBTj2mFRL3RB4kDRUSckwGg7Kzj6T8CTAFeR1kcSA", Et = [
|
|
159
|
+
H,
|
|
160
|
+
X,
|
|
161
|
+
q,
|
|
162
|
+
Q
|
|
163
|
+
], de = [
|
|
164
|
+
...Et,
|
|
165
|
+
vt,
|
|
166
|
+
Bt
|
|
167
167
|
];
|
|
168
168
|
Object.fromEntries(
|
|
169
|
-
|
|
169
|
+
wt.map((r, e) => [r, de[e]])
|
|
170
170
|
);
|
|
171
|
-
Object.fromEntries(
|
|
172
|
-
|
|
173
|
-
)
|
|
174
|
-
const O = class O {
|
|
171
|
+
const or = Object.fromEntries(
|
|
172
|
+
de.map((r, e) => [r, wt[e]])
|
|
173
|
+
), R = class R {
|
|
175
174
|
constructor(e) {
|
|
176
175
|
u(this, "name");
|
|
177
176
|
u(this, "description");
|
|
@@ -204,42 +203,42 @@ const O = class O {
|
|
|
204
203
|
return this.type;
|
|
205
204
|
}
|
|
206
205
|
setType(e) {
|
|
207
|
-
return typeof e == "string" ? this.type = new
|
|
206
|
+
return typeof e == "string" ? this.type = new R().setValue(e).setInlineValue(!0) : this.type = e, this;
|
|
208
207
|
}
|
|
209
208
|
getItemType() {
|
|
210
209
|
return this.itemType;
|
|
211
210
|
}
|
|
212
211
|
setItemType(e) {
|
|
213
|
-
return typeof e == "string" ? this.itemType = new
|
|
212
|
+
return typeof e == "string" ? this.itemType = new R().setValue(e).setInlineValue(!0) : this.itemType = e, this;
|
|
214
213
|
}
|
|
215
214
|
getKeyType() {
|
|
216
215
|
return this.keyType;
|
|
217
216
|
}
|
|
218
217
|
setKeyType(e) {
|
|
219
|
-
return typeof e == "string" ? this.keyType = new
|
|
218
|
+
return typeof e == "string" ? this.keyType = new R().setValue(e).setInlineValue(!0) : this.keyType = e, this;
|
|
220
219
|
}
|
|
221
220
|
getValueType() {
|
|
222
221
|
return this.valueType;
|
|
223
222
|
}
|
|
224
223
|
setValueType(e) {
|
|
225
|
-
return typeof e == "string" ? this.valueType = new
|
|
224
|
+
return typeof e == "string" ? this.valueType = new R().setValue(e).setInlineValue(!0) : this.valueType = e, this;
|
|
226
225
|
}
|
|
227
226
|
getValue() {
|
|
228
227
|
var t;
|
|
229
228
|
const e = (t = this.type) == null ? void 0 : t.getBlueId();
|
|
230
|
-
if (
|
|
231
|
-
if (e ===
|
|
232
|
-
return new
|
|
233
|
-
if (e ===
|
|
234
|
-
const n = new
|
|
235
|
-
return new
|
|
236
|
-
} else if (e ===
|
|
229
|
+
if (f(e) && f(this.value)) {
|
|
230
|
+
if (e === q && typeof this.value == "string")
|
|
231
|
+
return new S(this.value);
|
|
232
|
+
if (e === X && typeof this.value == "string") {
|
|
233
|
+
const n = new C(this.value), s = parseFloat(n.toString());
|
|
234
|
+
return new C(s.toString());
|
|
235
|
+
} else if (e === Q && typeof this.value == "string")
|
|
237
236
|
return this.value.toLowerCase() === "true";
|
|
238
237
|
}
|
|
239
238
|
return this.value;
|
|
240
239
|
}
|
|
241
240
|
setValue(e) {
|
|
242
|
-
return typeof e == "number" ? e % 1 === 0 ? this.value = new
|
|
241
|
+
return typeof e == "number" ? e % 1 === 0 ? this.value = new S(e.toString()) : this.value = new C(e.toString()) : this.value = e, this;
|
|
243
242
|
}
|
|
244
243
|
getItems() {
|
|
245
244
|
return this.items;
|
|
@@ -293,24 +292,24 @@ const O = class O {
|
|
|
293
292
|
return this.inlineValue = e, this;
|
|
294
293
|
}
|
|
295
294
|
get(e, t) {
|
|
296
|
-
return
|
|
295
|
+
return qt.get(this, e, t);
|
|
297
296
|
}
|
|
298
297
|
clone() {
|
|
299
298
|
var t, n, s, i, o, c;
|
|
300
|
-
const e = new
|
|
301
|
-
return e.description = this.description, e.type = (t = this.type) == null ? void 0 : t.clone(), e.itemType = (n = this.itemType) == null ? void 0 : n.clone(), e.keyType = (s = this.keyType) == null ? void 0 : s.clone(), e.valueType = (i = this.valueType) == null ? void 0 : i.clone(), e.value = this.value, e.items = (o = this.items) == null ? void 0 : o.map((
|
|
302
|
-
Object.entries(this.properties).map(([
|
|
299
|
+
const e = new R(this.name);
|
|
300
|
+
return e.description = this.description, e.type = (t = this.type) == null ? void 0 : t.clone(), e.itemType = (n = this.itemType) == null ? void 0 : n.clone(), e.keyType = (s = this.keyType) == null ? void 0 : s.clone(), e.valueType = (i = this.valueType) == null ? void 0 : i.clone(), e.value = this.value, e.items = (o = this.items) == null ? void 0 : o.map((l) => l.clone()), this.properties && (e.properties = Object.fromEntries(
|
|
301
|
+
Object.entries(this.properties).map(([l, h]) => [l, h.clone()])
|
|
303
302
|
)), this.contracts && (e.contracts = Object.fromEntries(
|
|
304
|
-
Object.entries(this.contracts).map(([
|
|
303
|
+
Object.entries(this.contracts).map(([l, h]) => [l, h.clone()])
|
|
305
304
|
)), e.blueId = this.blueId, e.blue = (c = this.blue) == null ? void 0 : c.clone(), e.inlineValue = this.inlineValue, e;
|
|
306
305
|
}
|
|
307
306
|
toString() {
|
|
308
307
|
return `BlueNode{name='${this.name}', description='${this.description}', type=${this.type}, itemType=${this.itemType}, keyType=${this.keyType}, valueType=${this.valueType}, value=${this.value}, items=${this.items}, properties=${this.properties}, contracts=${this.contracts}, blueId='${this.blueId}', blue=${this.blue}, inlineValue=${this.inlineValue}}`;
|
|
309
308
|
}
|
|
310
309
|
};
|
|
311
|
-
u(
|
|
312
|
-
let
|
|
313
|
-
class
|
|
310
|
+
u(R, "INTEGER", new R("Integer"));
|
|
311
|
+
let a = R;
|
|
312
|
+
class L {
|
|
314
313
|
static isPotentialBlueId(e) {
|
|
315
314
|
if (!e || e.length === 0 || !this.BLUE_ID_PATTERN.test(e))
|
|
316
315
|
return !1;
|
|
@@ -318,7 +317,7 @@ class M {
|
|
|
318
317
|
if (s < this.MIN_BLUE_ID_LENGTH || s > this.MAX_BLUE_ID_LENGTH)
|
|
319
318
|
return !1;
|
|
320
319
|
try {
|
|
321
|
-
if (
|
|
320
|
+
if (oe.decode(n).length !== 32)
|
|
322
321
|
return !1;
|
|
323
322
|
} catch {
|
|
324
323
|
return !1;
|
|
@@ -333,15 +332,15 @@ class M {
|
|
|
333
332
|
return !0;
|
|
334
333
|
}
|
|
335
334
|
}
|
|
336
|
-
u(
|
|
337
|
-
const
|
|
335
|
+
u(L, "MIN_BLUE_ID_LENGTH", 41), u(L, "MAX_BLUE_ID_LENGTH", 45), u(L, "BLUE_ID_PATTERN", /^[1-9A-HJ-NP-Za-km-z]{41,45}(?:#\d+)?$/);
|
|
336
|
+
const Qn = d.string().max(L.MAX_BLUE_ID_LENGTH, {
|
|
338
337
|
message: "Blue Id has a maximum length of 45 characters"
|
|
339
|
-
}).min(
|
|
338
|
+
}).min(L.MIN_BLUE_ID_LENGTH, {
|
|
340
339
|
message: "Blue Id has a minimum length of 41 characters"
|
|
341
340
|
}).refine(
|
|
342
341
|
(r) => {
|
|
343
342
|
try {
|
|
344
|
-
return
|
|
343
|
+
return oe.decode(r), !0;
|
|
345
344
|
} catch {
|
|
346
345
|
return !1;
|
|
347
346
|
}
|
|
@@ -349,45 +348,45 @@ const Pn = f.string().max(M.MAX_BLUE_ID_LENGTH, {
|
|
|
349
348
|
{
|
|
350
349
|
message: "Blue Id must be a valid Base58 string"
|
|
351
350
|
}
|
|
352
|
-
),
|
|
353
|
-
() =>
|
|
354
|
-
|
|
355
|
-
blueId:
|
|
356
|
-
name:
|
|
357
|
-
description:
|
|
358
|
-
type:
|
|
359
|
-
value:
|
|
360
|
-
items:
|
|
351
|
+
), ce = d.lazy(
|
|
352
|
+
() => d.record(d.unknown()).and(
|
|
353
|
+
d.object({
|
|
354
|
+
blueId: d.string().optional(),
|
|
355
|
+
name: d.string().optional(),
|
|
356
|
+
description: d.string().optional(),
|
|
357
|
+
type: ce.optional(),
|
|
358
|
+
value: d.union([d.string(), d.number(), d.boolean()]).optional().nullable(),
|
|
359
|
+
items: d.array(ce).optional()
|
|
361
360
|
})
|
|
362
361
|
)
|
|
363
|
-
),
|
|
364
|
-
blueId:
|
|
365
|
-
name:
|
|
366
|
-
description:
|
|
367
|
-
type:
|
|
368
|
-
}),
|
|
369
|
-
value:
|
|
370
|
-
}),
|
|
371
|
-
value:
|
|
372
|
-
}),
|
|
373
|
-
value:
|
|
374
|
-
}),
|
|
375
|
-
items:
|
|
376
|
-
}),
|
|
377
|
-
() =>
|
|
378
|
-
),
|
|
379
|
-
() =>
|
|
380
|
-
|
|
381
|
-
|
|
362
|
+
), Ae = d.object({
|
|
363
|
+
blueId: d.string().optional(),
|
|
364
|
+
name: d.string().optional(),
|
|
365
|
+
description: d.string().optional(),
|
|
366
|
+
type: ce.optional()
|
|
367
|
+
}), es = Ae.extend({
|
|
368
|
+
value: d.string().optional()
|
|
369
|
+
}), ts = Ae.extend({
|
|
370
|
+
value: d.number().optional()
|
|
371
|
+
}), rs = Ae.extend({
|
|
372
|
+
value: d.boolean().optional()
|
|
373
|
+
}), ns = Ae.extend({
|
|
374
|
+
items: d.array(d.string()).optional()
|
|
375
|
+
}), ss = (r) => ce.safeParse(r).success, cr = (r) => f(r) && "blueId" in r && f(r.blueId), is = (r) => f(r) && "name" in r && f(r.name), lr = (r) => f(r) && "items" in r && f(r.items), ar = (r) => f(r) && "type" in r && f(r.type), ur = (r) => f(r) && "value" in r && f(r.value), os = (r, e) => r.required({ type: !0 }).safeParse(e).success, O = (r) => r instanceof x, le = (r) => O(r) && r instanceof S, dr = (r) => O(r) && r instanceof C, fr = d.lazy(
|
|
376
|
+
() => d.record(be)
|
|
377
|
+
), hr = d.lazy(
|
|
378
|
+
() => d.union([
|
|
379
|
+
d.array(be),
|
|
380
|
+
d.array(be).readonly()
|
|
382
381
|
])
|
|
383
|
-
),
|
|
384
|
-
() =>
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
382
|
+
), be = d.lazy(
|
|
383
|
+
() => d.union([
|
|
384
|
+
kt,
|
|
385
|
+
fr,
|
|
386
|
+
hr,
|
|
387
|
+
d.instanceof(x)
|
|
389
388
|
])
|
|
390
|
-
),
|
|
389
|
+
), Nt = (r) => _e(r) && !Ne(r) && !ie(r) && !O(r), St = (r) => Ne(r) || ie(r), cs = (r) => St(r) || Nt(r) || O(r) || Ke(r);
|
|
391
390
|
class p {
|
|
392
391
|
static deserialize(e) {
|
|
393
392
|
return p.handleNode(e);
|
|
@@ -397,8 +396,8 @@ class p {
|
|
|
397
396
|
throw new Error(
|
|
398
397
|
"This is not a valid JSON-like value. Found 'undefined' as a value."
|
|
399
398
|
);
|
|
400
|
-
if (
|
|
401
|
-
const t = new
|
|
399
|
+
if (Nt(e)) {
|
|
400
|
+
const t = new a(), n = {}, s = {};
|
|
402
401
|
return Object.entries(e).forEach(([i, o]) => {
|
|
403
402
|
switch (i) {
|
|
404
403
|
case Y:
|
|
@@ -410,46 +409,46 @@ class p {
|
|
|
410
409
|
t.setName(o);
|
|
411
410
|
}
|
|
412
411
|
break;
|
|
413
|
-
case
|
|
412
|
+
case z:
|
|
414
413
|
if (o == null)
|
|
415
414
|
t.setDescription(void 0);
|
|
416
415
|
else {
|
|
417
416
|
if (typeof o != "string")
|
|
418
417
|
throw new Error(
|
|
419
|
-
`The ${
|
|
418
|
+
`The ${z} field must be a string.`
|
|
420
419
|
);
|
|
421
420
|
t.setDescription(o);
|
|
422
421
|
}
|
|
423
422
|
break;
|
|
424
|
-
case
|
|
423
|
+
case Te:
|
|
425
424
|
t.setType(p.handleNode(o));
|
|
426
425
|
break;
|
|
427
|
-
case
|
|
426
|
+
case He:
|
|
428
427
|
t.setItemType(p.handleNode(o));
|
|
429
428
|
break;
|
|
430
|
-
case
|
|
429
|
+
case Xe:
|
|
431
430
|
t.setKeyType(p.handleNode(o));
|
|
432
431
|
break;
|
|
433
|
-
case
|
|
432
|
+
case qe:
|
|
434
433
|
t.setValueType(p.handleNode(o));
|
|
435
434
|
break;
|
|
436
|
-
case
|
|
435
|
+
case Se:
|
|
437
436
|
t.setValue(p.handleValue(o));
|
|
438
437
|
break;
|
|
439
|
-
case
|
|
438
|
+
case _:
|
|
440
439
|
if (typeof o != "string")
|
|
441
|
-
throw new Error(`The ${
|
|
440
|
+
throw new Error(`The ${_} field must be a string.`);
|
|
442
441
|
t.setBlueId(o);
|
|
443
442
|
break;
|
|
444
|
-
case
|
|
443
|
+
case Qe:
|
|
445
444
|
t.setItems(p.handleArray(o));
|
|
446
445
|
break;
|
|
447
|
-
case
|
|
446
|
+
case et:
|
|
448
447
|
t.setBlue(p.handleNode(o));
|
|
449
448
|
break;
|
|
450
|
-
case
|
|
451
|
-
|
|
452
|
-
s[c] = p.handleNode(
|
|
449
|
+
case Pe:
|
|
450
|
+
_e(o) && !Ne(o) && !ie(o) && Object.entries(o).forEach(([c, l]) => {
|
|
451
|
+
s[c] = p.handleNode(l);
|
|
453
452
|
});
|
|
454
453
|
break;
|
|
455
454
|
default:
|
|
@@ -458,11 +457,11 @@ class p {
|
|
|
458
457
|
}
|
|
459
458
|
}), Object.keys(n).length > 0 && t.setProperties(n), Object.keys(s).length > 0 && t.setContracts(s), t;
|
|
460
459
|
} else {
|
|
461
|
-
if (
|
|
462
|
-
return new
|
|
460
|
+
if (St(e))
|
|
461
|
+
return new a().setItems(p.handleArray(e));
|
|
463
462
|
{
|
|
464
463
|
const t = e;
|
|
465
|
-
return new
|
|
464
|
+
return new a().setValue(p.handleValue(t)).setInlineValue(!0);
|
|
466
465
|
}
|
|
467
466
|
}
|
|
468
467
|
}
|
|
@@ -471,13 +470,13 @@ class p {
|
|
|
471
470
|
return null;
|
|
472
471
|
if (typeof e == "string")
|
|
473
472
|
return e;
|
|
474
|
-
if (typeof e == "number" ||
|
|
475
|
-
if (
|
|
476
|
-
const t = new
|
|
477
|
-
return t.lt(n) ? new
|
|
473
|
+
if (typeof e == "number" || O(e))
|
|
474
|
+
if (le(e) || Number.isSafeInteger(e)) {
|
|
475
|
+
const t = new S(e.toString()), n = Number.MIN_SAFE_INTEGER, s = Number.MAX_SAFE_INTEGER;
|
|
476
|
+
return t.lt(n) ? new S(n.toString()) : t.gt(s) ? new S(s.toString()) : t;
|
|
478
477
|
} else {
|
|
479
478
|
const t = parseFloat(e.toString());
|
|
480
|
-
return new
|
|
479
|
+
return new C(t.toString());
|
|
481
480
|
}
|
|
482
481
|
else if (typeof e == "boolean")
|
|
483
482
|
return e;
|
|
@@ -485,7 +484,7 @@ class p {
|
|
|
485
484
|
}
|
|
486
485
|
static handleArray(e) {
|
|
487
486
|
if (e != null) {
|
|
488
|
-
if (
|
|
487
|
+
if (_e(e) && !Array.isArray(e))
|
|
489
488
|
return [p.handleNode(e)];
|
|
490
489
|
if (Array.isArray(e))
|
|
491
490
|
return e.map(p.handleNode);
|
|
@@ -493,12 +492,12 @@ class p {
|
|
|
493
492
|
}
|
|
494
493
|
}
|
|
495
494
|
}
|
|
496
|
-
function
|
|
495
|
+
function pr(r) {
|
|
497
496
|
return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r;
|
|
498
497
|
}
|
|
499
|
-
var
|
|
500
|
-
function
|
|
501
|
-
return
|
|
498
|
+
var De, ot;
|
|
499
|
+
function yr() {
|
|
500
|
+
return ot || (ot = 1, De = function r(e) {
|
|
502
501
|
if (typeof e == "number" && isNaN(e))
|
|
503
502
|
throw new Error("NaN is not allowed");
|
|
504
503
|
if (typeof e == "number" && !isFinite(e))
|
|
@@ -509,52 +508,52 @@ function cr() {
|
|
|
509
508
|
const i = n.length === 0 ? "" : ",";
|
|
510
509
|
return `${n}${i}${r(s)}:${r(e[s])}`;
|
|
511
510
|
}, "")}}`;
|
|
512
|
-
}),
|
|
511
|
+
}), De;
|
|
513
512
|
}
|
|
514
|
-
var
|
|
515
|
-
const
|
|
516
|
-
class
|
|
513
|
+
var gr = yr();
|
|
514
|
+
const mr = /* @__PURE__ */ pr(gr);
|
|
515
|
+
class Ir {
|
|
517
516
|
static canonicalize(e) {
|
|
518
|
-
return
|
|
517
|
+
return mr(e);
|
|
519
518
|
}
|
|
520
519
|
}
|
|
521
|
-
const
|
|
520
|
+
const Fe = typeof process < "u" && process.versions != null && process.versions.node != null, ve = class ve {
|
|
522
521
|
constructor() {
|
|
523
522
|
u(this, "browserCrypto");
|
|
524
523
|
this.browserCrypto = this.initBrowserCrypto();
|
|
525
524
|
}
|
|
526
525
|
static getInstance() {
|
|
527
|
-
return this.instance || (this.instance = new
|
|
526
|
+
return this.instance || (this.instance = new ve()), this.instance;
|
|
528
527
|
}
|
|
529
528
|
initBrowserCrypto() {
|
|
530
|
-
return
|
|
529
|
+
return Fe ? null : "crypto" in globalThis ? globalThis.crypto : null;
|
|
531
530
|
}
|
|
532
531
|
hasNodeCrypto() {
|
|
533
|
-
return
|
|
532
|
+
return Fe && !!Oe && typeof Oe.createHash == "function";
|
|
534
533
|
}
|
|
535
534
|
getBrowserCrypto() {
|
|
536
535
|
return this.browserCrypto;
|
|
537
536
|
}
|
|
538
537
|
getNodeCrypto() {
|
|
539
|
-
return
|
|
538
|
+
return Fe ? Oe : null;
|
|
540
539
|
}
|
|
541
540
|
};
|
|
542
|
-
u(
|
|
543
|
-
let
|
|
544
|
-
class
|
|
541
|
+
u(ve, "instance");
|
|
542
|
+
let Ze = ve;
|
|
543
|
+
class Tr {
|
|
545
544
|
constructor() {
|
|
546
|
-
u(this, "cryptoEnv",
|
|
545
|
+
u(this, "cryptoEnv", Ze.getInstance());
|
|
547
546
|
}
|
|
548
547
|
applySync(e) {
|
|
549
548
|
const t = this.canonicalizeInput(e), n = this.cryptoEnv.hasNodeCrypto() ? this.sha256Sync(t) : this.sha256SyncBrowser(t);
|
|
550
|
-
return
|
|
549
|
+
return oe.encode(new Uint8Array(n));
|
|
551
550
|
}
|
|
552
551
|
async apply(e) {
|
|
553
552
|
const t = this.canonicalizeInput(e), n = this.cryptoEnv.hasNodeCrypto() ? this.sha256Sync(t) : await this.sha256Async(t);
|
|
554
|
-
return
|
|
553
|
+
return oe.encode(new Uint8Array(n));
|
|
555
554
|
}
|
|
556
555
|
canonicalizeInput(e) {
|
|
557
|
-
const t =
|
|
556
|
+
const t = Ir.canonicalize(e);
|
|
558
557
|
if (typeof t != "string")
|
|
559
558
|
throw new Error("Canonized value must be a string");
|
|
560
559
|
return t;
|
|
@@ -568,7 +567,7 @@ class fr {
|
|
|
568
567
|
return t.createHash("sha256").update(e).digest();
|
|
569
568
|
}
|
|
570
569
|
sha256SyncBrowser(e) {
|
|
571
|
-
return
|
|
570
|
+
return Ht.arrayBuffer(e);
|
|
572
571
|
}
|
|
573
572
|
async sha256Async(e) {
|
|
574
573
|
if (this.cryptoEnv.hasNodeCrypto())
|
|
@@ -580,7 +579,7 @@ class fr {
|
|
|
580
579
|
return t.subtle.digest("SHA-256", s);
|
|
581
580
|
}
|
|
582
581
|
}
|
|
583
|
-
class
|
|
582
|
+
class y {
|
|
584
583
|
/**
|
|
585
584
|
* Converts a BlueNode to a JSON representation based on the specified strategy.
|
|
586
585
|
*
|
|
@@ -592,11 +591,11 @@ class T {
|
|
|
592
591
|
* @returns A JSON representation of the node.
|
|
593
592
|
*/
|
|
594
593
|
static get(e, t = "official") {
|
|
595
|
-
var
|
|
594
|
+
var he;
|
|
596
595
|
const n = e.getValue(), s = this.handleValue(n);
|
|
597
596
|
if (s !== void 0 && t === "simple")
|
|
598
597
|
return s;
|
|
599
|
-
const i = (
|
|
598
|
+
const i = (he = e.getItems()) == null ? void 0 : he.map((F) => y.get(F, t));
|
|
600
599
|
if (i !== void 0 && t === "simple")
|
|
601
600
|
return i;
|
|
602
601
|
const o = e.getName(), c = e.getDescription();
|
|
@@ -606,38 +605,38 @@ class T {
|
|
|
606
605
|
if (i !== void 0)
|
|
607
606
|
return i;
|
|
608
607
|
}
|
|
609
|
-
const
|
|
610
|
-
o !== void 0 && (
|
|
611
|
-
const
|
|
612
|
-
if (t === "official" && n !== void 0 &&
|
|
613
|
-
const
|
|
614
|
-
|
|
615
|
-
} else
|
|
616
|
-
const
|
|
617
|
-
|
|
618
|
-
const
|
|
619
|
-
|
|
620
|
-
const
|
|
621
|
-
|
|
622
|
-
const
|
|
623
|
-
|
|
624
|
-
const
|
|
625
|
-
|
|
626
|
-
const
|
|
627
|
-
if (
|
|
628
|
-
const
|
|
629
|
-
Object.entries(
|
|
630
|
-
|
|
631
|
-
}),
|
|
632
|
-
}
|
|
633
|
-
const
|
|
634
|
-
return
|
|
635
|
-
|
|
636
|
-
}),
|
|
608
|
+
const l = {};
|
|
609
|
+
o !== void 0 && (l[Y] = o), c !== void 0 && (l[z] = c);
|
|
610
|
+
const h = e.getType();
|
|
611
|
+
if (t === "official" && n !== void 0 && h === void 0) {
|
|
612
|
+
const F = this.inferTypeBlueId(n);
|
|
613
|
+
F !== null && (l[Te] = { [_]: F });
|
|
614
|
+
} else h !== void 0 && (l[Te] = y.get(h, t));
|
|
615
|
+
const T = e.getItemType();
|
|
616
|
+
T !== void 0 && (l[He] = y.get(T, t));
|
|
617
|
+
const b = e.getKeyType();
|
|
618
|
+
b !== void 0 && (l[Xe] = y.get(b, t));
|
|
619
|
+
const I = e.getValueType();
|
|
620
|
+
I !== void 0 && (l[qe] = y.get(I, t)), s !== void 0 && (l[Se] = s), i !== void 0 && (l[Qe] = i);
|
|
621
|
+
const m = e.getBlueId();
|
|
622
|
+
m !== void 0 && (l[_] = m);
|
|
623
|
+
const g = e.getBlue();
|
|
624
|
+
g !== void 0 && (l[et] = g);
|
|
625
|
+
const v = e.getContracts();
|
|
626
|
+
if (v !== void 0) {
|
|
627
|
+
const F = {};
|
|
628
|
+
Object.entries(v).forEach(([Ve, Lt]) => {
|
|
629
|
+
F[Ve] = y.get(Lt, t);
|
|
630
|
+
}), l[Pe] = F;
|
|
631
|
+
}
|
|
632
|
+
const D = e.getProperties();
|
|
633
|
+
return D !== void 0 && Object.entries(D).forEach(([F, Ve]) => {
|
|
634
|
+
l[F] = y.get(Ve, t);
|
|
635
|
+
}), l;
|
|
637
636
|
}
|
|
638
637
|
static handleValue(e) {
|
|
639
|
-
if (
|
|
640
|
-
if (
|
|
638
|
+
if (O(e)) {
|
|
639
|
+
if (le(e)) {
|
|
641
640
|
const t = new x(Number.MIN_SAFE_INTEGER.toString()), n = new x(Number.MAX_SAFE_INTEGER.toString());
|
|
642
641
|
if (e.lt(t) || e.gt(n))
|
|
643
642
|
return e.toString();
|
|
@@ -647,29 +646,29 @@ class T {
|
|
|
647
646
|
return e;
|
|
648
647
|
}
|
|
649
648
|
static inferTypeBlueId(e) {
|
|
650
|
-
return typeof e == "string" ?
|
|
649
|
+
return typeof e == "string" ? H : O(e) ? le(e) ? q : X : typeof e == "boolean" ? Q : null;
|
|
651
650
|
}
|
|
652
651
|
}
|
|
653
|
-
const
|
|
652
|
+
const br = (r) => Ke(r) && f(r), j = class j {
|
|
654
653
|
constructor(e) {
|
|
655
654
|
u(this, "hashProvider");
|
|
656
655
|
this.hashProvider = e;
|
|
657
656
|
}
|
|
658
657
|
static calculateBlueId(e) {
|
|
659
658
|
if (Array.isArray(e)) {
|
|
660
|
-
const n = e.map((s) =>
|
|
661
|
-
return
|
|
659
|
+
const n = e.map((s) => y.get(s));
|
|
660
|
+
return j.INSTANCE.calculate(n);
|
|
662
661
|
}
|
|
663
|
-
const t =
|
|
664
|
-
return
|
|
662
|
+
const t = y.get(e);
|
|
663
|
+
return j.INSTANCE.calculate(t);
|
|
665
664
|
}
|
|
666
665
|
static calculateBlueIdSync(e) {
|
|
667
666
|
if (Array.isArray(e)) {
|
|
668
|
-
const n = e.map((s) =>
|
|
669
|
-
return
|
|
667
|
+
const n = e.map((s) => y.get(s));
|
|
668
|
+
return j.INSTANCE.calculateSync(n);
|
|
670
669
|
}
|
|
671
|
-
const t =
|
|
672
|
-
return
|
|
670
|
+
const t = y.get(e);
|
|
671
|
+
return j.INSTANCE.calculateSync(t);
|
|
673
672
|
}
|
|
674
673
|
// public static calculateBlueIdForNodes(nodes: BlueNode[]) {
|
|
675
674
|
// const objects = nodes.map((node) => NodeToMapListOrValue.get(node));
|
|
@@ -693,26 +692,26 @@ const dr = (r) => ke(r) && d(r), R = class R {
|
|
|
693
692
|
}
|
|
694
693
|
// Internal method to calculate BlueId recursively
|
|
695
694
|
internalCalculate(e, t) {
|
|
696
|
-
return
|
|
695
|
+
return br(e) || O(e) ? this.applyHash(e.toString(), t) : Array.isArray(e) || ie(e) ? this.calculateList(e, t) : this.calculateMap(e, t);
|
|
697
696
|
}
|
|
698
697
|
calculateMap(e, t) {
|
|
699
|
-
if (e[
|
|
700
|
-
return e[
|
|
698
|
+
if (e[_] !== void 0)
|
|
699
|
+
return e[_];
|
|
701
700
|
const s = Object.keys(e).map((o) => {
|
|
702
701
|
const c = e[o];
|
|
703
|
-
if ([Y,
|
|
702
|
+
if ([Y, Se, z].includes(o))
|
|
704
703
|
return t ? [o, c] : Promise.resolve([o, c]);
|
|
705
704
|
{
|
|
706
|
-
const
|
|
707
|
-
return t ? [o, { blueId:
|
|
705
|
+
const l = this.internalCalculate(c, t);
|
|
706
|
+
return t ? [o, { blueId: l }] : Promise.resolve(l).then((h) => [
|
|
708
707
|
o,
|
|
709
|
-
{ blueId:
|
|
708
|
+
{ blueId: h }
|
|
710
709
|
]);
|
|
711
710
|
}
|
|
712
711
|
}), i = (o) => {
|
|
713
712
|
const c = {};
|
|
714
|
-
for (const [
|
|
715
|
-
c[
|
|
713
|
+
for (const [l, h] of o)
|
|
714
|
+
c[l] = h;
|
|
716
715
|
return this.applyHash(c, t);
|
|
717
716
|
};
|
|
718
717
|
return t ? i(s) : Promise.all(s).then(i);
|
|
@@ -728,7 +727,7 @@ const dr = (r) => ke(r) && d(r), R = class R {
|
|
|
728
727
|
[{ blueId: i }, { blueId: o }],
|
|
729
728
|
!0
|
|
730
729
|
) : Promise.all([i, o]).then(
|
|
731
|
-
([c,
|
|
730
|
+
([c, l]) => this.applyHash([{ blueId: c }, { blueId: l }], !1)
|
|
732
731
|
);
|
|
733
732
|
for (let i = 1; i < e.length; i++) {
|
|
734
733
|
const o = this.internalCalculate(e[i], t);
|
|
@@ -743,10 +742,10 @@ const dr = (r) => ke(r) && d(r), R = class R {
|
|
|
743
742
|
// Method to clean the input structure by removing null or undefined values
|
|
744
743
|
cleanStructure(e) {
|
|
745
744
|
if (e != null) {
|
|
746
|
-
if (
|
|
745
|
+
if (Ke(e) || O(e))
|
|
747
746
|
return e;
|
|
748
|
-
if (Array.isArray(e) ||
|
|
749
|
-
const t = e.map((n) => this.cleanStructure(n)).filter(
|
|
747
|
+
if (Array.isArray(e) || ie(e)) {
|
|
748
|
+
const t = e.map((n) => this.cleanStructure(n)).filter(f);
|
|
750
749
|
return t.length > 0 ? t : void 0;
|
|
751
750
|
} else if (typeof e == "object") {
|
|
752
751
|
const t = {};
|
|
@@ -760,17 +759,17 @@ const dr = (r) => ke(r) && d(r), R = class R {
|
|
|
760
759
|
}
|
|
761
760
|
}
|
|
762
761
|
};
|
|
763
|
-
u(
|
|
764
|
-
let
|
|
765
|
-
class
|
|
762
|
+
u(j, "INSTANCE", new j(new Tr()));
|
|
763
|
+
let w = j;
|
|
764
|
+
class ls {
|
|
766
765
|
static convert(e) {
|
|
767
|
-
const t =
|
|
766
|
+
const t = oe.decode(e), n = new Uint8Array(2 + t.length);
|
|
768
767
|
n[0] = 18, n[1] = 32, n.set(t, 2);
|
|
769
768
|
const s = new Uint8Array(2 + n.length);
|
|
770
|
-
return s[0] = 1, s[1] = 85, s.set(n, 2), "b" + new
|
|
769
|
+
return s[0] = 1, s[1] = 85, s.set(n, 2), "b" + new Xt.Encoder({ type: "rfc4648", lc: !0 }).write(s).finalize().replace(/=/g, "");
|
|
771
770
|
}
|
|
772
771
|
}
|
|
773
|
-
class
|
|
772
|
+
class V {
|
|
774
773
|
/**
|
|
775
774
|
* Transforms a node and all its child nodes using the provided transformer function
|
|
776
775
|
* @param node - The node to transform
|
|
@@ -779,50 +778,50 @@ class N {
|
|
|
779
778
|
*/
|
|
780
779
|
static transform(e, t) {
|
|
781
780
|
const n = t(e.clone()), s = n.getType();
|
|
782
|
-
s !== void 0 && n.setType(
|
|
781
|
+
s !== void 0 && n.setType(V.transform(s, t));
|
|
783
782
|
const i = n.getItemType();
|
|
784
783
|
i !== void 0 && n.setItemType(
|
|
785
|
-
|
|
784
|
+
V.transform(i, t)
|
|
786
785
|
);
|
|
787
786
|
const o = n.getKeyType();
|
|
788
787
|
o !== void 0 && n.setKeyType(
|
|
789
|
-
|
|
788
|
+
V.transform(o, t)
|
|
790
789
|
);
|
|
791
790
|
const c = n.getValueType();
|
|
792
791
|
c !== void 0 && n.setValueType(
|
|
793
|
-
|
|
792
|
+
V.transform(c, t)
|
|
794
793
|
);
|
|
795
|
-
const
|
|
796
|
-
if (
|
|
797
|
-
const
|
|
798
|
-
(
|
|
794
|
+
const l = n.getItems();
|
|
795
|
+
if (l !== void 0) {
|
|
796
|
+
const b = l.map(
|
|
797
|
+
(I) => V.transform(I, t)
|
|
799
798
|
);
|
|
800
|
-
n.setItems(
|
|
799
|
+
n.setItems(b);
|
|
801
800
|
}
|
|
802
|
-
const
|
|
803
|
-
if (
|
|
804
|
-
const
|
|
805
|
-
(
|
|
801
|
+
const h = n.getProperties();
|
|
802
|
+
if (h !== void 0) {
|
|
803
|
+
const b = Object.keys(h).reduce(
|
|
804
|
+
(I, m) => (I[m] = V.transform(h[m], t), I),
|
|
806
805
|
{}
|
|
807
806
|
);
|
|
808
|
-
n.setProperties(
|
|
807
|
+
n.setProperties(b);
|
|
809
808
|
}
|
|
810
|
-
const
|
|
811
|
-
if (
|
|
812
|
-
const
|
|
813
|
-
n.setContracts(
|
|
809
|
+
const T = n.getContracts();
|
|
810
|
+
if (T !== void 0) {
|
|
811
|
+
const b = Object.keys(T).reduce((I, m) => (I[m] = V.transform(T[m], t), I), {});
|
|
812
|
+
n.setContracts(b);
|
|
814
813
|
}
|
|
815
814
|
return n;
|
|
816
815
|
}
|
|
817
816
|
}
|
|
818
|
-
const
|
|
819
|
-
function
|
|
817
|
+
const $ = (r) => !!r && typeof r == "object" && !Array.isArray(r) && !(r instanceof a), M = (r) => r instanceof S || r instanceof C, wr = (r) => r.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
818
|
+
function ee(r) {
|
|
820
819
|
if (r === "/") return [];
|
|
821
820
|
if (!r.startsWith("/"))
|
|
822
821
|
throw new Error(`Path must start with '/': ${r}`);
|
|
823
|
-
return r.split("/").slice(1).map(
|
|
822
|
+
return r.split("/").slice(1).map(wr);
|
|
824
823
|
}
|
|
825
|
-
function
|
|
824
|
+
function K(r) {
|
|
826
825
|
if (r === "-") return -1;
|
|
827
826
|
const e = typeof r == "number" ? r : parseInt(r, 10);
|
|
828
827
|
if (isNaN(e))
|
|
@@ -833,7 +832,7 @@ function z(r) {
|
|
|
833
832
|
);
|
|
834
833
|
return e;
|
|
835
834
|
}
|
|
836
|
-
function
|
|
835
|
+
function Pt(r, e, t, n = !0) {
|
|
837
836
|
switch (e) {
|
|
838
837
|
case "name":
|
|
839
838
|
return t ? n ? r.getName() ?? null : r : r.getName();
|
|
@@ -863,9 +862,9 @@ function gt(r, e, t, n = !0) {
|
|
|
863
862
|
return;
|
|
864
863
|
}
|
|
865
864
|
}
|
|
866
|
-
function
|
|
867
|
-
if (r instanceof
|
|
868
|
-
const n =
|
|
865
|
+
function ct(r, e, t = !0) {
|
|
866
|
+
if (r instanceof a) {
|
|
867
|
+
const n = Pt(
|
|
869
868
|
r,
|
|
870
869
|
e,
|
|
871
870
|
!0,
|
|
@@ -895,12 +894,12 @@ function Qe(r, e, t = !0) {
|
|
|
895
894
|
}
|
|
896
895
|
if (Array.isArray(r)) {
|
|
897
896
|
if (e === "-") return;
|
|
898
|
-
const n =
|
|
897
|
+
const n = K(e);
|
|
899
898
|
return n >= 0 && n < r.length ? r[n] : void 0;
|
|
900
899
|
}
|
|
901
|
-
if (
|
|
900
|
+
if ($(r)) return r[e];
|
|
902
901
|
}
|
|
903
|
-
function
|
|
902
|
+
function te(r, e) {
|
|
904
903
|
if (e.length === 0)
|
|
905
904
|
return {
|
|
906
905
|
parent: r,
|
|
@@ -909,30 +908,30 @@ function H(r, e) {
|
|
|
909
908
|
};
|
|
910
909
|
let t = r;
|
|
911
910
|
for (let s = 0; s < e.length - 1; ++s) {
|
|
912
|
-
const i = e[s], o =
|
|
911
|
+
const i = e[s], o = ct(t, i);
|
|
913
912
|
if (o === void 0)
|
|
914
913
|
throw new Error(`Cannot resolve '/${e.slice(0, s + 1).join("/")}'`);
|
|
915
914
|
t = o;
|
|
916
915
|
}
|
|
917
916
|
const n = e[e.length - 1];
|
|
918
|
-
if (t instanceof
|
|
919
|
-
const s =
|
|
920
|
-
if ((typeof s != "object" || s === null ||
|
|
917
|
+
if (t instanceof a) {
|
|
918
|
+
const s = ct(t, n, !1);
|
|
919
|
+
if ((typeof s != "object" || s === null || M(s)) && !(s instanceof a) && !Array.isArray(s) && ["name", "description", "value", "blueId"].includes(n))
|
|
921
920
|
return {
|
|
922
921
|
parent: t,
|
|
923
922
|
key: n,
|
|
924
923
|
actualTarget: s
|
|
925
924
|
};
|
|
926
925
|
}
|
|
927
|
-
return Array.isArray(t) && n === "-" ? { parent: t, key: "-" } : t instanceof
|
|
926
|
+
return Array.isArray(t) && n === "-" ? { parent: t, key: "-" } : t instanceof a && t.getItems() && n === "-" ? { parent: t, key: "-" } : {
|
|
928
927
|
parent: t,
|
|
929
|
-
key: Array.isArray(t) ?
|
|
928
|
+
key: Array.isArray(t) ? K(n) : n
|
|
930
929
|
};
|
|
931
930
|
}
|
|
932
|
-
function
|
|
931
|
+
function rt(r, e) {
|
|
933
932
|
var t;
|
|
934
|
-
if (r instanceof
|
|
935
|
-
const n = e, s =
|
|
933
|
+
if (r instanceof a) {
|
|
934
|
+
const n = e, s = Pt(r, n, !1);
|
|
936
935
|
if (s !== void 0 || [
|
|
937
936
|
"name",
|
|
938
937
|
"description",
|
|
@@ -954,26 +953,26 @@ function Ke(r, e) {
|
|
|
954
953
|
}
|
|
955
954
|
return (t = r.getProperties()) == null ? void 0 : t[n];
|
|
956
955
|
}
|
|
957
|
-
return Array.isArray(r) ||
|
|
956
|
+
return Array.isArray(r) || $(r) ? r[e] : r;
|
|
958
957
|
}
|
|
959
|
-
function
|
|
960
|
-
if (r instanceof
|
|
961
|
-
if (r === null || typeof r == "string" || typeof r == "number" || typeof r == "boolean" ||
|
|
958
|
+
function B(r) {
|
|
959
|
+
if (r instanceof a) return r;
|
|
960
|
+
if (r === null || typeof r == "string" || typeof r == "number" || typeof r == "boolean" || M(r))
|
|
962
961
|
return p.deserialize(r);
|
|
963
|
-
const e =
|
|
962
|
+
const e = ke(r);
|
|
964
963
|
return p.deserialize(e);
|
|
965
964
|
}
|
|
966
|
-
function
|
|
965
|
+
function ke(r) {
|
|
967
966
|
if (r === void 0) return null;
|
|
968
967
|
if (r === null || typeof r != "object") return r;
|
|
969
|
-
if (Array.isArray(r)) return r.map(
|
|
968
|
+
if (Array.isArray(r)) return r.map(ke);
|
|
970
969
|
const e = {};
|
|
971
970
|
for (const [t, n] of Object.entries(r))
|
|
972
|
-
e[t] =
|
|
971
|
+
e[t] = ke(n);
|
|
973
972
|
return e;
|
|
974
973
|
}
|
|
975
|
-
function
|
|
976
|
-
if (r instanceof
|
|
974
|
+
function nt(r, e, t) {
|
|
975
|
+
if (r instanceof a) {
|
|
977
976
|
const n = e;
|
|
978
977
|
switch (n) {
|
|
979
978
|
case "name":
|
|
@@ -984,22 +983,22 @@ function Xe(r, e, t) {
|
|
|
984
983
|
return;
|
|
985
984
|
case "type":
|
|
986
985
|
r.setType(
|
|
987
|
-
t instanceof
|
|
986
|
+
t instanceof a || typeof t == "string" || t === void 0 ? t : B(t)
|
|
988
987
|
);
|
|
989
988
|
return;
|
|
990
989
|
case "itemType":
|
|
991
990
|
r.setItemType(
|
|
992
|
-
t instanceof
|
|
991
|
+
t instanceof a || typeof t == "string" || t === void 0 ? t : B(t)
|
|
993
992
|
);
|
|
994
993
|
return;
|
|
995
994
|
case "keyType":
|
|
996
995
|
r.setKeyType(
|
|
997
|
-
t instanceof
|
|
996
|
+
t instanceof a || typeof t == "string" || t === void 0 ? t : B(t)
|
|
998
997
|
);
|
|
999
998
|
return;
|
|
1000
999
|
case "valueType":
|
|
1001
1000
|
r.setValueType(
|
|
1002
|
-
t instanceof
|
|
1001
|
+
t instanceof a || typeof t == "string" || t === void 0 ? t : B(t)
|
|
1003
1002
|
);
|
|
1004
1003
|
return;
|
|
1005
1004
|
case "value": {
|
|
@@ -1012,7 +1011,7 @@ function Xe(r, e, t) {
|
|
|
1012
1011
|
return;
|
|
1013
1012
|
case "blue":
|
|
1014
1013
|
r.setBlue(
|
|
1015
|
-
t instanceof
|
|
1014
|
+
t instanceof a || t === void 0 ? t : B(t)
|
|
1016
1015
|
);
|
|
1017
1016
|
return;
|
|
1018
1017
|
case "items":
|
|
@@ -1029,14 +1028,14 @@ function Xe(r, e, t) {
|
|
|
1029
1028
|
const s = r.getProperties();
|
|
1030
1029
|
s && n in s && delete s[n];
|
|
1031
1030
|
} else
|
|
1032
|
-
r.getProperties() || r.setProperties({}), r.addProperty(n, t instanceof
|
|
1031
|
+
r.getProperties() || r.setProperties({}), r.addProperty(n, t instanceof a ? t : B(t));
|
|
1033
1032
|
return;
|
|
1034
1033
|
}
|
|
1035
1034
|
}
|
|
1036
1035
|
}
|
|
1037
|
-
Array.isArray(r) ? r.splice(
|
|
1036
|
+
Array.isArray(r) ? r.splice(K(e), 1) : $(r) && (t === void 0 ? delete r[e] : r[e] = t);
|
|
1038
1037
|
}
|
|
1039
|
-
function
|
|
1038
|
+
function vr(r, e, t, n) {
|
|
1040
1039
|
let s = -1;
|
|
1041
1040
|
if (e !== "-" && (s = typeof e == "number" ? e : parseInt(e, 10), isNaN(s)))
|
|
1042
1041
|
throw new Error(
|
|
@@ -1062,16 +1061,16 @@ function pr(r, e, t, n) {
|
|
|
1062
1061
|
} else
|
|
1063
1062
|
i.splice(s, 0, t);
|
|
1064
1063
|
}
|
|
1065
|
-
function
|
|
1064
|
+
function we(r, e, t, n) {
|
|
1066
1065
|
if (Array.isArray(r)) {
|
|
1067
|
-
const s = e === "-" ? r.length :
|
|
1066
|
+
const s = e === "-" ? r.length : K(e);
|
|
1068
1067
|
if (!n && s > r.length)
|
|
1069
1068
|
throw new Error(
|
|
1070
1069
|
`ADD operation failed: Target array index '${s}' is greater than array length ${r.length}. Path involving key '${e}'.`
|
|
1071
1070
|
);
|
|
1072
1071
|
if (s < 0 && e !== "-")
|
|
1073
1072
|
throw new Error(`Invalid negative array index: ${e}`);
|
|
1074
|
-
const i =
|
|
1073
|
+
const i = B(t);
|
|
1075
1074
|
if (n) {
|
|
1076
1075
|
if (s >= 0 && s < r.length) r[s] = i;
|
|
1077
1076
|
else if (s >= r.length) {
|
|
@@ -1083,266 +1082,266 @@ function pe(r, e, t, n) {
|
|
|
1083
1082
|
r.splice(s, 0, i);
|
|
1084
1083
|
return;
|
|
1085
1084
|
}
|
|
1086
|
-
if (r instanceof
|
|
1087
|
-
e === "-" || typeof e == "number" && !isNaN(e) || typeof e == "string" && /^\d+$/.test(e) ?
|
|
1085
|
+
if (r instanceof a) {
|
|
1086
|
+
e === "-" || typeof e == "number" && !isNaN(e) || typeof e == "string" && /^\d+$/.test(e) ? vr(r, e, B(t), n) : nt(r, e, t);
|
|
1088
1087
|
return;
|
|
1089
1088
|
}
|
|
1090
|
-
if (
|
|
1091
|
-
r[e] =
|
|
1089
|
+
if ($(r)) {
|
|
1090
|
+
r[e] = B(t);
|
|
1092
1091
|
return;
|
|
1093
1092
|
}
|
|
1094
1093
|
throw new Error(`Cannot insert into parent of type ${typeof r}`);
|
|
1095
1094
|
}
|
|
1096
|
-
function
|
|
1095
|
+
function Br(r, e) {
|
|
1097
1096
|
if (Array.isArray(r)) {
|
|
1098
|
-
const t =
|
|
1097
|
+
const t = K(e);
|
|
1099
1098
|
t === -1 && e === "-" ? r.length > 0 && r.pop() : t >= 0 && t < r.length && r.splice(t, 1);
|
|
1100
1099
|
return;
|
|
1101
1100
|
}
|
|
1102
|
-
if (r instanceof
|
|
1101
|
+
if (r instanceof a) {
|
|
1103
1102
|
if (typeof e == "number" || typeof e == "string" && /^-?\d+$/.test(e)) {
|
|
1104
1103
|
const t = r.getItems();
|
|
1105
1104
|
if (t) {
|
|
1106
|
-
const n =
|
|
1105
|
+
const n = K(e);
|
|
1107
1106
|
n === -1 && e === "-" ? t.length > 0 && t.pop() : n >= 0 && n < t.length && t.splice(n, 1), t.length === 0 && r.setItems(void 0);
|
|
1108
1107
|
return;
|
|
1109
1108
|
}
|
|
1110
1109
|
}
|
|
1111
|
-
|
|
1112
|
-
} else
|
|
1110
|
+
nt(r, e, void 0);
|
|
1111
|
+
} else $(r) && delete r[e];
|
|
1113
1112
|
}
|
|
1114
|
-
function
|
|
1115
|
-
if (r instanceof
|
|
1113
|
+
function Je(r) {
|
|
1114
|
+
if (r instanceof a) return r.clone();
|
|
1116
1115
|
if (Array.isArray(r))
|
|
1117
|
-
return r.map((t) =>
|
|
1118
|
-
if (
|
|
1116
|
+
return r.map((t) => Je(t));
|
|
1117
|
+
if ($(r)) {
|
|
1119
1118
|
const e = {};
|
|
1120
1119
|
return Object.keys(r).forEach((t) => {
|
|
1121
|
-
e[t] =
|
|
1120
|
+
e[t] = Je(r[t]);
|
|
1122
1121
|
}), e;
|
|
1123
1122
|
}
|
|
1124
1123
|
return r;
|
|
1125
1124
|
}
|
|
1126
|
-
function
|
|
1127
|
-
if (r === e || r instanceof
|
|
1125
|
+
function U(r, e) {
|
|
1126
|
+
if (r === e || r instanceof a && (r.isInlineValue() || r.getValue() !== void 0) && U(r.getValue() ?? null, e) || e instanceof a && (e.isInlineValue() || e.getValue() !== void 0) && U(r, e.getValue() ?? null))
|
|
1128
1127
|
return !0;
|
|
1129
|
-
if (r instanceof
|
|
1128
|
+
if (r instanceof a && e instanceof a || M(r) && M(e) || M(r) && typeof e == "number" || typeof r == "number" && M(e))
|
|
1130
1129
|
return r.toString() === e.toString();
|
|
1131
1130
|
if (Array.isArray(r) && Array.isArray(e))
|
|
1132
|
-
return r.length === e.length && r.every((t, n) =>
|
|
1133
|
-
if (
|
|
1131
|
+
return r.length === e.length && r.every((t, n) => U(t, e[n]));
|
|
1132
|
+
if ($(r) && $(e)) {
|
|
1134
1133
|
const t = Object.keys(r), n = Object.keys(e);
|
|
1135
|
-
return t.length === n.length && t.every((s) =>
|
|
1134
|
+
return t.length === n.length && t.every((s) => U(r[s], e[s]));
|
|
1136
1135
|
}
|
|
1137
1136
|
return !1;
|
|
1138
1137
|
}
|
|
1139
|
-
function
|
|
1140
|
-
const { parent: t, key: n } =
|
|
1141
|
-
return
|
|
1138
|
+
function At(r, e) {
|
|
1139
|
+
const { parent: t, key: n } = te(r, ee(e));
|
|
1140
|
+
return rt(t, n);
|
|
1142
1141
|
}
|
|
1143
|
-
function
|
|
1144
|
-
const n =
|
|
1142
|
+
function Ct(r, e, t) {
|
|
1143
|
+
const n = ee(e);
|
|
1145
1144
|
if (n.length === 0 && e === "/") {
|
|
1146
|
-
const o =
|
|
1145
|
+
const o = B(t);
|
|
1147
1146
|
r.setValue(o.getValue() ?? null), o.getItems() ? r.setItems(o.getItems()) : r.setItems(void 0);
|
|
1148
1147
|
return;
|
|
1149
1148
|
}
|
|
1150
|
-
const { parent: s, key: i } =
|
|
1151
|
-
|
|
1149
|
+
const { parent: s, key: i } = te(r, n);
|
|
1150
|
+
we(s, i, t, !0);
|
|
1152
1151
|
}
|
|
1153
|
-
function
|
|
1154
|
-
const n =
|
|
1152
|
+
function Er(r, e, t) {
|
|
1153
|
+
const n = ee(e);
|
|
1155
1154
|
if (n.length === 0 && e === "/") {
|
|
1156
1155
|
if (r.getItems() && Array.isArray(t)) {
|
|
1157
|
-
const o =
|
|
1156
|
+
const o = B(t);
|
|
1158
1157
|
o.getItems() ? (r.setItems(o.getItems()), r.setValue(null)) : (r.setValue(o.getValue() ?? null), r.setItems(void 0));
|
|
1159
1158
|
} else {
|
|
1160
|
-
const o =
|
|
1159
|
+
const o = B(t);
|
|
1161
1160
|
r.setValue(o.getValue() ?? null), o.getItems() && r.setItems(o.getItems());
|
|
1162
1161
|
}
|
|
1163
1162
|
return !0;
|
|
1164
1163
|
}
|
|
1165
|
-
const { parent: s, key: i } =
|
|
1166
|
-
return
|
|
1164
|
+
const { parent: s, key: i } = te(r, n);
|
|
1165
|
+
return we(s, i, t, !1), !0;
|
|
1167
1166
|
}
|
|
1168
|
-
function
|
|
1169
|
-
const n =
|
|
1167
|
+
function Nr(r, e, t) {
|
|
1168
|
+
const n = ee(e);
|
|
1170
1169
|
if (n.length === 0 && e === "/") {
|
|
1171
|
-
const c =
|
|
1170
|
+
const c = B(t);
|
|
1172
1171
|
return r.setValue(c.getValue() ?? null), c.getItems() ? r.setItems(c.getItems()) : r.setItems(void 0), !0;
|
|
1173
1172
|
}
|
|
1174
|
-
const { parent: s, key: i, actualTarget: o } =
|
|
1175
|
-
if (o !== void 0 && s instanceof
|
|
1176
|
-
|
|
1173
|
+
const { parent: s, key: i, actualTarget: o } = te(r, n);
|
|
1174
|
+
if (o !== void 0 && s instanceof a)
|
|
1175
|
+
nt(s, i, t);
|
|
1177
1176
|
else {
|
|
1178
|
-
const c =
|
|
1177
|
+
const c = rt(s, i), l = Array.isArray(s) || s instanceof a && s.getItems() && (typeof i == "number" || typeof i == "string" && /^\d+$/.test(i));
|
|
1179
1178
|
if (c === void 0) {
|
|
1180
|
-
if (
|
|
1179
|
+
if (l)
|
|
1181
1180
|
throw new Error(
|
|
1182
1181
|
`REPLACE failed: Target array index '${i.toString()}' is out of bounds or does not exist at path '${e}'.`
|
|
1183
1182
|
);
|
|
1184
|
-
|
|
1183
|
+
we(s, i, t, !0);
|
|
1185
1184
|
} else
|
|
1186
|
-
|
|
1185
|
+
we(s, i, t, !0);
|
|
1187
1186
|
}
|
|
1188
1187
|
return !0;
|
|
1189
1188
|
}
|
|
1190
|
-
function
|
|
1191
|
-
const t =
|
|
1189
|
+
function Vt(r, e) {
|
|
1190
|
+
const t = ee(e);
|
|
1192
1191
|
if (t.length === 0 && e === "/")
|
|
1193
1192
|
return r.setValue(null), r.setItems(void 0), r.setProperties(void 0), !0;
|
|
1194
|
-
const { parent: n, key: s } =
|
|
1195
|
-
return
|
|
1193
|
+
const { parent: n, key: s } = te(r, t);
|
|
1194
|
+
return Br(n, s), !0;
|
|
1196
1195
|
}
|
|
1197
|
-
function
|
|
1198
|
-
const n =
|
|
1199
|
-
return
|
|
1196
|
+
function Sr(r, e, t) {
|
|
1197
|
+
const n = Je(At(r, e));
|
|
1198
|
+
return Ct(r, t, n), !0;
|
|
1200
1199
|
}
|
|
1201
|
-
function
|
|
1202
|
-
const n =
|
|
1200
|
+
function Pr(r, e, t) {
|
|
1201
|
+
const n = ee(e), { parent: s, key: i } = te(r, n), o = rt(s, i);
|
|
1203
1202
|
if (o === void 0)
|
|
1204
1203
|
throw new Error(`MOVE failed: 'from' location '${e}' does not exist.`);
|
|
1205
|
-
return
|
|
1204
|
+
return Vt(r, e) ? (Ct(r, t, o), !0) : !1;
|
|
1206
1205
|
}
|
|
1207
|
-
function
|
|
1208
|
-
const n =
|
|
1206
|
+
function Ar(r, e, t) {
|
|
1207
|
+
const n = At(r, e);
|
|
1209
1208
|
let s = t;
|
|
1210
|
-
if (n instanceof
|
|
1211
|
-
if ((t === null || typeof t == "string" || typeof t == "number" || typeof t == "boolean" ||
|
|
1212
|
-
if (
|
|
1209
|
+
if (n instanceof a)
|
|
1210
|
+
if ((t === null || typeof t == "string" || typeof t == "number" || typeof t == "boolean" || M(t)) && (n.isInlineValue() || n.getValue() !== void 0)) {
|
|
1211
|
+
if (!U(n.getValue() ?? null, t))
|
|
1213
1212
|
throw new Error(
|
|
1214
1213
|
`TEST failed at '${e}': Expected ${JSON.stringify(
|
|
1215
1214
|
t
|
|
1216
1215
|
)}, got ${JSON.stringify(n.getValue() ?? null)}`
|
|
1217
1216
|
);
|
|
1218
1217
|
return !0;
|
|
1219
|
-
} else typeof t == "object" && !(t instanceof
|
|
1220
|
-
else if (
|
|
1221
|
-
n instanceof
|
|
1222
|
-
else if ((n === null || typeof n == "string" || typeof n == "number" || typeof n == "boolean") &&
|
|
1218
|
+
} else typeof t == "object" && !(t instanceof a) && (s = B(t));
|
|
1219
|
+
else if (M(n) && typeof t == "number")
|
|
1220
|
+
n instanceof S ? s = new S(t.toString()) : n instanceof C && (s = new C(t.toString()));
|
|
1221
|
+
else if ((n === null || typeof n == "string" || typeof n == "number" || typeof n == "boolean") && M(t)) {
|
|
1223
1222
|
const i = t;
|
|
1224
|
-
|
|
1223
|
+
!U(n, i.toString()) && (typeof n == "number" && parseFloat(i.toString()));
|
|
1225
1224
|
}
|
|
1226
|
-
if (
|
|
1227
|
-
const i = n instanceof
|
|
1225
|
+
if (!U(n, s)) {
|
|
1226
|
+
const i = n instanceof a ? n.toString() : JSON.stringify(n), o = s instanceof a ? s.toString() : JSON.stringify(s);
|
|
1228
1227
|
throw new Error(
|
|
1229
1228
|
`TEST failed at '${e}': Expected ${o}, got ${i}`
|
|
1230
1229
|
);
|
|
1231
1230
|
}
|
|
1232
1231
|
return !0;
|
|
1233
1232
|
}
|
|
1234
|
-
function
|
|
1233
|
+
function Cr(r, e) {
|
|
1235
1234
|
switch (e.op) {
|
|
1236
1235
|
case "add":
|
|
1237
|
-
return
|
|
1236
|
+
return Er(r, e.path, e.val);
|
|
1238
1237
|
case "replace":
|
|
1239
|
-
return
|
|
1238
|
+
return Nr(r, e.path, e.val);
|
|
1240
1239
|
case "remove":
|
|
1241
|
-
return
|
|
1240
|
+
return Vt(r, e.path);
|
|
1242
1241
|
case "copy":
|
|
1243
|
-
return
|
|
1242
|
+
return Sr(r, e.from, e.path);
|
|
1244
1243
|
case "move":
|
|
1245
|
-
return
|
|
1244
|
+
return Pr(r, e.from, e.path);
|
|
1246
1245
|
case "test":
|
|
1247
|
-
return
|
|
1246
|
+
return Ar(r, e.path, e.val);
|
|
1248
1247
|
}
|
|
1249
1248
|
}
|
|
1250
|
-
function
|
|
1249
|
+
function as(r, e, t = !1) {
|
|
1251
1250
|
const n = t ? r : r.clone();
|
|
1252
|
-
return
|
|
1251
|
+
return Cr(n, e), n;
|
|
1253
1252
|
}
|
|
1254
|
-
const
|
|
1255
|
-
function
|
|
1253
|
+
const Re = Symbol.for("zod-schema-annotations");
|
|
1254
|
+
function Vr() {
|
|
1256
1255
|
if (typeof globalThis < "u") return globalThis;
|
|
1257
1256
|
if (typeof global < "u") return global;
|
|
1258
1257
|
if (typeof window < "u") return window;
|
|
1259
1258
|
if (typeof self < "u") return self;
|
|
1260
1259
|
throw new Error("Unable to locate global object");
|
|
1261
1260
|
}
|
|
1262
|
-
function
|
|
1263
|
-
const r =
|
|
1264
|
-
return
|
|
1261
|
+
function Ot() {
|
|
1262
|
+
const r = Vr();
|
|
1263
|
+
return Re in r || (r[Re] = /* @__PURE__ */ new WeakMap()), r[Re];
|
|
1265
1264
|
}
|
|
1266
|
-
function
|
|
1267
|
-
const t =
|
|
1265
|
+
function re(r, e) {
|
|
1266
|
+
const t = Ot(), n = t.get(r) || {};
|
|
1268
1267
|
return t.set(r, { ...n, ...e }), r;
|
|
1269
1268
|
}
|
|
1270
|
-
const
|
|
1271
|
-
const t =
|
|
1272
|
-
return
|
|
1269
|
+
const P = (r) => Ot().get(r), Or = (r) => (e) => {
|
|
1270
|
+
const t = P(e);
|
|
1271
|
+
return re(e, {
|
|
1273
1272
|
...t,
|
|
1274
1273
|
blueDescription: r
|
|
1275
1274
|
});
|
|
1276
|
-
},
|
|
1277
|
-
const e =
|
|
1278
|
-
return
|
|
1279
|
-
},
|
|
1280
|
-
const t =
|
|
1281
|
-
return
|
|
1275
|
+
}, Dr = (r) => {
|
|
1276
|
+
const e = P(r);
|
|
1277
|
+
return f(e) && We(e.blueDescription) ? e.blueDescription : null;
|
|
1278
|
+
}, us = (r) => Or(r)(d.string().optional()), Fr = d.union([d.string(), d.boolean()]), Rr = (r) => (e) => {
|
|
1279
|
+
const t = P(e);
|
|
1280
|
+
return re(e, {
|
|
1282
1281
|
...t,
|
|
1283
1282
|
blueId: r
|
|
1284
1283
|
});
|
|
1285
|
-
},
|
|
1286
|
-
const e =
|
|
1284
|
+
}, Mr = (r) => {
|
|
1285
|
+
const e = P(r), t = Fr.safeParse(e == null ? void 0 : e.blueId);
|
|
1287
1286
|
return t.success ? t.data : null;
|
|
1288
|
-
},
|
|
1289
|
-
const t =
|
|
1290
|
-
return
|
|
1287
|
+
}, ds = (r) => Rr(r ?? !0)(d.string()), jr = (r) => (e) => {
|
|
1288
|
+
const t = P(e);
|
|
1289
|
+
return re(e, {
|
|
1291
1290
|
...t,
|
|
1292
1291
|
blueName: r
|
|
1293
1292
|
});
|
|
1294
|
-
},
|
|
1295
|
-
const e =
|
|
1296
|
-
return
|
|
1297
|
-
},
|
|
1298
|
-
const e =
|
|
1299
|
-
return
|
|
1300
|
-
},
|
|
1301
|
-
const e =
|
|
1302
|
-
return
|
|
1293
|
+
}, xr = (r) => {
|
|
1294
|
+
const e = P(r);
|
|
1295
|
+
return f(e) && We(e.blueName) ? e.blueName : null;
|
|
1296
|
+
}, fs = (r) => {
|
|
1297
|
+
const e = d.string().optional();
|
|
1298
|
+
return jr(r)(e);
|
|
1299
|
+
}, $r = () => (r) => {
|
|
1300
|
+
const e = P(r);
|
|
1301
|
+
return re(r, {
|
|
1303
1302
|
...e,
|
|
1304
1303
|
blueNode: !0
|
|
1305
1304
|
});
|
|
1306
|
-
},
|
|
1307
|
-
const e =
|
|
1308
|
-
return
|
|
1309
|
-
},
|
|
1310
|
-
const r =
|
|
1311
|
-
return
|
|
1312
|
-
},
|
|
1305
|
+
}, Ur = (r) => {
|
|
1306
|
+
const e = P(r);
|
|
1307
|
+
return f(e) && f(e.blueNode) && e.blueNode === !0 ? e.blueNode : null;
|
|
1308
|
+
}, Dt = (r) => !!Ur(r), hs = () => {
|
|
1309
|
+
const r = d.instanceof(a);
|
|
1310
|
+
return $r()(r);
|
|
1311
|
+
}, Ge = "extendedFrom", Lr = ({
|
|
1313
1312
|
schema: r,
|
|
1314
1313
|
baseSchema: e
|
|
1315
1314
|
}) => {
|
|
1316
|
-
const t =
|
|
1317
|
-
return
|
|
1315
|
+
const t = P(r) || {};
|
|
1316
|
+
return re(r, {
|
|
1318
1317
|
...t,
|
|
1319
|
-
[
|
|
1318
|
+
[Ge]: e
|
|
1320
1319
|
});
|
|
1321
|
-
},
|
|
1322
|
-
const e =
|
|
1323
|
-
return
|
|
1324
|
-
},
|
|
1325
|
-
const t =
|
|
1326
|
-
return
|
|
1327
|
-
},
|
|
1320
|
+
}, _r = (r) => {
|
|
1321
|
+
const e = P(r);
|
|
1322
|
+
return f(e) && e[Ge] ? e[Ge] : null;
|
|
1323
|
+
}, Ft = (r, e) => {
|
|
1324
|
+
const t = _r(r);
|
|
1325
|
+
return N(t) ? !1 : (t == null ? void 0 : t._def) === (e == null ? void 0 : e._def) ? !0 : Ft(t, e);
|
|
1326
|
+
}, Zr = (r) => new Proxy(r, {
|
|
1328
1327
|
get(e, t, n) {
|
|
1329
1328
|
return t === "extend" ? function(...s) {
|
|
1330
1329
|
const i = e.extend(...s);
|
|
1331
|
-
return
|
|
1330
|
+
return Lr({
|
|
1332
1331
|
schema: i,
|
|
1333
1332
|
baseSchema: e
|
|
1334
1333
|
});
|
|
1335
1334
|
} : Reflect.get(e, t, n);
|
|
1336
1335
|
}
|
|
1337
|
-
}),
|
|
1338
|
-
value:
|
|
1339
|
-
defaultValue:
|
|
1340
|
-
}),
|
|
1341
|
-
const e =
|
|
1336
|
+
}), kr = d.object({
|
|
1337
|
+
value: d.array(d.string()).optional(),
|
|
1338
|
+
defaultValue: d.string().optional()
|
|
1339
|
+
}), Jr = (r) => {
|
|
1340
|
+
const e = P(r), t = kr.passthrough().safeParse(e == null ? void 0 : e.typeBlueId);
|
|
1342
1341
|
return t.success ? t.data : null;
|
|
1343
|
-
},
|
|
1344
|
-
const t =
|
|
1345
|
-
return
|
|
1342
|
+
}, ps = (r) => (e) => {
|
|
1343
|
+
const t = P(e), n = typeof r == "string" ? { value: [r] } : r, s = Zr(e);
|
|
1344
|
+
return re(s, {
|
|
1346
1345
|
...t,
|
|
1347
1346
|
typeBlueId: {
|
|
1348
1347
|
...(t == null ? void 0 : t.typeBlueId) || {},
|
|
@@ -1350,34 +1349,34 @@ const E = (r) => Tt().get(r), Br = (r) => (e) => {
|
|
|
1350
1349
|
}
|
|
1351
1350
|
});
|
|
1352
1351
|
};
|
|
1353
|
-
class
|
|
1352
|
+
class Ce {
|
|
1354
1353
|
static resolveBlueId(e) {
|
|
1355
1354
|
var i;
|
|
1356
|
-
const t =
|
|
1357
|
-
if (
|
|
1355
|
+
const t = Jr(e);
|
|
1356
|
+
if (N(t))
|
|
1358
1357
|
return null;
|
|
1359
1358
|
const n = t.defaultValue;
|
|
1360
|
-
if (
|
|
1359
|
+
if (f(n))
|
|
1361
1360
|
return n;
|
|
1362
1361
|
const s = (i = t.value) == null ? void 0 : i[0];
|
|
1363
|
-
return
|
|
1362
|
+
return f(s) ? s : Ce.getRepositoryBlueId(t, e);
|
|
1364
1363
|
}
|
|
1365
1364
|
static getRepositoryBlueId(e, t) {
|
|
1366
1365
|
throw new Error("Not implemented");
|
|
1367
1366
|
}
|
|
1368
1367
|
}
|
|
1369
|
-
class
|
|
1368
|
+
class A {
|
|
1370
1369
|
// TODO: Enhance to support schemas associated with multiple blueIds
|
|
1371
1370
|
static isTypeOf(e, t, n) {
|
|
1372
1371
|
var o;
|
|
1373
|
-
const s =
|
|
1374
|
-
if (
|
|
1372
|
+
const s = Ce.resolveBlueId(t), i = (o = e.getType()) == null ? void 0 : o.getBlueId();
|
|
1373
|
+
if (N(s) || N(i))
|
|
1375
1374
|
return !1;
|
|
1376
1375
|
if (s === i)
|
|
1377
1376
|
return !0;
|
|
1378
|
-
if (n != null && n.checkSchemaExtensions &&
|
|
1377
|
+
if (n != null && n.checkSchemaExtensions && f(n.typeSchemaResolver)) {
|
|
1379
1378
|
const c = n.typeSchemaResolver.resolveSchema(e);
|
|
1380
|
-
return
|
|
1379
|
+
return A.checkSchemaExtension(c, t);
|
|
1381
1380
|
}
|
|
1382
1381
|
return !1;
|
|
1383
1382
|
}
|
|
@@ -1385,19 +1384,19 @@ class P {
|
|
|
1385
1384
|
* Checks if a schema extends a base schema.
|
|
1386
1385
|
*/
|
|
1387
1386
|
static checkSchemaExtension(e, t) {
|
|
1388
|
-
if (!
|
|
1387
|
+
if (!f(e))
|
|
1389
1388
|
return !1;
|
|
1390
|
-
const n =
|
|
1391
|
-
return
|
|
1389
|
+
const n = A.unwrapSchema(e), s = A.unwrapSchema(t);
|
|
1390
|
+
return Ft(n, s);
|
|
1392
1391
|
}
|
|
1393
1392
|
static isWrapperType(e) {
|
|
1394
|
-
return e instanceof
|
|
1393
|
+
return e instanceof ht || e instanceof pt || e instanceof yt || e instanceof gt || e instanceof me || e instanceof Ie;
|
|
1395
1394
|
}
|
|
1396
1395
|
static unwrapSchema(e) {
|
|
1397
|
-
return
|
|
1396
|
+
return Dt(e) ? e : A.isWrapperType(e) ? e instanceof me ? A.unwrapSchema(e.innerType()) : e instanceof Ie ? A.unwrapSchema(e.schema) : A.unwrapSchema(e.unwrap()) : e;
|
|
1398
1397
|
}
|
|
1399
1398
|
}
|
|
1400
|
-
class
|
|
1399
|
+
class Gr {
|
|
1401
1400
|
constructor(e) {
|
|
1402
1401
|
u(this, "blueIdMap", /* @__PURE__ */ new Map());
|
|
1403
1402
|
this.registerSchemas(e);
|
|
@@ -1407,8 +1406,8 @@ class Ur {
|
|
|
1407
1406
|
this.registerSchema(t);
|
|
1408
1407
|
}
|
|
1409
1408
|
registerSchema(e) {
|
|
1410
|
-
const t =
|
|
1411
|
-
if (
|
|
1409
|
+
const t = Ce.resolveBlueId(e);
|
|
1410
|
+
if (f(t)) {
|
|
1412
1411
|
if (this.blueIdMap.has(t))
|
|
1413
1412
|
throw new Error(`Duplicate BlueId value: ${t}`);
|
|
1414
1413
|
this.blueIdMap.set(t, e);
|
|
@@ -1416,74 +1415,74 @@ class Ur {
|
|
|
1416
1415
|
}
|
|
1417
1416
|
resolveSchema(e) {
|
|
1418
1417
|
const t = this.getEffectiveBlueId(e);
|
|
1419
|
-
return
|
|
1418
|
+
return N(t) ? null : this.blueIdMap.get(t);
|
|
1420
1419
|
}
|
|
1421
1420
|
getEffectiveBlueId(e) {
|
|
1422
1421
|
const t = e.getType();
|
|
1423
|
-
return
|
|
1422
|
+
return f(t) && f(t.getBlueId()) ? t.getBlueId() : f(t) ? w.calculateBlueIdSync(t) : null;
|
|
1424
1423
|
}
|
|
1425
1424
|
getBlueIdMap() {
|
|
1426
1425
|
return new Map(this.blueIdMap);
|
|
1427
1426
|
}
|
|
1428
1427
|
}
|
|
1429
|
-
class
|
|
1428
|
+
class Rt {
|
|
1430
1429
|
static convertValue(e, t) {
|
|
1431
1430
|
var i;
|
|
1432
1431
|
const n = (i = e.getType()) == null ? void 0 : i.getBlueId(), s = e.getValue();
|
|
1433
|
-
return
|
|
1434
|
-
new
|
|
1432
|
+
return N(s) ? this.isPrimitive(t) ? this.getDefaultPrimitiveValue(t) : s : H === n ? this.convertFromString(String(s), t) : X === n || s instanceof C ? this.convertFromBigDecimal(
|
|
1433
|
+
new C(s == null ? void 0 : s.toString()),
|
|
1435
1434
|
t
|
|
1436
|
-
) :
|
|
1437
|
-
new
|
|
1435
|
+
) : q === n || s instanceof S ? this.convertFromBigInteger(
|
|
1436
|
+
new S(s == null ? void 0 : s.toString()),
|
|
1438
1437
|
t
|
|
1439
|
-
) :
|
|
1438
|
+
) : Q === n || typeof s == "boolean" ? this.convertFromBoolean(!!s, t) : this.convertFromString(String(s), t);
|
|
1440
1439
|
}
|
|
1441
1440
|
static convertFromString(e, t) {
|
|
1442
|
-
if (!t || t instanceof k || t instanceof
|
|
1441
|
+
if (!t || t instanceof k || t instanceof Jt || t instanceof Gt)
|
|
1443
1442
|
return e;
|
|
1444
|
-
if (t instanceof
|
|
1443
|
+
if (t instanceof J)
|
|
1445
1444
|
return Number(e);
|
|
1446
|
-
if (t instanceof
|
|
1445
|
+
if (t instanceof pe)
|
|
1447
1446
|
return e.toLowerCase() === "true";
|
|
1448
|
-
if (t instanceof
|
|
1447
|
+
if (t instanceof ye)
|
|
1449
1448
|
return BigInt(e);
|
|
1450
1449
|
throw new Error(`Cannot convert String to ${t._def.typeName}`);
|
|
1451
1450
|
}
|
|
1452
1451
|
static convertFromBigDecimal(e, t) {
|
|
1453
|
-
if (t instanceof
|
|
1452
|
+
if (t instanceof J)
|
|
1454
1453
|
return e.toNumber();
|
|
1455
1454
|
if (t instanceof k)
|
|
1456
1455
|
return e.toString();
|
|
1457
1456
|
throw new Error(`Cannot convert Number to ${t._def.typeName}`);
|
|
1458
1457
|
}
|
|
1459
1458
|
static convertFromBigInteger(e, t) {
|
|
1460
|
-
if (t instanceof
|
|
1459
|
+
if (t instanceof J)
|
|
1461
1460
|
return e.toNumber();
|
|
1462
|
-
if (t instanceof
|
|
1461
|
+
if (t instanceof ye)
|
|
1463
1462
|
return BigInt(e.toString());
|
|
1464
1463
|
if (t instanceof k)
|
|
1465
1464
|
return e.toString();
|
|
1466
1465
|
throw new Error(`Cannot convert Number to ${t._def.typeName}`);
|
|
1467
1466
|
}
|
|
1468
1467
|
static convertFromBoolean(e, t) {
|
|
1469
|
-
if (!t || t instanceof
|
|
1468
|
+
if (!t || t instanceof pe)
|
|
1470
1469
|
return e;
|
|
1471
1470
|
if (t instanceof k)
|
|
1472
1471
|
return e.toString();
|
|
1473
|
-
if (t instanceof
|
|
1472
|
+
if (t instanceof J)
|
|
1474
1473
|
return Number(e);
|
|
1475
|
-
if (t instanceof
|
|
1474
|
+
if (t instanceof ye)
|
|
1476
1475
|
return BigInt(e);
|
|
1477
1476
|
throw new Error(`Cannot convert Boolean to ${t._def.typeName}`);
|
|
1478
1477
|
}
|
|
1479
1478
|
static isPrimitive(e) {
|
|
1480
|
-
return e ? e instanceof k || e instanceof
|
|
1479
|
+
return e ? e instanceof k || e instanceof J || e instanceof pe || e instanceof ye : !1;
|
|
1481
1480
|
}
|
|
1482
1481
|
static getDefaultPrimitiveValue(e) {
|
|
1483
1482
|
if (!e) return null;
|
|
1484
|
-
if (e instanceof
|
|
1483
|
+
if (e instanceof J)
|
|
1485
1484
|
return 0;
|
|
1486
|
-
if (e instanceof
|
|
1485
|
+
if (e instanceof pe)
|
|
1487
1486
|
return !1;
|
|
1488
1487
|
if (e instanceof k)
|
|
1489
1488
|
return "";
|
|
@@ -1492,12 +1491,12 @@ class Bt {
|
|
|
1492
1491
|
);
|
|
1493
1492
|
}
|
|
1494
1493
|
}
|
|
1495
|
-
class
|
|
1494
|
+
class Yr {
|
|
1496
1495
|
convert(e, t) {
|
|
1497
|
-
return
|
|
1496
|
+
return Rt.convertValue(e, t);
|
|
1498
1497
|
}
|
|
1499
1498
|
}
|
|
1500
|
-
class
|
|
1499
|
+
class zr {
|
|
1501
1500
|
constructor(e) {
|
|
1502
1501
|
this.nodeToObjectConverter = e;
|
|
1503
1502
|
}
|
|
@@ -1505,69 +1504,69 @@ class Mr {
|
|
|
1505
1504
|
* Check if the valueSchema can handle structured data (contracts should be processed specially)
|
|
1506
1505
|
*/
|
|
1507
1506
|
canHandleStructuredData(e) {
|
|
1508
|
-
return e instanceof
|
|
1507
|
+
return e instanceof mt || e instanceof Ue || e instanceof Le || e instanceof It || e instanceof Tt;
|
|
1509
1508
|
}
|
|
1510
1509
|
convert(e, t) {
|
|
1511
1510
|
return this.convertFields(e, t);
|
|
1512
1511
|
}
|
|
1513
1512
|
convertFields(e, t) {
|
|
1514
|
-
if (t instanceof
|
|
1513
|
+
if (t instanceof Yt) {
|
|
1515
1514
|
const n = t._def.left, s = t._def.right, i = this.convert(e, n), o = this.convert(e, s);
|
|
1516
1515
|
return { ...i, ...o };
|
|
1517
1516
|
}
|
|
1518
|
-
if (t instanceof
|
|
1517
|
+
if (t instanceof zt)
|
|
1519
1518
|
throw new Error("Union not supported");
|
|
1520
|
-
if (t instanceof
|
|
1519
|
+
if (t instanceof Ue)
|
|
1521
1520
|
return Object.keys(t.shape).reduce((s, i) => {
|
|
1522
|
-
const o = e.getProperties(), c = t.shape[i],
|
|
1523
|
-
if (
|
|
1524
|
-
const
|
|
1525
|
-
return s[i] =
|
|
1521
|
+
const o = e.getProperties(), c = t.shape[i], l = Mr(c);
|
|
1522
|
+
if (f(l)) {
|
|
1523
|
+
const g = We(l) ? l : i, v = o == null ? void 0 : o[g], D = v ? w.calculateBlueIdSync(v) : void 0;
|
|
1524
|
+
return s[i] = D, s;
|
|
1526
1525
|
}
|
|
1527
|
-
const
|
|
1528
|
-
if (
|
|
1529
|
-
const
|
|
1530
|
-
return s[i] =
|
|
1526
|
+
const h = xr(c);
|
|
1527
|
+
if (f(h)) {
|
|
1528
|
+
const g = o == null ? void 0 : o[h];
|
|
1529
|
+
return s[i] = g == null ? void 0 : g.getName(), s;
|
|
1531
1530
|
}
|
|
1532
|
-
const
|
|
1533
|
-
if (
|
|
1534
|
-
const
|
|
1535
|
-
return s[i] =
|
|
1531
|
+
const T = Dr(c);
|
|
1532
|
+
if (f(T)) {
|
|
1533
|
+
const g = o == null ? void 0 : o[T];
|
|
1534
|
+
return s[i] = g == null ? void 0 : g.getDescription(), s;
|
|
1536
1535
|
}
|
|
1537
1536
|
if (i === "name") {
|
|
1538
|
-
const
|
|
1539
|
-
return s[i] =
|
|
1537
|
+
const g = e.getName();
|
|
1538
|
+
return s[i] = g, s;
|
|
1540
1539
|
}
|
|
1541
1540
|
if (i === "description") {
|
|
1542
|
-
const
|
|
1543
|
-
return s[i] =
|
|
1541
|
+
const g = e.getDescription();
|
|
1542
|
+
return s[i] = g, s;
|
|
1544
1543
|
}
|
|
1545
|
-
const
|
|
1546
|
-
if (i === "contracts" &&
|
|
1547
|
-
const
|
|
1548
|
-
Object.entries(
|
|
1549
|
-
|
|
1550
|
-
|
|
1544
|
+
const b = e.getContracts();
|
|
1545
|
+
if (i === "contracts" && f(b) && this.canHandleStructuredData(c)) {
|
|
1546
|
+
const g = Object.fromEntries(
|
|
1547
|
+
Object.entries(b).map(([D, he]) => [
|
|
1548
|
+
D,
|
|
1549
|
+
y.get(he)
|
|
1551
1550
|
])
|
|
1552
|
-
),
|
|
1551
|
+
), v = p.deserialize(g);
|
|
1553
1552
|
s[i] = this.nodeToObjectConverter.convert(
|
|
1554
|
-
|
|
1553
|
+
v,
|
|
1555
1554
|
c
|
|
1556
1555
|
);
|
|
1557
1556
|
}
|
|
1558
|
-
const
|
|
1559
|
-
if (
|
|
1557
|
+
const I = o == null ? void 0 : o[i];
|
|
1558
|
+
if (N(I))
|
|
1560
1559
|
return s;
|
|
1561
|
-
const
|
|
1562
|
-
|
|
1560
|
+
const m = this.nodeToObjectConverter.convert(
|
|
1561
|
+
I,
|
|
1563
1562
|
c
|
|
1564
1563
|
);
|
|
1565
|
-
return s[i] =
|
|
1564
|
+
return s[i] = m, s;
|
|
1566
1565
|
}, {});
|
|
1567
1566
|
throw new Error("Unknown schema type, " + t._def.typeName);
|
|
1568
1567
|
}
|
|
1569
1568
|
}
|
|
1570
|
-
class
|
|
1569
|
+
class Kr {
|
|
1571
1570
|
constructor(e) {
|
|
1572
1571
|
this.nodeToObjectConverter = e;
|
|
1573
1572
|
}
|
|
@@ -1581,7 +1580,7 @@ class Lr {
|
|
|
1581
1580
|
);
|
|
1582
1581
|
}
|
|
1583
1582
|
}
|
|
1584
|
-
class
|
|
1583
|
+
class Wr {
|
|
1585
1584
|
constructor(e) {
|
|
1586
1585
|
this.nodeToObjectConverter = e;
|
|
1587
1586
|
}
|
|
@@ -1595,7 +1594,7 @@ class Zr {
|
|
|
1595
1594
|
return new Set(i);
|
|
1596
1595
|
}
|
|
1597
1596
|
}
|
|
1598
|
-
class
|
|
1597
|
+
class Hr {
|
|
1599
1598
|
constructor(e) {
|
|
1600
1599
|
this.nodeToObjectConverter = e;
|
|
1601
1600
|
}
|
|
@@ -1603,52 +1602,52 @@ class kr {
|
|
|
1603
1602
|
* Check if the valueSchema can handle structured data (contracts should be processed specially)
|
|
1604
1603
|
*/
|
|
1605
1604
|
canHandleStructuredData(e) {
|
|
1606
|
-
return e instanceof
|
|
1605
|
+
return e instanceof mt || e instanceof Ue || e instanceof Le || e instanceof It || e instanceof Tt;
|
|
1607
1606
|
}
|
|
1608
1607
|
convert(e, t) {
|
|
1609
1608
|
const n = t.keySchema, s = t.valueSchema, i = /* @__PURE__ */ new Map(), o = e.getName();
|
|
1610
|
-
|
|
1609
|
+
f(o) && i.set(Y, o);
|
|
1611
1610
|
const c = e.getDescription();
|
|
1612
|
-
|
|
1613
|
-
const
|
|
1614
|
-
if (
|
|
1615
|
-
let
|
|
1616
|
-
const
|
|
1617
|
-
(
|
|
1611
|
+
f(c) && i.set(z, c);
|
|
1612
|
+
const l = e.getContracts();
|
|
1613
|
+
if (f(l) && this.canHandleStructuredData(s)) {
|
|
1614
|
+
let T = !1;
|
|
1615
|
+
const b = Object.entries(l).reduce(
|
|
1616
|
+
(I, [m, g]) => {
|
|
1618
1617
|
try {
|
|
1619
|
-
const
|
|
1620
|
-
|
|
1618
|
+
const v = this.nodeToObjectConverter.convert(
|
|
1619
|
+
g,
|
|
1621
1620
|
s
|
|
1622
1621
|
);
|
|
1623
|
-
|
|
1622
|
+
v != null && !Number.isNaN(v) && (I[m] = v, T = !0);
|
|
1624
1623
|
} catch {
|
|
1625
1624
|
}
|
|
1626
|
-
return
|
|
1625
|
+
return I;
|
|
1627
1626
|
},
|
|
1628
1627
|
{}
|
|
1629
1628
|
);
|
|
1630
|
-
|
|
1629
|
+
T && i.set(Pe, b);
|
|
1631
1630
|
}
|
|
1632
|
-
const
|
|
1633
|
-
return
|
|
1634
|
-
const
|
|
1635
|
-
|
|
1636
|
-
const
|
|
1637
|
-
i.set(
|
|
1638
|
-
}), t instanceof
|
|
1631
|
+
const h = e.getProperties();
|
|
1632
|
+
return f(h) && Object.entries(h).forEach(([T, b]) => {
|
|
1633
|
+
const I = new a().setValue(T);
|
|
1634
|
+
I.setType(new a().setBlueId(H));
|
|
1635
|
+
const m = Rt.convertValue(I, n), g = this.nodeToObjectConverter.convert(b, s);
|
|
1636
|
+
i.set(m, g);
|
|
1637
|
+
}), t instanceof Le ? Object.fromEntries(i) : i;
|
|
1639
1638
|
}
|
|
1640
1639
|
}
|
|
1641
|
-
class
|
|
1640
|
+
class Xr {
|
|
1642
1641
|
convert(e) {
|
|
1643
|
-
return
|
|
1642
|
+
return y.get(e);
|
|
1644
1643
|
}
|
|
1645
1644
|
}
|
|
1646
|
-
class
|
|
1645
|
+
class qr {
|
|
1647
1646
|
convert(e) {
|
|
1648
|
-
return
|
|
1647
|
+
return y.get(e);
|
|
1649
1648
|
}
|
|
1650
1649
|
}
|
|
1651
|
-
class
|
|
1650
|
+
class Qr {
|
|
1652
1651
|
constructor(e) {
|
|
1653
1652
|
this.nodeToObjectConverter = e;
|
|
1654
1653
|
}
|
|
@@ -1662,73 +1661,73 @@ class Gr {
|
|
|
1662
1661
|
);
|
|
1663
1662
|
}
|
|
1664
1663
|
}
|
|
1665
|
-
const
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1664
|
+
const en = d.union([
|
|
1665
|
+
d.literal("ZodString"),
|
|
1666
|
+
d.literal("ZodNumber"),
|
|
1667
|
+
d.literal("ZodBoolean"),
|
|
1668
|
+
d.literal("ZodBigInt"),
|
|
1669
|
+
d.literal("ZodArray"),
|
|
1670
|
+
d.literal("ZodSet"),
|
|
1671
|
+
d.literal("ZodMap"),
|
|
1672
|
+
d.literal("ZodRecord"),
|
|
1673
|
+
d.literal("ZodObject"),
|
|
1674
|
+
d.literal("ZodEnum"),
|
|
1675
|
+
d.literal("ZodNativeEnum"),
|
|
1676
|
+
d.literal("ZodUnknown"),
|
|
1677
|
+
d.literal("ZodAny"),
|
|
1678
|
+
d.literal("ZodTuple")
|
|
1680
1679
|
]);
|
|
1681
|
-
class
|
|
1680
|
+
class tn {
|
|
1682
1681
|
constructor(e) {
|
|
1683
1682
|
u(this, "converters", /* @__PURE__ */ new Map());
|
|
1684
1683
|
u(this, "complexObjectConverter");
|
|
1685
|
-
this.nodeToObjectConverter = e, this.registerConverters(), this.complexObjectConverter = new
|
|
1684
|
+
this.nodeToObjectConverter = e, this.registerConverters(), this.complexObjectConverter = new zr(
|
|
1686
1685
|
this.nodeToObjectConverter
|
|
1687
1686
|
);
|
|
1688
1687
|
}
|
|
1689
1688
|
registerConverters() {
|
|
1690
|
-
const e = new
|
|
1691
|
-
this.converters.set("ZodString", e), this.converters.set("ZodNumber", e), this.converters.set("ZodBoolean", e), this.converters.set("ZodBigInt", e), this.converters.set("ZodEnum", e), this.converters.set("ZodNativeEnum", e), this.converters.set("ZodUnknown", new
|
|
1689
|
+
const e = new Yr(), t = new Kr(this.nodeToObjectConverter), n = new Qr(this.nodeToObjectConverter), s = new Wr(this.nodeToObjectConverter), i = new Hr(this.nodeToObjectConverter);
|
|
1690
|
+
this.converters.set("ZodString", e), this.converters.set("ZodNumber", e), this.converters.set("ZodBoolean", e), this.converters.set("ZodBigInt", e), this.converters.set("ZodEnum", e), this.converters.set("ZodNativeEnum", e), this.converters.set("ZodUnknown", new Xr()), this.converters.set("ZodAny", new qr()), this.converters.set("ZodArray", t), this.converters.set("ZodTuple", n), this.converters.set("ZodSet", s), this.converters.set("ZodMap", i), this.converters.set("ZodRecord", i), this.converters.set("ZodObject", this.complexObjectConverter);
|
|
1692
1691
|
}
|
|
1693
1692
|
getConverter(e) {
|
|
1694
1693
|
const t = this.getSchemaTypeName(e);
|
|
1695
1694
|
return this.converters.get(t) ?? this.complexObjectConverter;
|
|
1696
1695
|
}
|
|
1697
1696
|
isWrapperType(e) {
|
|
1698
|
-
return e instanceof
|
|
1697
|
+
return e instanceof ht || e instanceof pt || e instanceof yt || e instanceof gt || e instanceof me || e instanceof Ie;
|
|
1699
1698
|
}
|
|
1700
1699
|
getSchemaTypeName(e) {
|
|
1701
1700
|
if (this.isWrapperType(e))
|
|
1702
|
-
return e instanceof
|
|
1701
|
+
return e instanceof me ? this.getSchemaTypeName(e.innerType()) : e instanceof Ie ? this.getSchemaTypeName(e.schema) : this.getSchemaTypeName(e.unwrap());
|
|
1703
1702
|
const t = e._def.typeName;
|
|
1704
1703
|
try {
|
|
1705
|
-
return
|
|
1704
|
+
return en.parse(t);
|
|
1706
1705
|
} catch {
|
|
1707
1706
|
throw new Error(`Schema type name ${t} is not supported`);
|
|
1708
1707
|
}
|
|
1709
1708
|
}
|
|
1710
1709
|
}
|
|
1711
|
-
class
|
|
1710
|
+
class rn {
|
|
1712
1711
|
constructor(e) {
|
|
1713
1712
|
u(this, "converterFactory");
|
|
1714
|
-
this.typeSchemaResolver = e, this.converterFactory = new
|
|
1713
|
+
this.typeSchemaResolver = e, this.converterFactory = new tn(this);
|
|
1715
1714
|
}
|
|
1716
1715
|
convert(e, t) {
|
|
1717
1716
|
var o;
|
|
1718
|
-
const n = (o = this.typeSchemaResolver) == null ? void 0 : o.resolveSchema(e), s =
|
|
1719
|
-
if (
|
|
1717
|
+
const n = (o = this.typeSchemaResolver) == null ? void 0 : o.resolveSchema(e), s = A.unwrapSchema(t);
|
|
1718
|
+
if (Dt(s))
|
|
1720
1719
|
return e;
|
|
1721
1720
|
let i = s;
|
|
1722
|
-
return
|
|
1721
|
+
return A.checkSchemaExtension(
|
|
1723
1722
|
n,
|
|
1724
1723
|
s
|
|
1725
|
-
) &&
|
|
1724
|
+
) && f(n) && (i = n), this.convertWithType(e, i);
|
|
1726
1725
|
}
|
|
1727
1726
|
convertWithType(e, t) {
|
|
1728
1727
|
return this.converterFactory.getConverter(t).convert(e, t);
|
|
1729
1728
|
}
|
|
1730
1729
|
}
|
|
1731
|
-
class
|
|
1730
|
+
class fe {
|
|
1732
1731
|
/**
|
|
1733
1732
|
* Fetches the first node associated with the given Blue ID
|
|
1734
1733
|
* Default implementation that takes the first node from fetchByBlueId result
|
|
@@ -1741,14 +1740,14 @@ class Pe {
|
|
|
1741
1740
|
return t && t.length > 0 ? t[0] : null;
|
|
1742
1741
|
}
|
|
1743
1742
|
}
|
|
1744
|
-
function
|
|
1745
|
-
return new class extends
|
|
1743
|
+
function nn(r) {
|
|
1744
|
+
return new class extends fe {
|
|
1746
1745
|
fetchByBlueId(e) {
|
|
1747
1746
|
return r(e);
|
|
1748
1747
|
}
|
|
1749
1748
|
}();
|
|
1750
1749
|
}
|
|
1751
|
-
class
|
|
1750
|
+
class sn extends fe {
|
|
1752
1751
|
constructor(t) {
|
|
1753
1752
|
super();
|
|
1754
1753
|
u(this, "nodeProviders");
|
|
@@ -1776,34 +1775,34 @@ class Kr extends Pe {
|
|
|
1776
1775
|
return this.nodeProviders;
|
|
1777
1776
|
}
|
|
1778
1777
|
}
|
|
1779
|
-
const
|
|
1780
|
-
...
|
|
1778
|
+
const Me = Z.types.float.options, on = {
|
|
1779
|
+
...Me,
|
|
1781
1780
|
construct: (r) => {
|
|
1782
1781
|
const e = r.replace(/_/g, "").toLowerCase();
|
|
1783
|
-
if (!
|
|
1784
|
-
return new
|
|
1785
|
-
if (
|
|
1786
|
-
return
|
|
1782
|
+
if (!ft(e))
|
|
1783
|
+
return new C(e);
|
|
1784
|
+
if (Me.construct)
|
|
1785
|
+
return Me.construct(r);
|
|
1787
1786
|
}
|
|
1788
|
-
},
|
|
1789
|
-
...
|
|
1787
|
+
}, cn = new Z.Type("tag:yaml.org,2002:float", on), je = Z.types.int.options, ln = {
|
|
1788
|
+
...je,
|
|
1790
1789
|
construct: (r) => {
|
|
1791
1790
|
let e = r;
|
|
1792
|
-
if (e.indexOf("_") !== -1 && (e = e.replace(/_/g, "")), !
|
|
1793
|
-
return new
|
|
1794
|
-
if (
|
|
1795
|
-
return
|
|
1796
|
-
}
|
|
1797
|
-
},
|
|
1798
|
-
implicit: [
|
|
1799
|
-
}),
|
|
1800
|
-
const e = Z.load(r, { schema:
|
|
1791
|
+
if (e.indexOf("_") !== -1 && (e = e.replace(/_/g, "")), !ft(e))
|
|
1792
|
+
return new S(e);
|
|
1793
|
+
if (je.construct)
|
|
1794
|
+
return je.construct(r);
|
|
1795
|
+
}
|
|
1796
|
+
}, an = new Z.Type("tag:yaml.org,2002:int", ln), Mt = Z.CORE_SCHEMA.extend({
|
|
1797
|
+
implicit: [cn, an]
|
|
1798
|
+
}), W = (r) => {
|
|
1799
|
+
const e = Z.load(r, { schema: Mt });
|
|
1801
1800
|
return e === void 0 ? void 0 : e;
|
|
1802
|
-
},
|
|
1803
|
-
schema:
|
|
1801
|
+
}, ys = (r) => Z.dump(r, {
|
|
1802
|
+
schema: Mt,
|
|
1804
1803
|
replacer: (e, t) => {
|
|
1805
|
-
if (
|
|
1806
|
-
if (
|
|
1804
|
+
if (O(t)) {
|
|
1805
|
+
if (le(t)) {
|
|
1807
1806
|
const n = new x(Number.MIN_SAFE_INTEGER.toString()), s = new x(Number.MAX_SAFE_INTEGER.toString());
|
|
1808
1807
|
if (t.lt(n) || t.gt(s))
|
|
1809
1808
|
return t.toString();
|
|
@@ -1812,7 +1811,7 @@ const Ve = Z.types.float.options, Xr = {
|
|
|
1812
1811
|
}
|
|
1813
1812
|
return t;
|
|
1814
1813
|
}
|
|
1815
|
-
}),
|
|
1814
|
+
}), jt = `- type:
|
|
1816
1815
|
blueId: 27B7fuxQCS1VAptiCPc2RMkKoutP5qxkh3uDxZ7dr6Eo
|
|
1817
1816
|
mappings:
|
|
1818
1817
|
Text: F92yo19rCcbBoBSpUA5LRxpfDejJDAaP1PRxxbWAraVP
|
|
@@ -1823,20 +1822,20 @@ const Ve = Z.types.float.options, Xr = {
|
|
|
1823
1822
|
Dictionary: 294NBTj2mFRL3RB4kDRUSckwGg7Kzj6T8CTAFeR1kcSA
|
|
1824
1823
|
- type:
|
|
1825
1824
|
blueId: FGYuTXwaoSKfZmpTysLTLsb8WzSqf43384rKZDkXhxD4
|
|
1826
|
-
`,
|
|
1827
|
-
description: TODO`,
|
|
1825
|
+
`, un = `name: Transformation
|
|
1826
|
+
description: TODO`, dn = `name: Infer Basic Types For Untyped Values
|
|
1828
1827
|
type:
|
|
1829
1828
|
blueId: Ct1SGRGw1i47qjzm1ruiUdSZofeV6WevPTGuieVvbRS4
|
|
1830
|
-
description: This transformation infers type details for Text, Integer, Number and Boolean.`,
|
|
1829
|
+
description: This transformation infers type details for Text, Integer, Number and Boolean.`, fn = `name: Replace Inline Types with BlueIds
|
|
1831
1830
|
type:
|
|
1832
1831
|
blueId: Ct1SGRGw1i47qjzm1ruiUdSZofeV6WevPTGuieVvbRS4
|
|
1833
|
-
description: This transformation replaces`,
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1832
|
+
description: This transformation replaces`, hn = [
|
|
1833
|
+
jt,
|
|
1834
|
+
un,
|
|
1835
|
+
dn,
|
|
1836
|
+
fn
|
|
1838
1837
|
];
|
|
1839
|
-
class
|
|
1838
|
+
class pn extends fe {
|
|
1840
1839
|
constructor() {
|
|
1841
1840
|
super();
|
|
1842
1841
|
u(this, "blueIdToNodesMap", /* @__PURE__ */ new Map());
|
|
@@ -1846,8 +1845,8 @@ class on extends Pe {
|
|
|
1846
1845
|
return this.blueIdToNodesMap.get(t) || [];
|
|
1847
1846
|
}
|
|
1848
1847
|
load() {
|
|
1849
|
-
for (const t of
|
|
1850
|
-
const n =
|
|
1848
|
+
for (const t of hn) {
|
|
1849
|
+
const n = W(t);
|
|
1851
1850
|
if (n === void 0) {
|
|
1852
1851
|
console.error(`This content file is not valid YAML: ${t}`);
|
|
1853
1852
|
continue;
|
|
@@ -1855,51 +1854,209 @@ class on extends Pe {
|
|
|
1855
1854
|
if (Array.isArray(n)) {
|
|
1856
1855
|
const s = n.map(
|
|
1857
1856
|
(o) => p.deserialize(o)
|
|
1858
|
-
), i =
|
|
1857
|
+
), i = w.calculateBlueIdSync(s);
|
|
1859
1858
|
this.blueIdToNodesMap.set(i, s);
|
|
1860
1859
|
} else {
|
|
1861
|
-
const s = p.deserialize(n), i =
|
|
1860
|
+
const s = p.deserialize(n), i = w.calculateBlueIdSync(s);
|
|
1862
1861
|
this.blueIdToNodesMap.set(i, [s]);
|
|
1863
1862
|
}
|
|
1864
1863
|
}
|
|
1865
1864
|
}
|
|
1866
1865
|
}
|
|
1867
|
-
const
|
|
1866
|
+
const Be = class Be extends fe {
|
|
1868
1867
|
constructor() {
|
|
1869
1868
|
super();
|
|
1870
1869
|
u(this, "nodeProvider");
|
|
1871
|
-
this.nodeProvider = new
|
|
1870
|
+
this.nodeProvider = new pn();
|
|
1872
1871
|
}
|
|
1873
1872
|
fetchByBlueId(t) {
|
|
1874
1873
|
return this.nodeProvider.fetchByBlueId(t);
|
|
1875
1874
|
}
|
|
1876
1875
|
};
|
|
1877
|
-
u(
|
|
1878
|
-
let
|
|
1879
|
-
class
|
|
1876
|
+
u(Be, "INSTANCE", new Be());
|
|
1877
|
+
let Ye = Be;
|
|
1878
|
+
class xe {
|
|
1879
|
+
constructor(e, t, n) {
|
|
1880
|
+
this.blueId = e, this.content = t, this.isMultipleDocuments = n;
|
|
1881
|
+
}
|
|
1882
|
+
}
|
|
1883
|
+
class ne {
|
|
1884
|
+
static parseAndCalculateBlueId(e, t) {
|
|
1885
|
+
let n;
|
|
1886
|
+
try {
|
|
1887
|
+
const c = W(e);
|
|
1888
|
+
if (c === void 0)
|
|
1889
|
+
throw new Error();
|
|
1890
|
+
n = c;
|
|
1891
|
+
} catch {
|
|
1892
|
+
throw new Error("Failed to parse content as YAML or JSON");
|
|
1893
|
+
}
|
|
1894
|
+
let s, i;
|
|
1895
|
+
const o = Array.isArray(n) && n.length > 1;
|
|
1896
|
+
if (o) {
|
|
1897
|
+
const c = n.map((l) => {
|
|
1898
|
+
const h = p.deserialize(l);
|
|
1899
|
+
return t(h);
|
|
1900
|
+
});
|
|
1901
|
+
s = w.calculateBlueIdSync(c), i = c.map((l) => y.get(l));
|
|
1902
|
+
} else {
|
|
1903
|
+
const c = p.deserialize(n), l = t(c);
|
|
1904
|
+
s = w.calculateBlueIdSync(l), i = y.get(l);
|
|
1905
|
+
}
|
|
1906
|
+
return new xe(s, i, o);
|
|
1907
|
+
}
|
|
1908
|
+
static parseAndCalculateBlueIdForNode(e, t) {
|
|
1909
|
+
const n = t(e), s = w.calculateBlueIdSync(n), i = y.get(n);
|
|
1910
|
+
return new xe(s, i, !1);
|
|
1911
|
+
}
|
|
1912
|
+
static parseAndCalculateBlueIdForNodeList(e, t) {
|
|
1913
|
+
if (!e || e.length === 0)
|
|
1914
|
+
throw new Error("List of nodes cannot be null or empty");
|
|
1915
|
+
const n = e.map(t), s = w.calculateBlueIdSync(n), i = n.map(
|
|
1916
|
+
(c) => y.get(c)
|
|
1917
|
+
), o = e.length > 1;
|
|
1918
|
+
return new xe(s, i, o);
|
|
1919
|
+
}
|
|
1920
|
+
static resolveThisReferences(e, t, n) {
|
|
1921
|
+
return this.resolveThisReferencesRecursive(
|
|
1922
|
+
e,
|
|
1923
|
+
t,
|
|
1924
|
+
n
|
|
1925
|
+
);
|
|
1926
|
+
}
|
|
1927
|
+
static resolveThisReferencesRecursive(e, t, n) {
|
|
1928
|
+
if (e && typeof e == "object" && !Array.isArray(e)) {
|
|
1929
|
+
const s = {};
|
|
1930
|
+
for (const [i, o] of Object.entries(e))
|
|
1931
|
+
typeof o == "string" ? this.THIS_REFERENCE_PATTERN.test(o) ? s[i] = this.resolveThisReference(
|
|
1932
|
+
o,
|
|
1933
|
+
t,
|
|
1934
|
+
n
|
|
1935
|
+
) : s[i] = o : o && typeof o == "object" ? s[i] = this.resolveThisReferencesRecursive(
|
|
1936
|
+
o,
|
|
1937
|
+
t,
|
|
1938
|
+
n
|
|
1939
|
+
) : s[i] = o;
|
|
1940
|
+
return s;
|
|
1941
|
+
} else if (Array.isArray(e))
|
|
1942
|
+
return e.map((s) => typeof s == "string" ? this.THIS_REFERENCE_PATTERN.test(s) ? this.resolveThisReference(
|
|
1943
|
+
s,
|
|
1944
|
+
t,
|
|
1945
|
+
n
|
|
1946
|
+
) : s : s && typeof s == "object" ? this.resolveThisReferencesRecursive(
|
|
1947
|
+
s,
|
|
1948
|
+
t,
|
|
1949
|
+
n
|
|
1950
|
+
) : s);
|
|
1951
|
+
return e;
|
|
1952
|
+
}
|
|
1953
|
+
static resolveThisReference(e, t, n) {
|
|
1954
|
+
if (n) {
|
|
1955
|
+
if (!e.startsWith("this#"))
|
|
1956
|
+
throw new Error(
|
|
1957
|
+
"For multiple documents, 'this' references must include an index (e.g., 'this#0')"
|
|
1958
|
+
);
|
|
1959
|
+
return t + e.substring(4);
|
|
1960
|
+
} else {
|
|
1961
|
+
if (e === "this")
|
|
1962
|
+
return t;
|
|
1963
|
+
throw new Error(
|
|
1964
|
+
"For a single document, only 'this' is allowed as a reference, not 'this#<id>'"
|
|
1965
|
+
);
|
|
1966
|
+
}
|
|
1967
|
+
}
|
|
1968
|
+
}
|
|
1969
|
+
u(ne, "THIS_REFERENCE_PATTERN", /^this(#\d+)?$/);
|
|
1970
|
+
class yn extends fe {
|
|
1971
|
+
fetchByBlueId(e) {
|
|
1972
|
+
const t = e.split("#")[0], n = this.fetchContentByBlueId(t);
|
|
1973
|
+
if (n == null)
|
|
1974
|
+
return null;
|
|
1975
|
+
const s = Array.isArray(n) && n.length > 1, i = ne.resolveThisReferences(
|
|
1976
|
+
n,
|
|
1977
|
+
t,
|
|
1978
|
+
s
|
|
1979
|
+
);
|
|
1980
|
+
if (e.includes("#")) {
|
|
1981
|
+
const o = e.split("#");
|
|
1982
|
+
if (o.length > 1) {
|
|
1983
|
+
const c = parseInt(o[1]);
|
|
1984
|
+
if (Array.isArray(i) && c < i.length) {
|
|
1985
|
+
const l = i[c], h = p.deserialize(l);
|
|
1986
|
+
return h.setBlueId(e), [h];
|
|
1987
|
+
} else if (c === 0) {
|
|
1988
|
+
const l = p.deserialize(i);
|
|
1989
|
+
return l.setBlueId(e), [l];
|
|
1990
|
+
} else
|
|
1991
|
+
return null;
|
|
1992
|
+
}
|
|
1993
|
+
}
|
|
1994
|
+
if (Array.isArray(i))
|
|
1995
|
+
return i.map((o) => p.deserialize(o));
|
|
1996
|
+
{
|
|
1997
|
+
const o = p.deserialize(i);
|
|
1998
|
+
return o.setBlueId(t), [o];
|
|
1999
|
+
}
|
|
2000
|
+
}
|
|
2001
|
+
}
|
|
2002
|
+
class gn extends yn {
|
|
2003
|
+
constructor() {
|
|
2004
|
+
super(...arguments);
|
|
2005
|
+
u(this, "nameToBlueIdsMap", /* @__PURE__ */ new Map());
|
|
2006
|
+
}
|
|
1880
2007
|
/**
|
|
1881
|
-
*
|
|
1882
|
-
* @param
|
|
1883
|
-
* @returns
|
|
2008
|
+
* Find a node by name. Throws an error if multiple nodes are found with the same name.
|
|
2009
|
+
* @param name - The name to search for
|
|
2010
|
+
* @returns The node if found, or undefined if not found
|
|
1884
2011
|
*/
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
2012
|
+
findNodeByName(t) {
|
|
2013
|
+
const n = this.nameToBlueIdsMap.get(t);
|
|
2014
|
+
if (!n)
|
|
2015
|
+
return;
|
|
2016
|
+
if (n.length > 1)
|
|
2017
|
+
throw new Error(`Multiple nodes found with name: ${t}`);
|
|
2018
|
+
const s = this.fetchByBlueId(n[0]);
|
|
2019
|
+
return s && s.length > 0 ? s[0] : void 0;
|
|
2020
|
+
}
|
|
2021
|
+
/**
|
|
2022
|
+
* Find all nodes with the given name
|
|
2023
|
+
* @param name - The name to search for
|
|
2024
|
+
* @returns Array of nodes with the given name
|
|
2025
|
+
*/
|
|
2026
|
+
findAllNodesByName(t) {
|
|
2027
|
+
const n = this.nameToBlueIdsMap.get(t);
|
|
2028
|
+
if (!n)
|
|
2029
|
+
return [];
|
|
2030
|
+
const s = [];
|
|
2031
|
+
for (const i of n) {
|
|
2032
|
+
const o = this.fetchByBlueId(i);
|
|
2033
|
+
o && s.push(...o);
|
|
2034
|
+
}
|
|
2035
|
+
return s;
|
|
2036
|
+
}
|
|
2037
|
+
/**
|
|
2038
|
+
* Add a name to Blue ID mapping
|
|
2039
|
+
* @param name - The name of the node
|
|
2040
|
+
* @param blueId - The Blue ID of the node
|
|
2041
|
+
*/
|
|
2042
|
+
addToNameMap(t, n) {
|
|
2043
|
+
this.nameToBlueIdsMap.set(t, [
|
|
2044
|
+
...this.nameToBlueIdsMap.get(t) || [],
|
|
2045
|
+
n
|
|
1889
2046
|
]);
|
|
1890
2047
|
}
|
|
1891
2048
|
}
|
|
1892
|
-
const
|
|
1893
|
-
const e =
|
|
1894
|
-
return
|
|
1895
|
-
},
|
|
1896
|
-
const e =
|
|
1897
|
-
return
|
|
1898
|
-
},
|
|
1899
|
-
if (
|
|
2049
|
+
const xt = (r) => r instanceof a || Array.isArray(r) && r.every((e) => e instanceof a) ? r : Ne(r) ? r.map((e) => p.deserialize(e)) : p.deserialize(r), mn = async (r) => {
|
|
2050
|
+
const e = xt(r);
|
|
2051
|
+
return w.calculateBlueId(e);
|
|
2052
|
+
}, gs = (r) => {
|
|
2053
|
+
const e = xt(r);
|
|
2054
|
+
return w.calculateBlueIdSync(e);
|
|
2055
|
+
}, lt = async (r) => {
|
|
2056
|
+
if (cr(r))
|
|
1900
2057
|
return r;
|
|
1901
2058
|
try {
|
|
1902
|
-
const e =
|
|
2059
|
+
const e = be.parse(r), t = await mn(e);
|
|
1903
2060
|
return {
|
|
1904
2061
|
...r,
|
|
1905
2062
|
blueId: t
|
|
@@ -1907,53 +2064,53 @@ const At = (r) => r instanceof l || Array.isArray(r) && r.every((e) => e instanc
|
|
|
1907
2064
|
} catch (e) {
|
|
1908
2065
|
throw new Error(`Failed enriching object with Blue ID: ${e}`);
|
|
1909
2066
|
}
|
|
1910
|
-
},
|
|
2067
|
+
}, ms = (r) => r == null ? void 0 : r.items, Is = (r) => r == null ? void 0 : r.value, Ts = (r) => N(r) ? {} : bt(
|
|
1911
2068
|
r,
|
|
1912
|
-
|
|
1913
|
-
),
|
|
2069
|
+
Qt
|
|
2070
|
+
), bs = (r) => ar(r) ? r.type.name ?? null : ur(r) ? Kt(typeof r.value) : lr(r) ? "List" : null, In = (r) => f(r) && Object.keys(bt(r, ["blueId"])).length > 0, ws = (r) => {
|
|
1914
2071
|
try {
|
|
1915
|
-
const e = p.deserialize(r), t =
|
|
1916
|
-
return
|
|
2072
|
+
const e = p.deserialize(r), t = y.get(e);
|
|
2073
|
+
return ce.parse(t);
|
|
1917
2074
|
} catch (e) {
|
|
1918
2075
|
throw new Error(
|
|
1919
2076
|
`Failed transforming JSON-like value to BlueObject: ${e}`
|
|
1920
2077
|
);
|
|
1921
2078
|
}
|
|
1922
|
-
},
|
|
2079
|
+
}, at = async (r) => {
|
|
1923
2080
|
const {
|
|
1924
2081
|
resolveFunction: e,
|
|
1925
2082
|
signal: t = new AbortController().signal,
|
|
1926
2083
|
omitItems: n
|
|
1927
2084
|
} = r, s = r.count ?? r.items.length;
|
|
1928
|
-
let i = await
|
|
2085
|
+
let i = await Wt(r.items, async (c) => await lt(c));
|
|
1929
2086
|
const o = Math.max((i == null ? void 0 : i.length) - s, 0);
|
|
1930
2087
|
for (let c = i.length - 1; c >= o; c--)
|
|
1931
|
-
if (!
|
|
1932
|
-
const
|
|
1933
|
-
if (Array.isArray(
|
|
1934
|
-
return
|
|
2088
|
+
if (!In(i[c])) {
|
|
2089
|
+
const l = await e(i[c], { signal: t });
|
|
2090
|
+
if (Array.isArray(l))
|
|
2091
|
+
return at({
|
|
1935
2092
|
...r,
|
|
1936
2093
|
items: [
|
|
1937
2094
|
...i.slice(0, c),
|
|
1938
|
-
...
|
|
2095
|
+
...l,
|
|
1939
2096
|
...i.slice(c + 1)
|
|
1940
2097
|
]
|
|
1941
2098
|
});
|
|
1942
|
-
const
|
|
1943
|
-
if (n != null && n.includes(
|
|
1944
|
-
return
|
|
2099
|
+
const h = await lt(l);
|
|
2100
|
+
if (n != null && n.includes(h.blueId))
|
|
2101
|
+
return at({
|
|
1945
2102
|
...r,
|
|
1946
2103
|
items: [...i.slice(0, c), ...i.slice(c + 1)]
|
|
1947
2104
|
});
|
|
1948
2105
|
i = [
|
|
1949
2106
|
...i.slice(0, c),
|
|
1950
|
-
|
|
2107
|
+
h,
|
|
1951
2108
|
...i.slice(c + 1)
|
|
1952
2109
|
];
|
|
1953
2110
|
}
|
|
1954
2111
|
return i;
|
|
1955
2112
|
};
|
|
1956
|
-
function
|
|
2113
|
+
function ge(r) {
|
|
1957
2114
|
try {
|
|
1958
2115
|
const e = new URL(r);
|
|
1959
2116
|
return e.protocol === "http:" || e.protocol === "https:";
|
|
@@ -1961,14 +2118,14 @@ function ae(r) {
|
|
|
1961
2118
|
return !1;
|
|
1962
2119
|
}
|
|
1963
2120
|
}
|
|
1964
|
-
class
|
|
2121
|
+
class Tn {
|
|
1965
2122
|
/**
|
|
1966
2123
|
* Process a document node to infer basic types for untyped values
|
|
1967
2124
|
* @param document - The document to process
|
|
1968
2125
|
* @returns The processed document
|
|
1969
2126
|
*/
|
|
1970
2127
|
process(e) {
|
|
1971
|
-
return
|
|
2128
|
+
return V.transform(e, this.inferType.bind(this));
|
|
1972
2129
|
}
|
|
1973
2130
|
/**
|
|
1974
2131
|
* Infer a basic type for a node
|
|
@@ -1977,23 +2134,23 @@ class an {
|
|
|
1977
2134
|
*/
|
|
1978
2135
|
inferType(e) {
|
|
1979
2136
|
const t = e.getType(), n = e.getValue();
|
|
1980
|
-
return
|
|
2137
|
+
return N(t) && f(n) && (typeof n == "string" ? e.setType(new a().setBlueId(H)) : typeof n == "bigint" || le(n) ? e.setType(new a().setBlueId(q)) : dr(n) ? e.setType(new a().setBlueId(X)) : typeof n == "boolean" && e.setType(new a().setBlueId(Q))), e;
|
|
1981
2138
|
}
|
|
1982
2139
|
}
|
|
1983
|
-
const
|
|
2140
|
+
const se = class se {
|
|
1984
2141
|
/**
|
|
1985
2142
|
* Creates a new processor with the given transformation node or mappings
|
|
1986
2143
|
* @param transformationOrMappings - The transformation node or mappings to use
|
|
1987
2144
|
*/
|
|
1988
2145
|
constructor(e) {
|
|
1989
2146
|
u(this, "mappings", /* @__PURE__ */ new Map());
|
|
1990
|
-
if (e instanceof
|
|
2147
|
+
if (e instanceof a) {
|
|
1991
2148
|
const n = e.getProperties();
|
|
1992
|
-
if (n && n[
|
|
1993
|
-
const i = n[
|
|
2149
|
+
if (n && n[se.MAPPINGS]) {
|
|
2150
|
+
const i = n[se.MAPPINGS].getProperties();
|
|
1994
2151
|
i && Object.entries(i).forEach(([o, c]) => {
|
|
1995
|
-
const
|
|
1996
|
-
typeof
|
|
2152
|
+
const l = c.getValue();
|
|
2153
|
+
typeof l == "string" && this.mappings.set(o, l);
|
|
1997
2154
|
});
|
|
1998
2155
|
}
|
|
1999
2156
|
} else
|
|
@@ -2005,7 +2162,7 @@ const K = class K {
|
|
|
2005
2162
|
* @returns The processed document
|
|
2006
2163
|
*/
|
|
2007
2164
|
process(e) {
|
|
2008
|
-
return
|
|
2165
|
+
return V.transform(e, this.transformNode.bind(this));
|
|
2009
2166
|
}
|
|
2010
2167
|
transformNode(e) {
|
|
2011
2168
|
const t = e.clone();
|
|
@@ -2017,16 +2174,16 @@ const K = class K {
|
|
|
2017
2174
|
if (this.mappings.has(n)) {
|
|
2018
2175
|
const s = this.mappings.get(n);
|
|
2019
2176
|
if (s) {
|
|
2020
|
-
const i = new
|
|
2177
|
+
const i = new a().setBlueId(s);
|
|
2021
2178
|
t === e.getType() ? e.setType(i) : t === e.getItemType() ? e.setItemType(i) : t === e.getKeyType() ? e.setKeyType(i) : t === e.getValueType() && e.setValueType(i);
|
|
2022
2179
|
}
|
|
2023
2180
|
}
|
|
2024
2181
|
}
|
|
2025
2182
|
}
|
|
2026
2183
|
};
|
|
2027
|
-
u(
|
|
2028
|
-
let
|
|
2029
|
-
class
|
|
2184
|
+
u(se, "MAPPINGS", "mappings");
|
|
2185
|
+
let ze = se;
|
|
2186
|
+
class st {
|
|
2030
2187
|
/**
|
|
2031
2188
|
* Creates a new NodeExtender with the specified NodeProvider and optional strategy
|
|
2032
2189
|
* @param nodeProvider - The NodeProvider to use for resolving nodes
|
|
@@ -2035,7 +2192,7 @@ class un {
|
|
|
2035
2192
|
constructor(e, t) {
|
|
2036
2193
|
u(this, "nodeProvider");
|
|
2037
2194
|
u(this, "strategy");
|
|
2038
|
-
this.nodeProvider =
|
|
2195
|
+
this.nodeProvider = ue.wrap(e), this.strategy = t || "THROW_EXCEPTION";
|
|
2039
2196
|
}
|
|
2040
2197
|
/**
|
|
2041
2198
|
* Extends a node with its resolved references
|
|
@@ -2053,38 +2210,40 @@ class un {
|
|
|
2053
2210
|
}
|
|
2054
2211
|
try {
|
|
2055
2212
|
const i = e.getBlueId();
|
|
2056
|
-
if (i && !(
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2213
|
+
if (i && !de.includes(
|
|
2214
|
+
i
|
|
2215
|
+
)) {
|
|
2216
|
+
const m = this.fetchNode(e);
|
|
2217
|
+
if (m && m.length > 0)
|
|
2218
|
+
if (m.length === 1) {
|
|
2219
|
+
const g = m[0];
|
|
2220
|
+
this.mergeNodes(e, g);
|
|
2062
2221
|
} else {
|
|
2063
|
-
const
|
|
2064
|
-
this.mergeNodes(e,
|
|
2222
|
+
const g = m.map((D) => D.clone()), v = new a().setItems(g);
|
|
2223
|
+
this.mergeNodes(e, v);
|
|
2065
2224
|
}
|
|
2066
2225
|
}
|
|
2067
2226
|
const o = e.getType();
|
|
2068
2227
|
o && this.extendNode(o, t, "type", !0);
|
|
2069
2228
|
const c = e.getItemType();
|
|
2070
2229
|
c && this.extendNode(c, t, "itemType", !0);
|
|
2071
|
-
const
|
|
2072
|
-
|
|
2073
|
-
const
|
|
2074
|
-
|
|
2075
|
-
const
|
|
2076
|
-
|
|
2077
|
-
this.extendNode(
|
|
2230
|
+
const l = e.getKeyType();
|
|
2231
|
+
l && this.extendNode(l, t, "keyType", !0);
|
|
2232
|
+
const h = e.getValueType();
|
|
2233
|
+
h && this.extendNode(h, t, "valueType", !0);
|
|
2234
|
+
const T = e.getProperties();
|
|
2235
|
+
T && Object.entries(T).forEach(([m, g]) => {
|
|
2236
|
+
this.extendNode(g, t, m, !1);
|
|
2078
2237
|
});
|
|
2079
|
-
const
|
|
2080
|
-
|
|
2081
|
-
this.extendNode(
|
|
2238
|
+
const b = e.getContracts();
|
|
2239
|
+
b && Object.entries(b).forEach(([m, g]) => {
|
|
2240
|
+
this.extendNode(g, t, m, !1);
|
|
2082
2241
|
});
|
|
2083
|
-
const
|
|
2084
|
-
if (
|
|
2085
|
-
this.reconstructList(
|
|
2086
|
-
for (let
|
|
2087
|
-
this.extendNode(m
|
|
2242
|
+
const I = e.getItems();
|
|
2243
|
+
if (I && I.length > 0) {
|
|
2244
|
+
this.reconstructList(I);
|
|
2245
|
+
for (let m = 0; m < I.length; m++)
|
|
2246
|
+
this.extendNode(I[m], t, String(m), !1);
|
|
2088
2247
|
}
|
|
2089
2248
|
} finally {
|
|
2090
2249
|
s || t.exitPathSegment();
|
|
@@ -2117,16 +2276,18 @@ class un {
|
|
|
2117
2276
|
return n;
|
|
2118
2277
|
}
|
|
2119
2278
|
mergeNodes(e, t) {
|
|
2120
|
-
e.setName(t.getName()), e.setDescription(t.getDescription()), e.setType(t.getType()), e.setItemType(t.getItemType()), e.setKeyType(t.getKeyType()), e.setValueType(t.getValueType())
|
|
2279
|
+
e.setName(t.getName()), e.setDescription(t.getDescription()), e.setType(t.getType()), e.setItemType(t.getItemType()), e.setKeyType(t.getKeyType()), e.setValueType(t.getValueType());
|
|
2280
|
+
const n = t.getValue();
|
|
2281
|
+
f(n) && e.setValue(n), e.setItems(t.getItems()), e.setProperties(t.getProperties()), e.setContracts(t.getContracts());
|
|
2121
2282
|
}
|
|
2122
2283
|
}
|
|
2123
|
-
class
|
|
2284
|
+
class $t {
|
|
2124
2285
|
}
|
|
2125
|
-
function
|
|
2286
|
+
function ut(r, e) {
|
|
2126
2287
|
const t = r.split(e), n = [...t].reverse().findIndex((i) => i !== ""), s = n === -1 ? 0 : t.length - n;
|
|
2127
2288
|
return t.slice(0, s);
|
|
2128
2289
|
}
|
|
2129
|
-
class
|
|
2290
|
+
class it extends $t {
|
|
2130
2291
|
/**
|
|
2131
2292
|
* Creates path limits with the specified paths and max depth
|
|
2132
2293
|
* @param allowedPaths - The paths to limit extension to
|
|
@@ -2178,7 +2339,7 @@ class Nt extends fn {
|
|
|
2178
2339
|
* @returns True if the path matches the allowed path pattern, false otherwise
|
|
2179
2340
|
*/
|
|
2180
2341
|
matchesAllowedPath(t, n) {
|
|
2181
|
-
const s =
|
|
2342
|
+
const s = ut(t, "/"), i = ut(n, "/");
|
|
2182
2343
|
if (i.length > s.length)
|
|
2183
2344
|
return !1;
|
|
2184
2345
|
for (let o = 1; o < i.length; o++)
|
|
@@ -2220,7 +2381,7 @@ class Nt extends fn {
|
|
|
2220
2381
|
* @returns The path limits
|
|
2221
2382
|
*/
|
|
2222
2383
|
static withMaxDepth(t) {
|
|
2223
|
-
return new
|
|
2384
|
+
return new dt().setMaxDepth(t).addPath("*").build();
|
|
2224
2385
|
}
|
|
2225
2386
|
/**
|
|
2226
2387
|
* Creates path limits with a single path
|
|
@@ -2228,10 +2389,10 @@ class Nt extends fn {
|
|
|
2228
2389
|
* @returns The path limits
|
|
2229
2390
|
*/
|
|
2230
2391
|
static withSinglePath(t) {
|
|
2231
|
-
return new
|
|
2392
|
+
return new dt().addPath(t).build();
|
|
2232
2393
|
}
|
|
2233
2394
|
}
|
|
2234
|
-
class
|
|
2395
|
+
class dt {
|
|
2235
2396
|
constructor() {
|
|
2236
2397
|
u(this, "allowedPaths", /* @__PURE__ */ new Set());
|
|
2237
2398
|
u(this, "maxDepth", Number.MAX_SAFE_INTEGER);
|
|
@@ -2257,10 +2418,37 @@ class nt {
|
|
|
2257
2418
|
* @returns The built PathLimits
|
|
2258
2419
|
*/
|
|
2259
2420
|
build() {
|
|
2260
|
-
return new
|
|
2421
|
+
return new it(this.allowedPaths, this.maxDepth);
|
|
2261
2422
|
}
|
|
2262
2423
|
}
|
|
2263
|
-
class
|
|
2424
|
+
class bn extends $t {
|
|
2425
|
+
/**
|
|
2426
|
+
* Determines if a path segment should be extended - always returns true
|
|
2427
|
+
* @returns Always true
|
|
2428
|
+
*/
|
|
2429
|
+
shouldExtendPathSegment() {
|
|
2430
|
+
return !0;
|
|
2431
|
+
}
|
|
2432
|
+
/**
|
|
2433
|
+
* Determines if a path segment should be merged - always returns true
|
|
2434
|
+
* @returns Always true
|
|
2435
|
+
*/
|
|
2436
|
+
shouldMergePathSegment() {
|
|
2437
|
+
return !0;
|
|
2438
|
+
}
|
|
2439
|
+
/**
|
|
2440
|
+
* Enters a path segment - no-op
|
|
2441
|
+
*/
|
|
2442
|
+
enterPathSegment() {
|
|
2443
|
+
}
|
|
2444
|
+
/**
|
|
2445
|
+
* Exits a path segment - no-op
|
|
2446
|
+
*/
|
|
2447
|
+
exitPathSegment() {
|
|
2448
|
+
}
|
|
2449
|
+
}
|
|
2450
|
+
const G = new bn();
|
|
2451
|
+
class Ut {
|
|
2264
2452
|
constructor() {
|
|
2265
2453
|
u(this, "blueIdsCollections", []);
|
|
2266
2454
|
}
|
|
@@ -2332,7 +2520,7 @@ ${n}`;
|
|
|
2332
2520
|
return Object.keys(this.getAllBlueIds()).length;
|
|
2333
2521
|
}
|
|
2334
2522
|
}
|
|
2335
|
-
const
|
|
2523
|
+
const Ee = class Ee {
|
|
2336
2524
|
/**
|
|
2337
2525
|
* Creates a new Preprocessor with the specified options
|
|
2338
2526
|
* @param options - Configuration options for the preprocessor
|
|
@@ -2345,7 +2533,7 @@ const be = class be {
|
|
|
2345
2533
|
const { nodeProvider: t, processorProvider: n, blueIdsMappingGenerator: s } = e;
|
|
2346
2534
|
if (!t)
|
|
2347
2535
|
throw new Error("NodeProvider is required");
|
|
2348
|
-
this.nodeProvider =
|
|
2536
|
+
this.nodeProvider = ue.wrap(t), this.processorProvider = n || Ee.getStandardProvider(), this.blueIdsMappingGenerator = s || new Ut(), this.loadDefaultSimpleBlue();
|
|
2349
2537
|
}
|
|
2350
2538
|
/**
|
|
2351
2539
|
* Preprocesses a document node
|
|
@@ -2372,9 +2560,9 @@ const be = class be {
|
|
|
2372
2560
|
preprocessWithOptions(e, t) {
|
|
2373
2561
|
let n = e.clone(), s = n.getBlue();
|
|
2374
2562
|
if (!s && t && (s = t.clone()), s) {
|
|
2375
|
-
new
|
|
2563
|
+
new st(this.nodeProvider).extend(
|
|
2376
2564
|
s,
|
|
2377
|
-
|
|
2565
|
+
it.withSinglePath("/*")
|
|
2378
2566
|
);
|
|
2379
2567
|
const i = s.getItems();
|
|
2380
2568
|
if (i && i.length > 0) {
|
|
@@ -2402,11 +2590,11 @@ const be = class be {
|
|
|
2402
2590
|
var i;
|
|
2403
2591
|
const t = "27B7fuxQCS1VAptiCPc2RMkKoutP5qxkh3uDxZ7dr6Eo", n = "FGYuTXwaoSKfZmpTysLTLsb8WzSqf43384rKZDkXhxD4", s = (i = e.getType()) == null ? void 0 : i.getBlueId();
|
|
2404
2592
|
if (t === s)
|
|
2405
|
-
return new
|
|
2593
|
+
return new ze(
|
|
2406
2594
|
e
|
|
2407
2595
|
);
|
|
2408
2596
|
if (n === s)
|
|
2409
|
-
return new
|
|
2597
|
+
return new Tn();
|
|
2410
2598
|
}
|
|
2411
2599
|
};
|
|
2412
2600
|
}
|
|
@@ -2426,9 +2614,9 @@ ${t}
|
|
|
2426
2614
|
* Loads the default simple Blue node
|
|
2427
2615
|
*/
|
|
2428
2616
|
loadDefaultSimpleBlue() {
|
|
2429
|
-
const e = this.enrichDefaultBlue(
|
|
2617
|
+
const e = this.enrichDefaultBlue(jt);
|
|
2430
2618
|
try {
|
|
2431
|
-
const t =
|
|
2619
|
+
const t = W(e);
|
|
2432
2620
|
if (t)
|
|
2433
2621
|
this.defaultSimpleBlue = p.deserialize(t);
|
|
2434
2622
|
else
|
|
@@ -2438,9 +2626,92 @@ ${t}
|
|
|
2438
2626
|
}
|
|
2439
2627
|
}
|
|
2440
2628
|
};
|
|
2441
|
-
u(
|
|
2442
|
-
let
|
|
2443
|
-
class
|
|
2629
|
+
u(Ee, "DEFAULT_BLUE_BLUE_ID", "FREHAAGDZSzpnoTUoCQ86bBmxbVCULMjvx9JZM6fyqT1");
|
|
2630
|
+
let ae = Ee;
|
|
2631
|
+
class wn extends gn {
|
|
2632
|
+
constructor(t) {
|
|
2633
|
+
super();
|
|
2634
|
+
u(this, "blueIdToContentMap", /* @__PURE__ */ new Map());
|
|
2635
|
+
u(this, "blueIdToMultipleDocumentsMap", /* @__PURE__ */ new Map());
|
|
2636
|
+
u(this, "preprocessor");
|
|
2637
|
+
const n = new ae({ nodeProvider: this });
|
|
2638
|
+
this.preprocessor = (s) => n.preprocessWithDefaultBlue(s), this.loadRepositories(t);
|
|
2639
|
+
}
|
|
2640
|
+
loadRepositories(t) {
|
|
2641
|
+
for (const n of t)
|
|
2642
|
+
if (n.contents)
|
|
2643
|
+
for (const [s, i] of Object.entries(
|
|
2644
|
+
n.contents
|
|
2645
|
+
))
|
|
2646
|
+
this.processContent(i, s);
|
|
2647
|
+
}
|
|
2648
|
+
processContent(t, n) {
|
|
2649
|
+
Array.isArray(t) ? this.processMultipleDocuments(t, n) : this.processSingleDocument(t, n);
|
|
2650
|
+
}
|
|
2651
|
+
processSingleDocument(t, n) {
|
|
2652
|
+
const s = p.deserialize(t), i = ne.parseAndCalculateBlueIdForNode(
|
|
2653
|
+
s,
|
|
2654
|
+
this.preprocessor
|
|
2655
|
+
), o = n || i.blueId;
|
|
2656
|
+
this.blueIdToContentMap.set(o, i.content), this.blueIdToMultipleDocumentsMap.set(o, !1);
|
|
2657
|
+
const c = s.getName();
|
|
2658
|
+
c && this.addToNameMap(c, o);
|
|
2659
|
+
}
|
|
2660
|
+
processMultipleDocuments(t, n) {
|
|
2661
|
+
const s = t.map((c) => {
|
|
2662
|
+
const l = p.deserialize(c);
|
|
2663
|
+
return this.preprocessor(l);
|
|
2664
|
+
}), i = ne.parseAndCalculateBlueIdForNodeList(
|
|
2665
|
+
s,
|
|
2666
|
+
(c) => c
|
|
2667
|
+
// Already preprocessed above
|
|
2668
|
+
), o = n || i.blueId;
|
|
2669
|
+
this.blueIdToContentMap.set(o, i.content), this.blueIdToMultipleDocumentsMap.set(o, !0), s.forEach((c, l) => {
|
|
2670
|
+
const h = `${o}#${l}`, T = y.get(c), b = w.calculateBlueIdSync(c);
|
|
2671
|
+
this.blueIdToContentMap.set(b, T), this.blueIdToMultipleDocumentsMap.set(b, !1);
|
|
2672
|
+
const I = c.getName();
|
|
2673
|
+
I && this.addToNameMap(I, h);
|
|
2674
|
+
});
|
|
2675
|
+
}
|
|
2676
|
+
fetchContentByBlueId(t) {
|
|
2677
|
+
const n = this.blueIdToContentMap.get(t), s = this.blueIdToMultipleDocumentsMap.get(t);
|
|
2678
|
+
return n !== void 0 && s !== void 0 ? ne.resolveThisReferences(
|
|
2679
|
+
n,
|
|
2680
|
+
t,
|
|
2681
|
+
s
|
|
2682
|
+
) : null;
|
|
2683
|
+
}
|
|
2684
|
+
/**
|
|
2685
|
+
* Get all stored Blue IDs
|
|
2686
|
+
*/
|
|
2687
|
+
getBlueIds() {
|
|
2688
|
+
return Array.from(this.blueIdToContentMap.keys());
|
|
2689
|
+
}
|
|
2690
|
+
/**
|
|
2691
|
+
* Check if a Blue ID exists in this provider
|
|
2692
|
+
*/
|
|
2693
|
+
hasBlueId(t) {
|
|
2694
|
+
const n = t.split("#")[0];
|
|
2695
|
+
return this.blueIdToContentMap.has(n);
|
|
2696
|
+
}
|
|
2697
|
+
}
|
|
2698
|
+
class ue {
|
|
2699
|
+
/**
|
|
2700
|
+
* Wraps a NodeProvider with a SequentialNodeProvider that includes bootstrap providers and repository definitions
|
|
2701
|
+
* @param originalProvider - The original NodeProvider to wrap
|
|
2702
|
+
* @param repositories - Optional repositories containing definitions
|
|
2703
|
+
* @returns A wrapped NodeProvider that includes bootstrap providers and repository definitions
|
|
2704
|
+
*/
|
|
2705
|
+
static wrap(e, t) {
|
|
2706
|
+
const n = [Ye.INSTANCE];
|
|
2707
|
+
if (t && t.length > 0) {
|
|
2708
|
+
const s = new wn(t);
|
|
2709
|
+
n.push(s);
|
|
2710
|
+
}
|
|
2711
|
+
return n.push(e), new sn(n);
|
|
2712
|
+
}
|
|
2713
|
+
}
|
|
2714
|
+
class vn {
|
|
2444
2715
|
/**
|
|
2445
2716
|
* Creates a new BlueDirectivePreprocessor
|
|
2446
2717
|
*
|
|
@@ -2464,9 +2735,9 @@ class dn {
|
|
|
2464
2735
|
const n = e.clone();
|
|
2465
2736
|
if (this.preprocessingAliases.has(t))
|
|
2466
2737
|
return this.handleAliasValue(n, t);
|
|
2467
|
-
if (
|
|
2738
|
+
if (L.isPotentialBlueId(t))
|
|
2468
2739
|
return this.handleBlueId(n, t);
|
|
2469
|
-
throw
|
|
2740
|
+
throw ge(t) ? new Error(
|
|
2470
2741
|
`URL '${t}' detected. Use the async version of this method to fetch the content.`
|
|
2471
2742
|
) : new Error(`Invalid blue value: ${t}`);
|
|
2472
2743
|
}
|
|
@@ -2484,19 +2755,19 @@ class dn {
|
|
|
2484
2755
|
const n = e.clone();
|
|
2485
2756
|
if (this.preprocessingAliases.has(t))
|
|
2486
2757
|
return this.handleAliasValue(n, t);
|
|
2487
|
-
if (
|
|
2758
|
+
if (L.isPotentialBlueId(t))
|
|
2488
2759
|
return this.handleBlueId(n, t);
|
|
2489
|
-
if (
|
|
2760
|
+
if (ge(t) && this.urlContentFetcher)
|
|
2490
2761
|
try {
|
|
2491
2762
|
const s = await this.fetchFromUrl(t);
|
|
2492
|
-
return s && n.setBlue(new
|
|
2763
|
+
return s && n.setBlue(new a().setItems(s)), n;
|
|
2493
2764
|
} catch (s) {
|
|
2494
2765
|
throw s instanceof Error ? new Error(
|
|
2495
2766
|
`Failed to fetch from URL '${t}'.
|
|
2496
2767
|
${s.message}`
|
|
2497
2768
|
) : s;
|
|
2498
2769
|
}
|
|
2499
|
-
else throw
|
|
2770
|
+
else throw ge(t) ? new Error(
|
|
2500
2771
|
`UrlContentFetcher not provided for URL: ${t}`
|
|
2501
2772
|
) : new Error(`Invalid blue value: ${t}`);
|
|
2502
2773
|
}
|
|
@@ -2519,7 +2790,7 @@ ${s.message}`
|
|
|
2519
2790
|
*/
|
|
2520
2791
|
handleAliasValue(e, t) {
|
|
2521
2792
|
return e.setBlue(
|
|
2522
|
-
new
|
|
2793
|
+
new a().setBlueId(this.preprocessingAliases.get(t))
|
|
2523
2794
|
), e;
|
|
2524
2795
|
}
|
|
2525
2796
|
/**
|
|
@@ -2529,7 +2800,7 @@ ${s.message}`
|
|
|
2529
2800
|
* @returns The modified node
|
|
2530
2801
|
*/
|
|
2531
2802
|
handleBlueId(e, t) {
|
|
2532
|
-
return e.setBlue(new
|
|
2803
|
+
return e.setBlue(new a().setBlueId(t)), e;
|
|
2533
2804
|
}
|
|
2534
2805
|
/**
|
|
2535
2806
|
* Fetches content from a URL
|
|
@@ -2582,24 +2853,24 @@ ${s.message}`
|
|
|
2582
2853
|
return this.urlContentFetcher;
|
|
2583
2854
|
}
|
|
2584
2855
|
}
|
|
2585
|
-
const
|
|
2856
|
+
const Bn = {
|
|
2586
2857
|
fetchUrl: async (r) => {
|
|
2587
2858
|
throw new Error(
|
|
2588
2859
|
`You must provide a custom UrlFetchStrategy to fetch content from URL: ${r}`
|
|
2589
2860
|
);
|
|
2590
2861
|
}
|
|
2591
2862
|
};
|
|
2592
|
-
class
|
|
2863
|
+
class En {
|
|
2593
2864
|
constructor(e) {
|
|
2594
2865
|
// Cache to avoid repeated network requests for the same URL
|
|
2595
2866
|
u(this, "cache", /* @__PURE__ */ new Map());
|
|
2596
2867
|
u(this, "fetchStrategy");
|
|
2597
2868
|
u(this, "enabled", !1);
|
|
2598
2869
|
u(this, "allowedDomains", []);
|
|
2599
|
-
this.fetchStrategy = e ||
|
|
2870
|
+
this.fetchStrategy = e || Bn;
|
|
2600
2871
|
}
|
|
2601
2872
|
validateUrl(e) {
|
|
2602
|
-
if (!
|
|
2873
|
+
if (!ge(e))
|
|
2603
2874
|
throw new Error(`Invalid URL: ${e}`);
|
|
2604
2875
|
return !0;
|
|
2605
2876
|
}
|
|
@@ -2638,7 +2909,7 @@ class pn {
|
|
|
2638
2909
|
const { data: n, contentType: s } = t;
|
|
2639
2910
|
let i;
|
|
2640
2911
|
if (s.includes("application/json") || s.includes("text/yaml") || s.includes("application/yaml") || s.includes("text/plain"))
|
|
2641
|
-
i =
|
|
2912
|
+
i = W(n);
|
|
2642
2913
|
else
|
|
2643
2914
|
throw new Error(`Unsupported content type from URL: ${s}`);
|
|
2644
2915
|
if (i === void 0)
|
|
@@ -2718,36 +2989,487 @@ class pn {
|
|
|
2718
2989
|
return this.allowedDomains = [], this;
|
|
2719
2990
|
}
|
|
2720
2991
|
}
|
|
2721
|
-
class
|
|
2992
|
+
class Nn {
|
|
2993
|
+
/**
|
|
2994
|
+
* Resolves a node without limits
|
|
2995
|
+
* Default implementation that uses NO_LIMITS
|
|
2996
|
+
*
|
|
2997
|
+
* @param node - The node to resolve
|
|
2998
|
+
* @returns The resolved node using NO_LIMITS
|
|
2999
|
+
*/
|
|
3000
|
+
resolveWithoutLimits(e) {
|
|
3001
|
+
return this.resolve(e, G);
|
|
3002
|
+
}
|
|
3003
|
+
}
|
|
3004
|
+
class Sn extends Nn {
|
|
3005
|
+
/**
|
|
3006
|
+
* Creates a new Merger with the specified MergingProcessor and NodeProvider
|
|
3007
|
+
* @param mergingProcessor - The processor to use for merge operations
|
|
3008
|
+
* @param nodeProvider - The provider to use for resolving nodes
|
|
3009
|
+
*/
|
|
3010
|
+
constructor(t, n) {
|
|
3011
|
+
super();
|
|
3012
|
+
u(this, "mergingProcessor");
|
|
3013
|
+
u(this, "nodeProvider");
|
|
3014
|
+
this.mergingProcessor = t, this.nodeProvider = ue.wrap(n);
|
|
3015
|
+
}
|
|
3016
|
+
/**
|
|
3017
|
+
* Merges a source node into a target node with the given limits
|
|
3018
|
+
* @param target - The target node to merge into
|
|
3019
|
+
* @param source - The source node to merge from
|
|
3020
|
+
* @param limits - The limits to apply during merging
|
|
3021
|
+
*/
|
|
3022
|
+
merge(t, n, s) {
|
|
3023
|
+
if (f(n.getBlue()))
|
|
3024
|
+
throw new Error(
|
|
3025
|
+
'Document contains "blue" attribute. Preprocess document before merging.'
|
|
3026
|
+
);
|
|
3027
|
+
const i = n.getType();
|
|
3028
|
+
if (f(i)) {
|
|
3029
|
+
f(i.getBlueId()) && new st(this.nodeProvider).extend(
|
|
3030
|
+
i,
|
|
3031
|
+
it.withSinglePath("/")
|
|
3032
|
+
);
|
|
3033
|
+
const o = this.resolve(i, s);
|
|
3034
|
+
n.setType(o), this.merge(t, i, s);
|
|
3035
|
+
}
|
|
3036
|
+
this.mergeObject(t, n, s);
|
|
3037
|
+
}
|
|
3038
|
+
/**
|
|
3039
|
+
* Merges the properties and items of a source node into a target node
|
|
3040
|
+
* @param target - The target node to merge into
|
|
3041
|
+
* @param source - The source node to merge from
|
|
3042
|
+
* @param limits - The limits to apply during merging
|
|
3043
|
+
*/
|
|
3044
|
+
mergeObject(t, n, s) {
|
|
3045
|
+
this.mergingProcessor.process(t, n, this.nodeProvider, this);
|
|
3046
|
+
const i = n.getItems();
|
|
3047
|
+
f(i) && this.mergeChildren(t, i, s);
|
|
3048
|
+
const o = n.getProperties();
|
|
3049
|
+
f(o) && Object.entries(o).forEach(([c, l]) => {
|
|
3050
|
+
s.shouldMergePathSegment(c, l) && (s.enterPathSegment(c, l), this.mergeProperty(t, c, l, s), s.exitPathSegment());
|
|
3051
|
+
}), f(n.getBlueId()) && t.setBlueId(n.getBlueId()), this.mergingProcessor.postProcess && this.mergingProcessor.postProcess(
|
|
3052
|
+
t,
|
|
3053
|
+
n,
|
|
3054
|
+
this.nodeProvider,
|
|
3055
|
+
this
|
|
3056
|
+
);
|
|
3057
|
+
}
|
|
3058
|
+
/**
|
|
3059
|
+
* Merges child items from source into target
|
|
3060
|
+
* @param target - The target node
|
|
3061
|
+
* @param sourceChildren - The source children to merge
|
|
3062
|
+
* @param limits - The limits to apply
|
|
3063
|
+
*/
|
|
3064
|
+
mergeChildren(t, n, s) {
|
|
3065
|
+
const i = t.getItems();
|
|
3066
|
+
if (N(i)) {
|
|
3067
|
+
const o = n.filter(
|
|
3068
|
+
(c, l) => s.shouldMergePathSegment(String(l), t)
|
|
3069
|
+
).map((c) => {
|
|
3070
|
+
s.enterPathSegment(
|
|
3071
|
+
String(n.indexOf(c)),
|
|
3072
|
+
t
|
|
3073
|
+
);
|
|
3074
|
+
const l = this.resolve(c, s);
|
|
3075
|
+
return s.exitPathSegment(), l;
|
|
3076
|
+
});
|
|
3077
|
+
t.setItems(o);
|
|
3078
|
+
return;
|
|
3079
|
+
} else if (n.length < i.length)
|
|
3080
|
+
throw new Error(
|
|
3081
|
+
`Subtype of element must not have more items (${i.length}) than the element itself (${n.length}).`
|
|
3082
|
+
);
|
|
3083
|
+
for (let o = 0; o < n.length; o++) {
|
|
3084
|
+
if (!s.shouldMergePathSegment(String(o), n[o]))
|
|
3085
|
+
continue;
|
|
3086
|
+
if (s.enterPathSegment(String(o), n[o]), o >= i.length) {
|
|
3087
|
+
i.push(n[o]), s.exitPathSegment();
|
|
3088
|
+
continue;
|
|
3089
|
+
}
|
|
3090
|
+
const c = w.calculateBlueIdSync(
|
|
3091
|
+
n[o]
|
|
3092
|
+
), l = w.calculateBlueIdSync(
|
|
3093
|
+
i[o]
|
|
3094
|
+
);
|
|
3095
|
+
if (c !== l)
|
|
3096
|
+
throw new Error(
|
|
3097
|
+
`Mismatched items at index ${o}: source item has blueId '${c}', but target item has blueId '${l}'.`
|
|
3098
|
+
);
|
|
3099
|
+
s.exitPathSegment();
|
|
3100
|
+
}
|
|
3101
|
+
}
|
|
3102
|
+
/**
|
|
3103
|
+
* Merges a property from source into target
|
|
3104
|
+
* @param target - The target node
|
|
3105
|
+
* @param sourceKey - The property key
|
|
3106
|
+
* @param sourceValue - The property value to merge
|
|
3107
|
+
* @param limits - The limits to apply
|
|
3108
|
+
*/
|
|
3109
|
+
mergeProperty(t, n, s, i) {
|
|
3110
|
+
const o = this.resolve(s, i);
|
|
3111
|
+
N(t.getProperties()) && t.setProperties({});
|
|
3112
|
+
const c = t.getProperties()[n];
|
|
3113
|
+
c === void 0 ? t.getProperties()[n] = o : this.mergeObject(c, o, i);
|
|
3114
|
+
}
|
|
3115
|
+
/**
|
|
3116
|
+
* Resolves a node by creating a new node and merging the source into it
|
|
3117
|
+
* @param node - The node to resolve
|
|
3118
|
+
* @param limits - The limits to apply during resolution
|
|
3119
|
+
* @returns The resolved node
|
|
3120
|
+
*/
|
|
3121
|
+
resolve(t, n) {
|
|
3122
|
+
const s = new a();
|
|
3123
|
+
return this.merge(s, t, n), s.setName(t.getName()), s.setDescription(t.getDescription()), s.setBlueId(t.getBlueId()), s;
|
|
3124
|
+
}
|
|
3125
|
+
}
|
|
3126
|
+
class Pn {
|
|
3127
|
+
/**
|
|
3128
|
+
* Creates a new SequentialMergingProcessor with the given processors
|
|
3129
|
+
* @param mergingProcessors - Array of processors to execute in sequence
|
|
3130
|
+
*/
|
|
3131
|
+
constructor(e) {
|
|
3132
|
+
u(this, "mergingProcessors");
|
|
3133
|
+
this.mergingProcessors = e;
|
|
3134
|
+
}
|
|
3135
|
+
/**
|
|
3136
|
+
* Processes all contained processors in sequence
|
|
3137
|
+
*/
|
|
3138
|
+
process(e, t, n, s) {
|
|
3139
|
+
this.mergingProcessors.forEach(
|
|
3140
|
+
(i) => i.process(e, t, n, s)
|
|
3141
|
+
);
|
|
3142
|
+
}
|
|
3143
|
+
/**
|
|
3144
|
+
* Post-processes all contained processors in sequence
|
|
3145
|
+
*/
|
|
3146
|
+
postProcess(e, t, n, s) {
|
|
3147
|
+
this.mergingProcessors.forEach((i) => {
|
|
3148
|
+
i.postProcess && i.postProcess(e, t, n, s);
|
|
3149
|
+
});
|
|
3150
|
+
}
|
|
3151
|
+
}
|
|
3152
|
+
class An {
|
|
3153
|
+
process(e, t) {
|
|
3154
|
+
const n = t.getValue();
|
|
3155
|
+
if (f(n)) {
|
|
3156
|
+
const s = e.getValue();
|
|
3157
|
+
if (N(s))
|
|
3158
|
+
e.setValue(n);
|
|
3159
|
+
else if (n !== s)
|
|
3160
|
+
throw new Error(
|
|
3161
|
+
`Node values conflict. Source node value: ${n}, target node value: ${s}`
|
|
3162
|
+
);
|
|
3163
|
+
}
|
|
3164
|
+
}
|
|
3165
|
+
}
|
|
3166
|
+
function $e(r, e) {
|
|
3167
|
+
const t = r.getType();
|
|
3168
|
+
if (t === void 0)
|
|
3169
|
+
return;
|
|
3170
|
+
const n = t.getBlueId();
|
|
3171
|
+
if (n !== void 0) {
|
|
3172
|
+
if (de.includes(
|
|
3173
|
+
n
|
|
3174
|
+
)) {
|
|
3175
|
+
const i = or[n];
|
|
3176
|
+
return new a().setBlueId(n).setName(i);
|
|
3177
|
+
}
|
|
3178
|
+
const s = e.fetchByBlueId(n);
|
|
3179
|
+
if (!s || s.length === 0)
|
|
3180
|
+
return;
|
|
3181
|
+
if (s.length > 1)
|
|
3182
|
+
throw new Error(
|
|
3183
|
+
`Expected a single node for type with blueId '${n}', but found multiple.`
|
|
3184
|
+
);
|
|
3185
|
+
return s[0];
|
|
3186
|
+
}
|
|
3187
|
+
return t;
|
|
3188
|
+
}
|
|
3189
|
+
function E(r, e, t) {
|
|
3190
|
+
const n = w.calculateBlueIdSync(r), s = w.calculateBlueIdSync(e);
|
|
3191
|
+
if (n === s)
|
|
3192
|
+
return !0;
|
|
3193
|
+
if (n && de.includes(
|
|
3194
|
+
n
|
|
3195
|
+
)) {
|
|
3196
|
+
let o = e;
|
|
3197
|
+
for (; o !== void 0; ) {
|
|
3198
|
+
if (w.calculateBlueIdSync(o) === n)
|
|
3199
|
+
return !0;
|
|
3200
|
+
o = $e(o, t);
|
|
3201
|
+
}
|
|
3202
|
+
return !1;
|
|
3203
|
+
}
|
|
3204
|
+
let i = $e(r, t);
|
|
3205
|
+
for (; i !== void 0; ) {
|
|
3206
|
+
if (w.calculateBlueIdSync(i) === s)
|
|
3207
|
+
return !0;
|
|
3208
|
+
i = $e(i, t);
|
|
3209
|
+
}
|
|
3210
|
+
return !1;
|
|
3211
|
+
}
|
|
3212
|
+
function Cn(r, e) {
|
|
3213
|
+
return Et.some((t) => {
|
|
3214
|
+
const n = new a().setBlueId(t);
|
|
3215
|
+
return E(r, n, e);
|
|
3216
|
+
});
|
|
3217
|
+
}
|
|
3218
|
+
function Vn(r, e) {
|
|
3219
|
+
const t = new a().setBlueId(H);
|
|
3220
|
+
return E(r, t, e);
|
|
3221
|
+
}
|
|
3222
|
+
function On(r, e) {
|
|
3223
|
+
const t = new a().setBlueId(q);
|
|
3224
|
+
return E(r, t, e);
|
|
3225
|
+
}
|
|
3226
|
+
function Dn(r, e) {
|
|
3227
|
+
const t = new a().setBlueId(X);
|
|
3228
|
+
return E(r, t, e);
|
|
3229
|
+
}
|
|
3230
|
+
function Fn(r, e) {
|
|
3231
|
+
const t = new a().setBlueId(Q);
|
|
3232
|
+
return E(r, t, e);
|
|
3233
|
+
}
|
|
3234
|
+
function Rn(r) {
|
|
3235
|
+
return (r == null ? void 0 : r.getBlueId()) === vt;
|
|
3236
|
+
}
|
|
3237
|
+
function Mn(r) {
|
|
3238
|
+
return (r == null ? void 0 : r.getBlueId()) === Bt;
|
|
3239
|
+
}
|
|
3240
|
+
function jn(r, e) {
|
|
3241
|
+
return tt.some((t) => {
|
|
3242
|
+
const n = new a().setName(t);
|
|
3243
|
+
return E(r, n, e);
|
|
3244
|
+
});
|
|
3245
|
+
}
|
|
3246
|
+
function xn(r, e) {
|
|
3247
|
+
for (const t of tt) {
|
|
3248
|
+
const n = new a().setName(t);
|
|
3249
|
+
if (E(r, n, e))
|
|
3250
|
+
return t;
|
|
3251
|
+
}
|
|
3252
|
+
throw new Error(
|
|
3253
|
+
`Cannot determine the basic type for node of type "${r.getName() || "unknown"}".`
|
|
3254
|
+
);
|
|
3255
|
+
}
|
|
3256
|
+
class $n {
|
|
3257
|
+
process(e, t, n) {
|
|
3258
|
+
const s = e.getType(), i = t.getType();
|
|
3259
|
+
if (s === void 0)
|
|
3260
|
+
e.setType(i);
|
|
3261
|
+
else if (i !== void 0) {
|
|
3262
|
+
if (!E(i, s, n)) {
|
|
3263
|
+
const c = y.get(i), l = y.get(s);
|
|
3264
|
+
throw new Error(
|
|
3265
|
+
`The source type '${JSON.stringify(
|
|
3266
|
+
c
|
|
3267
|
+
)}' is not a subtype of the target type '${JSON.stringify(
|
|
3268
|
+
l
|
|
3269
|
+
)}'.`
|
|
3270
|
+
);
|
|
3271
|
+
}
|
|
3272
|
+
e.setType(i);
|
|
3273
|
+
}
|
|
3274
|
+
}
|
|
3275
|
+
}
|
|
3276
|
+
class Un {
|
|
3277
|
+
process(e, t, n) {
|
|
3278
|
+
if (t.getItemType() !== void 0 && !Rn(t.getType()))
|
|
3279
|
+
throw new Error("Source node with itemType must have a List type");
|
|
3280
|
+
const s = e.getItemType(), i = t.getItemType();
|
|
3281
|
+
if (s === void 0)
|
|
3282
|
+
i !== void 0 && e.setItemType(i);
|
|
3283
|
+
else if (i !== void 0) {
|
|
3284
|
+
if (!E(
|
|
3285
|
+
i,
|
|
3286
|
+
s,
|
|
3287
|
+
n
|
|
3288
|
+
)) {
|
|
3289
|
+
const h = y.get(i), T = y.get(s);
|
|
3290
|
+
throw new Error(
|
|
3291
|
+
`The source item type '${JSON.stringify(
|
|
3292
|
+
h
|
|
3293
|
+
)}' is not a subtype of the target item type '${JSON.stringify(
|
|
3294
|
+
T
|
|
3295
|
+
)}'.`
|
|
3296
|
+
);
|
|
3297
|
+
}
|
|
3298
|
+
e.setItemType(i);
|
|
3299
|
+
}
|
|
3300
|
+
const o = e.getItemType(), c = t.getItems();
|
|
3301
|
+
if (o !== void 0 && c !== void 0)
|
|
3302
|
+
for (const l of c) {
|
|
3303
|
+
const h = l.getType();
|
|
3304
|
+
if (h !== void 0 && !E(h, o, n)) {
|
|
3305
|
+
const T = y.get(h), b = y.get(
|
|
3306
|
+
o
|
|
3307
|
+
);
|
|
3308
|
+
throw new Error(
|
|
3309
|
+
`Item of type '${JSON.stringify(
|
|
3310
|
+
T
|
|
3311
|
+
)}' is not a subtype of the list's item type '${JSON.stringify(
|
|
3312
|
+
b
|
|
3313
|
+
)}'.`
|
|
3314
|
+
);
|
|
3315
|
+
}
|
|
3316
|
+
}
|
|
3317
|
+
}
|
|
3318
|
+
}
|
|
3319
|
+
class Ln {
|
|
3320
|
+
process(e, t, n) {
|
|
3321
|
+
if ((t.getKeyType() !== void 0 || t.getValueType() !== void 0) && !Mn(t.getType()))
|
|
3322
|
+
throw new Error(
|
|
3323
|
+
"Source node with keyType or valueType must have a Dictionary type"
|
|
3324
|
+
);
|
|
3325
|
+
this.processKeyType(e, t, n), this.processValueType(e, t, n);
|
|
3326
|
+
const s = e.getKeyType(), i = e.getValueType(), o = t.getProperties();
|
|
3327
|
+
(s !== void 0 || i !== void 0) && o !== void 0 && Object.entries(o).forEach(([c, l]) => {
|
|
3328
|
+
s !== void 0 && this.validateKeyType(c, s, n), i !== void 0 && this.validateValueType(l, i, n);
|
|
3329
|
+
});
|
|
3330
|
+
}
|
|
3331
|
+
processKeyType(e, t, n) {
|
|
3332
|
+
const s = e.getKeyType(), i = t.getKeyType();
|
|
3333
|
+
if (s === void 0)
|
|
3334
|
+
i !== void 0 && (this.validateBasicKeyType(i, n), e.setKeyType(i));
|
|
3335
|
+
else if (i !== void 0) {
|
|
3336
|
+
if (this.validateBasicKeyType(i, n), !E(
|
|
3337
|
+
i,
|
|
3338
|
+
s,
|
|
3339
|
+
n
|
|
3340
|
+
)) {
|
|
3341
|
+
const c = y.get(i), l = y.get(s);
|
|
3342
|
+
throw new Error(
|
|
3343
|
+
`The source key type '${JSON.stringify(
|
|
3344
|
+
c
|
|
3345
|
+
)}' is not a subtype of the target key type '${JSON.stringify(
|
|
3346
|
+
l
|
|
3347
|
+
)}'.`
|
|
3348
|
+
);
|
|
3349
|
+
}
|
|
3350
|
+
e.setKeyType(i);
|
|
3351
|
+
}
|
|
3352
|
+
}
|
|
3353
|
+
processValueType(e, t, n) {
|
|
3354
|
+
const s = e.getValueType(), i = t.getValueType();
|
|
3355
|
+
if (s === void 0)
|
|
3356
|
+
i !== void 0 && e.setValueType(i);
|
|
3357
|
+
else if (i !== void 0) {
|
|
3358
|
+
if (!E(
|
|
3359
|
+
i,
|
|
3360
|
+
s,
|
|
3361
|
+
n
|
|
3362
|
+
)) {
|
|
3363
|
+
const c = y.get(i), l = y.get(s);
|
|
3364
|
+
throw new Error(
|
|
3365
|
+
`The source value type '${JSON.stringify(
|
|
3366
|
+
c
|
|
3367
|
+
)}' is not a subtype of the target value type '${JSON.stringify(
|
|
3368
|
+
l
|
|
3369
|
+
)}'.`
|
|
3370
|
+
);
|
|
3371
|
+
}
|
|
3372
|
+
e.setValueType(i);
|
|
3373
|
+
}
|
|
3374
|
+
}
|
|
3375
|
+
validateBasicKeyType(e, t) {
|
|
3376
|
+
if (!Cn(e, t))
|
|
3377
|
+
throw new Error("Dictionary key type must be a basic type");
|
|
3378
|
+
}
|
|
3379
|
+
validateKeyType(e, t, n) {
|
|
3380
|
+
if (!Vn(t, n))
|
|
3381
|
+
if (On(t, n)) {
|
|
3382
|
+
const s = Number.parseInt(e, 10);
|
|
3383
|
+
if (Number.isNaN(s) || s.toString() !== e)
|
|
3384
|
+
throw new Error(`Key '${e}' is not a valid Integer.`);
|
|
3385
|
+
} else if (Dn(t, n)) {
|
|
3386
|
+
const s = Number.parseFloat(e);
|
|
3387
|
+
if (Number.isNaN(s))
|
|
3388
|
+
throw new Error(`Key '${e}' is not a valid Number.`);
|
|
3389
|
+
} else if (Fn(t, n)) {
|
|
3390
|
+
if (e.toLowerCase() !== "true" && e.toLowerCase() !== "false")
|
|
3391
|
+
throw new Error(`Key '${e}' is not a valid Boolean.`);
|
|
3392
|
+
} else
|
|
3393
|
+
throw new Error(
|
|
3394
|
+
`Unsupported key type: ${t.getName() || "unknown"}`
|
|
3395
|
+
);
|
|
3396
|
+
}
|
|
3397
|
+
validateValueType(e, t, n) {
|
|
3398
|
+
const s = e.getType();
|
|
3399
|
+
if (s !== void 0 && !E(s, t, n)) {
|
|
3400
|
+
const i = y.get(s), o = y.get(t);
|
|
3401
|
+
throw new Error(
|
|
3402
|
+
`Value of type '${JSON.stringify(
|
|
3403
|
+
i
|
|
3404
|
+
)}' is not a subtype of the dictionary's value type '${JSON.stringify(
|
|
3405
|
+
o
|
|
3406
|
+
)}'.`
|
|
3407
|
+
);
|
|
3408
|
+
}
|
|
3409
|
+
}
|
|
3410
|
+
}
|
|
3411
|
+
class _n {
|
|
3412
|
+
process() {
|
|
3413
|
+
}
|
|
3414
|
+
postProcess(e, t, n) {
|
|
3415
|
+
const s = e.getType();
|
|
3416
|
+
if (s !== void 0 && jn(s, n)) {
|
|
3417
|
+
const i = e.getItems(), o = e.getProperties();
|
|
3418
|
+
if (i !== void 0 && i.length > 0 || o !== void 0 && Object.keys(o).length > 0) {
|
|
3419
|
+
const c = xn(s, n), l = s.getName() || "unknown";
|
|
3420
|
+
throw new Error(
|
|
3421
|
+
`Node of type "${l}" (which extends basic type "${c}") must not have items or properties.`
|
|
3422
|
+
);
|
|
3423
|
+
}
|
|
3424
|
+
}
|
|
3425
|
+
}
|
|
3426
|
+
}
|
|
3427
|
+
function Zn() {
|
|
3428
|
+
return new Pn([
|
|
3429
|
+
new An(),
|
|
3430
|
+
new $n(),
|
|
3431
|
+
new Un(),
|
|
3432
|
+
new Ln(),
|
|
3433
|
+
new _n()
|
|
3434
|
+
]);
|
|
3435
|
+
}
|
|
3436
|
+
class vs {
|
|
2722
3437
|
constructor(e = {}) {
|
|
2723
3438
|
u(this, "nodeProvider");
|
|
2724
3439
|
u(this, "typeSchemaResolver");
|
|
2725
3440
|
u(this, "blueDirectivePreprocessor");
|
|
2726
3441
|
u(this, "urlContentFetcher");
|
|
2727
3442
|
u(this, "blueIdsMappingGenerator");
|
|
2728
|
-
u(this, "
|
|
3443
|
+
u(this, "globalLimits", G);
|
|
3444
|
+
u(this, "mergingProcessor");
|
|
3445
|
+
u(this, "repositories");
|
|
3446
|
+
u(this, "prepareForBlueIdCalculation", async (e) => e instanceof a || Array.isArray(e) && e.every((t) => t instanceof a) ? e : Array.isArray(e) ? await Promise.all(
|
|
2729
3447
|
e.map((n) => this.jsonValueToNodeAsync(n))
|
|
2730
3448
|
) : this.jsonValueToNodeAsync(e));
|
|
2731
3449
|
u(this, "calculateBlueId", async (e) => {
|
|
2732
3450
|
const t = await this.prepareForBlueIdCalculation(e);
|
|
2733
|
-
return
|
|
3451
|
+
return w.calculateBlueId(t);
|
|
2734
3452
|
});
|
|
2735
|
-
u(this, "prepareForBlueIdCalculationSync", (e) => e instanceof
|
|
2736
|
-
var
|
|
3453
|
+
u(this, "prepareForBlueIdCalculationSync", (e) => e instanceof a || Array.isArray(e) && e.every((t) => t instanceof a) ? e : Array.isArray(e) ? e.map((t) => this.jsonValueToNode(t)) : this.jsonValueToNode(e));
|
|
3454
|
+
var l;
|
|
2737
3455
|
const {
|
|
2738
3456
|
nodeProvider: t,
|
|
2739
3457
|
typeSchemaResolver: n = null,
|
|
2740
3458
|
urlFetchStrategy: s,
|
|
2741
|
-
repositories: i
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
3459
|
+
repositories: i,
|
|
3460
|
+
mergingProcessor: o
|
|
3461
|
+
} = e;
|
|
3462
|
+
this.repositories = i;
|
|
3463
|
+
const c = nn(() => []);
|
|
3464
|
+
if (this.nodeProvider = ue.wrap(
|
|
3465
|
+
t || c,
|
|
3466
|
+
i
|
|
3467
|
+
), this.typeSchemaResolver = n ?? new Gr([]), this.mergingProcessor = o ?? Zn(), this.urlContentFetcher = new En(s), this.blueDirectivePreprocessor = new vn(
|
|
2746
3468
|
void 0,
|
|
2747
3469
|
this.urlContentFetcher
|
|
2748
|
-
), this.blueIdsMappingGenerator = new
|
|
2749
|
-
for (const { schemas:
|
|
2750
|
-
(
|
|
3470
|
+
), this.blueIdsMappingGenerator = new Ut(), i)
|
|
3471
|
+
for (const { schemas: h, blueIds: T } of i)
|
|
3472
|
+
(l = this.typeSchemaResolver) == null || l.registerSchemas(h), this.blueIdsMappingGenerator.registerBlueIds(T);
|
|
2751
3473
|
}
|
|
2752
3474
|
/**
|
|
2753
3475
|
* Converts a BlueNode to a JSON representation based on the specified strategy.
|
|
@@ -2757,10 +3479,18 @@ class Hn {
|
|
|
2757
3479
|
* @returns A JSON representation of the node.
|
|
2758
3480
|
*/
|
|
2759
3481
|
nodeToJson(e, t = "official") {
|
|
2760
|
-
return
|
|
3482
|
+
return y.get(e, t);
|
|
2761
3483
|
}
|
|
2762
3484
|
nodeToSchemaOutput(e, t) {
|
|
2763
|
-
return new
|
|
3485
|
+
return new rn(this.typeSchemaResolver).convert(e, t);
|
|
3486
|
+
}
|
|
3487
|
+
resolve(e, t = G) {
|
|
3488
|
+
const n = this.combineWithGlobalLimits(t);
|
|
3489
|
+
return new Sn(this.mergingProcessor, this.nodeProvider).resolve(e, n);
|
|
3490
|
+
}
|
|
3491
|
+
extend(e, t) {
|
|
3492
|
+
const n = this.combineWithGlobalLimits(t);
|
|
3493
|
+
new st(this.nodeProvider).extend(e, n);
|
|
2764
3494
|
}
|
|
2765
3495
|
jsonValueToNode(e) {
|
|
2766
3496
|
return this.preprocess(p.deserialize(e));
|
|
@@ -2769,27 +3499,27 @@ class Hn {
|
|
|
2769
3499
|
return this.preprocessAsync(p.deserialize(e));
|
|
2770
3500
|
}
|
|
2771
3501
|
yamlToNode(e) {
|
|
2772
|
-
const t =
|
|
3502
|
+
const t = W(e);
|
|
2773
3503
|
if (!t)
|
|
2774
3504
|
throw new Error("Failed to parse YAML to JSON");
|
|
2775
3505
|
return this.jsonValueToNode(t);
|
|
2776
3506
|
}
|
|
2777
3507
|
async yamlToNodeAsync(e) {
|
|
2778
|
-
const t =
|
|
3508
|
+
const t = W(e);
|
|
2779
3509
|
if (!t)
|
|
2780
3510
|
throw new Error("Failed to parse YAML to JSON");
|
|
2781
3511
|
return this.jsonValueToNodeAsync(t);
|
|
2782
3512
|
}
|
|
2783
3513
|
calculateBlueIdSync(e) {
|
|
2784
3514
|
const t = this.prepareForBlueIdCalculationSync(e);
|
|
2785
|
-
return
|
|
3515
|
+
return w.calculateBlueIdSync(t);
|
|
2786
3516
|
}
|
|
2787
3517
|
addPreprocessingAliases(e) {
|
|
2788
3518
|
this.blueDirectivePreprocessor.addPreprocessingAliases(e);
|
|
2789
3519
|
}
|
|
2790
3520
|
preprocess(e) {
|
|
2791
3521
|
const t = this.blueDirectivePreprocessor.process(e);
|
|
2792
|
-
return new
|
|
3522
|
+
return new ae({
|
|
2793
3523
|
nodeProvider: this.nodeProvider,
|
|
2794
3524
|
blueIdsMappingGenerator: this.blueIdsMappingGenerator
|
|
2795
3525
|
}).preprocessWithDefaultBlue(t);
|
|
@@ -2798,7 +3528,7 @@ class Hn {
|
|
|
2798
3528
|
const t = await this.blueDirectivePreprocessor.processAsync(
|
|
2799
3529
|
e
|
|
2800
3530
|
);
|
|
2801
|
-
return new
|
|
3531
|
+
return new ae({
|
|
2802
3532
|
nodeProvider: this.nodeProvider,
|
|
2803
3533
|
blueIdsMappingGenerator: this.blueIdsMappingGenerator
|
|
2804
3534
|
}).preprocessWithDefaultBlue(t);
|
|
@@ -2807,7 +3537,10 @@ class Hn {
|
|
|
2807
3537
|
return this.nodeProvider;
|
|
2808
3538
|
}
|
|
2809
3539
|
setNodeProvider(e) {
|
|
2810
|
-
return this.nodeProvider =
|
|
3540
|
+
return this.nodeProvider = ue.wrap(
|
|
3541
|
+
e,
|
|
3542
|
+
this.repositories
|
|
3543
|
+
), this;
|
|
2811
3544
|
}
|
|
2812
3545
|
getTypeSchemaResolver() {
|
|
2813
3546
|
return this.typeSchemaResolver;
|
|
@@ -2928,72 +3661,75 @@ class Hn {
|
|
|
2928
3661
|
* @returns true if the node matches the schema type, false otherwise
|
|
2929
3662
|
*/
|
|
2930
3663
|
isTypeOf(e, t, n) {
|
|
2931
|
-
return
|
|
3664
|
+
return A.isTypeOf(e, t, {
|
|
2932
3665
|
checkSchemaExtensions: n == null ? void 0 : n.checkSchemaExtensions,
|
|
2933
3666
|
typeSchemaResolver: this.typeSchemaResolver
|
|
2934
3667
|
});
|
|
2935
3668
|
}
|
|
3669
|
+
combineWithGlobalLimits(e) {
|
|
3670
|
+
return this.globalLimits == G ? e : e == G ? this.globalLimits : G;
|
|
3671
|
+
}
|
|
2936
3672
|
}
|
|
2937
3673
|
export {
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
3674
|
+
Tr as Base58Sha256Provider,
|
|
3675
|
+
vs as Blue,
|
|
3676
|
+
w as BlueIdCalculator,
|
|
3677
|
+
ls as BlueIdToCid,
|
|
3678
|
+
a as BlueNode,
|
|
3679
|
+
A as BlueNodeTypeSchema,
|
|
3680
|
+
Ir as JsonCanonicalizer,
|
|
3681
|
+
Gr as TypeSchemaResolver,
|
|
3682
|
+
as as applyBlueNodePatch,
|
|
3683
|
+
Ae as baseBlueObjectSchema,
|
|
3684
|
+
us as blueDescriptionField,
|
|
3685
|
+
ds as blueIdField,
|
|
3686
|
+
Qn as blueIdSchema,
|
|
3687
|
+
fs as blueNameField,
|
|
3688
|
+
hs as blueNodeField,
|
|
3689
|
+
rs as blueObjectBooleanValueSchema,
|
|
3690
|
+
ts as blueObjectNumberValueSchema,
|
|
3691
|
+
ce as blueObjectSchema,
|
|
3692
|
+
ns as blueObjectStringListItemsSchema,
|
|
3693
|
+
es as blueObjectStringValueSchema,
|
|
3694
|
+
mn as calculateBlueId,
|
|
3695
|
+
gs as calculateBlueIdSync,
|
|
3696
|
+
lt as enrichWithBlueId,
|
|
3697
|
+
Dr as getBlueDescriptionAnnotation,
|
|
3698
|
+
Mr as getBlueIdAnnotation,
|
|
3699
|
+
xr as getBlueNameAnnotation,
|
|
3700
|
+
Ur as getBlueNodeAnnotation,
|
|
3701
|
+
ms as getBlueObjectItems,
|
|
3702
|
+
Ts as getBlueObjectProperties,
|
|
3703
|
+
bs as getBlueObjectTypeLabel,
|
|
3704
|
+
Is as getBlueObjectValue,
|
|
3705
|
+
_r as getExtendedFromSchemaAnnotation,
|
|
3706
|
+
Jr as getTypeBlueIdAnnotation,
|
|
3707
|
+
cr as hasBlueObjectBlueIdDefined,
|
|
3708
|
+
lr as hasBlueObjectItemsDefined,
|
|
3709
|
+
is as hasBlueObjectNameDefined,
|
|
3710
|
+
ar as hasBlueObjectTypeDefined,
|
|
3711
|
+
ur as hasBlueObjectValueDefined,
|
|
3712
|
+
dr as isBigDecimalNumber,
|
|
3713
|
+
le as isBigIntegerNumber,
|
|
3714
|
+
O as isBigNumber,
|
|
3715
|
+
Dt as isBlueNodeSchema,
|
|
3716
|
+
ss as isBlueObject,
|
|
3717
|
+
In as isBlueObjectResolved,
|
|
3718
|
+
os as isGivenBlueObjectTypeSchema,
|
|
3719
|
+
St as isJsonBlueArray,
|
|
3720
|
+
Nt as isJsonBlueObject,
|
|
3721
|
+
cs as isJsonBlueValue,
|
|
3722
|
+
Ft as isSchemaExtendedFrom,
|
|
3723
|
+
ge as isUrl,
|
|
3724
|
+
be as jsonBlueValueSchema,
|
|
3725
|
+
ws as normalizeToBlueObject,
|
|
3726
|
+
at as resolveBlueObjectItems,
|
|
3727
|
+
Or as withBlueDescription,
|
|
3728
|
+
Rr as withBlueId,
|
|
3729
|
+
jr as withBlueName,
|
|
3730
|
+
$r as withBlueNode,
|
|
3731
|
+
Lr as withExtendedFromSchema,
|
|
3732
|
+
ps as withTypeBlueId,
|
|
3733
|
+
ys as yamlBlueDump,
|
|
3734
|
+
W as yamlBlueParse
|
|
2999
3735
|
};
|