@memberjunction/codegen-lib 3.3.0 → 4.0.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.
Files changed (92) hide show
  1. package/README.md +56 -1
  2. package/dist/Angular/angular-codegen.d.ts +1 -1
  3. package/dist/Angular/angular-codegen.d.ts.map +1 -1
  4. package/dist/Angular/angular-codegen.js +80 -136
  5. package/dist/Angular/angular-codegen.js.map +1 -1
  6. package/dist/Angular/entity-data-grid-related-entity-component.d.ts +1 -1
  7. package/dist/Angular/entity-data-grid-related-entity-component.js +6 -9
  8. package/dist/Angular/entity-data-grid-related-entity-component.js.map +1 -1
  9. package/dist/Angular/join-grid-related-entity-component.d.ts +1 -1
  10. package/dist/Angular/join-grid-related-entity-component.js +8 -36
  11. package/dist/Angular/join-grid-related-entity-component.js.map +1 -1
  12. package/dist/Angular/related-entity-components.js +13 -79
  13. package/dist/Angular/related-entity-components.js.map +1 -1
  14. package/dist/Angular/timeline-related-entity-component.d.ts +1 -1
  15. package/dist/Angular/timeline-related-entity-component.js +14 -38
  16. package/dist/Angular/timeline-related-entity-component.js.map +1 -1
  17. package/dist/Angular/user-view-grid-related-entity-component.d.ts +43 -0
  18. package/dist/Angular/user-view-grid-related-entity-component.d.ts.map +1 -0
  19. package/dist/Angular/user-view-grid-related-entity-component.js +85 -0
  20. package/dist/Angular/user-view-grid-related-entity-component.js.map +1 -0
  21. package/dist/Config/config.d.ts +79 -0
  22. package/dist/Config/config.d.ts.map +1 -1
  23. package/dist/Config/config.js +174 -172
  24. package/dist/Config/config.js.map +1 -1
  25. package/dist/Config/db-connection.d.ts +1 -1
  26. package/dist/Config/db-connection.d.ts.map +1 -1
  27. package/dist/Config/db-connection.js +6 -33
  28. package/dist/Config/db-connection.js.map +1 -1
  29. package/dist/Database/dbSchema.js +28 -35
  30. package/dist/Database/dbSchema.js.map +1 -1
  31. package/dist/Database/manage-metadata.d.ts +25 -9
  32. package/dist/Database/manage-metadata.d.ts.map +1 -1
  33. package/dist/Database/manage-metadata.js +438 -316
  34. package/dist/Database/manage-metadata.js.map +1 -1
  35. package/dist/Database/reorder-columns.d.ts +1 -1
  36. package/dist/Database/reorder-columns.d.ts.map +1 -1
  37. package/dist/Database/reorder-columns.js +1 -5
  38. package/dist/Database/reorder-columns.js.map +1 -1
  39. package/dist/Database/sql.d.ts +1 -1
  40. package/dist/Database/sql.d.ts.map +1 -1
  41. package/dist/Database/sql.js +67 -98
  42. package/dist/Database/sql.js.map +1 -1
  43. package/dist/Database/sql_codegen.d.ts +5 -2
  44. package/dist/Database/sql_codegen.d.ts.map +1 -1
  45. package/dist/Database/sql_codegen.js +344 -268
  46. package/dist/Database/sql_codegen.js.map +1 -1
  47. package/dist/Manifest/GenerateClassRegistrationsManifest.d.ts +110 -0
  48. package/dist/Manifest/GenerateClassRegistrationsManifest.d.ts.map +1 -0
  49. package/dist/Manifest/GenerateClassRegistrationsManifest.js +632 -0
  50. package/dist/Manifest/GenerateClassRegistrationsManifest.js.map +1 -0
  51. package/dist/Misc/action_subclasses_codegen.d.ts.map +1 -1
  52. package/dist/Misc/action_subclasses_codegen.js +15 -26
  53. package/dist/Misc/action_subclasses_codegen.js.map +1 -1
  54. package/dist/Misc/advanced_generation.d.ts +1 -1
  55. package/dist/Misc/advanced_generation.js +34 -40
  56. package/dist/Misc/advanced_generation.js.map +1 -1
  57. package/dist/Misc/createNewUser.d.ts +1 -1
  58. package/dist/Misc/createNewUser.js +22 -26
  59. package/dist/Misc/createNewUser.js.map +1 -1
  60. package/dist/Misc/entity_subclasses_codegen.d.ts +2 -2
  61. package/dist/Misc/entity_subclasses_codegen.d.ts.map +1 -1
  62. package/dist/Misc/entity_subclasses_codegen.js +33 -40
  63. package/dist/Misc/entity_subclasses_codegen.js.map +1 -1
  64. package/dist/Misc/graphql_server_codegen.js +36 -41
  65. package/dist/Misc/graphql_server_codegen.js.map +1 -1
  66. package/dist/Misc/runCommand.d.ts +1 -1
  67. package/dist/Misc/runCommand.js +13 -20
  68. package/dist/Misc/runCommand.js.map +1 -1
  69. package/dist/Misc/sql_logging.d.ts +7 -1
  70. package/dist/Misc/sql_logging.d.ts.map +1 -1
  71. package/dist/Misc/sql_logging.js +40 -53
  72. package/dist/Misc/sql_logging.js.map +1 -1
  73. package/dist/Misc/status_logging.js +45 -60
  74. package/dist/Misc/status_logging.js.map +1 -1
  75. package/dist/Misc/system_integrity.d.ts +1 -1
  76. package/dist/Misc/system_integrity.d.ts.map +1 -1
  77. package/dist/Misc/system_integrity.js +12 -16
  78. package/dist/Misc/system_integrity.js.map +1 -1
  79. package/dist/Misc/temp_batch_file.js +15 -22
  80. package/dist/Misc/temp_batch_file.js.map +1 -1
  81. package/dist/Misc/util.d.ts.map +1 -1
  82. package/dist/Misc/util.js +17 -28
  83. package/dist/Misc/util.js.map +1 -1
  84. package/dist/index.d.ts +21 -20
  85. package/dist/index.d.ts.map +1 -1
  86. package/dist/index.js +22 -40
  87. package/dist/index.js.map +1 -1
  88. package/dist/runCodeGen.d.ts +1 -0
  89. package/dist/runCodeGen.d.ts.map +1 -1
  90. package/dist/runCodeGen.js +151 -178
  91. package/dist/runCodeGen.js.map +1 -1
  92. package/package.json +24 -21
@@ -1,123 +1,117 @@
1
- "use strict";
2
1
  /**
3
2
  * Configuration management module for MemberJunction CodeGen.
4
3
  * Handles loading, parsing, and validation of configuration files using Zod schemas.
5
4
  * Supports various configuration sources through cosmiconfig (package.json, .mjrc, etc.).
6
5
  */
7
- var __importDefault = (this && this.__importDefault) || function (mod) {
8
- return (mod && mod.__esModule) ? mod : { "default": mod };
9
- };
10
- Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.mj_core_schema = exports.MAX_INDEX_NAME_LENGTH = exports.autoIndexForeignKeys = exports.getSettingValue = exports.getSetting = exports.customSqlScripts = exports.commands = exports.outputOptionValue = exports.outputOptions = exports.outputDir = exports.initializeConfig = exports.dbDatabase = exports.mjCoreSchema = exports.configInfo = exports.currentWorkingDirectory = exports.DEFAULT_CODEGEN_CONFIG = void 0;
12
- const zod_1 = require("zod");
13
- const cosmiconfig_1 = require("cosmiconfig");
14
- const path_1 = __importDefault(require("path"));
15
- const status_logging_1 = require("../Misc/status_logging");
16
- const config_1 = require("@memberjunction/config");
6
+ import { z } from 'zod';
7
+ import { cosmiconfigSync } from 'cosmiconfig';
8
+ import path from 'path';
9
+ import { logStatus } from '../Misc/status_logging.js';
10
+ import { mergeConfigs, parseBooleanEnv } from '@memberjunction/config';
17
11
  /** Global configuration explorer for finding MJ config files */
18
- const explorer = (0, cosmiconfig_1.cosmiconfigSync)('mj', { searchStrategy: 'global' });
12
+ const explorer = cosmiconfigSync('mj', { searchStrategy: 'global' });
19
13
  /** Initial config search result from current working directory */
20
14
  const configSearchResult = explorer.search(process.cwd());
21
- const settingInfoSchema = zod_1.z.object({
15
+ const settingInfoSchema = z.object({
22
16
  /** The name/key of the setting */
23
- name: zod_1.z.string(),
17
+ name: z.string(),
24
18
  /** The value of the setting (can be any type) */
25
- value: zod_1.z.any(),
19
+ value: z.any(),
26
20
  });
27
- const logInfoSchema = zod_1.z.object({
21
+ const logInfoSchema = z.object({
28
22
  /** Whether logging is enabled */
29
- log: zod_1.z.boolean().default(true),
23
+ log: z.boolean().default(true),
30
24
  /** File path for log output */
31
- logFile: zod_1.z.string().default('codegen.output.log'),
25
+ logFile: z.string().default('codegen.output.log'),
32
26
  /** Whether to also log to console */
33
- console: zod_1.z.boolean().default(true),
27
+ console: z.boolean().default(true),
34
28
  });
35
- const customSQLScriptSchema = zod_1.z.object({
29
+ const customSQLScriptSchema = z.object({
36
30
  /** When to run the script (e.g., 'before-all', 'after-all') */
37
- when: zod_1.z.string(),
31
+ when: z.string(),
38
32
  /** Path to the SQL script file */
39
- scriptFile: zod_1.z.string(),
33
+ scriptFile: z.string(),
40
34
  });
41
- const commandInfoSchema = zod_1.z.object({
35
+ const commandInfoSchema = z.object({
42
36
  /** Working directory to run the command from */
43
- workingDirectory: zod_1.z.string(),
37
+ workingDirectory: z.string(),
44
38
  /** The command to execute */
45
- command: zod_1.z.string(),
39
+ command: z.string(),
46
40
  /** Command line arguments */
47
- args: zod_1.z.string().array(),
41
+ args: z.string().array(),
48
42
  /** Optional timeout in milliseconds */
49
- timeout: zod_1.z.number().nullish(),
43
+ timeout: z.number().nullish(),
50
44
  /** When to run the command (e.g., 'before', 'after') */
51
- when: zod_1.z.string(),
45
+ when: z.string(),
52
46
  });
53
- const outputOptionInfoSchema = zod_1.z.object({
47
+ const outputOptionInfoSchema = z.object({
54
48
  /** Name of the output option */
55
- name: zod_1.z.string(),
49
+ name: z.string(),
56
50
  /** Value of the output option */
57
- value: zod_1.z.any(),
51
+ value: z.any(),
58
52
  });
59
- const outputInfoSchema = zod_1.z.object({
53
+ const outputInfoSchema = z.object({
60
54
  /** Type of output (e.g., 'SQL', 'Angular', 'GraphQLServer') */
61
- type: zod_1.z.string(),
55
+ type: z.string(),
62
56
  /** Directory path for output files */
63
- directory: zod_1.z.string(),
57
+ directory: z.string(),
64
58
  /** Whether to append additional output code subdirectory */
65
- appendOutputCode: zod_1.z.boolean().optional(),
59
+ appendOutputCode: z.boolean().optional(),
66
60
  /** Additional options for this output type */
67
61
  options: outputOptionInfoSchema.array().optional(),
68
62
  });
69
- const tableInfoSchema = zod_1.z.object({
63
+ const tableInfoSchema = z.object({
70
64
  /** Schema name (supports wildcards like '%') */
71
- schema: zod_1.z.string(),
65
+ schema: z.string(),
72
66
  /** Table name (supports wildcards like 'sys%') */
73
- table: zod_1.z.string(),
67
+ table: z.string(),
74
68
  });
75
- const dbSchemaJSONOutputBundleSchema = zod_1.z.object({
69
+ const dbSchemaJSONOutputBundleSchema = z.object({
76
70
  /** Name of the bundle */
77
- name: zod_1.z.string(),
71
+ name: z.string(),
78
72
  /** Schemas to include in this bundle */
79
- schemas: zod_1.z.string().array().default([]),
73
+ schemas: z.string().array().default([]),
80
74
  /** Schemas to exclude from this bundle */
81
- excludeSchemas: zod_1.z.string().array().default(['sys', 'staging']),
75
+ excludeSchemas: z.string().array().default(['sys', 'staging']),
82
76
  /** Entities to exclude from this bundle */
83
- excludeEntities: zod_1.z.string().array().default([]),
77
+ excludeEntities: z.string().array().default([]),
84
78
  });
85
- const dbSchemaJSONOutputSchema = zod_1.z.object({
86
- excludeEntities: zod_1.z.string().array(),
87
- excludeSchemas: zod_1.z.string().array().default(['sys', 'staging', 'dbo']),
79
+ const dbSchemaJSONOutputSchema = z.object({
80
+ excludeEntities: z.string().array(),
81
+ excludeSchemas: z.string().array().default(['sys', 'staging', 'dbo']),
88
82
  bundles: dbSchemaJSONOutputBundleSchema.array().default([{ name: '_Core_Apps', excludeSchemas: ['__mj'] }]),
89
83
  });
90
- const newUserSetupSchema = zod_1.z.object({
91
- UserName: zod_1.z.string(),
92
- FirstName: zod_1.z.string(),
93
- LastName: zod_1.z.string(),
94
- Email: zod_1.z.string(),
95
- Roles: zod_1.z.string().array().default(['Developer', 'Integration', 'UI']),
96
- CreateUserApplicationRecords: zod_1.z.boolean().optional().default(false),
97
- UserApplications: zod_1.z.array(zod_1.z.string()).optional().default([]),
84
+ const newUserSetupSchema = z.object({
85
+ UserName: z.string(),
86
+ FirstName: z.string(),
87
+ LastName: z.string(),
88
+ Email: z.string(),
89
+ Roles: z.string().array().default(['Developer', 'Integration', 'UI']),
90
+ CreateUserApplicationRecords: z.boolean().optional().default(false),
91
+ UserApplications: z.array(z.string()).optional().default([]),
98
92
  });
99
- const advancedGenerationFeatureOptionSchema = zod_1.z.object({
93
+ const advancedGenerationFeatureOptionSchema = z.object({
100
94
  /** Name of the option */
101
- name: zod_1.z.string(),
95
+ name: z.string(),
102
96
  /** Value of the option (can be any type) */
103
- value: zod_1.z.unknown(),
97
+ value: z.unknown(),
104
98
  });
105
- const advancedGenerationFeatureSchema = zod_1.z.object({
99
+ const advancedGenerationFeatureSchema = z.object({
106
100
  /** Name of the feature */
107
- name: zod_1.z.string(),
101
+ name: z.string(),
108
102
  /** Whether the feature is enabled */
109
- enabled: zod_1.z.boolean(),
103
+ enabled: z.boolean(),
110
104
  /** Description for documentation (not used by code) */
111
- description: zod_1.z.string().nullish(),
105
+ description: z.string().nullish(),
112
106
  /** System prompt for AI interaction */
113
- systemPrompt: zod_1.z.string().nullish(),
107
+ systemPrompt: z.string().nullish(),
114
108
  /** User message template for AI interaction */
115
- userMessage: zod_1.z.string().nullish(),
109
+ userMessage: z.string().nullish(),
116
110
  /** Additional options for the feature */
117
111
  options: advancedGenerationFeatureOptionSchema.array().nullish(),
118
112
  });
119
- const advancedGenerationSchema = zod_1.z.object({
120
- enableAdvancedGeneration: zod_1.z.boolean().default(true),
113
+ const advancedGenerationSchema = z.object({
114
+ enableAdvancedGeneration: z.boolean().default(true),
121
115
  // NOTE: AIVendor and AIModel have been removed. Model configuration is now per-prompt
122
116
  // in the AI Prompts table via the MJ: AI Prompt Models relationship.
123
117
  features: advancedGenerationFeatureSchema.array().default([
@@ -158,128 +152,143 @@ const advancedGenerationSchema = zod_1.z.object({
158
152
  },
159
153
  ]),
160
154
  });
161
- const integrityCheckConfigSchema = zod_1.z.object({
162
- enabled: zod_1.z.boolean(),
163
- entityFieldsSequenceCheck: zod_1.z.boolean(),
155
+ const integrityCheckConfigSchema = z.object({
156
+ enabled: z.boolean(),
157
+ entityFieldsSequenceCheck: z.boolean(),
164
158
  });
165
- const forceRegenerationConfigSchema = zod_1.z.object({
159
+ const forceRegenerationConfigSchema = z.object({
166
160
  /**
167
161
  * Force regeneration of all SQL objects even if no schema changes are detected
168
162
  */
169
- enabled: zod_1.z.boolean().default(false),
163
+ enabled: z.boolean().default(false),
170
164
  /**
171
165
  * Optional SQL WHERE clause to filter entities for forced regeneration
172
166
  * Example: "SchemaName = 'dbo' AND Name LIKE 'User%'"
173
167
  */
174
- entityWhereClause: zod_1.z.string().optional(),
168
+ entityWhereClause: z.string().optional(),
175
169
  /**
176
170
  * Force regeneration of base views
177
171
  */
178
- baseViews: zod_1.z.boolean().default(false),
172
+ baseViews: z.boolean().default(false),
179
173
  /**
180
174
  * Force regeneration of spCreate procedures
181
175
  */
182
- spCreate: zod_1.z.boolean().default(false),
176
+ spCreate: z.boolean().default(false),
183
177
  /**
184
178
  * Force regeneration of spUpdate procedures
185
179
  */
186
- spUpdate: zod_1.z.boolean().default(false),
180
+ spUpdate: z.boolean().default(false),
187
181
  /**
188
182
  * Force regeneration of spDelete procedures
189
183
  */
190
- spDelete: zod_1.z.boolean().default(false),
184
+ spDelete: z.boolean().default(false),
191
185
  /**
192
186
  * Force regeneration of all stored procedures
193
187
  */
194
- allStoredProcedures: zod_1.z.boolean().default(false),
188
+ allStoredProcedures: z.boolean().default(false),
195
189
  /**
196
190
  * Force regeneration of indexes for foreign keys
197
191
  */
198
- indexes: zod_1.z.boolean().default(false),
192
+ indexes: z.boolean().default(false),
199
193
  /**
200
194
  * Force regeneration of full text search components
201
195
  */
202
- fullTextSearch: zod_1.z.boolean().default(false),
196
+ fullTextSearch: z.boolean().default(false),
203
197
  });
204
- const sqlOutputConfigSchema = zod_1.z.object({
198
+ const sqlOutputConfigSchema = z.object({
205
199
  /**
206
200
  * Whether or not sql statements generated while managing metadata should be written to a file
207
201
  */
208
- enabled: zod_1.z.boolean().default(true),
202
+ enabled: z.boolean().default(true),
209
203
  /**
210
204
  * The path of the folder to use when logging is enabled.
211
205
  * If provided, a file will be created with the format "CodeGen_Run_yyyy-mm-dd_hh-mm-ss.sql"
212
206
  */
213
- folderPath: zod_1.z.string().default('../../migrations/v3/'),
207
+ folderPath: z.string().default('../../migrations/v3/'),
214
208
  /**
215
209
  * Optional, the file name that will be written WITHIN the folderPath specified.
216
210
  */
217
- fileName: zod_1.z.string().optional(),
211
+ fileName: z.string().optional(),
218
212
  /**
219
213
  * If set to true, then we append to the existing file, if one exists, otherwise we create a new file.
220
214
  */
221
- appendToFile: zod_1.z.boolean().default(true),
215
+ appendToFile: z.boolean().default(true),
222
216
  /**
223
217
  * If true, all mention of the core schema within the log file will be replaced with the flyway schema,
224
218
  * ${flyway:defaultSchema}
225
219
  */
226
- convertCoreSchemaToFlywayMigrationFile: zod_1.z.boolean().default(true),
220
+ convertCoreSchemaToFlywayMigrationFile: z.boolean().default(true),
227
221
  /**
228
222
  * If true, scripts that are being emitted via SQL logging that are marked by CodeGen as recurring will be SKIPPED. Defaults to false
229
223
  */
230
- omitRecurringScriptsFromLog: zod_1.z.boolean().default(false),
224
+ omitRecurringScriptsFromLog: z.boolean().default(false),
225
+ /**
226
+ * Optional array of schema-to-placeholder mappings for Flyway migrations.
227
+ * Each mapping specifies a database schema name and its corresponding Flyway placeholder.
228
+ * If not provided, defaults to replacing the MJ core schema with ${flyway:defaultSchema}.
229
+ *
230
+ * Example:
231
+ * [
232
+ * { schema: '__mj', placeholder: '${mjSchema}' },
233
+ * { schema: '__BCSaaS', placeholder: '${flyway:defaultSchema}' }
234
+ * ]
235
+ */
236
+ schemaPlaceholders: z.array(z.object({
237
+ schema: z.string(),
238
+ placeholder: z.string()
239
+ })).optional(),
231
240
  });
232
- const newSchemaDefaultsSchema = zod_1.z.object({
233
- CreateNewApplicationWithSchemaName: zod_1.z.boolean().default(true),
241
+ const newSchemaDefaultsSchema = z.object({
242
+ CreateNewApplicationWithSchemaName: z.boolean().default(true),
234
243
  });
235
- const entityPermissionSchema = zod_1.z.object({
236
- RoleName: zod_1.z.string(),
237
- CanRead: zod_1.z.boolean(),
238
- CanCreate: zod_1.z.boolean(),
239
- CanUpdate: zod_1.z.boolean(),
240
- CanDelete: zod_1.z.boolean(),
244
+ const entityPermissionSchema = z.object({
245
+ RoleName: z.string(),
246
+ CanRead: z.boolean(),
247
+ CanCreate: z.boolean(),
248
+ CanUpdate: z.boolean(),
249
+ CanDelete: z.boolean(),
241
250
  });
242
- const newEntityPermissionDefaultsSchema = zod_1.z.object({
243
- AutoAddPermissionsForNewEntities: zod_1.z.boolean().default(true),
251
+ const newEntityPermissionDefaultsSchema = z.object({
252
+ AutoAddPermissionsForNewEntities: z.boolean().default(true),
244
253
  Permissions: entityPermissionSchema.array().default([
245
254
  { RoleName: 'UI', CanRead: true, CanCreate: false, CanUpdate: false, CanDelete: false },
246
255
  { RoleName: 'Developer', CanRead: true, CanCreate: true, CanUpdate: true, CanDelete: false },
247
256
  { RoleName: 'Integration', CanRead: true, CanCreate: true, CanUpdate: true, CanDelete: true },
248
257
  ]),
249
258
  });
250
- const newEntityNameRulesBySchema = zod_1.z.object({
251
- SchemaName: zod_1.z.string(),
252
- EntityNamePrefix: zod_1.z.string().default(''),
253
- EntityNameSuffix: zod_1.z.string().default(''),
259
+ const newEntityNameRulesBySchema = z.object({
260
+ SchemaName: z.string(),
261
+ EntityNamePrefix: z.string().default(''),
262
+ EntityNameSuffix: z.string().default(''),
254
263
  });
255
- const newEntityDefaultsSchema = zod_1.z.object({
256
- TrackRecordChanges: zod_1.z.boolean().default(true),
257
- AuditRecordAccess: zod_1.z.boolean().default(false),
258
- AuditViewRuns: zod_1.z.boolean().default(false),
259
- AllowAllRowsAPI: zod_1.z.boolean().default(false),
260
- AllowCreateAPI: zod_1.z.boolean().default(true),
261
- AllowUpdateAPI: zod_1.z.boolean().default(true),
262
- AllowDeleteAPI: zod_1.z.boolean().default(true),
263
- AllowUserSearchAPI: zod_1.z.boolean().default(true),
264
- CascadeDeletes: zod_1.z.boolean().default(false),
265
- UserViewMaxRows: zod_1.z.number().default(1000),
266
- AddToApplicationWithSchemaName: zod_1.z.boolean().default(true),
267
- IncludeFirstNFieldsAsDefaultInView: zod_1.z.number().default(5),
264
+ const newEntityDefaultsSchema = z.object({
265
+ TrackRecordChanges: z.boolean().default(true),
266
+ AuditRecordAccess: z.boolean().default(false),
267
+ AuditViewRuns: z.boolean().default(false),
268
+ AllowAllRowsAPI: z.boolean().default(false),
269
+ AllowCreateAPI: z.boolean().default(true),
270
+ AllowUpdateAPI: z.boolean().default(true),
271
+ AllowDeleteAPI: z.boolean().default(true),
272
+ AllowUserSearchAPI: z.boolean().default(true),
273
+ CascadeDeletes: z.boolean().default(false),
274
+ UserViewMaxRows: z.number().default(1000),
275
+ AddToApplicationWithSchemaName: z.boolean().default(true),
276
+ IncludeFirstNFieldsAsDefaultInView: z.number().default(5),
268
277
  PermissionDefaults: newEntityPermissionDefaultsSchema,
269
278
  NameRulesBySchema: newEntityNameRulesBySchema.array().default([]),
270
279
  });
271
- const newEntityRelationshipDefaultsSchema = zod_1.z.object({
272
- AutomaticallyCreateRelationships: zod_1.z.boolean().default(true),
273
- CreateOneToManyRelationships: zod_1.z.boolean().default(true),
280
+ const newEntityRelationshipDefaultsSchema = z.object({
281
+ AutomaticallyCreateRelationships: z.boolean().default(true),
282
+ CreateOneToManyRelationships: z.boolean().default(true),
274
283
  });
275
- const configInfoSchema = zod_1.z.object({
284
+ const configInfoSchema = z.object({
276
285
  newUserSetup: newUserSetupSchema.nullish(),
277
286
  settings: settingInfoSchema.array().default([
278
287
  { name: 'mj_core_schema', value: '__mj' },
279
288
  { name: 'skip_database_generation', value: false },
280
289
  { name: 'auto_index_foreign_keys', value: true },
281
290
  ]),
282
- excludeSchemas: zod_1.z.string().array().default(['sys', 'staging']),
291
+ excludeSchemas: z.string().array().default(['sys', 'staging']),
283
292
  excludeTables: tableInfoSchema.array().default([
284
293
  { schema: '%', table: 'sys%' },
285
294
  { schema: '%', table: 'flyway_schema_history' }
@@ -320,6 +329,8 @@ const configInfoSchema = zod_1.z.object({
320
329
  { workingDirectory: '../MJServer', command: 'npm', args: ['run', 'build'], when: 'after' },
321
330
  { workingDirectory: '../MJAPI', command: 'npm', args: ['start'], timeout: 30000, when: 'after' },
322
331
  ]),
332
+ /** Path to JSON file containing soft PK/FK definitions for tables without database constraints */
333
+ additionalSchemaInfo: z.string().optional(),
323
334
  logging: logInfoSchema,
324
335
  newEntityDefaults: newEntityDefaultsSchema,
325
336
  newSchemaDefaults: newSchemaDefaultsSchema,
@@ -327,20 +338,21 @@ const configInfoSchema = zod_1.z.object({
327
338
  newEntityRelationshipDefaults: newEntityRelationshipDefaultsSchema,
328
339
  SQLOutput: sqlOutputConfigSchema,
329
340
  forceRegeneration: forceRegenerationConfigSchema,
330
- dbHost: zod_1.z.string(),
331
- dbPort: zod_1.z.coerce.number().int().positive().default(1433),
332
- codeGenLogin: zod_1.z.string(),
333
- codeGenPassword: zod_1.z.string(),
334
- dbDatabase: zod_1.z.string(),
335
- dbInstanceName: zod_1.z.string().nullish(),
336
- dbTrustServerCertificate: zod_1.z.coerce
341
+ dbHost: z.string(),
342
+ dbPort: z.coerce.number().int().positive().default(1433),
343
+ codeGenLogin: z.string(),
344
+ codeGenPassword: z.string(),
345
+ dbDatabase: z.string(),
346
+ dbInstanceName: z.string().nullish(),
347
+ dbTrustServerCertificate: z.coerce
337
348
  .boolean()
338
349
  .default(false)
339
350
  .transform((v) => (v ? 'Y' : 'N')),
340
- outputCode: zod_1.z.string().nullish(),
341
- mjCoreSchema: zod_1.z.string().default('__mj'),
342
- graphqlPort: zod_1.z.coerce.number().int().positive().default(4000),
343
- verboseOutput: zod_1.z.boolean().optional().default(false),
351
+ outputCode: z.string().nullish(),
352
+ mjCoreSchema: z.string().default('__mj'),
353
+ graphqlPort: z.coerce.number().int().positive().default(4000),
354
+ entityPackageName: z.string().default('mj_generatedentities'),
355
+ verboseOutput: z.boolean().optional().default(false),
344
356
  });
345
357
  /**
346
358
  * Default CodeGen configuration - provides sensible defaults for all CodeGen settings.
@@ -348,7 +360,7 @@ const configInfoSchema = zod_1.z.object({
348
360
  *
349
361
  * Database connection settings come from environment variables.
350
362
  */
351
- exports.DEFAULT_CODEGEN_CONFIG = {
363
+ export const DEFAULT_CODEGEN_CONFIG = {
352
364
  // Database connection settings (from environment variables)
353
365
  dbHost: process.env.DB_HOST ?? 'localhost',
354
366
  dbPort: 1433,
@@ -356,7 +368,7 @@ exports.DEFAULT_CODEGEN_CONFIG = {
356
368
  codeGenLogin: process.env.CODEGEN_DB_USERNAME ?? '',
357
369
  codeGenPassword: process.env.CODEGEN_DB_PASSWORD ?? '',
358
370
  dbInstanceName: process.env.DB_INSTANCE_NAME,
359
- dbTrustServerCertificate: ['true', '1', 'Y', 'y'].includes(process.env.DB_TRUST_SERVER_CERTIFICATE ?? '') ? 'Y' : 'N',
371
+ dbTrustServerCertificate: parseBooleanEnv(process.env.DB_TRUST_SERVER_CERTIFICATE) ? 'Y' : 'N',
360
372
  mjCoreSchema: '__mj',
361
373
  graphqlPort: 4000,
362
374
  verboseOutput: false,
@@ -483,14 +495,14 @@ exports.DEFAULT_CODEGEN_CONFIG = {
483
495
  /**
484
496
  * Current working directory for the code generation process
485
497
  */
486
- exports.currentWorkingDirectory = process.cwd();
498
+ export let currentWorkingDirectory = process.cwd();
487
499
  /**
488
500
  * Merge user config with DEFAULT_CODEGEN_CONFIG.
489
501
  * Database settings come from user config or environment variables.
490
502
  */
491
503
  const mergedConfig = configSearchResult?.config
492
- ? (0, config_1.mergeConfigs)(exports.DEFAULT_CODEGEN_CONFIG, configSearchResult.config)
493
- : exports.DEFAULT_CODEGEN_CONFIG;
504
+ ? mergeConfigs(DEFAULT_CODEGEN_CONFIG, configSearchResult.config)
505
+ : DEFAULT_CODEGEN_CONFIG;
494
506
  /** Parse and validate the merged configuration */
495
507
  const configParsing = configInfoSchema.safeParse(mergedConfig);
496
508
  // Don't log errors at module load - commands that need config will validate explicitly
@@ -500,67 +512,65 @@ const configParsing = configInfoSchema.safeParse(mergedConfig);
500
512
  /**
501
513
  * Parsed configuration object with fallback to empty object if parsing fails
502
514
  */
503
- exports.configInfo = configParsing.data ?? {};
515
+ export const configInfo = configParsing.data ?? {};
504
516
  /**
505
517
  * Destructured commonly used configuration values
506
518
  */
507
- exports.mjCoreSchema = exports.configInfo.mjCoreSchema, exports.dbDatabase = exports.configInfo.dbDatabase;
519
+ export const { mjCoreSchema, dbDatabase } = configInfo;
508
520
  /**
509
521
  * Initializes configuration from the specified working directory
510
522
  * @param cwd The current working directory to search for config files
511
523
  * @returns Parsed configuration object
512
524
  * @throws Error if no configuration is found
513
525
  */
514
- function initializeConfig(cwd) {
515
- exports.currentWorkingDirectory = cwd;
526
+ export function initializeConfig(cwd) {
527
+ currentWorkingDirectory = cwd;
516
528
  // Merge user config with DEFAULT_CODEGEN_CONFIG
517
- const userConfigResult = explorer.search(exports.currentWorkingDirectory);
529
+ const userConfigResult = explorer.search(currentWorkingDirectory);
518
530
  const mergedConfig = userConfigResult?.config
519
- ? (0, config_1.mergeConfigs)(exports.DEFAULT_CODEGEN_CONFIG, userConfigResult.config)
520
- : exports.DEFAULT_CODEGEN_CONFIG;
531
+ ? mergeConfigs(DEFAULT_CODEGEN_CONFIG, userConfigResult.config)
532
+ : DEFAULT_CODEGEN_CONFIG;
521
533
  const maybeConfig = configInfoSchema.safeParse(mergedConfig);
522
534
  // Don't log errors - let the calling code handle validation failures
523
535
  // if (!maybeConfig.success) {
524
536
  // LogError('Error parsing config file', null, JSON.stringify(maybeConfig.error.issues, null, 2));
525
537
  // }
526
- const config = maybeConfig.success ? maybeConfig.data : exports.configInfo;
538
+ const config = maybeConfig.success ? maybeConfig.data : configInfo;
527
539
  if (config === undefined) {
528
540
  throw new Error('No configuration found');
529
541
  }
530
542
  return config;
531
543
  }
532
- exports.initializeConfig = initializeConfig;
533
544
  /**
534
545
  * Gets the output directory for a specific generation type
535
546
  * @param type The type of output (e.g., 'SQL', 'Angular')
536
547
  * @param useLocalDirectoryIfMissing Whether to use a local directory if config is missing
537
548
  * @returns The output directory path or null if not found
538
549
  */
539
- function outputDir(type, useLocalDirectoryIfMissing) {
540
- const outputInfo = exports.configInfo.output.find((o) => o.type.trim().toUpperCase() === type.trim().toUpperCase());
550
+ export function outputDir(type, useLocalDirectoryIfMissing) {
551
+ const outputInfo = configInfo.output.find((o) => o.type.trim().toUpperCase() === type.trim().toUpperCase());
541
552
  if (outputInfo) {
542
- if (outputInfo.appendOutputCode && outputInfo.appendOutputCode === true && exports.configInfo.outputCode)
543
- return path_1.default.join(exports.currentWorkingDirectory, outputInfo.directory, exports.configInfo.outputCode);
553
+ if (outputInfo.appendOutputCode && outputInfo.appendOutputCode === true && configInfo.outputCode)
554
+ return path.join(currentWorkingDirectory, outputInfo.directory, configInfo.outputCode);
544
555
  else
545
- return path_1.default.join(exports.currentWorkingDirectory, outputInfo.directory);
556
+ return path.join(currentWorkingDirectory, outputInfo.directory);
546
557
  }
547
558
  else {
548
559
  if (useLocalDirectoryIfMissing) {
549
- (0, status_logging_1.logStatus)('>>> No output directory found for type: ' + type + ' within config file, using local directory instead');
550
- return path_1.default.join(exports.currentWorkingDirectory, 'output', type);
560
+ logStatus('>>> No output directory found for type: ' + type + ' within config file, using local directory instead');
561
+ return path.join(currentWorkingDirectory, 'output', type);
551
562
  }
552
563
  else
553
564
  return null;
554
565
  }
555
566
  }
556
- exports.outputDir = outputDir;
557
567
  /**
558
568
  * Gets the output options for a specific generation type
559
569
  * @param type The type of output
560
570
  * @returns Array of output options or null if not found
561
571
  */
562
- function outputOptions(type) {
563
- const outputInfo = exports.configInfo.output.find((o) => o.type.trim().toUpperCase() === type.trim().toUpperCase());
572
+ export function outputOptions(type) {
573
+ const outputInfo = configInfo.output.find((o) => o.type.trim().toUpperCase() === type.trim().toUpperCase());
564
574
  if (outputInfo) {
565
575
  return outputInfo.options;
566
576
  }
@@ -568,7 +578,6 @@ function outputOptions(type) {
568
578
  return null;
569
579
  }
570
580
  }
571
- exports.outputOptions = outputOptions;
572
581
  /**
573
582
  * Gets a specific output option value for a generation type
574
583
  * @param type The type of output
@@ -576,8 +585,8 @@ exports.outputOptions = outputOptions;
576
585
  * @param defaultValue Default value if option is not found
577
586
  * @returns The option value or default value
578
587
  */
579
- function outputOptionValue(type, optionName, defaultValue) {
580
- const outputInfo = exports.configInfo.output?.find((o) => o.type.trim().toUpperCase() === type.trim().toUpperCase());
588
+ export function outputOptionValue(type, optionName, defaultValue) {
589
+ const outputInfo = configInfo.output?.find((o) => o.type.trim().toUpperCase() === type.trim().toUpperCase());
581
590
  if (outputInfo && outputInfo.options) {
582
591
  const theOption = outputInfo.options.find((o) => o.name.trim().toUpperCase() === optionName.trim().toUpperCase());
583
592
  if (theOption)
@@ -589,53 +598,48 @@ function outputOptionValue(type, optionName, defaultValue) {
589
598
  return defaultValue;
590
599
  }
591
600
  }
592
- exports.outputOptionValue = outputOptionValue;
593
601
  /**
594
602
  * Gets commands configured to run at a specific time
595
603
  * @param when When the commands should run (e.g., 'before', 'after')
596
604
  * @returns Array of commands to execute
597
605
  */
598
- function commands(when) {
599
- return exports.configInfo.commands.filter((c) => c.when.trim().toUpperCase() === when.trim().toUpperCase());
606
+ export function commands(when) {
607
+ return configInfo.commands.filter((c) => c.when.trim().toUpperCase() === when.trim().toUpperCase());
600
608
  }
601
- exports.commands = commands;
602
609
  /**
603
610
  * Gets custom SQL scripts configured to run at a specific time
604
611
  * @param when When the scripts should run
605
612
  * @returns Array of SQL scripts to execute
606
613
  */
607
- function customSqlScripts(when) {
608
- return exports.configInfo.customSQLScripts.filter((c) => c.when.trim().toUpperCase() === when.trim().toUpperCase());
614
+ export function customSqlScripts(when) {
615
+ return configInfo.customSQLScripts.filter((c) => c.when.trim().toUpperCase() === when.trim().toUpperCase());
609
616
  }
610
- exports.customSqlScripts = customSqlScripts;
611
617
  /**
612
618
  * Gets a specific setting by name
613
619
  * @param settingName The name of the setting to retrieve
614
620
  * @returns The setting object
615
621
  */
616
- function getSetting(settingName) {
617
- return exports.configInfo.settings.find((s) => s.name.trim().toUpperCase() === settingName.trim().toUpperCase());
622
+ export function getSetting(settingName) {
623
+ return configInfo.settings.find((s) => s.name.trim().toUpperCase() === settingName.trim().toUpperCase());
618
624
  }
619
- exports.getSetting = getSetting;
620
625
  /**
621
626
  * Gets the value of a specific setting
622
627
  * @param settingName The name of the setting
623
628
  * @param defaultValue Default value if setting is not found
624
629
  * @returns The setting value or default value
625
630
  */
626
- function getSettingValue(settingName, defaultValue) {
631
+ export function getSettingValue(settingName, defaultValue) {
627
632
  const setting = getSetting(settingName);
628
633
  if (setting)
629
634
  return setting.value;
630
635
  else
631
636
  return defaultValue;
632
637
  }
633
- exports.getSettingValue = getSettingValue;
634
638
  /**
635
639
  * Checks if automatic indexing of foreign keys is enabled
636
640
  * @returns True if auto-indexing is enabled, false otherwise
637
641
  */
638
- function autoIndexForeignKeys() {
642
+ export function autoIndexForeignKeys() {
639
643
  const keyName = 'auto_index_foreign_keys';
640
644
  const setting = getSetting(keyName);
641
645
  if (setting)
@@ -643,17 +647,15 @@ function autoIndexForeignKeys() {
643
647
  else
644
648
  return false;
645
649
  }
646
- exports.autoIndexForeignKeys = autoIndexForeignKeys;
647
650
  /**
648
651
  * Maximum length allowed for database index names
649
652
  */
650
- exports.MAX_INDEX_NAME_LENGTH = 128;
653
+ export const MAX_INDEX_NAME_LENGTH = 128;
651
654
  /**
652
655
  * Gets the MemberJunction core schema name from configuration
653
656
  * @returns The core schema name (typically '__mj')
654
657
  */
655
- function mj_core_schema() {
658
+ export function mj_core_schema() {
656
659
  return getSetting('mj_core_schema').value;
657
660
  }
658
- exports.mj_core_schema = mj_core_schema;
659
661
  //# sourceMappingURL=config.js.map