orc-shared 5.10.0-dev.2 → 5.10.0-dev.21

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 (186) hide show
  1. package/dist/actions/metadata.js +30 -11
  2. package/dist/actions/requestsApi.js +10 -1
  3. package/dist/components/AppFrame/About.js +136 -100
  4. package/dist/components/AppFrame/Anchor.js +45 -21
  5. package/dist/components/AppFrame/AppFrame.js +53 -31
  6. package/dist/components/AppFrame/Help.js +35 -15
  7. package/dist/components/AppFrame/MenuItem.js +148 -114
  8. package/dist/components/AppFrame/Preferences.js +136 -97
  9. package/dist/components/AppFrame/Sidebar.js +51 -28
  10. package/dist/components/AppFrame/Topbar.js +61 -36
  11. package/dist/components/ColumnWrapper.js +28 -5
  12. package/dist/components/Culture.js +33 -14
  13. package/dist/components/DropMenu/Menu.js +79 -45
  14. package/dist/components/DropMenu/index.js +34 -29
  15. package/dist/components/Form/Combination.js +45 -16
  16. package/dist/components/Form/Field.js +57 -38
  17. package/dist/components/Form/FieldElements.js +0 -11
  18. package/dist/components/Form/Fieldset.js +47 -19
  19. package/dist/components/Form/Form.js +22 -9
  20. package/dist/components/Form/FormElement.js +40 -7
  21. package/dist/components/Form/Inputs/Button.js +63 -18
  22. package/dist/components/Form/Inputs/ReadOnly.js +50 -27
  23. package/dist/components/{AppFrame/ApplicationSelector/Header.js → Form/Inputs/Selector.js} +30 -31
  24. package/dist/components/Form/Inputs/Text.js +20 -37
  25. package/dist/components/Form/Inputs/Toggles.js +39 -40
  26. package/dist/components/Form/Inputs/index.js +2 -13
  27. package/dist/components/MaterialUI/DataDisplay/PredefinedElements/Placeholder.js +31 -11
  28. package/dist/components/MaterialUI/DataDisplay/PredefinedElements/SectionToolbar.js +89 -0
  29. package/dist/components/MaterialUI/DataDisplay/Table.js +109 -18
  30. package/dist/components/MaterialUI/DataDisplay/TableProps.js +5 -1
  31. package/dist/components/MaterialUI/DataDisplay/TableWithInMemoryPaging.js +198 -0
  32. package/dist/components/MaterialUI/DataDisplay/TooltippedElements/MultipleLinesText.js +4 -1
  33. package/dist/components/MaterialUI/Inputs/DatePicker.js +14 -14
  34. package/dist/components/MaterialUI/Inputs/PredefinedElements/SearchControl.js +1 -0
  35. package/dist/components/MaterialUI/Inputs/Select.js +2 -0
  36. package/dist/components/MaterialUI/Inputs/SelectProps.js +2 -0
  37. package/dist/components/MaterialUI/Inputs/Switch.js +17 -1
  38. package/dist/components/MaterialUI/Inputs/SwitchProps.js +2 -0
  39. package/dist/components/MaterialUI/Inputs/TimePicker.js +14 -21
  40. package/dist/components/MaterialUI/hocs/withDeferredTooltip.js +3 -1
  41. package/dist/components/MaterialUI/muiThemes.js +2 -1
  42. package/dist/components/Provision.js +1 -1
  43. package/dist/constants.js +2 -1
  44. package/dist/content/iconsSheet.svg +740 -116
  45. package/dist/hocs/withScrollBox.js +27 -12
  46. package/dist/hooks/useDaysAndMonthsLocalization.js +77 -0
  47. package/dist/hooks/useInMemoryPaging.js +135 -0
  48. package/dist/hooks/useMultipleFieldEditState.js +12 -3
  49. package/dist/reducers/metadata.js +6 -0
  50. package/dist/schemas/metadata.js +9 -1
  51. package/dist/selectors/locale.js +1 -0
  52. package/dist/selectors/metadata.js +14 -11
  53. package/dist/sharedMessages.js +184 -0
  54. package/dist/utils/ListHelper.js +271 -0
  55. package/dist/utils/comparisonHelper.js +185 -0
  56. package/dist/utils/propertyBagHelper.js +3 -1
  57. package/dist/utils/timezoneHelper.js +18 -31
  58. package/package.json +4 -3
  59. package/src/actions/metadata.js +11 -0
  60. package/src/actions/metadata.test.js +27 -0
  61. package/src/actions/requestsApi.js +6 -0
  62. package/src/components/AppFrame/About.js +97 -117
  63. package/src/components/AppFrame/About.test.js +128 -90
  64. package/src/components/AppFrame/Anchor.js +34 -36
  65. package/src/components/AppFrame/Anchor.test.js +5 -68
  66. package/src/components/AppFrame/AppFrame.js +31 -40
  67. package/src/components/AppFrame/AppFrame.test.js +424 -445
  68. package/src/components/AppFrame/Help.js +23 -20
  69. package/src/components/AppFrame/Help.test.js +3 -3
  70. package/src/components/AppFrame/MenuItem.js +106 -126
  71. package/src/components/AppFrame/MenuItem.test.js +78 -169
  72. package/src/components/AppFrame/Preferences.js +110 -98
  73. package/src/components/AppFrame/Preferences.test.js +115 -219
  74. package/src/components/AppFrame/Sidebar.js +39 -41
  75. package/src/components/AppFrame/Sidebar.test.js +88 -168
  76. package/src/components/AppFrame/Topbar.js +59 -52
  77. package/src/components/AppFrame/Topbar.test.js +31 -39
  78. package/src/components/ColumnWrapper.js +18 -9
  79. package/src/components/Culture.js +20 -10
  80. package/src/components/Culture.test.js +27 -16
  81. package/src/components/DropMenu/DropMenu.test.js +185 -224
  82. package/src/components/DropMenu/Menu.js +73 -80
  83. package/src/components/DropMenu/Menu.test.js +35 -86
  84. package/src/components/DropMenu/index.js +19 -15
  85. package/src/components/Form/Combination.js +35 -28
  86. package/src/components/Form/Combination.test.js +6 -19
  87. package/src/components/Form/Field.js +53 -66
  88. package/src/components/Form/Field.test.js +29 -51
  89. package/src/components/Form/FieldElements.js +0 -14
  90. package/src/components/Form/FieldElements.test.js +104 -111
  91. package/src/components/Form/Fieldset.js +42 -37
  92. package/src/components/Form/Fieldset.test.js +14 -7
  93. package/src/components/Form/Form.js +11 -7
  94. package/src/components/Form/Form.test.js +75 -56
  95. package/src/components/Form/FormElement.js +24 -16
  96. package/src/components/Form/InputField.test.js +24 -30
  97. package/src/components/Form/Inputs/Button.js +58 -14
  98. package/src/components/Form/Inputs/Button.test.js +32 -7
  99. package/src/components/Form/Inputs/Inputs.test.js +0 -7
  100. package/src/components/Form/Inputs/ReadOnly.js +34 -28
  101. package/src/components/Form/Inputs/ReadOnly.test.js +45 -7
  102. package/src/components/Form/Inputs/Selector.js +22 -0
  103. package/src/components/Form/Inputs/Selector.test.js +105 -0
  104. package/src/components/Form/Inputs/Text.js +15 -44
  105. package/src/components/Form/Inputs/Text.test.js +20 -29
  106. package/src/components/Form/Inputs/Toggles.js +27 -26
  107. package/src/components/Form/Inputs/Toggles.test.js +22 -28
  108. package/src/components/Form/Inputs/index.js +4 -15
  109. package/src/components/MaterialUI/DataDisplay/PredefinedElements/InformationItem.test.js +1 -4
  110. package/src/components/MaterialUI/DataDisplay/PredefinedElements/Placeholder.js +32 -6
  111. package/src/components/MaterialUI/DataDisplay/PredefinedElements/Placeholder.test.js +3 -1
  112. package/src/components/MaterialUI/DataDisplay/PredefinedElements/SectionToolbar.js +39 -0
  113. package/src/components/MaterialUI/DataDisplay/Table.js +190 -114
  114. package/src/components/MaterialUI/DataDisplay/Table.test.js +246 -1
  115. package/src/components/MaterialUI/DataDisplay/TableProps.js +4 -0
  116. package/src/components/MaterialUI/DataDisplay/TableProps.test.js +2 -0
  117. package/src/components/MaterialUI/DataDisplay/TableWithInMemoryPaging.js +145 -0
  118. package/src/components/MaterialUI/DataDisplay/TableWithInMemoryPaging.test.js +457 -0
  119. package/src/components/MaterialUI/DataDisplay/TooltippedElements/MultipleLinesText.js +5 -1
  120. package/src/components/MaterialUI/DataDisplay/TooltippedElements/MultipleLinesText.test.js +7 -1
  121. package/src/components/MaterialUI/Inputs/DatePicker.js +19 -20
  122. package/src/components/MaterialUI/Inputs/DatePicker.test.js +11 -6
  123. package/src/components/MaterialUI/Inputs/PredefinedElements/SearchControl.js +1 -0
  124. package/src/components/MaterialUI/Inputs/Select.js +2 -0
  125. package/src/components/MaterialUI/Inputs/SelectProps.js +2 -0
  126. package/src/components/MaterialUI/Inputs/SelectProps.test.js +2 -0
  127. package/src/components/MaterialUI/Inputs/Switch.js +22 -1
  128. package/src/components/MaterialUI/Inputs/Switch.test.js +23 -0
  129. package/src/components/MaterialUI/Inputs/SwitchProps.js +2 -0
  130. package/src/components/MaterialUI/Inputs/SwitchProps.test.js +2 -0
  131. package/src/components/MaterialUI/Inputs/TimePicker.js +10 -19
  132. package/src/components/MaterialUI/Inputs/TimePicker.test.js +278 -117
  133. package/src/components/MaterialUI/hocs/withDeferredTooltip.js +4 -1
  134. package/src/components/MaterialUI/hocs/withDeferredTooltip.test.js +27 -0
  135. package/src/components/MaterialUI/muiThemes.js +1 -0
  136. package/src/components/Navigation/Bar.test.js +92 -87
  137. package/src/components/Provision.js +1 -1
  138. package/src/components/TaskDetailsModal.test.js +1 -3
  139. package/src/constants.js +1 -0
  140. package/src/content/iconsSheet.svg +740 -116
  141. package/src/hocs/withScrollBox.js +32 -19
  142. package/src/hocs/withScrollBox.test.js +15 -3
  143. package/src/hooks/useDaysAndMonthsLocalization.js +79 -0
  144. package/src/hooks/useDaysAndMonthsLocalization.test.js +107 -0
  145. package/src/hooks/useInMemoryPaging.js +78 -0
  146. package/src/hooks/useInMemoryPaging.test.js +515 -0
  147. package/src/hooks/useMultipleFieldEditState.js +11 -4
  148. package/src/hooks/useMultipleFieldEditState.test.js +49 -1
  149. package/src/reducers/metadata.js +6 -1
  150. package/src/reducers/metadata.test.js +31 -0
  151. package/src/requests +1 -0
  152. package/src/schemas/metadata.js +3 -0
  153. package/src/selectors/locale.js +1 -1
  154. package/src/selectors/metadata.js +12 -9
  155. package/src/selectors/metadata.test.js +92 -11
  156. package/src/sharedMessages.js +184 -0
  157. package/src/timezones.json +883 -0
  158. package/src/translations/en-US.json +46 -0
  159. package/src/translations/fr-CA.json +46 -0
  160. package/src/utils/ListHelper.js +203 -0
  161. package/src/utils/ListHelper.test.js +710 -0
  162. package/src/utils/comparisonHelper.js +135 -0
  163. package/src/utils/comparisonHelper.test.js +334 -0
  164. package/src/utils/propertyBagHelper.js +2 -0
  165. package/src/utils/propertyBagHelper.test.js +6 -0
  166. package/src/utils/timezoneHelper.js +10 -135
  167. package/src/utils/timezoneHelper.test.js +7 -7
  168. package/dist/components/Form/FieldList.js +0 -270
  169. package/dist/components/Form/Inputs/FieldButtons.js +0 -66
  170. package/dist/components/Form/Inputs/Number.js +0 -117
  171. package/dist/components/Form/Inputs/SmallButton.js +0 -91
  172. package/dist/components/Form/Inputs/Time.js +0 -86
  173. package/dist/components/Form/Inputs/Translation.js +0 -169
  174. package/src/components/AppFrame/ApplicationSelector/Header.js +0 -34
  175. package/src/components/AppFrame/ApplicationSelector/Header.test.js +0 -23
  176. package/src/components/Form/FieldList.js +0 -210
  177. package/src/components/Form/FieldList.test.js +0 -558
  178. package/src/components/Form/Inputs/FieldButtons.js +0 -90
  179. package/src/components/Form/Inputs/Number.js +0 -60
  180. package/src/components/Form/Inputs/Number.test.js +0 -435
  181. package/src/components/Form/Inputs/SmallButton.js +0 -37
  182. package/src/components/Form/Inputs/SmallButton.test.js +0 -65
  183. package/src/components/Form/Inputs/Time.js +0 -32
  184. package/src/components/Form/Inputs/Time.test.js +0 -41
  185. package/src/components/Form/Inputs/Translation.js +0 -93
  186. package/src/components/Form/Inputs/Translation.test.js +0 -204
@@ -0,0 +1,135 @@
1
+ import _ from "lodash";
2
+
3
+ export const partialDeepEqual = (x, y, ignoredRootProps = null) => {
4
+ if (x == null || y == null) return x === y;
5
+
6
+ const keys = Object.keys(x);
7
+ if (!_.isEqual(keys, Object.keys(y))) {
8
+ return false;
9
+ }
10
+
11
+ for (let key of keys) {
12
+ if (ignoredRootProps && ignoredRootProps.includes(key)) {
13
+ continue;
14
+ }
15
+
16
+ if (!_.isEqual(x[key], y[key])) {
17
+ return false;
18
+ }
19
+ }
20
+
21
+ return true;
22
+ };
23
+
24
+ export const areGuidsEquals = (first, second) => {
25
+ function stripDash(value) {
26
+ return value?.replace(/-/g, "");
27
+ }
28
+
29
+ return areEqualCaseInsensitive(stripDash(first), stripDash(second));
30
+ };
31
+
32
+ export const areEqualCaseInsensitive = (first, second) => {
33
+ const isFirstNullish = first === null || first === undefined;
34
+ const isSecondNullish = second === null || second === undefined;
35
+
36
+ if (isFirstNullish || isSecondNullish) {
37
+ return isFirstNullish && isSecondNullish;
38
+ }
39
+
40
+ return first.localeCompare(second, undefined, { sensitivity: "accent" }) === 0;
41
+ };
42
+
43
+ const processOrderResult = (ascendingOrder, compareResult) => {
44
+ if (!ascendingOrder && compareResult != 0) {
45
+ return compareResult * -1;
46
+ }
47
+ return compareResult;
48
+ };
49
+
50
+ export const compareTextCaseInsensitive = (first, second, ascendingOrder = true, nullValue = "") => {
51
+ return processOrderResult(
52
+ ascendingOrder,
53
+ (first ?? nullValue).localeCompare(second ?? nullValue, undefined, { sensitivity: "accent" }),
54
+ );
55
+ };
56
+
57
+ export const getBooleanValue = value => {
58
+ let result = null;
59
+
60
+ if (typeof value === "string") {
61
+ if (areEqualCaseInsensitive(value, "true")) {
62
+ result = true;
63
+ } else if (areEqualCaseInsensitive(value, "false")) {
64
+ result = false;
65
+ }
66
+ } else if (typeof value === "boolean") {
67
+ result = value === true;
68
+ }
69
+
70
+ return result;
71
+ };
72
+
73
+ export const compareBoolean = (first, second) => {
74
+ const firstBool = getBooleanValue(first);
75
+ const secondBool = getBooleanValue(second);
76
+
77
+ if (firstBool === null && secondBool === null) {
78
+ return false;
79
+ }
80
+
81
+ return firstBool === secondBool;
82
+ };
83
+
84
+ export const compareNumeric = (first, second, ascendingOrder = true, nullValue = 0.0) => {
85
+ if (typeof first === "string" || first instanceof String || typeof second === "string" || second instanceof String) {
86
+ return processOrderResult(
87
+ ascendingOrder,
88
+ (first ?? nullValue.toString()).localeCompare(second ?? nullValue.toString(), undefined, {
89
+ numeric: true,
90
+ }),
91
+ );
92
+ }
93
+
94
+ let result = 0;
95
+ if ((first ?? nullValue) < (second ?? nullValue)) {
96
+ result = -1;
97
+ } else if ((first ?? nullValue) > (second ?? nullValue)) {
98
+ result = 1;
99
+ }
100
+
101
+ return processOrderResult(ascendingOrder, result);
102
+ };
103
+
104
+ export const doesObjectContainsTextCaseInsensitive = (obj, searchTerm, properties = []) => {
105
+ const caseInsensitiveIncludes = (a, b) => {
106
+ return a?.toLowerCase().includes(b);
107
+ };
108
+
109
+ if (!obj) {
110
+ return false;
111
+ }
112
+
113
+ if (searchTerm === null || searchTerm === undefined || searchTerm === "") {
114
+ return true;
115
+ }
116
+
117
+ const loweredSearchTerm = searchTerm.toLowerCase();
118
+ const propertiesToSearch = properties.length > 0 ? properties : Object.keys(obj);
119
+ const result =
120
+ propertiesToSearch.find(key => {
121
+ if (typeof obj[key] === "string") {
122
+ return caseInsensitiveIncludes(obj[key], loweredSearchTerm);
123
+ }
124
+
125
+ if (typeof obj[key] === "object" && obj[key]) {
126
+ const objectValues = Object.values(obj[key]);
127
+ return objectValues.find(
128
+ ovKey => typeof ovKey === "string" && caseInsensitiveIncludes(ovKey, loweredSearchTerm),
129
+ );
130
+ }
131
+
132
+ return false;
133
+ }) !== undefined;
134
+ return result;
135
+ };
@@ -0,0 +1,334 @@
1
+ import {
2
+ areEqualCaseInsensitive,
3
+ areGuidsEquals,
4
+ doesObjectContainsTextCaseInsensitive,
5
+ partialDeepEqual,
6
+ compareTextCaseInsensitive,
7
+ compareNumeric,
8
+ compareBoolean,
9
+ getBooleanValue,
10
+ } from "./comparisonHelper";
11
+
12
+ describe("partialDeepEqual function", () => {
13
+ it.each([
14
+ ["empty with non empty object", {}, { a: 1 }],
15
+ ["different properties", { b: 2 }, { a: 1 }],
16
+ ["same properties different values", { a: 2 }, { a: 1 }],
17
+ ["same nested properties different values", { a: { b: 3 } }, { a: { b: 4 } }],
18
+ ])("returns false if the objects are ", (msg, obj1, obj2) => {
19
+ const result = partialDeepEqual(obj1, obj2);
20
+ expect(result, "to equal", false);
21
+ });
22
+
23
+ it.each([
24
+ ["empty objects", {}, {}],
25
+ ["same properties", { a: 1 }, { a: 1 }],
26
+ ["same nested properties same values", { a: { b: 3 } }, { a: { b: 3 } }],
27
+ ])("returns true if the objects are ", (msg, obj1, obj2) => {
28
+ const result = partialDeepEqual(obj1, obj2);
29
+ expect(result, "to equal", true);
30
+ });
31
+
32
+ it("returns false even with ignored property", () => {
33
+ const obj1 = {
34
+ a: 2,
35
+ b: 1,
36
+ };
37
+
38
+ const obj2 = {
39
+ a: 1,
40
+ b: 1,
41
+ };
42
+
43
+ const result = partialDeepEqual(obj1, obj2, ["b"]);
44
+ expect(result, "to equal", false);
45
+ });
46
+
47
+ it("returns true with ignored property", () => {
48
+ const obj1 = {
49
+ a: 2,
50
+ b: 1,
51
+ };
52
+
53
+ const obj2 = {
54
+ a: 1,
55
+ b: 1,
56
+ };
57
+
58
+ const result = partialDeepEqual(obj1, obj2, ["a"]);
59
+ expect(result, "to equal", true);
60
+ });
61
+
62
+ it("returns true if both are null", () => {
63
+ const obj1 = null;
64
+
65
+ const obj2 = null;
66
+
67
+ const result = partialDeepEqual(obj1, obj2);
68
+ expect(result, "to equal", true);
69
+ });
70
+
71
+ it("returns true if both are undefined", () => {
72
+ const obj1 = undefined;
73
+
74
+ const obj2 = undefined;
75
+
76
+ const result = partialDeepEqual(obj1, obj2);
77
+ expect(result, "to equal", true);
78
+ });
79
+
80
+ it("returns true if one is null and the other undefined", () => {
81
+ const obj1 = null;
82
+
83
+ const obj2 = undefined;
84
+
85
+ const result = partialDeepEqual(obj1, obj2);
86
+ expect(result, "to equal", false);
87
+ });
88
+ });
89
+
90
+ describe("areGuidsEquals function", () => {
91
+ it.each([
92
+ [true, "AAA123", "aaa123"],
93
+ [true, "123", "1-2-3"],
94
+ [true, "1-2-3", "1-2-3"],
95
+ [true, "123", "123"],
96
+ [false, "123", "1-2-3-4"],
97
+ [false, "123", "1-2-3-4"],
98
+ [false, "123", null],
99
+ [false, "123", undefined],
100
+ [false, null, "123"],
101
+ [false, undefined, "123"],
102
+ [true, null, null],
103
+ [true, undefined, undefined],
104
+ [true, undefined, null],
105
+ [true, null, undefined],
106
+ ])("returns %s for values %s and %s ", (expectedResult, value1, value2) => {
107
+ const result = areGuidsEquals(value1, value2);
108
+ expect(result, "to equal", expectedResult);
109
+ });
110
+ });
111
+
112
+ describe("areEqualCaseInsensitive function", () => {
113
+ it.each([
114
+ [true, "AAA123", "aaa123"],
115
+ [false, "123", "1-2-3"],
116
+ [true, "123", "123"],
117
+ [false, "123", null],
118
+ [false, "123", undefined],
119
+ [false, null, "123"],
120
+ [false, undefined, "123"],
121
+ [true, null, null],
122
+ [true, undefined, undefined],
123
+ [true, undefined, null],
124
+ [true, null, undefined],
125
+ ])("returns %s for values %s and %s ", (expectedResult, value1, value2) => {
126
+ const result = areEqualCaseInsensitive(value1, value2);
127
+ expect(result, "to equal", expectedResult);
128
+ });
129
+ });
130
+
131
+ describe("getBooleanValue function", () => {
132
+ it.each([
133
+ [true, true],
134
+ [false, false],
135
+ ["trUE", true],
136
+ ["faLSe", false],
137
+ ["faLSeInvalid", null],
138
+ ["InvalidTrue", null],
139
+ ])("value %s returned the result %s ", (value, expectedResult) => {
140
+ const result = getBooleanValue(value);
141
+ expect(result, "to equal", expectedResult);
142
+ });
143
+ });
144
+
145
+ describe("compareBoolean function", () => {
146
+ it.each([
147
+ [true, "tRuE", true],
148
+ [true, "tRuE1", false],
149
+ [true, "false", false],
150
+ [true, false, false],
151
+ ["tRuE", true, true],
152
+ ["tRuE1", true, false],
153
+ ["false", true, false],
154
+ [true, true, true],
155
+ [false, true, false],
156
+ [false, "FaLSe", true],
157
+ [false, "FaLSe1", false],
158
+ [false, "TrUe", false],
159
+ ["FaLSe", false, true],
160
+ ["FaLSe1", false, false],
161
+ ["TrUe", false, false],
162
+ [false, false, true],
163
+ [false, null, false],
164
+ ["FaLSe", null, false],
165
+ [false, undefined, false],
166
+ ["FaLSe", undefined, false],
167
+ ["FaLSeInvalid", "TrueInvalid", false],
168
+ ])("values %s and %s returned the result %s ", (value1, value2, expectedResult) => {
169
+ const result = compareBoolean(value1, value2);
170
+ expect(result, "to equal", expectedResult);
171
+ });
172
+ });
173
+
174
+ describe("doesObjectContainsTextCaseInsensitive function", () => {
175
+ it("returns false if object is null", function () {
176
+ const result = doesObjectContainsTextCaseInsensitive(null, "val");
177
+ expect(result, "to be", false);
178
+ });
179
+
180
+ it("returns false if object is undefined", function () {
181
+ const result = doesObjectContainsTextCaseInsensitive(undefined, "val");
182
+ expect(result, "to be", false);
183
+ });
184
+
185
+ it("returns true if searchTerm is null", function () {
186
+ const result = doesObjectContainsTextCaseInsensitive({}, null);
187
+ expect(result, "to be", true);
188
+ });
189
+
190
+ it("returns true if searchTerm is undefined", function () {
191
+ const result = doesObjectContainsTextCaseInsensitive({}, undefined);
192
+ expect(result, "to be", true);
193
+ });
194
+
195
+ it("returns true if searchTerm is an empty string", function () {
196
+ const result = doesObjectContainsTextCaseInsensitive({}, "");
197
+ expect(result, "to be", true);
198
+ });
199
+
200
+ it("returns false if object has no properties", function () {
201
+ const result = doesObjectContainsTextCaseInsensitive({}, "val");
202
+ expect(result, "to be", false);
203
+ });
204
+
205
+ it("returns false if text cannot be found in property", function () {
206
+ const result = doesObjectContainsTextCaseInsensitive({ prop: "another" }, "val");
207
+ expect(result, "to be", false);
208
+ });
209
+
210
+ it("returns true if text is found in property (exact match)", function () {
211
+ const result = doesObjectContainsTextCaseInsensitive({ prop: "another", prop2: "val" }, "val");
212
+ expect(result, "to be", true);
213
+ });
214
+
215
+ it("returns true if text is found in property (contains)", function () {
216
+ const result = doesObjectContainsTextCaseInsensitive({ prop: "another", prop2: "some value" }, "val");
217
+ expect(result, "to be", true);
218
+ });
219
+
220
+ it("returns true if text is found in property (case insensitive)", function () {
221
+ const result = doesObjectContainsTextCaseInsensitive({ prop: "another", prop2: "VALUE" }, "val");
222
+ expect(result, "to be", true);
223
+ });
224
+
225
+ it("ignores non string properties", function () {
226
+ const result = doesObjectContainsTextCaseInsensitive({ prop: 123, prop2: "VALUE" }, "val");
227
+ expect(result, "to be", true);
228
+ });
229
+
230
+ it("does look at second level properties of type string", function () {
231
+ const result = doesObjectContainsTextCaseInsensitive({ prop: { prop2: "VALUE" } }, "val");
232
+ expect(result, "to be", true);
233
+ });
234
+
235
+ it("does not look at second level properties of type number", function () {
236
+ const result = doesObjectContainsTextCaseInsensitive({ prop: { prop2: 123 } }, "val");
237
+ expect(result, "to be", false);
238
+ });
239
+
240
+ it("does not look at third level properties", function () {
241
+ const result = doesObjectContainsTextCaseInsensitive({ prop: { prop2: { prop3: "VALUE" } } }, "val");
242
+ expect(result, "to be", false);
243
+ });
244
+
245
+ it("does not crash if prop value is null", function () {
246
+ const result = doesObjectContainsTextCaseInsensitive({ prop: null, prop2: "bob" }, "val");
247
+ expect(result, "to be", false);
248
+ });
249
+
250
+ it("returns false because property with value is not looked at", function () {
251
+ const result = doesObjectContainsTextCaseInsensitive({ prop: "123", prop2: "VALUE" }, "val", ["prop"]);
252
+ expect(result, "to be", false);
253
+ });
254
+
255
+ it("returns true because property with value is looked at", function () {
256
+ const result = doesObjectContainsTextCaseInsensitive({ prop: "123", prop2: "VALUE" }, "val", ["prop2"]);
257
+ expect(result, "to be", true);
258
+ });
259
+ });
260
+
261
+ describe("compareTextCaseInsensitive function", () => {
262
+ it.each([
263
+ [0, "AAA123", "aaa123"],
264
+ [-1, "AAA123", "AAA1234"],
265
+ [-1, "123", "123a"],
266
+ [-1, null, "123"],
267
+ [-1, undefined, "123"],
268
+ [0, null, null],
269
+ [0, undefined, undefined],
270
+ [0, undefined, null],
271
+ [0, null, undefined],
272
+ ])("returns %s for values %s and %s ", (expectedResult, value1, value2) => {
273
+ const result = compareTextCaseInsensitive(value1, value2);
274
+ expect(result, "to equal", expectedResult);
275
+ });
276
+
277
+ it.each([
278
+ [0, "AAA123", "aaa123"],
279
+ [1, "AAA123", "AAA1234"],
280
+ [1, "123", "123a"],
281
+ [1, null, "123"],
282
+ [1, undefined, "123"],
283
+ [0, null, null],
284
+ [0, undefined, undefined],
285
+ [0, undefined, null],
286
+ [0, null, undefined],
287
+ ])("returns %s for values %s and %s for descending order", (expectedResult, value1, value2) => {
288
+ const result = compareTextCaseInsensitive(value1, value2, false);
289
+ expect(result, "to equal", expectedResult);
290
+ });
291
+ });
292
+
293
+ describe("compareNumeric function", () => {
294
+ it.each([
295
+ [0, 42, 42],
296
+ [-1, 42, 42.42],
297
+ [-1, null, 42],
298
+ [-1, undefined, 42],
299
+ [0, null, null],
300
+ [0, undefined, undefined],
301
+ [0, undefined, null],
302
+ [0, null, undefined],
303
+ [-1, "9", "42"],
304
+ [1, "9", null],
305
+ [1, "9", undefined],
306
+ [1, 9, 7],
307
+ [1, 9, undefined],
308
+ [1, undefined, -1],
309
+ [-1, null, "1"],
310
+ [-1, undefined, "1"],
311
+ ])("returns %s for values %s and %s ", (expectedResult, value1, value2) => {
312
+ const result = compareNumeric(value1, value2);
313
+ expect(result, "to equal", expectedResult);
314
+ });
315
+
316
+ it.each([
317
+ [0, 42, 42],
318
+ [1, 42, 42.42],
319
+ [1, null, 42],
320
+ [1, undefined, 42],
321
+ [0, null, null],
322
+ [0, undefined, undefined],
323
+ [0, undefined, null],
324
+ [0, null, undefined],
325
+ [1, "9", "42"],
326
+ [-1, "9", null],
327
+ [-1, "9", undefined],
328
+ [1, null, "1"],
329
+ [1, undefined, "1"],
330
+ ])("returns %s for values %s and %s for descending order", (expectedResult, value1, value2) => {
331
+ const result = compareNumeric(value1, value2, false);
332
+ expect(result, "to equal", expectedResult);
333
+ });
334
+ });
@@ -20,6 +20,7 @@ export const customDataType = {
20
20
  multipleCarrierProvidersSelector: "MultipleCarrierProvidersSelector",
21
21
  serviceLevelSelector: "ServiceLevelSelector",
22
22
  percentageDecimal: "PercentageDecimal",
23
+ carrierReferenceFieldSelector: "CarrierReferenceFieldSelector",
23
24
  };
24
25
 
25
26
  const tieredAttributeTypes = [customDataType.priceTieredRateTable, customDataType.quantityTieredRateTable];
@@ -84,6 +85,7 @@ export const toJsonCargo = (attribute, value) => {
84
85
  case customDataType.routingProviderSelector:
85
86
  case customDataType.multipleCarrierProvidersSelector:
86
87
  case customDataType.serviceLevelSelector:
88
+ case customDataType.carrierReferenceFieldSelector:
87
89
  return value;
88
90
  default:
89
91
  throw new Error(`toJsonCargo: attribute.customDataType ${attribute.customDataType} is not implemented`);
@@ -48,6 +48,12 @@ describe("toJsonCargo function", () => {
48
48
  it.each([
49
49
  ["aTextValue", attributeDataType.text, null, "aTextValue"],
50
50
  ["aPassword", attributeDataType.customType, customDataType.password, "aPassword"],
51
+ [
52
+ "aCarrierReferenceFieldSelector",
53
+ attributeDataType.customType,
54
+ customDataType.carrierReferenceFieldSelector,
55
+ "aCarrierReferenceFieldSelector",
56
+ ],
51
57
  [
52
58
  "aCarrierProviderSelector",
53
59
  attributeDataType.customType,
@@ -1,19 +1,19 @@
1
1
  import moment from "moment-timezone";
2
2
 
3
- export const getTimeZone = () => Intl.DateTimeFormat().resolvedOptions().timeZone;
3
+ const timeZonesList = require("../timezones.json");
4
4
 
5
- export const getTimeZoneByName = name => {
6
- for (let [key, value] of timeZonesList.entries()) {
7
- if (value === name) return key;
8
- }
5
+ export const getIanaTimeZone = () => Intl.DateTimeFormat().resolvedOptions().timeZone;
9
6
 
10
- return getTimeZone();
7
+ export const getIanaTimeZoneFromWindowsName = windowsName => {
8
+ // If not found, the mapping might need to be updated, rerun the generateWindowsZone script
9
+ return (timeZonesList.windowsToIana[windowsName] ?? [getIanaTimeZone()])[0];
11
10
  };
12
11
 
13
- export const getTimeZoneName = () => {
14
- const customerTimezone = getTimeZone();
15
- const timezoneName = timeZonesList.get(customerTimezone);
16
- return timezoneName;
12
+ export const getWindowsTimeZone = () => {
13
+ const customerTimezone = getIanaTimeZone();
14
+ const windowsTimezones = timeZonesList.ianaToWindows[customerTimezone];
15
+ // If not found, the mapping might need to be updated, rerun the generateWindowsZone script
16
+ return (windowsTimezones ?? [customerTimezone])[0];
17
17
  };
18
18
 
19
19
  //converting time from other timezone to local
@@ -31,128 +31,3 @@ export const convertTimeToOtherTimeZone = (date, timezone) => {
31
31
  const dateWithOtherZone = [dateWithoutZone, otherZone].join("");
32
32
  return new Date(dateWithOtherZone);
33
33
  };
34
-
35
- export const timeZonesList = new Map([
36
- ["Africa/Bangui", "W. Central Africa Standard Time"],
37
- ["Africa/Cairo", "Egypt Standard Time"],
38
- ["Africa/Casablanca", "Morocco Standard Time"],
39
- ["Africa/Harare", "South Africa Standard Time"],
40
- ["Africa/Johannesburg", "South Africa Standard Time"],
41
- ["Africa/Lagos", "W. Central Africa Standard Time"],
42
- ["Africa/Monrovia", "Greenwich Standard Time"],
43
- ["Africa/Nairobi", "E. Africa Standard Time"],
44
- ["Africa/Windhoek", "Namibia Standard Time"],
45
- ["America/Anchorage", "Alaskan Standard Time"],
46
- ["America/Argentina/San_Juan", "Argentina Standard Time"],
47
- ["America/Asuncion", "Paraguay Standard Time"],
48
- ["America/Bahia", "Bahia Standard Time"],
49
- ["America/Bogota", "SA Pacific Standard Time"],
50
- ["America/Buenos_Aires", "Argentina Standard Time"],
51
- ["America/Caracas", "Venezuela Standard Time"],
52
- ["America/Cayenne", "SA Eastern Standard Time"],
53
- ["America/Chicago", "Central Standard Time"],
54
- ["America/Chihuahua", "Mountain Standard Time (Mexico)"],
55
- ["America/Cuiaba", "Central Brazilian Standard Time"],
56
- ["America/Denver", "Mountain Standard Time"],
57
- ["America/Fortaleza", "SA Eastern Standard Time"],
58
- ["America/Godthab", "Greenland Standard Time"],
59
- ["America/Guatemala", "Central America Standard Time"],
60
- ["America/Halifax", "Atlantic Standard Time"],
61
- ["America/Indianapolis", "US Eastern Standard Time"],
62
- ["America/Indiana/Indianapolis", "US Eastern Standard Time"],
63
- ["America/La_Paz", "SA Western Standard Time"],
64
- ["America/Los_Angeles", "Pacific Standard Time"],
65
- ["America/Mexico_City", "Mexico Standard Time"],
66
- ["America/Montevideo", "Montevideo Standard Time"],
67
- ["America/New_York", "Eastern Standard Time"],
68
- ["America/Noronha", "UTC-02"],
69
- ["America/Phoenix", "US Mountain Standard Time"],
70
- ["America/Regina", "Canada Central Standard Time"],
71
- ["America/Santa_Isabel", "Pacific Standard Time (Mexico)"],
72
- ["America/Santiago", "Pacific SA Standard Time"],
73
- ["America/Sao_Paulo", "E. South America Standard Time"],
74
- ["America/St_Johns", "Newfoundland Standard Time"],
75
- ["America/Tijuana", "Pacific Standard Time"],
76
- ["Antarctica/McMurdo", "New Zealand Standard Time"],
77
- ["Atlantic/South_Georgia", "UTC-02"],
78
- ["Asia/Almaty", "Central Asia Standard Time"],
79
- ["Asia/Amman", "Jordan Standard Time"],
80
- ["Asia/Baghdad", "Arabic Standard Time"],
81
- ["Asia/Baku", "Azerbaijan Standard Time"],
82
- ["Asia/Bangkok", "SE Asia Standard Time"],
83
- ["Asia/Beirut", "Middle East Standard Time"],
84
- ["Asia/Calcutta", "India Standard Time"],
85
- ["Asia/Colombo", "Sri Lanka Standard Time"],
86
- ["Asia/Damascus", "Syria Standard Time"],
87
- ["Asia/Dhaka", "Bangladesh Standard Time"],
88
- ["Asia/Dubai", "Arabian Standard Time"],
89
- ["Asia/Irkutsk", "North Asia East Standard Time"],
90
- ["Asia/Jerusalem", "Israel Standard Time"],
91
- ["Asia/Kabul", "Afghanistan Standard Time"],
92
- ["Asia/Kamchatka", "Kamchatka Standard Time"],
93
- ["Asia/Karachi", "Pakistan Standard Time"],
94
- ["Asia/Katmandu", "Nepal Standard Time"],
95
- ["Asia/Kolkata", "India Standard Time"],
96
- ["Asia/Krasnoyarsk", "North Asia Standard Time"],
97
- ["Asia/Kuala_Lumpur", "Singapore Standard Time"],
98
- ["Asia/Kuwait", "Arab Standard Time"],
99
- ["Asia/Magadan", "Magadan Standard Time"],
100
- ["Asia/Muscat", "Arabian Standard Time"],
101
- ["Asia/Novosibirsk", "N. Central Asia Standard Time"],
102
- ["Asia/Oral", "West Asia Standard Time"],
103
- ["Asia/Rangoon", "Myanmar Standard Time"],
104
- ["Asia/Riyadh", "Arab Standard Time"],
105
- ["Asia/Seoul", "Korea Standard Time"],
106
- ["Asia/Shanghai", "China Standard Time"],
107
- ["Asia/Singapore", "Singapore Standard Time"],
108
- ["Asia/Taipei", "Taipei Standard Time"],
109
- ["Asia/Tashkent", "West Asia Standard Time"],
110
- ["Asia/Tbilisi", "Georgian Standard Time"],
111
- ["Asia/Tehran", "Iran Standard Time"],
112
- ["Asia/Tokyo", "Tokyo Standard Time"],
113
- ["Asia/Ulaanbaatar", "Ulaanbaatar Standard Time"],
114
- ["Asia/Vladivostok", "Vladivostok Standard Time"],
115
- ["Asia/Yakutsk", "Yakutsk Standard Time"],
116
- ["Asia/Yekaterinburg", "Ekaterinburg Standard Time"],
117
- ["Asia/Yerevan", "Armenian Standard Time"],
118
- ["Atlantic/Azores", "Azores Standard Time"],
119
- ["Atlantic/Cape_Verde", "Cape Verde Standard Time"],
120
- ["Atlantic/Reykjavik", "Greenwich Standard Time"],
121
- ["Australia/Adelaide", "Cen. Australia Standard Time"],
122
- ["Australia/Brisbane", "E. Australia Standard Time"],
123
- ["Australia/Darwin", "AUS Central Standard Time"],
124
- ["Australia/Hobart", "Tasmania Standard Time"],
125
- ["Australia/Perth", "W. Australia Standard Time"],
126
- ["Australia/Sydney", "AUS Eastern Standard Time"],
127
- ["UTC", "UTC"],
128
- ["Etc/GMT+11", "UTC-11"],
129
- ["Etc/GMT+12", "Dateline Standard Time"],
130
- ["Etc/GMT+2", "UTC-02"],
131
- ["Etc/GMT-12", "UTC+12"],
132
- ["Europe/Amsterdam", "W. Europe Standard Time"],
133
- ["Europe/Athens", "GTB Standard Time"],
134
- ["Europe/Belgrade", "Central Europe Standard Time"],
135
- ["Europe/Berlin", "W. Europe Standard Time"],
136
- ["Europe/Brussels", "Romance Standard Time"],
137
- ["Europe/Budapest", "Central Europe Standard Time"],
138
- ["Europe/Dublin", "GMT Standard Time"],
139
- ["Europe/Helsinki", "FLE Standard Time"],
140
- ["Europe/Istanbul", "GTB Standard Time"],
141
- ["Europe/Kiev", "FLE Standard Time"],
142
- ["Europe/London", "GMT Standard Time"],
143
- ["Europe/Minsk", "E. Europe Standard Time"],
144
- ["Europe/Moscow", "Russian Standard Time"],
145
- ["Europe/Paris", "Romance Standard Time"],
146
- ["Europe/Sarajevo", "Central European Standard Time"],
147
- ["Europe/Warsaw", "Central European Standard Time"],
148
- ["Indian/Mauritius", "Mauritius Standard Time"],
149
- ["Pacific/Apia", "Samoa Standard Time"],
150
- ["Pacific/Auckland", "New Zealand Standard Time"],
151
- ["Pacific/Fiji", "Fiji Standard Time"],
152
- ["Pacific/Guadalcanal", "Central Pacific Standard Time"],
153
- ["Pacific/Guam", "West Pacific Standard Time"],
154
- ["Pacific/Honolulu", "Hawaiian Standard Time"],
155
- ["Pacific/Pago_Pago", "UTC-11"],
156
- ["Pacific/Port_Moresby", "West Pacific Standard Time"],
157
- ["Pacific/Tongatapu", "Tonga Standard Time"],
158
- ]);