@famgia/omnify-types 0.0.4 → 0.0.5

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @famgia/omnify-types
2
2
 
3
- Shared TypeScript types for the Omnify schema system.
3
+ Shared TypeScript type definitions for the Omnify schema system.
4
4
 
5
5
  ## Installation
6
6
 
@@ -12,22 +12,217 @@ npm install @famgia/omnify-types
12
12
 
13
13
  ```typescript
14
14
  import type {
15
+ // Schema types
15
16
  SchemaDefinition,
16
17
  LoadedSchema,
18
+ SchemaCollection,
17
19
  PropertyDefinition,
18
20
  AssociationDefinition,
19
- OmnifyPlugin
21
+
22
+ // Plugin types
23
+ OmnifyPlugin,
24
+ PluginContext,
25
+ PluginLogger,
26
+ CustomTypeDefinition,
27
+
28
+ // Generator types
29
+ GeneratorDefinition,
30
+ GeneratorContext,
31
+ GeneratorOutput,
32
+ GeneratorOutputType,
33
+
34
+ // Config types
35
+ OmnifyConfig,
36
+ ResolvedOmnifyConfig,
20
37
  } from '@famgia/omnify-types';
21
38
  ```
22
39
 
23
- ## Types
40
+ ## Type Reference
41
+
42
+ ### Schema Types
43
+
44
+ #### `SchemaDefinition`
45
+ Raw schema definition as loaded from YAML/JSON.
46
+
47
+ ```typescript
48
+ interface SchemaDefinition {
49
+ name: string;
50
+ kind: 'object' | 'enum';
51
+ displayName?: string;
52
+ properties?: Record<string, PropertyDefinition>;
53
+ associations?: Record<string, AssociationDefinition>;
54
+ options?: SchemaOptions;
55
+ values?: string[]; // For enums
56
+ }
57
+ ```
58
+
59
+ #### `LoadedSchema`
60
+ Parsed and validated schema with file path.
61
+
62
+ ```typescript
63
+ interface LoadedSchema extends SchemaDefinition {
64
+ filePath: string;
65
+ }
66
+ ```
67
+
68
+ #### `SchemaCollection`
69
+ Map of schema name to loaded schema.
70
+
71
+ ```typescript
72
+ type SchemaCollection = Record<string, LoadedSchema>;
73
+ ```
74
+
75
+ #### `PropertyDefinition`
76
+ Field/property definition.
77
+
78
+ ```typescript
79
+ interface PropertyDefinition {
80
+ type: string;
81
+ nullable?: boolean;
82
+ unique?: boolean;
83
+ default?: unknown;
84
+ displayName?: string;
85
+ }
86
+ ```
87
+
88
+ #### `AssociationDefinition`
89
+ Relationship definition.
90
+
91
+ ```typescript
92
+ interface AssociationDefinition {
93
+ type: 'belongsTo' | 'hasMany' | 'hasOne' | 'belongsToMany';
94
+ model: string;
95
+ foreignKey?: string;
96
+ pivotTable?: string;
97
+ }
98
+ ```
99
+
100
+ ### Plugin Types
101
+
102
+ #### `OmnifyPlugin`
103
+ Plugin interface for extending Omnify.
104
+
105
+ ```typescript
106
+ interface OmnifyPlugin {
107
+ name: string;
108
+ version: string;
109
+
110
+ // Lifecycle hooks
111
+ setup?: (context: PluginContext) => Promise<void>;
112
+ teardown?: () => Promise<void>;
113
+
114
+ // Custom types
115
+ types?: CustomTypeDefinition[];
116
+
117
+ // Generators
118
+ generators?: GeneratorDefinition[];
119
+ }
120
+ ```
24
121
 
25
- - `SchemaDefinition` - Raw schema definition from YAML/JSON
26
- - `LoadedSchema` - Parsed and validated schema
27
- - `PropertyDefinition` - Field/property definition
28
- - `AssociationDefinition` - Relationship definition
29
- - `OmnifyPlugin` - Plugin interface
30
- - `OmnifyConfig` - Configuration options
122
+ #### `CustomTypeDefinition`
123
+ Custom type for extending schema types.
124
+
125
+ ```typescript
126
+ interface CustomTypeDefinition {
127
+ name: string;
128
+ typescript: string;
129
+ laravel: string;
130
+ laravelParams?: unknown[];
131
+ }
132
+ ```
133
+
134
+ ### Generator Types
135
+
136
+ #### `GeneratorDefinition`
137
+ Generator definition for creating output files.
138
+
139
+ ```typescript
140
+ interface GeneratorDefinition {
141
+ name: string;
142
+ description?: string;
143
+ dependsOn?: string[];
144
+ generate: (ctx: GeneratorContext) => Promise<GeneratorOutput[]>;
145
+ }
146
+ ```
147
+
148
+ #### `GeneratorContext`
149
+ Context passed to generator functions.
150
+
151
+ ```typescript
152
+ interface GeneratorContext {
153
+ schemas: SchemaCollection;
154
+ pluginConfig: Record<string, unknown>;
155
+ cwd: string;
156
+ logger: PluginLogger;
157
+ previousOutputs: ReadonlyMap<string, readonly GeneratorOutput[]>;
158
+ }
159
+ ```
160
+
161
+ #### `GeneratorOutput`
162
+ Output file from a generator.
163
+
164
+ ```typescript
165
+ interface GeneratorOutput {
166
+ path: string;
167
+ content: string;
168
+ type: GeneratorOutputType;
169
+ metadata?: Record<string, unknown>;
170
+ }
171
+
172
+ type GeneratorOutputType = 'migration' | 'type' | 'model' | 'schema' | 'other';
173
+ ```
174
+
175
+ ### Config Types
176
+
177
+ #### `OmnifyConfig`
178
+ Configuration options.
179
+
180
+ ```typescript
181
+ interface OmnifyConfig {
182
+ schemasDir: string;
183
+ lockFilePath?: string;
184
+ database?: DatabaseConfig;
185
+ output?: OutputConfig;
186
+ plugins?: OmnifyPlugin[];
187
+ }
188
+ ```
189
+
190
+ ## Creating a Plugin
191
+
192
+ ```typescript
193
+ import type { OmnifyPlugin } from '@famgia/omnify-types';
194
+
195
+ const myPlugin: OmnifyPlugin = {
196
+ name: 'my-plugin',
197
+ version: '1.0.0',
198
+
199
+ types: [
200
+ {
201
+ name: 'Money',
202
+ typescript: 'number',
203
+ laravel: 'decimal',
204
+ laravelParams: [10, 2],
205
+ },
206
+ ],
207
+
208
+ generators: [
209
+ {
210
+ name: 'my-generator',
211
+ dependsOn: ['other-generator'],
212
+
213
+ generate: async (ctx) => {
214
+ return [{
215
+ path: 'output/file.ts',
216
+ content: '// Generated',
217
+ type: 'other',
218
+ }];
219
+ },
220
+ },
221
+ ],
222
+ };
223
+
224
+ export default myPlugin;
225
+ ```
31
226
 
32
227
  ## Related Packages
33
228
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/errors.ts"],"sourcesContent":["/**\n * @famgia/omnify-types\n * Core type definitions for omnify-schema\n *\n * This package provides shared TypeScript interfaces and types\n * used across all omnify packages.\n */\n\n// ============================================================================\n// Schema Types\n// ============================================================================\n\nexport type {\n // Property types\n BuiltInPropertyType,\n PropertyType,\n // Association types\n AssociationRelation,\n ReferentialAction,\n AssociationDefinition,\n // Property definitions\n BasePropertyDefinition,\n StringPropertyDefinition,\n NumericPropertyDefinition,\n EnumPropertyDefinition,\n SelectPropertyDefinition,\n PropertyDefinition,\n // Schema options\n IndexDefinition,\n SchemaOptions,\n // Schema definitions\n SchemaKind,\n SchemaDefinition,\n LoadedSchema,\n SchemaCollection,\n} from './schema.js';\n\n// ============================================================================\n// Configuration Types\n// ============================================================================\n\nexport type {\n // Database config\n DatabaseDriver,\n DatabaseConfig,\n // Output config\n LaravelOutputConfig,\n TypeScriptOutputConfig,\n OutputConfig,\n // Main config\n OmnifyConfig,\n ResolvedOmnifyConfig,\n} from './config.js';\n\n// ============================================================================\n// Plugin Types\n// ============================================================================\n\nexport type {\n // Type definitions\n SqlColumnDefinition,\n TypeScriptTypeInfo,\n ExpandedFieldDefinition,\n CustomTypeDefinition,\n // Plugin interface\n PluginContext,\n PluginLogger,\n OmnifyPlugin,\n PluginFactory,\n} from './plugin.js';\n\n// ============================================================================\n// Error Types\n// ============================================================================\n\nexport type {\n ErrorCode,\n ErrorLocation,\n OmnifyErrorInfo,\n Result,\n} from './errors.js';\n\nexport { ok, err } from './errors.js';\n","/**\n * @famgia/omnify-types - Error Types\n *\n * Type definitions for omnify error handling.\n * Errors follow the format: file:line + message + suggestion\n */\n\n// ============================================================================\n// Error Codes\n// ============================================================================\n\n/**\n * Error code categories:\n * - E0xx: Configuration errors\n * - E1xx: Schema parsing errors\n * - E2xx: Schema validation errors\n * - E3xx: Plugin errors\n * - E4xx: Atlas/Database errors\n * - E5xx: Generation errors\n * - E9xx: Internal errors\n */\nexport type ErrorCode =\n // Configuration errors (E0xx)\n | 'E001' // Config file not found\n | 'E002' // Invalid config format\n | 'E003' // Missing required config field\n | 'E004' // Invalid database driver\n | 'E005' // Invalid output path\n // Schema parsing errors (E1xx)\n | 'E101' // Schema file not found\n | 'E102' // Invalid YAML syntax\n | 'E103' // Invalid JSON syntax\n | 'E104' // Empty schema file\n | 'E105' // Schema read error\n // Schema validation errors (E2xx)\n | 'E201' // Invalid property type\n | 'E202' // Missing required field\n | 'E203' // Invalid association target\n | 'E204' // Circular reference detected\n | 'E205' // Duplicate schema name\n | 'E206' // Invalid schema options\n | 'E207' // Invalid enum values\n | 'E208' // Orphaned inverse relation\n // Plugin errors (E3xx)\n | 'E301' // Plugin not found\n | 'E302' // Plugin load error\n | 'E303' // Invalid plugin format\n | 'E304' // Plugin type conflict\n | 'E305' // Plugin setup error\n // Atlas/Database errors (E4xx)\n | 'E401' // Atlas CLI not found\n | 'E402' // Atlas diff failed\n | 'E403' // Database connection error\n | 'E404' // HCL generation error\n | 'E405' // Lock file error\n // Generation errors (E5xx)\n | 'E501' // Migration generation failed\n | 'E502' // TypeScript generation failed\n | 'E503' // Output write error\n | 'E504' // Template error\n // Internal errors (E9xx)\n | 'E901' // Unexpected error\n | 'E902'; // Not implemented\n\n// ============================================================================\n// Error Info\n// ============================================================================\n\n/**\n * Source location where an error occurred.\n */\nexport interface ErrorLocation {\n /** File path where the error occurred */\n readonly file?: string;\n /** Line number (1-based) */\n readonly line?: number;\n /** Column number (1-based) */\n readonly column?: number;\n}\n\n/**\n * Structured error information for omnify errors.\n */\nexport interface OmnifyErrorInfo {\n /** Error code (e.g., 'E201') */\n readonly code: ErrorCode;\n /** Human-readable error message */\n readonly message: string;\n /** Location where the error occurred */\n readonly location?: ErrorLocation;\n /** Suggested fix for the error */\n readonly suggestion?: string;\n /** Additional context or details */\n readonly details?: Record<string, unknown>;\n /** Original error if this wraps another error */\n readonly cause?: Error;\n}\n\n/**\n * Result type for operations that may fail.\n */\nexport type Result<T, E = OmnifyErrorInfo> =\n | { readonly ok: true; readonly value: T }\n | { readonly ok: false; readonly error: E };\n\n/**\n * Helper to create a successful result.\n */\nexport function ok<T>(value: T): Result<T, never> {\n return { ok: true, value };\n}\n\n/**\n * Helper to create an error result.\n */\nexport function err<E>(error: E): Result<never, E> {\n return { ok: false, error };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;AC4GO,SAAS,GAAM,OAA4B;AAChD,SAAO,EAAE,IAAI,MAAM,MAAM;AAC3B;AAKO,SAAS,IAAO,OAA4B;AACjD,SAAO,EAAE,IAAI,OAAO,MAAM;AAC5B;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts","../src/errors.ts"],"sourcesContent":["/**\n * @famgia/omnify-types\n * Core type definitions for omnify-schema\n *\n * This package provides shared TypeScript interfaces and types\n * used across all omnify packages.\n */\n\n// ============================================================================\n// Schema Types\n// ============================================================================\n\nexport type {\n // Property types\n BuiltInPropertyType,\n PropertyType,\n // Association types\n AssociationRelation,\n ReferentialAction,\n AssociationDefinition,\n // Property definitions\n BasePropertyDefinition,\n StringPropertyDefinition,\n NumericPropertyDefinition,\n EnumPropertyDefinition,\n SelectPropertyDefinition,\n PropertyDefinition,\n // Schema options\n IndexDefinition,\n SchemaOptions,\n // Schema definitions\n SchemaKind,\n SchemaDefinition,\n LoadedSchema,\n SchemaCollection,\n} from './schema.js';\n\n// ============================================================================\n// Configuration Types\n// ============================================================================\n\nexport type {\n // Database config\n DatabaseDriver,\n DatabaseConfig,\n // Output config\n LaravelOutputConfig,\n TypeScriptOutputConfig,\n OutputConfig,\n // Main config\n OmnifyConfig,\n ResolvedOmnifyConfig,\n} from './config.js';\n\n// ============================================================================\n// Plugin Types\n// ============================================================================\n\nexport type {\n // Type definitions\n SqlColumnDefinition,\n TypeScriptTypeInfo,\n ExpandedFieldDefinition,\n CustomTypeDefinition,\n // Plugin interface\n PluginContext,\n PluginLogger,\n OmnifyPlugin,\n PluginFactory,\n // Generator types\n GeneratorOutputType,\n GeneratorOutput,\n GeneratorContext,\n GeneratorDefinition,\n} from './plugin.js';\n\n// ============================================================================\n// Error Types\n// ============================================================================\n\nexport type {\n ErrorCode,\n ErrorLocation,\n OmnifyErrorInfo,\n Result,\n} from './errors.js';\n\nexport { ok, err } from './errors.js';\n","/**\n * @famgia/omnify-types - Error Types\n *\n * Type definitions for omnify error handling.\n * Errors follow the format: file:line + message + suggestion\n */\n\n// ============================================================================\n// Error Codes\n// ============================================================================\n\n/**\n * Error code categories:\n * - E0xx: Configuration errors\n * - E1xx: Schema parsing errors\n * - E2xx: Schema validation errors\n * - E3xx: Plugin errors\n * - E4xx: Atlas/Database errors\n * - E5xx: Generation errors\n * - E9xx: Internal errors\n */\nexport type ErrorCode =\n // Configuration errors (E0xx)\n | 'E001' // Config file not found\n | 'E002' // Invalid config format\n | 'E003' // Missing required config field\n | 'E004' // Invalid database driver\n | 'E005' // Invalid output path\n // Schema parsing errors (E1xx)\n | 'E101' // Schema file not found\n | 'E102' // Invalid YAML syntax\n | 'E103' // Invalid JSON syntax\n | 'E104' // Empty schema file\n | 'E105' // Schema read error\n // Schema validation errors (E2xx)\n | 'E201' // Invalid property type\n | 'E202' // Missing required field\n | 'E203' // Invalid association target\n | 'E204' // Circular reference detected\n | 'E205' // Duplicate schema name\n | 'E206' // Invalid schema options\n | 'E207' // Invalid enum values\n | 'E208' // Orphaned inverse relation\n // Plugin errors (E3xx)\n | 'E301' // Plugin not found\n | 'E302' // Plugin load error\n | 'E303' // Invalid plugin format\n | 'E304' // Plugin type conflict\n | 'E305' // Plugin setup error\n // Atlas/Database errors (E4xx)\n | 'E401' // Atlas CLI not found\n | 'E402' // Atlas diff failed\n | 'E403' // Database connection error\n | 'E404' // HCL generation error\n | 'E405' // Lock file error\n // Generation errors (E5xx)\n | 'E501' // Migration generation failed\n | 'E502' // TypeScript generation failed\n | 'E503' // Output write error\n | 'E504' // Template error\n // Internal errors (E9xx)\n | 'E901' // Unexpected error\n | 'E902'; // Not implemented\n\n// ============================================================================\n// Error Info\n// ============================================================================\n\n/**\n * Source location where an error occurred.\n */\nexport interface ErrorLocation {\n /** File path where the error occurred */\n readonly file?: string;\n /** Line number (1-based) */\n readonly line?: number;\n /** Column number (1-based) */\n readonly column?: number;\n}\n\n/**\n * Structured error information for omnify errors.\n */\nexport interface OmnifyErrorInfo {\n /** Error code (e.g., 'E201') */\n readonly code: ErrorCode;\n /** Human-readable error message */\n readonly message: string;\n /** Location where the error occurred */\n readonly location?: ErrorLocation;\n /** Suggested fix for the error */\n readonly suggestion?: string;\n /** Additional context or details */\n readonly details?: Record<string, unknown>;\n /** Original error if this wraps another error */\n readonly cause?: Error;\n}\n\n/**\n * Result type for operations that may fail.\n */\nexport type Result<T, E = OmnifyErrorInfo> =\n | { readonly ok: true; readonly value: T }\n | { readonly ok: false; readonly error: E };\n\n/**\n * Helper to create a successful result.\n */\nexport function ok<T>(value: T): Result<T, never> {\n return { ok: true, value };\n}\n\n/**\n * Helper to create an error result.\n */\nexport function err<E>(error: E): Result<never, E> {\n return { ok: false, error };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;AC4GO,SAAS,GAAM,OAA4B;AAChD,SAAO,EAAE,IAAI,MAAM,MAAM;AAC3B;AAKO,SAAS,IAAO,OAA4B;AACjD,SAAO,EAAE,IAAI,OAAO,MAAM;AAC5B;","names":[]}
package/dist/index.d.cts CHANGED
@@ -327,6 +327,11 @@ interface OmnifyPlugin {
327
327
  * Custom type definitions provided by this plugin.
328
328
  */
329
329
  readonly types?: readonly CustomTypeDefinition[];
330
+ /**
331
+ * Generator definitions provided by this plugin.
332
+ * Generators produce output files (migrations, types, models, etc.)
333
+ */
334
+ readonly generators?: readonly GeneratorDefinition[];
330
335
  /**
331
336
  * Optional setup function called when plugin is loaded.
332
337
  * @param context - Plugin context with utilities
@@ -342,6 +347,75 @@ interface OmnifyPlugin {
342
347
  * Useful for plugins that need configuration.
343
348
  */
344
349
  type PluginFactory<TOptions = unknown> = (options?: TOptions) => OmnifyPlugin;
350
+ /**
351
+ * Output type for generated files.
352
+ */
353
+ type GeneratorOutputType = 'migration' | 'type' | 'model' | 'schema' | 'other';
354
+ /**
355
+ * Output from a generator - represents a file to be written.
356
+ */
357
+ interface GeneratorOutput {
358
+ /** Relative path where the file should be written */
359
+ readonly path: string;
360
+ /** Content of the file */
361
+ readonly content: string;
362
+ /** Type of output for categorization */
363
+ readonly type: GeneratorOutputType;
364
+ /** Optional metadata */
365
+ readonly metadata?: Record<string, unknown>;
366
+ }
367
+ /**
368
+ * Context provided to generators during execution.
369
+ */
370
+ interface GeneratorContext {
371
+ /** Loaded and validated schema collection */
372
+ readonly schemas: SchemaCollection;
373
+ /** Plugin-specific configuration (passed to plugin factory) */
374
+ readonly pluginConfig: Record<string, unknown>;
375
+ /** Current working directory */
376
+ readonly cwd: string;
377
+ /** Logger for output */
378
+ readonly logger: PluginLogger;
379
+ /** Outputs from previously run generators (for dependencies) */
380
+ readonly previousOutputs: ReadonlyMap<string, readonly GeneratorOutput[]>;
381
+ }
382
+ /**
383
+ * Definition of a generator provided by a plugin.
384
+ *
385
+ * @example
386
+ * ```typescript
387
+ * const migrationGenerator: GeneratorDefinition = {
388
+ * name: 'laravel-migrations',
389
+ * description: 'Generate Laravel migration files',
390
+ * generate: async (ctx) => {
391
+ * const migrations = generateMigrations(ctx.schemas);
392
+ * return migrations.map(m => ({
393
+ * path: `database/migrations/${m.fileName}`,
394
+ * content: m.content,
395
+ * type: 'migration',
396
+ * }));
397
+ * },
398
+ * };
399
+ * ```
400
+ */
401
+ interface GeneratorDefinition {
402
+ /** Unique generator name (e.g., 'laravel-migrations') */
403
+ readonly name: string;
404
+ /** Human-readable description */
405
+ readonly description?: string;
406
+ /**
407
+ * Dependencies on other generators.
408
+ * This generator will run after all dependencies have completed.
409
+ * Used for topological sorting (DAG).
410
+ */
411
+ readonly dependsOn?: readonly string[];
412
+ /**
413
+ * Generator function.
414
+ * @param ctx - Generator context with schemas and configuration
415
+ * @returns Array of files to generate
416
+ */
417
+ readonly generate: (ctx: GeneratorContext) => GeneratorOutput[] | Promise<GeneratorOutput[]>;
418
+ }
345
419
 
346
420
  /**
347
421
  * @famgia/omnify-types - Configuration Types
@@ -508,4 +582,4 @@ declare function ok<T>(value: T): Result<T, never>;
508
582
  */
509
583
  declare function err<E>(error: E): Result<never, E>;
510
584
 
511
- export { type AssociationDefinition, type AssociationRelation, type BasePropertyDefinition, type BuiltInPropertyType, type CustomTypeDefinition, type DatabaseConfig, type DatabaseDriver, type EnumPropertyDefinition, type ErrorCode, type ErrorLocation, type ExpandedFieldDefinition, type IndexDefinition, type LaravelOutputConfig, type LoadedSchema, type NumericPropertyDefinition, type OmnifyConfig, type OmnifyErrorInfo, type OmnifyPlugin, type OutputConfig, type PluginContext, type PluginFactory, type PluginLogger, type PropertyDefinition, type PropertyType, type ReferentialAction, type ResolvedOmnifyConfig, type Result, type SchemaCollection, type SchemaDefinition, type SchemaKind, type SchemaOptions, type SelectPropertyDefinition, type SqlColumnDefinition, type StringPropertyDefinition, type TypeScriptOutputConfig, type TypeScriptTypeInfo, err, ok };
585
+ export { type AssociationDefinition, type AssociationRelation, type BasePropertyDefinition, type BuiltInPropertyType, type CustomTypeDefinition, type DatabaseConfig, type DatabaseDriver, type EnumPropertyDefinition, type ErrorCode, type ErrorLocation, type ExpandedFieldDefinition, type GeneratorContext, type GeneratorDefinition, type GeneratorOutput, type GeneratorOutputType, type IndexDefinition, type LaravelOutputConfig, type LoadedSchema, type NumericPropertyDefinition, type OmnifyConfig, type OmnifyErrorInfo, type OmnifyPlugin, type OutputConfig, type PluginContext, type PluginFactory, type PluginLogger, type PropertyDefinition, type PropertyType, type ReferentialAction, type ResolvedOmnifyConfig, type Result, type SchemaCollection, type SchemaDefinition, type SchemaKind, type SchemaOptions, type SelectPropertyDefinition, type SqlColumnDefinition, type StringPropertyDefinition, type TypeScriptOutputConfig, type TypeScriptTypeInfo, err, ok };
package/dist/index.d.ts CHANGED
@@ -327,6 +327,11 @@ interface OmnifyPlugin {
327
327
  * Custom type definitions provided by this plugin.
328
328
  */
329
329
  readonly types?: readonly CustomTypeDefinition[];
330
+ /**
331
+ * Generator definitions provided by this plugin.
332
+ * Generators produce output files (migrations, types, models, etc.)
333
+ */
334
+ readonly generators?: readonly GeneratorDefinition[];
330
335
  /**
331
336
  * Optional setup function called when plugin is loaded.
332
337
  * @param context - Plugin context with utilities
@@ -342,6 +347,75 @@ interface OmnifyPlugin {
342
347
  * Useful for plugins that need configuration.
343
348
  */
344
349
  type PluginFactory<TOptions = unknown> = (options?: TOptions) => OmnifyPlugin;
350
+ /**
351
+ * Output type for generated files.
352
+ */
353
+ type GeneratorOutputType = 'migration' | 'type' | 'model' | 'schema' | 'other';
354
+ /**
355
+ * Output from a generator - represents a file to be written.
356
+ */
357
+ interface GeneratorOutput {
358
+ /** Relative path where the file should be written */
359
+ readonly path: string;
360
+ /** Content of the file */
361
+ readonly content: string;
362
+ /** Type of output for categorization */
363
+ readonly type: GeneratorOutputType;
364
+ /** Optional metadata */
365
+ readonly metadata?: Record<string, unknown>;
366
+ }
367
+ /**
368
+ * Context provided to generators during execution.
369
+ */
370
+ interface GeneratorContext {
371
+ /** Loaded and validated schema collection */
372
+ readonly schemas: SchemaCollection;
373
+ /** Plugin-specific configuration (passed to plugin factory) */
374
+ readonly pluginConfig: Record<string, unknown>;
375
+ /** Current working directory */
376
+ readonly cwd: string;
377
+ /** Logger for output */
378
+ readonly logger: PluginLogger;
379
+ /** Outputs from previously run generators (for dependencies) */
380
+ readonly previousOutputs: ReadonlyMap<string, readonly GeneratorOutput[]>;
381
+ }
382
+ /**
383
+ * Definition of a generator provided by a plugin.
384
+ *
385
+ * @example
386
+ * ```typescript
387
+ * const migrationGenerator: GeneratorDefinition = {
388
+ * name: 'laravel-migrations',
389
+ * description: 'Generate Laravel migration files',
390
+ * generate: async (ctx) => {
391
+ * const migrations = generateMigrations(ctx.schemas);
392
+ * return migrations.map(m => ({
393
+ * path: `database/migrations/${m.fileName}`,
394
+ * content: m.content,
395
+ * type: 'migration',
396
+ * }));
397
+ * },
398
+ * };
399
+ * ```
400
+ */
401
+ interface GeneratorDefinition {
402
+ /** Unique generator name (e.g., 'laravel-migrations') */
403
+ readonly name: string;
404
+ /** Human-readable description */
405
+ readonly description?: string;
406
+ /**
407
+ * Dependencies on other generators.
408
+ * This generator will run after all dependencies have completed.
409
+ * Used for topological sorting (DAG).
410
+ */
411
+ readonly dependsOn?: readonly string[];
412
+ /**
413
+ * Generator function.
414
+ * @param ctx - Generator context with schemas and configuration
415
+ * @returns Array of files to generate
416
+ */
417
+ readonly generate: (ctx: GeneratorContext) => GeneratorOutput[] | Promise<GeneratorOutput[]>;
418
+ }
345
419
 
346
420
  /**
347
421
  * @famgia/omnify-types - Configuration Types
@@ -508,4 +582,4 @@ declare function ok<T>(value: T): Result<T, never>;
508
582
  */
509
583
  declare function err<E>(error: E): Result<never, E>;
510
584
 
511
- export { type AssociationDefinition, type AssociationRelation, type BasePropertyDefinition, type BuiltInPropertyType, type CustomTypeDefinition, type DatabaseConfig, type DatabaseDriver, type EnumPropertyDefinition, type ErrorCode, type ErrorLocation, type ExpandedFieldDefinition, type IndexDefinition, type LaravelOutputConfig, type LoadedSchema, type NumericPropertyDefinition, type OmnifyConfig, type OmnifyErrorInfo, type OmnifyPlugin, type OutputConfig, type PluginContext, type PluginFactory, type PluginLogger, type PropertyDefinition, type PropertyType, type ReferentialAction, type ResolvedOmnifyConfig, type Result, type SchemaCollection, type SchemaDefinition, type SchemaKind, type SchemaOptions, type SelectPropertyDefinition, type SqlColumnDefinition, type StringPropertyDefinition, type TypeScriptOutputConfig, type TypeScriptTypeInfo, err, ok };
585
+ export { type AssociationDefinition, type AssociationRelation, type BasePropertyDefinition, type BuiltInPropertyType, type CustomTypeDefinition, type DatabaseConfig, type DatabaseDriver, type EnumPropertyDefinition, type ErrorCode, type ErrorLocation, type ExpandedFieldDefinition, type GeneratorContext, type GeneratorDefinition, type GeneratorOutput, type GeneratorOutputType, type IndexDefinition, type LaravelOutputConfig, type LoadedSchema, type NumericPropertyDefinition, type OmnifyConfig, type OmnifyErrorInfo, type OmnifyPlugin, type OutputConfig, type PluginContext, type PluginFactory, type PluginLogger, type PropertyDefinition, type PropertyType, type ReferentialAction, type ResolvedOmnifyConfig, type Result, type SchemaCollection, type SchemaDefinition, type SchemaKind, type SchemaOptions, type SelectPropertyDefinition, type SqlColumnDefinition, type StringPropertyDefinition, type TypeScriptOutputConfig, type TypeScriptTypeInfo, err, ok };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@famgia/omnify-types",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "description": "Shared TypeScript types for omnify-schema",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",