@futdevpro/nts-dynamo 1.6.40 → 1.6.41

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 (36) hide show
  1. package/lib/_constants/global-settings.const.js +1 -1
  2. package/lib/_constants/global-settings.const.js.map +1 -1
  3. package/lib/_constants/mocks/app-params.mock.d.ts.map +1 -1
  4. package/lib/_constants/mocks/app-params.mock.js.map +1 -1
  5. package/lib/_constants/mocks/app-server.mock.d.ts +15 -0
  6. package/lib/_constants/mocks/app-server.mock.d.ts.map +1 -1
  7. package/lib/_constants/mocks/app-server.mock.js +57 -1
  8. package/lib/_constants/mocks/app-server.mock.js.map +1 -1
  9. package/lib/_constants/mocks/data-model.mock.d.ts +4 -4
  10. package/lib/_constants/mocks/data-model.mock.d.ts.map +1 -1
  11. package/lib/_constants/mocks/data-model.mock.js +5 -5
  12. package/lib/_constants/mocks/data-model.mock.js.map +1 -1
  13. package/lib/_models/control-models/endpoint-params.control-model.d.ts +1 -0
  14. package/lib/_models/control-models/endpoint-params.control-model.d.ts.map +1 -1
  15. package/lib/_models/control-models/endpoint-params.control-model.js +33 -22
  16. package/lib/_models/control-models/endpoint-params.control-model.js.map +1 -1
  17. package/lib/_models/control-models/socket-event.control-model.js +2 -2
  18. package/lib/_models/control-models/socket-event.control-model.js.map +1 -1
  19. package/lib/_services/base/db.service.spec.d.ts +1 -0
  20. package/lib/_services/base/db.service.spec.d.ts.map +1 -0
  21. package/lib/_services/base/db.service.spec.js +7 -0
  22. package/lib/_services/base/db.service.spec.js.map +1 -0
  23. package/lib/_services/server/app.server.spec.js.map +1 -1
  24. package/lib/_services/socket/socket-server.service.js +5 -5
  25. package/lib/_services/socket/socket-server.service.js.map +1 -1
  26. package/lib/tsconfig.tsbuildinfo +1 -1
  27. package/package.json +1 -1
  28. package/src/_constants/global-settings.const.ts +1 -1
  29. package/src/_constants/mocks/app-params.mock.ts +1 -1
  30. package/src/_constants/mocks/app-server.mock.ts +74 -1
  31. package/src/_constants/mocks/data-model.mock.ts +4 -4
  32. package/src/_models/control-models/endpoint-params.control-model.ts +34 -16
  33. package/src/_models/control-models/socket-event.control-model.ts +2 -2
  34. package/src/_services/base/db.service.spec.ts +9 -0
  35. package/src/_services/server/app.server.spec.ts +1 -2
  36. package/src/_services/socket/socket-server.service.ts +5 -5
@@ -1,5 +1,5 @@
1
- import { DynamoNTS_AppParams } from '../../_models';
2
1
 
2
+ import { DynamoNTS_AppParams } from '../../_models';
3
3
 
4
4
  export const DynamoNTS_appParams_mock: DynamoNTS_AppParams = new DynamoNTS_AppParams({
5
5
  name: 'test',
@@ -103,4 +103,77 @@ export class DynamoNTS_AppFull_Mock extends DynamoNTS_App {
103
103
  async getRootServices(): Promise<DynamoNTS_SingletonService[]> {
104
104
  return [];
105
105
  }
106
- }
106
+ }
107
+
108
+ ////////////////////////////////////////////////////////////////////
109
+ ////////////////////////////////////////////////////////////////////
110
+ ////////////////////////////////////////////////////////////////////
111
+
112
+ export class DynamoNTS_AppTEST_Mock extends DynamoNTS_App {
113
+ constructor(
114
+ overrides: {
115
+ getAppParams?(): DynamoNTS_AppParams;
116
+ getGlobalServiceCollection?(): DynamoNTS_GlobalServiceSettings;
117
+ getPortSettings?(): DynamoNTS_PortSettings;
118
+ getRoutingModules?(): DynamoNTS_RoutingModule[];
119
+ getRootServices?(): Promise<DynamoNTS_SingletonService[]>;
120
+ }
121
+ ) {
122
+ if (overrides.getAppParams) {
123
+ DynamoNTS_App.prototype.getAppParams = overrides.getAppParams;
124
+ }
125
+ if (overrides.getGlobalServiceCollection) {
126
+ DynamoNTS_App.prototype.getGlobalServiceCollection = overrides.getGlobalServiceCollection;
127
+ }
128
+ if (overrides.getPortSettings) {
129
+ DynamoNTS_App.prototype.getPortSettings = overrides.getPortSettings;
130
+ }
131
+ if (overrides.getRoutingModules) {
132
+ DynamoNTS_App.prototype.getRoutingModules = overrides.getRoutingModules;
133
+ }
134
+ if (overrides.getRootServices) {
135
+ DynamoNTS_App.prototype.getRootServices = overrides.getRootServices;
136
+ }
137
+
138
+ super();
139
+ }
140
+
141
+ getAppParams(): DynamoNTS_AppParams {
142
+ return new DynamoNTS_AppParams({
143
+ name: 'test-partial',
144
+ version: 'p.0.1',
145
+ dbName: 'test-partial',
146
+ });
147
+ }
148
+
149
+ overrideDynamoNTSGlobalSettings(): void {}
150
+
151
+ getGlobalServiceCollection(): DynamoNTS_GlobalServiceSettings {
152
+ return {
153
+ authService: AuthService_Mock.getInstance(),
154
+ dbModels: [
155
+ dependency_mock_DataParams,
156
+ dependent_mock_DataParams,
157
+
158
+ usageSessionModelParams,
159
+ customDataModelParams,
160
+ ],
161
+ };
162
+ }
163
+
164
+ getPortSettings(): DynamoNTS_PortSettings {
165
+ return {
166
+ httpPort: 10203,
167
+ };
168
+ }
169
+
170
+ getRoutingModules(): DynamoNTS_RoutingModule[] {
171
+ return [];
172
+ }
173
+
174
+ async getRootServices(): Promise<DynamoNTS_SingletonService[]> {
175
+ return [];
176
+ }
177
+ }
178
+
179
+
@@ -1,7 +1,7 @@
1
1
  import { Dynamo_DataParams, Dynamo_Metadata } from '@futdevpro/fsm-dynamo';
2
2
 
3
3
 
4
- export class Depemndency_Mock extends Dynamo_Metadata {
4
+ export class Dependency_Mock extends Dynamo_Metadata {
5
5
  string?: string;
6
6
  number?: number;
7
7
  date?: Date;
@@ -12,7 +12,7 @@ export class Depemndency_Mock extends Dynamo_Metadata {
12
12
  objectArrayArray?: any[][];
13
13
 
14
14
  constructor(
15
- set?: Depemndent_Mock
15
+ set?: Dependent_Mock
16
16
  ) {
17
17
  super(set);
18
18
 
@@ -40,7 +40,7 @@ export const dependency_mock_DataParams = new Dynamo_DataParams({
40
40
  ////////////////////////////////////////////////////////////////////
41
41
  ////////////////////////////////////////////////////////////////////
42
42
 
43
- export class Depemndent_Mock extends Dynamo_Metadata {
43
+ export class Dependent_Mock extends Dynamo_Metadata {
44
44
  dependencyId?: string;
45
45
 
46
46
  string?: string;
@@ -53,7 +53,7 @@ export class Depemndent_Mock extends Dynamo_Metadata {
53
53
  objectArrayArray?: any[][];
54
54
 
55
55
  constructor(
56
- set?: Depemndent_Mock
56
+ set?: Dependent_Mock
57
57
  ) {
58
58
  super(set);
59
59
 
@@ -105,7 +105,7 @@ export class DynamoNTS_EndpointParams{
105
105
 
106
106
  this.logRequest = set.logRequest ?? dynamoNTS_globalSettings.logRequest;
107
107
  this.logRequestsContent = set.logRequestsContent ?? dynamoNTS_globalSettings.logRequestsContent;
108
- this.logResponseContent = set.logResponseContent ?? dynamoNTS_globalSettings.logResponseContent;
108
+ /* this.logResponseContent = set.logResponseContent ?? dynamoNTS_globalSettings.logResponseContent; */
109
109
  } catch (error) {
110
110
  Dynamo_Log.error(
111
111
  `\nEndpoint params setup failed: name: '${set.name}' (security: ${set.security}) endpoint: ${set.endpoint}\nERROR:\n`, error);
@@ -121,21 +121,22 @@ export class DynamoNTS_EndpointParams{
121
121
  try {
122
122
  if (this.logRequest) {
123
123
  if (this.logRequestsContent) {
124
- let inputs = '';
124
+ const params = this.getPathParamsLogContent(req);
125
+ /* let params = '';
125
126
  for(let i = 0; i < this.pathParams.length; i++) {
126
- inputs += ` ${this.pathParams[i]}: ${req.params[this.pathParams[i]]}`;
127
- if (i + 1 < this.pathParams.length || req.body && `${req.body}` !== '{}') {
128
- inputs += ',';
127
+ params += `\n ${this.pathParams[i]}: ${req.params[this.pathParams[i]]}`;
128
+ if (i + 1 < this.pathParams.length) {
129
+ params += ',';
129
130
  }
130
- }
131
+ } */
131
132
 
132
133
  if (req.body && 0 < Object.keys(req.body).length) {
133
- console.log(`==> incoming ${this.name} request...${inputs} body:`, req.body);
134
+ console.log(`===> incoming ${this.name} request...\npathParams:${params}\nbody:`, req.body);
134
135
  } else {
135
- console.log(`==> incoming ${this.name} request...${inputs}`);
136
+ console.log(`===> incoming ${this.name} request...\npathParams:${params}`);
136
137
  }
137
138
  } else {
138
- console.log(`==> incoming ${this.name} request...`);
139
+ console.log(`===> incoming ${this.name} request...`);
139
140
  }
140
141
  }
141
142
 
@@ -191,17 +192,24 @@ export class DynamoNTS_EndpointParams{
191
192
  private error(req: Request, res: Response, error: Error | Dynamo_Error): void {
192
193
  try {
193
194
  let msg: string = `Endpoint catched an error. ${this.name} (${this.endpoint})`;
194
- this.pathParams.forEach((param: string) => {
195
+ /* this.pathParams.forEach((param: string) => {
195
196
  msg += `\n${param}: ${req.params[param]}`;
196
- });
197
+ }); */
198
+ msg += this.getPathParamsLogContent(req);
197
199
  msg += `\nERROR:`;
198
200
 
199
201
  Dynamo_Log.error(msg);
200
- console.log((error as Dynamo_Error)?.flag.includes('DYNAMO') ? (error as Dynamo_Error).getErrorSimplified() : error, '\n');
201
- if (this.logRequest && req.body && 0 < Object.keys(req.body).length) {
202
+ console.log(
203
+ (error as Dynamo_Error)?.flag.includes('DYNAMO') ?
204
+ (error as Dynamo_Error).getErrorSimplified() :
205
+ error,
206
+ '\n'
207
+ );
208
+
209
+ /* if (this.logRequest && req.body && 0 < Object.keys(req.body).length) {
202
210
  console.log('body: ');
203
211
  console.log(req.body, '\n');
204
- }
212
+ } */
205
213
 
206
214
  res.status((error as Dynamo_Error)?.___status ?? 501);
207
215
  res.send(error);
@@ -209,14 +217,14 @@ export class DynamoNTS_EndpointParams{
209
217
  if (this.logRequest) {
210
218
  if (this.logResponseContent) {
211
219
  Dynamo_Log.error(
212
- ` <<<===== ${this.name} error sent. ${(error as Dynamo_Error)?._message ?? ''}`
220
+ ` <<<===== ${this.name} error sent: ${(error as Dynamo_Error)?._message ?? ''}`
213
221
  );
214
222
  Dynamo_Log.error(
215
223
  'sorry, the logResponseContent is not implemented yet.'
216
224
  );
217
225
  } else {
218
226
  Dynamo_Log.error(
219
- ` <<<===== ${this.name} error sent. ${(error as Dynamo_Error)?._message ?? ''}`
227
+ ` <<<===== ${this.name} error sent: ${(error as Dynamo_Error)?._message ?? ''}`
220
228
  );
221
229
  }
222
230
  }
@@ -227,6 +235,16 @@ export class DynamoNTS_EndpointParams{
227
235
  );
228
236
  }
229
237
  }
238
+
239
+ private getPathParamsLogContent(req: Request): string {
240
+ let params: string = '';
241
+
242
+ this.pathParams.forEach((param: string) => {
243
+ params += `\n${param}: ${req.params[param]}\n`;
244
+ });
245
+
246
+ return params;
247
+ }
230
248
  }
231
249
 
232
250
 
@@ -94,9 +94,9 @@ export class DynamoNTS_SocketEvent<T>{
94
94
  private async getPreLog(content: T, issuer?: string): Promise<void> {
95
95
  try {
96
96
  if (this.logEventContent && this.eventType !== DynamoNTS_SocketEventType.connection) {
97
- Dynamo_Log.log(`--> incoming socket(${this.socketName}) event: ${this.eventType}; content:`, content);
97
+ Dynamo_Log.log(`---> incoming socket(${this.socketName}) event: ${this.eventType};\ncontent:`, content);
98
98
  } else {
99
- Dynamo_Log.log(`--> incoming socket(${this.socketName}) event: ${this.eventType}...`);
99
+ Dynamo_Log.log(`---> incoming socket(${this.socketName}) event: ${this.eventType}...`);
100
100
  }
101
101
  } catch (error) {
102
102
  Dynamo_Log.error(`PreLog failed... (socket: ${this.socketName})`, error);
@@ -0,0 +1,9 @@
1
+
2
+
3
+
4
+ /*
5
+
6
+ xdescribe('DynamoNTS_DBService', () => {
7
+
8
+ });
9
+ */
@@ -1,6 +1,5 @@
1
1
 
2
- import { delay, Dynamo_Log, second } from '@futdevpro/fsm-dynamo';
3
- import { DynamoNTS_AppExtendedBase_Mock, DynamoNTS_AppExtendedFull_Mock } from '../../_constants/mocks/app-extended-server.mock';
2
+ import { Dynamo_Log } from '@futdevpro/fsm-dynamo';
4
3
  import { DynamoNTS_AppBase_Mock, DynamoNTS_AppFull_Mock } from '../../_constants/mocks/app-server.mock';
5
4
 
6
5
  describe('DynamoNTS_App AND DynamoNTS_AppExtended?;', () => {
@@ -54,7 +54,7 @@ export abstract class DynamoNTS_SocketServerService<
54
54
  protected logFn: boolean;
55
55
 
56
56
  defaultErrorUserMsg =
57
- `We encountered an unhandled Socket Error, ` +
57
+ `We encountered an unhandled Socket Server Error, ` +
58
58
  `\nplease contact the responsible development team.`;
59
59
 
60
60
  constructor(){
@@ -180,7 +180,7 @@ export abstract class DynamoNTS_SocketServerService<
180
180
  * to be able to check content before getPresenceFromSubscrioptionEventContent
181
181
  */
182
182
  if (dynamoNTS_globalSettings.logMainSocketEvents || dynamoNTS_globalSettings.logAllSocketEvent || dynamoNTS_globalSettings.logSocketEventContent) {
183
- Dynamo_Log.log(`---> incoming socket(${this.params.name}) event: ${DynamoNTS_SocketEventType.subscribe}; content:`, content);
183
+ Dynamo_Log.log(`---> incoming socket(${this.params.name}) event: ${DynamoNTS_SocketEventType.subscribe};\ncontent:`, content);
184
184
  } else {
185
185
  Dynamo_Log.log(`---> incoming socket(${this.params.name}) event: ${DynamoNTS_SocketEventType.subscribe}`);
186
186
  }
@@ -191,7 +191,7 @@ export abstract class DynamoNTS_SocketServerService<
191
191
  this.socketSubscription(presence);
192
192
  await this.subscriptionEvent.executeEventTasks(content, issuer);
193
193
 
194
- Dynamo_Log.success(` <=> socket subscription successfull (${issuer})`);
194
+ Dynamo_Log.success(`<===> socket subscription successfull (${issuer})`);
195
195
  } catch (error) {
196
196
  Dynamo_Log.error(`Socket Subscription failed: ${this.params.name} (${this.params.port}) will disconnect now...`, error);
197
197
  socket.emit(DynamoNTS_SocketEventType.error, error);
@@ -212,7 +212,7 @@ export abstract class DynamoNTS_SocketServerService<
212
212
  });
213
213
 
214
214
  if (dynamoNTS_globalSettings.logMainSocketEvents) {
215
- console.log(`Socket (${this.params.name}): new CONNECTION established`);
215
+ Dynamo_Log.success(`< > Socket (${this.params.name}): new CONNECTION established`);
216
216
  }
217
217
  } catch (error) {
218
218
  Dynamo_Log.error(`Socket Connection failed: ${this.params.name} (${this.params.port}) will disconnect now...`, error);
@@ -328,7 +328,7 @@ export abstract class DynamoNTS_SocketServerService<
328
328
  throw new Dynamo_Error({
329
329
  ...this.getDefaultErrorSettings(
330
330
  'sendEventForId',
331
- new Error(`No active socket whit this specific ID: ${id}`),
331
+ new Error(`No active socket with this specific ID: ${id}`),
332
332
  content?.source
333
333
  ),
334
334