@famgia/omnify-laravel 0.0.118 → 0.0.120

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 (36) hide show
  1. package/dist/{chunk-3YANFHE5.js → chunk-NMX3TLZT.js} +35 -6
  2. package/dist/{chunk-3YANFHE5.js.map → chunk-NMX3TLZT.js.map} +1 -1
  3. package/dist/index.cjs +34 -5
  4. package/dist/index.cjs.map +1 -1
  5. package/dist/index.d.cts +5 -0
  6. package/dist/index.d.ts +5 -0
  7. package/dist/index.js +1 -1
  8. package/dist/plugin.cjs +34 -5
  9. package/dist/plugin.cjs.map +1 -1
  10. package/dist/plugin.js +1 -1
  11. package/package.json +4 -4
  12. package/stubs/ai-guides/claude-checklists/react.md.stub +108 -0
  13. package/stubs/ai-guides/claude-rules/laravel-controllers.md.stub +57 -0
  14. package/stubs/ai-guides/claude-rules/laravel-migrations.md.stub +47 -0
  15. package/stubs/ai-guides/claude-rules/laravel-tests.md.stub +52 -0
  16. package/stubs/ai-guides/claude-rules/naming.md.stub +5 -0
  17. package/stubs/ai-guides/claude-rules/performance.md.stub +5 -0
  18. package/stubs/ai-guides/claude-rules/react-components.md.stub +67 -0
  19. package/stubs/ai-guides/claude-rules/schema-yaml.md.stub +69 -0
  20. package/stubs/ai-guides/claude-rules/security.md.stub +5 -0
  21. package/stubs/ai-guides/cursor/omnify-schema.mdc.stub +339 -0
  22. package/stubs/ai-guides/cursor/react-design.mdc.stub +693 -0
  23. package/stubs/ai-guides/cursor/react-form.mdc.stub +277 -0
  24. package/stubs/ai-guides/cursor/react-services.mdc.stub +304 -0
  25. package/stubs/ai-guides/cursor/react.mdc.stub +336 -0
  26. package/stubs/ai-guides/cursor/schema-create.mdc.stub +344 -0
  27. package/stubs/ai-guides/react/README.md.stub +221 -0
  28. package/stubs/ai-guides/react/antd-guide.md.stub +457 -0
  29. package/stubs/ai-guides/react/checklist.md.stub +108 -0
  30. package/stubs/ai-guides/react/datetime-guide.md.stub +137 -0
  31. package/stubs/ai-guides/react/design-philosophy.md.stub +363 -0
  32. package/stubs/ai-guides/react/i18n-guide.md.stub +211 -0
  33. package/stubs/ai-guides/react/laravel-integration.md.stub +181 -0
  34. package/stubs/ai-guides/react/service-pattern.md.stub +180 -0
  35. package/stubs/ai-guides/react/tanstack-query.md.stub +339 -0
  36. package/stubs/ai-guides/react/types-guide.md.stub +671 -0
@@ -0,0 +1,339 @@
1
+ ---
2
+ description: "Omnify schema YAML syntax and examples. Apply when creating or editing schema files in schemas/ folder. Covers property types, relationships, validations, and Japanese compound types."
3
+ globs: ["schemas/**/*.yaml", "schemas/**/*.yml", "{{LARAVEL_BASE}}/database/migrations/**"]
4
+ alwaysApply: false
5
+ ---
6
+
7
+ # Omnify Schema Creation Workflow
8
+
9
+ > **Usage:** This rule auto-applies when editing schema files, or mention `@omnify-schema` in chat
10
+
11
+ ## 📋 Workflow Steps
12
+
13
+ ```
14
+ ┌─────────────────────────────────────────────────────────────────┐
15
+ │ 1. READ GUIDE → Read schema guide documentation │
16
+ │ 2. CREATE SCHEMA → Create/modify YAML schema file │
17
+ │ 3. GENERATE → Run `npx omnify generate` │
18
+ │ 4. VALIDATE → Check generated code matches requirements │
19
+ │ 5. MIGRATE → Run database migration │
20
+ └─────────────────────────────────────────────────────────────────┘
21
+ ```
22
+
23
+ ---
24
+
25
+ ## Step 1: Read Schema Guide 📖
26
+
27
+ **MUST READ before creating schema:**
28
+
29
+ ```bash
30
+ # Read the schema guide
31
+ cat .claude/omnify/guides/omnify/schema-guide.md
32
+ # OR
33
+ cat packages/omnify/ai-guides/schema-guide.md
34
+ ```
35
+
36
+ **Key Documentation:**
37
+ - Schema syntax and property types
38
+ - Relationships (belongsTo, hasMany, etc.)
39
+ - Validation rules (nullable, minLength, maxLength)
40
+ - Display names (ja, en, vi)
41
+ - Special types (JapaneseName, JapaneseAddress, etc.)
42
+
43
+ ---
44
+
45
+ ## Step 2: Create Schema 📝
46
+
47
+ ### Schema File Location
48
+
49
+ ```
50
+ schemas/
51
+ ├── {domain}/ # Group by domain
52
+ │ ├── {Model}.yaml # PascalCase filename
53
+ │ └── {Enum}.yaml # Enum schemas
54
+ └── shared/ # Shared enums/types
55
+ ```
56
+
57
+ ### Basic Schema Template
58
+
59
+ ```yaml
60
+ # schemas/{domain}/{ModelName}.yaml
61
+ name: ModelName
62
+ kind: object
63
+
64
+ displayName:
65
+ ja: モデル名
66
+ en: Model Name
67
+
68
+ options:
69
+ timestamps: true # created_at, updated_at
70
+ softDelete: false # deleted_at
71
+
72
+ properties:
73
+ # Required field
74
+ name:
75
+ type: String
76
+ length: 100
77
+ displayName:
78
+ ja: 名前
79
+ en: Name
80
+ placeholder:
81
+ ja: 例:田中太郎
82
+ en: e.g. John Doe
83
+
84
+ # Optional field
85
+ description:
86
+ type: Text
87
+ nullable: true
88
+ displayName:
89
+ ja: 説明
90
+ en: Description
91
+
92
+ # Enum field
93
+ status:
94
+ type: OrderStatus
95
+ default: pending
96
+ displayName:
97
+ ja: ステータス
98
+ en: Status
99
+
100
+ # Relationship
101
+ category:
102
+ type: Category
103
+ relation: belongsTo
104
+ nullable: true
105
+ ```
106
+
107
+ ### From SQL/Database Requirements
108
+
109
+ When creating schema from SQL or database design:
110
+
111
+ ```yaml
112
+ # SQL: VARCHAR(255) NOT NULL
113
+ property_name:
114
+ type: String
115
+ length: 255
116
+
117
+ # SQL: VARCHAR(100) NULL
118
+ property_name:
119
+ type: String
120
+ length: 100
121
+ nullable: true
122
+
123
+ # SQL: TEXT
124
+ property_name:
125
+ type: Text
126
+
127
+ # SQL: INT / BIGINT
128
+ property_name:
129
+ type: Int # or BigInt
130
+
131
+ # SQL: DECIMAL(10,2)
132
+ property_name:
133
+ type: Float
134
+
135
+ # SQL: BOOLEAN DEFAULT false
136
+ property_name:
137
+ type: Boolean
138
+ default: false
139
+
140
+ # SQL: DATE
141
+ property_name:
142
+ type: Date
143
+
144
+ # SQL: DATETIME / TIMESTAMP
145
+ property_name:
146
+ type: DateTime
147
+
148
+ # SQL: ENUM('draft', 'published', 'archived')
149
+ # → Create separate enum schema
150
+ ```
151
+
152
+ ---
153
+
154
+ ## Step 3: Generate Code 🔧
155
+
156
+ ```bash
157
+ # Generate all code from schemas
158
+ npx omnify generate
159
+ ```
160
+
161
+ **What gets generated:**
162
+ - TypeScript types & Zod schemas
163
+ - Laravel migrations & models
164
+ - API resources & controllers
165
+ - Form requests & validation
166
+
167
+ ---
168
+
169
+ ## Step 4: Validate Generated Code ✅
170
+
171
+ ### ⚠️ CRITICAL for SQL-based schemas
172
+
173
+ **If creating schema from SQL requirements, MUST verify:**
174
+
175
+ ```bash
176
+ # 1. Check generated migration matches SQL design
177
+ cat database/migrations/*_create_{table_name}_table.php
178
+
179
+ # 2. Check TypeScript types match requirements
180
+ cat resources/ts/omnify/schemas/{ModelName}.ts
181
+
182
+ # 3. Check Laravel model relationships
183
+ cat app/Models/{ModelName}.php
184
+ ```
185
+
186
+ ### Validation Checklist
187
+
188
+ | Check | What to Verify |
189
+ |-------|----------------|
190
+ | ✅ Column names | snake_case in migration matches schema |
191
+ | ✅ Column types | VARCHAR, TEXT, INT match schema types |
192
+ | ✅ Nullable | NULL/NOT NULL matches `nullable: true/false` |
193
+ | ✅ Defaults | DEFAULT values match `default:` in schema |
194
+ | ✅ Foreign keys | Relationships generate correct FK |
195
+ | ✅ Indexes | Required indexes are present |
196
+
197
+ ### If Generated Code is Wrong
198
+
199
+ ```
200
+ ┌─────────────────────────────────────────┐
201
+ │ Generated code doesn't match SQL? │
202
+ │ │
203
+ │ 1. Fix the YAML schema │
204
+ │ 2. Run `npx omnify generate` again │
205
+ │ 3. Verify generated code │
206
+ │ 4. Repeat until correct │
207
+ └─────────────────────────────────────────┘
208
+ ```
209
+
210
+ **Common fixes:**
211
+
212
+ ```yaml
213
+ # Problem: Column should be nullable
214
+ # Fix: Add nullable: true
215
+ property_name:
216
+ type: String
217
+ nullable: true # ← Add this
218
+
219
+ # Problem: Wrong column length
220
+ # Fix: Adjust length
221
+ property_name:
222
+ type: String
223
+ length: 255 # ← Change this
224
+
225
+ # Problem: Missing default value
226
+ # Fix: Add default
227
+ status:
228
+ type: OrderStatus
229
+ default: pending # ← Add this
230
+
231
+ # Problem: Wrong relationship type
232
+ # Fix: Change relation
233
+ category:
234
+ type: Category
235
+ relation: belongsTo # belongsTo, hasMany, hasOne, belongsToMany
236
+ ```
237
+
238
+ ---
239
+
240
+ ## Step 5: Run Migration 🗄️
241
+
242
+ ```bash
243
+ # Run migration
244
+ php artisan migrate
245
+
246
+ # If migration fails, rollback and fix
247
+ php artisan migrate:rollback
248
+ # Fix schema, regenerate, try again
249
+ ```
250
+
251
+ ---
252
+
253
+ ## 🔄 Complete Workflow Example
254
+
255
+ ```bash
256
+ # 1. Read guide
257
+ cat .claude/omnify/guides/omnify/schema-guide.md
258
+
259
+ # 2. Create schema file
260
+ # schemas/shop/Product.yaml
261
+
262
+ # 3. Generate code
263
+ npx omnify generate
264
+
265
+ # 4. Validate (especially for SQL-based requirements)
266
+ cat database/migrations/*_create_products_table.php
267
+ # If wrong: fix schema → regenerate → validate again
268
+
269
+ # 5. Run migration
270
+ php artisan migrate
271
+ ```
272
+
273
+ ---
274
+
275
+ ## 📌 Quick Reference
276
+
277
+ ### Property Types
278
+
279
+ | Type | SQL | TypeScript |
280
+ |------|-----|------------|
281
+ | `String` | VARCHAR | `string` |
282
+ | `Text` | TEXT | `string` |
283
+ | `LongText` | LONGTEXT | `string` |
284
+ | `Int` | INT | `number` |
285
+ | `BigInt` | BIGINT | `number` |
286
+ | `Float` | DECIMAL | `number` |
287
+ | `Boolean` | BOOLEAN | `boolean` |
288
+ | `Date` | DATE | `string` |
289
+ | `DateTime` | DATETIME | `string` |
290
+ | `Email` | VARCHAR | `string` |
291
+ | `Url` | VARCHAR | `string` |
292
+ | `Json` | JSON | `Record<string, unknown>` |
293
+
294
+ ### Japanese Compound Types
295
+
296
+ | Type | Fields Generated |
297
+ |------|------------------|
298
+ | `JapaneseName` | `{prefix}_lastname`, `{prefix}_firstname`, `{prefix}_kana_lastname`, `{prefix}_kana_firstname` |
299
+ | `JapaneseAddress` | `{prefix}_postal_code`, `{prefix}_prefecture`, `{prefix}_address1`, `{prefix}_address2`, `{prefix}_address3` |
300
+ | `JapaneseBankAccount` | `{prefix}_bank_code`, `{prefix}_bank_name`, `{prefix}_branch_code`, etc. |
301
+
302
+ ### Relationship Types
303
+
304
+ | Relation | Description | Foreign Key |
305
+ |----------|-------------|-------------|
306
+ | `belongsTo` | N:1 | `{property}_id` on this table |
307
+ | `hasMany` | 1:N | `{this_model}_id` on related table |
308
+ | `hasOne` | 1:1 | `{this_model}_id` on related table |
309
+ | `belongsToMany` | N:N | Pivot table |
310
+
311
+ ---
312
+
313
+ ## ⚠️ Common Mistakes
314
+
315
+ ```yaml
316
+ # ❌ Wrong: camelCase property name (use camelCase, converts to snake_case)
317
+ firstName: # ✅ Correct - will become first_name in DB
318
+
319
+ # ❌ Wrong: Missing displayName for non-English projects
320
+ name:
321
+ type: String
322
+ # Missing displayName!
323
+
324
+ # ✅ Correct: Always add displayName
325
+ name:
326
+ type: String
327
+ displayName:
328
+ ja: 名前
329
+ en: Name
330
+
331
+ # ❌ Wrong: Hardcoded enum values in property
332
+ status:
333
+ type: String
334
+ enum: [draft, published] # Don't do this
335
+
336
+ # ✅ Correct: Create separate enum schema
337
+ status:
338
+ type: PostStatus # Reference enum schema
339
+ ```