@futdevpro/fsm-dynamo 1.9.9 → 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.
- package/.github/workflows/main.yml +196 -0
- package/HOWTO.md +15 -15
- package/README.md +17 -17
- package/build/_collections/constants/country-divisions.const.d.ts +1 -1
- package/build/_collections/constants/country-divisions.const.d.ts.map +1 -1
- package/build/_collections/constants/country-divisions.const.js +2 -2
- package/build/_collections/constants/country-divisions.const.js.map +1 -1
- package/build/_collections/constants/courtry-isos.const.d.ts +1 -1
- package/build/_collections/constants/courtry-isos.const.d.ts.map +1 -1
- package/build/_collections/constants/courtry-isos.const.js +2 -2
- package/build/_collections/constants/courtry-isos.const.js.map +1 -1
- package/build/_collections/constants/error-defaults.const.d.ts +1 -1
- package/build/_collections/constants/error-defaults.const.d.ts.map +1 -1
- package/build/_collections/constants/module-settings/usage-module-settings.const.js +1 -1
- package/build/_collections/constants/pipe-transforms.const.js +12 -12
- package/build/_collections/constants/pipe-transforms.const.js.map +1 -1
- package/build/_collections/utils/pipe-transforms/division-pipe.util.js +1 -1
- package/build/_collections/utils/pipe-transforms/division-pipe.util.js.map +1 -1
- package/build/_collections/utils/pipe-transforms/list-pipe.util.d.ts.map +1 -1
- package/build/_collections/utils/pipe-transforms/list-pipe.util.js.map +1 -1
- package/build/_collections/utils/pipe-transforms/range-pipe.util.d.ts +2 -2
- package/build/_collections/utils/pipe-transforms/range-pipe.util.d.ts.map +1 -1
- package/build/_collections/utils/pipe-transforms/range-pipe.util.js +11 -11
- package/build/_collections/utils/pipe-transforms/range-pipe.util.js.map +1 -1
- package/build/_collections/utils/regions.util.d.ts.map +1 -1
- package/build/_collections/utils/regions.util.js +3 -0
- package/build/_collections/utils/regions.util.js.map +1 -1
- package/build/_enums/range-pipe-setting.enum.d.ts +1 -1
- package/build/_enums/range-pipe-setting.enum.d.ts.map +1 -1
- package/build/_enums/range-pipe-setting.enum.js +12 -12
- package/build/_enums/range-pipe-setting.enum.js.map +1 -1
- package/build/_models/control-models/error.control-model.js +1 -1
- package/build/_models/control-models/error.control-model.js.map +1 -1
- package/build/_models/control-models/error.control-model.spec.js +25 -6
- package/build/_models/control-models/error.control-model.spec.js.map +1 -1
- package/build/_models/interfaces/index.d.ts +3 -0
- package/build/_models/interfaces/index.d.ts.map +1 -1
- package/build/_models/interfaces/index.js +3 -0
- package/build/_models/interfaces/index.js.map +1 -1
- package/build/_models/interfaces/pipe-transforms.interface.d.ts +2 -2
- package/build/_models/interfaces/pipe-transforms.interface.d.ts.map +1 -1
- package/futdevpro-fsm-dynamo-01.09.12.tgz +0 -0
- package/nodemon.json +11 -11
- package/package.json +151 -151
- package/src/_collections/assets/location/country-codes-ISO-3166.json +3239 -3239
- package/src/_collections/assets/location/country-divisions-ISO-3166-all-list.json +19035 -19035
- package/src/_collections/assets/location/country-divisions-ISO-3166.json +4993 -4993
- package/src/_collections/assets/location/country-phone-codes.json +1203 -1203
- package/src/_collections/constants/country-divisions.const.ts +9 -9
- package/src/_collections/constants/courtry-isos.const.ts +8 -8
- package/src/_collections/constants/error-defaults.const.ts +11 -11
- package/src/_collections/constants/index.ts +15 -15
- package/src/_collections/constants/module-settings/custom-data-module-settings.const.ts +15 -15
- package/src/_collections/constants/module-settings/index.ts +8 -8
- package/src/_collections/constants/module-settings/test-module-settings.const.ts +19 -19
- package/src/_collections/constants/module-settings/usage-module-settings.const.ts +19 -19
- package/src/_collections/constants/pipe-transforms.const.ts +35 -35
- package/src/_collections/constants/times.const.ts +8 -8
- package/src/_collections/index.ts +6 -6
- package/src/_collections/utils/array.util.spec.ts +39 -39
- package/src/_collections/utils/array.util.ts +137 -137
- package/src/_collections/utils/index.ts +18 -18
- package/src/_collections/utils/location.util.ts +55 -55
- package/src/_collections/utils/log.util.ts +239 -239
- package/src/_collections/utils/math/box-bounds.util.ts +85 -85
- package/src/_collections/utils/math/index.ts +5 -5
- package/src/_collections/utils/math/math.util.ts +53 -53
- package/src/_collections/utils/math/random.util.ts +80 -80
- package/src/_collections/utils/math/trigonometry.util.ts +73 -73
- package/src/_collections/utils/math/vector2.util.ts +197 -197
- package/src/_collections/utils/pipe-transforms/country-pipe.util.ts +18 -18
- package/src/_collections/utils/pipe-transforms/custom-pipe.util.ts +9 -9
- package/src/_collections/utils/pipe-transforms/division-pipe.util.ts +20 -20
- package/src/_collections/utils/pipe-transforms/index.ts +15 -15
- package/src/_collections/utils/pipe-transforms/list-pipe.util.ts +10 -14
- package/src/_collections/utils/pipe-transforms/multi-pipe-pipe.util.ts +160 -160
- package/src/_collections/utils/pipe-transforms/obj-key-pipe.util.ts +9 -9
- package/src/_collections/utils/pipe-transforms/range-pipe.util.ts +94 -94
- package/src/_collections/utils/pipe-transforms/region-pipe.util.ts +18 -18
- package/src/_collections/utils/pipe-transforms/replace-pipe.util.ts +11 -11
- package/src/_collections/utils/pipe-transforms/slider-pipe.util.ts +20 -20
- package/src/_collections/utils/pipe-transforms/smart-replace-pipe.util.ts +71 -71
- package/src/_collections/utils/regex/index.ts +4 -4
- package/src/_collections/utils/regex/password-regex.util.ts +52 -52
- package/src/_collections/utils/regex/regex.util.ts +6 -6
- package/src/_collections/utils/regex/username-regex.util.ts +33 -33
- package/src/_collections/utils/regions.util.ts +100 -97
- package/src/_collections/utils/round-list.util.ts +44 -44
- package/src/_collections/utils/shared.static-service.ts +177 -177
- package/src/_collections/utils/time.util.spec.ts +50 -50
- package/src/_collections/utils/time.util.ts +219 -219
- package/src/_collections/utils/type-cloning-facility.util.ts +121 -121
- package/src/_collections/utils/utilities.util.ts +130 -130
- package/src/_enums/basic-property-type.enum.ts +9 -9
- package/src/_enums/data-model-type.enum.ts +13 -13
- package/src/_enums/day-of-week.enum.ts +28 -28
- package/src/_enums/error-level.enum.ts +17 -17
- package/src/_enums/index.ts +16 -16
- package/src/_enums/location/index.ts +3 -3
- package/src/_enums/location/region.enum.ts +9 -9
- package/src/_enums/location/sub-region.enum.ts +26 -26
- package/src/_enums/location/subdivision-region-type.enum.ts +44 -44
- package/src/_enums/log-style.enum.ts +30 -30
- package/src/_enums/month.enum.ts +16 -16
- package/src/_enums/pipe.enum.ts +45 -45
- package/src/_enums/range-pipe-setting.enum.ts +11 -11
- package/src/_enums/time/day-of-week.enum.ts +28 -28
- package/src/_enums/time/index.ts +3 -3
- package/src/_enums/time/month.enum.ts +16 -16
- package/src/_enums/time/relative-date.enum.ts +13 -13
- package/src/_models/control-models/daily-usage-data.control-model.ts +21 -21
- package/src/_models/control-models/data-model-params.control-model.ts +39 -39
- package/src/_models/control-models/data-property-params.control-model.ts +106 -106
- package/src/_models/control-models/error.control-model.spec.ts +753 -716
- package/src/_models/control-models/error.control-model.ts +722 -722
- package/src/_models/control-models/index.ts +10 -10
- package/src/_models/control-models/poll.control-model.ts +113 -113
- package/src/_models/control-models/range-value.control-model.ts +142 -142
- package/src/_models/control-models/usage-action.control-model.ts +15 -15
- package/src/_models/control-models/usage-data.control-model.ts +20 -20
- package/src/_models/data-models/custom-data.data-model.ts +28 -28
- package/src/_models/data-models/index.ts +5 -5
- package/src/_models/data-models/metadata.data-model.ts +83 -83
- package/src/_models/data-models/usage-session.data-model.ts +53 -53
- package/src/_models/index.ts +12 -12
- package/src/_models/interfaces/error-defaults.interface.ts +11 -11
- package/src/_models/interfaces/index.ts +11 -8
- package/src/_models/interfaces/location/country-division.interface.ts +7 -7
- package/src/_models/interfaces/location/country-iso.interface.ts +21 -21
- package/src/_models/interfaces/location/country-phone-code.interface.ts +7 -7
- package/src/_models/interfaces/location/division-collection.interface.ts +10 -10
- package/src/_models/interfaces/location/division-region-data.interface.ts +8 -8
- package/src/_models/interfaces/location/geo-ip-location.interface.ts +26 -26
- package/src/_models/interfaces/location/index.ts +10 -10
- package/src/_models/interfaces/location/location-coordinates.interface.ts +5 -5
- package/src/_models/interfaces/multi-pipe-settings.type.ts +7 -7
- package/src/_models/interfaces/paged.interface.ts +11 -11
- package/src/_models/interfaces/pipe-transforms.interface.ts +29 -29
- package/src/_models/interfaces/random-weight.interface.ts +7 -7
- package/src/_models/interfaces/route-settings.interface.ts +11 -11
- package/src/_modules/collections.index.ts +2 -2
- package/src/_modules/constants.index.ts +2 -2
- package/src/_modules/custom-data-module.index.ts +6 -6
- package/src/_modules/data-modules.index.ts +9 -9
- package/src/_modules/enums.index.ts +2 -2
- package/src/_modules/error-module.index.ts +8 -8
- package/src/_modules/location.index.ts +15 -15
- package/src/_modules/models.index.ts +2 -2
- package/src/_modules/shared-service.index.ts +9 -9
- package/src/_modules/test-module.index.ts +5 -5
- package/src/_modules/usage-module.index.ts +10 -10
- package/tsconfig.json +29 -29
- package/tslint.json +153 -153
- package/build/_enums/region.enum.d.ts +0 -8
- package/build/_enums/region.enum.d.ts.map +0 -1
- package/build/_enums/region.enum.js +0 -12
- package/build/_enums/region.enum.js.map +0 -1
- package/build/_enums/relative-date.enum.d.ts +0 -9
- package/build/_enums/relative-date.enum.d.ts.map +0 -1
- package/build/_enums/relative-date.enum.js +0 -13
- package/build/_enums/relative-date.enum.js.map +0 -1
- package/build/_enums/sub-region.enum.d.ts +0 -20
- package/build/_enums/sub-region.enum.d.ts.map +0 -1
- package/build/_enums/sub-region.enum.js +0 -24
- package/build/_enums/sub-region.enum.js.map +0 -1
- package/build/_enums/subdivision-region-type.enum.d.ts +0 -41
- package/build/_enums/subdivision-region-type.enum.d.ts.map +0 -1
- package/build/_enums/subdivision-region-type.enum.js +0 -46
- package/build/_enums/subdivision-region-type.enum.js.map +0 -1
- package/src/_enums/region.enum.ts +0 -9
- package/src/_enums/relative-date.enum.ts +0 -13
- package/src/_enums/sub-region.enum.ts +0 -26
- package/src/_enums/subdivision-region-type.enum.ts +0 -44
|
@@ -1,177 +1,177 @@
|
|
|
1
|
-
|
|
2
|
-
import { DynamoFM_clone } from './utilities.util';
|
|
3
|
-
|
|
4
|
-
export type DFM_Shared = DynamoFM_Shared;
|
|
5
|
-
export class DynamoFM_Shared {
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* returns remapped object list by path list
|
|
9
|
-
* @param objList object list to map
|
|
10
|
-
* @param paths string list of path etc.:
|
|
11
|
-
* ```ts
|
|
12
|
-
* [ [ 'first', 'sub', 'label' ], [ 'first', 'dif', 'name' ] ]
|
|
13
|
-
* ```
|
|
14
|
-
* will be...
|
|
15
|
-
* from
|
|
16
|
-
* ```ts
|
|
17
|
-
* {
|
|
18
|
-
* first: {
|
|
19
|
-
* sub: {
|
|
20
|
-
* label: 'vlmi'
|
|
21
|
-
* },
|
|
22
|
-
* dif: {
|
|
23
|
-
* name: 'asd'
|
|
24
|
-
* }
|
|
25
|
-
* }
|
|
26
|
-
* }[]
|
|
27
|
-
* ```
|
|
28
|
-
* to
|
|
29
|
-
* ```
|
|
30
|
-
* { label: 'vlmi', name: 'asd' }[]
|
|
31
|
-
* ```
|
|
32
|
-
* @returns remapped object list (the final obj will use the deepest keys)
|
|
33
|
-
*/
|
|
34
|
-
static mapObjList(objList: object[], paths: string[][]): object[] {
|
|
35
|
-
let newObjList = [...objList];
|
|
36
|
-
|
|
37
|
-
newObjList = newObjList.map((obj): any => {
|
|
38
|
-
const newObj = {};
|
|
39
|
-
|
|
40
|
-
paths.forEach((path: string[]): void => {
|
|
41
|
-
newObj[path[path.length - 1]] = this.getNestedData(obj, path);
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
return newObj;
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
return newObjList;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* returns nested value from object
|
|
52
|
-
* @param parentObj data source object
|
|
53
|
-
* @param nestedDataKeys path of value as string list
|
|
54
|
-
* etc.: ['nestLvl1', 'nestLvl2', 'nestLvl3'] as parentObj.nestLvl1.nestLvl2.nestLvl3
|
|
55
|
-
* @returns data from object by path
|
|
56
|
-
*/
|
|
57
|
-
static getNestedData(parentObj: object, nestedDataKeys: string[]): any {
|
|
58
|
-
let newData = DynamoFM_clone(parentObj); // {...parentObj};
|
|
59
|
-
|
|
60
|
-
nestedDataKeys.forEach((dk: string): void => {
|
|
61
|
-
if (newData) {
|
|
62
|
-
newData = newData[dk];
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
return newData;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* recursive function that nests data
|
|
71
|
-
* @param newData the object that that is needed to be updated
|
|
72
|
-
* @param nestKeys the path where the data should be updated
|
|
73
|
-
* @param dataToSet the actual value that will be setted
|
|
74
|
-
* @returns modified data
|
|
75
|
-
*/
|
|
76
|
-
static nestData(parentObj: object, nestKeys: string[], dataToSet: any): object {
|
|
77
|
-
const newData = DynamoFM_clone(parentObj); // {...parentObj};
|
|
78
|
-
|
|
79
|
-
if (nestKeys.length > 1) {
|
|
80
|
-
const keys = [...nestKeys];
|
|
81
|
-
const nextNestKey = keys.shift();
|
|
82
|
-
|
|
83
|
-
newData[nextNestKey] = this.nestData(newData[nextNestKey], keys, dataToSet);
|
|
84
|
-
} else {
|
|
85
|
-
newData[nestKeys[0]] = dataToSet;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return newData;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* recursive function that adds to nested data
|
|
93
|
-
* @param newData the object that that is needed to be updated
|
|
94
|
-
* @param nestKeys the path where the data should be updated
|
|
95
|
-
* @param dataToAdd the actual value that will be setted
|
|
96
|
-
* @returns modified data
|
|
97
|
-
*/
|
|
98
|
-
static addToNestedData(parentObj: object, nestKeys: string[], dataToAdd: any): object {
|
|
99
|
-
const newData = DynamoFM_clone(parentObj); // {...parentObj};
|
|
100
|
-
|
|
101
|
-
if (nestKeys.length > 1) {
|
|
102
|
-
const keys = [...nestKeys];
|
|
103
|
-
const nextNestKey = keys.shift();
|
|
104
|
-
|
|
105
|
-
newData[nextNestKey] = this.addToNestedData(newData[nextNestKey], keys, dataToAdd);
|
|
106
|
-
} else {
|
|
107
|
-
newData[nestKeys[0]] += dataToAdd;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
return newData;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* recursive function that pushes to nested data
|
|
115
|
-
* @param newData the object that that is needed to be updated
|
|
116
|
-
* @param nestKeys the path where the data should be updated
|
|
117
|
-
* @param dataToPush the actual value that will be setted
|
|
118
|
-
* @returns modified data
|
|
119
|
-
*/
|
|
120
|
-
static pushToNestedData(parentObj: object, nestKeys: string[], dataToPush: any): object {
|
|
121
|
-
const newData = DynamoFM_clone(parentObj); // {...parentObj};
|
|
122
|
-
|
|
123
|
-
if (nestKeys.length > 1) {
|
|
124
|
-
const keys = [...nestKeys];
|
|
125
|
-
const nextNestKey = keys.shift();
|
|
126
|
-
|
|
127
|
-
newData[nextNestKey] = this.pushToNestedData(newData[nextNestKey], keys, dataToPush);
|
|
128
|
-
} else {
|
|
129
|
-
if (Array.isArray(newData[nestKeys[0]])) {
|
|
130
|
-
newData[nestKeys[0]].push(dataToPush);
|
|
131
|
-
} else {
|
|
132
|
-
newData[nestKeys[0]] = [dataToPush];
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
return newData;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* recursive function that nests data on recursive data structure etc.: xData: { ..., 'nestedListKey': xData[] }
|
|
141
|
-
* @param newData the object that that is needed to be updated
|
|
142
|
-
* @param nestedListKey the location of nested dataList
|
|
143
|
-
* @param nestIndexes path to the subject ect.: xData.listKey[1].listKey[4].listKey[0] will be [1, 4, 0]
|
|
144
|
-
* @param dataToSet the actual value that will be setted on location
|
|
145
|
-
* @returns modified data
|
|
146
|
-
*/
|
|
147
|
-
static nestRecursiveListedData<T>(
|
|
148
|
-
parentObj: T,
|
|
149
|
-
nestedListKey: string,
|
|
150
|
-
nestIndexes: number[],
|
|
151
|
-
dataToSet: any
|
|
152
|
-
): T {
|
|
153
|
-
const newData = DynamoFM_clone(parentObj); // parentObj; // {...parentObj};
|
|
154
|
-
|
|
155
|
-
if (nestIndexes.length > 1) {
|
|
156
|
-
const indexes = [...nestIndexes];
|
|
157
|
-
const nextLevelKey = indexes.shift();
|
|
158
|
-
|
|
159
|
-
newData[nestedListKey][nextLevelKey] = this.nestRecursiveListedData(
|
|
160
|
-
newData[nestedListKey][nextLevelKey], nestedListKey, indexes, dataToSet
|
|
161
|
-
);
|
|
162
|
-
} else {
|
|
163
|
-
newData[nestedListKey][nestIndexes[0]] = dataToSet;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
return newData;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
static addMetadataToSchema(schema: any): any {
|
|
170
|
-
schema.__created = { type: Date };
|
|
171
|
-
schema.__createdBy = { type: String };
|
|
172
|
-
schema.__lastModified = { type: Date };
|
|
173
|
-
schema.__lastModifiedBy = { type: String };
|
|
174
|
-
|
|
175
|
-
return schema;
|
|
176
|
-
}
|
|
177
|
-
}
|
|
1
|
+
|
|
2
|
+
import { DynamoFM_clone } from './utilities.util';
|
|
3
|
+
|
|
4
|
+
export type DFM_Shared = DynamoFM_Shared;
|
|
5
|
+
export class DynamoFM_Shared {
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* returns remapped object list by path list
|
|
9
|
+
* @param objList object list to map
|
|
10
|
+
* @param paths string list of path etc.:
|
|
11
|
+
* ```ts
|
|
12
|
+
* [ [ 'first', 'sub', 'label' ], [ 'first', 'dif', 'name' ] ]
|
|
13
|
+
* ```
|
|
14
|
+
* will be...
|
|
15
|
+
* from
|
|
16
|
+
* ```ts
|
|
17
|
+
* {
|
|
18
|
+
* first: {
|
|
19
|
+
* sub: {
|
|
20
|
+
* label: 'vlmi'
|
|
21
|
+
* },
|
|
22
|
+
* dif: {
|
|
23
|
+
* name: 'asd'
|
|
24
|
+
* }
|
|
25
|
+
* }
|
|
26
|
+
* }[]
|
|
27
|
+
* ```
|
|
28
|
+
* to
|
|
29
|
+
* ```
|
|
30
|
+
* { label: 'vlmi', name: 'asd' }[]
|
|
31
|
+
* ```
|
|
32
|
+
* @returns remapped object list (the final obj will use the deepest keys)
|
|
33
|
+
*/
|
|
34
|
+
static mapObjList(objList: object[], paths: string[][]): object[] {
|
|
35
|
+
let newObjList = [...objList];
|
|
36
|
+
|
|
37
|
+
newObjList = newObjList.map((obj): any => {
|
|
38
|
+
const newObj = {};
|
|
39
|
+
|
|
40
|
+
paths.forEach((path: string[]): void => {
|
|
41
|
+
newObj[path[path.length - 1]] = this.getNestedData(obj, path);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
return newObj;
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
return newObjList;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* returns nested value from object
|
|
52
|
+
* @param parentObj data source object
|
|
53
|
+
* @param nestedDataKeys path of value as string list
|
|
54
|
+
* etc.: ['nestLvl1', 'nestLvl2', 'nestLvl3'] as parentObj.nestLvl1.nestLvl2.nestLvl3
|
|
55
|
+
* @returns data from object by path
|
|
56
|
+
*/
|
|
57
|
+
static getNestedData(parentObj: object, nestedDataKeys: string[]): any {
|
|
58
|
+
let newData = DynamoFM_clone(parentObj); // {...parentObj};
|
|
59
|
+
|
|
60
|
+
nestedDataKeys.forEach((dk: string): void => {
|
|
61
|
+
if (newData) {
|
|
62
|
+
newData = newData[dk];
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
return newData;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* recursive function that nests data
|
|
71
|
+
* @param newData the object that that is needed to be updated
|
|
72
|
+
* @param nestKeys the path where the data should be updated
|
|
73
|
+
* @param dataToSet the actual value that will be setted
|
|
74
|
+
* @returns modified data
|
|
75
|
+
*/
|
|
76
|
+
static nestData(parentObj: object, nestKeys: string[], dataToSet: any): object {
|
|
77
|
+
const newData = DynamoFM_clone(parentObj); // {...parentObj};
|
|
78
|
+
|
|
79
|
+
if (nestKeys.length > 1) {
|
|
80
|
+
const keys = [...nestKeys];
|
|
81
|
+
const nextNestKey = keys.shift();
|
|
82
|
+
|
|
83
|
+
newData[nextNestKey] = this.nestData(newData[nextNestKey], keys, dataToSet);
|
|
84
|
+
} else {
|
|
85
|
+
newData[nestKeys[0]] = dataToSet;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return newData;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* recursive function that adds to nested data
|
|
93
|
+
* @param newData the object that that is needed to be updated
|
|
94
|
+
* @param nestKeys the path where the data should be updated
|
|
95
|
+
* @param dataToAdd the actual value that will be setted
|
|
96
|
+
* @returns modified data
|
|
97
|
+
*/
|
|
98
|
+
static addToNestedData(parentObj: object, nestKeys: string[], dataToAdd: any): object {
|
|
99
|
+
const newData = DynamoFM_clone(parentObj); // {...parentObj};
|
|
100
|
+
|
|
101
|
+
if (nestKeys.length > 1) {
|
|
102
|
+
const keys = [...nestKeys];
|
|
103
|
+
const nextNestKey = keys.shift();
|
|
104
|
+
|
|
105
|
+
newData[nextNestKey] = this.addToNestedData(newData[nextNestKey], keys, dataToAdd);
|
|
106
|
+
} else {
|
|
107
|
+
newData[nestKeys[0]] += dataToAdd;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return newData;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* recursive function that pushes to nested data
|
|
115
|
+
* @param newData the object that that is needed to be updated
|
|
116
|
+
* @param nestKeys the path where the data should be updated
|
|
117
|
+
* @param dataToPush the actual value that will be setted
|
|
118
|
+
* @returns modified data
|
|
119
|
+
*/
|
|
120
|
+
static pushToNestedData(parentObj: object, nestKeys: string[], dataToPush: any): object {
|
|
121
|
+
const newData = DynamoFM_clone(parentObj); // {...parentObj};
|
|
122
|
+
|
|
123
|
+
if (nestKeys.length > 1) {
|
|
124
|
+
const keys = [...nestKeys];
|
|
125
|
+
const nextNestKey = keys.shift();
|
|
126
|
+
|
|
127
|
+
newData[nextNestKey] = this.pushToNestedData(newData[nextNestKey], keys, dataToPush);
|
|
128
|
+
} else {
|
|
129
|
+
if (Array.isArray(newData[nestKeys[0]])) {
|
|
130
|
+
newData[nestKeys[0]].push(dataToPush);
|
|
131
|
+
} else {
|
|
132
|
+
newData[nestKeys[0]] = [dataToPush];
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return newData;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* recursive function that nests data on recursive data structure etc.: xData: { ..., 'nestedListKey': xData[] }
|
|
141
|
+
* @param newData the object that that is needed to be updated
|
|
142
|
+
* @param nestedListKey the location of nested dataList
|
|
143
|
+
* @param nestIndexes path to the subject ect.: xData.listKey[1].listKey[4].listKey[0] will be [1, 4, 0]
|
|
144
|
+
* @param dataToSet the actual value that will be setted on location
|
|
145
|
+
* @returns modified data
|
|
146
|
+
*/
|
|
147
|
+
static nestRecursiveListedData<T>(
|
|
148
|
+
parentObj: T,
|
|
149
|
+
nestedListKey: string,
|
|
150
|
+
nestIndexes: number[],
|
|
151
|
+
dataToSet: any
|
|
152
|
+
): T {
|
|
153
|
+
const newData = DynamoFM_clone(parentObj); // parentObj; // {...parentObj};
|
|
154
|
+
|
|
155
|
+
if (nestIndexes.length > 1) {
|
|
156
|
+
const indexes = [...nestIndexes];
|
|
157
|
+
const nextLevelKey = indexes.shift();
|
|
158
|
+
|
|
159
|
+
newData[nestedListKey][nextLevelKey] = this.nestRecursiveListedData(
|
|
160
|
+
newData[nestedListKey][nextLevelKey], nestedListKey, indexes, dataToSet
|
|
161
|
+
);
|
|
162
|
+
} else {
|
|
163
|
+
newData[nestedListKey][nestIndexes[0]] = dataToSet;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return newData;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
static addMetadataToSchema(schema: any): any {
|
|
170
|
+
schema.__created = { type: Date };
|
|
171
|
+
schema.__createdBy = { type: String };
|
|
172
|
+
schema.__lastModified = { type: Date };
|
|
173
|
+
schema.__lastModifiedBy = { type: String };
|
|
174
|
+
|
|
175
|
+
return schema;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
|
|
2
|
-
import { DynamoFM_LogStyle } from '../../_enums';
|
|
3
|
-
import { DynamoFM_Log } from './log.util';
|
|
4
|
-
import { DynamoFM_Time } from './time.util';
|
|
5
|
-
|
|
6
|
-
describe('DynamoFM_Time', () => {
|
|
7
|
-
xit(DynamoFM_Log.addStyle('tenYearsAgo', [DynamoFM_LogStyle.yellow]) +' should return correct date', () => {
|
|
8
|
-
const date = DynamoFM_Time.tenYearsAgo(new Date('2021-01-01'));
|
|
9
|
-
const expected = new Date('2011-01-01');
|
|
10
|
-
|
|
11
|
-
expect(date).toEqual(expected);
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
xit(DynamoFM_Log.addStyle('oneYearAgo', [DynamoFM_LogStyle.yellow]) +' should return correct date', () => {
|
|
15
|
-
const date = DynamoFM_Time.oneYearAgo(new Date('2021-01-01'));
|
|
16
|
-
const expected = new Date('2020-01-01');
|
|
17
|
-
|
|
18
|
-
expect(date).toEqual(expected);
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
xit(DynamoFM_Log.addStyle('oneMonthAgo', [DynamoFM_LogStyle.yellow]) +' should return correct date', () => {
|
|
22
|
-
const date = DynamoFM_Time.oneMonthAgo(new Date('2021-01-01'));
|
|
23
|
-
const expected = new Date('2020-12-01');
|
|
24
|
-
|
|
25
|
-
expect(date).toEqual(expected);
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it(DynamoFM_Log.addStyle('oneWeekAgo', [DynamoFM_LogStyle.yellow]) +' should return correct date', () => {
|
|
29
|
-
const date = DynamoFM_Time.oneWeekAgo(new Date('2021-01-01'));
|
|
30
|
-
const expected = new Date('2020-12-25');
|
|
31
|
-
|
|
32
|
-
expect(date).toEqual(expected);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it(DynamoFM_Log.addStyle('oneDayAgo', [DynamoFM_LogStyle.yellow]) +' should return correct date', () => {
|
|
36
|
-
const date = DynamoFM_Time.oneDayAgo(new Date('2021-01-01'));
|
|
37
|
-
const expected = new Date('2020-12-31');
|
|
38
|
-
|
|
39
|
-
expect(date).toEqual(expected);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it(DynamoFM_Log.addStyle('oneHourAgo', [DynamoFM_LogStyle.yellow]) +' should return correct date', () => {
|
|
43
|
-
const date = DynamoFM_Time.oneHourAgo(new Date('2021-01-01T00:00:00'));
|
|
44
|
-
const expected = new Date('2020-12-31T23:00:00');
|
|
45
|
-
|
|
46
|
-
expect(date).toEqual(expected);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
});
|
|
1
|
+
|
|
2
|
+
import { DynamoFM_LogStyle } from '../../_enums';
|
|
3
|
+
import { DynamoFM_Log } from './log.util';
|
|
4
|
+
import { DynamoFM_Time } from './time.util';
|
|
5
|
+
|
|
6
|
+
describe('DynamoFM_Time', () => {
|
|
7
|
+
xit(DynamoFM_Log.addStyle('tenYearsAgo', [DynamoFM_LogStyle.yellow]) +' should return correct date', () => {
|
|
8
|
+
const date = DynamoFM_Time.tenYearsAgo(new Date('2021-01-01'));
|
|
9
|
+
const expected = new Date('2011-01-01');
|
|
10
|
+
|
|
11
|
+
expect(date).toEqual(expected);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
xit(DynamoFM_Log.addStyle('oneYearAgo', [DynamoFM_LogStyle.yellow]) +' should return correct date', () => {
|
|
15
|
+
const date = DynamoFM_Time.oneYearAgo(new Date('2021-01-01'));
|
|
16
|
+
const expected = new Date('2020-01-01');
|
|
17
|
+
|
|
18
|
+
expect(date).toEqual(expected);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
xit(DynamoFM_Log.addStyle('oneMonthAgo', [DynamoFM_LogStyle.yellow]) +' should return correct date', () => {
|
|
22
|
+
const date = DynamoFM_Time.oneMonthAgo(new Date('2021-01-01'));
|
|
23
|
+
const expected = new Date('2020-12-01');
|
|
24
|
+
|
|
25
|
+
expect(date).toEqual(expected);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it(DynamoFM_Log.addStyle('oneWeekAgo', [DynamoFM_LogStyle.yellow]) +' should return correct date', () => {
|
|
29
|
+
const date = DynamoFM_Time.oneWeekAgo(new Date('2021-01-01'));
|
|
30
|
+
const expected = new Date('2020-12-25');
|
|
31
|
+
|
|
32
|
+
expect(date).toEqual(expected);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it(DynamoFM_Log.addStyle('oneDayAgo', [DynamoFM_LogStyle.yellow]) +' should return correct date', () => {
|
|
36
|
+
const date = DynamoFM_Time.oneDayAgo(new Date('2021-01-01'));
|
|
37
|
+
const expected = new Date('2020-12-31');
|
|
38
|
+
|
|
39
|
+
expect(date).toEqual(expected);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it(DynamoFM_Log.addStyle('oneHourAgo', [DynamoFM_LogStyle.yellow]) +' should return correct date', () => {
|
|
43
|
+
const date = DynamoFM_Time.oneHourAgo(new Date('2021-01-01T00:00:00'));
|
|
44
|
+
const expected = new Date('2020-12-31T23:00:00');
|
|
45
|
+
|
|
46
|
+
expect(date).toEqual(expected);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
});
|