@player-tools/xlr-sdk 0.9.1-next.2 → 0.10.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +116 -18
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/index.legacy-esm.js +115 -18
- package/dist/index.mjs +115 -18
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/src/__tests__/__snapshots__/sdk.test.ts.snap +12 -0
- package/src/__tests__/sdk.test.ts +150 -1
- package/src/types.ts +38 -5
- package/src/validator.ts +168 -18
- package/types/sdk.d.ts +2 -2
- package/types/types.d.ts +25 -5
- package/types/validator.d.ts +9 -3
package/dist/cjs/index.cjs
CHANGED
|
@@ -31,6 +31,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
var src_exports = {};
|
|
32
32
|
__export(src_exports, {
|
|
33
33
|
BasicXLRRegistry: () => BasicXLRRegistry,
|
|
34
|
+
ValidationSeverity: () => ValidationSeverity,
|
|
34
35
|
XLRSDK: () => XLRSDK,
|
|
35
36
|
simpleTransformGenerator: () => simpleTransformGenerator,
|
|
36
37
|
xlrTransformWalker: () => xlrTransformWalker
|
|
@@ -102,10 +103,24 @@ var BasicXLRRegistry = class {
|
|
|
102
103
|
|
|
103
104
|
// ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/xlr/sdk/src/validator.ts
|
|
104
105
|
var import_xlr_utils = require("@player-tools/xlr-utils");
|
|
106
|
+
|
|
107
|
+
// ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/xlr/sdk/src/types.ts
|
|
108
|
+
var ValidationSeverity = /* @__PURE__ */ ((ValidationSeverity2) => {
|
|
109
|
+
ValidationSeverity2[ValidationSeverity2["Error"] = 1] = "Error";
|
|
110
|
+
ValidationSeverity2[ValidationSeverity2["Warning"] = 2] = "Warning";
|
|
111
|
+
ValidationSeverity2[ValidationSeverity2["Info"] = 3] = "Info";
|
|
112
|
+
ValidationSeverity2[ValidationSeverity2["Trace"] = 4] = "Trace";
|
|
113
|
+
return ValidationSeverity2;
|
|
114
|
+
})(ValidationSeverity || {});
|
|
115
|
+
|
|
116
|
+
// ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/xlr/sdk/src/validator.ts
|
|
117
|
+
var MAX_VALID_SHOWN = 20;
|
|
105
118
|
var XLRValidator = class {
|
|
119
|
+
config;
|
|
106
120
|
resolveType;
|
|
107
121
|
regexCache;
|
|
108
|
-
constructor(resolveType) {
|
|
122
|
+
constructor(resolveType, config) {
|
|
123
|
+
this.config = config || {};
|
|
109
124
|
this.resolveType = resolveType;
|
|
110
125
|
this.regexCache = /* @__PURE__ */ new Map();
|
|
111
126
|
}
|
|
@@ -119,7 +134,8 @@ var XLRValidator = class {
|
|
|
119
134
|
validationIssues.push({
|
|
120
135
|
type: "type",
|
|
121
136
|
node: rootNode,
|
|
122
|
-
message: `Expected an object but got an "${rootNode.type}"
|
|
137
|
+
message: `Expected an object but got an "${rootNode.type}"`,
|
|
138
|
+
severity: 1 /* Error */
|
|
123
139
|
});
|
|
124
140
|
}
|
|
125
141
|
} else if (xlrNode.type === "array") {
|
|
@@ -129,7 +145,8 @@ var XLRValidator = class {
|
|
|
129
145
|
validationIssues.push({
|
|
130
146
|
type: "type",
|
|
131
147
|
node: rootNode,
|
|
132
|
-
message: `Expected an array but got an "${rootNode.type}"
|
|
148
|
+
message: `Expected an array but got an "${rootNode.type}"`,
|
|
149
|
+
severity: 1 /* Error */
|
|
133
150
|
});
|
|
134
151
|
}
|
|
135
152
|
} else if (xlrNode.type === "template") {
|
|
@@ -138,25 +155,45 @@ var XLRValidator = class {
|
|
|
138
155
|
validationIssues.push(error);
|
|
139
156
|
}
|
|
140
157
|
} else if (xlrNode.type === "or") {
|
|
158
|
+
const potentialTypeErrors = [];
|
|
141
159
|
for (const potentialType of xlrNode.or) {
|
|
142
160
|
const potentialErrors = this.validateType(rootNode, potentialType);
|
|
143
161
|
if (potentialErrors.length === 0) {
|
|
144
162
|
return validationIssues;
|
|
145
163
|
}
|
|
164
|
+
potentialTypeErrors.push({
|
|
165
|
+
type: potentialType,
|
|
166
|
+
errors: potentialErrors
|
|
167
|
+
});
|
|
146
168
|
}
|
|
147
169
|
let message;
|
|
170
|
+
const expectedTypes = xlrNode.or.map((node) => node.name ?? node.title ?? node.type ?? "<unnamed type>").join(" | ");
|
|
148
171
|
if (xlrNode.name) {
|
|
149
172
|
message = `Does not match any of the expected types for type: '${xlrNode.name}'`;
|
|
150
173
|
} else if (xlrNode.title) {
|
|
151
174
|
message = `Does not match any of the expected types for property: '${xlrNode.title}'`;
|
|
152
175
|
} else {
|
|
153
|
-
message = `Does not match any of the types ${
|
|
176
|
+
message = `Does not match any of the types: ${expectedTypes}`;
|
|
154
177
|
}
|
|
178
|
+
const { infoMessage } = this.generateNestedTypesInfo(
|
|
179
|
+
potentialTypeErrors,
|
|
180
|
+
xlrNode,
|
|
181
|
+
rootNode
|
|
182
|
+
);
|
|
155
183
|
validationIssues.push({
|
|
156
184
|
type: "value",
|
|
157
185
|
node: rootNode,
|
|
158
|
-
message
|
|
186
|
+
message: message.trim(),
|
|
187
|
+
severity: 1 /* Error */
|
|
159
188
|
});
|
|
189
|
+
if (infoMessage) {
|
|
190
|
+
validationIssues.push({
|
|
191
|
+
type: "value",
|
|
192
|
+
node: rootNode,
|
|
193
|
+
message: infoMessage,
|
|
194
|
+
severity: 3 /* Info */
|
|
195
|
+
});
|
|
196
|
+
}
|
|
160
197
|
} else if (xlrNode.type === "and") {
|
|
161
198
|
const effectiveType = {
|
|
162
199
|
...this.computeIntersectionType(xlrNode.and),
|
|
@@ -178,7 +215,8 @@ var XLRValidator = class {
|
|
|
178
215
|
validationIssues.push({
|
|
179
216
|
type: "unknown",
|
|
180
217
|
node: rootNode,
|
|
181
|
-
message: `Type "${xlrNode.ref}" is not defined in provided bundles
|
|
218
|
+
message: `Type "${xlrNode.ref}" is not defined in provided bundles`,
|
|
219
|
+
severity: 1 /* Error */
|
|
182
220
|
});
|
|
183
221
|
} else {
|
|
184
222
|
validationIssues.push(
|
|
@@ -191,13 +229,17 @@ var XLRValidator = class {
|
|
|
191
229
|
validationIssues.push({
|
|
192
230
|
type: "type",
|
|
193
231
|
node: rootNode.parent,
|
|
194
|
-
message: `Expected "${xlrNode.const}" but got "${rootNode.value}"
|
|
232
|
+
message: `Expected "${xlrNode.const}" but got "${rootNode.value}"`,
|
|
233
|
+
expected: xlrNode.const,
|
|
234
|
+
severity: 1 /* Error */
|
|
195
235
|
});
|
|
196
236
|
} else {
|
|
197
237
|
validationIssues.push({
|
|
198
238
|
type: "type",
|
|
199
239
|
node: rootNode.parent,
|
|
200
|
-
message: `Expected type "${xlrNode.type}" but got "${rootNode.type}"
|
|
240
|
+
message: `Expected type "${xlrNode.type}" but got "${rootNode.type}"`,
|
|
241
|
+
expected: xlrNode.type,
|
|
242
|
+
severity: 1 /* Error */
|
|
201
243
|
});
|
|
202
244
|
}
|
|
203
245
|
}
|
|
@@ -230,12 +272,45 @@ var XLRValidator = class {
|
|
|
230
272
|
}
|
|
231
273
|
return validationIssues;
|
|
232
274
|
}
|
|
275
|
+
generateNestedTypesInfo(potentialTypeErrors, xlrNode, rootNode) {
|
|
276
|
+
const nestedTypes = /* @__PURE__ */ new Set();
|
|
277
|
+
potentialTypeErrors.forEach((typeError) => {
|
|
278
|
+
if (typeError.type.type !== "template") {
|
|
279
|
+
typeError.errors.forEach((error) => {
|
|
280
|
+
if (error.type === "type" && error.expected) {
|
|
281
|
+
String(error.expected).split(" | ").forEach((val) => nestedTypes.add(val.trim()));
|
|
282
|
+
}
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
if (nestedTypes.size === 0) {
|
|
287
|
+
xlrNode.or.forEach((type) => {
|
|
288
|
+
const typeName = type.name ?? type.title ?? type.type ?? "<unnamed type>";
|
|
289
|
+
nestedTypes.add(typeName);
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
const nestedTypesArray = [...nestedTypes];
|
|
293
|
+
let nestedTypesList = nestedTypesArray.slice(0, MAX_VALID_SHOWN).join(" | ") + (nestedTypesArray.length > MAX_VALID_SHOWN ? ` | +${nestedTypesArray.length - MAX_VALID_SHOWN} ... ${nestedTypesArray.pop()}` : "");
|
|
294
|
+
const docsURL = this.config.urlMapping;
|
|
295
|
+
if (docsURL && xlrNode.name && docsURL[xlrNode.name]) {
|
|
296
|
+
nestedTypesList = docsURL[xlrNode.name];
|
|
297
|
+
}
|
|
298
|
+
let infoMessage;
|
|
299
|
+
if (rootNode.value !== void 0) {
|
|
300
|
+
infoMessage = `Got: ${rootNode.value} and expected: ${nestedTypesList}`;
|
|
301
|
+
} else if (nestedTypesList) {
|
|
302
|
+
infoMessage = `Expected: ${nestedTypesList}`;
|
|
303
|
+
}
|
|
304
|
+
return { nestedTypesList, infoMessage };
|
|
305
|
+
}
|
|
233
306
|
validateTemplate(node, xlrNode) {
|
|
234
307
|
if (node.type !== "string") {
|
|
235
308
|
return {
|
|
236
309
|
type: "type",
|
|
237
310
|
node: node.parent,
|
|
238
|
-
message: `Expected type "${xlrNode.type}" but got "${typeof node}"
|
|
311
|
+
message: `Expected type "${xlrNode.type}" but got "${typeof node}"`,
|
|
312
|
+
expected: xlrNode.type,
|
|
313
|
+
severity: 1 /* Error */
|
|
239
314
|
};
|
|
240
315
|
}
|
|
241
316
|
const regex = this.getRegex(xlrNode.format);
|
|
@@ -244,7 +319,9 @@ var XLRValidator = class {
|
|
|
244
319
|
return {
|
|
245
320
|
type: "value",
|
|
246
321
|
node: node.parent,
|
|
247
|
-
message: `Does not match expected format: ${xlrNode.format}
|
|
322
|
+
message: `Does not match expected format: ${xlrNode.format}`,
|
|
323
|
+
expected: xlrNode.format,
|
|
324
|
+
severity: 1 /* Error */
|
|
248
325
|
};
|
|
249
326
|
}
|
|
250
327
|
}
|
|
@@ -265,7 +342,8 @@ var XLRValidator = class {
|
|
|
265
342
|
issues.push({
|
|
266
343
|
type: "missing",
|
|
267
344
|
node,
|
|
268
|
-
message: `Property "${prop}" missing from type "${xlrNode.name}"
|
|
345
|
+
message: `Property "${prop}" missing from type "${xlrNode.name}"`,
|
|
346
|
+
severity: 1 /* Error */
|
|
269
347
|
});
|
|
270
348
|
}
|
|
271
349
|
if (valueNode) {
|
|
@@ -283,7 +361,8 @@ var XLRValidator = class {
|
|
|
283
361
|
node,
|
|
284
362
|
message: `Unexpected properties on "${xlrNode.name}": ${extraKeys.join(
|
|
285
363
|
", "
|
|
286
|
-
)}
|
|
364
|
+
)}`,
|
|
365
|
+
severity: 1 /* Error */
|
|
287
366
|
});
|
|
288
367
|
} else {
|
|
289
368
|
issues.push(
|
|
@@ -350,6 +429,7 @@ var XLRValidator = class {
|
|
|
350
429
|
computeIntersectionType(types) {
|
|
351
430
|
let firstElement = types[0];
|
|
352
431
|
let effectiveType;
|
|
432
|
+
const topLevelTypeName = types[0].name;
|
|
353
433
|
if (firstElement.type === "ref") {
|
|
354
434
|
firstElement = this.getRefType(firstElement);
|
|
355
435
|
}
|
|
@@ -389,18 +469,32 @@ var XLRValidator = class {
|
|
|
389
469
|
} else {
|
|
390
470
|
effectiveType = {
|
|
391
471
|
...effectiveType,
|
|
392
|
-
or: effectiveType.or.map(
|
|
393
|
-
|
|
394
|
-
|
|
472
|
+
or: effectiveType.or.map((y) => {
|
|
473
|
+
const intersectedType = this.computeIntersectionType([
|
|
474
|
+
y,
|
|
475
|
+
typeToApply
|
|
476
|
+
]);
|
|
477
|
+
if (!intersectedType.name && topLevelTypeName) {
|
|
478
|
+
intersectedType.name = topLevelTypeName;
|
|
479
|
+
}
|
|
480
|
+
return intersectedType;
|
|
481
|
+
})
|
|
395
482
|
};
|
|
396
483
|
}
|
|
397
484
|
} else if (typeToApply.type === "or") {
|
|
398
485
|
if (effectiveType.type === "object") {
|
|
399
486
|
effectiveType = {
|
|
400
487
|
...typeToApply,
|
|
401
|
-
or: typeToApply.or.map(
|
|
402
|
-
|
|
403
|
-
|
|
488
|
+
or: typeToApply.or.map((y) => {
|
|
489
|
+
const intersectedType = this.computeIntersectionType([
|
|
490
|
+
y,
|
|
491
|
+
effectiveType
|
|
492
|
+
]);
|
|
493
|
+
if (!intersectedType.name && topLevelTypeName) {
|
|
494
|
+
intersectedType.name = topLevelTypeName;
|
|
495
|
+
}
|
|
496
|
+
return intersectedType;
|
|
497
|
+
})
|
|
404
498
|
};
|
|
405
499
|
} else {
|
|
406
500
|
throw new Error("unimplemented operation or x or projection");
|
|
@@ -411,6 +505,9 @@ var XLRValidator = class {
|
|
|
411
505
|
);
|
|
412
506
|
}
|
|
413
507
|
});
|
|
508
|
+
if (effectiveType.type === "or" && !effectiveType.name && topLevelTypeName) {
|
|
509
|
+
effectiveType.name = topLevelTypeName;
|
|
510
|
+
}
|
|
414
511
|
return effectiveType;
|
|
415
512
|
}
|
|
416
513
|
};
|
|
@@ -885,6 +982,7 @@ ${nodeText}`;
|
|
|
885
982
|
// Annotate the CommonJS export names for ESM import in node:
|
|
886
983
|
0 && (module.exports = {
|
|
887
984
|
BasicXLRRegistry,
|
|
985
|
+
ValidationSeverity,
|
|
888
986
|
XLRSDK,
|
|
889
987
|
simpleTransformGenerator,
|
|
890
988
|
xlrTransformWalker
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/xlr/sdk/src/index.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/xlr/sdk/src/sdk.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/xlr/sdk/src/registry/basic-registry.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/xlr/sdk/src/validator.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/xlr/sdk/src/utils.ts"],"sourcesContent":["export * from \"./sdk\";\nexport * from \"./types\";\nexport * from \"./registry\";\nexport * from \"./utils\";\n","/* eslint-disable prettier/prettier */\nimport type {\n Manifest,\n NamedType,\n NodeType,\n ObjectNode,\n ObjectType,\n TransformFunction,\n TSManifest,\n} from \"@player-tools/xlr\";\nimport type { TopLevelDeclaration } from \"@player-tools/xlr-utils\";\nimport {\n computeEffectiveObject,\n resolveConditional,\n resolveReferenceNode,\n} from \"@player-tools/xlr-utils\";\nimport { fillInGenerics } from \"@player-tools/xlr-utils\";\nimport type { Node } from \"jsonc-parser\";\nimport { TSWriter } from \"@player-tools/xlr-converters\";\nimport fs from \"fs\";\nimport path from \"path\";\nimport ts from \"typescript\";\n\nimport type { XLRRegistry, Filters } from \"./registry\";\nimport { BasicXLRRegistry } from \"./registry\";\nimport type { ExportTypes } from \"./types\";\nimport { XLRValidator } from \"./validator\";\nimport { TransformFunctionMap, xlrTransformWalker } from \"./utils\";\n\nexport interface GetTypeOptions {\n /** Resolves `extends` fields in objects */\n getRawType?: boolean;\n /** Perform optimizations to resolve all references, type intersections, and conditionals */\n optimize?: boolean;\n}\n\n/**\n * Abstraction for interfacing with XLRs making it more approachable to use without understanding the inner workings of the types and how they are packaged\n */\nexport class XLRSDK {\n private registry: XLRRegistry;\n private validator: XLRValidator;\n private tsWriter: TSWriter;\n private computedNodeCache: Map<string, NodeType>;\n private externalTransformFunctions: Map<string, TransformFunction>;\n\n constructor(customRegistry?: XLRRegistry) {\n this.registry = customRegistry ?? new BasicXLRRegistry();\n this.validator = new XLRValidator(this.getType.bind(this));\n this.tsWriter = new TSWriter();\n this.computedNodeCache = new Map();\n this.externalTransformFunctions = new Map();\n }\n\n /**\n * Loads definitions from a path on the filesystem\n *\n * @param inputPath - path to the directory to load (above the xlr folder)\n * @param filters - Any filters to apply when loading the types (a positive match will omit)\n * @param transforms - any transforms to apply to the types being loaded\n */\n public loadDefinitionsFromDisk(\n inputPath: string,\n filters?: Omit<Filters, \"pluginFilter\">,\n transforms?: Array<TransformFunction>\n ) {\n this.computedNodeCache.clear();\n\n const transformsToRun = [\n ...this.externalTransformFunctions.values(),\n ...(transforms ?? []),\n ];\n\n const manifest = JSON.parse(\n fs.readFileSync(path.join(inputPath, \"xlr\", \"manifest.json\")).toString(),\n (key: unknown, value: unknown) => {\n // Custom parser because JSON objects -> JS Objects, not maps\n if (typeof value === \"object\" && value !== null) {\n if (key === \"capabilities\") {\n return new Map(Object.entries(value));\n }\n }\n\n return value;\n }\n ) as Manifest;\n\n manifest.capabilities?.forEach((capabilityList, capabilityName) => {\n if (\n filters?.capabilityFilter &&\n capabilityName.match(filters?.capabilityFilter)\n )\n return;\n capabilityList.forEach((extensionName) => {\n if (!filters?.typeFilter || !extensionName.match(filters?.typeFilter)) {\n const cType: NamedType<NodeType> = JSON.parse(\n fs\n .readFileSync(\n path.join(inputPath, \"xlr\", `${extensionName}.json`)\n )\n .toString()\n );\n const effectiveType =\n transformsToRun?.reduce(\n (typeAccumulator: NamedType<NodeType>, transformFn) =>\n transformFn(\n typeAccumulator,\n capabilityName\n ) as NamedType<NodeType>,\n cType\n ) ?? cType;\n\n this.registry.add(effectiveType, manifest.pluginName, capabilityName);\n }\n });\n });\n }\n\n /**\n * Load definitions from a js/ts file in memory\n *\n * @param manifest - The imported XLR manifest module\n * @param filters - Any filters to apply when loading the types (a positive match will omit)\n * @param transforms - any transforms to apply to the types being loaded\n */\n public async loadDefinitionsFromModule(\n manifest: TSManifest,\n filters?: Omit<Filters, \"pluginFilter\">,\n transforms?: Array<TransformFunction>\n ) {\n this.computedNodeCache.clear();\n\n const transformsToRun = [\n ...this.externalTransformFunctions.values(),\n ...(transforms ?? []),\n ];\n\n Object.keys(manifest.capabilities)?.forEach((capabilityName) => {\n if (\n filters?.capabilityFilter &&\n capabilityName.match(filters?.capabilityFilter)\n )\n return;\n const capabilityList = manifest.capabilities[capabilityName];\n capabilityList.forEach((extension) => {\n if (\n !filters?.typeFilter ||\n !extension.name.match(filters?.typeFilter)\n ) {\n const effectiveType =\n transformsToRun?.reduce(\n (typeAccumulator: NamedType<NodeType>, transformFn) =>\n transformFn(\n typeAccumulator,\n capabilityName\n ) as NamedType<NodeType>,\n extension\n ) ?? extension;\n\n this.registry.add(effectiveType, manifest.pluginName, capabilityName);\n }\n });\n });\n }\n\n /**\n * Statically load transform function that should be applied to every XLR bundle that is imported\n */\n public addTransformFunction(name: string, fn: TransformFunction): void {\n this.externalTransformFunctions.set(name, fn);\n }\n\n /**\n * Remove any transform function loaded via the `addTransformFunction` method by name\n */\n public removeTransformFunction(name: string): void {\n this.externalTransformFunctions.delete(name);\n }\n\n /**\n * Returns a Type that has been previously loaded\n *\n * @param id - Type to retrieve\n * @param options - `GetTypeOptions`\n * @returns `NamedType<NodeType>` | `undefined`\n */\n public getType(\n id: string,\n options?: GetTypeOptions\n ): NamedType<NodeType> | undefined {\n let type = this.registry.get(id);\n if (options?.getRawType === true || !type) {\n return type;\n }\n\n if (this.computedNodeCache.has(id)) {\n return JSON.parse(JSON.stringify(this.computedNodeCache.get(id))) as\n | NamedType<NodeType>\n | undefined;\n }\n\n type = this.resolveType(type, options?.optimize)\n\n this.computedNodeCache.set(id, type);\n\n return type;\n }\n\n /**\n * Returns if a Type with `id` has been loaded into the DSK\n *\n * @param id - Type to retrieve\n * @returns `boolean`\n */\n public hasType(id: string) {\n return this.registry.has(id);\n }\n\n /**\n * Lists types that have been loaded into the SDK\n *\n * @param filters - Any filters to apply to the types returned (a positive match will omit)\n * @returns `Array<NamedTypes>`\n */\n public listTypes(filters?: Filters) {\n return this.registry.list(filters);\n }\n\n /**\n * Returns meta information around a registered type\n *\n * @param id - Name of Type to retrieve\n * @returns `TypeMetaData` | `undefined`\n */\n public getTypeInfo(id: string) {\n return this.registry.info(id);\n }\n\n /**\n * Validates if a JSONC Node follows the XLR Type registered under the `typeName` specified\n *\n * @param typeName - Registered XLR Type to use for validation\n * @param rootNode - Node to validate\n * @returns `Array<ValidationErrors>`\n */\n public validateByName(typeName: string, rootNode: Node) {\n const xlr = this.getType(typeName);\n if (!xlr) {\n throw new Error(\n `Type ${typeName} does not exist in registry, can't validate`\n );\n }\n\n return this.validator.validateType(rootNode, xlr);\n }\n\n /**\n * Validates if a JSONC Node follows the supplied XLR Type\n *\n * @param type - Type to validate against\n * @param rootNode - Node to validate\n * @returns `Array<ValidationErrors>`\n */\n public validateByType(type: NodeType, rootNode: Node) {\n return this.validator.validateType(rootNode, type);\n }\n\n /**\n * Exports the types loaded into the registry to the specified format\n *\n * @param exportType - what format to export as\n * @param importMap - a map of primitive packages to types exported from that package to add import statements\n * @param filters - filter out plugins/capabilities/types you don't want to export\n * @param transforms - transforms to apply to types before exporting them\n * @returns [filename, content][] - Tuples of filenames and content to write\n */\n public exportRegistry(\n exportType: ExportTypes,\n importMap: Map<string, string[]>,\n filters?: Filters,\n transforms?: Array<TransformFunction>\n ): [string, string][] {\n const typesToExport = this.registry.list(filters).map((type) => {\n const effectiveType =\n transforms?.reduce(\n (typeAccumulator: NamedType<NodeType>, transformFn) =>\n transformFn(\n typeAccumulator,\n this.registry.info(type.name)?.capability as string\n ) as NamedType<NodeType>,\n type\n ) ?? type;\n\n return effectiveType;\n });\n\n if (exportType === \"TypeScript\") {\n const outputString = this.exportToTypeScript(typesToExport, importMap);\n return [[\"out.d.ts\", outputString]];\n }\n\n throw new Error(`Unknown export format ${exportType}`);\n }\n\n /**\n * Transforms a generated XLR node into its final representation by resolving all `extends` properties.\n * If `optimize` is set to true the following operations are also performed:\n * - Solving any conditional types\n * - Computing the effective types of any union elements\n * - Resolving any ref nodes\n * - filing in any remaining generics with their default value\n */\n private resolveType(type: NamedType, optimize = true): NamedType {\n const resolvedObject = fillInGenerics(type);\n\n let transformMap: TransformFunctionMap = {\n object: [(objectNode: ObjectType) => {\n if (objectNode.extends) {\n const refName = objectNode.extends.ref.split(\"<\")[0];\n let extendedType = this.getType(refName, {getRawType: true});\n if (!extendedType) {\n throw new Error(\n `Error resolving ${objectNode.name}: can't find extended type ${refName}`\n );\n }\n\n extendedType = resolveReferenceNode(\n objectNode.extends,\n extendedType as NamedType<ObjectType>\n ) as NamedType;\n if (extendedType.type === \"object\") {\n return {\n ...computeEffectiveObject(\n extendedType as ObjectType,\n objectNode as ObjectType,\n false\n ),\n name: objectNode.name,\n description: objectNode.description,\n };\n }\n\n if( extendedType.type === \"or\"){\n return {\n ...this.validator.computeIntersectionType([\n objectNode,\n extendedType\n ]\n ),\n name: objectNode.name,\n description: objectNode.description,\n } as any;\n }\n\n // if the merge isn't straightforward, defer until validation time for now\n return {\n name: objectNode.name,\n type: \"and\",\n and: [\n {\n ...objectNode,\n extends: undefined,\n },\n extendedType,\n ],\n } as unknown as ObjectNode;\n }\n\n return objectNode;\n }],\n } \n\n if(optimize){\n transformMap = {\n ...transformMap,\n conditional: [(node) => {\n return resolveConditional(node) as any\n }],\n and: [(node) => {\n return {\n ...this.validator.computeIntersectionType(node.and),\n ...(node.name ? { name: node.name } : {}),\n } as any\n }],\n ref: [(refNode) => {\n return this.validator.getRefType(refNode) as any\n }]\n }\n }\n\n return xlrTransformWalker(transformMap)(resolvedObject) as NamedType\n }\n\n private exportToTypeScript(\n typesToExport: NamedType[],\n importMap: Map<string, string[]>\n ): string {\n const referencedImports: Set<string> = new Set();\n const exportedTypes: Map<string, TopLevelDeclaration> = new Map();\n const printer = ts.createPrinter({ newLine: ts.NewLineKind.LineFeed });\n\n let resultFile = ts.createSourceFile(\n \"output.d.ts\",\n \"\",\n ts.ScriptTarget.ES2017,\n false, // setParentNodes\n ts.ScriptKind.TS\n );\n\n typesToExport.forEach((typeNode) => {\n const { type, referencedTypes, additionalTypes } =\n this.tsWriter.convertNamedType(typeNode);\n exportedTypes.set(typeNode.name, type);\n additionalTypes?.forEach((additionalType, name) =>\n exportedTypes.set(name, additionalType)\n );\n referencedTypes?.forEach((referencedType) =>\n referencedImports.add(referencedType)\n );\n });\n\n const typesToPrint: Array<string> = [];\n\n exportedTypes.forEach((type) =>\n typesToPrint.push(\n printer.printNode(ts.EmitHint.Unspecified, type, resultFile)\n )\n );\n\n importMap.forEach((imports, packageName) => {\n const applicableImports = imports.filter((i) => referencedImports.has(i));\n resultFile = ts.factory.updateSourceFile(resultFile, [\n ts.factory.createImportDeclaration(\n /* modifiers */ undefined,\n ts.factory.createImportClause(\n false,\n undefined,\n ts.factory.createNamedImports(\n applicableImports.map((i) =>\n ts.factory.createImportSpecifier(\n false,\n undefined,\n ts.factory.createIdentifier(i)\n )\n )\n )\n ),\n ts.factory.createStringLiteral(packageName)\n ),\n ...resultFile.statements,\n ]);\n });\n\n const headerText = printer.printFile(resultFile);\n const nodeText = typesToPrint.join(\"\\n\");\n return `${headerText}\\n${nodeText}`;\n }\n}\n","import type { NamedType, NodeType } from \"@player-tools/xlr\";\nimport type { XLRRegistry, Filters, TypeMetadata } from \"./types\";\n\n/**\n * Basic example of a XLRs Registry\n */\nexport class BasicXLRRegistry implements XLRRegistry {\n private typeMap: Map<string, NamedType<NodeType>>;\n private pluginMap: Map<string, Map<string, Array<string>>>;\n private infoMap: Map<string, TypeMetadata>;\n\n constructor() {\n this.typeMap = new Map();\n this.pluginMap = new Map();\n this.infoMap = new Map();\n }\n\n /** Returns a copy of the XLR to guard against unexpected type modification */\n get(id: string): NamedType<NodeType> | undefined {\n const value = this.typeMap.get(id);\n return value ? JSON.parse(JSON.stringify(value)) : undefined;\n }\n\n add(type: NamedType<NodeType>, plugin: string, capability: string): void {\n this.typeMap.set(type.name, type);\n this.infoMap.set(type.name, { plugin, capability });\n\n if (!this.pluginMap.has(plugin)) {\n this.pluginMap.set(plugin, new Map());\n }\n\n const pluginsCapabilities = this.pluginMap.get(plugin) as Map<\n string,\n Array<string>\n >;\n\n if (!pluginsCapabilities.has(capability)) {\n pluginsCapabilities.set(capability, []);\n }\n\n const providedCapabilities = pluginsCapabilities.get(\n capability\n ) as string[];\n providedCapabilities.push(type.name);\n }\n\n has(id: string): boolean {\n return this.typeMap.has(id);\n }\n\n list(filterArgs?: Filters): NamedType<NodeType>[] {\n const validTypes: Array<string> = [];\n\n this.pluginMap.forEach((manifest, pluginName) => {\n if (\n !filterArgs?.pluginFilter ||\n !pluginName.match(filterArgs.pluginFilter)\n ) {\n manifest.forEach((types, capabilityName) => {\n if (\n !filterArgs?.capabilityFilter ||\n !capabilityName.match(filterArgs.capabilityFilter)\n ) {\n types.forEach((type) => {\n if (\n !filterArgs?.typeFilter ||\n !type.match(filterArgs.typeFilter)\n ) {\n validTypes.push(type);\n }\n });\n }\n });\n }\n });\n return validTypes.map((type) => this.get(type) as NamedType);\n }\n\n info(id: string): TypeMetadata | undefined {\n return this.infoMap.get(id);\n }\n}\n","import type { Node } from \"jsonc-parser\";\nimport type {\n ArrayType,\n NamedType,\n NodeType,\n ObjectType,\n OrType,\n PrimitiveTypes,\n RefType,\n TemplateLiteralType,\n} from \"@player-tools/xlr\";\nimport {\n makePropertyMap,\n resolveConditional,\n isPrimitiveTypeNode,\n resolveReferenceNode,\n computeEffectiveObject,\n} from \"@player-tools/xlr-utils\";\nimport type { ValidationError } from \"./types\";\n\n/**\n * Validator for XLRs on JSON Nodes\n */\nexport class XLRValidator {\n private resolveType: (id: string) => NamedType<NodeType> | undefined;\n private regexCache: Map<string, RegExp>;\n\n constructor(resolveType: (id: string) => NamedType<NodeType> | undefined) {\n this.resolveType = resolveType;\n this.regexCache = new Map();\n }\n\n /** Main entrypoint for validation */\n public validateType(\n rootNode: Node,\n xlrNode: NodeType\n ): Array<ValidationError> {\n const validationIssues = new Array<ValidationError>();\n if (xlrNode.type === \"object\") {\n if (rootNode.type === \"object\") {\n validationIssues.push(...this.validateObject(xlrNode, rootNode));\n } else {\n validationIssues.push({\n type: \"type\",\n node: rootNode,\n message: `Expected an object but got an \"${rootNode.type}\"`,\n });\n }\n } else if (xlrNode.type === \"array\") {\n if (rootNode.type === \"array\") {\n validationIssues.push(...this.validateArray(rootNode, xlrNode));\n } else {\n validationIssues.push({\n type: \"type\",\n node: rootNode,\n message: `Expected an array but got an \"${rootNode.type}\"`,\n });\n }\n } else if (xlrNode.type === \"template\") {\n const error = this.validateTemplate(rootNode, xlrNode);\n if (error) {\n validationIssues.push(error);\n }\n } else if (xlrNode.type === \"or\") {\n // eslint-disable-next-line no-restricted-syntax\n for (const potentialType of xlrNode.or) {\n const potentialErrors = this.validateType(rootNode, potentialType);\n if (potentialErrors.length === 0) {\n return validationIssues;\n }\n }\n\n let message: string;\n\n if (xlrNode.name) {\n message = `Does not match any of the expected types for type: '${xlrNode.name}'`;\n } else if (xlrNode.title) {\n message = `Does not match any of the expected types for property: '${xlrNode.title}'`;\n } else {\n message = `Does not match any of the types ${xlrNode.or\n .map((node) => node.name ?? node.title ?? \"<unnamed type>\")\n .join(\" | \")}`;\n }\n\n validationIssues.push({\n type: \"value\",\n node: rootNode,\n message,\n });\n } else if (xlrNode.type === \"and\") {\n const effectiveType = {\n ...this.computeIntersectionType(xlrNode.and),\n ...(xlrNode.name ? { name: xlrNode.name } : {}),\n };\n validationIssues.push(...this.validateType(rootNode, effectiveType));\n } else if (xlrNode.type === \"record\") {\n rootNode.children?.forEach((child) => {\n validationIssues.push(\n ...this.validateType(child.children?.[0] as Node, xlrNode.keyType)\n );\n validationIssues.push(\n ...this.validateType(child.children?.[1] as Node, xlrNode.valueType)\n );\n });\n } else if (xlrNode.type === \"ref\") {\n const refType = this.getRefType(xlrNode);\n if (refType === undefined) {\n validationIssues.push({\n type: \"unknown\",\n node: rootNode,\n message: `Type \"${xlrNode.ref}\" is not defined in provided bundles`,\n });\n } else {\n validationIssues.push(\n ...this.validateType(rootNode, refType as NamedType)\n );\n }\n } else if (isPrimitiveTypeNode(xlrNode)) {\n if (!this.validateLiteralType(xlrNode, rootNode)) {\n if (\n (xlrNode.type === \"string\" ||\n xlrNode.type === \"number\" ||\n xlrNode.type === \"boolean\") &&\n xlrNode.const\n ) {\n validationIssues.push({\n type: \"type\",\n node: rootNode.parent as Node,\n message: `Expected \"${xlrNode.const}\" but got \"${rootNode.value}\"`,\n });\n } else {\n validationIssues.push({\n type: \"type\",\n node: rootNode.parent as Node,\n message: `Expected type \"${xlrNode.type}\" but got \"${rootNode.type}\"`,\n });\n }\n }\n } else if (xlrNode.type === \"conditional\") {\n // Resolve RefNodes in check conditions if needed\n let { right, left } = xlrNode.check;\n\n if (right.type === \"ref\") {\n right = this.getRefType(right);\n }\n\n if (left.type === \"ref\") {\n left = this.getRefType(left);\n }\n\n const resolvedXLRNode = {\n ...xlrNode,\n check: {\n left,\n right,\n },\n };\n\n const resolvedConditional = resolveConditional(resolvedXLRNode);\n if (resolvedConditional === resolvedXLRNode) {\n throw Error(\n `Unable to resolve conditional type at runtime: ${xlrNode.name}`\n );\n }\n\n validationIssues.push(\n ...this.validateType(rootNode, resolvedConditional)\n );\n } else {\n throw Error(`Unknown type ${xlrNode.type}`);\n }\n\n return validationIssues;\n }\n\n private validateTemplate(\n node: Node,\n xlrNode: TemplateLiteralType\n ): ValidationError | undefined {\n if (node.type !== \"string\") {\n return {\n type: \"type\",\n node: node.parent as Node,\n message: `Expected type \"${xlrNode.type}\" but got \"${typeof node}\"`,\n };\n }\n\n const regex = this.getRegex(xlrNode.format);\n const valid = regex.exec(node.value);\n if (!valid) {\n return {\n type: \"value\",\n node: node.parent as Node,\n message: `Does not match expected format: ${xlrNode.format}`,\n };\n }\n }\n\n private validateArray(rootNode: Node, xlrNode: ArrayType) {\n const issues: Array<ValidationError> = [];\n rootNode.children?.forEach((child) =>\n issues.push(...this.validateType(child, xlrNode.elementType))\n );\n return issues;\n }\n\n private validateObject(xlrNode: ObjectType, node: Node) {\n const issues: Array<ValidationError> = [];\n const objectProps = makePropertyMap(node);\n\n // eslint-disable-next-line guard-for-in, no-restricted-syntax\n for (const prop in xlrNode.properties) {\n const expectedType = xlrNode.properties[prop];\n const valueNode = objectProps.get(prop);\n if (expectedType.required && valueNode === undefined) {\n issues.push({\n type: \"missing\",\n node,\n message: `Property \"${prop}\" missing from type \"${xlrNode.name}\"`,\n });\n }\n\n if (valueNode) {\n issues.push(\n ...this.validateType(valueNode, expectedType.node as NamedType)\n );\n }\n }\n\n // Check if unknown keys are allowed and if they are - do the violate the constraint\n const extraKeys = Array.from(objectProps.keys()).filter(\n (key) => xlrNode.properties[key] === undefined\n );\n if (xlrNode.additionalProperties === false && extraKeys.length > 0) {\n issues.push({\n type: \"value\",\n node,\n message: `Unexpected properties on \"${xlrNode.name}\": ${extraKeys.join(\n \", \"\n )}`,\n });\n } else {\n issues.push(\n ...extraKeys.flatMap((key) =>\n this.validateType(\n objectProps.get(key) as Node,\n xlrNode.additionalProperties as NodeType\n )\n )\n );\n }\n\n return issues;\n }\n\n private validateLiteralType(expectedType: PrimitiveTypes, literalType: Node) {\n switch (expectedType.type) {\n case \"boolean\":\n if (expectedType.const) {\n return expectedType.const === literalType.value;\n }\n\n return typeof literalType.value === \"boolean\";\n case \"number\":\n if (expectedType.const) {\n return expectedType.const === literalType.value;\n }\n\n return typeof literalType.value === \"number\";\n case \"string\":\n if (expectedType.const) {\n return expectedType.const === literalType.value;\n }\n\n return typeof literalType.value === \"string\";\n case \"null\":\n return literalType.value === null;\n case \"never\":\n return literalType === undefined;\n case \"any\":\n return literalType !== undefined;\n case \"unknown\":\n return literalType !== undefined;\n case \"undefined\":\n return true;\n default:\n return false;\n }\n }\n\n public getRefType(ref: RefType): NodeType {\n let refName = ref.ref;\n if (refName.indexOf(\"<\") > 0) {\n [refName] = refName.split(\"<\");\n }\n\n const actualType = this.resolveType(refName);\n if (!actualType) {\n throw new Error(`Error: can't resolve type reference ${refName}`);\n }\n\n return resolveReferenceNode(ref, actualType);\n }\n\n private getRegex(expString: string): RegExp {\n if (this.regexCache.has(expString)) {\n return this.regexCache.get(expString) as RegExp;\n }\n\n const exp = new RegExp(expString);\n this.regexCache.set(expString, exp);\n return exp;\n }\n\n public computeIntersectionType(types: Array<NodeType>): ObjectType | OrType {\n let firstElement = types[0];\n let effectiveType: ObjectType | OrType;\n\n if (firstElement.type === \"ref\") {\n firstElement = this.getRefType(firstElement);\n }\n\n if (firstElement.type === \"and\") {\n effectiveType = this.computeIntersectionType(firstElement.and);\n } else if (firstElement.type === \"record\") {\n effectiveType = {\n type: \"object\",\n properties: {},\n additionalProperties: firstElement.valueType,\n };\n } else if (firstElement.type !== \"or\" && firstElement.type !== \"object\") {\n throw new Error(\n `Can't compute a union with a non-object type ${firstElement.type} (${firstElement.name})`\n );\n } else {\n effectiveType = firstElement;\n }\n\n types.slice(1).forEach((type) => {\n let typeToApply = type;\n\n if (typeToApply.type === \"record\") {\n typeToApply = {\n type: \"object\",\n properties: {},\n additionalProperties: typeToApply.valueType,\n };\n }\n\n if (type.type === \"ref\") {\n typeToApply = this.getRefType(type);\n }\n\n if (typeToApply.type === \"and\") {\n typeToApply = this.computeIntersectionType([type, effectiveType]);\n }\n\n if (typeToApply.type === \"object\") {\n if (effectiveType.type === \"object\") {\n effectiveType = computeEffectiveObject(effectiveType, typeToApply);\n } else {\n effectiveType = {\n ...effectiveType,\n or: effectiveType.or.map((y) =>\n this.computeIntersectionType([y, typeToApply])\n ),\n };\n }\n } else if (typeToApply.type === \"or\") {\n if (effectiveType.type === \"object\") {\n effectiveType = {\n ...typeToApply,\n or: typeToApply.or.map((y) =>\n this.computeIntersectionType([y, effectiveType])\n ),\n };\n } else {\n throw new Error(\"unimplemented operation or x or projection\");\n }\n } else {\n throw new Error(\n `Can't compute a union with a non-object type ${typeToApply.type} (${typeToApply.name})`\n );\n }\n });\n\n return effectiveType;\n }\n}\n","/* eslint-disable guard-for-in */\n/* eslint-disable no-restricted-syntax */\nimport type {\n NamedType,\n NodeTypeStrings,\n NodeTypeMap,\n TransformFunction,\n NodeType,\n ObjectProperty,\n RefNode,\n} from \"@player-tools/xlr\";\nimport { isGenericNamedType } from \"@player-tools/xlr-utils\";\n\ntype TypedTransformFunction<T extends NodeTypeStrings = NodeTypeStrings> = (\n input: NodeTypeMap[T]\n) => NodeTypeMap[T];\n\nexport type TransformFunctionMap = {\n [nodeType in NodeTypeStrings]?: Array<TypedTransformFunction<nodeType>>;\n};\n\nconst isMatchingCapability = (\n capability: string,\n capabilitiesToMatch: string | Array<string>\n): boolean => {\n if (Array.isArray(capabilitiesToMatch)) {\n return capabilitiesToMatch.includes(capability);\n }\n\n return capability === capabilitiesToMatch;\n};\n\nexport function xlrTransformWalker(\n transformMap: TransformFunctionMap\n): (node: NodeType) => NodeType {\n const walker = (n: NamedType | NodeType): NodeType => {\n let node = { ...n };\n const transformFunctions = transformMap[node.type] as unknown as Array<\n TypedTransformFunction<typeof node.type>\n >;\n\n for (const transformFn of transformFunctions ?? []) {\n node = transformFn(node);\n }\n\n if (node.type === \"object\") {\n const newObjectProperties: Record<string, ObjectProperty> = {};\n\n for (const key in node.properties) {\n const value = node.properties[key];\n newObjectProperties[key] = {\n required: value.required,\n node: walker(value.node),\n };\n }\n\n // need to walk generic tokens\n return {\n ...node,\n properties: { ...newObjectProperties },\n ...(isGenericNamedType(node)\n ? {\n genericTokens: node.genericTokens.map((token) => {\n return {\n ...token,\n constraints: token.constraints\n ? walker(token.constraints)\n : undefined,\n default: token.default ? walker(token.default) : undefined,\n };\n }),\n }\n : {}),\n extends: node.extends ? (walker(node.extends) as RefNode) : undefined,\n additionalProperties: node.additionalProperties\n ? walker(node.additionalProperties)\n : false,\n };\n }\n\n if (node.type === \"array\") {\n return {\n ...node,\n elementType: walker(node.elementType),\n };\n }\n\n if (node.type === \"and\") {\n return {\n ...node,\n and: node.and.map((element) => walker(element)),\n };\n }\n\n if (node.type === \"or\") {\n return {\n ...node,\n or: node.or.map((element) => walker(element)),\n };\n }\n\n if (node.type === \"ref\") {\n return {\n ...node,\n ...(node.genericArguments\n ? {\n genericArguments: node.genericArguments?.map((arg) =>\n walker(arg)\n ),\n }\n : {}),\n };\n }\n\n if (node.type === \"tuple\") {\n return {\n ...node,\n elementTypes: node.elementTypes.map((element) => {\n return {\n name: element.name,\n type: walker(element.type),\n optional: element.optional,\n };\n }),\n additionalItems: node.additionalItems\n ? walker(node.additionalItems)\n : false,\n };\n }\n\n if (node.type === \"function\") {\n return {\n ...node,\n parameters: node.parameters.map((param) => {\n return {\n ...param,\n type: walker(param.type),\n default: param.default ? walker(param.default) : undefined,\n };\n }),\n returnType: node.returnType ? walker(node.returnType) : undefined,\n };\n }\n\n if (node.type === \"record\") {\n return {\n ...node,\n keyType: walker(node.keyType),\n valueType: walker(node.valueType),\n };\n }\n\n if (node.type === \"conditional\") {\n return {\n ...node,\n check: {\n left: walker(node.check.left),\n right: walker(node.check.left),\n },\n value: {\n true: walker(node.value.true),\n false: walker(node.value.false),\n },\n };\n }\n\n return node;\n };\n\n return walker;\n}\n\n/**\n * Helper function for simple transforms\n * Walks an XLR tree looking for the specified node type calls the supplied function when called\n */\nexport function simpleTransformGenerator<\n T extends NodeTypeStrings = NodeTypeStrings\n>(\n typeToTransform: T,\n capabilityToTransform: string | Array<string>,\n functionToRun: TypedTransformFunction<T>\n): TransformFunction {\n /** walker for an XLR tree to touch every node */\n return (n: NamedType | NodeType, capability: string) => {\n // Run transform on base node before running on children\n if (isMatchingCapability(capability, capabilityToTransform)) {\n return xlrTransformWalker({ [typeToTransform]: [functionToRun] })(n);\n }\n\n return n;\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACWA,IAAAA,oBAIO;AACP,IAAAA,oBAA+B;AAE/B,4BAAyB;AACzB,gBAAe;AACf,kBAAiB;AACjB,wBAAe;;;ACfR,IAAM,mBAAN,MAA8C;AAAA,EAC3C;AAAA,EACA;AAAA,EACA;AAAA,EAER,cAAc;AACZ,SAAK,UAAU,oBAAI,IAAI;AACvB,SAAK,YAAY,oBAAI,IAAI;AACzB,SAAK,UAAU,oBAAI,IAAI;AAAA,EACzB;AAAA;AAAA,EAGA,IAAI,IAA6C;AAC/C,UAAM,QAAQ,KAAK,QAAQ,IAAI,EAAE;AACjC,WAAO,QAAQ,KAAK,MAAM,KAAK,UAAU,KAAK,CAAC,IAAI;AAAA,EACr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,QAAG,QAAQ,iBAAiB,YAAY;AAAA,QACnD,kBAAAA,QAAG,QAAQ;AAAA;AAAA,UACO;AAAA,UAChB,kBAAAA,QAAG,QAAQ;AAAA,YACT;AAAA,YACA;AAAA,YACA,kBAAAA,QAAG,QAAQ;AAAA,cACT,kBAAkB;AAAA,gBAAI,CAAC,MACrB,kBAAAA,QAAG,QAAQ;AAAA,kBACT;AAAA,kBACA;AAAA,kBACA,kBAAAA,QAAG,QAAQ,iBAAiB,CAAC;AAAA,gBAC/B;AAAA,cACF;AAAA,YACF;AAAA,UACF;AAAA,UACA,kBAAAA,QAAG,QAAQ,oBAAoB,WAAW;AAAA,QAC5C;AAAA,QACA,GAAG,WAAW;AAAA,MAChB,CAAC;AAAA,IACH,CAAC;AAED,UAAM,aAAa,QAAQ,UAAU,UAAU;AAC/C,UAAM,WAAW,aAAa,KAAK,IAAI;AACvC,WAAO,GAAG,UAAU;AAAA,EAAK,QAAQ;AAAA,EACnC;AACF;","names":["import_xlr_utils","import_xlr_utils","fs","path","ts"]}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/xlr/sdk/src/index.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/xlr/sdk/src/sdk.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/xlr/sdk/src/registry/basic-registry.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/xlr/sdk/src/validator.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/xlr/sdk/src/types.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/xlr/sdk/src/utils.ts"],"sourcesContent":["export * from \"./sdk\";\nexport * from \"./types\";\nexport * from \"./registry\";\nexport * from \"./utils\";\n","/* eslint-disable prettier/prettier */\nimport type {\n Manifest,\n NamedType,\n NodeType,\n ObjectNode,\n ObjectType,\n TransformFunction,\n TSManifest,\n} from \"@player-tools/xlr\";\nimport type { TopLevelDeclaration } from \"@player-tools/xlr-utils\";\nimport {\n computeEffectiveObject,\n resolveConditional,\n resolveReferenceNode,\n} from \"@player-tools/xlr-utils\";\nimport { fillInGenerics } from \"@player-tools/xlr-utils\";\nimport type { Node } from \"jsonc-parser\";\nimport { TSWriter } from \"@player-tools/xlr-converters\";\nimport fs from \"fs\";\nimport path from \"path\";\nimport ts from \"typescript\";\n\nimport type { XLRRegistry, Filters } from \"./registry\";\nimport { BasicXLRRegistry } from \"./registry\";\nimport type { ExportTypes } from \"./types\";\nimport { XLRValidator } from \"./validator\";\nimport { TransformFunctionMap, xlrTransformWalker } from \"./utils\";\n\nexport interface GetTypeOptions {\n /** Resolves `extends` fields in objects */\n getRawType?: boolean;\n /** Perform optimizations to resolve all references, type intersections, and conditionals */\n optimize?: boolean;\n}\n\n/**\n * Abstraction for interfacing with XLRs making it more approachable to use without understanding the inner workings of the types and how they are packaged\n */\nexport class XLRSDK {\n private registry: XLRRegistry;\n private validator: XLRValidator;\n private tsWriter: TSWriter;\n private computedNodeCache: Map<string, NodeType>;\n private externalTransformFunctions: Map<string, TransformFunction>;\n\n constructor(customRegistry?: XLRRegistry) {\n this.registry = customRegistry ?? new BasicXLRRegistry();\n this.validator = new XLRValidator(this.getType.bind(this));\n this.tsWriter = new TSWriter();\n this.computedNodeCache = new Map();\n this.externalTransformFunctions = new Map();\n }\n\n /**\n * Loads definitions from a path on the filesystem\n *\n * @param inputPath - path to the directory to load (above the xlr folder)\n * @param filters - Any filters to apply when loading the types (a positive match will omit)\n * @param transforms - any transforms to apply to the types being loaded\n */\n public loadDefinitionsFromDisk(\n inputPath: string,\n filters?: Omit<Filters, \"pluginFilter\">,\n transforms?: Array<TransformFunction>\n ) {\n this.computedNodeCache.clear();\n\n const transformsToRun = [\n ...this.externalTransformFunctions.values(),\n ...(transforms ?? []),\n ];\n\n const manifest = JSON.parse(\n fs.readFileSync(path.join(inputPath, \"xlr\", \"manifest.json\")).toString(),\n (key: unknown, value: unknown) => {\n // Custom parser because JSON objects -> JS Objects, not maps\n if (typeof value === \"object\" && value !== null) {\n if (key === \"capabilities\") {\n return new Map(Object.entries(value));\n }\n }\n\n return value;\n }\n ) as Manifest;\n\n manifest.capabilities?.forEach((capabilityList, capabilityName) => {\n if (\n filters?.capabilityFilter &&\n capabilityName.match(filters?.capabilityFilter)\n )\n return;\n capabilityList.forEach((extensionName) => {\n if (!filters?.typeFilter || !extensionName.match(filters?.typeFilter)) {\n const cType: NamedType<NodeType> = JSON.parse(\n fs\n .readFileSync(\n path.join(inputPath, \"xlr\", `${extensionName}.json`)\n )\n .toString()\n );\n const effectiveType =\n transformsToRun?.reduce(\n (typeAccumulator: NamedType<NodeType>, transformFn) =>\n transformFn(\n typeAccumulator,\n capabilityName\n ) as NamedType<NodeType>,\n cType\n ) ?? cType;\n\n this.registry.add(effectiveType, manifest.pluginName, capabilityName);\n }\n });\n });\n }\n\n /**\n * Load definitions from a js/ts file in memory\n *\n * @param manifest - The imported XLR manifest module\n * @param filters - Any filters to apply when loading the types (a positive match will omit)\n * @param transforms - any transforms to apply to the types being loaded\n */\n public async loadDefinitionsFromModule(\n manifest: TSManifest,\n filters?: Omit<Filters, \"pluginFilter\">,\n transforms?: Array<TransformFunction>\n ) {\n this.computedNodeCache.clear();\n\n const transformsToRun = [\n ...this.externalTransformFunctions.values(),\n ...(transforms ?? []),\n ];\n\n Object.keys(manifest.capabilities)?.forEach((capabilityName) => {\n if (\n filters?.capabilityFilter &&\n capabilityName.match(filters?.capabilityFilter)\n )\n return;\n const capabilityList = manifest.capabilities[capabilityName];\n capabilityList.forEach((extension) => {\n if (\n !filters?.typeFilter ||\n !extension.name.match(filters?.typeFilter)\n ) {\n const effectiveType =\n transformsToRun?.reduce(\n (typeAccumulator: NamedType<NodeType>, transformFn) =>\n transformFn(\n typeAccumulator,\n capabilityName\n ) as NamedType<NodeType>,\n extension\n ) ?? extension;\n\n this.registry.add(effectiveType, manifest.pluginName, capabilityName);\n }\n });\n });\n }\n\n /**\n * Statically load transform function that should be applied to every XLR bundle that is imported\n */\n public addTransformFunction(name: string, fn: TransformFunction): void {\n this.externalTransformFunctions.set(name, fn);\n }\n\n /**\n * Remove any transform function loaded via the `addTransformFunction` method by name\n */\n public removeTransformFunction(name: string): void {\n this.externalTransformFunctions.delete(name);\n }\n\n /**\n * Returns a Type that has been previously loaded\n *\n * @param id - Type to retrieve\n * @param options - `GetTypeOptions`\n * @returns `NamedType<NodeType>` | `undefined`\n */\n public getType(\n id: string,\n options?: GetTypeOptions\n ): NamedType<NodeType> | undefined {\n let type = this.registry.get(id);\n if (options?.getRawType === true || !type) {\n return type;\n }\n\n if (this.computedNodeCache.has(id)) {\n return JSON.parse(JSON.stringify(this.computedNodeCache.get(id))) as\n | NamedType<NodeType>\n | undefined;\n }\n\n type = this.resolveType(type, options?.optimize)\n\n this.computedNodeCache.set(id, type);\n\n return type;\n }\n\n /**\n * Returns if a Type with `id` has been loaded into the DSK\n *\n * @param id - Type to retrieve\n * @returns `boolean`\n */\n public hasType(id: string) {\n return this.registry.has(id);\n }\n\n /**\n * Lists types that have been loaded into the SDK\n *\n * @param filters - Any filters to apply to the types returned (a positive match will omit)\n * @returns `Array<NamedTypes>`\n */\n public listTypes(filters?: Filters) {\n return this.registry.list(filters);\n }\n\n /**\n * Returns meta information around a registered type\n *\n * @param id - Name of Type to retrieve\n * @returns `TypeMetaData` | `undefined`\n */\n public getTypeInfo(id: string) {\n return this.registry.info(id);\n }\n\n /**\n * Validates if a JSONC Node follows the XLR Type registered under the `typeName` specified\n *\n * @param typeName - Registered XLR Type to use for validation\n * @param rootNode - Node to validate\n * @returns `Array<ValidationErrors>`\n */\n public validateByName(typeName: string, rootNode: Node) {\n const xlr = this.getType(typeName);\n if (!xlr) {\n throw new Error(\n `Type ${typeName} does not exist in registry, can't validate`\n );\n }\n\n return this.validator.validateType(rootNode, xlr);\n }\n\n /**\n * Validates if a JSONC Node follows the supplied XLR Type\n *\n * @param type - Type to validate against\n * @param rootNode - Node to validate\n * @returns `Array<ValidationErrors>`\n */\n public validateByType(type: NodeType, rootNode: Node) {\n return this.validator.validateType(rootNode, type);\n }\n\n /**\n * Exports the types loaded into the registry to the specified format\n *\n * @param exportType - what format to export as\n * @param importMap - a map of primitive packages to types exported from that package to add import statements\n * @param filters - filter out plugins/capabilities/types you don't want to export\n * @param transforms - transforms to apply to types before exporting them\n * @returns [filename, content][] - Tuples of filenames and content to write\n */\n public exportRegistry(\n exportType: ExportTypes,\n importMap: Map<string, string[]>,\n filters?: Filters,\n transforms?: Array<TransformFunction>\n ): [string, string][] {\n const typesToExport = this.registry.list(filters).map((type) => {\n const effectiveType =\n transforms?.reduce(\n (typeAccumulator: NamedType<NodeType>, transformFn) =>\n transformFn(\n typeAccumulator,\n this.registry.info(type.name)?.capability as string\n ) as NamedType<NodeType>,\n type\n ) ?? type;\n\n return effectiveType;\n });\n\n if (exportType === \"TypeScript\") {\n const outputString = this.exportToTypeScript(typesToExport, importMap);\n return [[\"out.d.ts\", outputString]];\n }\n\n throw new Error(`Unknown export format ${exportType}`);\n }\n\n /**\n * Transforms a generated XLR node into its final representation by resolving all `extends` properties.\n * If `optimize` is set to true the following operations are also performed:\n * - Solving any conditional types\n * - Computing the effective types of any union elements\n * - Resolving any ref nodes\n * - filing in any remaining generics with their default value\n */\n private resolveType(type: NamedType, optimize = true): NamedType {\n const resolvedObject = fillInGenerics(type);\n\n let transformMap: TransformFunctionMap = {\n object: [(objectNode: ObjectType) => {\n if (objectNode.extends) {\n const refName = objectNode.extends.ref.split(\"<\")[0];\n let extendedType = this.getType(refName, {getRawType: true});\n if (!extendedType) {\n throw new Error(\n `Error resolving ${objectNode.name}: can't find extended type ${refName}`\n );\n }\n\n extendedType = resolveReferenceNode(\n objectNode.extends,\n extendedType as NamedType<ObjectType>\n ) as NamedType;\n if (extendedType.type === \"object\") {\n return {\n ...computeEffectiveObject(\n extendedType as ObjectType,\n objectNode as ObjectType,\n false\n ),\n name: objectNode.name,\n description: objectNode.description,\n };\n }\n\n if( extendedType.type === \"or\"){\n return {\n ...this.validator.computeIntersectionType([\n objectNode,\n extendedType\n ]\n ),\n name: objectNode.name,\n description: objectNode.description,\n } as any;\n }\n\n // if the merge isn't straightforward, defer until validation time for now\n return {\n name: objectNode.name,\n type: \"and\",\n and: [\n {\n ...objectNode,\n extends: undefined,\n },\n extendedType,\n ],\n } as unknown as ObjectNode;\n }\n\n return objectNode;\n }],\n } \n\n if(optimize){\n transformMap = {\n ...transformMap,\n conditional: [(node) => {\n return resolveConditional(node) as any\n }],\n and: [(node) => {\n return {\n ...this.validator.computeIntersectionType(node.and),\n ...(node.name ? { name: node.name } : {}),\n } as any\n }],\n ref: [(refNode) => {\n return this.validator.getRefType(refNode) as any\n }]\n }\n }\n\n return xlrTransformWalker(transformMap)(resolvedObject) as NamedType\n }\n\n private exportToTypeScript(\n typesToExport: NamedType[],\n importMap: Map<string, string[]>\n ): string {\n const referencedImports: Set<string> = new Set();\n const exportedTypes: Map<string, TopLevelDeclaration> = new Map();\n const printer = ts.createPrinter({ newLine: ts.NewLineKind.LineFeed });\n\n let resultFile = ts.createSourceFile(\n \"output.d.ts\",\n \"\",\n ts.ScriptTarget.ES2017,\n false, // setParentNodes\n ts.ScriptKind.TS\n );\n\n typesToExport.forEach((typeNode) => {\n const { type, referencedTypes, additionalTypes } =\n this.tsWriter.convertNamedType(typeNode);\n exportedTypes.set(typeNode.name, type);\n additionalTypes?.forEach((additionalType, name) =>\n exportedTypes.set(name, additionalType)\n );\n referencedTypes?.forEach((referencedType) =>\n referencedImports.add(referencedType)\n );\n });\n\n const typesToPrint: Array<string> = [];\n\n exportedTypes.forEach((type) =>\n typesToPrint.push(\n printer.printNode(ts.EmitHint.Unspecified, type, resultFile)\n )\n );\n\n importMap.forEach((imports, packageName) => {\n const applicableImports = imports.filter((i) => referencedImports.has(i));\n resultFile = ts.factory.updateSourceFile(resultFile, [\n ts.factory.createImportDeclaration(\n /* modifiers */ undefined,\n ts.factory.createImportClause(\n false,\n undefined,\n ts.factory.createNamedImports(\n applicableImports.map((i) =>\n ts.factory.createImportSpecifier(\n false,\n undefined,\n ts.factory.createIdentifier(i)\n )\n )\n )\n ),\n ts.factory.createStringLiteral(packageName)\n ),\n ...resultFile.statements,\n ]);\n });\n\n const headerText = printer.printFile(resultFile);\n const nodeText = typesToPrint.join(\"\\n\");\n return `${headerText}\\n${nodeText}`;\n }\n}\n","import type { NamedType, NodeType } from \"@player-tools/xlr\";\nimport type { XLRRegistry, Filters, TypeMetadata } from \"./types\";\n\n/**\n * Basic example of a XLRs Registry\n */\nexport class BasicXLRRegistry implements XLRRegistry {\n private typeMap: Map<string, NamedType<NodeType>>;\n private pluginMap: Map<string, Map<string, Array<string>>>;\n private infoMap: Map<string, TypeMetadata>;\n\n constructor() {\n this.typeMap = new Map();\n this.pluginMap = new Map();\n this.infoMap = new Map();\n }\n\n /** Returns a copy of the XLR to guard against unexpected type modification */\n get(id: string): NamedType<NodeType> | undefined {\n const value = this.typeMap.get(id);\n return value ? JSON.parse(JSON.stringify(value)) : undefined;\n }\n\n add(type: NamedType<NodeType>, plugin: string, capability: string): void {\n this.typeMap.set(type.name, type);\n this.infoMap.set(type.name, { plugin, capability });\n\n if (!this.pluginMap.has(plugin)) {\n this.pluginMap.set(plugin, new Map());\n }\n\n const pluginsCapabilities = this.pluginMap.get(plugin) as Map<\n string,\n Array<string>\n >;\n\n if (!pluginsCapabilities.has(capability)) {\n pluginsCapabilities.set(capability, []);\n }\n\n const providedCapabilities = pluginsCapabilities.get(\n capability\n ) as string[];\n providedCapabilities.push(type.name);\n }\n\n has(id: string): boolean {\n return this.typeMap.has(id);\n }\n\n list(filterArgs?: Filters): NamedType<NodeType>[] {\n const validTypes: Array<string> = [];\n\n this.pluginMap.forEach((manifest, pluginName) => {\n if (\n !filterArgs?.pluginFilter ||\n !pluginName.match(filterArgs.pluginFilter)\n ) {\n manifest.forEach((types, capabilityName) => {\n if (\n !filterArgs?.capabilityFilter ||\n !capabilityName.match(filterArgs.capabilityFilter)\n ) {\n types.forEach((type) => {\n if (\n !filterArgs?.typeFilter ||\n !type.match(filterArgs.typeFilter)\n ) {\n validTypes.push(type);\n }\n });\n }\n });\n }\n });\n return validTypes.map((type) => this.get(type) as NamedType);\n }\n\n info(id: string): TypeMetadata | undefined {\n return this.infoMap.get(id);\n }\n}\n","import type { Node } from \"jsonc-parser\";\nimport type {\n ArrayType,\n NamedType,\n NodeType,\n ObjectType,\n OrType,\n PrimitiveTypes,\n RefType,\n TemplateLiteralType,\n} from \"@player-tools/xlr\";\nimport {\n makePropertyMap,\n resolveConditional,\n isPrimitiveTypeNode,\n resolveReferenceNode,\n computeEffectiveObject,\n} from \"@player-tools/xlr-utils\";\nimport { ValidationSeverity } from \"./types\";\nimport type { ValidationMessage } from \"./types\";\n\nexport interface XLRValidatorConfig {\n /** URL mapping for supplemental documentation */\n urlMapping?: Record<string, string>;\n}\n\nconst MAX_VALID_SHOWN = 20;\n\n/**\n * Validator for XLRs on JSON Nodes\n */\nexport class XLRValidator {\n private config: XLRValidatorConfig;\n private resolveType: (id: string) => NamedType<NodeType> | undefined;\n private regexCache: Map<string, RegExp>;\n\n constructor(\n resolveType: (id: string) => NamedType<NodeType> | undefined,\n config?: XLRValidatorConfig\n ) {\n this.config = config || {};\n this.resolveType = resolveType;\n this.regexCache = new Map();\n }\n\n /** Main entrypoint for validation */\n public validateType(\n rootNode: Node,\n xlrNode: NodeType\n ): Array<ValidationMessage> {\n const validationIssues = new Array<ValidationMessage>();\n if (xlrNode.type === \"object\") {\n if (rootNode.type === \"object\") {\n validationIssues.push(...this.validateObject(xlrNode, rootNode));\n } else {\n validationIssues.push({\n type: \"type\",\n node: rootNode,\n message: `Expected an object but got an \"${rootNode.type}\"`,\n severity: ValidationSeverity.Error,\n });\n }\n } else if (xlrNode.type === \"array\") {\n if (rootNode.type === \"array\") {\n validationIssues.push(...this.validateArray(rootNode, xlrNode));\n } else {\n validationIssues.push({\n type: \"type\",\n node: rootNode,\n message: `Expected an array but got an \"${rootNode.type}\"`,\n severity: ValidationSeverity.Error,\n });\n }\n } else if (xlrNode.type === \"template\") {\n const error = this.validateTemplate(rootNode, xlrNode);\n if (error) {\n validationIssues.push(error);\n }\n } else if (xlrNode.type === \"or\") {\n const potentialTypeErrors: Array<{\n type: NodeType;\n errors: Array<ValidationMessage>;\n }> = [];\n\n for (const potentialType of xlrNode.or) {\n const potentialErrors = this.validateType(rootNode, potentialType);\n\n if (potentialErrors.length === 0) {\n return validationIssues;\n }\n\n potentialTypeErrors.push({\n type: potentialType,\n errors: potentialErrors,\n });\n }\n\n let message: string;\n const expectedTypes = xlrNode.or\n .map((node) => node.name ?? node.title ?? node.type ?? \"<unnamed type>\")\n .join(\" | \");\n\n if (xlrNode.name) {\n message = `Does not match any of the expected types for type: '${xlrNode.name}'`;\n } else if (xlrNode.title) {\n message = `Does not match any of the expected types for property: '${xlrNode.title}'`;\n } else {\n message = `Does not match any of the types: ${expectedTypes}`;\n }\n\n const { infoMessage } = this.generateNestedTypesInfo(\n potentialTypeErrors,\n xlrNode,\n rootNode\n );\n\n validationIssues.push({\n type: \"value\",\n node: rootNode,\n message: message.trim(),\n severity: ValidationSeverity.Error,\n });\n\n if (infoMessage) {\n validationIssues.push({\n type: \"value\",\n node: rootNode,\n message: infoMessage,\n severity: ValidationSeverity.Info,\n });\n }\n } else if (xlrNode.type === \"and\") {\n const effectiveType = {\n ...this.computeIntersectionType(xlrNode.and),\n ...(xlrNode.name ? { name: xlrNode.name } : {}),\n };\n validationIssues.push(...this.validateType(rootNode, effectiveType));\n } else if (xlrNode.type === \"record\") {\n rootNode.children?.forEach((child) => {\n validationIssues.push(\n ...this.validateType(child.children?.[0] as Node, xlrNode.keyType)\n );\n validationIssues.push(\n ...this.validateType(child.children?.[1] as Node, xlrNode.valueType)\n );\n });\n } else if (xlrNode.type === \"ref\") {\n const refType = this.getRefType(xlrNode);\n if (refType === undefined) {\n validationIssues.push({\n type: \"unknown\",\n node: rootNode,\n message: `Type \"${xlrNode.ref}\" is not defined in provided bundles`,\n severity: ValidationSeverity.Error,\n });\n } else {\n validationIssues.push(\n ...this.validateType(rootNode, refType as NamedType)\n );\n }\n } else if (isPrimitiveTypeNode(xlrNode)) {\n if (!this.validateLiteralType(xlrNode, rootNode)) {\n if (\n (xlrNode.type === \"string\" ||\n xlrNode.type === \"number\" ||\n xlrNode.type === \"boolean\") &&\n xlrNode.const\n ) {\n validationIssues.push({\n type: \"type\",\n node: rootNode.parent as Node,\n message: `Expected \"${xlrNode.const}\" but got \"${rootNode.value}\"`,\n expected: xlrNode.const,\n severity: ValidationSeverity.Error,\n });\n } else {\n validationIssues.push({\n type: \"type\",\n node: rootNode.parent as Node,\n message: `Expected type \"${xlrNode.type}\" but got \"${rootNode.type}\"`,\n expected: xlrNode.type,\n severity: ValidationSeverity.Error,\n });\n }\n }\n } else if (xlrNode.type === \"conditional\") {\n // Resolve RefNodes in check conditions if needed\n let { right, left } = xlrNode.check;\n\n if (right.type === \"ref\") {\n right = this.getRefType(right);\n }\n\n if (left.type === \"ref\") {\n left = this.getRefType(left);\n }\n\n const resolvedXLRNode = {\n ...xlrNode,\n check: {\n left,\n right,\n },\n };\n\n const resolvedConditional = resolveConditional(resolvedXLRNode);\n if (resolvedConditional === resolvedXLRNode) {\n throw Error(\n `Unable to resolve conditional type at runtime: ${xlrNode.name}`\n );\n }\n\n validationIssues.push(\n ...this.validateType(rootNode, resolvedConditional)\n );\n } else {\n throw Error(`Unknown type ${xlrNode.type}`);\n }\n\n return validationIssues;\n }\n\n private generateNestedTypesInfo(\n potentialTypeErrors: Array<{\n type: NodeType;\n errors: Array<ValidationMessage>;\n }>,\n xlrNode: OrType,\n rootNode: Node\n ): { nestedTypesList: string; infoMessage?: string } {\n const nestedTypes = new Set<string>();\n\n // TODO: Create a recursive function that returns value or xlrNode info\n // First, try to extract types from potential type errors\n potentialTypeErrors.forEach((typeError) => {\n if (typeError.type.type !== \"template\") {\n typeError.errors.forEach((error) => {\n if (error.type === \"type\" && error.expected) {\n // Split by separate types if union\n String(error.expected)\n .split(\" | \")\n .forEach((val) => nestedTypes.add(val.trim()));\n }\n });\n }\n });\n\n // If no types found from errors, try using type from xlrNode\n if (nestedTypes.size === 0) {\n xlrNode.or.forEach((type) => {\n const typeName =\n type.name ?? type.title ?? type.type ?? \"<unnamed type>\";\n nestedTypes.add(typeName);\n });\n }\n\n const nestedTypesArray = [...nestedTypes];\n\n // Display list of expected types as a union\n let nestedTypesList =\n nestedTypesArray.slice(0, MAX_VALID_SHOWN).join(\" | \") +\n (nestedTypesArray.length > MAX_VALID_SHOWN\n ? ` | +${\n nestedTypesArray.length - MAX_VALID_SHOWN\n } ... ${nestedTypesArray.pop()}`\n : \"\");\n\n // TODO: Be able to pass the validator's config to the SDK\n const docsURL = this.config.urlMapping;\n\n // Support passing in a URL for matching type\n if (docsURL && xlrNode.name && docsURL[xlrNode.name]) {\n nestedTypesList = docsURL[xlrNode.name];\n }\n\n // Support supplemental info message\n let infoMessage;\n\n if (rootNode.value !== undefined) {\n infoMessage = `Got: ${rootNode.value} and expected: ${nestedTypesList}`;\n } else if (nestedTypesList) {\n infoMessage = `Expected: ${nestedTypesList}`;\n }\n\n return { nestedTypesList, infoMessage };\n }\n\n private validateTemplate(\n node: Node,\n xlrNode: TemplateLiteralType\n ): ValidationMessage | undefined {\n if (node.type !== \"string\") {\n return {\n type: \"type\",\n node: node.parent as Node,\n message: `Expected type \"${xlrNode.type}\" but got \"${typeof node}\"`,\n expected: xlrNode.type,\n severity: ValidationSeverity.Error,\n };\n }\n\n const regex = this.getRegex(xlrNode.format);\n const valid = regex.exec(node.value);\n if (!valid) {\n return {\n type: \"value\",\n node: node.parent as Node,\n message: `Does not match expected format: ${xlrNode.format}`,\n expected: xlrNode.format,\n severity: ValidationSeverity.Error,\n };\n }\n }\n\n private validateArray(rootNode: Node, xlrNode: ArrayType) {\n const issues: Array<ValidationMessage> = [];\n rootNode.children?.forEach((child) =>\n issues.push(...this.validateType(child, xlrNode.elementType))\n );\n return issues;\n }\n\n private validateObject(xlrNode: ObjectType, node: Node) {\n const issues: Array<ValidationMessage> = [];\n const objectProps = makePropertyMap(node);\n\n // eslint-disable-next-line guard-for-in, no-restricted-syntax\n for (const prop in xlrNode.properties) {\n const expectedType = xlrNode.properties[prop];\n const valueNode = objectProps.get(prop);\n if (expectedType.required && valueNode === undefined) {\n issues.push({\n type: \"missing\",\n node,\n message: `Property \"${prop}\" missing from type \"${xlrNode.name}\"`,\n severity: ValidationSeverity.Error,\n });\n }\n\n if (valueNode) {\n issues.push(\n ...this.validateType(valueNode, expectedType.node as NamedType)\n );\n }\n }\n\n // Check if unknown keys are allowed and if they are - do the violate the constraint\n const extraKeys = Array.from(objectProps.keys()).filter(\n (key) => xlrNode.properties[key] === undefined\n );\n if (xlrNode.additionalProperties === false && extraKeys.length > 0) {\n issues.push({\n type: \"value\",\n node,\n message: `Unexpected properties on \"${xlrNode.name}\": ${extraKeys.join(\n \", \"\n )}`,\n severity: ValidationSeverity.Error,\n });\n } else {\n issues.push(\n ...extraKeys.flatMap((key) =>\n this.validateType(\n objectProps.get(key) as Node,\n xlrNode.additionalProperties as NodeType\n )\n )\n );\n }\n\n return issues;\n }\n\n private validateLiteralType(expectedType: PrimitiveTypes, literalType: Node) {\n switch (expectedType.type) {\n case \"boolean\":\n if (expectedType.const) {\n return expectedType.const === literalType.value;\n }\n\n return typeof literalType.value === \"boolean\";\n case \"number\":\n if (expectedType.const) {\n return expectedType.const === literalType.value;\n }\n\n return typeof literalType.value === \"number\";\n case \"string\":\n if (expectedType.const) {\n return expectedType.const === literalType.value;\n }\n\n return typeof literalType.value === \"string\";\n case \"null\":\n return literalType.value === null;\n case \"never\":\n return literalType === undefined;\n case \"any\":\n return literalType !== undefined;\n case \"unknown\":\n return literalType !== undefined;\n case \"undefined\":\n return true;\n default:\n return false;\n }\n }\n\n public getRefType(ref: RefType): NodeType {\n let refName = ref.ref;\n if (refName.indexOf(\"<\") > 0) {\n [refName] = refName.split(\"<\");\n }\n\n const actualType = this.resolveType(refName);\n if (!actualType) {\n throw new Error(`Error: can't resolve type reference ${refName}`);\n }\n\n return resolveReferenceNode(ref, actualType);\n }\n\n private getRegex(expString: string): RegExp {\n if (this.regexCache.has(expString)) {\n return this.regexCache.get(expString) as RegExp;\n }\n\n const exp = new RegExp(expString);\n this.regexCache.set(expString, exp);\n return exp;\n }\n\n public computeIntersectionType(types: Array<NodeType>): ObjectType | OrType {\n let firstElement = types[0];\n let effectiveType: ObjectType | OrType;\n\n // Capture the original top-level type name if exists\n const topLevelTypeName = types[0].name;\n\n if (firstElement.type === \"ref\") {\n firstElement = this.getRefType(firstElement);\n }\n\n if (firstElement.type === \"and\") {\n effectiveType = this.computeIntersectionType(firstElement.and);\n } else if (firstElement.type === \"record\") {\n effectiveType = {\n type: \"object\",\n properties: {},\n additionalProperties: firstElement.valueType,\n };\n } else if (firstElement.type !== \"or\" && firstElement.type !== \"object\") {\n throw new Error(\n `Can't compute a union with a non-object type ${firstElement.type} (${firstElement.name})`\n );\n } else {\n effectiveType = firstElement;\n }\n\n types.slice(1).forEach((type) => {\n let typeToApply = type;\n\n if (typeToApply.type === \"record\") {\n typeToApply = {\n type: \"object\",\n properties: {},\n additionalProperties: typeToApply.valueType,\n };\n }\n\n if (type.type === \"ref\") {\n typeToApply = this.getRefType(type);\n }\n\n if (typeToApply.type === \"and\") {\n typeToApply = this.computeIntersectionType([type, effectiveType]);\n }\n\n if (typeToApply.type === \"object\") {\n if (effectiveType.type === \"object\") {\n effectiveType = computeEffectiveObject(effectiveType, typeToApply);\n } else {\n effectiveType = {\n ...effectiveType,\n or: effectiveType.or.map((y) => {\n const intersectedType = this.computeIntersectionType([\n y,\n typeToApply,\n ]);\n\n // If the intersected type doesn't have a name, use the top-level type name\n if (!intersectedType.name && topLevelTypeName) {\n intersectedType.name = topLevelTypeName;\n }\n\n return intersectedType;\n }),\n };\n }\n } else if (typeToApply.type === \"or\") {\n if (effectiveType.type === \"object\") {\n effectiveType = {\n ...typeToApply,\n or: typeToApply.or.map((y) => {\n const intersectedType = this.computeIntersectionType([\n y,\n effectiveType,\n ]);\n\n // If the intersected type doesn't have a name, use the top-level type name\n if (!intersectedType.name && topLevelTypeName) {\n intersectedType.name = topLevelTypeName;\n }\n\n return intersectedType;\n }),\n };\n } else {\n throw new Error(\"unimplemented operation or x or projection\");\n }\n } else {\n throw new Error(\n `Can't compute a union with a non-object type ${typeToApply.type} (${typeToApply.name})`\n );\n }\n });\n\n // If the final effective type is an or type and doesn't have a name, use the top-level type name\n if (\n effectiveType.type === \"or\" &&\n !effectiveType.name &&\n topLevelTypeName\n ) {\n effectiveType.name = topLevelTypeName;\n }\n\n return effectiveType;\n }\n}\n","import type { Node } from \"jsonc-parser\";\n\n/** Support Export Formats */\nexport type ExportTypes = \"TypeScript\";\n\nexport interface BaseValidationMessage<ErrorType extends string = string> {\n /** Validation Type */\n type: ErrorType;\n\n /** Error message text */\n message: string;\n\n /** JSONC node that the error originates from */\n node: Node;\n\n /** Level of the message */\n severity: ValidationSeverity;\n}\n\nexport interface TypeValidationError extends BaseValidationMessage<\"type\"> {\n /** Expected types */\n expected?: string[] | string | number | boolean;\n}\n\nexport type MissingValidationError = BaseValidationMessage<\"missing\">;\n\nexport type UnknownValidationError = BaseValidationMessage<\"unknown\">;\n\nexport interface ValueValidationError extends BaseValidationMessage<\"value\"> {\n /** Expected value */\n expected?: string;\n}\n\nexport type UnexpectedValidationError = BaseValidationMessage<\"unexpected\">;\n\nexport type ValidationMessage =\n | TypeValidationError\n | MissingValidationError\n | UnknownValidationError\n | ValueValidationError\n | UnexpectedValidationError;\n\nexport enum ValidationSeverity {\n Error = 1,\n Warning = 2,\n Info = 3,\n Trace = 4,\n}\n","/* eslint-disable guard-for-in */\n/* eslint-disable no-restricted-syntax */\nimport type {\n NamedType,\n NodeTypeStrings,\n NodeTypeMap,\n TransformFunction,\n NodeType,\n ObjectProperty,\n RefNode,\n} from \"@player-tools/xlr\";\nimport { isGenericNamedType } from \"@player-tools/xlr-utils\";\n\ntype TypedTransformFunction<T extends NodeTypeStrings = NodeTypeStrings> = (\n input: NodeTypeMap[T]\n) => NodeTypeMap[T];\n\nexport type TransformFunctionMap = {\n [nodeType in NodeTypeStrings]?: Array<TypedTransformFunction<nodeType>>;\n};\n\nconst isMatchingCapability = (\n capability: string,\n capabilitiesToMatch: string | Array<string>\n): boolean => {\n if (Array.isArray(capabilitiesToMatch)) {\n return capabilitiesToMatch.includes(capability);\n }\n\n return capability === capabilitiesToMatch;\n};\n\nexport function xlrTransformWalker(\n transformMap: TransformFunctionMap\n): (node: NodeType) => NodeType {\n const walker = (n: NamedType | NodeType): NodeType => {\n let node = { ...n };\n const transformFunctions = transformMap[node.type] as unknown as Array<\n TypedTransformFunction<typeof node.type>\n >;\n\n for (const transformFn of transformFunctions ?? []) {\n node = transformFn(node);\n }\n\n if (node.type === \"object\") {\n const newObjectProperties: Record<string, ObjectProperty> = {};\n\n for (const key in node.properties) {\n const value = node.properties[key];\n newObjectProperties[key] = {\n required: value.required,\n node: walker(value.node),\n };\n }\n\n // need to walk generic tokens\n return {\n ...node,\n properties: { ...newObjectProperties },\n ...(isGenericNamedType(node)\n ? {\n genericTokens: node.genericTokens.map((token) => {\n return {\n ...token,\n constraints: token.constraints\n ? walker(token.constraints)\n : undefined,\n default: token.default ? walker(token.default) : undefined,\n };\n }),\n }\n : {}),\n extends: node.extends ? (walker(node.extends) as RefNode) : undefined,\n additionalProperties: node.additionalProperties\n ? walker(node.additionalProperties)\n : false,\n };\n }\n\n if (node.type === \"array\") {\n return {\n ...node,\n elementType: walker(node.elementType),\n };\n }\n\n if (node.type === \"and\") {\n return {\n ...node,\n and: node.and.map((element) => walker(element)),\n };\n }\n\n if (node.type === \"or\") {\n return {\n ...node,\n or: node.or.map((element) => walker(element)),\n };\n }\n\n if (node.type === \"ref\") {\n return {\n ...node,\n ...(node.genericArguments\n ? {\n genericArguments: node.genericArguments?.map((arg) =>\n walker(arg)\n ),\n }\n : {}),\n };\n }\n\n if (node.type === \"tuple\") {\n return {\n ...node,\n elementTypes: node.elementTypes.map((element) => {\n return {\n name: element.name,\n type: walker(element.type),\n optional: element.optional,\n };\n }),\n additionalItems: node.additionalItems\n ? walker(node.additionalItems)\n : false,\n };\n }\n\n if (node.type === \"function\") {\n return {\n ...node,\n parameters: node.parameters.map((param) => {\n return {\n ...param,\n type: walker(param.type),\n default: param.default ? walker(param.default) : undefined,\n };\n }),\n returnType: node.returnType ? walker(node.returnType) : undefined,\n };\n }\n\n if (node.type === \"record\") {\n return {\n ...node,\n keyType: walker(node.keyType),\n valueType: walker(node.valueType),\n };\n }\n\n if (node.type === \"conditional\") {\n return {\n ...node,\n check: {\n left: walker(node.check.left),\n right: walker(node.check.left),\n },\n value: {\n true: walker(node.value.true),\n false: walker(node.value.false),\n },\n };\n }\n\n return node;\n };\n\n return walker;\n}\n\n/**\n * Helper function for simple transforms\n * Walks an XLR tree looking for the specified node type calls the supplied function when called\n */\nexport function simpleTransformGenerator<\n T extends NodeTypeStrings = NodeTypeStrings\n>(\n typeToTransform: T,\n capabilityToTransform: string | Array<string>,\n functionToRun: TypedTransformFunction<T>\n): TransformFunction {\n /** walker for an XLR tree to touch every node */\n return (n: NamedType | NodeType, capability: string) => {\n // Run transform on base node before running on children\n if (isMatchingCapability(capability, capabilityToTransform)) {\n return xlrTransformWalker({ [typeToTransform]: [functionToRun] })(n);\n }\n\n return n;\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACWA,IAAAA,oBAIO;AACP,IAAAA,oBAA+B;AAE/B,4BAAyB;AACzB,gBAAe;AACf,kBAAiB;AACjB,wBAAe;;;ACfR,IAAM,mBAAN,MAA8C;AAAA,EAC3C;AAAA,EACA;AAAA,EACA;AAAA,EAER,cAAc;AACZ,SAAK,UAAU,oBAAI,IAAI;AACvB,SAAK,YA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