@omnifyjp/omnify 5.8.10 → 5.8.12
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@omnifyjp/omnify",
|
|
3
|
-
"version": "5.8.
|
|
3
|
+
"version": "5.8.12",
|
|
4
4
|
"description": "Schema-driven code generation for Laravel, TypeScript, and SQL",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -36,10 +36,10 @@
|
|
|
36
36
|
"zod": "^3.24.0"
|
|
37
37
|
},
|
|
38
38
|
"optionalDependencies": {
|
|
39
|
-
"@omnifyjp/omnify-darwin-arm64": "5.8.
|
|
40
|
-
"@omnifyjp/omnify-darwin-x64": "5.8.
|
|
41
|
-
"@omnifyjp/omnify-linux-x64": "5.8.
|
|
42
|
-
"@omnifyjp/omnify-linux-arm64": "5.8.
|
|
43
|
-
"@omnifyjp/omnify-win32-x64": "5.8.
|
|
39
|
+
"@omnifyjp/omnify-darwin-arm64": "5.8.12",
|
|
40
|
+
"@omnifyjp/omnify-darwin-x64": "5.8.12",
|
|
41
|
+
"@omnifyjp/omnify-linux-x64": "5.8.12",
|
|
42
|
+
"@omnifyjp/omnify-linux-arm64": "5.8.12",
|
|
43
|
+
"@omnifyjp/omnify-win32-x64": "5.8.12"
|
|
44
44
|
}
|
|
45
45
|
}
|
|
@@ -42,7 +42,13 @@ function generateBaseController(name, schema, reader, config) {
|
|
|
42
42
|
const baseNs = config.structure === 'modular'
|
|
43
43
|
? resolveModularBaseNamespace(config, name, 'Controllers', config.controllers.baseNamespace)
|
|
44
44
|
: groupNestBase(config.controllers.baseNamespace);
|
|
45
|
-
|
|
45
|
+
// Issue #98 v5.8.11: controller base methods type-hint the
|
|
46
|
+
// USER-EDITABLE Model — same reasoning as the service-generator
|
|
47
|
+
// signature fix. Without this, the controller's `show` /
|
|
48
|
+
// `update` / `destroy` route bindings resolve as base instances
|
|
49
|
+
// and every project-owned service / policy that takes the
|
|
50
|
+
// editable type fails with TypeError.
|
|
51
|
+
const modelNs = groupNestEditable(config.models.userEditableNamespace, config.models);
|
|
46
52
|
const serviceBaseNs = config.structure === 'modular'
|
|
47
53
|
? resolveModularBaseNamespace(config, name, 'Services', config.services.baseNamespace)
|
|
48
54
|
: groupNestBase(config.services.baseNamespace);
|
|
@@ -198,7 +198,24 @@ function addAssociationFields(propName, prop, fields, resourceNamespace, modelNa
|
|
|
198
198
|
const target = prop['target'] ?? '';
|
|
199
199
|
const methodName = toCamelCase(propName);
|
|
200
200
|
// Resolve resource namespace for the target (null if package without resource ns)
|
|
201
|
-
|
|
201
|
+
// Issue #98 v5.8.12: nest the resource FQCN by the TARGET schema's
|
|
202
|
+
// group folder so the inline `new \<ns>\<Name>Resource(...)` ref
|
|
203
|
+
// matches where the target Resource file actually lives. Pre-fix
|
|
204
|
+
// every cross-resource ref emitted FLAT (`use App\Omnify\Resources\PaymentProviderResource`)
|
|
205
|
+
// while the file lived at `App\Omnify\Resources\Payments\PaymentProviderResource` —
|
|
206
|
+
// PHP autoload failed at runtime on every base resource that
|
|
207
|
+
// referenced a sibling resource (whenLoaded relation).
|
|
208
|
+
const rawTargetResNs = target ? reader.resolveResourceNamespace(target, resourceNamespace) : resourceNamespace;
|
|
209
|
+
let targetResNs = rawTargetResNs;
|
|
210
|
+
if (rawTargetResNs && rawTargetResNs === resourceNamespace) {
|
|
211
|
+
// Project-owned target: nest by the target's group so the FQCN
|
|
212
|
+
// matches the grouped base resource. Package targets keep their
|
|
213
|
+
// own namespace.
|
|
214
|
+
const targetSchema = target ? reader.getSchema(target) : undefined;
|
|
215
|
+
if (targetSchema?.group) {
|
|
216
|
+
targetResNs = `${rawTargetResNs}\\${toPascalCase(targetSchema.group)}`;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
202
219
|
// If target is a package schema without a resource namespace, use simple whenLoaded
|
|
203
220
|
if (!targetResNs && relation !== 'MorphTo') {
|
|
204
221
|
if (relation === 'ManyToOne') {
|
|
@@ -510,15 +510,24 @@ function generateBaseService(name, schema, reader, config) {
|
|
|
510
510
|
const baseNs = config.structure === 'modular'
|
|
511
511
|
? resolveModularBaseNamespace(config, name, 'Services', config.services.baseNamespace)
|
|
512
512
|
: nestByGroup({ path: '', namespace: config.services.baseNamespace }, schema.group).namespace;
|
|
513
|
-
// Issue #98 v5.8.
|
|
514
|
-
//
|
|
515
|
-
//
|
|
516
|
-
//
|
|
517
|
-
//
|
|
518
|
-
//
|
|
513
|
+
// Issue #98 v5.8.11: service base methods type-hint the USER-EDITABLE
|
|
514
|
+
// Model class (`App\Models\Banner`), NOT the grouped base
|
|
515
|
+
// (`App\Omnify\Models\Cms\Banner`). PHP signature contravariance:
|
|
516
|
+
// when the user-editable child service overrides a base method,
|
|
517
|
+
// PHP requires the override's parameter type to be the SAME or
|
|
518
|
+
// WIDER than the parent's. The user-editable class is what app code
|
|
519
|
+
// type-hints against everywhere else (factory $model since v5.8.9,
|
|
520
|
+
// relations since v5.8.10, controllers, tests). Without this fix,
|
|
521
|
+
// every override of `find / create / update / delete` on every
|
|
522
|
+
// editable service blew up with a Fatal compile error.
|
|
523
|
+
// Modular structure: per-Schema isolation — base + editable share ns.
|
|
524
|
+
// Pivot schemas don't have services (kind:object only), so the only
|
|
525
|
+
// shape adjustment is `userEditableGroupByFolder` group nesting.
|
|
519
526
|
const modelNs = config.structure === 'modular'
|
|
520
527
|
? config.models.namespace
|
|
521
|
-
:
|
|
528
|
+
: (config.models.userEditableGroupByFolder
|
|
529
|
+
? nestByGroup({ path: '', namespace: config.models.userEditableNamespace }, schema.group).namespace
|
|
530
|
+
: config.models.userEditableNamespace);
|
|
522
531
|
// Build imports
|
|
523
532
|
const imports = [
|
|
524
533
|
`use ${modelNs}\\${modelName};`,
|