@futdevpro/nts-dynamo 1.5.38 → 1.5.45

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 (98) hide show
  1. package/BuildPackage.bat +1 -1
  2. package/futdevpro-nts-dynamo-01.05.40.tgz +0 -0
  3. package/futdevpro-nts-dynamo-01.05.41.tgz +0 -0
  4. package/futdevpro-nts-dynamo-01.05.42.tgz +0 -0
  5. package/futdevpro-nts-dynamo-01.05.43.tgz +0 -0
  6. package/futdevpro-nts-dynamo-01.05.44.tgz +0 -0
  7. package/futdevpro-nts-dynamo-01.05.45.tgz +0 -0
  8. package/lib/_enums/http/socket-event.enum.d.ts +2 -0
  9. package/lib/_enums/http/socket-event.enum.d.ts.map +1 -1
  10. package/lib/_enums/http/socket-event.enum.js +2 -0
  11. package/lib/_enums/http/socket-event.enum.js.map +1 -1
  12. package/lib/_models/dynamo-nts-socket-dictionary.d.ts +16 -0
  13. package/lib/_models/dynamo-nts-socket-dictionary.d.ts.map +1 -0
  14. package/lib/_models/dynamo-nts-socket-dictionary.js +28 -0
  15. package/lib/_models/dynamo-nts-socket-dictionary.js.map +1 -0
  16. package/lib/_models/dynamo-nts-socket-event-params.d.ts +2 -0
  17. package/lib/_models/dynamo-nts-socket-event-params.d.ts.map +1 -1
  18. package/lib/_models/dynamo-nts-socket-event-params.js +6 -5
  19. package/lib/_models/dynamo-nts-socket-event-params.js.map +1 -1
  20. package/lib/_models/index.d.ts +1 -0
  21. package/lib/_models/index.d.ts.map +1 -1
  22. package/lib/_models/index.js +1 -0
  23. package/lib/_models/index.js.map +1 -1
  24. package/lib/_modules/app-extended.index.d.ts +1 -0
  25. package/lib/_modules/app-extended.index.d.ts.map +1 -1
  26. package/lib/_modules/app-extended.index.js +1 -0
  27. package/lib/_modules/app-extended.index.js.map +1 -1
  28. package/lib/_modules/usage/usage.service.d.ts.map +1 -1
  29. package/lib/_modules/usage/usage.service.js +8 -4
  30. package/lib/_modules/usage/usage.service.js.map +1 -1
  31. package/lib/_services/dynamo-nts-api.service.d.ts.map +1 -1
  32. package/lib/_services/dynamo-nts-api.service.js +5 -4
  33. package/lib/_services/dynamo-nts-api.service.js.map +1 -1
  34. package/lib/_services/dynamo-nts-app-extended.d.ts +1 -1
  35. package/lib/_services/dynamo-nts-app-extended.d.ts.map +1 -1
  36. package/lib/_services/dynamo-nts-app-extended.js +4 -3
  37. package/lib/_services/dynamo-nts-app-extended.js.map +1 -1
  38. package/lib/_services/dynamo-nts-app.d.ts.map +1 -1
  39. package/lib/_services/dynamo-nts-app.js +4 -2
  40. package/lib/_services/dynamo-nts-app.js.map +1 -1
  41. package/lib/_services/dynamo-nts-auth.service.d.ts.map +1 -1
  42. package/lib/_services/dynamo-nts-auth.service.js +4 -2
  43. package/lib/_services/dynamo-nts-auth.service.js.map +1 -1
  44. package/lib/_services/dynamo-nts-controller.service.d.ts +37 -0
  45. package/lib/_services/dynamo-nts-controller.service.d.ts.map +1 -1
  46. package/lib/_services/dynamo-nts-controller.service.js +37 -0
  47. package/lib/_services/dynamo-nts-controller.service.js.map +1 -1
  48. package/lib/_services/dynamo-nts-data.service.d.ts +19 -0
  49. package/lib/_services/dynamo-nts-data.service.d.ts.map +1 -1
  50. package/lib/_services/dynamo-nts-data.service.js +70 -31
  51. package/lib/_services/dynamo-nts-data.service.js.map +1 -1
  52. package/lib/_services/dynamo-nts-db.service.d.ts.map +1 -1
  53. package/lib/_services/dynamo-nts-db.service.js +72 -48
  54. package/lib/_services/dynamo-nts-db.service.js.map +1 -1
  55. package/lib/_services/dynamo-nts-email.service.js +4 -4
  56. package/lib/_services/dynamo-nts-email.service.js.map +1 -1
  57. package/lib/_services/dynamo-nts-global.service.d.ts +2 -2
  58. package/lib/_services/dynamo-nts-global.service.d.ts.map +1 -1
  59. package/lib/_services/dynamo-nts-global.service.js.map +1 -1
  60. package/lib/_services/dynamo-nts-routing-module.service.js +3 -3
  61. package/lib/_services/dynamo-nts-routing-module.service.js.map +1 -1
  62. package/lib/_services/dynamo-nts-shared.service.d.ts +6 -0
  63. package/lib/_services/dynamo-nts-shared.service.d.ts.map +1 -1
  64. package/lib/_services/dynamo-nts-shared.service.js +8 -0
  65. package/lib/_services/dynamo-nts-shared.service.js.map +1 -1
  66. package/lib/_services/dynamo-nts-socket-service-collection.service.d.ts +1 -1
  67. package/lib/_services/dynamo-nts-socket-service-collection.service.d.ts.map +1 -1
  68. package/lib/_services/dynamo-nts-socket.service.d.ts +6 -9
  69. package/lib/_services/dynamo-nts-socket.service.d.ts.map +1 -1
  70. package/lib/_services/dynamo-nts-socket.service.js +20 -19
  71. package/lib/_services/dynamo-nts-socket.service.js.map +1 -1
  72. package/lib/_services/dynamobe-api.service.js +2 -2
  73. package/lib/_services/dynamobe-auth.service.js +2 -2
  74. package/lib/_services/dynamobe-data.service.js +15 -15
  75. package/lib/_services/dynamobe-db.service.js +24 -24
  76. package/lib/_services/dynamobe-email.service.js +4 -4
  77. package/lib/_services/dynamobe-routing-module.service.js +3 -3
  78. package/lib/tsconfig.tsbuildinfo +77 -52
  79. package/package.json +13 -8
  80. package/src/_enums/http/socket-event.enum.ts +2 -0
  81. package/src/_models/dynamo-nts-socket-dictionary.ts +36 -0
  82. package/src/_models/dynamo-nts-socket-event-params.ts +8 -5
  83. package/src/_models/index.ts +1 -0
  84. package/src/_modules/app-extended.index.ts +1 -0
  85. package/src/_modules/usage/usage.service.ts +8 -4
  86. package/src/_services/dynamo-nts-api.service.ts +7 -4
  87. package/src/_services/dynamo-nts-app-extended.ts +13 -8
  88. package/src/_services/dynamo-nts-app.ts +2 -3
  89. package/src/_services/dynamo-nts-auth.service.ts +6 -2
  90. package/src/_services/dynamo-nts-controller.service.ts +37 -0
  91. package/src/_services/dynamo-nts-data.service.ts +70 -31
  92. package/src/_services/dynamo-nts-db.service.ts +72 -48
  93. package/src/_services/dynamo-nts-email.service.ts +4 -4
  94. package/src/_services/dynamo-nts-global.service.ts +9 -2
  95. package/src/_services/dynamo-nts-routing-module.service.ts +3 -3
  96. package/src/_services/dynamo-nts-shared.service.ts +9 -0
  97. package/src/_services/dynamo-nts-socket-service-collection.service.ts +1 -1
  98. package/src/_services/dynamo-nts-socket.service.ts +27 -27
@@ -91,7 +91,7 @@ export class DynamoNTS_RoutingModule {
91
91
  } catch (error) {
92
92
  throw new DynamoNTS_Error({
93
93
  message: `DYNAMOBEERROR: Failed to mount routes.`,
94
- userMessage: `We encountered an uncought BackEnd Build Error, please contact the responsible development team. errorcode: 900-456-100`,
94
+ userMessage: `We encountered an uncought BackEnd Build Error, please contact the responsible development team. \nerrorCode: 900-456-100`,
95
95
  error
96
96
  })
97
97
  }
@@ -127,7 +127,7 @@ export class DynamoNTS_RoutingModule {
127
127
  default:
128
128
  throw new DynamoNTS_Error({
129
129
  message: `DYNAMOBEERROR: INVALID route type: ${endpointParams.type} - ${endpointParams.name}` ,
130
- userMessage: `We encountered an uncought BackEnd Build Error, please contact the responsible development team. errorcode: 900-456-200`,
130
+ userMessage: `We encountered an uncought BackEnd Build Error, please contact the responsible development team. \nerrorCode: 900-456-200`,
131
131
  error: new Error()
132
132
  })
133
133
  }
@@ -162,7 +162,7 @@ export class DynamoNTS_RoutingModule {
162
162
  default:
163
163
  throw new DynamoNTS_Error({
164
164
  message: `DYNAMOBEERROR: INVALID route type: ${endpointParams.type} - ${endpointParams.name}`,
165
- userMessage: `We encountered an uncought BackEnd Build Error, please contact the responsible development team. errorcode: 900-456-300`,
165
+ userMessage: `We encountered an uncought BackEnd Build Error, please contact the responsible development team. \nerrorCode: 900-456-300`,
166
166
  error: new Error()
167
167
  })
168
168
  }
@@ -35,6 +35,15 @@ export class DynamoNTS_Shared extends Dynamo_Shared {
35
35
  return GeoIp.lookup(this.getIpFromRequest(request));
36
36
  }
37
37
 
38
+ /**
39
+ *
40
+ * @param request
41
+ * @returns
42
+ */
43
+ static getLocationByIp(ip: string): GeoIpLocation {
44
+ return GeoIp.lookup(ip);
45
+ }
46
+
38
47
  /**
39
48
  *
40
49
  * @param question
@@ -11,6 +11,6 @@ export class DynamoNTS_SocketServiceCollection extends DynamoNTS_SingletonServic
11
11
  return DynamoNTS_SocketServiceCollection.getSingletonInstance();
12
12
  }
13
13
 
14
- [service: string]: DynamoNTS_SocketService;
14
+ [service: string]: DynamoNTS_SocketService<any>;
15
15
 
16
16
  }
@@ -3,23 +3,19 @@ import * as SocketIO from 'socket.io';
3
3
 
4
4
  import { dynamoNTS_GlobalSettings } from '../_constants/dynamo-nts-global-settings';
5
5
  import { DynamoNTS_Shared } from './dynamo-nts-shared.service';
6
- import { DynamoNTS_SocketServiceParams } from '../_models';
7
6
  import { DynamoNTS_SingletonService } from './dynamo-nts-singleton.service';
8
7
  import { DynamoNTS_SocketEventParams } from '../_models/dynamo-nts-socket-event-params';
9
8
  import { DynamoNTS_SocketEvent } from '../_enums/http/socket-event.enum';
10
9
  import { DynamoNTS_GlobalService } from './dynamo-nts-global.service';
11
10
  import { DynamoNTS_Error } from '@futdevpro/fsm-dynamo';
12
- import { DynamoNTS_SocketSecurity } from '../_enums';
13
-
14
- export interface DynamoNTS_SocketDictionary {
15
- id?: string;
16
- sockets: SocketIO.Socket[];
17
- }
11
+ import { DynamoNTS_SocketServiceParams } from '../_models/dynamo-nts-socket-service-params';
12
+ import { DynamoNTS_SocketDictionary } from '../_models/dynamo-nts-socket-dictionary';
13
+ import { DynamoNTS_SocketSecurity } from '../_enums/dynamo-nts-socket-security.enum';
18
14
 
19
15
  /**
20
16
  *
21
17
  */
22
- export abstract class DynamoNTS_SocketService extends DynamoNTS_SingletonService {
18
+ export abstract class DynamoNTS_SocketService<T extends DynamoNTS_SocketDictionary> extends DynamoNTS_SingletonService {
23
19
  protected params: DynamoNTS_SocketServiceParams;
24
20
  get name(): string { return this.params.name; }
25
21
  get port(): number { return this.params.port; }
@@ -31,8 +27,8 @@ export abstract class DynamoNTS_SocketService extends DynamoNTS_SingletonService
31
27
  protected incomingEvents: DynamoNTS_SocketEventParams<any>[];
32
28
 
33
29
  private subscriptionEvent: DynamoNTS_SocketEventParams<any>;
34
- private getIdFromSubscrioption?: <T>(content: T) => Promise<string>;
35
- private activeSockets: DynamoNTS_SocketDictionary[] = [];
30
+ private getDicFromSubscrioption?: (content: any) => Promise<T>;
31
+ protected activeSockets: T[] = [];
36
32
 
37
33
  protected log: boolean = dynamoNTS_GlobalSettings.logSetup;
38
34
 
@@ -69,8 +65,9 @@ export abstract class DynamoNTS_SocketService extends DynamoNTS_SingletonService
69
65
  tasks: []
70
66
  });
71
67
  }
68
+ this.connectEvent.socketName = this.params.name;
72
69
 
73
- if (this.getIdFromSubscrioption) {
70
+ if (this.getDicFromSubscrioption) {
74
71
  const subscriptionEventIndex = this.incomingEvents.findIndex((event: DynamoNTS_SocketEventParams<any>) => event.event === DynamoNTS_SocketEvent.subscribe);
75
72
  if (0 <= subscriptionEventIndex) {
76
73
  this.subscriptionEvent = this.incomingEvents.splice(subscriptionEventIndex)[0];
@@ -92,7 +89,13 @@ export abstract class DynamoNTS_SocketService extends DynamoNTS_SingletonService
92
89
  ]
93
90
  }));
94
91
  }
92
+
93
+ this.subscriptionEvent.socketName = this.params.name;
95
94
  }
95
+
96
+ this.incomingEvents.forEach((event: DynamoNTS_SocketEventParams<any>) => {
97
+ event.socketName = this.params.name;
98
+ });
96
99
  }
97
100
 
98
101
  async setupSocketServer(newSocketServer: SocketIO.Server): Promise<void> {
@@ -108,11 +111,12 @@ export abstract class DynamoNTS_SocketService extends DynamoNTS_SingletonService
108
111
  await this.connectEvent.tasks[i](socket);
109
112
  }
110
113
 
111
- if (this.getIdFromSubscrioption) {
114
+ if (this.getDicFromSubscrioption) {
112
115
  socket.on(DynamoNTS_SocketEvent.subscribe, async (content: any) => {
113
- issuer = await this.getIdFromSubscrioption(content);
116
+ const dic: T = await this.getDicFromSubscrioption(content);
117
+ issuer = dic.issuerId;
114
118
 
115
- this.socketSubscription(socket, issuer);
119
+ this.socketSubscription(dic);
116
120
  this.subscriptionEvent.getFullExecution(issuer)(content);
117
121
  })
118
122
  }
@@ -124,18 +128,18 @@ export abstract class DynamoNTS_SocketService extends DynamoNTS_SingletonService
124
128
 
125
129
  this.socketServer.listen(this.params.port);
126
130
 
127
- if (this.log) console.log(
131
+ console.log(
128
132
  `\nsocket service setup finished: ${this.params.name}` +
129
133
  `\nsocket server listening on port: ${this.params.port}`
130
134
  );
131
135
  }
132
136
 
133
- private async socketSubscription(newSocket: SocketIO.Socket, id: string): Promise<void> {
134
- const activeSocket: DynamoNTS_SocketDictionary = this.activeSockets.find((dic: DynamoNTS_SocketDictionary) => dic.id === id);
137
+ private async socketSubscription(dictionary: T): Promise<void> {
138
+ const activeSocket: T = this.activeSockets.find((dic: T) => dic.issuerId === dictionary.issuerId);
135
139
  if (activeSocket) {
136
- activeSocket.sockets.push(newSocket);
140
+ activeSocket.sockets.push(dictionary.sockets[0]);
137
141
  } else {
138
- this.activeSockets.push({ id, sockets: [ newSocket ] });
142
+ this.activeSockets.push(dictionary);
139
143
  }
140
144
  }
141
145
 
@@ -155,15 +159,13 @@ export abstract class DynamoNTS_SocketService extends DynamoNTS_SingletonService
155
159
  }
156
160
 
157
161
  idIsSubscribed(id: string): boolean {
158
- return !!this.activeSockets.find((dic: DynamoNTS_SocketDictionary) => dic.id === id);
162
+ return !!this.activeSockets.find((dic: DynamoNTS_SocketDictionary) => dic.issuerId === id);
159
163
  }
160
164
 
161
165
  async sendEventForId(id: string, event: string, content: any, error?: (err: any) => void): Promise<void> {
162
- const dic: DynamoNTS_SocketDictionary = this.activeSockets.find((dic: DynamoNTS_SocketDictionary) => dic.id === id);
166
+ const dic: DynamoNTS_SocketDictionary = this.activeSockets.find((dic: DynamoNTS_SocketDictionary) => dic.issuerId === id);
163
167
  if (dic) {
164
- dic.sockets.forEach((socket: SocketIO.Socket) => {
165
- socket.emit(event, content);
166
- });
168
+ dic.emitEvent(event, content);
167
169
  } else {
168
170
  if (error)
169
171
  throw new DynamoNTS_Error({ status: 404, message: `No active socket whit this specific ID: ${id}` });
@@ -172,9 +174,7 @@ export abstract class DynamoNTS_SocketService extends DynamoNTS_SingletonService
172
174
 
173
175
  broadcastEvent(event: string, content: any): void {
174
176
  this.activeSockets.forEach((dic: DynamoNTS_SocketDictionary) => {
175
- dic.sockets.forEach((socket: SocketIO.Socket) => {
176
- socket.emit(event, content);
177
- })
177
+ dic.emitEvent(event, content);
178
178
  })
179
179
  }
180
180