@xlr-lib/xlr-utils 0.1.1--canary.9.190
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/cjs/index.cjs +507 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/index.legacy-esm.js +456 -0
- package/dist/index.mjs +456 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +32 -0
- package/src/__tests__/__snapshots__/annotations.test.ts.snap +22 -0
- package/src/__tests__/__snapshots__/validation-helpers.test.ts.snap +53 -0
- package/src/__tests__/validation-helpers.test.ts +141 -0
- package/src/__tests__/xlr-helpers.test.ts +543 -0
- package/src/index.ts +3 -0
- package/src/type-checks.ts +130 -0
- package/src/validation-helpers.ts +246 -0
- package/src/xlr-helpers.ts +340 -0
- package/types/index.d.ts +4 -0
- package/types/type-checks.d.ts +58 -0
- package/types/validation-helpers.d.ts +41 -0
- package/types/xlr-helpers.d.ts +13 -0
|
@@ -0,0 +1,507 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// ../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/utils/src/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
applyExcludeToNodeType: () => applyExcludeToNodeType,
|
|
24
|
+
applyPartialOrRequiredToNodeType: () => applyPartialOrRequiredToNodeType,
|
|
25
|
+
applyPickOrOmitToNodeType: () => applyPickOrOmitToNodeType,
|
|
26
|
+
computeEffectiveObject: () => computeEffectiveObject,
|
|
27
|
+
computeExtends: () => computeExtends,
|
|
28
|
+
fillInGenerics: () => fillInGenerics,
|
|
29
|
+
isAndType: () => isAndType,
|
|
30
|
+
isArrayType: () => isArrayType,
|
|
31
|
+
isBooleanType: () => isBooleanType,
|
|
32
|
+
isGenericNamedType: () => isGenericNamedType,
|
|
33
|
+
isGenericNodeType: () => isGenericNodeType,
|
|
34
|
+
isNamedType: () => isNamedType,
|
|
35
|
+
isNode: () => isNode,
|
|
36
|
+
isNonNullable: () => isNonNullable,
|
|
37
|
+
isNumberType: () => isNumberType,
|
|
38
|
+
isObjectType: () => isObjectType,
|
|
39
|
+
isOrType: () => isOrType,
|
|
40
|
+
isPrimitiveTypeNode: () => isPrimitiveTypeNode,
|
|
41
|
+
isRecordType: () => isRecordType,
|
|
42
|
+
isRefType: () => isRefType,
|
|
43
|
+
isStringType: () => isStringType,
|
|
44
|
+
makePropertyMap: () => makePropertyMap,
|
|
45
|
+
propertyToTuple: () => propertyToTuple,
|
|
46
|
+
resolveConditional: () => resolveConditional,
|
|
47
|
+
resolveReferenceNode: () => resolveReferenceNode
|
|
48
|
+
});
|
|
49
|
+
module.exports = __toCommonJS(src_exports);
|
|
50
|
+
|
|
51
|
+
// ../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/utils/src/type-checks.ts
|
|
52
|
+
function isGenericNodeType(nt) {
|
|
53
|
+
return nt.genericTokens?.length > 0;
|
|
54
|
+
}
|
|
55
|
+
function isGenericNamedType(nt) {
|
|
56
|
+
return nt.genericTokens?.length > 0;
|
|
57
|
+
}
|
|
58
|
+
function isPrimitiveTypeNode(node) {
|
|
59
|
+
return node.type === "string" || node.type === "number" || node.type === "boolean" || node.type === "null" || node.type === "any" || node.type === "never" || node.type === "undefined" || node.type === "unknown" || node.type === "void";
|
|
60
|
+
}
|
|
61
|
+
function isNonNullable(a) {
|
|
62
|
+
return a !== null || a !== void 0;
|
|
63
|
+
}
|
|
64
|
+
function isStringType(node) {
|
|
65
|
+
return node.type === "string";
|
|
66
|
+
}
|
|
67
|
+
function isNumberType(node) {
|
|
68
|
+
return node.type === "number";
|
|
69
|
+
}
|
|
70
|
+
function isBooleanType(node) {
|
|
71
|
+
return node.type === "boolean";
|
|
72
|
+
}
|
|
73
|
+
function isObjectType(node) {
|
|
74
|
+
return node.type === "object";
|
|
75
|
+
}
|
|
76
|
+
function isArrayType(node) {
|
|
77
|
+
return node.type === "array";
|
|
78
|
+
}
|
|
79
|
+
function isRefType(node) {
|
|
80
|
+
return node.type === "ref";
|
|
81
|
+
}
|
|
82
|
+
function isOrType(node) {
|
|
83
|
+
return node.type === "or";
|
|
84
|
+
}
|
|
85
|
+
function isAndType(node) {
|
|
86
|
+
return node.type === "and";
|
|
87
|
+
}
|
|
88
|
+
function isRecordType(node) {
|
|
89
|
+
return node.type === "record";
|
|
90
|
+
}
|
|
91
|
+
function isNamedType(node) {
|
|
92
|
+
return "name" in node && "source" in node && typeof node.name === "string";
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// ../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/utils/src/validation-helpers.ts
|
|
96
|
+
function propertyToTuple(node) {
|
|
97
|
+
return {
|
|
98
|
+
key: node.children?.[0].value,
|
|
99
|
+
value: node.children?.[1]
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
function makePropertyMap(node) {
|
|
103
|
+
const m = /* @__PURE__ */ new Map();
|
|
104
|
+
node.children?.forEach((child) => {
|
|
105
|
+
const property = propertyToTuple(child);
|
|
106
|
+
m.set(property.key, property.value);
|
|
107
|
+
});
|
|
108
|
+
return m;
|
|
109
|
+
}
|
|
110
|
+
function isNode(obj) {
|
|
111
|
+
return typeof obj !== "string" || typeof obj !== "number" || typeof obj !== "boolean";
|
|
112
|
+
}
|
|
113
|
+
function computeExtends(a, b) {
|
|
114
|
+
if ((a.type === "any" || a.type === "unknown") && (b.type === "any" || b.type === "unknown")) {
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
117
|
+
if ((a.type === "null" || a.type === "undefined") && (b.type === "null" || b.type === "undefined")) {
|
|
118
|
+
return true;
|
|
119
|
+
}
|
|
120
|
+
if (a.type === b.type) {
|
|
121
|
+
if (isPrimitiveTypeNode(a) && isPrimitiveTypeNode(b)) {
|
|
122
|
+
if (a.const && b.const) {
|
|
123
|
+
if (a.const === b.const) {
|
|
124
|
+
return true;
|
|
125
|
+
}
|
|
126
|
+
} else {
|
|
127
|
+
return true;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
if (a.type === "ref" && b.type === "ref") {
|
|
131
|
+
return a.ref === b.ref;
|
|
132
|
+
}
|
|
133
|
+
if (a.type === "object" && b.type === "object") {
|
|
134
|
+
for (const property in b.properties) {
|
|
135
|
+
const propertyNode = b.properties[property];
|
|
136
|
+
if (!a.properties[property] || !computeExtends(a.properties[property].node, propertyNode.node)) {
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return true;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
if (isPrimitiveTypeNode(a) && b.type === "or") {
|
|
144
|
+
return b.or.every((member) => computeExtends(a, member));
|
|
145
|
+
}
|
|
146
|
+
if (isPrimitiveTypeNode(b) && a.type === "or") {
|
|
147
|
+
return a.or.every((member) => computeExtends(b, member));
|
|
148
|
+
}
|
|
149
|
+
if (a.type === "or" && b.type === "or") {
|
|
150
|
+
return a.or.every((x) => b.or.some((y) => computeExtends(x, y)));
|
|
151
|
+
}
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
function resolveConditional(conditional) {
|
|
155
|
+
const { left, right } = conditional.check;
|
|
156
|
+
const conditionalResult = computeExtends(left, right) ? conditional.value.true : conditional.value.false;
|
|
157
|
+
if (isGenericNodeType(conditional)) {
|
|
158
|
+
const genericMap = /* @__PURE__ */ new Map();
|
|
159
|
+
conditional.genericTokens.forEach((token) => {
|
|
160
|
+
genericMap.set(
|
|
161
|
+
token.symbol,
|
|
162
|
+
token.default ?? token.constraints ?? { type: "any" }
|
|
163
|
+
);
|
|
164
|
+
});
|
|
165
|
+
return fillInGenerics(conditionalResult, genericMap);
|
|
166
|
+
}
|
|
167
|
+
return conditionalResult;
|
|
168
|
+
}
|
|
169
|
+
function resolveReferenceNode(genericReference, typeToFill) {
|
|
170
|
+
const genericArgs = genericReference.genericArguments;
|
|
171
|
+
const genericMap = /* @__PURE__ */ new Map();
|
|
172
|
+
if (genericArgs && isGenericNodeType(typeToFill)) {
|
|
173
|
+
typeToFill.genericTokens.forEach((token, index) => {
|
|
174
|
+
genericMap.set(
|
|
175
|
+
token.symbol,
|
|
176
|
+
genericArgs[index] ?? token.default ?? token.constraints
|
|
177
|
+
);
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
const filledInNode = fillInGenerics(typeToFill, genericMap);
|
|
181
|
+
if (isGenericNodeType(filledInNode) && genericArgs?.length) {
|
|
182
|
+
if (genericArgs.length < filledInNode.genericTokens.length) {
|
|
183
|
+
filledInNode.genericTokens = filledInNode.genericTokens.slice(
|
|
184
|
+
genericArgs?.length
|
|
185
|
+
);
|
|
186
|
+
} else if (genericArgs.length === filledInNode.genericTokens.length) {
|
|
187
|
+
filledInNode.genericTokens = [];
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
if (genericReference.property && filledInNode.type === "object") {
|
|
191
|
+
return filledInNode.properties[genericReference.property]?.node ?? filledInNode.additionalProperties ?? { type: "undefined" };
|
|
192
|
+
}
|
|
193
|
+
return filledInNode;
|
|
194
|
+
}
|
|
195
|
+
function computeEffectiveObject(base, operand, errorOnOverlap = true) {
|
|
196
|
+
const baseObjectName = base.name ?? base.title ?? "object literal";
|
|
197
|
+
const operandObjectName = operand.name ?? operand.title ?? "object literal";
|
|
198
|
+
const newObject = {
|
|
199
|
+
...JSON.parse(JSON.stringify(base)),
|
|
200
|
+
name: `${baseObjectName} & ${operandObjectName}`,
|
|
201
|
+
description: `Effective type combining ${baseObjectName} and ${operandObjectName}`,
|
|
202
|
+
genericTokens: [
|
|
203
|
+
...isGenericNodeType(base) ? base.genericTokens : [],
|
|
204
|
+
...isGenericNodeType(operand) ? operand.genericTokens : []
|
|
205
|
+
]
|
|
206
|
+
};
|
|
207
|
+
for (const property in operand.properties) {
|
|
208
|
+
if (newObject.properties[property] !== void 0 && errorOnOverlap) {
|
|
209
|
+
if (!computeExtends(
|
|
210
|
+
newObject.properties[property].node,
|
|
211
|
+
operand.properties[property].node
|
|
212
|
+
)) {
|
|
213
|
+
throw new Error(
|
|
214
|
+
`Can't compute effective type for ${baseObjectName} and ${operandObjectName} because of conflicting properties ${property}`
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
newObject.properties[property] = operand.properties[property];
|
|
219
|
+
}
|
|
220
|
+
if (newObject.additionalProperties && operand.additionalProperties) {
|
|
221
|
+
if (!isPrimitiveTypeNode(newObject.additionalProperties) || !isPrimitiveTypeNode(operand.additionalProperties) || newObject.additionalProperties.type !== operand.additionalProperties.type) {
|
|
222
|
+
newObject.additionalProperties = {
|
|
223
|
+
type: "and",
|
|
224
|
+
and: [newObject.additionalProperties, operand.additionalProperties]
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
} else if (operand.additionalProperties) {
|
|
228
|
+
newObject.additionalProperties = operand.additionalProperties;
|
|
229
|
+
}
|
|
230
|
+
return newObject;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// ../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/utils/src/xlr-helpers.ts
|
|
234
|
+
function fillInGenerics(xlrNode, generics, preferLocalGenerics = false) {
|
|
235
|
+
let localGenerics;
|
|
236
|
+
if (generics) {
|
|
237
|
+
localGenerics = new Map(generics);
|
|
238
|
+
if (preferLocalGenerics && isGenericNodeType(xlrNode)) {
|
|
239
|
+
xlrNode.genericTokens?.forEach((token) => {
|
|
240
|
+
const genericValue = token.default ?? token.constraints;
|
|
241
|
+
localGenerics.set(
|
|
242
|
+
token.symbol,
|
|
243
|
+
fillInGenerics(genericValue, localGenerics, preferLocalGenerics)
|
|
244
|
+
);
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
} else {
|
|
248
|
+
localGenerics = /* @__PURE__ */ new Map();
|
|
249
|
+
if (isGenericNodeType(xlrNode)) {
|
|
250
|
+
xlrNode.genericTokens?.forEach((token) => {
|
|
251
|
+
const genericValue = token.default ?? token.constraints;
|
|
252
|
+
localGenerics.set(
|
|
253
|
+
token.symbol,
|
|
254
|
+
fillInGenerics(genericValue, localGenerics, preferLocalGenerics)
|
|
255
|
+
);
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
if (xlrNode.type === "ref") {
|
|
260
|
+
if (localGenerics.has(xlrNode.ref)) {
|
|
261
|
+
return {
|
|
262
|
+
...localGenerics.get(xlrNode.ref),
|
|
263
|
+
...xlrNode.genericArguments ? {
|
|
264
|
+
genericArguments: xlrNode.genericArguments.map(
|
|
265
|
+
(ga) => fillInGenerics(ga, localGenerics, preferLocalGenerics)
|
|
266
|
+
)
|
|
267
|
+
} : {},
|
|
268
|
+
...xlrNode.title ? { title: xlrNode.title } : {},
|
|
269
|
+
...xlrNode.name ? { name: xlrNode.name } : {},
|
|
270
|
+
...xlrNode.description ? { description: xlrNode.description } : {},
|
|
271
|
+
...xlrNode.comment ? { comment: xlrNode.comment } : {}
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
return {
|
|
275
|
+
...xlrNode,
|
|
276
|
+
...xlrNode.genericArguments ? {
|
|
277
|
+
genericArguments: xlrNode.genericArguments.map(
|
|
278
|
+
(ga) => fillInGenerics(ga, localGenerics, preferLocalGenerics)
|
|
279
|
+
)
|
|
280
|
+
} : {}
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
if (xlrNode.type === "object") {
|
|
284
|
+
const newProperties = {};
|
|
285
|
+
Object.getOwnPropertyNames(xlrNode.properties).forEach((propName) => {
|
|
286
|
+
const prop = xlrNode.properties[propName];
|
|
287
|
+
newProperties[propName] = {
|
|
288
|
+
required: prop.required,
|
|
289
|
+
node: fillInGenerics(prop.node, localGenerics, preferLocalGenerics)
|
|
290
|
+
};
|
|
291
|
+
});
|
|
292
|
+
return {
|
|
293
|
+
...xlrNode,
|
|
294
|
+
properties: newProperties,
|
|
295
|
+
...isGenericNamedType(xlrNode) ? {
|
|
296
|
+
genericTokens: xlrNode.genericTokens.map((token) => {
|
|
297
|
+
return {
|
|
298
|
+
...token,
|
|
299
|
+
constraints: token.constraints ? fillInGenerics(
|
|
300
|
+
token.constraints,
|
|
301
|
+
localGenerics,
|
|
302
|
+
preferLocalGenerics
|
|
303
|
+
) : void 0,
|
|
304
|
+
default: token.default ? fillInGenerics(
|
|
305
|
+
token.default,
|
|
306
|
+
localGenerics,
|
|
307
|
+
preferLocalGenerics
|
|
308
|
+
) : void 0
|
|
309
|
+
};
|
|
310
|
+
})
|
|
311
|
+
} : {},
|
|
312
|
+
extends: xlrNode.extends ? fillInGenerics(
|
|
313
|
+
xlrNode.extends,
|
|
314
|
+
localGenerics,
|
|
315
|
+
preferLocalGenerics
|
|
316
|
+
) : void 0,
|
|
317
|
+
additionalProperties: xlrNode.additionalProperties ? fillInGenerics(
|
|
318
|
+
xlrNode.additionalProperties,
|
|
319
|
+
localGenerics,
|
|
320
|
+
preferLocalGenerics
|
|
321
|
+
) : false
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
if (xlrNode.type === "array") {
|
|
325
|
+
return {
|
|
326
|
+
...xlrNode,
|
|
327
|
+
elementType: fillInGenerics(
|
|
328
|
+
xlrNode.elementType,
|
|
329
|
+
localGenerics,
|
|
330
|
+
preferLocalGenerics
|
|
331
|
+
)
|
|
332
|
+
};
|
|
333
|
+
} else if (xlrNode.type === "or" || xlrNode.type === "and") {
|
|
334
|
+
let pointer;
|
|
335
|
+
if (xlrNode.type === "or") {
|
|
336
|
+
pointer = xlrNode.or;
|
|
337
|
+
} else {
|
|
338
|
+
pointer = xlrNode.and;
|
|
339
|
+
}
|
|
340
|
+
return {
|
|
341
|
+
...xlrNode,
|
|
342
|
+
[xlrNode.type]: pointer.map((prop) => {
|
|
343
|
+
return fillInGenerics(prop, localGenerics, preferLocalGenerics);
|
|
344
|
+
})
|
|
345
|
+
};
|
|
346
|
+
} else if (xlrNode.type === "record") {
|
|
347
|
+
return {
|
|
348
|
+
...xlrNode,
|
|
349
|
+
keyType: fillInGenerics(
|
|
350
|
+
xlrNode.keyType,
|
|
351
|
+
localGenerics,
|
|
352
|
+
preferLocalGenerics
|
|
353
|
+
),
|
|
354
|
+
valueType: fillInGenerics(
|
|
355
|
+
xlrNode.valueType,
|
|
356
|
+
localGenerics,
|
|
357
|
+
preferLocalGenerics
|
|
358
|
+
)
|
|
359
|
+
};
|
|
360
|
+
} else if (xlrNode.type === "conditional") {
|
|
361
|
+
const filledInConditional = {
|
|
362
|
+
...xlrNode,
|
|
363
|
+
check: {
|
|
364
|
+
left: fillInGenerics(
|
|
365
|
+
xlrNode.check.left,
|
|
366
|
+
localGenerics,
|
|
367
|
+
preferLocalGenerics
|
|
368
|
+
),
|
|
369
|
+
right: fillInGenerics(
|
|
370
|
+
xlrNode.check.right,
|
|
371
|
+
localGenerics,
|
|
372
|
+
preferLocalGenerics
|
|
373
|
+
)
|
|
374
|
+
},
|
|
375
|
+
value: {
|
|
376
|
+
true: fillInGenerics(
|
|
377
|
+
xlrNode.value.true,
|
|
378
|
+
localGenerics,
|
|
379
|
+
preferLocalGenerics
|
|
380
|
+
),
|
|
381
|
+
false: fillInGenerics(
|
|
382
|
+
xlrNode.value.false,
|
|
383
|
+
localGenerics,
|
|
384
|
+
preferLocalGenerics
|
|
385
|
+
)
|
|
386
|
+
}
|
|
387
|
+
};
|
|
388
|
+
if (filledInConditional.check.left.type !== "ref" && filledInConditional.check.right.type !== "ref") {
|
|
389
|
+
return {
|
|
390
|
+
name: xlrNode.name,
|
|
391
|
+
title: xlrNode.title,
|
|
392
|
+
...resolveConditional(filledInConditional)
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
return filledInConditional;
|
|
396
|
+
}
|
|
397
|
+
return xlrNode;
|
|
398
|
+
}
|
|
399
|
+
function applyPickOrOmitToNodeType(baseObject, operation, properties) {
|
|
400
|
+
if (baseObject.type === "object") {
|
|
401
|
+
const newObject = { ...baseObject };
|
|
402
|
+
Object.keys(baseObject.properties).forEach((key) => {
|
|
403
|
+
if (operation === "Omit" && properties.has(key) || operation === "Pick" && !properties.has(key)) {
|
|
404
|
+
delete newObject.properties[key];
|
|
405
|
+
}
|
|
406
|
+
});
|
|
407
|
+
if (Object.keys(newObject.properties).length === 0 && (operation !== "Omit" || newObject.additionalProperties === false)) {
|
|
408
|
+
return void 0;
|
|
409
|
+
}
|
|
410
|
+
return newObject;
|
|
411
|
+
}
|
|
412
|
+
let pointer;
|
|
413
|
+
if (baseObject.type === "and") {
|
|
414
|
+
pointer = baseObject.and;
|
|
415
|
+
} else if (baseObject.type === "or") {
|
|
416
|
+
pointer = baseObject.or;
|
|
417
|
+
} else {
|
|
418
|
+
throw new Error(
|
|
419
|
+
`Error: Can not apply ${operation} to type ${baseObject.type}`
|
|
420
|
+
);
|
|
421
|
+
}
|
|
422
|
+
const pickedTypes = pointer.map((type) => {
|
|
423
|
+
const node = applyPickOrOmitToNodeType(type, operation, properties);
|
|
424
|
+
if (node === void 0) {
|
|
425
|
+
return void 0;
|
|
426
|
+
}
|
|
427
|
+
return { ...node, additionalProperties: false };
|
|
428
|
+
}).filter((type) => type !== void 0);
|
|
429
|
+
if (pickedTypes.length === 0) {
|
|
430
|
+
return void 0;
|
|
431
|
+
}
|
|
432
|
+
if (pickedTypes.length === 1) {
|
|
433
|
+
return pickedTypes[0];
|
|
434
|
+
}
|
|
435
|
+
if (baseObject.type === "and") {
|
|
436
|
+
return { ...baseObject, and: pickedTypes };
|
|
437
|
+
}
|
|
438
|
+
return { ...baseObject, or: pickedTypes };
|
|
439
|
+
}
|
|
440
|
+
function applyPartialOrRequiredToNodeType(baseObject, modifier) {
|
|
441
|
+
if (baseObject.type === "object") {
|
|
442
|
+
const newObject = { ...baseObject };
|
|
443
|
+
Object.keys(baseObject.properties).forEach((key) => {
|
|
444
|
+
newObject.properties[key].required = modifier;
|
|
445
|
+
});
|
|
446
|
+
return newObject;
|
|
447
|
+
}
|
|
448
|
+
if (baseObject.type === "and") {
|
|
449
|
+
const pickedTypes = baseObject.and.map(
|
|
450
|
+
(type) => applyPartialOrRequiredToNodeType(type, modifier)
|
|
451
|
+
);
|
|
452
|
+
return { ...baseObject, and: pickedTypes };
|
|
453
|
+
}
|
|
454
|
+
if (baseObject.type === "or") {
|
|
455
|
+
const pickedTypes = baseObject.or.map(
|
|
456
|
+
(type) => applyPartialOrRequiredToNodeType(type, modifier)
|
|
457
|
+
);
|
|
458
|
+
return { ...baseObject, or: pickedTypes };
|
|
459
|
+
}
|
|
460
|
+
throw new Error(
|
|
461
|
+
`Error: Can not apply ${modifier ? "Required" : "Partial"} to type ${baseObject.type}`
|
|
462
|
+
);
|
|
463
|
+
}
|
|
464
|
+
function applyExcludeToNodeType(baseObject, filters) {
|
|
465
|
+
const remainingMembers = baseObject.or.filter((type) => {
|
|
466
|
+
if (filters.type === "or") {
|
|
467
|
+
return !filters.or.some((filter) => computeExtends(type, filter));
|
|
468
|
+
}
|
|
469
|
+
return !computeExtends(type, filters);
|
|
470
|
+
});
|
|
471
|
+
if (remainingMembers.length === 1) {
|
|
472
|
+
return remainingMembers[0];
|
|
473
|
+
}
|
|
474
|
+
return {
|
|
475
|
+
...baseObject,
|
|
476
|
+
or: remainingMembers
|
|
477
|
+
};
|
|
478
|
+
}
|
|
479
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
480
|
+
0 && (module.exports = {
|
|
481
|
+
applyExcludeToNodeType,
|
|
482
|
+
applyPartialOrRequiredToNodeType,
|
|
483
|
+
applyPickOrOmitToNodeType,
|
|
484
|
+
computeEffectiveObject,
|
|
485
|
+
computeExtends,
|
|
486
|
+
fillInGenerics,
|
|
487
|
+
isAndType,
|
|
488
|
+
isArrayType,
|
|
489
|
+
isBooleanType,
|
|
490
|
+
isGenericNamedType,
|
|
491
|
+
isGenericNodeType,
|
|
492
|
+
isNamedType,
|
|
493
|
+
isNode,
|
|
494
|
+
isNonNullable,
|
|
495
|
+
isNumberType,
|
|
496
|
+
isObjectType,
|
|
497
|
+
isOrType,
|
|
498
|
+
isPrimitiveTypeNode,
|
|
499
|
+
isRecordType,
|
|
500
|
+
isRefType,
|
|
501
|
+
isStringType,
|
|
502
|
+
makePropertyMap,
|
|
503
|
+
propertyToTuple,
|
|
504
|
+
resolveConditional,
|
|
505
|
+
resolveReferenceNode
|
|
506
|
+
});
|
|
507
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/utils/src/index.ts","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/utils/src/type-checks.ts","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/utils/src/validation-helpers.ts","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/utils/src/xlr-helpers.ts"],"sourcesContent":["export * from \"./xlr-helpers\";\nexport * from \"./type-checks\";\nexport * from \"./validation-helpers\";\n","import type {\n NamedType,\n NamedTypeWithGenerics,\n NodeType,\n NodeTypeWithGenerics,\n PrimitiveTypes,\n StringType,\n NumberType,\n BooleanType,\n ObjectType,\n ArrayType,\n RefType,\n OrType,\n AndType,\n RecordType,\n} from \"@xlr-lib/xlr\";\n\n/**\n * Returns if the NodeType has generic tokens\n */\nexport function isGenericNodeType<T extends NodeType = NodeType>(\n nt: NodeType,\n): nt is NodeTypeWithGenerics<T> {\n return (nt as NodeTypeWithGenerics).genericTokens?.length > 0;\n}\n\n/**\n * Returns if the named type has generic tokens\n */\nexport function isGenericNamedType<T extends NamedType = NamedType>(\n nt: NodeType,\n): nt is NamedTypeWithGenerics<T> {\n return (nt as NamedTypeWithGenerics).genericTokens?.length > 0;\n}\n\n/**\n * Returns if the node is a `PrimitiveTypes`\n */\nexport function isPrimitiveTypeNode(node: NodeType): node is PrimitiveTypes {\n return (\n node.type === \"string\" ||\n node.type === \"number\" ||\n node.type === \"boolean\" ||\n node.type === \"null\" ||\n node.type === \"any\" ||\n node.type === \"never\" ||\n node.type === \"undefined\" ||\n node.type === \"unknown\" ||\n node.type === \"void\"\n );\n}\n\n/**\n * Type Guard for non-null values\n */\nexport function isNonNullable<T>(a: T | null | undefined): a is NonNullable<T> {\n return a !== null || a !== undefined;\n}\n\n/**\n * Type guard for string type nodes\n */\nexport function isStringType(node: NodeType): node is StringType {\n return node.type === \"string\";\n}\n\n/**\n * Type guard for number type nodes\n */\nexport function isNumberType(node: NodeType): node is NumberType {\n return node.type === \"number\";\n}\n\n/**\n * Type guard for boolean type nodes\n */\nexport function isBooleanType(node: NodeType): node is BooleanType {\n return node.type === \"boolean\";\n}\n\n/**\n * Type guard for object type nodes\n */\nexport function isObjectType(node: NodeType): node is ObjectType {\n return node.type === \"object\";\n}\n\n/**\n * Type guard for array type nodes\n */\nexport function isArrayType(node: NodeType): node is ArrayType {\n return node.type === \"array\";\n}\n\n/**\n * Type guard for ref type nodes\n */\nexport function isRefType(node: NodeType): node is RefType {\n return node.type === \"ref\";\n}\n\n/**\n * Type guard for or (union) type nodes\n */\nexport function isOrType(node: NodeType): node is OrType {\n return node.type === \"or\";\n}\n\n/**\n * Type guard for and (intersection) type nodes\n */\nexport function isAndType(node: NodeType): node is AndType {\n return node.type === \"and\";\n}\n\n/**\n * Type guard for record type nodes\n */\nexport function isRecordType(node: NodeType): node is RecordType {\n return node.type === \"record\";\n}\n\n/**\n * Type guard for named types (have name and source)\n */\nexport function isNamedType<T extends NodeType = NodeType>(\n node: NodeType,\n): node is NamedType<T> {\n return \"name\" in node && \"source\" in node && typeof node.name === \"string\";\n}\n","import type { Node } from \"jsonc-parser\";\nimport type {\n ConditionalType,\n NodeType,\n ObjectType,\n RefNode,\n} from \"@xlr-lib/xlr\";\nimport { isGenericNodeType, isPrimitiveTypeNode } from \"./type-checks\";\nimport { fillInGenerics } from \"./xlr-helpers\";\n\nexport interface PropertyNode {\n /** Equivalent Property Name */\n key: string;\n\n /** Equivalent Property Value */\n value: Node;\n}\n\n/**\n * Takes a property node and returns the underlying Key/Value Pairs\n */\nexport function propertyToTuple(node: Node): PropertyNode {\n return {\n key: node.children?.[0].value as string,\n value: node.children?.[1] as Node,\n };\n}\n\n/**\n * Turns a node's children into a map for easy access\n */\nexport function makePropertyMap(node: Node): Map<string, Node> {\n const m = new Map();\n node.children?.forEach((child) => {\n const property = propertyToTuple(child);\n m.set(property.key, property.value);\n });\n return m;\n}\n\n/**\n * Checks if property is a leaf node or another node\n */\nexport function isNode(obj: Node | string | number | boolean): obj is Node {\n return (\n typeof obj !== \"string\" ||\n typeof obj !== \"number\" ||\n typeof obj !== \"boolean\"\n );\n}\n\n/**\n * Computes if the first arg extends the second arg\n */\nexport function computeExtends(a: NodeType, b: NodeType): boolean {\n // special case for any/unknown being functionally the same\n if (\n (a.type === \"any\" || a.type === \"unknown\") &&\n (b.type === \"any\" || b.type === \"unknown\")\n ) {\n return true;\n }\n\n // special case for null/undefined being functionally the same\n if (\n (a.type === \"null\" || a.type === \"undefined\") &&\n (b.type === \"null\" || b.type === \"undefined\")\n ) {\n return true;\n }\n\n // check simple case of equal types\n if (a.type === b.type) {\n if (isPrimitiveTypeNode(a) && isPrimitiveTypeNode(b)) {\n if (a.const && b.const) {\n if (a.const === b.const) {\n return true;\n }\n } else {\n return true;\n }\n }\n\n if (a.type === \"ref\" && b.type === \"ref\") {\n return a.ref === b.ref;\n }\n\n if (a.type === \"object\" && b.type === \"object\") {\n for (const property in b.properties) {\n const propertyNode = b.properties[property];\n if (\n !a.properties[property] ||\n !computeExtends(a.properties[property].node, propertyNode.node)\n ) {\n return false;\n }\n }\n\n return true;\n }\n }\n\n if (isPrimitiveTypeNode(a) && b.type === \"or\") {\n return b.or.every((member) => computeExtends(a, member));\n }\n\n if (isPrimitiveTypeNode(b) && a.type === \"or\") {\n return a.or.every((member) => computeExtends(b, member));\n }\n\n if (a.type === \"or\" && b.type === \"or\") {\n return a.or.every((x) => b.or.some((y) => computeExtends(x, y)));\n }\n\n return false;\n}\n\n/**\n * Attempts to resolve a conditional type\n */\nexport function resolveConditional(conditional: ConditionalType): NodeType {\n const { left, right } = conditional.check;\n const conditionalResult = computeExtends(left, right)\n ? conditional.value.true\n : conditional.value.false;\n\n // Compose first level generics here since `conditionalResult` won't have them\n if (isGenericNodeType(conditional)) {\n const genericMap: Map<string, NodeType> = new Map();\n conditional.genericTokens.forEach((token) => {\n genericMap.set(\n token.symbol,\n token.default ?? token.constraints ?? { type: \"any\" },\n );\n });\n\n return fillInGenerics(conditionalResult, genericMap);\n }\n\n return conditionalResult;\n}\n\n/**\n * Resolve referenced node with potential generic arguments\n */\nexport function resolveReferenceNode(\n genericReference: RefNode,\n typeToFill: NodeType,\n): NodeType {\n const genericArgs = genericReference.genericArguments;\n const genericMap: Map<string, NodeType> = new Map();\n\n // Compose first level generics here from `genericReference`\n if (genericArgs && isGenericNodeType(typeToFill)) {\n typeToFill.genericTokens.forEach((token, index) => {\n genericMap.set(\n token.symbol,\n genericArgs[index] ?? token.default ?? token.constraints,\n );\n });\n }\n\n // Fill in generics\n const filledInNode = fillInGenerics(typeToFill, genericMap);\n\n // Remove generic tokens that were resolve\n if (isGenericNodeType(filledInNode) && genericArgs?.length) {\n if (genericArgs.length < filledInNode.genericTokens.length) {\n filledInNode.genericTokens = filledInNode.genericTokens.slice(\n genericArgs?.length,\n );\n } else if (genericArgs.length === filledInNode.genericTokens.length) {\n filledInNode.genericTokens = [];\n }\n }\n\n // Resolve index access\n if (genericReference.property && filledInNode.type === \"object\") {\n return (\n filledInNode.properties[genericReference.property]?.node ??\n filledInNode.additionalProperties ?? { type: \"undefined\" }\n );\n }\n\n return filledInNode;\n}\n\n/**\n * Combines two ObjectType objects to get a representation of the effective TypeScript interface of `base` extending `operand`\n - * @param base The base interface\n - * @param operand The interface that is extended\n - * @param errorOnOverlap whether or not conflicting properties should throw an error or use the property from operand\n - * @returns `ObjectType`\n */\nexport function computeEffectiveObject(\n base: ObjectType,\n operand: ObjectType,\n errorOnOverlap = true,\n): ObjectType {\n const baseObjectName = base.name ?? base.title ?? \"object literal\";\n const operandObjectName = operand.name ?? operand.title ?? \"object literal\";\n const newObject = {\n ...JSON.parse(JSON.stringify(base)),\n name: `${baseObjectName} & ${operandObjectName}`,\n description: `Effective type combining ${baseObjectName} and ${operandObjectName}`,\n genericTokens: [\n ...(isGenericNodeType(base) ? base.genericTokens : []),\n ...(isGenericNodeType(operand) ? operand.genericTokens : []),\n ],\n };\n // TODO this check needs to account for primitive -> primitive generic overlap\n\n for (const property in operand.properties) {\n if (newObject.properties[property] !== undefined && errorOnOverlap) {\n if (\n !computeExtends(\n newObject.properties[property].node,\n operand.properties[property].node,\n )\n ) {\n throw new Error(\n `Can't compute effective type for ${baseObjectName} and ${operandObjectName} because of conflicting properties ${property}`,\n );\n }\n }\n\n newObject.properties[property] = operand.properties[property];\n }\n\n if (newObject.additionalProperties && operand.additionalProperties) {\n if (\n !isPrimitiveTypeNode(newObject.additionalProperties) ||\n !isPrimitiveTypeNode(operand.additionalProperties) ||\n newObject.additionalProperties.type !== operand.additionalProperties.type\n ) {\n newObject.additionalProperties = {\n type: \"and\",\n and: [newObject.additionalProperties, operand.additionalProperties],\n };\n }\n } else if (operand.additionalProperties) {\n newObject.additionalProperties = operand.additionalProperties;\n }\n\n return newObject;\n}\n","import type {\n NamedType,\n NodeType,\n ObjectProperty,\n ObjectType,\n OrType,\n RefNode,\n} from \"@xlr-lib/xlr\";\nimport { computeExtends, resolveConditional } from \"./validation-helpers\";\nimport { isGenericNamedType, isGenericNodeType } from \"./type-checks\";\n\n/**\n * Walks generics to fill in values from a combination of the default, constraint, and passed in map values\n * TODO convert this to use simpleTransformGenerator\n */\nexport function fillInGenerics(\n xlrNode: NodeType,\n generics?: Map<string, NodeType>,\n preferLocalGenerics = false,\n): NodeType {\n // Need to make sure not to set generics in passed in map to avoid using generics outside of tree\n let localGenerics: Map<string, NodeType>;\n\n if (generics) {\n localGenerics = new Map(generics);\n if (preferLocalGenerics && isGenericNodeType(xlrNode)) {\n xlrNode.genericTokens?.forEach((token) => {\n const genericValue = (token.default ?? token.constraints) as NodeType;\n localGenerics.set(\n token.symbol,\n fillInGenerics(genericValue, localGenerics, preferLocalGenerics),\n );\n });\n }\n } else {\n localGenerics = new Map();\n if (isGenericNodeType(xlrNode)) {\n xlrNode.genericTokens?.forEach((token) => {\n const genericValue = (token.default ?? token.constraints) as NodeType;\n localGenerics.set(\n token.symbol,\n fillInGenerics(genericValue, localGenerics, preferLocalGenerics),\n );\n });\n }\n }\n\n if (xlrNode.type === \"ref\") {\n if (localGenerics.has(xlrNode.ref)) {\n return {\n ...(localGenerics.get(xlrNode.ref) as NodeType),\n ...(xlrNode.genericArguments\n ? {\n genericArguments: xlrNode.genericArguments.map((ga) =>\n fillInGenerics(ga, localGenerics, preferLocalGenerics),\n ),\n }\n : {}),\n ...(xlrNode.title ? { title: xlrNode.title } : {}),\n ...(xlrNode.name ? { name: xlrNode.name } : {}),\n ...(xlrNode.description ? { description: xlrNode.description } : {}),\n ...(xlrNode.comment ? { comment: xlrNode.comment } : {}),\n };\n }\n\n return {\n ...xlrNode,\n ...(xlrNode.genericArguments\n ? {\n genericArguments: xlrNode.genericArguments.map((ga) =>\n fillInGenerics(ga, localGenerics, preferLocalGenerics),\n ),\n }\n : {}),\n };\n }\n\n if (xlrNode.type === \"object\") {\n const newProperties: { [name: string]: ObjectProperty } = {};\n Object.getOwnPropertyNames(xlrNode.properties).forEach((propName) => {\n const prop = xlrNode.properties[propName];\n newProperties[propName] = {\n required: prop.required,\n node: fillInGenerics(prop.node, localGenerics, preferLocalGenerics),\n };\n });\n\n return {\n ...xlrNode,\n properties: newProperties,\n ...(isGenericNamedType(xlrNode)\n ? {\n genericTokens: xlrNode.genericTokens.map((token) => {\n return {\n ...token,\n constraints: token.constraints\n ? fillInGenerics(\n token.constraints,\n localGenerics,\n preferLocalGenerics,\n )\n : undefined,\n default: token.default\n ? fillInGenerics(\n token.default,\n localGenerics,\n preferLocalGenerics,\n )\n : undefined,\n };\n }),\n }\n : {}),\n extends: xlrNode.extends\n ? (fillInGenerics(\n xlrNode.extends,\n localGenerics,\n preferLocalGenerics,\n ) as RefNode)\n : undefined,\n additionalProperties: xlrNode.additionalProperties\n ? fillInGenerics(\n xlrNode.additionalProperties,\n localGenerics,\n preferLocalGenerics,\n )\n : false,\n };\n }\n\n if (xlrNode.type === \"array\") {\n return {\n ...xlrNode,\n elementType: fillInGenerics(\n xlrNode.elementType,\n localGenerics,\n preferLocalGenerics,\n ),\n };\n } else if (xlrNode.type === \"or\" || xlrNode.type === \"and\") {\n let pointer;\n if (xlrNode.type === \"or\") {\n pointer = xlrNode.or;\n } else {\n pointer = xlrNode.and;\n }\n\n return {\n ...xlrNode,\n [xlrNode.type]: pointer.map((prop) => {\n return fillInGenerics(prop, localGenerics, preferLocalGenerics);\n }),\n };\n } else if (xlrNode.type === \"record\") {\n return {\n ...xlrNode,\n keyType: fillInGenerics(\n xlrNode.keyType,\n localGenerics,\n preferLocalGenerics,\n ),\n valueType: fillInGenerics(\n xlrNode.valueType,\n localGenerics,\n preferLocalGenerics,\n ),\n };\n } else if (xlrNode.type === \"conditional\") {\n const filledInConditional = {\n ...xlrNode,\n check: {\n left: fillInGenerics(\n xlrNode.check.left,\n localGenerics,\n preferLocalGenerics,\n ),\n right: fillInGenerics(\n xlrNode.check.right,\n localGenerics,\n preferLocalGenerics,\n ),\n },\n value: {\n true: fillInGenerics(\n xlrNode.value.true,\n localGenerics,\n preferLocalGenerics,\n ),\n false: fillInGenerics(\n xlrNode.value.false,\n localGenerics,\n preferLocalGenerics,\n ),\n },\n };\n\n // Check to see if we have enough information to resolve this conditional\n if (\n filledInConditional.check.left.type !== \"ref\" &&\n filledInConditional.check.right.type !== \"ref\"\n ) {\n return {\n name: xlrNode.name,\n title: xlrNode.title,\n ...resolveConditional(filledInConditional),\n } as NamedType;\n }\n\n return filledInConditional;\n }\n\n return xlrNode;\n}\n\n/** Applies the TS `Pick` or `Omit` type to an interface/union/intersection */\nexport function applyPickOrOmitToNodeType(\n baseObject: NodeType,\n operation: \"Pick\" | \"Omit\",\n properties: Set<string>,\n): NodeType | undefined {\n if (baseObject.type === \"object\") {\n const newObject = { ...baseObject };\n Object.keys(baseObject.properties).forEach((key) => {\n if (\n (operation === \"Omit\" && properties.has(key)) ||\n (operation === \"Pick\" && !properties.has(key))\n ) {\n delete newObject.properties[key];\n }\n });\n\n /**\n * Filter out objects in cases:\n * - A Pick operation and there are no properties left\n * - An Omit operation and there are no properties left and no additional properties allowed\n */\n if (\n Object.keys(newObject.properties).length === 0 &&\n (operation !== \"Omit\" || newObject.additionalProperties === false)\n ) {\n return undefined;\n }\n\n return newObject;\n }\n\n let pointer;\n if (baseObject.type === \"and\") {\n pointer = baseObject.and;\n } else if (baseObject.type === \"or\") {\n pointer = baseObject.or;\n } else {\n throw new Error(\n `Error: Can not apply ${operation} to type ${baseObject.type}`,\n );\n }\n\n const pickedTypes = pointer\n .map((type) => {\n const node = applyPickOrOmitToNodeType(type, operation, properties);\n if (node === undefined) {\n return undefined;\n }\n\n return { ...node, additionalProperties: false } as ObjectType;\n })\n .filter((type) => type !== undefined) as NodeType[];\n\n if (pickedTypes.length === 0) {\n return undefined;\n }\n\n if (pickedTypes.length === 1) {\n return pickedTypes[0];\n }\n\n if (baseObject.type === \"and\") {\n return { ...baseObject, and: pickedTypes };\n }\n\n return { ...baseObject, or: pickedTypes };\n}\n\n/** Applies the TS `Partial` or `Required` type to an interface/union/intersection */\nexport function applyPartialOrRequiredToNodeType(\n baseObject: NodeType,\n modifier: boolean,\n): NodeType {\n if (baseObject.type === \"object\") {\n const newObject = { ...baseObject };\n Object.keys(baseObject.properties).forEach((key) => {\n newObject.properties[key].required = modifier;\n });\n\n return newObject;\n }\n\n if (baseObject.type === \"and\") {\n const pickedTypes = baseObject.and.map((type) =>\n applyPartialOrRequiredToNodeType(type, modifier),\n );\n return { ...baseObject, and: pickedTypes };\n }\n\n if (baseObject.type === \"or\") {\n const pickedTypes = baseObject.or.map((type) =>\n applyPartialOrRequiredToNodeType(type, modifier),\n );\n return { ...baseObject, or: pickedTypes };\n }\n\n throw new Error(\n `Error: Can not apply ${modifier ? \"Required\" : \"Partial\"} to type ${\n baseObject.type\n }`,\n );\n}\n\n/** Applies the TS `Exclude` type to a union */\nexport function applyExcludeToNodeType(\n baseObject: OrType,\n filters: NodeType | OrType,\n): NodeType {\n const remainingMembers = baseObject.or.filter((type) => {\n if (filters.type === \"or\") {\n return !filters.or.some((filter) => computeExtends(type, filter));\n }\n\n return !computeExtends(type, filters);\n });\n\n if (remainingMembers.length === 1) {\n return remainingMembers[0];\n }\n\n return {\n ...baseObject,\n or: remainingMembers,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACoBO,SAAS,kBACd,IAC+B;AAC/B,SAAQ,GAA4B,eA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