@wavemaker/react-runtime 11.14.3-rc.6401 → 11.15.0-1.246
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/actions/base-action.js +5 -7
- package/actions/login-action.js +7 -8
- package/actions/logout-action.js +5 -7
- package/actions/navigation-action.js +73 -18
- package/actions/notification-action.js +22 -8
- package/actions/timer-action.js +13 -15
- package/actions/toast.js +4 -2
- package/actions/toast.service.js +1 -2
- package/components/advanced/carousel/index.js +1 -1
- package/components/advanced/carousel/template.js +1 -1
- package/components/basic/anchor/index.js +31 -11
- package/components/basic/html/index.js +115 -24
- package/components/basic/icon/index.js +2 -1
- package/components/basic/iframe/index.js +2 -1
- package/components/basic/label/index.js +12 -9
- package/components/basic/message/index.js +12 -3
- package/components/basic/picture/index.js +11 -4
- package/components/basic/progress-bar/index.js +4 -1
- package/components/basic/progress-circle/index.js +34 -28
- package/components/basic/progress-circle/props.js +10 -2
- package/components/basic/richtexteditor/index.js +95 -94
- package/components/basic/search/index.js +401 -156
- package/components/basic/search/providers.js +126 -61
- package/components/basic/spinner/index.js +2 -1
- package/components/basic/tree/index.js +34 -34
- package/components/basic/tree/utils.js +10 -4
- package/components/chart/components/barColumnChart/index.js +36 -33
- package/components/chart/components/bubbleChart/index.js +35 -25
- package/components/chart/components/chartLegend/utils.js +2 -1
- package/components/chart/components/cumulativeLineChart/index.js +30 -26
- package/components/chart/components/lineAreaChart/index.js +50 -32
- package/components/chart/components/pieDonutChart/index.js +13 -4
- package/components/chart/hooks/useXAxisConfig.js +15 -8
- package/components/chart/index.js +223 -53
- package/components/chart/utils.js +12 -1
- package/components/constants.js +5 -2
- package/components/container/accordion/accordion-pane/index.js +17 -12
- package/components/container/accordion/index.js +9 -4
- package/components/container/alignment-utils.js +56 -1
- package/components/container/index.js +49 -20
- package/components/container/panel/components/panel-header/index.js +3 -4
- package/components/container/panel/index.js +15 -10
- package/components/container/repeat-template/index.js +33 -0
- package/components/container/tabs/index.js +83 -14
- package/components/container/tabs/tab-pane/index.js +33 -10
- package/components/container/tabs/utils.js +51 -0
- package/components/container/wizard/components/StepComponents.js +2 -1
- package/components/container/wizard/components/WizardStep.js +2 -1
- package/components/container/wizard/index.js +64 -35
- package/components/container/wizard/utils.js +46 -1
- package/components/container/wizard/wizard-step/index.js +11 -1
- package/components/data/card/card-content/index.js +1 -1
- package/components/data/form/base-form/index.js +985 -183
- package/components/data/form/base-form/props.js +3 -1
- package/components/data/form/base-form/utils.js +159 -1
- package/components/data/form/dynamic-fields/constant.js +53 -0
- package/components/data/form/dynamic-fields/index.js +10 -45
- package/components/data/form/dynamic-fields/utils.js +37 -2
- package/components/data/form/form-action/index.js +5 -4
- package/components/data/form/form-context.js +5 -1
- package/components/data/form/form-controller/utils.js +84 -0
- package/components/data/form/form-controller/validation-contrustor.js +402 -189
- package/components/data/form/form-controller/withFormController.js +191 -52
- package/components/data/form/form-field/base-field.js +67 -45
- package/components/data/form/form-field/index.js +28 -5
- package/components/data/form/form-header/index.js +3 -4
- package/components/data/form/index.js +20 -1
- package/components/data/list/components/ListDND.js +2 -1
- package/components/data/list/components/ListItem.js +6 -2
- package/components/data/list/components/ListItemWithTemplate.js +46 -2
- package/components/data/list/components/ListItems.js +17 -26
- package/components/data/list/components/ListPagination.js +3 -3
- package/components/data/list/components/StandardListItems.js +3 -4
- package/components/data/list/hooks/useListEffects.js +55 -14
- package/components/data/list/hooks/useListEventHandlers.js +3 -1
- package/components/data/list/hooks/useListState.js +3 -1
- package/components/data/list/hooks/usePaginatedGroupedData.js +18 -5
- package/components/data/list/index.js +74 -55
- package/components/data/list/utils/list-helpers.js +73 -35
- package/components/data/list/utils/list-widget-methods.js +138 -95
- package/components/data/live-filter/index.js +26 -15
- package/components/data/live-form/index.js +51 -18
- package/components/data/live-form/props.js +1 -1
- package/components/data/pagination/components/BasicPagination.js +71 -16
- package/components/data/pagination/components/PageSizeSelector.js +8 -3
- package/components/data/pagination/components/TotalRecords.js +1 -5
- package/components/data/pagination/hooks/usePagination.js +349 -66
- package/components/data/pagination/index.js +137 -19
- package/components/data/table/components/AddNewRow.js +5 -1
- package/components/data/table/components/EditableCell.js +2 -2
- package/components/data/table/components/RowCells.js +64 -0
- package/components/data/table/components/RowExpansionButton.js +2 -2
- package/components/data/table/components/SummaryCell.js +111 -0
- package/components/data/table/components/SummaryRow.js +54 -0
- package/components/data/table/components/SummaryRowFooter.js +46 -0
- package/components/data/table/components/TableBody.js +61 -59
- package/components/data/table/components/TableDataRow.js +109 -0
- package/components/data/table/components/TableFilters.js +225 -121
- package/components/data/table/components/TableHeader.js +291 -23
- package/components/data/table/components/TablePanelHeading.js +139 -8
- package/components/data/table/components/index.js +22 -1
- package/components/data/table/hooks/use-edited-rows.js +141 -0
- package/components/data/table/hooks/useCellState.js +5 -12
- package/components/data/table/hooks/useFormWidget.js +58 -52
- package/components/data/table/hooks/usePaginationState.js +45 -24
- package/components/data/table/hooks/usePanelStructure.js +4 -4
- package/components/data/table/hooks/useRowHandlers.js +39 -5
- package/components/data/table/hooks/useRowSelection.js +244 -50
- package/components/data/table/hooks/useServerSideSorting.js +81 -37
- package/components/data/table/hooks/useTableColumns.js +211 -118
- package/components/data/table/hooks/useTableData.js +54 -9
- package/components/data/table/hooks/useTableEdit.js +272 -97
- package/components/data/table/hooks/useTableEffects.js +31 -13
- package/components/data/table/hooks/useTableFilter.js +1 -1
- package/components/data/table/hooks/useTableInitialization.js +23 -22
- package/components/data/table/hooks/useTableState.js +11 -5
- package/components/data/table/hooks/useTableStateManager.js +140 -65
- package/components/data/table/index.js +637 -274
- package/components/data/table/live-table/index.js +54 -22
- package/components/data/table/table-action/index.js +1 -1
- package/components/data/table/table-group/index.js +26 -0
- package/components/data/table/table-row-action/index.js +32 -18
- package/components/data/table/utils/buildSelectionColumns.js +12 -21
- package/components/data/table/utils/columnBuilder.js +29 -14
- package/components/data/table/utils/columnProxy.js +68 -1
- package/components/data/table/utils/constants.js +6 -2
- package/components/data/table/utils/crud-handlers.js +68 -63
- package/components/data/table/utils/groupHeaderUtils.js +102 -0
- package/components/data/table/utils/index.js +210 -21
- package/components/data/table/utils/renderDisplayCell.js +6 -6
- package/components/data/table/utils/selectionUtils.js +25 -26
- package/components/data/table/utils/validation.js +1 -0
- package/components/data/utils/filter-field-util.js +3 -3
- package/components/dialogs/alert-dialog/index.js +1 -1
- package/components/dialogs/confirm-dialog/index.js +1 -1
- package/components/dialogs/dialog/index.js +4 -1
- package/components/dialogs/dialog-content/index.js +3 -1
- package/components/dialogs/dialog-header/index.js +2 -2
- package/components/dialogs/iframe-dialog/index.js +11 -5
- package/components/dialogs/index.js +1 -1
- package/components/dialogs/login-dialog/index.js +1 -1
- package/components/dialogs/page-dialog/index.js +1 -1
- package/components/form/button/index.js +33 -7
- package/components/input/calendar/index.js +18 -6
- package/components/input/chips/index.js +99 -28
- package/components/input/chips/utils.js +34 -4
- package/components/input/color-picker/index.js +74 -25
- package/components/input/composite/index.js +3 -3
- package/components/input/currency/index.js +35 -49
- package/components/input/default/checkbox/index.js +23 -28
- package/components/input/default/checkboxset/index.js +38 -18
- package/components/input/default/checkboxset/utils.js +30 -0
- package/components/input/default/radioset/index.js +36 -39
- package/components/input/default/switch/index.js +30 -13
- package/components/input/epoch/date/index.js +130 -69
- package/components/input/epoch/date/utils.js +94 -1
- package/components/input/epoch/datetime/index.js +72 -22
- package/components/input/epoch/datetime/utils.js +49 -10
- package/components/input/epoch/time/index.js +68 -19
- package/components/input/epoch/time/utils.js +62 -14
- package/components/input/fileupload/Utils.js +12 -7
- package/components/input/fileupload/components/MultiUpload.js +2 -6
- package/components/input/fileupload/components/SingleUpload.js +3 -7
- package/components/input/fileupload/index.js +6 -10
- package/components/input/fileupload/useFileUpload.js +16 -5
- package/components/input/number/index.js +158 -43
- package/components/input/rating/index.js +90 -7
- package/components/input/select/index.js +209 -72
- package/components/input/slider/index.js +84 -26
- package/components/input/text/index.js +38 -18
- package/components/input/text/util.js +283 -130
- package/components/input/textarea/index.js +13 -10
- package/components/input/upload/index.js +124 -0
- package/components/input/upload/props.js +5 -0
- package/components/input/util/index.js +11 -0
- package/components/navbar/index.js +51 -3
- package/components/navbar/nav/index.js +46 -16
- package/components/navbar/nav-item/index.js +11 -5
- package/components/navigation/menu/components/ListItems.js +3 -0
- package/components/navigation/menu/constants.js +2 -1
- package/components/navigation/menu/hooks/useHoverState.hook.js +48 -0
- package/components/navigation/menu/hooks/useKeyboardMovements.hook.js +37 -0
- package/components/navigation/menu/hooks/useTransformedDataset.hook.js +15 -0
- package/components/navigation/menu/index.js +326 -188
- package/components/navigation/menu/utils/action-task.js +14 -0
- package/components/navigation/menu/utils/role-filter.js +76 -0
- package/components/navigation/popover/index.js +105 -32
- package/components/page/partial-container/index.js +34 -5
- package/components/prefab/index.js +2 -4
- package/context/PrefabContext.js +10 -6
- package/context/WidgetProvider.js +30 -31
- package/core/app.service.js +1 -1
- package/core/constants/events.js +57 -1
- package/core/dialog.service.js +1 -2
- package/core/event-notifier.js +1 -2
- package/core/formatter/array-formatters.js +33 -0
- package/core/formatter/date-formatters.js +2 -4
- package/core/formatter/index.js +2 -1
- package/core/formatter/number-formatters.js +5 -10
- package/core/formatter/security-formatters.js +2 -4
- package/core/formatter/string-formatters.js +3 -6
- package/core/proxy-service.js +85 -13
- package/core/script-registry.js +108 -48
- package/core/util/common.js +4 -4
- package/core/util/compare.js +30 -0
- package/core/util/dom.js +8 -8
- package/core/util/index.js +16 -6
- package/core/util/safe-is-equal.js +156 -0
- package/core/util/security.js +1 -2
- package/core/util/utils.js +16 -7
- package/higherOrder/BaseApp.js +108 -65
- package/higherOrder/BaseDateTime.js +31 -13
- package/higherOrder/BasePage.js +268 -144
- package/higherOrder/BasePartial.js +1 -1
- package/higherOrder/BasePrefab.js +33 -15
- package/higherOrder/DataNav.js +99 -16
- package/higherOrder/helper.js +41 -3
- package/higherOrder/withBaseWrapper.js +41 -28
- package/hooks/useAuth.js +11 -5
- package/hooks/useHttp.js +280 -94
- package/mui-config/theme-provider.js +1 -1
- package/mui-config/theme.js +1 -1
- package/package-lock.json +307 -266
- package/package.json +8 -8
- package/store/bindActions/i18nActions.js +18 -0
- package/store/index.js +3 -1
- package/store/slices/appConfigSlice.js +2 -2
- package/store/slices/authSlice.js +31 -28
- package/store/slices/i18nSlice.js +2 -2
- package/store/slices/navigationSlice.js +35 -0
- package/store/viewport.service.js +255 -0
- package/utils/attr.js +35 -0
- package/utils/dataset-util.js +1 -2
- package/utils/form-state.util.js +43 -12
- package/utils/form-utils.js +47 -2
- package/utils/format-util.js +28 -13
- package/utils/page-params-util.js +33 -1
- package/utils/state-persistance.js +72 -13
- package/utils/transformedDataset-utils.js +35 -24
- package/variables/base-variable.js +12 -14
- package/variables/crud-variable.js +225 -0
- package/variables/live-variable.js +56 -20
- package/variables/metadata.service.js +123 -0
- package/variables/model-variable.js +21 -15
- package/variables/service-variable.js +88 -83
package/hooks/useHttp.js
CHANGED
|
@@ -5,7 +5,7 @@ var _typeof = require("@babel/runtime/helpers/typeof");
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.useHttp = exports.httpService = exports["default"] = exports.HttpProvider = void 0;
|
|
8
|
+
exports.useHttp = exports.httpService = exports.getHttpService = exports["default"] = exports.HttpProvider = void 0;
|
|
9
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
10
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
11
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
@@ -13,13 +13,17 @@ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/cl
|
|
|
13
13
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
14
14
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
15
15
|
var _axios = _interopRequireWildcard(require("axios"));
|
|
16
|
+
var axiosModule = _axios;
|
|
16
17
|
var _constants = require("@wavemaker/react-runtime/variables/constants");
|
|
17
18
|
var _store = require("../store");
|
|
18
19
|
var _authSlice = require("../store/slices/authSlice");
|
|
19
20
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t2 in e) "default" !== _t2 && {}.hasOwnProperty.call(e, _t2) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t2)) && (i.get || i.set) ? o(f, _t2, i) : f[_t2] = e[_t2]); return f; })(e, t); }
|
|
20
21
|
var __jsx = _react["default"].createElement;
|
|
21
22
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
22
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
23
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
24
|
+
var axios = axiosModule["default"] || axiosModule;
|
|
25
|
+
|
|
26
|
+
// @ts-ignore
|
|
23
27
|
// Types
|
|
24
28
|
// Create the HTTP service class implementing HttpClientService
|
|
25
29
|
var ModernHttpService = /*#__PURE__*/function () {
|
|
@@ -27,74 +31,201 @@ var ModernHttpService = /*#__PURE__*/function () {
|
|
|
27
31
|
var baseURL = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
|
|
28
32
|
(0, _classCallCheck2["default"])(this, ModernHttpService);
|
|
29
33
|
(0, _defineProperty2["default"])(this, "axiosInstance", void 0);
|
|
30
|
-
|
|
34
|
+
(0, _defineProperty2["default"])(this, "_context", null);
|
|
35
|
+
(0, _defineProperty2["default"])(this, "localeObject", _store.store.getState().i18n.appLocale);
|
|
36
|
+
this.axiosInstance = axios.create({
|
|
31
37
|
baseURL: baseURL
|
|
32
38
|
});
|
|
33
39
|
this.setupInterceptors();
|
|
34
40
|
}
|
|
35
|
-
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Set the current context (page/component context)
|
|
44
|
+
* @param context - The context object to store
|
|
45
|
+
*/
|
|
46
|
+
return (0, _createClass2["default"])(ModernHttpService, [{
|
|
47
|
+
key: "setContext",
|
|
48
|
+
value: function setContext(context) {
|
|
49
|
+
this._context = context;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Get the currently stored context
|
|
54
|
+
* @returns The stored context object
|
|
55
|
+
*/
|
|
56
|
+
}, {
|
|
57
|
+
key: "getContext",
|
|
58
|
+
value: function getContext() {
|
|
59
|
+
return this._context;
|
|
60
|
+
}
|
|
61
|
+
}, {
|
|
62
|
+
key: "getAppManager",
|
|
63
|
+
value: function getAppManager() {
|
|
64
|
+
var _ref, _currentContext$App;
|
|
65
|
+
var currentContext = this.getContext();
|
|
66
|
+
return (_ref = (_currentContext$App = currentContext === null || currentContext === void 0 ? void 0 : currentContext.App) !== null && _currentContext$App !== void 0 ? _currentContext$App : currentContext) !== null && _ref !== void 0 ? _ref : {};
|
|
67
|
+
}
|
|
68
|
+
}, {
|
|
36
69
|
key: "setupInterceptors",
|
|
37
70
|
value: function setupInterceptors() {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
var baseUrl = ((_state$info = state.info) === null || _state$info === void 0 || (_state$info = _state$info.appConfig) === null || _state$info === void 0 ? void 0 : _state$info.url) || "";
|
|
44
|
-
var headers = new _axios.AxiosHeaders(config.headers);
|
|
45
|
-
// Check if this is a file download operation
|
|
46
|
-
var wmVariable = config.__wmVariable;
|
|
47
|
-
var isFileDownload = (wmVariable === null || wmVariable === void 0 ? void 0 : wmVariable.operation) === "getDownloadFile";
|
|
48
|
-
|
|
49
|
-
// Only set Accept header for non-download operations
|
|
50
|
-
if (!isFileDownload) {
|
|
51
|
-
headers.set("Accept", "application/json");
|
|
52
|
-
}
|
|
53
|
-
config.headers = headers;
|
|
54
|
-
config.withCredentials = (_config$withCredentia = config.withCredentials) !== null && _config$withCredentia !== void 0 ? _config$withCredentia : true;
|
|
55
|
-
if ((_config$url = config.url) !== null && _config$url !== void 0 && _config$url.startsWith(baseUrl) && token) {
|
|
56
|
-
if (config.headers) config.headers[_authSlice.XSRF_HEADER_NAME] = token;
|
|
57
|
-
}
|
|
58
|
-
return config;
|
|
59
|
-
}, function (error) {
|
|
60
|
-
return Promise.reject(error);
|
|
61
|
-
});
|
|
62
|
-
this.axiosInstance.interceptors.response.use(function (response) {
|
|
63
|
-
return _objectSpread(_objectSpread({}, response), {}, {
|
|
64
|
-
body: response.data,
|
|
65
|
-
type: 4 // mimic Angular's HttpEventType.Response
|
|
66
|
-
});
|
|
67
|
-
}, /*#__PURE__*/function () {
|
|
68
|
-
var _ref = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee(error) {
|
|
69
|
-
var _error$response;
|
|
71
|
+
var _this = this;
|
|
72
|
+
this.axiosInstance.interceptors.request.use(/*#__PURE__*/function () {
|
|
73
|
+
var _ref2 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee(config) {
|
|
74
|
+
var _state$info, _config$withCredentia, _config$url;
|
|
75
|
+
var appManager, state, token, baseUrl, headers, wmVariable, isFileDownload, modifiedReq;
|
|
70
76
|
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
71
77
|
while (1) switch (_context.prev = _context.next) {
|
|
72
78
|
case 0:
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
79
|
+
appManager = _this.getAppManager(); // Create new headers instance
|
|
80
|
+
state = _store.store.getState();
|
|
81
|
+
token = state.auth.token;
|
|
82
|
+
baseUrl = ((_state$info = state.info) === null || _state$info === void 0 || (_state$info = _state$info.appConfig) === null || _state$info === void 0 ? void 0 : _state$info.url) || "";
|
|
83
|
+
headers = new _axios.AxiosHeaders(config.headers); // Check if this is a file download operation
|
|
84
|
+
wmVariable = config.__wmVariable;
|
|
85
|
+
isFileDownload = (wmVariable === null || wmVariable === void 0 ? void 0 : wmVariable.operation) === "getDownloadFile"; // Only set Accept header for non-download operations
|
|
86
|
+
if (!isFileDownload) {
|
|
87
|
+
headers.set("Accept", "application/json");
|
|
88
|
+
}
|
|
89
|
+
config.headers = headers;
|
|
90
|
+
config.withCredentials = (_config$withCredentia = config.withCredentials) !== null && _config$withCredentia !== void 0 ? _config$withCredentia : true;
|
|
91
|
+
if ((_config$url = config.url) !== null && _config$url !== void 0 && _config$url.startsWith(baseUrl) && token) {
|
|
92
|
+
if (config.headers) config.headers[_authSlice.XSRF_HEADER_NAME] = token;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Call onBeforeServiceCall if available - wait for promise to resolve
|
|
96
|
+
// This allows the app to modify the request config before it's sent
|
|
97
|
+
if (!(appManager && appManager.onBeforeServiceCall)) {
|
|
98
|
+
_context.next = 22;
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
_context.prev = 12;
|
|
102
|
+
_context.next = 15;
|
|
103
|
+
return appManager.onBeforeServiceCall(config);
|
|
104
|
+
case 15:
|
|
105
|
+
modifiedReq = _context.sent;
|
|
106
|
+
if (modifiedReq) {
|
|
107
|
+
config = modifiedReq;
|
|
108
|
+
}
|
|
109
|
+
_context.next = 22;
|
|
110
|
+
break;
|
|
111
|
+
case 19:
|
|
112
|
+
_context.prev = 19;
|
|
113
|
+
_context.t0 = _context["catch"](12);
|
|
114
|
+
console.error("Error in onBeforeServiceCall:", _context.t0);
|
|
115
|
+
// Continue with original config if the callback fails
|
|
116
|
+
case 22:
|
|
117
|
+
return _context.abrupt("return", config);
|
|
118
|
+
case 23:
|
|
76
119
|
case "end":
|
|
77
120
|
return _context.stop();
|
|
78
121
|
}
|
|
79
|
-
}, _callee);
|
|
122
|
+
}, _callee, null, [[12, 19]]);
|
|
80
123
|
}));
|
|
81
124
|
return function (_x) {
|
|
82
|
-
return
|
|
125
|
+
return _ref2.apply(this, arguments);
|
|
126
|
+
};
|
|
127
|
+
}(), function (error) {
|
|
128
|
+
return Promise.reject(error);
|
|
129
|
+
});
|
|
130
|
+
this.axiosInstance.interceptors.response.use(/*#__PURE__*/function () {
|
|
131
|
+
var _ref3 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee2(response) {
|
|
132
|
+
var appManager, modifiedResponse, modifiedResp;
|
|
133
|
+
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
134
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
135
|
+
case 0:
|
|
136
|
+
appManager = _this.getAppManager();
|
|
137
|
+
modifiedResponse = _objectSpread(_objectSpread({}, response), {}, {
|
|
138
|
+
body: response.data,
|
|
139
|
+
type: 4 // mimic Angular's HttpEventType.Response
|
|
140
|
+
}); // Call appOnServiceSuccess if available - similar to Angular's tap operator
|
|
141
|
+
if (!(appManager && appManager.onServiceSuccess)) {
|
|
142
|
+
_context2.next = 13;
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
_context2.prev = 3;
|
|
146
|
+
_context2.next = 6;
|
|
147
|
+
return appManager.onServiceSuccess(modifiedResponse.body, modifiedResponse);
|
|
148
|
+
case 6:
|
|
149
|
+
modifiedResp = _context2.sent;
|
|
150
|
+
if (modifiedResp) {
|
|
151
|
+
modifiedResponse = _objectSpread(_objectSpread({}, modifiedResponse), modifiedResp);
|
|
152
|
+
}
|
|
153
|
+
_context2.next = 13;
|
|
154
|
+
break;
|
|
155
|
+
case 10:
|
|
156
|
+
_context2.prev = 10;
|
|
157
|
+
_context2.t0 = _context2["catch"](3);
|
|
158
|
+
console.error("Error in onServiceSuccess:", _context2.t0);
|
|
159
|
+
case 13:
|
|
160
|
+
return _context2.abrupt("return", modifiedResponse);
|
|
161
|
+
case 14:
|
|
162
|
+
case "end":
|
|
163
|
+
return _context2.stop();
|
|
164
|
+
}
|
|
165
|
+
}, _callee2, null, [[3, 10]]);
|
|
166
|
+
}));
|
|
167
|
+
return function (_x2) {
|
|
168
|
+
return _ref3.apply(this, arguments);
|
|
169
|
+
};
|
|
170
|
+
}(), /*#__PURE__*/function () {
|
|
171
|
+
var _ref4 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee3(error) {
|
|
172
|
+
var _error$response;
|
|
173
|
+
var appManager, errorResponse, _errorResponse, _errorResponse2, _errorResponse3, errorMessage, modifiedResp;
|
|
174
|
+
return _regenerator["default"].wrap(function _callee3$(_context3) {
|
|
175
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
176
|
+
case 0:
|
|
177
|
+
appManager = _this.getAppManager();
|
|
178
|
+
errorResponse = error.response || error; // Handle 401 session timeout if needed
|
|
179
|
+
if (((_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.status) === 401) {
|
|
180
|
+
// Session timeout handling can be added here
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// Call appOnServiceError if available
|
|
184
|
+
if (!(appManager && appManager.onServiceError)) {
|
|
185
|
+
_context3.next = 16;
|
|
186
|
+
break;
|
|
187
|
+
}
|
|
188
|
+
_context3.prev = 4;
|
|
189
|
+
errorMessage = ((_errorResponse = errorResponse) === null || _errorResponse === void 0 || (_errorResponse = _errorResponse.data) === null || _errorResponse === void 0 ? void 0 : _errorResponse.message) || ((_errorResponse2 = errorResponse) === null || _errorResponse2 === void 0 ? void 0 : _errorResponse2.message) || "Unknown error";
|
|
190
|
+
errorResponse.error = ((_errorResponse3 = errorResponse) === null || _errorResponse3 === void 0 ? void 0 : _errorResponse3.data) || errorResponse;
|
|
191
|
+
_context3.next = 9;
|
|
192
|
+
return appManager.onServiceError(errorMessage, errorResponse);
|
|
193
|
+
case 9:
|
|
194
|
+
modifiedResp = _context3.sent;
|
|
195
|
+
if (modifiedResp) {
|
|
196
|
+
errorResponse = _objectSpread(_objectSpread({}, errorResponse), modifiedResp);
|
|
197
|
+
}
|
|
198
|
+
_context3.next = 16;
|
|
199
|
+
break;
|
|
200
|
+
case 13:
|
|
201
|
+
_context3.prev = 13;
|
|
202
|
+
_context3.t0 = _context3["catch"](4);
|
|
203
|
+
console.error("Error in onServiceError:", _context3.t0);
|
|
204
|
+
case 16:
|
|
205
|
+
throw errorResponse;
|
|
206
|
+
case 17:
|
|
207
|
+
case "end":
|
|
208
|
+
return _context3.stop();
|
|
209
|
+
}
|
|
210
|
+
}, _callee3, null, [[4, 13]]);
|
|
211
|
+
}));
|
|
212
|
+
return function (_x3) {
|
|
213
|
+
return _ref4.apply(this, arguments);
|
|
83
214
|
};
|
|
84
215
|
}());
|
|
85
216
|
}
|
|
86
217
|
}, {
|
|
87
218
|
key: "send",
|
|
88
219
|
value: function () {
|
|
89
|
-
var _send = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function
|
|
220
|
+
var _send = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee4(options, variable) {
|
|
90
221
|
var serviceInfo, headers, requestBody, url, _serviceInfo$proxySet, isProxyCall, _options$url$replace, methodType, isNonDataMethod, axiosConfig, response;
|
|
91
|
-
return _regenerator["default"].wrap(function
|
|
92
|
-
while (1) switch (
|
|
222
|
+
return _regenerator["default"].wrap(function _callee4$(_context4) {
|
|
223
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
93
224
|
case 0:
|
|
94
225
|
serviceInfo = variable.serviceInfo;
|
|
95
226
|
headers = new _axios.AxiosHeaders(options.headers);
|
|
96
227
|
requestBody = options.data;
|
|
97
|
-
variable.cancelTokenSource =
|
|
228
|
+
variable.cancelTokenSource = axios.CancelToken.source();
|
|
98
229
|
url = options.url;
|
|
99
230
|
if (serviceInfo) {
|
|
100
231
|
serviceInfo.proxySettings = (serviceInfo === null || serviceInfo === void 0 ? void 0 : serviceInfo.proxySettings) || {
|
|
@@ -103,7 +234,13 @@ var ModernHttpService = /*#__PURE__*/function () {
|
|
|
103
234
|
isProxyCall = serviceInfo === null || serviceInfo === void 0 || (_serviceInfo$proxySet = serviceInfo.proxySettings) === null || _serviceInfo$proxySet === void 0 ? void 0 : _serviceInfo$proxySet.web;
|
|
104
235
|
url = isProxyCall ? options.url : serviceInfo === null || serviceInfo === void 0 ? void 0 : serviceInfo.directPath;
|
|
105
236
|
}
|
|
106
|
-
if (variable.category === "wm.
|
|
237
|
+
if (variable.category === "wm.CrudVariable") {
|
|
238
|
+
if (url.startsWith("http://") || url.startsWith("https://")) {
|
|
239
|
+
url = url;
|
|
240
|
+
} else {
|
|
241
|
+
url = variable.config.baseUrl + options.url.replace(".//", "/").replace("./", "/");
|
|
242
|
+
}
|
|
243
|
+
} else if (variable.category === "wm.LiveVariable" && !(url.startsWith("http://") || url.startsWith("https://"))) {
|
|
107
244
|
url = variable.config.baseUrl + options.url.replace("./", "/");
|
|
108
245
|
} else if (url === (serviceInfo === null || serviceInfo === void 0 ? void 0 : serviceInfo.directPath) && options.url.startsWith("http")) {
|
|
109
246
|
url = options.url;
|
|
@@ -140,29 +277,29 @@ var ModernHttpService = /*#__PURE__*/function () {
|
|
|
140
277
|
if (options !== null && options !== void 0 && options.onUploadProgress) {
|
|
141
278
|
axiosConfig.onUploadProgress = options.onUploadProgress;
|
|
142
279
|
}
|
|
143
|
-
|
|
144
|
-
|
|
280
|
+
_context4.prev = 13;
|
|
281
|
+
_context4.next = 16;
|
|
145
282
|
return this.axiosInstance.request(axiosConfig);
|
|
146
283
|
case 16:
|
|
147
|
-
response =
|
|
284
|
+
response = _context4.sent;
|
|
148
285
|
if (!(variable.operation === "getDownloadFile" || (serviceInfo === null || serviceInfo === void 0 ? void 0 : serviceInfo.operationId) === "FileController_getDownloadFile")) {
|
|
149
|
-
|
|
286
|
+
_context4.next = 19;
|
|
150
287
|
break;
|
|
151
288
|
}
|
|
152
|
-
return
|
|
289
|
+
return _context4.abrupt("return", this.handleFileDownload(response, options, variable));
|
|
153
290
|
case 19:
|
|
154
|
-
return
|
|
291
|
+
return _context4.abrupt("return", response);
|
|
155
292
|
case 22:
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
throw
|
|
293
|
+
_context4.prev = 22;
|
|
294
|
+
_context4.t0 = _context4["catch"](13);
|
|
295
|
+
throw _context4.t0.response || _context4.t0;
|
|
159
296
|
case 25:
|
|
160
297
|
case "end":
|
|
161
|
-
return
|
|
298
|
+
return _context4.stop();
|
|
162
299
|
}
|
|
163
|
-
},
|
|
300
|
+
}, _callee4, this, [[13, 22]]);
|
|
164
301
|
}));
|
|
165
|
-
function send(
|
|
302
|
+
function send(_x4, _x5) {
|
|
166
303
|
return _send.apply(this, arguments);
|
|
167
304
|
}
|
|
168
305
|
return send;
|
|
@@ -170,36 +307,41 @@ var ModernHttpService = /*#__PURE__*/function () {
|
|
|
170
307
|
}, {
|
|
171
308
|
key: "sendCall",
|
|
172
309
|
value: function () {
|
|
173
|
-
var _sendCall = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function
|
|
310
|
+
var _sendCall = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee5(requestParams, variable) {
|
|
174
311
|
var response;
|
|
175
|
-
return _regenerator["default"].wrap(function
|
|
176
|
-
while (1) switch (
|
|
312
|
+
return _regenerator["default"].wrap(function _callee5$(_context5) {
|
|
313
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
177
314
|
case 0:
|
|
178
|
-
|
|
179
|
-
|
|
315
|
+
_context5.prev = 0;
|
|
316
|
+
_context5.next = 3;
|
|
180
317
|
return this.send(requestParams, variable);
|
|
181
318
|
case 3:
|
|
182
|
-
response =
|
|
183
|
-
return
|
|
319
|
+
response = _context5.sent;
|
|
320
|
+
return _context5.abrupt("return", response);
|
|
184
321
|
case 7:
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
throw
|
|
322
|
+
_context5.prev = 7;
|
|
323
|
+
_context5.t0 = _context5["catch"](0);
|
|
324
|
+
throw _context5.t0;
|
|
188
325
|
case 10:
|
|
189
326
|
case "end":
|
|
190
|
-
return
|
|
327
|
+
return _context5.stop();
|
|
191
328
|
}
|
|
192
|
-
},
|
|
329
|
+
}, _callee5, this, [[0, 7]]);
|
|
193
330
|
}));
|
|
194
|
-
function sendCall(
|
|
331
|
+
function sendCall(_x6, _x7) {
|
|
195
332
|
return _sendCall.apply(this, arguments);
|
|
196
333
|
}
|
|
197
334
|
return sendCall;
|
|
198
335
|
}()
|
|
336
|
+
}, {
|
|
337
|
+
key: "setLocale",
|
|
338
|
+
value: function setLocale(locale) {
|
|
339
|
+
this.localeObject = locale;
|
|
340
|
+
}
|
|
199
341
|
}, {
|
|
200
342
|
key: "getLocale",
|
|
201
343
|
value: function getLocale() {
|
|
202
|
-
return
|
|
344
|
+
return this.localeObject;
|
|
203
345
|
}
|
|
204
346
|
}, {
|
|
205
347
|
key: "cancel",
|
|
@@ -260,13 +402,13 @@ var ModernHttpService = /*#__PURE__*/function () {
|
|
|
260
402
|
}, {
|
|
261
403
|
key: "uploadFile",
|
|
262
404
|
value: function () {
|
|
263
|
-
var _uploadFile = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function
|
|
264
|
-
var
|
|
405
|
+
var _uploadFile = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee6(url, data, variable, options) {
|
|
406
|
+
var _this2 = this;
|
|
265
407
|
var requestParams;
|
|
266
|
-
return _regenerator["default"].wrap(function
|
|
267
|
-
while (1) switch (
|
|
408
|
+
return _regenerator["default"].wrap(function _callee6$(_context6) {
|
|
409
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
268
410
|
case 0:
|
|
269
|
-
|
|
411
|
+
_context6.prev = 0;
|
|
270
412
|
requestParams = {
|
|
271
413
|
url: url,
|
|
272
414
|
data: data,
|
|
@@ -282,39 +424,38 @@ var ModernHttpService = /*#__PURE__*/function () {
|
|
|
282
424
|
}
|
|
283
425
|
}
|
|
284
426
|
};
|
|
285
|
-
return
|
|
286
|
-
variable.request =
|
|
427
|
+
return _context6.abrupt("return", new Promise(function (resolve, reject) {
|
|
428
|
+
variable.request = _this2.send(requestParams, variable).then(function (event) {
|
|
287
429
|
resolve(event.data);
|
|
288
430
|
})["catch"](function (error) {
|
|
289
431
|
reject(error);
|
|
290
432
|
});
|
|
291
433
|
}));
|
|
292
434
|
case 5:
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
console.error("Unexpected error in uploadFile:",
|
|
296
|
-
throw
|
|
435
|
+
_context6.prev = 5;
|
|
436
|
+
_context6.t0 = _context6["catch"](0);
|
|
437
|
+
console.error("Unexpected error in uploadFile:", _context6.t0);
|
|
438
|
+
throw _context6.t0;
|
|
297
439
|
case 9:
|
|
298
440
|
case "end":
|
|
299
|
-
return
|
|
441
|
+
return _context6.stop();
|
|
300
442
|
}
|
|
301
|
-
},
|
|
443
|
+
}, _callee6, null, [[0, 5]]);
|
|
302
444
|
}));
|
|
303
|
-
function uploadFile(
|
|
445
|
+
function uploadFile(_x8, _x9, _x0, _x1) {
|
|
304
446
|
return _uploadFile.apply(this, arguments);
|
|
305
447
|
}
|
|
306
448
|
return uploadFile;
|
|
307
449
|
}()
|
|
308
450
|
}]);
|
|
309
|
-
return ModernHttpService;
|
|
310
451
|
}(); // Create Context
|
|
311
452
|
var HttpContext = /*#__PURE__*/(0, _react.createContext)(null);
|
|
312
453
|
|
|
313
454
|
// Provider Component
|
|
314
|
-
var HttpProvider = exports.HttpProvider = function HttpProvider(
|
|
315
|
-
var children =
|
|
316
|
-
|
|
317
|
-
baseURL =
|
|
455
|
+
var HttpProvider = exports.HttpProvider = function HttpProvider(_ref5) {
|
|
456
|
+
var children = _ref5.children,
|
|
457
|
+
_ref5$baseURL = _ref5.baseURL,
|
|
458
|
+
baseURL = _ref5$baseURL === void 0 ? "" : _ref5$baseURL;
|
|
318
459
|
var httpService = (0, _react.useRef)(new ModernHttpService(baseURL));
|
|
319
460
|
var contextValue = (0, _react.useMemo)(function () {
|
|
320
461
|
return _objectSpread(_objectSpread({}, httpService.current), {}, {
|
|
@@ -323,7 +464,9 @@ var HttpProvider = exports.HttpProvider = function HttpProvider(_ref2) {
|
|
|
323
464
|
sendCall: httpService.current.sendCall.bind(httpService.current),
|
|
324
465
|
cancel: httpService.current.cancel.bind(httpService.current),
|
|
325
466
|
uploadFile: httpService.current.uploadFile.bind(httpService.current),
|
|
326
|
-
getLocale: httpService.current.getLocale.bind(httpService.current)
|
|
467
|
+
getLocale: httpService.current.getLocale.bind(httpService.current),
|
|
468
|
+
setContext: httpService.current.setContext.bind(httpService.current),
|
|
469
|
+
getContext: httpService.current.getContext.bind(httpService.current)
|
|
327
470
|
});
|
|
328
471
|
}, []);
|
|
329
472
|
return __jsx(HttpContext.Provider, {
|
|
@@ -340,6 +483,49 @@ var useHttp = exports.useHttp = function useHttp() {
|
|
|
340
483
|
return context;
|
|
341
484
|
};
|
|
342
485
|
|
|
343
|
-
//
|
|
344
|
-
var
|
|
486
|
+
// Lazy singleton - only created when first accessed
|
|
487
|
+
var _httpService = null;
|
|
488
|
+
var getHttpService = exports.getHttpService = function getHttpService() {
|
|
489
|
+
if (!_httpService) {
|
|
490
|
+
_httpService = new ModernHttpService();
|
|
491
|
+
}
|
|
492
|
+
return _httpService;
|
|
493
|
+
};
|
|
494
|
+
|
|
495
|
+
// For backward compatibility - use getter pattern
|
|
496
|
+
var httpService = exports.httpService = {
|
|
497
|
+
get instance() {
|
|
498
|
+
return getHttpService();
|
|
499
|
+
},
|
|
500
|
+
send: function send() {
|
|
501
|
+
var _getHttpService;
|
|
502
|
+
return (_getHttpService = getHttpService()).send.apply(_getHttpService, arguments);
|
|
503
|
+
},
|
|
504
|
+
sendCall: function sendCall() {
|
|
505
|
+
var _getHttpService2;
|
|
506
|
+
return (_getHttpService2 = getHttpService()).sendCall.apply(_getHttpService2, arguments);
|
|
507
|
+
},
|
|
508
|
+
cancel: function cancel() {
|
|
509
|
+
var _getHttpService3;
|
|
510
|
+
return (_getHttpService3 = getHttpService()).cancel.apply(_getHttpService3, arguments);
|
|
511
|
+
},
|
|
512
|
+
uploadFile: function uploadFile() {
|
|
513
|
+
var _getHttpService4;
|
|
514
|
+
return (_getHttpService4 = getHttpService()).uploadFile.apply(_getHttpService4, arguments);
|
|
515
|
+
},
|
|
516
|
+
setLocale: function setLocale() {
|
|
517
|
+
var _getHttpService5;
|
|
518
|
+
return (_getHttpService5 = getHttpService()).setLocale.apply(_getHttpService5, arguments);
|
|
519
|
+
},
|
|
520
|
+
getLocale: function getLocale() {
|
|
521
|
+
return getHttpService().getLocale();
|
|
522
|
+
},
|
|
523
|
+
setContext: function setContext() {
|
|
524
|
+
var _getHttpService6;
|
|
525
|
+
return (_getHttpService6 = getHttpService()).setContext.apply(_getHttpService6, arguments);
|
|
526
|
+
},
|
|
527
|
+
getContext: function getContext() {
|
|
528
|
+
return getHttpService().getContext();
|
|
529
|
+
}
|
|
530
|
+
};
|
|
345
531
|
var _default = exports["default"] = httpService;
|