@famgia/omnify 1.0.123 → 1.0.125
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/ai-guides/schema-guide.md +95 -0
- package/package.json +9 -9
|
@@ -1083,6 +1083,101 @@ status:
|
|
|
1083
1083
|
default: draft # Default value from enum
|
|
1084
1084
|
```
|
|
1085
1085
|
|
|
1086
|
+
## Partial Schema (Schema Extensions)
|
|
1087
|
+
|
|
1088
|
+
Partial schemas allow packages to extend existing schemas with additional properties.
|
|
1089
|
+
This is useful when Laravel packages need to add fields to core models like User.
|
|
1090
|
+
|
|
1091
|
+
### Basic Structure
|
|
1092
|
+
|
|
1093
|
+
```yaml
|
|
1094
|
+
# schemas/billing/UserBilling.yaml
|
|
1095
|
+
kind: partial
|
|
1096
|
+
target: User # Which schema to extend
|
|
1097
|
+
|
|
1098
|
+
displayName:
|
|
1099
|
+
ja: ユーザー請求情報
|
|
1100
|
+
en: User Billing
|
|
1101
|
+
|
|
1102
|
+
properties:
|
|
1103
|
+
stripe_customer_id:
|
|
1104
|
+
type: String
|
|
1105
|
+
length: 255
|
|
1106
|
+
nullable: true
|
|
1107
|
+
displayName:
|
|
1108
|
+
ja: Stripe顧客ID
|
|
1109
|
+
en: Stripe Customer ID
|
|
1110
|
+
|
|
1111
|
+
subscription_status:
|
|
1112
|
+
type: String
|
|
1113
|
+
length: 50
|
|
1114
|
+
nullable: true
|
|
1115
|
+
displayName:
|
|
1116
|
+
ja: 購読状態
|
|
1117
|
+
en: Subscription Status
|
|
1118
|
+
```
|
|
1119
|
+
|
|
1120
|
+
### How It Works
|
|
1121
|
+
|
|
1122
|
+
1. **Merging**: Properties from partial schemas are merged into the target schema
|
|
1123
|
+
2. **Priority**: Target schema properties take priority (won't be overwritten)
|
|
1124
|
+
3. **Migrations**: New columns are added via ALTER TABLE migrations
|
|
1125
|
+
4. **Models**: TypeScript types and Laravel models include merged properties
|
|
1126
|
+
|
|
1127
|
+
### Rules for Partial Schemas
|
|
1128
|
+
|
|
1129
|
+
| Rule | Description |
|
|
1130
|
+
|------|-------------|
|
|
1131
|
+
| `kind: partial` | Required to mark as partial schema |
|
|
1132
|
+
| `target: SchemaName` | Required - specifies which schema to extend |
|
|
1133
|
+
| `properties` | Required - at least one property |
|
|
1134
|
+
| `options` | ❌ Not allowed (table options belong to target) |
|
|
1135
|
+
| `values` | ❌ Not allowed (that's for enums) |
|
|
1136
|
+
|
|
1137
|
+
### Use Cases
|
|
1138
|
+
|
|
1139
|
+
```yaml
|
|
1140
|
+
# Package: Billing
|
|
1141
|
+
kind: partial
|
|
1142
|
+
target: User
|
|
1143
|
+
properties:
|
|
1144
|
+
stripe_id: { type: String, nullable: true }
|
|
1145
|
+
plan: { type: String, nullable: true }
|
|
1146
|
+
|
|
1147
|
+
# Package: Notifications
|
|
1148
|
+
kind: partial
|
|
1149
|
+
target: User
|
|
1150
|
+
properties:
|
|
1151
|
+
notification_preferences: { type: Json, nullable: true }
|
|
1152
|
+
push_token: { type: String, nullable: true }
|
|
1153
|
+
|
|
1154
|
+
# Package: Social
|
|
1155
|
+
kind: partial
|
|
1156
|
+
target: User
|
|
1157
|
+
properties:
|
|
1158
|
+
avatar_url: { type: String, nullable: true }
|
|
1159
|
+
bio: { type: Text, nullable: true }
|
|
1160
|
+
```
|
|
1161
|
+
|
|
1162
|
+
### Package Schema Registration
|
|
1163
|
+
|
|
1164
|
+
Laravel packages can register their schema directories:
|
|
1165
|
+
|
|
1166
|
+
```php
|
|
1167
|
+
// In your package's ServiceProvider
|
|
1168
|
+
use App\Support\Omnify;
|
|
1169
|
+
|
|
1170
|
+
public function boot()
|
|
1171
|
+
{
|
|
1172
|
+
Omnify::addSchemaPath(__DIR__.'/../database/schemas');
|
|
1173
|
+
}
|
|
1174
|
+
```
|
|
1175
|
+
|
|
1176
|
+
Then run:
|
|
1177
|
+
```bash
|
|
1178
|
+
npx omnify generate
|
|
1179
|
+
```
|
|
1180
|
+
|
|
1086
1181
|
## MCP Tools
|
|
1087
1182
|
|
|
1088
1183
|
If Omnify MCP is configured, these tools are available:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@famgia/omnify",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.125",
|
|
4
4
|
"description": "Schema-driven database migration system with TypeScript types and Laravel migrations",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -26,14 +26,14 @@
|
|
|
26
26
|
"README.md"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@famgia/omnify-
|
|
30
|
-
"@famgia/omnify-
|
|
31
|
-
"@famgia/omnify-
|
|
32
|
-
"@famgia/omnify-
|
|
33
|
-
"@famgia/omnify-
|
|
34
|
-
"@famgia/omnify-
|
|
35
|
-
"@famgia/omnify-
|
|
36
|
-
"@famgia/omnify-
|
|
29
|
+
"@famgia/omnify-core": "0.0.115",
|
|
30
|
+
"@famgia/omnify-types": "0.0.113",
|
|
31
|
+
"@famgia/omnify-cli": "0.0.121",
|
|
32
|
+
"@famgia/omnify-atlas": "0.0.109",
|
|
33
|
+
"@famgia/omnify-typescript": "0.0.103",
|
|
34
|
+
"@famgia/omnify-mcp": "0.0.101",
|
|
35
|
+
"@famgia/omnify-japan": "0.0.108",
|
|
36
|
+
"@famgia/omnify-laravel": "0.0.124"
|
|
37
37
|
},
|
|
38
38
|
"keywords": [
|
|
39
39
|
"omnify",
|