@futdevpro/nts-dynamo 1.7.25 → 1.7.28

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@futdevpro/nts-dynamo",
3
- "version": "01.07.25",
3
+ "version": "01.07.28",
4
4
  "description": "Dynamic NodeTS (NodeJS-Typescript), MongoDB Backend System Framework by Future Development Program Ltd.",
5
5
  "scripts": {
6
6
  "prep": "npm i rimraf nodemon -g",
@@ -196,7 +196,7 @@
196
196
  },
197
197
  "homepage": "https:/futdevpro.hu/projects/dynamo",
198
198
  "peerDependencies": {
199
- "@futdevpro/fsm-dynamo": "^1.7.8",
199
+ "@futdevpro/fsm-dynamo": "^1.7.12",
200
200
  "@types/express": "^4.17.17",
201
201
  "@types/geoip-lite": "^1.4.1",
202
202
  "@types/node": "^20.5.7",
@@ -10,7 +10,7 @@ import * as SocketIO from 'socket.io';
10
10
  export class DynamoNTS_SocketPresence {
11
11
  issuerId: string;
12
12
  serviceName?: string = 'unknown';
13
- onDestroy?: (issuerId: string) => void = id => {};
13
+ onDestroy?: (issuerId: string) => void = (): void => {};
14
14
 
15
15
  defaultErrorUserMsg?: string =
16
16
  `We encountered an unhandled Socket Error, ` +
@@ -111,12 +111,20 @@ export class DynamoNTS_SocketPresence {
111
111
  }
112
112
  });
113
113
 
114
+ /* this.sockets.forEach((socket: SocketIO.Socket, index: number) => {
115
+ if (!socket) {
116
+ return;
117
+ }
118
+ if (inactiveSockets.includes(socket) || !socket?.connected) {
119
+ socket.TRY RECONNECT
120
+ } */
121
+
114
122
  this.sockets = this.sockets.filter(
115
- socket => !inactiveSockets.includes(socket) && socket?.connected
123
+ (socket): boolean => !inactiveSockets.includes(socket) && socket?.connected
116
124
  );
117
125
 
118
- this.sockets.forEach((socket: SocketIO.Socket, index: number) => {
119
- const success: boolean = socket.emit(event, content, error => {
126
+ this.sockets.forEach((socket: SocketIO.Socket, index: number): void => {
127
+ const success: boolean = socket.emit(event, content, (error): void => {
120
128
  Dynamo_Log.error(
121
129
  `Emitting event '${event}' on socket(${this.serviceName})-(${index}) failed!(0)` +
122
130
  `\nerror:`, error
@@ -1,6 +1,7 @@
1
1
 
2
2
  import {
3
- Dynamo_Metadata, Dynamo_DataParams, Dynamo_DataPropertyParams, Dynamo_Error, Dynamo_Log, Dynamo_AnyError, Dynamo_Error_Settings
3
+ Dynamo_Metadata, Dynamo_DataParams, Dynamo_DataPropertyParams, Dynamo_Error,
4
+ Dynamo_Log, Dynamo_AnyError, Dynamo_Error_Settings
4
5
  } from '@futdevpro/fsm-dynamo';
5
6
  import { DynamoNTS_DBFilter } from '../../_models/types/db-filter.type';
6
7
  import { DynamoNTS_DBUpdate } from '../../_models/types/db-update.type';
@@ -39,6 +40,7 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
39
40
  depKey?: string;
40
41
  depDBServiceKey?: string;
41
42
  depKeyIsUnique?: boolean;
43
+ depKeyIsRequired?: boolean;
42
44
  private depDataDBService: DynamoNTS_DBService<any>;
43
45
 
44
46
  dataParams: Dynamo_DataParams;
@@ -62,7 +64,7 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
62
64
  /**
63
65
  * Initial set for issuer to be able to follow the issuer's activity
64
66
  */
65
- issuer: string,
67
+ issuer: string
66
68
  ) {
67
69
  try {
68
70
  this.serviceName = this.constructor?.name;
@@ -181,7 +183,7 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
181
183
  return [];
182
184
  }
183
185
 
184
- const datas: T[] = await this.dataDBService.find({ _id: { $in: ids, }, });
186
+ const datas: T[] = await this.dataDBService.find({ _id: { $in: ids } });
185
187
 
186
188
  if (!dontSetToService) {
187
189
  this.dataList = datas;
@@ -685,13 +687,13 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
685
687
 
686
688
  return this.data;
687
689
 
688
- } else {
690
+ } else if (this.depKeyIsRequired) {
689
691
  // if data not exists check that dependency already exists for this
690
692
  const dependencyExists = await this.getDependencyDataDBService()
691
693
  .getDataById(this.data[this.depKey])
692
- .catch((error): null => null);
694
+ .catch();
693
695
 
694
- if(!dependencyExists) {
696
+ if (!dependencyExists) {
695
697
  throw new Dynamo_Error({
696
698
  ...this._getDefaultErrorSettings(
697
699
  'saveData',
@@ -852,6 +854,10 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
852
854
  if (dependencyParam.unique) {
853
855
  this.depKeyIsUnique = true;
854
856
  }
857
+
858
+ if (dependencyParam.required) {
859
+ this.depKeyIsRequired = true;
860
+ }
855
861
  }
856
862
  }
857
863
 
@@ -3,7 +3,8 @@ import * as mongoose from 'mongoose';
3
3
  import { Schema } from 'mongoose';
4
4
 
5
5
  import {
6
- Dynamo_Metadata, Dynamo_DataParams, Dynamo_DataPropertyParams, Dynamo_Error, Dynamo_Log, Dynamo_AnyError, Dynamo_Error_Settings
6
+ Dynamo_Metadata, Dynamo_DataParams, Dynamo_DataPropertyParams, Dynamo_Error,
7
+ Dynamo_Log, Dynamo_AnyError, Dynamo_Error_Settings
7
8
  } from '@futdevpro/fsm-dynamo';
8
9
  import { DynamoNTS_DBFilter } from '../../_models/types/db-filter.type';
9
10
  import { DynamoNTS_DBUpdate } from '../../_models/types/db-update.type';
@@ -79,7 +80,7 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
79
80
  new Error(
80
81
  `createData failed, save ${this.dataParams.dbName} result not found! (NTS DB)`
81
82
  ),
82
- issuer,
83
+ issuer
83
84
  ),
84
85
 
85
86
  status: 204,
@@ -98,7 +99,7 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
98
99
 
99
100
  status: 422,
100
101
  errorCode: 'NTS-DBS-CD0',
101
- additionalContent: { data },
102
+ additionalContent: { data, dataModel },
102
103
  message:
103
104
  `createData failed, Create new ${this.dataParams.dbName} was unsuccessful (NTS DB)`,
104
105
  issuer,
@@ -629,13 +629,13 @@ export abstract class DynamoNTS_SocketServerService<
629
629
  if (dynamoNTS_globalSettings.logSocketEventContent) {
630
630
  Dynamo_Log.success(
631
631
  ` <--= emitted socket(${this.params.name}) event for presence: ${event}, ` +
632
- `presenceId: ${id}, sockets: ${presence.sockets.length}` +
633
- `\ncontent:`, content
632
+ `\n presenceId: ${id}, sockets: ${presence.sockets.length}` +
633
+ `\n content:`, content
634
634
  );
635
635
  } else {
636
636
  Dynamo_Log.success(
637
637
  ` <--= emitted socket(${this.params.name}) event for presence: ${event}, ` +
638
- `presenceId: ${id}, sockets: ${presence.sockets.length}`
638
+ `\n presenceId: ${id}, sockets: ${presence.sockets.length}`
639
639
  );
640
640
  }
641
641
  } catch (error) {