@zeniai/client-epic-state 4.10.5 → 4.10.7
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.
|
@@ -3,7 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.toAllowedValueWithCode = exports.isAllowedValueWithCodeOptionalPayload = exports.isAllowedValueWithCodePayload = void 0;
|
|
4
4
|
function isAllowedValueWithCodePayload(allowedValueWithCodePayload // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
5
5
|
) {
|
|
6
|
-
return ((allowedValueWithCodePayload
|
|
6
|
+
return (isAllowedValueWithCodeOptionalPayload(allowedValueWithCodePayload) &&
|
|
7
|
+
allowedValueWithCodePayload.code != null &&
|
|
8
|
+
allowedValueWithCodePayload.name != null);
|
|
7
9
|
}
|
|
8
10
|
exports.isAllowedValueWithCodePayload = isAllowedValueWithCodePayload;
|
|
9
11
|
function isAllowedValueWithCodeOptionalPayload(allowedValueWithCodePayload // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
@@ -4,8 +4,8 @@ import { Notification } from './types/notificationStateTypes';
|
|
|
4
4
|
interface NotificationUpdatesPayload {
|
|
5
5
|
field: string;
|
|
6
6
|
type: string;
|
|
7
|
-
old_value: string | string[] | AllowedValueWithCodeOptionalPayload;
|
|
8
|
-
new_value: string | string[] | AllowedValueWithCodeOptionalPayload;
|
|
7
|
+
old_value: string | string[] | AllowedValueWithCodeOptionalPayload | null;
|
|
8
|
+
new_value: string | string[] | AllowedValueWithCodeOptionalPayload | null;
|
|
9
9
|
}
|
|
10
10
|
interface NotificationAdditionalInfoPayload {
|
|
11
11
|
due_date: string;
|
|
@@ -20,45 +20,65 @@ const toNotificationUpdates = (payload) => {
|
|
|
20
20
|
codeNamePair: null,
|
|
21
21
|
};
|
|
22
22
|
const updateType = (0, notificationTypes_1.toNotificationUpdateValueType)(type);
|
|
23
|
+
const oldValuePayload = old_value;
|
|
24
|
+
const newValuePayload = new_value;
|
|
23
25
|
switch (updateType) {
|
|
24
26
|
case 'list':
|
|
25
|
-
if (Array.isArray(
|
|
26
|
-
|
|
27
|
+
if (oldValuePayload != null && Array.isArray(oldValuePayload) === false) {
|
|
28
|
+
console.warn(`Invalid old_value - ${oldValuePayload} for type - ${type}`);
|
|
27
29
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
else {
|
|
31
|
+
oldValue[updateType] = Array.isArray(oldValuePayload)
|
|
32
|
+
? oldValuePayload
|
|
33
|
+
: [];
|
|
34
|
+
}
|
|
35
|
+
if (newValuePayload != null && Array.isArray(newValuePayload) === false) {
|
|
36
|
+
console.warn(`Invalid new_value - ${newValuePayload} for type - ${type}`);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
newValue[updateType] = Array.isArray(newValuePayload)
|
|
40
|
+
? newValuePayload
|
|
41
|
+
: [];
|
|
30
42
|
}
|
|
31
|
-
oldValue[updateType] = old_value;
|
|
32
|
-
newValue[updateType] = new_value;
|
|
33
43
|
break;
|
|
34
44
|
case 'code_name_pair':
|
|
35
|
-
if (
|
|
36
|
-
|
|
45
|
+
if (oldValuePayload != null &&
|
|
46
|
+
(0, commonPayload_1.isAllowedValueWithCodeOptionalPayload)(oldValuePayload) === false) {
|
|
47
|
+
console.warn(`Invalid old_value - ${oldValuePayload} for type - ${type}`);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
oldValue['codeNamePair'] =
|
|
51
|
+
oldValuePayload != null &&
|
|
52
|
+
(0, commonPayload_1.isAllowedValueWithCodePayload)(oldValuePayload)
|
|
53
|
+
? (0, commonPayload_1.toAllowedValueWithCode)(oldValuePayload)
|
|
54
|
+
: null;
|
|
37
55
|
}
|
|
38
|
-
if (
|
|
39
|
-
|
|
56
|
+
if (newValuePayload != null &&
|
|
57
|
+
(0, commonPayload_1.isAllowedValueWithCodeOptionalPayload)(newValuePayload) === false) {
|
|
58
|
+
console.warn(`Invalid new_value - ${newValuePayload} for type - ${type}`);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
newValue['codeNamePair'] =
|
|
62
|
+
newValuePayload != null &&
|
|
63
|
+
(0, commonPayload_1.isAllowedValueWithCodePayload)(newValuePayload)
|
|
64
|
+
? (0, commonPayload_1.toAllowedValueWithCode)(newValuePayload)
|
|
65
|
+
: null;
|
|
40
66
|
}
|
|
41
|
-
oldValue['codeNamePair'] =
|
|
42
|
-
old_value.code != null &&
|
|
43
|
-
old_value.name != null
|
|
44
|
-
? (0, commonPayload_1.toAllowedValueWithCode)(old_value)
|
|
45
|
-
: null;
|
|
46
|
-
newValue['codeNamePair'] =
|
|
47
|
-
new_value.code != null &&
|
|
48
|
-
new_value.name != null
|
|
49
|
-
? (0, commonPayload_1.toAllowedValueWithCode)(new_value)
|
|
50
|
-
: null;
|
|
51
67
|
break;
|
|
52
68
|
case 'string':
|
|
53
69
|
default:
|
|
54
|
-
if (typeof
|
|
55
|
-
|
|
70
|
+
if (oldValuePayload != null && typeof oldValuePayload !== 'string') {
|
|
71
|
+
console.warn(`Invalid old_value - ${oldValuePayload} for type - ${type}`);
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
oldValue['text'] = oldValuePayload == null ? '' : oldValuePayload;
|
|
75
|
+
}
|
|
76
|
+
if (newValuePayload != null && typeof newValuePayload !== 'string') {
|
|
77
|
+
console.warn(`Invalid new_value - ${newValuePayload} for type - ${type}`);
|
|
56
78
|
}
|
|
57
|
-
|
|
58
|
-
|
|
79
|
+
else {
|
|
80
|
+
newValue['text'] = newValuePayload == null ? '' : newValuePayload;
|
|
59
81
|
}
|
|
60
|
-
oldValue['text'] = old_value;
|
|
61
|
-
newValue['text'] = new_value;
|
|
62
82
|
break;
|
|
63
83
|
}
|
|
64
84
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeniai/client-epic-state",
|
|
3
|
-
"version": "4.10.
|
|
3
|
+
"version": "4.10.7",
|
|
4
4
|
"description": "Shared module between Web & Mobile containing required abstractions for state management, async network communication. ",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|