@famgia/omnify-laravel 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 +106 -8
- package/dist/chunk-AVGA7WYF.js +965 -0
- package/dist/chunk-AVGA7WYF.js.map +1 -0
- package/dist/index.cjs +68 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +40 -858
- package/dist/index.js.map +1 -1
- package/dist/plugin.cjs +895 -0
- package/dist/plugin.cjs.map +1 -0
- package/dist/plugin.d.cts +71 -0
- package/dist/plugin.d.ts +71 -0
- package/dist/plugin.js +8 -0
- package/dist/plugin.js.map +1 -0
- package/package.json +8 -3
package/README.md
CHANGED
|
@@ -10,22 +10,80 @@ npm install @famgia/omnify-laravel
|
|
|
10
10
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
13
|
+
### Plugin Mode (Recommended)
|
|
14
|
+
|
|
15
|
+
Use as a plugin in your `omnify.config.ts`:
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
import { defineConfig } from '@famgia/omnify';
|
|
19
|
+
import laravel from '@famgia/omnify-laravel/plugin';
|
|
20
|
+
|
|
21
|
+
export default defineConfig({
|
|
22
|
+
schemasDir: './schemas',
|
|
23
|
+
database: {
|
|
24
|
+
driver: 'mysql',
|
|
25
|
+
devUrl: 'mysql://root@localhost:3306/dev',
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
plugins: [
|
|
29
|
+
laravel({
|
|
30
|
+
// Path for Laravel migration files (default: 'database/migrations')
|
|
31
|
+
migrationsPath: 'database/migrations',
|
|
32
|
+
|
|
33
|
+
// Path for TypeScript type files (default: 'types')
|
|
34
|
+
typesPath: 'resources/js/types',
|
|
35
|
+
|
|
36
|
+
// Generate all types in a single file (default: true)
|
|
37
|
+
singleFile: true,
|
|
38
|
+
|
|
39
|
+
// Database connection name for migrations (optional)
|
|
40
|
+
connection: 'mysql',
|
|
41
|
+
|
|
42
|
+
// Enable/disable generators (both default: true)
|
|
43
|
+
generateMigrations: true,
|
|
44
|
+
generateTypes: true,
|
|
45
|
+
}),
|
|
46
|
+
],
|
|
47
|
+
});
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Then run:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
npx omnify generate
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Plugin Options
|
|
57
|
+
|
|
58
|
+
| Option | Type | Default | Description |
|
|
59
|
+
|--------|------|---------|-------------|
|
|
60
|
+
| `migrationsPath` | `string` | `'database/migrations'` | Output path for Laravel migrations |
|
|
61
|
+
| `typesPath` | `string` | `'types'` | Output path for TypeScript types |
|
|
62
|
+
| `singleFile` | `boolean` | `true` | Generate all types in one file |
|
|
63
|
+
| `connection` | `string` | `undefined` | Database connection name |
|
|
64
|
+
| `generateMigrations` | `boolean` | `true` | Generate Laravel migrations |
|
|
65
|
+
| `generateTypes` | `boolean` | `true` | Generate TypeScript types |
|
|
66
|
+
|
|
67
|
+
### Direct API Usage
|
|
68
|
+
|
|
69
|
+
For programmatic usage without the plugin system:
|
|
70
|
+
|
|
13
71
|
```typescript
|
|
14
72
|
import {
|
|
15
|
-
|
|
73
|
+
generateMigrations,
|
|
16
74
|
generateTypeScript,
|
|
17
|
-
MigrationGenerator,
|
|
18
|
-
TypeScriptGenerator
|
|
19
75
|
} from '@famgia/omnify-laravel';
|
|
20
76
|
|
|
21
|
-
// Generate Laravel
|
|
22
|
-
const
|
|
23
|
-
tableName: 'users',
|
|
77
|
+
// Generate Laravel migrations
|
|
78
|
+
const migrations = generateMigrations(schemas, {
|
|
24
79
|
timestamp: '2024_01_01_000000',
|
|
80
|
+
connection: 'mysql',
|
|
25
81
|
});
|
|
26
82
|
|
|
27
|
-
// Generate TypeScript
|
|
28
|
-
const
|
|
83
|
+
// Generate TypeScript interfaces
|
|
84
|
+
const types = generateTypeScript(schemas, {
|
|
85
|
+
singleFile: true,
|
|
86
|
+
});
|
|
29
87
|
```
|
|
30
88
|
|
|
31
89
|
## Features
|
|
@@ -36,6 +94,7 @@ const typescript = generateTypeScript(schemas);
|
|
|
36
94
|
- Relationship handling (belongsTo, hasMany, etc.)
|
|
37
95
|
- Index and constraint generation
|
|
38
96
|
- Enum type support
|
|
97
|
+
- Plugin system with DAG-based generator ordering
|
|
39
98
|
|
|
40
99
|
## Generated Output
|
|
41
100
|
|
|
@@ -76,11 +135,50 @@ export interface User {
|
|
|
76
135
|
}
|
|
77
136
|
```
|
|
78
137
|
|
|
138
|
+
## Creating Custom Plugins
|
|
139
|
+
|
|
140
|
+
You can create your own generator plugins following this pattern:
|
|
141
|
+
|
|
142
|
+
```typescript
|
|
143
|
+
import type { OmnifyPlugin, GeneratorContext, GeneratorOutput } from '@famgia/omnify-types';
|
|
144
|
+
|
|
145
|
+
export default function myPlugin(options?: MyOptions): OmnifyPlugin {
|
|
146
|
+
return {
|
|
147
|
+
name: 'my-plugin',
|
|
148
|
+
version: '1.0.0',
|
|
149
|
+
|
|
150
|
+
generators: [
|
|
151
|
+
{
|
|
152
|
+
name: 'my-generator',
|
|
153
|
+
description: 'Generate custom files',
|
|
154
|
+
|
|
155
|
+
// Optional: run after other generators
|
|
156
|
+
dependsOn: ['laravel-migrations'],
|
|
157
|
+
|
|
158
|
+
generate: async (ctx: GeneratorContext): Promise<GeneratorOutput[]> => {
|
|
159
|
+
// Access schemas via ctx.schemas
|
|
160
|
+
// Access previous generator outputs via ctx.previousOutputs
|
|
161
|
+
|
|
162
|
+
return [
|
|
163
|
+
{
|
|
164
|
+
path: 'output/file.ts',
|
|
165
|
+
content: '// Generated content',
|
|
166
|
+
type: 'other',
|
|
167
|
+
},
|
|
168
|
+
];
|
|
169
|
+
},
|
|
170
|
+
},
|
|
171
|
+
],
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
79
176
|
## Related Packages
|
|
80
177
|
|
|
81
178
|
- [@famgia/omnify-core](https://www.npmjs.com/package/@famgia/omnify-core) - Core engine
|
|
82
179
|
- [@famgia/omnify-cli](https://www.npmjs.com/package/@famgia/omnify-cli) - CLI tool
|
|
83
180
|
- [@famgia/omnify-atlas](https://www.npmjs.com/package/@famgia/omnify-atlas) - Atlas adapter
|
|
181
|
+
- [@famgia/omnify-types](https://www.npmjs.com/package/@famgia/omnify-types) - Type definitions
|
|
84
182
|
|
|
85
183
|
## License
|
|
86
184
|
|