@omnifyjp/ts 5.8.21 → 5.8.23

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.
@@ -58,9 +58,14 @@ export function generatePolicies(reader, config) {
58
58
  // Per-schema generation
59
59
  // ============================================================================
60
60
  function generateForSchema(name, schema, reader, config) {
61
+ // Issue #101 v5.8.23: only emit the policy BASE. The user-editable
62
+ // stub was pure scaffolding (extends base, no body) for every
63
+ // schema — typically 80+ noise files in a project. When the dev
64
+ // wants to customize a permission check, they hand-create the
65
+ // wrapper at `userEditablePath`; Laravel's policy auto-discovery
66
+ // picks it up. Until then, the base alone is enough.
61
67
  return [
62
68
  generateBasePolicyClass(name, schema, reader, config),
63
- generateUserPolicyClass(name, schema, config),
64
69
  ];
65
70
  }
66
71
  function generateBasePolicyClass(name, schema, reader, config) {
@@ -33,11 +33,14 @@ export function generateRequests(reader, config) {
33
33
  return files;
34
34
  }
35
35
  function generateForSchema(name, schema, reader, config) {
36
+ // Issue #101 v5.8.23: only emit the request BASE classes. The
37
+ // user-editable stubs were pure scaffolding (extends base, no body)
38
+ // — typically 121 noise files in a project. Controllers + DI inject
39
+ // the BASE FQN directly. When custom validation IS needed, the dev
40
+ // creates the editable file by hand under `userEditablePath`.
36
41
  return [
37
42
  generateBaseRequest(name, schema, reader, config, 'Store'),
38
43
  generateBaseRequest(name, schema, reader, config, 'Update'),
39
- generateUserRequest(name, schema, config, 'Store'),
40
- generateUserRequest(name, schema, config, 'Update'),
41
44
  ];
42
45
  }
43
46
  function generateBaseRequest(name, schema, reader, config, action) {
@@ -3,5 +3,11 @@
3
3
  */
4
4
  import { SchemaReader } from './schema-reader.js';
5
5
  import type { GeneratedFile, PhpConfig } from './types.js';
6
- /** Generate Resource classes for all project-owned visible object schemas. */
6
+ /** Generate Resource classes for all project-owned visible object schemas.
7
+ *
8
+ * Issue #101 v5.8.23: only the base is emitted. Empty editable stubs
9
+ * (every project's 30+ thin `class XResource extends Base {}`) are
10
+ * pure scaffolding noise — devs hand-create wrappers only when custom
11
+ * serialization logic IS needed.
12
+ */
7
13
  export declare function generateResources(reader: SchemaReader, config: PhpConfig): GeneratedFile[];
@@ -4,14 +4,19 @@
4
4
  import { toPascalCase, toSnakeCase, toCamelCase } from './naming-helper.js';
5
5
  import { isHiddenByDefault, toResourceExpression } from './type-mapper.js';
6
6
  import { baseFile, userFile, resolveModularBasePath, resolveModularBaseNamespace, resolveBaseClass, resolveEditableClass, nestByGroup, nestEditableByGroup } from './types.js';
7
- /** Generate Resource classes for all project-owned visible object schemas. */
7
+ /** Generate Resource classes for all project-owned visible object schemas.
8
+ *
9
+ * Issue #101 v5.8.23: only the base is emitted. Empty editable stubs
10
+ * (every project's 30+ thin `class XResource extends Base {}`) are
11
+ * pure scaffolding noise — devs hand-create wrappers only when custom
12
+ * serialization logic IS needed.
13
+ */
8
14
  export function generateResources(reader, config) {
9
15
  const files = [];
10
16
  for (const [name, schema] of Object.entries(reader.getProjectVisibleObjectSchemas())) {
11
17
  if (schema.kind === 'extend')
12
18
  continue;
13
19
  files.push(generateBaseResource(name, schema, reader, config));
14
- files.push(generateUserResource(name, schema, config));
15
20
  }
16
21
  return files;
17
22
  }
@@ -200,9 +200,21 @@ function warnLegacyServiceKeys(name, schema) {
200
200
  }
201
201
  }
202
202
  function generateForSchema(name, schema, reader, config) {
203
+ // Issue #101 v5.8.22: only emit the service BASE. The user-editable
204
+ // service stub is pure scaffolding (extends base, no body) for every
205
+ // schema in every project — 290+ noise files in a typical project.
206
+ // Consumers inject the BASE FQN directly:
207
+ //
208
+ // public function __construct(
209
+ // private \App\Omnify\Services\<Group>\<Name>ServiceBase \$service,
210
+ // ) {}
211
+ //
212
+ // When custom logic IS needed, the dev creates the editable file by
213
+ // hand under the `userEditablePath` (`app/Services/<Name>Service.php`)
214
+ // — Laravel autoloads it like any other class. Omnify won't recreate
215
+ // it on subsequent generates because we no longer emit it at all.
203
216
  return [
204
217
  generateBaseService(name, schema, reader, config),
205
- generateUserService(name, schema, config),
206
218
  ];
207
219
  }
208
220
  /**
@@ -38,5 +38,15 @@ export declare function findAppRootAncestor(filePath: string): string | null;
38
38
  * Scan `rootDir` recursively for a file whose basename matches
39
39
  * `baseName`, excluding `excludePath` itself. Returns the first
40
40
  * match's full path or null.
41
+ *
42
+ * Issue #99 v5.8.19 follow-up: skip the auto-gen `Omnify/` subtree
43
+ * (its files are codegen output, not project-owned siblings) so the
44
+ * editable layer at `app/Models/<Name>.php` doesn't get blocked by
45
+ * the sibling base at `app/Omnify/Models/<Group>/<Name>.php` under
46
+ * canonical+flatBase layout. Project-owned siblings under
47
+ * `app/Services/Omnify/<Name>Service.php` (v4 wrapper layout) DO still
48
+ * trigger a skip because they live OUTSIDE the auto-gen zone — the
49
+ * skip rule is "any directory whose name starts with `Omnify` is
50
+ * codegen-owned", which matches `Omnify/`, `OmnifyBase/`, etc.
41
51
  */
42
52
  export declare function findSiblingWithSameBasename(rootDir: string, baseName: string, excludePath: string): string | null;
@@ -52,6 +52,16 @@ export function findAppRootAncestor(filePath) {
52
52
  * Scan `rootDir` recursively for a file whose basename matches
53
53
  * `baseName`, excluding `excludePath` itself. Returns the first
54
54
  * match's full path or null.
55
+ *
56
+ * Issue #99 v5.8.19 follow-up: skip the auto-gen `Omnify/` subtree
57
+ * (its files are codegen output, not project-owned siblings) so the
58
+ * editable layer at `app/Models/<Name>.php` doesn't get blocked by
59
+ * the sibling base at `app/Omnify/Models/<Group>/<Name>.php` under
60
+ * canonical+flatBase layout. Project-owned siblings under
61
+ * `app/Services/Omnify/<Name>Service.php` (v4 wrapper layout) DO still
62
+ * trigger a skip because they live OUTSIDE the auto-gen zone — the
63
+ * skip rule is "any directory whose name starts with `Omnify` is
64
+ * codegen-owned", which matches `Omnify/`, `OmnifyBase/`, etc.
55
65
  */
56
66
  export function findSiblingWithSameBasename(rootDir, baseName, excludePath) {
57
67
  let scanned = 0;
@@ -82,6 +92,15 @@ export function findSiblingWithSameBasename(rootDir, baseName, excludePath) {
82
92
  continue;
83
93
  }
84
94
  if (stats.isDirectory()) {
95
+ // Skip the auto-gen `app/Omnify/` zone — its files are codegen
96
+ // outputs, not user-owned siblings. Detect via "directory is
97
+ // named `Omnify` AND its parent is named `app`": this catches
98
+ // the canonical `app/Omnify/` zone but does NOT skip
99
+ // `app/Services/Omnify/` (a v4 wrapper layout where `Omnify`
100
+ // is project-owned and should still trigger sibling-skip per
101
+ // issue #99 v5.8.19).
102
+ if (entry === 'Omnify' && basename(dir) === 'app')
103
+ continue;
85
104
  stack.push(fullPath);
86
105
  }
87
106
  else if (entry === baseName && fullPath !== excludePath) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omnifyjp/ts",
3
- "version": "5.8.21",
3
+ "version": "5.8.23",
4
4
  "description": "TypeScript model type generator from Omnify schemas.json",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",