@famgia/omnify-typescript 0.0.1 → 0.0.4

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.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/interface-generator.ts","../src/enum-generator.ts","../src/generator.ts"],"sourcesContent":["/**\n * @famgia/omnify-typescript\n *\n * TypeScript type definitions generator for Omnify schemas.\n */\n\nexport type {\n TypeScriptFile,\n TypeScriptOptions,\n TSProperty,\n TSInterface,\n TSEnum,\n TSEnumValue,\n TSTypeAlias,\n} from './types.js';\n\nexport {\n toPropertyName,\n toInterfaceName,\n getPropertyType,\n propertyToTSProperty,\n schemaToInterface,\n formatProperty,\n formatInterface,\n generateInterfaces,\n} from './interface-generator.js';\n\nexport {\n toEnumMemberName,\n toEnumName,\n schemaToEnum,\n generateEnums,\n formatEnum,\n enumToUnionType,\n formatTypeAlias,\n extractInlineEnums,\n} from './enum-generator.js';\n\nexport {\n generateTypeScriptFile,\n generateTypeScriptFiles,\n generateTypeScript,\n getTypeScriptPath,\n} from './generator.js';\n","/**\n * @famgia/omnify-laravel - TypeScript Interface Generator\n *\n * Generates TypeScript interfaces from schemas.\n */\n\nimport type { LoadedSchema, PropertyDefinition, SchemaCollection } from '@famgia/omnify-types';\nimport type { TSInterface, TSProperty, TypeScriptOptions } from './types.js';\n\n/**\n * Maps Omnify property types to TypeScript types.\n */\nconst TYPE_MAP: Record<string, string> = {\n String: 'string',\n Int: 'number',\n BigInt: 'number',\n Float: 'number',\n Boolean: 'boolean',\n Text: 'string',\n LongText: 'string',\n Date: 'string',\n Time: 'string',\n Timestamp: 'string',\n Json: 'unknown',\n Email: 'string',\n Password: 'string',\n Enum: 'string',\n Select: 'string',\n Lookup: 'number',\n};\n\n/**\n * File interface name (references the File.yaml schema).\n * The File schema is auto-generated by ensureFileSchema() when File type is used.\n */\nexport const FILE_INTERFACE_NAME = 'File';\n\n/**\n * Maps primary key types to TypeScript types.\n */\nconst PK_TYPE_MAP: Record<string, string> = {\n Int: 'number',\n BigInt: 'number',\n Uuid: 'string',\n String: 'string',\n};\n\n/**\n * Converts property name to TypeScript property name.\n * Preserves camelCase.\n */\nexport function toPropertyName(name: string): string {\n return name;\n}\n\n/**\n * Converts schema name to TypeScript interface name.\n * Preserves PascalCase.\n */\nexport function toInterfaceName(schemaName: string): string {\n return schemaName;\n}\n\n/**\n * Gets TypeScript type for a property.\n */\nexport function getPropertyType(\n property: PropertyDefinition,\n _allSchemas: SchemaCollection\n): string {\n // Handle File type specially (polymorphic relation to files table)\n // References the File interface generated from File.yaml schema\n if (property.type === 'File') {\n const fileProp = property as { multiple?: boolean };\n if (fileProp.multiple) {\n return `${FILE_INTERFACE_NAME}[]`;\n }\n return `${FILE_INTERFACE_NAME} | null`;\n }\n\n // Handle associations\n if (property.type === 'Association') {\n const assocProp = property as {\n relation?: string;\n target?: string;\n targets?: readonly string[];\n };\n\n const targetName = assocProp.target ?? 'unknown';\n\n switch (assocProp.relation) {\n // Standard relations\n case 'OneToOne':\n case 'ManyToOne':\n return targetName;\n case 'OneToMany':\n case 'ManyToMany':\n return `${targetName}[]`;\n\n // Polymorphic relations\n case 'MorphTo':\n // Union type of all possible targets\n if (assocProp.targets && assocProp.targets.length > 0) {\n return assocProp.targets.join(' | ');\n }\n return 'unknown';\n case 'MorphOne':\n return targetName;\n case 'MorphMany':\n case 'MorphToMany':\n case 'MorphedByMany':\n return `${targetName}[]`;\n\n default:\n return 'unknown';\n }\n }\n\n // Handle enum types\n if (property.type === 'Enum') {\n const enumProp = property as { enum?: string | readonly string[] };\n if (typeof enumProp.enum === 'string') {\n // Reference to a named enum\n return enumProp.enum;\n }\n if (Array.isArray(enumProp.enum)) {\n // Inline enum - create union type\n return enumProp.enum.map(v => `'${v}'`).join(' | ');\n }\n }\n\n // Handle Select with options\n if (property.type === 'Select') {\n const selectProp = property as { options?: readonly string[] };\n if (selectProp.options && selectProp.options.length > 0) {\n return selectProp.options.map(v => `'${v}'`).join(' | ');\n }\n }\n\n // Standard type mapping\n return TYPE_MAP[property.type] ?? 'unknown';\n}\n\n/**\n * Converts a property to TypeScript property definition.\n * For MorphTo, returns multiple properties (_type, _id, and relation).\n */\nexport function propertyToTSProperties(\n propertyName: string,\n property: PropertyDefinition,\n allSchemas: SchemaCollection,\n options: TypeScriptOptions = {}\n): TSProperty[] {\n const baseProp = property as { nullable?: boolean; displayName?: string };\n const isReadonly = options.readonly ?? true;\n\n // Handle MorphTo specially - it creates _type and _id columns\n if (property.type === 'Association') {\n const assocProp = property as {\n relation?: string;\n targets?: readonly string[];\n };\n\n if (assocProp.relation === 'MorphTo' && assocProp.targets && assocProp.targets.length > 0) {\n const propBaseName = toPropertyName(propertyName);\n const targetUnion = assocProp.targets.map(t => `'${t}'`).join(' | ');\n const relationUnion = assocProp.targets.join(' | ');\n\n return [\n {\n name: `${propBaseName}Type`,\n type: targetUnion,\n optional: true, // Polymorphic columns are nullable\n readonly: isReadonly,\n comment: `Polymorphic type for ${propertyName}`,\n },\n {\n name: `${propBaseName}Id`,\n type: 'number',\n optional: true,\n readonly: isReadonly,\n comment: `Polymorphic ID for ${propertyName}`,\n },\n {\n name: propBaseName,\n type: `${relationUnion} | null`,\n optional: true,\n readonly: isReadonly,\n comment: baseProp.displayName ?? `Polymorphic relation to ${assocProp.targets.join(', ')}`,\n },\n ];\n }\n }\n\n // Default: single property\n const type = getPropertyType(property, allSchemas);\n\n return [{\n name: toPropertyName(propertyName),\n type,\n optional: baseProp.nullable ?? false,\n readonly: isReadonly,\n comment: baseProp.displayName,\n }];\n}\n\n/**\n * Converts a property to TypeScript property definition (legacy - returns single property).\n */\nexport function propertyToTSProperty(\n propertyName: string,\n property: PropertyDefinition,\n allSchemas: SchemaCollection,\n options: TypeScriptOptions = {}\n): TSProperty {\n return propertyToTSProperties(propertyName, property, allSchemas, options)[0]!;\n}\n\n/**\n * Generates TypeScript interface from schema.\n */\nexport function schemaToInterface(\n schema: LoadedSchema,\n allSchemas: SchemaCollection,\n options: TypeScriptOptions = {}\n): TSInterface {\n const properties: TSProperty[] = [];\n\n // ID property (only if id is not disabled)\n if (schema.options?.id !== false) {\n const pkType = (schema.options?.idType ?? 'BigInt') as keyof typeof PK_TYPE_MAP;\n properties.push({\n name: 'id',\n type: PK_TYPE_MAP[pkType] ?? 'number',\n optional: false,\n readonly: options.readonly ?? true,\n comment: 'Primary key',\n });\n }\n\n // Schema properties\n if (schema.properties) {\n for (const [propName, property] of Object.entries(schema.properties)) {\n // Use propertyToTSProperties which handles MorphTo returning multiple properties\n properties.push(...propertyToTSProperties(propName, property, allSchemas, options));\n }\n }\n\n // Timestamps\n if (schema.options?.timestamps !== false) {\n properties.push(\n {\n name: 'createdAt',\n type: 'string',\n optional: true,\n readonly: options.readonly ?? true,\n comment: 'Creation timestamp',\n },\n {\n name: 'updatedAt',\n type: 'string',\n optional: true,\n readonly: options.readonly ?? true,\n comment: 'Last update timestamp',\n }\n );\n }\n\n // Soft delete\n if (schema.options?.softDelete) {\n properties.push({\n name: 'deletedAt',\n type: 'string',\n optional: true,\n readonly: options.readonly ?? true,\n comment: 'Soft delete timestamp',\n });\n }\n\n return {\n name: toInterfaceName(schema.name),\n properties,\n comment: schema.displayName ?? schema.name,\n };\n}\n\n/**\n * Formats a TypeScript property.\n */\nexport function formatProperty(property: TSProperty): string {\n const readonly = property.readonly ? 'readonly ' : '';\n const optional = property.optional ? '?' : '';\n const comment = property.comment ? ` /** ${property.comment} */\\n` : '';\n return `${comment} ${readonly}${property.name}${optional}: ${property.type};`;\n}\n\n/**\n * Formats a TypeScript interface.\n */\nexport function formatInterface(iface: TSInterface): string {\n const comment = iface.comment ? `/**\\n * ${iface.comment}\\n */\\n` : '';\n const extendsClause = iface.extends && iface.extends.length > 0\n ? ` extends ${iface.extends.join(', ')}`\n : '';\n const properties = iface.properties.map(formatProperty).join('\\n');\n\n return `${comment}export interface ${iface.name}${extendsClause} {\\n${properties}\\n}`;\n}\n\n/**\n * Generates interfaces for all schemas.\n * Note: File interface is now generated from File.yaml schema (use ensureFileSchema() to auto-create it).\n */\nexport function generateInterfaces(\n schemas: SchemaCollection,\n options: TypeScriptOptions = {}\n): TSInterface[] {\n const interfaces: TSInterface[] = [];\n\n for (const schema of Object.values(schemas)) {\n // Skip enum schemas\n if (schema.kind === 'enum') {\n continue;\n }\n\n interfaces.push(schemaToInterface(schema, schemas, options));\n }\n\n return interfaces;\n}\n","/**\n * @famgia/omnify-laravel - TypeScript Enum Generator\n *\n * Generates TypeScript enums from schema enum definitions.\n */\n\nimport type { LoadedSchema, SchemaCollection } from '@famgia/omnify-types';\nimport type { TSEnum, TSEnumValue, TSTypeAlias } from './types.js';\n\n/**\n * Converts enum value to valid TypeScript enum member name.\n */\nexport function toEnumMemberName(value: string): string {\n // Convert to PascalCase and remove invalid characters\n return value\n .split(/[-_\\s]+/)\n .map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())\n .join('')\n .replace(/[^a-zA-Z0-9]/g, '');\n}\n\n/**\n * Converts schema name to TypeScript enum name.\n */\nexport function toEnumName(schemaName: string): string {\n return schemaName;\n}\n\n/**\n * Generates TypeScript enum from schema enum.\n */\nexport function schemaToEnum(schema: LoadedSchema): TSEnum | null {\n if (schema.kind !== 'enum' || !schema.values) {\n return null;\n }\n\n const values: TSEnumValue[] = schema.values.map(value => ({\n name: toEnumMemberName(value),\n value,\n }));\n\n return {\n name: toEnumName(schema.name),\n values,\n comment: schema.displayName ?? schema.name,\n };\n}\n\n/**\n * Generates enums for all enum schemas.\n */\nexport function generateEnums(schemas: SchemaCollection): TSEnum[] {\n const enums: TSEnum[] = [];\n\n for (const schema of Object.values(schemas)) {\n if (schema.kind === 'enum') {\n const enumDef = schemaToEnum(schema);\n if (enumDef) {\n enums.push(enumDef);\n }\n }\n }\n\n return enums;\n}\n\n/**\n * Formats a TypeScript enum.\n */\nexport function formatEnum(enumDef: TSEnum): string {\n const comment = enumDef.comment ? `/**\\n * ${enumDef.comment}\\n */\\n` : '';\n const values = enumDef.values\n .map(v => ` ${v.name} = '${v.value}',`)\n .join('\\n');\n\n return `${comment}export enum ${enumDef.name} {\\n${values}\\n}`;\n}\n\n/**\n * Generates a union type alias as an alternative to enum.\n */\nexport function enumToUnionType(enumDef: TSEnum): TSTypeAlias {\n const type = enumDef.values\n .map(v => `'${v.value}'`)\n .join(' | ');\n\n return {\n name: enumDef.name,\n type,\n comment: enumDef.comment,\n };\n}\n\n/**\n * Formats a TypeScript type alias.\n */\nexport function formatTypeAlias(alias: TSTypeAlias): string {\n const comment = alias.comment ? `/**\\n * ${alias.comment}\\n */\\n` : '';\n return `${comment}export type ${alias.name} = ${alias.type};`;\n}\n\n/**\n * Extracts inline enums from properties for type generation.\n */\nexport function extractInlineEnums(schemas: SchemaCollection): TSTypeAlias[] {\n const typeAliases: TSTypeAlias[] = [];\n\n for (const schema of Object.values(schemas)) {\n if (schema.kind === 'enum' || !schema.properties) {\n continue;\n }\n\n for (const [propName, property] of Object.entries(schema.properties)) {\n if (property.type === 'Enum') {\n const enumProp = property as { enum?: readonly string[]; displayName?: string };\n\n // Only handle inline array enums (not references to named enums)\n if (Array.isArray(enumProp.enum) && enumProp.enum.length > 0) {\n const typeName = `${schema.name}${propName.charAt(0).toUpperCase() + propName.slice(1)}`;\n typeAliases.push({\n name: typeName,\n type: enumProp.enum.map(v => `'${v}'`).join(' | '),\n comment: enumProp.displayName ?? `${schema.name} ${propName} enum`,\n });\n }\n }\n\n if (property.type === 'Select') {\n const selectProp = property as { options?: readonly string[]; displayName?: string };\n\n if (selectProp.options && selectProp.options.length > 0) {\n const typeName = `${schema.name}${propName.charAt(0).toUpperCase() + propName.slice(1)}`;\n typeAliases.push({\n name: typeName,\n type: selectProp.options.map(v => `'${v}'`).join(' | '),\n comment: selectProp.displayName ?? `${schema.name} ${propName} options`,\n });\n }\n }\n }\n }\n\n return typeAliases;\n}\n","/**\n * @famgia/omnify-laravel - TypeScript Generator\n *\n * Main TypeScript code generator combining interfaces, enums, and types.\n */\n\nimport type { SchemaCollection } from '@famgia/omnify-types';\nimport type { TypeScriptFile, TypeScriptOptions, TSInterface, TSEnum, TSTypeAlias } from './types.js';\nimport { generateInterfaces, formatInterface } from './interface-generator.js';\nimport { generateEnums, formatEnum, formatTypeAlias, extractInlineEnums } from './enum-generator.js';\n\n/**\n * Default options for TypeScript generation.\n */\nconst DEFAULT_OPTIONS: TypeScriptOptions = {\n singleFile: true,\n fileName: 'types.ts',\n readonly: true,\n strictNullChecks: true,\n};\n\n/**\n * Generates the file header comment.\n */\nfunction generateHeader(): string {\n return `/**\n * Auto-generated TypeScript types from Omnify schemas.\n * DO NOT EDIT - This file is automatically generated.\n */\n\n`;\n}\n\n/**\n * Generates all TypeScript code as a single file.\n */\nexport function generateTypeScriptFile(\n schemas: SchemaCollection,\n options: TypeScriptOptions = {}\n): TypeScriptFile {\n const opts = { ...DEFAULT_OPTIONS, ...options };\n const parts: string[] = [generateHeader()];\n const types: string[] = [];\n\n // Generate enums first (they're referenced by interfaces)\n const enums = generateEnums(schemas);\n if (enums.length > 0) {\n parts.push('// Enums\\n');\n for (const enumDef of enums) {\n parts.push(formatEnum(enumDef));\n parts.push('\\n\\n');\n types.push(enumDef.name);\n }\n }\n\n // Generate inline enum type aliases\n const inlineEnums = extractInlineEnums(schemas);\n if (inlineEnums.length > 0) {\n parts.push('// Type Aliases\\n');\n for (const alias of inlineEnums) {\n parts.push(formatTypeAlias(alias));\n parts.push('\\n\\n');\n types.push(alias.name);\n }\n }\n\n // Generate interfaces\n const interfaces = generateInterfaces(schemas, opts);\n if (interfaces.length > 0) {\n parts.push('// Interfaces\\n');\n for (const iface of interfaces) {\n parts.push(formatInterface(iface));\n parts.push('\\n\\n');\n types.push(iface.name);\n }\n }\n\n return {\n fileName: opts.fileName ?? 'types.ts',\n content: parts.join('').trim() + '\\n',\n types,\n };\n}\n\n/**\n * Generates TypeScript code as multiple files.\n */\nexport function generateTypeScriptFiles(\n schemas: SchemaCollection,\n options: TypeScriptOptions = {}\n): TypeScriptFile[] {\n const opts = { ...DEFAULT_OPTIONS, ...options };\n const files: TypeScriptFile[] = [];\n\n // Enums file\n const enums = generateEnums(schemas);\n if (enums.length > 0) {\n const content = generateHeader() +\n enums.map(formatEnum).join('\\n\\n') + '\\n';\n files.push({\n fileName: 'enums.ts',\n content,\n types: enums.map(e => e.name),\n });\n }\n\n // Inline enums/type aliases file\n const inlineEnums = extractInlineEnums(schemas);\n if (inlineEnums.length > 0) {\n const content = generateHeader() +\n inlineEnums.map(formatTypeAlias).join('\\n\\n') + '\\n';\n files.push({\n fileName: 'type-aliases.ts',\n content,\n types: inlineEnums.map(a => a.name),\n });\n }\n\n // Individual interface files\n const interfaces = generateInterfaces(schemas, opts);\n for (const iface of interfaces) {\n const imports = collectImports(iface, enums, inlineEnums, interfaces);\n const importStatement = formatImports(imports);\n\n const content = generateHeader() +\n (importStatement ? importStatement + '\\n\\n' : '') +\n formatInterface(iface) + '\\n';\n\n files.push({\n fileName: `${toKebabCase(iface.name)}.ts`,\n content,\n types: [iface.name],\n });\n }\n\n // Index file\n const indexContent = generateIndexFile(files);\n files.push({\n fileName: 'index.ts',\n content: indexContent,\n types: [],\n });\n\n return files;\n}\n\n/**\n * Converts PascalCase to kebab-case.\n */\nfunction toKebabCase(name: string): string {\n return name\n .replace(/([A-Z])/g, '-$1')\n .toLowerCase()\n .replace(/^-/, '');\n}\n\n/**\n * Collects imports needed for an interface.\n */\nfunction collectImports(\n iface: TSInterface,\n enums: TSEnum[],\n typeAliases: TSTypeAlias[],\n allInterfaces: TSInterface[]\n): Map<string, string[]> {\n const imports = new Map<string, string[]>();\n const enumNames = new Set(enums.map(e => e.name));\n const aliasNames = new Set(typeAliases.map(a => a.name));\n const interfaceNames = new Set(allInterfaces.map(i => i.name));\n\n for (const prop of iface.properties) {\n // Check if type references an enum\n if (enumNames.has(prop.type)) {\n const existing = imports.get('./enums.js') ?? [];\n if (!existing.includes(prop.type)) {\n imports.set('./enums.js', [...existing, prop.type]);\n }\n }\n\n // Check if type references a type alias\n if (aliasNames.has(prop.type)) {\n const existing = imports.get('./type-aliases.js') ?? [];\n if (!existing.includes(prop.type)) {\n imports.set('./type-aliases.js', [...existing, prop.type]);\n }\n }\n\n // Check if type references another interface (for relationships)\n const baseType = prop.type.replace('[]', '');\n if (interfaceNames.has(baseType) && baseType !== iface.name) {\n const fileName = `./${toKebabCase(baseType)}.js`;\n const existing = imports.get(fileName) ?? [];\n if (!existing.includes(baseType)) {\n imports.set(fileName, [...existing, baseType]);\n }\n }\n }\n\n return imports;\n}\n\n/**\n * Formats import statements.\n */\nfunction formatImports(imports: Map<string, string[]>): string {\n if (imports.size === 0) return '';\n\n const lines: string[] = [];\n for (const [path, names] of imports) {\n lines.push(`import type { ${names.join(', ')} } from '${path}';`);\n }\n return lines.join('\\n');\n}\n\n/**\n * Generates index.ts file for re-exports.\n */\nfunction generateIndexFile(files: TypeScriptFile[]): string {\n const exports: string[] = [generateHeader().trim(), ''];\n\n for (const file of files) {\n if (file.fileName === 'index.ts') continue;\n const moduleName = file.fileName.replace('.ts', '.js');\n exports.push(`export * from './${moduleName}';`);\n }\n\n return exports.join('\\n') + '\\n';\n}\n\n/**\n * Generates TypeScript types with configurable output.\n */\nexport function generateTypeScript(\n schemas: SchemaCollection,\n options: TypeScriptOptions = {}\n): TypeScriptFile[] {\n const opts = { ...DEFAULT_OPTIONS, ...options };\n\n if (opts.singleFile) {\n return [generateTypeScriptFile(schemas, opts)];\n }\n\n return generateTypeScriptFiles(schemas, opts);\n}\n\n/**\n * Gets output path for a TypeScript file.\n */\nexport function getTypeScriptPath(\n file: TypeScriptFile,\n outputDir: string = 'src/types'\n): string {\n return `${outputDir}/${file.fileName}`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAA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AI,CAAC,YAAY,IAAI,IAAI;AAAA,EAClE;AACA,SAAO,MAAM,KAAK,IAAI;AACxB;AAKA,SAAS,kBAAkB,OAAiC;AAC1D,QAAMA,WAAoB,CAAC,eAAe,EAAE,KAAK,GAAG,EAAE;AAEtD,aAAW,QAAQ,OAAO;AACxB,QAAI,KAAK,aAAa,WAAY;AAClC,UAAM,aAAa,KAAK,SAAS,QAAQ,OAAO,KAAK;AACrD,IAAAA,SAAQ,KAAK,oBAAoB,UAAU,IAAI;AAAA,EACjD;AAEA,SAAOA,SAAQ,KAAK,IAAI,IAAI;AAC9B;AAKO,SAAS,mBACd,SACA,UAA6B,CAAC,GACZ;AAClB,QAAM,OAAO,EAAE,GAAG,iBAAiB,GAAG,QAAQ;AAE9C,MAAI,KAAK,YAAY;AACnB,WAAO,CAAC,uBAAuB,SAAS,IAAI,CAAC;AAAA,EAC/C;AAEA,SAAO,wBAAwB,SAAS,IAAI;AAC9C;AAKO,SAAS,kBACd,MACA,YAAoB,aACZ;AACR,SAAO,GAAG,SAAS,IAAI,KAAK,QAAQ;AACtC;","names":["exports"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/interface-generator.ts","../src/enum-generator.ts","../src/generator.ts"],"sourcesContent":["/**\n * @famgia/omnify-typescript\n *\n * TypeScript type definitions generator for Omnify schemas.\n */\n\nexport type {\n TypeScriptFile,\n TypeScriptOptions,\n TSProperty,\n TSInterface,\n TSEnum,\n TSEnumValue,\n TSTypeAlias,\n} from './types.js';\n\nexport {\n toPropertyName,\n toInterfaceName,\n getPropertyType,\n propertyToTSProperty,\n schemaToInterface,\n formatProperty,\n formatInterface,\n generateInterfaces,\n} from './interface-generator.js';\n\nexport {\n toEnumMemberName,\n toEnumName,\n schemaToEnum,\n generateEnums,\n formatEnum,\n enumToUnionType,\n formatTypeAlias,\n extractInlineEnums,\n} from './enum-generator.js';\n\nexport {\n generateTypeScript,\n generateTypeScriptFiles,\n} from './generator.js';\n","/**\n * @famgia/omnify-laravel - TypeScript Interface Generator\n *\n * Generates TypeScript interfaces from schemas.\n */\n\nimport type { LoadedSchema, PropertyDefinition, SchemaCollection, LocalizedString } from '@famgia/omnify-types';\nimport { resolveLocalizedString } from '@famgia/omnify-types';\nimport type { TSInterface, TSProperty, TypeScriptOptions } from './types.js';\n\n/**\n * Maps Omnify property types to TypeScript types.\n */\nconst TYPE_MAP: Record<string, string> = {\n String: 'string',\n Int: 'number',\n BigInt: 'number',\n Float: 'number',\n Boolean: 'boolean',\n Text: 'string',\n LongText: 'string',\n Date: 'string',\n Time: 'string',\n Timestamp: 'string',\n Json: 'unknown',\n Email: 'string',\n Password: 'string',\n Enum: 'string',\n Select: 'string',\n Lookup: 'number',\n};\n\n/**\n * File interface name (references the File.yaml schema).\n * The File schema is auto-generated by ensureFileSchema() when File type is used.\n */\nexport const FILE_INTERFACE_NAME = 'File';\n\n/**\n * Maps primary key types to TypeScript types.\n */\nconst PK_TYPE_MAP: Record<string, string> = {\n Int: 'number',\n BigInt: 'number',\n Uuid: 'string',\n String: 'string',\n};\n\n/**\n * Resolves a localized string using the given options.\n * Returns undefined if the value is undefined or cannot be resolved.\n */\nfunction resolveDisplayName(\n value: LocalizedString | undefined,\n options: TypeScriptOptions = {}\n): string | undefined {\n if (value === undefined) {\n return undefined;\n }\n return resolveLocalizedString(value, {\n locale: options.locale,\n config: options.localeConfig,\n });\n}\n\n/**\n * Converts property name to TypeScript property name.\n * Preserves camelCase.\n */\nexport function toPropertyName(name: string): string {\n return name;\n}\n\n/**\n * Converts schema name to TypeScript interface name.\n * Preserves PascalCase.\n */\nexport function toInterfaceName(schemaName: string): string {\n return schemaName;\n}\n\n/**\n * Gets TypeScript type for a property.\n */\nexport function getPropertyType(\n property: PropertyDefinition,\n _allSchemas: SchemaCollection\n): string {\n // Handle File type specially (polymorphic relation to files table)\n // References the File interface generated from File.yaml schema\n if (property.type === 'File') {\n const fileProp = property as { multiple?: boolean };\n if (fileProp.multiple) {\n return `${FILE_INTERFACE_NAME}[]`;\n }\n return `${FILE_INTERFACE_NAME} | null`;\n }\n\n // Handle associations\n if (property.type === 'Association') {\n const assocProp = property as {\n relation?: string;\n target?: string;\n targets?: readonly string[];\n };\n\n const targetName = assocProp.target ?? 'unknown';\n\n switch (assocProp.relation) {\n // Standard relations\n case 'OneToOne':\n case 'ManyToOne':\n return targetName;\n case 'OneToMany':\n case 'ManyToMany':\n return `${targetName}[]`;\n\n // Polymorphic relations\n case 'MorphTo':\n // Union type of all possible targets\n if (assocProp.targets && assocProp.targets.length > 0) {\n return assocProp.targets.join(' | ');\n }\n return 'unknown';\n case 'MorphOne':\n return targetName;\n case 'MorphMany':\n case 'MorphToMany':\n case 'MorphedByMany':\n return `${targetName}[]`;\n\n default:\n return 'unknown';\n }\n }\n\n // Handle enum types\n if (property.type === 'Enum') {\n const enumProp = property as { enum?: string | readonly string[] };\n if (typeof enumProp.enum === 'string') {\n // Reference to a named enum\n return enumProp.enum;\n }\n if (Array.isArray(enumProp.enum)) {\n // Inline enum - create union type\n return enumProp.enum.map(v => `'${v}'`).join(' | ');\n }\n }\n\n // Handle Select with options\n if (property.type === 'Select') {\n const selectProp = property as { options?: readonly string[] };\n if (selectProp.options && selectProp.options.length > 0) {\n return selectProp.options.map(v => `'${v}'`).join(' | ');\n }\n }\n\n // Standard type mapping\n return TYPE_MAP[property.type] ?? 'unknown';\n}\n\n/**\n * Converts a property to TypeScript property definition.\n * For MorphTo, returns multiple properties (_type, _id, and relation).\n */\nexport function propertyToTSProperties(\n propertyName: string,\n property: PropertyDefinition,\n allSchemas: SchemaCollection,\n options: TypeScriptOptions = {}\n): TSProperty[] {\n const baseProp = property as { nullable?: boolean; displayName?: LocalizedString };\n const isReadonly = options.readonly ?? true;\n // Resolve displayName using locale config\n const displayName = resolveDisplayName(baseProp.displayName, options);\n\n // Handle MorphTo specially - it creates _type and _id columns\n if (property.type === 'Association') {\n const assocProp = property as {\n relation?: string;\n targets?: readonly string[];\n };\n\n if (assocProp.relation === 'MorphTo' && assocProp.targets && assocProp.targets.length > 0) {\n const propBaseName = toPropertyName(propertyName);\n const targetUnion = assocProp.targets.map(t => `'${t}'`).join(' | ');\n const relationUnion = assocProp.targets.join(' | ');\n\n return [\n {\n name: `${propBaseName}Type`,\n type: targetUnion,\n optional: true, // Polymorphic columns are nullable\n readonly: isReadonly,\n comment: `Polymorphic type for ${propertyName}`,\n },\n {\n name: `${propBaseName}Id`,\n type: 'number',\n optional: true,\n readonly: isReadonly,\n comment: `Polymorphic ID for ${propertyName}`,\n },\n {\n name: propBaseName,\n type: `${relationUnion} | null`,\n optional: true,\n readonly: isReadonly,\n comment: displayName ?? `Polymorphic relation to ${assocProp.targets.join(', ')}`,\n },\n ];\n }\n }\n\n // Default: single property\n const type = getPropertyType(property, allSchemas);\n\n return [{\n name: toPropertyName(propertyName),\n type,\n optional: baseProp.nullable ?? false,\n readonly: isReadonly,\n comment: displayName,\n }];\n}\n\n/**\n * Converts a property to TypeScript property definition (legacy - returns single property).\n */\nexport function propertyToTSProperty(\n propertyName: string,\n property: PropertyDefinition,\n allSchemas: SchemaCollection,\n options: TypeScriptOptions = {}\n): TSProperty {\n return propertyToTSProperties(propertyName, property, allSchemas, options)[0]!;\n}\n\n/**\n * Generates TypeScript interface from schema.\n */\nexport function schemaToInterface(\n schema: LoadedSchema,\n allSchemas: SchemaCollection,\n options: TypeScriptOptions = {}\n): TSInterface {\n const properties: TSProperty[] = [];\n\n // ID property (only if id is not disabled)\n if (schema.options?.id !== false) {\n const pkType = (schema.options?.idType ?? 'BigInt') as keyof typeof PK_TYPE_MAP;\n properties.push({\n name: 'id',\n type: PK_TYPE_MAP[pkType] ?? 'number',\n optional: false,\n readonly: options.readonly ?? true,\n comment: 'Primary key',\n });\n }\n\n // Schema properties\n if (schema.properties) {\n for (const [propName, property] of Object.entries(schema.properties)) {\n // Use propertyToTSProperties which handles MorphTo returning multiple properties\n properties.push(...propertyToTSProperties(propName, property, allSchemas, options));\n }\n }\n\n // Timestamps\n if (schema.options?.timestamps !== false) {\n properties.push(\n {\n name: 'createdAt',\n type: 'string',\n optional: true,\n readonly: options.readonly ?? true,\n comment: 'Creation timestamp',\n },\n {\n name: 'updatedAt',\n type: 'string',\n optional: true,\n readonly: options.readonly ?? true,\n comment: 'Last update timestamp',\n }\n );\n }\n\n // Soft delete\n if (schema.options?.softDelete) {\n properties.push({\n name: 'deletedAt',\n type: 'string',\n optional: true,\n readonly: options.readonly ?? true,\n comment: 'Soft delete timestamp',\n });\n }\n\n // Resolve schema displayName using locale config\n const schemaDisplayName = resolveDisplayName(schema.displayName, options);\n\n return {\n name: toInterfaceName(schema.name),\n properties,\n comment: schemaDisplayName ?? schema.name,\n };\n}\n\n/**\n * Formats a TypeScript property.\n */\nexport function formatProperty(property: TSProperty): string {\n const readonly = property.readonly ? 'readonly ' : '';\n const optional = property.optional ? '?' : '';\n const comment = property.comment ? ` /** ${property.comment} */\\n` : '';\n return `${comment} ${readonly}${property.name}${optional}: ${property.type};`;\n}\n\n/**\n * Formats a TypeScript interface.\n */\nexport function formatInterface(iface: TSInterface): string {\n const comment = iface.comment ? `/**\\n * ${iface.comment}\\n */\\n` : '';\n const extendsClause = iface.extends && iface.extends.length > 0\n ? ` extends ${iface.extends.join(', ')}`\n : '';\n const properties = iface.properties.map(formatProperty).join('\\n');\n\n return `${comment}export interface ${iface.name}${extendsClause} {\\n${properties}\\n}`;\n}\n\n/**\n * Generates interfaces for all schemas.\n * Note: File interface is now generated from File.yaml schema (use ensureFileSchema() to auto-create it).\n */\nexport function generateInterfaces(\n schemas: SchemaCollection,\n options: TypeScriptOptions = {}\n): TSInterface[] {\n const interfaces: TSInterface[] = [];\n\n for (const schema of Object.values(schemas)) {\n // Skip enum schemas\n if (schema.kind === 'enum') {\n continue;\n }\n\n interfaces.push(schemaToInterface(schema, schemas, options));\n }\n\n return interfaces;\n}\n","/**\n * @famgia/omnify-typescript - TypeScript Enum Generator\n *\n * Generates TypeScript enums with helper methods from schema enum definitions.\n */\n\nimport type { LoadedSchema, SchemaCollection, LocalizedString } from '@famgia/omnify-types';\nimport { resolveLocalizedString } from '@famgia/omnify-types';\nimport type { TSEnum, TSEnumValue, TSTypeAlias, TypeScriptOptions } from './types.js';\n\n/**\n * Resolves a localized string using the given options.\n */\nfunction resolveDisplayName(\n value: LocalizedString | undefined,\n options: TypeScriptOptions = {}\n): string | undefined {\n if (value === undefined) {\n return undefined;\n }\n return resolveLocalizedString(value, {\n locale: options.locale,\n config: options.localeConfig,\n });\n}\n\n/**\n * Inline enum value from schema (can be string or object with value/label/extra).\n */\ninterface InlineEnumValue {\n readonly value: string;\n readonly label?: string;\n readonly extra?: Readonly<Record<string, unknown>>;\n}\n\n/**\n * Converts enum value to valid TypeScript enum member name.\n */\nexport function toEnumMemberName(value: string): string {\n // Convert to PascalCase and remove invalid characters\n return value\n .split(/[-_\\s]+/)\n .map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())\n .join('')\n .replace(/[^a-zA-Z0-9]/g, '');\n}\n\n/**\n * Converts schema name to TypeScript enum name.\n */\nexport function toEnumName(schemaName: string): string {\n return schemaName;\n}\n\n/**\n * Parses enum value from schema (can be string or object).\n */\nfunction parseEnumValue(value: string | InlineEnumValue): TSEnumValue {\n if (typeof value === 'string') {\n return {\n name: toEnumMemberName(value),\n value,\n // No label or extra - will fallback to value\n };\n }\n\n return {\n name: toEnumMemberName(value.value),\n value: value.value,\n label: value.label,\n extra: value.extra,\n };\n}\n\n/**\n * Generates TypeScript enum from schema enum.\n */\nexport function schemaToEnum(schema: LoadedSchema, options: TypeScriptOptions = {}): TSEnum | null {\n if (schema.kind !== 'enum' || !schema.values) {\n return null;\n }\n\n const values: TSEnumValue[] = schema.values.map(value => parseEnumValue(value as string | InlineEnumValue));\n const displayName = resolveDisplayName(schema.displayName, options);\n\n return {\n name: toEnumName(schema.name),\n values,\n comment: displayName ?? schema.name,\n };\n}\n\n/**\n * Generates enums for all enum schemas.\n */\nexport function generateEnums(schemas: SchemaCollection, options: TypeScriptOptions = {}): TSEnum[] {\n const enums: TSEnum[] = [];\n\n for (const schema of Object.values(schemas)) {\n if (schema.kind === 'enum') {\n const enumDef = schemaToEnum(schema, options);\n if (enumDef) {\n enums.push(enumDef);\n }\n }\n }\n\n return enums;\n}\n\n/**\n * Formats a TypeScript enum with helper methods.\n */\nexport function formatEnum(enumDef: TSEnum): string {\n const { name, values, comment } = enumDef;\n const parts: string[] = [];\n\n // JSDoc comment\n if (comment) {\n parts.push(`/**\\n * ${comment}\\n */\\n`);\n }\n\n // Enum definition\n const enumValues = values\n .map(v => ` ${v.name} = '${v.value}',`)\n .join('\\n');\n parts.push(`export enum ${name} {\\n${enumValues}\\n}\\n\\n`);\n\n // Values array\n parts.push(`/** All ${name} values */\\n`);\n parts.push(`export const ${name}Values = Object.values(${name});\\n\\n`);\n\n // Type guard\n parts.push(`/** Type guard for ${name} */\\n`);\n parts.push(`export function is${name}(value: unknown): value is ${name} {\\n`);\n parts.push(` return ${name}Values.includes(value as ${name});\\n`);\n parts.push(`}\\n\\n`);\n\n // Labels - only generate if at least one value has a label\n const hasLabels = values.some(v => v.label !== undefined);\n if (hasLabels) {\n const labelEntries = values\n .filter(v => v.label !== undefined)\n .map(v => ` [${name}.${v.name}]: '${v.label}',`)\n .join('\\n');\n parts.push(`const ${lowerFirst(name)}Labels: Partial<Record<${name}, string>> = {\\n${labelEntries}\\n};\\n\\n`);\n }\n\n parts.push(`/** Get label for ${name} value (fallback to value if no label) */\\n`);\n parts.push(`export function get${name}Label(value: ${name}): string {\\n`);\n if (hasLabels) {\n parts.push(` return ${lowerFirst(name)}Labels[value] ?? value;\\n`);\n } else {\n parts.push(` return value;\\n`);\n }\n parts.push(`}\\n\\n`);\n\n // Extra - only generate if at least one value has extra\n const hasExtra = values.some(v => v.extra !== undefined);\n if (hasExtra) {\n const extraEntries = values\n .filter(v => v.extra !== undefined)\n .map(v => ` [${name}.${v.name}]: ${JSON.stringify(v.extra)},`)\n .join('\\n');\n parts.push(`const ${lowerFirst(name)}Extra: Partial<Record<${name}, Record<string, unknown>>> = {\\n${extraEntries}\\n};\\n\\n`);\n\n parts.push(`/** Get extra metadata for ${name} value (undefined if not defined) */\\n`);\n parts.push(`export function get${name}Extra(value: ${name}): Record<string, unknown> | undefined {\\n`);\n parts.push(` return ${lowerFirst(name)}Extra[value];\\n`);\n parts.push(`}`);\n } else {\n parts.push(`/** Get extra metadata for ${name} value (undefined if not defined) */\\n`);\n parts.push(`export function get${name}Extra(_value: ${name}): Record<string, unknown> | undefined {\\n`);\n parts.push(` return undefined;\\n`);\n parts.push(`}`);\n }\n\n return parts.join('');\n}\n\n/**\n * Convert first character to lowercase.\n */\nfunction lowerFirst(str: string): string {\n return str.charAt(0).toLowerCase() + str.slice(1);\n}\n\n/**\n * Generates a union type alias as an alternative to enum.\n */\nexport function enumToUnionType(enumDef: TSEnum): TSTypeAlias {\n const type = enumDef.values\n .map(v => `'${v.value}'`)\n .join(' | ');\n\n return {\n name: enumDef.name,\n type,\n comment: enumDef.comment,\n };\n}\n\n/**\n * Formats a TypeScript type alias with helper methods.\n */\nexport function formatTypeAlias(alias: TSTypeAlias): string {\n const { name, type, comment } = alias;\n const parts: string[] = [];\n\n // JSDoc comment\n if (comment) {\n parts.push(`/**\\n * ${comment}\\n */\\n`);\n }\n\n // Type alias\n parts.push(`export type ${name} = ${type};\\n\\n`);\n\n // Values array\n const values = type.split(' | ').map(v => v.trim());\n parts.push(`/** All ${name} values */\\n`);\n parts.push(`export const ${name}Values: ${name}[] = [${values.join(', ')}];\\n\\n`);\n\n // Type guard\n parts.push(`/** Type guard for ${name} */\\n`);\n parts.push(`export function is${name}(value: unknown): value is ${name} {\\n`);\n parts.push(` return ${name}Values.includes(value as ${name});\\n`);\n parts.push(`}\\n\\n`);\n\n // Label getter (fallback to value for type aliases - no labels)\n parts.push(`/** Get label for ${name} value (returns value as-is) */\\n`);\n parts.push(`export function get${name}Label(value: ${name}): string {\\n`);\n parts.push(` return value;\\n`);\n parts.push(`}\\n\\n`);\n\n // Extra getter (always undefined for type aliases)\n parts.push(`/** Get extra metadata for ${name} value (always undefined for type aliases) */\\n`);\n parts.push(`export function get${name}Extra(_value: ${name}): Record<string, unknown> | undefined {\\n`);\n parts.push(` return undefined;\\n`);\n parts.push(`}`);\n\n return parts.join('');\n}\n\n/**\n * Extracts inline enums from properties for type generation.\n */\nexport function extractInlineEnums(schemas: SchemaCollection, options: TypeScriptOptions = {}): TSTypeAlias[] {\n const typeAliases: TSTypeAlias[] = [];\n\n for (const schema of Object.values(schemas)) {\n if (schema.kind === 'enum' || !schema.properties) {\n continue;\n }\n\n for (const [propName, property] of Object.entries(schema.properties)) {\n if (property.type === 'Enum') {\n const enumProp = property as { enum?: readonly (string | InlineEnumValue)[]; displayName?: LocalizedString };\n\n // Only handle inline array enums (not references to named enums)\n if (Array.isArray(enumProp.enum) && enumProp.enum.length > 0) {\n const typeName = `${schema.name}${propName.charAt(0).toUpperCase() + propName.slice(1)}`;\n const values = enumProp.enum.map(v =>\n typeof v === 'string' ? v : v.value\n );\n const displayName = resolveDisplayName(enumProp.displayName, options);\n typeAliases.push({\n name: typeName,\n type: values.map(v => `'${v}'`).join(' | '),\n comment: displayName ?? `${schema.name} ${propName} enum`,\n });\n }\n }\n\n if (property.type === 'Select') {\n const selectProp = property as { options?: readonly string[]; displayName?: LocalizedString };\n\n if (selectProp.options && selectProp.options.length > 0) {\n const typeName = `${schema.name}${propName.charAt(0).toUpperCase() + propName.slice(1)}`;\n const displayName = resolveDisplayName(selectProp.displayName, options);\n typeAliases.push({\n name: typeName,\n type: selectProp.options.map(v => `'${v}'`).join(' | '),\n comment: displayName ?? `${schema.name} ${propName} options`,\n });\n }\n }\n }\n }\n\n return typeAliases;\n}\n","/**\n * @famgia/omnify-typescript - TypeScript Generator\n *\n * Generates TypeScript models with base/model pattern:\n * - models/base/[SchemaName].ts - Auto-generated base interfaces, DO NOT EDIT\n * - models/enum/[EnumName].ts - Auto-generated enums/type aliases, DO NOT EDIT\n * - models/[SchemaName].ts - Extends base, user can customize\n * - models/index.ts - Re-exports all\n */\n\nimport type { SchemaCollection } from '@famgia/omnify-types';\nimport type { TypeScriptFile, TypeScriptOptions, TSEnum, TSTypeAlias } from './types.js';\nimport { generateInterfaces, formatInterface } from './interface-generator.js';\nimport { generateEnums, formatEnum, formatTypeAlias, extractInlineEnums } from './enum-generator.js';\n\n/**\n * Default options for TypeScript generation.\n */\nconst DEFAULT_OPTIONS: TypeScriptOptions = {\n readonly: true,\n strictNullChecks: true,\n};\n\n/**\n * Generates the base file header comment (DO NOT EDIT).\n */\nfunction generateBaseHeader(): string {\n return `/**\n * Auto-generated TypeScript types from Omnify schemas.\n * DO NOT EDIT - This file is automatically generated and will be overwritten.\n */\n\n`;\n}\n\n/**\n * Generates the model file header comment (user can edit).\n */\nfunction generateModelHeader(schemaName: string): string {\n return `/**\n * ${schemaName} Model\n *\n * This file extends the auto-generated base interface.\n * You can add custom methods, computed properties, or override types here.\n * This file will NOT be overwritten by the generator.\n */\n\n`;\n}\n\n/**\n * Generates a single base interface file.\n */\nfunction generateBaseInterfaceFile(\n schemaName: string,\n schemas: SchemaCollection,\n options: TypeScriptOptions\n): TypeScriptFile {\n const interfaces = generateInterfaces(schemas, options);\n const iface = interfaces.find(i => i.name === schemaName);\n\n if (!iface) {\n throw new Error(`Interface not found for schema: ${schemaName}`);\n }\n\n const parts: string[] = [generateBaseHeader()];\n parts.push(formatInterface(iface));\n parts.push('\\n');\n\n return {\n filePath: `base/${schemaName}.ts`,\n content: parts.join(''),\n types: [schemaName],\n overwrite: true,\n };\n}\n\n/**\n * Generates a single enum file.\n */\nfunction generateEnumFile(enumDef: TSEnum): TypeScriptFile {\n const parts: string[] = [generateBaseHeader()];\n parts.push(formatEnum(enumDef));\n parts.push('\\n');\n\n return {\n filePath: `enum/${enumDef.name}.ts`,\n content: parts.join(''),\n types: [enumDef.name],\n overwrite: true,\n };\n}\n\n/**\n * Generates a single type alias file.\n */\nfunction generateTypeAliasFile(alias: TSTypeAlias): TypeScriptFile {\n const parts: string[] = [generateBaseHeader()];\n parts.push(formatTypeAlias(alias));\n parts.push('\\n');\n\n return {\n filePath: `enum/${alias.name}.ts`,\n content: parts.join(''),\n types: [alias.name],\n overwrite: true,\n };\n}\n\n/**\n * Generates model file content that extends base.\n */\nfunction generateModelFile(schemaName: string): TypeScriptFile {\n const parts: string[] = [generateModelHeader(schemaName)];\n\n // Import base interface\n parts.push(`import type { ${schemaName} as ${schemaName}Base } from './base/${schemaName}.js';\\n\\n`);\n\n // Export interface that extends base\n parts.push(`/**\\n * ${schemaName} model interface.\\n * Add custom properties or methods here.\\n */\\n`);\n parts.push(`export interface ${schemaName} extends ${schemaName}Base {\\n`);\n parts.push(` // Add custom properties here\\n`);\n parts.push(`}\\n\\n`);\n\n // Re-export base for convenience\n parts.push(`// Re-export base type for internal use\\n`);\n parts.push(`export type { ${schemaName}Base };\\n`);\n\n return {\n filePath: `${schemaName}.ts`,\n content: parts.join(''),\n types: [schemaName],\n overwrite: false, // Never overwrite user models\n };\n}\n\n/**\n * Generates index file for re-exports.\n */\nfunction generateIndexFile(\n schemas: SchemaCollection,\n enums: TSEnum[],\n typeAliases: TSTypeAlias[]\n): TypeScriptFile {\n const parts: string[] = [generateBaseHeader()];\n\n // Export enums (enum + Values + isX + getXLabel + getXExtra)\n if (enums.length > 0 || typeAliases.length > 0) {\n parts.push(`// Enums\\n`);\n for (const enumDef of enums) {\n parts.push(`export {\\n`);\n parts.push(` ${enumDef.name},\\n`);\n parts.push(` ${enumDef.name}Values,\\n`);\n parts.push(` is${enumDef.name},\\n`);\n parts.push(` get${enumDef.name}Label,\\n`);\n parts.push(` get${enumDef.name}Extra,\\n`);\n parts.push(`} from './enum/${enumDef.name}.js';\\n`);\n }\n for (const alias of typeAliases) {\n parts.push(`export {\\n`);\n parts.push(` type ${alias.name},\\n`);\n parts.push(` ${alias.name}Values,\\n`);\n parts.push(` is${alias.name},\\n`);\n parts.push(` get${alias.name}Label,\\n`);\n parts.push(` get${alias.name}Extra,\\n`);\n parts.push(`} from './enum/${alias.name}.js';\\n`);\n }\n parts.push('\\n');\n }\n\n // Export all models\n parts.push(`// Models\\n`);\n for (const schema of Object.values(schemas)) {\n if (schema.kind === 'enum') continue;\n parts.push(`export type { ${schema.name} } from './${schema.name}.js';\\n`);\n }\n\n return {\n filePath: 'index.ts',\n content: parts.join(''),\n types: [],\n overwrite: true,\n };\n}\n\n/**\n * Generates TypeScript files with base/model pattern.\n *\n * Output structure:\n * - models/base/[SchemaName].ts - Auto-generated base interfaces (always overwritten)\n * - models/enum/[EnumName].ts - Auto-generated enums/type aliases (always overwritten)\n * - models/[SchemaName].ts - User-editable models that extend base (created once, never overwritten)\n * - models/index.ts - Re-exports (always overwritten)\n */\nexport function generateTypeScript(\n schemas: SchemaCollection,\n options: TypeScriptOptions = {}\n): TypeScriptFile[] {\n const opts = { ...DEFAULT_OPTIONS, ...options };\n const files: TypeScriptFile[] = [];\n\n // Generate enum files\n const enums = generateEnums(schemas);\n for (const enumDef of enums) {\n files.push(generateEnumFile(enumDef));\n }\n\n // Generate type alias files\n const typeAliases = extractInlineEnums(schemas);\n for (const alias of typeAliases) {\n files.push(generateTypeAliasFile(alias));\n }\n\n // Generate base interface files\n for (const schema of Object.values(schemas)) {\n if (schema.kind === 'enum') continue;\n files.push(generateBaseInterfaceFile(schema.name, schemas, opts));\n }\n\n // Generate model files (only created if not exists)\n for (const schema of Object.values(schemas)) {\n if (schema.kind === 'enum') continue;\n files.push(generateModelFile(schema.name));\n }\n\n // Generate index file\n files.push(generateIndexFile(schemas, enums, typeAliases));\n\n return files;\n}\n\n// Legacy exports for compatibility\nexport { generateTypeScript as generateTypeScriptFiles };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACOA,0BAAuC;AAMvC,I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AACT;","names":["import_omnify_types","resolveDisplayName"]}
package/dist/index.d.cts CHANGED
@@ -1,37 +1,42 @@
1
- import { PropertyDefinition, SchemaCollection, LoadedSchema } from '@famgia/omnify-types';
1
+ import { LocaleConfig, PropertyDefinition, SchemaCollection, LoadedSchema } from '@famgia/omnify-types';
2
2
 
3
3
  /**
4
- * @famgia/omnify-laravel - TypeScript Types
4
+ * @famgia/omnify-typescript - TypeScript Types
5
5
  *
6
6
  * Types for TypeScript code generation.
7
7
  */
8
+
8
9
  /**
9
10
  * Generated TypeScript file.
10
11
  */
11
12
  interface TypeScriptFile {
12
- /** File name */
13
- readonly fileName: string;
13
+ /** File path relative to output directory */
14
+ readonly filePath: string;
14
15
  /** Full file content */
15
16
  readonly content: string;
16
17
  /** Types defined in this file */
17
18
  readonly types: readonly string[];
19
+ /** Whether this file can be overwritten (base files) or should be preserved (model files) */
20
+ readonly overwrite: boolean;
18
21
  }
19
22
  /**
20
23
  * TypeScript generation options.
21
24
  */
22
25
  interface TypeScriptOptions {
23
- /** Output directory for TypeScript files */
24
- readonly outputDir?: string | undefined;
25
- /** Whether to generate a single file or multiple files */
26
- readonly singleFile?: boolean | undefined;
27
- /** File name for single file output */
28
- readonly fileName?: string | undefined;
29
- /** Whether to export as default */
30
- readonly exportDefault?: boolean | undefined;
31
26
  /** Whether to include readonly modifiers */
32
27
  readonly readonly?: boolean | undefined;
33
28
  /** Whether to use strict null checks compatible types */
34
29
  readonly strictNullChecks?: boolean | undefined;
30
+ /**
31
+ * Locale configuration for resolving localized strings.
32
+ * If provided, displayName/description will be resolved to the specified locale.
33
+ */
34
+ readonly localeConfig?: LocaleConfig | undefined;
35
+ /**
36
+ * Target locale for generation.
37
+ * If not provided, uses localeConfig.defaultLocale.
38
+ */
39
+ readonly locale?: string | undefined;
35
40
  }
36
41
  /**
37
42
  * TypeScript property definition.
@@ -76,10 +81,14 @@ interface TSEnum {
76
81
  * TypeScript enum value.
77
82
  */
78
83
  interface TSEnumValue {
79
- /** Value name */
84
+ /** Value name (PascalCase) */
80
85
  readonly name: string;
81
86
  /** Value (string or number) */
82
87
  readonly value: string | number;
88
+ /** Display label (optional - fallback to value if not provided) */
89
+ readonly label?: string | undefined;
90
+ /** Extra metadata (optional) */
91
+ readonly extra?: Readonly<Record<string, unknown>> | undefined;
83
92
  }
84
93
  /**
85
94
  * TypeScript type alias definition.
@@ -136,9 +145,9 @@ declare function formatInterface(iface: TSInterface): string;
136
145
  declare function generateInterfaces(schemas: SchemaCollection, options?: TypeScriptOptions): TSInterface[];
137
146
 
138
147
  /**
139
- * @famgia/omnify-laravel - TypeScript Enum Generator
148
+ * @famgia/omnify-typescript - TypeScript Enum Generator
140
149
  *
141
- * Generates TypeScript enums from schema enum definitions.
150
+ * Generates TypeScript enums with helper methods from schema enum definitions.
142
151
  */
143
152
 
144
153
  /**
@@ -152,13 +161,13 @@ declare function toEnumName(schemaName: string): string;
152
161
  /**
153
162
  * Generates TypeScript enum from schema enum.
154
163
  */
155
- declare function schemaToEnum(schema: LoadedSchema): TSEnum | null;
164
+ declare function schemaToEnum(schema: LoadedSchema, options?: TypeScriptOptions): TSEnum | null;
156
165
  /**
157
166
  * Generates enums for all enum schemas.
158
167
  */
159
- declare function generateEnums(schemas: SchemaCollection): TSEnum[];
168
+ declare function generateEnums(schemas: SchemaCollection, options?: TypeScriptOptions): TSEnum[];
160
169
  /**
161
- * Formats a TypeScript enum.
170
+ * Formats a TypeScript enum with helper methods.
162
171
  */
163
172
  declare function formatEnum(enumDef: TSEnum): string;
164
173
  /**
@@ -166,35 +175,33 @@ declare function formatEnum(enumDef: TSEnum): string;
166
175
  */
167
176
  declare function enumToUnionType(enumDef: TSEnum): TSTypeAlias;
168
177
  /**
169
- * Formats a TypeScript type alias.
178
+ * Formats a TypeScript type alias with helper methods.
170
179
  */
171
180
  declare function formatTypeAlias(alias: TSTypeAlias): string;
172
181
  /**
173
182
  * Extracts inline enums from properties for type generation.
174
183
  */
175
- declare function extractInlineEnums(schemas: SchemaCollection): TSTypeAlias[];
184
+ declare function extractInlineEnums(schemas: SchemaCollection, options?: TypeScriptOptions): TSTypeAlias[];
176
185
 
177
186
  /**
178
- * @famgia/omnify-laravel - TypeScript Generator
187
+ * @famgia/omnify-typescript - TypeScript Generator
179
188
  *
180
- * Main TypeScript code generator combining interfaces, enums, and types.
189
+ * Generates TypeScript models with base/model pattern:
190
+ * - models/base/[SchemaName].ts - Auto-generated base interfaces, DO NOT EDIT
191
+ * - models/enum/[EnumName].ts - Auto-generated enums/type aliases, DO NOT EDIT
192
+ * - models/[SchemaName].ts - Extends base, user can customize
193
+ * - models/index.ts - Re-exports all
181
194
  */
182
195
 
183
196
  /**
184
- * Generates all TypeScript code as a single file.
185
- */
186
- declare function generateTypeScriptFile(schemas: SchemaCollection, options?: TypeScriptOptions): TypeScriptFile;
187
- /**
188
- * Generates TypeScript code as multiple files.
189
- */
190
- declare function generateTypeScriptFiles(schemas: SchemaCollection, options?: TypeScriptOptions): TypeScriptFile[];
191
- /**
192
- * Generates TypeScript types with configurable output.
197
+ * Generates TypeScript files with base/model pattern.
198
+ *
199
+ * Output structure:
200
+ * - models/base/[SchemaName].ts - Auto-generated base interfaces (always overwritten)
201
+ * - models/enum/[EnumName].ts - Auto-generated enums/type aliases (always overwritten)
202
+ * - models/[SchemaName].ts - User-editable models that extend base (created once, never overwritten)
203
+ * - models/index.ts - Re-exports (always overwritten)
193
204
  */
194
205
  declare function generateTypeScript(schemas: SchemaCollection, options?: TypeScriptOptions): TypeScriptFile[];
195
- /**
196
- * Gets output path for a TypeScript file.
197
- */
198
- declare function getTypeScriptPath(file: TypeScriptFile, outputDir?: string): string;
199
206
 
200
- export { type TSEnum, type TSEnumValue, type TSInterface, type TSProperty, type TSTypeAlias, type TypeScriptFile, type TypeScriptOptions, enumToUnionType, extractInlineEnums, formatEnum, formatInterface, formatProperty, formatTypeAlias, generateEnums, generateInterfaces, generateTypeScript, generateTypeScriptFile, generateTypeScriptFiles, getPropertyType, getTypeScriptPath, propertyToTSProperty, schemaToEnum, schemaToInterface, toEnumMemberName, toEnumName, toInterfaceName, toPropertyName };
207
+ export { type TSEnum, type TSEnumValue, type TSInterface, type TSProperty, type TSTypeAlias, type TypeScriptFile, type TypeScriptOptions, enumToUnionType, extractInlineEnums, formatEnum, formatInterface, formatProperty, formatTypeAlias, generateEnums, generateInterfaces, generateTypeScript, generateTypeScript as generateTypeScriptFiles, getPropertyType, propertyToTSProperty, schemaToEnum, schemaToInterface, toEnumMemberName, toEnumName, toInterfaceName, toPropertyName };
package/dist/index.d.ts CHANGED
@@ -1,37 +1,42 @@
1
- import { PropertyDefinition, SchemaCollection, LoadedSchema } from '@famgia/omnify-types';
1
+ import { LocaleConfig, PropertyDefinition, SchemaCollection, LoadedSchema } from '@famgia/omnify-types';
2
2
 
3
3
  /**
4
- * @famgia/omnify-laravel - TypeScript Types
4
+ * @famgia/omnify-typescript - TypeScript Types
5
5
  *
6
6
  * Types for TypeScript code generation.
7
7
  */
8
+
8
9
  /**
9
10
  * Generated TypeScript file.
10
11
  */
11
12
  interface TypeScriptFile {
12
- /** File name */
13
- readonly fileName: string;
13
+ /** File path relative to output directory */
14
+ readonly filePath: string;
14
15
  /** Full file content */
15
16
  readonly content: string;
16
17
  /** Types defined in this file */
17
18
  readonly types: readonly string[];
19
+ /** Whether this file can be overwritten (base files) or should be preserved (model files) */
20
+ readonly overwrite: boolean;
18
21
  }
19
22
  /**
20
23
  * TypeScript generation options.
21
24
  */
22
25
  interface TypeScriptOptions {
23
- /** Output directory for TypeScript files */
24
- readonly outputDir?: string | undefined;
25
- /** Whether to generate a single file or multiple files */
26
- readonly singleFile?: boolean | undefined;
27
- /** File name for single file output */
28
- readonly fileName?: string | undefined;
29
- /** Whether to export as default */
30
- readonly exportDefault?: boolean | undefined;
31
26
  /** Whether to include readonly modifiers */
32
27
  readonly readonly?: boolean | undefined;
33
28
  /** Whether to use strict null checks compatible types */
34
29
  readonly strictNullChecks?: boolean | undefined;
30
+ /**
31
+ * Locale configuration for resolving localized strings.
32
+ * If provided, displayName/description will be resolved to the specified locale.
33
+ */
34
+ readonly localeConfig?: LocaleConfig | undefined;
35
+ /**
36
+ * Target locale for generation.
37
+ * If not provided, uses localeConfig.defaultLocale.
38
+ */
39
+ readonly locale?: string | undefined;
35
40
  }
36
41
  /**
37
42
  * TypeScript property definition.
@@ -76,10 +81,14 @@ interface TSEnum {
76
81
  * TypeScript enum value.
77
82
  */
78
83
  interface TSEnumValue {
79
- /** Value name */
84
+ /** Value name (PascalCase) */
80
85
  readonly name: string;
81
86
  /** Value (string or number) */
82
87
  readonly value: string | number;
88
+ /** Display label (optional - fallback to value if not provided) */
89
+ readonly label?: string | undefined;
90
+ /** Extra metadata (optional) */
91
+ readonly extra?: Readonly<Record<string, unknown>> | undefined;
83
92
  }
84
93
  /**
85
94
  * TypeScript type alias definition.
@@ -136,9 +145,9 @@ declare function formatInterface(iface: TSInterface): string;
136
145
  declare function generateInterfaces(schemas: SchemaCollection, options?: TypeScriptOptions): TSInterface[];
137
146
 
138
147
  /**
139
- * @famgia/omnify-laravel - TypeScript Enum Generator
148
+ * @famgia/omnify-typescript - TypeScript Enum Generator
140
149
  *
141
- * Generates TypeScript enums from schema enum definitions.
150
+ * Generates TypeScript enums with helper methods from schema enum definitions.
142
151
  */
143
152
 
144
153
  /**
@@ -152,13 +161,13 @@ declare function toEnumName(schemaName: string): string;
152
161
  /**
153
162
  * Generates TypeScript enum from schema enum.
154
163
  */
155
- declare function schemaToEnum(schema: LoadedSchema): TSEnum | null;
164
+ declare function schemaToEnum(schema: LoadedSchema, options?: TypeScriptOptions): TSEnum | null;
156
165
  /**
157
166
  * Generates enums for all enum schemas.
158
167
  */
159
- declare function generateEnums(schemas: SchemaCollection): TSEnum[];
168
+ declare function generateEnums(schemas: SchemaCollection, options?: TypeScriptOptions): TSEnum[];
160
169
  /**
161
- * Formats a TypeScript enum.
170
+ * Formats a TypeScript enum with helper methods.
162
171
  */
163
172
  declare function formatEnum(enumDef: TSEnum): string;
164
173
  /**
@@ -166,35 +175,33 @@ declare function formatEnum(enumDef: TSEnum): string;
166
175
  */
167
176
  declare function enumToUnionType(enumDef: TSEnum): TSTypeAlias;
168
177
  /**
169
- * Formats a TypeScript type alias.
178
+ * Formats a TypeScript type alias with helper methods.
170
179
  */
171
180
  declare function formatTypeAlias(alias: TSTypeAlias): string;
172
181
  /**
173
182
  * Extracts inline enums from properties for type generation.
174
183
  */
175
- declare function extractInlineEnums(schemas: SchemaCollection): TSTypeAlias[];
184
+ declare function extractInlineEnums(schemas: SchemaCollection, options?: TypeScriptOptions): TSTypeAlias[];
176
185
 
177
186
  /**
178
- * @famgia/omnify-laravel - TypeScript Generator
187
+ * @famgia/omnify-typescript - TypeScript Generator
179
188
  *
180
- * Main TypeScript code generator combining interfaces, enums, and types.
189
+ * Generates TypeScript models with base/model pattern:
190
+ * - models/base/[SchemaName].ts - Auto-generated base interfaces, DO NOT EDIT
191
+ * - models/enum/[EnumName].ts - Auto-generated enums/type aliases, DO NOT EDIT
192
+ * - models/[SchemaName].ts - Extends base, user can customize
193
+ * - models/index.ts - Re-exports all
181
194
  */
182
195
 
183
196
  /**
184
- * Generates all TypeScript code as a single file.
185
- */
186
- declare function generateTypeScriptFile(schemas: SchemaCollection, options?: TypeScriptOptions): TypeScriptFile;
187
- /**
188
- * Generates TypeScript code as multiple files.
189
- */
190
- declare function generateTypeScriptFiles(schemas: SchemaCollection, options?: TypeScriptOptions): TypeScriptFile[];
191
- /**
192
- * Generates TypeScript types with configurable output.
197
+ * Generates TypeScript files with base/model pattern.
198
+ *
199
+ * Output structure:
200
+ * - models/base/[SchemaName].ts - Auto-generated base interfaces (always overwritten)
201
+ * - models/enum/[EnumName].ts - Auto-generated enums/type aliases (always overwritten)
202
+ * - models/[SchemaName].ts - User-editable models that extend base (created once, never overwritten)
203
+ * - models/index.ts - Re-exports (always overwritten)
193
204
  */
194
205
  declare function generateTypeScript(schemas: SchemaCollection, options?: TypeScriptOptions): TypeScriptFile[];
195
- /**
196
- * Gets output path for a TypeScript file.
197
- */
198
- declare function getTypeScriptPath(file: TypeScriptFile, outputDir?: string): string;
199
206
 
200
- export { type TSEnum, type TSEnumValue, type TSInterface, type TSProperty, type TSTypeAlias, type TypeScriptFile, type TypeScriptOptions, enumToUnionType, extractInlineEnums, formatEnum, formatInterface, formatProperty, formatTypeAlias, generateEnums, generateInterfaces, generateTypeScript, generateTypeScriptFile, generateTypeScriptFiles, getPropertyType, getTypeScriptPath, propertyToTSProperty, schemaToEnum, schemaToInterface, toEnumMemberName, toEnumName, toInterfaceName, toPropertyName };
207
+ export { type TSEnum, type TSEnumValue, type TSInterface, type TSProperty, type TSTypeAlias, type TypeScriptFile, type TypeScriptOptions, enumToUnionType, extractInlineEnums, formatEnum, formatInterface, formatProperty, formatTypeAlias, generateEnums, generateInterfaces, generateTypeScript, generateTypeScript as generateTypeScriptFiles, getPropertyType, propertyToTSProperty, schemaToEnum, schemaToInterface, toEnumMemberName, toEnumName, toInterfaceName, toPropertyName };
package/dist/index.js CHANGED
@@ -8,10 +8,7 @@ import {
8
8
  generateEnums,
9
9
  generateInterfaces,
10
10
  generateTypeScript,
11
- generateTypeScriptFile,
12
- generateTypeScriptFiles,
13
11
  getPropertyType,
14
- getTypeScriptPath,
15
12
  propertyToTSProperty,
16
13
  schemaToEnum,
17
14
  schemaToInterface,
@@ -19,7 +16,7 @@ import {
19
16
  toEnumName,
20
17
  toInterfaceName,
21
18
  toPropertyName
22
- } from "./chunk-2BXDNKIN.js";
19
+ } from "./chunk-J46F3EBS.js";
23
20
  export {
24
21
  enumToUnionType,
25
22
  extractInlineEnums,
@@ -30,10 +27,8 @@ export {
30
27
  generateEnums,
31
28
  generateInterfaces,
32
29
  generateTypeScript,
33
- generateTypeScriptFile,
34
- generateTypeScriptFiles,
30
+ generateTypeScript as generateTypeScriptFiles,
35
31
  getPropertyType,
36
- getTypeScriptPath,
37
32
  propertyToTSProperty,
38
33
  schemaToEnum,
39
34
  schemaToInterface,