@famgia/omnify 1.0.127 → 1.0.132

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.
@@ -4,6 +4,76 @@
4
4
 
5
5
  All schemas are stored in `schemas/` directory with `.yaml` extension.
6
6
 
7
+ ## Registering Schemas from Laravel Packages
8
+
9
+ Laravel packages can register their own schemas to be included in code generation.
10
+
11
+ ### In Package's ServiceProvider
12
+
13
+ ```php
14
+ <?php
15
+
16
+ namespace YourPackage\Providers;
17
+
18
+ use App\Support\Omnify;
19
+ use Illuminate\Support\ServiceProvider;
20
+
21
+ class YourPackageServiceProvider extends ServiceProvider
22
+ {
23
+ public function boot(): void
24
+ {
25
+ // Register package schemas for Omnify CLI
26
+ if (class_exists(Omnify::class)) {
27
+ Omnify::registerSchemaPath(
28
+ path: __DIR__ . '/../../schemas', // Path to schema files
29
+ namespace: 'your-package' // Optional namespace
30
+ );
31
+ }
32
+ }
33
+ }
34
+ ```
35
+
36
+ ### Export Registered Paths
37
+
38
+ Before running `npx omnify generate`, export the registered paths:
39
+
40
+ ```bash
41
+ # Via Artisan command (if available)
42
+ php artisan omnify:sync
43
+
44
+ # Or via Tinker
45
+ php artisan tinker --execute="App\Support\Omnify::exportPaths()"
46
+ ```
47
+
48
+ This creates `storage/omnify/schema-paths.json` which the CLI reads to find package schemas.
49
+
50
+ ### Using Package Schemas in Your App
51
+
52
+ Once registered, package schemas can be:
53
+
54
+ 1. **Referenced in relations**: `type: PackageModel` works automatically
55
+ 2. **Extended via Partial**: Create partial schemas to add custom properties
56
+ 3. **Overridden**: Create same-named schema in main `schemas/` to override
57
+
58
+ ### Connecting to Unloaded Package Schemas
59
+
60
+ If a package's schema is not loaded but you need to reference it:
61
+
62
+ ```yaml
63
+ # Create a Partial schema stub
64
+ # schemas/stubs/User.yaml
65
+ name: User
66
+ kind: partial
67
+ target: User
68
+
69
+ # Minimal properties for relation connectivity
70
+ properties:
71
+ id:
72
+ type: BigInt
73
+ ```
74
+
75
+ Now other schemas can reference `User` in relationships.
76
+
7
77
  ## Multi-language Support (i18n)
8
78
 
9
79
  Omnify supports multi-language labels and placeholders for internationalized applications.
@@ -109,6 +179,90 @@ properties:
109
179
  # Property definitions here
110
180
  ```
111
181
 
182
+ ## Partial Schema (Extension Schema)
183
+
184
+ Partial schemas allow you to extend existing schemas or connect to external package schemas.
185
+
186
+ ### Use Cases
187
+
188
+ 1. **Extend package schema**: Add properties to a schema from external package
189
+ 2. **Connect to external schema**: Create relation target for schemas not in your project
190
+ 3. **Override properties**: Customize package schema with project-specific fields
191
+
192
+ ### Basic Partial Schema
193
+
194
+ ```yaml
195
+ # schemas/extensions/User.yaml
196
+ name: User
197
+ kind: partial
198
+ target: User # Target schema to extend (can be same as name)
199
+
200
+ displayName:
201
+ ja: ユーザー拡張
202
+ en: User Extension
203
+
204
+ properties:
205
+ # Add new properties to the target schema
206
+ profile_image_url:
207
+ type: String
208
+ nullable: true
209
+ displayName:
210
+ ja: プロフィール画像
211
+ en: Profile Image
212
+
213
+ department:
214
+ type: Department
215
+ relation: belongsTo
216
+ nullable: true
217
+ ```
218
+
219
+ ### Self-Referencing Partial (Connect to External Package)
220
+
221
+ When connecting to a schema from an external package that isn't loaded in your project:
222
+
223
+ ```yaml
224
+ # schemas/package/User.yaml
225
+ # Create a stub for external package's User schema
226
+ name: User
227
+ kind: partial
228
+ target: User # Same as name = standalone schema
229
+
230
+ displayName:
231
+ ja: ユーザー
232
+ en: User
233
+
234
+ # Minimal properties for relationship connections
235
+ properties:
236
+ email:
237
+ type: Email
238
+ displayName:
239
+ ja: メール
240
+ en: Email
241
+ ```
242
+
243
+ This creates a valid `User` schema that can be referenced by other schemas:
244
+
245
+ ```yaml
246
+ # schemas/blog/Post.yaml
247
+ name: Post
248
+ kind: object
249
+
250
+ properties:
251
+ author:
252
+ type: User # ✅ Now works! User exists as partial schema
253
+ relation: belongsTo
254
+ ```
255
+
256
+ ### Partial Schema Rules
257
+
258
+ | Rule | Description |
259
+ |------|-------------|
260
+ | `kind: partial` | Required to mark as partial schema |
261
+ | `target` | Schema to extend (required) |
262
+ | Same name = standalone | If `name === target`, treated as independent schema |
263
+ | Properties merge | Partial properties merged with target (target takes priority) |
264
+ | No duplicates | Cannot have multiple partials with same name |
265
+
112
266
  ### Schema Options Reference
113
267
 
114
268
  | Option | Type | Default | Description |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@famgia/omnify",
3
- "version": "1.0.127",
3
+ "version": "1.0.132",
4
4
  "description": "Schema-driven database migration system with TypeScript types and Laravel migrations",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -25,15 +25,24 @@
25
25
  "ai-guides",
26
26
  "README.md"
27
27
  ],
28
+ "scripts": {
29
+ "build": "tsup",
30
+ "clean": "rm -rf dist",
31
+ "test": "vitest run --passWithNoTests",
32
+ "test:watch": "vitest",
33
+ "lint": "eslint src",
34
+ "typecheck": "tsc --noEmit",
35
+ "postinstall": "node scripts/postinstall.js"
36
+ },
28
37
  "dependencies": {
29
- "@famgia/omnify-cli": "0.0.123",
30
- "@famgia/omnify-core": "0.0.117",
31
- "@famgia/omnify-types": "0.0.115",
32
- "@famgia/omnify-laravel": "0.0.126",
33
- "@famgia/omnify-atlas": "0.0.111",
34
- "@famgia/omnify-mcp": "0.0.103",
35
- "@famgia/omnify-typescript": "0.0.105",
36
- "@famgia/omnify-japan": "0.0.110"
38
+ "@famgia/omnify-cli": "workspace:*",
39
+ "@famgia/omnify-core": "workspace:*",
40
+ "@famgia/omnify-types": "workspace:*",
41
+ "@famgia/omnify-laravel": "workspace:*",
42
+ "@famgia/omnify-typescript": "workspace:*",
43
+ "@famgia/omnify-atlas": "workspace:*",
44
+ "@famgia/omnify-mcp": "workspace:*",
45
+ "@famgia/omnify-japan": "workspace:*"
37
46
  },
38
47
  "keywords": [
39
48
  "omnify",
@@ -48,14 +57,5 @@
48
57
  "claude"
49
58
  ],
50
59
  "author": "Famgia",
51
- "license": "MIT",
52
- "scripts": {
53
- "build": "tsup",
54
- "clean": "rm -rf dist",
55
- "test": "vitest run --passWithNoTests",
56
- "test:watch": "vitest",
57
- "lint": "eslint src",
58
- "typecheck": "tsc --noEmit",
59
- "postinstall": "node scripts/postinstall.js"
60
- }
61
- }
60
+ "license": "MIT"
61
+ }
@@ -4,6 +4,76 @@
4
4
 
5
5
  All schemas are stored in `schemas/` directory with `.yaml` extension.
6
6
 
7
+ ## Registering Schemas from Laravel Packages
8
+
9
+ Laravel packages can register their own schemas to be included in code generation.
10
+
11
+ ### In Package's ServiceProvider
12
+
13
+ ```php
14
+ <?php
15
+
16
+ namespace YourPackage\Providers;
17
+
18
+ use App\Support\Omnify;
19
+ use Illuminate\Support\ServiceProvider;
20
+
21
+ class YourPackageServiceProvider extends ServiceProvider
22
+ {
23
+ public function boot(): void
24
+ {
25
+ // Register package schemas for Omnify CLI
26
+ if (class_exists(Omnify::class)) {
27
+ Omnify::registerSchemaPath(
28
+ path: __DIR__ . '/../../schemas', // Path to schema files
29
+ namespace: 'your-package' // Optional namespace
30
+ );
31
+ }
32
+ }
33
+ }
34
+ ```
35
+
36
+ ### Export Registered Paths
37
+
38
+ Before running `npx omnify generate`, export the registered paths:
39
+
40
+ ```bash
41
+ # Via Artisan command (if available)
42
+ php artisan omnify:sync
43
+
44
+ # Or via Tinker
45
+ php artisan tinker --execute="App\Support\Omnify::exportPaths()"
46
+ ```
47
+
48
+ This creates `storage/omnify/schema-paths.json` which the CLI reads to find package schemas.
49
+
50
+ ### Using Package Schemas in Your App
51
+
52
+ Once registered, package schemas can be:
53
+
54
+ 1. **Referenced in relations**: `type: PackageModel` works automatically
55
+ 2. **Extended via Partial**: Create partial schemas to add custom properties
56
+ 3. **Overridden**: Create same-named schema in main `schemas/` to override
57
+
58
+ ### Connecting to Unloaded Package Schemas
59
+
60
+ If a package's schema is not loaded but you need to reference it:
61
+
62
+ ```yaml
63
+ # Create a Partial schema stub
64
+ # schemas/stubs/User.yaml
65
+ name: User
66
+ kind: partial
67
+ target: User
68
+
69
+ # Minimal properties for relation connectivity
70
+ properties:
71
+ id:
72
+ type: BigInt
73
+ ```
74
+
75
+ Now other schemas can reference `User` in relationships.
76
+
7
77
  ## Multi-language Support (i18n)
8
78
 
9
79
  Omnify supports multi-language labels and placeholders for internationalized applications.
@@ -109,6 +179,90 @@ properties:
109
179
  # Property definitions here
110
180
  ```
111
181
 
182
+ ## Partial Schema (Extension Schema)
183
+
184
+ Partial schemas allow you to extend existing schemas or connect to external package schemas.
185
+
186
+ ### Use Cases
187
+
188
+ 1. **Extend package schema**: Add properties to a schema from external package
189
+ 2. **Connect to external schema**: Create relation target for schemas not in your project
190
+ 3. **Override properties**: Customize package schema with project-specific fields
191
+
192
+ ### Basic Partial Schema
193
+
194
+ ```yaml
195
+ # schemas/extensions/User.yaml
196
+ name: User
197
+ kind: partial
198
+ target: User # Target schema to extend (can be same as name)
199
+
200
+ displayName:
201
+ ja: ユーザー拡張
202
+ en: User Extension
203
+
204
+ properties:
205
+ # Add new properties to the target schema
206
+ profile_image_url:
207
+ type: String
208
+ nullable: true
209
+ displayName:
210
+ ja: プロフィール画像
211
+ en: Profile Image
212
+
213
+ department:
214
+ type: Department
215
+ relation: belongsTo
216
+ nullable: true
217
+ ```
218
+
219
+ ### Self-Referencing Partial (Connect to External Package)
220
+
221
+ When connecting to a schema from an external package that isn't loaded in your project:
222
+
223
+ ```yaml
224
+ # schemas/package/User.yaml
225
+ # Create a stub for external package's User schema
226
+ name: User
227
+ kind: partial
228
+ target: User # Same as name = standalone schema
229
+
230
+ displayName:
231
+ ja: ユーザー
232
+ en: User
233
+
234
+ # Minimal properties for relationship connections
235
+ properties:
236
+ email:
237
+ type: Email
238
+ displayName:
239
+ ja: メール
240
+ en: Email
241
+ ```
242
+
243
+ This creates a valid `User` schema that can be referenced by other schemas:
244
+
245
+ ```yaml
246
+ # schemas/blog/Post.yaml
247
+ name: Post
248
+ kind: object
249
+
250
+ properties:
251
+ author:
252
+ type: User # ✅ Now works! User exists as partial schema
253
+ relation: belongsTo
254
+ ```
255
+
256
+ ### Partial Schema Rules
257
+
258
+ | Rule | Description |
259
+ |------|-------------|
260
+ | `kind: partial` | Required to mark as partial schema |
261
+ | `target` | Schema to extend (required) |
262
+ | Same name = standalone | If `name === target`, treated as independent schema |
263
+ | Properties merge | Partial properties merged with target (target takes priority) |
264
+ | No duplicates | Cannot have multiple partials with same name |
265
+
112
266
  ### Schema Options Reference
113
267
 
114
268
  | Option | Type | Default | Description |