@omnifyjp/ts 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.
@@ -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 actual file location, not the
585
- * source schema's. Three knobs:
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 / userEditableGroupByFolder setting.
590
- * 3. Group nesting — only when `userEditableGroupByFolder: true`
591
- * (matches where the editable lives so the relation resolves to
592
- * the user's customizable class). Default off flat FQCN
593
- * matches the Laravel-canonical flat editable layout.
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-fix every relation emitted `\${modelNamespace}\${target}::class`
596
- * (flat FQCN) regardless of where the target's file actually lived.
597
- * For grouped projects this dispatched to a non-existent class at
598
- * runtime `ErrorException: include(... no such file)`.
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
- if (config.models.userEditableGroupByFolder && targetSchema.group) {
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omnifyjp/ts",
3
- "version": "5.8.5",
3
+ "version": "5.8.6",
4
4
  "description": "TypeScript model type generator from Omnify schemas.json",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",