@omnifyjp/omnify 5.8.5 → 5.8.6
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 +6 -6
- package/ts-dist/php/model-generator.js +21 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@omnifyjp/omnify",
|
|
3
|
-
"version": "5.8.
|
|
3
|
+
"version": "5.8.6",
|
|
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.6",
|
|
40
|
+
"@omnifyjp/omnify-darwin-x64": "5.8.6",
|
|
41
|
+
"@omnifyjp/omnify-linux-x64": "5.8.6",
|
|
42
|
+
"@omnifyjp/omnify-linux-arm64": "5.8.6",
|
|
43
|
+
"@omnifyjp/omnify-win32-x64": "5.8.6"
|
|
44
44
|
}
|
|
45
45
|
}
|
|
@@ -581,21 +581,27 @@ function buildCasts(properties, expandedProperties, propertyOrder, reader, confi
|
|
|
581
581
|
/**
|
|
582
582
|
* Issue #98 v5.8.6: resolve the FQCN namespace of a related Model
|
|
583
583
|
* for inline `belongsTo / hasMany / belongsToMany / morphTo` references.
|
|
584
|
-
* The namespace must match the TARGET's
|
|
585
|
-
*
|
|
584
|
+
* The namespace must match the TARGET's CANONICAL CLASS LOCATION:
|
|
585
|
+
*
|
|
586
586
|
* 1. Package schemas — return the package's namespace verbatim
|
|
587
587
|
* (already handled by reader.resolveModelNamespace).
|
|
588
588
|
* 2. Pivot schemas — always nest under `Pivot/` regardless of any
|
|
589
|
-
* group /
|
|
590
|
-
*
|
|
591
|
-
*
|
|
592
|
-
*
|
|
593
|
-
*
|
|
589
|
+
* group / flat flag (matches the dedicated `Pivot/` folder
|
|
590
|
+
* enforced for pivot models).
|
|
591
|
+
* 3. flatBase: true — the BASE class is the user's canonical class
|
|
592
|
+
* (no `*BaseModel` suffix, lives at the grouped path). Nest by
|
|
593
|
+
* group so the FQCN matches the grouped base.
|
|
594
|
+
* 4. flatBase: false + userEditableGroupByFolder: true — the editable
|
|
595
|
+
* mirrors the base group. Nest by group so the FQCN matches the
|
|
596
|
+
* grouped editable.
|
|
597
|
+
* 5. flatBase: false + userEditableGroupByFolder: false (Laravel-
|
|
598
|
+
* canonical default) — the editable is FLAT. Don't nest; the
|
|
599
|
+
* FQCN matches the flat editable's location.
|
|
594
600
|
*
|
|
595
|
-
* Pre-
|
|
596
|
-
* (flat
|
|
597
|
-
*
|
|
598
|
-
*
|
|
601
|
+
* Pre-v5.8.6 every relation emitted `\${modelNamespace}\${target}::class`
|
|
602
|
+
* (flat) regardless of where the target's file actually lived. Grouped
|
|
603
|
+
* projects (especially flatBase) hit `ErrorException: include(... no
|
|
604
|
+
* such file)` on every cross-Model reference.
|
|
599
605
|
*/
|
|
600
606
|
function resolveRelatedModelNamespace(target, modelNamespace, config, reader) {
|
|
601
607
|
const baseNs = reader.resolveModelNamespace(target, modelNamespace);
|
|
@@ -608,7 +614,10 @@ function resolveRelatedModelNamespace(target, modelNamespace, config, reader) {
|
|
|
608
614
|
if (targetSchema.kind === 'pivot') {
|
|
609
615
|
return `${baseNs}\\Pivot`;
|
|
610
616
|
}
|
|
611
|
-
|
|
617
|
+
// Nest by group when EITHER flatBase is on (base is canonical, grouped)
|
|
618
|
+
// OR the editable explicitly mirrors the base group.
|
|
619
|
+
const shouldNestByGroup = config.models.flatBase || config.models.userEditableGroupByFolder;
|
|
620
|
+
if (shouldNestByGroup && targetSchema.group) {
|
|
612
621
|
return `${baseNs}\\${toPascalCase(targetSchema.group)}`;
|
|
613
622
|
}
|
|
614
623
|
return baseNs;
|