@famgia/omnify-cli 0.0.146 → 0.0.148

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/dist/index.d.cts CHANGED
@@ -1,14 +1,234 @@
1
- import * as _famgia_omnify_types from '@famgia/omnify-types';
2
- import { OmnifyConfig } from '@famgia/omnify-types';
3
- export { DatabaseConfig, OmnifyConfig, OutputConfig, ResolvedOmnifyConfig } from '@famgia/omnify-types';
1
+ import { OmnifyPlugin, LocaleConfig } from '@famgia/omnify-types';
4
2
  import { Command } from 'commander';
5
3
  import { OmnifyError } from '@famgia/omnify-core';
6
4
 
5
+ /**
6
+ * @famgia/omnify-cli - Configuration Types
7
+ *
8
+ * Inline type definitions for omnify.config.ts configuration file.
9
+ * これらの型定義は @famgia/omnify-types からのコピーです。
10
+ * pnpm symlink解決問題を回避するため、直接インライン化しています。
11
+ */
12
+
13
+ /**
14
+ * Supported database drivers.
15
+ */
16
+ type DatabaseDriver = 'mysql' | 'pgsql' | 'postgres' | 'sqlite' | 'sqlsrv' | 'mariadb';
17
+ /**
18
+ * Database configuration for Atlas and migrations.
19
+ */
20
+ interface DatabaseConfig {
21
+ /** Database driver type */
22
+ readonly driver: DatabaseDriver;
23
+ /** Development database URL for Atlas diff operations */
24
+ readonly devUrl?: string;
25
+ /** Enable field comments in migrations (MySQL only) */
26
+ readonly enableFieldComments?: boolean;
27
+ }
28
+ /**
29
+ * Laravel output configuration.
30
+ */
31
+ interface LaravelOutputConfig {
32
+ /** Directory for generated migration files */
33
+ readonly migrationsPath: string;
34
+ /** Directory for generated model files */
35
+ readonly modelsPath?: string;
36
+ /** Directory for generated base model files (auto-generated, always overwritten) */
37
+ readonly baseModelsPath?: string;
38
+ /** Directory for generated service provider files */
39
+ readonly providersPath?: string;
40
+ /** Model namespace */
41
+ readonly modelsNamespace?: string;
42
+ /** Directory for generated factory files */
43
+ readonly factoriesPath?: string;
44
+ /** Directory for generated enum files */
45
+ readonly enumsPath?: string;
46
+ /** Enum namespace */
47
+ readonly enumsNamespace?: string;
48
+ }
49
+ /**
50
+ * TypeScript output configuration.
51
+ */
52
+ interface TypeScriptOutputConfig {
53
+ /**
54
+ * Base output directory for all TypeScript files.
55
+ * Schemas and enums will be placed in subdirectories.
56
+ * @example 'resources/ts/omnify'
57
+ */
58
+ readonly path: string;
59
+ /**
60
+ * Subdirectory for schema files (interfaces, Zod schemas, i18n).
61
+ * Relative to `path`.
62
+ * @default 'schemas'
63
+ * @example 'models' - places schemas at {path}/models/
64
+ */
65
+ readonly schemasDir?: string;
66
+ /**
67
+ * Subdirectory for enum files.
68
+ * Relative to `path`.
69
+ * @default 'enum'
70
+ * @example 'enums' - places enums at {path}/enums/
71
+ */
72
+ readonly enumDir?: string;
73
+ /** Whether to generate a single file or multiple files */
74
+ readonly singleFile?: boolean;
75
+ /** Whether to generate enum types */
76
+ readonly generateEnums?: boolean;
77
+ /** Whether to generate relationship types */
78
+ readonly generateRelationships?: boolean;
79
+ }
80
+ /**
81
+ * Combined output configuration.
82
+ */
83
+ interface OutputConfig {
84
+ /** Laravel migration and model output */
85
+ readonly laravel?: LaravelOutputConfig;
86
+ /** TypeScript type definitions output */
87
+ readonly typescript?: TypeScriptOutputConfig;
88
+ }
89
+ /**
90
+ * Package-level Laravel output configuration.
91
+ * パッケージ独自の出力パスとnamespaceを定義可能
92
+ */
93
+ interface PackageLaravelOutputConfig {
94
+ /** Base path for all package outputs (relative to project root) */
95
+ readonly base: string;
96
+ /** Model namespace for the package (e.g., 'Omnify\\SsoClient\\Models') */
97
+ readonly modelsNamespace: string;
98
+ /** Path for user-editable models (relative to base). @default 'src/Models' */
99
+ readonly modelsPath?: string;
100
+ /** Path for auto-generated base models (relative to base). @default 'src/Models/Generated' */
101
+ readonly baseModelsPath?: string;
102
+ /** Base model namespace. @default derived from modelsNamespace + '\\Generated' */
103
+ readonly baseModelsNamespace?: string;
104
+ /** Path for migrations (relative to base). @default 'database/migrations' */
105
+ readonly migrationsPath?: string;
106
+ /** Path for enums (relative to base). @default 'src/Enums' */
107
+ readonly enumsPath?: string;
108
+ /** Enum namespace. @default derived from modelsNamespace parent + '\\Enums' */
109
+ readonly enumsNamespace?: string;
110
+ /** Whether to generate a service provider. @default true */
111
+ readonly generateServiceProvider?: boolean;
112
+ /** Path for service provider (relative to base). @default 'src/Providers' */
113
+ readonly providersPath?: string;
114
+ /** Service provider namespace. @default derived from modelsNamespace parent + '\\Providers' */
115
+ readonly providersNamespace?: string;
116
+ /** Whether to generate factories. @default true */
117
+ readonly generateFactories?: boolean;
118
+ /** Path for factories (relative to base). @default 'database/factories' */
119
+ readonly factoriesPath?: string;
120
+ }
121
+ /**
122
+ * Package-level output configuration.
123
+ */
124
+ interface PackageOutputConfig {
125
+ /** Laravel output configuration for the package */
126
+ readonly laravel?: PackageLaravelOutputConfig;
127
+ }
128
+ /**
129
+ * Additional schema path entry for loading schemas from packages.
130
+ */
131
+ interface AdditionalSchemaPath {
132
+ /**
133
+ * Path to the schema directory.
134
+ * Can be relative (from project root) or absolute.
135
+ * @example './packages/sso-client/database/schemas'
136
+ */
137
+ readonly path: string;
138
+ /**
139
+ * Optional namespace prefix for schemas from this path.
140
+ * Used for organizing schemas from different packages.
141
+ * @example 'Sso'
142
+ */
143
+ readonly namespace?: string;
144
+ /**
145
+ * Package-level output configuration.
146
+ * When set, generated files for schemas from this path will be placed
147
+ * in the package directory with custom namespaces.
148
+ *
149
+ * @example
150
+ * output: {
151
+ * laravel: {
152
+ * base: './packages/sso-client',
153
+ * modelsNamespace: 'Omnify\\SsoClient\\Models',
154
+ * }
155
+ * }
156
+ */
157
+ readonly output?: PackageOutputConfig;
158
+ }
159
+ /**
160
+ * Main omnify configuration interface.
161
+ * Used in omnify.config.ts files.
162
+ */
163
+ interface OmnifyConfig {
164
+ /**
165
+ * Directory containing schema definition files.
166
+ * @default './schemas'
167
+ */
168
+ readonly schemasDir?: string;
169
+ /**
170
+ * Additional schema paths from packages or other directories.
171
+ * Schemas from these paths will be merged with the main schemasDir.
172
+ * Package schemas won't override main schemas with the same name.
173
+ *
174
+ * @example
175
+ * additionalSchemaPaths: [
176
+ * { path: './packages/sso-client/database/schemas', namespace: 'Sso' },
177
+ * { path: './packages/billing/schemas', namespace: 'Billing' },
178
+ * ]
179
+ */
180
+ readonly additionalSchemaPaths?: readonly AdditionalSchemaPath[];
181
+ /**
182
+ * Database configuration.
183
+ */
184
+ readonly database: DatabaseConfig;
185
+ /**
186
+ * Output configuration for generated files.
187
+ */
188
+ readonly output?: OutputConfig;
189
+ /**
190
+ * Plugins to load for custom types.
191
+ * Can be npm package names or plugin objects.
192
+ */
193
+ readonly plugins?: readonly (string | OmnifyPlugin)[];
194
+ /**
195
+ * Enable verbose logging.
196
+ * @default false
197
+ */
198
+ readonly verbose?: boolean;
199
+ /**
200
+ * Lock file path for tracking schema state.
201
+ * @default '.omnify.lock'
202
+ */
203
+ readonly lockFilePath?: string;
204
+ /**
205
+ * Locale configuration for multi-language support.
206
+ * Used for displayName, description, and other localizable strings.
207
+ *
208
+ * @example
209
+ * locale: {
210
+ * locales: ['en', 'ja', 'vi'],
211
+ * defaultLocale: 'en',
212
+ * fallbackLocale: 'en'
213
+ * }
214
+ */
215
+ readonly locale?: LocaleConfig;
216
+ }
217
+ /**
218
+ * Resolved configuration with all defaults applied.
219
+ * locale is optional since multi-language support is opt-in.
220
+ * additionalSchemaPaths is optional since it's not required.
221
+ */
222
+ interface ResolvedOmnifyConfig extends Required<Omit<OmnifyConfig, 'plugins' | 'locale' | 'additionalSchemaPaths'>> {
223
+ readonly plugins: readonly OmnifyPlugin[];
224
+ readonly locale?: LocaleConfig;
225
+ readonly additionalSchemaPaths?: readonly AdditionalSchemaPath[];
226
+ }
7
227
  /**
8
228
  * Configuration file loading result.
9
229
  */
10
230
  interface ConfigLoadResult {
11
- config: _famgia_omnify_types.ResolvedOmnifyConfig;
231
+ config: ResolvedOmnifyConfig;
12
232
  configPath: string | null;
13
233
  }
14
234
 
@@ -169,4 +389,4 @@ declare class Logger {
169
389
  */
170
390
  declare const logger: Logger;
171
391
 
172
- export { defineConfig, loadConfig, logger, registerDiffCommand, registerGenerateCommand, registerInitCommand, registerValidateCommand, runInit };
392
+ export { type AdditionalSchemaPath, type DatabaseConfig, type DatabaseDriver, type LaravelOutputConfig, type OmnifyConfig, type OutputConfig, type PackageLaravelOutputConfig, type PackageOutputConfig, type ResolvedOmnifyConfig, type TypeScriptOutputConfig, defineConfig, loadConfig, logger, registerDiffCommand, registerGenerateCommand, registerInitCommand, registerValidateCommand, runInit };
package/dist/index.d.ts CHANGED
@@ -1,14 +1,234 @@
1
- import * as _famgia_omnify_types from '@famgia/omnify-types';
2
- import { OmnifyConfig } from '@famgia/omnify-types';
3
- export { DatabaseConfig, OmnifyConfig, OutputConfig, ResolvedOmnifyConfig } from '@famgia/omnify-types';
1
+ import { OmnifyPlugin, LocaleConfig } from '@famgia/omnify-types';
4
2
  import { Command } from 'commander';
5
3
  import { OmnifyError } from '@famgia/omnify-core';
6
4
 
5
+ /**
6
+ * @famgia/omnify-cli - Configuration Types
7
+ *
8
+ * Inline type definitions for omnify.config.ts configuration file.
9
+ * これらの型定義は @famgia/omnify-types からのコピーです。
10
+ * pnpm symlink解決問題を回避するため、直接インライン化しています。
11
+ */
12
+
13
+ /**
14
+ * Supported database drivers.
15
+ */
16
+ type DatabaseDriver = 'mysql' | 'pgsql' | 'postgres' | 'sqlite' | 'sqlsrv' | 'mariadb';
17
+ /**
18
+ * Database configuration for Atlas and migrations.
19
+ */
20
+ interface DatabaseConfig {
21
+ /** Database driver type */
22
+ readonly driver: DatabaseDriver;
23
+ /** Development database URL for Atlas diff operations */
24
+ readonly devUrl?: string;
25
+ /** Enable field comments in migrations (MySQL only) */
26
+ readonly enableFieldComments?: boolean;
27
+ }
28
+ /**
29
+ * Laravel output configuration.
30
+ */
31
+ interface LaravelOutputConfig {
32
+ /** Directory for generated migration files */
33
+ readonly migrationsPath: string;
34
+ /** Directory for generated model files */
35
+ readonly modelsPath?: string;
36
+ /** Directory for generated base model files (auto-generated, always overwritten) */
37
+ readonly baseModelsPath?: string;
38
+ /** Directory for generated service provider files */
39
+ readonly providersPath?: string;
40
+ /** Model namespace */
41
+ readonly modelsNamespace?: string;
42
+ /** Directory for generated factory files */
43
+ readonly factoriesPath?: string;
44
+ /** Directory for generated enum files */
45
+ readonly enumsPath?: string;
46
+ /** Enum namespace */
47
+ readonly enumsNamespace?: string;
48
+ }
49
+ /**
50
+ * TypeScript output configuration.
51
+ */
52
+ interface TypeScriptOutputConfig {
53
+ /**
54
+ * Base output directory for all TypeScript files.
55
+ * Schemas and enums will be placed in subdirectories.
56
+ * @example 'resources/ts/omnify'
57
+ */
58
+ readonly path: string;
59
+ /**
60
+ * Subdirectory for schema files (interfaces, Zod schemas, i18n).
61
+ * Relative to `path`.
62
+ * @default 'schemas'
63
+ * @example 'models' - places schemas at {path}/models/
64
+ */
65
+ readonly schemasDir?: string;
66
+ /**
67
+ * Subdirectory for enum files.
68
+ * Relative to `path`.
69
+ * @default 'enum'
70
+ * @example 'enums' - places enums at {path}/enums/
71
+ */
72
+ readonly enumDir?: string;
73
+ /** Whether to generate a single file or multiple files */
74
+ readonly singleFile?: boolean;
75
+ /** Whether to generate enum types */
76
+ readonly generateEnums?: boolean;
77
+ /** Whether to generate relationship types */
78
+ readonly generateRelationships?: boolean;
79
+ }
80
+ /**
81
+ * Combined output configuration.
82
+ */
83
+ interface OutputConfig {
84
+ /** Laravel migration and model output */
85
+ readonly laravel?: LaravelOutputConfig;
86
+ /** TypeScript type definitions output */
87
+ readonly typescript?: TypeScriptOutputConfig;
88
+ }
89
+ /**
90
+ * Package-level Laravel output configuration.
91
+ * パッケージ独自の出力パスとnamespaceを定義可能
92
+ */
93
+ interface PackageLaravelOutputConfig {
94
+ /** Base path for all package outputs (relative to project root) */
95
+ readonly base: string;
96
+ /** Model namespace for the package (e.g., 'Omnify\\SsoClient\\Models') */
97
+ readonly modelsNamespace: string;
98
+ /** Path for user-editable models (relative to base). @default 'src/Models' */
99
+ readonly modelsPath?: string;
100
+ /** Path for auto-generated base models (relative to base). @default 'src/Models/Generated' */
101
+ readonly baseModelsPath?: string;
102
+ /** Base model namespace. @default derived from modelsNamespace + '\\Generated' */
103
+ readonly baseModelsNamespace?: string;
104
+ /** Path for migrations (relative to base). @default 'database/migrations' */
105
+ readonly migrationsPath?: string;
106
+ /** Path for enums (relative to base). @default 'src/Enums' */
107
+ readonly enumsPath?: string;
108
+ /** Enum namespace. @default derived from modelsNamespace parent + '\\Enums' */
109
+ readonly enumsNamespace?: string;
110
+ /** Whether to generate a service provider. @default true */
111
+ readonly generateServiceProvider?: boolean;
112
+ /** Path for service provider (relative to base). @default 'src/Providers' */
113
+ readonly providersPath?: string;
114
+ /** Service provider namespace. @default derived from modelsNamespace parent + '\\Providers' */
115
+ readonly providersNamespace?: string;
116
+ /** Whether to generate factories. @default true */
117
+ readonly generateFactories?: boolean;
118
+ /** Path for factories (relative to base). @default 'database/factories' */
119
+ readonly factoriesPath?: string;
120
+ }
121
+ /**
122
+ * Package-level output configuration.
123
+ */
124
+ interface PackageOutputConfig {
125
+ /** Laravel output configuration for the package */
126
+ readonly laravel?: PackageLaravelOutputConfig;
127
+ }
128
+ /**
129
+ * Additional schema path entry for loading schemas from packages.
130
+ */
131
+ interface AdditionalSchemaPath {
132
+ /**
133
+ * Path to the schema directory.
134
+ * Can be relative (from project root) or absolute.
135
+ * @example './packages/sso-client/database/schemas'
136
+ */
137
+ readonly path: string;
138
+ /**
139
+ * Optional namespace prefix for schemas from this path.
140
+ * Used for organizing schemas from different packages.
141
+ * @example 'Sso'
142
+ */
143
+ readonly namespace?: string;
144
+ /**
145
+ * Package-level output configuration.
146
+ * When set, generated files for schemas from this path will be placed
147
+ * in the package directory with custom namespaces.
148
+ *
149
+ * @example
150
+ * output: {
151
+ * laravel: {
152
+ * base: './packages/sso-client',
153
+ * modelsNamespace: 'Omnify\\SsoClient\\Models',
154
+ * }
155
+ * }
156
+ */
157
+ readonly output?: PackageOutputConfig;
158
+ }
159
+ /**
160
+ * Main omnify configuration interface.
161
+ * Used in omnify.config.ts files.
162
+ */
163
+ interface OmnifyConfig {
164
+ /**
165
+ * Directory containing schema definition files.
166
+ * @default './schemas'
167
+ */
168
+ readonly schemasDir?: string;
169
+ /**
170
+ * Additional schema paths from packages or other directories.
171
+ * Schemas from these paths will be merged with the main schemasDir.
172
+ * Package schemas won't override main schemas with the same name.
173
+ *
174
+ * @example
175
+ * additionalSchemaPaths: [
176
+ * { path: './packages/sso-client/database/schemas', namespace: 'Sso' },
177
+ * { path: './packages/billing/schemas', namespace: 'Billing' },
178
+ * ]
179
+ */
180
+ readonly additionalSchemaPaths?: readonly AdditionalSchemaPath[];
181
+ /**
182
+ * Database configuration.
183
+ */
184
+ readonly database: DatabaseConfig;
185
+ /**
186
+ * Output configuration for generated files.
187
+ */
188
+ readonly output?: OutputConfig;
189
+ /**
190
+ * Plugins to load for custom types.
191
+ * Can be npm package names or plugin objects.
192
+ */
193
+ readonly plugins?: readonly (string | OmnifyPlugin)[];
194
+ /**
195
+ * Enable verbose logging.
196
+ * @default false
197
+ */
198
+ readonly verbose?: boolean;
199
+ /**
200
+ * Lock file path for tracking schema state.
201
+ * @default '.omnify.lock'
202
+ */
203
+ readonly lockFilePath?: string;
204
+ /**
205
+ * Locale configuration for multi-language support.
206
+ * Used for displayName, description, and other localizable strings.
207
+ *
208
+ * @example
209
+ * locale: {
210
+ * locales: ['en', 'ja', 'vi'],
211
+ * defaultLocale: 'en',
212
+ * fallbackLocale: 'en'
213
+ * }
214
+ */
215
+ readonly locale?: LocaleConfig;
216
+ }
217
+ /**
218
+ * Resolved configuration with all defaults applied.
219
+ * locale is optional since multi-language support is opt-in.
220
+ * additionalSchemaPaths is optional since it's not required.
221
+ */
222
+ interface ResolvedOmnifyConfig extends Required<Omit<OmnifyConfig, 'plugins' | 'locale' | 'additionalSchemaPaths'>> {
223
+ readonly plugins: readonly OmnifyPlugin[];
224
+ readonly locale?: LocaleConfig;
225
+ readonly additionalSchemaPaths?: readonly AdditionalSchemaPath[];
226
+ }
7
227
  /**
8
228
  * Configuration file loading result.
9
229
  */
10
230
  interface ConfigLoadResult {
11
- config: _famgia_omnify_types.ResolvedOmnifyConfig;
231
+ config: ResolvedOmnifyConfig;
12
232
  configPath: string | null;
13
233
  }
14
234
 
@@ -169,4 +389,4 @@ declare class Logger {
169
389
  */
170
390
  declare const logger: Logger;
171
391
 
172
- export { defineConfig, loadConfig, logger, registerDiffCommand, registerGenerateCommand, registerInitCommand, registerValidateCommand, runInit };
392
+ export { type AdditionalSchemaPath, type DatabaseConfig, type DatabaseDriver, type LaravelOutputConfig, type OmnifyConfig, type OutputConfig, type PackageLaravelOutputConfig, type PackageOutputConfig, type ResolvedOmnifyConfig, type TypeScriptOutputConfig, defineConfig, loadConfig, logger, registerDiffCommand, registerGenerateCommand, registerInitCommand, registerValidateCommand, runInit };
package/dist/index.js CHANGED
@@ -1515,11 +1515,22 @@ async function runGenerate(options) {
1515
1515
  const absolutePath = resolve7(rootDir, entry.path);
1516
1516
  logger.debug(` Checking: ${entry.path} \u2192 ${absolutePath}`);
1517
1517
  if (existsSync7(absolutePath)) {
1518
- const packageSchemas = await loadSchemas3(absolutePath, { skipPartialResolution: true });
1518
+ let packageSchemas = await loadSchemas3(absolutePath, { skipPartialResolution: true });
1519
+ if (entry.output) {
1520
+ const schemasWithOutput = {};
1521
+ for (const [name, schema] of Object.entries(packageSchemas)) {
1522
+ schemasWithOutput[name] = {
1523
+ ...schema,
1524
+ packageOutput: entry.output
1525
+ };
1526
+ }
1527
+ packageSchemas = schemasWithOutput;
1528
+ }
1519
1529
  const count = Object.keys(packageSchemas).filter((k) => !k.startsWith("__partial__")).length;
1520
1530
  const partialCount = Object.keys(packageSchemas).filter((k) => k.startsWith("__partial__")).length;
1521
1531
  const nsInfo = entry.namespace ? ` [${entry.namespace}]` : "";
1522
- logger.info(` \u2022 ${entry.path}${nsInfo}: ${count} schema(s)${partialCount > 0 ? ` + ${partialCount} partial(s)` : ""}`);
1532
+ const outputInfo = entry.output?.laravel ? ` \u2192 ${entry.output.laravel.base}` : "";
1533
+ logger.info(` \u2022 ${entry.path}${nsInfo}: ${count} schema(s)${partialCount > 0 ? ` + ${partialCount} partial(s)` : ""}${outputInfo}`);
1523
1534
  schemas = { ...packageSchemas, ...schemas };
1524
1535
  hasPackageSchemas = true;
1525
1536
  } else {