@omnifyjp/omnify 3.3.0 → 3.4.0
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/types.js +57 -22
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@omnifyjp/omnify",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.0",
|
|
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": "3.
|
|
40
|
-
"@omnifyjp/omnify-darwin-x64": "3.
|
|
41
|
-
"@omnifyjp/omnify-linux-x64": "3.
|
|
42
|
-
"@omnifyjp/omnify-linux-arm64": "3.
|
|
43
|
-
"@omnifyjp/omnify-win32-x64": "3.
|
|
39
|
+
"@omnifyjp/omnify-darwin-arm64": "3.4.0",
|
|
40
|
+
"@omnifyjp/omnify-darwin-x64": "3.4.0",
|
|
41
|
+
"@omnifyjp/omnify-linux-x64": "3.4.0",
|
|
42
|
+
"@omnifyjp/omnify-linux-arm64": "3.4.0",
|
|
43
|
+
"@omnifyjp/omnify-win32-x64": "3.4.0"
|
|
44
44
|
}
|
|
45
45
|
}
|
package/ts-dist/php/types.js
CHANGED
|
@@ -70,15 +70,58 @@ function pathToNamespace(p) {
|
|
|
70
70
|
.map(s => s.charAt(0).toUpperCase() + s.slice(1))
|
|
71
71
|
.join('\\');
|
|
72
72
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
73
|
+
/**
|
|
74
|
+
* Convert a PHP namespace to a Laravel filesystem path
|
|
75
|
+
* (e.g., App\Models → app/Models, App\Models\Omnify → app/Models/Omnify).
|
|
76
|
+
*
|
|
77
|
+
* Lowercases the leading "App" segment to match Laravel's autoload convention.
|
|
78
|
+
*/
|
|
79
|
+
function namespaceToPath(ns) {
|
|
80
|
+
const parts = ns.split('\\').filter(Boolean);
|
|
81
|
+
if (parts.length === 0)
|
|
82
|
+
return '';
|
|
83
|
+
if (parts[0] === 'App')
|
|
84
|
+
parts[0] = 'app';
|
|
85
|
+
return parts.join('/');
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Resolve the path/namespace pair for a target (model, policy, etc.) so they
|
|
89
|
+
* always stay in sync. Either side can be overridden independently:
|
|
90
|
+
* - both unset → use defaults
|
|
91
|
+
* - only path set → derive namespace from path
|
|
92
|
+
* - only namespace set → derive path from namespace (prevents autoload
|
|
93
|
+
* mismatches like generating App\Foo into app/Foo/Bar/)
|
|
94
|
+
* - both set → use as-is (caller is responsible for keeping them aligned)
|
|
95
|
+
*/
|
|
96
|
+
function resolvePathAndNamespace(rootPath, override, defaultPath, nsFromPath) {
|
|
97
|
+
const hasPath = override?.path !== undefined;
|
|
98
|
+
const hasNs = override?.namespace !== undefined;
|
|
99
|
+
if (hasNs && !hasPath) {
|
|
100
|
+
const namespace = override.namespace;
|
|
101
|
+
const path = withRoot(rootPath, namespaceToPath(namespace));
|
|
102
|
+
return { path, namespace };
|
|
103
|
+
}
|
|
104
|
+
const path = withRoot(rootPath, override?.path ?? defaultPath);
|
|
105
|
+
const namespace = hasNs ? override.namespace : nsFromPath(path);
|
|
106
|
+
return { path, namespace };
|
|
107
|
+
}
|
|
108
|
+
// Default paths.
|
|
109
|
+
//
|
|
110
|
+
// Hybrid projects (manual team code + Omnify codegen) need Omnify-generated
|
|
111
|
+
// files to live in their own `Omnify/` subfolder so they don't collide with
|
|
112
|
+
// hand-written controllers/services/requests/resources of the same name.
|
|
113
|
+
// See issue #32. Models keep the standard `app/Models` location because
|
|
114
|
+
// editable models are first-class entities the team owns directly; the
|
|
115
|
+
// regenerated base classes already live under `app/Modules/{Schema}/Models/`
|
|
116
|
+
// in modular structure.
|
|
117
|
+
const DEFAULT_MODEL_PATH = 'app/Models';
|
|
118
|
+
const DEFAULT_REQUEST_PATH = 'app/Http/Requests/Omnify';
|
|
119
|
+
const DEFAULT_RESOURCE_PATH = 'app/Http/Resources/Omnify';
|
|
77
120
|
const DEFAULT_FACTORY_PATH = 'database/factories';
|
|
78
121
|
const DEFAULT_PROVIDER_PATH = 'app/Providers';
|
|
79
122
|
const DEFAULT_POLICY_PATH = 'app/Policies/Omnify';
|
|
80
|
-
const DEFAULT_CONTROLLER_PATH = 'app/Http/Controllers';
|
|
81
|
-
const DEFAULT_SERVICE_PATH = 'app/Services';
|
|
123
|
+
const DEFAULT_CONTROLLER_PATH = 'app/Http/Controllers/Omnify';
|
|
124
|
+
const DEFAULT_SERVICE_PATH = 'app/Services/Omnify';
|
|
82
125
|
const DEFAULT_ROUTE_PATH = 'routes/api/omnify';
|
|
83
126
|
const DEFAULT_CONFIG_FILE_PATH = 'config/omnify-schemas.php';
|
|
84
127
|
const DEFAULT_MODULES_PATH = 'app/Modules';
|
|
@@ -115,22 +158,14 @@ export function derivePhpConfig(overrides) {
|
|
|
115
158
|
return p;
|
|
116
159
|
};
|
|
117
160
|
const nsFromPath = (p) => pathToNamespace(stripRoot(p));
|
|
118
|
-
const modelPath =
|
|
119
|
-
const
|
|
120
|
-
const
|
|
121
|
-
const
|
|
122
|
-
const
|
|
123
|
-
const
|
|
124
|
-
const
|
|
125
|
-
const
|
|
126
|
-
const providerPath = withRoot(rootPath, overrides?.provider?.path ?? DEFAULT_PROVIDER_PATH);
|
|
127
|
-
const providerNs = overrides?.provider?.namespace ?? nsFromPath(providerPath);
|
|
128
|
-
const policyPath = withRoot(rootPath, overrides?.policy?.path ?? DEFAULT_POLICY_PATH);
|
|
129
|
-
const policyNs = overrides?.policy?.namespace ?? nsFromPath(policyPath);
|
|
130
|
-
const controllerPath = withRoot(rootPath, overrides?.controller?.path ?? DEFAULT_CONTROLLER_PATH);
|
|
131
|
-
const controllerNs = overrides?.controller?.namespace ?? nsFromPath(controllerPath);
|
|
132
|
-
const servicePath = withRoot(rootPath, overrides?.service?.path ?? DEFAULT_SERVICE_PATH);
|
|
133
|
-
const serviceNs = overrides?.service?.namespace ?? nsFromPath(servicePath);
|
|
161
|
+
const { path: modelPath, namespace: modelNs } = resolvePathAndNamespace(rootPath, overrides?.model, DEFAULT_MODEL_PATH, nsFromPath);
|
|
162
|
+
const { path: requestPath, namespace: requestNs } = resolvePathAndNamespace(rootPath, overrides?.request, DEFAULT_REQUEST_PATH, nsFromPath);
|
|
163
|
+
const { path: resourcePath, namespace: resourceNs } = resolvePathAndNamespace(rootPath, overrides?.resource, DEFAULT_RESOURCE_PATH, nsFromPath);
|
|
164
|
+
const { path: factoryPath, namespace: factoryNs } = resolvePathAndNamespace(rootPath, overrides?.factory, DEFAULT_FACTORY_PATH, nsFromPath);
|
|
165
|
+
const { path: providerPath, namespace: providerNs } = resolvePathAndNamespace(rootPath, overrides?.provider, DEFAULT_PROVIDER_PATH, nsFromPath);
|
|
166
|
+
const { path: policyPath, namespace: policyNs } = resolvePathAndNamespace(rootPath, overrides?.policy, DEFAULT_POLICY_PATH, nsFromPath);
|
|
167
|
+
const { path: controllerPath, namespace: controllerNs } = resolvePathAndNamespace(rootPath, overrides?.controller, DEFAULT_CONTROLLER_PATH, nsFromPath);
|
|
168
|
+
const { path: servicePath, namespace: serviceNs } = resolvePathAndNamespace(rootPath, overrides?.service, DEFAULT_SERVICE_PATH, nsFromPath);
|
|
134
169
|
const routePath = withRoot(rootPath, overrides?.route?.path ?? DEFAULT_ROUTE_PATH);
|
|
135
170
|
const configFilePath = withRoot(rootPath, overrides?.config?.path ?? DEFAULT_CONFIG_FILE_PATH);
|
|
136
171
|
const nestedsetNs = overrides?.nestedset?.namespace ?? 'Aimeos\\Nestedset';
|