@famgia/omnify-typescript 0.0.24 → 0.0.26
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/{chunk-N5ZH7GJS.js → chunk-SQD3KCIT.js} +45 -2
- package/dist/chunk-SQD3KCIT.js.map +1 -0
- package/dist/index.cjs +44 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -1
- package/dist/plugin.cjs +44 -1
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.js +1 -1
- package/package.json +2 -2
- package/dist/chunk-N5ZH7GJS.js.map +0 -1
|
@@ -13,6 +13,7 @@ var TYPE_MAP = {
|
|
|
13
13
|
LongText: "string",
|
|
14
14
|
Date: "string",
|
|
15
15
|
Time: "string",
|
|
16
|
+
DateTime: "string",
|
|
16
17
|
Timestamp: "string",
|
|
17
18
|
Json: "unknown",
|
|
18
19
|
Email: "string",
|
|
@@ -116,6 +117,18 @@ function propertyToTSProperties(propertyName, property, allSchemas, options = {}
|
|
|
116
117
|
comment: `${displayName ?? propertyName} (${field.suffix})`
|
|
117
118
|
});
|
|
118
119
|
}
|
|
120
|
+
if (customType.accessors) {
|
|
121
|
+
for (const accessor of customType.accessors) {
|
|
122
|
+
const accessorName = `${propertyName}_${toSnakeCase(accessor.name)}`;
|
|
123
|
+
expandedProps.push({
|
|
124
|
+
name: accessorName,
|
|
125
|
+
type: "string | null",
|
|
126
|
+
optional: true,
|
|
127
|
+
readonly: isReadonly,
|
|
128
|
+
comment: `${displayName ?? propertyName} (computed)`
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
}
|
|
119
132
|
return expandedProps;
|
|
120
133
|
}
|
|
121
134
|
if (customType && !customType.compound) {
|
|
@@ -173,8 +186,22 @@ function propertyToTSProperties(propertyName, property, allSchemas, options = {}
|
|
|
173
186
|
function propertyToTSProperty(propertyName, property, allSchemas, options = {}) {
|
|
174
187
|
return propertyToTSProperties(propertyName, property, allSchemas, options)[0];
|
|
175
188
|
}
|
|
189
|
+
function extractTypeReferences(type, allSchemaNames) {
|
|
190
|
+
const primitives = /* @__PURE__ */ new Set(["string", "number", "boolean", "unknown", "null", "undefined", "void", "never", "any"]);
|
|
191
|
+
const refs = [];
|
|
192
|
+
const cleanType = type.replace(/\[\]/g, "").replace(/\s*\|\s*null/g, "");
|
|
193
|
+
const parts = cleanType.split(/\s*\|\s*/);
|
|
194
|
+
for (const part of parts) {
|
|
195
|
+
const trimmed = part.trim().replace(/^['"]|['"]$/g, "");
|
|
196
|
+
if (!primitives.has(trimmed) && allSchemaNames.has(trimmed)) {
|
|
197
|
+
refs.push(trimmed);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
return refs;
|
|
201
|
+
}
|
|
176
202
|
function schemaToInterface(schema, allSchemas, options = {}) {
|
|
177
203
|
const properties = [];
|
|
204
|
+
const allSchemaNames = new Set(Object.keys(allSchemas).filter((name) => allSchemas[name].kind !== "enum"));
|
|
178
205
|
if (schema.options?.id !== false) {
|
|
179
206
|
const pkType = schema.options?.idType ?? "BigInt";
|
|
180
207
|
properties.push({
|
|
@@ -217,11 +244,20 @@ function schemaToInterface(schema, allSchemas, options = {}) {
|
|
|
217
244
|
comment: "Soft delete timestamp"
|
|
218
245
|
});
|
|
219
246
|
}
|
|
247
|
+
const dependencySet = /* @__PURE__ */ new Set();
|
|
248
|
+
for (const prop of properties) {
|
|
249
|
+
for (const ref of extractTypeReferences(prop.type, allSchemaNames)) {
|
|
250
|
+
if (ref !== schema.name) {
|
|
251
|
+
dependencySet.add(ref);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
220
255
|
const schemaDisplayName = resolveDisplayName(schema.displayName, options);
|
|
221
256
|
return {
|
|
222
257
|
name: toInterfaceName(schema.name),
|
|
223
258
|
properties,
|
|
224
|
-
comment: schemaDisplayName ?? schema.name
|
|
259
|
+
comment: schemaDisplayName ?? schema.name,
|
|
260
|
+
dependencies: dependencySet.size > 0 ? Array.from(dependencySet).sort() : void 0
|
|
225
261
|
};
|
|
226
262
|
}
|
|
227
263
|
function formatProperty(property) {
|
|
@@ -516,6 +552,13 @@ function generateBaseInterfaceFile(schemaName, schemas, options) {
|
|
|
516
552
|
throw new Error(`Interface not found for schema: ${schemaName}`);
|
|
517
553
|
}
|
|
518
554
|
const parts = [generateBaseHeader()];
|
|
555
|
+
if (iface.dependencies && iface.dependencies.length > 0) {
|
|
556
|
+
for (const dep of iface.dependencies) {
|
|
557
|
+
parts.push(`import type { ${dep} } from './${dep}.js';
|
|
558
|
+
`);
|
|
559
|
+
}
|
|
560
|
+
parts.push("\n");
|
|
561
|
+
}
|
|
519
562
|
parts.push(formatInterface(iface));
|
|
520
563
|
parts.push("\n");
|
|
521
564
|
return {
|
|
@@ -671,4 +714,4 @@ export {
|
|
|
671
714
|
extractInlineEnums,
|
|
672
715
|
generateTypeScript
|
|
673
716
|
};
|
|
674
|
-
//# sourceMappingURL=chunk-
|
|
717
|
+
//# sourceMappingURL=chunk-SQD3KCIT.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/interface-generator.ts","../src/enum-generator.ts","../src/generator.ts"],"sourcesContent":["/**\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 * Convert a string to snake_case.\n */\nfunction toSnakeCase(str: string): string {\n return str\n .replace(/([A-Z])/g, '_$1')\n .replace(/^_/, '')\n .toLowerCase();\n}\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 DateTime: '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 * For compound custom types, expands to multiple properties.\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; fields?: Record<string, { nullable?: boolean }> };\n const isReadonly = options.readonly ?? true;\n // Resolve displayName using locale config\n const displayName = resolveDisplayName(baseProp.displayName, options);\n\n // Handle custom compound types from plugins (e.g., JapaneseName, JapaneseAddress)\n if (options.customTypes) {\n const customType = options.customTypes.get(property.type);\n if (customType?.compound && customType.expand) {\n const expandedProps: TSProperty[] = [];\n for (const field of customType.expand) {\n const fieldName = `${propertyName}_${toSnakeCase(field.suffix)}`;\n const fieldOverride = baseProp.fields?.[field.suffix];\n const isNullable = fieldOverride?.nullable ?? baseProp.nullable ?? false;\n const tsType = field.typescript?.type ?? 'string';\n\n expandedProps.push({\n name: fieldName,\n type: tsType,\n optional: isNullable,\n readonly: isReadonly,\n comment: `${displayName ?? propertyName} (${field.suffix})`,\n });\n }\n\n // Add accessor properties (computed properties like full_name)\n if (customType.accessors) {\n for (const accessor of customType.accessors) {\n const accessorName = `${propertyName}_${toSnakeCase(accessor.name)}`;\n expandedProps.push({\n name: accessorName,\n type: 'string | null',\n optional: true,\n readonly: isReadonly,\n comment: `${displayName ?? propertyName} (computed)`,\n });\n }\n }\n\n return expandedProps;\n }\n // Handle simple custom types (non-compound)\n if (customType && !customType.compound) {\n const tsType = customType.typescript?.type ?? 'string';\n return [{\n name: toPropertyName(propertyName),\n type: tsType,\n optional: baseProp.nullable ?? false,\n readonly: isReadonly,\n comment: displayName,\n }];\n }\n }\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 * Extracts referenced interface names from a TypeScript type string.\n * Returns only interface names (not primitives like string, number, boolean, unknown).\n */\nfunction extractTypeReferences(type: string, allSchemaNames: Set<string>): string[] {\n const primitives = new Set(['string', 'number', 'boolean', 'unknown', 'null', 'undefined', 'void', 'never', 'any']);\n const refs: string[] = [];\n\n // Remove array notation and split by | for union types\n const cleanType = type.replace(/\\[\\]/g, '').replace(/\\s*\\|\\s*null/g, '');\n const parts = cleanType.split(/\\s*\\|\\s*/);\n\n for (const part of parts) {\n // Remove quotes (for string literal types like 'Post')\n const trimmed = part.trim().replace(/^['\"]|['\"]$/g, '');\n if (!primitives.has(trimmed) && allSchemaNames.has(trimmed)) {\n refs.push(trimmed);\n }\n }\n\n return refs;\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 const allSchemaNames = new Set(Object.keys(allSchemas).filter(name => allSchemas[name]!.kind !== 'enum'));\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 (snake_case to match database columns)\n if (schema.options?.timestamps !== false) {\n properties.push(\n {\n name: 'created_at',\n type: 'string',\n optional: true,\n readonly: options.readonly ?? true,\n comment: 'Creation timestamp',\n },\n {\n name: 'updated_at',\n type: 'string',\n optional: true,\n readonly: options.readonly ?? true,\n comment: 'Last update timestamp',\n }\n );\n }\n\n // Soft delete (snake_case to match database columns)\n if (schema.options?.softDelete) {\n properties.push({\n name: 'deleted_at',\n type: 'string',\n optional: true,\n readonly: options.readonly ?? true,\n comment: 'Soft delete timestamp',\n });\n }\n\n // Collect dependencies from property types\n const dependencySet = new Set<string>();\n for (const prop of properties) {\n for (const ref of extractTypeReferences(prop.type, allSchemaNames)) {\n if (ref !== schema.name) { // Don't include self-references\n dependencySet.add(ref);\n }\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 dependencies: dependencySet.size > 0 ? Array.from(dependencySet).sort() : undefined,\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 /** Display label - supports multi-language (string or locale map) */\n readonly label?: LocalizedString;\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 * Resolves LocalizedString labels to string using provided options.\n */\nfunction parseEnumValue(\n value: string | InlineEnumValue,\n options: TypeScriptOptions = {}\n): 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 // Resolve LocalizedString label to string\n const resolvedLabel = resolveDisplayName(value.label, options);\n\n return {\n name: toEnumMemberName(value.value),\n value: value.value,\n label: resolvedLabel,\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 =>\n parseEnumValue(value as string | InlineEnumValue, options)\n );\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\n // Add imports for dependencies\n if (iface.dependencies && iface.dependencies.length > 0) {\n for (const dep of iface.dependencies) {\n parts.push(`import type { ${dep} } from './${dep}.js';\\n`);\n }\n parts.push('\\n');\n }\n\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":";AAOA,SAAS,8BAA8B;AAMvC,SAAS,YAAY,KAAqB;AACxC,SAAO,IACJ,QAAQ,YAAY,KAAK,EACzB,QAAQ,MAAM,EAAE,EAChB,YAAY;AACjB;AAKA,IAAM,WAAmC;AAAA,EACvC,QAAQ;AAAA,EACR,KAAK;AAAA,EACL,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,SAAS;AAAA,EACT,MAAM;AAAA,EACN,UAAU;AAAA,EACV,MAAM;AAAA,EACN,MAAM;AAAA,EACN,UAAU;AAAA,EACV,WAAW;AAAA,EACX,MAAM;AAAA,EACN,OAAO;AAAA,EACP,UAAU;AAAA,EACV,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,QAAQ;AACV;AAMO,IAAM,sBAAsB;AAKnC,IAAM,cAAsC;AAAA,EAC1C,KAAK;AAAA,EACL,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,QAAQ;AACV;AAMA,SAAS,mBACP,OACA,UAA6B,CAAC,GACV;AACpB,MAAI,UAAU,QAAW;AACvB,WAAO;AAAA,EACT;AACA,SAAO,uBAAuB,OAAO;AAAA,IACnC,QAAQ,QAAQ;AAAA,IAChB,QAAQ,QAAQ;AAAA,EAClB,CAAC;AACH;AAMO,SAAS,eAAe,MAAsB;AACnD,SAAO;AACT;AAMO,SAAS,gBAAgB,YAA4B;AAC1D,SAAO;AACT;AAKO,SAAS,gBACd,UACA,aACQ;AAGR,MAAI,SAAS,SAAS,QAAQ;AAC5B,UAAM,WAAW;AACjB,QAAI,SAAS,UAAU;AACrB,aAAO,GAAG,mBAAmB;AAAA,IAC/B;AACA,WAAO,GAAG,mBAAmB;AAAA,EAC/B;AAGA,MAAI,SAAS,SAAS,eAAe;AACnC,UAAM,YAAY;AAMlB,UAAM,aAAa,UAAU,UAAU;AAEvC,YAAQ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AC;AAEzD,SAAO;AACT;","names":["resolveLocalizedString","resolveDisplayName"]}
|
package/dist/index.cjs
CHANGED
|
@@ -56,6 +56,7 @@ var TYPE_MAP = {
|
|
|
56
56
|
LongText: "string",
|
|
57
57
|
Date: "string",
|
|
58
58
|
Time: "string",
|
|
59
|
+
DateTime: "string",
|
|
59
60
|
Timestamp: "string",
|
|
60
61
|
Json: "unknown",
|
|
61
62
|
Email: "string",
|
|
@@ -159,6 +160,18 @@ function propertyToTSProperties(propertyName, property, allSchemas, options = {}
|
|
|
159
160
|
comment: `${displayName ?? propertyName} (${field.suffix})`
|
|
160
161
|
});
|
|
161
162
|
}
|
|
163
|
+
if (customType.accessors) {
|
|
164
|
+
for (const accessor of customType.accessors) {
|
|
165
|
+
const accessorName = `${propertyName}_${toSnakeCase(accessor.name)}`;
|
|
166
|
+
expandedProps.push({
|
|
167
|
+
name: accessorName,
|
|
168
|
+
type: "string | null",
|
|
169
|
+
optional: true,
|
|
170
|
+
readonly: isReadonly,
|
|
171
|
+
comment: `${displayName ?? propertyName} (computed)`
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
}
|
|
162
175
|
return expandedProps;
|
|
163
176
|
}
|
|
164
177
|
if (customType && !customType.compound) {
|
|
@@ -216,8 +229,22 @@ function propertyToTSProperties(propertyName, property, allSchemas, options = {}
|
|
|
216
229
|
function propertyToTSProperty(propertyName, property, allSchemas, options = {}) {
|
|
217
230
|
return propertyToTSProperties(propertyName, property, allSchemas, options)[0];
|
|
218
231
|
}
|
|
232
|
+
function extractTypeReferences(type, allSchemaNames) {
|
|
233
|
+
const primitives = /* @__PURE__ */ new Set(["string", "number", "boolean", "unknown", "null", "undefined", "void", "never", "any"]);
|
|
234
|
+
const refs = [];
|
|
235
|
+
const cleanType = type.replace(/\[\]/g, "").replace(/\s*\|\s*null/g, "");
|
|
236
|
+
const parts = cleanType.split(/\s*\|\s*/);
|
|
237
|
+
for (const part of parts) {
|
|
238
|
+
const trimmed = part.trim().replace(/^['"]|['"]$/g, "");
|
|
239
|
+
if (!primitives.has(trimmed) && allSchemaNames.has(trimmed)) {
|
|
240
|
+
refs.push(trimmed);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
return refs;
|
|
244
|
+
}
|
|
219
245
|
function schemaToInterface(schema, allSchemas, options = {}) {
|
|
220
246
|
const properties = [];
|
|
247
|
+
const allSchemaNames = new Set(Object.keys(allSchemas).filter((name) => allSchemas[name].kind !== "enum"));
|
|
221
248
|
if (schema.options?.id !== false) {
|
|
222
249
|
const pkType = schema.options?.idType ?? "BigInt";
|
|
223
250
|
properties.push({
|
|
@@ -260,11 +287,20 @@ function schemaToInterface(schema, allSchemas, options = {}) {
|
|
|
260
287
|
comment: "Soft delete timestamp"
|
|
261
288
|
});
|
|
262
289
|
}
|
|
290
|
+
const dependencySet = /* @__PURE__ */ new Set();
|
|
291
|
+
for (const prop of properties) {
|
|
292
|
+
for (const ref of extractTypeReferences(prop.type, allSchemaNames)) {
|
|
293
|
+
if (ref !== schema.name) {
|
|
294
|
+
dependencySet.add(ref);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
263
298
|
const schemaDisplayName = resolveDisplayName(schema.displayName, options);
|
|
264
299
|
return {
|
|
265
300
|
name: toInterfaceName(schema.name),
|
|
266
301
|
properties,
|
|
267
|
-
comment: schemaDisplayName ?? schema.name
|
|
302
|
+
comment: schemaDisplayName ?? schema.name,
|
|
303
|
+
dependencies: dependencySet.size > 0 ? Array.from(dependencySet).sort() : void 0
|
|
268
304
|
};
|
|
269
305
|
}
|
|
270
306
|
function formatProperty(property) {
|
|
@@ -559,6 +595,13 @@ function generateBaseInterfaceFile(schemaName, schemas, options) {
|
|
|
559
595
|
throw new Error(`Interface not found for schema: ${schemaName}`);
|
|
560
596
|
}
|
|
561
597
|
const parts = [generateBaseHeader()];
|
|
598
|
+
if (iface.dependencies && iface.dependencies.length > 0) {
|
|
599
|
+
for (const dep of iface.dependencies) {
|
|
600
|
+
parts.push(`import type { ${dep} } from './${dep}.js';
|
|
601
|
+
`);
|
|
602
|
+
}
|
|
603
|
+
parts.push("\n");
|
|
604
|
+
}
|
|
562
605
|
parts.push(formatInterface(iface));
|
|
563
606
|
parts.push("\n");
|
|
564
607
|
return {
|
package/dist/index.cjs.map
CHANGED
|
@@ -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 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 * Convert a string to snake_case.\n */\nfunction toSnakeCase(str: string): string {\n return str\n .replace(/([A-Z])/g, '_$1')\n .replace(/^_/, '')\n .toLowerCase();\n}\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 * For compound custom types, expands to multiple properties.\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; fields?: Record<string, { nullable?: boolean }> };\n const isReadonly = options.readonly ?? true;\n // Resolve displayName using locale config\n const displayName = resolveDisplayName(baseProp.displayName, options);\n\n // Handle custom compound types from plugins (e.g., JapaneseName, JapaneseAddress)\n if (options.customTypes) {\n const customType = options.customTypes.get(property.type);\n if (customType?.compound && customType.expand) {\n const expandedProps: TSProperty[] = [];\n for (const field of customType.expand) {\n const fieldName = `${propertyName}_${toSnakeCase(field.suffix)}`;\n const fieldOverride = baseProp.fields?.[field.suffix];\n const isNullable = fieldOverride?.nullable ?? baseProp.nullable ?? false;\n const tsType = field.typescript?.type ?? 'string';\n\n expandedProps.push({\n name: fieldName,\n type: tsType,\n optional: isNullable,\n readonly: isReadonly,\n comment: `${displayName ?? propertyName} (${field.suffix})`,\n });\n }\n return expandedProps;\n }\n // Handle simple custom types (non-compound)\n if (customType && !customType.compound) {\n const tsType = customType.typescript?.type ?? 'string';\n return [{\n name: toPropertyName(propertyName),\n type: tsType,\n optional: baseProp.nullable ?? false,\n readonly: isReadonly,\n comment: displayName,\n }];\n }\n }\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 (snake_case to match database columns)\n if (schema.options?.timestamps !== false) {\n properties.push(\n {\n name: 'created_at',\n type: 'string',\n optional: true,\n readonly: options.readonly ?? true,\n comment: 'Creation timestamp',\n },\n {\n name: 'updated_at',\n type: 'string',\n optional: true,\n readonly: options.readonly ?? true,\n comment: 'Last update timestamp',\n }\n );\n }\n\n // Soft delete (snake_case to match database columns)\n if (schema.options?.softDelete) {\n properties.push({\n name: 'deleted_at',\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 /** Display label - supports multi-language (string or locale map) */\n readonly label?: LocalizedString;\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 * Resolves LocalizedString labels to string using provided options.\n */\nfunction parseEnumValue(\n value: string | InlineEnumValue,\n options: TypeScriptOptions = {}\n): 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 // Resolve LocalizedString label to string\n const resolvedLabel = resolveDisplayName(value.label, options);\n\n return {\n name: toEnumMemberName(value.value),\n value: value.value,\n label: resolvedLabel,\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 =>\n parseEnumValue(value as string | InlineEnumValue, options)\n );\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,SAAS,YAAY,KAAqB;AACxC,SAAO,IACJ,QAAQ,YAAY,KAAK,EACzB,QAAQ,MAAM,EAAE,EAChB,YAAY;AACjB;AAKA,IAAM,WAAmC;AAAA,EACvC,QAAQ;AAAA,EACR,KAAK;AAAA,EACL,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,SAAS;AAAA,EACT,MAAM;AAAA,EACN,UAAU;AAAA,EACV,MAAM;AAAA,EACN,MAAM;AAAA,EACN,WAAW;AAAA,EACX,MAAM;AAAA,EACN,OAAO;AAAA,EACP,UAAU;AAAA,EACV,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,QAAQ;AACV;AAMO,IAAM,sBAAsB;AAKnC,IAAM,cAAsC;AAAA,EAC1C,KAAK;AAAA,EACL,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,QAAQ;AACV;AAMA,SAAS,mBACP,OACA,UAA6B,CAAC,GACV;AACpB,MAAI,UAAU,QAAW;AACvB,WAAO;AAAA,EACT;AACA,aAAO,4CAAuB,OAAO;AAAA,IACnC,QAAQ,QAAQ;AAAA,IAChB,QAAQ,QAAQ;AAAA,EAClB,CAAC;AACH;AAMO,SAAS,eAAe,MAAsB;AACnD,SAAO;AACT;AAMO,SAAS,gBAAgB,YAA4B;AAC1D,SAAO;AACT;AAKO,S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AO,OAAO,OAAO,GAAG;AAC3C,QAAI,OAAO,SAAS,OAAQ;AAC5B,UAAM,KAAK,kBAAkB,OAAO,IAAI,CAAC;AAAA,EAC3C;AAGA,QAAM,KAAK,kBAAkB,SAAS,OAAO,WAAW,CAAC;AAEzD,SAAO;AACT;","names":["import_omnify_types","resolveDisplayName"]}
|
|
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 * Convert a string to snake_case.\n */\nfunction toSnakeCase(str: string): string {\n return str\n .replace(/([A-Z])/g, '_$1')\n .replace(/^_/, '')\n .toLowerCase();\n}\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 DateTime: '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 * For compound custom types, expands to multiple properties.\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; fields?: Record<string, { nullable?: boolean }> };\n const isReadonly = options.readonly ?? true;\n // Resolve displayName using locale config\n const displayName = resolveDisplayName(baseProp.displayName, options);\n\n // Handle custom compound types from plugins (e.g., JapaneseName, JapaneseAddress)\n if (options.customTypes) {\n const customType = options.customTypes.get(property.type);\n if (customType?.compound && customType.expand) {\n const expandedProps: TSProperty[] = [];\n for (const field of customType.expand) {\n const fieldName = `${propertyName}_${toSnakeCase(field.suffix)}`;\n const fieldOverride = baseProp.fields?.[field.suffix];\n const isNullable = fieldOverride?.nullable ?? baseProp.nullable ?? false;\n const tsType = field.typescript?.type ?? 'string';\n\n expandedProps.push({\n name: fieldName,\n type: tsType,\n optional: isNullable,\n readonly: isReadonly,\n comment: `${displayName ?? propertyName} (${field.suffix})`,\n });\n }\n\n // Add accessor properties (computed properties like full_name)\n if (customType.accessors) {\n for (const accessor of customType.accessors) {\n const accessorName = `${propertyName}_${toSnakeCase(accessor.name)}`;\n expandedProps.push({\n name: accessorName,\n type: 'string | null',\n optional: true,\n readonly: isReadonly,\n comment: `${displayName ?? propertyName} (computed)`,\n });\n }\n }\n\n return expandedProps;\n }\n // Handle simple custom types (non-compound)\n if (customType && !customType.compound) {\n const tsType = customType.typescript?.type ?? 'string';\n return [{\n name: toPropertyName(propertyName),\n type: tsType,\n optional: baseProp.nullable ?? false,\n readonly: isReadonly,\n comment: displayName,\n }];\n }\n }\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 * Extracts referenced interface names from a TypeScript type string.\n * Returns only interface names (not primitives like string, number, boolean, unknown).\n */\nfunction extractTypeReferences(type: string, allSchemaNames: Set<string>): string[] {\n const primitives = new Set(['string', 'number', 'boolean', 'unknown', 'null', 'undefined', 'void', 'never', 'any']);\n const refs: string[] = [];\n\n // Remove array notation and split by | for union types\n const cleanType = type.replace(/\\[\\]/g, '').replace(/\\s*\\|\\s*null/g, '');\n const parts = cleanType.split(/\\s*\\|\\s*/);\n\n for (const part of parts) {\n // Remove quotes (for string literal types like 'Post')\n const trimmed = part.trim().replace(/^['\"]|['\"]$/g, '');\n if (!primitives.has(trimmed) && allSchemaNames.has(trimmed)) {\n refs.push(trimmed);\n }\n }\n\n return refs;\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 const allSchemaNames = new Set(Object.keys(allSchemas).filter(name => allSchemas[name]!.kind !== 'enum'));\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 (snake_case to match database columns)\n if (schema.options?.timestamps !== false) {\n properties.push(\n {\n name: 'created_at',\n type: 'string',\n optional: true,\n readonly: options.readonly ?? true,\n comment: 'Creation timestamp',\n },\n {\n name: 'updated_at',\n type: 'string',\n optional: true,\n readonly: options.readonly ?? true,\n comment: 'Last update timestamp',\n }\n );\n }\n\n // Soft delete (snake_case to match database columns)\n if (schema.options?.softDelete) {\n properties.push({\n name: 'deleted_at',\n type: 'string',\n optional: true,\n readonly: options.readonly ?? true,\n comment: 'Soft delete timestamp',\n });\n }\n\n // Collect dependencies from property types\n const dependencySet = new Set<string>();\n for (const prop of properties) {\n for (const ref of extractTypeReferences(prop.type, allSchemaNames)) {\n if (ref !== schema.name) { // Don't include self-references\n dependencySet.add(ref);\n }\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 dependencies: dependencySet.size > 0 ? Array.from(dependencySet).sort() : undefined,\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 /** Display label - supports multi-language (string or locale map) */\n readonly label?: LocalizedString;\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 * Resolves LocalizedString labels to string using provided options.\n */\nfunction parseEnumValue(\n value: string | InlineEnumValue,\n options: TypeScriptOptions = {}\n): 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 // Resolve LocalizedString label to string\n const resolvedLabel = resolveDisplayName(value.label, options);\n\n return {\n name: toEnumMemberName(value.value),\n value: value.value,\n label: resolvedLabel,\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 =>\n parseEnumValue(value as string | InlineEnumValue, options)\n );\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\n // Add imports for dependencies\n if (iface.dependencies && iface.dependencies.length > 0) {\n for (const dep of iface.dependencies) {\n parts.push(`import type { ${dep} } from './${dep}.js';\\n`);\n }\n parts.push('\\n');\n }\n\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,SAAS,YAAY,KAAqB;AACxC,SAAO,IACJ,QAAQ,YAAY,KAAK,EACzB,QAAQ,MAAM,EAAE,EAChB,YAAY;AACjB;AAKA,IAAM,WAAmC;AAAA,EACvC,QAAQ;AAAA,EACR,KAAK;AAAA,EACL,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,SAAS;AAAA,EACT,MAAM;AAAA,EACN,UAAU;AAAA,EACV,MAAM;AAAA,EACN,MAAM;AAAA,EACN,UAAU;AAAA,EACV,WAAW;AAAA,EACX,MAAM;AAAA,EACN,OAAO;AAAA,EACP,UAAU;AAAA,EACV,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,QAAQ;AACV;AAMO,IAAM,sBAAsB;AAKnC,IAAM,cAAsC;AAAA,EAC1C,KAAK;AAAA,EACL,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,QAAQ;AACV;AAMA,SAAS,mBACP,OACA,UAA6B,CAAC,GACV;AACpB,MAAI,UAAU,QAAW;AACvB,WAAO;AAAA,EACT;AACA,aAAO,4CAAuB,OAAO;AAAA,IACnC,QAAQ,QAAQ;AAAA,IAChB,QAAQ,QAAQ;AAAA,EAClB,CAAC;AACH;AAMO,SAAS,eAAe,MAAsB;AACnD,SAAO;AACT;AAMO,SAAS,gBAAgB,YAA4B;AAC1D,SAAO;AACT;AAKO,SAAS,gBACd,UACA,aACQ;AAGR,MAAI,SAAS,SAAS,QAAQ;AAC5B,UAAM,WAAW;AACjB,QAAI,SAAS,UAAU;AACrB,aAAO,GAAG,mBAAmB;AAAA,IAC/B;AACA,WAAO,GAAG,mBAAm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,UAAM,KAAK,kBAAkB,OAAO,IAAI,CAAC;AAAA,EAC3C;AAGA,QAAM,KAAK,kBAAkB,SAAS,OAAO,WAAW,CAAC;AAEzD,SAAO;AACT;","names":["import_omnify_types","resolveDisplayName"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -70,6 +70,8 @@ interface TSInterface {
|
|
|
70
70
|
readonly extends?: readonly string[] | undefined;
|
|
71
71
|
/** JSDoc comment */
|
|
72
72
|
readonly comment?: string | undefined;
|
|
73
|
+
/** Dependencies - other interfaces that need to be imported */
|
|
74
|
+
readonly dependencies?: readonly string[] | undefined;
|
|
73
75
|
}
|
|
74
76
|
/**
|
|
75
77
|
* TypeScript enum definition.
|
package/dist/index.d.ts
CHANGED
|
@@ -70,6 +70,8 @@ interface TSInterface {
|
|
|
70
70
|
readonly extends?: readonly string[] | undefined;
|
|
71
71
|
/** JSDoc comment */
|
|
72
72
|
readonly comment?: string | undefined;
|
|
73
|
+
/** Dependencies - other interfaces that need to be imported */
|
|
74
|
+
readonly dependencies?: readonly string[] | undefined;
|
|
73
75
|
}
|
|
74
76
|
/**
|
|
75
77
|
* TypeScript enum definition.
|
package/dist/index.js
CHANGED
package/dist/plugin.cjs
CHANGED
|
@@ -40,6 +40,7 @@ var TYPE_MAP = {
|
|
|
40
40
|
LongText: "string",
|
|
41
41
|
Date: "string",
|
|
42
42
|
Time: "string",
|
|
43
|
+
DateTime: "string",
|
|
43
44
|
Timestamp: "string",
|
|
44
45
|
Json: "unknown",
|
|
45
46
|
Email: "string",
|
|
@@ -143,6 +144,18 @@ function propertyToTSProperties(propertyName, property, allSchemas, options = {}
|
|
|
143
144
|
comment: `${displayName ?? propertyName} (${field.suffix})`
|
|
144
145
|
});
|
|
145
146
|
}
|
|
147
|
+
if (customType.accessors) {
|
|
148
|
+
for (const accessor of customType.accessors) {
|
|
149
|
+
const accessorName = `${propertyName}_${toSnakeCase(accessor.name)}`;
|
|
150
|
+
expandedProps.push({
|
|
151
|
+
name: accessorName,
|
|
152
|
+
type: "string | null",
|
|
153
|
+
optional: true,
|
|
154
|
+
readonly: isReadonly,
|
|
155
|
+
comment: `${displayName ?? propertyName} (computed)`
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
}
|
|
146
159
|
return expandedProps;
|
|
147
160
|
}
|
|
148
161
|
if (customType && !customType.compound) {
|
|
@@ -197,8 +210,22 @@ function propertyToTSProperties(propertyName, property, allSchemas, options = {}
|
|
|
197
210
|
comment: displayName
|
|
198
211
|
}];
|
|
199
212
|
}
|
|
213
|
+
function extractTypeReferences(type, allSchemaNames) {
|
|
214
|
+
const primitives = /* @__PURE__ */ new Set(["string", "number", "boolean", "unknown", "null", "undefined", "void", "never", "any"]);
|
|
215
|
+
const refs = [];
|
|
216
|
+
const cleanType = type.replace(/\[\]/g, "").replace(/\s*\|\s*null/g, "");
|
|
217
|
+
const parts = cleanType.split(/\s*\|\s*/);
|
|
218
|
+
for (const part of parts) {
|
|
219
|
+
const trimmed = part.trim().replace(/^['"]|['"]$/g, "");
|
|
220
|
+
if (!primitives.has(trimmed) && allSchemaNames.has(trimmed)) {
|
|
221
|
+
refs.push(trimmed);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
return refs;
|
|
225
|
+
}
|
|
200
226
|
function schemaToInterface(schema, allSchemas, options = {}) {
|
|
201
227
|
const properties = [];
|
|
228
|
+
const allSchemaNames = new Set(Object.keys(allSchemas).filter((name) => allSchemas[name].kind !== "enum"));
|
|
202
229
|
if (schema.options?.id !== false) {
|
|
203
230
|
const pkType = schema.options?.idType ?? "BigInt";
|
|
204
231
|
properties.push({
|
|
@@ -241,11 +268,20 @@ function schemaToInterface(schema, allSchemas, options = {}) {
|
|
|
241
268
|
comment: "Soft delete timestamp"
|
|
242
269
|
});
|
|
243
270
|
}
|
|
271
|
+
const dependencySet = /* @__PURE__ */ new Set();
|
|
272
|
+
for (const prop of properties) {
|
|
273
|
+
for (const ref of extractTypeReferences(prop.type, allSchemaNames)) {
|
|
274
|
+
if (ref !== schema.name) {
|
|
275
|
+
dependencySet.add(ref);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
244
279
|
const schemaDisplayName = resolveDisplayName(schema.displayName, options);
|
|
245
280
|
return {
|
|
246
281
|
name: toInterfaceName(schema.name),
|
|
247
282
|
properties,
|
|
248
|
-
comment: schemaDisplayName ?? schema.name
|
|
283
|
+
comment: schemaDisplayName ?? schema.name,
|
|
284
|
+
dependencies: dependencySet.size > 0 ? Array.from(dependencySet).sort() : void 0
|
|
249
285
|
};
|
|
250
286
|
}
|
|
251
287
|
function formatProperty(property) {
|
|
@@ -532,6 +568,13 @@ function generateBaseInterfaceFile(schemaName, schemas, options) {
|
|
|
532
568
|
throw new Error(`Interface not found for schema: ${schemaName}`);
|
|
533
569
|
}
|
|
534
570
|
const parts = [generateBaseHeader()];
|
|
571
|
+
if (iface.dependencies && iface.dependencies.length > 0) {
|
|
572
|
+
for (const dep of iface.dependencies) {
|
|
573
|
+
parts.push(`import type { ${dep} } from './${dep}.js';
|
|
574
|
+
`);
|
|
575
|
+
}
|
|
576
|
+
parts.push("\n");
|
|
577
|
+
}
|
|
535
578
|
parts.push(formatInterface(iface));
|
|
536
579
|
parts.push("\n");
|
|
537
580
|
return {
|
package/dist/plugin.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/plugin.ts","../src/interface-generator.ts","../src/enum-generator.ts","../src/generator.ts"],"sourcesContent":["/**\n * @famgia/omnify-typescript - Plugin\n *\n * Plugin for generating TypeScript type definitions from Omnify schemas.\n *\n * Output structure:\n * - types/models/base/[SchemaName].ts - Auto-generated base interfaces, always overwritten\n * - types/models/enum/[EnumName].ts - Auto-generated enums/type aliases, always overwritten\n * - types/models/[SchemaName].ts - Extends base, user can customize, never overwritten\n * - types/models/index.ts - Re-exports, always overwritten\n *\n * @example\n * ```typescript\n * import { defineConfig } from '@famgia/omnify';\n * import typescript from '@famgia/omnify-typescript/plugin';\n *\n * export default defineConfig({\n * plugins: [\n * typescript({\n * modelsPath: 'types/models', // default\n * }),\n * ],\n * });\n * ```\n */\n\nimport type { OmnifyPlugin, GeneratorOutput, GeneratorContext, PluginConfigSchema } from '@famgia/omnify-types';\nimport { generateTypeScript } from './generator.js';\n\n/**\n * Configuration schema for TypeScript plugin UI settings\n */\nconst TYPESCRIPT_CONFIG_SCHEMA: PluginConfigSchema = {\n fields: [\n {\n key: 'modelsPath',\n type: 'path',\n label: 'Models Output Path',\n description: 'Directory for generated TypeScript model files',\n default: 'types/models',\n group: 'output',\n },\n ],\n};\n\n/**\n * Options for the TypeScript plugin.\n */\nexport interface TypeScriptPluginOptions {\n /**\n * Path for TypeScript model files.\n * @default 'types/models'\n */\n modelsPath?: string;\n}\n\n/**\n * Resolved options with defaults applied.\n */\ninterface ResolvedOptions {\n modelsPath: string;\n}\n\n/**\n * Resolves options with defaults.\n */\nfunction resolveOptions(options?: TypeScriptPluginOptions): ResolvedOptions {\n return {\n modelsPath: options?.modelsPath ?? 'types/models',\n };\n}\n\n/**\n * Creates the TypeScript plugin with the specified options.\n *\n * @param options - Plugin configuration options\n * @returns OmnifyPlugin configured for TypeScript generation\n */\nexport default function typescriptPlugin(options?: TypeScriptPluginOptions): OmnifyPlugin {\n const resolved = resolveOptions(options);\n\n return {\n name: '@famgia/omnify-typescript',\n version: '0.0.1',\n configSchema: TYPESCRIPT_CONFIG_SCHEMA,\n\n generators: [\n {\n name: 'typescript-models',\n description: 'Generate TypeScript model definitions',\n\n generate: async (ctx: GeneratorContext): Promise<GeneratorOutput[]> => {\n const files = generateTypeScript(ctx.schemas);\n\n return files.map((file) => ({\n path: `${resolved.modelsPath}/${file.filePath}`,\n content: file.content,\n type: 'type' as const,\n overwrite: file.overwrite,\n metadata: {\n types: file.types,\n },\n }));\n },\n },\n ],\n };\n}\n\n// Named export for flexibility\nexport { typescriptPlugin };\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 * Convert a string to snake_case.\n */\nfunction toSnakeCase(str: string): string {\n return str\n .replace(/([A-Z])/g, '_$1')\n .replace(/^_/, '')\n .toLowerCase();\n}\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 * For compound custom types, expands to multiple properties.\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; fields?: Record<string, { nullable?: boolean }> };\n const isReadonly = options.readonly ?? true;\n // Resolve displayName using locale config\n const displayName = resolveDisplayName(baseProp.displayName, options);\n\n // Handle custom compound types from plugins (e.g., JapaneseName, JapaneseAddress)\n if (options.customTypes) {\n const customType = options.customTypes.get(property.type);\n if (customType?.compound && customType.expand) {\n const expandedProps: TSProperty[] = [];\n for (const field of customType.expand) {\n const fieldName = `${propertyName}_${toSnakeCase(field.suffix)}`;\n const fieldOverride = baseProp.fields?.[field.suffix];\n const isNullable = fieldOverride?.nullable ?? baseProp.nullable ?? false;\n const tsType = field.typescript?.type ?? 'string';\n\n expandedProps.push({\n name: fieldName,\n type: tsType,\n optional: isNullable,\n readonly: isReadonly,\n comment: `${displayName ?? propertyName} (${field.suffix})`,\n });\n }\n return expandedProps;\n }\n // Handle simple custom types (non-compound)\n if (customType && !customType.compound) {\n const tsType = customType.typescript?.type ?? 'string';\n return [{\n name: toPropertyName(propertyName),\n type: tsType,\n optional: baseProp.nullable ?? false,\n readonly: isReadonly,\n comment: displayName,\n }];\n }\n }\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 (snake_case to match database columns)\n if (schema.options?.timestamps !== false) {\n properties.push(\n {\n name: 'created_at',\n type: 'string',\n optional: true,\n readonly: options.readonly ?? true,\n comment: 'Creation timestamp',\n },\n {\n name: 'updated_at',\n type: 'string',\n optional: true,\n readonly: options.readonly ?? true,\n comment: 'Last update timestamp',\n }\n );\n }\n\n // Soft delete (snake_case to match database columns)\n if (schema.options?.softDelete) {\n properties.push({\n name: 'deleted_at',\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 /** Display label - supports multi-language (string or locale map) */\n readonly label?: LocalizedString;\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 * Resolves LocalizedString labels to string using provided options.\n */\nfunction parseEnumValue(\n value: string | InlineEnumValue,\n options: TypeScriptOptions = {}\n): 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 // Resolve LocalizedString label to string\n const resolvedLabel = resolveDisplayName(value.label, options);\n\n return {\n name: toEnumMemberName(value.value),\n value: value.value,\n label: resolvedLabel,\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 =>\n parseEnumValue(value as string | InlineEnumValue, options)\n );\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;;;ACOA,0BAAuC;AAMvC,SAAS,YAAY,KAAqB;AACxC,SAAO,IACJ,QAAQ,YAAY,KAAK,EACzB,QAAQ,MAAM,EAAE,EAChB,YAAY;AACjB;AAKA,IAAM,WAAmC;AAAA,EACvC,QAAQ;AAAA,EACR,KAAK;AAAA,EACL,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,SAAS;AAAA,EACT,MAAM;AAAA,EACN,UAAU;AAAA,EACV,MAAM;AAAA,EACN,MAAM;AAAA,EACN,WAAW;AAAA,EACX,MAAM;AAAA,EACN,OAAO;AAAA,EACP,UAAU;AAAA,EACV,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,QAAQ;AACV;AAMO,IAAM,sBAAsB;AAKnC,IAAM,cAAsC;AAAA,EAC1C,KAAK;AAA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E;AAGA,aAAW,UAAU,OAAO,OAAO,OAAO,GAAG;AAC3C,QAAI,OAAO,SAAS,OAAQ;AAC5B,UAAM,KAAK,kBAAkB,OAAO,IAAI,CAAC;AAAA,EAC3C;AAGA,QAAM,KAAK,kBAAkB,SAAS,OAAO,WAAW,CAAC;AAEzD,SAAO;AACT;;;AHrMA,IAAM,2BAA+C;AAAA,EACnD,QAAQ;AAAA,IACN;AAAA,MACE,KAAK;AAAA,MACL,MAAM;AAAA,MACN,OAAO;AAAA,MACP,aAAa;AAAA,MACb,SAAS;AAAA,MACT,OAAO;AAAA,IACT;AAAA,EACF;AACF;AAuBA,SAAS,eAAe,SAAoD;AAC1E,SAAO;AAAA,IACL,YAAY,SAAS,cAAc;AAAA,EACrC;AACF;AAQe,SAAR,iBAAkC,SAAiD;AACxF,QAAM,WAAW,eAAe,OAAO;AAEvC,SAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS;AAAA,IACT,cAAc;AAAA,IAEd,YAAY;AAAA,MACV;AAAA,QACE,MAAM;AAAA,QACN,aAAa;AAAA,QAEb,UAAU,OAAO,QAAsD;AACrE,gBAAM,QAAQ,mBAAmB,IAAI,OAAO;AAE5C,iBAAO,MAAM,IAAI,CAAC,UAAU;AAAA,YAC1B,MAAM,GAAG,SAAS,UAAU,IAAI,KAAK,QAAQ;AAAA,YAC7C,SAAS,KAAK;AAAA,YACd,MAAM;AAAA,YACN,WAAW,KAAK;AAAA,YAChB,UAAU;AAAA,cACR,OAAO,KAAK;AAAA,YACd;AAAA,UACF,EAAE;AAAA,QACJ;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;","names":["import_omnify_types","resolveDisplayName","resolveDisplayName"]}
|
|
1
|
+
{"version":3,"sources":["../src/plugin.ts","../src/interface-generator.ts","../src/enum-generator.ts","../src/generator.ts"],"sourcesContent":["/**\n * @famgia/omnify-typescript - Plugin\n *\n * Plugin for generating TypeScript type definitions from Omnify schemas.\n *\n * Output structure:\n * - types/models/base/[SchemaName].ts - Auto-generated base interfaces, always overwritten\n * - types/models/enum/[EnumName].ts - Auto-generated enums/type aliases, always overwritten\n * - types/models/[SchemaName].ts - Extends base, user can customize, never overwritten\n * - types/models/index.ts - Re-exports, always overwritten\n *\n * @example\n * ```typescript\n * import { defineConfig } from '@famgia/omnify';\n * import typescript from '@famgia/omnify-typescript/plugin';\n *\n * export default defineConfig({\n * plugins: [\n * typescript({\n * modelsPath: 'types/models', // default\n * }),\n * ],\n * });\n * ```\n */\n\nimport type { OmnifyPlugin, GeneratorOutput, GeneratorContext, PluginConfigSchema } from '@famgia/omnify-types';\nimport { generateTypeScript } from './generator.js';\n\n/**\n * Configuration schema for TypeScript plugin UI settings\n */\nconst TYPESCRIPT_CONFIG_SCHEMA: PluginConfigSchema = {\n fields: [\n {\n key: 'modelsPath',\n type: 'path',\n label: 'Models Output Path',\n description: 'Directory for generated TypeScript model files',\n default: 'types/models',\n group: 'output',\n },\n ],\n};\n\n/**\n * Options for the TypeScript plugin.\n */\nexport interface TypeScriptPluginOptions {\n /**\n * Path for TypeScript model files.\n * @default 'types/models'\n */\n modelsPath?: string;\n}\n\n/**\n * Resolved options with defaults applied.\n */\ninterface ResolvedOptions {\n modelsPath: string;\n}\n\n/**\n * Resolves options with defaults.\n */\nfunction resolveOptions(options?: TypeScriptPluginOptions): ResolvedOptions {\n return {\n modelsPath: options?.modelsPath ?? 'types/models',\n };\n}\n\n/**\n * Creates the TypeScript plugin with the specified options.\n *\n * @param options - Plugin configuration options\n * @returns OmnifyPlugin configured for TypeScript generation\n */\nexport default function typescriptPlugin(options?: TypeScriptPluginOptions): OmnifyPlugin {\n const resolved = resolveOptions(options);\n\n return {\n name: '@famgia/omnify-typescript',\n version: '0.0.1',\n configSchema: TYPESCRIPT_CONFIG_SCHEMA,\n\n generators: [\n {\n name: 'typescript-models',\n description: 'Generate TypeScript model definitions',\n\n generate: async (ctx: GeneratorContext): Promise<GeneratorOutput[]> => {\n const files = generateTypeScript(ctx.schemas);\n\n return files.map((file) => ({\n path: `${resolved.modelsPath}/${file.filePath}`,\n content: file.content,\n type: 'type' as const,\n overwrite: file.overwrite,\n metadata: {\n types: file.types,\n },\n }));\n },\n },\n ],\n };\n}\n\n// Named export for flexibility\nexport { typescriptPlugin };\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 * Convert a string to snake_case.\n */\nfunction toSnakeCase(str: string): string {\n return str\n .replace(/([A-Z])/g, '_$1')\n .replace(/^_/, '')\n .toLowerCase();\n}\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 DateTime: '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 * For compound custom types, expands to multiple properties.\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; fields?: Record<string, { nullable?: boolean }> };\n const isReadonly = options.readonly ?? true;\n // Resolve displayName using locale config\n const displayName = resolveDisplayName(baseProp.displayName, options);\n\n // Handle custom compound types from plugins (e.g., JapaneseName, JapaneseAddress)\n if (options.customTypes) {\n const customType = options.customTypes.get(property.type);\n if (customType?.compound && customType.expand) {\n const expandedProps: TSProperty[] = [];\n for (const field of customType.expand) {\n const fieldName = `${propertyName}_${toSnakeCase(field.suffix)}`;\n const fieldOverride = baseProp.fields?.[field.suffix];\n const isNullable = fieldOverride?.nullable ?? baseProp.nullable ?? false;\n const tsType = field.typescript?.type ?? 'string';\n\n expandedProps.push({\n name: fieldName,\n type: tsType,\n optional: isNullable,\n readonly: isReadonly,\n comment: `${displayName ?? propertyName} (${field.suffix})`,\n });\n }\n\n // Add accessor properties (computed properties like full_name)\n if (customType.accessors) {\n for (const accessor of customType.accessors) {\n const accessorName = `${propertyName}_${toSnakeCase(accessor.name)}`;\n expandedProps.push({\n name: accessorName,\n type: 'string | null',\n optional: true,\n readonly: isReadonly,\n comment: `${displayName ?? propertyName} (computed)`,\n });\n }\n }\n\n return expandedProps;\n }\n // Handle simple custom types (non-compound)\n if (customType && !customType.compound) {\n const tsType = customType.typescript?.type ?? 'string';\n return [{\n name: toPropertyName(propertyName),\n type: tsType,\n optional: baseProp.nullable ?? false,\n readonly: isReadonly,\n comment: displayName,\n }];\n }\n }\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 * Extracts referenced interface names from a TypeScript type string.\n * Returns only interface names (not primitives like string, number, boolean, unknown).\n */\nfunction extractTypeReferences(type: string, allSchemaNames: Set<string>): string[] {\n const primitives = new Set(['string', 'number', 'boolean', 'unknown', 'null', 'undefined', 'void', 'never', 'any']);\n const refs: string[] = [];\n\n // Remove array notation and split by | for union types\n const cleanType = type.replace(/\\[\\]/g, '').replace(/\\s*\\|\\s*null/g, '');\n const parts = cleanType.split(/\\s*\\|\\s*/);\n\n for (const part of parts) {\n // Remove quotes (for string literal types like 'Post')\n const trimmed = part.trim().replace(/^['\"]|['\"]$/g, '');\n if (!primitives.has(trimmed) && allSchemaNames.has(trimmed)) {\n refs.push(trimmed);\n }\n }\n\n return refs;\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 const allSchemaNames = new Set(Object.keys(allSchemas).filter(name => allSchemas[name]!.kind !== 'enum'));\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 (snake_case to match database columns)\n if (schema.options?.timestamps !== false) {\n properties.push(\n {\n name: 'created_at',\n type: 'string',\n optional: true,\n readonly: options.readonly ?? true,\n comment: 'Creation timestamp',\n },\n {\n name: 'updated_at',\n type: 'string',\n optional: true,\n readonly: options.readonly ?? true,\n comment: 'Last update timestamp',\n }\n );\n }\n\n // Soft delete (snake_case to match database columns)\n if (schema.options?.softDelete) {\n properties.push({\n name: 'deleted_at',\n type: 'string',\n optional: true,\n readonly: options.readonly ?? true,\n comment: 'Soft delete timestamp',\n });\n }\n\n // Collect dependencies from property types\n const dependencySet = new Set<string>();\n for (const prop of properties) {\n for (const ref of extractTypeReferences(prop.type, allSchemaNames)) {\n if (ref !== schema.name) { // Don't include self-references\n dependencySet.add(ref);\n }\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 dependencies: dependencySet.size > 0 ? Array.from(dependencySet).sort() : undefined,\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 /** Display label - supports multi-language (string or locale map) */\n readonly label?: LocalizedString;\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 * Resolves LocalizedString labels to string using provided options.\n */\nfunction parseEnumValue(\n value: string | InlineEnumValue,\n options: TypeScriptOptions = {}\n): 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 // Resolve LocalizedString label to string\n const resolvedLabel = resolveDisplayName(value.label, options);\n\n return {\n name: toEnumMemberName(value.value),\n value: value.value,\n label: resolvedLabel,\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 =>\n parseEnumValue(value as string | InlineEnumValue, options)\n );\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\n // Add imports for dependencies\n if (iface.dependencies && iface.dependencies.length > 0) {\n for (const dep of iface.dependencies) {\n parts.push(`import type { ${dep} } from './${dep}.js';\\n`);\n }\n parts.push('\\n');\n }\n\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;;;ACOA,0BAAuC;AAMvC,SAAS,YAAY,KAAqB;AACxC,SAAO,IACJ,QAAQ,YAAY,KAAK,EACzB,QAAQ,MAAM,EAAE,EAChB,YAAY;AACjB;AAKA,IAAM,WAAmC;AAAA,EACvC,QAAQ;AAAA,EACR,KAAK;AAAA,EACL,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,SAAS;AAAA,EACT,MAAM;AAAA,EACN,UAAU;AAAA,EACV,MAAM;AAAA,EACN,MAAM;AAAA,EACN,UAAU;AAAA,EACV,WAAW;AAAA,EACX,MAAM;AAAA,EACN,OAAO;AAAA,EACP,UAAU;AAAA,EACV,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,QAAQ;AACV;AAMO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AC;AAAA,EACzC;AAGA,aAAW,UAAU,OAAO,OAAO,OAAO,GAAG;AAC3C,QAAI,OAAO,SAAS,OAAQ;AAC5B,UAAM,KAAK,0BAA0B,OAAO,MAAM,SAAS,IAAI,CAAC;AAAA,EAClE;AAGA,aAAW,UAAU,OAAO,OAAO,OAAO,GAAG;AAC3C,QAAI,OAAO,SAAS,OAAQ;AAC5B,UAAM,KAAK,kBAAkB,OAAO,IAAI,CAAC;AAAA,EAC3C;AAGA,QAAM,KAAK,kBAAkB,SAAS,OAAO,WAAW,CAAC;AAEzD,SAAO;AACT;;;AH9MA,IAAM,2BAA+C;AAAA,EACnD,QAAQ;AAAA,IACN;AAAA,MACE,KAAK;AAAA,MACL,MAAM;AAAA,MACN,OAAO;AAAA,MACP,aAAa;AAAA,MACb,SAAS;AAAA,MACT,OAAO;AAAA,IACT;AAAA,EACF;AACF;AAuBA,SAAS,eAAe,SAAoD;AAC1E,SAAO;AAAA,IACL,YAAY,SAAS,cAAc;AAAA,EACrC;AACF;AAQe,SAAR,iBAAkC,SAAiD;AACxF,QAAM,WAAW,eAAe,OAAO;AAEvC,SAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS;AAAA,IACT,cAAc;AAAA,IAEd,YAAY;AAAA,MACV;AAAA,QACE,MAAM;AAAA,QACN,aAAa;AAAA,QAEb,UAAU,OAAO,QAAsD;AACrE,gBAAM,QAAQ,mBAAmB,IAAI,OAAO;AAE5C,iBAAO,MAAM,IAAI,CAAC,UAAU;AAAA,YAC1B,MAAM,GAAG,SAAS,UAAU,IAAI,KAAK,QAAQ;AAAA,YAC7C,SAAS,KAAK;AAAA,YACd,MAAM;AAAA,YACN,WAAW,KAAK;AAAA,YAChB,UAAU;AAAA,cACR,OAAO,KAAK;AAAA,YACd;AAAA,UACF,EAAE;AAAA,QACJ;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;","names":["import_omnify_types","resolveDisplayName","resolveDisplayName"]}
|
package/dist/plugin.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@famgia/omnify-typescript",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.26",
|
|
4
4
|
"description": "TypeScript type definitions generator for Omnify schemas",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"directory": "packages/typescript-generator"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@famgia/omnify-types": "0.0.
|
|
50
|
+
"@famgia/omnify-types": "0.0.34"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"tsup": "^8.5.1",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/interface-generator.ts","../src/enum-generator.ts","../src/generator.ts"],"sourcesContent":["/**\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 * Convert a string to snake_case.\n */\nfunction toSnakeCase(str: string): string {\n return str\n .replace(/([A-Z])/g, '_$1')\n .replace(/^_/, '')\n .toLowerCase();\n}\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 * For compound custom types, expands to multiple properties.\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; fields?: Record<string, { nullable?: boolean }> };\n const isReadonly = options.readonly ?? true;\n // Resolve displayName using locale config\n const displayName = resolveDisplayName(baseProp.displayName, options);\n\n // Handle custom compound types from plugins (e.g., JapaneseName, JapaneseAddress)\n if (options.customTypes) {\n const customType = options.customTypes.get(property.type);\n if (customType?.compound && customType.expand) {\n const expandedProps: TSProperty[] = [];\n for (const field of customType.expand) {\n const fieldName = `${propertyName}_${toSnakeCase(field.suffix)}`;\n const fieldOverride = baseProp.fields?.[field.suffix];\n const isNullable = fieldOverride?.nullable ?? baseProp.nullable ?? false;\n const tsType = field.typescript?.type ?? 'string';\n\n expandedProps.push({\n name: fieldName,\n type: tsType,\n optional: isNullable,\n readonly: isReadonly,\n comment: `${displayName ?? propertyName} (${field.suffix})`,\n });\n }\n return expandedProps;\n }\n // Handle simple custom types (non-compound)\n if (customType && !customType.compound) {\n const tsType = customType.typescript?.type ?? 'string';\n return [{\n name: toPropertyName(propertyName),\n type: tsType,\n optional: baseProp.nullable ?? false,\n readonly: isReadonly,\n comment: displayName,\n }];\n }\n }\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 (snake_case to match database columns)\n if (schema.options?.timestamps !== false) {\n properties.push(\n {\n name: 'created_at',\n type: 'string',\n optional: true,\n readonly: options.readonly ?? true,\n comment: 'Creation timestamp',\n },\n {\n name: 'updated_at',\n type: 'string',\n optional: true,\n readonly: options.readonly ?? true,\n comment: 'Last update timestamp',\n }\n );\n }\n\n // Soft delete (snake_case to match database columns)\n if (schema.options?.softDelete) {\n properties.push({\n name: 'deleted_at',\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 /** Display label - supports multi-language (string or locale map) */\n readonly label?: LocalizedString;\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 * Resolves LocalizedString labels to string using provided options.\n */\nfunction parseEnumValue(\n value: string | InlineEnumValue,\n options: TypeScriptOptions = {}\n): 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 // Resolve LocalizedString label to string\n const resolvedLabel = resolveDisplayName(value.label, options);\n\n return {\n name: toEnumMemberName(value.value),\n value: value.value,\n label: resolvedLabel,\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 =>\n parseEnumValue(value as string | InlineEnumValue, options)\n );\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;\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