@famgia/omnify 0.12.9 → 1.0.1
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 +435 -89
- package/dist/index.cjs +101 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -7
- package/dist/index.js +78 -22
- package/dist/index.js.map +1 -1
- package/package.json +34 -65
- package/CHANGELOG.md +0 -129
- package/dist/__tests__/generators/contextGenerator.test.d.ts +0 -2
- package/dist/__tests__/generators/contextGenerator.test.d.ts.map +0 -1
- package/dist/__tests__/generators/contextGenerator.test.js +0 -109
- package/dist/__tests__/generators/contextGenerator.test.js.map +0 -1
- package/dist/__tests__/generators/enumGenerator.test.d.ts +0 -2
- package/dist/__tests__/generators/enumGenerator.test.d.ts.map +0 -1
- package/dist/__tests__/generators/enumGenerator.test.js +0 -151
- package/dist/__tests__/generators/enumGenerator.test.js.map +0 -1
- package/dist/__tests__/generators/modelGenerator.test.d.ts +0 -2
- package/dist/__tests__/generators/modelGenerator.test.d.ts.map +0 -1
- package/dist/__tests__/generators/modelGenerator.test.js +0 -329
- package/dist/__tests__/generators/modelGenerator.test.js.map +0 -1
- package/dist/__tests__/utils/pascalCase.test.d.ts +0 -1
- package/dist/__tests__/utils/pascalCase.test.d.ts.map +0 -1
- package/dist/__tests__/utils/pascalCase.test.js +0 -75
- package/dist/__tests__/utils/pascalCase.test.js.map +0 -1
- package/dist/__tests__/utils/typeMapper.test.d.ts +0 -2
- package/dist/__tests__/utils/typeMapper.test.d.ts.map +0 -1
- package/dist/__tests__/utils/typeMapper.test.js +0 -41
- package/dist/__tests__/utils/typeMapper.test.js.map +0 -1
- package/dist/cli.d.ts +0 -3
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js +0 -248
- package/dist/cli.js.map +0 -1
- package/dist/generators/commonTypesGenerator.d.ts +0 -5
- package/dist/generators/commonTypesGenerator.d.ts.map +0 -1
- package/dist/generators/commonTypesGenerator.js +0 -37
- package/dist/generators/commonTypesGenerator.js.map +0 -1
- package/dist/generators/contextGenerator.d.ts +0 -3
- package/dist/generators/contextGenerator.d.ts.map +0 -1
- package/dist/generators/contextGenerator.js +0 -248
- package/dist/generators/contextGenerator.js.map +0 -1
- package/dist/generators/enumGenerator.d.ts +0 -13
- package/dist/generators/enumGenerator.d.ts.map +0 -1
- package/dist/generators/enumGenerator.js +0 -83
- package/dist/generators/enumGenerator.js.map +0 -1
- package/dist/generators/hooksGenerator.d.ts +0 -4
- package/dist/generators/hooksGenerator.d.ts.map +0 -1
- package/dist/generators/hooksGenerator.js +0 -265
- package/dist/generators/hooksGenerator.js.map +0 -1
- package/dist/generators/modelGenerator.d.ts +0 -13
- package/dist/generators/modelGenerator.d.ts.map +0 -1
- package/dist/generators/modelGenerator.js +0 -262
- package/dist/generators/modelGenerator.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/runtime/hooks/useFormSubmit.d.ts +0 -36
- package/dist/runtime/hooks/useFormSubmit.d.ts.map +0 -1
- package/dist/runtime/hooks/useFormSubmit.js +0 -86
- package/dist/runtime/hooks/useFormSubmit.js.map +0 -1
- package/dist/runtime/index.d.ts +0 -5
- package/dist/runtime/index.d.ts.map +0 -1
- package/dist/runtime/index.js +0 -21
- package/dist/runtime/index.js.map +0 -1
- package/dist/runtime/lib/axios.d.ts +0 -7
- package/dist/runtime/lib/axios.d.ts.map +0 -1
- package/dist/runtime/lib/axios.js +0 -54
- package/dist/runtime/lib/axios.js.map +0 -1
- package/dist/runtime/lib/validation.d.ts +0 -50
- package/dist/runtime/lib/validation.d.ts.map +0 -1
- package/dist/runtime/lib/validation.js +0 -85
- package/dist/runtime/lib/validation.js.map +0 -1
- package/dist/types.d.ts +0 -54
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -3
- package/dist/types.js.map +0 -1
- package/dist/utils/typeMapper.d.ts +0 -10
- package/dist/utils/typeMapper.d.ts.map +0 -1
- package/dist/utils/typeMapper.js +0 -119
- package/dist/utils/typeMapper.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,135 +1,481 @@
|
|
|
1
1
|
# @famgia/omnify
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Schema-driven database migration system with TypeScript types and Laravel migrations.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
### 🎯 Build-time (Code Generation)
|
|
8
|
-
- ✅ Convert Omnify `schema-lock.json` to TypeScript types
|
|
9
|
-
- ✅ Generate enum types and options
|
|
10
|
-
- ✅ Generate model interfaces with relations
|
|
11
|
-
- ✅ Generate Enums Context Provider with type-safe helpers
|
|
12
|
-
- ✅ Watch mode for auto-regeneration
|
|
13
|
-
|
|
14
|
-
### 🚀 Runtime (React Helpers)
|
|
15
|
-
- ✅ `useFormSubmit` - Auto Laravel validation error mapping
|
|
16
|
-
- ✅ `createLaravelAxios` - Pre-configured axios for Laravel
|
|
17
|
-
- ✅ `getCsrfCookie` - CSRF token helper
|
|
18
|
-
- ✅ Full TypeScript support
|
|
5
|
+
Define your database schema in YAML, generate Laravel migrations and TypeScript types automatically.
|
|
19
6
|
|
|
20
7
|
## Installation
|
|
21
8
|
|
|
22
9
|
```bash
|
|
10
|
+
# Main package (for programmatic usage)
|
|
23
11
|
npm install @famgia/omnify
|
|
12
|
+
|
|
13
|
+
# CLI tool (for command line usage)
|
|
14
|
+
npm install -g @famgia/omnify-cli
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Quick Start
|
|
18
|
+
|
|
19
|
+
### 1. Initialize project
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
omnify init
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
This creates:
|
|
26
|
+
- `omnify.config.ts` - Configuration file
|
|
27
|
+
- `schemas/` - Directory for schema files
|
|
28
|
+
- `schemas/user.yaml` - Example schema
|
|
29
|
+
|
|
30
|
+
### 2. Configure
|
|
31
|
+
|
|
32
|
+
Edit `omnify.config.ts`:
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
import { defineConfig } from '@famgia/omnify-cli';
|
|
36
|
+
|
|
37
|
+
export default defineConfig({
|
|
38
|
+
// Schema files location
|
|
39
|
+
schemaDir: './schemas',
|
|
40
|
+
|
|
41
|
+
// Laravel migrations output
|
|
42
|
+
migrations: {
|
|
43
|
+
outputDir: './database/migrations',
|
|
44
|
+
connection: 'mysql', // mysql | pgsql | sqlite
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
// TypeScript types output
|
|
48
|
+
typescript: {
|
|
49
|
+
outputDir: './resources/js/types',
|
|
50
|
+
// Or for React/Vue frontend:
|
|
51
|
+
// outputDir: './frontend/src/types',
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
// Atlas HCL output (optional)
|
|
55
|
+
atlas: {
|
|
56
|
+
outputDir: './atlas',
|
|
57
|
+
lockFile: './atlas/omnify.lock',
|
|
58
|
+
},
|
|
59
|
+
|
|
60
|
+
// Plugins (optional)
|
|
61
|
+
plugins: [
|
|
62
|
+
// '@famgia/omnify-japan', // Japan-specific types
|
|
63
|
+
],
|
|
64
|
+
});
|
|
24
65
|
```
|
|
25
66
|
|
|
26
|
-
|
|
67
|
+
### 3. Create schemas
|
|
68
|
+
|
|
69
|
+
```yaml
|
|
70
|
+
# schemas/user.yaml
|
|
71
|
+
name: User
|
|
72
|
+
displayName: User Account
|
|
73
|
+
group: auth
|
|
74
|
+
|
|
75
|
+
properties:
|
|
76
|
+
email:
|
|
77
|
+
type: String
|
|
78
|
+
unique: true
|
|
79
|
+
name:
|
|
80
|
+
type: String
|
|
81
|
+
password:
|
|
82
|
+
type: String
|
|
83
|
+
role:
|
|
84
|
+
type: Enum
|
|
85
|
+
values: [admin, user, guest]
|
|
86
|
+
default: user
|
|
87
|
+
avatar:
|
|
88
|
+
type: String
|
|
89
|
+
nullable: true
|
|
90
|
+
email_verified_at:
|
|
91
|
+
type: DateTime
|
|
92
|
+
nullable: true
|
|
93
|
+
|
|
94
|
+
options:
|
|
95
|
+
timestamps: true # adds created_at, updated_at
|
|
96
|
+
softDelete: true # adds deleted_at
|
|
97
|
+
primaryKeyType: Int # Int | BigInt | Uuid
|
|
98
|
+
```
|
|
27
99
|
|
|
28
|
-
###
|
|
100
|
+
### 4. Generate code
|
|
29
101
|
|
|
30
102
|
```bash
|
|
31
|
-
#
|
|
32
|
-
|
|
103
|
+
# Validate schemas
|
|
104
|
+
omnify validate
|
|
105
|
+
|
|
106
|
+
# Preview changes (dry run)
|
|
107
|
+
omnify diff
|
|
33
108
|
|
|
34
|
-
#
|
|
35
|
-
|
|
109
|
+
# Generate migrations and types
|
|
110
|
+
omnify generate
|
|
36
111
|
```
|
|
37
112
|
|
|
38
|
-
|
|
113
|
+
## Configuration Reference
|
|
114
|
+
|
|
115
|
+
### Full Config Options
|
|
39
116
|
|
|
40
117
|
```typescript
|
|
41
|
-
import {
|
|
42
|
-
import {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
118
|
+
import { defineConfig } from '@famgia/omnify-cli';
|
|
119
|
+
import { japanPlugin } from '@famgia/omnify-japan';
|
|
120
|
+
|
|
121
|
+
export default defineConfig({
|
|
122
|
+
// Required: Schema files directory
|
|
123
|
+
schemaDir: './schemas',
|
|
124
|
+
|
|
125
|
+
// Laravel migration settings
|
|
126
|
+
migrations: {
|
|
127
|
+
outputDir: './database/migrations',
|
|
128
|
+
connection: 'mysql', // Database driver
|
|
129
|
+
tablePrefix: '', // Prefix for table names
|
|
130
|
+
generateDropMigrations: false,
|
|
131
|
+
},
|
|
132
|
+
|
|
133
|
+
// TypeScript generation settings
|
|
134
|
+
typescript: {
|
|
135
|
+
outputDir: './types',
|
|
136
|
+
generateEnums: true, // Generate enum types
|
|
137
|
+
generateInterfaces: true, // Generate model interfaces
|
|
138
|
+
exportStyle: 'named', // 'named' | 'default'
|
|
139
|
+
},
|
|
140
|
+
|
|
141
|
+
// Atlas integration settings
|
|
142
|
+
atlas: {
|
|
143
|
+
outputDir: './atlas',
|
|
144
|
+
lockFile: './atlas/omnify.lock',
|
|
145
|
+
dialect: 'mysql', // mysql | postgres | sqlite
|
|
146
|
+
},
|
|
147
|
+
|
|
148
|
+
// Plugins for custom types
|
|
149
|
+
plugins: [
|
|
150
|
+
japanPlugin,
|
|
151
|
+
],
|
|
152
|
+
});
|
|
52
153
|
```
|
|
53
154
|
|
|
54
|
-
|
|
155
|
+
## Schema Format
|
|
156
|
+
|
|
157
|
+
### Basic Schema
|
|
158
|
+
|
|
159
|
+
```yaml
|
|
160
|
+
name: Post # Required: Schema name (PascalCase)
|
|
161
|
+
displayName: Blog Post # Optional: Human-readable name
|
|
162
|
+
group: content # Optional: Group for organization
|
|
163
|
+
|
|
164
|
+
properties:
|
|
165
|
+
title:
|
|
166
|
+
type: String
|
|
167
|
+
content:
|
|
168
|
+
type: Text
|
|
169
|
+
published:
|
|
170
|
+
type: Boolean
|
|
171
|
+
default: false
|
|
172
|
+
|
|
173
|
+
options:
|
|
174
|
+
timestamps: true
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### Property Types
|
|
178
|
+
|
|
179
|
+
| Type | Laravel | TypeScript | Description |
|
|
180
|
+
|------|---------|------------|-------------|
|
|
181
|
+
| `String` | `string(255)` | `string` | Short text |
|
|
182
|
+
| `Text` | `text` | `string` | Long text |
|
|
183
|
+
| `Int` | `integer` | `number` | Integer |
|
|
184
|
+
| `BigInt` | `bigInteger` | `number` | Large integer |
|
|
185
|
+
| `Float` | `float` | `number` | Floating point |
|
|
186
|
+
| `Decimal` | `decimal(10,2)` | `number` | Precise decimal |
|
|
187
|
+
| `Boolean` | `boolean` | `boolean` | True/false |
|
|
188
|
+
| `Date` | `date` | `string` | Date only |
|
|
189
|
+
| `DateTime` | `dateTime` | `string` | Date and time |
|
|
190
|
+
| `Timestamp` | `timestamp` | `string` | Unix timestamp |
|
|
191
|
+
| `Time` | `time` | `string` | Time only |
|
|
192
|
+
| `Json` | `json` | `Record<string, unknown>` | JSON data |
|
|
193
|
+
| `Uuid` | `uuid` | `string` | UUID |
|
|
194
|
+
| `Enum` | `enum` | `union type` | Enumeration |
|
|
195
|
+
|
|
196
|
+
### Property Modifiers
|
|
197
|
+
|
|
198
|
+
```yaml
|
|
199
|
+
properties:
|
|
200
|
+
email:
|
|
201
|
+
type: String
|
|
202
|
+
unique: true # Unique constraint
|
|
203
|
+
nullable: true # Allow NULL
|
|
204
|
+
default: 'default@example.com' # Default value
|
|
205
|
+
length: 100 # String length (default: 255)
|
|
206
|
+
|
|
207
|
+
price:
|
|
208
|
+
type: Decimal
|
|
209
|
+
precision: 10 # Total digits
|
|
210
|
+
scale: 2 # Decimal places
|
|
211
|
+
|
|
212
|
+
status:
|
|
213
|
+
type: Enum
|
|
214
|
+
values: [draft, published, archived]
|
|
215
|
+
default: draft
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### Associations (Relationships)
|
|
219
|
+
|
|
220
|
+
```yaml
|
|
221
|
+
# schemas/post.yaml
|
|
222
|
+
name: Post
|
|
223
|
+
properties:
|
|
224
|
+
title:
|
|
225
|
+
type: String
|
|
226
|
+
content:
|
|
227
|
+
type: Text
|
|
228
|
+
|
|
229
|
+
# BelongsTo relationship
|
|
230
|
+
author:
|
|
231
|
+
type: Association
|
|
232
|
+
relation: ManyToOne
|
|
233
|
+
target: User
|
|
234
|
+
mappedBy: posts
|
|
235
|
+
onDelete: CASCADE
|
|
236
|
+
|
|
237
|
+
# HasMany relationship
|
|
238
|
+
comments:
|
|
239
|
+
type: Association
|
|
240
|
+
relation: OneToMany
|
|
241
|
+
target: Comment
|
|
242
|
+
inversedBy: post
|
|
243
|
+
|
|
244
|
+
# ManyToMany relationship
|
|
245
|
+
tags:
|
|
246
|
+
type: Association
|
|
247
|
+
relation: ManyToMany
|
|
248
|
+
target: Tag
|
|
249
|
+
inversedBy: posts
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
### Enum Schema
|
|
253
|
+
|
|
254
|
+
```yaml
|
|
255
|
+
# schemas/status.yaml
|
|
256
|
+
name: OrderStatus
|
|
257
|
+
kind: enum
|
|
258
|
+
values:
|
|
259
|
+
- pending
|
|
260
|
+
- processing
|
|
261
|
+
- shipped
|
|
262
|
+
- delivered
|
|
263
|
+
- cancelled
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
### Schema Options
|
|
267
|
+
|
|
268
|
+
```yaml
|
|
269
|
+
options:
|
|
270
|
+
timestamps: true # Add created_at, updated_at
|
|
271
|
+
softDelete: true # Add deleted_at for soft deletes
|
|
272
|
+
primaryKeyType: Int # Int | BigInt | Uuid
|
|
273
|
+
table: custom_table # Custom table name (default: snake_case of name)
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
## CLI Commands
|
|
277
|
+
|
|
278
|
+
### `omnify init`
|
|
279
|
+
|
|
280
|
+
Initialize a new project with config and example schemas.
|
|
281
|
+
|
|
282
|
+
```bash
|
|
283
|
+
omnify init
|
|
284
|
+
omnify init --force # Overwrite existing files
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
### `omnify validate`
|
|
288
|
+
|
|
289
|
+
Validate all schema files for errors.
|
|
290
|
+
|
|
291
|
+
```bash
|
|
292
|
+
omnify validate
|
|
293
|
+
omnify validate --schema user # Validate specific schema
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
### `omnify diff`
|
|
297
|
+
|
|
298
|
+
Preview pending changes without generating files.
|
|
299
|
+
|
|
300
|
+
```bash
|
|
301
|
+
omnify diff
|
|
302
|
+
omnify diff --verbose # Show detailed changes
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
### `omnify generate`
|
|
306
|
+
|
|
307
|
+
Generate Laravel migrations and TypeScript types.
|
|
308
|
+
|
|
309
|
+
```bash
|
|
310
|
+
omnify generate
|
|
311
|
+
omnify generate --migrations-only # Only migrations
|
|
312
|
+
omnify generate --types-only # Only TypeScript
|
|
313
|
+
omnify generate --dry-run # Preview without writing
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
## Programmatic API
|
|
55
317
|
|
|
56
318
|
```typescript
|
|
57
|
-
import {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
319
|
+
import {
|
|
320
|
+
loadSchemas,
|
|
321
|
+
validateSchemas,
|
|
322
|
+
generateMigrations,
|
|
323
|
+
generateTypeScript,
|
|
324
|
+
createOmnify,
|
|
325
|
+
} from '@famgia/omnify';
|
|
326
|
+
|
|
327
|
+
// Simple usage
|
|
328
|
+
async function generate() {
|
|
329
|
+
const schemas = await loadSchemas('./schemas');
|
|
330
|
+
const validation = validateSchemas(schemas);
|
|
331
|
+
|
|
332
|
+
if (!validation.valid) {
|
|
333
|
+
console.error('Validation errors:', validation.errors);
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
// Generate Laravel migrations
|
|
338
|
+
const migrations = generateMigrations(schemas);
|
|
339
|
+
|
|
340
|
+
// Generate TypeScript types
|
|
341
|
+
const types = generateTypeScript(schemas);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
// Advanced usage with Omnify class
|
|
345
|
+
async function advancedGenerate() {
|
|
346
|
+
const omnify = createOmnify({
|
|
347
|
+
schemaDir: './schemas',
|
|
348
|
+
plugins: [],
|
|
71
349
|
});
|
|
72
350
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
</Form>
|
|
82
|
-
);
|
|
351
|
+
await omnify.initialize();
|
|
352
|
+
|
|
353
|
+
const schemas = omnify.getSchemas();
|
|
354
|
+
const metadata = omnify.introspectSchemas();
|
|
355
|
+
|
|
356
|
+
// Access relationship graph
|
|
357
|
+
const graph = omnify.getRelationshipGraph();
|
|
358
|
+
const order = omnify.getTopologicalOrder();
|
|
83
359
|
}
|
|
84
360
|
```
|
|
85
361
|
|
|
86
|
-
##
|
|
362
|
+
## Generated Output Examples
|
|
363
|
+
|
|
364
|
+
### Laravel Migration
|
|
365
|
+
|
|
366
|
+
```php
|
|
367
|
+
<?php
|
|
368
|
+
|
|
369
|
+
use Illuminate\Database\Migrations\Migration;
|
|
370
|
+
use Illuminate\Database\Schema\Blueprint;
|
|
371
|
+
use Illuminate\Support\Facades\Schema;
|
|
372
|
+
|
|
373
|
+
return new class extends Migration
|
|
374
|
+
{
|
|
375
|
+
public function up(): void
|
|
376
|
+
{
|
|
377
|
+
Schema::create('users', function (Blueprint $table) {
|
|
378
|
+
$table->id();
|
|
379
|
+
$table->string('email')->unique();
|
|
380
|
+
$table->string('name');
|
|
381
|
+
$table->string('password');
|
|
382
|
+
$table->enum('role', ['admin', 'user', 'guest'])->default('user');
|
|
383
|
+
$table->string('avatar')->nullable();
|
|
384
|
+
$table->timestamp('email_verified_at')->nullable();
|
|
385
|
+
$table->timestamps();
|
|
386
|
+
$table->softDeletes();
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
public function down(): void
|
|
391
|
+
{
|
|
392
|
+
Schema::dropIfExists('users');
|
|
393
|
+
}
|
|
394
|
+
};
|
|
395
|
+
```
|
|
87
396
|
|
|
88
|
-
###
|
|
397
|
+
### TypeScript Types
|
|
89
398
|
|
|
90
|
-
|
|
399
|
+
```typescript
|
|
400
|
+
// types/models.ts
|
|
401
|
+
export interface User {
|
|
402
|
+
id: number;
|
|
403
|
+
email: string;
|
|
404
|
+
name: string;
|
|
405
|
+
password: string;
|
|
406
|
+
role: UserRole;
|
|
407
|
+
avatar: string | null;
|
|
408
|
+
email_verified_at: string | null;
|
|
409
|
+
created_at: string;
|
|
410
|
+
updated_at: string;
|
|
411
|
+
deleted_at: string | null;
|
|
412
|
+
}
|
|
91
413
|
|
|
92
|
-
|
|
93
|
-
- `form: FormInstance` - Ant Design form instance
|
|
94
|
-
- `submitFn: (values) => Promise<TResponse>` - API call function
|
|
95
|
-
- `getCsrfToken?: () => Promise<void>` - CSRF token getter
|
|
96
|
-
- `onSuccess?: (response, values) => void` - Success callback
|
|
97
|
-
- `onError?: (error, values) => void` - Custom error handler
|
|
98
|
-
- `errorMessages?: { 500?, 401?, 403?, default? }` - Custom error messages
|
|
414
|
+
export type UserRole = 'admin' | 'user' | 'guest';
|
|
99
415
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
416
|
+
export interface Post {
|
|
417
|
+
id: number;
|
|
418
|
+
title: string;
|
|
419
|
+
content: string;
|
|
420
|
+
author_id: number;
|
|
421
|
+
created_at: string;
|
|
422
|
+
updated_at: string;
|
|
423
|
+
}
|
|
424
|
+
```
|
|
104
425
|
|
|
105
|
-
|
|
426
|
+
## Plugins
|
|
106
427
|
|
|
107
|
-
|
|
428
|
+
### Japan Types Plugin
|
|
429
|
+
|
|
430
|
+
```bash
|
|
431
|
+
npm install @famgia/omnify-japan
|
|
432
|
+
```
|
|
108
433
|
|
|
109
434
|
```typescript
|
|
110
|
-
|
|
435
|
+
// omnify.config.ts
|
|
436
|
+
import { defineConfig } from '@famgia/omnify-cli';
|
|
437
|
+
import { japanPlugin } from '@famgia/omnify-japan';
|
|
438
|
+
|
|
439
|
+
export default defineConfig({
|
|
440
|
+
schemaDir: './schemas',
|
|
441
|
+
plugins: [japanPlugin],
|
|
442
|
+
});
|
|
443
|
+
```
|
|
111
444
|
|
|
112
|
-
|
|
445
|
+
```yaml
|
|
446
|
+
# schemas/customer.yaml
|
|
447
|
+
name: Customer
|
|
448
|
+
properties:
|
|
449
|
+
postal_code:
|
|
450
|
+
type: JapanPostalCode # 〒123-4567
|
|
451
|
+
phone:
|
|
452
|
+
type: JapanPhone # 03-1234-5678
|
|
453
|
+
prefecture:
|
|
454
|
+
type: JapanPrefecture # 東京都, 大阪府, etc.
|
|
113
455
|
```
|
|
114
456
|
|
|
115
|
-
|
|
457
|
+
## Packages
|
|
116
458
|
|
|
117
|
-
|
|
459
|
+
| Package | Description |
|
|
460
|
+
|---------|-------------|
|
|
461
|
+
| [@famgia/omnify](https://www.npmjs.com/package/@famgia/omnify) | Main entry point |
|
|
462
|
+
| [@famgia/omnify-cli](https://www.npmjs.com/package/@famgia/omnify-cli) | CLI tool |
|
|
463
|
+
| [@famgia/omnify-core](https://www.npmjs.com/package/@famgia/omnify-core) | Core engine |
|
|
464
|
+
| [@famgia/omnify-types](https://www.npmjs.com/package/@famgia/omnify-types) | Type definitions |
|
|
465
|
+
| [@famgia/omnify-laravel](https://www.npmjs.com/package/@famgia/omnify-laravel) | Laravel generator |
|
|
466
|
+
| [@famgia/omnify-atlas](https://www.npmjs.com/package/@famgia/omnify-atlas) | Atlas integration |
|
|
467
|
+
| [@famgia/omnify-japan](https://www.npmjs.com/package/@famgia/omnify-japan) | Japan types |
|
|
118
468
|
|
|
119
|
-
|
|
120
|
-
import { getCsrfCookie } from '@famgia/omnify';
|
|
469
|
+
## Migration from @famgia/omnify (v0.12.x)
|
|
121
470
|
|
|
122
|
-
|
|
123
|
-
```
|
|
471
|
+
The old `@famgia/omnify` package has been renamed to `@famgia/omnify-old`:
|
|
124
472
|
|
|
125
|
-
|
|
473
|
+
```bash
|
|
474
|
+
npm uninstall @famgia/omnify
|
|
475
|
+
npm install @famgia/omnify-old
|
|
476
|
+
```
|
|
126
477
|
|
|
127
|
-
|
|
128
|
-
- 🛡️ Type-safe enums and models
|
|
129
|
-
- 🔄 Auto-sync with backend schema
|
|
130
|
-
- 📝 Consistent error handling
|
|
131
|
-
- ⚡ Build-time code generation
|
|
132
|
-
- 🎯 Runtime helpers for common tasks
|
|
478
|
+
The old package provided React/Antd form helpers. The new `@famgia/omnify` is a complete rewrite focused on schema-driven code generation.
|
|
133
479
|
|
|
134
480
|
## License
|
|
135
481
|
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
Omnify: () => import_omnify_core.Omnify,
|
|
24
|
+
PluginManager: () => import_omnify_core.PluginManager,
|
|
25
|
+
compareSchemas: () => import_omnify_atlas.compareSchemas,
|
|
26
|
+
createOmnify: () => import_omnify_core.createOmnify,
|
|
27
|
+
diffHclSchemas: () => import_omnify_atlas.diffHclSchemas,
|
|
28
|
+
findReferencedSchemas: () => import_omnify_core.findReferencedSchemas,
|
|
29
|
+
findReferencingSchemas: () => import_omnify_core.findReferencingSchemas,
|
|
30
|
+
generateEnums: () => import_omnify_laravel.generateEnums,
|
|
31
|
+
generateHclSchema: () => import_omnify_atlas.generateHclSchema,
|
|
32
|
+
generateInterfaces: () => import_omnify_laravel.generateInterfaces,
|
|
33
|
+
generateMigrationFromSchema: () => import_omnify_laravel.generateMigrationFromSchema,
|
|
34
|
+
generateMigrations: () => import_omnify_laravel.generateMigrations,
|
|
35
|
+
generatePreview: () => import_omnify_atlas.generatePreview,
|
|
36
|
+
generateTypeScript: () => import_omnify_laravel.generateTypeScript,
|
|
37
|
+
generateTypeScriptFile: () => import_omnify_laravel.generateTypeScriptFile,
|
|
38
|
+
getEntitySchemas: () => import_omnify_core.getEntitySchemas,
|
|
39
|
+
getEnumSchemas: () => import_omnify_core.getEnumSchemas,
|
|
40
|
+
getGroups: () => import_omnify_core.getGroups,
|
|
41
|
+
getRelationshipGraph: () => import_omnify_core.getRelationshipGraph,
|
|
42
|
+
getSchemaMetadata: () => import_omnify_core.getSchemaMetadata,
|
|
43
|
+
getSchemaNames: () => import_omnify_core.getSchemaNames,
|
|
44
|
+
getSchemasByGroup: () => import_omnify_core.getSchemasByGroup,
|
|
45
|
+
getTopologicalOrder: () => import_omnify_core.getTopologicalOrder,
|
|
46
|
+
hasCircularReferences: () => import_omnify_core.hasCircularReferences,
|
|
47
|
+
introspectSchema: () => import_omnify_core.introspectSchema,
|
|
48
|
+
introspectSchemas: () => import_omnify_core.introspectSchemas,
|
|
49
|
+
loadSchemas: () => import_omnify_core.loadSchemas,
|
|
50
|
+
parseDiffOutput: () => import_omnify_atlas.parseDiffOutput,
|
|
51
|
+
readLockFile: () => import_omnify_atlas.readLockFile,
|
|
52
|
+
renderHcl: () => import_omnify_atlas.renderHcl,
|
|
53
|
+
runAtlasDiff: () => import_omnify_atlas.runAtlasDiff,
|
|
54
|
+
schemaToBlueprint: () => import_omnify_laravel.schemaToBlueprint,
|
|
55
|
+
schemaToInterface: () => import_omnify_laravel.schemaToInterface,
|
|
56
|
+
validateSchemas: () => import_omnify_core.validateSchemas,
|
|
57
|
+
writeLockFile: () => import_omnify_atlas.writeLockFile
|
|
58
|
+
});
|
|
59
|
+
module.exports = __toCommonJS(index_exports);
|
|
60
|
+
var import_omnify_core = require("@famgia/omnify-core");
|
|
61
|
+
var import_omnify_laravel = require("@famgia/omnify-laravel");
|
|
62
|
+
var import_omnify_atlas = require("@famgia/omnify-atlas");
|
|
63
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
64
|
+
0 && (module.exports = {
|
|
65
|
+
Omnify,
|
|
66
|
+
PluginManager,
|
|
67
|
+
compareSchemas,
|
|
68
|
+
createOmnify,
|
|
69
|
+
diffHclSchemas,
|
|
70
|
+
findReferencedSchemas,
|
|
71
|
+
findReferencingSchemas,
|
|
72
|
+
generateEnums,
|
|
73
|
+
generateHclSchema,
|
|
74
|
+
generateInterfaces,
|
|
75
|
+
generateMigrationFromSchema,
|
|
76
|
+
generateMigrations,
|
|
77
|
+
generatePreview,
|
|
78
|
+
generateTypeScript,
|
|
79
|
+
generateTypeScriptFile,
|
|
80
|
+
getEntitySchemas,
|
|
81
|
+
getEnumSchemas,
|
|
82
|
+
getGroups,
|
|
83
|
+
getRelationshipGraph,
|
|
84
|
+
getSchemaMetadata,
|
|
85
|
+
getSchemaNames,
|
|
86
|
+
getSchemasByGroup,
|
|
87
|
+
getTopologicalOrder,
|
|
88
|
+
hasCircularReferences,
|
|
89
|
+
introspectSchema,
|
|
90
|
+
introspectSchemas,
|
|
91
|
+
loadSchemas,
|
|
92
|
+
parseDiffOutput,
|
|
93
|
+
readLockFile,
|
|
94
|
+
renderHcl,
|
|
95
|
+
runAtlasDiff,
|
|
96
|
+
schemaToBlueprint,
|
|
97
|
+
schemaToInterface,
|
|
98
|
+
validateSchemas,
|
|
99
|
+
writeLockFile
|
|
100
|
+
});
|
|
101
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * @famgia/omnify - Schema-driven database migration system\n *\n * Main entry point that re-exports key APIs.\n */\n\n// Core exports\nexport {\n loadSchemas,\n validateSchemas,\n createOmnify,\n Omnify,\n PluginManager,\n getSchemaMetadata,\n introspectSchema,\n introspectSchemas,\n getSchemaNames,\n getEntitySchemas,\n getEnumSchemas,\n getSchemasByGroup,\n getGroups,\n findReferencingSchemas,\n findReferencedSchemas,\n getRelationshipGraph,\n hasCircularReferences,\n getTopologicalOrder,\n} from '@famgia/omnify-core';\n\n// Type exports\nexport type {\n SchemaDefinition,\n LoadedSchema,\n SchemaCollection,\n PropertyDefinition,\n AssociationDefinition,\n OmnifyPlugin,\n OmnifyConfig,\n} from '@famgia/omnify-types';\n\n// Laravel generator exports\nexport {\n generateMigrations,\n generateMigrationFromSchema,\n generateTypeScript,\n generateTypeScriptFile,\n generateInterfaces,\n generateEnums,\n schemaToBlueprint,\n schemaToInterface,\n} from '@famgia/omnify-laravel';\n\nexport type {\n MigrationFile,\n MigrationOptions,\n TypeScriptFile,\n TypeScriptOptions,\n} from '@famgia/omnify-laravel';\n\n// Atlas adapter exports\nexport {\n runAtlasDiff,\n diffHclSchemas,\n generateHclSchema,\n renderHcl,\n readLockFile,\n writeLockFile,\n compareSchemas,\n generatePreview,\n parseDiffOutput,\n} from '@famgia/omnify-atlas';\n\nexport type {\n AtlasDiffResult,\n HclSchema,\n LockFile,\n DiffResult,\n ChangePreview,\n} from '@famgia/omnify-atlas';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,yBAmBO;AAcP,4BASO;AAUP,0BAUO;","names":[]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { Omnify, PluginManager, createOmnify, findReferencedSchemas, findReferencingSchemas, getEntitySchemas, getEnumSchemas, getGroups, getRelationshipGraph, getSchemaMetadata, getSchemaNames, getSchemasByGroup, getTopologicalOrder, hasCircularReferences, introspectSchema, introspectSchemas, loadSchemas, validateSchemas } from '@famgia/omnify-core';
|
|
2
|
+
export { AssociationDefinition, LoadedSchema, OmnifyConfig, OmnifyPlugin, PropertyDefinition, SchemaCollection, SchemaDefinition } from '@famgia/omnify-types';
|
|
3
|
+
export { MigrationFile, MigrationOptions, TypeScriptFile, TypeScriptOptions, generateEnums, generateInterfaces, generateMigrationFromSchema, generateMigrations, generateTypeScript, generateTypeScriptFile, schemaToBlueprint, schemaToInterface } from '@famgia/omnify-laravel';
|
|
4
|
+
export { AtlasDiffResult, ChangePreview, DiffResult, HclSchema, LockFile, compareSchemas, diffHclSchemas, generateHclSchema, generatePreview, parseDiffOutput, readLockFile, renderHcl, runAtlasDiff, writeLockFile } from '@famgia/omnify-atlas';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export * from './generators/contextGenerator';
|
|
6
|
-
export * from './utils/typeMapper';
|
|
7
|
-
//# sourceMappingURL=index.d.ts.map
|
|
1
|
+
export { Omnify, PluginManager, createOmnify, findReferencedSchemas, findReferencingSchemas, getEntitySchemas, getEnumSchemas, getGroups, getRelationshipGraph, getSchemaMetadata, getSchemaNames, getSchemasByGroup, getTopologicalOrder, hasCircularReferences, introspectSchema, introspectSchemas, loadSchemas, validateSchemas } from '@famgia/omnify-core';
|
|
2
|
+
export { AssociationDefinition, LoadedSchema, OmnifyConfig, OmnifyPlugin, PropertyDefinition, SchemaCollection, SchemaDefinition } from '@famgia/omnify-types';
|
|
3
|
+
export { MigrationFile, MigrationOptions, TypeScriptFile, TypeScriptOptions, generateEnums, generateInterfaces, generateMigrationFromSchema, generateMigrations, generateTypeScript, generateTypeScriptFile, schemaToBlueprint, schemaToInterface } from '@famgia/omnify-laravel';
|
|
4
|
+
export { AtlasDiffResult, ChangePreview, DiffResult, HclSchema, LockFile, compareSchemas, diffHclSchemas, generateHclSchema, generatePreview, parseDiffOutput, readLockFile, renderHcl, runAtlasDiff, writeLockFile } from '@famgia/omnify-atlas';
|