@famgia/omnify-laravel 0.0.118 → 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/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.
|