@futdevpro/nts-dynamo 1.6.39 → 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.
- package/lib/_constants/global-settings.const.js +1 -1
- package/lib/_constants/global-settings.const.js.map +1 -1
- package/lib/_constants/mocks/app-params.mock.d.ts.map +1 -1
- package/lib/_constants/mocks/app-params.mock.js.map +1 -1
- package/lib/_constants/mocks/app-server.mock.d.ts +15 -0
- package/lib/_constants/mocks/app-server.mock.d.ts.map +1 -1
- package/lib/_constants/mocks/app-server.mock.js +57 -1
- package/lib/_constants/mocks/app-server.mock.js.map +1 -1
- package/lib/_constants/mocks/data-model.mock.d.ts +4 -4
- package/lib/_constants/mocks/data-model.mock.d.ts.map +1 -1
- package/lib/_constants/mocks/data-model.mock.js +5 -5
- package/lib/_constants/mocks/data-model.mock.js.map +1 -1
- package/lib/_models/control-models/endpoint-params.control-model.d.ts +1 -0
- package/lib/_models/control-models/endpoint-params.control-model.d.ts.map +1 -1
- package/lib/_models/control-models/endpoint-params.control-model.js +33 -22
- package/lib/_models/control-models/endpoint-params.control-model.js.map +1 -1
- package/lib/_models/control-models/socket-event.control-model.js +2 -2
- package/lib/_models/control-models/socket-event.control-model.js.map +1 -1
- package/lib/_services/base/data.service.d.ts +1 -0
- package/lib/_services/base/data.service.d.ts.map +1 -1
- package/lib/_services/base/data.service.js +36 -226
- package/lib/_services/base/data.service.js.map +1 -1
- package/lib/_services/base/db.service.d.ts +1 -0
- package/lib/_services/base/db.service.d.ts.map +1 -1
- package/lib/_services/base/db.service.js +15 -9
- package/lib/_services/base/db.service.js.map +1 -1
- package/lib/_services/base/db.service.spec.d.ts +1 -0
- package/lib/_services/base/db.service.spec.d.ts.map +1 -0
- package/lib/_services/base/db.service.spec.js +7 -0
- package/lib/_services/base/db.service.spec.js.map +1 -0
- package/lib/_services/server/app.server.d.ts.map +1 -1
- package/lib/_services/server/app.server.js +2 -1
- package/lib/_services/server/app.server.js.map +1 -1
- package/lib/_services/server/app.server.spec.js.map +1 -1
- package/lib/_services/socket/socket-server.service.d.ts +1 -0
- package/lib/_services/socket/socket-server.service.d.ts.map +1 -1
- package/lib/_services/socket/socket-server.service.js +20 -17
- package/lib/_services/socket/socket-server.service.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/_constants/global-settings.const.ts +1 -1
- package/src/_constants/mocks/app-params.mock.ts +1 -1
- package/src/_constants/mocks/app-server.mock.ts +74 -1
- package/src/_constants/mocks/data-model.mock.ts +4 -4
- package/src/_models/control-models/endpoint-params.control-model.ts +34 -16
- package/src/_models/control-models/socket-event.control-model.ts +2 -2
- package/src/_services/base/data.service.ts +99 -148
- package/src/_services/base/db.service.spec.ts +9 -0
- package/src/_services/base/db.service.ts +20 -9
- package/src/_services/server/app.server.spec.ts +1 -2
- package/src/_services/server/app.server.ts +3 -3
- package/src/_services/socket/socket-server.service.ts +38 -13
|
@@ -531,15 +531,7 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
|
|
|
531
531
|
});
|
|
532
532
|
});
|
|
533
533
|
|
|
534
|
-
|
|
535
|
-
data._id = `${data._id}`;
|
|
536
|
-
if (typeof data._id !== 'string' || typeof data._id === 'object') {
|
|
537
|
-
data = JSON.parse(JSON.stringify(data));
|
|
538
|
-
if (typeof data._id !== 'string' || typeof data._id === 'object') {
|
|
539
|
-
Dynamo_Log.error('data._id stringifying failed! Please notfiy the developer! (DynamoNTS_DBService.findOne)')
|
|
540
|
-
}
|
|
541
|
-
}
|
|
542
|
-
}
|
|
534
|
+
data = this.stringifyDataId(data);
|
|
543
535
|
|
|
544
536
|
return data;
|
|
545
537
|
}
|
|
@@ -830,6 +822,25 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
|
|
|
830
822
|
|
|
831
823
|
// ----------------------------------------------------------------------------------
|
|
832
824
|
// ----------------------------------------------------------------------------------
|
|
825
|
+
// ----------------------------------------------------------------------------------
|
|
826
|
+
// PRIVATE FUNCTIONS
|
|
827
|
+
|
|
828
|
+
private stringifyDataId(data: T): T {
|
|
829
|
+
if (data && (typeof data._id !== 'string' || typeof data._id === 'object')) {
|
|
830
|
+
data._id = `${data._id}`;
|
|
831
|
+
|
|
832
|
+
if (typeof data._id !== 'string' || typeof data._id === 'object') {
|
|
833
|
+
data = JSON.parse(JSON.stringify(data));
|
|
834
|
+
|
|
835
|
+
if (typeof data._id !== 'string' || typeof data._id === 'object') {
|
|
836
|
+
Dynamo_Log.error('data._id stringifying failed! Please notfiy the developers!', new Error());
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
return data;
|
|
842
|
+
}
|
|
843
|
+
|
|
833
844
|
// ----------------------------------------------------------------------------------
|
|
834
845
|
// PRIVATE BUILD FUNCTIONS
|
|
835
846
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import {
|
|
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?;', () => {
|
|
@@ -6,7 +6,7 @@ import * as Https from 'https';
|
|
|
6
6
|
import * as FileSystem from 'fs';
|
|
7
7
|
import * as BodyParser from 'body-parser';
|
|
8
8
|
|
|
9
|
-
import { Dynamo_Array, Dynamo_Error, Dynamo_Log, second, wait } from '@futdevpro/fsm-dynamo';
|
|
9
|
+
import { Dynamo_Array, Dynamo_Error, dynamo_error_default, Dynamo_Log, second, wait } from '@futdevpro/fsm-dynamo';
|
|
10
10
|
|
|
11
11
|
import { DynamoNTS_SingletonService } from '../base/singleton.service';
|
|
12
12
|
import { DynamoNTS_RouteSecurity } from '../../_enums/route-security.enum';
|
|
@@ -230,13 +230,13 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
230
230
|
if (this.logFn && this.deepLog) console.log('\nfn:. asyncConstruct');
|
|
231
231
|
try {
|
|
232
232
|
this.systemControls.app.init = true;
|
|
233
|
-
this.logSetup = dynamoNTS_globalSettings.logSetup;
|
|
234
233
|
this._params = this.getAppParams();
|
|
235
|
-
|
|
234
|
+
dynamo_error_default.issuerSystem = this._params.name;
|
|
236
235
|
|
|
237
236
|
if (this.overrideDynamoNTSGlobalSettings) {
|
|
238
237
|
this.overrideDynamoNTSGlobalSettings();
|
|
239
238
|
}
|
|
239
|
+
this.logSetup = dynamoNTS_globalSettings.logSetup;
|
|
240
240
|
|
|
241
241
|
this.globalService = DynamoNTS_GlobalService.getInstance();
|
|
242
242
|
DynamoNTS_GlobalService.setServices(this.getGlobalServiceCollection());
|
|
@@ -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}
|
|
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(
|
|
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
|
-
|
|
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);
|
|
@@ -320,23 +320,30 @@ export abstract class DynamoNTS_SocketServerService<
|
|
|
320
320
|
async sendEventForId(id: string, event: string, content: any/* , error?: (err: any) => void */): Promise<void> {
|
|
321
321
|
try {
|
|
322
322
|
const presence: DynamoNTS_SocketPresence = this.presences.find((pres: DynamoNTS_SocketPresence) => pres.issuerId === id);
|
|
323
|
+
|
|
323
324
|
if (presence) {
|
|
324
325
|
Dynamo_Log.log(` <--- emitting socket event for presence: ${event} (${this.params.name}, presenceId: ${id})`);
|
|
325
326
|
presence.emitEvent(event, content);
|
|
326
327
|
} else {
|
|
327
|
-
/* if (error) { */
|
|
328
328
|
throw new Dynamo_Error({
|
|
329
|
+
...this.getDefaultErrorSettings(
|
|
330
|
+
'sendEventForId',
|
|
331
|
+
new Error(`No active socket with this specific ID: ${id}`),
|
|
332
|
+
content?.source
|
|
333
|
+
),
|
|
334
|
+
|
|
329
335
|
status: 404,
|
|
330
|
-
errorCode: 'NTS-
|
|
331
|
-
addECToUserMsg: true,
|
|
332
|
-
message: `No active socket whit this specific ID: ${id}`,
|
|
333
|
-
userMessage: this.defaultErrorUserMsg
|
|
336
|
+
errorCode: 'NTS-SSS-301',
|
|
334
337
|
});
|
|
335
|
-
/* } */
|
|
336
338
|
}
|
|
337
339
|
} catch (error) {
|
|
338
|
-
|
|
339
|
-
|
|
340
|
+
throw new Dynamo_Error({
|
|
341
|
+
...this.getDefaultErrorSettings('sendEventForId', error, content?.source),
|
|
342
|
+
|
|
343
|
+
errorCode: 'NTS-SSS-300',
|
|
344
|
+
message: `Socket Event Emit for id (${id}, ${event}) failed: ${this.params?.name} (${this.params?.port})`,
|
|
345
|
+
error
|
|
346
|
+
});
|
|
340
347
|
}
|
|
341
348
|
}
|
|
342
349
|
|
|
@@ -347,7 +354,25 @@ export abstract class DynamoNTS_SocketServerService<
|
|
|
347
354
|
});
|
|
348
355
|
} catch (error) {
|
|
349
356
|
Dynamo_Log.error(`Socket Event Broadcast (${event}) failed: ${this.params?.name} (${this.params?.port})`, error);
|
|
350
|
-
throw
|
|
357
|
+
throw new Dynamo_Error({
|
|
358
|
+
...this.getDefaultErrorSettings('broadcastEvent', error),
|
|
359
|
+
|
|
360
|
+
errorCode: 'NTS-SSS-400',
|
|
361
|
+
message: `Socket Event Broadcast (${event}) failed: ${this.params?.name} (${this.params?.port})`,
|
|
362
|
+
error
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
private getDefaultErrorSettings(fnName: string, error: Error | Dynamo_Error, issuer?: string) {
|
|
368
|
+
return {
|
|
369
|
+
status: 417,
|
|
370
|
+
message: (error as Error)?.message ?? `${fnName} was UNSUCCESFUL (NTS)`,
|
|
371
|
+
addECToUserMsg: true,
|
|
372
|
+
userMessage: this.defaultErrorUserMsg,
|
|
373
|
+
issuer: issuer,
|
|
374
|
+
issuerService: this.constructor?.name,
|
|
375
|
+
error: error,
|
|
351
376
|
}
|
|
352
377
|
}
|
|
353
378
|
|