@memberjunction/codegen-lib 0.9.2
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/angular_client_codegen.d.ts +2 -0
- package/dist/angular_client_codegen.js +360 -0
- package/dist/angular_client_codegen.js.map +1 -0
- package/dist/config.d.ts +101 -0
- package/dist/config.js +55 -0
- package/dist/config.js.map +1 -0
- package/dist/db.d.ts +3 -0
- package/dist/db.js +19 -0
- package/dist/db.js.map +1 -0
- package/dist/dbSchema.d.ts +3 -0
- package/dist/dbSchema.js +143 -0
- package/dist/dbSchema.js.map +1 -0
- package/dist/entity_subclasses_codegen.d.ts +4 -0
- package/dist/entity_subclasses_codegen.js +84 -0
- package/dist/entity_subclasses_codegen.js.map +1 -0
- package/dist/graphql_client_codegen.d.ts +4 -0
- package/dist/graphql_client_codegen.js +161 -0
- package/dist/graphql_client_codegen.js.map +1 -0
- package/dist/graphql_server_codegen.d.ts +5 -0
- package/dist/graphql_server_codegen.js +509 -0
- package/dist/graphql_server_codegen.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +32 -0
- package/dist/index.js.map +1 -0
- package/dist/logging.d.ts +2 -0
- package/dist/logging.js +36 -0
- package/dist/logging.js.map +1 -0
- package/dist/manageMetadata.d.ts +9 -0
- package/dist/manageMetadata.js +603 -0
- package/dist/manageMetadata.js.map +1 -0
- package/dist/react_client_codegen.d.ts +4 -0
- package/dist/react_client_codegen.js +147 -0
- package/dist/react_client_codegen.js.map +1 -0
- package/dist/runCodeGen.d.ts +1 -0
- package/dist/runCodeGen.js +213 -0
- package/dist/runCodeGen.js.map +1 -0
- package/dist/runCommand.d.ts +9 -0
- package/dist/runCommand.js +111 -0
- package/dist/runCommand.js.map +1 -0
- package/dist/sql.d.ts +6 -0
- package/dist/sql.js +78 -0
- package/dist/sql.js.map +1 -0
- package/dist/sql_codegen.d.ts +11 -0
- package/dist/sql_codegen.js +753 -0
- package/dist/sql_codegen.js.map +1 -0
- package/dist/util.d.ts +4 -0
- package/dist/util.js +36 -0
- package/dist/util.js.map +1 -0
- package/package.json +28 -0
- package/readme.md +3 -0
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.generateAngularCode = void 0;
|
|
7
|
+
const core_1 = require("@memberjunction/core");
|
|
8
|
+
const logging_1 = require("./logging");
|
|
9
|
+
const fs_1 = __importDefault(require("fs"));
|
|
10
|
+
const path_1 = __importDefault(require("path"));
|
|
11
|
+
const config_1 = require("./config");
|
|
12
|
+
class AngularFormSectionInfo {
|
|
13
|
+
}
|
|
14
|
+
function generateAngularCode(entities, directory) {
|
|
15
|
+
try {
|
|
16
|
+
const entityPath = path_1.default.join(directory, 'Entities');
|
|
17
|
+
//const classMapEntries: string[] = [];
|
|
18
|
+
const componentImports = [];
|
|
19
|
+
const componentNames = [];
|
|
20
|
+
const sections = [];
|
|
21
|
+
if (!fs_1.default.existsSync(entityPath))
|
|
22
|
+
fs_1.default.mkdirSync(entityPath, { recursive: true }); // create the directory if it doesn't exist
|
|
23
|
+
for (let i = 0; i < entities.length; ++i) {
|
|
24
|
+
const entity = entities[i];
|
|
25
|
+
if (entity._hasIdField && entity.IncludeInAPI) {
|
|
26
|
+
const thisEntityPath = path_1.default.join(entityPath, entity.ClassName);
|
|
27
|
+
if (!fs_1.default.existsSync(thisEntityPath))
|
|
28
|
+
fs_1.default.mkdirSync(thisEntityPath, { recursive: true }); // create the directory if it doesn't exist
|
|
29
|
+
const { htmlCode, sections: entitySections } = generateSingleEntityHTMLForAngular(entity);
|
|
30
|
+
const tsCode = generateSingleEntityTypeScriptForAngular(entity, entitySections);
|
|
31
|
+
fs_1.default.writeFileSync(path_1.default.join(thisEntityPath, `${entity.ClassName.toLowerCase()}.form.component.ts`), tsCode);
|
|
32
|
+
fs_1.default.writeFileSync(path_1.default.join(thisEntityPath, `${entity.ClassName.toLowerCase()}.form.component.html`), htmlCode);
|
|
33
|
+
if (entitySections.length > 0) {
|
|
34
|
+
const sectionPath = path_1.default.join(thisEntityPath, 'sections');
|
|
35
|
+
if (!fs_1.default.existsSync(sectionPath))
|
|
36
|
+
fs_1.default.mkdirSync(sectionPath, { recursive: true }); // create the directory if it doesn't exist
|
|
37
|
+
for (let j = 0; j < entitySections.length; ++j) {
|
|
38
|
+
fs_1.default.writeFileSync(path_1.default.join(sectionPath, `${entitySections[j].FileName}`), entitySections[j].ComponentCode);
|
|
39
|
+
sections.push(entitySections[j]); // add the entity's secitons one by one to the master/global list of sections
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const componentName = `${entity.ClassName}FormComponent`;
|
|
43
|
+
componentImports.push(`import { ${componentName}, Load${componentName} } from "./Entities/${entity.ClassName}/${entity.ClassName.toLowerCase()}.form.component";`);
|
|
44
|
+
componentNames.push(componentName);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const moduleCode = generateAngularModule(componentImports, componentNames, sections);
|
|
48
|
+
fs_1.default.writeFileSync(path_1.default.join(directory, 'generated-forms.module.ts'), moduleCode);
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
catch (err) {
|
|
52
|
+
(0, logging_1.logError)(err);
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.generateAngularCode = generateAngularCode;
|
|
57
|
+
function generateAngularModule(componentImports, componentNames, sections) {
|
|
58
|
+
return `/**********************************************************************************
|
|
59
|
+
* GENERATED FILE - This file is automatically managed by the MJ CodeGen tool,
|
|
60
|
+
*
|
|
61
|
+
* DO NOT MODIFY THIS FILE - any changes you make will be wiped out the next time the file is
|
|
62
|
+
* generated
|
|
63
|
+
*
|
|
64
|
+
**********************************************************************************/
|
|
65
|
+
import { NgModule } from '@angular/core';
|
|
66
|
+
import { CommonModule } from '@angular/common';
|
|
67
|
+
import { FormsModule } from '@angular/forms';
|
|
68
|
+
import { InputsModule } from '@progress/kendo-angular-inputs';
|
|
69
|
+
import { DateInputsModule } from '@progress/kendo-angular-dateinputs';
|
|
70
|
+
import { ButtonsModule } from '@progress/kendo-angular-buttons';
|
|
71
|
+
import { LayoutModule } from '@progress/kendo-angular-layout';
|
|
72
|
+
import { GenericComponentsModule } from '../generic/generic.module';
|
|
73
|
+
import { UserViewGridModule } from '@memberjunction/ng-user-view-grid';
|
|
74
|
+
import { LinkDirectivesModule } from '@memberjunction/ng-link-directives';
|
|
75
|
+
|
|
76
|
+
// Import Generated Components
|
|
77
|
+
${componentImports.join('\n')}
|
|
78
|
+
${sections.map(s => `import { ${s.ClassName}, Load${s.ClassName} } from "./Entities/${s.EntityClassName}/sections/${s.FileNameWithoutExtension}"`).join('\n')}
|
|
79
|
+
|
|
80
|
+
@NgModule({
|
|
81
|
+
declarations: [
|
|
82
|
+
${componentNames.join(',\n ') + (componentNames.length > 0 ? ',' : '')}
|
|
83
|
+
${sections.map(s => s.ClassName).join(',\n ')}
|
|
84
|
+
],
|
|
85
|
+
imports: [
|
|
86
|
+
CommonModule,
|
|
87
|
+
FormsModule,
|
|
88
|
+
LayoutModule,
|
|
89
|
+
InputsModule,
|
|
90
|
+
ButtonsModule,
|
|
91
|
+
DateInputsModule,
|
|
92
|
+
GenericComponentsModule,
|
|
93
|
+
UserViewGridModule,
|
|
94
|
+
LinkDirectivesModule
|
|
95
|
+
],
|
|
96
|
+
exports: [
|
|
97
|
+
${componentNames.join(',\n ') + (componentNames.length > 0 ? ',' : '')}
|
|
98
|
+
${sections.map(s => s.ClassName).join(',\n ')}
|
|
99
|
+
]
|
|
100
|
+
})
|
|
101
|
+
export class GeneratedFormsModule { }
|
|
102
|
+
|
|
103
|
+
export function LoadGeneratedForms() {
|
|
104
|
+
// This function doesn't do much, but it calls each generated form's loader function
|
|
105
|
+
// which in turn calls the sections for that generated form. Ultimately, those bits of
|
|
106
|
+
// code do NOTHING - the point is to prevent the code from being eliminated during tree shaking
|
|
107
|
+
// since it is dynamically instantiated on demand, and the Angular compiler has no way to know that,
|
|
108
|
+
// in production builds tree shaking will eliminate the code unless we do this
|
|
109
|
+
${componentNames.map(c => `Load${c}();`).join('\n ')}
|
|
110
|
+
${sections.map(s => `Load${s.ClassName}();`).join('\n ')}
|
|
111
|
+
}
|
|
112
|
+
`;
|
|
113
|
+
}
|
|
114
|
+
function generateSingleEntityTypeScriptForAngular(entity, sections) {
|
|
115
|
+
const entityObjectClass = entity.ClassName;
|
|
116
|
+
const sectionImports = sections.length > 0 ? sections.map(s => `import { Load${s.ClassName} } from "./sections/${s.FileNameWithoutExtension}"`).join('\n') : '';
|
|
117
|
+
return `import { Component } from '@angular/core';
|
|
118
|
+
import { ${entityObjectClass}Entity } from '${entity.SchemaName === config_1.mjCoreSchema ? '@memberjunction/core-entities' : 'mj_generatedentities'}';
|
|
119
|
+
import { RegisterClass } from '@memberjunction/global';
|
|
120
|
+
import { BaseFormComponent } from 'src/app/generic/base-form-component';
|
|
121
|
+
${sectionImports}
|
|
122
|
+
@RegisterClass(BaseFormComponent, '${entity.Name}') // Tell MemberJunction about this class
|
|
123
|
+
@Component({
|
|
124
|
+
selector: 'gen-${entity.ClassName.toLowerCase()}-form',
|
|
125
|
+
templateUrl: './${entity.ClassName.toLowerCase()}.form.component.html',
|
|
126
|
+
styleUrls: ['../../../shared/form-styles.css']
|
|
127
|
+
})
|
|
128
|
+
export class ${entity.ClassName}FormComponent extends BaseFormComponent {
|
|
129
|
+
public record: ${entityObjectClass}Entity | null = null;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export function Load${entity.ClassName}FormComponent() {
|
|
133
|
+
${sections.map(s => `Load${s.ClassName}();`).join('\n ')}
|
|
134
|
+
}
|
|
135
|
+
`;
|
|
136
|
+
}
|
|
137
|
+
function entityHasTopArea(entity) {
|
|
138
|
+
return entity.Fields.some(f => f.GeneratedFormSectionType === core_1.GeneratedFormSectionType.Top);
|
|
139
|
+
}
|
|
140
|
+
function generateTopAreaHTMLForAngular(entity) {
|
|
141
|
+
if (!entityHasTopArea(entity))
|
|
142
|
+
return '';
|
|
143
|
+
else
|
|
144
|
+
return `<mj-form-section Entity="${entity.Name}" Section="top-area" [record]="record" [EditMode]="this.EditMode"></mj-form-section>`;
|
|
145
|
+
}
|
|
146
|
+
function AddSectionIfNeeded(entity, sections, type, name) {
|
|
147
|
+
const section = sections.find(s => s.Name === name && s.Type === type);
|
|
148
|
+
const fName = `${stripWhiteSpace(name.toLowerCase())}.component`;
|
|
149
|
+
if (!section)
|
|
150
|
+
sections.push({
|
|
151
|
+
Type: type,
|
|
152
|
+
Name: name,
|
|
153
|
+
FileName: `${fName}.ts`,
|
|
154
|
+
ComponentCode: '',
|
|
155
|
+
ClassName: `${entity.ClassName}${stripWhiteSpace(name)}Component`,
|
|
156
|
+
TabCode: '',
|
|
157
|
+
Fields: [],
|
|
158
|
+
EntityClassName: entity.ClassName,
|
|
159
|
+
FileNameWithoutExtension: fName
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
function generateAngularAdditionalSections(entity, startIndex) {
|
|
163
|
+
const sections = [];
|
|
164
|
+
let index = startIndex;
|
|
165
|
+
for (const field of entity.Fields) {
|
|
166
|
+
if (field.IncludeInGeneratedForm) {
|
|
167
|
+
if (field.GeneratedFormSectionType === core_1.GeneratedFormSectionType.Category && field.Category && field.Category !== '' && field.IncludeInGeneratedForm)
|
|
168
|
+
AddSectionIfNeeded(entity, sections, core_1.GeneratedFormSectionType.Category, field.Category);
|
|
169
|
+
else if (field.GeneratedFormSectionType === core_1.GeneratedFormSectionType.Details)
|
|
170
|
+
AddSectionIfNeeded(entity, sections, core_1.GeneratedFormSectionType.Details, "Details");
|
|
171
|
+
else if (field.GeneratedFormSectionType === core_1.GeneratedFormSectionType.Top)
|
|
172
|
+
AddSectionIfNeeded(entity, sections, core_1.GeneratedFormSectionType.Top, "Top");
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
// now we have a distinct list of section names set, generate HTML for each section
|
|
176
|
+
for (const section of sections) {
|
|
177
|
+
let sectionName = '';
|
|
178
|
+
if (section.Type === core_1.GeneratedFormSectionType.Top) {
|
|
179
|
+
section.TabCode = generateTopAreaHTMLForAngular(entity);
|
|
180
|
+
sectionName = 'top-area';
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
if (section.Type === core_1.GeneratedFormSectionType.Category)
|
|
184
|
+
sectionName = stripWhiteSpace(section.Name.toLowerCase());
|
|
185
|
+
else if (section.Type === core_1.GeneratedFormSectionType.Details)
|
|
186
|
+
sectionName = 'details';
|
|
187
|
+
section.TabCode = `
|
|
188
|
+
<kendo-tabstrip-tab [selected]="this.RegisterAndCheckIfCurrentTab('${section.Name}')">
|
|
189
|
+
<ng-template kendoTabTitle>${section.Name}</ng-template>
|
|
190
|
+
<ng-template kendoTabContent >
|
|
191
|
+
<mj-form-section Entity="${entity.Name}" Section="${stripWhiteSpace(section.Name.toLowerCase())}" [record]="record" [EditMode]="this.EditMode"></mj-form-section>
|
|
192
|
+
</ng-template>
|
|
193
|
+
</kendo-tabstrip-tab>`;
|
|
194
|
+
}
|
|
195
|
+
const { readModeHTML, editModeHTML } = generateSectionHTMLForAngular(entity, section);
|
|
196
|
+
section.ComponentCode = `import { Component, Input } from '@angular/core';
|
|
197
|
+
import { RegisterClass } from '@memberjunction/global';
|
|
198
|
+
import { BaseFormSectionComponent } from 'src/app/generic/base-form-section-component';
|
|
199
|
+
import { ${entity.ClassName}Entity } from '${entity.SchemaName === config_1.mjCoreSchema ? '@memberjunction/core-entities' : 'mj_generatedentities'}';
|
|
200
|
+
|
|
201
|
+
@RegisterClass(BaseFormSectionComponent, '${entity.Name}.${sectionName}') // Tell MemberJunction about this class
|
|
202
|
+
@Component({
|
|
203
|
+
selector: 'gen-${entity.ClassName.toLowerCase()}-form-${sectionName}',
|
|
204
|
+
styleUrls: ['../../../../shared/form-styles.css'],
|
|
205
|
+
template: \`<div *ngIf="this.record">
|
|
206
|
+
<div *ngIf="this.EditMode" class="record-form">
|
|
207
|
+
${editModeHTML}
|
|
208
|
+
</div>
|
|
209
|
+
<div *ngIf="!this.EditMode" class="record-form">
|
|
210
|
+
${readModeHTML}
|
|
211
|
+
</div>
|
|
212
|
+
</div>
|
|
213
|
+
\`
|
|
214
|
+
})
|
|
215
|
+
export class ${entity.ClassName}${stripWhiteSpace(section.Name)}Component extends BaseFormSectionComponent {
|
|
216
|
+
@Input() override record: ${entity.ClassName}Entity | null = null;
|
|
217
|
+
@Input() override EditMode: boolean = false;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export function Load${entity.ClassName}${stripWhiteSpace(section.Name)}Component() {
|
|
221
|
+
// does nothing, but called in order to prevent tree-shaking from eliminating this component from the build
|
|
222
|
+
}
|
|
223
|
+
`;
|
|
224
|
+
if (section.Type !== core_1.GeneratedFormSectionType.Top)
|
|
225
|
+
index++; // don't increment the tab index for TOP AREA, becuse it won't be rendered as a tab
|
|
226
|
+
}
|
|
227
|
+
return sections;
|
|
228
|
+
}
|
|
229
|
+
function generateSectionHTMLForAngular(entity, section) {
|
|
230
|
+
let readModeHTML = '';
|
|
231
|
+
let editModeHTML = '';
|
|
232
|
+
for (const field of entity.Fields) {
|
|
233
|
+
if (field.IncludeInGeneratedForm) {
|
|
234
|
+
let bMatch = false;
|
|
235
|
+
if (field.GeneratedFormSectionType === core_1.GeneratedFormSectionType.Top && section.Type === core_1.GeneratedFormSectionType.Top) {
|
|
236
|
+
// match, include the field in the output
|
|
237
|
+
bMatch = true;
|
|
238
|
+
}
|
|
239
|
+
else if (field.GeneratedFormSectionType === core_1.GeneratedFormSectionType.Category && field.Category && section.Name && field.Category.trim().toLowerCase() === section.Name.trim().toLowerCase()) {
|
|
240
|
+
// match, include the field in the output
|
|
241
|
+
bMatch = true;
|
|
242
|
+
}
|
|
243
|
+
else if (field.GeneratedFormSectionType === core_1.GeneratedFormSectionType.Details && section.Type === core_1.GeneratedFormSectionType.Details) {
|
|
244
|
+
// match, include the field in the output
|
|
245
|
+
bMatch = true;
|
|
246
|
+
}
|
|
247
|
+
if (bMatch && field.Name.toLowerCase() !== 'id') {
|
|
248
|
+
section.Fields.push(field); // add the field to the section fields array
|
|
249
|
+
// next, generate HTML for the field
|
|
250
|
+
const linkDirective = field.RelatedEntity && field.RelatedEntity.length > 0 ? `mjFieldLink [record]="record" fieldName="${field.Name}" ` : '';
|
|
251
|
+
const linkNoTextDirective = field.RelatedEntity && field.RelatedEntity.length > 0 ? `mjFieldLink [record]="record" fieldName="${field.Name}" [replaceText]="false" ` : '';
|
|
252
|
+
const webLinkDirective = field.ExtendedType && field.ExtendedType.length > 0 && field.ExtendedType.trim().toLowerCase() === 'url' ? `mjWebLink [field]="record.GetFieldByName('${field.Name}')" ` : '';
|
|
253
|
+
const emailLinkDirective = field.ExtendedType && field.ExtendedType.length > 0 && field.ExtendedType.trim().toLowerCase() === 'email' ? `mjEmailLink [field]="record.GetFieldByName('${field.Name}')" ` : '';
|
|
254
|
+
readModeHTML += `
|
|
255
|
+
<div class="record-form-row">
|
|
256
|
+
<label class="fieldLabel">${field.DisplayNameOrName}</label>
|
|
257
|
+
<span ${linkDirective}${webLinkDirective}${emailLinkDirective}>{{FormatValue('${field.Name}', 0)}}</span>
|
|
258
|
+
</div>`;
|
|
259
|
+
let editControl = '';
|
|
260
|
+
let bReadOnly = false;
|
|
261
|
+
if (!field.ReadOnly) {
|
|
262
|
+
if (field.TSType === core_1.EntityFieldTSType.Boolean)
|
|
263
|
+
editControl = `<input type="checkbox" [(ngModel)]="record.${field.Name}" kendoCheckBox />`;
|
|
264
|
+
else if (field.TSType === core_1.EntityFieldTSType.Date)
|
|
265
|
+
editControl = `<kendo-datepicker [(value)]="record.${field.Name}" ></kendo-datepicker>`;
|
|
266
|
+
else if (field.TSType === core_1.EntityFieldTSType.Number)
|
|
267
|
+
editControl = `<kendo-numerictextbox [(value)]="record.${field.Name}" ></kendo-numerictextbox>`;
|
|
268
|
+
else if (field.TSType === core_1.EntityFieldTSType.String) {
|
|
269
|
+
if (field.MaxLength > 100)
|
|
270
|
+
editControl = `<kendo-textarea [(ngModel)]="record.${field.Name}" ></kendo-textarea>`;
|
|
271
|
+
else
|
|
272
|
+
editControl = `<kendo-textbox [(ngModel)]="record.${field.Name}" />`;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
else {
|
|
276
|
+
// read only field
|
|
277
|
+
editControl = `<span ${linkDirective}${webLinkDirective}${emailLinkDirective}>{{FormatValue('${field.Name}', 0)}}</span>`;
|
|
278
|
+
bReadOnly = true;
|
|
279
|
+
}
|
|
280
|
+
editModeHTML += `
|
|
281
|
+
<div class="record-form-row">
|
|
282
|
+
<label class="fieldLabel">${field.DisplayNameOrName}</label>
|
|
283
|
+
${editControl}
|
|
284
|
+
</div> `;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
return { readModeHTML, editModeHTML };
|
|
289
|
+
}
|
|
290
|
+
function generateRelatedEntityTabs(entity, startIndex) {
|
|
291
|
+
const tabs = [];
|
|
292
|
+
let index = startIndex;
|
|
293
|
+
for (const relatedEntity of entity.RelatedEntities) {
|
|
294
|
+
const tabName = relatedEntity.DisplayName ? relatedEntity.DisplayName : relatedEntity.RelatedEntity;
|
|
295
|
+
tabs.push(`
|
|
296
|
+
<kendo-tabstrip-tab [selected]="this.RegisterAndCheckIfCurrentTab('${tabName}')">
|
|
297
|
+
<ng-template kendoTabTitle>${tabName}</ng-template>
|
|
298
|
+
<ng-template kendoTabContent >
|
|
299
|
+
<mj-user-view-grid [Params]="this.BuildRelationshipViewParamsByEntityName('${relatedEntity.RelatedEntity}')"
|
|
300
|
+
[AllowLoad]="this.IsCurrentTab('${tabName}')"
|
|
301
|
+
[EditMode]="this.GridEditMode()"
|
|
302
|
+
[BottomMargin]="GridBottomMargin"></mj-user-view-grid>
|
|
303
|
+
</ng-template>
|
|
304
|
+
</kendo-tabstrip-tab>`);
|
|
305
|
+
index++;
|
|
306
|
+
}
|
|
307
|
+
return tabs;
|
|
308
|
+
}
|
|
309
|
+
function stripWhiteSpace(s) {
|
|
310
|
+
return s.replace(/\s/g, '');
|
|
311
|
+
}
|
|
312
|
+
function generateSingleEntityHTMLForAngular(entity) {
|
|
313
|
+
const topArea = generateTopAreaHTMLForAngular(entity);
|
|
314
|
+
const additionalSections = generateAngularAdditionalSections(entity, 0);
|
|
315
|
+
// calc ending index for additional sections so we can pass taht into the related entity tabs because they need to start incrementally up from there...
|
|
316
|
+
const endingIndex = additionalSections && additionalSections.length ? (topArea && topArea.length > 0 ? additionalSections.length - 1 : additionalSections.length) : 0;
|
|
317
|
+
const relatedEntitySections = generateRelatedEntityTabs(entity, endingIndex);
|
|
318
|
+
const htmlCode = topArea.length > 0 ? generateSingleEntityHTMLWithSplitterForAngular(topArea, additionalSections, relatedEntitySections) :
|
|
319
|
+
generateSingleEntityHTMLWithOUTSplitterForAngular(topArea, additionalSections, relatedEntitySections);
|
|
320
|
+
return { htmlCode, sections: additionalSections };
|
|
321
|
+
}
|
|
322
|
+
function generateSingleEntityHTMLWithSplitterForAngular(topArea, additionalSections, relatedEntitySections) {
|
|
323
|
+
const htmlCode = `<div class="record-form-container">
|
|
324
|
+
<form *ngIf="record" class="record-form" #form="ngForm">
|
|
325
|
+
<kendo-splitter orientation="vertical" (layoutChange)="splitterLayoutChange()">
|
|
326
|
+
<kendo-splitter-pane>
|
|
327
|
+
${innerTopAreaHTML(topArea)}
|
|
328
|
+
</kendo-splitter-pane>
|
|
329
|
+
<kendo-splitter-pane>
|
|
330
|
+
${innerTabStripHTML(additionalSections, relatedEntitySections)}
|
|
331
|
+
</kendo-splitter-pane>
|
|
332
|
+
</kendo-splitter>
|
|
333
|
+
</form>
|
|
334
|
+
</div>
|
|
335
|
+
`;
|
|
336
|
+
return htmlCode;
|
|
337
|
+
}
|
|
338
|
+
function innerTopAreaHTML(topArea) {
|
|
339
|
+
return ` <div #topArea class="record-form-group">
|
|
340
|
+
<mj-form-toolbar [form]="this"></mj-form-toolbar>
|
|
341
|
+
${topArea}
|
|
342
|
+
</div>`;
|
|
343
|
+
}
|
|
344
|
+
function innerTabStripHTML(additionalSections, relatedEntitySections) {
|
|
345
|
+
return ` <kendo-tabstrip #tabStrip (tabSelect)="onTabSelect($event)" [keepTabContent]="true" [animate] = "false" [height]="TabHeight" >
|
|
346
|
+
${additionalSections ? additionalSections.filter(s => s.Type !== core_1.GeneratedFormSectionType.Top).map(s => s.TabCode).join('\n ') : ''}
|
|
347
|
+
${relatedEntitySections ? relatedEntitySections.join('\n') : ''}
|
|
348
|
+
</kendo-tabstrip>`;
|
|
349
|
+
}
|
|
350
|
+
function generateSingleEntityHTMLWithOUTSplitterForAngular(topArea, additionalSections, relatedEntitySections) {
|
|
351
|
+
const htmlCode = `<div class="record-form-container">
|
|
352
|
+
<form *ngIf="record" class="record-form" #form="ngForm">
|
|
353
|
+
${innerTopAreaHTML(topArea)}
|
|
354
|
+
${innerTabStripHTML(additionalSections, relatedEntitySections)}
|
|
355
|
+
</form>
|
|
356
|
+
</div>
|
|
357
|
+
`;
|
|
358
|
+
return htmlCode;
|
|
359
|
+
}
|
|
360
|
+
//# sourceMappingURL=angular_client_codegen.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"angular_client_codegen.js","sourceRoot":"","sources":["../src/angular_client_codegen.ts"],"names":[],"mappings":";;;;;;AAAA,+CAAgH;AAChH,uCAAqC;AACrC,4CAAoB;AACpB,gDAAwB;AACxB,qCAAwC;AAExC,MAAM,sBAAsB;CAU3B;AAED,SAAgB,mBAAmB,CAAC,QAAsB,EAAE,SAAiB;IAC3E,IAAI;QACF,MAAM,UAAU,GAAG,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;QACpD,uCAAuC;QACvC,MAAM,gBAAgB,GAAa,EAAE,CAAC;QACtC,MAAM,c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B,CAAC,kBAAkB,EAAE,qBAAqB;IAChE,OAAO;kCACuB,kBAAkB,CAAC,CAAC,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,+BAAwB,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,EAAE;kCAC/I,qBAAqB,CAAC,CAAC,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE;8CACjD,CAAA;AAC9C,CAAC;AAED,SAAS,iDAAiD,CAAC,OAAO,EAAE,kBAAkB,EAAE,qBAAqB;IACzG,MAAM,QAAQ,GAAY;;UAEpB,gBAAgB,CAAC,OAAO,CAAC;UACzB,iBAAiB,CAAC,kBAAkB,EAAE,qBAAqB,CAAC;;;KAGjE,CAAA;IACD,OAAO,QAAQ,CAAC;AACpB,CAAC"}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
export declare const dbHost: string;
|
|
2
|
+
export declare const dbPort: number;
|
|
3
|
+
export declare const dbUsername: string;
|
|
4
|
+
export declare const dbPassword: string;
|
|
5
|
+
export declare const dbDatabase: string;
|
|
6
|
+
export declare const outputCode: string;
|
|
7
|
+
export declare const configFile: string;
|
|
8
|
+
export declare const mjCoreSchema: string;
|
|
9
|
+
export declare const graphqlPort: number;
|
|
10
|
+
export type TableInfo = {
|
|
11
|
+
schema: string;
|
|
12
|
+
table: string;
|
|
13
|
+
};
|
|
14
|
+
export type OutputInfo = {
|
|
15
|
+
type: string;
|
|
16
|
+
directory: string;
|
|
17
|
+
appendOutputCode?: boolean;
|
|
18
|
+
};
|
|
19
|
+
export type CommandInfo = {
|
|
20
|
+
workingDirectory: string;
|
|
21
|
+
command: string;
|
|
22
|
+
args: string[];
|
|
23
|
+
timeout: number;
|
|
24
|
+
when: string;
|
|
25
|
+
};
|
|
26
|
+
export type CustomSQLScript = {
|
|
27
|
+
when: string;
|
|
28
|
+
scriptFile: string;
|
|
29
|
+
};
|
|
30
|
+
export type LogInfo = {
|
|
31
|
+
log: boolean;
|
|
32
|
+
logFile: string;
|
|
33
|
+
console: boolean;
|
|
34
|
+
};
|
|
35
|
+
export type SettingInfo = {
|
|
36
|
+
name: string;
|
|
37
|
+
value: string;
|
|
38
|
+
};
|
|
39
|
+
export type DBSchemaJSONOutput = {
|
|
40
|
+
excludeSchemas: string[];
|
|
41
|
+
excludeEntities: string[];
|
|
42
|
+
bundles: DBSchemaJSONOutputBundle[];
|
|
43
|
+
};
|
|
44
|
+
export type DBSchemaJSONOutputBundle = {
|
|
45
|
+
name: string;
|
|
46
|
+
schemas: string[];
|
|
47
|
+
excludeSchemas: string[];
|
|
48
|
+
excludeEntities: string[];
|
|
49
|
+
};
|
|
50
|
+
export type ConfigInfo = {
|
|
51
|
+
settings: SettingInfo[];
|
|
52
|
+
excludeSchemas: string[];
|
|
53
|
+
excludeTables: TableInfo[];
|
|
54
|
+
customSQLScripts: CustomSQLScript[];
|
|
55
|
+
output: OutputInfo[];
|
|
56
|
+
commands: CommandInfo[];
|
|
57
|
+
logging: LogInfo;
|
|
58
|
+
newEntityDefaults: NewEntityDefaults;
|
|
59
|
+
newSchemaDefaults: NewSchemaDefaults;
|
|
60
|
+
dbSchemaJSONOutput: DBSchemaJSONOutput;
|
|
61
|
+
newEntityRelationshipDefaults: NewEntityRelationshipDefaults;
|
|
62
|
+
};
|
|
63
|
+
export type NewEntityDefaults = {
|
|
64
|
+
TrackRecordChanges: boolean;
|
|
65
|
+
AuditRecordAccess: boolean;
|
|
66
|
+
AuditViewRuns: boolean;
|
|
67
|
+
AllowAllRowsAPI: boolean;
|
|
68
|
+
AllowCreateAPI: boolean;
|
|
69
|
+
AllowUpdateAPI: boolean;
|
|
70
|
+
AllowDeleteAPI: boolean;
|
|
71
|
+
AllowUserSearchAPI: boolean;
|
|
72
|
+
UserViewMaxRows: number;
|
|
73
|
+
AddToApplicationWithSchemaName: boolean;
|
|
74
|
+
IncludeFirstNFieldsAsDefaultInView: number;
|
|
75
|
+
PermissionDefaults: NewEntityPermissionDefaults;
|
|
76
|
+
};
|
|
77
|
+
export type EntityPermission = {
|
|
78
|
+
RoleName: string;
|
|
79
|
+
CanRead: boolean;
|
|
80
|
+
CanCreate: boolean;
|
|
81
|
+
CanUpdate: boolean;
|
|
82
|
+
CanDelete: boolean;
|
|
83
|
+
};
|
|
84
|
+
export type NewEntityPermissionDefaults = {
|
|
85
|
+
AutoAddPermissionsForNewEntities: boolean;
|
|
86
|
+
Permissions: EntityPermission[];
|
|
87
|
+
};
|
|
88
|
+
export type NewSchemaDefaults = {
|
|
89
|
+
CreateNewApplicationWithSchemaName: boolean;
|
|
90
|
+
};
|
|
91
|
+
export type NewEntityRelationshipDefaults = {
|
|
92
|
+
AutomaticallyCreateRelationships: boolean;
|
|
93
|
+
CreateOneToManyRelationships: boolean;
|
|
94
|
+
};
|
|
95
|
+
export declare const configInfo: ConfigInfo;
|
|
96
|
+
export declare function loadConfig(): ConfigInfo;
|
|
97
|
+
export declare function outputDir(type: string): string;
|
|
98
|
+
export declare function commands(when: string): CommandInfo[];
|
|
99
|
+
export declare function customSqlScripts(when: string): CustomSQLScript[];
|
|
100
|
+
export declare function getSetting(settingName: string): SettingInfo;
|
|
101
|
+
export declare function mj_core_schema(): string;
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.mj_core_schema = exports.getSetting = exports.customSqlScripts = exports.commands = exports.outputDir = exports.loadConfig = exports.configInfo = exports.graphqlPort = exports.mjCoreSchema = exports.configFile = exports.outputCode = exports.dbDatabase = exports.dbPassword = exports.dbUsername = exports.dbPort = exports.dbHost = void 0;
|
|
7
|
+
const env_var_1 = __importDefault(require("env-var"));
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
exports.dbHost = env_var_1.default.get('DB_HOST').required().asString();
|
|
11
|
+
exports.dbPort = env_var_1.default.get('DB_PORT').default('1433').asPortNumber();
|
|
12
|
+
exports.dbUsername = env_var_1.default.get('DB_USERNAME').required().asString();
|
|
13
|
+
exports.dbPassword = env_var_1.default.get('DB_PASSWORD').required().asString();
|
|
14
|
+
exports.dbDatabase = env_var_1.default.get('DB_DATABASE').required().asString();
|
|
15
|
+
exports.outputCode = env_var_1.default.get('OUTPUT_CODE').asString();
|
|
16
|
+
exports.configFile = env_var_1.default.get('CONFIG_FILE').asString();
|
|
17
|
+
exports.mjCoreSchema = env_var_1.default.get('MJ_CORE_SCHEMA').default('admin').asString();
|
|
18
|
+
exports.graphqlPort = env_var_1.default.get('GRAPHQL_PORT').default('4000').asPortNumber();
|
|
19
|
+
exports.configInfo = loadConfig();
|
|
20
|
+
function loadConfig() {
|
|
21
|
+
const configFileName = exports.configFile ? exports.configFile : 'config.json';
|
|
22
|
+
const configPath = path_1.default.join(__dirname, '..', configFileName);
|
|
23
|
+
const configData = fs_1.default.readFileSync(configPath, 'utf-8');
|
|
24
|
+
return JSON.parse(configData);
|
|
25
|
+
}
|
|
26
|
+
exports.loadConfig = loadConfig;
|
|
27
|
+
function outputDir(type) {
|
|
28
|
+
const outputInfo = exports.configInfo.output.find(o => o.type.trim().toUpperCase() === type.trim().toUpperCase());
|
|
29
|
+
if (outputInfo) {
|
|
30
|
+
if (outputInfo.appendOutputCode && outputInfo.appendOutputCode === true &&
|
|
31
|
+
exports.outputCode && exports.outputCode.length > 0)
|
|
32
|
+
return path_1.default.join(outputInfo.directory, exports.outputCode);
|
|
33
|
+
else
|
|
34
|
+
return outputInfo.directory;
|
|
35
|
+
}
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
exports.outputDir = outputDir;
|
|
39
|
+
function commands(when) {
|
|
40
|
+
return exports.configInfo.commands.filter(c => c.when.trim().toUpperCase() === when.trim().toUpperCase());
|
|
41
|
+
}
|
|
42
|
+
exports.commands = commands;
|
|
43
|
+
function customSqlScripts(when) {
|
|
44
|
+
return exports.configInfo.customSQLScripts.filter(c => c.when.trim().toUpperCase() === when.trim().toUpperCase());
|
|
45
|
+
}
|
|
46
|
+
exports.customSqlScripts = customSqlScripts;
|
|
47
|
+
function getSetting(settingName) {
|
|
48
|
+
return exports.configInfo.settings.find(s => s.name.trim().toUpperCase() === settingName.trim().toUpperCase());
|
|
49
|
+
}
|
|
50
|
+
exports.getSetting = getSetting;
|
|
51
|
+
function mj_core_schema() {
|
|
52
|
+
return getSetting('mj_core_schema').value;
|
|
53
|
+
}
|
|
54
|
+
exports.mj_core_schema = mj_core_schema;
|
|
55
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;;;;;AAAA,sDAA0B;AAC1B,4CAAoB;AACpB,gDAAwB;AAEX,QAAA,MAAM,GAAG,iBAAG,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC;AAClD,QAAA,MAAM,GAAG,iBAAG,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,YAAY,EAAE,CAAC;AAC3D,QAAA,UAAU,GAAG,iBAAG,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC;AAC1D,QAAA,UAAU,GAAG,iBAAG,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC;AAC1D,QAAA,UAAU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,kBAAU,IAAI,kBAAU,CAAC,MAAM,GAAG,CAAC;YACnC,OAAO,cAAI,CAAC,IAAI,CAAC,UAAU,CAAC,SAAS,EAAE,kBAAU,CAAC,CAAC;;YAEnD,OAAO,UAAU,CAAC,SAAS,CAAA;KAClC;IACD,OAAO,IAAI,CAAC;AAChB,CAAC;AAVD,8BAUC;AAED,SAAgB,QAAQ,CAAC,IAAY;IACjC,OAAO,kBAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC;AACtG,CAAC;AAFD,4BAEC;AACD,SAAgB,gBAAgB,CAAC,IAAY;IACzC,OAAO,kBAAU,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC;AAC9G,CAAC;AAFD,4CAEC;AAED,SAAgB,UAAU,CAAC,WAAmB;IAC1C,OAAO,kBAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,KAAK,WAAW,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC;AAC3G,CAAC;AAFD,gCAEC;AACD,SAAgB,cAAc;IAC1B,OAAO,UAAU,CAAC,gBAAgB,CAAC,CAAC,KAAK,CAAC;AAC9C,CAAC;AAFD,wCAEC"}
|
package/dist/db.d.ts
ADDED
package/dist/db.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
//import * as mssql from "mssql";
|
|
4
|
+
const config_1 = require("./config");
|
|
5
|
+
const typeorm_1 = require("typeorm");
|
|
6
|
+
const orm = {
|
|
7
|
+
type: 'mssql',
|
|
8
|
+
logging: false,
|
|
9
|
+
host: config_1.dbHost,
|
|
10
|
+
port: config_1.dbPort,
|
|
11
|
+
username: config_1.dbUsername,
|
|
12
|
+
password: config_1.dbPassword,
|
|
13
|
+
database: config_1.dbDatabase,
|
|
14
|
+
synchronize: false,
|
|
15
|
+
requestTimeout: 120000, // long timeout for code gen, some queries are long at times...
|
|
16
|
+
};
|
|
17
|
+
const AppDataSource = new typeorm_1.DataSource(orm);
|
|
18
|
+
exports.default = AppDataSource;
|
|
19
|
+
//# sourceMappingURL=db.js.map
|
package/dist/db.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"db.js","sourceRoot":"","sources":["../src/db.ts"],"names":[],"mappings":";;AAAA,iCAAiC;AACjC,qCAA8E;AAC9E,qCAAoC;AAIpC,MAAM,GAAG,GAA+B;IACpC,IAAI,EAAE,OAAO;IACb,OAAO,EAAE,KAAK;IACd,IAAI,EAAE,eAAM;IACZ,IAAI,EAAE,eAAM;IACZ,QAAQ,EAAE,mBAAU;IACpB,QAAQ,EAAE,mBAAU;IACpB,QAAQ,EAAE,mBAAU;IACpB,WAAW,EAAE,KAAK;IAClB,cAAc,EAAE,MAAM,EAAE,+DAA+D;CACxF,CAAC;AAEJ,MAAM,aAAa,GAAG,IAAI,oBAAU,CAAC,GAAG,CAAC,CAAA;AAEzC,kBAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { EntityInfo } from '@memberjunction/core';
|
|
2
|
+
export declare function generateDBSchemaJSONOutput(entities: EntityInfo[], outputDir: string): boolean;
|
|
3
|
+
export declare function generateDBSchemaJSON(entities: EntityInfo[], excludeEntities: string[], schemaName: string, simpleVersion: boolean): string;
|