@famgia/omnify-laravel 0.0.87 → 0.0.89

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/dist/{chunk-YVVAJA3T.js → chunk-V7LWJ6OM.js} +178 -12
  2. package/dist/chunk-V7LWJ6OM.js.map +1 -0
  3. package/dist/index.cjs +180 -11
  4. package/dist/index.cjs.map +1 -1
  5. package/dist/index.d.cts +48 -1
  6. package/dist/index.d.ts +48 -1
  7. package/dist/index.js +5 -1
  8. package/dist/plugin.cjs +176 -11
  9. package/dist/plugin.cjs.map +1 -1
  10. package/dist/plugin.js +1 -1
  11. package/package.json +5 -5
  12. package/scripts/postinstall.js +29 -36
  13. package/stubs/ai-guides/claude-agents/architect.md.stub +150 -0
  14. package/stubs/ai-guides/claude-agents/developer.md.stub +190 -0
  15. package/stubs/ai-guides/claude-agents/reviewer.md.stub +134 -0
  16. package/stubs/ai-guides/claude-agents/tester.md.stub +196 -0
  17. package/stubs/ai-guides/claude-checklists/backend.md.stub +112 -0
  18. package/stubs/ai-guides/claude-omnify/antdesign-guide.md.stub +401 -0
  19. package/stubs/ai-guides/claude-omnify/config-guide.md.stub +253 -0
  20. package/stubs/ai-guides/claude-omnify/japan-guide.md.stub +186 -0
  21. package/stubs/ai-guides/claude-omnify/laravel-guide.md.stub +61 -0
  22. package/stubs/ai-guides/claude-omnify/schema-guide.md.stub +115 -0
  23. package/stubs/ai-guides/claude-omnify/typescript-guide.md.stub +310 -0
  24. package/stubs/ai-guides/claude-rules/naming.md.stub +364 -0
  25. package/stubs/ai-guides/claude-rules/performance.md.stub +251 -0
  26. package/stubs/ai-guides/claude-rules/security.md.stub +159 -0
  27. package/stubs/ai-guides/claude-workflows/bug-fix.md.stub +201 -0
  28. package/stubs/ai-guides/claude-workflows/code-review.md.stub +164 -0
  29. package/stubs/ai-guides/claude-workflows/new-feature.md.stub +327 -0
  30. package/stubs/ai-guides/cursor/laravel-controller.mdc.stub +391 -0
  31. package/stubs/ai-guides/cursor/laravel-request.mdc.stub +112 -0
  32. package/stubs/ai-guides/cursor/laravel-resource.mdc.stub +73 -0
  33. package/stubs/ai-guides/cursor/laravel-review.mdc.stub +69 -0
  34. package/stubs/ai-guides/cursor/laravel-testing.mdc.stub +138 -0
  35. package/stubs/ai-guides/cursor/laravel.mdc.stub +82 -0
  36. package/stubs/ai-guides/laravel/README.md.stub +59 -0
  37. package/stubs/ai-guides/laravel/architecture.md.stub +424 -0
  38. package/stubs/ai-guides/laravel/controller.md.stub +484 -0
  39. package/stubs/ai-guides/laravel/datetime.md.stub +334 -0
  40. package/stubs/ai-guides/laravel/openapi.md.stub +369 -0
  41. package/stubs/ai-guides/laravel/request.md.stub +450 -0
  42. package/stubs/ai-guides/laravel/resource.md.stub +516 -0
  43. package/stubs/ai-guides/laravel/service.md.stub +503 -0
  44. package/stubs/ai-guides/laravel/testing.md.stub +1504 -0
  45. package/ai-guides/laravel-guide.md +0 -461
  46. package/dist/chunk-YVVAJA3T.js.map +0 -1
@@ -1,461 +0,0 @@
1
- # Omnify Laravel Generator Guide
2
-
3
- This guide covers Laravel-specific features and generated code patterns for Omnify.
4
-
5
- ## Quick Start
6
-
7
- ```bash
8
- # Create new Laravel project (recommended)
9
- npx @famgia/omnify create-laravel-project my-app
10
- cd my-app
11
-
12
- # Or initialize in existing project
13
- npx @famgia/omnify init
14
-
15
- # Generate Laravel migrations and models
16
- npx @famgia/omnify generate
17
- ```
18
-
19
- ## Generated Files
20
-
21
- When you run `npx @famgia/omnify generate`, the following Laravel files are generated:
22
-
23
- ### Migrations
24
- - `database/migrations/omnify/*.php` - Laravel migrations for each schema
25
-
26
- ### Models
27
- - `app/Models/OmnifyBase/{ModelName}BaseModel.php` - Generated base models (DO NOT EDIT)
28
- - `app/Models/{ModelName}.php` - Extendable model classes (safe to customize)
29
-
30
- ### Traits
31
- - `app/Models/OmnifyBase/Traits/HasLocalizedDisplayName.php` - Localization trait
32
-
33
- ### Locales
34
- - `app/Models/OmnifyBase/Locales/{ModelName}Locales.php` - i18n display names
35
-
36
- ### Service Provider
37
- - `app/Providers/OmnifyServiceProvider.php` - Morph map registration (configurable path)
38
-
39
- ## Model Structure
40
-
41
- ```php
42
- // app/Models/User.php (YOUR customizations go here)
43
- <?php
44
- namespace App\Models;
45
-
46
- use App\Models\OmnifyBase\UserBaseModel;
47
-
48
- class User extends UserBaseModel
49
- {
50
- // Add your custom methods, scopes, accessors, etc.
51
- }
52
- ```
53
-
54
- ```php
55
- // app/Models/OmnifyBase/UserBaseModel.php (DO NOT EDIT - auto-generated)
56
- <?php
57
- namespace App\Models\OmnifyBase;
58
-
59
- use App\Models\OmnifyBase\Traits\HasLocalizedDisplayName;
60
- use App\Models\OmnifyBase\Locales\UserLocales;
61
-
62
- class UserBaseModel extends Model
63
- {
64
- use HasLocalizedDisplayName;
65
-
66
- protected static array $localizedDisplayNames = UserLocales::DISPLAY_NAMES;
67
- protected static array $localizedPropertyDisplayNames = UserLocales::PROPERTY_DISPLAY_NAMES;
68
-
69
- protected $fillable = ['name', 'email', 'password'];
70
- protected $casts = [...];
71
-
72
- // Relations defined here
73
- }
74
- ```
75
-
76
- ## Schema Options
77
-
78
- ### Hidden Schemas (System Tables)
79
-
80
- For system tables that only need migrations (no models), use `hidden: true`:
81
-
82
- ```yaml
83
- # schemas/system/Cache.yaml
84
- name: AppCache
85
- options:
86
- id: false
87
- timestamps: false
88
- hidden: true # Skip model generation
89
- tableName: cache # Use Laravel's default cache table name
90
- properties:
91
- key:
92
- type: String
93
- primary: true
94
- value:
95
- type: MediumText
96
- expiration:
97
- type: Int
98
- ```
99
-
100
- Use cases for `hidden: true`:
101
- - Laravel cache tables (`cache`, `cache_locks`)
102
- - Job queues (`jobs`, `failed_jobs`)
103
- - Session tables
104
- - System tables that don't need application models
105
-
106
- ### Custom Table Name
107
-
108
- Override the auto-generated table name:
109
-
110
- ```yaml
111
- name: AppCache
112
- options:
113
- tableName: cache # Use 'cache' instead of 'app_caches'
114
- ```
115
-
116
- ### Soft Delete
117
-
118
- ```yaml
119
- options:
120
- softDelete: true # Adds deleted_at column and SoftDeletes trait
121
- ```
122
-
123
- ### Timestamps
124
-
125
- ```yaml
126
- options:
127
- timestamps: true # Adds created_at, updated_at columns (default: true)
128
- ```
129
-
130
- ### Custom ID Type
131
-
132
- ```yaml
133
- options:
134
- idType: Uuid # BigInt (default), Int, Uuid, String
135
- ```
136
-
137
- ### No Auto ID
138
-
139
- ```yaml
140
- options:
141
- id: false # For tables with custom primary key
142
- ```
143
-
144
- ## Property Types
145
-
146
- ### String Types
147
-
148
- | Type | Description | MySQL Column |
149
- |------|-------------|--------------|
150
- | `String` | Short text (default 255) | `VARCHAR(length)` |
151
- | `Text` | Text (~65KB) | `TEXT` |
152
- | `MediumText` | Medium text (~16MB) | `MEDIUMTEXT` |
153
- | `LongText` | Long text (~4GB) | `LONGTEXT` |
154
-
155
- ### Numeric Types
156
-
157
- | Type | Description | MySQL Column |
158
- |------|-------------|--------------|
159
- | `TinyInt` | 8-bit (-128~127) | `TINYINT` |
160
- | `Int` | 32-bit integer | `INT` |
161
- | `BigInt` | 64-bit integer | `BIGINT` |
162
- | `Float` | Floating point | `FLOAT` |
163
- | `Decimal` | Precise decimal | `DECIMAL(p,s)` |
164
-
165
- ### Date/Time Types
166
-
167
- | Type | Description | MySQL Column |
168
- |------|-------------|--------------|
169
- | `Date` | Date only | `DATE` |
170
- | `DateTime` | Date and time | `DATETIME` |
171
- | `Timestamp` | Timestamp | `TIMESTAMP` |
172
-
173
- ### Timestamp with useCurrent
174
-
175
- ```yaml
176
- properties:
177
- created_at:
178
- type: Timestamp
179
- useCurrent: true # Default to CURRENT_TIMESTAMP
180
- updated_at:
181
- type: Timestamp
182
- useCurrent: true
183
- useCurrentOnUpdate: true # Auto-update on row change
184
- ```
185
-
186
- Generated migration:
187
- ```php
188
- $table->timestamp('created_at')->useCurrent();
189
- $table->timestamp('updated_at')->useCurrent()->useCurrentOnUpdate();
190
- ```
191
-
192
- ## Localization (i18n)
193
-
194
- ### Display Names
195
- ```php
196
- // Get localized model name
197
- User::getLocalizedDisplayName(); // Returns based on app()->getLocale()
198
-
199
- // Get localized property name
200
- User::getLocalizedPropertyDisplayName('email');
201
- ```
202
-
203
- ### Schema Definition
204
- ```yaml
205
- name: User
206
- displayName:
207
- ja: ユーザー
208
- en: User
209
- properties:
210
- email:
211
- type: String
212
- displayName:
213
- ja: メールアドレス
214
- en: Email Address
215
- ```
216
-
217
- ## Relationships
218
-
219
- ### ManyToOne (BelongsTo)
220
- ```yaml
221
- # In Post schema
222
- author:
223
- type: Association
224
- relation: ManyToOne
225
- target: User
226
- onDelete: CASCADE
227
- ```
228
-
229
- Generated:
230
- ```php
231
- public function author(): BelongsTo
232
- {
233
- return $this->belongsTo(User::class);
234
- }
235
- ```
236
-
237
- ### OneToMany (HasMany)
238
- ```yaml
239
- # In User schema
240
- posts:
241
- type: Association
242
- relation: OneToMany
243
- target: Post
244
- mappedBy: author
245
- ```
246
-
247
- Generated:
248
- ```php
249
- public function posts(): HasMany
250
- {
251
- return $this->hasMany(Post::class, 'author_id');
252
- }
253
- ```
254
-
255
- ### ManyToMany (BelongsToMany)
256
- ```yaml
257
- tags:
258
- type: Association
259
- relation: ManyToMany
260
- target: Tag
261
- pivotTable: post_tags
262
- pivotFields:
263
- - name: order
264
- type: Int
265
- default: 0
266
- ```
267
-
268
- Generated:
269
- ```php
270
- public function tags(): BelongsToMany
271
- {
272
- return $this->belongsToMany(Tag::class, 'post_tags')
273
- ->withPivot(['order']);
274
- }
275
- ```
276
-
277
- ### MorphTo (Polymorphic)
278
- ```yaml
279
- # Comment can belong to Post or Video
280
- commentable:
281
- type: Association
282
- relation: MorphTo
283
- targets: [Post, Video]
284
- nullable: true # Default: true
285
- ```
286
-
287
- Generated columns:
288
- - `commentable_type` (enum: 'Post', 'Video')
289
- - `commentable_id` (bigint, nullable)
290
-
291
- ## Enum Support
292
-
293
- ```yaml
294
- # schemas/PostStatus.yaml
295
- name: PostStatus
296
- kind: enum
297
- values:
298
- draft: 下書き
299
- published: 公開済み
300
- archived: アーカイブ
301
- ```
302
-
303
- Usage in schema:
304
- ```yaml
305
- status:
306
- type: EnumRef
307
- enum: PostStatus
308
- default: draft
309
- ```
310
-
311
- Generated migration:
312
- ```php
313
- $table->enum('status', ['draft', 'published', 'archived'])->default('draft');
314
- ```
315
-
316
- ## Configuration
317
-
318
- ```typescript
319
- // omnify.config.ts
320
- import { defineConfig } from '@famgia/omnify';
321
- import laravel from '@famgia/omnify-laravel/plugin';
322
-
323
- export default defineConfig({
324
- schemasDir: './schemas',
325
- lockFilePath: './.omnify.lock',
326
-
327
- database: {
328
- driver: 'mysql',
329
- devUrl: 'mysql://root:password@localhost:3306/dev_db',
330
- },
331
-
332
- plugins: [
333
- laravel({
334
- // Migration output path
335
- migrationsPath: 'database/migrations/omnify',
336
-
337
- // Model output paths
338
- modelsPath: 'app/Models',
339
- baseModelsPath: 'app/Models/OmnifyBase',
340
-
341
- // Service provider path (for morph map)
342
- providersPath: 'app/Providers',
343
-
344
- // Locales path
345
- localesPath: 'app/Models/OmnifyBase/Locales',
346
- }),
347
- ],
348
- });
349
- ```
350
-
351
- ### Configuration Options
352
-
353
- | Option | Type | Default | Description |
354
- |--------|------|---------|-------------|
355
- | `migrationsPath` | `string` | `database/migrations/omnify` | Laravel migrations output |
356
- | `modelsPath` | `string` | `app/Models` | Model classes output |
357
- | `baseModelsPath` | `string` | `app/Models/OmnifyBase` | Base model classes output |
358
- | `providersPath` | `string` | `app/Providers` | Service provider output |
359
- | `localesPath` | `string` | `app/Models/OmnifyBase/Locales` | Locale files output |
360
-
361
- ## Commands
362
-
363
- ```bash
364
- # Create new Laravel project
365
- npx @famgia/omnify create-laravel-project my-app
366
-
367
- # Generate Laravel migrations and models
368
- npx @famgia/omnify generate
369
-
370
- # Force regenerate all files
371
- npx @famgia/omnify generate --force
372
-
373
- # Only generate migrations
374
- npx @famgia/omnify generate --migrations-only
375
-
376
- # Validate schemas
377
- npx @famgia/omnify validate
378
-
379
- # Show pending changes
380
- npx @famgia/omnify diff
381
-
382
- # Reset all generated files
383
- npx @famgia/omnify reset
384
- ```
385
-
386
- ## Examples
387
-
388
- ### System Table (Cache)
389
-
390
- ```yaml
391
- # schemas/system/AppCache.yaml
392
- name: AppCache
393
- options:
394
- id: false
395
- timestamps: false
396
- hidden: true
397
- tableName: cache
398
- properties:
399
- key:
400
- type: String
401
- length: 255
402
- primary: true
403
- value:
404
- type: MediumText
405
- expiration:
406
- type: Int
407
- ```
408
-
409
- ### User with Authenticatable
410
-
411
- ```yaml
412
- # schemas/User.yaml
413
- name: User
414
- displayName:
415
- ja: ユーザー
416
- en: User
417
- options:
418
- softDelete: true
419
- authenticatable: true
420
- properties:
421
- name:
422
- type: String
423
- displayName:
424
- ja: 氏名
425
- en: Full Name
426
- email:
427
- type: Email
428
- unique: true
429
- password:
430
- type: Password
431
- ```
432
-
433
- ### Post with Relations
434
-
435
- ```yaml
436
- # schemas/Post.yaml
437
- name: Post
438
- displayName:
439
- ja: 投稿
440
- en: Post
441
- options:
442
- softDelete: true
443
- properties:
444
- title:
445
- type: String
446
- content:
447
- type: LongText
448
- status:
449
- type: EnumRef
450
- enum: PostStatus
451
- default: draft
452
- author:
453
- type: Association
454
- relation: ManyToOne
455
- target: User
456
- onDelete: CASCADE
457
- tags:
458
- type: Association
459
- relation: ManyToMany
460
- target: Tag
461
- ```