@omnifyjp/ts 5.9.0 → 5.9.1
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.
|
@@ -386,12 +386,14 @@ function buildImports(baseNamespace, modelName, hasSoftDelete, isAuthenticatable
|
|
|
386
386
|
}
|
|
387
387
|
}
|
|
388
388
|
if (hasAuditLog) {
|
|
389
|
-
// HasOmnifyAuditLog is a
|
|
390
|
-
// audit-trait-generator.ts
|
|
391
|
-
//
|
|
392
|
-
//
|
|
389
|
+
// HasOmnifyAuditLog is a GLOBAL Omnify trait emitted by
|
|
390
|
+
// audit-trait-generator.ts at `config.models.baseNamespace\Traits`
|
|
391
|
+
// (e.g. App\Models\Omnify\Base\Traits). The import here must resolve to
|
|
392
|
+
// that SAME global namespace — using the per-model (group) `baseNamespace`
|
|
393
|
+
// (e.g. ...\Base\Logistics) yields `Base\Logistics\Traits\HasOmnifyAuditLog`
|
|
394
|
+
// which does not exist → "Trait not found" fatal on every model load.
|
|
393
395
|
const auditTraitsNs = config
|
|
394
|
-
? resolveGlobalTraitNamespace(config, baseNamespace + '\\Traits')
|
|
396
|
+
? resolveGlobalTraitNamespace(config, config.models.baseNamespace + '\\Traits')
|
|
395
397
|
: (traitsNamespace || baseNamespace + '\\Traits');
|
|
396
398
|
lines.push(`use ${auditTraitsNs}\\HasOmnifyAuditLog;`);
|
|
397
399
|
}
|
|
@@ -195,7 +195,7 @@ namespace ${baseNamespace};
|
|
|
195
195
|
use Illuminate\\Foundation\\Http\\FormRequest;${ruleImport}
|
|
196
196
|
use ${localesClass};
|
|
197
197
|
|
|
198
|
-
|
|
198
|
+
class ${modelName}${action}RequestBase extends FormRequest
|
|
199
199
|
{
|
|
200
200
|
/**
|
|
201
201
|
* Determine if the user is authorized to make this request.
|
|
@@ -277,7 +277,10 @@ ${attributeKeysList}
|
|
|
277
277
|
const nested = nestByGroup({ path: raw.path, namespace: '' }, schema.group);
|
|
278
278
|
baseDescriptor = { className: raw.className, path: nested.path };
|
|
279
279
|
}
|
|
280
|
-
|
|
280
|
+
// Issue #114: the request base is the class controllers inject directly
|
|
281
|
+
// (#101) — so it must be CONCRETE, not abstract (an abstract FormRequest is
|
|
282
|
+
// not container-resolvable → BindingResolutionException / HTTP 500).
|
|
283
|
+
const finalContent = content.replace(new RegExp(`class ${modelName}${action}RequestBase\\b`, 'g'), `class ${baseDescriptor.className}`);
|
|
281
284
|
return baseFile(`${baseDescriptor.path}/${baseDescriptor.className}.php`, finalContent);
|
|
282
285
|
}
|
|
283
286
|
function generateUserRequest(name, schema, config, action) {
|
|
@@ -5,9 +5,12 @@ import { SchemaReader } from './schema-reader.js';
|
|
|
5
5
|
import type { GeneratedFile, PhpConfig } from './types.js';
|
|
6
6
|
/** Generate Resource classes for all project-owned visible object schemas.
|
|
7
7
|
*
|
|
8
|
-
* Issue #101 v5.8.23
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
8
|
+
* Issue #101 v5.8.23 emitted ONLY the base — but child resources embed a
|
|
9
|
+
* parent relation via `new \App\Http\Resources\<Parent>Resource(...)` (the
|
|
10
|
+
* editable sibling). With the sibling gone, any loaded relation fatals with a
|
|
11
|
+
* "class not found" Error (issue #114). So the editable sibling is re-emitted
|
|
12
|
+
* as a create-if-missing user file (`overwrite: false`): written once, never
|
|
13
|
+
* regenerated (so it is not the scaffolding noise #101 removed), and the
|
|
14
|
+
* cross-resource reference always resolves.
|
|
12
15
|
*/
|
|
13
16
|
export declare function generateResources(reader: SchemaReader, config: PhpConfig): GeneratedFile[];
|
|
@@ -6,10 +6,13 @@ import { isHiddenByDefault, toResourceExpression } from './type-mapper.js';
|
|
|
6
6
|
import { baseFile, userFile, resolveModularBasePath, resolveModularBaseNamespace, resolveBaseClass, resolveEditableClass, nestByGroup, nestEditableByGroup } from './types.js';
|
|
7
7
|
/** Generate Resource classes for all project-owned visible object schemas.
|
|
8
8
|
*
|
|
9
|
-
* Issue #101 v5.8.23
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
9
|
+
* Issue #101 v5.8.23 emitted ONLY the base — but child resources embed a
|
|
10
|
+
* parent relation via `new \App\Http\Resources\<Parent>Resource(...)` (the
|
|
11
|
+
* editable sibling). With the sibling gone, any loaded relation fatals with a
|
|
12
|
+
* "class not found" Error (issue #114). So the editable sibling is re-emitted
|
|
13
|
+
* as a create-if-missing user file (`overwrite: false`): written once, never
|
|
14
|
+
* regenerated (so it is not the scaffolding noise #101 removed), and the
|
|
15
|
+
* cross-resource reference always resolves.
|
|
13
16
|
*/
|
|
14
17
|
export function generateResources(reader, config) {
|
|
15
18
|
const files = [];
|
|
@@ -17,6 +20,7 @@ export function generateResources(reader, config) {
|
|
|
17
20
|
if (schema.kind === 'extend')
|
|
18
21
|
continue;
|
|
19
22
|
files.push(generateBaseResource(name, schema, reader, config));
|
|
23
|
+
files.push(generateUserResource(name, schema, config));
|
|
20
24
|
}
|
|
21
25
|
return files;
|
|
22
26
|
}
|