@omnifyjp/omnify 5.9.2 → 5.9.4

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.
@@ -520,6 +520,11 @@
520
520
  "CodegenLaravelPath": {
521
521
  "type": "object",
522
522
  "properties": {
523
+ "enable": {
524
+ "type": "boolean",
525
+ "default": true,
526
+ "description": "Enable generation for this layer. Currently honored by the Laravel service layer; set service.enable to false to keep other Laravel artifacts while emitting no services."
527
+ },
523
528
  "path": {
524
529
  "type": "string",
525
530
  "description": "Output directory for BASE (auto-regenerated) class."
@@ -176,10 +176,16 @@
176
176
  ]
177
177
  },
178
178
  "service": {
179
- "type": "object",
180
- "description": "Service layer codegen options — controls BaseService generation (searchable, filterable, eager loading, etc.)",
181
- "additionalProperties": false,
182
- "properties": {
179
+ "description": "Service layer codegen options, or false to disable service generation for this schema.",
180
+ "oneOf": [
181
+ {
182
+ "const": false,
183
+ "description": "Disable service generation for this schema."
184
+ },
185
+ {
186
+ "type": "object",
187
+ "additionalProperties": false,
188
+ "properties": {
183
189
  "searchable": {
184
190
  "type": "array",
185
191
  "items": { "type": "string" },
@@ -208,8 +214,10 @@
208
214
  "type": "array",
209
215
  "items": { "type": "string" },
210
216
  "description": "Fields returned by the lookup() method (lightweight select for dropdowns)."
217
+ }
211
218
  }
212
- }
219
+ }
220
+ ]
213
221
  },
214
222
  "api": {
215
223
  "type": "object",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omnifyjp/omnify",
3
- "version": "5.9.2",
3
+ "version": "5.9.4",
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.9.2",
40
- "@omnifyjp/omnify-darwin-x64": "5.9.2",
41
- "@omnifyjp/omnify-linux-x64": "5.9.2",
42
- "@omnifyjp/omnify-linux-arm64": "5.9.2",
43
- "@omnifyjp/omnify-win32-x64": "5.9.2"
39
+ "@omnifyjp/omnify-darwin-arm64": "5.9.4",
40
+ "@omnifyjp/omnify-darwin-x64": "5.9.4",
41
+ "@omnifyjp/omnify-linux-x64": "5.9.4",
42
+ "@omnifyjp/omnify-linux-arm64": "5.9.4",
43
+ "@omnifyjp/omnify-win32-x64": "5.9.4"
44
44
  }
45
45
  }
package/ts-dist/cli.js CHANGED
@@ -29,7 +29,7 @@ import { Command } from 'commander';
29
29
  import { parse as parseYaml } from 'yaml';
30
30
  import { generateTypeScript } from './generator.js';
31
31
  import { generatePhp, derivePhpConfig } from './php/index.js';
32
- import { pruneOrphanServiceFiles } from './php/orphan-cleanup.js';
32
+ import { pruneOrphanServiceFilesIfEnabled } from './php/orphan-cleanup.js';
33
33
  import { findSiblingWithSameBasename, findAppRootAncestor } from './php/sibling-skip.js';
34
34
  import { runPintFormat } from './php/pint-format.js';
35
35
  import { resolveInput, sniffInputKind } from './input-resolver.js';
@@ -315,7 +315,7 @@ program
315
315
  // pollutes Composer autoload. Prune base files automatically; warn
316
316
  // about editable `*Service.php` (may contain user code).
317
317
  const phpConfig = derivePhpConfig(laravelOverrides);
318
- const cleanup = pruneOrphanServiceFiles(configDir, phpConfig, phpFiles);
318
+ const cleanup = pruneOrphanServiceFilesIfEnabled(configDir, phpConfig, phpFiles);
319
319
  if (cleanup.prunedBases.length > 0) {
320
320
  console.log(` ${cleanup.prunedBases.length} orphan ServiceBase pruned (schema removed/renamed/opted-out)`);
321
321
  for (const p of cleanup.prunedBases) {
@@ -26,6 +26,12 @@ export interface ServiceCleanupResult {
26
26
  * preserved (may contain user code). Caller should print a warning. */
27
27
  warnedEditables: string[];
28
28
  }
29
+ /**
30
+ * Apply service cleanup only while this target is managed by Omnify.
31
+ * A globally disabled service layer is a migration boundary: existing bases
32
+ * must remain available until the host application removes its inheritance.
33
+ */
34
+ export declare function pruneOrphanServiceFilesIfEnabled(configDir: string, config: PhpConfig, generated: readonly GeneratedFile[]): ServiceCleanupResult;
29
35
  /**
30
36
  * Delete orphan `*ServiceBase.php` files; flag orphan editable services
31
37
  * for warning. Pure-ish: takes the generated file list (= source of
@@ -20,6 +20,17 @@
20
20
  */
21
21
  import { existsSync, readdirSync, statSync, unlinkSync } from 'node:fs';
22
22
  import { join, resolve, basename } from 'node:path';
23
+ /**
24
+ * Apply service cleanup only while this target is managed by Omnify.
25
+ * A globally disabled service layer is a migration boundary: existing bases
26
+ * must remain available until the host application removes its inheritance.
27
+ */
28
+ export function pruneOrphanServiceFilesIfEnabled(configDir, config, generated) {
29
+ if (!config.services.enabled) {
30
+ return { prunedBases: [], warnedEditables: [] };
31
+ }
32
+ return pruneOrphanServiceFiles(configDir, config, generated);
33
+ }
23
34
  /**
24
35
  * Delete orphan `*ServiceBase.php` files; flag orphan editable services
25
36
  * for warning. Pure-ish: takes the generated file list (= source of
@@ -30,6 +30,8 @@ import { baseFile, userFile, resolveModularBasePath, resolveModularBaseNamespace
30
30
  * - package-owned schemas (those get services in their owning package)
31
31
  */
32
32
  export function generateServices(reader, config) {
33
+ if (!config.services.enabled)
34
+ return [];
33
35
  const files = [];
34
36
  const candidates = collectServiceCandidates(reader);
35
37
  // Emit deprecation warnings once per schema for legacy service-block keys
@@ -99,8 +99,9 @@ class OmnifyServiceProvider extends ServiceProvider
99
99
  $this->loadMigrationsFrom($connectionDir);
100
100
  }
101
101
  ${packageMigrationsBlock}
102
- // Register morph map for polymorphic relationships
103
- Relation::enforceMorphMap([
102
+ // Merge Omnify aliases without requiring every host-application model
103
+ // (Sanctum tokenables, media, notifications, etc.) to be listed here.
104
+ Relation::morphMap([
104
105
  ${morphMapContent}
105
106
  ]);
106
107
  }
@@ -87,6 +87,8 @@ export declare function resolveGlobalTraitNamespace(config: PhpConfig, legacyNam
87
87
  * working.
88
88
  */
89
89
  export interface LaravelPathOverride {
90
+ /** Disable generation for layers that support it (currently `service`). */
91
+ enable?: boolean;
90
92
  /** Path for BASE (auto-generated, regenerated) classes. */
91
93
  path?: string;
92
94
  /** Namespace for BASE (auto-generated) classes. */
@@ -303,7 +305,10 @@ export interface PhpConfig {
303
305
  };
304
306
  policies: BaseEditableLayer;
305
307
  controllers: BaseEditableLayer;
306
- services: BaseEditableLayer;
308
+ services: BaseEditableLayer & {
309
+ /** False disables Laravel service emission and cleanup for this target. */
310
+ enabled: boolean;
311
+ };
307
312
  routes: {
308
313
  path: string;
309
314
  };
@@ -359,7 +359,10 @@ export function derivePhpConfig(overrides) {
359
359
  },
360
360
  policies: policiesLayer,
361
361
  controllers: controllersLayer,
362
- services: servicesLayer,
362
+ services: {
363
+ ...servicesLayer,
364
+ enabled: overrides?.service?.enable ?? true,
365
+ },
363
366
  routes: {
364
367
  path: routePath,
365
368
  },
@@ -603,7 +603,7 @@ export function formatZodModelFile(schemaName) {
603
603
  * This file will NOT be overwritten by the generator.
604
604
  */
605
605
 
606
- import { z } from 'zod';
606
+ import type { z } from 'zod';
607
607
  import type { ${schemaName} as ${schemaName}Base } from './base/${schemaName}';
608
608
  import {
609
609
  base${schemaName}Schemas,
package/types/config.d.ts CHANGED
@@ -41,6 +41,8 @@ export interface CodegenTypeScriptConfig {
41
41
 
42
42
  /** Laravel codegen path configuration for a target (model, request, etc.). */
43
43
  export interface CodegenLaravelPathConfig {
44
+ /** Disable generation for layers that support it (currently `service`). */
45
+ enable?: boolean;
44
46
  /** Output directory path for the BASE (auto-generated, regenerated) class. */
45
47
  path?: string;
46
48
  /** PHP namespace for the BASE class. Defaults to namespace derived from path. */