@futdevpro/fsm-dynamo 1.5.58 → 1.5.60

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 (106) hide show
  1. package/lib/_constants/error-defaults.const.d.ts +3 -0
  2. package/lib/_constants/error-defaults.const.d.ts.map +1 -0
  3. package/lib/_constants/error-defaults.const.js +12 -0
  4. package/lib/_constants/error-defaults.const.js.map +1 -0
  5. package/lib/_constants/index.d.ts +1 -0
  6. package/lib/_constants/index.d.ts.map +1 -1
  7. package/lib/_constants/index.js +1 -0
  8. package/lib/_constants/index.js.map +1 -1
  9. package/lib/_enums/basic-property-type.enum.d.ts +1 -1
  10. package/lib/_enums/basic-property-type.enum.d.ts.map +1 -1
  11. package/lib/_enums/basic-property-type.enum.js +9 -9
  12. package/lib/_enums/basic-property-type.enum.js.map +1 -1
  13. package/lib/_enums/data-model-type.enum.d.ts +1 -1
  14. package/lib/_enums/data-model-type.enum.d.ts.map +1 -1
  15. package/lib/_enums/data-model-type.enum.js +7 -7
  16. package/lib/_enums/data-model-type.enum.js.map +1 -1
  17. package/lib/_enums/log-style.enum.d.ts +1 -1
  18. package/lib/_enums/log-style.enum.d.ts.map +1 -1
  19. package/lib/_enums/log-style.enum.js +27 -27
  20. package/lib/_enums/log-style.enum.js.map +1 -1
  21. package/lib/_enums/region.enum.d.ts +1 -1
  22. package/lib/_enums/region.enum.d.ts.map +1 -1
  23. package/lib/_enums/region.enum.js +9 -9
  24. package/lib/_enums/region.enum.js.map +1 -1
  25. package/lib/_enums/sub-region.enum.d.ts +1 -1
  26. package/lib/_enums/sub-region.enum.d.ts.map +1 -1
  27. package/lib/_enums/sub-region.enum.js +21 -21
  28. package/lib/_enums/sub-region.enum.js.map +1 -1
  29. package/lib/_enums/subdivision-region-type.enum.d.ts +1 -1
  30. package/lib/_enums/subdivision-region-type.enum.d.ts.map +1 -1
  31. package/lib/_enums/subdivision-region-type.enum.js +42 -42
  32. package/lib/_enums/subdivision-region-type.enum.js.map +1 -1
  33. package/lib/_models/control-models/data-params.control-model.d.ts +2 -2
  34. package/lib/_models/control-models/data-params.control-model.d.ts.map +1 -1
  35. package/lib/_models/control-models/data-params.control-model.js +2 -2
  36. package/lib/_models/control-models/data-params.control-model.js.map +1 -1
  37. package/lib/_models/control-models/data-property-params.control-model.d.ts +2 -2
  38. package/lib/_models/control-models/data-property-params.control-model.d.ts.map +1 -1
  39. package/lib/_models/control-models/data-property-params.control-model.js +5 -5
  40. package/lib/_models/control-models/data-property-params.control-model.js.map +1 -1
  41. package/lib/_models/control-models/error.control-model.d.ts +30 -17
  42. package/lib/_models/control-models/error.control-model.d.ts.map +1 -1
  43. package/lib/_models/control-models/error.control-model.js +93 -88
  44. package/lib/_models/control-models/error.control-model.js.map +1 -1
  45. package/lib/_models/control-models/error.control-model.spec.d.ts +2 -0
  46. package/lib/_models/control-models/error.control-model.spec.d.ts.map +1 -0
  47. package/lib/_models/control-models/error.control-model.spec.js +272 -0
  48. package/lib/_models/control-models/error.control-model.spec.js.map +1 -0
  49. package/lib/_models/control-models/poll.control-model.d.ts.map +1 -1
  50. package/lib/_models/control-models/poll.control-model.js +0 -2
  51. package/lib/_models/control-models/poll.control-model.js.map +1 -1
  52. package/lib/_models/data-models/metadata.data-model.d.ts +7 -1
  53. package/lib/_models/data-models/metadata.data-model.d.ts.map +1 -1
  54. package/lib/_models/data-models/metadata.data-model.js +39 -3
  55. package/lib/_models/data-models/metadata.data-model.js.map +1 -1
  56. package/lib/_models/interfaces/error-defaults.interface.d.ts +9 -0
  57. package/lib/_models/interfaces/error-defaults.interface.d.ts.map +1 -0
  58. package/lib/_models/interfaces/error-defaults.interface.js +3 -0
  59. package/lib/_models/interfaces/error-defaults.interface.js.map +1 -0
  60. package/lib/_models/interfaces/index.d.ts +1 -0
  61. package/lib/_models/interfaces/index.d.ts.map +1 -1
  62. package/lib/_models/interfaces/index.js +1 -0
  63. package/lib/_models/interfaces/index.js.map +1 -1
  64. package/lib/_models/interfaces/location/country-iso.interface.d.ts +4 -4
  65. package/lib/_models/interfaces/location/country-iso.interface.d.ts.map +1 -1
  66. package/lib/_models/interfaces/location/division-region-data.interface.d.ts +2 -2
  67. package/lib/_models/interfaces/location/division-region-data.interface.d.ts.map +1 -1
  68. package/lib/_modules/error-module.index.d.ts +2 -0
  69. package/lib/_modules/error-module.index.d.ts.map +1 -1
  70. package/lib/_modules/error-module.index.js +2 -0
  71. package/lib/_modules/error-module.index.js.map +1 -1
  72. package/lib/_utils/array.util.d.ts +2 -2
  73. package/lib/_utils/array.util.d.ts.map +1 -1
  74. package/lib/_utils/array.util.js +2 -2
  75. package/lib/_utils/array.util.js.map +1 -1
  76. package/lib/_utils/log.util.d.ts +5 -3
  77. package/lib/_utils/log.util.d.ts.map +1 -1
  78. package/lib/_utils/log.util.js +23 -12
  79. package/lib/_utils/log.util.js.map +1 -1
  80. package/lib/_utils/regions.util.d.ts +2 -2
  81. package/lib/_utils/regions.util.d.ts.map +1 -1
  82. package/lib/_utils/regions.util.js.map +1 -1
  83. package/lib/tsconfig.tsbuildinfo +154 -90
  84. package/package.json +1 -1
  85. package/src/_constants/error-defaults.const.ts +11 -0
  86. package/src/_constants/index.ts +1 -0
  87. package/src/_enums/basic-property-type.enum.ts +1 -1
  88. package/src/_enums/data-model-type.enum.ts +1 -1
  89. package/src/_enums/log-style.enum.ts +1 -1
  90. package/src/_enums/region.enum.ts +1 -1
  91. package/src/_enums/sub-region.enum.ts +1 -1
  92. package/src/_enums/subdivision-region-type.enum.ts +1 -1
  93. package/src/_models/control-models/data-params.control-model.ts +4 -4
  94. package/src/_models/control-models/data-property-params.control-model.ts +7 -7
  95. package/src/_models/control-models/error.control-model.spec.ts +345 -0
  96. package/src/_models/control-models/error.control-model.ts +134 -108
  97. package/src/_models/control-models/poll.control-model.ts +0 -2
  98. package/src/_models/data-models/metadata.data-model.ts +49 -4
  99. package/src/_models/interfaces/error-defaults.interface.ts +11 -0
  100. package/src/_models/interfaces/index.ts +1 -0
  101. package/src/_models/interfaces/location/country-iso.interface.ts +4 -4
  102. package/src/_models/interfaces/location/division-region-data.interface.ts +2 -2
  103. package/src/_modules/error-module.index.ts +2 -0
  104. package/src/_utils/array.util.ts +4 -4
  105. package/src/_utils/log.util.ts +30 -17
  106. package/src/_utils/regions.util.ts +3 -3
@@ -1,4 +1,4 @@
1
-
1
+ import { Dynamo_Error } from '../control-models';
2
2
 
3
3
  export type D_Metadata = Dynamo_Metadata;
4
4
  export type D_MetaD = Dynamo_Metadata;
@@ -12,14 +12,59 @@ export class Dynamo_Metadata {
12
12
  __v?: number;
13
13
 
14
14
  constructor(
15
- set?: Dynamo_Metadata
15
+ set?: Dynamo_Metadata,
16
+ forceInit?: {
17
+ id?: string,
18
+ issuer: string,
19
+ },
20
+ forceUpdate?: {
21
+ throwOnMissingId?: boolean,
22
+ issuer: string,
23
+ },
16
24
  ){
17
25
  if (set) {
18
26
  if (!set._id && set._id !== undefined) {
19
- delete set._id;
27
+ set._id = undefined;
28
+ }
29
+
30
+ this._id = set._id;
31
+ this.__created = set.__created;
32
+ this.__createdBy = set.__createdBy;
33
+ this.__lastModified = set.__lastModified;
34
+ this.__lastModifiedBy = set.__lastModifiedBy;
35
+ this.__v = set.__v;
36
+ }
37
+
38
+ if (forceInit?.issuer) {
39
+ if (!this._id && forceInit.id) {
40
+ this._id = forceInit.id;
41
+ }
42
+ if (!this.__created) {
43
+ this.__created = new Date();
20
44
  }
45
+ if (!this.__createdBy) {
46
+ this.__createdBy = forceInit.issuer;
47
+ }
48
+ if (!this.__lastModified) {
49
+ this.__lastModified = new Date();
50
+ }
51
+ if (!this.__lastModifiedBy) {
52
+ this.__lastModifiedBy = forceInit.issuer;
53
+ }
54
+ if (!this.__v) {
55
+ this.__v = 0;
56
+ }
57
+ }
21
58
 
22
- Object.assign(this, set);
59
+ if (forceUpdate?.issuer) {
60
+ if (!this._id && forceUpdate.throwOnMissingId) {
61
+ throw new Dynamo_Error({
62
+ message: `Dynamo_Metadata.constructor: missing _id`,
63
+ });
64
+ }
65
+ this.__lastModified = new Date();
66
+ this.__lastModifiedBy = forceUpdate.issuer;
67
+ this.__v = this.__v ? this.__v + 1 : 1;
23
68
  }
24
69
  }
25
70
  }
@@ -0,0 +1,11 @@
1
+
2
+
3
+ export interface Dynamo_Error_Defaults {
4
+ errorCode: string;
5
+ message: string;
6
+ userMessage: string;
7
+ issuer: string;
8
+ issuerService: string;
9
+ issuerSystem: string;
10
+ }
11
+
@@ -1,5 +1,6 @@
1
1
 
2
2
  // INTERFACES
3
+ export * from './error-defaults.interface';
3
4
  export * from './random-weight.interface';
4
5
  export * from './route-settings.interface';
5
6
 
@@ -1,7 +1,7 @@
1
1
 
2
2
 
3
- import { Region } from '../../../_enums/region.enum';
4
- import { SubRegion } from '../../../_enums/sub-region.enum';
3
+ import { Dynamo_Region } from '../../../_enums/region.enum';
4
+ import { Dynamo_SubRegion } from '../../../_enums/sub-region.enum';
5
5
  import { CountryDivision } from './country-division.interface';
6
6
 
7
7
  export interface CountryISO {
@@ -10,9 +10,9 @@ export interface CountryISO {
10
10
  iso3: string;
11
11
  countryCode: string;
12
12
  fullIso: string;
13
- region: Region;
13
+ region: Dynamo_Region;
14
14
  regionCode: string;
15
- subRegion: SubRegion;
15
+ subRegion: Dynamo_SubRegion;
16
16
  subRegionCode: string;
17
17
  subdivisionRegion: string;
18
18
  subdivisionRegionCode: string;
@@ -1,8 +1,8 @@
1
- import { SubdivisionRegionType } from '../../../_enums/subdivision-region-type.enum';
1
+ import { Dynamo_SubdivisionRegionType } from '../../../_enums/subdivision-region-type.enum';
2
2
  import { CountryISO } from './country-iso.interface';
3
3
 
4
4
  export interface SubdivisionRegionData extends CountryISO {
5
- type?: SubdivisionRegionType;
5
+ type?: Dynamo_SubdivisionRegionType;
6
6
  }
7
7
 
8
8
 
@@ -1,5 +1,7 @@
1
1
 
2
2
  // ERROR MODULE
3
3
  export * from '../_models/control-models/error.control-model';
4
+ export * from '../_constants/error-defaults.const';
5
+ export * from '../_models/interfaces/error-defaults.interface';
4
6
 
5
7
 
@@ -3,16 +3,16 @@
3
3
  export type D_Array = Dynamo_Array;
4
4
  export class Dynamo_Array {
5
5
 
6
- static async asyncForEach<T>(list: T[], func: (element: T, index?: number) => Promise<void>): Promise<void> {
6
+ static async asyncForEach<T>(list: T[], func: (element: T, index?: number, array?: T[]) => Promise<void>): Promise<void> {
7
7
  for (let i = 0; i < list.length; i++) {
8
- await func(list[i], i);
8
+ await func(list[i], i, list);
9
9
  }
10
10
  }
11
11
 
12
- static async asyncMapArray<T, R>(list: T[], mapFunc: (element: T, index?: number) => Promise<R>): Promise<R[]> {
12
+ static async asyncMapArray<T, R>(list: T[], mapFunc: (element: T, index?: number, array?: T[]) => Promise<R>): Promise<R[]> {
13
13
  const resultList: R[] = [];
14
14
  for (let i = 0; i < list.length; i++) {
15
- resultList.push(await mapFunc(list[i], i));
15
+ resultList.push(await mapFunc(list[i], i, list));
16
16
  }
17
17
  return resultList;
18
18
  }
@@ -1,5 +1,5 @@
1
1
 
2
- import { LogStyle } from '../_enums/log-style.enum';
2
+ import { Dynamo_LogStyle } from '../_enums/log-style.enum';
3
3
 
4
4
  /* export class D_Log implements Dynamo_Log {}; */
5
5
  export type Dynamo_L = Dynamo_Log;
@@ -7,34 +7,47 @@ export type D_Log = Dynamo_Log;
7
7
  export type D_L = Dynamo_Log;
8
8
 
9
9
  export class Dynamo_Log {
10
- static setStyle(styles: LogStyle[]): void {
10
+ static highlightedLog(message: string, ...optionalParams: any[]): void {
11
+ console.log('\n\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!');
12
+ console.log(message, ...optionalParams);
13
+ console.log('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\n');
14
+ }
15
+
16
+ static testLog(message: string, ...optionalParams: any[]): void {
17
+ console.log('\n\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!');
18
+ console.log('TEST');
19
+ console.log(message, ...optionalParams);
20
+ console.log('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\n');
21
+ }
22
+
23
+ static setStyle(styles: Dynamo_LogStyle[]): void {
11
24
  let styleSets = '';
12
- styles.forEach((style: LogStyle) => {
25
+ styles.forEach((style: Dynamo_LogStyle) => {
13
26
  styleSets += style;
14
27
  });
15
28
  console.log(styleSets);
16
29
  }
17
30
  static resetStyle(): void {
18
- console.log(LogStyle.reset);
31
+ console.log(Dynamo_LogStyle.reset);
19
32
  }
20
33
 
21
- static addStyle(input: string, styles: LogStyle[], dontReset?: boolean): string {
34
+ static addStyle(input: string, styles: Dynamo_LogStyle[], dontReset?: boolean): string {
22
35
  let result = '';
23
- styles.forEach((style: LogStyle) => {
36
+ styles.forEach((style: Dynamo_LogStyle) => {
24
37
  result += style;
25
38
  });
26
39
  result += input;
27
40
  if (!dontReset) {
28
- result += LogStyle.reset;
41
+ result += Dynamo_LogStyle.reset;
29
42
  }
30
43
  return result;
31
44
  }
32
45
 
33
46
  static success(message: string, ...optionalParams: any[]): void {
34
47
  if (0 < optionalParams.length) {
35
- console.log(`${LogStyle.green}${LogStyle.bright}${message}`, ...optionalParams, LogStyle.reset);
48
+ console.log(`${Dynamo_LogStyle.green}${Dynamo_LogStyle.bright}${message}`, ...optionalParams, Dynamo_LogStyle.reset);
36
49
  } else {
37
- console.log(`${LogStyle.green}${LogStyle.bright}${message}${LogStyle.reset}`);
50
+ console.log(`${Dynamo_LogStyle.green}${Dynamo_LogStyle.bright}${message}${Dynamo_LogStyle.reset}`);
38
51
  }
39
52
  }
40
53
  /**
@@ -46,9 +59,9 @@ export class Dynamo_Log {
46
59
 
47
60
  static error(message: string, ...optionalParams: any[]): void {
48
61
  if (0 < optionalParams.length) {
49
- console.error(`${LogStyle.red}${LogStyle.bright}${message}`, ...optionalParams, LogStyle.reset);
62
+ console.error(`${Dynamo_LogStyle.red}${Dynamo_LogStyle.bright}${message}`, ...optionalParams, Dynamo_LogStyle.reset);
50
63
  } else {
51
- console.error(`${LogStyle.red}${LogStyle.bright}${message}${LogStyle.reset}`);
64
+ console.error(`${Dynamo_LogStyle.red}${Dynamo_LogStyle.bright}${message}${Dynamo_LogStyle.reset}`);
52
65
  }
53
66
  }
54
67
  /**
@@ -60,9 +73,9 @@ export class Dynamo_Log {
60
73
 
61
74
  static warn(message: string, ...optionalParams: any[]): void {
62
75
  if (0 < optionalParams.length) {
63
- console.warn(`${LogStyle.yellow}${LogStyle.bright}${message}`, ...optionalParams, LogStyle.reset);
76
+ console.warn(`${Dynamo_LogStyle.yellow}${Dynamo_LogStyle.bright}${message}`, ...optionalParams, Dynamo_LogStyle.reset);
64
77
  } else {
65
- console.warn(`${LogStyle.yellow}${LogStyle.bright}${message}${LogStyle.reset}`);
78
+ console.warn(`${Dynamo_LogStyle.yellow}${Dynamo_LogStyle.bright}${message}${Dynamo_LogStyle.reset}`);
66
79
  }
67
80
  }
68
81
  /**
@@ -80,15 +93,15 @@ export class Dynamo_Log {
80
93
 
81
94
  static highlighted(message: string, ...optionalParams: any[]): void {
82
95
  if (0 < optionalParams.length) {
83
- console.log(`${LogStyle.white}${LogStyle.bright}${message}`, ...optionalParams, LogStyle.reset);
96
+ console.log(`${Dynamo_LogStyle.white}${Dynamo_LogStyle.bright}${message}`, ...optionalParams, Dynamo_LogStyle.reset);
84
97
  } else {
85
- console.log(`${LogStyle.white}${LogStyle.bright}${message}${LogStyle.reset}`);
98
+ console.log(`${Dynamo_LogStyle.white}${Dynamo_LogStyle.bright}${message}${Dynamo_LogStyle.reset}`);
86
99
  }
87
100
  }
88
101
 
89
102
  static removeLogStyles(message: string): string {
90
- for (let styleKey of Object(LogStyle)) {
91
- message = message.replace(new RegExp(LogStyle[styleKey], 'g'), '');
103
+ for (let styleKey of Object(Dynamo_LogStyle)) {
104
+ message = message.replace(new RegExp(Dynamo_LogStyle[styleKey], 'g'), '');
92
105
  }
93
106
  return message;
94
107
  }
@@ -4,7 +4,7 @@ import * as ISOs from '../_constants/location/country-codes-ISO-3166.json';
4
4
  import * as PhoneCodes from '../_constants/location/country-phone-codes.json';
5
5
  import * as Divisions from '../_constants/location/country-divisions-ISO-3166-all-list.json';
6
6
 
7
- import { Region } from '../_enums/region.enum';
7
+ import { Dynamo_Region } from '../_enums/region.enum';
8
8
  import { Dynamo_Error } from '../_models';
9
9
  import { CountryPhoneCode } from '../_models/interfaces/location/country-phone-code.interface';
10
10
  import { CountryISO } from '../_models/interfaces/location/country-iso.interface';
@@ -48,8 +48,8 @@ export class Dynamo_Regions {
48
48
  }
49
49
  }
50
50
 
51
- static isoToRegion(iso2: string): Region {
52
- const region: Region = this.ISOs.find(iso => iso.iso2 == iso2).region;
51
+ static isoToRegion(iso2: string): Dynamo_Region {
52
+ const region: Dynamo_Region = this.ISOs.find(iso => iso.iso2 == iso2).region;
53
53
  if (!region) {
54
54
  throw new Dynamo_Error({
55
55
  message: `Cannot find ISO-3166 code for this: ${iso2}`