@omnifyjp/ts 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/cli.d.ts +13 -0
  2. package/dist/cli.js +180 -0
  3. package/dist/enum-generator.d.ts +28 -0
  4. package/dist/enum-generator.js +253 -0
  5. package/dist/generator.d.ts +19 -0
  6. package/dist/generator.js +330 -0
  7. package/dist/i18n-generator.d.ts +10 -0
  8. package/dist/i18n-generator.js +143 -0
  9. package/dist/index.d.ts +10 -0
  10. package/dist/index.js +9 -0
  11. package/dist/interface-generator.d.ts +31 -0
  12. package/dist/interface-generator.js +341 -0
  13. package/dist/php/base-model-generator.d.ts +7 -0
  14. package/dist/php/base-model-generator.js +70 -0
  15. package/dist/php/factory-generator.d.ts +7 -0
  16. package/dist/php/factory-generator.js +95 -0
  17. package/dist/php/faker-mapper.d.ts +12 -0
  18. package/dist/php/faker-mapper.js +206 -0
  19. package/dist/php/index.d.ts +18 -0
  20. package/dist/php/index.js +40 -0
  21. package/dist/php/locales-generator.d.ts +7 -0
  22. package/dist/php/locales-generator.js +135 -0
  23. package/dist/php/model-generator.d.ts +7 -0
  24. package/dist/php/model-generator.js +396 -0
  25. package/dist/php/naming-helper.d.ts +22 -0
  26. package/dist/php/naming-helper.js +61 -0
  27. package/dist/php/relation-builder.d.ts +12 -0
  28. package/dist/php/relation-builder.js +147 -0
  29. package/dist/php/request-generator.d.ts +7 -0
  30. package/dist/php/request-generator.js +221 -0
  31. package/dist/php/resource-generator.d.ts +7 -0
  32. package/dist/php/resource-generator.js +178 -0
  33. package/dist/php/schema-reader.d.ts +28 -0
  34. package/dist/php/schema-reader.js +79 -0
  35. package/dist/php/service-provider-generator.d.ts +7 -0
  36. package/dist/php/service-provider-generator.js +64 -0
  37. package/dist/php/trait-generator.d.ts +6 -0
  38. package/dist/php/trait-generator.js +104 -0
  39. package/dist/php/type-mapper.d.ts +25 -0
  40. package/dist/php/type-mapper.js +217 -0
  41. package/dist/php/types.d.ts +61 -0
  42. package/dist/php/types.js +68 -0
  43. package/dist/types.d.ts +196 -0
  44. package/dist/types.js +6 -0
  45. package/dist/zod-generator.d.ts +32 -0
  46. package/dist/zod-generator.js +428 -0
  47. package/package.json +31 -0
@@ -0,0 +1,104 @@
1
+ /**
2
+ * Port of TraitGenerator.php — generates HasLocalizedDisplayName trait.
3
+ */
4
+ import { baseFile } from './types.js';
5
+ /** Generate the HasLocalizedDisplayName trait. */
6
+ export function generateTrait(config) {
7
+ const baseNamespace = config.models.baseNamespace;
8
+ const content = `<?php
9
+
10
+ namespace ${baseNamespace}\\Traits;
11
+
12
+ /**
13
+ * Trait for localized display names.
14
+ * Uses Laravel's app()->getLocale() for locale resolution.
15
+ *
16
+ * DO NOT EDIT - This file is auto-generated by Omnify.
17
+ * Any changes will be overwritten on next generation.
18
+ *
19
+ * @generated by omnify
20
+ */
21
+ trait HasLocalizedDisplayName
22
+ {
23
+ /**
24
+ * Get the localized display name for this model.
25
+ *
26
+ * @param string|null $locale Locale code (defaults to app locale)
27
+ * @return string
28
+ */
29
+ public static function displayName(?string $locale = null): string
30
+ {
31
+ $locale = $locale ?? app()->getLocale();
32
+ $displayNames = static::$localizedDisplayNames ?? [];
33
+
34
+ return $displayNames[$locale]
35
+ ?? $displayNames[config('app.fallback_locale', 'en')]
36
+ ?? $displayNames[array_key_first($displayNames) ?? 'en']
37
+ ?? class_basename(static::class);
38
+ }
39
+
40
+ /**
41
+ * Get all localized display names for this model.
42
+ *
43
+ * @return array<string, string>
44
+ */
45
+ public static function allDisplayNames(): array
46
+ {
47
+ return static::$localizedDisplayNames ?? [];
48
+ }
49
+
50
+ /**
51
+ * Get the localized display name for a property.
52
+ *
53
+ * @param string $property Property name
54
+ * @param string|null $locale Locale code (defaults to app locale)
55
+ * @return string
56
+ */
57
+ public static function propertyDisplayName(string $property, ?string $locale = null): string
58
+ {
59
+ $locale = $locale ?? app()->getLocale();
60
+ $displayNames = static::$localizedPropertyDisplayNames[$property] ?? [];
61
+
62
+ return $displayNames[$locale]
63
+ ?? $displayNames[config('app.fallback_locale', 'en')]
64
+ ?? $displayNames[array_key_first($displayNames) ?? 'en']
65
+ ?? $property;
66
+ }
67
+
68
+ /**
69
+ * Get all localized display names for a property.
70
+ *
71
+ * @param string $property Property name
72
+ * @return array<string, string>
73
+ */
74
+ public static function allPropertyDisplayNames(string $property): array
75
+ {
76
+ return static::$localizedPropertyDisplayNames[$property] ?? [];
77
+ }
78
+
79
+ /**
80
+ * Get all property display names for a given locale.
81
+ *
82
+ * @param string|null $locale Locale code (defaults to app locale)
83
+ * @return array<string, string>
84
+ */
85
+ public static function allPropertyDisplayNamesForLocale(?string $locale = null): array
86
+ {
87
+ $locale = $locale ?? app()->getLocale();
88
+ $result = [];
89
+
90
+ foreach (static::$localizedPropertyDisplayNames ?? [] as $property => $displayNames) {
91
+ $result[$property] = $displayNames[$locale]
92
+ ?? $displayNames[config('app.fallback_locale', 'en')]
93
+ ?? $displayNames[array_key_first($displayNames) ?? 'en']
94
+ ?? $property;
95
+ }
96
+
97
+ return $result;
98
+ }
99
+ }
100
+ `;
101
+ return [
102
+ baseFile(`${config.models.basePath}/Traits/HasLocalizedDisplayName.php`, content),
103
+ ];
104
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Port of TypeMapper.php — type mappings for PHP casts, rules, resources.
3
+ */
4
+ type Rule = string | ['rule_in', string[]] | ['rule_unique_ignore', string, string];
5
+ /** Map Omnify property type to PHP cast. */
6
+ export declare function toCast(type: string, property?: Record<string, unknown>): string | null;
7
+ /** Map Omnify property type to PHP doc type. */
8
+ export declare function toPhpDocType(type: string, nullable?: boolean): string;
9
+ /** Generate validation rules for a property (Store request). */
10
+ export declare function toStoreRules(property: Record<string, unknown>, tableName: string): Rule[];
11
+ /** Generate validation rules for a property (Update request). */
12
+ export declare function toUpdateRules(property: Record<string, unknown>, tableName: string, modelRouteParam: string): Rule[];
13
+ /** Format validation rules as PHP code string. */
14
+ export declare function formatRules(rules: Rule[]): string;
15
+ /** Resolve enum values from property definition. */
16
+ export declare function resolveEnumValues(property: Record<string, unknown>): string[] | null;
17
+ /** Check if a property type should be hidden by default. */
18
+ export declare function isHiddenByDefault(type: string): boolean;
19
+ /** Check if a property needs a cast. */
20
+ export declare function needsCast(type: string): boolean;
21
+ /** Get the resource output expression for a property. */
22
+ export declare function toResourceExpression(fieldName: string, type: string): string;
23
+ /** Check if a rules array contains a Rule:: object. */
24
+ export declare function hasRuleObject(rules: Rule[]): boolean;
25
+ export {};
@@ -0,0 +1,217 @@
1
+ /**
2
+ * Port of TypeMapper.php — type mappings for PHP casts, rules, resources.
3
+ */
4
+ import { toTableName } from './naming-helper.js';
5
+ /** Map Omnify property type to PHP cast. */
6
+ export function toCast(type, property = {}) {
7
+ switch (type) {
8
+ case 'Boolean': return 'boolean';
9
+ case 'Int':
10
+ case 'BigInt':
11
+ case 'TinyInt': return 'integer';
12
+ case 'Float': return 'float';
13
+ case 'Decimal': return `decimal:${property['scale'] ?? 2}`;
14
+ case 'Json': return 'array';
15
+ case 'Date': return 'date';
16
+ case 'DateTime':
17
+ case 'Timestamp': return 'datetime';
18
+ case 'Password': return 'hashed';
19
+ default: return null;
20
+ }
21
+ }
22
+ /** Map Omnify property type to PHP doc type. */
23
+ export function toPhpDocType(type, nullable = false) {
24
+ let phpType;
25
+ switch (type) {
26
+ case 'String':
27
+ case 'Email':
28
+ case 'Password':
29
+ case 'Text':
30
+ case 'MediumText':
31
+ case 'LongText':
32
+ case 'Enum':
33
+ case 'EnumRef':
34
+ case 'Uuid':
35
+ case 'Slug':
36
+ case 'Url':
37
+ case 'Phone':
38
+ phpType = 'string';
39
+ break;
40
+ case 'Int':
41
+ case 'BigInt':
42
+ case 'TinyInt':
43
+ phpType = 'int';
44
+ break;
45
+ case 'Float':
46
+ case 'Decimal':
47
+ phpType = 'float';
48
+ break;
49
+ case 'Boolean':
50
+ phpType = 'bool';
51
+ break;
52
+ case 'Date':
53
+ case 'DateTime':
54
+ case 'Timestamp':
55
+ case 'Time':
56
+ phpType = 'mixed';
57
+ break;
58
+ case 'Json':
59
+ phpType = 'array';
60
+ break;
61
+ default:
62
+ phpType = 'mixed';
63
+ }
64
+ return nullable ? `${phpType}|null` : phpType;
65
+ }
66
+ /** Generate validation rules for a property (Store request). */
67
+ export function toStoreRules(property, tableName) {
68
+ const type = property['type'] ?? 'String';
69
+ const nullable = property['nullable'] ?? false;
70
+ const unique = property['unique'] ?? false;
71
+ const rules = [];
72
+ rules.push(nullable ? 'nullable' : 'required');
73
+ switch (type) {
74
+ case 'String':
75
+ case 'Slug':
76
+ case 'Url':
77
+ case 'Phone': {
78
+ rules.push('string');
79
+ const length = property['length'] ?? 255;
80
+ rules.push(`max:${length}`);
81
+ break;
82
+ }
83
+ case 'Email':
84
+ rules.push('string', 'max:255', 'email');
85
+ if (unique)
86
+ rules.push(`unique:${tableName}`);
87
+ break;
88
+ case 'Password':
89
+ rules.push('string', 'max:255');
90
+ break;
91
+ case 'Text':
92
+ case 'MediumText':
93
+ case 'LongText':
94
+ rules.push('string');
95
+ break;
96
+ case 'Int':
97
+ case 'BigInt':
98
+ case 'TinyInt':
99
+ rules.push('integer');
100
+ break;
101
+ case 'Float':
102
+ case 'Decimal':
103
+ rules.push('numeric');
104
+ break;
105
+ case 'Boolean':
106
+ rules.push('boolean');
107
+ break;
108
+ case 'Date':
109
+ case 'DateTime':
110
+ case 'Timestamp':
111
+ case 'Time':
112
+ rules.push('date');
113
+ break;
114
+ case 'Json':
115
+ rules.push('array');
116
+ break;
117
+ case 'Uuid':
118
+ rules.push('string', 'uuid');
119
+ break;
120
+ case 'Enum': {
121
+ rules.push('string');
122
+ const enumValues = resolveEnumValues(property);
123
+ if (enumValues)
124
+ rules.push(['rule_in', enumValues]);
125
+ break;
126
+ }
127
+ case 'EnumRef':
128
+ rules.push('string');
129
+ break;
130
+ case 'Association': {
131
+ const relation = property['relation'] ?? '';
132
+ if (relation === 'ManyToOne') {
133
+ rules.push('integer');
134
+ const target = property['target'] ?? '';
135
+ if (target)
136
+ rules.push(`exists:${toTableName(target)},id`);
137
+ }
138
+ break;
139
+ }
140
+ default:
141
+ rules.push('string', 'max:255');
142
+ }
143
+ if (unique && type !== 'Email') {
144
+ rules.push(`unique:${tableName}`);
145
+ }
146
+ return rules;
147
+ }
148
+ /** Generate validation rules for a property (Update request). */
149
+ export function toUpdateRules(property, tableName, modelRouteParam) {
150
+ let rules = toStoreRules(property, tableName);
151
+ const unique = property['unique'] ?? false;
152
+ // Replace 'required' with 'sometimes'
153
+ rules = rules.map(r => r === 'required' ? 'sometimes' : r);
154
+ // Replace simple unique with Rule::unique()->ignore()
155
+ if (unique) {
156
+ rules = rules.filter(r => !(typeof r === 'string' && r === `unique:${tableName}`));
157
+ rules.push(['rule_unique_ignore', tableName, modelRouteParam]);
158
+ }
159
+ return rules;
160
+ }
161
+ /** Format validation rules as PHP code string. */
162
+ export function formatRules(rules) {
163
+ const parts = [];
164
+ for (const rule of rules) {
165
+ if (typeof rule === 'string') {
166
+ parts.push(`'${rule}'`);
167
+ }
168
+ else if (Array.isArray(rule)) {
169
+ if (rule[0] === 'rule_in') {
170
+ const values = rule[1].map(v => `'${v}'`).join(', ');
171
+ parts.push(`Rule::in([${values}])`);
172
+ }
173
+ else if (rule[0] === 'rule_unique_ignore') {
174
+ parts.push(`Rule::unique('${rule[1]}')->ignore($this->route('${rule[2]}'))`);
175
+ }
176
+ }
177
+ }
178
+ return `[${parts.join(', ')}]`;
179
+ }
180
+ /** Resolve enum values from property definition. */
181
+ export function resolveEnumValues(property) {
182
+ const enumDef = property['enum'];
183
+ if (enumDef == null)
184
+ return null;
185
+ if (Array.isArray(enumDef)) {
186
+ const values = [];
187
+ for (const v of enumDef) {
188
+ if (typeof v === 'string')
189
+ values.push(v);
190
+ else if (typeof v === 'object' && v !== null && 'value' in v)
191
+ values.push(v.value);
192
+ }
193
+ return values.length > 0 ? values : null;
194
+ }
195
+ return null;
196
+ }
197
+ /** Check if a property type should be hidden by default. */
198
+ export function isHiddenByDefault(type) {
199
+ return type === 'Password';
200
+ }
201
+ /** Check if a property needs a cast. */
202
+ export function needsCast(type) {
203
+ return toCast(type) !== null;
204
+ }
205
+ /** Get the resource output expression for a property. */
206
+ export function toResourceExpression(fieldName, type) {
207
+ switch (type) {
208
+ case 'Date': return `$this->${fieldName}?->toDateString()`;
209
+ case 'DateTime':
210
+ case 'Timestamp': return `$this->${fieldName}?->toISOString()`;
211
+ default: return `$this->${fieldName}`;
212
+ }
213
+ }
214
+ /** Check if a rules array contains a Rule:: object. */
215
+ export function hasRuleObject(rules) {
216
+ return rules.some(r => Array.isArray(r) && ['rule_in', 'rule_unique_ignore'].includes(r[0]));
217
+ }
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Types for PHP code generation output.
3
+ */
4
+ /** A generated PHP file. */
5
+ export interface GeneratedFile {
6
+ readonly path: string;
7
+ readonly content: string;
8
+ readonly overwrite: boolean;
9
+ readonly type: 'base' | 'user';
10
+ }
11
+ /** Create a base file (always overwritten). */
12
+ export declare function baseFile(path: string, content: string): GeneratedFile;
13
+ /** Create a user file (created once, skip if exists). */
14
+ export declare function userFile(path: string, content: string): GeneratedFile;
15
+ /** Per-target path and namespace override from codegen.laravel config. */
16
+ export interface LaravelPathOverride {
17
+ path?: string;
18
+ namespace?: string;
19
+ }
20
+ /** Overrides from codegen.laravel YAML config (all optional). */
21
+ export interface LaravelCodegenOverrides {
22
+ model?: LaravelPathOverride;
23
+ request?: LaravelPathOverride;
24
+ resource?: LaravelPathOverride;
25
+ factory?: LaravelPathOverride;
26
+ provider?: LaravelPathOverride;
27
+ }
28
+ /** PHP codegen configuration (resolved with defaults). */
29
+ export interface PhpConfig {
30
+ models: {
31
+ namespace: string;
32
+ baseNamespace: string;
33
+ path: string;
34
+ basePath: string;
35
+ };
36
+ requests: {
37
+ namespace: string;
38
+ baseNamespace: string;
39
+ path: string;
40
+ basePath: string;
41
+ };
42
+ resources: {
43
+ namespace: string;
44
+ baseNamespace: string;
45
+ path: string;
46
+ basePath: string;
47
+ };
48
+ factories: {
49
+ namespace: string;
50
+ path: string;
51
+ };
52
+ providers: {
53
+ namespace: string;
54
+ path: string;
55
+ };
56
+ }
57
+ /**
58
+ * Derive full PHP config from optional overrides.
59
+ * All paths and namespaces fall back to sensible defaults.
60
+ */
61
+ export declare function derivePhpConfig(overrides?: LaravelCodegenOverrides): PhpConfig;
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Types for PHP code generation output.
3
+ */
4
+ /** Create a base file (always overwritten). */
5
+ export function baseFile(path, content) {
6
+ return { path, content, overwrite: true, type: 'base' };
7
+ }
8
+ /** Create a user file (created once, skip if exists). */
9
+ export function userFile(path, content) {
10
+ return { path, content, overwrite: false, type: 'user' };
11
+ }
12
+ /** Convert a file path to a PHP namespace (e.g., app/Models/Omnify → App\Models\Omnify). */
13
+ function pathToNamespace(p) {
14
+ return p
15
+ .split('/')
16
+ .map(s => s.charAt(0).toUpperCase() + s.slice(1))
17
+ .join('\\');
18
+ }
19
+ // Default paths
20
+ const DEFAULT_MODEL_PATH = 'app/Models/Omnify';
21
+ const DEFAULT_REQUEST_PATH = 'app/Http/Requests';
22
+ const DEFAULT_RESOURCE_PATH = 'app/Http/Resources';
23
+ const DEFAULT_FACTORY_PATH = 'database/factories';
24
+ const DEFAULT_PROVIDER_PATH = 'app/Providers';
25
+ /**
26
+ * Derive full PHP config from optional overrides.
27
+ * All paths and namespaces fall back to sensible defaults.
28
+ */
29
+ export function derivePhpConfig(overrides) {
30
+ const modelPath = overrides?.model?.path ?? DEFAULT_MODEL_PATH;
31
+ const modelNs = overrides?.model?.namespace ?? pathToNamespace(modelPath);
32
+ const requestPath = overrides?.request?.path ?? DEFAULT_REQUEST_PATH;
33
+ const requestNs = overrides?.request?.namespace ?? pathToNamespace(requestPath);
34
+ const resourcePath = overrides?.resource?.path ?? DEFAULT_RESOURCE_PATH;
35
+ const resourceNs = overrides?.resource?.namespace ?? pathToNamespace(resourcePath);
36
+ const factoryPath = overrides?.factory?.path ?? DEFAULT_FACTORY_PATH;
37
+ const factoryNs = overrides?.factory?.namespace ?? pathToNamespace(factoryPath);
38
+ const providerPath = overrides?.provider?.path ?? DEFAULT_PROVIDER_PATH;
39
+ const providerNs = overrides?.provider?.namespace ?? pathToNamespace(providerPath);
40
+ return {
41
+ models: {
42
+ namespace: modelNs,
43
+ baseNamespace: `${modelNs}\\Base`,
44
+ path: modelPath,
45
+ basePath: `${modelPath}/Base`,
46
+ },
47
+ requests: {
48
+ namespace: requestNs,
49
+ baseNamespace: `${requestNs}\\OmnifyBase`,
50
+ path: requestPath,
51
+ basePath: `${requestPath}/OmnifyBase`,
52
+ },
53
+ resources: {
54
+ namespace: resourceNs,
55
+ baseNamespace: `${resourceNs}\\OmnifyBase`,
56
+ path: resourcePath,
57
+ basePath: `${resourcePath}/OmnifyBase`,
58
+ },
59
+ factories: {
60
+ namespace: factoryNs,
61
+ path: factoryPath,
62
+ },
63
+ providers: {
64
+ namespace: providerNs,
65
+ path: providerPath,
66
+ },
67
+ };
68
+ }
@@ -0,0 +1,196 @@
1
+ /**
2
+ * @omnify/ts — Internal types
3
+ *
4
+ * Types for schemas.json input and TypeScript code generation output.
5
+ */
6
+ /** Localized string — either a plain string or a locale map. */
7
+ export type LocalizedString = string | Record<string, string>;
8
+ /** Top-level schemas.json structure. */
9
+ export interface SchemasJson {
10
+ readonly generatedAt: string;
11
+ readonly database: {
12
+ readonly driver: string;
13
+ };
14
+ readonly connections: Record<string, string>;
15
+ readonly locale: {
16
+ readonly locales: string[];
17
+ readonly defaultLocale: string;
18
+ readonly fallbackLocale: string;
19
+ };
20
+ readonly customTypes: {
21
+ readonly compound: Record<string, CompoundTypeDefinition>;
22
+ readonly simple: Record<string, SimpleTypeDefinition>;
23
+ readonly enums: Record<string, string[]>;
24
+ };
25
+ readonly schemas: Record<string, SchemaDefinition>;
26
+ }
27
+ /** Compound type definition (e.g., JapaneseName). */
28
+ export interface CompoundTypeDefinition {
29
+ readonly fields: readonly CompoundField[];
30
+ }
31
+ /** A field within a compound type. */
32
+ export interface CompoundField {
33
+ readonly suffix: string;
34
+ readonly mapsTo?: string;
35
+ readonly length?: number;
36
+ readonly nullable?: boolean;
37
+ readonly enumRef?: string;
38
+ }
39
+ /** Simple custom type (e.g., JapanesePhone). */
40
+ export interface SimpleTypeDefinition {
41
+ readonly mapsTo: string;
42
+ readonly length?: number;
43
+ }
44
+ /** Expanded property info (pre-computed by omnify-go). */
45
+ export interface ExpandedProperty {
46
+ readonly sourceType: string;
47
+ readonly columns: readonly ExpandedColumn[];
48
+ }
49
+ /** A single expanded column from a compound type. */
50
+ export interface ExpandedColumn {
51
+ readonly name: string;
52
+ readonly suffix: string;
53
+ readonly type: string;
54
+ readonly length?: number;
55
+ readonly nullable?: boolean;
56
+ readonly enum?: readonly string[];
57
+ }
58
+ /** Schema options. */
59
+ export interface SchemaOptions {
60
+ readonly id?: boolean;
61
+ readonly idType?: string;
62
+ readonly timestamps?: boolean;
63
+ readonly softDelete?: boolean;
64
+ readonly hidden?: boolean;
65
+ readonly tableName?: string;
66
+ readonly indexes?: readonly unknown[];
67
+ readonly unique?: readonly unknown[];
68
+ }
69
+ /** Schema definition from schemas.json. */
70
+ export interface SchemaDefinition {
71
+ readonly name: string;
72
+ readonly tableName?: string;
73
+ readonly connection?: string;
74
+ readonly displayName?: LocalizedString;
75
+ readonly group?: string;
76
+ readonly kind?: 'object' | 'enum' | 'pivot' | 'partial' | 'extend';
77
+ readonly options?: SchemaOptions;
78
+ readonly properties?: Record<string, PropertyDefinition>;
79
+ readonly propertyOrder?: readonly string[];
80
+ readonly expandedProperties?: Record<string, ExpandedProperty>;
81
+ readonly values?: readonly EnumValueDefinition[];
82
+ readonly pivotFor?: readonly string[];
83
+ }
84
+ /** Property definition within a schema. */
85
+ export interface PropertyDefinition {
86
+ readonly type: string;
87
+ readonly displayName?: LocalizedString;
88
+ readonly description?: LocalizedString;
89
+ readonly placeholder?: LocalizedString;
90
+ readonly nullable?: boolean;
91
+ readonly unique?: boolean;
92
+ readonly primary?: boolean;
93
+ readonly default?: unknown;
94
+ readonly length?: number;
95
+ readonly minLength?: number;
96
+ readonly maxLength?: number;
97
+ readonly min?: number;
98
+ readonly max?: number;
99
+ readonly unsigned?: boolean;
100
+ readonly precision?: number;
101
+ readonly scale?: number;
102
+ readonly pattern?: string;
103
+ readonly enum?: string | readonly string[];
104
+ readonly relation?: string;
105
+ readonly target?: string;
106
+ readonly targets?: readonly string[];
107
+ readonly onDelete?: string;
108
+ readonly morphName?: string;
109
+ readonly joinTable?: string;
110
+ readonly mappedBy?: string;
111
+ readonly useCurrent?: boolean;
112
+ readonly fields?: Record<string, FieldOverride>;
113
+ }
114
+ /** Field override for compound type properties. */
115
+ export interface FieldOverride {
116
+ readonly nullable?: boolean;
117
+ readonly length?: number;
118
+ readonly hidden?: boolean;
119
+ readonly displayName?: LocalizedString;
120
+ readonly placeholder?: LocalizedString;
121
+ }
122
+ /** Enum value definition (for schema enums). */
123
+ export interface EnumValueDefinition {
124
+ readonly value: string;
125
+ readonly label?: LocalizedString;
126
+ readonly extra?: Record<string, unknown>;
127
+ }
128
+ /** File category for organizing output. */
129
+ export type FileCategory = 'schema' | 'base' | 'enum' | 'plugin-enum';
130
+ /** Generated TypeScript file. */
131
+ export interface TypeScriptFile {
132
+ readonly filePath: string;
133
+ readonly content: string;
134
+ readonly types: readonly string[];
135
+ readonly overwrite: boolean;
136
+ readonly category?: FileCategory;
137
+ }
138
+ /** TypeScript property definition. */
139
+ export interface TSProperty {
140
+ readonly name: string;
141
+ readonly type: string;
142
+ readonly optional: boolean;
143
+ readonly readonly: boolean;
144
+ readonly comment?: string;
145
+ }
146
+ /** TypeScript interface definition. */
147
+ export interface TSInterface {
148
+ readonly name: string;
149
+ readonly properties: readonly TSProperty[];
150
+ readonly extends?: readonly string[];
151
+ readonly comment?: string;
152
+ readonly dependencies?: readonly string[];
153
+ readonly enumDependencies?: readonly string[];
154
+ }
155
+ /** TypeScript enum definition. */
156
+ export interface TSEnum {
157
+ readonly name: string;
158
+ readonly values: readonly TSEnumValue[];
159
+ readonly comment?: string;
160
+ }
161
+ /** Multi-locale string map. */
162
+ export type LocaleMap = Record<string, string>;
163
+ /** TypeScript enum value. */
164
+ export interface TSEnumValue {
165
+ readonly name: string;
166
+ readonly value: string | number;
167
+ readonly label?: string | LocaleMap;
168
+ readonly extra?: Record<string, unknown>;
169
+ }
170
+ /** TypeScript type alias definition. */
171
+ export interface TSTypeAlias {
172
+ readonly name: string;
173
+ readonly type: string;
174
+ readonly comment?: string;
175
+ }
176
+ /** Zod schema information for a property. */
177
+ export interface ZodPropertySchema {
178
+ readonly fieldName: string;
179
+ readonly schema: string;
180
+ readonly inCreate: boolean;
181
+ readonly inUpdate: boolean;
182
+ readonly comment?: string;
183
+ }
184
+ /** Display names for a schema. */
185
+ export interface SchemaDisplayNames {
186
+ readonly displayName: LocaleMap;
187
+ readonly propertyDisplayNames: Record<string, LocaleMap>;
188
+ readonly propertyPlaceholders: Record<string, LocaleMap>;
189
+ }
190
+ /** Generation options (internal). */
191
+ export interface GeneratorOptions {
192
+ readonly locales: string[];
193
+ readonly defaultLocale: string;
194
+ readonly fallbackLocale: string;
195
+ readonly customTypes: SchemasJson['customTypes'];
196
+ }
package/dist/types.js ADDED
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @omnify/ts — Internal types
3
+ *
4
+ * Types for schemas.json input and TypeScript code generation output.
5
+ */
6
+ export {};