orc-shared 1.1.0-dev.9 → 1.1.2
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/dist/actions/applications.js +1 -1
- package/dist/actions/authentication.js +1 -1
- package/dist/actions/countries.js +1 -1
- package/dist/actions/locale.js +1 -1
- package/dist/actions/makeApiAction.js +73 -3
- package/dist/actions/makeOrcApiAction.js +2 -2
- package/dist/actions/metadata.js +295 -31
- package/dist/actions/navigation.js +3 -3
- package/dist/actions/requestState.js +78 -0
- package/dist/actions/requestsApi.js +58 -7
- package/dist/actions/scopes.js +1 -1
- package/dist/actions/timezones.js +1 -1
- package/dist/actions/toasts.js +1 -1
- package/dist/actions/versionInfo.js +1 -1
- package/dist/actions/view.js +1 -1
- package/dist/buildStore.js +7 -4
- package/dist/components/AppFrame/About.js +3 -3
- package/dist/components/AppFrame/ApplicationSelector/ApplicationDialog.js +115 -62
- package/dist/components/AppFrame/ApplicationSelector/index.js +45 -47
- package/dist/components/AppFrame/MenuItem.js +1 -1
- package/dist/components/AppFrame/Preferences.js +3 -3
- package/dist/components/AppFrame/Sidebar.js +1 -1
- package/dist/components/AppFrame/Topbar.js +1 -1
- package/dist/components/Authenticate.js +1 -1
- package/dist/components/CategoryList.js +1 -1
- package/dist/components/Checkbox.js +1 -1
- package/dist/components/DropMenu/Menu.js +1 -1
- package/dist/components/DropMenu/index.js +1 -1
- package/dist/components/Form/FieldList.js +3 -3
- package/dist/components/Form/Form.js +1 -1
- package/dist/components/Form/Inputs/Button.js +1 -1
- package/dist/components/Form/Inputs/FieldButtons.js +1 -1
- package/dist/components/Form/Inputs/Number.js +1 -1
- package/dist/components/Form/Inputs/ReadOnly.js +1 -1
- package/dist/components/Form/Inputs/SmallButton.js +1 -1
- package/dist/components/Form/Inputs/Text.js +1 -1
- package/dist/components/Form/Inputs/Time.js +1 -1
- package/dist/components/Form/Inputs/Toggles.js +1 -1
- package/dist/components/Form/Inputs/Translation.js +3 -3
- package/dist/components/List/HeadCell.js +1 -1
- package/dist/components/List/List.js +1 -1
- package/dist/components/List/Row.js +1 -1
- package/dist/components/List/enhanceColumnDefs.js +2 -2
- package/dist/components/MaterialUI/DataDisplay/List.js +1 -1
- package/dist/components/MaterialUI/DataDisplay/Notification.js +2 -2
- package/dist/components/MaterialUI/DataDisplay/NotificationProps.js +1 -1
- package/dist/components/MaterialUI/DataDisplay/PredefinedElements/Translations.js +3 -3
- package/dist/components/MaterialUI/DataDisplay/SelectionList.js +19 -6
- package/dist/components/MaterialUI/DataDisplay/Table.js +28 -10
- package/dist/components/MaterialUI/DataDisplay/TableProps.js +5 -2
- package/dist/components/MaterialUI/DataDisplay/TransferList.js +5 -2
- package/dist/components/MaterialUI/DataDisplay/chipProps.js +1 -1
- package/dist/components/MaterialUI/DataDisplay/collapsableListProps.js +1 -1
- package/dist/components/MaterialUI/DataDisplay/dividerProps.js +1 -1
- package/dist/components/MaterialUI/DataDisplay/index.js +1 -1
- package/dist/components/MaterialUI/DataDisplay/modalProps.js +1 -1
- package/dist/components/MaterialUI/DataDisplay/useTableSelection.js +3 -3
- package/dist/components/MaterialUI/Feedback/useNotification.js +1 -1
- package/dist/components/MaterialUI/Inputs/Autocomplete.js +2 -2
- package/dist/components/MaterialUI/Inputs/AutocompleteProps.js +1 -1
- package/dist/components/MaterialUI/Inputs/CheckboxGroupProps.js +1 -1
- package/dist/components/MaterialUI/Inputs/CheckboxProps.js +1 -1
- package/dist/components/MaterialUI/Inputs/DatePicker.js +11 -0
- package/dist/components/MaterialUI/Inputs/InputBase.js +3 -2
- package/dist/components/MaterialUI/Inputs/InputBaseProps.js +1 -1
- package/dist/components/MaterialUI/Inputs/PredefinedElements/SearchControl.js +1 -1
- package/dist/components/MaterialUI/Inputs/RadioProps.js +1 -1
- package/dist/components/MaterialUI/Inputs/Select.js +2 -2
- package/dist/components/MaterialUI/Inputs/SelectProps.js +1 -1
- package/dist/components/MaterialUI/Inputs/Switch.js +3 -3
- package/dist/components/MaterialUI/Inputs/SwitchProps.js +1 -1
- package/dist/components/MaterialUI/Inputs/TimePicker.js +19 -8
- package/dist/components/MaterialUI/Inputs/createInput.js +3 -3
- package/dist/components/MaterialUI/Inputs/index.js +1 -1
- package/dist/components/MaterialUI/Inputs/standaloneRadioProps.js +1 -1
- package/dist/components/MaterialUI/Navigation/DropDownMenuProps.js +1 -1
- package/dist/components/MaterialUI/Navigation/TabBar.js +38 -33
- package/dist/components/MaterialUI/ScopeSelector/ScopeSelector.js +13 -5
- package/dist/components/MaterialUI/ScopeSelector/ScopeTreeView.js +8 -4
- package/dist/components/MaterialUI/ScopeSelector/TreeItem.js +9 -6
- package/dist/components/MaterialUI/Surfaces/ExpansionPanel.js +11 -2
- package/dist/components/MaterialUI/Surfaces/SectionExpansionPanel.js +10 -2
- package/dist/components/MaterialUI/Surfaces/expansionPanelProps.js +5 -2
- package/dist/components/MaterialUI/Surfaces/paperProps.js +1 -1
- package/dist/components/MaterialUI/muiThemes.js +21 -6
- package/dist/components/MaterialUI/textProps.js +1 -1
- package/dist/components/Modules.js +24 -2
- package/dist/components/MultiSelector.js +1 -1
- package/dist/components/Navigation/Bar.js +3 -3
- package/dist/components/Navigation/Tab.js +1 -1
- package/dist/components/Navigation/useNavigationState.js +30 -4
- package/dist/components/Placeholder.js +1 -1
- package/dist/components/Routing/FullPage.js +2 -0
- package/dist/components/Routing/Segment.js +4 -3
- package/dist/components/Routing/SegmentPage.js +8 -6
- package/dist/components/Routing/withWaypointing.js +10 -4
- package/dist/components/Scope/ScopeNode.js +1 -1
- package/dist/components/Scope/Selector.js +1 -1
- package/dist/components/Scope/index.js +11 -3
- package/dist/components/Scope/useScopeSelect.js +1 -1
- package/dist/components/Selector.js +1 -1
- package/dist/components/Sidepanel.js +1 -2
- package/dist/components/Spritesheet.js +1 -1
- package/dist/components/Switch.js +1 -1
- package/dist/components/Text.js +1 -1
- package/dist/components/ToastList.js +1 -1
- package/dist/components/Toolbar.js +1 -1
- package/dist/components/Treeview/Label.js +1 -1
- package/dist/components/Treeview/Leaf.js +1 -1
- package/dist/components/Treeview/Node.js +3 -3
- package/dist/components/Treeview/index.js +2 -2
- package/dist/components/Treeview/settings.js +1 -1
- package/dist/constants.js +26 -1
- package/dist/content/icons/html-templates.svg +3 -0
- package/dist/content/iconsSheet.svg +3 -0
- package/dist/getThemeOverrides.js +2 -2
- package/dist/hocs/withInfiniteScroll.js +1 -1
- package/dist/hocs/withUpdateHandler.js +2 -2
- package/dist/hooks/useDispatchWithModulesData.js +1 -1
- package/dist/hooks/useEditState.js +3 -3
- package/dist/hooks/useEntityLoader.js +182 -0
- package/dist/hooks/useFullEntityEditState.js +3 -3
- package/dist/hooks/useInfiniteScroll.js +104 -0
- package/dist/hooks/useLabelMessage.js +3 -3
- package/dist/hooks/useLoader.js +1 -0
- package/dist/hooks/useMultipleFieldEditState.js +2 -2
- package/dist/hooks/useNavigationHandler.js +1 -1
- package/dist/hooks/useNotificationRequestState.js +159 -0
- package/dist/hooks/useRequestState.js +146 -0
- package/dist/hooks/useSelectorAndUnwrap.js +1 -1
- package/dist/reducers/metadata.js +52 -26
- package/dist/reducers/requestStates.js +181 -0
- package/dist/schemas/countries.js +1 -1
- package/dist/schemas/definitions.js +1 -1
- package/dist/schemas/metadata.js +1 -1
- package/dist/schemas/productDefinitions.js +1 -1
- package/dist/schemas/timezones.js +1 -1
- package/dist/selectors/applications.js +1 -1
- package/dist/selectors/authentication.js +1 -2
- package/dist/selectors/countries.js +1 -1
- package/dist/selectors/locale.js +1 -1
- package/dist/selectors/metadata.js +117 -17
- package/dist/selectors/navigation.js +1 -1
- package/dist/selectors/requestStates.js +82 -0
- package/dist/selectors/requests.js +1 -1
- package/dist/selectors/scope.js +2 -1
- package/dist/selectors/versionInfo.js +1 -1
- package/dist/selectors/view.js +1 -1
- package/dist/sharedMessages.js +44 -0
- package/dist/spawnerMiddleware.js +1 -1
- package/dist/utils/displayModeHelper.js +1 -1
- package/dist/utils/flatten.js +2 -2
- package/dist/utils/localizationHelper.js +1 -1
- package/dist/utils/mapHelper.js +1 -1
- package/dist/utils/modelValidationHelper.js +2 -2
- package/dist/utils/parseHelper.js +1 -1
- package/dist/utils/propertyHelper.js +2 -2
- package/dist/utils/propertyValidator.js +1 -1
- package/dist/utils/setTranslation.js +27 -1
- package/dist/utils/setTranslationWithFallback.js +33 -3
- package/dist/utils/testUtils.js +6 -2
- package/dist/utils/timezoneHelper.js +111 -0
- package/dist/utils/unwrapImmutable.js +1 -1
- package/dist/utils/urlHelper.js +11 -1
- package/package.json +3 -7
- package/src/actions/makeApiAction.js +24 -1
- package/src/actions/makeApiAction.test.js +76 -3
- package/src/actions/metadata.js +130 -0
- package/src/actions/metadata.test.js +337 -5
- package/src/actions/requestState.js +8 -0
- package/src/actions/requestState.test.js +14 -0
- package/src/actions/requestsApi.js +30 -0
- package/src/buildStore.js +2 -0
- package/src/components/AppFrame/AppFrame.test.js +6 -16
- package/src/components/AppFrame/ApplicationSelector/ApplicationDialog.js +105 -82
- package/src/components/AppFrame/ApplicationSelector/ApplicationDialog.test.js +60 -23
- package/src/components/AppFrame/ApplicationSelector/ApplicationSelector.test.js +22 -89
- package/src/components/AppFrame/ApplicationSelector/index.js +34 -15
- package/src/components/AppFrame/Topbar.test.js +2 -4
- package/src/components/MaterialUI/DataDisplay/SelectionList.js +14 -6
- package/src/components/MaterialUI/DataDisplay/SelectionList.test.js +21 -11
- package/src/components/MaterialUI/DataDisplay/Table.js +29 -5
- package/src/components/MaterialUI/DataDisplay/Table.test.js +23 -0
- package/src/components/MaterialUI/DataDisplay/TableProps.js +2 -0
- package/src/components/MaterialUI/DataDisplay/TableProps.test.js +2 -0
- package/src/components/MaterialUI/DataDisplay/TransferList.js +3 -0
- package/src/components/MaterialUI/Inputs/DatePicker.js +11 -0
- package/src/components/MaterialUI/Inputs/InputBase.js +3 -1
- package/src/components/MaterialUI/Inputs/InputBase.test.js +38 -0
- package/src/components/MaterialUI/Inputs/TimePicker.js +9 -3
- package/src/components/MaterialUI/Inputs/TimePicker.test.js +263 -118
- package/src/components/MaterialUI/Navigation/TabBar.js +82 -78
- package/src/components/MaterialUI/Navigation/TabBar.test.js +129 -3
- package/src/components/MaterialUI/ScopeSelector/ScopeSelector.js +9 -3
- package/src/components/MaterialUI/ScopeSelector/ScopeSelector.test.js +29 -0
- package/src/components/MaterialUI/ScopeSelector/ScopeTreeView.js +4 -1
- package/src/components/MaterialUI/ScopeSelector/ScopeTreeView.test.js +52 -0
- package/src/components/MaterialUI/ScopeSelector/TreeItem.js +9 -6
- package/src/components/MaterialUI/ScopeSelector/TreeItem.test.js +63 -2
- package/src/components/MaterialUI/Surfaces/ExpansionPanel.js +14 -1
- package/src/components/MaterialUI/Surfaces/ExpansionPanel.test.js +16 -0
- package/src/components/MaterialUI/Surfaces/SectionExpansionPanel.js +11 -2
- package/src/components/MaterialUI/Surfaces/SectionExpansionPanel.test.js +36 -0
- package/src/components/MaterialUI/Surfaces/expansionPanelProps.js +2 -0
- package/src/components/MaterialUI/Surfaces/expansionPanelProps.test.js +2 -2
- package/src/components/MaterialUI/muiThemes.js +18 -3
- package/src/components/Modules.js +13 -1
- package/src/components/Modules.test.js +133 -1
- package/src/components/Navigation/Navigation.test.js +2 -0
- package/src/components/Navigation/useNavigationState.js +21 -1
- package/src/components/Navigation/useNavigationState.test.js +10 -0
- package/src/components/Routing/FullPage.js +2 -1
- package/src/components/Routing/FullPage.test.js +52 -0
- package/src/components/Routing/Segment.js +5 -2
- package/src/components/Routing/Segment.test.js +22 -1
- package/src/components/Routing/SegmentPage.js +12 -4
- package/src/components/Routing/SubPage.test.js +1 -1
- package/src/components/Routing/withWaypointing.js +19 -17
- package/src/components/Routing/withWaypointing.test.js +50 -0
- package/src/components/Scope/Scope.test.js +117 -0
- package/src/components/Scope/index.js +6 -10
- package/src/components/Sidepanel.js +0 -1
- package/src/components/Sidepanel.test.js +0 -3
- package/src/constants.js +18 -0
- package/src/content/icons/html-templates.svg +3 -0
- package/src/content/iconsSheet.svg +3 -0
- package/src/hooks/useEntityLoader.js +68 -0
- package/src/hooks/useEntityLoader.test.js +266 -0
- package/src/hooks/useInfiniteScroll.js +25 -0
- package/src/hooks/useInfiniteScroll.test.js +87 -0
- package/src/hooks/useLoader.js +1 -0
- package/src/hooks/useNotificationRequestState.js +78 -0
- package/src/hooks/useNotificationRequestState.test.js +264 -0
- package/src/hooks/useRequestState.js +57 -0
- package/src/hooks/useRequestState.test.js +217 -0
- package/src/reducers/metadata.js +76 -16
- package/src/reducers/metadata.test.js +458 -4
- package/src/reducers/requestStates.js +98 -0
- package/src/reducers/requestStates.test.js +399 -0
- package/src/selectors/authentication.js +0 -1
- package/src/selectors/locale.test.js +0 -2
- package/src/selectors/metadata.js +90 -19
- package/src/selectors/metadata.test.js +532 -123
- package/src/selectors/requestStates.js +12 -0
- package/src/selectors/requestStates.test.js +83 -0
- package/src/selectors/scope.js +1 -1
- package/src/sharedMessages.js +44 -0
- package/src/translations/en-US.json +12 -1
- package/src/translations/fr-CA.json +13 -2
- package/src/utils/modelValidationHelper.js +1 -1
- package/src/utils/setTranslation.js +16 -1
- package/src/utils/setTranslation.test.js +24 -0
- package/src/utils/setTranslationWithFallback.js +19 -2
- package/src/utils/setTranslationWithFallback.test.js +104 -6
- package/src/utils/testUtils.js +3 -1
- package/src/utils/timezoneHelper.js +140 -0
- package/src/utils/timezoneHelper.test.js +33 -0
- package/src/utils/urlHelper.js +6 -0
- package/src/translations/it-IT.json +0 -54
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
|
-
exports.
|
|
4
|
+
exports.setTranslationWithFallbackValue = exports.setTranslationWithFallbackField = void 0;
|
|
5
5
|
|
|
6
6
|
var _flatten = require("./flatten");
|
|
7
7
|
|
|
@@ -15,6 +15,12 @@ var _flatten = require("./flatten");
|
|
|
15
15
|
enterModule && enterModule(module);
|
|
16
16
|
})();
|
|
17
17
|
|
|
18
|
+
function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
19
|
+
|
|
20
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
21
|
+
|
|
22
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
23
|
+
|
|
18
24
|
var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
|
|
19
25
|
return a;
|
|
20
26
|
};
|
|
@@ -24,12 +30,36 @@ var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoader
|
|
|
24
30
|
};
|
|
25
31
|
|
|
26
32
|
var setTranslationWithFallbackValue = function setTranslationWithFallbackValue(locale, obj, fallbackValue) {
|
|
33
|
+
if (!obj) return obj;
|
|
34
|
+
|
|
27
35
|
for (var _len = arguments.length, field = new Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++) {
|
|
28
36
|
field[_key - 3] = arguments[_key];
|
|
29
37
|
}
|
|
30
38
|
|
|
31
|
-
|
|
32
|
-
|
|
39
|
+
var localeValue = obj.getIn((0, _flatten.flatten)([field, locale]));
|
|
40
|
+
|
|
41
|
+
if (!localeValue && locale.includes("-")) {
|
|
42
|
+
var fieldValue = obj.getIn((0, _flatten.flatten)([field]));
|
|
43
|
+
|
|
44
|
+
if (fieldValue) {
|
|
45
|
+
var fieldKeys = fieldValue.keys();
|
|
46
|
+
var language = locale.substring(0, locale.indexOf("-"));
|
|
47
|
+
|
|
48
|
+
for (var _iterator = _createForOfIteratorHelperLoose(fieldKeys), _step; !(_step = _iterator()).done;) {
|
|
49
|
+
var key = _step.value;
|
|
50
|
+
|
|
51
|
+
if (key !== locale && key.startsWith(language)) {
|
|
52
|
+
localeValue = obj.getIn((0, _flatten.flatten)([field, key]));
|
|
53
|
+
|
|
54
|
+
if (localeValue) {
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
var value = localeValue || fallbackValue || "";
|
|
33
63
|
return obj.setIn((0, _flatten.flatten)([field]), value);
|
|
34
64
|
};
|
|
35
65
|
|
package/dist/utils/testUtils.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
|
+
exports.createMuiTheme = exports.TestWrapper = exports.PropStruct = void 0;
|
|
4
5
|
exports.extractMessages = extractMessages;
|
|
5
|
-
exports.
|
|
6
|
+
exports.spyOnConsole = exports.ignoreConsoleError = exports.getStyledClassSelector = exports.getElmClasses = exports.getClassSelector = exports.getClassName = exports.generateClassName = exports.firstItemComparator = void 0;
|
|
6
7
|
|
|
7
8
|
var _react = _interopRequireDefault(require("react"));
|
|
8
9
|
|
|
@@ -256,10 +257,13 @@ var TestWrapper = function TestWrapper(_ref3) {
|
|
|
256
257
|
};
|
|
257
258
|
|
|
258
259
|
var MuiThemeProviderWrapper = function MuiThemeProviderWrapper(_ref7) {
|
|
260
|
+
var _muiThemeProvider$the;
|
|
261
|
+
|
|
259
262
|
var children = _ref7.children;
|
|
260
263
|
if (muiThemeProvider == null) return children;
|
|
264
|
+
var theme = (_muiThemeProvider$the = muiThemeProvider.theme) != null ? _muiThemeProvider$the : createMuiTheme();
|
|
261
265
|
return /*#__PURE__*/_react.default.createElement(_core.MuiThemeProvider, {
|
|
262
|
-
theme:
|
|
266
|
+
theme: theme
|
|
263
267
|
}, children);
|
|
264
268
|
};
|
|
265
269
|
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.timeZonesList = exports.getTimeZoneName = exports.getTimeZoneByName = exports.getTimeZone = void 0;
|
|
5
|
+
|
|
6
|
+
(function () {
|
|
7
|
+
var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
|
|
8
|
+
enterModule && enterModule(module);
|
|
9
|
+
})();
|
|
10
|
+
|
|
11
|
+
(function () {
|
|
12
|
+
var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
|
|
13
|
+
enterModule && enterModule(module);
|
|
14
|
+
})();
|
|
15
|
+
|
|
16
|
+
function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
17
|
+
|
|
18
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
19
|
+
|
|
20
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
21
|
+
|
|
22
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
23
|
+
|
|
24
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
25
|
+
|
|
26
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
27
|
+
|
|
28
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
29
|
+
|
|
30
|
+
var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
|
|
31
|
+
return a;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
|
|
35
|
+
return a;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
var getTimeZone = function getTimeZone() {
|
|
39
|
+
return Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
exports.getTimeZone = getTimeZone;
|
|
43
|
+
|
|
44
|
+
var getTimeZoneByName = function getTimeZoneByName(name) {
|
|
45
|
+
for (var _iterator = _createForOfIteratorHelperLoose(timeZonesList.entries()), _step; !(_step = _iterator()).done;) {
|
|
46
|
+
var _ref3 = _step.value;
|
|
47
|
+
|
|
48
|
+
var _ref2 = _slicedToArray(_ref3, 2);
|
|
49
|
+
|
|
50
|
+
var key = _ref2[0];
|
|
51
|
+
var value = _ref2[1];
|
|
52
|
+
if (value === name) return key;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return getTimeZone();
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
exports.getTimeZoneByName = getTimeZoneByName;
|
|
59
|
+
|
|
60
|
+
var getTimeZoneName = function getTimeZoneName() {
|
|
61
|
+
var customerTimezone = getTimeZone();
|
|
62
|
+
var timezoneName = timeZonesList.get(customerTimezone);
|
|
63
|
+
return timezoneName;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
exports.getTimeZoneName = getTimeZoneName;
|
|
67
|
+
var timeZonesList = new Map([["Africa/Bangui", "W. Central Africa Standard Time"], ["Africa/Cairo", "Egypt Standard Time"], ["Africa/Casablanca", "Morocco Standard Time"], ["Africa/Harare", "South Africa Standard Time"], ["Africa/Johannesburg", "South Africa Standard Time"], ["Africa/Lagos", "W. Central Africa Standard Time"], ["Africa/Monrovia", "Greenwich Standard Time"], ["Africa/Nairobi", "E. Africa Standard Time"], ["Africa/Windhoek", "Namibia Standard Time"], ["America/Anchorage", "Alaskan Standard Time"], ["America/Argentina/San_Juan", "Argentina Standard Time"], ["America/Asuncion", "Paraguay Standard Time"], ["America/Bahia", "Bahia Standard Time"], ["America/Bogota", "SA Pacific Standard Time"], ["America/Buenos_Aires", "Argentina Standard Time"], ["America/Caracas", "Venezuela Standard Time"], ["America/Cayenne", "SA Eastern Standard Time"], ["America/Chicago", "Central Standard Time"], ["America/Chihuahua", "Mountain Standard Time (Mexico)"], ["America/Cuiaba", "Central Brazilian Standard Time"], ["America/Denver", "Mountain Standard Time"], ["America/Fortaleza", "SA Eastern Standard Time"], ["America/Godthab", "Greenland Standard Time"], ["America/Guatemala", "Central America Standard Time"], ["America/Halifax", "Atlantic Standard Time"], ["America/Indianapolis", "US Eastern Standard Time"], ["America/Indiana/Indianapolis", "US Eastern Standard Time"], ["America/La_Paz", "SA Western Standard Time"], ["America/Los_Angeles", "Pacific Standard Time"], ["America/Mexico_City", "Mexico Standard Time"], ["America/Montevideo", "Montevideo Standard Time"], ["America/New_York", "Eastern Standard Time"], ["America/Noronha", "UTC-02"], ["America/Phoenix", "US Mountain Standard Time"], ["America/Regina", "Canada Central Standard Time"], ["America/Santa_Isabel", "Pacific Standard Time (Mexico)"], ["America/Santiago", "Pacific SA Standard Time"], ["America/Sao_Paulo", "E. South America Standard Time"], ["America/St_Johns", "Newfoundland Standard Time"], ["America/Tijuana", "Pacific Standard Time"], ["Antarctica/McMurdo", "New Zealand Standard Time"], ["Atlantic/South_Georgia", "UTC-02"], ["Asia/Almaty", "Central Asia Standard Time"], ["Asia/Amman", "Jordan Standard Time"], ["Asia/Baghdad", "Arabic Standard Time"], ["Asia/Baku", "Azerbaijan Standard Time"], ["Asia/Bangkok", "SE Asia Standard Time"], ["Asia/Beirut", "Middle East Standard Time"], ["Asia/Calcutta", "India Standard Time"], ["Asia/Colombo", "Sri Lanka Standard Time"], ["Asia/Damascus", "Syria Standard Time"], ["Asia/Dhaka", "Bangladesh Standard Time"], ["Asia/Dubai", "Arabian Standard Time"], ["Asia/Irkutsk", "North Asia East Standard Time"], ["Asia/Jerusalem", "Israel Standard Time"], ["Asia/Kabul", "Afghanistan Standard Time"], ["Asia/Kamchatka", "Kamchatka Standard Time"], ["Asia/Karachi", "Pakistan Standard Time"], ["Asia/Katmandu", "Nepal Standard Time"], ["Asia/Kolkata", "India Standard Time"], ["Asia/Krasnoyarsk", "North Asia Standard Time"], ["Asia/Kuala_Lumpur", "Singapore Standard Time"], ["Asia/Kuwait", "Arab Standard Time"], ["Asia/Magadan", "Magadan Standard Time"], ["Asia/Muscat", "Arabian Standard Time"], ["Asia/Novosibirsk", "N. Central Asia Standard Time"], ["Asia/Oral", "West Asia Standard Time"], ["Asia/Rangoon", "Myanmar Standard Time"], ["Asia/Riyadh", "Arab Standard Time"], ["Asia/Seoul", "Korea Standard Time"], ["Asia/Shanghai", "China Standard Time"], ["Asia/Singapore", "Singapore Standard Time"], ["Asia/Taipei", "Taipei Standard Time"], ["Asia/Tashkent", "West Asia Standard Time"], ["Asia/Tbilisi", "Georgian Standard Time"], ["Asia/Tehran", "Iran Standard Time"], ["Asia/Tokyo", "Tokyo Standard Time"], ["Asia/Ulaanbaatar", "Ulaanbaatar Standard Time"], ["Asia/Vladivostok", "Vladivostok Standard Time"], ["Asia/Yakutsk", "Yakutsk Standard Time"], ["Asia/Yekaterinburg", "Ekaterinburg Standard Time"], ["Asia/Yerevan", "Armenian Standard Time"], ["Atlantic/Azores", "Azores Standard Time"], ["Atlantic/Cape_Verde", "Cape Verde Standard Time"], ["Atlantic/Reykjavik", "Greenwich Standard Time"], ["Australia/Adelaide", "Cen. Australia Standard Time"], ["Australia/Brisbane", "E. Australia Standard Time"], ["Australia/Darwin", "AUS Central Standard Time"], ["Australia/Hobart", "Tasmania Standard Time"], ["Australia/Perth", "W. Australia Standard Time"], ["Australia/Sydney", "AUS Eastern Standard Time"], ["UTC", "UTC"], ["Etc/GMT+11", "UTC-11"], ["Etc/GMT+12", "Dateline Standard Time"], ["Etc/GMT+2", "UTC-02"], ["Etc/GMT-12", "UTC+12"], ["Europe/Amsterdam", "W. Europe Standard Time"], ["Europe/Athens", "GTB Standard Time"], ["Europe/Belgrade", "Central Europe Standard Time"], ["Europe/Berlin", "W. Europe Standard Time"], ["Europe/Brussels", "Romance Standard Time"], ["Europe/Budapest", "Central Europe Standard Time"], ["Europe/Dublin", "GMT Standard Time"], ["Europe/Helsinki", "FLE Standard Time"], ["Europe/Istanbul", "GTB Standard Time"], ["Europe/Kiev", "FLE Standard Time"], ["Europe/London", "GMT Standard Time"], ["Europe/Minsk", "E. Europe Standard Time"], ["Europe/Moscow", "Russian Standard Time"], ["Europe/Paris", "Romance Standard Time"], ["Europe/Sarajevo", "Central European Standard Time"], ["Europe/Warsaw", "Central European Standard Time"], ["Indian/Mauritius", "Mauritius Standard Time"], ["Pacific/Apia", "Samoa Standard Time"], ["Pacific/Auckland", "New Zealand Standard Time"], ["Pacific/Fiji", "Fiji Standard Time"], ["Pacific/Guadalcanal", "Central Pacific Standard Time"], ["Pacific/Guam", "West Pacific Standard Time"], ["Pacific/Honolulu", "Hawaiian Standard Time"], ["Pacific/Pago_Pago", "UTC-11"], ["Pacific/Port_Moresby", "West Pacific Standard Time"], ["Pacific/Tongatapu", "Tonga Standard Time"]]);
|
|
68
|
+
exports.timeZonesList = timeZonesList;
|
|
69
|
+
;
|
|
70
|
+
|
|
71
|
+
(function () {
|
|
72
|
+
var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;
|
|
73
|
+
|
|
74
|
+
if (!reactHotLoader) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
reactHotLoader.register(getTimeZone, "getTimeZone", "/home/vsts/work/1/s/src/utils/timezoneHelper.js");
|
|
79
|
+
reactHotLoader.register(getTimeZoneByName, "getTimeZoneByName", "/home/vsts/work/1/s/src/utils/timezoneHelper.js");
|
|
80
|
+
reactHotLoader.register(getTimeZoneName, "getTimeZoneName", "/home/vsts/work/1/s/src/utils/timezoneHelper.js");
|
|
81
|
+
reactHotLoader.register(timeZonesList, "timeZonesList", "/home/vsts/work/1/s/src/utils/timezoneHelper.js");
|
|
82
|
+
})();
|
|
83
|
+
|
|
84
|
+
;
|
|
85
|
+
|
|
86
|
+
(function () {
|
|
87
|
+
var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
|
|
88
|
+
leaveModule && leaveModule(module);
|
|
89
|
+
})();
|
|
90
|
+
|
|
91
|
+
;
|
|
92
|
+
|
|
93
|
+
(function () {
|
|
94
|
+
var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;
|
|
95
|
+
|
|
96
|
+
if (!reactHotLoader) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
reactHotLoader.register(getTimeZone, "getTimeZone", "/home/vsts/work/1/s/src/utils/timezoneHelper.js");
|
|
101
|
+
reactHotLoader.register(getTimeZoneByName, "getTimeZoneByName", "/home/vsts/work/1/s/src/utils/timezoneHelper.js");
|
|
102
|
+
reactHotLoader.register(getTimeZoneName, "getTimeZoneName", "/home/vsts/work/1/s/src/utils/timezoneHelper.js");
|
|
103
|
+
reactHotLoader.register(timeZonesList, "timeZonesList", "/home/vsts/work/1/s/src/utils/timezoneHelper.js");
|
|
104
|
+
})();
|
|
105
|
+
|
|
106
|
+
;
|
|
107
|
+
|
|
108
|
+
(function () {
|
|
109
|
+
var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
|
|
110
|
+
leaveModule && leaveModule(module);
|
|
111
|
+
})();
|
package/dist/utils/urlHelper.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
|
-
exports.tryGetNewEntityIdKey = exports.
|
|
4
|
+
exports.tryGetNewEntityIdKey = exports.resolveEntityId = exports.getValueFromUrlByKey = exports.NEW_ENTITY_URL_KEY = void 0;
|
|
5
5
|
|
|
6
6
|
(function () {
|
|
7
7
|
var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
|
|
@@ -59,6 +59,14 @@ var tryGetNewEntityIdKey = function tryGetNewEntityIdKey(url) {
|
|
|
59
59
|
};
|
|
60
60
|
|
|
61
61
|
exports.tryGetNewEntityIdKey = tryGetNewEntityIdKey;
|
|
62
|
+
|
|
63
|
+
var resolveEntityId = function resolveEntityId(url, path, entityIdKey) {
|
|
64
|
+
var newKey = tryGetNewEntityIdKey(url);
|
|
65
|
+
var key = entityIdKey === newKey ? entityIdKey : ":".concat(entityIdKey);
|
|
66
|
+
return getValueFromUrlByKey(url, path, key);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
exports.resolveEntityId = resolveEntityId;
|
|
62
70
|
;
|
|
63
71
|
|
|
64
72
|
(function () {
|
|
@@ -71,6 +79,7 @@ exports.tryGetNewEntityIdKey = tryGetNewEntityIdKey;
|
|
|
71
79
|
reactHotLoader.register(getValueFromUrlByKey, "getValueFromUrlByKey", "/home/vsts/work/1/s/src/utils/urlHelper.js");
|
|
72
80
|
reactHotLoader.register(NEW_ENTITY_URL_KEY, "NEW_ENTITY_URL_KEY", "/home/vsts/work/1/s/src/utils/urlHelper.js");
|
|
73
81
|
reactHotLoader.register(tryGetNewEntityIdKey, "tryGetNewEntityIdKey", "/home/vsts/work/1/s/src/utils/urlHelper.js");
|
|
82
|
+
reactHotLoader.register(resolveEntityId, "resolveEntityId", "/home/vsts/work/1/s/src/utils/urlHelper.js");
|
|
74
83
|
})();
|
|
75
84
|
|
|
76
85
|
;
|
|
@@ -92,6 +101,7 @@ exports.tryGetNewEntityIdKey = tryGetNewEntityIdKey;
|
|
|
92
101
|
reactHotLoader.register(getValueFromUrlByKey, "getValueFromUrlByKey", "/home/vsts/work/1/s/src/utils/urlHelper.js");
|
|
93
102
|
reactHotLoader.register(NEW_ENTITY_URL_KEY, "NEW_ENTITY_URL_KEY", "/home/vsts/work/1/s/src/utils/urlHelper.js");
|
|
94
103
|
reactHotLoader.register(tryGetNewEntityIdKey, "tryGetNewEntityIdKey", "/home/vsts/work/1/s/src/utils/urlHelper.js");
|
|
104
|
+
reactHotLoader.register(resolveEntityId, "resolveEntityId", "/home/vsts/work/1/s/src/utils/urlHelper.js");
|
|
95
105
|
})();
|
|
96
106
|
|
|
97
107
|
;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "orc-shared",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "Shared code for Orckestra applications",
|
|
5
5
|
"main": "./src/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -45,17 +45,13 @@
|
|
|
45
45
|
{
|
|
46
46
|
"language": "Français",
|
|
47
47
|
"cultureIso": "fr-CA"
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
"language": "Italiano",
|
|
51
|
-
"cultureIso": "it-IT"
|
|
52
48
|
}
|
|
53
49
|
],
|
|
54
50
|
"devDependencies": {
|
|
55
|
-
"orc-scripts": "1.2.0
|
|
51
|
+
"orc-scripts": "1.2.0"
|
|
56
52
|
},
|
|
57
53
|
"peerDependencies": {
|
|
58
|
-
"orc-scripts": "1.2.0
|
|
54
|
+
"orc-scripts": "1.2.0"
|
|
59
55
|
},
|
|
60
56
|
"sideEffects": false,
|
|
61
57
|
"lint-staged": {
|
|
@@ -1,7 +1,30 @@
|
|
|
1
|
-
import { RSAA } from "redux-api-middleware";
|
|
1
|
+
import { RSAA, getJSON, ApiError } from "redux-api-middleware";
|
|
2
|
+
|
|
3
|
+
export const getJSONWithValidBody = async res => {
|
|
4
|
+
const contentType = res.headers.get("Content-Type");
|
|
5
|
+
const possiblyEmptyCodes = [404];
|
|
6
|
+
|
|
7
|
+
if (~possiblyEmptyCodes.indexOf(res.status) && contentType && ~contentType.indexOf("json")) {
|
|
8
|
+
const value = await res.text();
|
|
9
|
+
|
|
10
|
+
if (value === null || value === undefined || value === "") {
|
|
11
|
+
return value;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return JSON.parse(value);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return getJSON(res);
|
|
18
|
+
};
|
|
2
19
|
|
|
3
20
|
export const makeActionTypes = name => [`${name}_REQUEST`, `${name}_SUCCESS`, `${name}_FAILURE`];
|
|
4
21
|
|
|
22
|
+
export const makeFailureActionType = actionType => ({
|
|
23
|
+
type: actionType,
|
|
24
|
+
payload: (action, state, res) =>
|
|
25
|
+
getJSONWithValidBody(res).then(json => new ApiError(res.status, res.statusText, json)),
|
|
26
|
+
});
|
|
27
|
+
|
|
5
28
|
const addMeta = meta => type => ({ type, meta });
|
|
6
29
|
|
|
7
30
|
export const makeApiAction = (name, endpoint, method = "GET", configuration = {}) => {
|
|
@@ -1,16 +1,89 @@
|
|
|
1
1
|
import sinon from "sinon";
|
|
2
|
-
import { makeActionTypes, makeApiAction } from "./makeApiAction";
|
|
3
|
-
import { RSAA } from "redux-api-middleware";
|
|
2
|
+
import { getJSONWithValidBody, makeActionTypes, makeApiAction, makeFailureActionType } from "./makeApiAction";
|
|
3
|
+
import { RSAA, ApiError } from "redux-api-middleware";
|
|
4
|
+
|
|
5
|
+
const getTestResponse = (extra = {}, contentType = null) => ({
|
|
6
|
+
headers: {
|
|
7
|
+
"Content-Type": contentType ?? "application/json",
|
|
8
|
+
get: function (key) {
|
|
9
|
+
return this[key];
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
json: () => ({ key1: "value1", key2: "value2" }),
|
|
13
|
+
text: () => '{"key1": "value1", "key2": "value2"}',
|
|
14
|
+
status: 200,
|
|
15
|
+
statusText: "a status text",
|
|
16
|
+
message: "a Message",
|
|
17
|
+
...extra,
|
|
18
|
+
});
|
|
4
19
|
|
|
5
20
|
describe("makeActionTypes", () => {
|
|
6
21
|
it("returns an array with three action types in the form used by RSAAs", () =>
|
|
7
|
-
expect(makeActionTypes, "when called with", ["ACTION_NAME"], "to
|
|
22
|
+
expect(makeActionTypes, "when called with", ["ACTION_NAME"], "to satisfy", [
|
|
8
23
|
"ACTION_NAME_REQUEST",
|
|
9
24
|
"ACTION_NAME_SUCCESS",
|
|
10
25
|
"ACTION_NAME_FAILURE",
|
|
11
26
|
]));
|
|
12
27
|
});
|
|
13
28
|
|
|
29
|
+
describe("makeFailureActionType", () => {
|
|
30
|
+
it("returns a failure action type with a payload override", () =>
|
|
31
|
+
expect(makeFailureActionType, "when called with", ["ACTION_NAME_FAILURE"], "to satisfy", {
|
|
32
|
+
type: "ACTION_NAME_FAILURE",
|
|
33
|
+
payload: expect.it("to be a function"),
|
|
34
|
+
}));
|
|
35
|
+
|
|
36
|
+
it("handles failure payload function", async () => {
|
|
37
|
+
const actionType = makeFailureActionType("ACTION_NAME_FAILURE");
|
|
38
|
+
|
|
39
|
+
const testResponse = getTestResponse();
|
|
40
|
+
|
|
41
|
+
const apiError = new ApiError(testResponse.status, testResponse.statusText, testResponse.json());
|
|
42
|
+
|
|
43
|
+
const result = await actionType.payload("ACTION_NAME_FAILURE", {}, testResponse);
|
|
44
|
+
|
|
45
|
+
expect(result, "to equal", apiError);
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
describe("getJSONWithValidBody", () => {
|
|
50
|
+
it("return a resolved promise by default when called with basic response", async () => {
|
|
51
|
+
const result = await getJSONWithValidBody(getTestResponse());
|
|
52
|
+
|
|
53
|
+
expect(result, "to equal", { key1: "value1", key2: "value2" });
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it("return a resolved promise by default when called with 404 response, a body and another content type", async () => {
|
|
57
|
+
const result = await getJSONWithValidBody(getTestResponse({ status: 404 }, "fakeContentType"));
|
|
58
|
+
|
|
59
|
+
expect(result, "to be", undefined);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it("return a resolved promise by default when called with 404 response and a body", async () => {
|
|
63
|
+
const result = await getJSONWithValidBody(getTestResponse({ status: 404 }));
|
|
64
|
+
|
|
65
|
+
expect(result, "to equal", { key1: "value1", key2: "value2" });
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it("return a resolved promise by default when called with 404 response and null body", async () => {
|
|
69
|
+
const result = await getJSONWithValidBody(getTestResponse({ status: 404, text: () => null }));
|
|
70
|
+
|
|
71
|
+
expect(result, "to equal", null);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it("return a resolved promise by default when called with 404 response and undefined body", async () => {
|
|
75
|
+
const result = await getJSONWithValidBody(getTestResponse({ status: 404, text: () => undefined }));
|
|
76
|
+
|
|
77
|
+
expect(result, "to equal", undefined);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it("return a resolved promise by default when called with 404 response and empty body", async () => {
|
|
81
|
+
const result = await getJSONWithValidBody(getTestResponse({ status: 404, text: () => "" }));
|
|
82
|
+
|
|
83
|
+
expect(result, "to equal", "");
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
|
|
14
87
|
describe("makeApiActions", () => {
|
|
15
88
|
it("creates a basic RSAA", () =>
|
|
16
89
|
expect(makeApiAction, "when called with", ["TEST_ACTION", "/mock/endpoint"], "to equal", {
|
package/src/actions/metadata.js
CHANGED
|
@@ -8,6 +8,14 @@ import {
|
|
|
8
8
|
getOrderDefinitionRequest,
|
|
9
9
|
getProfileAttributeGroupsRequest,
|
|
10
10
|
getProductDefinitionsRequest,
|
|
11
|
+
updateOrderLookupTypeDefinitionRequest,
|
|
12
|
+
updateCustomerLookupTypeDefinitionRequest,
|
|
13
|
+
createEntityTypeRequest,
|
|
14
|
+
updateEntityTypeRequest,
|
|
15
|
+
createOrderLookupTypeDefinitionRequest,
|
|
16
|
+
createCustomerLookupTypeDefinitionRequest,
|
|
17
|
+
getCustomerLookupRequest,
|
|
18
|
+
getOrderLookupRequest,
|
|
11
19
|
} from "./requestsApi";
|
|
12
20
|
|
|
13
21
|
export const lookupsPageLength = 20;
|
|
@@ -19,6 +27,50 @@ export const [GET_ORDER_LOOKUPS_REQUEST, GET_ORDER_LOOKUPS_SUCCESS, GET_ORDER_LO
|
|
|
19
27
|
|
|
20
28
|
export const getOrderLookups = () => makeOrcApiAction(GET_ORDER_LOOKUPS, getOrderLookupsRequest.buildUrl());
|
|
21
29
|
|
|
30
|
+
const GET_ORDER_LOOKUP = "GET_ORDER_LOOKUP";
|
|
31
|
+
|
|
32
|
+
export const [GET_ORDER_LOOKUP_REQUEST, GET_ORDER_LOOKUP_SUCCESS, GET_ORDER_LOOKUP_FAILURE] =
|
|
33
|
+
makeActionTypes(GET_ORDER_LOOKUP);
|
|
34
|
+
|
|
35
|
+
export const getOrderLookup = lookupName =>
|
|
36
|
+
makeOrcApiAction(GET_ORDER_LOOKUP, getOrderLookupRequest.buildUrl(lookupName));
|
|
37
|
+
|
|
38
|
+
const SAVE_ORDER_LOOKUP = "SAVE_ORDER_LOOKUP";
|
|
39
|
+
|
|
40
|
+
export const [SAVE_ORDER_LOOKUP_REQUEST, SAVE_ORDER_LOOKUP_SUCCESS, SAVE_ORDER_LOOKUP_FAILURE] =
|
|
41
|
+
makeActionTypes(SAVE_ORDER_LOOKUP);
|
|
42
|
+
|
|
43
|
+
export const saveOrderLookup = (lookup, additionalActionContext = null) =>
|
|
44
|
+
makeOrcApiAction(
|
|
45
|
+
SAVE_ORDER_LOOKUP,
|
|
46
|
+
updateOrderLookupTypeDefinitionRequest.buildUrl(lookup.lookupName),
|
|
47
|
+
updateOrderLookupTypeDefinitionRequest.verb,
|
|
48
|
+
{
|
|
49
|
+
body: lookup,
|
|
50
|
+
meta: {
|
|
51
|
+
...additionalActionContext,
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
const ADD_ORDER_LOOKUP = "ADD_ORDER_LOOKUP";
|
|
57
|
+
|
|
58
|
+
export const [ADD_ORDER_LOOKUP_REQUEST, ADD_ORDER_LOOKUP_SUCCESS, ADD_ORDER_LOOKUP_FAILURE] =
|
|
59
|
+
makeActionTypes(ADD_ORDER_LOOKUP);
|
|
60
|
+
|
|
61
|
+
export const addOrderLookup = (lookup, additionalActionContext = null) =>
|
|
62
|
+
makeOrcApiAction(
|
|
63
|
+
ADD_ORDER_LOOKUP,
|
|
64
|
+
createOrderLookupTypeDefinitionRequest.buildUrl(lookup.lookupName),
|
|
65
|
+
createOrderLookupTypeDefinitionRequest.verb,
|
|
66
|
+
{
|
|
67
|
+
body: lookup,
|
|
68
|
+
meta: {
|
|
69
|
+
...additionalActionContext,
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
);
|
|
73
|
+
|
|
22
74
|
export const SET_PAGED_ORDER_LOOKUPS_CURRENT_INFO = "SET_PAGED_ORDER_LOOKUPS_CURRENT_INFO";
|
|
23
75
|
|
|
24
76
|
export const setPagedOrderLookupsCurrentInfo = (page = 1, resetList = false) => ({
|
|
@@ -49,6 +101,14 @@ export const [GET_CUSTOMER_LOOKUPS_REQUEST, GET_CUSTOMER_LOOKUPS_SUCCESS, GET_CU
|
|
|
49
101
|
|
|
50
102
|
export const getCustomerLookups = () => makeOrcApiAction(GET_CUSTOMER_LOOKUPS, getCustomerLookupsRequest.buildUrl());
|
|
51
103
|
|
|
104
|
+
const GET_CUSTOMER_LOOKUP = "GET_CUSTOMER_LOOKUP";
|
|
105
|
+
|
|
106
|
+
export const [GET_CUSTOMER_LOOKUP_REQUEST, GET_CUSTOMER_LOOKUP_SUCCESS, GET_CUSTOMER_LOOKUP_FAILURE] =
|
|
107
|
+
makeActionTypes(GET_CUSTOMER_LOOKUP);
|
|
108
|
+
|
|
109
|
+
export const getCustomerLookup = lookupName =>
|
|
110
|
+
makeOrcApiAction(GET_CUSTOMER_LOOKUP, getCustomerLookupRequest.buildUrl(lookupName));
|
|
111
|
+
|
|
52
112
|
const GET_PRODUCT_LOOKUPS = "GET_PRODUCT_LOOKUPS";
|
|
53
113
|
|
|
54
114
|
export const [GET_PRODUCT_LOOKUPS_REQUEST, GET_PRODUCT_LOOKUPS_SUCCESS, GET_PRODUCT_LOOKUPS_FAILURE] =
|
|
@@ -56,6 +116,42 @@ export const [GET_PRODUCT_LOOKUPS_REQUEST, GET_PRODUCT_LOOKUPS_SUCCESS, GET_PROD
|
|
|
56
116
|
|
|
57
117
|
export const getProductLookups = () => makeOrcApiAction(GET_PRODUCT_LOOKUPS, getProductLookupsRequest.buildUrl());
|
|
58
118
|
|
|
119
|
+
const SAVE_CUSTOMER_LOOKUP = "SAVE_CUSTOMER_LOOKUP";
|
|
120
|
+
|
|
121
|
+
export const [SAVE_CUSTOMER_LOOKUP_REQUEST, SAVE_CUSTOMER_LOOKUP_SUCCESS, SAVE_CUSTOMER_LOOKUP_FAILURE] =
|
|
122
|
+
makeActionTypes(SAVE_CUSTOMER_LOOKUP);
|
|
123
|
+
|
|
124
|
+
export const saveCustomerLookup = (lookup, additionalActionContext = null) =>
|
|
125
|
+
makeOrcApiAction(
|
|
126
|
+
SAVE_CUSTOMER_LOOKUP,
|
|
127
|
+
updateCustomerLookupTypeDefinitionRequest.buildUrl(lookup.lookupName),
|
|
128
|
+
updateCustomerLookupTypeDefinitionRequest.verb,
|
|
129
|
+
{
|
|
130
|
+
body: lookup,
|
|
131
|
+
meta: {
|
|
132
|
+
...additionalActionContext,
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
const ADD_CUSTOMER_LOOKUP = "ADD_CUSTOMER_LOOKUP";
|
|
138
|
+
|
|
139
|
+
export const [ADD_CUSTOMER_LOOKUP_REQUEST, ADD_CUSTOMER_LOOKUP_SUCCESS, ADD_CUSTOMER_LOOKUP_FAILURE] =
|
|
140
|
+
makeActionTypes(ADD_CUSTOMER_LOOKUP);
|
|
141
|
+
|
|
142
|
+
export const addCustomerLookup = (lookup, additionalActionContext = null) =>
|
|
143
|
+
makeOrcApiAction(
|
|
144
|
+
ADD_CUSTOMER_LOOKUP,
|
|
145
|
+
createCustomerLookupTypeDefinitionRequest.buildUrl(lookup.lookupName),
|
|
146
|
+
createCustomerLookupTypeDefinitionRequest.verb,
|
|
147
|
+
{
|
|
148
|
+
body: lookup,
|
|
149
|
+
meta: {
|
|
150
|
+
...additionalActionContext,
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
);
|
|
154
|
+
|
|
59
155
|
const GET_CUSTOMER_DEFINITIONS = "GET_CUSTOMER_DEFINITIONS";
|
|
60
156
|
export const [GET_CUSTOMER_DEFINITIONS_REQUEST, GET_CUSTOMER_DEFINITIONS_SUCCESS, GET_CUSTOMER_DEFINITIONS_FAILURE] =
|
|
61
157
|
makeActionTypes(GET_CUSTOMER_DEFINITIONS);
|
|
@@ -105,3 +201,37 @@ export const incrementCustomerLookupsPage = pageToLoad => ({
|
|
|
105
201
|
type: INCREMENT_CUSTOMER_LOOKUPS_PAGE,
|
|
106
202
|
pageToLoad: pageToLoad,
|
|
107
203
|
});
|
|
204
|
+
|
|
205
|
+
const CREATE_PROFILE_DEFINITION = "CREATE_PROFILE_DEFINITION";
|
|
206
|
+
export const [CREATE_PROFILE_DEFINITION_REQUEST, CREATE_PROFILE_DEFINITION_SUCCESS, CREATE_PROFILE_DEFINITION_FAILURE] =
|
|
207
|
+
makeActionTypes(CREATE_PROFILE_DEFINITION);
|
|
208
|
+
|
|
209
|
+
export const createProfileDefinition = (definition, additionalActionContext = null) =>
|
|
210
|
+
makeOrcApiAction(
|
|
211
|
+
CREATE_PROFILE_DEFINITION,
|
|
212
|
+
createEntityTypeRequest.buildUrl(definition.entityTypeName),
|
|
213
|
+
createEntityTypeRequest.verb,
|
|
214
|
+
{
|
|
215
|
+
body: definition,
|
|
216
|
+
meta: {
|
|
217
|
+
...additionalActionContext,
|
|
218
|
+
},
|
|
219
|
+
},
|
|
220
|
+
);
|
|
221
|
+
|
|
222
|
+
const UPDATE_PROFILE_DEFINITION = "UPDATE_PROFILE_DEFINITION";
|
|
223
|
+
export const [UPDATE_PROFILE_DEFINITION_REQUEST, UPDATE_PROFILE_DEFINITION_SUCCESS, UPDATE_PROFILE_DEFINITION_FAILURE] =
|
|
224
|
+
makeActionTypes(UPDATE_PROFILE_DEFINITION);
|
|
225
|
+
|
|
226
|
+
export const updateProfileDefinition = (definition, additionalActionContext = null) =>
|
|
227
|
+
makeOrcApiAction(
|
|
228
|
+
UPDATE_PROFILE_DEFINITION,
|
|
229
|
+
updateEntityTypeRequest.buildUrl(definition.entityTypeName),
|
|
230
|
+
updateEntityTypeRequest.verb,
|
|
231
|
+
{
|
|
232
|
+
body: definition,
|
|
233
|
+
meta: {
|
|
234
|
+
...additionalActionContext,
|
|
235
|
+
},
|
|
236
|
+
},
|
|
237
|
+
);
|