@famgia/omnify-types 0.0.6 → 0.0.8

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
@@ -224,12 +224,70 @@ const myPlugin: OmnifyPlugin = {
224
224
  export default myPlugin;
225
225
  ```
226
226
 
227
+ ## Built-in Property Types
228
+
229
+ ```typescript
230
+ type BuiltInPropertyType =
231
+ // Primitive types
232
+ | 'String' // VARCHAR(255) / TEXT
233
+ | 'Int' // INT / INTEGER
234
+ | 'BigInt' // BIGINT / INTEGER
235
+ | 'Float' // DOUBLE / REAL
236
+ | 'Decimal' // DECIMAL(p,s)
237
+ | 'Boolean' // TINYINT(1) / BOOLEAN / INTEGER
238
+
239
+ // Text types
240
+ | 'Text' // TEXT
241
+ | 'LongText' // LONGTEXT / TEXT
242
+
243
+ // Date/Time types
244
+ | 'Date' // DATE
245
+ | 'Time' // TIME
246
+ | 'Timestamp' // TIMESTAMP
247
+
248
+ // Special types
249
+ | 'Json' // JSON / JSONB / TEXT
250
+ | 'Email' // VARCHAR(255)
251
+ | 'Password' // VARCHAR(255)
252
+
253
+ // File types
254
+ | 'File' // VARCHAR(255)
255
+ | 'MultiFile' // JSON
256
+
257
+ // Spatial/Geographic types
258
+ | 'Point' // POINT / geometry(Point, 4326) - native spatial
259
+ | 'Coordinates' // Two DECIMAL columns (latitude, longitude) - cross-DB
260
+
261
+ // Enum type
262
+ | 'Enum' // ENUM / CREATE TYPE / TEXT
263
+
264
+ // Selection types
265
+ | 'Select' // VARCHAR(255)
266
+ | 'Lookup' // BIGINT (FK reference)
267
+
268
+ // Relationship
269
+ | 'Association' // Foreign key / pivot table
270
+ ```
271
+
272
+ ## Index Types
273
+
274
+ ```typescript
275
+ type IndexType =
276
+ | 'btree' // Default B-tree index (all dialects)
277
+ | 'hash' // Hash index (MySQL, PostgreSQL)
278
+ | 'fulltext' // Full-text search (MySQL, PostgreSQL)
279
+ | 'spatial' // Spatial index (MySQL, PostgreSQL)
280
+ | 'gin' // GIN index (PostgreSQL only)
281
+ | 'gist' // GiST index (PostgreSQL only)
282
+ ```
283
+
227
284
  ## Related Packages
228
285
 
229
286
  - [@famgia/omnify-core](https://www.npmjs.com/package/@famgia/omnify-core) - Core engine
230
287
  - [@famgia/omnify-cli](https://www.npmjs.com/package/@famgia/omnify-cli) - CLI tool
231
288
  - [@famgia/omnify-laravel](https://www.npmjs.com/package/@famgia/omnify-laravel) - Laravel generator
232
289
  - [@famgia/omnify-atlas](https://www.npmjs.com/package/@famgia/omnify-atlas) - Atlas adapter
290
+ - [@famgia/omnify-sql](https://www.npmjs.com/package/@famgia/omnify-sql) - Raw SQL generator
233
291
 
234
292
  ## License
235
293
 
@@ -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 // 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":[]}
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 IdType,\n IndexType,\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
@@ -7,7 +7,7 @@
7
7
  * Built-in property types supported by omnify-schema.
8
8
  * Custom types can be added via plugins.
9
9
  */
10
- type BuiltInPropertyType = 'String' | 'Int' | 'BigInt' | 'Float' | 'Boolean' | 'Text' | 'LongText' | 'Date' | 'Time' | 'Timestamp' | 'Json' | 'Email' | 'Password' | 'File' | 'MultiFile' | 'Enum' | 'Select' | 'Lookup' | 'Association' | 'Polymorphic';
10
+ type BuiltInPropertyType = 'String' | 'Int' | 'BigInt' | 'Float' | 'Decimal' | 'Boolean' | 'Text' | 'LongText' | 'Date' | 'Time' | 'Timestamp' | 'Json' | 'Email' | 'Password' | 'File' | 'MultiFile' | 'Point' | 'Coordinates' | 'Enum' | 'Select' | 'Lookup' | 'Association';
11
11
  /**
12
12
  * Property type - can be a built-in type or a custom plugin type (string).
13
13
  */
@@ -15,7 +15,7 @@ type PropertyType = BuiltInPropertyType | (string & {});
15
15
  /**
16
16
  * Relationship cardinality types for associations.
17
17
  */
18
- type AssociationRelation = 'OneToOne' | 'OneToMany' | 'ManyToOne' | 'ManyToMany';
18
+ type AssociationRelation = 'OneToOne' | 'OneToMany' | 'ManyToOne' | 'ManyToMany' | 'MorphTo' | 'MorphOne' | 'MorphMany' | 'MorphToMany' | 'MorphedByMany';
19
19
  /**
20
20
  * Referential action for foreign key constraints.
21
21
  */
@@ -30,8 +30,12 @@ interface AssociationDefinition {
30
30
  readonly type: 'Association';
31
31
  /** Relationship cardinality */
32
32
  readonly relation: AssociationRelation;
33
- /** Target schema name (e.g., 'User', 'Product') */
34
- readonly target: string;
33
+ /** Target schema name (e.g., 'User', 'Product') - for standard relations */
34
+ readonly target?: string;
35
+ /** Target schema names for polymorphic relations (MorphTo) */
36
+ readonly targets?: readonly string[];
37
+ /** Polymorphic name for inverse side (MorphOne, MorphMany, MorphedByMany) */
38
+ readonly morphName?: string;
35
39
  /** Property name on the target schema that maps back (for bidirectional) */
36
40
  readonly inversedBy?: string;
37
41
  /** Property name on this schema that is mapped by target (for bidirectional) */
@@ -42,7 +46,7 @@ interface AssociationDefinition {
42
46
  readonly onUpdate?: ReferentialAction;
43
47
  /** Whether this side owns the relationship (has the foreign key) */
44
48
  readonly owning?: boolean;
45
- /** Custom join table name for ManyToMany */
49
+ /** Custom join table name for ManyToMany or MorphToMany */
46
50
  readonly joinTable?: string;
47
51
  }
48
52
  /**
@@ -76,12 +80,12 @@ interface StringPropertyDefinition extends BasePropertyDefinition {
76
80
  * Numeric property definition.
77
81
  */
78
82
  interface NumericPropertyDefinition extends BasePropertyDefinition {
79
- readonly type: 'Int' | 'BigInt' | 'Float';
83
+ readonly type: 'Int' | 'BigInt' | 'Float' | 'Decimal';
80
84
  /** Whether the number is unsigned (positive only) */
81
85
  readonly unsigned?: boolean;
82
- /** Precision for decimal types */
86
+ /** Total number of digits for Decimal (default: 8) */
83
87
  readonly precision?: number;
84
- /** Scale for decimal types */
88
+ /** Number of decimal places for Decimal (default: 2) */
85
89
  readonly scale?: number;
86
90
  }
87
91
  /**
@@ -108,6 +112,10 @@ interface SelectPropertyDefinition extends BasePropertyDefinition {
108
112
  type PropertyDefinition = (BasePropertyDefinition & {
109
113
  readonly type: PropertyType;
110
114
  }) | StringPropertyDefinition | NumericPropertyDefinition | EnumPropertyDefinition | SelectPropertyDefinition | AssociationDefinition;
115
+ /**
116
+ * Index type for specialized indexes.
117
+ */
118
+ type IndexType = 'btree' | 'hash' | 'fulltext' | 'spatial' | 'gin' | 'gist';
111
119
  /**
112
120
  * Index definition for database optimization.
113
121
  */
@@ -118,11 +126,29 @@ interface IndexDefinition {
118
126
  readonly unique?: boolean;
119
127
  /** Custom index name */
120
128
  readonly name?: string;
129
+ /** Index type (btree, hash, fulltext, spatial, gin, gist) */
130
+ readonly type?: IndexType;
121
131
  }
132
+ /**
133
+ * ID column type options.
134
+ */
135
+ type IdType = 'BigInt' | 'Int' | 'Uuid' | 'String';
122
136
  /**
123
137
  * Schema-level options for behavior configuration.
124
138
  */
125
139
  interface SchemaOptions {
140
+ /**
141
+ * Whether to auto-generate an 'id' primary key column.
142
+ * Set to false for pivot tables or tables with custom primary keys.
143
+ * @default true
144
+ */
145
+ readonly id?: boolean;
146
+ /**
147
+ * Type of the auto-generated 'id' column.
148
+ * Only applies when id is true (default).
149
+ * @default 'BigInt'
150
+ */
151
+ readonly idType?: IdType;
126
152
  /** Add created_at and updated_at timestamp columns */
127
153
  readonly timestamps?: boolean;
128
154
  /** Add deleted_at column for soft deletes */
@@ -135,8 +161,6 @@ interface SchemaOptions {
135
161
  readonly translations?: boolean;
136
162
  /** Custom table name (defaults to pluralized snake_case of schema name) */
137
163
  readonly tableName?: string;
138
- /** Primary key type */
139
- readonly primaryKeyType?: 'Int' | 'BigInt' | 'Uuid' | 'String';
140
164
  /** Enable authenticatable trait (for User-like schemas) */
141
165
  readonly authenticatable?: boolean;
142
166
  /** Login ID field for authenticatable */
@@ -584,4 +608,4 @@ declare function ok<T>(value: T): Result<T, never>;
584
608
  */
585
609
  declare function err<E>(error: E): Result<never, E>;
586
610
 
587
- 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 };
611
+ 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 IdType, type IndexDefinition, type IndexType, 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
@@ -7,7 +7,7 @@
7
7
  * Built-in property types supported by omnify-schema.
8
8
  * Custom types can be added via plugins.
9
9
  */
10
- type BuiltInPropertyType = 'String' | 'Int' | 'BigInt' | 'Float' | 'Boolean' | 'Text' | 'LongText' | 'Date' | 'Time' | 'Timestamp' | 'Json' | 'Email' | 'Password' | 'File' | 'MultiFile' | 'Enum' | 'Select' | 'Lookup' | 'Association' | 'Polymorphic';
10
+ type BuiltInPropertyType = 'String' | 'Int' | 'BigInt' | 'Float' | 'Decimal' | 'Boolean' | 'Text' | 'LongText' | 'Date' | 'Time' | 'Timestamp' | 'Json' | 'Email' | 'Password' | 'File' | 'MultiFile' | 'Point' | 'Coordinates' | 'Enum' | 'Select' | 'Lookup' | 'Association';
11
11
  /**
12
12
  * Property type - can be a built-in type or a custom plugin type (string).
13
13
  */
@@ -15,7 +15,7 @@ type PropertyType = BuiltInPropertyType | (string & {});
15
15
  /**
16
16
  * Relationship cardinality types for associations.
17
17
  */
18
- type AssociationRelation = 'OneToOne' | 'OneToMany' | 'ManyToOne' | 'ManyToMany';
18
+ type AssociationRelation = 'OneToOne' | 'OneToMany' | 'ManyToOne' | 'ManyToMany' | 'MorphTo' | 'MorphOne' | 'MorphMany' | 'MorphToMany' | 'MorphedByMany';
19
19
  /**
20
20
  * Referential action for foreign key constraints.
21
21
  */
@@ -30,8 +30,12 @@ interface AssociationDefinition {
30
30
  readonly type: 'Association';
31
31
  /** Relationship cardinality */
32
32
  readonly relation: AssociationRelation;
33
- /** Target schema name (e.g., 'User', 'Product') */
34
- readonly target: string;
33
+ /** Target schema name (e.g., 'User', 'Product') - for standard relations */
34
+ readonly target?: string;
35
+ /** Target schema names for polymorphic relations (MorphTo) */
36
+ readonly targets?: readonly string[];
37
+ /** Polymorphic name for inverse side (MorphOne, MorphMany, MorphedByMany) */
38
+ readonly morphName?: string;
35
39
  /** Property name on the target schema that maps back (for bidirectional) */
36
40
  readonly inversedBy?: string;
37
41
  /** Property name on this schema that is mapped by target (for bidirectional) */
@@ -42,7 +46,7 @@ interface AssociationDefinition {
42
46
  readonly onUpdate?: ReferentialAction;
43
47
  /** Whether this side owns the relationship (has the foreign key) */
44
48
  readonly owning?: boolean;
45
- /** Custom join table name for ManyToMany */
49
+ /** Custom join table name for ManyToMany or MorphToMany */
46
50
  readonly joinTable?: string;
47
51
  }
48
52
  /**
@@ -76,12 +80,12 @@ interface StringPropertyDefinition extends BasePropertyDefinition {
76
80
  * Numeric property definition.
77
81
  */
78
82
  interface NumericPropertyDefinition extends BasePropertyDefinition {
79
- readonly type: 'Int' | 'BigInt' | 'Float';
83
+ readonly type: 'Int' | 'BigInt' | 'Float' | 'Decimal';
80
84
  /** Whether the number is unsigned (positive only) */
81
85
  readonly unsigned?: boolean;
82
- /** Precision for decimal types */
86
+ /** Total number of digits for Decimal (default: 8) */
83
87
  readonly precision?: number;
84
- /** Scale for decimal types */
88
+ /** Number of decimal places for Decimal (default: 2) */
85
89
  readonly scale?: number;
86
90
  }
87
91
  /**
@@ -108,6 +112,10 @@ interface SelectPropertyDefinition extends BasePropertyDefinition {
108
112
  type PropertyDefinition = (BasePropertyDefinition & {
109
113
  readonly type: PropertyType;
110
114
  }) | StringPropertyDefinition | NumericPropertyDefinition | EnumPropertyDefinition | SelectPropertyDefinition | AssociationDefinition;
115
+ /**
116
+ * Index type for specialized indexes.
117
+ */
118
+ type IndexType = 'btree' | 'hash' | 'fulltext' | 'spatial' | 'gin' | 'gist';
111
119
  /**
112
120
  * Index definition for database optimization.
113
121
  */
@@ -118,11 +126,29 @@ interface IndexDefinition {
118
126
  readonly unique?: boolean;
119
127
  /** Custom index name */
120
128
  readonly name?: string;
129
+ /** Index type (btree, hash, fulltext, spatial, gin, gist) */
130
+ readonly type?: IndexType;
121
131
  }
132
+ /**
133
+ * ID column type options.
134
+ */
135
+ type IdType = 'BigInt' | 'Int' | 'Uuid' | 'String';
122
136
  /**
123
137
  * Schema-level options for behavior configuration.
124
138
  */
125
139
  interface SchemaOptions {
140
+ /**
141
+ * Whether to auto-generate an 'id' primary key column.
142
+ * Set to false for pivot tables or tables with custom primary keys.
143
+ * @default true
144
+ */
145
+ readonly id?: boolean;
146
+ /**
147
+ * Type of the auto-generated 'id' column.
148
+ * Only applies when id is true (default).
149
+ * @default 'BigInt'
150
+ */
151
+ readonly idType?: IdType;
126
152
  /** Add created_at and updated_at timestamp columns */
127
153
  readonly timestamps?: boolean;
128
154
  /** Add deleted_at column for soft deletes */
@@ -135,8 +161,6 @@ interface SchemaOptions {
135
161
  readonly translations?: boolean;
136
162
  /** Custom table name (defaults to pluralized snake_case of schema name) */
137
163
  readonly tableName?: string;
138
- /** Primary key type */
139
- readonly primaryKeyType?: 'Int' | 'BigInt' | 'Uuid' | 'String';
140
164
  /** Enable authenticatable trait (for User-like schemas) */
141
165
  readonly authenticatable?: boolean;
142
166
  /** Login ID field for authenticatable */
@@ -584,4 +608,4 @@ declare function ok<T>(value: T): Result<T, never>;
584
608
  */
585
609
  declare function err<E>(error: E): Result<never, E>;
586
610
 
587
- 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 };
611
+ 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 IdType, type IndexDefinition, type IndexType, 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.6",
3
+ "version": "0.0.8",
4
4
  "description": "Shared TypeScript types for omnify-schema",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",