@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.
- package/README.md +56 -1
- 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 -136
- 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.d.ts +79 -0
- package/dist/Config/config.d.ts.map +1 -1
- package/dist/Config/config.js +174 -172
- 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 +25 -9
- package/dist/Database/manage-metadata.d.ts.map +1 -1
- package/dist/Database/manage-metadata.js +438 -316
- 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 +5 -2
- package/dist/Database/sql_codegen.d.ts.map +1 -1
- package/dist/Database/sql_codegen.js +344 -268
- package/dist/Database/sql_codegen.js.map +1 -1
- package/dist/Manifest/GenerateClassRegistrationsManifest.d.ts +110 -0
- package/dist/Manifest/GenerateClassRegistrationsManifest.d.ts.map +1 -0
- package/dist/Manifest/GenerateClassRegistrationsManifest.js +632 -0
- package/dist/Manifest/GenerateClassRegistrationsManifest.js.map +1 -0
- 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 +7 -1
- package/dist/Misc/sql_logging.d.ts.map +1 -1
- package/dist/Misc/sql_logging.js +40 -53
- 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 -20
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +22 -40
- 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 +151 -178
- package/dist/runCodeGen.js.map +1 -1
- package/package.json +24 -21
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,328 +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
|
-
|
|
285
|
-
|
|
256
|
+
startSpinner('Generating GraphQL Resolver Code...');
|
|
257
|
+
const graphQLGenerator = MJGlobal.Instance.ClassFactory.CreateInstance(GraphQLServerGeneratorBase);
|
|
258
|
+
const entityPackageName = configInfo.entityPackageName || 'mj_generatedentities';
|
|
259
|
+
if (!graphQLGenerator.generateGraphQLServerCode(nonCoreEntities, graphqlOutputDir, entityPackageName, false)) {
|
|
260
|
+
failSpinner('Error generating GraphQL Resolver code');
|
|
286
261
|
return;
|
|
287
262
|
}
|
|
288
263
|
else if (isVerbose) {
|
|
289
|
-
|
|
264
|
+
succeedSpinner('GraphQL Resolver Code generated');
|
|
290
265
|
}
|
|
291
266
|
}
|
|
292
267
|
else if (isVerbose) {
|
|
293
|
-
|
|
268
|
+
warnSpinner('GraphQL server output directory NOT found in config file, skipping...');
|
|
294
269
|
}
|
|
295
270
|
/****************************************************************************************
|
|
296
271
|
// STEP 4 - Core Entity Subclass Code Gen
|
|
297
272
|
****************************************************************************************/
|
|
298
|
-
const coreEntitySubClassOutputDir =
|
|
273
|
+
const coreEntitySubClassOutputDir = outputDir('CoreEntitySubClasses', false);
|
|
299
274
|
if (coreEntitySubClassOutputDir && coreEntitySubClassOutputDir.length > 0) {
|
|
300
275
|
// generate the entity subclass code
|
|
301
276
|
if (isVerbose)
|
|
302
|
-
|
|
303
|
-
const entitySubClassGeneratorObject =
|
|
277
|
+
startSpinner('Generating CORE Entity Subclass Code...');
|
|
278
|
+
const entitySubClassGeneratorObject = MJGlobal.Instance.ClassFactory.CreateInstance(EntitySubClassGeneratorBase);
|
|
304
279
|
if (!await entitySubClassGeneratorObject.generateAllEntitySubClasses(pool, coreEntities, coreEntitySubClassOutputDir, skipDB)) {
|
|
305
|
-
|
|
280
|
+
failSpinner('Error generating entity subclass code');
|
|
306
281
|
return;
|
|
307
282
|
}
|
|
308
283
|
else if (isVerbose) {
|
|
309
|
-
|
|
284
|
+
succeedSpinner('CORE Entity Subclass Code generated');
|
|
310
285
|
}
|
|
311
286
|
}
|
|
312
287
|
/****************************************************************************************
|
|
313
288
|
// STEP 4.1 - Entity Subclass Code Gen
|
|
314
289
|
****************************************************************************************/
|
|
315
|
-
const entitySubClassOutputDir =
|
|
290
|
+
const entitySubClassOutputDir = outputDir('EntitySubClasses', true);
|
|
316
291
|
if (entitySubClassOutputDir) {
|
|
317
292
|
// generate the entity subclass code
|
|
318
293
|
if (isVerbose)
|
|
319
|
-
|
|
320
|
-
const entitySubClassGeneratorObject =
|
|
294
|
+
startSpinner('Generating Entity Subclass Code...');
|
|
295
|
+
const entitySubClassGeneratorObject = MJGlobal.Instance.ClassFactory.CreateInstance(EntitySubClassGeneratorBase);
|
|
321
296
|
if (!await entitySubClassGeneratorObject.generateAllEntitySubClasses(pool, nonCoreEntities, entitySubClassOutputDir, skipDB)) {
|
|
322
|
-
|
|
297
|
+
failSpinner('Error generating entity subclass code');
|
|
323
298
|
return;
|
|
324
299
|
}
|
|
325
300
|
else if (isVerbose) {
|
|
326
|
-
|
|
301
|
+
succeedSpinner('Entity Subclass Code generated');
|
|
327
302
|
}
|
|
328
303
|
}
|
|
329
304
|
else if (isVerbose) {
|
|
330
|
-
|
|
305
|
+
warnSpinner('Entity subclass output directory NOT found in config file, skipping...');
|
|
331
306
|
}
|
|
332
307
|
/****************************************************************************************
|
|
333
308
|
// STEP 5 - Angular Code Gen
|
|
334
309
|
****************************************************************************************/
|
|
335
|
-
const angularCoreEntitiesOutputDir =
|
|
310
|
+
const angularCoreEntitiesOutputDir = outputDir('AngularCoreEntities', false);
|
|
336
311
|
if (angularCoreEntitiesOutputDir) {
|
|
337
312
|
// generate the Angular client code
|
|
338
313
|
if (isVerbose)
|
|
339
|
-
|
|
340
|
-
const angularGenerator =
|
|
314
|
+
startSpinner('Generating Angular CORE Entities Code...');
|
|
315
|
+
const angularGenerator = MJGlobal.Instance.ClassFactory.CreateInstance(AngularClientGeneratorBase);
|
|
341
316
|
if (!(await angularGenerator.generateAngularCode(coreEntities, angularCoreEntitiesOutputDir, 'Core', currentUser))) {
|
|
342
|
-
|
|
317
|
+
failSpinner('Error generating Angular CORE Entities code');
|
|
343
318
|
return;
|
|
344
319
|
}
|
|
345
320
|
else if (isVerbose) {
|
|
346
|
-
|
|
321
|
+
succeedSpinner('Angular CORE Entities Code generated');
|
|
347
322
|
}
|
|
348
323
|
}
|
|
349
|
-
const angularOutputDir =
|
|
324
|
+
const angularOutputDir = outputDir('Angular', false);
|
|
350
325
|
if (angularOutputDir) {
|
|
351
326
|
// generate the Angular client code
|
|
352
327
|
if (isVerbose)
|
|
353
|
-
|
|
354
|
-
const angularGenerator =
|
|
328
|
+
startSpinner('Generating Angular Code...');
|
|
329
|
+
const angularGenerator = MJGlobal.Instance.ClassFactory.CreateInstance(AngularClientGeneratorBase);
|
|
355
330
|
if (!(await angularGenerator.generateAngularCode(nonCoreEntities, angularOutputDir, '', currentUser))) {
|
|
356
|
-
|
|
331
|
+
failSpinner('Error generating Angular code');
|
|
357
332
|
return;
|
|
358
333
|
}
|
|
359
334
|
else if (isVerbose) {
|
|
360
|
-
|
|
335
|
+
succeedSpinner('Angular Code generated');
|
|
361
336
|
}
|
|
362
337
|
}
|
|
363
338
|
else if (isVerbose) {
|
|
364
|
-
|
|
339
|
+
warnSpinner('Angular output directory NOT found in config file, skipping...');
|
|
365
340
|
}
|
|
366
341
|
/****************************************************************************************
|
|
367
342
|
// STEP 6 - Database Schema Output in JSON - for documentation and can be used by AI/etc.
|
|
368
343
|
****************************************************************************************/
|
|
369
|
-
const dbSchemaOutputDir =
|
|
344
|
+
const dbSchemaOutputDir = outputDir('DBSchemaJSON', false);
|
|
370
345
|
if (dbSchemaOutputDir) {
|
|
371
346
|
// generate the GraphQL client code
|
|
372
347
|
if (isVerbose)
|
|
373
|
-
|
|
374
|
-
const schemaGeneratorObject =
|
|
348
|
+
startSpinner('Generating Database Schema JSON Output...');
|
|
349
|
+
const schemaGeneratorObject = MJGlobal.Instance.ClassFactory.CreateInstance(DBSchemaGeneratorBase);
|
|
375
350
|
if (!schemaGeneratorObject.generateDBSchemaJSONOutput(md.Entities, dbSchemaOutputDir)) {
|
|
376
|
-
|
|
351
|
+
failSpinner('Error generating Database Schema JSON Output, non-fatal, continuing...');
|
|
377
352
|
}
|
|
378
353
|
else if (isVerbose) {
|
|
379
|
-
|
|
354
|
+
succeedSpinner('Database Schema JSON Output generated');
|
|
380
355
|
}
|
|
381
356
|
}
|
|
382
357
|
else if (isVerbose) {
|
|
383
|
-
|
|
358
|
+
warnSpinner('DB Schema output directory NOT found in config file, skipping...');
|
|
384
359
|
}
|
|
385
360
|
/****************************************************************************************
|
|
386
361
|
// STEP 7 - Actions Code Gen
|
|
387
362
|
****************************************************************************************/
|
|
388
|
-
const coreActionsOutputDir =
|
|
389
|
-
await
|
|
363
|
+
const coreActionsOutputDir = outputDir('CoreActionSubclasses', false);
|
|
364
|
+
await ActionEngineBase.Instance.Config(false, currentUser); // this is inefficient as we have the server
|
|
390
365
|
if (coreActionsOutputDir) {
|
|
391
366
|
if (isVerbose)
|
|
392
|
-
|
|
393
|
-
const actionsGenerator =
|
|
394
|
-
if (!(await actionsGenerator.generateActions(
|
|
395
|
-
|
|
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');
|
|
396
371
|
return;
|
|
397
372
|
}
|
|
398
373
|
else if (isVerbose) {
|
|
399
|
-
|
|
374
|
+
succeedSpinner('CORE Actions Code generated');
|
|
400
375
|
}
|
|
401
376
|
}
|
|
402
|
-
const actionsOutputDir =
|
|
377
|
+
const actionsOutputDir = outputDir('ActionSubclasses', false);
|
|
403
378
|
if (actionsOutputDir) {
|
|
404
379
|
if (isVerbose)
|
|
405
|
-
|
|
406
|
-
const actionsGenerator =
|
|
407
|
-
if (!(await actionsGenerator.generateActions(
|
|
408
|
-
|
|
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');
|
|
409
384
|
return;
|
|
410
385
|
}
|
|
411
386
|
else if (isVerbose) {
|
|
412
|
-
|
|
387
|
+
succeedSpinner('Actions Code generated');
|
|
413
388
|
}
|
|
414
389
|
}
|
|
415
390
|
else if (isVerbose) {
|
|
416
|
-
|
|
391
|
+
warnSpinner('Actions output directory NOT found in config file, skipping...');
|
|
417
392
|
}
|
|
418
393
|
// WRAP UP SQL LOGGING HERE
|
|
419
|
-
|
|
394
|
+
SQLLogging.finishSQLLogging(); // finish up the SQL Logging
|
|
420
395
|
// Complete the TypeScript generation spinner in non-verbose mode
|
|
421
396
|
if (!isVerbose) {
|
|
422
|
-
|
|
397
|
+
succeedSpinner('TypeScript code generation completed');
|
|
423
398
|
}
|
|
424
399
|
// now run integrity checks
|
|
425
|
-
|
|
426
|
-
await
|
|
427
|
-
|
|
400
|
+
startSpinner('Running system integrity checks...');
|
|
401
|
+
await SystemIntegrityBase.RunIntegrityChecks(pool, true);
|
|
402
|
+
succeedSpinner('System integrity checks completed');
|
|
428
403
|
/****************************************************************************************
|
|
429
404
|
// STEP 8 --- Finalization Step - execute any AFTER commands specified in the config file
|
|
430
405
|
****************************************************************************************/
|
|
431
|
-
const afterCommands =
|
|
406
|
+
const afterCommands = commands('AFTER');
|
|
432
407
|
if (afterCommands && afterCommands.length > 0) {
|
|
433
|
-
|
|
408
|
+
startSpinner('Executing AFTER commands...');
|
|
434
409
|
const results = await runCommandsObject.runCommands(afterCommands);
|
|
435
410
|
if (results.some((r) => !r.success)) {
|
|
436
|
-
|
|
411
|
+
failSpinner('ERROR running one or more AFTER commands');
|
|
437
412
|
}
|
|
438
413
|
else {
|
|
439
|
-
|
|
414
|
+
succeedSpinner('AFTER commands completed');
|
|
440
415
|
}
|
|
441
416
|
}
|
|
442
417
|
/****************************************************************************************
|
|
443
418
|
// STEP 9 --- Execute any AFTER SQL Scripts specified in the config file
|
|
444
419
|
****************************************************************************************/
|
|
445
420
|
if (!skipDB) {
|
|
446
|
-
|
|
421
|
+
startSpinner('Executing after-all SQL Scripts...');
|
|
447
422
|
if (!(await sqlCodeGenObject.runCustomSQLScripts(pool, 'after-all'))) {
|
|
448
|
-
|
|
423
|
+
failSpinner('ERROR running after-all SQL Scripts');
|
|
449
424
|
}
|
|
450
425
|
else {
|
|
451
|
-
|
|
426
|
+
succeedSpinner('After-all SQL Scripts completed');
|
|
452
427
|
}
|
|
453
428
|
}
|
|
454
429
|
const endTime = new Date();
|
|
455
430
|
const totalSeconds = (endTime.getTime() - startTime.getTime()) / 1000;
|
|
456
|
-
|
|
431
|
+
succeedSpinner(`MJ CodeGen Complete! ${md.Entities.length} entities processed in ${totalSeconds}s @ ${endTime.toLocaleString()}`);
|
|
457
432
|
process.exit(0); // wrap it up, 0 means success
|
|
458
433
|
}
|
|
459
434
|
catch (e) {
|
|
460
|
-
|
|
461
|
-
|
|
435
|
+
failSpinner(`CodeGen failed: ${e}`);
|
|
436
|
+
logError(e);
|
|
462
437
|
process.exit(1); // error code
|
|
463
438
|
}
|
|
464
439
|
}
|
|
465
440
|
}
|
|
466
|
-
exports.RunCodeGenBase = RunCodeGenBase;
|
|
467
441
|
/**
|
|
468
442
|
* Convenience function to run the MemberJunction code generation process.
|
|
469
443
|
* Creates a new instance of RunCodeGenBase and executes the full generation pipeline.
|
|
@@ -484,9 +458,8 @@ exports.RunCodeGenBase = RunCodeGenBase;
|
|
|
484
458
|
* await runMemberJunctionCodeGeneration(true);
|
|
485
459
|
* ```
|
|
486
460
|
*/
|
|
487
|
-
async function runMemberJunctionCodeGeneration(skipDatabaseGeneration = false) {
|
|
488
|
-
const runObject =
|
|
461
|
+
export async function runMemberJunctionCodeGeneration(skipDatabaseGeneration = false) {
|
|
462
|
+
const runObject = MJGlobal.Instance.ClassFactory.CreateInstance(RunCodeGenBase);
|
|
489
463
|
return await runObject.Run(skipDatabaseGeneration);
|
|
490
464
|
}
|
|
491
|
-
exports.runMemberJunctionCodeGeneration = runMemberJunctionCodeGeneration;
|
|
492
465
|
//# sourceMappingURL=runCodeGen.js.map
|