@famgia/omnify-laravel 0.0.117 → 0.0.119
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/dist/{chunk-3YANFHE5.js → chunk-7I6UNXOD.js} +28 -6
- package/dist/{chunk-3YANFHE5.js.map → chunk-7I6UNXOD.js.map} +1 -1
- package/dist/index.cjs +27 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +1 -1
- package/dist/plugin.cjs +27 -5
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.js +1 -1
- package/package.json +4 -4
- package/stubs/ai-guides/claude-rules/laravel-controllers.md.stub +57 -0
- package/stubs/ai-guides/claude-rules/laravel-migrations.md.stub +47 -0
- package/stubs/ai-guides/claude-rules/laravel-tests.md.stub +52 -0
- package/stubs/ai-guides/claude-rules/naming.md.stub +5 -0
- package/stubs/ai-guides/claude-rules/performance.md.stub +5 -0
- package/stubs/ai-guides/claude-rules/react-components.md.stub +67 -0
- package/stubs/ai-guides/claude-rules/schema-yaml.md.stub +69 -0
- package/stubs/ai-guides/claude-rules/security.md.stub +5 -0
- package/stubs/ai-guides/cursor/laravel-controller.mdc.stub +2 -2
- package/stubs/ai-guides/cursor/laravel-request.mdc.stub +2 -2
- package/stubs/ai-guides/cursor/laravel-resource.mdc.stub +2 -2
- package/stubs/ai-guides/cursor/laravel-review.mdc.stub +1 -1
- package/stubs/ai-guides/cursor/laravel-testing.mdc.stub +2 -2
- package/stubs/ai-guides/cursor/laravel.mdc.stub +2 -2
- package/stubs/ai-guides/cursor/migrations-workflow.mdc.stub +1 -1
- package/stubs/ai-guides/cursor/omnify-migrations.mdc.stub +2 -2
- package/stubs/ai-guides/cursor/omnify.mdc.stub +2 -2
package/dist/plugin.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@famgia/omnify-laravel",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.119",
|
|
4
4
|
"description": "Laravel migration and TypeScript type generator for omnify-schema",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
"README.md"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@famgia/omnify-types": "0.0.
|
|
29
|
-
"@famgia/omnify-core": "0.0.
|
|
30
|
-
"@famgia/omnify-atlas": "0.0.
|
|
28
|
+
"@famgia/omnify-types": "0.0.108",
|
|
29
|
+
"@famgia/omnify-core": "0.0.110",
|
|
30
|
+
"@famgia/omnify-atlas": "0.0.104"
|
|
31
31
|
},
|
|
32
32
|
"scripts": {
|
|
33
33
|
"build": "tsup",
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
---
|
|
2
|
+
paths:
|
|
3
|
+
- "{{LARAVEL_ROOT}}app/Http/Controllers/**/*.php"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Laravel Controller Rules
|
|
7
|
+
|
|
8
|
+
## Thin Controller Pattern
|
|
9
|
+
|
|
10
|
+
Controllers should: Validate → Delegate → Respond
|
|
11
|
+
|
|
12
|
+
```php
|
|
13
|
+
public function store(StoreUserRequest $request): JsonResponse
|
|
14
|
+
{
|
|
15
|
+
// ✅ Validate (via FormRequest)
|
|
16
|
+
$data = $request->validated();
|
|
17
|
+
|
|
18
|
+
// ✅ Delegate (simple = Model, complex = Service)
|
|
19
|
+
$user = User::create($data);
|
|
20
|
+
|
|
21
|
+
// ✅ Respond (via Resource)
|
|
22
|
+
return new UserResource($user);
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## ⚠️ CRITICAL: OpenAPI Paths
|
|
27
|
+
|
|
28
|
+
**DO NOT add `/api` prefix!** The `api.php` route file already has it.
|
|
29
|
+
|
|
30
|
+
```php
|
|
31
|
+
// ❌ WRONG
|
|
32
|
+
#[OA\Get(path: '/api/users')]
|
|
33
|
+
|
|
34
|
+
// ✅ CORRECT
|
|
35
|
+
#[OA\Get(path: '/users')]
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Security Rules
|
|
39
|
+
|
|
40
|
+
- Always use `$request->validated()`, never `$request->all()`
|
|
41
|
+
- Use route model binding for single resources
|
|
42
|
+
- Use `authorize()` in FormRequest for authorization
|
|
43
|
+
|
|
44
|
+
## Query Patterns
|
|
45
|
+
|
|
46
|
+
```php
|
|
47
|
+
// ✅ List with pagination and eager loading
|
|
48
|
+
User::query()
|
|
49
|
+
->with(['posts', 'profile'])
|
|
50
|
+
->when($search, fn($q) => $q->where('name', 'like', "%{$search}%"))
|
|
51
|
+
->latest()
|
|
52
|
+
->paginate(15);
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Full Documentation
|
|
56
|
+
|
|
57
|
+
See @.claude/omnify/guides/laravel/controller.md for complete patterns.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
---
|
|
2
|
+
paths:
|
|
3
|
+
- "{{LARAVEL_ROOT}}database/migrations/**/*.php"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# ⛔ STOP: Migration Rules
|
|
7
|
+
|
|
8
|
+
## Auto-Generated Migrations (DO NOT EDIT)
|
|
9
|
+
|
|
10
|
+
Files in `database/migrations/omnify/` are **AUTO-GENERATED** by Omnify.
|
|
11
|
+
|
|
12
|
+
**ANY MANUAL CHANGES WILL BE OVERWRITTEN** on next `npx omnify generate`.
|
|
13
|
+
|
|
14
|
+
## ✅ Correct Workflow
|
|
15
|
+
|
|
16
|
+
### To add/modify columns:
|
|
17
|
+
|
|
18
|
+
1. Edit schema YAML in `schemas/`
|
|
19
|
+
2. Run `npx omnify generate`
|
|
20
|
+
3. Run `php artisan migrate`
|
|
21
|
+
|
|
22
|
+
### For custom migrations (outside Omnify):
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
php artisan make:migration add_custom_field_to_users_table
|
|
26
|
+
# Creates: database/migrations/2026_xx_xx_xxxxxx_add_custom_field_to_users_table.php
|
|
27
|
+
# This is SAFE - Omnify won't touch it
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## File Structure
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
database/migrations/
|
|
34
|
+
├── omnify/ ← ⛔ AUTO-GENERATED - DO NOT EDIT
|
|
35
|
+
│ ├── 2026_01_01_000000_create_users_table.php
|
|
36
|
+
│ └── ...
|
|
37
|
+
├── 2026_01_12_120000_add_custom_field.php ← ✅ Safe to edit
|
|
38
|
+
└── 2026_01_12_130000_custom_migration.php ← ✅ Safe to edit
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Quick Reference
|
|
42
|
+
|
|
43
|
+
| Want to... | Do this |
|
|
44
|
+
|------------|---------|
|
|
45
|
+
| Add column | Edit schema YAML → `npx omnify generate` |
|
|
46
|
+
| Modify column | Edit schema YAML → `npx omnify generate` |
|
|
47
|
+
| Custom migration | `php artisan make:migration` (outside omnify/) |
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
---
|
|
2
|
+
paths:
|
|
3
|
+
- "{{LARAVEL_ROOT}}tests/**/*.php"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Testing Rules (PEST)
|
|
7
|
+
|
|
8
|
+
## Test Naming Convention (Japanese Style)
|
|
9
|
+
|
|
10
|
+
```php
|
|
11
|
+
describe('UserController', function () {
|
|
12
|
+
// 正常系 (Happy Path)
|
|
13
|
+
describe('正常系', function () {
|
|
14
|
+
test('一覧が取得できる', function () { ... });
|
|
15
|
+
test('新規作成ができる', function () { ... });
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
// 異常系 (Error Cases)
|
|
19
|
+
describe('異常系', function () {
|
|
20
|
+
test('認証なしで401', function () { ... });
|
|
21
|
+
test('存在しないIDで404', function () { ... });
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Required Setup
|
|
27
|
+
|
|
28
|
+
```php
|
|
29
|
+
uses(RefreshDatabase::class);
|
|
30
|
+
|
|
31
|
+
beforeEach(function () {
|
|
32
|
+
$this->user = User::factory()->create();
|
|
33
|
+
$this->actingAs($this->user);
|
|
34
|
+
});
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Assertion Patterns
|
|
38
|
+
|
|
39
|
+
```php
|
|
40
|
+
// API Response
|
|
41
|
+
$response->assertStatus(200)
|
|
42
|
+
->assertJsonStructure(['data' => ['id', 'name']]);
|
|
43
|
+
|
|
44
|
+
// Database
|
|
45
|
+
$this->assertDatabaseHas('users', ['email' => 'test@example.com']);
|
|
46
|
+
$this->assertDatabaseMissing('users', ['id' => $user->id]);
|
|
47
|
+
$this->assertDatabaseCount('users', 3);
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Full Documentation
|
|
51
|
+
|
|
52
|
+
See @.claude/omnify/guides/laravel/testing.md for complete patterns.
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
---
|
|
2
|
+
paths:
|
|
3
|
+
- "{{TYPESCRIPT_BASE}}/**/*.tsx"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# React + Ant Design Rules
|
|
7
|
+
|
|
8
|
+
## Core Patterns
|
|
9
|
+
|
|
10
|
+
### Service Layer (API calls)
|
|
11
|
+
|
|
12
|
+
```typescript
|
|
13
|
+
// services/user.ts
|
|
14
|
+
export const userService = {
|
|
15
|
+
list: (params?: UserListParams) =>
|
|
16
|
+
api.get("/api/users", { params }).then(r => r.data),
|
|
17
|
+
create: (input: UserCreate) =>
|
|
18
|
+
api.post("/api/users", input).then(r => r.data.data),
|
|
19
|
+
};
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### TanStack Query
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
const { data, isLoading } = useQuery({
|
|
26
|
+
queryKey: queryKeys.users.list(filters),
|
|
27
|
+
queryFn: () => userService.list(filters),
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const mutation = useMutation({
|
|
31
|
+
mutationFn: userService.create,
|
|
32
|
+
onSuccess: () => {
|
|
33
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.users.all });
|
|
34
|
+
message.success(t("messages.created"));
|
|
35
|
+
},
|
|
36
|
+
onError: (error) => form.setFields(getFormErrors(error)),
|
|
37
|
+
});
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## ⚠️ Enum Usage (CRITICAL)
|
|
41
|
+
|
|
42
|
+
```typescript
|
|
43
|
+
// ✅ CORRECT - Import generated Enum
|
|
44
|
+
import { ApprovalStatus, ApprovalStatusValues } from "@/omnify/enum/ApprovalStatus";
|
|
45
|
+
|
|
46
|
+
// ✅ Use Enum values
|
|
47
|
+
if (status === ApprovalStatus.Pending) { ... }
|
|
48
|
+
|
|
49
|
+
// ❌ WRONG - Inline union types
|
|
50
|
+
newFilter.status = status as "pending" | "approved";
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Ant Design Static Method Warning
|
|
54
|
+
|
|
55
|
+
```typescript
|
|
56
|
+
// ❌ Wrong - No context
|
|
57
|
+
import { message } from "antd";
|
|
58
|
+
message.success("Done");
|
|
59
|
+
|
|
60
|
+
// ✅ Correct - Use App.useApp()
|
|
61
|
+
const { message } = App.useApp();
|
|
62
|
+
message.success("Done");
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Full Documentation
|
|
66
|
+
|
|
67
|
+
See @.claude/omnify/guides/react/ for complete patterns.
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
---
|
|
2
|
+
paths:
|
|
3
|
+
- "schemas/**/*.yaml"
|
|
4
|
+
- "schemas/**/*.yml"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Omnify Schema Rules
|
|
8
|
+
|
|
9
|
+
## Schema Workflow
|
|
10
|
+
|
|
11
|
+
1. Read @.claude/omnify/guides/omnify/schema-guide.md first
|
|
12
|
+
2. Create/edit YAML schema
|
|
13
|
+
3. Run `npx omnify generate`
|
|
14
|
+
4. Validate generated code
|
|
15
|
+
5. Run `php artisan migrate`
|
|
16
|
+
|
|
17
|
+
## Basic Template
|
|
18
|
+
|
|
19
|
+
```yaml
|
|
20
|
+
name: ModelName
|
|
21
|
+
kind: object
|
|
22
|
+
|
|
23
|
+
displayName:
|
|
24
|
+
ja: モデル名
|
|
25
|
+
en: Model Name
|
|
26
|
+
|
|
27
|
+
options:
|
|
28
|
+
timestamps: true
|
|
29
|
+
|
|
30
|
+
properties:
|
|
31
|
+
name:
|
|
32
|
+
type: String
|
|
33
|
+
length: 100
|
|
34
|
+
displayName:
|
|
35
|
+
ja: 名前
|
|
36
|
+
en: Name
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## ⚠️ CRITICAL: String Defaults
|
|
40
|
+
|
|
41
|
+
```yaml
|
|
42
|
+
# ❌ WRONG - produces curly quotes
|
|
43
|
+
default: "'cloud'"
|
|
44
|
+
|
|
45
|
+
# ✅ CORRECT - just the value
|
|
46
|
+
default: cloud
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Property Types
|
|
50
|
+
|
|
51
|
+
| Type | SQL | TypeScript |
|
|
52
|
+
|------|-----|------------|
|
|
53
|
+
| String | VARCHAR | string |
|
|
54
|
+
| Text | TEXT | string |
|
|
55
|
+
| Int | INT | number |
|
|
56
|
+
| Boolean | BOOLEAN | boolean |
|
|
57
|
+
| DateTime | DATETIME | string |
|
|
58
|
+
|
|
59
|
+
## Relationships
|
|
60
|
+
|
|
61
|
+
| Relation | Description |
|
|
62
|
+
|----------|-------------|
|
|
63
|
+
| belongsTo | Foreign key on THIS table |
|
|
64
|
+
| hasMany | Foreign key on OTHER table |
|
|
65
|
+
| belongsToMany | Pivot table |
|
|
66
|
+
|
|
67
|
+
## Full Documentation
|
|
68
|
+
|
|
69
|
+
See @.claude/omnify/guides/omnify/schema-guide.md for complete syntax.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: "
|
|
3
|
-
globs: ["{{LARAVEL_BASE}}/Http/Controllers
|
|
2
|
+
description: "Laravel controller patterns: thin controllers with query builder, OpenAPI documentation (NO /api prefix!), validation with $request->validated(), and proper Resource usage. Apply when creating or editing controllers."
|
|
3
|
+
globs: ["{{LARAVEL_BASE}}/app/Http/Controllers/**/*.php"]
|
|
4
4
|
alwaysApply: false
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: "FormRequest rules
|
|
3
|
-
globs: ["{{LARAVEL_BASE}}/Http/Requests
|
|
2
|
+
description: "Laravel FormRequest rules: OpenAPI schema MUST match schemaRules(), extend OmnifyBase for auto-generated validation, never use $request->all(). Apply when editing Request classes."
|
|
3
|
+
globs: ["{{LARAVEL_BASE}}/app/Http/Requests/**/*.php"]
|
|
4
4
|
alwaysApply: false
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: "Resource
|
|
3
|
-
globs: ["{{LARAVEL_BASE}}/Http/Resources
|
|
2
|
+
description: "Laravel API Resource rules: OpenAPI schema MUST match toArray() output, extend OmnifyBase for auto-generated fields, use whenLoaded() for relations. Apply when editing Resource classes."
|
|
3
|
+
globs: ["{{LARAVEL_BASE}}/app/Http/Resources/**/*.php"]
|
|
4
4
|
alwaysApply: false
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: "Code review checklist
|
|
2
|
+
description: "Code review checklist for Laravel: security ($request->validated, SQL injection), performance (eager loading, N+1), and quality standards. Mention @laravel-review in chat to invoke."
|
|
3
3
|
globs: []
|
|
4
4
|
alwaysApply: false
|
|
5
5
|
---
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: "PEST testing
|
|
3
|
-
globs: ["tests
|
|
2
|
+
description: "PEST testing guide: 正常系 (happy path) + 異常系 (error cases), Japanese naming conventions, RefreshDatabase trait, and factory usage. Apply when writing or reviewing tests."
|
|
3
|
+
globs: ["{{LARAVEL_BASE}}/tests/**/*.php"]
|
|
4
4
|
alwaysApply: false
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: "Laravel backend
|
|
3
|
-
globs: ["{{LARAVEL_BASE}}
|
|
2
|
+
description: "Laravel backend rules for Omnify projects: schema-first migrations, thin controllers, security patterns, and code generation. Apply when working with Laravel controllers, models, migrations, or API endpoints."
|
|
3
|
+
globs: ["{{LARAVEL_BASE}}/**/*.php"]
|
|
4
4
|
alwaysApply: false
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: "
|
|
2
|
+
description: "Schema-first workflow for database changes. NEVER use php artisan make:migration - always edit schemas/*.yaml and run npx omnify generate instead. This rule enforces the correct workflow when working with migrations."
|
|
3
3
|
globs: ["{{LARAVEL_BASE}}/database/migrations/**"]
|
|
4
4
|
alwaysApply: true
|
|
5
5
|
---
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: "
|
|
3
|
-
globs: ["{{LARAVEL_BASE}}/migrations/omnify/**"]
|
|
2
|
+
description: "STOP! These are auto-generated Omnify migrations. DO NOT EDIT these files - edit schemas/*.yaml instead and run npx omnify generate"
|
|
3
|
+
globs: ["{{LARAVEL_BASE}}/database/migrations/omnify/**"]
|
|
4
4
|
alwaysApply: true
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: "Omnify schema-driven code generation
|
|
3
|
-
globs: ["schemas/**/*.yaml", "omnify.config.ts"]
|
|
2
|
+
description: "Omnify schema-driven code generation: YAML schema syntax, configuration (omnify.config.ts), and generation workflow. Apply when editing schema files or config."
|
|
3
|
+
globs: ["schemas/**/*.yaml", "schemas/**/*.yml", "omnify.config.ts"]
|
|
4
4
|
alwaysApply: false
|
|
5
5
|
---
|
|
6
6
|
|