@omnifyjp/omnify 5.8.0 → 5.8.2
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.2",
|
|
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.2",
|
|
40
|
+
"@omnifyjp/omnify-darwin-x64": "5.8.2",
|
|
41
|
+
"@omnifyjp/omnify-linux-x64": "5.8.2",
|
|
42
|
+
"@omnifyjp/omnify-linux-arm64": "5.8.2",
|
|
43
|
+
"@omnifyjp/omnify-win32-x64": "5.8.2"
|
|
44
44
|
}
|
|
45
45
|
}
|
|
@@ -42,7 +42,11 @@ function generateForSchema(name, schema, reader, config) {
|
|
|
42
42
|
}
|
|
43
43
|
function generateBaseRequest(name, schema, reader, config, action) {
|
|
44
44
|
const modelName = toPascalCase(name);
|
|
45
|
-
|
|
45
|
+
// Issue #98 v5.8.2: nest namespace by group in legacy structure so the
|
|
46
|
+
// file's `namespace App\Omnify\Requests\Cms;` matches its grouped path.
|
|
47
|
+
const baseNamespace = config.structure === 'modular'
|
|
48
|
+
? resolveModularBaseNamespace(config, name, 'Requests', config.requests.baseNamespace)
|
|
49
|
+
: nestByGroup({ path: '', namespace: config.requests.baseNamespace }, schema.group).namespace;
|
|
46
50
|
const modelLocalesNamespace = resolveModularBaseNamespace(config, name, 'Locales', config.models.baseNamespace + '\\Locales');
|
|
47
51
|
const properties = (schema.properties ?? {});
|
|
48
52
|
const expandedProperties = reader.getExpandedProperties(name);
|
|
@@ -17,7 +17,13 @@ export function generateResources(reader, config) {
|
|
|
17
17
|
}
|
|
18
18
|
function generateBaseResource(name, schema, reader, config) {
|
|
19
19
|
const modelName = toPascalCase(name);
|
|
20
|
-
|
|
20
|
+
// Issue #98 v5.8.2: nest namespace by group in legacy structure so the
|
|
21
|
+
// file's `namespace App\Omnify\Resources\Cms;` matches its grouped path.
|
|
22
|
+
// (Models layer was already correct in v5.8.0; the other 3 base+editable
|
|
23
|
+
// layers shipped with path nested but namespace ungrouped — broken PSR-4.)
|
|
24
|
+
const baseNamespace = config.structure === 'modular'
|
|
25
|
+
? resolveModularBaseNamespace(config, name, 'Resources', config.resources.baseNamespace)
|
|
26
|
+
: nestByGroup({ path: '', namespace: config.resources.baseNamespace }, schema.group).namespace;
|
|
21
27
|
const resourceNamespace = config.resources.namespace;
|
|
22
28
|
const modelNamespace = config.models.namespace;
|
|
23
29
|
const properties = (schema.properties ?? {});
|
|
@@ -500,7 +500,16 @@ function generateBaseService(name, schema, reader, config) {
|
|
|
500
500
|
const defaults = resolveDefaults(schema, reader, name);
|
|
501
501
|
// Locales (for translatable)
|
|
502
502
|
const locales = reader.getLocales();
|
|
503
|
-
|
|
503
|
+
// Issue #98 v5.8.2: legacy structure must nest by group so the file's
|
|
504
|
+
// `namespace App\Omnify\Services\Cms;` declaration matches its
|
|
505
|
+
// grouped path (`app/Omnify/Services/Cms/BannerServiceBase.php`).
|
|
506
|
+
// Without this, PSR-4 autoload silently breaks: composer dump-autoload
|
|
507
|
+
// succeeds (it doesn't read the file body) but `App\Omnify\Services\Cms\BannerService`
|
|
508
|
+
// resolves to nothing at runtime → "Class not found" for every consumer.
|
|
509
|
+
// Modular structure handled separately below.
|
|
510
|
+
const baseNs = config.structure === 'modular'
|
|
511
|
+
? resolveModularBaseNamespace(config, name, 'Services', config.services.baseNamespace)
|
|
512
|
+
: nestByGroup({ path: '', namespace: config.services.baseNamespace }, schema.group).namespace;
|
|
504
513
|
const modelNs = config.models.namespace;
|
|
505
514
|
// Build imports
|
|
506
515
|
const imports = [
|
|
@@ -56,7 +56,17 @@ function castFor(type) {
|
|
|
56
56
|
function generateTranslationBaseModel(name, translatableFields, enforceLanguageFk, config) {
|
|
57
57
|
const modelName = toPascalCase(name);
|
|
58
58
|
const modelSnake = toSnakeCase(name);
|
|
59
|
-
|
|
59
|
+
// Issue #98 v5.8.2: consolidate every Translation model under one
|
|
60
|
+
// dedicated `Translation/` subfolder + sub-namespace. Reporter's
|
|
61
|
+
// rationale: 39 translation models flat at the top of `Models/`
|
|
62
|
+
// (next to the grouped main models) is the worst-of-both-worlds
|
|
63
|
+
// layout. One consolidated `Translation/` folder lets a project set
|
|
64
|
+
// Astrotomic's `translation_model_namespace` once globally instead
|
|
65
|
+
// of per-model `$translationModel` overrides. Modular structure
|
|
66
|
+
// already isolates per-Schema so this nesting only applies to legacy.
|
|
67
|
+
const baseNamespace = config.structure === 'modular'
|
|
68
|
+
? resolveModularBaseNamespace(config, name, 'Models', config.models.baseNamespace)
|
|
69
|
+
: `${config.models.baseNamespace}\\Translation`;
|
|
60
70
|
const tableName = `${modelSnake}_translations`;
|
|
61
71
|
// Fillable: every translatable column + the optional `language_id`
|
|
62
72
|
// FK column (added by the migration when locale.enforceLanguageFk is
|
|
@@ -119,12 +129,24 @@ ${fillableLines}
|
|
|
119
129
|
];${castsBlock}
|
|
120
130
|
}
|
|
121
131
|
`;
|
|
122
|
-
|
|
132
|
+
// Issue #98 v5.8.2: legacy structure routes translation bases to
|
|
133
|
+
// `<modelsBasePath>/Translation/<Name>TranslationBaseModel.php`.
|
|
134
|
+
const filePath = config.structure === 'modular'
|
|
135
|
+
? resolveModularBasePath(config, name, 'Models', `${modelName}TranslationBaseModel.php`, config.models.basePath)
|
|
136
|
+
: `${config.models.basePath}/Translation/${modelName}TranslationBaseModel.php`;
|
|
137
|
+
return baseFile(filePath, content);
|
|
123
138
|
}
|
|
124
139
|
function generateTranslationUserModel(name, config) {
|
|
125
140
|
const modelName = toPascalCase(name);
|
|
126
|
-
|
|
127
|
-
|
|
141
|
+
// Issue #98 v5.8.2: editable translation stub also lives under
|
|
142
|
+
// `Translation/` to mirror the base layout. Astrotomic finds it via
|
|
143
|
+
// the project-set `translation_model_namespace`.
|
|
144
|
+
const modelNamespace = config.structure === 'modular'
|
|
145
|
+
? config.models.namespace
|
|
146
|
+
: `${config.models.namespace}\\Translation`;
|
|
147
|
+
const baseNamespace = config.structure === 'modular'
|
|
148
|
+
? resolveModularBaseNamespace(config, name, 'Models', config.models.baseNamespace)
|
|
149
|
+
: `${config.models.baseNamespace}\\Translation`;
|
|
128
150
|
const content = `<?php
|
|
129
151
|
|
|
130
152
|
namespace ${modelNamespace};
|
|
@@ -142,5 +164,9 @@ class ${modelName}Translation extends ${modelName}TranslationBaseModel
|
|
|
142
164
|
// Add your custom methods here
|
|
143
165
|
}
|
|
144
166
|
`;
|
|
145
|
-
|
|
167
|
+
// Editable file path mirrors the namespace nesting.
|
|
168
|
+
const filePath = config.structure === 'modular'
|
|
169
|
+
? `${config.models.path}/${modelName}Translation.php`
|
|
170
|
+
: `${config.models.userEditablePath}/Translation/${modelName}Translation.php`;
|
|
171
|
+
return userFile(filePath, content);
|
|
146
172
|
}
|