@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.
- package/dist/{chunk-3YANFHE5.js → chunk-NMX3TLZT.js} +35 -6
- package/dist/{chunk-3YANFHE5.js.map → chunk-NMX3TLZT.js.map} +1 -1
- package/dist/index.cjs +34 -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 +34 -5
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.js +1 -1
- package/package.json +4 -4
- package/stubs/ai-guides/claude-checklists/react.md.stub +108 -0
- 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/omnify-schema.mdc.stub +339 -0
- package/stubs/ai-guides/cursor/react-design.mdc.stub +693 -0
- package/stubs/ai-guides/cursor/react-form.mdc.stub +277 -0
- package/stubs/ai-guides/cursor/react-services.mdc.stub +304 -0
- package/stubs/ai-guides/cursor/react.mdc.stub +336 -0
- package/stubs/ai-guides/cursor/schema-create.mdc.stub +344 -0
- package/stubs/ai-guides/react/README.md.stub +221 -0
- package/stubs/ai-guides/react/antd-guide.md.stub +457 -0
- package/stubs/ai-guides/react/checklist.md.stub +108 -0
- package/stubs/ai-guides/react/datetime-guide.md.stub +137 -0
- package/stubs/ai-guides/react/design-philosophy.md.stub +363 -0
- package/stubs/ai-guides/react/i18n-guide.md.stub +211 -0
- package/stubs/ai-guides/react/laravel-integration.md.stub +181 -0
- package/stubs/ai-guides/react/service-pattern.md.stub +180 -0
- package/stubs/ai-guides/react/tanstack-query.md.stub +339 -0
- package/stubs/ai-guides/react/types-guide.md.stub +671 -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.120",
|
|
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.109",
|
|
29
|
+
"@famgia/omnify-core": "0.0.111",
|
|
30
|
+
"@famgia/omnify-atlas": "0.0.105"
|
|
31
31
|
},
|
|
32
32
|
"scripts": {
|
|
33
33
|
"build": "tsup",
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# Checklists
|
|
2
|
+
|
|
3
|
+
> **Related:** [README](./README.md)
|
|
4
|
+
|
|
5
|
+
## After Writing Code
|
|
6
|
+
|
|
7
|
+
> **IMPORTANT**: Always run these commands after writing/modifying code:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
# 1. Type check
|
|
11
|
+
npm run typecheck
|
|
12
|
+
|
|
13
|
+
# 2. Lint check
|
|
14
|
+
npm run lint
|
|
15
|
+
|
|
16
|
+
# Or combined
|
|
17
|
+
npm run typecheck && npm run lint
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Adding New Resource
|
|
23
|
+
|
|
24
|
+
When adding a new resource (e.g., `posts`), follow these steps:
|
|
25
|
+
|
|
26
|
+
### 1. Service Layer (Always in `services/`)
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
# Create: services/posts.ts
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
- [ ] Import types: `import type { Post, PostCreate, PostUpdate } from "@/types/model"`
|
|
33
|
+
- [ ] Define only `PostListParams` (Create/Update come from Omnify)
|
|
34
|
+
- [ ] Create `postService` object with CRUD methods
|
|
35
|
+
- [ ] Add JSDoc comments for each method
|
|
36
|
+
|
|
37
|
+
### 2. Query Keys
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
# Update: lib/queryKeys.ts
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
- [ ] Add `posts` object to `queryKeys`
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
posts: {
|
|
47
|
+
all: ["posts"] as const,
|
|
48
|
+
lists: () => [...queryKeys.posts.all, "list"] as const,
|
|
49
|
+
list: (params?: PostListParams) => [...queryKeys.posts.lists(), params] as const,
|
|
50
|
+
details: () => [...queryKeys.posts.all, "detail"] as const,
|
|
51
|
+
detail: (id: number) => [...queryKeys.posts.details(), id] as const,
|
|
52
|
+
},
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### 3. Feature Components (in `features/posts/`)
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
# Create: features/posts/
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
- [ ] `PostTable.tsx` - Table component
|
|
62
|
+
- [ ] `PostForm.tsx` - Form component
|
|
63
|
+
- [ ] `usePostFilters.ts` - Feature-specific hooks (if needed)
|
|
64
|
+
|
|
65
|
+
### 4. Pages
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
# Create pages in app/(dashboard)/posts/
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
- [ ] `page.tsx` - List page (imports from `features/posts/`)
|
|
72
|
+
- [ ] `new/page.tsx` - Create form
|
|
73
|
+
- [ ] `[id]/page.tsx` - Detail view
|
|
74
|
+
- [ ] `[id]/edit/page.tsx` - Edit form
|
|
75
|
+
|
|
76
|
+
### 5. Shared Components (only if reused)
|
|
77
|
+
|
|
78
|
+
- [ ] If component used in 2+ features → move to `components/common/`
|
|
79
|
+
|
|
80
|
+
### 6. Translations
|
|
81
|
+
|
|
82
|
+
- [ ] Add labels to `src/i18n/messages/*.json` if needed
|
|
83
|
+
|
|
84
|
+
### 7. Final Check
|
|
85
|
+
|
|
86
|
+
- [ ] Run `npm run typecheck && npm run lint`
|
|
87
|
+
- [ ] Test create, read, update, delete operations
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## Adding New Language
|
|
92
|
+
|
|
93
|
+
- [ ] Create message file: `src/i18n/messages/{locale}.json`
|
|
94
|
+
- [ ] Add locale to `src/i18n/config.ts`
|
|
95
|
+
- [ ] Import Ant Design locale in `src/components/AntdThemeProvider.tsx`
|
|
96
|
+
- [ ] Test with `LocaleSwitcher` component
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## Before Commit
|
|
101
|
+
|
|
102
|
+
- [ ] `npm run typecheck` passes
|
|
103
|
+
- [ ] `npm run lint` passes
|
|
104
|
+
- [ ] No console warnings about deprecated props
|
|
105
|
+
- [ ] No hardcoded strings (use i18n)
|
|
106
|
+
- [ ] Forms handle loading state (`isPending`)
|
|
107
|
+
- [ ] Forms handle validation errors (`getFormErrors`)
|
|
108
|
+
- [ ] Mutations invalidate related queries
|
|
@@ -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.
|