@player-tools/xlr-sdk 0.7.0-next.1 → 0.7.0-next.3

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.
@@ -32,7 +32,8 @@ var src_exports = {};
32
32
  __export(src_exports, {
33
33
  BasicXLRRegistry: () => BasicXLRRegistry,
34
34
  XLRSDK: () => XLRSDK,
35
- simpleTransformGenerator: () => simpleTransformGenerator
35
+ simpleTransformGenerator: () => simpleTransformGenerator,
36
+ xlrTransformWalker: () => xlrTransformWalker
36
37
  });
37
38
  module.exports = __toCommonJS(src_exports);
38
39
 
@@ -422,117 +423,124 @@ var isMatchingCapability = (capability, capabilitiesToMatch) => {
422
423
  }
423
424
  return capability === capabilitiesToMatch;
424
425
  };
425
- function simpleTransformGenerator(typeToTransform, capabilityToTransform, functionToRun) {
426
- const walker = (n, capability) => {
427
- if (isMatchingCapability(capability, capabilityToTransform)) {
428
- let node = { ...n };
429
- if (node.type === typeToTransform) {
430
- node = functionToRun(node);
431
- }
432
- if (node.type === "object") {
433
- const newObjectProperties = {};
434
- for (const key in node.properties) {
435
- const value = node.properties[key];
436
- newObjectProperties[key] = {
437
- required: value.required,
438
- node: walker(value.node, capability)
439
- };
440
- }
441
- return {
442
- ...node,
443
- properties: { ...newObjectProperties },
444
- ...(0, import_xlr_utils2.isGenericNamedType)(node) ? {
445
- genericTokens: node.genericTokens.map((token) => {
446
- return {
447
- ...token,
448
- constraints: token.constraints ? walker(token.constraints, capability) : void 0,
449
- default: token.default ? walker(token.default, capability) : void 0
450
- };
451
- })
452
- } : {},
453
- extends: node.extends ? walker(node.extends, capability) : void 0,
454
- additionalProperties: node.additionalProperties ? walker(node.additionalProperties, capability) : false
455
- };
456
- }
457
- if (node.type === "array") {
458
- return {
459
- ...node,
460
- elementType: walker(node.elementType, capability)
461
- };
462
- }
463
- if (node.type === "and") {
464
- return {
465
- ...node,
466
- and: node.and.map((element) => walker(element, capability))
467
- };
468
- }
469
- if (node.type === "or") {
470
- return {
471
- ...node,
472
- or: node.or.map((element) => walker(element, capability))
473
- };
474
- }
475
- if (node.type === "ref") {
476
- return {
477
- ...node,
478
- ...node.genericArguments ? {
479
- genericArguments: node.genericArguments?.map(
480
- (arg) => walker(arg, capability)
481
- )
482
- } : {}
483
- };
484
- }
485
- if (node.type === "tuple") {
486
- return {
487
- ...node,
488
- elementTypes: node.elementTypes.map((element) => {
489
- return {
490
- name: element.name,
491
- type: walker(element.type, capability),
492
- optional: element.optional
493
- };
494
- }),
495
- additionalItems: node.additionalItems ? walker(node.additionalItems, capability) : false
426
+ function xlrTransformWalker(transformMap) {
427
+ const walker = (n) => {
428
+ let node = { ...n };
429
+ const transformFunctions = transformMap[node.type];
430
+ for (const transformFn of transformFunctions ?? []) {
431
+ node = transformFn(node);
432
+ }
433
+ if (node.type === "object") {
434
+ const newObjectProperties = {};
435
+ for (const key in node.properties) {
436
+ const value = node.properties[key];
437
+ newObjectProperties[key] = {
438
+ required: value.required,
439
+ node: walker(value.node)
496
440
  };
497
441
  }
498
- if (node.type === "function") {
499
- return {
500
- ...node,
501
- parameters: node.parameters.map((param) => {
442
+ return {
443
+ ...node,
444
+ properties: { ...newObjectProperties },
445
+ ...(0, import_xlr_utils2.isGenericNamedType)(node) ? {
446
+ genericTokens: node.genericTokens.map((token) => {
502
447
  return {
503
- ...param,
504
- type: walker(param.type, capability),
505
- default: param.default ? walker(param.default, capability) : void 0
448
+ ...token,
449
+ constraints: token.constraints ? walker(token.constraints) : void 0,
450
+ default: token.default ? walker(token.default) : void 0
506
451
  };
507
- }),
508
- returnType: node.returnType ? walker(node.returnType, capability) : void 0
509
- };
510
- }
511
- if (node.type === "record") {
512
- return {
513
- ...node,
514
- keyType: walker(node.keyType, capability),
515
- valueType: walker(node.valueType, capability)
516
- };
517
- }
518
- if (node.type === "conditional") {
519
- return {
520
- ...node,
521
- check: {
522
- left: walker(node.check.left, capability),
523
- right: walker(node.check.left, capability)
524
- },
525
- value: {
526
- true: walker(node.value.true, capability),
527
- false: walker(node.value.false, capability)
528
- }
529
- };
530
- }
452
+ })
453
+ } : {},
454
+ extends: node.extends ? walker(node.extends) : void 0,
455
+ additionalProperties: node.additionalProperties ? walker(node.additionalProperties) : false
456
+ };
531
457
  }
532
- return n;
458
+ if (node.type === "array") {
459
+ return {
460
+ ...node,
461
+ elementType: walker(node.elementType)
462
+ };
463
+ }
464
+ if (node.type === "and") {
465
+ return {
466
+ ...node,
467
+ and: node.and.map((element) => walker(element))
468
+ };
469
+ }
470
+ if (node.type === "or") {
471
+ return {
472
+ ...node,
473
+ or: node.or.map((element) => walker(element))
474
+ };
475
+ }
476
+ if (node.type === "ref") {
477
+ return {
478
+ ...node,
479
+ ...node.genericArguments ? {
480
+ genericArguments: node.genericArguments?.map(
481
+ (arg) => walker(arg)
482
+ )
483
+ } : {}
484
+ };
485
+ }
486
+ if (node.type === "tuple") {
487
+ return {
488
+ ...node,
489
+ elementTypes: node.elementTypes.map((element) => {
490
+ return {
491
+ name: element.name,
492
+ type: walker(element.type),
493
+ optional: element.optional
494
+ };
495
+ }),
496
+ additionalItems: node.additionalItems ? walker(node.additionalItems) : false
497
+ };
498
+ }
499
+ if (node.type === "function") {
500
+ return {
501
+ ...node,
502
+ parameters: node.parameters.map((param) => {
503
+ return {
504
+ ...param,
505
+ type: walker(param.type),
506
+ default: param.default ? walker(param.default) : void 0
507
+ };
508
+ }),
509
+ returnType: node.returnType ? walker(node.returnType) : void 0
510
+ };
511
+ }
512
+ if (node.type === "record") {
513
+ return {
514
+ ...node,
515
+ keyType: walker(node.keyType),
516
+ valueType: walker(node.valueType)
517
+ };
518
+ }
519
+ if (node.type === "conditional") {
520
+ return {
521
+ ...node,
522
+ check: {
523
+ left: walker(node.check.left),
524
+ right: walker(node.check.left)
525
+ },
526
+ value: {
527
+ true: walker(node.value.true),
528
+ false: walker(node.value.false)
529
+ }
530
+ };
531
+ }
532
+ return node;
533
533
  };
534
534
  return walker;
535
535
  }
536
+ function simpleTransformGenerator(typeToTransform, capabilityToTransform, functionToRun) {
537
+ return (n, capability) => {
538
+ if (isMatchingCapability(capability, capabilityToTransform)) {
539
+ return xlrTransformWalker({ [typeToTransform]: [functionToRun] })(n);
540
+ }
541
+ return n;
542
+ };
543
+ }
536
544
 
537
545
  // ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/xlr/sdk/src/sdk.ts
538
546
  var XLRSDK = class {
@@ -652,7 +660,7 @@ var XLRSDK = class {
652
660
  if (this.computedNodeCache.has(id)) {
653
661
  return JSON.parse(JSON.stringify(this.computedNodeCache.get(id)));
654
662
  }
655
- type = (0, import_xlr_utils4.fillInGenerics)(this.resolveType(type));
663
+ type = this.resolveType(type, options?.optimize);
656
664
  this.computedNodeCache.set(id, type);
657
665
  return type;
658
666
  }
@@ -720,14 +728,13 @@ var XLRSDK = class {
720
728
  */
721
729
  exportRegistry(exportType, importMap, filters, transforms) {
722
730
  const typesToExport = this.registry.list(filters).map((type) => {
723
- const resolvedType = this.resolveType(type);
724
731
  const effectiveType = transforms?.reduce(
725
732
  (typeAccumulator, transformFn) => transformFn(
726
733
  typeAccumulator,
727
734
  this.registry.info(type.name)?.capability
728
735
  ),
729
- resolvedType
730
- ) ?? resolvedType;
736
+ type
737
+ ) ?? type;
731
738
  return effectiveType;
732
739
  });
733
740
  if (exportType === "TypeScript") {
@@ -736,45 +743,86 @@ var XLRSDK = class {
736
743
  }
737
744
  throw new Error(`Unknown export format ${exportType}`);
738
745
  }
739
- resolveType(type) {
740
- return simpleTransformGenerator("object", "any", (objectNode) => {
741
- if (objectNode.extends) {
742
- const refName = objectNode.extends.ref.split("<")[0];
743
- let extendedType = this.getType(refName, { getRawType: true });
744
- if (!extendedType) {
745
- throw new Error(
746
- `Error resolving ${objectNode.name}: can't find extended type ${refName}`
746
+ /**
747
+ * Transforms a generated XLR node into its final representation by resolving all `extends` properties.
748
+ * If `optimize` is set to true the following operations are also performed:
749
+ * - Solving any conditional types
750
+ * - Computing the effective types of any union elements
751
+ * - Resolving any ref nodes
752
+ * - filing in any remaining generics with their default value
753
+ */
754
+ resolveType(type, optimize = true) {
755
+ const resolvedObject = (0, import_xlr_utils4.fillInGenerics)(type);
756
+ let transformMap = {
757
+ object: [(objectNode) => {
758
+ if (objectNode.extends) {
759
+ const refName = objectNode.extends.ref.split("<")[0];
760
+ let extendedType = this.getType(refName, { getRawType: true });
761
+ if (!extendedType) {
762
+ throw new Error(
763
+ `Error resolving ${objectNode.name}: can't find extended type ${refName}`
764
+ );
765
+ }
766
+ extendedType = (0, import_xlr_utils3.resolveReferenceNode)(
767
+ objectNode.extends,
768
+ extendedType
747
769
  );
748
- }
749
- extendedType = (0, import_xlr_utils3.resolveReferenceNode)(
750
- objectNode.extends,
751
- extendedType
752
- );
753
- if (extendedType.type === "object") {
770
+ if (extendedType.type === "object") {
771
+ return {
772
+ ...(0, import_xlr_utils3.computeEffectiveObject)(
773
+ extendedType,
774
+ objectNode,
775
+ false
776
+ ),
777
+ name: objectNode.name,
778
+ description: objectNode.description
779
+ };
780
+ }
781
+ if (extendedType.type === "or") {
782
+ return {
783
+ ...this.validator.computeIntersectionType(
784
+ [
785
+ objectNode,
786
+ extendedType
787
+ ]
788
+ ),
789
+ name: objectNode.name,
790
+ description: objectNode.description
791
+ };
792
+ }
754
793
  return {
755
- ...(0, import_xlr_utils3.computeEffectiveObject)(
756
- extendedType,
757
- objectNode,
758
- false
759
- ),
760
794
  name: objectNode.name,
761
- description: objectNode.description
795
+ type: "and",
796
+ and: [
797
+ {
798
+ ...objectNode,
799
+ extends: void 0
800
+ },
801
+ extendedType
802
+ ]
762
803
  };
763
804
  }
764
- return {
765
- name: objectNode.name,
766
- type: "and",
767
- and: [
768
- {
769
- ...objectNode,
770
- extends: void 0
771
- },
772
- extendedType
773
- ]
774
- };
775
- }
776
- return objectNode;
777
- })(type, "any");
805
+ return objectNode;
806
+ }]
807
+ };
808
+ if (optimize) {
809
+ transformMap = {
810
+ ...transformMap,
811
+ conditional: [(node) => {
812
+ return (0, import_xlr_utils3.resolveConditional)(node);
813
+ }],
814
+ and: [(node) => {
815
+ return {
816
+ ...this.validator.computeIntersectionType(node.and),
817
+ ...node.name ? { name: node.name } : {}
818
+ };
819
+ }],
820
+ ref: [(refNode) => {
821
+ return this.validator.getRefType(refNode);
822
+ }]
823
+ };
824
+ }
825
+ return xlrTransformWalker(transformMap)(resolvedObject);
778
826
  }
779
827
  exportToTypeScript(typesToExport, importMap) {
780
828
  const referencedImports = /* @__PURE__ */ new Set();
@@ -838,6 +886,7 @@ ${nodeText}`;
838
886
  0 && (module.exports = {
839
887
  BasicXLRRegistry,
840
888
  XLRSDK,
841
- simpleTransformGenerator
889
+ simpleTransformGenerator,
890
+ xlrTransformWalker
842
891
  });
843
892
  //# sourceMappingURL=index.cjs.map
@@ -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","import 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 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 { simpleTransformGenerator } from \"./utils\";\n\nexport interface GetTypeOptions {\n /** Resolves `extends` fields in objects */\n getRawType?: 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 = fillInGenerics(this.resolveType(type)) as NamedType;\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 resolvedType = this.resolveType(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 resolvedType\n ) ?? resolvedType;\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 private resolveType(type: NodeType): NamedType {\n return simpleTransformGenerator(\"object\", \"any\", (objectNode) => {\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 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 })(type, \"any\") 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 private 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 private 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\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\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: (input: NodeTypeMap[T]) => NodeTypeMap[T]\n): TransformFunction {\n /** walker for an XLR tree to touch every node */\n const walker: TransformFunction = (\n n: NamedType | NodeType,\n capability: string\n ) => {\n // Run transform on base node before running on children\n if (isMatchingCapability(capability, capabilityToTransform)) {\n let node = { ...n };\n if (node.type === typeToTransform) {\n node = functionToRun(node as unknown as NodeTypeMap[T]);\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, capability),\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, capability)\n : undefined,\n default: token.default\n ? walker(token.default, capability)\n : undefined,\n };\n }),\n }\n : {}),\n extends: node.extends\n ? (walker(node.extends, capability) as RefNode)\n : undefined,\n additionalProperties: node.additionalProperties\n ? walker(node.additionalProperties, capability)\n : false,\n };\n }\n\n if (node.type === \"array\") {\n return {\n ...node,\n elementType: walker(node.elementType, capability),\n };\n }\n\n if (node.type === \"and\") {\n return {\n ...node,\n and: node.and.map((element) => walker(element, capability)),\n };\n }\n\n if (node.type === \"or\") {\n return {\n ...node,\n or: node.or.map((element) => walker(element, capability)),\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, capability)\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, capability),\n optional: element.optional,\n };\n }),\n additionalItems: node.additionalItems\n ? walker(node.additionalItems, capability)\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, capability),\n default: param.default\n ? walker(param.default, capability)\n : undefined,\n };\n }),\n returnType: node.returnType\n ? walker(node.returnType, capability)\n : undefined,\n };\n }\n\n if (node.type === \"record\") {\n return {\n ...node,\n keyType: walker(node.keyType, capability),\n valueType: walker(node.valueType, capability),\n };\n }\n\n if (node.type === \"conditional\") {\n return {\n ...node,\n check: {\n left: walker(node.check.left, capability),\n right: walker(node.check.left, capability),\n },\n value: {\n true: walker(node.value.true, capability),\n false: walker(node.value.false, capability),\n },\n };\n }\n }\n\n return n;\n };\n\n return walker;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACUA,IAAAA,oBAGO;AACP,IAAAA,oBAA+B;AAE/B,4BAAyB;AACzB,gBAAe;AACf,kBAAiB;AACjB,wBAAe;;;ACbR,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;AACj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,uBAAiB;AAAA,QAAQ,CAAC,gBAAgB,SACxC,cAAc,IAAI,MAAM,cAAc;AAAA,MACxC;AACA,uBAAiB;AAAA,QAAQ,CAAC,mBACxB,kBAAkB,IAAI,cAAc;AAAA,MACtC;AAAA,IACF,CAAC;AAED,UAAM,eAA8B,CAAC;AAErC,kBAAc;AAAA,MAAQ,CAAC,SACrB,aAAa;AAAA,QACX,QAAQ,UAAU,kBAAAA,QAAG,SAAS,aAAa,MAAM,UAAU;AAAA,MAC7D;AAAA,IACF;AAEA,cAAU,QAAQ,CAAC,SAAS,gBAAgB;AAC1C,YAAM,oBAAoB,QAAQ,OAAO,CAAC,MAAM,kBAAkB,IAAI,CAAC,CAAC;AACxE,mBAAa,kBAAAA,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/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,U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