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