@futdevpro/nts-dynamo 1.9.32 → 1.9.33
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/build/_models/control-models/endpoint-params.control-model.js +1 -1
- package/build/_models/control-models/endpoint-params.control-model.js.map +1 -1
- package/build/_models/interfaces/global-service-settings.interface.d.ts +2 -1
- package/build/_models/interfaces/global-service-settings.interface.d.ts.map +1 -1
- package/build/_modules/socket/_services/app-extended.server.d.ts +1 -0
- package/build/_modules/socket/_services/app-extended.server.d.ts.map +1 -1
- package/build/_modules/socket/_services/app-extended.server.js +125 -96
- package/build/_modules/socket/_services/app-extended.server.js.map +1 -1
- package/build/_modules/socket/_services/app-extended.server.spec.js +2 -0
- package/build/_modules/socket/_services/app-extended.server.spec.js.map +1 -1
- package/build/_services/core/email.service.d.ts.map +1 -1
- package/build/_services/core/email.service.js +33 -25
- package/build/_services/core/email.service.js.map +1 -1
- package/build/_services/core/global.service.d.ts +4 -0
- package/build/_services/core/global.service.d.ts.map +1 -1
- package/build/_services/core/global.service.js +67 -14
- package/build/_services/core/global.service.js.map +1 -1
- package/build/_services/server/app.server.d.ts.map +1 -1
- package/build/_services/server/app.server.js +352 -291
- package/build/_services/server/app.server.js.map +1 -1
- package/package.json +2 -2
- package/src/_models/control-models/endpoint-params.control-model.ts +1 -1
- package/src/_models/interfaces/global-service-settings.interface.ts +3 -1
- package/src/_modules/socket/_services/app-extended.server.spec.ts +5 -0
- package/src/_modules/socket/_services/app-extended.server.ts +165 -124
- package/src/_services/core/email.service.ts +49 -37
- package/src/_services/core/global.service.ts +82 -24
- package/src/_services/server/app.server.ts +479 -402
|
@@ -171,7 +171,7 @@ export class DyNTS_EmailService /* extends DyNTS_SingletonService */ {
|
|
|
171
171
|
});
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
-
content = this.compileTemplateComponent(
|
|
174
|
+
content = await this.compileTemplateComponent(
|
|
175
175
|
set.templateComponentName,
|
|
176
176
|
set.templateProperties,
|
|
177
177
|
issuer
|
|
@@ -217,11 +217,11 @@ export class DyNTS_EmailService /* extends DyNTS_SingletonService */ {
|
|
|
217
217
|
}
|
|
218
218
|
}
|
|
219
219
|
|
|
220
|
-
private compileTemplateComponent<T>(
|
|
220
|
+
private async compileTemplateComponent<T>(
|
|
221
221
|
componentName: string,
|
|
222
222
|
componentProperties:T,
|
|
223
223
|
issuer: string
|
|
224
|
-
): string {
|
|
224
|
+
): Promise<string> {
|
|
225
225
|
try {
|
|
226
226
|
if (!this.componentsByName[componentName]) {
|
|
227
227
|
throw new DyFM_Error({
|
|
@@ -233,7 +233,7 @@ export class DyNTS_EmailService /* extends DyNTS_SingletonService */ {
|
|
|
233
233
|
|
|
234
234
|
errorCode: 'NTS-ES0-SC1',
|
|
235
235
|
additionalContent: {
|
|
236
|
-
|
|
236
|
+
availableComponents: Object.keys(this.componentsByName),
|
|
237
237
|
},
|
|
238
238
|
});
|
|
239
239
|
}
|
|
@@ -242,20 +242,23 @@ export class DyNTS_EmailService /* extends DyNTS_SingletonService */ {
|
|
|
242
242
|
let template: string = this.compileHTMLMainFrame(component);
|
|
243
243
|
|
|
244
244
|
template = template.replace('<nts-content>', '');
|
|
245
|
-
template = this.compileComponentProperties<T>(
|
|
245
|
+
template = await this.compileComponentProperties<T>(
|
|
246
246
|
component,
|
|
247
247
|
componentProperties,
|
|
248
248
|
template,
|
|
249
249
|
issuer
|
|
250
250
|
);
|
|
251
251
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
252
|
+
await DyFM_Array.asyncForEach(
|
|
253
|
+
component.subComponentSelectors,
|
|
254
|
+
async (subComponentSelector: string): Promise<void> => {
|
|
255
|
+
while (template.includes(`<nts-${subComponentSelector}`)) {
|
|
256
|
+
template = await this.compileSubComponent<T>(
|
|
257
|
+
subComponentSelector, componentProperties, template, issuer
|
|
258
|
+
);
|
|
259
|
+
}
|
|
257
260
|
}
|
|
258
|
-
|
|
261
|
+
);
|
|
259
262
|
|
|
260
263
|
template = this.templateTrim(template);
|
|
261
264
|
|
|
@@ -325,9 +328,9 @@ export class DyNTS_EmailService /* extends DyNTS_SingletonService */ {
|
|
|
325
328
|
|
|
326
329
|
/** trims all rows and remove everything between /*...*\/ */
|
|
327
330
|
private styleTrim(style: string): string {
|
|
328
|
-
let result: string = style
|
|
331
|
+
let result: string = style?.split('\n').map((row: string): string => row.trim()).join('');
|
|
329
332
|
|
|
330
|
-
while (result
|
|
333
|
+
while (result?.includes('/*')) {
|
|
331
334
|
const start = result.indexOf('/*');
|
|
332
335
|
const end = result.indexOf('*/', start) + 2;
|
|
333
336
|
|
|
@@ -358,44 +361,53 @@ export class DyNTS_EmailService /* extends DyNTS_SingletonService */ {
|
|
|
358
361
|
return b / 1024;
|
|
359
362
|
}
|
|
360
363
|
|
|
361
|
-
private compileComponentProperties<T>(
|
|
364
|
+
private async compileComponentProperties<T>(
|
|
362
365
|
component: DyNTS_EmailTemplateComponent,
|
|
363
366
|
componentProperties: T,
|
|
364
367
|
template: string,
|
|
365
368
|
issuer: string
|
|
366
|
-
): string {
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
369
|
+
): Promise<string> {
|
|
370
|
+
try {
|
|
371
|
+
component.properties.forEach((propertyKey: string): void => {
|
|
372
|
+
if (!componentProperties[propertyKey]) {
|
|
373
|
+
throw new DyFM_Error({
|
|
374
|
+
...this._getDefaultErrorSettings(
|
|
375
|
+
'setupComponent',
|
|
376
|
+
new Error(
|
|
377
|
+
`ComponentProperty missing from input! '${propertyKey}' for ${component.name}`
|
|
378
|
+
),
|
|
379
|
+
issuer
|
|
374
380
|
),
|
|
375
|
-
issuer
|
|
376
|
-
),
|
|
377
381
|
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
382
|
+
errorCode: 'NTS-ES0-SC4',
|
|
383
|
+
additionalContent: {
|
|
384
|
+
componentProperties: Object.keys(componentProperties),
|
|
385
|
+
},
|
|
386
|
+
});
|
|
387
|
+
}
|
|
384
388
|
|
|
385
|
-
|
|
389
|
+
const propReg = new RegExp(`{{${propertyKey}}}`, 'g');
|
|
386
390
|
|
|
387
|
-
|
|
388
|
-
|
|
391
|
+
template = template.replace(propReg, componentProperties[propertyKey]);
|
|
392
|
+
});
|
|
389
393
|
|
|
390
|
-
|
|
394
|
+
return template;
|
|
395
|
+
} catch (error) {
|
|
396
|
+
throw new DyFM_Error({
|
|
397
|
+
...this._getDefaultErrorSettings('setupComponent', error, issuer),
|
|
398
|
+
|
|
399
|
+
errorCode: 'NTS-ES0-SC3',
|
|
400
|
+
});
|
|
401
|
+
}
|
|
391
402
|
}
|
|
392
403
|
|
|
393
|
-
private compileSubComponent<T>(
|
|
404
|
+
private async compileSubComponent<T>(
|
|
394
405
|
subComponentSelector: string,
|
|
395
406
|
componentProperties: T,
|
|
396
407
|
template: string,
|
|
397
408
|
issuer: string
|
|
398
|
-
): string {
|
|
409
|
+
): Promise<string> {
|
|
410
|
+
|
|
399
411
|
const subComponent: DyNTS_EmailTemplateComponent =
|
|
400
412
|
this.componentsBySelector[subComponentSelector];
|
|
401
413
|
|
|
@@ -428,7 +440,7 @@ export class DyNTS_EmailService /* extends DyNTS_SingletonService */ {
|
|
|
428
440
|
const contentReg = new RegExp(`<nts-content>`, 'g');
|
|
429
441
|
|
|
430
442
|
subComponentTemplate = subComponentTemplate.replace(contentReg, componentContent);
|
|
431
|
-
subComponentTemplate = this.compileComponentProperties<T>(
|
|
443
|
+
subComponentTemplate = await this.compileComponentProperties<T>(
|
|
432
444
|
subComponent,
|
|
433
445
|
componentProperties,
|
|
434
446
|
subComponentTemplate,
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
import { DyNTS_App_Params } from '../../_models/control-models/app-params.control-model';
|
|
10
10
|
|
|
11
11
|
import {
|
|
12
|
+
DyNTS_GlobalErrorHandlerFn,
|
|
12
13
|
DyNTS_GlobalService_Settings
|
|
13
14
|
} from '../../_models/interfaces/global-service-settings.interface';
|
|
14
15
|
|
|
@@ -62,14 +63,32 @@ export class DyNTS_GlobalService extends DyNTS_SingletonService {
|
|
|
62
63
|
static async setServices(set: DyNTS_GlobalService_Settings): Promise<void> {
|
|
63
64
|
this.getInstance();
|
|
64
65
|
|
|
66
|
+
try {
|
|
67
|
+
await this.setDBServices(set?.dbModels);
|
|
68
|
+
|
|
69
|
+
await this.setAuthService(set?.authService);
|
|
70
|
+
|
|
71
|
+
await this.setEmailServices(set?.emailServiceCollection);
|
|
72
|
+
|
|
73
|
+
await this.setErrorHandler(set?.errorHandler);
|
|
74
|
+
} catch (error) {
|
|
75
|
+
throw new DyFM_Error({
|
|
76
|
+
message: `Failed to setServices on DyNTS_GlobalService.`,
|
|
77
|
+
error: error,
|
|
78
|
+
errorCode: 'NTS-GS0-SS0',
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
private static async setDBServices(dbModels?: DyFM_DataModel_Params[]): Promise<void> {
|
|
65
84
|
try {
|
|
66
85
|
this.instance.dbServiceCollection = {};
|
|
67
|
-
|
|
86
|
+
dbModels?.forEach((dbModel: DyFM_DataModel_Params): void => {
|
|
68
87
|
if (!dbModel.constructed) {
|
|
69
88
|
throw new DyFM_Error({
|
|
70
89
|
message: `DyNTS_GlobalService.setServices failed, ` +
|
|
71
90
|
`ERROR: dbModel is not constructed!`,
|
|
72
|
-
errorCode: 'NTS-GS0-
|
|
91
|
+
errorCode: 'NTS-GS0-SDBS1',
|
|
73
92
|
additionalContent: {
|
|
74
93
|
dbModel: dbModel,
|
|
75
94
|
},
|
|
@@ -91,14 +110,36 @@ export class DyNTS_GlobalService extends DyNTS_SingletonService {
|
|
|
91
110
|
});
|
|
92
111
|
}
|
|
93
112
|
});
|
|
113
|
+
} catch (error) {
|
|
114
|
+
throw new DyFM_Error({
|
|
115
|
+
message: `Failed to set dbServiceCollections on DyNTS_GlobalService.`,
|
|
116
|
+
error: error,
|
|
117
|
+
errorCode: 'NTS-GS0-SDBS0',
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
}
|
|
94
121
|
|
|
95
|
-
|
|
122
|
+
private static async setAuthService(authService?: DyNTS_AuthService): Promise<void> {
|
|
123
|
+
try {
|
|
124
|
+
if (!authService) {
|
|
96
125
|
DyFM_Log.warn(`Authentication Service missing!`);
|
|
97
126
|
} else {
|
|
98
|
-
this.instance.authService =
|
|
127
|
+
this.instance.authService = authService;
|
|
99
128
|
}
|
|
129
|
+
} catch (error) {
|
|
130
|
+
throw new DyFM_Error({
|
|
131
|
+
message: `Failed to set authService on DyNTS_GlobalService.`,
|
|
132
|
+
error: error,
|
|
133
|
+
errorCode: 'NTS-GS0-SAS0',
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
}
|
|
100
137
|
|
|
101
|
-
|
|
138
|
+
private static async setEmailServices(
|
|
139
|
+
emailServiceCollection?: DyNTS_Service_Collection<DyNTS_EmailService>
|
|
140
|
+
): Promise<void> {
|
|
141
|
+
try {
|
|
142
|
+
this.instance.emailServiceCollection = emailServiceCollection ?? {};
|
|
102
143
|
await DyFM_Array.asyncForEach(
|
|
103
144
|
Object.keys(this.instance.emailServiceCollection),
|
|
104
145
|
async (key: string): Promise<void> => {
|
|
@@ -107,34 +148,51 @@ export class DyNTS_GlobalService extends DyNTS_SingletonService {
|
|
|
107
148
|
).asyncPostConstruct();
|
|
108
149
|
}
|
|
109
150
|
);
|
|
110
|
-
|
|
151
|
+
} catch (error) {
|
|
152
|
+
throw new DyFM_Error({
|
|
153
|
+
message: `Failed to set emailServiceCollections on DyNTS_GlobalService.`,
|
|
154
|
+
error: error,
|
|
155
|
+
errorCode: 'NTS-GS0-SS4',
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
private static async setErrorHandler(errorHandler?: DyNTS_GlobalErrorHandlerFn): Promise<void> {
|
|
161
|
+
try {
|
|
111
162
|
DyNTS_GlobalService.globalErrorHandler =
|
|
112
|
-
|
|
163
|
+
errorHandler ??
|
|
113
164
|
(async (error: any): Promise<void> => {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
if (
|
|
120
|
-
DyNTS_global_settings.log_settings.highDetailedLogs ||
|
|
121
|
-
!(error instanceof DyFM_Error)
|
|
122
|
-
) {
|
|
123
|
-
DyFM_Log.H_error(
|
|
124
|
-
`Error caught by globalErrorHandler.`,
|
|
125
|
-
`\n ERROR:`, error
|
|
165
|
+
try {
|
|
166
|
+
DyFM_Log.warn(
|
|
167
|
+
`globalErrorHandler not set! (set in app.getGlobalServiceCollection)`,
|
|
168
|
+
'\nwill use default-logging',
|
|
126
169
|
);
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
170
|
+
|
|
171
|
+
if (
|
|
172
|
+
DyNTS_global_settings.log_settings.highDetailedLogs ||
|
|
173
|
+
!(error instanceof DyFM_Error)
|
|
174
|
+
) {
|
|
175
|
+
DyFM_Log.H_error(
|
|
176
|
+
`Error caught by globalErrorHandler.`,
|
|
177
|
+
`\n ERROR:`, error
|
|
178
|
+
);
|
|
179
|
+
} else {
|
|
180
|
+
error.logSimple(
|
|
181
|
+
`Error caught by globalErrorHandler.`
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
} catch (error) {
|
|
185
|
+
DyFM_Log.error(
|
|
186
|
+
`NTS GLOBAL MULTILEVEL ERROR: \nFailed to handle error on globalErrorHandler.`,
|
|
187
|
+
error
|
|
130
188
|
);
|
|
131
189
|
}
|
|
132
190
|
});
|
|
133
191
|
} catch (error) {
|
|
134
192
|
throw new DyFM_Error({
|
|
135
|
-
message: `Failed to
|
|
193
|
+
message: `Failed to set errorHandler on DyNTS_GlobalService.`,
|
|
136
194
|
error: error,
|
|
137
|
-
errorCode: 'NTS-GS0-
|
|
195
|
+
errorCode: 'NTS-GS0-SEH0',
|
|
138
196
|
});
|
|
139
197
|
}
|
|
140
198
|
}
|