@player-lang/functional-dsl-generator 0.0.2-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +2146 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/index.legacy-esm.js +2075 -0
- package/dist/index.mjs +2075 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +38 -0
- package/src/__tests__/__snapshots__/generator.test.ts.snap +886 -0
- package/src/__tests__/builder-class-generator.test.ts +627 -0
- package/src/__tests__/cli.test.ts +685 -0
- package/src/__tests__/default-value-generator.test.ts +365 -0
- package/src/__tests__/generator.test.ts +2860 -0
- package/src/__tests__/import-generator.test.ts +444 -0
- package/src/__tests__/path-utils.test.ts +174 -0
- package/src/__tests__/type-collector.test.ts +674 -0
- package/src/__tests__/type-transformer.test.ts +934 -0
- package/src/__tests__/utils.test.ts +597 -0
- package/src/builder-class-generator.ts +254 -0
- package/src/cli.ts +285 -0
- package/src/default-value-generator.ts +307 -0
- package/src/generator.ts +257 -0
- package/src/import-generator.ts +331 -0
- package/src/index.ts +38 -0
- package/src/path-utils.ts +155 -0
- package/src/ts-morph-type-finder.ts +319 -0
- package/src/type-categorizer.ts +131 -0
- package/src/type-collector.ts +296 -0
- package/src/type-resolver.ts +266 -0
- package/src/type-transformer.ts +487 -0
- package/src/utils.ts +762 -0
- package/types/builder-class-generator.d.ts +56 -0
- package/types/cli.d.ts +6 -0
- package/types/default-value-generator.d.ts +74 -0
- package/types/generator.d.ts +102 -0
- package/types/import-generator.d.ts +77 -0
- package/types/index.d.ts +12 -0
- package/types/path-utils.d.ts +65 -0
- package/types/ts-morph-type-finder.d.ts +73 -0
- package/types/type-categorizer.d.ts +46 -0
- package/types/type-collector.d.ts +62 -0
- package/types/type-resolver.d.ts +49 -0
- package/types/type-transformer.d.ts +74 -0
- package/types/utils.d.ts +205 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/generators/javascript/src/index.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/generators/javascript/src/generator.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/generators/javascript/src/utils.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/generators/javascript/src/type-collector.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/generators/javascript/src/type-transformer.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/generators/javascript/src/import-generator.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/generators/javascript/src/type-resolver.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/generators/javascript/src/ts-morph-type-finder.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/generators/javascript/src/default-value-generator.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/generators/javascript/src/builder-class-generator.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/generators/javascript/src/path-utils.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/generators/javascript/src/type-categorizer.ts"],"sourcesContent":["/**\n * @player-lang/functional-dsl-generator\n *\n * Generates functional builders from XLR types for Player-UI assets.\n */\n\nexport {\n generateFunctionalBuilder,\n generateFunctionalBuilderWithWarnings,\n type GeneratorConfig,\n type BuilderInfo,\n type GeneratorResult,\n type UnexportedTypeInfo,\n type TypeScriptContext,\n} from \"./generator\";\nexport * from \"./utils\";\nexport {\n TsMorphTypeDefinitionFinder,\n type UnexportedTypeLocation,\n} from \"./ts-morph-type-finder\";\nexport {\n createTypeScriptResolver,\n isBuiltInDeclarationPath,\n isDeclarationExported,\n type TypeResolutionResult,\n} from \"./type-resolver\";\nexport {\n isNodeModulesPath,\n extractPackageNameFromPath,\n createRelativeImportPath,\n resolveRelativeImportPath,\n} from \"./path-utils\";\nexport {\n categorizeTypes,\n groupExternalTypesByPackage,\n type TypeCategories,\n type CategorizerOptions,\n} from \"./type-categorizer\";\n","import type { ObjectType, NamedType } from \"@xlr-lib/xlr\";\nimport { isGenericNamedType } from \"@xlr-lib/xlr-utils\";\nimport {\n toFactoryName,\n toBuilderClassName,\n getAssetTypeFromExtends,\n type TypeRegistry,\n} from \"./utils\";\nimport {\n type TypeScriptContext,\n type UnexportedTypeInfo,\n} from \"./type-resolver\";\nimport { TypeCollector } from \"./type-collector\";\nimport { TypeTransformer } from \"./type-transformer\";\nimport {\n ImportGenerator,\n type ImportGeneratorConfig,\n} from \"./import-generator\";\nimport {\n BuilderClassGenerator,\n type BuilderInfo,\n} from \"./builder-class-generator\";\n\n// Re-export types for public API\nexport type { TypeScriptContext, UnexportedTypeInfo } from \"./type-resolver\";\nexport type { BuilderInfo } from \"./builder-class-generator\";\n\n/**\n * Configuration for the generator\n */\nexport interface GeneratorConfig {\n /** Import path for functional utilities (default: \"@player-lang/functional-dsl\") */\n functionalImportPath?: string;\n /** Import path for player-ui types (default: \"@player-ui/types\") */\n typesImportPath?: string;\n /**\n * TypeScript context for automatic import resolution.\n * When provided, the generator will automatically resolve import paths\n * using TypeScript's module resolution.\n */\n tsContext?: TypeScriptContext;\n /** Function to generate the type import path for a given type name */\n typeImportPathGenerator?: (typeName: string) => string;\n /**\n * Set of type names that are defined in the same source file as the main type.\n * Types not in this set will be imported from their own source files using typeImportPathGenerator.\n * When tsContext is provided, this is computed automatically from the source file.\n */\n sameFileTypes?: Set<string>;\n /**\n * Explicitly maps type names to their package names for external imports.\n * Types in this map will be imported from the specified package (e.g., \"@player-lang/types\").\n * This takes precedence over typeImportPathGenerator for the specified types.\n */\n externalTypes?: Map<string, string>;\n /**\n * Type registry for resolving nested interface references.\n * Maps type names to their XLR ObjectType definitions.\n * Used to find AssetWrapper paths in nested interfaces.\n */\n typeRegistry?: TypeRegistry;\n}\n\n/**\n * Result of builder generation including warnings\n */\nexport interface GeneratorResult {\n /** Generated TypeScript code */\n code: string;\n /** Types that need to be exported in their source files */\n unexportedTypes: UnexportedTypeInfo[];\n}\n\n/**\n * Generates functional builder TypeScript code from XLR types.\n * This class orchestrates the type collection, transformation, and code generation.\n */\nexport class FunctionalBuilderGenerator {\n private readonly namedType: NamedType<ObjectType>;\n private readonly config: GeneratorConfig;\n\n /** Import generator handles import tracking and generation */\n private readonly importGenerator: ImportGenerator;\n\n /** Type transformer handles XLR to TypeScript type conversion */\n private readonly typeTransformer: TypeTransformer;\n\n /** Type collector handles collecting type references */\n private readonly typeCollector: TypeCollector;\n\n /** Builder class generator handles class code generation */\n private readonly builderClassGenerator: BuilderClassGenerator;\n\n /** Map short type names to their full qualified names */\n private readonly namespaceMemberMap = new Map<string, string>();\n\n constructor(namedType: NamedType<ObjectType>, config: GeneratorConfig = {}) {\n this.namedType = namedType;\n this.config = config;\n\n // Create import generator config\n const importConfig: ImportGeneratorConfig = {\n functionalImportPath: config.functionalImportPath,\n typesImportPath: config.typesImportPath,\n tsContext: config.tsContext,\n typeImportPathGenerator: config.typeImportPathGenerator,\n sameFileTypes: config.sameFileTypes,\n externalTypes: config.externalTypes,\n typeRegistry: config.typeRegistry,\n };\n\n // Initialize the import generator\n this.importGenerator = new ImportGenerator(importConfig);\n\n // Initialize the type transformer with the import generator as context\n this.typeTransformer = new TypeTransformer(this.importGenerator);\n\n // Initialize the type collector with the import generator as tracker\n this.typeCollector = new TypeCollector(\n this.importGenerator,\n this.importGenerator.getGenericParamSymbols(),\n namedType.name,\n this.importGenerator.getNamespaceMemberMap(),\n config.typeRegistry,\n );\n\n // Initialize the builder class generator with the type transformer and type registry\n this.builderClassGenerator = new BuilderClassGenerator(\n this.typeTransformer,\n config.typeRegistry,\n );\n }\n\n /**\n * Get list of types that exist but need to be exported.\n * Call this after generate() to get warnings for the user.\n */\n getUnexportedTypes(): UnexportedTypeInfo[] {\n return this.importGenerator.getUnexportedTypes();\n }\n\n /**\n * Get list of types that couldn't be resolved at all.\n * These types are used in the generated code but won't be imported,\n * causing type errors. Often these are namespaced types (e.g., Validation.CrossfieldReference).\n */\n getUnresolvedTypes(): string[] {\n return this.importGenerator.getUnresolvedTypes();\n }\n\n /**\n * Generate the builder code\n */\n generate(): string {\n // Collect generic parameter symbols first so we can exclude them from imports\n // This MUST happen before createBuilderInfo since transformTypeForConstraint needs it\n this.typeCollector.collectGenericParamSymbols(this.namedType);\n\n const mainBuilder = this.createBuilderInfo(this.namedType);\n\n // Collect types from generic constraints/defaults for import generation\n this.typeCollector.collectTypesFromGenericTokens(this.namedType);\n\n // Collect all referenced types for imports (no nested builders are generated)\n this.typeCollector.collectReferencedTypes(this.namedType);\n\n // Generate main builder class (this also sets needsAssetImport flag)\n const mainBuilderCode =\n this.builderClassGenerator.generateBuilderClass(mainBuilder);\n\n // Generate imports after builder code so we know what imports are needed\n const imports = this.importGenerator.generateImports(mainBuilder.name);\n\n return [imports, mainBuilderCode].filter(Boolean).join(\"\\n\\n\");\n }\n\n private createBuilderInfo(namedType: NamedType<ObjectType>): BuilderInfo {\n const assetType = getAssetTypeFromExtends(namedType);\n const isAsset = !!assetType;\n\n let genericParams: string | undefined;\n if (isGenericNamedType(namedType)) {\n // Deduplicate generic parameters by symbol name\n // This handles cases where a type extends another generic type without\n // passing type arguments, causing XLR to collect parameters from both\n const seenParams = new Set<string>();\n genericParams = namedType.genericTokens\n .filter((t) => {\n if (seenParams.has(t.symbol)) {\n return false;\n }\n seenParams.add(t.symbol);\n return true;\n })\n .map((t) => {\n let param = t.symbol;\n if (t.constraints) {\n const constraintType =\n this.typeTransformer.transformTypeForConstraint(t.constraints);\n // Skip 'any' constraints - these represent unconstrained generics in TypeScript\n // Adding \"extends any\" is redundant and reduces type safety\n if (constraintType !== \"any\") {\n param += ` extends ${constraintType}`;\n }\n }\n if (t.default) {\n param += ` = ${this.typeTransformer.transformTypeForConstraint(t.default)}`;\n }\n return param;\n })\n .join(\", \");\n }\n\n return {\n name: namedType.name,\n className: toBuilderClassName(namedType.name),\n factoryName: toFactoryName(namedType.name),\n objectType: namedType,\n assetType,\n genericParams,\n isAsset,\n };\n }\n}\n\n/**\n * Generate functional builder code from a NamedType<ObjectType>\n * @param namedType - The XLR NamedType to generate a builder for\n * @param config - Optional generator configuration\n * @returns Generated TypeScript code for the functional builder\n */\nexport function generateFunctionalBuilder(\n namedType: NamedType<ObjectType>,\n config: GeneratorConfig = {},\n): string {\n const generator = new FunctionalBuilderGenerator(namedType, config);\n return generator.generate();\n}\n\n/**\n * Generate functional builder code with warnings about unexported types.\n * Use this when you want to get detailed information about types that need\n * to be exported in their source files.\n *\n * @param namedType - The XLR NamedType to generate a builder for\n * @param config - Optional generator configuration\n * @returns Generated code and list of types that need to be exported\n */\nexport function generateFunctionalBuilderWithWarnings(\n namedType: NamedType<ObjectType>,\n config: GeneratorConfig = {},\n): GeneratorResult {\n const generator = new FunctionalBuilderGenerator(namedType, config);\n const code = generator.generate();\n const unexportedTypes = generator.getUnexportedTypes();\n return { code, unexportedTypes };\n}\n","import type {\n NodeType,\n ObjectType,\n ArrayType,\n StringType,\n NumberType,\n BooleanType,\n TupleType,\n RefType,\n} from \"@xlr-lib/xlr\";\n\nimport {\n isStringType,\n isNumberType,\n isBooleanType,\n isObjectType,\n isArrayType,\n isRefType,\n isOrType,\n isAndType,\n isRecordType,\n isNamedType,\n} from \"@xlr-lib/xlr-utils\";\n\n// Re-export type guards from xlr-utils for consumers\nexport {\n isStringType,\n isNumberType,\n isBooleanType,\n isObjectType,\n isArrayType,\n isRefType,\n isOrType,\n isAndType,\n isRecordType,\n isNamedType,\n};\n\n/**\n * Type guard for tuple type nodes\n */\nexport function isTupleType(node: NodeType): node is TupleType {\n return node.type === \"tuple\";\n}\n\n/**\n * Check if a primitive type has a const value (literal type)\n */\nexport function isPrimitiveConst(\n node: NodeType,\n): node is (StringType | NumberType | BooleanType) & { const: unknown } {\n return (\n (isStringType(node) || isNumberType(node) || isBooleanType(node)) &&\n \"const\" in node &&\n node.const !== undefined\n );\n}\n\n/**\n * Check if a ref type is an AssetWrapper\n */\nexport function isAssetWrapperRef(node: NodeType): boolean {\n return isRefType(node) && node.ref.startsWith(\"AssetWrapper\");\n}\n\n/**\n * Check if a NodeType resolves to a type that extends AssetWrapper.\n * Handles:\n * - RefType nodes resolved via type registry\n * - Inline ObjectType nodes with an `extends` field\n * - Transitive chains: e.g., ListItem → ListItemBase → AssetWrapper\n * Uses cycle detection to prevent infinite recursion on circular type hierarchies.\n *\n * @param node - The node to check\n * @param typeRegistry - Map of type names to their ObjectType definitions\n * @param visited - Set of already-visited type names for cycle detection\n * @returns true if the node resolves to a type extending AssetWrapper\n */\nexport function extendsAssetWrapper(\n node: NodeType,\n typeRegistry: TypeRegistry,\n visited: Set<string> = new Set(),\n): boolean {\n // Inline ObjectType with extends field (XLR inlines types in many positions)\n if (isObjectType(node) && node.extends) {\n if (node.extends.ref.startsWith(\"AssetWrapper\")) return true;\n return extendsAssetWrapper(node.extends, typeRegistry, visited);\n }\n\n // RefType - look up in registry\n if (isRefType(node)) {\n const typeName = extractBaseName(node.ref);\n if (visited.has(typeName)) return false;\n visited.add(typeName);\n\n const resolved = typeRegistry.get(typeName);\n if (!resolved?.extends) return false;\n\n if (resolved.extends.ref.startsWith(\"AssetWrapper\")) return true;\n return extendsAssetWrapper(resolved.extends, typeRegistry, visited);\n }\n\n return false;\n}\n\n/**\n * Get the AssetWrapper ancestor's RefType for a node that extends AssetWrapper.\n * Handles both inline ObjectTypes and RefType lookups via registry.\n * This allows extracting the generic argument (e.g., ImageAsset from AssetWrapper<ImageAsset>).\n *\n * @param node - The node to inspect\n * @param typeRegistry - Map of type names to their ObjectType definitions\n * @param visited - Set of already-visited type names for cycle detection\n * @returns The RefType of the AssetWrapper ancestor, or undefined if not found\n */\nexport function getAssetWrapperExtendsRef(\n node: NodeType,\n typeRegistry: TypeRegistry,\n visited: Set<string> = new Set(),\n): RefType | undefined {\n // Inline ObjectType with extends field\n if (isObjectType(node) && node.extends) {\n if (node.extends.ref.startsWith(\"AssetWrapper\")) return node.extends;\n return getAssetWrapperExtendsRef(node.extends, typeRegistry, visited);\n }\n\n // RefType - look up in registry\n if (isRefType(node)) {\n const typeName = extractBaseName(node.ref);\n if (visited.has(typeName)) return undefined;\n visited.add(typeName);\n\n const resolved = typeRegistry.get(typeName);\n if (!resolved?.extends) return undefined;\n\n if (resolved.extends.ref.startsWith(\"AssetWrapper\"))\n return resolved.extends;\n return getAssetWrapperExtendsRef(resolved.extends, typeRegistry, visited);\n }\n\n return undefined;\n}\n\n/**\n * Look up the AssetWrapper ancestor's RefType by type name via the registry.\n * Convenience wrapper around getAssetWrapperExtendsRef for name-based lookups.\n */\nexport function getAssetWrapperExtendsRefByName(\n typeName: string,\n typeRegistry: TypeRegistry,\n): RefType | undefined {\n return getAssetWrapperExtendsRef(\n { type: \"ref\", ref: typeName } as RefType,\n typeRegistry,\n );\n}\n\n/**\n * Check if a ref type is an Expression\n */\nexport function isExpressionRef(node: NodeType): boolean {\n return isRefType(node) && node.ref === \"Expression\";\n}\n\n/**\n * Check if a ref type is a Binding\n */\nexport function isBindingRef(node: NodeType): boolean {\n return isRefType(node) && node.ref === \"Binding\";\n}\n\n/**\n * Sanitize a property name by removing surrounding quotes.\n * TypeScript allows quoted property names like \"mime-type\" which may\n * end up in XLR with quotes preserved.\n *\n * @example\n * sanitizePropertyName(\"'mime-type'\") // \"mime-type\"\n * sanitizePropertyName('\"content-type\"') // \"content-type\"\n * sanitizePropertyName(\"normalProp\") // \"normalProp\"\n */\nexport function sanitizePropertyName(name: string): string {\n return name.replace(/^['\"]|['\"]$/g, \"\");\n}\n\n/**\n * Convert a property name to PascalCase for method names.\n * Handles camelCase, kebab-case, snake_case inputs, and quoted property names.\n *\n * @example\n * toPascalCase(\"myProperty\") // \"MyProperty\"\n * toPascalCase(\"my-property\") // \"MyProperty\"\n * toPascalCase(\"my_property\") // \"MyProperty\"\n * toPascalCase(\"'mime-type'\") // \"MimeType\"\n */\nexport function toPascalCase(str: string): string {\n // First sanitize any quotes that may have been preserved from TypeScript source\n const sanitized = sanitizePropertyName(str);\n\n return sanitized\n .split(/[-_]/)\n .map((part) => part.charAt(0).toUpperCase() + part.slice(1))\n .join(\"\");\n}\n\n/**\n * Convert a type name to a factory function name (camelCase)\n */\nexport function toFactoryName(typeName: string): string {\n // Remove \"Asset\" suffix if present\n const name = typeName.replace(/Asset$/, \"\");\n return name.charAt(0).toLowerCase() + name.slice(1);\n}\n\n/**\n * Convert a type name to a builder class name\n */\nexport function toBuilderClassName(typeName: string): string {\n return `${typeName}Builder`;\n}\n\n/**\n * Check if an object type is complex enough to warrant its own builder class\n */\nexport function isComplexObjectType(obj: ObjectType): boolean {\n const props = Object.values(obj.properties);\n\n // Has AssetWrapper properties\n const hasSlots = props.some((p) => isAssetWrapperRef(p.node));\n if (hasSlots) return true;\n\n // Has many properties\n if (props.length > 3) return true;\n\n // Has nested objects\n const hasNestedObjects = props.some(\n (p) => isObjectType(p.node) && !isPrimitiveConst(p.node),\n );\n if (hasNestedObjects) return true;\n\n return false;\n}\n\n/**\n * Get the asset type string from extends ref\n */\nexport function getAssetTypeFromExtends(obj: ObjectType): string | undefined {\n if (!obj.extends) return undefined;\n\n const ref = obj.extends;\n if (ref.genericArguments && ref.genericArguments.length > 0) {\n const typeArg = ref.genericArguments[0];\n if (isStringType(typeArg) && typeArg.const) {\n return typeArg.const;\n }\n }\n return undefined;\n}\n\n/**\n * Information about a property for code generation\n */\nexport interface PropertyInfo {\n name: string;\n node: NodeType;\n required: boolean;\n isSlot: boolean;\n isArraySlot: boolean;\n isArray: boolean;\n}\n\n/**\n * Extract property information from an ObjectType\n */\nexport function getPropertiesInfo(obj: ObjectType): PropertyInfo[] {\n return Object.entries(obj.properties).map(([name, prop]) => {\n const isSlot = isAssetWrapperRef(prop.node);\n const isArray = isArrayType(prop.node);\n const isArraySlot =\n isArray && isAssetWrapperRef((prop.node as ArrayType).elementType);\n\n return {\n name,\n node: prop.node,\n required: prop.required,\n isSlot,\n isArraySlot,\n isArray,\n };\n });\n}\n\n/**\n * Check if a type contains an array type (directly or within a union/intersection)\n * This handles cases like `Array<T> | T` where the property can be either\n */\nexport function containsArrayType(node: NodeType): boolean {\n if (isArrayType(node)) {\n return true;\n }\n\n if (isOrType(node)) {\n return node.or.some(containsArrayType);\n }\n\n if (isAndType(node)) {\n return node.and.some(containsArrayType);\n }\n\n return false;\n}\n\n/**\n * Split a string by commas, but only at the top level (ignoring commas inside angle brackets).\n * This is needed for parsing generic parameter lists like \"T extends Foo<A, B>, U = Bar<C, D>\"\n *\n * @example\n * splitAtTopLevelCommas(\"T extends Foo, U = Bar\") // [\"T extends Foo\", \"U = Bar\"]\n * splitAtTopLevelCommas(\"T extends Foo<A, B>, U\") // [\"T extends Foo<A, B>\", \"U\"]\n */\nexport function splitAtTopLevelCommas(str: string): string[] {\n const result: string[] = [];\n let current = \"\";\n let depth = 0;\n\n for (const char of str) {\n if (char === \"<\") {\n depth++;\n current += char;\n } else if (char === \">\") {\n depth--;\n current += char;\n } else if (char === \",\" && depth === 0) {\n result.push(current.trim());\n current = \"\";\n } else {\n current += char;\n }\n }\n\n if (current.trim()) {\n result.push(current.trim());\n }\n\n return result;\n}\n\n/**\n * Extract generic usage string from generic params declaration\n * Converts \"T extends Foo, U = Bar\" to \"<T, U>\"\n * Handles nested generics like \"T extends Foo<A, B>, U = Bar<C, D>\" correctly\n */\nexport function extractGenericUsage(genericParams: string | undefined): string {\n if (!genericParams) {\n return \"\";\n }\n\n const params = splitAtTopLevelCommas(genericParams)\n .map((p) => p.trim().split(\" \")[0])\n .join(\", \");\n\n return `<${params}>`;\n}\n\n/**\n * Set of TypeScript built-in types that should never be imported.\n * These are either global types or utility types provided by TypeScript.\n */\nexport const TYPESCRIPT_BUILTINS = new Set([\n // Primitive wrappers\n \"String\",\n \"Number\",\n \"Boolean\",\n \"Symbol\",\n \"BigInt\",\n\n // Collections\n \"Array\",\n \"Map\",\n \"Set\",\n \"WeakMap\",\n \"WeakSet\",\n \"ReadonlyArray\",\n \"ReadonlyMap\",\n \"ReadonlySet\",\n\n // Object types\n \"Object\",\n \"Function\",\n \"Date\",\n \"RegExp\",\n \"Error\",\n \"Promise\",\n \"PromiseLike\",\n\n // Utility types\n \"Partial\",\n \"Required\",\n \"Readonly\",\n \"Pick\",\n \"Omit\",\n \"Exclude\",\n \"Extract\",\n \"NonNullable\",\n \"Parameters\",\n \"ConstructorParameters\",\n \"ReturnType\",\n \"InstanceType\",\n \"ThisParameterType\",\n \"OmitThisParameter\",\n \"ThisType\",\n \"Awaited\",\n \"Record\",\n\n // Iterable types\n \"Iterable\",\n \"Iterator\",\n \"IterableIterator\",\n \"Generator\",\n \"AsyncIterator\",\n \"AsyncIterable\",\n \"AsyncIterableIterator\",\n \"AsyncGenerator\",\n \"GeneratorFunction\",\n \"AsyncGeneratorFunction\",\n\n // Array-like types\n \"ArrayLike\",\n \"ArrayBuffer\",\n \"SharedArrayBuffer\",\n \"DataView\",\n \"TypedArray\",\n \"Int8Array\",\n \"Uint8Array\",\n \"Uint8ClampedArray\",\n \"Int16Array\",\n \"Uint16Array\",\n \"Int32Array\",\n \"Uint32Array\",\n \"Float32Array\",\n \"Float64Array\",\n \"BigInt64Array\",\n \"BigUint64Array\",\n\n // Other built-ins\n \"JSON\",\n \"Math\",\n \"Console\",\n \"Proxy\",\n \"Reflect\",\n \"WeakRef\",\n \"FinalizationRegistry\",\n]);\n\n/**\n * Set of Player-specific built-in types that have special handling\n * and should not be imported as regular types.\n */\nexport const PLAYER_BUILTINS = new Set([\n \"Asset\",\n \"AssetWrapper\",\n \"Binding\",\n \"Expression\",\n]);\n\n/**\n * Check if a type name is a built-in type (TypeScript or Player-specific)\n * that should not be imported.\n */\nexport function isBuiltinType(typeName: string): boolean {\n return TYPESCRIPT_BUILTINS.has(typeName) || PLAYER_BUILTINS.has(typeName);\n}\n\n/**\n * Extracts the base type name from a ref string, handling nested generics.\n * @example\n * extractBaseName(\"MyType\") // \"MyType\"\n * extractBaseName(\"MyType<T>\") // \"MyType\"\n * extractBaseName(\"Map<string, Array<T>>\") // \"Map\"\n */\nexport function extractBaseName(ref: string): string {\n const bracketIndex = ref.indexOf(\"<\");\n return bracketIndex === -1 ? ref : ref.substring(0, bracketIndex);\n}\n\n/**\n * Checks if a type name is a namespaced type (e.g., \"Validation.CrossfieldReference\").\n * Returns the namespace and member name if it is, null otherwise.\n */\nexport function parseNamespacedType(\n typeName: string,\n): { namespace: string; member: string } | null {\n const dotIndex = typeName.indexOf(\".\");\n if (dotIndex === -1) return null;\n return {\n namespace: typeName.substring(0, dotIndex),\n member: typeName.substring(dotIndex + 1),\n };\n}\n\n/**\n * Type registry for resolving named type references.\n *\n * This map stores XLR ObjectType definitions keyed by their type name.\n * It's used by `findAssetWrapperPaths` to resolve references to named\n * interface types when searching for nested AssetWrapper properties.\n *\n * Example usage:\n * ```typescript\n * const registry: TypeRegistry = new Map([\n * [\"ContentCardHeader\", headerObjectType],\n * [\"SlotConfig\", slotConfigObjectType],\n * ]);\n *\n * // Now findAssetWrapperPaths can resolve ContentCardHeader references\n * const paths = findAssetWrapperPaths(contentCardType, registry);\n * ```\n *\n * Types should be registered when:\n * - They are referenced by other types in the codebase\n * - They contain AssetWrapper properties that need to be discovered\n * - They are part of a nested type hierarchy\n */\nexport type TypeRegistry = Map<string, ObjectType>;\n\n/**\n * Context for AssetWrapper path finding\n */\ninterface PathFindingContext {\n typeRegistry: TypeRegistry;\n visited: Set<string>;\n currentPath: string[];\n}\n\n/**\n * Finds all paths to AssetWrapper properties within a type, including nested interfaces.\n *\n * This function recursively traverses the type tree to find all property paths\n * that lead to AssetWrapper fields. It supports:\n * - Direct AssetWrapper properties\n * - Named interface references resolved via type registry\n * - Arbitrary nesting depth\n * - Cycle detection for recursive types\n *\n * @param node - The type node to search\n * @param typeRegistry - Map of type names to their ObjectType definitions\n * @returns Array of paths, where each path is an array of property names\n *\n * @example\n * // For a type like:\n * // interface ContentCard { header: ContentCardHeader }\n * // interface ContentCardHeader { left: AssetWrapper }\n * // Returns: [[\"header\", \"left\"]]\n */\nexport function findAssetWrapperPaths(\n node: NodeType,\n typeRegistry: TypeRegistry,\n): string[][] {\n const context: PathFindingContext = {\n typeRegistry,\n visited: new Set(),\n currentPath: [],\n };\n\n return findPathsRecursive(node, context);\n}\n\n/**\n * Recursively finds AssetWrapper paths within a node\n */\nfunction findPathsRecursive(\n node: NodeType,\n context: PathFindingContext,\n): string[][] {\n const paths: string[][] = [];\n\n // Handle object types with properties\n if (isObjectType(node)) {\n // Check if this is a named type we need to track for cycle detection\n if (isNamedType(node)) {\n if (context.visited.has(node.name)) {\n return [];\n }\n context.visited.add(node.name);\n }\n\n // Process each property\n for (const [propName, prop] of Object.entries(node.properties)) {\n const propPaths = findPathsForProperty(propName, prop.node, context);\n paths.push(...propPaths);\n }\n\n // Clean up visited for named types\n if (isNamedType(node)) {\n context.visited.delete(node.name);\n }\n }\n\n return paths;\n}\n\n/**\n * Recurse into a type node to find nested AssetWrapper paths.\n * Handles both inline ObjectTypes (recurse directly) and RefTypes (resolve from registry).\n * Used for AssetWrapper-extending types and array element types.\n */\nfunction recurseIntoExtendingType(\n targetNode: NodeType,\n context: PathFindingContext,\n propName: string,\n): string[][] {\n const newContext = {\n ...context,\n currentPath: [...context.currentPath, propName],\n };\n if (isObjectType(targetNode)) {\n return findPathsRecursive(targetNode, newContext);\n }\n if (isRefType(targetNode)) {\n const typeName = extractBaseName(targetNode.ref);\n const resolvedType = context.typeRegistry.get(typeName);\n if (resolvedType && !context.visited.has(typeName)) {\n context.visited.add(typeName);\n const nestedPaths = findPathsRecursive(resolvedType, newContext);\n context.visited.delete(typeName);\n return nestedPaths;\n }\n }\n return [];\n}\n\n/**\n * Finds AssetWrapper paths for a specific property.\n *\n * Design decision: The `visited` set is intentionally shared across recursive calls\n * for cycle detection. When processing union/intersection types, we spread the context\n * but keep the same `visited` reference. This ensures that if TypeA -> TypeB -> TypeA,\n * the cycle is detected regardless of which branch we came from. This prevents\n * infinite recursion in complex type hierarchies with circular references.\n */\nfunction findPathsForProperty(\n propName: string,\n node: NodeType,\n context: PathFindingContext,\n): string[][] {\n const paths: string[][] = [];\n\n // Direct AssetWrapper property\n if (isAssetWrapperRef(node)) {\n paths.push([...context.currentPath, propName]);\n return paths;\n }\n\n // Array of AssetWrappers\n if (isArrayType(node) && isAssetWrapperRef(node.elementType)) {\n paths.push([...context.currentPath, propName]);\n return paths;\n }\n\n // Type (ref or inline object) that extends AssetWrapper\n // e.g., Header extends AssetWrapper<AnyAsset>\n if (\n extendsAssetWrapper(node, context.typeRegistry, new Set(context.visited))\n ) {\n paths.push([...context.currentPath, propName]);\n paths.push(...recurseIntoExtendingType(node, context, propName));\n return paths;\n }\n\n // Array where element type extends AssetWrapper\n if (\n isArrayType(node) &&\n extendsAssetWrapper(\n node.elementType,\n context.typeRegistry,\n new Set(context.visited),\n )\n ) {\n paths.push([...context.currentPath, propName]);\n paths.push(\n ...recurseIntoExtendingType(node.elementType, context, propName),\n );\n return paths;\n }\n\n // Array with complex element type — recurse into element type to find nested\n // AssetWrapper paths (e.g., Array<StaticFilter> where StaticFilter contains\n // label: AssetWrapper and value: AssetWrapper)\n if (isArrayType(node)) {\n paths.push(\n ...recurseIntoExtendingType(node.elementType, context, propName),\n );\n return paths;\n }\n\n // Named reference - look up in type registry\n if (isRefType(node)) {\n const typeName = extractBaseName(node.ref);\n const resolvedType = context.typeRegistry.get(typeName);\n\n if (resolvedType && !context.visited.has(typeName)) {\n context.visited.add(typeName);\n const newContext = {\n ...context,\n currentPath: [...context.currentPath, propName],\n };\n const nestedPaths = findPathsRecursive(resolvedType, newContext);\n paths.push(...nestedPaths);\n context.visited.delete(typeName);\n }\n return paths;\n }\n\n // Nested object type (inline)\n if (isObjectType(node)) {\n const newContext = {\n ...context,\n currentPath: [...context.currentPath, propName],\n };\n const nestedPaths = findPathsRecursive(node, newContext);\n paths.push(...nestedPaths);\n return paths;\n }\n\n // Union types - check all variants\n if (isOrType(node)) {\n for (const variant of node.or) {\n const variantPaths = findPathsForProperty(propName, variant, {\n ...context,\n currentPath: context.currentPath,\n });\n // Only add unique paths\n for (const path of variantPaths) {\n const pathStr = path.join(\".\");\n if (!paths.some((p) => p.join(\".\") === pathStr)) {\n paths.push(path);\n }\n }\n }\n return paths;\n }\n\n // Intersection types - check all parts\n if (isAndType(node)) {\n for (const part of node.and) {\n const partPaths = findPathsForProperty(propName, part, {\n ...context,\n currentPath: context.currentPath,\n });\n // Only add unique paths\n for (const path of partPaths) {\n const pathStr = path.join(\".\");\n if (!paths.some((p) => p.join(\".\") === pathStr)) {\n paths.push(path);\n }\n }\n }\n return paths;\n }\n\n return paths;\n}\n","import type { NodeType, ObjectType, NamedType } from \"@xlr-lib/xlr\";\nimport { isGenericNamedType } from \"@xlr-lib/xlr-utils\";\nimport {\n isObjectType,\n isArrayType,\n isRefType,\n isOrType,\n isAndType,\n isNamedType,\n isBuiltinType,\n extractBaseName,\n parseNamespacedType,\n type TypeRegistry,\n} from \"./utils\";\n\n/**\n * Interface for tracking type references.\n * Implemented by the import generator to track types that need to be imported.\n */\nexport interface TypeTracker {\n trackReferencedType(typeName: string): void;\n trackNamespaceImport(namespaceName: string): void;\n}\n\n/**\n * Collects type references from XLR types for import generation.\n */\nexport class TypeCollector {\n private readonly typeTracker: TypeTracker;\n private readonly genericParamSymbols: Set<string>;\n private readonly mainTypeName: string;\n private readonly namespaceMemberMap: Map<string, string>;\n private readonly typeRegistry?: TypeRegistry;\n\n constructor(\n typeTracker: TypeTracker,\n genericParamSymbols: Set<string>,\n mainTypeName: string,\n namespaceMemberMap: Map<string, string>,\n typeRegistry?: TypeRegistry,\n ) {\n this.typeTracker = typeTracker;\n this.genericParamSymbols = genericParamSymbols;\n this.mainTypeName = mainTypeName;\n this.namespaceMemberMap = namespaceMemberMap;\n this.typeRegistry = typeRegistry;\n }\n\n /**\n * Collect generic parameter symbols (e.g., T, U) from the type definition.\n * These should not be imported as they are type parameters, not concrete types.\n *\n * Also handles the case where a non-generic type extends a generic base without\n * passing type arguments. In that scenario, XLR copies properties from the base\n * (including references to the base's generic params like `AnyAsset`) but does\n * NOT propagate `genericTokens` to the child type. We scan the type registry for\n * generic parameter symbols that should be excluded from imports.\n */\n collectGenericParamSymbols(namedType: NamedType<ObjectType>): void {\n if (isGenericNamedType(namedType)) {\n for (const token of namedType.genericTokens) {\n this.genericParamSymbols.add(token.symbol);\n }\n }\n\n // Scan the type registry for generic parameter symbols from other types.\n // When XLR copies properties from a generic base without resolving generics,\n // the property types still reference the base's generic parameter names\n // (e.g., `AnyAsset` from `FileInputAssetBase<AnyAsset>`). These names are\n // not concrete types and should not be imported. We collect them from all\n // registry types, excluding any that are themselves registered as concrete types.\n if (this.typeRegistry) {\n for (const registeredType of this.typeRegistry.values()) {\n if (isGenericNamedType(registeredType)) {\n for (const token of registeredType.genericTokens) {\n if (!this.typeRegistry.has(token.symbol)) {\n this.genericParamSymbols.add(token.symbol);\n }\n }\n }\n }\n }\n }\n\n /**\n * Collect type references from generic parameter constraints and defaults.\n * This ensures types used in generics like \"T extends Foo = Bar<X>\" have\n * Foo, Bar, and X added to referencedTypes for import generation.\n */\n collectTypesFromGenericTokens(namedType: NamedType<ObjectType>): void {\n if (!isGenericNamedType(namedType)) {\n return;\n }\n\n for (const token of namedType.genericTokens) {\n if (token.constraints) {\n this.collectTypeReferencesFromNode(token.constraints);\n }\n\n if (token.default) {\n this.collectTypeReferencesFromNode(token.default);\n }\n }\n }\n\n /**\n * Collect all referenced types from an object type for imports.\n */\n collectReferencedTypes(objType: ObjectType): void {\n for (const prop of Object.values(objType.properties)) {\n this.collectReferencedTypesFromNode(prop.node);\n }\n }\n\n /**\n * Collect referenced types from a node type.\n */\n collectReferencedTypesFromNode(node: NodeType): void {\n if (isObjectType(node)) {\n if (isNamedType(node)) {\n // Named types are defined elsewhere - track for import\n // Skip built-in types and the type being generated\n if (\n node.name !== this.mainTypeName &&\n !isBuiltinType(node.name) &&\n !this.genericParamSymbols.has(node.name)\n ) {\n this.typeTracker.trackReferencedType(node.name);\n }\n } else {\n // Anonymous object - recurse into properties to collect type references\n for (const prop of Object.values(node.properties)) {\n this.collectReferencedTypesFromNode(prop.node);\n }\n }\n } else if (isArrayType(node)) {\n this.collectReferencedTypesFromNode(node.elementType);\n } else if (isOrType(node)) {\n for (const variant of node.or) {\n this.collectReferencedTypesFromNode(variant);\n }\n } else if (isAndType(node)) {\n for (const part of node.and) {\n this.collectReferencedTypesFromNode(part);\n }\n } else if (isRefType(node)) {\n const baseName = extractBaseName(node.ref);\n\n // Check if this is a namespaced type (e.g., \"Validation.CrossfieldReference\")\n const namespaced = parseNamespacedType(baseName);\n if (namespaced) {\n // Track the namespace for import and the member mapping\n this.typeTracker.trackNamespaceImport(namespaced.namespace);\n this.namespaceMemberMap.set(namespaced.member, baseName);\n } else {\n // Track reference types that aren't built-in or generic params\n if (\n !isBuiltinType(baseName) &&\n !this.genericParamSymbols.has(baseName)\n ) {\n this.typeTracker.trackReferencedType(baseName);\n }\n }\n\n // Also process generic arguments, but skip type parameters of the referenced type\n if (node.genericArguments) {\n for (const arg of node.genericArguments) {\n // Skip if this argument appears to be a type parameter of the referenced type\n // e.g., in ref=\"Bar<AnyAsset>\", skip \"AnyAsset\" since it's Bar's type param\n if (isRefType(arg)) {\n const argName = extractBaseName(arg.ref);\n if (this.isTypeParamOfRef(argName, node.ref)) {\n continue;\n }\n }\n this.collectReferencedTypesFromNode(arg);\n }\n }\n }\n }\n\n /**\n * Recursively collect type references from any NodeType.\n * This handles refs, arrays, unions, intersections, and objects.\n */\n private collectTypeReferencesFromNode(node: NodeType): void {\n if (isRefType(node)) {\n const baseName = extractBaseName(node.ref);\n\n // Check if this is a namespaced type (e.g., \"Validation.CrossfieldReference\")\n const namespaced = parseNamespacedType(baseName);\n if (namespaced) {\n // Track the namespace for import and the member mapping\n this.typeTracker.trackNamespaceImport(namespaced.namespace);\n this.namespaceMemberMap.set(namespaced.member, baseName);\n } else if (\n !isBuiltinType(baseName) &&\n !this.genericParamSymbols.has(baseName)\n ) {\n // Skip built-in types and generic param symbols\n this.typeTracker.trackReferencedType(baseName);\n }\n\n // Also process generic arguments, but skip type parameters of the referenced type\n if (node.genericArguments) {\n for (const arg of node.genericArguments) {\n // Skip if this argument appears to be a type parameter of the referenced type\n // e.g., in ref=\"Bar<AnyAsset>\", skip \"AnyAsset\" since it's Bar's type param\n if (isRefType(arg)) {\n const argName = extractBaseName(arg.ref);\n if (this.isTypeParamOfRef(argName, node.ref)) {\n continue;\n }\n }\n this.collectTypeReferencesFromNode(arg);\n }\n }\n } else if (isArrayType(node)) {\n this.collectTypeReferencesFromNode(node.elementType);\n } else if (isOrType(node)) {\n for (const variant of node.or) {\n this.collectTypeReferencesFromNode(variant);\n }\n } else if (isAndType(node)) {\n for (const part of node.and) {\n this.collectTypeReferencesFromNode(part);\n }\n } else if (isObjectType(node)) {\n if (isNamedType(node)) {\n // Skip generic param symbols and built-in types in named types\n // Strip generic arguments for import purposes\n const importName = extractBaseName(node.name);\n if (\n !this.genericParamSymbols.has(importName) &&\n !isBuiltinType(importName)\n ) {\n // Use trackReferencedType to properly resolve import path\n this.typeTracker.trackReferencedType(importName);\n }\n }\n\n for (const prop of Object.values(node.properties)) {\n this.collectTypeReferencesFromNode(prop.node);\n }\n }\n }\n\n /**\n * Check if a type name appears to be a generic type parameter of the referenced type.\n * This detects cases like ref=\"Bar<AnyAsset>\" where \"AnyAsset\" is Bar's type parameter,\n * not a concrete type to import.\n *\n * @param argName - The name of the type argument being checked\n * @param parentRef - The parent ref string that contains the generic usage\n * @returns true if argName appears to be a type parameter in parentRef\n */\n private isTypeParamOfRef(argName: string, parentRef: string): boolean {\n // Extract the generic parameters portion from the ref string\n // e.g., \"Bar<AnyAsset>\" -> \"AnyAsset\", \"Map<K, V>\" -> \"K, V\"\n const genericMatch = parentRef.match(/<(.+)>/);\n if (!genericMatch) {\n return false;\n }\n\n const genericPart = genericMatch[1];\n\n // Split by comma while respecting nested generics\n // and check if argName matches any parameter\n let depth = 0;\n let current = \"\";\n const params: string[] = [];\n\n for (const char of genericPart) {\n if (char === \"<\") {\n depth++;\n current += char;\n } else if (char === \">\") {\n depth--;\n current += char;\n } else if (char === \",\" && depth === 0) {\n params.push(current.trim());\n current = \"\";\n } else {\n current += char;\n }\n }\n if (current.trim()) {\n params.push(current.trim());\n }\n\n // Check if argName matches any parameter exactly or is the base of a constrained param\n return params.some(\n (param) => param === argName || param.startsWith(`${argName} `),\n );\n }\n}\n","import type { NodeType, ObjectType, RefType } from \"@xlr-lib/xlr\";\nimport {\n isStringType,\n isNumberType,\n isBooleanType,\n isObjectType,\n isArrayType,\n isRefType,\n isOrType,\n isAndType,\n isRecordType,\n isNamedType,\n isTupleType,\n isPrimitiveConst,\n isBuiltinType,\n extractBaseName,\n parseNamespacedType,\n} from \"./utils\";\n\n/**\n * Interface for tracking Asset import needs and namespace mappings.\n */\nexport interface TypeTransformContext {\n /** Set to true when Asset type needs to be imported */\n setNeedsAssetImport(value: boolean): void;\n /** Get the current Asset import need state */\n getNeedsAssetImport(): boolean;\n /** Track a referenced type for import */\n trackReferencedType(typeName: string): void;\n /** Track a namespace import */\n trackNamespaceImport(namespaceName: string): void;\n /** Get the namespace member map for type resolution */\n getNamespaceMemberMap(): Map<string, string>;\n /** Get the generic parameter symbols */\n getGenericParamSymbols(): Set<string>;\n /** Get the AssetWrapper ancestor's RefType for a type extending AssetWrapper (via registry) */\n getAssetWrapperExtendsRef(typeName: string): RefType | undefined;\n}\n\n/**\n * Transforms XLR types to TypeScript type strings.\n */\nexport class TypeTransformer {\n private readonly context: TypeTransformContext;\n\n constructor(context: TypeTransformContext) {\n this.context = context;\n }\n\n /**\n * Determines if a type name should be tracked for import.\n * A type should be tracked if it's not a generic parameter and not a builtin type.\n * Note: PLAYER_BUILTINS (Asset, AssetWrapper, Binding, Expression) are filtered\n * by isBuiltinType(), so no explicit Asset check is needed here.\n */\n private shouldTrackTypeForImport(typeName: string): boolean {\n return (\n !this.context.getGenericParamSymbols().has(typeName) &&\n !isBuiltinType(typeName)\n );\n }\n\n /**\n * Transform an XLR type to a TypeScript type string.\n * This is the core recursive transformation that adds TaggedTemplateValue support.\n */\n transformType(node: NodeType, forParameter = false): string {\n // Primitive types get TaggedTemplateValue support\n if (isStringType(node)) {\n if (isPrimitiveConst(node)) {\n return `\"${node.const}\"`;\n }\n return forParameter ? \"string | TaggedTemplateValue<string>\" : \"string\";\n }\n\n if (isNumberType(node)) {\n if (isPrimitiveConst(node)) {\n return `${node.const}`;\n }\n return forParameter ? \"number | TaggedTemplateValue<number>\" : \"number\";\n }\n\n if (isBooleanType(node)) {\n if (isPrimitiveConst(node)) {\n return `${node.const}`;\n }\n return forParameter\n ? \"boolean | TaggedTemplateValue<boolean>\"\n : \"boolean\";\n }\n\n // Reference types\n if (isRefType(node)) {\n return this.transformRefType(node, forParameter);\n }\n\n // Array types\n if (isArrayType(node)) {\n const elementType = this.transformType(node.elementType, forParameter);\n return `Array<${elementType}>`;\n }\n\n // Union types\n if (isOrType(node)) {\n const variants = node.or.map((v) => this.transformType(v, forParameter));\n return variants.join(\" | \");\n }\n\n // Intersection types\n if (isAndType(node)) {\n const parts = node.and.map((p) => this.transformType(p, forParameter));\n return parts.join(\" & \");\n }\n\n // Record types - key type should NOT have TaggedTemplateValue since\n // TypeScript Record keys can only be string | number | symbol\n if (isRecordType(node)) {\n const keyType = this.transformType(node.keyType, false);\n const valueType = this.transformType(node.valueType, forParameter);\n return `Record<${keyType}, ${valueType}>`;\n }\n\n // Object types - transform properties recursively\n // Any nested object can accept either a raw object OR a FunctionalBuilder that produces it\n if (isObjectType(node)) {\n if (isNamedType(node)) {\n // Resolve to full qualified name if it's a namespace member\n const typeName = this.resolveTypeName(node.name);\n\n // Check if this named type extends AssetWrapper:\n // 1. Inline ObjectType with extends field directly pointing to AssetWrapper\n // 2. Transitive extension via registry (e.g., ListItem → ListItemBase → AssetWrapper)\n const inlineExtendsRef = node.extends?.ref.startsWith(\"AssetWrapper\")\n ? node.extends\n : null;\n const extendsRef =\n inlineExtendsRef ?? this.context.getAssetWrapperExtendsRef(node.name);\n\n if (extendsRef) {\n return this.transformAssetWrapperExtension(\n typeName,\n node.name,\n extendsRef,\n );\n }\n\n // Named type - accept raw type, a builder that produces it, or a partial with nested builders\n return `${typeName} | FunctionalBuilder<${typeName}, BaseBuildContext> | FunctionalPartial<${typeName}, BaseBuildContext>`;\n }\n\n // Anonymous object - accept inline type, a builder that produces it, or a partial with nested builders\n const inlineType = this.generateInlineObjectType(node, forParameter);\n return `${inlineType} | FunctionalBuilder<${inlineType}, BaseBuildContext> | FunctionalPartial<${inlineType}, BaseBuildContext>`;\n }\n\n // Tuple types - transform to TypeScript tuple syntax [T1, T2, ...]\n if (isTupleType(node)) {\n const elements = node.elementTypes.map((member) => {\n const elementType = this.transformType(member.type, forParameter);\n return member.optional ? `${elementType}?` : elementType;\n });\n\n // Handle rest elements (additionalItems)\n // additionalItems is either false or a NodeType; truthy check suffices\n if (node.additionalItems) {\n const restType = this.transformType(node.additionalItems, forParameter);\n elements.push(`...${restType}[]`);\n }\n\n return `[${elements.join(\", \")}]`;\n }\n\n // Handle other primitive types\n if (node.type === \"null\") return \"null\";\n if (node.type === \"undefined\") return \"undefined\";\n if (node.type === \"any\") return \"any\";\n if (node.type === \"unknown\") return \"unknown\";\n if (node.type === \"never\") return \"never\";\n if (node.type === \"void\") return \"void\";\n\n // Default fallback\n return \"unknown\";\n }\n\n /**\n * Transform a type for use in generic constraints and defaults.\n * Unlike transformType(), this returns raw type names without FunctionalBuilder unions,\n * since constraints define type bounds, not parameter types that accept builders.\n *\n * @param node - The type node to transform\n * @returns The raw TypeScript type string\n */\n transformTypeForConstraint(node: NodeType): string {\n if (isRefType(node)) {\n const baseName = extractBaseName(node.ref);\n\n // Check if this is a namespaced type (e.g., \"Validation.CrossfieldReference\")\n const namespaced = parseNamespacedType(baseName);\n if (namespaced) {\n // Track the namespace for import and the member mapping\n this.context.trackNamespaceImport(namespaced.namespace);\n this.context.getNamespaceMemberMap().set(namespaced.member, baseName);\n } else if (baseName === \"Asset\" || node.ref.startsWith(\"Asset<\")) {\n // Track Asset import when used in generic constraints\n this.context.setNeedsAssetImport(true);\n } else if (this.shouldTrackTypeForImport(baseName)) {\n this.context.trackReferencedType(baseName);\n }\n\n // Resolve to full qualified name if it's a namespace member\n const resolvedName = this.resolveTypeName(baseName);\n\n // Handle generic arguments\n if (node.genericArguments && node.genericArguments.length > 0) {\n const args = node.genericArguments.map((a) =>\n this.transformTypeForConstraint(a),\n );\n return `${resolvedName}<${args.join(\", \")}>`;\n }\n\n // Preserve embedded generics if present in the ref string\n if (node.ref.includes(\"<\")) {\n // Also resolve the base name in case it's a namespace member\n return (\n this.resolveTypeName(extractBaseName(node.ref)) +\n node.ref.substring(node.ref.indexOf(\"<\"))\n );\n }\n\n return resolvedName;\n }\n\n if (isObjectType(node) && isNamedType(node)) {\n // Track Asset import if used in constraint\n if (node.name === \"Asset\") {\n this.context.setNeedsAssetImport(true);\n } else if (this.shouldTrackTypeForImport(node.name)) {\n this.context.trackReferencedType(node.name);\n }\n // Just the type name, no FunctionalBuilder union\n // Resolve to full qualified name if it's a namespace member\n return this.resolveTypeName(node.name);\n }\n\n if (isArrayType(node)) {\n const elementType = this.transformTypeForConstraint(node.elementType);\n return `Array<${elementType}>`;\n }\n\n if (isOrType(node)) {\n const variants = node.or.map((v) => this.transformTypeForConstraint(v));\n return variants.join(\" | \");\n }\n\n if (isAndType(node)) {\n const parts = node.and.map((p) => this.transformTypeForConstraint(p));\n return parts.join(\" & \");\n }\n\n // Tuple types - transform to TypeScript tuple syntax for constraints\n if (isTupleType(node)) {\n const elements = node.elementTypes.map((member) => {\n const elementType = this.transformTypeForConstraint(member.type);\n return member.optional ? `${elementType}?` : elementType;\n });\n\n // Handle rest elements (additionalItems)\n // additionalItems is either false or a NodeType; truthy check suffices\n if (node.additionalItems) {\n const restType = this.transformTypeForConstraint(node.additionalItems);\n elements.push(`...${restType}[]`);\n }\n\n return `[${elements.join(\", \")}]`;\n }\n\n // For primitives, use standard transformation (no FunctionalBuilder needed anyway)\n return this.transformType(node, false);\n }\n\n /**\n * Transform a reference type to TypeScript.\n */\n private transformRefType(node: RefType, forParameter: boolean): string {\n const ref = node.ref;\n\n // AssetWrapper - transform to accept Asset or FunctionalBuilder\n // Preserves the generic type argument when present for better type safety\n if (ref.startsWith(\"AssetWrapper\")) {\n this.context.setNeedsAssetImport(true);\n\n let innerType = \"Asset\";\n\n // Track whether we handled an intersection type (parts tracked separately)\n let isIntersectionType = false;\n\n // Check for structured generic arguments first\n if (node.genericArguments && node.genericArguments.length > 0) {\n const genericArg = node.genericArguments[0];\n // transformTypeForConstraint recursively tracks each part of intersection types\n const argType = this.transformTypeForConstraint(genericArg);\n\n // If it's a generic param (like AnyAsset), fall back to Asset\n innerType = this.context.getGenericParamSymbols().has(argType)\n ? \"Asset\"\n : argType;\n\n // Mark intersection types so we don't double-track the combined string\n isIntersectionType = isAndType(genericArg);\n } else if (ref.includes(\"<\")) {\n // Handle embedded generics like \"AssetWrapper<ImageAsset>\" or \"AssetWrapper<ImageAsset & Trackable>\"\n const match = ref.match(/AssetWrapper<(.+)>/);\n if (match) {\n const extractedType = match[1].trim();\n\n // Check if the extracted type is an intersection (contains \" & \")\n if (extractedType.includes(\" & \")) {\n // Parse intersection parts and track each separately\n isIntersectionType = true;\n innerType = extractedType;\n\n const parts = extractedType.split(\" & \").map((p) => p.trim());\n for (const part of parts) {\n const partName = extractBaseName(part);\n if (this.shouldTrackTypeForImport(partName)) {\n this.context.trackReferencedType(partName);\n }\n }\n } else {\n const baseName = extractBaseName(extractedType);\n innerType = this.context.getGenericParamSymbols().has(baseName)\n ? \"Asset\"\n : baseName;\n }\n }\n }\n\n // Track inner type for import if it's concrete and not Asset\n // Skip if it was an intersection type (parts already tracked above)\n if (!isIntersectionType && this.shouldTrackTypeForImport(innerType)) {\n this.context.trackReferencedType(innerType);\n }\n\n return `${innerType} | FunctionalBuilder<${innerType}, BaseBuildContext>`;\n }\n\n // Expression - allow TaggedTemplateValue\n if (ref === \"Expression\") {\n return forParameter ? \"string | TaggedTemplateValue<string>\" : \"string\";\n }\n\n // Binding - allow TaggedTemplateValue\n if (ref === \"Binding\") {\n return forParameter ? \"string | TaggedTemplateValue<string>\" : \"string\";\n }\n\n // Asset reference\n if (ref === \"Asset\" || ref.startsWith(\"Asset<\")) {\n this.context.setNeedsAssetImport(true);\n return \"Asset\";\n }\n\n // Type that extends AssetWrapper (e.g., Header extends AssetWrapper<ImageAsset>)\n // Detected via registry-based transitive lookup\n {\n const refBaseName = extractBaseName(ref);\n const extendsRef = this.context.getAssetWrapperExtendsRef(refBaseName);\n if (extendsRef) {\n return this.transformAssetWrapperExtension(\n this.resolveTypeName(refBaseName),\n refBaseName,\n extendsRef,\n );\n }\n }\n\n // Other references - user-defined types that may be objects\n // Accept both raw type or FunctionalBuilder that produces it\n const baseName = extractBaseName(ref);\n // Resolve to full qualified name if it's a namespace member (e.g., \"CrossfieldReference\" -> \"Validation.CrossfieldReference\")\n const resolvedName = this.resolveTypeName(baseName);\n\n // Handle structured generic arguments\n if (node.genericArguments && node.genericArguments.length > 0) {\n const args = node.genericArguments.map((a) =>\n this.transformType(a, forParameter),\n );\n const fullType = `${resolvedName}<${args.join(\", \")}>`;\n return `${fullType} | FunctionalBuilder<${fullType}, BaseBuildContext> | FunctionalPartial<${fullType}, BaseBuildContext>`;\n }\n\n // If ref contains embedded generics but genericArguments is empty, preserve them\n // This handles cases like \"SimpleModifier<'format'>\" where the type argument\n // is encoded in the ref string rather than in genericArguments array\n if (ref.includes(\"<\")) {\n // Also resolve the base name in case it's a namespace member\n const resolvedRef =\n this.resolveTypeName(extractBaseName(ref)) +\n ref.substring(ref.indexOf(\"<\"));\n return `${resolvedRef} | FunctionalBuilder<${resolvedRef}, BaseBuildContext> | FunctionalPartial<${resolvedRef}, BaseBuildContext>`;\n }\n\n return `${resolvedName} | FunctionalBuilder<${resolvedName}, BaseBuildContext> | FunctionalPartial<${resolvedName}, BaseBuildContext>`;\n }\n\n /**\n * Transform a type that extends AssetWrapper into a combined union.\n * Produces: InnerType | FunctionalBuilder<InnerType> | TypeName | FunctionalBuilder<TypeName> | FunctionalPartial<TypeName>\n */\n private transformAssetWrapperExtension(\n resolvedTypeName: string,\n rawTypeName: string,\n extendsRef: RefType,\n ): string {\n this.context.setNeedsAssetImport(true);\n\n // Determine the inner asset type from the AssetWrapper ancestor\n let innerType = \"Asset\";\n if (extendsRef.genericArguments && extendsRef.genericArguments.length > 0) {\n const genericArg = extendsRef.genericArguments[0];\n const argType = this.transformTypeForConstraint(genericArg);\n innerType = this.context.getGenericParamSymbols().has(argType)\n ? \"Asset\"\n : argType;\n } else if (extendsRef.ref.includes(\"<\")) {\n const match = extendsRef.ref.match(/AssetWrapper<(.+)>/);\n if (match) {\n const extracted = extractBaseName(match[1].trim());\n innerType = this.context.getGenericParamSymbols().has(extracted)\n ? \"Asset\"\n : extracted;\n }\n }\n\n // Track inner type for import if it's concrete and not Asset\n if (innerType !== \"Asset\" && this.shouldTrackTypeForImport(innerType)) {\n this.context.trackReferencedType(innerType);\n }\n\n // Track the extending type itself for import\n if (this.shouldTrackTypeForImport(rawTypeName)) {\n this.context.trackReferencedType(rawTypeName);\n }\n\n return `${innerType} | FunctionalBuilder<${innerType}, BaseBuildContext> | ${resolvedTypeName} | FunctionalBuilder<${resolvedTypeName}, BaseBuildContext> | FunctionalPartial<${resolvedTypeName}, BaseBuildContext>`;\n }\n\n /**\n * Generate an inline object type for anonymous objects.\n */\n generateInlineObjectType(node: ObjectType, forParameter: boolean): string {\n const props = Object.entries(node.properties)\n .map(([propName, prop]) => {\n const propType = this.transformType(prop.node, forParameter);\n const optional = prop.required ? \"\" : \"?\";\n // Quote property names that contain special characters (like hyphens)\n const quotedName = this.needsQuoting(propName)\n ? `\"${propName}\"`\n : propName;\n return `${quotedName}${optional}: ${propType}`;\n })\n .join(\"; \");\n\n return `{ ${props} }`;\n }\n\n /**\n * Check if a property name needs to be quoted in TypeScript.\n * Property names with special characters like hyphens must be quoted.\n */\n private needsQuoting(name: string): boolean {\n // Valid unquoted property names match JavaScript identifier rules\n // Must start with letter, underscore, or dollar sign\n // Can contain letters, digits, underscores, or dollar signs\n return !/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name);\n }\n\n /**\n * Get the full qualified name for a type if it's a namespace member.\n * For example, \"CrossfieldReference\" -> \"Validation.CrossfieldReference\"\n * if we've seen \"Validation.CrossfieldReference\" in the source.\n * Returns the original name if no namespace mapping exists.\n */\n private resolveTypeName(typeName: string): string {\n return this.context.getNamespaceMemberMap().get(typeName) ?? typeName;\n }\n}\n","import path from \"node:path\";\nimport type { RefType } from \"@xlr-lib/xlr\";\nimport type {\n TypeScriptContext,\n TypeResolutionResult,\n UnexportedTypeInfo,\n} from \"./type-resolver\";\nimport { createTypeScriptResolver } from \"./type-resolver\";\nimport {\n extractBaseName,\n parseNamespacedType,\n PLAYER_BUILTINS,\n getAssetWrapperExtendsRefByName,\n type TypeRegistry,\n} from \"./utils\";\nimport type { TypeTracker } from \"./type-collector\";\nimport type { TypeTransformContext } from \"./type-transformer\";\n\n/**\n * Configuration for import generation.\n */\nexport interface ImportGeneratorConfig {\n /** Import path for functional utilities (default: \"@player-lang/functional-dsl\") */\n functionalImportPath?: string;\n /** Import path for player-ui types (default: \"@player-ui/types\") */\n typesImportPath?: string;\n /** TypeScript context for automatic import resolution */\n tsContext?: TypeScriptContext;\n /** Function to generate the type import path for a given type name */\n typeImportPathGenerator?: (typeName: string) => string;\n /** Types defined in the same source file as the main type */\n sameFileTypes?: Set<string>;\n /** External type mappings (type name -> package name) */\n externalTypes?: Map<string, string>;\n /** Type registry for resolving types that extend AssetWrapper */\n typeRegistry?: TypeRegistry;\n}\n\n/**\n * Generates import statements and tracks type references.\n * Implements both TypeTracker and TypeTransformContext interfaces.\n */\nexport class ImportGenerator implements TypeTracker, TypeTransformContext {\n private readonly config: ImportGeneratorConfig;\n\n /** Track all type references that need to be imported, grouped by source file */\n private referencedTypesBySource = new Map<string, Set<string>>();\n\n /** Track types that should be imported from the main type's source file */\n private referencedTypes = new Set<string>();\n\n /** Track whether Asset type is needed for imports */\n private needsAssetImport = false;\n\n /** Track generic parameter symbols (e.g., T, U) that should not be imported */\n private genericParamSymbols = new Set<string>();\n\n /** TypeScript resolver for automatic import path resolution */\n private readonly tsResolver?: {\n resolveTypePath: (typeName: string) => TypeResolutionResult;\n getUnexportedTypes: () => UnexportedTypeInfo[];\n };\n\n /** Track types that couldn't be resolved - will cause errors if used */\n private unresolvedTypes = new Set<string>();\n\n /** Track namespaces that need to be imported (e.g., \"Validation\" from @player-ui/types) */\n private namespaceImports = new Set<string>();\n\n /** Map short type names to their full qualified names (e.g., \"CrossfieldReference\" -> \"Validation.CrossfieldReference\") */\n private namespaceMemberMap = new Map<string, string>();\n\n /** Effective sameFileTypes - computed from tsContext or provided directly */\n private readonly effectiveSameFileTypes?: Set<string>;\n\n constructor(config: ImportGeneratorConfig = {}) {\n this.config = config;\n\n // Initialize TypeScript resolver if tsContext is provided\n if (config.tsContext) {\n this.tsResolver = createTypeScriptResolver(config.tsContext);\n }\n\n // Use provided sameFileTypes or fall back to empty set\n this.effectiveSameFileTypes = config.sameFileTypes;\n }\n\n // TypeTransformContext implementation\n setNeedsAssetImport(value: boolean): void {\n this.needsAssetImport = value;\n }\n\n getNeedsAssetImport(): boolean {\n return this.needsAssetImport;\n }\n\n getNamespaceMemberMap(): Map<string, string> {\n return this.namespaceMemberMap;\n }\n\n getGenericParamSymbols(): Set<string> {\n return this.genericParamSymbols;\n }\n\n getAssetWrapperExtendsRef(typeName: string): RefType | undefined {\n const registry = this.config.typeRegistry;\n if (!registry) return undefined;\n return getAssetWrapperExtendsRefByName(typeName, registry);\n }\n\n /**\n * Get list of types that exist but need to be exported.\n */\n getUnexportedTypes(): UnexportedTypeInfo[] {\n return this.tsResolver?.getUnexportedTypes() ?? [];\n }\n\n /**\n * Get list of types that couldn't be resolved at all.\n */\n getUnresolvedTypes(): string[] {\n return Array.from(this.unresolvedTypes);\n }\n\n /**\n * Track a referenced type for import generation.\n */\n trackReferencedType(typeName: string): void {\n const { externalTypes, typeImportPathGenerator } = this.config;\n\n // Strip generic arguments for import purposes (import { ListItem } not { ListItem<T> })\n const importName = extractBaseName(typeName);\n\n // Never track PLAYER_BUILTINS (Asset, AssetWrapper, Binding, Expression)\n // These have special handling and should not be imported as regular types.\n // Note: This is intentionally redundant with isBuiltinType() filtering in\n // TypeTransformer.shouldTrackTypeForImport() to provide defense in depth.\n if (PLAYER_BUILTINS.has(importName)) {\n return;\n }\n\n // Check if it's a namespaced type (e.g., \"Validation.CrossfieldReference\")\n const namespaced = parseNamespacedType(importName);\n if (namespaced) {\n // Track the namespace for import (e.g., \"Validation\" from \"@player-ui/types\")\n const namespaceName = namespaced.namespace;\n\n // Check if we have an external types mapping for the namespace\n if (externalTypes?.has(namespaceName)) {\n const packageName = externalTypes.get(namespaceName)!;\n if (!this.referencedTypesBySource.has(packageName)) {\n this.referencedTypesBySource.set(packageName, new Set());\n }\n this.referencedTypesBySource.get(packageName)!.add(namespaceName);\n return;\n }\n\n // Default: assume it comes from @player-ui/types for namespaced types\n const typesImportPath = this.config.typesImportPath ?? \"@player-ui/types\";\n if (!this.referencedTypesBySource.has(typesImportPath)) {\n this.referencedTypesBySource.set(typesImportPath, new Set());\n }\n this.referencedTypesBySource.get(typesImportPath)!.add(namespaceName);\n return;\n }\n\n // Check if it's an explicitly configured external type\n if (externalTypes?.has(importName)) {\n const packageName = externalTypes.get(importName)!;\n if (!this.referencedTypesBySource.has(packageName)) {\n this.referencedTypesBySource.set(packageName, new Set());\n }\n this.referencedTypesBySource.get(packageName)!.add(importName);\n return;\n }\n\n // If TypeScript resolver is available, use it for automatic resolution\n if (this.tsResolver) {\n const result = this.tsResolver.resolveTypePath(importName);\n if (result === \"notFound\") {\n this.unresolvedTypes.add(importName);\n return;\n }\n if (result === \"sameFile\") {\n this.referencedTypes.add(importName);\n } else {\n if (!this.referencedTypesBySource.has(result)) {\n this.referencedTypesBySource.set(result, new Set());\n }\n this.referencedTypesBySource.get(result)!.add(importName);\n }\n return;\n }\n\n // Fall back to manual configuration\n const sameFileTypes = this.effectiveSameFileTypes;\n if (sameFileTypes) {\n if (sameFileTypes.has(importName)) {\n this.referencedTypes.add(importName);\n } else if (typeImportPathGenerator) {\n const importPath = typeImportPathGenerator(importName);\n if (importPath) {\n if (!this.referencedTypesBySource.has(importPath)) {\n this.referencedTypesBySource.set(importPath, new Set());\n }\n this.referencedTypesBySource.get(importPath)!.add(importName);\n }\n } else {\n this.referencedTypes.add(importName);\n }\n } else {\n this.referencedTypes.add(importName);\n }\n }\n\n /**\n * Track a namespace that needs to be imported.\n */\n trackNamespaceImport(namespaceName: string): void {\n this.namespaceImports.add(namespaceName);\n\n // Use the TypeScript resolver to find where the namespace is exported from\n if (this.tsResolver) {\n const result = this.tsResolver.resolveTypePath(namespaceName);\n if (result === \"sameFile\") {\n this.referencedTypes.add(namespaceName);\n } else if (result !== \"notFound\") {\n if (!this.referencedTypesBySource.has(result)) {\n this.referencedTypesBySource.set(result, new Set());\n }\n this.referencedTypesBySource.get(result)!.add(namespaceName);\n } else {\n this.unresolvedTypes.add(namespaceName);\n }\n return;\n }\n\n // Fall back: check external types first\n const { externalTypes, typeImportPathGenerator } = this.config;\n if (externalTypes?.has(namespaceName)) {\n const packageName = externalTypes.get(namespaceName)!;\n if (!this.referencedTypesBySource.has(packageName)) {\n this.referencedTypesBySource.set(packageName, new Set());\n }\n this.referencedTypesBySource.get(packageName)!.add(namespaceName);\n return;\n }\n\n // Try typeImportPathGenerator\n if (typeImportPathGenerator) {\n const importPath = typeImportPathGenerator(namespaceName);\n if (importPath) {\n if (!this.referencedTypesBySource.has(importPath)) {\n this.referencedTypesBySource.set(importPath, new Set());\n }\n this.referencedTypesBySource.get(importPath)!.add(namespaceName);\n return;\n }\n }\n\n // Last resort: assume same file\n this.referencedTypes.add(namespaceName);\n }\n\n /**\n * Generate import statements.\n */\n generateImports(mainTypeName: string): string {\n // Determine the import path for the main type\n let typeImportPath: string;\n if (this.config.tsContext) {\n const { sourceFile, outputDir } = this.config.tsContext;\n let relativePath = path.relative(outputDir, sourceFile.fileName);\n relativePath = relativePath.replace(/\\.tsx?$/, \".js\");\n if (!relativePath.startsWith(\".\")) {\n relativePath = \"./\" + relativePath;\n }\n typeImportPath = relativePath;\n } else if (this.config.typeImportPathGenerator) {\n typeImportPath = this.config.typeImportPathGenerator(mainTypeName);\n } else {\n typeImportPath = `../types/${this.getTypeFileName(mainTypeName)}`;\n }\n\n // Collect all types to import from the main source file\n const typesToImport = new Set<string>([mainTypeName]);\n\n // Add referenced types that are in the same source file\n Array.from(this.referencedTypes).forEach((name) => {\n typesToImport.add(name);\n });\n\n // Get import paths from config or use defaults\n const typesImportPath = this.config.typesImportPath ?? \"@player-ui/types\";\n const functionalImportPath =\n this.config.functionalImportPath ?? \"@player-lang/functional-dsl\";\n\n // Build import lines\n const lines: string[] = [];\n\n // Main type import\n const typeImportStatement = `import type { ${Array.from(typesToImport).join(\", \")} } from \"${typeImportPath}\";`;\n lines.push(typeImportStatement);\n\n // Generate imports for types from other source files\n for (const [importPath, types] of this.referencedTypesBySource) {\n const typeNames = Array.from(types).join(\", \");\n lines.push(`import type { ${typeNames} } from \"${importPath}\";`);\n }\n\n // Only import Asset if it's used\n if (this.needsAssetImport) {\n lines.push(`import type { Asset } from \"${typesImportPath}\";`);\n }\n\n lines.push(\n `import { type FunctionalBuilder, type BaseBuildContext, type FunctionalPartial, FunctionalBuilderBase, createInspectMethod, type TaggedTemplateValue } from \"${functionalImportPath}\";`,\n );\n\n return lines.join(\"\\n\");\n }\n\n private getTypeFileName(typeName: string): string {\n // Convert PascalCase to kebab-case for file name\n return typeName\n .replace(/([A-Z])/g, \"-$1\")\n .toLowerCase()\n .replace(/^-/, \"\")\n .replace(/asset$/, \"\");\n }\n}\n","import ts from \"typescript\";\nimport path from \"node:path\";\nimport { TsMorphTypeDefinitionFinder } from \"./ts-morph-type-finder\";\n\n/**\n * TypeScript context for automatic import resolution.\n * When provided, the generator uses TypeScript's module resolution to determine\n * where types should be imported from.\n */\nexport interface TypeScriptContext {\n /** The TypeScript program */\n program: ts.Program;\n /** The source file containing the type being generated */\n sourceFile: ts.SourceFile;\n /** The output directory where generated files will be written */\n outputDir: string;\n}\n\n/**\n * Information about an unexported type that needs to be exported\n */\nexport interface UnexportedTypeInfo {\n /** The type name that needs to be exported */\n typeName: string;\n /** The file path where the type is declared */\n filePath: string;\n}\n\n/**\n * Result from type resolution.\n * - sameFile: type is defined in the same file as the main type\n * - notFound: type couldn't be resolved anywhere\n * - string: import path for the type (package name or relative path)\n */\nexport type TypeResolutionResult = \"sameFile\" | \"notFound\" | string;\n\n/**\n * Check if a file path is a TypeScript lib/built-in declaration file.\n * These are files like lib.dom.d.ts that contain built-in type definitions.\n */\nexport function isBuiltInDeclarationPath(filePath: string): boolean {\n // TypeScript lib files\n if (filePath.includes(\"/typescript/lib/lib.\")) return true;\n // Node.js built-in types\n if (filePath.includes(\"/@types/node/\")) return true;\n return false;\n}\n\n/**\n * Check if a declaration node is exported.\n */\nexport function isDeclarationExported(\n node: ts.Declaration,\n typescript: typeof ts,\n): boolean {\n // Check for export modifier on the declaration itself\n const modifiers = typescript.canHaveModifiers(node)\n ? typescript.getModifiers(node)\n : undefined;\n if (modifiers) {\n for (const modifier of modifiers) {\n if (modifier.kind === typescript.SyntaxKind.ExportKeyword) {\n return true;\n }\n }\n }\n\n // Check if this declaration is part of an export statement\n const parent = node.parent;\n if (parent && typescript.isExportDeclaration(parent)) {\n return true;\n }\n\n return false;\n}\n\n/**\n * Creates an import resolver using TypeScript's type checker and\n * TsMorphTypeDefinitionFinder for tracing types through imports.\n * This handles cases where types come through extends, Pick, re-exports, etc.\n */\nexport function createTypeScriptResolver(tsContext: TypeScriptContext): {\n resolveTypePath: (typeName: string) => TypeResolutionResult;\n getUnexportedTypes: () => UnexportedTypeInfo[];\n} {\n const { program, sourceFile, outputDir } = tsContext;\n const typeChecker = program.getTypeChecker();\n\n // Create the type definition finder for recursive search\n const finder = new TsMorphTypeDefinitionFinder();\n\n // Cache resolved paths\n const resolvedCache = new Map<string, TypeResolutionResult>();\n\n // Track types that exist but aren't exported\n const unexportedTypes: UnexportedTypeInfo[] = [];\n\n /**\n * Resolve a type name to its import path.\n * Returns:\n * - \"sameFile\": type is in the same file as the source\n * - \"notFound\": type couldn't be resolved anywhere\n * - string (import path): type should be imported from this path\n */\n function resolveTypePath(typeName: string): TypeResolutionResult {\n if (resolvedCache.has(typeName)) {\n return resolvedCache.get(typeName)!;\n }\n\n // First, try to find the type using TsMorphTypeDefinitionFinder\n // This recursively searches through imports\n const typeFilePath = finder.findTypeSourceFile(\n typeName,\n sourceFile.fileName,\n );\n\n if (typeFilePath) {\n // Check if it's from the same file\n if (typeFilePath === sourceFile.fileName) {\n resolvedCache.set(typeName, \"sameFile\");\n return \"sameFile\";\n }\n\n // Check if it's a built-in declaration\n if (isBuiltInDeclarationPath(typeFilePath)) {\n resolvedCache.set(typeName, \"sameFile\");\n return \"sameFile\";\n }\n\n // Check if it's from node_modules (external package)\n if (typeFilePath.includes(\"node_modules\")) {\n const nodeModulesIdx = typeFilePath.lastIndexOf(\"node_modules/\");\n const afterNodeModules = typeFilePath.slice(\n nodeModulesIdx + \"node_modules/\".length,\n );\n\n // Handle scoped packages (@scope/package)\n let packageName: string;\n if (afterNodeModules.startsWith(\"@\")) {\n const parts = afterNodeModules.split(\"/\");\n packageName = `${parts[0]}/${parts[1]}`;\n } else {\n packageName = afterNodeModules.split(\"/\")[0];\n }\n\n resolvedCache.set(typeName, packageName);\n return packageName;\n }\n\n // It's a local file - compute relative path from outputDir\n let relativePath = path.relative(outputDir, typeFilePath);\n relativePath = relativePath.replace(/\\.tsx?$/, \".js\");\n if (!relativePath.startsWith(\".\")) {\n relativePath = \"./\" + relativePath;\n }\n\n resolvedCache.set(typeName, relativePath);\n return relativePath;\n }\n\n // If TsMorphTypeDefinitionFinder didn't find it, fall back to symbol resolution\n // This handles cases where types are in scope but not through imports\n const symbols = typeChecker.getSymbolsInScope(\n sourceFile,\n ts.SymbolFlags.Type | ts.SymbolFlags.Interface | ts.SymbolFlags.TypeAlias,\n );\n\n const matchingSymbols = symbols.filter((s) => s.getName() === typeName);\n\n let symbol: ts.Symbol | undefined;\n let validDeclaration: ts.Declaration | undefined;\n let unexportedDeclarationFile: string | undefined;\n\n for (const s of matchingSymbols) {\n const declarations = s.getDeclarations();\n if (declarations && declarations.length > 0) {\n const decl = declarations[0];\n const declFile = decl.getSourceFile().fileName;\n\n // Skip built-in declarations\n if (isBuiltInDeclarationPath(declFile)) {\n continue;\n }\n\n // Check if the declaration is exported (has export modifier or is in node_modules)\n const isFromNodeModules = declFile.includes(\"node_modules\");\n const isExported = isFromNodeModules || isDeclarationExported(decl, ts);\n\n if (isExported) {\n symbol = s;\n validDeclaration = decl;\n break;\n } else {\n // Track unexported declaration for warning\n unexportedDeclarationFile = declFile;\n }\n }\n }\n\n if (!symbol || !validDeclaration) {\n // Type exists but is not exported - track for warning\n if (unexportedDeclarationFile) {\n // Check if we already tracked this type\n const alreadyTracked = unexportedTypes.some(\n (t) =>\n t.typeName === typeName && t.filePath === unexportedDeclarationFile,\n );\n if (!alreadyTracked) {\n unexportedTypes.push({\n typeName,\n filePath: unexportedDeclarationFile,\n });\n }\n // Type exists but isn't exported - treat as \"not found\" for import purposes\n // It will be added to the same-file import, which will cause a type error,\n // but the warning system will tell users what to export\n resolvedCache.set(typeName, \"sameFile\");\n return \"sameFile\";\n }\n // Type truly not found\n resolvedCache.set(typeName, \"notFound\");\n return \"notFound\";\n }\n\n const declSourceFile = validDeclaration.getSourceFile();\n const declFilePath = declSourceFile.fileName;\n\n if (declFilePath === sourceFile.fileName) {\n resolvedCache.set(typeName, \"sameFile\");\n return \"sameFile\";\n }\n\n if (declFilePath.includes(\"node_modules\")) {\n const nodeModulesIdx = declFilePath.lastIndexOf(\"node_modules/\");\n const afterNodeModules = declFilePath.slice(\n nodeModulesIdx + \"node_modules/\".length,\n );\n\n let packageName: string;\n if (afterNodeModules.startsWith(\"@\")) {\n const parts = afterNodeModules.split(\"/\");\n packageName = `${parts[0]}/${parts[1]}`;\n } else {\n packageName = afterNodeModules.split(\"/\")[0];\n }\n\n resolvedCache.set(typeName, packageName);\n return packageName;\n }\n\n let relativePath = path.relative(outputDir, declFilePath);\n relativePath = relativePath.replace(/\\.tsx?$/, \".js\");\n if (!relativePath.startsWith(\".\")) {\n relativePath = \"./\" + relativePath;\n }\n\n resolvedCache.set(typeName, relativePath);\n return relativePath;\n }\n\n function getUnexportedTypes(): UnexportedTypeInfo[] {\n return [...unexportedTypes];\n }\n\n return { resolveTypePath, getUnexportedTypes };\n}\n","import { Project, SourceFile, ts } from \"ts-morph\";\nimport { existsSync } from \"fs\";\nimport { dirname, resolve } from \"path\";\n\n/**\n * Information about an unexported type that was found\n */\nexport interface UnexportedTypeLocation {\n /** The name of the type */\n typeName: string;\n /** The file where the type is declared (but not exported) */\n filePath: string;\n}\n\n/**\n * Finds type definitions by searching through TypeScript source files using ts-morph.\n * Handles interfaces, type aliases, classes, and re-exported types.\n * Supports both local files and types from node_modules.\n *\n * Note: This is the ts-morph based implementation. For the TypeScript API based\n * implementation, see TypeScriptTypeDefinitionFinder in type-resolver.ts.\n */\nexport class TsMorphTypeDefinitionFinder {\n private project: Project | undefined;\n private readonly typeLocationCache = new Map<string, string | null>();\n private readonly unexportedTypes = new Map<string, string>();\n\n /**\n * Finds the source file for a type by searching the codebase.\n * Recursively follows imports to find where a type is actually defined.\n * Supports both relative imports and node_modules packages.\n *\n * @param typeName - The name of the type to find\n * @param startingFile - The file to start searching from\n * @returns The path to the file containing the type definition, or null if not found\n */\n findTypeSourceFile(typeName: string, startingFile: string): string | null {\n if (!typeName || !startingFile) return null;\n\n const cacheKey = `${typeName}:${startingFile}`;\n if (this.typeLocationCache.has(cacheKey)) {\n return this.typeLocationCache.get(cacheKey) || null;\n }\n\n try {\n if (!this.project) {\n this.project = new Project({\n useInMemoryFileSystem: false,\n // Enable module resolution for node_modules support\n skipFileDependencyResolution: false,\n compilerOptions: {\n moduleResolution: ts.ModuleResolutionKind.Node16,\n resolveJsonModule: true,\n },\n });\n }\n\n const visitedFiles = new Set<string>();\n const result = this.searchForType(typeName, startingFile, visitedFiles);\n this.typeLocationCache.set(cacheKey, result);\n return result;\n } catch {\n this.typeLocationCache.set(cacheKey, null);\n return null;\n }\n }\n\n /**\n * Recursively searches for a type definition through imports.\n * Handles both relative imports and node_modules packages.\n */\n private searchForType(\n typeName: string,\n filePath: string,\n visitedFiles: Set<string>,\n ): string | null {\n if (!existsSync(filePath) || visitedFiles.has(filePath)) return null;\n visitedFiles.add(filePath);\n\n try {\n const sourceFile = this.project!.addSourceFileAtPath(filePath);\n\n // Check if this file defines and exports the type\n if (this.fileDefinesType(sourceFile, typeName)) {\n return filePath;\n }\n\n // Check if the file has the type but doesn't export it\n const typeCheck = this.fileHasTypeDeclaration(sourceFile, typeName);\n if (typeCheck.found && !typeCheck.exported) {\n // Track this unexported type for warning\n this.trackUnexportedType(typeName, typeCheck.filePath);\n }\n\n // Search through imports\n for (const importDecl of sourceFile.getImportDeclarations()) {\n const moduleSpecifier = importDecl.getModuleSpecifierValue();\n\n // Check if this import includes the type we're looking for\n const importedType = this.getImportedTypeFromDeclaration(\n importDecl,\n typeName,\n );\n\n if (importedType) {\n // Try to resolve the module to its source file\n const resolvedSourceFile = importDecl.getModuleSpecifierSourceFile();\n\n if (resolvedSourceFile) {\n // Found it via ts-morph module resolution (works for node_modules)\n const resolvedPath = resolvedSourceFile.getFilePath();\n\n // For re-exports, we might need to search deeper\n if (this.fileDefinesType(resolvedSourceFile, typeName)) {\n return resolvedPath;\n }\n\n // Check if it's re-exported from somewhere else\n const deeperResult = this.searchForType(\n typeName,\n resolvedPath,\n visitedFiles,\n );\n if (deeperResult) return deeperResult;\n\n // If we can't find it deeper, return the resolved path\n // (the type might be defined in a way we can't detect)\n return resolvedPath;\n }\n\n // Fallback: manual resolution for relative imports\n if (moduleSpecifier.startsWith(\".\")) {\n const resolvedPath = this.resolveImportPath(\n filePath,\n moduleSpecifier,\n );\n if (resolvedPath) {\n const result = this.searchForType(\n typeName,\n resolvedPath,\n visitedFiles,\n );\n if (result) return result;\n }\n }\n }\n\n // Also follow relative imports even if they don't explicitly import the type\n // (the type might be re-exported)\n if (moduleSpecifier.startsWith(\".\")) {\n const resolvedPath = this.resolveImportPath(\n filePath,\n moduleSpecifier,\n );\n if (resolvedPath) {\n const result = this.searchForType(\n typeName,\n resolvedPath,\n visitedFiles,\n );\n if (result) return result;\n }\n }\n }\n\n return null;\n } catch {\n return null;\n }\n }\n\n /**\n * Checks if an import declaration imports a specific type.\n * Handles named imports, default imports, and namespace imports.\n */\n private getImportedTypeFromDeclaration(\n importDecl: ReturnType<SourceFile[\"getImportDeclarations\"]>[0],\n typeName: string,\n ): boolean {\n // Check named imports: import { Foo } from \"...\"\n for (const namedImport of importDecl.getNamedImports()) {\n const name =\n namedImport.getAliasNode()?.getText() || namedImport.getName();\n if (name === typeName) return true;\n }\n\n // Check default import: import Foo from \"...\"\n const defaultImport = importDecl.getDefaultImport();\n if (defaultImport?.getText() === typeName) return true;\n\n // Check namespace import: import * as Foo from \"...\"\n const namespaceImport = importDecl.getNamespaceImport();\n if (namespaceImport?.getText() === typeName) return true;\n\n return false;\n }\n\n /**\n * Checks if a source file defines and exports a specific type.\n * Handles interfaces, type aliases, classes, and re-exported types.\n * Only returns true if the type is publicly exported.\n */\n private fileDefinesType(sourceFile: SourceFile, typeName: string): boolean {\n // Check exported interfaces, type aliases, and classes\n for (const decl of [\n ...sourceFile.getInterfaces(),\n ...sourceFile.getTypeAliases(),\n ...sourceFile.getClasses(),\n ]) {\n if (decl.getName() === typeName && decl.isExported()) {\n return true;\n }\n }\n\n // Check exported types in export declarations (re-exports)\n for (const exportDecl of sourceFile.getExportDeclarations()) {\n for (const namedExport of exportDecl.getNamedExports()) {\n if (namedExport.getName() === typeName) return true;\n }\n }\n\n return false;\n }\n\n /**\n * Resolves a relative import path to an actual file path.\n * Handles TypeScript extensions and index files.\n */\n private resolveImportPath(\n fromFile: string,\n importPath: string,\n ): string | null {\n const dir = dirname(fromFile);\n const extensions = [\".ts\", \".tsx\", \".d.ts\"];\n\n // Try direct file with TS extensions\n for (const ext of extensions) {\n const fullPath = resolve(dir, `${importPath}${ext}`);\n if (existsSync(fullPath)) return fullPath;\n }\n\n // Try index files\n for (const ext of extensions) {\n const fullPath = resolve(dir, `${importPath}/index${ext}`);\n if (existsSync(fullPath)) return fullPath;\n }\n\n // Handle .js → .ts mapping\n if (importPath.endsWith(\".js\")) {\n const tsPath = resolve(dir, importPath.replace(/\\.js$/, \".ts\"));\n if (existsSync(tsPath)) return tsPath;\n\n const dtsPath = resolve(dir, importPath.replace(/\\.js$/, \".d.ts\"));\n if (existsSync(dtsPath)) return dtsPath;\n }\n\n return null;\n }\n\n /**\n * Get all types that were found to exist but are not exported.\n * Call this after searching to get the list of types that need to be exported.\n */\n getUnexportedTypes(): UnexportedTypeLocation[] {\n return Array.from(this.unexportedTypes.entries()).map(\n ([typeName, filePath]) => ({\n typeName,\n filePath,\n }),\n );\n }\n\n /**\n * Check if a file declares a type (regardless of export status).\n * Used internally to track unexported types.\n */\n private fileHasTypeDeclaration(\n sourceFile: SourceFile,\n typeName: string,\n ): { found: boolean; exported: boolean; filePath: string } {\n const filePath = sourceFile.getFilePath();\n\n // Check interfaces, type aliases, and classes\n for (const decl of [\n ...sourceFile.getInterfaces(),\n ...sourceFile.getTypeAliases(),\n ...sourceFile.getClasses(),\n ]) {\n if (decl.getName() === typeName) {\n return {\n found: true,\n exported: decl.isExported(),\n filePath,\n };\n }\n }\n\n return { found: false, exported: false, filePath };\n }\n\n /**\n * Track an unexported type for later reporting.\n */\n private trackUnexportedType(typeName: string, filePath: string): void {\n if (!this.unexportedTypes.has(typeName)) {\n this.unexportedTypes.set(typeName, filePath);\n }\n }\n\n /**\n * Disposes of internal resources and clears caches.\n * Should be called when the finder is no longer needed.\n */\n dispose(): void {\n this.typeLocationCache.clear();\n this.unexportedTypes.clear();\n this.project = undefined;\n }\n}\n","import type { NodeType, ObjectType } from \"@xlr-lib/xlr\";\nimport {\n isStringType,\n isNumberType,\n isBooleanType,\n isObjectType,\n isArrayType,\n isRefType,\n isOrType,\n isAndType,\n isPrimitiveConst,\n isAssetWrapperRef,\n isExpressionRef,\n isBindingRef,\n} from \"./utils\";\n\n/**\n * Configuration for default value generation\n */\nexport interface DefaultValueConfig {\n /**\n * Maximum depth for recursive object defaults.\n * Prevents infinite recursion for deeply nested or circular types.\n *\n * The depth counter starts at 0 for the root object and increments\n * for each nested object level. When depth equals maxDepth, nested\n * objects are returned as empty `{}` instead of recursing further.\n *\n * Example with maxDepth=3:\n * - Root object (depth 0): full defaults generated\n * - level1.nested (depth 1): full defaults generated\n * - level1.nested.child (depth 2): full defaults generated\n * - level1.nested.child.deep (depth 3): returns {} (depth limit reached)\n *\n * Default: 3\n */\n maxDepth?: number;\n\n /**\n * Type names to skip (user must provide these values).\n * Typically includes \"Asset\" and \"AssetWrapper\".\n */\n skipTypes?: Set<string>;\n}\n\nconst DEFAULT_CONFIG: Required<DefaultValueConfig> = {\n maxDepth: 3,\n skipTypes: new Set([\"Asset\", \"AssetWrapper\"]),\n};\n\n/**\n * Context for tracking default generation state\n */\ninterface GenerationContext {\n depth: number;\n config: Required<DefaultValueConfig>;\n}\n\n/**\n * Generates smart default values for builder classes.\n *\n * This generator creates sensible defaults for required fields:\n * - String → \"\"\n * - Number → 0\n * - Boolean → false\n * - Array → []\n * - Object → {} or recursive defaults for required properties\n * - Expression/Binding → \"\"\n * - Union types → uses the first non-null/undefined variant\n * - AssetWrapper → SKIPPED (user must provide)\n */\nexport class DefaultValueGenerator {\n private readonly config: Required<DefaultValueConfig>;\n\n constructor(config: DefaultValueConfig = {}) {\n this.config = {\n ...DEFAULT_CONFIG,\n ...config,\n skipTypes: config.skipTypes ?? DEFAULT_CONFIG.skipTypes,\n };\n }\n\n /**\n * Generate default values for an ObjectType.\n *\n * @param objectType - The XLR ObjectType to generate defaults for\n * @param assetType - Optional asset type string for Asset types\n * @returns Record of property names to default values\n */\n generateDefaults(\n objectType: ObjectType,\n assetType?: string,\n ): Record<string, unknown> {\n const defaults: Record<string, unknown> = {};\n\n // Add asset type default if this is an asset\n if (assetType) {\n defaults[\"type\"] = assetType;\n }\n\n // Add default ID for assets (types that extend Asset)\n if (objectType.extends?.ref.startsWith(\"Asset\")) {\n defaults[\"id\"] = \"\";\n }\n // Also add default ID for non-Asset types that have an 'id' property\n else if (\"id\" in objectType.properties) {\n defaults[\"id\"] = \"\";\n }\n\n // Process each property\n const context: GenerationContext = {\n depth: 0,\n config: this.config,\n };\n\n for (const [propName, prop] of Object.entries(objectType.properties)) {\n // Const values take precedence\n if (isPrimitiveConst(prop.node)) {\n defaults[propName] = prop.node.const;\n continue;\n }\n\n // Only generate defaults for required properties\n if (!prop.required) {\n continue;\n }\n\n // Skip if we already have a default (e.g., id)\n if (propName in defaults) {\n continue;\n }\n\n const defaultValue = this.getDefaultForType(prop.node, context);\n if (defaultValue !== undefined) {\n defaults[propName] = defaultValue;\n }\n }\n\n return defaults;\n }\n\n /**\n * Get the default value for a specific type node.\n *\n * @param node - The type node\n * @param context - Generation context for tracking depth\n * @returns The default value, or undefined if the type should be skipped\n */\n private getDefaultForType(\n node: NodeType,\n context: GenerationContext,\n ): unknown {\n // Skip AssetWrapper - user must provide\n if (isAssetWrapperRef(node)) {\n return undefined;\n }\n\n // Check for other skip types\n if (isRefType(node)) {\n const baseName = node.ref.split(\"<\")[0];\n if (context.config.skipTypes.has(baseName)) {\n return undefined;\n }\n }\n\n // Handle primitive types\n if (isStringType(node)) {\n return \"\";\n }\n\n if (isNumberType(node)) {\n return 0;\n }\n\n if (isBooleanType(node)) {\n return false;\n }\n\n // Handle Expression and Binding refs\n if (isExpressionRef(node) || isBindingRef(node)) {\n return \"\";\n }\n\n // Handle arrays\n if (isArrayType(node)) {\n return [];\n }\n\n // Handle union types - pick first non-null/undefined variant\n if (isOrType(node)) {\n return this.getDefaultForUnion(node.or, context);\n }\n\n // Handle intersection types - try to merge defaults\n if (isAndType(node)) {\n return this.getDefaultForIntersection(node.and, context);\n }\n\n // Handle object types with depth limit\n if (isObjectType(node)) {\n if (context.depth >= context.config.maxDepth) {\n return {};\n }\n\n return this.getDefaultForObject(node, {\n ...context,\n depth: context.depth + 1,\n });\n }\n\n // Handle null/undefined types\n if (node.type === \"null\") {\n return null;\n }\n\n if (node.type === \"undefined\") {\n return undefined;\n }\n\n // Refs to other types - return empty object as a safe default\n if (isRefType(node)) {\n return {};\n }\n\n return undefined;\n }\n\n /**\n * Get default for a union type by picking the first non-null/undefined variant.\n */\n private getDefaultForUnion(\n variants: NodeType[],\n context: GenerationContext,\n ): unknown {\n for (const variant of variants) {\n // Skip null and undefined\n if (variant.type === \"null\" || variant.type === \"undefined\") {\n continue;\n }\n\n const defaultValue = this.getDefaultForType(variant, context);\n if (defaultValue !== undefined) {\n return defaultValue;\n }\n }\n\n // If all variants are null/undefined, return undefined\n return undefined;\n }\n\n /**\n * Get default for an intersection type by attempting to merge.\n */\n private getDefaultForIntersection(\n parts: NodeType[],\n context: GenerationContext,\n ): unknown {\n // For intersections, we need to satisfy all parts\n // Start with an empty object and merge\n const merged: Record<string, unknown> = {};\n\n for (const part of parts) {\n const partDefault = this.getDefaultForType(part, context);\n\n if (\n partDefault !== undefined &&\n typeof partDefault === \"object\" &&\n partDefault !== null &&\n !Array.isArray(partDefault)\n ) {\n Object.assign(merged, partDefault);\n }\n }\n\n return Object.keys(merged).length > 0 ? merged : {};\n }\n\n /**\n * Get default for an object type by processing required properties.\n */\n private getDefaultForObject(\n node: ObjectType,\n context: GenerationContext,\n ): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n\n for (const [propName, prop] of Object.entries(node.properties)) {\n // Const values take precedence\n if (isPrimitiveConst(prop.node)) {\n result[propName] = prop.node.const;\n continue;\n }\n\n // Only generate defaults for required properties\n if (!prop.required) {\n continue;\n }\n\n const defaultValue = this.getDefaultForType(prop.node, context);\n if (defaultValue !== undefined) {\n result[propName] = defaultValue;\n }\n }\n\n return result;\n }\n}\n","import type { NodeType, ObjectType } from \"@xlr-lib/xlr\";\nimport {\n toPascalCase,\n containsArrayType,\n extractGenericUsage,\n findAssetWrapperPaths,\n type TypeRegistry,\n} from \"./utils\";\nimport type { TypeTransformer } from \"./type-transformer\";\nimport { DefaultValueGenerator } from \"./default-value-generator\";\n\n/**\n * Information about a builder class to generate.\n */\nexport interface BuilderInfo {\n /** Original type name from XLR */\n name: string;\n /** Generated class name (e.g., \"TextAssetBuilder\") */\n className: string;\n /** Factory function name (e.g., \"text\") */\n factoryName: string;\n /** The XLR ObjectType being generated */\n objectType: ObjectType;\n /** Asset type string if this is an Asset (e.g., \"text\") */\n assetType?: string;\n /** Generic parameters declaration if type is generic */\n genericParams?: string;\n /** Whether this type extends Asset */\n isAsset: boolean;\n}\n\n/**\n * Information about a property for code generation.\n */\ninterface PropertyInfo {\n propName: string;\n propType: NodeType;\n description: string;\n}\n\n/**\n * Generates builder class code from BuilderInfo.\n */\nexport class BuilderClassGenerator {\n private readonly typeTransformer: TypeTransformer;\n private readonly defaultValueGenerator: DefaultValueGenerator;\n private readonly typeRegistry: TypeRegistry;\n\n /** Track array properties for __arrayProperties__ */\n private arrayProperties = new Set<string>();\n\n /** Track asset wrapper paths for __assetWrapperPaths__ */\n private assetWrapperPaths: string[][] = [];\n\n constructor(typeTransformer: TypeTransformer, typeRegistry?: TypeRegistry) {\n this.typeTransformer = typeTransformer;\n this.typeRegistry = typeRegistry ?? new Map();\n this.defaultValueGenerator = new DefaultValueGenerator({\n maxDepth: 3,\n skipTypes: new Set([\"Asset\", \"AssetWrapper\"]),\n });\n }\n\n /**\n * Generate the builder class code.\n */\n generateBuilderClass(info: BuilderInfo): string {\n const {\n name,\n className,\n factoryName,\n objectType,\n assetType,\n genericParams,\n } = info;\n\n // Reset tracking for this builder\n this.arrayProperties.clear();\n this.assetWrapperPaths = [];\n\n const genericPart = genericParams ? `<${genericParams}>` : \"\";\n const genericUsage = extractGenericUsage(genericParams);\n\n // Generate interface methods\n const interfaceCode = this.generateInterfaceMethods(info);\n\n // Generate class methods\n const classMethods = this.generateClassMethods(info);\n\n // Generate defaults\n const defaults = this.generateDefaults(objectType, assetType);\n\n // Find all nested AssetWrapper paths\n this.assetWrapperPaths = findAssetWrapperPaths(\n objectType,\n this.typeRegistry,\n );\n\n // Generate array properties metadata\n const arrayPropsCode =\n this.arrayProperties.size > 0\n ? ` private static readonly __arrayProperties__: ReadonlySet<string> = new Set([${Array.from(\n this.arrayProperties,\n )\n .map((p) => `\"${p}\"`)\n .join(\", \")}]);\\n`\n : \"\";\n\n // Generate asset wrapper paths metadata\n const assetWrapperPathsCode =\n this.assetWrapperPaths.length > 0\n ? ` private static readonly __assetWrapperPaths__: ReadonlyArray<ReadonlyArray<string>> = ${JSON.stringify(this.assetWrapperPaths)};\\n`\n : \"\";\n\n // Build the class\n const classCode = `\n${interfaceCode}\n\n/**\n * A builder for ${name}\n */\nexport class ${className}${genericPart} extends FunctionalBuilderBase<${name}${genericUsage}> implements ${className}Methods${genericUsage}, FunctionalBuilder<${name}${genericUsage}, BaseBuildContext> {\n private static readonly defaults: Record<string, unknown> = ${defaults};\n${arrayPropsCode}${assetWrapperPathsCode}\n${classMethods}\n\n /**\n * Builds the final ${name} object\n * @param context - Optional build context for nested builders\n */\n build(context?: BaseBuildContext): ${name}${genericUsage} {\n return this.buildWithDefaults(${className}.defaults, context);\n }\n\n [Symbol.for(\"nodejs.util.inspect.custom\")](): string {\n return createInspectMethod(\"${className}\", this.values);\n }\n}\n\n/**\n * Creates a new ${name} builder\n * @param initial Optional initial values\n * @returns A functional builder for ${name}\n */\nexport function ${factoryName}${genericPart}(initial?: FunctionalPartial<${name}${genericUsage}>): ${className}${genericUsage} {\n return new ${className}${genericUsage}(initial);\n}`;\n\n return classCode.trim();\n }\n\n /**\n * Generate interface methods for the builder.\n */\n private generateInterfaceMethods(info: BuilderInfo): string {\n const { className, objectType, genericParams, isAsset } = info;\n const genericUsage = extractGenericUsage(genericParams);\n\n // Collect all properties to generate methods for\n const properties = this.collectPropertiesForMethods(objectType, isAsset);\n\n const methods = properties\n .map(({ propName, propType, description }) => {\n const methodName = `with${toPascalCase(propName)}`;\n const paramType = this.typeTransformer.transformType(propType, true);\n\n return ` /** ${description} */\n ${methodName}(value: ${paramType}): ${className}${genericUsage};`;\n })\n .join(\"\\n\");\n\n return `export interface ${className}Methods${genericParams ? `<${genericParams}>` : \"\"} {\n${methods}\n}`;\n }\n\n /**\n * Collect properties that need methods generated.\n */\n private collectPropertiesForMethods(\n objectType: ObjectType,\n isAsset: boolean,\n ): PropertyInfo[] {\n const properties: PropertyInfo[] = [];\n const seenProps = new Set<string>();\n\n // Add inherited Asset properties for asset types\n // Skip if the type explicitly declares the property (explicit takes precedence)\n if (isAsset && !(\"id\" in objectType.properties)) {\n // Add id property - all assets have an id\n properties.push({\n propName: \"id\",\n propType: { type: \"string\" },\n description: \"A unique identifier for this asset\",\n });\n seenProps.add(\"id\");\n }\n\n // Add properties from the object type\n for (const [propName, prop] of Object.entries(objectType.properties)) {\n // Skip if we've already seen this property (deduplication)\n if (seenProps.has(propName)) {\n continue;\n }\n seenProps.add(propName);\n properties.push({\n propName,\n propType: prop.node,\n description: prop.node.description || `Sets the ${propName} property`,\n });\n }\n\n return properties;\n }\n\n /**\n * Generate class methods for the builder.\n */\n private generateClassMethods(info: BuilderInfo): string {\n const { className, objectType, genericParams, isAsset } = info;\n const genericUsage = extractGenericUsage(genericParams);\n\n // Collect all properties to generate methods for\n const properties = this.collectPropertiesForMethods(objectType, isAsset);\n\n return properties\n .map(({ propName, propType, description }) => {\n const methodName = `with${toPascalCase(propName)}`;\n const paramType = this.typeTransformer.transformType(propType, true);\n\n // Track array properties (including union types that contain arrays)\n if (containsArrayType(propType)) {\n this.arrayProperties.add(propName);\n }\n\n return ` /** ${description} */\n ${methodName}(value: ${paramType}): ${className}${genericUsage} {\n return this.set(\"${propName}\", value);\n }`;\n })\n .join(\"\\n\\n\");\n }\n\n /**\n * Generate default values object using DefaultValueGenerator.\n */\n private generateDefaults(objectType: ObjectType, assetType?: string): string {\n const defaults = this.defaultValueGenerator.generateDefaults(\n objectType,\n assetType,\n );\n return JSON.stringify(defaults);\n }\n}\n","import { normalize, sep, dirname, relative, resolve } from \"path\";\n\n/**\n * Normalizes a file path and splits it into parts.\n */\nfunction normalizeAndSplitPath(filePath: string): string[] {\n return normalize(filePath).split(sep);\n}\n\n/**\n * Checks if a path segment indicates a package directory.\n */\nfunction isPackageDirectory(part: string): boolean {\n return part === \"node_modules\" || part.startsWith(\".pnpm\");\n}\n\n/**\n * Determines if a file path appears to be from a package (node_modules or pnpm store).\n *\n * @param filePath - The file path to analyze\n * @returns True if the path looks like it belongs to a package\n *\n * @example\n * ```ts\n * isNodeModulesPath('/project/node_modules/react/index.d.ts') // true\n * isNodeModulesPath('/project/src/components/Button.ts') // false\n * isNodeModulesPath('/project/node_modules/.pnpm/react@18.0.0/...') // true\n * ```\n */\nexport function isNodeModulesPath(filePath: string): boolean {\n const parts = normalizeAndSplitPath(filePath);\n return parts.some(isPackageDirectory);\n}\n\n/**\n * Extracts the package name from a node_modules path.\n * Handles npm, pnpm store, scoped packages, and various structures.\n *\n * @param filePath - The file path to extract package name from\n * @returns The package name (e.g., 'lodash', '@player-lang/types') or null\n *\n * @example\n * ```ts\n * // Standard npm package\n * extractPackageNameFromPath('/project/node_modules/lodash/index.d.ts')\n * // Returns: 'lodash'\n *\n * // Scoped package\n * extractPackageNameFromPath('/project/node_modules/@player-lang/types/index.d.ts')\n * // Returns: '@player-lang/types'\n *\n * // pnpm store\n * extractPackageNameFromPath('/project/node_modules/.pnpm/@player-lang+types@1.0.0/node_modules/@player-lang/types/index.d.ts')\n * // Returns: '@player-lang/types'\n * ```\n */\nexport function extractPackageNameFromPath(filePath: string): string | null {\n const parts = normalizeAndSplitPath(filePath);\n\n // Find the last occurrence of node_modules (for pnpm which has nested node_modules)\n let lastNodeModulesIndex = -1;\n for (let i = parts.length - 1; i >= 0; i--) {\n if (parts[i] === \"node_modules\") {\n lastNodeModulesIndex = i;\n break;\n }\n }\n\n if (lastNodeModulesIndex === -1 || lastNodeModulesIndex >= parts.length - 1) {\n return null;\n }\n\n const afterNodeModules = parts.slice(lastNodeModulesIndex + 1);\n\n // Check if it's a scoped package (@scope/package)\n if (afterNodeModules[0]?.startsWith(\"@\")) {\n if (afterNodeModules.length >= 2) {\n return `${afterNodeModules[0]}/${afterNodeModules[1]}`;\n }\n return null;\n }\n\n // Regular package\n return afterNodeModules[0] || null;\n}\n\n/**\n * Creates a relative import path from one file to another.\n * Converts TypeScript extensions to JavaScript for runtime imports.\n *\n * @param fromFile - The absolute path of the importing file\n * @param toFile - The absolute path of the file being imported\n * @returns Relative import path with .js extension\n *\n * @example\n * ```ts\n * createRelativeImportPath('/project/src/types/foo.ts', '/project/src/types/bar.ts')\n * // Returns: './bar.js'\n *\n * createRelativeImportPath('/project/src/builders/foo.ts', '/project/src/types/bar.ts')\n * // Returns: '../types/bar.js'\n * ```\n */\nexport function createRelativeImportPath(\n fromFile: string,\n toFile: string,\n): string {\n const fromDir = dirname(fromFile);\n let relativePath = relative(fromDir, toFile);\n\n // Convert TypeScript extensions to JavaScript\n relativePath = relativePath.replace(/\\.tsx?$/, \".js\");\n relativePath = relativePath.replace(/\\.d\\.ts$/, \".js\");\n\n // Ensure the path starts with ./ or ../\n if (!relativePath.startsWith(\".\")) {\n relativePath = `./${relativePath}`;\n }\n\n return relativePath;\n}\n\n/**\n * Resolves a relative import path to an absolute file path.\n * Handles .js to .ts conversion for TypeScript resolution.\n *\n * @param fromFile - The absolute path of the file containing the import\n * @param importSpecifier - The import specifier (e.g., './types', '../utils.js')\n * @returns Absolute path with .ts extension\n */\nexport function resolveRelativeImportPath(\n fromFile: string,\n importSpecifier: string,\n): string {\n const fromDir = dirname(fromFile);\n\n // Convert .js to .ts for TypeScript resolution\n let actualSpecifier = importSpecifier;\n if (importSpecifier.endsWith(\".js\")) {\n actualSpecifier = importSpecifier.replace(/\\.js$/, \".ts\");\n }\n\n let resolvedPath = resolve(fromDir, actualSpecifier);\n\n // Add .ts extension if not present\n if (\n !resolvedPath.endsWith(\".ts\") &&\n !resolvedPath.endsWith(\".tsx\") &&\n !resolvedPath.endsWith(\".d.ts\")\n ) {\n resolvedPath += \".ts\";\n }\n\n return resolvedPath;\n}\n","import { TsMorphTypeDefinitionFinder } from \"./ts-morph-type-finder\";\nimport {\n isNodeModulesPath,\n extractPackageNameFromPath,\n createRelativeImportPath,\n} from \"./path-utils\";\n\n/**\n * Categorized types for import generation.\n * Types are split into three categories based on where they should be imported from.\n */\nexport interface TypeCategories {\n /** Types defined in the same file as the main type (import from main source) */\n localTypes: Set<string>;\n /** Types from other local files, grouped by relative import path */\n relativeImports: Map<string, Set<string>>;\n /** Types from external packages (node_modules), mapped to package name */\n externalTypes: Map<string, string>;\n}\n\n/**\n * Options for type categorization.\n */\nexport interface CategorizerOptions {\n /** The main source file being generated */\n mainSourceFile: string;\n /** Types known to be in the main source file (optional optimization) */\n sameFileTypes?: Set<string>;\n}\n\n/**\n * Categorizes referenced types into local, relative, and external imports.\n *\n * Uses TsMorphTypeDefinitionFinder to resolve where each type is defined, then\n * categorizes based on the resolved path:\n * - Same file as main → localTypes\n * - Different local file → relativeImports\n * - node_modules → externalTypes\n *\n * @param referencedTypes - Set of type names that need to be imported\n * @param finder - TsMorphTypeDefinitionFinder instance for resolving type locations\n * @param options - Categorization options including main source file\n * @returns Categorized types for import generation\n */\nexport function categorizeTypes(\n referencedTypes: Set<string>,\n finder: TsMorphTypeDefinitionFinder,\n options: CategorizerOptions,\n): TypeCategories {\n const { mainSourceFile, sameFileTypes } = options;\n\n const result: TypeCategories = {\n localTypes: new Set(),\n relativeImports: new Map(),\n externalTypes: new Map(),\n };\n\n for (const typeName of referencedTypes) {\n // Optimization: if we know the type is in the same file, skip resolution\n if (sameFileTypes?.has(typeName)) {\n result.localTypes.add(typeName);\n continue;\n }\n\n // Try to resolve the type's source file\n const sourceFile = finder.findTypeSourceFile(typeName, mainSourceFile);\n\n if (!sourceFile) {\n // Could not resolve - assume it's in the same file\n result.localTypes.add(typeName);\n continue;\n }\n\n // Normalize paths for comparison\n const normalizedSource = normalizePath(sourceFile);\n const normalizedMain = normalizePath(mainSourceFile);\n\n if (normalizedSource === normalizedMain) {\n // Same file\n result.localTypes.add(typeName);\n } else if (isNodeModulesPath(sourceFile)) {\n // External package\n const packageName = extractPackageNameFromPath(sourceFile);\n if (packageName) {\n result.externalTypes.set(typeName, packageName);\n } else {\n // Couldn't extract package name, fallback to local\n result.localTypes.add(typeName);\n }\n } else {\n // Different local file - create relative import path\n const relativePath = createRelativeImportPath(mainSourceFile, sourceFile);\n if (!result.relativeImports.has(relativePath)) {\n result.relativeImports.set(relativePath, new Set());\n }\n result.relativeImports.get(relativePath)!.add(typeName);\n }\n }\n\n return result;\n}\n\n/**\n * Groups external types by their package name for import generation.\n * This allows generating single imports per package with multiple types.\n *\n * @param externalTypes - Map of typeName → packageName\n * @returns Map of packageName → Set of typeNames\n */\nexport function groupExternalTypesByPackage(\n externalTypes: Map<string, string>,\n): Map<string, Set<string>> {\n const grouped = new Map<string, Set<string>>();\n\n for (const [typeName, packageName] of externalTypes) {\n if (!grouped.has(packageName)) {\n grouped.set(packageName, new Set());\n }\n grouped.get(packageName)!.add(typeName);\n }\n\n return grouped;\n}\n\n/**\n * Normalizes a file path for comparison.\n * Removes trailing slashes and normalizes separators.\n */\nfunction normalizePath(filePath: string): string {\n return filePath.replace(/\\\\/g, \"/\").replace(/\\/$/, \"\");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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