@futdevpro/nts-dynamo 1.5.18 → 1.5.20

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.
Files changed (83) hide show
  1. package/lib/_models/dynamo-module-settings.d.ts +3 -0
  2. package/lib/_models/dynamo-module-settings.d.ts.map +1 -1
  3. package/lib/_models/dynamobe-app-params.d.ts +3 -0
  4. package/lib/_models/dynamobe-app-params.d.ts.map +1 -1
  5. package/lib/_models/dynamobe-app-params.js +3 -0
  6. package/lib/_models/dynamobe-app-params.js.map +1 -1
  7. package/lib/_models/dynamobe-endpoint-params.d.ts +17 -1
  8. package/lib/_models/dynamobe-endpoint-params.d.ts.map +1 -1
  9. package/lib/_models/dynamobe-endpoint-params.js +16 -0
  10. package/lib/_models/dynamobe-endpoint-params.js.map +1 -1
  11. package/lib/_models/dynamobe-global-settings.d.ts +3 -0
  12. package/lib/_models/dynamobe-global-settings.d.ts.map +1 -1
  13. package/lib/_modules/usage/usage.service.d.ts.map +1 -1
  14. package/lib/_modules/usage/usage.service.js +20 -4
  15. package/lib/_modules/usage/usage.service.js.map +1 -1
  16. package/lib/_services/dynamobe-api.service.d.ts +9 -0
  17. package/lib/_services/dynamobe-api.service.d.ts.map +1 -1
  18. package/lib/_services/dynamobe-api.service.js +20 -3
  19. package/lib/_services/dynamobe-api.service.js.map +1 -1
  20. package/lib/_services/dynamobe-app.d.ts +24 -0
  21. package/lib/_services/dynamobe-app.d.ts.map +1 -1
  22. package/lib/_services/dynamobe-app.js +28 -4
  23. package/lib/_services/dynamobe-app.js.map +1 -1
  24. package/lib/_services/dynamobe-auth.service.d.ts +13 -0
  25. package/lib/_services/dynamobe-auth.service.d.ts.map +1 -1
  26. package/lib/_services/dynamobe-auth.service.js +8 -2
  27. package/lib/_services/dynamobe-auth.service.js.map +1 -1
  28. package/lib/_services/dynamobe-controller.service.d.ts +3 -0
  29. package/lib/_services/dynamobe-controller.service.d.ts.map +1 -1
  30. package/lib/_services/dynamobe-controller.service.js +3 -0
  31. package/lib/_services/dynamobe-controller.service.js.map +1 -1
  32. package/lib/_services/dynamobe-data.service.d.ts +6 -2
  33. package/lib/_services/dynamobe-data.service.d.ts.map +1 -1
  34. package/lib/_services/dynamobe-data.service.js +76 -26
  35. package/lib/_services/dynamobe-data.service.js.map +1 -1
  36. package/lib/_services/dynamobe-db-service-collection.service.d.ts +3 -0
  37. package/lib/_services/dynamobe-db-service-collection.service.d.ts.map +1 -1
  38. package/lib/_services/dynamobe-db-service-collection.service.js +3 -0
  39. package/lib/_services/dynamobe-db-service-collection.service.js.map +1 -1
  40. package/lib/_services/dynamobe-db.service.d.ts +110 -15
  41. package/lib/_services/dynamobe-db.service.d.ts.map +1 -1
  42. package/lib/_services/dynamobe-db.service.js +237 -63
  43. package/lib/_services/dynamobe-db.service.js.map +1 -1
  44. package/lib/_services/dynamobe-email.service.d.ts +22 -0
  45. package/lib/_services/dynamobe-email.service.d.ts.map +1 -1
  46. package/lib/_services/dynamobe-email.service.js +45 -11
  47. package/lib/_services/dynamobe-email.service.js.map +1 -1
  48. package/lib/_services/dynamobe-global.service.d.ts +22 -0
  49. package/lib/_services/dynamobe-global.service.d.ts.map +1 -1
  50. package/lib/_services/dynamobe-global.service.js +22 -0
  51. package/lib/_services/dynamobe-global.service.js.map +1 -1
  52. package/lib/_services/dynamobe-routing-module.service.d.ts +15 -0
  53. package/lib/_services/dynamobe-routing-module.service.d.ts.map +1 -1
  54. package/lib/_services/dynamobe-routing-module.service.js +28 -3
  55. package/lib/_services/dynamobe-routing-module.service.js.map +1 -1
  56. package/lib/_services/dynamobe-shared.service.d.ts +18 -0
  57. package/lib/_services/dynamobe-shared.service.d.ts.map +1 -1
  58. package/lib/_services/dynamobe-shared.service.js +18 -0
  59. package/lib/_services/dynamobe-shared.service.js.map +1 -1
  60. package/lib/_services/dynamobe-singleton.service.d.ts +3 -0
  61. package/lib/_services/dynamobe-singleton.service.d.ts.map +1 -1
  62. package/lib/_services/dynamobe-singleton.service.js +3 -0
  63. package/lib/_services/dynamobe-singleton.service.js.map +1 -1
  64. package/lib/tsconfig.tsbuildinfo +33 -47
  65. package/package.json +11 -11
  66. package/src/_models/dynamo-module-settings.ts +3 -1
  67. package/src/_models/dynamobe-app-params.ts +3 -0
  68. package/src/_models/dynamobe-endpoint-params.ts +17 -1
  69. package/src/_models/dynamobe-global-settings.ts +3 -0
  70. package/src/_modules/usage/usage.service.ts +20 -4
  71. package/src/_services/dynamobe-api.service.ts +20 -3
  72. package/src/_services/dynamobe-app.ts +28 -4
  73. package/src/_services/dynamobe-auth.service.ts +21 -2
  74. package/src/_services/dynamobe-controller.service.ts +3 -0
  75. package/src/_services/dynamobe-data.service.ts +78 -26
  76. package/src/_services/dynamobe-db-service-collection.service.ts +3 -0
  77. package/src/_services/dynamobe-db.service.ts +224 -48
  78. package/src/_services/dynamobe-email.service.ts +45 -11
  79. package/src/_services/dynamobe-global.service.ts +22 -0
  80. package/src/_services/dynamobe-routing-module.service.ts +28 -3
  81. package/src/_services/dynamobe-shared.service.ts +18 -0
  82. package/src/_services/dynamobe-singleton.service.ts +3 -0
  83. package/src/_models/dynamobe-data-model-params.ts +0 -24
@@ -7,6 +7,9 @@ import { DynamoBEError } from '@futdevpro/fsm-dynamo';
7
7
 
8
8
  import { DBE_Shared } from './dynamobe-shared.service';
9
9
 
10
+ /**
11
+ *
12
+ */
10
13
  export class DynamoBEEmailService {
11
14
  private nmTransporter: NodeMailer.Transporter;
12
15
  private senderName: string;
@@ -52,14 +55,21 @@ export class DynamoBEEmailService {
52
55
  this.constructionFinished();
53
56
  }
54
57
  } catch (error) {
55
- console.log(`\nDynamoBEEmailService ERROR, The emailService construction failed for ${set.email}.`, new Error());
58
+ DBE_Shared.logError(`\nDynamoBEEmailService ERROR, The emailService construction failed for ${set.email}.`, new Error());
56
59
  }
57
60
  }
58
61
 
62
+ /**
63
+ *
64
+ */
59
65
  private constructionFinished(): void {
60
66
  DBE_Shared.logSuccess(`\nEmailService construction (${this.senderName}) Finished!\n`)
61
67
  }
62
68
 
69
+ /**
70
+ *
71
+ * @param set
72
+ */
63
73
  public async sendEmail(set: {
64
74
  to: string,
65
75
  subject: string,
@@ -77,24 +87,33 @@ export class DynamoBEEmailService {
77
87
  content = set.content
78
88
  } else if (set.useTemplate) {
79
89
  if (!this.templates[set.useTemplate]) {
80
- throw new DynamoBEError({ message: `no template found with this parameter! (${set.useTemplate})` });
90
+ throw new DynamoBEError({
91
+ message: `no template found with this parameter! (${set.useTemplate})`,
92
+ userMessage: `We encountered an uncought BackEnd Email Service Error, please contact the responsible development team. errorcode: 701-114-101`,
93
+ });
81
94
  }
82
95
  content = this.templates[set.useTemplate];
83
96
 
84
97
  if (this.templatePropertyKeys[set.useTemplate].length > 0) {
85
98
  if (!set.templateProperties) {
86
- throw new DynamoBEError({ message: `templateProperties missing!` });
99
+ throw new DynamoBEError({
100
+ message: `templateProperties missing!`,
101
+ userMessage: `We encountered an uncought BackEnd Email Service Error, please contact the responsible development team. errorcode: 701-114-102`,
102
+ });
87
103
  }
88
104
  this.templatePropertyKeys[set.useTemplate].forEach((propertyKey: string) => {
89
105
  if (!set.templateProperties[propertyKey]) {
90
- console.log(`templateProperty missing! (${propertyKey})`);
106
+ DBE_Shared.logError(`templateProperty missing! (${propertyKey})`);
91
107
  }
92
108
  const reg = new RegExp(`{{${propertyKey}}}`, 'g')
93
109
  content = content.replace(reg, set.templateProperties[propertyKey]);
94
110
  })
95
111
  }
96
112
  } else {
97
- throw new DynamoBEError({ message: 'no content setting passsed to emailSending!' });
113
+ throw new DynamoBEError({
114
+ message: 'no content setting passsed to emailSending!',
115
+ userMessage: `We encountered an uncought BackEnd Email Service Error, please contact the responsible development team. errorcode: 701-114-100`,
116
+ });
98
117
  }
99
118
 
100
119
  let mailOptions: MailOptions = {
@@ -112,10 +131,17 @@ export class DynamoBEEmailService {
112
131
  }
113
132
  });
114
133
  } catch (error) {
115
- console.log('\nDynamoBEEmailService ERROR, email sending error', error);
134
+ DBE_Shared.logError('\nDynamoBEEmailService ERROR, email sending error', error);
116
135
  }
117
136
  }
118
137
 
138
+ /**
139
+ *
140
+ * @param templateName
141
+ * @param rootPath
142
+ * @param templatePath
143
+ * @returns
144
+ */
119
145
  private async loadTemplate(templateName: string, rootPath: string, templatePath: string): Promise<void> {
120
146
  try {
121
147
  this.templateLoadingInProgressCounter++;
@@ -123,7 +149,7 @@ export class DynamoBEEmailService {
123
149
  templatePath = Path.join(rootPath, templatePath);
124
150
  FileSystem.readFile(templatePath, 'utf8' , (err, template) => {
125
151
  if (err) {
126
- console.log(`\nDynamoBEEmailService readFile ERROR (0), Couldn't load email template; ${templateName} from ${templatePath}\nerror:\n`, err, '\n');
152
+ DBE_Shared.logError(`\nDynamoBEEmailService readFile ERROR (0), Couldn't load email template; ${templateName} from ${templatePath}\nerror:\n`, err, '\n');
127
153
  reject(err);
128
154
  return;
129
155
  } else {
@@ -139,10 +165,15 @@ export class DynamoBEEmailService {
139
165
  });
140
166
  });
141
167
  } catch (error) {
142
- console.log(`\nDynamoBEEmailService ERROR (1), Couldn't load email template; ${templateName} from ${templatePath}`, new Error());
168
+ DBE_Shared.logError(`\nDynamoBEEmailService ERROR (1), Couldn't load email template; ${templateName} from ${templatePath}`, new Error());
143
169
  }
144
170
  }
145
171
 
172
+ /**
173
+ *
174
+ * @param template
175
+ * @returns
176
+ */
146
177
  private getTemplatePropertyKeys(template: string): string[] {
147
178
  try {
148
179
  const propertyKeys: string[] = [];
@@ -150,8 +181,11 @@ export class DynamoBEEmailService {
150
181
  let propertyCloseTagIndex = template.indexOf('}}', propertyOpenTagIndex + 2);
151
182
  while (propertyOpenTagIndex >= 0) {
152
183
  if (propertyCloseTagIndex === -1) {
153
- console.log(`\nDynamoBEEmailService ERROR, missing closing tag from email template! (${propertyOpenTagIndex} -)`, propertyKeys);
154
- throw new DynamoBEError({ message: `ERROR, missing closing tag from email template! (${propertyOpenTagIndex} -)` });
184
+ DBE_Shared.logError(`\nDynamoBEEmailService ERROR, missing closing tag from email template! (${propertyOpenTagIndex} -)`, propertyKeys);
185
+ throw new DynamoBEError({
186
+ message: `ERROR, missing closing tag from email template! (${propertyOpenTagIndex} -)`,
187
+ userMessage: `We encountered an uncought BackEnd Email Service Error, please contact the responsible development team. errorcode: 701-114-200`,
188
+ });
155
189
  }
156
190
  const newKey: string = template.substring(propertyOpenTagIndex + 2, propertyCloseTagIndex);
157
191
  if (!propertyKeys.includes(newKey)) {
@@ -163,7 +197,7 @@ export class DynamoBEEmailService {
163
197
  // console.log('\n\n\nTEST propertyKeys: ', propertyKeys);
164
198
  return propertyKeys;
165
199
  } catch (error) {
166
- console.log(`\nDynamoBEEmailService ERROR, getTemplatePropertyKeys ERROR`, new Error(), '\ntemplate:\n', template);
200
+ DBE_Shared.logError(`\nDynamoBEEmailService ERROR, getTemplatePropertyKeys ERROR`, new Error(), '\ntemplate:\n', template);
167
201
  }
168
202
  }
169
203
  }
@@ -55,6 +55,10 @@ export class DBE_Global_S extends DynamoBESingletonService {
55
55
  this.instance.emailServiceCollection = set.emailServiceCollection;
56
56
  }
57
57
 
58
+ /**
59
+ *
60
+ * @returns
61
+ */
58
62
  static getAuthService(): DynamoBEAuthService {
59
63
  if (!this.instance?.authService?.authenticateToken) {
60
64
  throw new Error(
@@ -65,6 +69,10 @@ export class DBE_Global_S extends DynamoBESingletonService {
65
69
  return this.instance.authService;
66
70
  }
67
71
 
72
+ /**
73
+ *
74
+ * @returns
75
+ */
68
76
  static getDBServiceCollection(): DynamoBEDBServiceCollection {
69
77
  if (!this.instance?.dbServiceCollection) {
70
78
  throw new Error(
@@ -75,10 +83,20 @@ export class DBE_Global_S extends DynamoBESingletonService {
75
83
  return this.instance.dbServiceCollection;
76
84
  }
77
85
 
86
+ /**
87
+ *
88
+ * @param dataParams
89
+ * @returns
90
+ */
78
91
  static getDBService<T extends Metadata>(dataParams: DynamoBEDataParams): DynamoBEDBService<T> {
79
92
  return this.getDBServiceByKey<T>(dataParams.dataName);
80
93
  }
81
94
 
95
+ /**
96
+ *
97
+ * @param key
98
+ * @returns
99
+ */
82
100
  static getDBServiceByKey<T extends Metadata>(key: string): DynamoBEDBService<T> {
83
101
  const collection = this.getDBServiceCollection();
84
102
  if (collection[key]) {
@@ -94,6 +112,10 @@ export class DBE_Global_S extends DynamoBESingletonService {
94
112
  }
95
113
  }
96
114
 
115
+ /**
116
+ *
117
+ * @returns
118
+ */
97
119
  static getEmailServiceCollection(): DynamoBEEmailServiceCollection {
98
120
  if (!this.instance?.emailServiceCollection) {
99
121
  throw new Error(
@@ -15,6 +15,9 @@ export interface DynamoBERoutingModuleSettings {
15
15
  securityOverride?: DynamoBERouteSecurity;
16
16
  }
17
17
 
18
+ /**
19
+ *
20
+ */
18
21
  export class DynamoBERoutingModule {
19
22
 
20
23
  security: DynamoBERouteSecurity;
@@ -52,6 +55,10 @@ export class DynamoBERoutingModule {
52
55
  });
53
56
  }
54
57
 
58
+ /**
59
+ *
60
+ * @param securityOverride
61
+ */
55
62
  private mountRoutes(securityOverride?: DynamoBERouteSecurity): void {
56
63
  if (securityOverride) {
57
64
  this.security = securityOverride;
@@ -87,11 +94,19 @@ export class DynamoBERoutingModule {
87
94
  this.mountSecureRoute(endpoint);
88
95
  }
89
96
  } catch (error) {
90
- throw new DynamoBEError({ message: `DYNAMOBEERROR: Failed to mount routes.`, error })
97
+ throw new DynamoBEError({
98
+ message: `DYNAMOBEERROR: Failed to mount routes.`,
99
+ userMessage: `We encountered an uncought BackEnd Build Error, please contact the responsible development team. errorcode: 900-456-100`,
100
+ error
101
+ })
91
102
  }
92
103
  });
93
104
  }
94
105
 
106
+ /**
107
+ *
108
+ * @param endpointParams
109
+ */
95
110
  private mountOpenRoute(endpointParams: DynamoBEEndpointParams): void {
96
111
  switch(endpointParams.type) {
97
112
  case HttpCallType.get:
@@ -115,10 +130,17 @@ export class DynamoBERoutingModule {
115
130
  endpointParams.preProcessess, endpointParams.getTasksExecution());
116
131
  break;
117
132
  default:
118
- throw new DynamoBEError({ message: `DYNAMOBEERROR: INVALID route type: ${endpointParams.type} - ${endpointParams.name}` })
133
+ throw new DynamoBEError({
134
+ message: `DYNAMOBEERROR: INVALID route type: ${endpointParams.type} - ${endpointParams.name}` ,
135
+ userMessage: `We encountered an uncought BackEnd Build Error, please contact the responsible development team. errorcode: 900-456-200`,
136
+ })
119
137
  }
120
138
  }
121
139
 
140
+ /**
141
+ *
142
+ * @param endpointParams
143
+ */
122
144
  private mountSecureRoute(endpointParams: DynamoBEEndpointParams): void {
123
145
  switch(endpointParams.type) {
124
146
  case HttpCallType.get:
@@ -142,7 +164,10 @@ export class DynamoBERoutingModule {
142
164
  endpointParams.preProcessess, endpointParams.getTasksExecution());
143
165
  break;
144
166
  default:
145
- throw new DynamoBEError({ message: `DYNAMOBEERROR: INVALID route type: ${endpointParams.type} - ${endpointParams.name}` })
167
+ throw new DynamoBEError({
168
+ message: `DYNAMOBEERROR: INVALID route type: ${endpointParams.type} - ${endpointParams.name}`,
169
+ userMessage: `We encountered an uncought BackEnd Build Error, please contact the responsible development team. errorcode: 900-456-300`,
170
+ })
146
171
  }
147
172
  }
148
173
  }
@@ -4,8 +4,16 @@ import { Request } from 'express';
4
4
  import * as GeoIp from 'geoip-lite';
5
5
  import { GeoIpLocation, D_Shared } from '@futdevpro/fsm-dynamo/shared-service';
6
6
 
7
+ /**
8
+ *
9
+ */
7
10
  export class DBE_Shared extends D_Shared {
8
11
 
12
+ /**
13
+ *
14
+ * @param request
15
+ * @returns
16
+ */
9
17
  static getIpFromRequest(request: Request): string {
10
18
  let ip: string;
11
19
  if (request.headers['x-forwarded-for']) {
@@ -18,10 +26,20 @@ export class DBE_Shared extends D_Shared {
18
26
  return ip;
19
27
  }
20
28
 
29
+ /**
30
+ *
31
+ * @param request
32
+ * @returns
33
+ */
21
34
  static getLocationDataByRequest(request: Request): GeoIpLocation {
22
35
  return GeoIp.lookup(this.getIpFromRequest(request));
23
36
  }
24
37
 
38
+ /**
39
+ *
40
+ * @param question
41
+ * @returns
42
+ */
25
43
  static async prompt(question: string): Promise<string> {
26
44
  const readLine = ReadLine.createInterface({
27
45
  input: process.stdin,
@@ -1,4 +1,7 @@
1
1
 
2
+ /**
3
+ *
4
+ */
2
5
  export class DynamoBESingletonService {
3
6
  /// --- --- --- SINGLETON --- --- --- \\\
4
7
  protected static instance;
@@ -1,24 +0,0 @@
1
- /*
2
- export { DynamoBEDataPropertyParams } from '@futdevpro/fsm-dynamo';
3
- import { DataModelType } from '../_enums/data-model-type.enum';
4
-
5
- export class DynamoBEDataModelParams {
6
- dataName: string;
7
- type: DataModelType;
8
- properties: DynamoBEDataPropertyParams[] = [];
9
-
10
- constructor(
11
- set?: {
12
- dataName: string,
13
- type: DataModelType,
14
- properties: DynamoBEDataPropertyParams[],
15
- }
16
- ) {
17
- if (set) {
18
- this.dataName = set.dataName;
19
- this.type = set.type;
20
- this.properties = set.properties ? set.properties : [];
21
- }
22
- }
23
- }
24
- */