@memberjunction/codegen-lib 2.12.1 → 2.13.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/dist/Misc/logging.d.ts +43 -0
- package/dist/Misc/logging.d.ts.map +1 -0
- package/dist/Misc/logging.js +115 -0
- package/dist/Misc/logging.js.map +1 -0
- package/dist/action_subclasses_codegen.d.ts +23 -0
- package/dist/action_subclasses_codegen.d.ts.map +1 -0
- package/dist/action_subclasses_codegen.js +135 -0
- package/dist/action_subclasses_codegen.js.map +1 -0
- package/dist/entity_subclasses_codegen.d.ts +17 -0
- package/dist/entity_subclasses_codegen.d.ts.map +1 -0
- package/dist/entity_subclasses_codegen.js +227 -0
- package/dist/entity_subclasses_codegen.js.map +1 -0
- package/dist/entity_types_codegen.d.ts +15 -0
- package/dist/entity_types_codegen.d.ts.map +1 -0
- package/dist/entity_types_codegen.js +106 -0
- package/dist/entity_types_codegen.js.map +1 -0
- package/dist/graphql_server_codegen.d.ts +29 -0
- package/dist/graphql_server_codegen.d.ts.map +1 -0
- package/dist/graphql_server_codegen.js +546 -0
- package/dist/graphql_server_codegen.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { SeverityType } from '@memberjunction/core';
|
|
2
|
+
/**
|
|
3
|
+
* Base class for logging, you can sub-class this class to create your own logger and override the logError and logStatus methods if desired.
|
|
4
|
+
* The default behavior in the base class is to use the LogError/LogStatus functions from the @memberjunction/core package to log to the console and to a log file if configured in the config.json file.
|
|
5
|
+
*/
|
|
6
|
+
export declare class LoggerBase {
|
|
7
|
+
/**
|
|
8
|
+
* Logs an error message to the console and to the log file if configured
|
|
9
|
+
* @param message
|
|
10
|
+
* @param args
|
|
11
|
+
*/
|
|
12
|
+
logError(message: string, severity: SeverityType, ...args: any[]): void;
|
|
13
|
+
/**
|
|
14
|
+
* Logs a status message to the console and to the log file if configured
|
|
15
|
+
* @param message
|
|
16
|
+
* @param args
|
|
17
|
+
*/
|
|
18
|
+
logStatus(message: string, severity: SeverityType, ...args: any[]): void;
|
|
19
|
+
/**
|
|
20
|
+
* Helper function to log a message with a specified severity and whether it is an error
|
|
21
|
+
* @param message The message to log
|
|
22
|
+
* @param severity The severity of the message
|
|
23
|
+
* @param isError Whether to treat this message as an error
|
|
24
|
+
* @param args Any additional arguments to log
|
|
25
|
+
*/
|
|
26
|
+
logMessage(message: string, severity: SeverityType, isError: boolean, ...args: any[]): void;
|
|
27
|
+
protected logToConsole(message: string, isError: boolean, ...args: any[]): void;
|
|
28
|
+
protected logToFile(message: string, isError: boolean, ...args: any[]): void;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Wrapper for the LoggerBase.logError method
|
|
32
|
+
*/
|
|
33
|
+
export declare function logError(message: string, ...args: any[]): void;
|
|
34
|
+
export declare function logWarning(message: string, ...args: any[]): void;
|
|
35
|
+
/**
|
|
36
|
+
* Wrapper for the LoggerBase.logStatus method
|
|
37
|
+
*/
|
|
38
|
+
export declare function logStatus(message: string, ...args: any[]): void;
|
|
39
|
+
/**
|
|
40
|
+
* Wrapper for the LoggerBase.logMessage method
|
|
41
|
+
*/
|
|
42
|
+
export declare function logMessage(message: string, severity: SeverityType, isError?: boolean, ...args: any[]): void;
|
|
43
|
+
//# sourceMappingURL=logging.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logging.d.ts","sourceRoot":"","sources":["../../src/Misc/logging.ts"],"names":[],"mappings":"AACA,OAAO,EAAuB,YAAY,EAA2C,MAAM,sBAAsB,CAAA;AAIjH;;;GAGG;AACH,qBACa,UAAU;IACpB;;;;OAIG;IACI,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE;IAOvE;;;;OAIG;IACI,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE;IAOxE;;;;;;OAMG;IACI,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE;IAO3F,SAAS,CAAC,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE;IAUxE,SAAS,CAAC,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE;CAgBvE;AAKD;;GAEG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,QAEvD;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,QAEzD;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,QAExD;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,OAAO,UAAQ,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAEzG"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.logMessage = exports.logStatus = exports.logWarning = exports.logError = exports.LoggerBase = void 0;
|
|
13
|
+
const config_1 = require("../Config/config");
|
|
14
|
+
const core_1 = require("@memberjunction/core");
|
|
15
|
+
const global_1 = require("@memberjunction/global");
|
|
16
|
+
const path_1 = __importDefault(require("path"));
|
|
17
|
+
/**
|
|
18
|
+
* Base class for logging, you can sub-class this class to create your own logger and override the logError and logStatus methods if desired.
|
|
19
|
+
* The default behavior in the base class is to use the LogError/LogStatus functions from the @memberjunction/core package to log to the console and to a log file if configured in the config.json file.
|
|
20
|
+
*/
|
|
21
|
+
let LoggerBase = class LoggerBase {
|
|
22
|
+
/**
|
|
23
|
+
* Logs an error message to the console and to the log file if configured
|
|
24
|
+
* @param message
|
|
25
|
+
* @param args
|
|
26
|
+
*/
|
|
27
|
+
logError(message, severity, ...args) {
|
|
28
|
+
const consoleMessage = (0, core_1.FormatConsoleMessage)(message, severity);
|
|
29
|
+
const fileMessage = (0, core_1.FormatFileMessage)(message, severity);
|
|
30
|
+
this.logToConsole(consoleMessage, true, ...args);
|
|
31
|
+
this.logToFile(fileMessage, true, ...args);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Logs a status message to the console and to the log file if configured
|
|
35
|
+
* @param message
|
|
36
|
+
* @param args
|
|
37
|
+
*/
|
|
38
|
+
logStatus(message, severity, ...args) {
|
|
39
|
+
const consoleMessage = (0, core_1.FormatConsoleMessage)(message, severity);
|
|
40
|
+
const fileMessage = (0, core_1.FormatFileMessage)(message, severity);
|
|
41
|
+
this.logToConsole(consoleMessage, false, ...args);
|
|
42
|
+
this.logToFile(fileMessage, false, ...args);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Helper function to log a message with a specified severity and whether it is an error
|
|
46
|
+
* @param message The message to log
|
|
47
|
+
* @param severity The severity of the message
|
|
48
|
+
* @param isError Whether to treat this message as an error
|
|
49
|
+
* @param args Any additional arguments to log
|
|
50
|
+
*/
|
|
51
|
+
logMessage(message, severity, isError, ...args) {
|
|
52
|
+
const consoleMessage = (0, core_1.FormatConsoleMessage)(message, severity);
|
|
53
|
+
const fileMessage = (0, core_1.FormatFileMessage)(message, severity);
|
|
54
|
+
this.logToConsole(consoleMessage, isError, ...args);
|
|
55
|
+
this.logToFile(fileMessage, isError, ...args);
|
|
56
|
+
}
|
|
57
|
+
logToConsole(message, isError, ...args) {
|
|
58
|
+
if (config_1.configInfo.logging.console) {
|
|
59
|
+
if (isError) {
|
|
60
|
+
(0, core_1.LogError)(message, null, ...args);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
(0, core_1.LogStatus)(message, null, ...args);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
logToFile(message, isError, ...args) {
|
|
68
|
+
if (config_1.configInfo.logging.log) {
|
|
69
|
+
if (config_1.configInfo.logging.logFile === null || config_1.configInfo.logging.logFile === undefined || config_1.configInfo.logging.logFile === '') {
|
|
70
|
+
(0, core_1.LogError)('ERROR: No log file specified in config.json', null, ...args);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
const file = path_1.default.join(config_1.currentWorkingDirectory, config_1.configInfo.logging.logFile);
|
|
74
|
+
if (isError) {
|
|
75
|
+
(0, core_1.LogError)(message, file, ...args);
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
(0, core_1.LogStatus)(message, file, ...args);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
exports.LoggerBase = LoggerBase;
|
|
85
|
+
exports.LoggerBase = LoggerBase = __decorate([
|
|
86
|
+
(0, global_1.RegisterClass)(LoggerBase)
|
|
87
|
+
], LoggerBase);
|
|
88
|
+
// use the classes below so that it is easier for external code to sub-class the logger if desired
|
|
89
|
+
const _logger = global_1.MJGlobal.Instance.ClassFactory.CreateInstance(LoggerBase);
|
|
90
|
+
/**
|
|
91
|
+
* Wrapper for the LoggerBase.logError method
|
|
92
|
+
*/
|
|
93
|
+
function logError(message, ...args) {
|
|
94
|
+
return _logger.logError(message, core_1.SeverityType.Critical, ...args);
|
|
95
|
+
}
|
|
96
|
+
exports.logError = logError;
|
|
97
|
+
function logWarning(message, ...args) {
|
|
98
|
+
return _logger.logError(message, core_1.SeverityType.Warning, ...args);
|
|
99
|
+
}
|
|
100
|
+
exports.logWarning = logWarning;
|
|
101
|
+
/**
|
|
102
|
+
* Wrapper for the LoggerBase.logStatus method
|
|
103
|
+
*/
|
|
104
|
+
function logStatus(message, ...args) {
|
|
105
|
+
return _logger.logStatus(message, core_1.SeverityType.Info, ...args);
|
|
106
|
+
}
|
|
107
|
+
exports.logStatus = logStatus;
|
|
108
|
+
/**
|
|
109
|
+
* Wrapper for the LoggerBase.logMessage method
|
|
110
|
+
*/
|
|
111
|
+
function logMessage(message, severity, isError = false, ...args) {
|
|
112
|
+
return _logger.logMessage(message, severity, isError, ...args);
|
|
113
|
+
}
|
|
114
|
+
exports.logMessage = logMessage;
|
|
115
|
+
//# sourceMappingURL=logging.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logging.js","sourceRoot":"","sources":["../../src/Misc/logging.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAAuE;AACvE,+CAAiH;AACjH,mDAAiE;AACjE,gDAAwB;AAExB;;;GAGG;AAEI,IAAM,UAAU,GAAhB,MAAM,UAAU;IACpB;;;;OAIG;IACI,QAAQ,CAAC,OAAe,EAAE,QAAsB,EAAE,GAAG,IAAW;QACpE,MAAM,cAAc,GAAW,IAAA,2BAAoB,EAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QACvE,MAAM,WAAW,GAAW,IAAA,wBAAiB,EA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AFD,4BAEC;AAED,SAAgB,UAAU,CAAC,OAAe,EAAE,GAAG,IAAW;IACvD,OAAO,OAAO,CAAC,QAAQ,CAAC,OAAO,EAAE,mBAAY,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;AACnE,CAAC;AAFD,gCAEC;AAED;;GAEG;AACH,SAAgB,SAAS,CAAC,OAAe,EAAE,GAAG,IAAW;IACtD,OAAO,OAAO,CAAC,SAAS,CAAC,OAAO,EAAE,mBAAY,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,CAAC;AACjE,CAAC;AAFD,8BAEC;AAED;;GAEG;AACH,SAAgB,UAAU,CAAC,OAAe,EAAE,QAAsB,EAAE,OAAO,GAAG,KAAK,EAAE,GAAG,IAAW;IAChG,OAAO,OAAO,CAAC,UAAU,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;AAClE,CAAC;AAFD,gCAEC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ActionEntity } from '@memberjunction/core-entities';
|
|
2
|
+
import { ActionEntityServerEntity } from '@memberjunction/actions';
|
|
3
|
+
/**
|
|
4
|
+
* Base class for generating entity sub-classes, you can sub-class this class to modify/extend your own entity sub-class generator logic
|
|
5
|
+
*/
|
|
6
|
+
export declare class ActionSubClassGeneratorBase {
|
|
7
|
+
protected getAllActionLibrariesAndUsedItems(actions: ActionEntityServerEntity[]): {
|
|
8
|
+
Library: string;
|
|
9
|
+
LibraryID: string;
|
|
10
|
+
ItemsUsedArray: string[];
|
|
11
|
+
}[];
|
|
12
|
+
generateActions(actions: ActionEntityServerEntity[], directory: string): Promise<boolean>;
|
|
13
|
+
/**
|
|
14
|
+
*
|
|
15
|
+
* description: Generate a single Action
|
|
16
|
+
* @description
|
|
17
|
+
* @param action
|
|
18
|
+
* @param directory
|
|
19
|
+
* @returns
|
|
20
|
+
*/
|
|
21
|
+
generateSingleAction(action: ActionEntity, directory: string): Promise<string>;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=action_subclasses_codegen.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action_subclasses_codegen.d.ts","sourceRoot":"","sources":["../src/action_subclasses_codegen.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAuB,MAAM,+BAA+B,CAAC;AAGlF,OAAO,EAAgB,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AAEjF;;GAEG;AACH,qBACa,2BAA2B;IAEpC,SAAS,CAAC,iCAAiC,CAAC,OAAO,EAAE,wBAAwB,EAAE;iBAEvC,MAAM;mBAAa,MAAM;wBAAkB,MAAM,EAAE;;IA6B9E,eAAe,CAAC,OAAO,EAAE,wBAAwB,EAAE,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAsCtG;;;;;;;OAOG;IACU,oBAAoB,CAAC,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAmC9F"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ActionSubClassGeneratorBase = void 0;
|
|
13
|
+
const core_1 = require("@memberjunction/core");
|
|
14
|
+
const fs_1 = __importDefault(require("fs"));
|
|
15
|
+
const path_1 = __importDefault(require("path"));
|
|
16
|
+
const global_1 = require("@memberjunction/global");
|
|
17
|
+
const logging_1 = require("./Misc/logging");
|
|
18
|
+
const fs_extra_1 = require("fs-extra");
|
|
19
|
+
/**
|
|
20
|
+
* Base class for generating entity sub-classes, you can sub-class this class to modify/extend your own entity sub-class generator logic
|
|
21
|
+
*/
|
|
22
|
+
let ActionSubClassGeneratorBase = class ActionSubClassGeneratorBase {
|
|
23
|
+
getAllActionLibrariesAndUsedItems(actions) {
|
|
24
|
+
// get all of the libraries from the combination of distinct libraries from all of the actions we have here
|
|
25
|
+
const allActionLibraries = [];
|
|
26
|
+
actions.forEach(action => {
|
|
27
|
+
action.Libraries.forEach(lib => {
|
|
28
|
+
if (!allActionLibraries.find(l => l.LibraryID === lib.LibraryID)) {
|
|
29
|
+
allActionLibraries.push({
|
|
30
|
+
Library: lib.Library,
|
|
31
|
+
LibraryID: lib.LibraryID,
|
|
32
|
+
ItemsUsedArray: lib.ItemsUsed && lib.ItemsUsed.length > 0 ? lib.ItemsUsed.split(',').map(item => item.trim()) : []
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
// lib already in array, make sure the ItemsUsed for this paritcular Action are merged in to the ItemsUsed array in the entry
|
|
37
|
+
// in the allActionLibraries array element
|
|
38
|
+
const existingLib = allActionLibraries.find(l => l.LibraryID === lib.LibraryID);
|
|
39
|
+
if (existingLib && lib.ItemsUsed && lib.ItemsUsed.length > 0) {
|
|
40
|
+
const itemsUsed = lib.ItemsUsed.split(',').map(item => item.trim());
|
|
41
|
+
if (itemsUsed.length > 0) {
|
|
42
|
+
itemsUsed.forEach(item => {
|
|
43
|
+
if (!existingLib.ItemsUsedArray.includes(item)) {
|
|
44
|
+
existingLib.ItemsUsedArray.push(item);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
return allActionLibraries;
|
|
53
|
+
}
|
|
54
|
+
async generateActions(actions, directory) {
|
|
55
|
+
try {
|
|
56
|
+
const actionFilePath = path_1.default.join(directory, 'action_subclasses.ts');
|
|
57
|
+
// get all of the libraries from the combination of distinct libraries from all of the actions we have here
|
|
58
|
+
const allActionLibraries = this.getAllActionLibrariesAndUsedItems(actions);
|
|
59
|
+
const actionHeader = `/*************************************************
|
|
60
|
+
* GENERATED CODE - DO NOT MODIFY
|
|
61
|
+
* Generated by MemberJunction CodeGen at ${new Date().toLocaleString()}
|
|
62
|
+
**************************************************/
|
|
63
|
+
import { ActionResultSimple, BaseAction, RunActionParams } from "@memberjunction/actions";
|
|
64
|
+
import { RegisterClass } from "@memberjunction/global";
|
|
65
|
+
${allActionLibraries.map(lib => `import { ${lib.ItemsUsedArray.map(item => item).join(', ')} } from "${lib.Library}";`).join('\n')}
|
|
66
|
+
`;
|
|
67
|
+
let sCode = "";
|
|
68
|
+
for (const action of actions) {
|
|
69
|
+
sCode += await this.generateSingleAction(action, directory);
|
|
70
|
+
}
|
|
71
|
+
let actionCode = actionHeader + sCode;
|
|
72
|
+
// finally add the LoadGeneratedActions() stub function at the very end
|
|
73
|
+
actionCode += `
|
|
74
|
+
|
|
75
|
+
export function LoadGeneratedActions() {
|
|
76
|
+
// this function is a stub that is used to force the bundler to include the generated action classes in the final bundle and not tree shake them out
|
|
77
|
+
}
|
|
78
|
+
`;
|
|
79
|
+
(0, fs_extra_1.mkdirSync)(directory, { recursive: true });
|
|
80
|
+
fs_1.default.writeFileSync(actionFilePath, actionCode);
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
catch (e) {
|
|
84
|
+
(0, logging_1.logError)(`Error generating actions`, e);
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
*
|
|
90
|
+
* description: Generate a single Action
|
|
91
|
+
* @description
|
|
92
|
+
* @param action
|
|
93
|
+
* @param directory
|
|
94
|
+
* @returns
|
|
95
|
+
*/
|
|
96
|
+
async generateSingleAction(action, directory) {
|
|
97
|
+
if (action.Status !== 'Active' || action.CodeApprovalStatus !== 'Approved') {
|
|
98
|
+
//logMessage(` Skipping action ${action.Name} because Status <> Active and/or CodeApprovalStatus <> Approved --- Status: ${action.Status}, Code Approval Status: ${action.CodeApprovalStatus}`, SeverityType.Warning, false);
|
|
99
|
+
return "";
|
|
100
|
+
}
|
|
101
|
+
try {
|
|
102
|
+
const codeName = (0, core_1.CodeNameFromString)(action.Name);
|
|
103
|
+
const actionClassName = codeName + '_Action';
|
|
104
|
+
// replace all \n with \t\t\n
|
|
105
|
+
const generatedCode = action.Code ? action.Code.replace(/\n/g, '\n\t\t') : 'throw new Error("Action not yet implemented")';
|
|
106
|
+
const codeComments = action.CodeComments ? action.CodeComments.replace(/\n/g, '\n\t\t') : '';
|
|
107
|
+
const codeCommentsInserted = codeComments ? `/*\n\t\t${codeComments}\n\t*/` : '';
|
|
108
|
+
const actionCode = `
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* ${action.Name}
|
|
112
|
+
* Generated Class
|
|
113
|
+
* User Prompt: ${action.UserPrompt}${action.UserComments ? "\n * User Comments: " + action.UserComments : ""}
|
|
114
|
+
*/
|
|
115
|
+
@RegisterClass(BaseAction, "${action.Name}")
|
|
116
|
+
export class ${actionClassName} extends BaseAction {
|
|
117
|
+
${codeCommentsInserted}
|
|
118
|
+
protected override async InternalRunAction(params: RunActionParams): Promise<ActionResultSimple> {
|
|
119
|
+
${generatedCode}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
`;
|
|
123
|
+
return actionCode;
|
|
124
|
+
}
|
|
125
|
+
catch (e) {
|
|
126
|
+
(0, logging_1.logError)(`Error generating action ${action.Name}`, e);
|
|
127
|
+
throw e;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
exports.ActionSubClassGeneratorBase = ActionSubClassGeneratorBase;
|
|
132
|
+
exports.ActionSubClassGeneratorBase = ActionSubClassGeneratorBase = __decorate([
|
|
133
|
+
(0, global_1.RegisterClass)(ActionSubClassGeneratorBase)
|
|
134
|
+
], ActionSubClassGeneratorBase);
|
|
135
|
+
//# sourceMappingURL=action_subclasses_codegen.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action_subclasses_codegen.js","sourceRoot":"","sources":["../src/action_subclasses_codegen.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+CAAmJ;AACnJ,4CAAoB;AACpB,gDAAwB;AAExB,mDAAuD;AAEvD,4CAAiE;AACjE,uCAAqC;AAGrC;;GAEG;AAEI,IAAM,2BAA2B,GAAjC,MAAM,2BAA2B;IAE1B,iCAAiC,CAAC,OAAmC;QAC3E,2GAA2G;QAC3G,MAAM,kBAAkB,GAAqE,EAAE,CAAC;QAChG,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;YACrB,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;gBAC3B,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,KAAK,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;oBAC/D,kBAAkB,CAAC,IAAI,CAAC;wBACpB,OAAO,EAAE,GAAG,CAAC,OAAO;wBACpB,SAAS,EAAE,GAAG,CAAC,SAAS;wBACxB,cAAc,EAAE,GAAG,CAAC,SAAS,IAAI,GAAG,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE;qBACrH,CAAC,CAAC;gBACP,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AAQ,CAAC,CAAC,CAAC,CAAC,+CAA+C,CAAC;YAC3H,MAAM,YAAY,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAC7F,MAAM,oBAAoB,GAAG,YAAY,CAAC,CAAC,CAAC,WAAW,YAAY,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;YACjF,MAAM,UAAU,GAAG;;;KAG1B,MAAM,CAAC,IAAI;;kBAEE,MAAM,CAAC,UAAU,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,sBAAsB,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE;;8BAE/E,MAAM,CAAC,IAAI;eAC1B,eAAe;MACxB,oBAAoB;;UAEhB,aAAa;;;aAGV,CAAA;YACD,OAAO,UAAU,CAAC;QACtB,CAAC;QACD,OAAO,CAAC,EAAE,CAAC;YACP,IAAA,kBAAQ,EAAC,2BAA2B,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;YACtD,MAAM,CAAC,CAAA;QACX,CAAC;IACL,CAAC;CACJ,CAAA;AAlHY,kEAA2B;sCAA3B,2BAA2B;IADvC,IAAA,sBAAa,EAAC,2BAA2B,CAAC;GAC9B,2BAA2B,CAkHvC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { EntityFieldInfo, EntityInfo } from '@memberjunction/core';
|
|
2
|
+
/**
|
|
3
|
+
* Base class for generating entity sub-classes, you can sub-class this class to modify/extend your own entity sub-class generator logic
|
|
4
|
+
*/
|
|
5
|
+
export declare class EntitySubClassGeneratorBase {
|
|
6
|
+
generateAllEntitySubClasses(entities: EntityInfo[], directory: string): boolean;
|
|
7
|
+
generateEntitySubClassFileHeader(): string;
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
* @param entity
|
|
11
|
+
* @param includeFileHeader
|
|
12
|
+
*/
|
|
13
|
+
generateEntitySubClass(entity: EntityInfo, includeFileHeader?: boolean): string;
|
|
14
|
+
GenerateSchemaAndType(entity: EntityInfo): string;
|
|
15
|
+
GenetateZodDescription(entityField: EntityFieldInfo): string;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=entity_subclasses_codegen.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity_subclasses_codegen.d.ts","sourceRoot":"","sources":["../src/entity_subclasses_codegen.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAA4B,UAAU,EAA6B,MAAM,sBAAsB,CAAC;AAOxH;;GAEG;AACH,qBACa,2BAA2B;IAC/B,2BAA2B,CAAC,QAAQ,EAAE,UAAU,EAAE,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO;IAkB/E,gCAAgC,IAAI,MAAM;IAYjD;;;;OAIG;IACI,sBAAsB,CAAC,MAAM,EAAE,UAAU,EAAE,iBAAiB,GAAE,OAAe,GAAG,MAAM;IAwHtF,qBAAqB,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM;IAiDjD,sBAAsB,CAAC,WAAW,EAAE,eAAe,GAAG,MAAM;CAepE"}
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.EntitySubClassGeneratorBase = void 0;
|
|
13
|
+
const core_1 = require("@memberjunction/core");
|
|
14
|
+
const fs_1 = __importDefault(require("fs"));
|
|
15
|
+
const path_1 = __importDefault(require("path"));
|
|
16
|
+
const util_1 = require("./Misc/util");
|
|
17
|
+
const global_1 = require("@memberjunction/global");
|
|
18
|
+
const logging_1 = require("./Misc/logging");
|
|
19
|
+
/**
|
|
20
|
+
* Base class for generating entity sub-classes, you can sub-class this class to modify/extend your own entity sub-class generator logic
|
|
21
|
+
*/
|
|
22
|
+
let EntitySubClassGeneratorBase = class EntitySubClassGeneratorBase {
|
|
23
|
+
generateAllEntitySubClasses(entities, directory) {
|
|
24
|
+
try {
|
|
25
|
+
const sortedEntities = entities.sort((a, b) => a.Name.localeCompare(b.Name));
|
|
26
|
+
const zodContent = sortedEntities.map((entity) => this.GenerateSchemaAndType(entity)).join('');
|
|
27
|
+
const sContent = sortedEntities.map((e) => this.generateEntitySubClass(e, false)).join('');
|
|
28
|
+
const allContent = `${this.generateEntitySubClassFileHeader()} \n ${zodContent} \n ${sContent}`;
|
|
29
|
+
(0, util_1.makeDir)(directory);
|
|
30
|
+
fs_1.default.writeFileSync(path_1.default.join(directory, 'entity_subclasses.ts'), allContent);
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
catch (err) {
|
|
34
|
+
console.error(err);
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
generateEntitySubClassFileHeader() {
|
|
39
|
+
return `import { BaseEntity, EntitySaveOptions, CompositeKey } from "@memberjunction/core";
|
|
40
|
+
import { RegisterClass } from "@memberjunction/global";
|
|
41
|
+
import { z } from "zod";
|
|
42
|
+
|
|
43
|
+
export const loadModule = () => {
|
|
44
|
+
// no-op, only used to ensure this file is a valid module and to allow easy loading
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
`;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
*
|
|
51
|
+
* @param entity
|
|
52
|
+
* @param includeFileHeader
|
|
53
|
+
*/
|
|
54
|
+
generateEntitySubClass(entity, includeFileHeader = false) {
|
|
55
|
+
if (entity.PrimaryKeys.length === 0) {
|
|
56
|
+
console.warn(`Entity ${entity.Name} has no primary keys. Skipping.`);
|
|
57
|
+
return '';
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
const fields = entity.Fields.map((e) => {
|
|
61
|
+
let values = '';
|
|
62
|
+
let valueList = '';
|
|
63
|
+
if (e.ValueListType && e.ValueListType.length > 0 && e.ValueListType.trim().toLowerCase() !== 'none') {
|
|
64
|
+
values = e.EntityFieldValues.map((v) => `\n * * ${v.Value}${v.Description && v.Description.length > 0 ? ' - ' + v.Description : ''}`).join('');
|
|
65
|
+
valueList = `\n * * Value List Type: ${e.ValueListType}\n * * Possible Values ` + values;
|
|
66
|
+
}
|
|
67
|
+
let typeString = (0, core_1.TypeScriptTypeFromSQLType)(e.Type) + (e.AllowsNull ? ' | null' : '');
|
|
68
|
+
if (e.ValueListTypeEnum !== core_1.EntityFieldValueListType.None && e.EntityFieldValues && e.EntityFieldValues.length > 0) {
|
|
69
|
+
// construct a typeString that is a union of the possible values
|
|
70
|
+
const quotes = e.NeedsQuotes ? "'" : '';
|
|
71
|
+
typeString = e.EntityFieldValues.map((v) => `${quotes}${v.Value}${quotes}`).join(' | ');
|
|
72
|
+
if (e.ValueListTypeEnum === core_1.EntityFieldValueListType.ListOrUserEntry) {
|
|
73
|
+
// special case becuase a user can enter whatever they want
|
|
74
|
+
typeString += ' | ' + (0, core_1.TypeScriptTypeFromSQLType)(e.Type);
|
|
75
|
+
}
|
|
76
|
+
// finally, add the null type if it allows null
|
|
77
|
+
if (e.AllowsNull) {
|
|
78
|
+
typeString += ' | null';
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
let sRet = ` /**
|
|
82
|
+
* * Field Name: ${e.Name}${e.DisplayName && e.DisplayName.length > 0 ? '\n * * Display Name: ' + e.DisplayName : ''}
|
|
83
|
+
* * SQL Data Type: ${e.SQLFullType}${e.RelatedEntity ? '\n * * Related Entity/Foreign Key: ' + e.RelatedEntity + ' (' + e.RelatedEntityBaseView + '.' + e.RelatedEntityFieldName + ')' : ''}${e.DefaultValue && e.DefaultValue.length > 0 ? '\n * * Default Value: ' + e.DefaultValue : ''}${valueList}${e.Description && e.Description.length > 0 ? '\n * * Description: ' + e.Description : ''}
|
|
84
|
+
*/
|
|
85
|
+
get ${e.CodeName}(): ${typeString} {
|
|
86
|
+
return this.Get('${e.Name}');
|
|
87
|
+
}`;
|
|
88
|
+
if (!e.ReadOnly) {
|
|
89
|
+
sRet += `
|
|
90
|
+
set ${e.CodeName}(value: ${typeString}) {
|
|
91
|
+
this.Set('${e.Name}', value);
|
|
92
|
+
}`;
|
|
93
|
+
}
|
|
94
|
+
return sRet;
|
|
95
|
+
}).join('\n\n');
|
|
96
|
+
const sClassName = `${entity.ClassName}Entity`;
|
|
97
|
+
const subClass = entity.EntityObjectSubclassName ? entity.EntityObjectSubclassName : '';
|
|
98
|
+
const subClassImport = entity.EntityObjectSubclassImport ? entity.EntityObjectSubclassImport : '';
|
|
99
|
+
const sBaseClass = subClass.length > 0 && subClassImport.length > 0 ? `${subClass}` : 'BaseEntity';
|
|
100
|
+
const subClassImportStatement = subClass.length > 0 && subClassImport.length > 0 ? `import { ${subClass} } from '${subClassImport}';\n` : '';
|
|
101
|
+
const loadFieldString = entity.PrimaryKeys.map((f) => `${f.CodeName}: ${f.TSType}`).join(', ');
|
|
102
|
+
const loadFunction = ` /**
|
|
103
|
+
* Loads the ${entity.Name} record from the database
|
|
104
|
+
${entity.PrimaryKeys.map((f) => `* @param ${f.CodeName}: ${f.TSType} - primary key value to load the ${entity.Name} record.`).join('\n ')}
|
|
105
|
+
* @param EntityRelationshipsToLoad - (optional) the relationships to load
|
|
106
|
+
* @returns {Promise<boolean>} - true if successful, false otherwise
|
|
107
|
+
* @public
|
|
108
|
+
* @async
|
|
109
|
+
* @memberof ${sClassName}
|
|
110
|
+
* @method
|
|
111
|
+
* @override
|
|
112
|
+
*/
|
|
113
|
+
public async Load(${loadFieldString}, EntityRelationshipsToLoad?: string[]) : Promise<boolean> {
|
|
114
|
+
const compositeKey: CompositeKey = new CompositeKey();
|
|
115
|
+
${entity.PrimaryKeys.map((f) => `compositeKey.KeyValuePairs.push({ FieldName: '${f.Name}', Value: ${f.CodeName} });`).join('\n ')}
|
|
116
|
+
return await super.InnerLoad(compositeKey, EntityRelationshipsToLoad);
|
|
117
|
+
}`;
|
|
118
|
+
const deleteFunction = entity.AllowDeleteAPI
|
|
119
|
+
? ''
|
|
120
|
+
: ` /**
|
|
121
|
+
* ${entity.Name} - AllowDeleteAPI is set to 0 in the database. Delete is not allowed, so this method is generated to override the base class method and throw an error. To enable delete for this entity, set AllowDeleteAPI to 1 in the database.
|
|
122
|
+
* @public
|
|
123
|
+
* @method
|
|
124
|
+
* @override
|
|
125
|
+
* @memberof ${sClassName}
|
|
126
|
+
* @throws {Error} - Delete is not allowed for ${entity.Name}, to enable it set AllowDeleteAPI to 1 in the database.
|
|
127
|
+
*/
|
|
128
|
+
public async Delete(): Promise<boolean> {
|
|
129
|
+
throw new Error('Delete is not allowed for ${entity.Name}, to enable it set AllowDeleteAPI to 1 in the database.');
|
|
130
|
+
}`;
|
|
131
|
+
const saveFunction = entity.AllowCreateAPI || entity.AllowUpdateAPI
|
|
132
|
+
? ''
|
|
133
|
+
: ` /**
|
|
134
|
+
* ${entity.Name} - AllowCreateAPI and AllowUpdateAPI are both set to 0 in the database. Save is not allowed, so this method is generated to override the base class method and throw an error. To enable save for this entity, set AllowCreateAPI and/or AllowUpdateAPI to 1 in the database.
|
|
135
|
+
* @public
|
|
136
|
+
* @method
|
|
137
|
+
* @override
|
|
138
|
+
* @memberof ${sClassName}
|
|
139
|
+
* @throws {Error} - Save is not allowed for ${entity.Name}, to enable it set AllowCreateAPI and/or AllowUpdateAPI to 1 in the database.
|
|
140
|
+
*/
|
|
141
|
+
public async Save(options?: EntitySaveOptions) : Promise<boolean> {
|
|
142
|
+
throw new Error('Save is not allowed for ${entity.Name}, to enable it set AllowCreateAPI and/or AllowUpdateAPI to 1 in the database.');
|
|
143
|
+
}`;
|
|
144
|
+
let sRet = `
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* ${entity.Name} - strongly typed entity sub-class
|
|
148
|
+
* * Schema: ${entity.SchemaName}
|
|
149
|
+
* * Base Table: ${entity.BaseTable}
|
|
150
|
+
* * Base View: ${entity.BaseView}${entity.Description && entity.Description.length > 0 ? '\n * * @description ' + entity.Description : ''}
|
|
151
|
+
* * Primary Key${entity.PrimaryKeys.length > 1 ? 's' : ''}: ${entity.PrimaryKeys.map((f) => f.Name).join(', ')}
|
|
152
|
+
* @extends {BaseEntity}
|
|
153
|
+
* @class
|
|
154
|
+
* @public
|
|
155
|
+
*/
|
|
156
|
+
${subClassImportStatement}@RegisterClass(BaseEntity, '${entity.Name}')
|
|
157
|
+
export class ${sClassName} extends ${sBaseClass}<${sClassName}Type> {${loadFunction ? '\n' + loadFunction : ''}${saveFunction ? '\n\n' + saveFunction : ''}${deleteFunction ? '\n\n' + deleteFunction : ''}
|
|
158
|
+
|
|
159
|
+
${fields}
|
|
160
|
+
}
|
|
161
|
+
`;
|
|
162
|
+
if (includeFileHeader)
|
|
163
|
+
sRet = this.generateEntitySubClassFileHeader() + sRet;
|
|
164
|
+
return sRet;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
GenerateSchemaAndType(entity) {
|
|
168
|
+
let content = '';
|
|
169
|
+
if (entity.PrimaryKeys.length === 0) {
|
|
170
|
+
(0, logging_1.logStatus)(`Entity ${entity.Name} has no primary keys. Skipping.`);
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
const fields = entity.Fields.map((e) => {
|
|
174
|
+
let values = '';
|
|
175
|
+
let valueList = '';
|
|
176
|
+
if (e.ValueListType && e.ValueListType.length > 0 && e.ValueListType.trim().toLowerCase() !== 'none') {
|
|
177
|
+
values = e.EntityFieldValues.map((v) => `\n * * ${v.Value}${v.Description && v.Description.length > 0 ? ' - ' + v.Description : ''}`).join('');
|
|
178
|
+
valueList = `\n * * Value List Type: ${e.ValueListType}\n * * Possible Values ` + values;
|
|
179
|
+
}
|
|
180
|
+
let typeString = `${(0, core_1.TypeScriptTypeFromSQLType)(e.Type).toLowerCase()}()` + (e.AllowsNull ? '.nullish()' : '');
|
|
181
|
+
if (e.ValueListTypeEnum !== core_1.EntityFieldValueListType.None && e.EntityFieldValues && e.EntityFieldValues.length > 0) {
|
|
182
|
+
// construct a typeString that is a union of the possible values
|
|
183
|
+
const quotes = e.NeedsQuotes ? "'" : '';
|
|
184
|
+
typeString = `union([${e.EntityFieldValues.map((v) => `z.literal(${quotes}${v.Value}${quotes})`).join(', ')}])`;
|
|
185
|
+
if (e.ValueListTypeEnum === core_1.EntityFieldValueListType.ListOrUserEntry) {
|
|
186
|
+
// special case becuase a user can enter whatever they want
|
|
187
|
+
typeString += `.or(z.${(0, core_1.TypeScriptTypeFromSQLType)(e.Type)}()) `;
|
|
188
|
+
}
|
|
189
|
+
// finally, add the null type if it allows null
|
|
190
|
+
if (e.AllowsNull) {
|
|
191
|
+
typeString += '.nullish()';
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
let sRet = ` ${e.CodeName}: z.${typeString}.describe(\`\n${this.GenetateZodDescription(e)}\`),`;
|
|
195
|
+
return sRet;
|
|
196
|
+
}).join('\n');
|
|
197
|
+
const schemaName = `${entity.ClassName}Schema`;
|
|
198
|
+
content = `
|
|
199
|
+
/**
|
|
200
|
+
* zod schema definition for the entity ${entity.Name}
|
|
201
|
+
*/
|
|
202
|
+
export const ${schemaName} = z.object({
|
|
203
|
+
${fields}
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
export type ${entity.ClassName}EntityType = z.infer<typeof ${schemaName}>;
|
|
207
|
+
`;
|
|
208
|
+
}
|
|
209
|
+
return content;
|
|
210
|
+
}
|
|
211
|
+
GenetateZodDescription(entityField) {
|
|
212
|
+
let result = '';
|
|
213
|
+
let valueList = '';
|
|
214
|
+
if (entityField.ValueListType && entityField.ValueListType.length > 0 && entityField.ValueListType.trim().toLowerCase() !== 'none') {
|
|
215
|
+
let values = entityField.EntityFieldValues.map((v) => `\n * * ${v.Value}${v.Description && v.Description.length > 0 ? ' - ' + v.Description : ''}`).join('');
|
|
216
|
+
valueList = `\n * * Value List Type: ${entityField.ValueListType}\n * * Possible Values ` + values;
|
|
217
|
+
}
|
|
218
|
+
result += ` * * Field Name: ${entityField.Name}${entityField.DisplayName && entityField.DisplayName.length > 0 ? '\n * * Display Name: ' + entityField.DisplayName : ''}\n`;
|
|
219
|
+
result += ` * * SQL Data Type: ${entityField.SQLFullType}${entityField.RelatedEntity ? '\n * * Related Entity/Foreign Key: ' + entityField.RelatedEntity + ' (' + entityField.RelatedEntityBaseView + '.' + entityField.RelatedEntityFieldName + ')' : ''}${entityField.DefaultValue && entityField.DefaultValue.length > 0 ? '\n * * Default Value: ' + entityField.DefaultValue : ''}${valueList}${entityField.Description && entityField.Description.length > 0 ? '\n * * Description: ' + entityField.Description : ''}`;
|
|
220
|
+
return result;
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
exports.EntitySubClassGeneratorBase = EntitySubClassGeneratorBase;
|
|
224
|
+
exports.EntitySubClassGeneratorBase = EntitySubClassGeneratorBase = __decorate([
|
|
225
|
+
(0, global_1.RegisterClass)(EntitySubClassGeneratorBase)
|
|
226
|
+
], EntitySubClassGeneratorBase);
|
|
227
|
+
//# sourceMappingURL=entity_subclasses_codegen.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity_subclasses_codegen.js","sourceRoot":"","sources":["../src/entity_subclasses_codegen.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+CAAwH;AACx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M,IAAI,8BAA8B,WAAW,CAAC,WAAW,GAAG,WAAW,CAAC,aAAa,CAAC,CAAC,CAAC,4CAA4C,GAAG,WAAW,CAAC,aAAa,GAAG,IAAI,GAAG,WAAW,CAAC,qBAAqB,GAAG,GAAG,GAAG,WAAW,CAAC,sBAAsB,GAAG,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,WAAW,CAAC,YAAY,IAAI,WAAW,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,+BAA+B,GAAG,WAAW,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,GAAG,SAAS,GAAG,WAAW,CAAC,WAAW,IAAI,WAAW,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,yBAAyB,GAAG,WAAW,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;QACrhB,OAAO,MAAM,CAAC;IAChB,CAAC;CACF,CAAA;AA5NY,kEAA2B;sCAA3B,2BAA2B;IADvC,IAAA,sBAAa,EAAC,2BAA2B,CAAC;GAC9B,2BAA2B,CA4NvC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { EntityInfo } from '@memberjunction/core';
|
|
2
|
+
/**
|
|
3
|
+
* Base class for generating type definitions for entity sub-classes, you can sub-class this class to modify/extend your own entity sub-class generator logic
|
|
4
|
+
*/
|
|
5
|
+
export declare class EntityTypeGeneratorBase {
|
|
6
|
+
generateAllEntityTypeDefinitions(entities: EntityInfo[], directory: string): boolean;
|
|
7
|
+
generateTypeDefinitionHeader(): string;
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
* @param entity
|
|
11
|
+
* @param includeFileHeader
|
|
12
|
+
*/
|
|
13
|
+
generateEntitySubClass(entity: EntityInfo): string;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=entity_types_codegen.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity_types_codegen.d.ts","sourceRoot":"","sources":["../src/entity_types_codegen.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,UAAU,EAA6B,MAAM,sBAAsB,CAAC;AAOvG;;GAEG;AACH,qBACa,uBAAuB;IACzB,gCAAgC,CAAC,QAAQ,EAAE,UAAU,EAAE,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO;IAepF,4BAA4B,IAAI,MAAM;IAO7C;;;;OAIG;IACI,sBAAsB,CAAC,MAAM,EAAE,UAAU,GAAI,MAAM;CAuD7D"}
|