@futdevpro/fsm-dynamo 1.9.10 → 1.9.12

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 (119) hide show
  1. package/.github/workflows/main.yml +196 -0
  2. package/HOWTO.md +15 -15
  3. package/README.md +17 -17
  4. package/build/_models/control-models/error.control-model.js +1 -1
  5. package/build/_models/control-models/error.control-model.js.map +1 -1
  6. package/build/_models/control-models/error.control-model.spec.js +25 -6
  7. package/build/_models/control-models/error.control-model.spec.js.map +1 -1
  8. package/futdevpro-fsm-dynamo-01.09.12.tgz +0 -0
  9. package/nodemon.json +11 -11
  10. package/package.json +151 -151
  11. package/src/_collections/assets/location/country-codes-ISO-3166.json +3239 -3239
  12. package/src/_collections/assets/location/country-divisions-ISO-3166-all-list.json +19035 -19035
  13. package/src/_collections/assets/location/country-divisions-ISO-3166.json +4993 -4993
  14. package/src/_collections/assets/location/country-phone-codes.json +1203 -1203
  15. package/src/_collections/constants/country-divisions.const.ts +9 -9
  16. package/src/_collections/constants/courtry-isos.const.ts +8 -8
  17. package/src/_collections/constants/error-defaults.const.ts +11 -11
  18. package/src/_collections/constants/index.ts +15 -15
  19. package/src/_collections/constants/module-settings/custom-data-module-settings.const.ts +15 -15
  20. package/src/_collections/constants/module-settings/index.ts +8 -8
  21. package/src/_collections/constants/module-settings/test-module-settings.const.ts +19 -19
  22. package/src/_collections/constants/module-settings/usage-module-settings.const.ts +19 -19
  23. package/src/_collections/constants/pipe-transforms.const.ts +35 -35
  24. package/src/_collections/constants/times.const.ts +8 -8
  25. package/src/_collections/index.ts +6 -6
  26. package/src/_collections/utils/array.util.spec.ts +39 -39
  27. package/src/_collections/utils/array.util.ts +137 -137
  28. package/src/_collections/utils/index.ts +18 -18
  29. package/src/_collections/utils/location.util.ts +55 -55
  30. package/src/_collections/utils/log.util.ts +239 -239
  31. package/src/_collections/utils/math/box-bounds.util.ts +85 -85
  32. package/src/_collections/utils/math/index.ts +5 -5
  33. package/src/_collections/utils/math/math.util.ts +53 -53
  34. package/src/_collections/utils/math/random.util.ts +80 -80
  35. package/src/_collections/utils/math/trigonometry.util.ts +73 -73
  36. package/src/_collections/utils/math/vector2.util.ts +197 -197
  37. package/src/_collections/utils/pipe-transforms/country-pipe.util.ts +18 -18
  38. package/src/_collections/utils/pipe-transforms/custom-pipe.util.ts +9 -9
  39. package/src/_collections/utils/pipe-transforms/division-pipe.util.ts +20 -20
  40. package/src/_collections/utils/pipe-transforms/index.ts +15 -15
  41. package/src/_collections/utils/pipe-transforms/list-pipe.util.ts +10 -10
  42. package/src/_collections/utils/pipe-transforms/multi-pipe-pipe.util.ts +160 -160
  43. package/src/_collections/utils/pipe-transforms/obj-key-pipe.util.ts +9 -9
  44. package/src/_collections/utils/pipe-transforms/range-pipe.util.ts +94 -94
  45. package/src/_collections/utils/pipe-transforms/region-pipe.util.ts +18 -18
  46. package/src/_collections/utils/pipe-transforms/replace-pipe.util.ts +11 -11
  47. package/src/_collections/utils/pipe-transforms/slider-pipe.util.ts +20 -20
  48. package/src/_collections/utils/pipe-transforms/smart-replace-pipe.util.ts +71 -71
  49. package/src/_collections/utils/regex/index.ts +4 -4
  50. package/src/_collections/utils/regex/password-regex.util.ts +52 -52
  51. package/src/_collections/utils/regex/regex.util.ts +6 -6
  52. package/src/_collections/utils/regex/username-regex.util.ts +33 -33
  53. package/src/_collections/utils/regions.util.ts +100 -100
  54. package/src/_collections/utils/round-list.util.ts +44 -44
  55. package/src/_collections/utils/shared.static-service.ts +177 -177
  56. package/src/_collections/utils/time.util.spec.ts +50 -50
  57. package/src/_collections/utils/time.util.ts +219 -219
  58. package/src/_collections/utils/type-cloning-facility.util.ts +121 -121
  59. package/src/_collections/utils/utilities.util.ts +130 -130
  60. package/src/_enums/basic-property-type.enum.ts +9 -9
  61. package/src/_enums/data-model-type.enum.ts +13 -13
  62. package/src/_enums/day-of-week.enum.ts +28 -28
  63. package/src/_enums/error-level.enum.ts +17 -17
  64. package/src/_enums/index.ts +16 -16
  65. package/src/_enums/location/index.ts +3 -3
  66. package/src/_enums/location/region.enum.ts +9 -9
  67. package/src/_enums/location/sub-region.enum.ts +26 -26
  68. package/src/_enums/location/subdivision-region-type.enum.ts +44 -44
  69. package/src/_enums/log-style.enum.ts +30 -30
  70. package/src/_enums/month.enum.ts +16 -16
  71. package/src/_enums/pipe.enum.ts +45 -45
  72. package/src/_enums/range-pipe-setting.enum.ts +11 -11
  73. package/src/_enums/time/day-of-week.enum.ts +28 -28
  74. package/src/_enums/time/index.ts +3 -3
  75. package/src/_enums/time/month.enum.ts +16 -16
  76. package/src/_enums/time/relative-date.enum.ts +13 -13
  77. package/src/_models/control-models/daily-usage-data.control-model.ts +21 -21
  78. package/src/_models/control-models/data-model-params.control-model.ts +39 -39
  79. package/src/_models/control-models/data-property-params.control-model.ts +106 -106
  80. package/src/_models/control-models/error.control-model.spec.ts +753 -716
  81. package/src/_models/control-models/error.control-model.ts +722 -722
  82. package/src/_models/control-models/index.ts +10 -10
  83. package/src/_models/control-models/poll.control-model.ts +113 -113
  84. package/src/_models/control-models/range-value.control-model.ts +142 -142
  85. package/src/_models/control-models/usage-action.control-model.ts +15 -15
  86. package/src/_models/control-models/usage-data.control-model.ts +20 -20
  87. package/src/_models/data-models/custom-data.data-model.ts +28 -28
  88. package/src/_models/data-models/index.ts +5 -5
  89. package/src/_models/data-models/metadata.data-model.ts +83 -83
  90. package/src/_models/data-models/usage-session.data-model.ts +53 -53
  91. package/src/_models/index.ts +12 -12
  92. package/src/_models/interfaces/error-defaults.interface.ts +11 -11
  93. package/src/_models/interfaces/index.ts +11 -11
  94. package/src/_models/interfaces/location/country-division.interface.ts +7 -7
  95. package/src/_models/interfaces/location/country-iso.interface.ts +21 -21
  96. package/src/_models/interfaces/location/country-phone-code.interface.ts +7 -7
  97. package/src/_models/interfaces/location/division-collection.interface.ts +10 -10
  98. package/src/_models/interfaces/location/division-region-data.interface.ts +8 -8
  99. package/src/_models/interfaces/location/geo-ip-location.interface.ts +26 -26
  100. package/src/_models/interfaces/location/index.ts +10 -10
  101. package/src/_models/interfaces/location/location-coordinates.interface.ts +5 -5
  102. package/src/_models/interfaces/multi-pipe-settings.type.ts +7 -7
  103. package/src/_models/interfaces/paged.interface.ts +11 -11
  104. package/src/_models/interfaces/pipe-transforms.interface.ts +29 -29
  105. package/src/_models/interfaces/random-weight.interface.ts +7 -7
  106. package/src/_models/interfaces/route-settings.interface.ts +11 -11
  107. package/src/_modules/collections.index.ts +2 -2
  108. package/src/_modules/constants.index.ts +2 -2
  109. package/src/_modules/custom-data-module.index.ts +6 -6
  110. package/src/_modules/data-modules.index.ts +9 -9
  111. package/src/_modules/enums.index.ts +2 -2
  112. package/src/_modules/error-module.index.ts +8 -8
  113. package/src/_modules/location.index.ts +15 -15
  114. package/src/_modules/models.index.ts +2 -2
  115. package/src/_modules/shared-service.index.ts +9 -9
  116. package/src/_modules/test-module.index.ts +5 -5
  117. package/src/_modules/usage-module.index.ts +10 -10
  118. package/tsconfig.json +29 -29
  119. package/tslint.json +153 -153
@@ -1,161 +1,161 @@
1
-
2
-
3
-
4
-
5
-
6
-
7
-
8
- import { DynamoFM_AngularMultiPipeAvailable, DynamoFM_MultiPipeAvailable, DynamoFM_Pipe, DynamoFM_allDynamoPipes, DynamoFM_allMultiPipesAvailable } from '../../../_enums';
9
- import { DynamoFM_RangeValue } from '../../../_models';
10
- import { DynamoFM_MultiPipe_Setting } from '../../../_models/interfaces/multi-pipe-settings.type';
11
- import { DynamoFM_pipeTransforms } from '../../constants';
12
-
13
-
14
- export type DynamoFM_MultiPipeAngularPipes = {
15
- [pipeName in DynamoFM_AngularMultiPipeAvailable]: (value: string, ...args: unknown[]) => string;
16
- };
17
-
18
- export const DynamoFM_multiPipeAngularPipes: DynamoFM_MultiPipeAngularPipes = {
19
- [DynamoFM_AngularMultiPipeAvailable.currency]: null,
20
- [DynamoFM_AngularMultiPipeAvailable.date]: null,
21
- [DynamoFM_AngularMultiPipeAvailable.decimal]: null,
22
- [DynamoFM_AngularMultiPipeAvailable.number]: null,
23
- [DynamoFM_AngularMultiPipeAvailable.percent]: null,
24
- };
25
-
26
- export function DynamoFM_multiPipe_pipeTransform(
27
- value: unknown, pipes: DynamoFM_MultiPipe_Setting[]
28
- ): string | number | DynamoFM_RangeValue | any {
29
- /* console.log(
30
- 'applyPipes...',
31
- '\nvalue:', value,
32
- '\npipes:', DynamoFM_clone(pipes)
33
- ); */
34
-
35
- stackPipes(pipes);
36
-
37
- /* console.log('stacked pipes:', DynamoFM_clone(pipes)); */
38
-
39
- for (let i = 0; i < pipes.length; i++) {
40
- const pipe: DynamoFM_MultiPipe_Setting = pipes[i];
41
- /* pipes.forEach((pipe: DynamoFM_MultiPipe_Setting): void => { */
42
- const keys: string[] = Object.keys(pipe);
43
-
44
- if (keys.length !== 1) {
45
- console.warn(
46
- 'DYNAMO WARNING: ' +
47
- '\nMultiPipe: pipeSettings has more than one key...',
48
- '\npipeSettings: ', pipe,
49
- '\n\n',
50
- new Error()
51
- );
52
-
53
- return value;
54
- }
55
-
56
- const pipeName: DynamoFM_MultiPipeAvailable = keys[0] as DynamoFM_MultiPipeAvailable;
57
-
58
- if (!DynamoFM_allMultiPipesAvailable.includes(pipeName as DynamoFM_MultiPipeAvailable)) {
59
- console.warn(
60
- 'DYNAMO WARNING: ' +
61
- '\nMultiPipe: unknown pipe "' + pipeName + '"...',
62
- '\nsorry, but this pipe is not supported by the MultiPipe yet.',
63
- '\navailable pipes are: ' + DynamoFM_allMultiPipesAvailable.join(', '),
64
- '\nthe custom pipe is basically usable for anything, you might try to use that.',
65
- '\n\n',
66
- new Error()
67
- );
68
-
69
- return value;
70
- }
71
-
72
- const pipeArgs: any[] = pipe[pipeName];
73
-
74
- /* console.log(
75
- 'transforming...',
76
- '\npipe:', pipeName,
77
- '\nargs:', pipeArgs,
78
- '\nvalue:', value
79
- ); */
80
-
81
- if (DynamoFM_allDynamoPipes.includes(pipeName as DynamoFM_Pipe)) {
82
- if (pipeArgs?.length) {
83
- value = DynamoFM_pipeTransforms[pipeName](value, ...pipeArgs);
84
- } else {
85
- value = DynamoFM_pipeTransforms[pipeName](value);
86
- }
87
- } else {
88
- if (!DynamoFM_multiPipeAngularPipes[pipeName]) {
89
- console.error(
90
- 'DYNAMO ERROR: ' +
91
- '\nMultiPipe: Angular pipe "' + pipeName + '" is not defined...',
92
- '\nPlease set the pipe in the DynamoFM_multiPipeAngularPipes object.',
93
- '\n\n',
94
- new Error()
95
- );
96
-
97
- return value;
98
- }
99
-
100
- value = DynamoFM_multiPipeAngularPipes[pipeName](value, ...pipeArgs);
101
- }
102
- }
103
-
104
- return value;
105
- }
106
-
107
- /**
108
- * This method stacks the pipes in the pipe settings.
109
- * Developing this funcfion you must know which pipe have multiPipe settings
110
- * and which argument is that
111
- *
112
- * IMPORTANT: the args are starting from the second transform argument!
113
- *
114
- * @param pipes
115
- */
116
- function stackPipes(pipes: DynamoFM_MultiPipe_Setting[]): void {
117
- for (let i = 0; i < pipes.length; i++) {
118
- if (i + 1 < pipes.length) {
119
- const pipe: DynamoFM_MultiPipe_Setting = pipes[i];
120
- const pipeName: DynamoFM_MultiPipeAvailable =
121
- Object.keys(pipe)[0] as DynamoFM_MultiPipeAvailable;
122
-
123
- switch (pipeName) {
124
- case DynamoFM_Pipe.range:
125
- const furtherPipesAfterRange: DynamoFM_MultiPipe_Setting[] = pipes.splice(i + 1);
126
-
127
- if (!(pipe[pipeName] as any[])?.length) {
128
- (pipe[pipeName] as any[]) = [ null, furtherPipesAfterRange ];
129
- } else if ((pipe[pipeName][1] as any[])?.length) {
130
- (pipe[pipeName][1] as any[]).push(...furtherPipesAfterRange);
131
- } else {
132
- (pipe[pipeName][1] as DynamoFM_MultiPipe_Setting[]) = furtherPipesAfterRange;
133
- }
134
- break;
135
-
136
- case DynamoFM_Pipe.smartReplace:
137
- const furtherPipesAfterSR: DynamoFM_MultiPipe_Setting[] = pipes.splice(i + 1);
138
-
139
- if (!(pipe[pipeName] as any[])?.length) {
140
- throw new Error(
141
- 'DYNAMO ERROR: ' +
142
- '\nMultiPipe: SmartReplacePipe has no arguments...' +
143
- '\nSmartReplacePipe needs at least one argument: replaceTo.' +
144
- '\nMaybe you forgot to put the replacerObject in an array?' +
145
- '\n\n'
146
- );
147
- }
148
-
149
- if ((pipe[pipeName][1] as any[])?.length) {
150
- (pipe[pipeName][1] as any[]).push(...furtherPipesAfterSR);
151
- } else {
152
- (pipe[pipeName][1] as DynamoFM_MultiPipe_Setting[]) = furtherPipesAfterSR;
153
- }
154
- break;
155
-
156
- default:
157
- break;
158
- }
159
- }
160
- }
1
+
2
+
3
+
4
+
5
+
6
+
7
+
8
+ import { DynamoFM_AngularMultiPipeAvailable, DynamoFM_MultiPipeAvailable, DynamoFM_Pipe, DynamoFM_allDynamoPipes, DynamoFM_allMultiPipesAvailable } from '../../../_enums';
9
+ import { DynamoFM_RangeValue } from '../../../_models';
10
+ import { DynamoFM_MultiPipe_Setting } from '../../../_models/interfaces/multi-pipe-settings.type';
11
+ import { DynamoFM_pipeTransforms } from '../../constants';
12
+
13
+
14
+ export type DynamoFM_MultiPipeAngularPipes = {
15
+ [pipeName in DynamoFM_AngularMultiPipeAvailable]: (value: string, ...args: unknown[]) => string;
16
+ };
17
+
18
+ export const DynamoFM_multiPipeAngularPipes: DynamoFM_MultiPipeAngularPipes = {
19
+ [DynamoFM_AngularMultiPipeAvailable.currency]: null,
20
+ [DynamoFM_AngularMultiPipeAvailable.date]: null,
21
+ [DynamoFM_AngularMultiPipeAvailable.decimal]: null,
22
+ [DynamoFM_AngularMultiPipeAvailable.number]: null,
23
+ [DynamoFM_AngularMultiPipeAvailable.percent]: null,
24
+ };
25
+
26
+ export function DynamoFM_multiPipe_pipeTransform(
27
+ value: unknown, pipes: DynamoFM_MultiPipe_Setting[]
28
+ ): string | number | DynamoFM_RangeValue | any {
29
+ /* console.log(
30
+ 'applyPipes...',
31
+ '\nvalue:', value,
32
+ '\npipes:', DynamoFM_clone(pipes)
33
+ ); */
34
+
35
+ stackPipes(pipes);
36
+
37
+ /* console.log('stacked pipes:', DynamoFM_clone(pipes)); */
38
+
39
+ for (let i = 0; i < pipes.length; i++) {
40
+ const pipe: DynamoFM_MultiPipe_Setting = pipes[i];
41
+ /* pipes.forEach((pipe: DynamoFM_MultiPipe_Setting): void => { */
42
+ const keys: string[] = Object.keys(pipe);
43
+
44
+ if (keys.length !== 1) {
45
+ console.warn(
46
+ 'DYNAMO WARNING: ' +
47
+ '\nMultiPipe: pipeSettings has more than one key...',
48
+ '\npipeSettings: ', pipe,
49
+ '\n\n',
50
+ new Error()
51
+ );
52
+
53
+ return value;
54
+ }
55
+
56
+ const pipeName: DynamoFM_MultiPipeAvailable = keys[0] as DynamoFM_MultiPipeAvailable;
57
+
58
+ if (!DynamoFM_allMultiPipesAvailable.includes(pipeName as DynamoFM_MultiPipeAvailable)) {
59
+ console.warn(
60
+ 'DYNAMO WARNING: ' +
61
+ '\nMultiPipe: unknown pipe "' + pipeName + '"...',
62
+ '\nsorry, but this pipe is not supported by the MultiPipe yet.',
63
+ '\navailable pipes are: ' + DynamoFM_allMultiPipesAvailable.join(', '),
64
+ '\nthe custom pipe is basically usable for anything, you might try to use that.',
65
+ '\n\n',
66
+ new Error()
67
+ );
68
+
69
+ return value;
70
+ }
71
+
72
+ const pipeArgs: any[] = pipe[pipeName];
73
+
74
+ /* console.log(
75
+ 'transforming...',
76
+ '\npipe:', pipeName,
77
+ '\nargs:', pipeArgs,
78
+ '\nvalue:', value
79
+ ); */
80
+
81
+ if (DynamoFM_allDynamoPipes.includes(pipeName as DynamoFM_Pipe)) {
82
+ if (pipeArgs?.length) {
83
+ value = DynamoFM_pipeTransforms[pipeName](value, ...pipeArgs);
84
+ } else {
85
+ value = DynamoFM_pipeTransforms[pipeName](value);
86
+ }
87
+ } else {
88
+ if (!DynamoFM_multiPipeAngularPipes[pipeName]) {
89
+ console.error(
90
+ 'DYNAMO ERROR: ' +
91
+ '\nMultiPipe: Angular pipe "' + pipeName + '" is not defined...',
92
+ '\nPlease set the pipe in the DynamoFM_multiPipeAngularPipes object.',
93
+ '\n\n',
94
+ new Error()
95
+ );
96
+
97
+ return value;
98
+ }
99
+
100
+ value = DynamoFM_multiPipeAngularPipes[pipeName](value, ...pipeArgs);
101
+ }
102
+ }
103
+
104
+ return value;
105
+ }
106
+
107
+ /**
108
+ * This method stacks the pipes in the pipe settings.
109
+ * Developing this funcfion you must know which pipe have multiPipe settings
110
+ * and which argument is that
111
+ *
112
+ * IMPORTANT: the args are starting from the second transform argument!
113
+ *
114
+ * @param pipes
115
+ */
116
+ function stackPipes(pipes: DynamoFM_MultiPipe_Setting[]): void {
117
+ for (let i = 0; i < pipes.length; i++) {
118
+ if (i + 1 < pipes.length) {
119
+ const pipe: DynamoFM_MultiPipe_Setting = pipes[i];
120
+ const pipeName: DynamoFM_MultiPipeAvailable =
121
+ Object.keys(pipe)[0] as DynamoFM_MultiPipeAvailable;
122
+
123
+ switch (pipeName) {
124
+ case DynamoFM_Pipe.range:
125
+ const furtherPipesAfterRange: DynamoFM_MultiPipe_Setting[] = pipes.splice(i + 1);
126
+
127
+ if (!(pipe[pipeName] as any[])?.length) {
128
+ (pipe[pipeName] as any[]) = [ null, furtherPipesAfterRange ];
129
+ } else if ((pipe[pipeName][1] as any[])?.length) {
130
+ (pipe[pipeName][1] as any[]).push(...furtherPipesAfterRange);
131
+ } else {
132
+ (pipe[pipeName][1] as DynamoFM_MultiPipe_Setting[]) = furtherPipesAfterRange;
133
+ }
134
+ break;
135
+
136
+ case DynamoFM_Pipe.smartReplace:
137
+ const furtherPipesAfterSR: DynamoFM_MultiPipe_Setting[] = pipes.splice(i + 1);
138
+
139
+ if (!(pipe[pipeName] as any[])?.length) {
140
+ throw new Error(
141
+ 'DYNAMO ERROR: ' +
142
+ '\nMultiPipe: SmartReplacePipe has no arguments...' +
143
+ '\nSmartReplacePipe needs at least one argument: replaceTo.' +
144
+ '\nMaybe you forgot to put the replacerObject in an array?' +
145
+ '\n\n'
146
+ );
147
+ }
148
+
149
+ if ((pipe[pipeName][1] as any[])?.length) {
150
+ (pipe[pipeName][1] as any[]).push(...furtherPipesAfterSR);
151
+ } else {
152
+ (pipe[pipeName][1] as DynamoFM_MultiPipe_Setting[]) = furtherPipesAfterSR;
153
+ }
154
+ break;
155
+
156
+ default:
157
+ break;
158
+ }
159
+ }
160
+ }
161
161
  }
@@ -1,9 +1,9 @@
1
-
2
-
3
-
4
-
5
-
6
-
7
- export function DynamoFM_objKey_pipeTransform<Obj_T>(value: Obj_T): string[] {
8
- return value ? Object.keys(value) : [];
9
- }
1
+
2
+
3
+
4
+
5
+
6
+
7
+ export function DynamoFM_objKey_pipeTransform<Obj_T>(value: Obj_T): string[] {
8
+ return value ? Object.keys(value) : [];
9
+ }
@@ -1,94 +1,94 @@
1
-
2
-
3
-
4
-
5
-
6
-
7
-
8
- import { DynamoFM_RangePipe_Setting } from '../../../_enums';
9
- import { DynamoFM_RangeValue } from '../../../_models';
10
- import { DynamoFM_MultiPipe_Setting } from '../../../_models/interfaces/multi-pipe-settings.type';
11
- import { DynamoFM_multiPipe_pipeTransform } from './multi-pipe-pipe.util';
12
-
13
- export function DynamoFM_range_pipeTransform(
14
- value: DynamoFM_RangeValue,
15
- setting: DynamoFM_RangePipe_Setting,
16
- multiPipes?: DynamoFM_MultiPipe_Setting[]
17
- ): string | number | DynamoFM_RangeValue {
18
- if (!checkRangePipeRequirements(value, setting, multiPipes)) {
19
- return value;
20
- }
21
-
22
- switch (setting) {
23
- case DynamoFM_RangePipe_Setting.avg:
24
- case DynamoFM_RangePipe_Setting.average:
25
- return (value.to + value.from) / 2;
26
-
27
- case DynamoFM_RangePipe_Setting.min:
28
- case DynamoFM_RangePipe_Setting.from:
29
- return value.from;
30
-
31
- case DynamoFM_RangePipe_Setting.max:
32
- case DynamoFM_RangePipe_Setting.to:
33
- return value.to;
34
-
35
- case DynamoFM_RangePipe_Setting.both:
36
- case DynamoFM_RangePipe_Setting.fromTo:
37
- if (0 < multiPipes?.length) {
38
- if (value.from === value.to) {
39
- return DynamoFM_multiPipe_pipeTransform(value.from, multiPipes);
40
- } else {
41
- return DynamoFM_multiPipe_pipeTransform(value.from, multiPipes) +
42
- ' - ' +
43
- DynamoFM_multiPipe_pipeTransform(value.to, multiPipes);
44
- }
45
- } else {
46
- return `${value.from} - ${value.to}`;
47
- }
48
-
49
- default:
50
- return value;
51
- }
52
- }
53
-
54
- function checkRangePipeRequirements(
55
- value: DynamoFM_RangeValue,
56
- setting: DynamoFM_RangePipe_Setting | string,
57
- multiPipes?: DynamoFM_MultiPipe_Setting[]
58
- ): boolean {
59
- if (!value?.isRange) {
60
- console.warn(
61
- 'DYNAMO WARNING: ' +
62
- '\nRangePipe: value is not a DynamoFM_RangeValue...',
63
- '\nrange pipe is only usable for DynamoFM_RangeValue.',
64
- '\nvalue: ', value,
65
- '\n\n',
66
- new Error()
67
- );
68
-
69
- return false;
70
- }
71
-
72
- if (!setting) {
73
- setting = DynamoFM_RangePipe_Setting.fromTo;
74
- }
75
-
76
- if (
77
- setting !== DynamoFM_RangePipe_Setting.both &&
78
- setting !== DynamoFM_RangePipe_Setting.fromTo &&
79
- 0 < multiPipes?.length
80
- ) {
81
- console.warn(
82
- 'DYNAMO WARNING: ' +
83
- '\nRangePipe: you can only use further pipes with setting "both"/"from-to"...',
84
- '\nThere is no need to use this special syntax for the other pipes.',
85
- '\nvalue: ', value,
86
- '\nsetting: ', setting,
87
- '\nfurtherPipes: ', multiPipes,
88
- '\n\n',
89
- new Error()
90
- );
91
- }
92
-
93
- return true;
94
- }
1
+
2
+
3
+
4
+
5
+
6
+
7
+
8
+ import { DynamoFM_RangePipe_Setting } from '../../../_enums';
9
+ import { DynamoFM_RangeValue } from '../../../_models';
10
+ import { DynamoFM_MultiPipe_Setting } from '../../../_models/interfaces/multi-pipe-settings.type';
11
+ import { DynamoFM_multiPipe_pipeTransform } from './multi-pipe-pipe.util';
12
+
13
+ export function DynamoFM_range_pipeTransform(
14
+ value: DynamoFM_RangeValue,
15
+ setting: DynamoFM_RangePipe_Setting,
16
+ multiPipes?: DynamoFM_MultiPipe_Setting[]
17
+ ): string | number | DynamoFM_RangeValue {
18
+ if (!checkRangePipeRequirements(value, setting, multiPipes)) {
19
+ return value;
20
+ }
21
+
22
+ switch (setting) {
23
+ case DynamoFM_RangePipe_Setting.avg:
24
+ case DynamoFM_RangePipe_Setting.average:
25
+ return (value.to + value.from) / 2;
26
+
27
+ case DynamoFM_RangePipe_Setting.min:
28
+ case DynamoFM_RangePipe_Setting.from:
29
+ return value.from;
30
+
31
+ case DynamoFM_RangePipe_Setting.max:
32
+ case DynamoFM_RangePipe_Setting.to:
33
+ return value.to;
34
+
35
+ case DynamoFM_RangePipe_Setting.both:
36
+ case DynamoFM_RangePipe_Setting.fromTo:
37
+ if (0 < multiPipes?.length) {
38
+ if (value.from === value.to) {
39
+ return DynamoFM_multiPipe_pipeTransform(value.from, multiPipes);
40
+ } else {
41
+ return DynamoFM_multiPipe_pipeTransform(value.from, multiPipes) +
42
+ ' - ' +
43
+ DynamoFM_multiPipe_pipeTransform(value.to, multiPipes);
44
+ }
45
+ } else {
46
+ return `${value.from} - ${value.to}`;
47
+ }
48
+
49
+ default:
50
+ return value;
51
+ }
52
+ }
53
+
54
+ function checkRangePipeRequirements(
55
+ value: DynamoFM_RangeValue,
56
+ setting: DynamoFM_RangePipe_Setting | string,
57
+ multiPipes?: DynamoFM_MultiPipe_Setting[]
58
+ ): boolean {
59
+ if (!value?.isRange) {
60
+ console.warn(
61
+ 'DYNAMO WARNING: ' +
62
+ '\nRangePipe: value is not a DynamoFM_RangeValue...',
63
+ '\nrange pipe is only usable for DynamoFM_RangeValue.',
64
+ '\nvalue: ', value,
65
+ '\n\n',
66
+ new Error()
67
+ );
68
+
69
+ return false;
70
+ }
71
+
72
+ if (!setting) {
73
+ setting = DynamoFM_RangePipe_Setting.fromTo;
74
+ }
75
+
76
+ if (
77
+ setting !== DynamoFM_RangePipe_Setting.both &&
78
+ setting !== DynamoFM_RangePipe_Setting.fromTo &&
79
+ 0 < multiPipes?.length
80
+ ) {
81
+ console.warn(
82
+ 'DYNAMO WARNING: ' +
83
+ '\nRangePipe: you can only use further pipes with setting "both"/"from-to"...',
84
+ '\nThere is no need to use this special syntax for the other pipes.',
85
+ '\nvalue: ', value,
86
+ '\nsetting: ', setting,
87
+ '\nfurtherPipes: ', multiPipes,
88
+ '\n\n',
89
+ new Error()
90
+ );
91
+ }
92
+
93
+ return true;
94
+ }
@@ -1,18 +1,18 @@
1
-
2
-
3
-
4
-
5
-
6
-
7
-
8
- import { DynamoFM_CountryISO } from '../../../_models';
9
- import { DynamoFM_countryISOs } from '../../constants/courtry-isos.const';
10
-
11
-
12
- export function DynamoFM_region_pipeTransform(countryISO: string): string {
13
- const result = DynamoFM_countryISOs.find(
14
- (iso: DynamoFM_CountryISO): boolean => iso.iso2 === countryISO
15
- )?.region;
16
-
17
- return result ?? countryISO;
18
- }
1
+
2
+
3
+
4
+
5
+
6
+
7
+
8
+ import { DynamoFM_CountryISO } from '../../../_models';
9
+ import { DynamoFM_countryISOs } from '../../constants/courtry-isos.const';
10
+
11
+
12
+ export function DynamoFM_region_pipeTransform(countryISO: string): string {
13
+ const result = DynamoFM_countryISOs.find(
14
+ (iso: DynamoFM_CountryISO): boolean => iso.iso2 === countryISO
15
+ )?.region;
16
+
17
+ return result ?? countryISO;
18
+ }
@@ -1,11 +1,11 @@
1
-
2
-
3
-
4
-
5
-
6
-
7
-
8
-
9
- export function DynamoFM_replace_pipeTransform(value: string, from: string, to: string): string {
10
- return value?.replaceAll(from, to) ?? value;
11
- }
1
+
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+ export function DynamoFM_replace_pipeTransform(value: string, from: string, to: string): string {
10
+ return value?.replaceAll(from, to) ?? value;
11
+ }
@@ -1,20 +1,20 @@
1
-
2
-
3
-
4
-
5
-
6
-
7
-
8
- import { DynamoFM_RangeValue } from '../../../_models';
9
-
10
- export function DynamoFM_slider_pipeTransform(
11
- value: number | DynamoFM_RangeValue<number> | string,
12
- ): string {
13
- if (value instanceof DynamoFM_RangeValue /* (value as DynamoFM_RangeValue).isRange */) {
14
- return value.toString();
15
- } else if (typeof value === 'number') {
16
- return `${value}`;
17
- } else {
18
- return value;
19
- }
20
- }
1
+
2
+
3
+
4
+
5
+
6
+
7
+
8
+ import { DynamoFM_RangeValue } from '../../../_models';
9
+
10
+ export function DynamoFM_slider_pipeTransform(
11
+ value: number | DynamoFM_RangeValue<number> | string,
12
+ ): string {
13
+ if (value instanceof DynamoFM_RangeValue /* (value as DynamoFM_RangeValue).isRange */) {
14
+ return value.toString();
15
+ } else if (typeof value === 'number') {
16
+ return `${value}`;
17
+ } else {
18
+ return value;
19
+ }
20
+ }