@futdevpro/nts-dynamo 1.9.45 → 1.9.50

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 (44) hide show
  1. package/build/_models/interfaces/global-service-settings.interface.d.ts +3 -3
  2. package/build/_models/interfaces/global-service-settings.interface.d.ts.map +1 -1
  3. package/build/_modules/mock/data-model.mock.d.ts +2 -2
  4. package/build/_modules/mock/data-model.mock.d.ts.map +1 -1
  5. package/build/_modules/mock/data-model.mock.js +21 -21
  6. package/build/_modules/mock/data-model.mock.js.map +1 -1
  7. package/build/_modules/mock/socket-server.mock.d.ts +1 -1
  8. package/build/_modules/mock/socket-server.mock.d.ts.map +1 -1
  9. package/build/_modules/socket/_services/socket-server.service.d.ts +1 -1
  10. package/build/_modules/socket/_services/socket-server.service.d.ts.map +1 -1
  11. package/build/_modules/socket/_services/socket-server.service.spec.js +1 -1
  12. package/build/_modules/socket/_services/socket-server.service.spec.js.map +1 -1
  13. package/build/_services/base/archive-data.service.d.ts +1 -1
  14. package/build/_services/base/archive-data.service.d.ts.map +1 -1
  15. package/build/_services/base/archive-data.service.js.map +1 -1
  16. package/build/_services/base/data.service.d.ts +3 -3
  17. package/build/_services/base/data.service.d.ts.map +1 -1
  18. package/build/_services/base/data.service.js +4 -3
  19. package/build/_services/base/data.service.js.map +1 -1
  20. package/build/_services/base/db.service.d.ts +3 -3
  21. package/build/_services/base/db.service.d.ts.map +1 -1
  22. package/build/_services/base/db.service.js +15 -13
  23. package/build/_services/base/db.service.js.map +1 -1
  24. package/build/_services/core/api.service.d.ts.map +1 -1
  25. package/build/_services/core/api.service.js +3 -3
  26. package/build/_services/core/api.service.js.map +1 -1
  27. package/build/_services/core/global.service.d.ts +2 -2
  28. package/build/_services/core/global.service.d.ts.map +1 -1
  29. package/build/_services/core/global.service.js +1 -1
  30. package/build/_services/core/global.service.js.map +1 -1
  31. package/build/_services/route/controller.service.d.ts.map +1 -1
  32. package/build/_services/route/controller.service.js.map +1 -1
  33. package/package.json +3 -3
  34. package/src/_models/interfaces/global-service-settings.interface.ts +3 -3
  35. package/src/_modules/mock/data-model.mock.ts +23 -23
  36. package/src/_modules/mock/socket-server.mock.ts +5 -5
  37. package/src/_modules/socket/_services/socket-server.service.spec.ts +1 -1
  38. package/src/_modules/socket/_services/socket-server.service.ts +1 -1
  39. package/src/_services/base/archive-data.service.ts +2 -2
  40. package/src/_services/base/data.service.ts +66 -61
  41. package/src/_services/base/db.service.ts +67 -54
  42. package/src/_services/core/api.service.ts +5 -5
  43. package/src/_services/core/global.service.ts +16 -14
  44. package/src/_services/route/controller.service.ts +2 -3
@@ -4,7 +4,9 @@ import { Schema } from 'mongoose';
4
4
 
5
5
  import {
6
6
  DyFM_AnyError,
7
- DyFM_DataModel_Params, DyFM_DataProperty_Params,
7
+ DyFM_DataModel_Params,
8
+ DyFM_DataProperties,
9
+ DyFM_DataProperty_Params,
8
10
  DyFM_DBFilter, DyFM_DBFilterSimple, DyFM_DBSort,
9
11
  DyFM_Error,
10
12
  DyFM_Error_Settings, DyFM_ErrorLevel,
@@ -36,7 +38,7 @@ export class DyNTS_DBService<T extends DyFM_Metadata> {
36
38
  * schemaSettings also MUST contain specific types that differs from the listed above (Array, Date)
37
39
  */
38
40
  constructor(
39
- public dataParams: DyFM_DataModel_Params
41
+ public dataParams: DyFM_DataModel_Params<T>
40
42
  ){
41
43
  try {
42
44
  this.serviceName = this.constructor?.name;
@@ -349,7 +351,7 @@ export class DyNTS_DBService<T extends DyFM_Metadata> {
349
351
  _deleted: new Date(),
350
352
  _deletedBy: issuer,
351
353
  },
352
- issuer
354
+ /* issuer */
353
355
  ).catch(
354
356
  (error): void => {
355
357
  throw new DyFM_Error({
@@ -392,7 +394,7 @@ export class DyNTS_DBService<T extends DyFM_Metadata> {
392
394
  __lastModified: new Date(),
393
395
  __lastModifiedBy: issuer,
394
396
  },
395
- issuer
397
+ /* issuer */
396
398
  ).catch((error): void => {
397
399
  throw new DyFM_Error({
398
400
  ...this._getDefaultErrorSettings('restoreDeletedById', error, issuer),
@@ -531,55 +533,63 @@ export class DyNTS_DBService<T extends DyFM_Metadata> {
531
533
  filter[this.depDataName] = { $in: narrowByDependencyIds };
532
534
  }
533
535
 
534
- this.dataParams.properties.forEach((modelParam: DyFM_DataProperty_Params): void => {
535
- if (
536
- (filterBy[modelParam.key] !== null && filterBy[modelParam.key] !== undefined) ||
537
- filterBy[modelParam.key + 'Range']
538
- ) {
539
- if (modelParam.key.includes('Range') || modelParam.type.includes('[]')) {
540
- // inverz search filter (for Range and Array functions)
541
- if (modelParam.key.includes('Range')) {
542
- const searchParamKeyWithoutRange = modelParam.key.split('Range')[0];
543
-
544
- if (
545
- filterBy[searchParamKeyWithoutRange] !== null &&
546
- filterBy[searchParamKeyWithoutRange] !== undefined
547
- ) {
548
- filter[modelParam.key] = {
549
- from: { $lte: filterBy[searchParamKeyWithoutRange] },
550
- to: { $gte: filterBy[searchParamKeyWithoutRange] },
551
- };
536
+ Object.values(this.dataParams.properties).forEach(
537
+ (modelParam: DyFM_DataProperty_Params<any>): void => {
538
+ if (
539
+ (filterBy[modelParam.key] !== null && filterBy[modelParam.key] !== undefined) ||
540
+ filterBy[modelParam.key + 'Range']
541
+ ) {
542
+ if (modelParam.key.includes('Range') || modelParam.type.includes('[]')) {
543
+ // inverz search filter (for Range and Array functions)
544
+ if (modelParam.key.includes('Range')) {
545
+ const searchParamKeyWithoutRange = modelParam.key.split('Range')[0];
546
+
547
+ if (
548
+ filterBy[searchParamKeyWithoutRange] !== null &&
549
+ filterBy[searchParamKeyWithoutRange] !== undefined
550
+ ) {
551
+ filter[modelParam.key] = {
552
+ from: { $lte: filterBy[searchParamKeyWithoutRange] },
553
+ to: { $gte: filterBy[searchParamKeyWithoutRange] },
554
+ };
555
+ }
556
+ } else {
557
+ if (
558
+ filterBy[modelParam.key] !== null &&
559
+ filterBy[modelParam.key] !== undefined
560
+ ) {
561
+ filter[modelParam.key] = { $in: filterBy[modelParam.key] };
562
+ }
552
563
  }
553
564
  } else {
554
- if (
565
+ // basic search filter
566
+ if (filterBy[modelParam.key + 'Range']) {
567
+ if (
568
+ filterBy[modelParam.key + 'Range'].from ||
569
+ filterBy[modelParam.key + 'Range'].to
570
+ ) {
571
+ filter[modelParam.key] = {};
572
+
573
+ if (filterBy[modelParam.key + 'Range'].from) {
574
+ filter[modelParam.key].$gte = filterBy[modelParam.key + 'Range'].from;
575
+ }
576
+
577
+ if (filterBy[modelParam.key + 'Range'].to) {
578
+ filter[modelParam.key].$lte = filterBy[modelParam.key + 'Range'].to;
579
+ }
580
+ }
581
+ } else if (
555
582
  filterBy[modelParam.key] !== null &&
556
583
  filterBy[modelParam.key] !== undefined
557
584
  ) {
558
- filter[modelParam.key] = { $in: filterBy[modelParam.key] };
559
- }
560
- }
561
- } else {
562
- // basic search filter
563
- if (filterBy[modelParam.key + 'Range']) {
564
- if (filterBy[modelParam.key + 'Range'].from || filterBy[modelParam.key + 'Range'].to) {
565
- filter[modelParam.key] = {};
566
-
567
- if (filterBy[modelParam.key + 'Range'].from) {
568
- filter[modelParam.key].$gte = filterBy[modelParam.key + 'Range'].from;
569
- }
570
-
571
- if (filterBy[modelParam.key + 'Range'].to) {
572
- filter[modelParam.key].$lte = filterBy[modelParam.key + 'Range'].to;
585
+ if (filterBy[modelParam.key].lenght > 0) {
586
+ filter[modelParam.key] = { $in: filterBy[modelParam.key] };
573
587
  }
574
588
  }
575
- } else if (filterBy[modelParam.key] !== null && filterBy[modelParam.key] !== undefined) {
576
- if (filterBy[modelParam.key].lenght > 0) {
577
- filter[modelParam.key] = { $in: filterBy[modelParam.key] };
578
- }
579
589
  }
580
590
  }
581
591
  }
582
- });
592
+ );
583
593
 
584
594
  let dataList: T[] = await this.dataModel
585
595
  .find(filter)
@@ -1013,23 +1023,23 @@ export class DyNTS_DBService<T extends DyFM_Metadata> {
1013
1023
 
1014
1024
  /**
1015
1025
  * builds mongoose schema building settings object by dynamoDataModelParamsList
1016
- * @param params DynamoBEDataPropertyParams
1026
+ * @param properties DynamoBEDataPropertyParams
1017
1027
  * @returns mongoose schema object
1018
1028
  */
1019
- private buildMongooseSchemaByModelParams(params?: DyFM_DataProperty_Params[]): any {
1029
+ private buildMongooseSchemaByModelParams(properties?: DyFM_DataProperties<T>): any {
1020
1030
  const schemaSettingsObj = {};
1021
1031
 
1022
- if (!params) {
1023
- params = this.dataParams.properties;
1032
+ if (!properties) {
1033
+ properties = this.dataParams.properties;
1024
1034
  }
1025
1035
 
1026
- params.forEach((property: DyFM_DataProperty_Params): void => {
1036
+ Object.values(properties).forEach((property: DyFM_DataProperty_Params<any>): void => {
1027
1037
  const beType = this.getBEType(property.type);
1028
1038
 
1029
1039
  if (
1030
1040
  beType !== Object ||
1031
1041
  !property?.subObjectParams ||
1032
- property?.subObjectParams?.length == 0
1042
+ (property?.subObjectParams && Object.keys(property.subObjectParams).length == 0)
1033
1043
  ) {
1034
1044
  schemaSettingsObj[property.key] = {
1035
1045
  type: beType,
@@ -1123,12 +1133,15 @@ export class DyNTS_DBService<T extends DyFM_Metadata> {
1123
1133
  * sets depDataKey
1124
1134
  */
1125
1135
  private lookForDependencyDataSettings(): void {
1126
- const dependencyParam: DyFM_DataProperty_Params = this.dataParams.properties.find(
1127
- (modelParams: DyFM_DataProperty_Params): boolean => modelParams.isDependencyHook
1128
- );
1136
+ const dependencyParam: DyFM_DataProperty_Params<any> =
1137
+ Object.values(this.dataParams.properties).find(
1138
+ (modelParams: DyFM_DataProperty_Params<any>): boolean => modelParams.isDependencyHook
1139
+ );
1129
1140
 
1130
- if (this.dataParams.properties.filter(
1131
- (modelParams: DyFM_DataProperty_Params): boolean => modelParams.isDependencyHook).length > 1
1141
+ if (
1142
+ Object.values(this.dataParams.properties).filter(
1143
+ (modelParams: DyFM_DataProperty_Params<any>): boolean => modelParams.isDependencyHook
1144
+ ).length > 1
1132
1145
  ) {
1133
1146
  throw new DyFM_Error({
1134
1147
  ...this._getDefaultErrorSettings(
@@ -1,15 +1,15 @@
1
1
 
2
- import * as Axios from 'axios';
3
- import {
4
- DyFM_AnyError, DyFM_Error, DyFM_Error_Settings, DyFM_Log
2
+ import {
3
+ DyFM_AnyError, DyFM_Error, DyFM_Error_Settings, DyFM_Log
5
4
  } from '@futdevpro/fsm-dynamo';
5
+ import * as Axios from 'axios';
6
6
 
7
+ import { DyNTS_global_settings } from '../../_collections/global-settings.const';
7
8
  import { DyNTS_HttpCallType } from '../../_enums/http/http-call-type.enum';
8
9
  import { DyNTS_HttpResponseType } from '../../_enums/http/http-response-type.enum';
9
10
  import {
10
11
  DyNTS_ApiCall_Params
11
12
  } from '../../_models/control-models/api-call-params.control-model';
12
- import { DyNTS_global_settings } from '../../_collections/global-settings.const';
13
13
 
14
14
  export interface DyNTS_ApiCallInput_Params<T_Body = any> {
15
15
  pathParams?: {
@@ -77,7 +77,7 @@ export class DyNTS_ApiService {
77
77
  switch (callParams.type) {
78
78
  case DyNTS_HttpCallType.get:
79
79
  if (inputParams?.body) {
80
- DyFM_Log.warn('WARNING you cant send body in get calls');
80
+ DyFM_Log.warn(`WARNING you cant send body in get calls (${callParams.name})`);
81
81
  }
82
82
 
83
83
  a = await this.get<T_Response>(axios, url, callParams);
@@ -1,18 +1,20 @@
1
1
 
2
2
 
3
- import { Request, Response } from 'express';
4
3
 
5
- import {
6
- DyFM_Metadata, DyFM_DataModel_Params, DyFM_Log, DyFM_Error, DyFM_Array,
7
- DyFM_errorFlag,
4
+ import {
8
5
  DyFM_AnyError,
9
- DyFM_Error_Settings
6
+ DyFM_Array,
7
+ DyFM_DataModel_Params,
8
+ DyFM_Error,
9
+ DyFM_Error_Settings,
10
+ DyFM_Log,
11
+ DyFM_Metadata
10
12
  } from '@futdevpro/fsm-dynamo';
11
13
  import { DyNTS_App_Params } from '../../_models/control-models/app-params.control-model';
12
14
 
13
- import {
15
+ import {
14
16
  DyNTS_GlobalErrorHandlerFn,
15
- DyNTS_GlobalService_Settings
17
+ DyNTS_GlobalService_Settings
16
18
  } from '../../_models/interfaces/global-service-settings.interface';
17
19
 
18
20
  import { DyNTS_AuthService } from './auth.service';
@@ -21,8 +23,8 @@ import { DyNTS_DBService } from '../base/db.service';
21
23
  import { DyNTS_EmailService } from './email.service';
22
24
  import { DyNTS_Service_Collection } from './service-collection.service';
23
25
  /* import { DyNTS_EmailServiceCollection } from './email-service-collection.service'; */
24
- import { DyNTS_SingletonService } from '../base/singleton.service';
25
26
  import { DyNTS_global_settings } from '../../_collections/global-settings.const';
27
+ import { DyNTS_SingletonService } from '../base/singleton.service';
26
28
  /* import { DyNTS_archiveFlag } from '../../_collections/archive-flag.const'; */
27
29
  import { DyNTS_getArchivedDBName } from '../../_collections/archive.util';
28
30
 
@@ -84,11 +86,11 @@ export class DyNTS_GlobalService extends DyNTS_SingletonService {
84
86
  }
85
87
  }
86
88
 
87
- private static async setDBServices(dbModels?: DyFM_DataModel_Params[]): Promise<void> {
89
+ private static async setDBServices(dbModels?: DyFM_DataModel_Params<any>[]): Promise<void> {
88
90
  try {
89
91
  this.instance.dbServiceCollection = {};
90
92
 
91
- dbModels?.forEach((dbModel: DyFM_DataModel_Params): void => {
93
+ dbModels?.forEach((dbModel: DyFM_DataModel_Params<any>): void => {
92
94
  if (!dbModel) {
93
95
  throw new DyFM_Error({
94
96
  ...this.getDefaultErrorSettings(
@@ -100,13 +102,13 @@ export class DyNTS_GlobalService extends DyNTS_SingletonService {
100
102
  errorCode: 'NTS-GS0-SDBS2',
101
103
  additionalContent: {
102
104
  dbModels: dbModels,
103
- dbModelNames: dbModels.map((dbModel: DyFM_DataModel_Params) => dbModel.dataName),
105
+ dbModelNames: dbModels.map((dbModel: DyFM_DataModel_Params<any>) => dbModel.dataName),
104
106
  },
105
107
  });
106
108
  }
107
109
 
108
110
  if (dbModel.addArchive) {
109
- const archiveModel: DyFM_DataModel_Params = new DyFM_DataModel_Params({
111
+ const archiveModel: DyFM_DataModel_Params<any> = new DyFM_DataModel_Params<any>({
110
112
  ...dbModel,
111
113
  dataName: DyNTS_getArchivedDBName(dbModel.dataName),
112
114
  });
@@ -115,7 +117,7 @@ export class DyNTS_GlobalService extends DyNTS_SingletonService {
115
117
  }
116
118
  });
117
119
 
118
- dbModels?.forEach((dbModel: DyFM_DataModel_Params): void => {
120
+ dbModels?.forEach((dbModel: DyFM_DataModel_Params<any>): void => {
119
121
  if (!dbModel.constructed) {
120
122
  throw new DyFM_Error({
121
123
  ...this.getDefaultErrorSettings(
@@ -280,7 +282,7 @@ export class DyNTS_GlobalService extends DyNTS_SingletonService {
280
282
  * @returns
281
283
  */
282
284
  static getDBService<T extends DyFM_Metadata>(
283
- dataParams: DyFM_DataModel_Params
285
+ dataParams: DyFM_DataModel_Params<T>
284
286
  ): DyNTS_DBService<T> {
285
287
  return this.getDBServiceByKey<T>(dataParams.dataName);
286
288
  }
@@ -1,8 +1,7 @@
1
1
 
2
2
 
3
- import { DyFM_Error, DyFM_ErrorLevel, DyFM_Log } from '@futdevpro/fsm-dynamo';
4
- import {
5
- DyNTS_Endpoint_Params
3
+ import {
4
+ DyNTS_Endpoint_Params
6
5
  } from '../../_models/control-models/endpoint-params.control-model';
7
6
 
8
7
  import { DyNTS_SingletonService } from '../base/singleton.service';