@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/runCodeGen.js
CHANGED
|
@@ -1,59 +1,33 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* Main orchestrator for the MemberJunction code generation process.
|
|
4
3
|
* Coordinates all aspects of code generation including database schema analysis,
|
|
5
4
|
* metadata management, SQL generation, TypeScript entities, Angular components,
|
|
6
5
|
* GraphQL resolvers, and more.
|
|
7
6
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
};
|
|
31
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
-
exports.runMemberJunctionCodeGeneration = exports.RunCodeGenBase = void 0;
|
|
33
|
-
const graphql_server_codegen_1 = require("./Misc/graphql_server_codegen");
|
|
34
|
-
const sql_codegen_1 = require("./Database/sql_codegen");
|
|
35
|
-
const entity_subclasses_codegen_1 = require("./Misc/entity_subclasses_codegen");
|
|
36
|
-
const sqlserver_dataprovider_1 = require("@memberjunction/sqlserver-dataprovider");
|
|
37
|
-
const db_connection_1 = require("./Config/db-connection");
|
|
38
|
-
const manage_metadata_1 = require("./Database/manage-metadata");
|
|
39
|
-
const config_1 = require("./Config/config");
|
|
40
|
-
const status_logging_1 = require("./Misc/status_logging");
|
|
41
|
-
const MJ = __importStar(require("@memberjunction/core"));
|
|
42
|
-
const runCommand_1 = require("./Misc/runCommand");
|
|
43
|
-
const dbSchema_1 = require("./Database/dbSchema");
|
|
44
|
-
const angular_codegen_1 = require("./Angular/angular-codegen");
|
|
45
|
-
const sqlserver_dataprovider_2 = require("@memberjunction/sqlserver-dataprovider");
|
|
46
|
-
const createNewUser_1 = require("./Misc/createNewUser");
|
|
47
|
-
const global_1 = require("@memberjunction/global");
|
|
48
|
-
const action_subclasses_codegen_1 = require("./Misc/action_subclasses_codegen");
|
|
49
|
-
const sql_logging_1 = require("./Misc/sql_logging");
|
|
50
|
-
const system_integrity_1 = require("./Misc/system_integrity");
|
|
51
|
-
const actions_base_1 = require("@memberjunction/actions-base");
|
|
52
|
-
const core_entities_server_1 = require("@memberjunction/core-entities-server");
|
|
53
|
-
const aiengine_1 = require("@memberjunction/aiengine");
|
|
54
|
-
(0, core_entities_server_1.LoadCoreEntitiesServerSubClasses)(); // Load the core entities server subclasses to ensure they are registered and not tree shaken
|
|
7
|
+
import { GraphQLServerGeneratorBase } from './Misc/graphql_server_codegen.js';
|
|
8
|
+
import { SQLCodeGenBase } from './Database/sql_codegen.js';
|
|
9
|
+
import { EntitySubClassGeneratorBase } from './Misc/entity_subclasses_codegen.js';
|
|
10
|
+
import { UserCache, setupSQLServerClient } from '@memberjunction/sqlserver-dataprovider';
|
|
11
|
+
import { MSSQLConnection, sqlConfig } from './Config/db-connection.js';
|
|
12
|
+
import { ManageMetadataBase } from './Database/manage-metadata.js';
|
|
13
|
+
import { outputDir, commands, mj_core_schema, configInfo, getSettingValue } from './Config/config.js';
|
|
14
|
+
import { logError, logWarning, startSpinner, updateSpinner, succeedSpinner, failSpinner, warnSpinner } from './Misc/status_logging.js';
|
|
15
|
+
import * as MJ from '@memberjunction/core';
|
|
16
|
+
import { RunCommandsBase } from './Misc/runCommand.js';
|
|
17
|
+
import { DBSchemaGeneratorBase } from './Database/dbSchema.js';
|
|
18
|
+
import { AngularClientGeneratorBase } from './Angular/angular-codegen.js';
|
|
19
|
+
import { SQLServerProviderConfigData } from '@memberjunction/sqlserver-dataprovider';
|
|
20
|
+
import { CreateNewUserBase } from './Misc/createNewUser.js';
|
|
21
|
+
import { MJGlobal } from '@memberjunction/global';
|
|
22
|
+
import { ActionSubClassGeneratorBase } from './Misc/action_subclasses_codegen.js';
|
|
23
|
+
import { SQLLogging } from './Misc/sql_logging.js';
|
|
24
|
+
import { SystemIntegrityBase } from './Misc/system_integrity.js';
|
|
25
|
+
import { ActionEngineBase } from '@memberjunction/actions-base';
|
|
26
|
+
import { AIEngine } from '@memberjunction/aiengine';
|
|
27
|
+
// Import pre-built MJ class registrations manifest (covers all @memberjunction/* packages)
|
|
28
|
+
import '@memberjunction/server-bootstrap-lite/mj-class-registrations';
|
|
55
29
|
/** Extract core schema name from configuration */
|
|
56
|
-
const { mjCoreSchema } =
|
|
30
|
+
const { mjCoreSchema } = configInfo;
|
|
57
31
|
/**
|
|
58
32
|
* Main orchestrator class for the MemberJunction code generation process.
|
|
59
33
|
*
|
|
@@ -82,7 +56,7 @@ const { mjCoreSchema } = config_1.configInfo;
|
|
|
82
56
|
* await codeGen.Run(true); // Skip database operations
|
|
83
57
|
* ```
|
|
84
58
|
*/
|
|
85
|
-
class RunCodeGenBase {
|
|
59
|
+
export class RunCodeGenBase {
|
|
86
60
|
/**
|
|
87
61
|
* Sets up the SQL Server data source and initializes the MemberJunction core metadata.
|
|
88
62
|
* This method establishes the database connection pool and configures the data provider
|
|
@@ -98,20 +72,20 @@ class RunCodeGenBase {
|
|
|
98
72
|
/****************************************************************************************
|
|
99
73
|
// First, setup the data source and make sure the metadata and related stuff for MJCore is initialized
|
|
100
74
|
****************************************************************************************/
|
|
101
|
-
|
|
102
|
-
const pool = await
|
|
103
|
-
const config = new
|
|
104
|
-
const sqlServerProvider = await
|
|
75
|
+
startSpinner('Initializing database connection...');
|
|
76
|
+
const pool = await MSSQLConnection(); // get the MSSQL connection pool
|
|
77
|
+
const config = new SQLServerProviderConfigData(pool, mj_core_schema());
|
|
78
|
+
const sqlServerProvider = await setupSQLServerClient(config);
|
|
105
79
|
// Get connection details from the sqlConfig
|
|
106
|
-
let connectionInfo =
|
|
107
|
-
if (
|
|
108
|
-
connectionInfo += `:${
|
|
80
|
+
let connectionInfo = sqlConfig.server;
|
|
81
|
+
if (sqlConfig.port) {
|
|
82
|
+
connectionInfo += `:${sqlConfig.port}`;
|
|
109
83
|
}
|
|
110
|
-
if (
|
|
111
|
-
connectionInfo += `\\${
|
|
84
|
+
if (sqlConfig.options?.instanceName) {
|
|
85
|
+
connectionInfo += `\\${sqlConfig.options.instanceName}`;
|
|
112
86
|
}
|
|
113
|
-
connectionInfo += `/${
|
|
114
|
-
|
|
87
|
+
connectionInfo += `/${sqlConfig.database}`;
|
|
88
|
+
succeedSpinner(`Database connection initialized: ${connectionInfo}`);
|
|
115
89
|
return sqlServerProvider;
|
|
116
90
|
}
|
|
117
91
|
/**
|
|
@@ -142,329 +116,328 @@ class RunCodeGenBase {
|
|
|
142
116
|
async Run(skipDatabaseGeneration = false) {
|
|
143
117
|
try {
|
|
144
118
|
const startTime = new Date();
|
|
145
|
-
|
|
119
|
+
startSpinner(`Starting MemberJunction CodeGen @ ${startTime.toLocaleString()}`);
|
|
146
120
|
const provider = await this.setupDataSource();
|
|
147
|
-
|
|
148
|
-
const pool = await
|
|
149
|
-
await
|
|
150
|
-
const userMatch =
|
|
151
|
-
const currentUser = userMatch ? userMatch :
|
|
121
|
+
updateSpinner('Loading user cache and metadata...');
|
|
122
|
+
const pool = await MSSQLConnection();
|
|
123
|
+
await UserCache.Instance.Refresh(pool);
|
|
124
|
+
const userMatch = UserCache.Users.find((u) => u?.Type?.trim().toLowerCase() === 'owner');
|
|
125
|
+
const currentUser = userMatch ? userMatch : UserCache.Users[0]; // if we don't find an Owner, use the first user in the cache
|
|
152
126
|
// get the entity metadata
|
|
153
127
|
const md = new MJ.Metadata();
|
|
154
128
|
if (md.Entities.length === 0) {
|
|
155
|
-
|
|
129
|
+
failSpinner('No entities found in metadata');
|
|
156
130
|
process.exit(1);
|
|
157
131
|
}
|
|
158
|
-
|
|
132
|
+
succeedSpinner(`Loaded ${md.Entities.length} entities from metadata`);
|
|
159
133
|
// Initialize AIEngine for advanced generation features (needed for prompt metadata access)
|
|
160
|
-
if (
|
|
161
|
-
|
|
162
|
-
await
|
|
163
|
-
|
|
134
|
+
if (configInfo.advancedGeneration?.enableAdvancedGeneration) {
|
|
135
|
+
startSpinner('Initializing AI Engine for advanced generation...');
|
|
136
|
+
await AIEngine.Instance.Config(false, currentUser);
|
|
137
|
+
succeedSpinner('AI Engine initialized');
|
|
164
138
|
}
|
|
165
|
-
const runCommandsObject =
|
|
166
|
-
const sqlCodeGenObject =
|
|
139
|
+
const runCommandsObject = MJGlobal.Instance.ClassFactory.CreateInstance(RunCommandsBase);
|
|
140
|
+
const sqlCodeGenObject = MJGlobal.Instance.ClassFactory.CreateInstance(SQLCodeGenBase);
|
|
167
141
|
// check to see if the user wants to skip database generation via the config settings
|
|
168
|
-
const skipDB = skipDatabaseGeneration ||
|
|
142
|
+
const skipDB = skipDatabaseGeneration || getSettingValue('skip_database_generation', false);
|
|
169
143
|
if (!skipDB) {
|
|
170
|
-
|
|
171
|
-
|
|
144
|
+
startSpinner('Handling SQL Script Execution, Metadata Maintenance, and SQL Object Generation...');
|
|
145
|
+
SQLLogging.initSQLLogging(); // initialize the SQL Logging functionality
|
|
172
146
|
/****************************************************************************************
|
|
173
147
|
// STEP 0 --- Precursor Step execute any commands specified in the config file
|
|
174
148
|
****************************************************************************************/
|
|
175
|
-
const beforeCommands =
|
|
149
|
+
const beforeCommands = commands('BEFORE');
|
|
176
150
|
if (beforeCommands && beforeCommands.length > 0) {
|
|
177
|
-
|
|
151
|
+
updateSpinner('Executing BEFORE commands...');
|
|
178
152
|
const results = await runCommandsObject.runCommands(beforeCommands);
|
|
179
153
|
if (results.some((r) => !r.success))
|
|
180
|
-
|
|
154
|
+
logError('ERROR running one or more BEFORE commands');
|
|
181
155
|
}
|
|
182
156
|
/****************************************************************************************
|
|
183
157
|
// STEP 0.1 --- Execute any before SQL Scripts specified in the config file
|
|
184
158
|
****************************************************************************************/
|
|
185
|
-
|
|
159
|
+
updateSpinner('Executing before-all SQL Scripts...');
|
|
186
160
|
if (!(await sqlCodeGenObject.runCustomSQLScripts(pool, 'before-all')))
|
|
187
|
-
|
|
161
|
+
logError('ERROR running before-all SQL Scripts');
|
|
188
162
|
/****************************************************************************************
|
|
189
163
|
// STEP 0.2 --- Create a new user if there is newUserSetup info in the config file
|
|
190
164
|
****************************************************************************************/
|
|
191
|
-
const newUserSetup =
|
|
165
|
+
const newUserSetup = configInfo.newUserSetup;
|
|
192
166
|
if (newUserSetup) {
|
|
193
|
-
|
|
194
|
-
const newUserObject =
|
|
167
|
+
updateSpinner('Setting up new user...');
|
|
168
|
+
const newUserObject = MJGlobal.Instance.ClassFactory.CreateInstance(CreateNewUserBase);
|
|
195
169
|
const result = await newUserObject.createNewUser(newUserSetup);
|
|
196
170
|
if (!result.Success) {
|
|
197
171
|
if (result.Severity === 'error') {
|
|
198
|
-
|
|
199
|
-
|
|
172
|
+
logError('ERROR creating new user');
|
|
173
|
+
logError(' ' + result.Message);
|
|
200
174
|
}
|
|
201
175
|
else {
|
|
202
|
-
|
|
176
|
+
logWarning('Warning: (New User Setup) ' + result.Message);
|
|
203
177
|
}
|
|
204
178
|
}
|
|
205
179
|
}
|
|
206
180
|
/****************************************************************************************
|
|
207
181
|
// STEP 1 - Manage Metadata - including generating new metadata as required
|
|
208
182
|
****************************************************************************************/
|
|
209
|
-
const manageMD =
|
|
210
|
-
|
|
183
|
+
const manageMD = MJGlobal.Instance.ClassFactory.CreateInstance(ManageMetadataBase);
|
|
184
|
+
updateSpinner('Managing Metadata...');
|
|
211
185
|
const metadataSuccess = await manageMD.manageMetadata(pool, currentUser);
|
|
212
186
|
if (!metadataSuccess) {
|
|
213
|
-
|
|
187
|
+
failSpinner('ERROR managing metadata');
|
|
214
188
|
}
|
|
215
189
|
else {
|
|
216
190
|
// now - we need to tell our metadata object to refresh itself
|
|
217
191
|
await provider.Refresh();
|
|
218
|
-
|
|
192
|
+
succeedSpinner('Metadata management completed');
|
|
219
193
|
}
|
|
220
194
|
/****************************************************************************************
|
|
221
195
|
// STEP 2 - SQL Script Generation
|
|
222
196
|
****************************************************************************************/
|
|
223
|
-
const sqlOutputDir =
|
|
197
|
+
const sqlOutputDir = outputDir('SQL', true);
|
|
224
198
|
if (sqlOutputDir) {
|
|
225
|
-
|
|
199
|
+
startSpinner('Managing SQL Scripts and Execution...');
|
|
226
200
|
const sqlSuccess = await sqlCodeGenObject.manageSQLScriptsAndExecution(pool, md.Entities, sqlOutputDir, currentUser);
|
|
227
201
|
if (!sqlSuccess) {
|
|
228
|
-
|
|
202
|
+
failSpinner('Error managing SQL scripts and execution');
|
|
229
203
|
}
|
|
230
204
|
else {
|
|
231
|
-
|
|
205
|
+
succeedSpinner('SQL scripts and execution completed');
|
|
232
206
|
}
|
|
233
207
|
}
|
|
234
208
|
else {
|
|
235
|
-
|
|
209
|
+
warnSpinner('SQL output directory NOT found in config file, skipping...');
|
|
236
210
|
}
|
|
237
211
|
}
|
|
238
212
|
else {
|
|
239
|
-
|
|
213
|
+
warnSpinner('Skipping database generation (skip_database_generation = true)');
|
|
240
214
|
// we skipped the database generation but we need to load generated code for validators from the database to ensure that we have them
|
|
241
215
|
// ready for later use.
|
|
242
|
-
const manageMD =
|
|
243
|
-
|
|
216
|
+
const manageMD = MJGlobal.Instance.ClassFactory.CreateInstance(ManageMetadataBase);
|
|
217
|
+
startSpinner('Checking/Loading AI Generated Code from Metadata...');
|
|
244
218
|
const metadataSuccess = await manageMD.loadGeneratedCode(pool, currentUser);
|
|
245
219
|
if (!metadataSuccess) {
|
|
246
|
-
|
|
220
|
+
failSpinner('ERROR checking/loading AI Generated Code from Metadata');
|
|
247
221
|
return; // FATAL ERROR - we can't continue
|
|
248
222
|
}
|
|
249
223
|
else {
|
|
250
|
-
|
|
224
|
+
succeedSpinner('AI Generated Code loaded from Metadata');
|
|
251
225
|
}
|
|
252
226
|
}
|
|
253
227
|
const coreEntities = md.Entities.filter((e) => e.IncludeInAPI).filter((e) => e.SchemaName.trim().toLowerCase() === mjCoreSchema.trim().toLowerCase());
|
|
254
228
|
const nonCoreEntities = md.Entities.filter((e) => e.IncludeInAPI).filter((e) => e.SchemaName.trim().toLowerCase() !== mjCoreSchema.trim().toLowerCase());
|
|
255
229
|
// Check if we're in verbose mode to determine spinner behavior
|
|
256
|
-
const isVerbose =
|
|
230
|
+
const isVerbose = configInfo?.verboseOutput ?? false;
|
|
257
231
|
if (!isVerbose) {
|
|
258
232
|
// In non-verbose mode, start a single spinner for all TypeScript generation
|
|
259
|
-
|
|
233
|
+
startSpinner('Generating TypeScript code...');
|
|
260
234
|
}
|
|
261
235
|
/****************************************************************************************
|
|
262
236
|
// STEP 3(a) - GraphQL Server Code Gen
|
|
263
237
|
****************************************************************************************/
|
|
264
|
-
const graphQLCoreResolversOutputDir =
|
|
238
|
+
const graphQLCoreResolversOutputDir = outputDir('GraphQLCoreEntityResolvers', false);
|
|
265
239
|
if (graphQLCoreResolversOutputDir) {
|
|
266
240
|
// generate the GraphQL server code
|
|
267
241
|
if (isVerbose)
|
|
268
|
-
|
|
269
|
-
const graphQLGenerator =
|
|
242
|
+
startSpinner('Generating CORE Entity GraphQL Resolver Code...');
|
|
243
|
+
const graphQLGenerator = MJGlobal.Instance.ClassFactory.CreateInstance(GraphQLServerGeneratorBase);
|
|
270
244
|
if (!graphQLGenerator.generateGraphQLServerCode(coreEntities, graphQLCoreResolversOutputDir, '@memberjunction/core-entities', true)) {
|
|
271
|
-
|
|
245
|
+
failSpinner('Error generating GraphQL server code');
|
|
272
246
|
return;
|
|
273
247
|
}
|
|
274
248
|
else if (isVerbose) {
|
|
275
|
-
|
|
249
|
+
succeedSpinner('CORE Entity GraphQL Resolver Code generated');
|
|
276
250
|
}
|
|
277
251
|
}
|
|
278
|
-
const graphqlOutputDir =
|
|
252
|
+
const graphqlOutputDir = outputDir('GraphQLServer', true);
|
|
279
253
|
if (graphqlOutputDir) {
|
|
280
254
|
// generate the GraphQL server code
|
|
281
255
|
if (isVerbose)
|
|
282
|
-
|
|
283
|
-
const graphQLGenerator =
|
|
284
|
-
const entityPackageName =
|
|
256
|
+
startSpinner('Generating GraphQL Resolver Code...');
|
|
257
|
+
const graphQLGenerator = MJGlobal.Instance.ClassFactory.CreateInstance(GraphQLServerGeneratorBase);
|
|
258
|
+
const entityPackageName = configInfo.entityPackageName || 'mj_generatedentities';
|
|
285
259
|
if (!graphQLGenerator.generateGraphQLServerCode(nonCoreEntities, graphqlOutputDir, entityPackageName, false)) {
|
|
286
|
-
|
|
260
|
+
failSpinner('Error generating GraphQL Resolver code');
|
|
287
261
|
return;
|
|
288
262
|
}
|
|
289
263
|
else if (isVerbose) {
|
|
290
|
-
|
|
264
|
+
succeedSpinner('GraphQL Resolver Code generated');
|
|
291
265
|
}
|
|
292
266
|
}
|
|
293
267
|
else if (isVerbose) {
|
|
294
|
-
|
|
268
|
+
warnSpinner('GraphQL server output directory NOT found in config file, skipping...');
|
|
295
269
|
}
|
|
296
270
|
/****************************************************************************************
|
|
297
271
|
// STEP 4 - Core Entity Subclass Code Gen
|
|
298
272
|
****************************************************************************************/
|
|
299
|
-
const coreEntitySubClassOutputDir =
|
|
273
|
+
const coreEntitySubClassOutputDir = outputDir('CoreEntitySubClasses', false);
|
|
300
274
|
if (coreEntitySubClassOutputDir && coreEntitySubClassOutputDir.length > 0) {
|
|
301
275
|
// generate the entity subclass code
|
|
302
276
|
if (isVerbose)
|
|
303
|
-
|
|
304
|
-
const entitySubClassGeneratorObject =
|
|
277
|
+
startSpinner('Generating CORE Entity Subclass Code...');
|
|
278
|
+
const entitySubClassGeneratorObject = MJGlobal.Instance.ClassFactory.CreateInstance(EntitySubClassGeneratorBase);
|
|
305
279
|
if (!await entitySubClassGeneratorObject.generateAllEntitySubClasses(pool, coreEntities, coreEntitySubClassOutputDir, skipDB)) {
|
|
306
|
-
|
|
280
|
+
failSpinner('Error generating entity subclass code');
|
|
307
281
|
return;
|
|
308
282
|
}
|
|
309
283
|
else if (isVerbose) {
|
|
310
|
-
|
|
284
|
+
succeedSpinner('CORE Entity Subclass Code generated');
|
|
311
285
|
}
|
|
312
286
|
}
|
|
313
287
|
/****************************************************************************************
|
|
314
288
|
// STEP 4.1 - Entity Subclass Code Gen
|
|
315
289
|
****************************************************************************************/
|
|
316
|
-
const entitySubClassOutputDir =
|
|
290
|
+
const entitySubClassOutputDir = outputDir('EntitySubClasses', true);
|
|
317
291
|
if (entitySubClassOutputDir) {
|
|
318
292
|
// generate the entity subclass code
|
|
319
293
|
if (isVerbose)
|
|
320
|
-
|
|
321
|
-
const entitySubClassGeneratorObject =
|
|
294
|
+
startSpinner('Generating Entity Subclass Code...');
|
|
295
|
+
const entitySubClassGeneratorObject = MJGlobal.Instance.ClassFactory.CreateInstance(EntitySubClassGeneratorBase);
|
|
322
296
|
if (!await entitySubClassGeneratorObject.generateAllEntitySubClasses(pool, nonCoreEntities, entitySubClassOutputDir, skipDB)) {
|
|
323
|
-
|
|
297
|
+
failSpinner('Error generating entity subclass code');
|
|
324
298
|
return;
|
|
325
299
|
}
|
|
326
300
|
else if (isVerbose) {
|
|
327
|
-
|
|
301
|
+
succeedSpinner('Entity Subclass Code generated');
|
|
328
302
|
}
|
|
329
303
|
}
|
|
330
304
|
else if (isVerbose) {
|
|
331
|
-
|
|
305
|
+
warnSpinner('Entity subclass output directory NOT found in config file, skipping...');
|
|
332
306
|
}
|
|
333
307
|
/****************************************************************************************
|
|
334
308
|
// STEP 5 - Angular Code Gen
|
|
335
309
|
****************************************************************************************/
|
|
336
|
-
const angularCoreEntitiesOutputDir =
|
|
310
|
+
const angularCoreEntitiesOutputDir = outputDir('AngularCoreEntities', false);
|
|
337
311
|
if (angularCoreEntitiesOutputDir) {
|
|
338
312
|
// generate the Angular client code
|
|
339
313
|
if (isVerbose)
|
|
340
|
-
|
|
341
|
-
const angularGenerator =
|
|
314
|
+
startSpinner('Generating Angular CORE Entities Code...');
|
|
315
|
+
const angularGenerator = MJGlobal.Instance.ClassFactory.CreateInstance(AngularClientGeneratorBase);
|
|
342
316
|
if (!(await angularGenerator.generateAngularCode(coreEntities, angularCoreEntitiesOutputDir, 'Core', currentUser))) {
|
|
343
|
-
|
|
317
|
+
failSpinner('Error generating Angular CORE Entities code');
|
|
344
318
|
return;
|
|
345
319
|
}
|
|
346
320
|
else if (isVerbose) {
|
|
347
|
-
|
|
321
|
+
succeedSpinner('Angular CORE Entities Code generated');
|
|
348
322
|
}
|
|
349
323
|
}
|
|
350
|
-
const angularOutputDir =
|
|
324
|
+
const angularOutputDir = outputDir('Angular', false);
|
|
351
325
|
if (angularOutputDir) {
|
|
352
326
|
// generate the Angular client code
|
|
353
327
|
if (isVerbose)
|
|
354
|
-
|
|
355
|
-
const angularGenerator =
|
|
328
|
+
startSpinner('Generating Angular Code...');
|
|
329
|
+
const angularGenerator = MJGlobal.Instance.ClassFactory.CreateInstance(AngularClientGeneratorBase);
|
|
356
330
|
if (!(await angularGenerator.generateAngularCode(nonCoreEntities, angularOutputDir, '', currentUser))) {
|
|
357
|
-
|
|
331
|
+
failSpinner('Error generating Angular code');
|
|
358
332
|
return;
|
|
359
333
|
}
|
|
360
334
|
else if (isVerbose) {
|
|
361
|
-
|
|
335
|
+
succeedSpinner('Angular Code generated');
|
|
362
336
|
}
|
|
363
337
|
}
|
|
364
338
|
else if (isVerbose) {
|
|
365
|
-
|
|
339
|
+
warnSpinner('Angular output directory NOT found in config file, skipping...');
|
|
366
340
|
}
|
|
367
341
|
/****************************************************************************************
|
|
368
342
|
// STEP 6 - Database Schema Output in JSON - for documentation and can be used by AI/etc.
|
|
369
343
|
****************************************************************************************/
|
|
370
|
-
const dbSchemaOutputDir =
|
|
344
|
+
const dbSchemaOutputDir = outputDir('DBSchemaJSON', false);
|
|
371
345
|
if (dbSchemaOutputDir) {
|
|
372
346
|
// generate the GraphQL client code
|
|
373
347
|
if (isVerbose)
|
|
374
|
-
|
|
375
|
-
const schemaGeneratorObject =
|
|
348
|
+
startSpinner('Generating Database Schema JSON Output...');
|
|
349
|
+
const schemaGeneratorObject = MJGlobal.Instance.ClassFactory.CreateInstance(DBSchemaGeneratorBase);
|
|
376
350
|
if (!schemaGeneratorObject.generateDBSchemaJSONOutput(md.Entities, dbSchemaOutputDir)) {
|
|
377
|
-
|
|
351
|
+
failSpinner('Error generating Database Schema JSON Output, non-fatal, continuing...');
|
|
378
352
|
}
|
|
379
353
|
else if (isVerbose) {
|
|
380
|
-
|
|
354
|
+
succeedSpinner('Database Schema JSON Output generated');
|
|
381
355
|
}
|
|
382
356
|
}
|
|
383
357
|
else if (isVerbose) {
|
|
384
|
-
|
|
358
|
+
warnSpinner('DB Schema output directory NOT found in config file, skipping...');
|
|
385
359
|
}
|
|
386
360
|
/****************************************************************************************
|
|
387
361
|
// STEP 7 - Actions Code Gen
|
|
388
362
|
****************************************************************************************/
|
|
389
|
-
const coreActionsOutputDir =
|
|
390
|
-
await
|
|
363
|
+
const coreActionsOutputDir = outputDir('CoreActionSubclasses', false);
|
|
364
|
+
await ActionEngineBase.Instance.Config(false, currentUser); // this is inefficient as we have the server
|
|
391
365
|
if (coreActionsOutputDir) {
|
|
392
366
|
if (isVerbose)
|
|
393
|
-
|
|
394
|
-
const actionsGenerator =
|
|
395
|
-
if (!(await actionsGenerator.generateActions(
|
|
396
|
-
|
|
367
|
+
startSpinner('Generating CORE Actions Code...');
|
|
368
|
+
const actionsGenerator = MJGlobal.Instance.ClassFactory.CreateInstance(ActionSubClassGeneratorBase);
|
|
369
|
+
if (!(await actionsGenerator.generateActions(ActionEngineBase.Instance.CoreActions, coreActionsOutputDir))) {
|
|
370
|
+
failSpinner('Error generating CORE Actions code');
|
|
397
371
|
return;
|
|
398
372
|
}
|
|
399
373
|
else if (isVerbose) {
|
|
400
|
-
|
|
374
|
+
succeedSpinner('CORE Actions Code generated');
|
|
401
375
|
}
|
|
402
376
|
}
|
|
403
|
-
const actionsOutputDir =
|
|
377
|
+
const actionsOutputDir = outputDir('ActionSubclasses', false);
|
|
404
378
|
if (actionsOutputDir) {
|
|
405
379
|
if (isVerbose)
|
|
406
|
-
|
|
407
|
-
const actionsGenerator =
|
|
408
|
-
if (!(await actionsGenerator.generateActions(
|
|
409
|
-
|
|
380
|
+
startSpinner('Generating Actions Code...');
|
|
381
|
+
const actionsGenerator = MJGlobal.Instance.ClassFactory.CreateInstance(ActionSubClassGeneratorBase);
|
|
382
|
+
if (!(await actionsGenerator.generateActions(ActionEngineBase.Instance.NonCoreActions, actionsOutputDir))) {
|
|
383
|
+
failSpinner('Error generating Actions code');
|
|
410
384
|
return;
|
|
411
385
|
}
|
|
412
386
|
else if (isVerbose) {
|
|
413
|
-
|
|
387
|
+
succeedSpinner('Actions Code generated');
|
|
414
388
|
}
|
|
415
389
|
}
|
|
416
390
|
else if (isVerbose) {
|
|
417
|
-
|
|
391
|
+
warnSpinner('Actions output directory NOT found in config file, skipping...');
|
|
418
392
|
}
|
|
419
393
|
// WRAP UP SQL LOGGING HERE
|
|
420
|
-
|
|
394
|
+
SQLLogging.finishSQLLogging(); // finish up the SQL Logging
|
|
421
395
|
// Complete the TypeScript generation spinner in non-verbose mode
|
|
422
396
|
if (!isVerbose) {
|
|
423
|
-
|
|
397
|
+
succeedSpinner('TypeScript code generation completed');
|
|
424
398
|
}
|
|
425
399
|
// now run integrity checks
|
|
426
|
-
|
|
427
|
-
await
|
|
428
|
-
|
|
400
|
+
startSpinner('Running system integrity checks...');
|
|
401
|
+
await SystemIntegrityBase.RunIntegrityChecks(pool, true);
|
|
402
|
+
succeedSpinner('System integrity checks completed');
|
|
429
403
|
/****************************************************************************************
|
|
430
404
|
// STEP 8 --- Finalization Step - execute any AFTER commands specified in the config file
|
|
431
405
|
****************************************************************************************/
|
|
432
|
-
const afterCommands =
|
|
406
|
+
const afterCommands = commands('AFTER');
|
|
433
407
|
if (afterCommands && afterCommands.length > 0) {
|
|
434
|
-
|
|
408
|
+
startSpinner('Executing AFTER commands...');
|
|
435
409
|
const results = await runCommandsObject.runCommands(afterCommands);
|
|
436
410
|
if (results.some((r) => !r.success)) {
|
|
437
|
-
|
|
411
|
+
failSpinner('ERROR running one or more AFTER commands');
|
|
438
412
|
}
|
|
439
413
|
else {
|
|
440
|
-
|
|
414
|
+
succeedSpinner('AFTER commands completed');
|
|
441
415
|
}
|
|
442
416
|
}
|
|
443
417
|
/****************************************************************************************
|
|
444
418
|
// STEP 9 --- Execute any AFTER SQL Scripts specified in the config file
|
|
445
419
|
****************************************************************************************/
|
|
446
420
|
if (!skipDB) {
|
|
447
|
-
|
|
421
|
+
startSpinner('Executing after-all SQL Scripts...');
|
|
448
422
|
if (!(await sqlCodeGenObject.runCustomSQLScripts(pool, 'after-all'))) {
|
|
449
|
-
|
|
423
|
+
failSpinner('ERROR running after-all SQL Scripts');
|
|
450
424
|
}
|
|
451
425
|
else {
|
|
452
|
-
|
|
426
|
+
succeedSpinner('After-all SQL Scripts completed');
|
|
453
427
|
}
|
|
454
428
|
}
|
|
455
429
|
const endTime = new Date();
|
|
456
430
|
const totalSeconds = (endTime.getTime() - startTime.getTime()) / 1000;
|
|
457
|
-
|
|
431
|
+
succeedSpinner(`MJ CodeGen Complete! ${md.Entities.length} entities processed in ${totalSeconds}s @ ${endTime.toLocaleString()}`);
|
|
458
432
|
process.exit(0); // wrap it up, 0 means success
|
|
459
433
|
}
|
|
460
434
|
catch (e) {
|
|
461
|
-
|
|
462
|
-
|
|
435
|
+
failSpinner(`CodeGen failed: ${e}`);
|
|
436
|
+
logError(e);
|
|
463
437
|
process.exit(1); // error code
|
|
464
438
|
}
|
|
465
439
|
}
|
|
466
440
|
}
|
|
467
|
-
exports.RunCodeGenBase = RunCodeGenBase;
|
|
468
441
|
/**
|
|
469
442
|
* Convenience function to run the MemberJunction code generation process.
|
|
470
443
|
* Creates a new instance of RunCodeGenBase and executes the full generation pipeline.
|
|
@@ -485,9 +458,8 @@ exports.RunCodeGenBase = RunCodeGenBase;
|
|
|
485
458
|
* await runMemberJunctionCodeGeneration(true);
|
|
486
459
|
* ```
|
|
487
460
|
*/
|
|
488
|
-
async function runMemberJunctionCodeGeneration(skipDatabaseGeneration = false) {
|
|
489
|
-
const runObject =
|
|
461
|
+
export async function runMemberJunctionCodeGeneration(skipDatabaseGeneration = false) {
|
|
462
|
+
const runObject = MJGlobal.Instance.ClassFactory.CreateInstance(RunCodeGenBase);
|
|
490
463
|
return await runObject.Run(skipDatabaseGeneration);
|
|
491
464
|
}
|
|
492
|
-
exports.runMemberJunctionCodeGeneration = runMemberJunctionCodeGeneration;
|
|
493
465
|
//# sourceMappingURL=runCodeGen.js.map
|