@omnifyjp/ts 5.8.16 → 5.8.17
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/dist/php/resource-generator.js +29 -18
- package/package.json +1 -1
|
@@ -46,7 +46,7 @@ function generateBaseResource(name, schema, reader, config) {
|
|
|
46
46
|
if (isHiddenByDefault(type) || hidden)
|
|
47
47
|
continue;
|
|
48
48
|
if (type === 'Association') {
|
|
49
|
-
addAssociationFields(propName, prop, fields, resourceNamespace, modelNamespace, reader);
|
|
49
|
+
addAssociationFields(propName, prop, fields, resourceNamespace, modelNamespace, reader, config);
|
|
50
50
|
continue;
|
|
51
51
|
}
|
|
52
52
|
if (expandedProperties[propName]) {
|
|
@@ -193,27 +193,38 @@ class ${editable.className} extends ${baseAlias}
|
|
|
193
193
|
`;
|
|
194
194
|
return userFile(`${editable.path}/${editable.fileName}`, content);
|
|
195
195
|
}
|
|
196
|
-
function addAssociationFields(propName, prop, fields, resourceNamespace, modelNamespace, reader) {
|
|
196
|
+
function addAssociationFields(propName, prop, fields, resourceNamespace, modelNamespace, reader, config) {
|
|
197
197
|
const relation = prop['relation'] ?? '';
|
|
198
198
|
const target = prop['target'] ?? '';
|
|
199
199
|
const methodName = toCamelCase(propName);
|
|
200
|
-
// Resolve resource namespace for the target
|
|
201
|
-
// Issue #98 v5.8.12
|
|
202
|
-
//
|
|
203
|
-
//
|
|
204
|
-
//
|
|
205
|
-
//
|
|
206
|
-
//
|
|
207
|
-
//
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
200
|
+
// Resolve resource namespace for the target.
|
|
201
|
+
// Issue #98 v5.8.12 / #99 v5.8.17: cross-resource refs match where
|
|
202
|
+
// the target Resource file actually lives. Same pattern as the
|
|
203
|
+
// v5.8.10/11 model + service / controller fixes — point at the
|
|
204
|
+
// EDITABLE so app code consistently resolves the same class:
|
|
205
|
+
// 1. Package target → keep the package's resource namespace.
|
|
206
|
+
// 2. Project target on modular structure → use the resource
|
|
207
|
+
// namespace as-is (modular has its own per-schema isolation).
|
|
208
|
+
// 3. `userEditableGroupByFolder: true` → nest editable namespace
|
|
209
|
+
// by group so the FQCN matches the grouped editable file.
|
|
210
|
+
// 4. Default (flat editable) → use the editable namespace as-is.
|
|
211
|
+
// v4 projects with `resource.namespace: App\\Http\\Resources`
|
|
212
|
+
// single-tier flat layout (#99) hit this path and stay flat.
|
|
213
|
+
const packageResNs = target ? reader.resolveResourceNamespace(target, resourceNamespace) : resourceNamespace;
|
|
214
|
+
let targetResNs = packageResNs;
|
|
215
|
+
if (packageResNs && packageResNs === resourceNamespace) {
|
|
216
|
+
// Project-owned target: switch to editable namespace + apply
|
|
217
|
+
// optional group nesting. Modular structure aligns base + editable
|
|
218
|
+
// on the same namespace so this is a no-op.
|
|
219
|
+
const editableNs = config.resources.userEditableNamespace || resourceNamespace;
|
|
214
220
|
const targetSchema = target ? reader.getSchema(target) : undefined;
|
|
215
|
-
if (
|
|
216
|
-
|
|
221
|
+
if (config.structure !== 'modular'
|
|
222
|
+
&& config.resources.userEditableGroupByFolder
|
|
223
|
+
&& targetSchema?.group) {
|
|
224
|
+
targetResNs = `${editableNs}\\${toPascalCase(targetSchema.group)}`;
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
targetResNs = editableNs;
|
|
217
228
|
}
|
|
218
229
|
}
|
|
219
230
|
// If target is a package schema without a resource namespace, use simple whenLoaded
|