@player-tools/xlr-sdk 0.10.0-next.0 → 0.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/src/__tests__/sdk.test.ts +10 -10
- package/src/registry/basic-registry.ts +1 -1
- package/src/utils.ts +6 -8
- package/src/validator.ts +19 -20
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/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,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,EACrD;AAAA,EAEA,IAAI,MAA2B,QAAgB,YAA0B;AACvE,SAAK,QAAQ,IAAI,KAAK,MAAM,IAAI;AAChC,SAAK,QAAQ,IAA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;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","ValidationSeverity","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 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","import 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,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,EACrD;AAAA,EAEA,IAAI,MAA2B,QAAgB,YAA0B;AACvE,SAAK,QAAQ,IAAI,KAAK,MAAM,IAAI;AAChC,SAAK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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","ValidationSeverity","import_xlr_utils","fs","path","ts"]}
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../../../../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":["/* 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":";AAWA;AAAA,EACE,0BAAAA;AAAA,EACA,sBAAAC;AAAA,EACA,wBAAAC;AAAA,OACK;AACP,SAAS,sBAAsB;AAE/B,SAAS,gBAAgB;AACzB,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,OAAO,QAAQ;;;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,EACrD;AAAA,EAEA,IAAI,MAA2B,QAAgB,YAA0B;AACvE,SAAK,QAAQ,IAAI,KAAK,MAAM,IAAI;AAChC,SAAK,QAAQ,IAAI,KAAK,MAAM,EAAE,Q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;AAAA,UACA,GAAG,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":["computeEffectiveObject","resolveConditional","resolveReferenceNode","ValidationSeverity","resolveReferenceNode","computeEffectiveObject","resolveConditional"]}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../../../../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":["/* 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 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","import 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":";AAWA;AAAA,EACE,0BAAAA;AAAA,EACA,sBAAAC;AAAA,EACA,wBAAAC;AAAA,OACK;AACP,SAAS,sBAAsB;AAE/B,SAAS,gBAAgB;AACzB,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,OAAO,QAAQ;;;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,EACrD;AAAA,EAEA,IAAI,MAA2B,QAAgB,YAA0B;AACvE,SAAK,QAAQ,IAAI,KAAK,MAAM,IAAI;AAChC,SAAK,QAAQ,IAAI,KAAK,MAAM,EAAE,QAAQ,WAAW,CAAC;AAElD,QAAI,CAAC,KAAK,UAAU,IAAI,MAAM,GAAG;AAC/B,WAAK,UAAU,IAAI,QAAQ,oBAAI,IAAI,CAAC;AAAA,IACtC;AAEA,UAAM,sBAAsB,KAAK,UAAU,IAAI,MAAM;AAKrD,QA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ACvC,WAAO,GAAG,UAAU;AAAA,EAAK,QAAQ;AAAA,EACnC;AACF;","names":["computeEffectiveObject","resolveConditional","resolveReferenceNode","ValidationSeverity","resolveReferenceNode","computeEffectiveObject","resolveConditional"]}
|
package/package.json
CHANGED
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
"types"
|
|
7
7
|
],
|
|
8
8
|
"name": "@player-tools/xlr-sdk",
|
|
9
|
-
"version": "0.10.
|
|
9
|
+
"version": "0.10.1",
|
|
10
10
|
"main": "dist/cjs/index.cjs",
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@player-tools/xlr": "0.10.
|
|
13
|
-
"@player-tools/xlr-utils": "0.10.
|
|
14
|
-
"@player-tools/xlr-converters": "0.10.
|
|
12
|
+
"@player-tools/xlr": "0.10.1",
|
|
13
|
+
"@player-tools/xlr-utils": "0.10.1",
|
|
14
|
+
"@player-tools/xlr-converters": "0.10.1",
|
|
15
15
|
"@types/fs-extra": "^9.0.13",
|
|
16
16
|
"@types/node": "^18.18.0",
|
|
17
17
|
"fs-extra": "^10.0.0",
|
|
@@ -33,7 +33,7 @@ describe("Loading XLRs", () => {
|
|
|
33
33
|
const sdk = new XLRSDK();
|
|
34
34
|
await sdk.loadDefinitionsFromModule(
|
|
35
35
|
ReferenceAssetsWebPluginManifest,
|
|
36
|
-
EXCLUDE
|
|
36
|
+
EXCLUDE,
|
|
37
37
|
);
|
|
38
38
|
await sdk.loadDefinitionsFromModule(Types);
|
|
39
39
|
|
|
@@ -116,7 +116,7 @@ describe("Validation", () => {
|
|
|
116
116
|
const inputAsset = sdk.getType("InputAsset", { optimize: false });
|
|
117
117
|
expect(inputAsset).toBeDefined();
|
|
118
118
|
expect(
|
|
119
|
-
sdk.validateByType(inputAsset as NamedType, mockAsset)
|
|
119
|
+
sdk.validateByType(inputAsset as NamedType, mockAsset),
|
|
120
120
|
).toMatchSnapshot();
|
|
121
121
|
});
|
|
122
122
|
|
|
@@ -140,7 +140,7 @@ describe("Validation", () => {
|
|
|
140
140
|
const inputAsset = sdk.getType("InputAsset");
|
|
141
141
|
expect(inputAsset).toBeDefined();
|
|
142
142
|
expect(
|
|
143
|
-
sdk.validateByType(inputAsset as NamedType, mockAsset)
|
|
143
|
+
sdk.validateByType(inputAsset as NamedType, mockAsset),
|
|
144
144
|
).toMatchSnapshot();
|
|
145
145
|
});
|
|
146
146
|
});
|
|
@@ -217,7 +217,7 @@ describe("Export Test", () => {
|
|
|
217
217
|
{
|
|
218
218
|
pluginFilter: "Types",
|
|
219
219
|
},
|
|
220
|
-
[transformFunction]
|
|
220
|
+
[transformFunction],
|
|
221
221
|
);
|
|
222
222
|
expect(results[0][0]).toBe("out.d.ts");
|
|
223
223
|
expect(results[0][1]).toMatchSnapshot();
|
|
@@ -258,10 +258,10 @@ describe("Or Type Validation", () => {
|
|
|
258
258
|
// Expected error and info messages
|
|
259
259
|
expect(validationResult).toHaveLength(2);
|
|
260
260
|
expect(validationResult[0].message).toBe(
|
|
261
|
-
"Does not match any of the types: string | string | string | string"
|
|
261
|
+
"Does not match any of the types: string | string | string | string",
|
|
262
262
|
);
|
|
263
263
|
expect(validationResult[1].message).toBe(
|
|
264
|
-
"Expected: apple | banana | carrot | deli-meat"
|
|
264
|
+
"Expected: apple | banana | carrot | deli-meat",
|
|
265
265
|
);
|
|
266
266
|
});
|
|
267
267
|
});
|
|
@@ -301,7 +301,7 @@ describe("generateNestedTypesInfo Test", () => {
|
|
|
301
301
|
const result = (validator as any).generateNestedTypesInfo(
|
|
302
302
|
potentialTypeErrors,
|
|
303
303
|
xlrNode,
|
|
304
|
-
rootNode
|
|
304
|
+
rootNode,
|
|
305
305
|
);
|
|
306
306
|
|
|
307
307
|
expect(result.nestedTypesList).toBe("string");
|
|
@@ -334,12 +334,12 @@ describe("generateNestedTypesInfo Test", () => {
|
|
|
334
334
|
const result = (validator as any).generateNestedTypesInfo(
|
|
335
335
|
potentialTypeErrors,
|
|
336
336
|
xlrNode,
|
|
337
|
-
rootNode
|
|
337
|
+
rootNode,
|
|
338
338
|
);
|
|
339
339
|
|
|
340
340
|
expect(result.nestedTypesList).toBe("https://example.com/mytype");
|
|
341
341
|
expect(result.infoMessage).toBe(
|
|
342
|
-
"Got: true and expected: https://example.com/mytype"
|
|
342
|
+
"Got: true and expected: https://example.com/mytype",
|
|
343
343
|
);
|
|
344
344
|
});
|
|
345
345
|
|
|
@@ -363,7 +363,7 @@ describe("generateNestedTypesInfo Test", () => {
|
|
|
363
363
|
const result = (validator as any).generateNestedTypesInfo(
|
|
364
364
|
potentialTypeErrors,
|
|
365
365
|
xlrNode,
|
|
366
|
-
rootNode
|
|
366
|
+
rootNode,
|
|
367
367
|
);
|
|
368
368
|
|
|
369
369
|
expect(result.nestedTypesList).toBe("string | number");
|
package/src/utils.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/* eslint-disable guard-for-in */
|
|
2
|
-
/* eslint-disable no-restricted-syntax */
|
|
3
1
|
import type {
|
|
4
2
|
NamedType,
|
|
5
3
|
NodeTypeStrings,
|
|
@@ -12,7 +10,7 @@ import type {
|
|
|
12
10
|
import { isGenericNamedType } from "@player-tools/xlr-utils";
|
|
13
11
|
|
|
14
12
|
type TypedTransformFunction<T extends NodeTypeStrings = NodeTypeStrings> = (
|
|
15
|
-
input: NodeTypeMap[T]
|
|
13
|
+
input: NodeTypeMap[T],
|
|
16
14
|
) => NodeTypeMap[T];
|
|
17
15
|
|
|
18
16
|
export type TransformFunctionMap = {
|
|
@@ -21,7 +19,7 @@ export type TransformFunctionMap = {
|
|
|
21
19
|
|
|
22
20
|
const isMatchingCapability = (
|
|
23
21
|
capability: string,
|
|
24
|
-
capabilitiesToMatch: string | Array<string
|
|
22
|
+
capabilitiesToMatch: string | Array<string>,
|
|
25
23
|
): boolean => {
|
|
26
24
|
if (Array.isArray(capabilitiesToMatch)) {
|
|
27
25
|
return capabilitiesToMatch.includes(capability);
|
|
@@ -31,7 +29,7 @@ const isMatchingCapability = (
|
|
|
31
29
|
};
|
|
32
30
|
|
|
33
31
|
export function xlrTransformWalker(
|
|
34
|
-
transformMap: TransformFunctionMap
|
|
32
|
+
transformMap: TransformFunctionMap,
|
|
35
33
|
): (node: NodeType) => NodeType {
|
|
36
34
|
const walker = (n: NamedType | NodeType): NodeType => {
|
|
37
35
|
let node = { ...n };
|
|
@@ -105,7 +103,7 @@ export function xlrTransformWalker(
|
|
|
105
103
|
...(node.genericArguments
|
|
106
104
|
? {
|
|
107
105
|
genericArguments: node.genericArguments?.map((arg) =>
|
|
108
|
-
walker(arg)
|
|
106
|
+
walker(arg),
|
|
109
107
|
),
|
|
110
108
|
}
|
|
111
109
|
: {}),
|
|
@@ -175,11 +173,11 @@ export function xlrTransformWalker(
|
|
|
175
173
|
* Walks an XLR tree looking for the specified node type calls the supplied function when called
|
|
176
174
|
*/
|
|
177
175
|
export function simpleTransformGenerator<
|
|
178
|
-
T extends NodeTypeStrings = NodeTypeStrings
|
|
176
|
+
T extends NodeTypeStrings = NodeTypeStrings,
|
|
179
177
|
>(
|
|
180
178
|
typeToTransform: T,
|
|
181
179
|
capabilityToTransform: string | Array<string>,
|
|
182
|
-
functionToRun: TypedTransformFunction<T
|
|
180
|
+
functionToRun: TypedTransformFunction<T>,
|
|
183
181
|
): TransformFunction {
|
|
184
182
|
/** walker for an XLR tree to touch every node */
|
|
185
183
|
return (n: NamedType | NodeType, capability: string) => {
|
package/src/validator.ts
CHANGED
|
@@ -36,7 +36,7 @@ export class XLRValidator {
|
|
|
36
36
|
|
|
37
37
|
constructor(
|
|
38
38
|
resolveType: (id: string) => NamedType<NodeType> | undefined,
|
|
39
|
-
config?: XLRValidatorConfig
|
|
39
|
+
config?: XLRValidatorConfig,
|
|
40
40
|
) {
|
|
41
41
|
this.config = config || {};
|
|
42
42
|
this.resolveType = resolveType;
|
|
@@ -46,7 +46,7 @@ export class XLRValidator {
|
|
|
46
46
|
/** Main entrypoint for validation */
|
|
47
47
|
public validateType(
|
|
48
48
|
rootNode: Node,
|
|
49
|
-
xlrNode: NodeType
|
|
49
|
+
xlrNode: NodeType,
|
|
50
50
|
): Array<ValidationMessage> {
|
|
51
51
|
const validationIssues = new Array<ValidationMessage>();
|
|
52
52
|
if (xlrNode.type === "object") {
|
|
@@ -111,7 +111,7 @@ export class XLRValidator {
|
|
|
111
111
|
const { infoMessage } = this.generateNestedTypesInfo(
|
|
112
112
|
potentialTypeErrors,
|
|
113
113
|
xlrNode,
|
|
114
|
-
rootNode
|
|
114
|
+
rootNode,
|
|
115
115
|
);
|
|
116
116
|
|
|
117
117
|
validationIssues.push({
|
|
@@ -138,10 +138,10 @@ export class XLRValidator {
|
|
|
138
138
|
} else if (xlrNode.type === "record") {
|
|
139
139
|
rootNode.children?.forEach((child) => {
|
|
140
140
|
validationIssues.push(
|
|
141
|
-
...this.validateType(child.children?.[0] as Node, xlrNode.keyType)
|
|
141
|
+
...this.validateType(child.children?.[0] as Node, xlrNode.keyType),
|
|
142
142
|
);
|
|
143
143
|
validationIssues.push(
|
|
144
|
-
...this.validateType(child.children?.[1] as Node, xlrNode.valueType)
|
|
144
|
+
...this.validateType(child.children?.[1] as Node, xlrNode.valueType),
|
|
145
145
|
);
|
|
146
146
|
});
|
|
147
147
|
} else if (xlrNode.type === "ref") {
|
|
@@ -155,7 +155,7 @@ export class XLRValidator {
|
|
|
155
155
|
});
|
|
156
156
|
} else {
|
|
157
157
|
validationIssues.push(
|
|
158
|
-
...this.validateType(rootNode, refType as NamedType)
|
|
158
|
+
...this.validateType(rootNode, refType as NamedType),
|
|
159
159
|
);
|
|
160
160
|
}
|
|
161
161
|
} else if (isPrimitiveTypeNode(xlrNode)) {
|
|
@@ -206,12 +206,12 @@ export class XLRValidator {
|
|
|
206
206
|
const resolvedConditional = resolveConditional(resolvedXLRNode);
|
|
207
207
|
if (resolvedConditional === resolvedXLRNode) {
|
|
208
208
|
throw Error(
|
|
209
|
-
`Unable to resolve conditional type at runtime: ${xlrNode.name}
|
|
209
|
+
`Unable to resolve conditional type at runtime: ${xlrNode.name}`,
|
|
210
210
|
);
|
|
211
211
|
}
|
|
212
212
|
|
|
213
213
|
validationIssues.push(
|
|
214
|
-
...this.validateType(rootNode, resolvedConditional)
|
|
214
|
+
...this.validateType(rootNode, resolvedConditional),
|
|
215
215
|
);
|
|
216
216
|
} else {
|
|
217
217
|
throw Error(`Unknown type ${xlrNode.type}`);
|
|
@@ -226,7 +226,7 @@ export class XLRValidator {
|
|
|
226
226
|
errors: Array<ValidationMessage>;
|
|
227
227
|
}>,
|
|
228
228
|
xlrNode: OrType,
|
|
229
|
-
rootNode: Node
|
|
229
|
+
rootNode: Node,
|
|
230
230
|
): { nestedTypesList: string; infoMessage?: string } {
|
|
231
231
|
const nestedTypes = new Set<string>();
|
|
232
232
|
|
|
@@ -287,7 +287,7 @@ export class XLRValidator {
|
|
|
287
287
|
|
|
288
288
|
private validateTemplate(
|
|
289
289
|
node: Node,
|
|
290
|
-
xlrNode: TemplateLiteralType
|
|
290
|
+
xlrNode: TemplateLiteralType,
|
|
291
291
|
): ValidationMessage | undefined {
|
|
292
292
|
if (node.type !== "string") {
|
|
293
293
|
return {
|
|
@@ -315,7 +315,7 @@ export class XLRValidator {
|
|
|
315
315
|
private validateArray(rootNode: Node, xlrNode: ArrayType) {
|
|
316
316
|
const issues: Array<ValidationMessage> = [];
|
|
317
317
|
rootNode.children?.forEach((child) =>
|
|
318
|
-
issues.push(...this.validateType(child, xlrNode.elementType))
|
|
318
|
+
issues.push(...this.validateType(child, xlrNode.elementType)),
|
|
319
319
|
);
|
|
320
320
|
return issues;
|
|
321
321
|
}
|
|
@@ -324,7 +324,6 @@ export class XLRValidator {
|
|
|
324
324
|
const issues: Array<ValidationMessage> = [];
|
|
325
325
|
const objectProps = makePropertyMap(node);
|
|
326
326
|
|
|
327
|
-
// eslint-disable-next-line guard-for-in, no-restricted-syntax
|
|
328
327
|
for (const prop in xlrNode.properties) {
|
|
329
328
|
const expectedType = xlrNode.properties[prop];
|
|
330
329
|
const valueNode = objectProps.get(prop);
|
|
@@ -339,21 +338,21 @@ export class XLRValidator {
|
|
|
339
338
|
|
|
340
339
|
if (valueNode) {
|
|
341
340
|
issues.push(
|
|
342
|
-
...this.validateType(valueNode, expectedType.node as NamedType)
|
|
341
|
+
...this.validateType(valueNode, expectedType.node as NamedType),
|
|
343
342
|
);
|
|
344
343
|
}
|
|
345
344
|
}
|
|
346
345
|
|
|
347
346
|
// Check if unknown keys are allowed and if they are - do the violate the constraint
|
|
348
347
|
const extraKeys = Array.from(objectProps.keys()).filter(
|
|
349
|
-
(key) => xlrNode.properties[key] === undefined
|
|
348
|
+
(key) => xlrNode.properties[key] === undefined,
|
|
350
349
|
);
|
|
351
350
|
if (xlrNode.additionalProperties === false && extraKeys.length > 0) {
|
|
352
351
|
issues.push({
|
|
353
352
|
type: "value",
|
|
354
353
|
node,
|
|
355
354
|
message: `Unexpected properties on "${xlrNode.name}": ${extraKeys.join(
|
|
356
|
-
", "
|
|
355
|
+
", ",
|
|
357
356
|
)}`,
|
|
358
357
|
severity: ValidationSeverity.Error,
|
|
359
358
|
});
|
|
@@ -362,9 +361,9 @@ export class XLRValidator {
|
|
|
362
361
|
...extraKeys.flatMap((key) =>
|
|
363
362
|
this.validateType(
|
|
364
363
|
objectProps.get(key) as Node,
|
|
365
|
-
xlrNode.additionalProperties as NodeType
|
|
366
|
-
)
|
|
367
|
-
)
|
|
364
|
+
xlrNode.additionalProperties as NodeType,
|
|
365
|
+
),
|
|
366
|
+
),
|
|
368
367
|
);
|
|
369
368
|
}
|
|
370
369
|
|
|
@@ -451,7 +450,7 @@ export class XLRValidator {
|
|
|
451
450
|
};
|
|
452
451
|
} else if (firstElement.type !== "or" && firstElement.type !== "object") {
|
|
453
452
|
throw new Error(
|
|
454
|
-
`Can't compute a union with a non-object type ${firstElement.type} (${firstElement.name})
|
|
453
|
+
`Can't compute a union with a non-object type ${firstElement.type} (${firstElement.name})`,
|
|
455
454
|
);
|
|
456
455
|
} else {
|
|
457
456
|
effectiveType = firstElement;
|
|
@@ -520,7 +519,7 @@ export class XLRValidator {
|
|
|
520
519
|
}
|
|
521
520
|
} else {
|
|
522
521
|
throw new Error(
|
|
523
|
-
`Can't compute a union with a non-object type ${typeToApply.type} (${typeToApply.name})
|
|
522
|
+
`Can't compute a union with a non-object type ${typeToApply.type} (${typeToApply.name})`,
|
|
524
523
|
);
|
|
525
524
|
}
|
|
526
525
|
});
|