@cxbox-ui/core 2.7.0-beta.0 → 2.7.1-beta.0

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/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/actions/index.ts","../src/reducers/ReducerBuilderManager.ts","../src/reducers/data.ts","../node_modules/@cxbox-ui/schema/dist/index.js","../src/interfaces/objectMap.ts","../src/interfaces/router.ts","../src/interfaces/view.ts","../src/interfaces/widget.ts","../src/interfaces/operation.ts","../src/interfaces/filters.ts","../src/interfaces/navigation.ts","../src/reducers/router.ts","../src/utils/api.ts","../src/utils/apiError.ts","../src/utils/strings.ts","../src/utils/history.ts","../src/utils/filters.ts","../src/utils/operations.ts","../src/utils/bc.ts","../src/utils/tree.ts","../src/utils/getDefaultViewForPrimary.ts","../src/utils/getDefaultViewFromPrimaries.ts","../src/utils/data.ts","../src/utils/getWidgetsForLazyLoad.ts","../src/utils/breadthFirst.ts","../src/utils/deleteUndefinedFromObject.ts","../src/utils/extendPopupWidgetTypes.ts","../src/reducers/screen.ts","../src/reducers/view.ts","../src/reducers/depthData.ts","../src/reducers/session.ts","../src/epics/utils/postOperationRoutine.ts","../src/epics/view/sendOperationEpic.ts","../src/epics/view/waitUntil.ts","../src/epics/router/loginDoneEpic.ts","../src/epics/screen/httpErrorDefaultEpic.ts","../src/epics/session/loginByAnotherRoleEpic.ts","../src/utils/cancelRequestEpic.ts","../src/epics/data/bcLoadMoreEpic.ts","../src/selectors/selectors.ts","../src/epics/data/bcFetchDataEpic.ts","../src/epics/data/bcDeleteDataEpic.ts","../src/epics/data/bcCancelCreateDataEpic.ts","../src/epics/screen/apiErrorEpic.ts","../src/epics/data/bcFetchRowMetaRequestEpic.ts","../src/epics/data/bcNewDataEpic.ts","../src/epics/data/bcSaveDataEpic.ts","../src/epics/data/bcSelectDepthRecordEpic.ts","../src/epics/data/bcSelectRecordEpic.ts","../src/epics/data/changeAssociationEpic.ts","../src/epics/data/changeAssociationFullEpic.ts","../src/epics/data/changeAssociationSameBcEpic.ts","../src/epics/data/changeChildrenAssociationsEpic.ts","../src/epics/data/changeChildrenAssociationsSameBcEpic.ts","../src/epics/data/changeDescendantsAssociationsFullEpic.ts","../src/epics/router/changeLocationEpic.ts","../src/epics/router/selectScreenEpic.ts","../src/epics/router/selectViewEpic.ts","../src/epics/view/clearPendingDataChangesAfterCursorChangeEpic.ts","../src/epics/screen/downloadFileByUrlEpic.ts","../src/epics/screen/downloadFileEpic.ts","../src/epics/router/drilldownEpic.ts","../src/epics/view/fileUploadConfirmEpic.ts","../src/epics/view/getRowMetaByForceActiveEpic.ts","../src/epics/router/handleRouterEpic.ts","../src/epics/screen/httpError401Epic.ts","../src/epics/screen/httpError409Epic.ts","../src/epics/screen/httpError418Epic.ts","../src/epics/screen/httpError500Epic.ts","../src/epics/data/inlinePickListFetchDataEpic.ts","../src/epics/session/loginDoneEpic.ts","../src/epics/screen/processPostInvokeConfirmEpic.ts","../src/epics/screen/processPostInvokeEpic.ts","../src/epics/session/refreshMetaAndReloadPageEpic.ts","../src/epics/session/refreshMetaEpic.ts","../src/epics/data/removeMultivalueTagEpic.ts","../src/epics/data/saveAssociationsActiveEpic.ts","../src/epics/data/saveAssociationsPassiveEpic.ts","../src/epics/router/selectScreenFailEpic.ts","../src/epics/view/selectTableRowInitEpic.ts","../src/epics/data/selectViewEpic.ts","../src/epics/router/selectViewFailEpic.ts","../src/epics/view/sendOperationAssociateEpic.ts","../src/epics/view/setPendingSendOperationEpic.ts","../src/epics/view/showAllTableRecordsInitEpic.ts","../src/epics/view/showAssocPopupEpic.ts","../src/epics/view/showFileUploadPopupEpic.ts","../src/epics/session/switchRoleEpic.ts","../src/epics/router/userDrilldownChangeCursorsEpic.ts","../src/epics/router/userDrillDownEpic.ts","../src/api/ObservableApiWrapper.ts","../src/api/ObservableApi.ts","../src/utils/autosave.ts","../src/middlewares/preInvokeMiddleware.ts","../src/middlewares/index.ts","../src/middlewares/autosaveMiddleware.ts","../src/middlewares/requiredFieldsMiddleware.ts","../src/middlewares/popupMiddleware.ts"],"sourcesContent":["/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { SessionScreen, PendingRequest, NotificationKeys, LoginResponse, OperationPostInvokeWaitUntil, ISendOperation } from '../interfaces'\r\nimport { DrillDownType, Route } from '../interfaces/router'\r\nimport { ViewMetaResponse, ApplicationError, PopupType } from '../interfaces'\r\nimport { DataItem, MultivalueSingleValue, PendingDataItem, PickMap } from '../interfaces/data'\r\nimport {\r\n RowMeta,\r\n AppNotificationType,\r\n OperationPostInvokeAny,\r\n OperationTypeCrud,\r\n AssociatedItem,\r\n OperationErrorEntity,\r\n OperationPostInvokeConfirm,\r\n OperationPreInvoke,\r\n BcFilter,\r\n BcSorter,\r\n Notification\r\n} from '../interfaces'\r\nimport { AxiosError } from 'axios'\r\nimport { ApiCallContext } from '../utils'\r\nimport { createAction, AnyAction } from '@reduxjs/toolkit'\r\nimport { OperationType } from '@cxbox-ui/schema'\r\n\r\nexport const changeLocation = createAction<{ location: Route; forceUpdate?: boolean; isTab?: boolean; onSuccessAction?: AnyAction }>(\r\n 'changeLocation'\r\n)\r\n/**\r\n * Authentication request\r\n */\r\nexport const login = createAction<{\r\n /**\r\n * User-provided login\r\n */\r\n login: string\r\n /**\r\n * User-provided password\r\n */\r\n password: string\r\n /**\r\n * Optionally user can choose a role to authentificate with\r\n */\r\n role?: string\r\n}>('login')\r\n\r\n/**\r\n * Login was successful\r\n */\r\nexport const loginDone = createAction<LoginResponse>('loginDone')\r\n\r\n/**\r\n * Login was unsuccesful\r\n */\r\nexport const loginFail = createAction<{\r\n /**\r\n * Reason could be provided\r\n */\r\n errorMsg: string\r\n}>('loginFail')\r\n\r\n/**\r\n * Logout was requested, manually or through stale session\r\n */\r\nexport const logout = createAction<null>('logout')\r\n\r\n/**\r\n * User successfully was logged out\r\n */\r\nexport const logoutDone = createAction<null>('logoutDone')\r\n\r\n/**\r\n * Request to change active screen was initiated\r\n *\r\n * TODO: 2.0.0 Should be string (just the screen name) instead;\r\n *\r\n * Initially this was due to `screen` reducer did not having access to `session` part of redux store\r\n */\r\nexport const selectScreen = createAction<{\r\n /**\r\n * Request initiated with all the meta from login response\r\n */\r\n screen: SessionScreen\r\n}>('selectScreen')\r\n\r\n/**\r\n * Request to change active screen was unsuccesful (incorrect path, unknown screen, etc.)\r\n */\r\nexport const selectScreenFail = createAction<{\r\n /**\r\n * Which screen was requested originally\r\n */\r\n screenName: string\r\n}>('selectScreenFail')\r\n\r\n/**\r\n * Request to change active view was initiated\r\n *\r\n * TODO: 2.0.0 Should be string (just the view name) instead;\r\n * Initially this was due to `screen` and `view` reducers did not having access to `session` part of redux store\r\n */\r\nexport const selectView = createAction<ViewMetaResponse & { isTab?: boolean }>('selectView')\r\n\r\n/**\r\n * Request to change active view was unsuccesful (incorrect path, unknown screen, etc.)\r\n *\r\n * @param selectViewFail Which view was requested originally\r\n */\r\nexport const selectViewFail = createAction<{\r\n viewName: string\r\n}>('selectViewFail')\r\n\r\n/**\r\n * Fetch data request for business component was initiated\r\n */\r\nexport const bcFetchDataRequest = createAction<{\r\n /**\r\n * The business component to fetch data for\r\n */\r\n bcName?: string\r\n /**\r\n * The level of hierarchy to fetch data for\r\n *\r\n * @deprecated Do not use; TODO: Will be removed in 2.0.0\r\n */\r\n depth?: number\r\n /**\r\n * What widget requires data (widget can only request its own data here)\r\n */\r\n widgetName: string\r\n /**\r\n * Page size should be ignored\r\n *\r\n * Used mostly for hierarchy widgets which does not have controls\r\n * for navigating between pages aside of root level.\r\n */\r\n ignorePageLimit?: boolean\r\n /**\r\n * Pending changes should not be dropped when performing this request\r\n * (due to hierarchy expanging through cursor change, for same BC hierarchy this leads to data loss)\r\n */\r\n keepDelta?: boolean\r\n}>('bcFetchDataRequest')\r\n\r\n/**\r\n * Fetch data request request for specific pages range\r\n */\r\nexport const bcFetchDataPages = createAction<{\r\n /**\r\n * The business component to fetch data for\r\n *\r\n * @deprecated TODO: 2.0.0 Should be removed in favor of widgetName\r\n */\r\n bcName: string\r\n /**\r\n * Fisrt page to fetch (default is 1)\r\n */\r\n widgetName: string\r\n /**\r\n * What widget requires data (widget can only request its own data here)\r\n */\r\n from?: number\r\n /**\r\n * Last page to fetch (default is current page)\r\n */\r\n to?: number\r\n}>('bcFetchDataPages')\r\n\r\nexport const bcClearData = createAction<{ bcNames: string[] }>('bcClearData')\r\n\r\n/**\r\n * Fetch data request for searchable fields\r\n */\r\nexport const inlinePickListFetchDataRequest = createAction<{\r\n /**\r\n * The business component to fetch data for\r\n */\r\n bcName: string\r\n /**\r\n * Search expression // TODO: Check format\r\n */\r\n searchSpec: string\r\n /**\r\n * Value to search for\r\n */\r\n searchString: string\r\n}>('inlinePickListFetchDataRequest')\r\n\r\n/**\r\n * Fetch data request was succesful\r\n */\r\nexport const bcFetchDataSuccess = createAction<{\r\n /**\r\n * Business component that requested data\r\n *\r\n * @deprecated TODO: 2.0.0 Remove in favor of widgetName\r\n */\r\n bcName: string\r\n /**\r\n * Data records from response for this business component\r\n */\r\n data: DataItem[]\r\n /**\r\n * For same BC hierarchies, the level which was requested\r\n *\r\n * @deprecated TODO: 2.0.0 Should be all moved to separate hierarchy-specific action\r\n */\r\n depth?: number\r\n /**\r\n * BC url with respect of parents cursors\r\n */\r\n bcUrl: string\r\n /**\r\n * If there are more data to fetch (other pages etc.)\r\n */\r\n hasNext?: boolean\r\n}>('bcFetchDataSuccess')\r\n\r\n/**\r\n * Fetch data request wac unsuccesful\r\n */\r\nexport const bcFetchDataFail = createAction<{\r\n /**\r\n * Business component that initiated data fetch\r\n */\r\n bcName: string\r\n /**\r\n * BC url with respect of parents cursors\r\n */\r\n bcUrl: string\r\n /**\r\n * For same BC hierarchies, the level which was requested\r\n *\r\n * @deprecated TODO: 2.0.0 Should be all moved to separate hierarchy-specific action\r\n */\r\n depth?: number\r\n}>('bcFetchDataFail')\r\n\r\n/**\r\n * Fetch next chunk of data for table widgets with infinite scroll\r\n */\r\nexport const bcLoadMore = createAction<{\r\n /**\r\n * Business component that initiated data fetch\r\n */\r\n bcName: string\r\n /**\r\n * Widget that initiated row meta fetch\r\n */\r\n widgetName?: string\r\n}>('bcLoadMore')\r\n\r\n/**\r\n * Fetch meta information for active record of business component\r\n */\r\nexport const bcFetchRowMeta = createAction<{\r\n /**\r\n *\r\n * Business component that initiated row meta fetch\r\n *\r\n * @deprecated TODO: 2.0.0 Remove in favor of widgetName\r\n */\r\n bcName: string\r\n /**\r\n * Widget that initiated row meta fetch\r\n */\r\n widgetName: string\r\n}>('bcFetchRowMeta')\r\n\r\n/**\r\n * Puts row meta received from Cxbox API to the store.\r\n *\r\n * Updates values in `data` store slice with new values from row meta when possible.\r\n */\r\nexport const bcFetchRowMetaSuccess = createAction<{\r\n /**\r\n * Business component that initiated row meta fetch\r\n */\r\n bcName: string\r\n /**\r\n * Path to BC with respect to ancestors BC and their cursors\r\n */\r\n bcUrl: string\r\n /**\r\n * Row meta returned by Cxbox API\r\n */\r\n rowMeta: RowMeta\r\n /**\r\n * Cursor for a record that initiated row meta fetch.\r\n *\r\n * Can be empty (e.g. BC has no records) or will be set to new id for `create` operation.\r\n */\r\n cursor?: string\r\n}>('bcFetchRowMetaSuccess')\r\n\r\n/**\r\n * Fetch request for row meta was unsuccesful\r\n */\r\nexport const bcFetchRowMetaFail = createAction<{\r\n /**\r\n * Business component initiated row meta fetch\r\n */\r\n bcName: string\r\n}>('bcFetchRowMetaFail')\r\n\r\n/**\r\n * @deprecated Not used; `sendOperationEpic` with `create` role is used instead\r\n *\r\n * TODO: Remove in 2.0.0\r\n */\r\nexport const bcNewData = createAction<{\r\n /**\r\n * Business component for which to create a new record\r\n */\r\n bcName: string\r\n}>('bcNewData')\r\n\r\n/**\r\n * Put new record draft to `data` store slice\r\n */\r\nexport const bcNewDataSuccess = createAction<{\r\n /**\r\n * Business component for which new record was created\r\n */\r\n bcName: string\r\n /**\r\n * New record with `id` returned by Cxbox API and vstamp = -1 (denoting a record draft)\r\n */\r\n dataItem: DataItem\r\n /**\r\n * Path to BC with respect to ancestors BC and their cursors\r\n */\r\n bcUrl: string\r\n}>('bcNewDataSuccess')\r\n\r\n/**\r\n * Dispatched when record creation failed\r\n */\r\nexport const bcNewDataFail = createAction<{\r\n /**\r\n * Business component for which record creation failed\r\n */\r\n bcName: string\r\n}>('bcNewDataFail')\r\n\r\n/**\r\n * Delete record request was\r\n */\r\nexport const bcDeleteDataFail = createAction<{\r\n /**\r\n * Business component initiated delete record\r\n */\r\n bcName: string\r\n}>('bcDeleteDataFail')\r\n\r\n/**\r\n * Request to change Force active field was unsuccesful\r\n */\r\nexport const forceActiveChangeFail = createAction<{\r\n /**\r\n * Business component initiated force active change\r\n */\r\n bcName: string\r\n /**\r\n * Cursors hierarchy at the time of force active change to\r\n */\r\n bcUrl: string\r\n /**\r\n * Error to show in modal\r\n */\r\n viewError: string\r\n /**\r\n * Validation errors on fields\r\n */\r\n entityError: OperationErrorEntity\r\n}>('forceActiveChangeFail')\r\n\r\n/**\r\n * Perform CustomAction\r\n */\r\nexport const sendOperation = createAction<ISendOperation>('sendOperation')\r\n\r\n/**\r\n * Send operation request was unsuccessful\r\n */\r\nexport const sendOperationFail = createAction<{\r\n /**\r\n * Business component initiated send operation request\r\n */\r\n bcName: string\r\n /**\r\n * Cursors hierarchy at the time when request was fired\r\n */\r\n bcUrl: string\r\n /**\r\n * Error to show in modal\r\n */\r\n viewError: string\r\n /**\r\n * Validation errors on fields\r\n */\r\n entityError: OperationErrorEntity\r\n}>('sendOperationFail')\r\n\r\n/**\r\n * Send operation request was successful\r\n */\r\nexport const sendOperationSuccess = createAction<{\r\n /**\r\n * Business component initiated the request\r\n */\r\n bcName: string\r\n /**\r\n * Cursor which initiated the request\r\n */\r\n cursor: string\r\n /**\r\n * New record with `id` returned by Cxbox API and vstamp = -1 (denoting a record draft)\r\n */\r\n dataItem?: DataItem\r\n}>('sendOperationSuccess')\r\n\r\n/**\r\n * TODO\r\n */\r\nexport const processPostInvoke = createAction<{\r\n /**\r\n * @deprecated TODO: Prefer widgetName instead (2.0.0)\r\n */\r\n bcName: string\r\n postInvoke: OperationPostInvokeAny\r\n cursor?: string\r\n /**\r\n * What widget initiated original operation, TODO: mandatory in 2.0.0\r\n */\r\n widgetName?: string\r\n}>('processPostInvoke')\r\n\r\n/**\r\n * Operation to perform preInvoke actions\r\n */\r\nexport const processPreInvoke = createAction<{\r\n /**\r\n * The business component to fetch data for\r\n */\r\n bcName: string\r\n /**\r\n * Type of operation to be performed\r\n */\r\n operationType: string\r\n /**\r\n * What widget requires data\r\n */\r\n widgetName: string\r\n /**\r\n * Action that will be performed before the main operation\r\n */\r\n preInvoke: OperationPreInvoke\r\n}>('processPreInvoke')\r\n\r\n/**\r\n * Operation to perform postInvokeConfirm actions\r\n */\r\nexport const processPostInvokeConfirm = createAction<{\r\n /**\r\n * The business component to fetch data for\r\n */\r\n bcName: string\r\n /**\r\n * Type of operation to be performed\r\n */\r\n operationType: string\r\n /**\r\n * What widget requires data\r\n */\r\n widgetName: string\r\n /**\r\n * Action that will be performed after the main operation and confirmation\r\n */\r\n postInvokeConfirm: OperationPostInvokeConfirm\r\n}>('processPostInvokeConfirm')\r\n\r\n/**\r\n * TODO\r\n */\r\nexport const userDrillDown = createAction<{\r\n widgetName: string\r\n bcName: string\r\n cursor: string\r\n fieldKey: string\r\n}>('userDrillDown')\r\n\r\n/**\r\n * TODO\r\n */\r\nexport const userDrillDownSuccess = createAction<{\r\n bcUrl: string\r\n bcName: string\r\n cursor: string\r\n}>('userDrillDownSuccess')\r\n\r\n/**\r\n * TODO\r\n */\r\nexport const drillDown = createAction<{\r\n url: string\r\n drillDownType?: DrillDownType\r\n urlName?: string\r\n route: Route\r\n widgetName?: string\r\n onSuccessAction?: AnyAction\r\n}>('drillDown')\r\n\r\n/**\r\n * TODO\r\n */\r\nexport const bcChangeCursors = createAction<{\r\n cursorsMap: Record<string, string>\r\n keepDelta?: boolean\r\n}>('bcChangeCursors')\r\n\r\n/**\r\n * Sets a cursor for the specified depth level of hierarchy widget\r\n * builded around a single business component.\r\n */\r\nexport const bcChangeDepthCursor = createAction<{\r\n /**\r\n * Business component for the hierarchy widget\r\n */\r\n bcName: string\r\n /**\r\n * Depth level for which cursor is set\r\n */\r\n depth: number\r\n /**\r\n * Cursor set for specific depth level of the hierarchy widget.\r\n *\r\n * Controls the collapsed state of the record and which data are fetched for the next level of hierarchy\r\n */\r\n cursor: string\r\n}>('bcChangeDepthCursor')\r\n\r\n/**\r\n * TODO\r\n */\r\nexport const changeDataItem = createAction<{\r\n bcName: string\r\n bcUrl: string\r\n cursor: string\r\n dataItem: PendingDataItem\r\n disableRetry?: boolean\r\n}>('changeDataItem')\r\n\r\n/**\r\n * TODO\r\n */\r\nexport const changeDataItems = createAction<{\r\n bcName: string\r\n cursors: string[]\r\n dataItems: PendingDataItem[]\r\n}>('changeDataItems')\r\n\r\n/**\r\n * TODO\r\n */\r\nexport const forceActiveRmUpdate = createAction<{\r\n /**\r\n * current data for record that initiated rowMeta fetch\r\n */\r\n currentRecordData: DataItem\r\n rowMeta: RowMeta\r\n bcName: string\r\n bcUrl: string\r\n cursor: string\r\n}>('forceActiveRmUpdate')\r\n\r\nexport interface WaitUntilPopupOptions {\r\n status: 'progress' | 'success' | 'timeout'\r\n message: string\r\n}\r\n\r\n/**\r\n * TODO\r\n */\r\nexport const showViewPopup = createAction<{\r\n options?: Partial<WaitUntilPopupOptions>\r\n /**\r\n * BC name of popup widget\r\n *\r\n * @deprecated TODO: Remove in 2.0.0 in favor of widget name\r\n */\r\n bcName: string\r\n /**\r\n * Name of popup widget\r\n */\r\n widgetName?: string\r\n /**\r\n * It's BC name of `caller` widget actually\r\n *\r\n * @deprecated TODO: Remove in 2.0.0 in favor of widget name\r\n */\r\n calleeBCName?: string\r\n /**\r\n * Name of `caller` widget actually\r\n *\r\n * TODO: 2.0.0 : Rename to `callerWidgetName`\r\n */\r\n calleeWidgetName?: string\r\n /**\r\n * Popup widget field key associated to `assocValueKey` of caller widget\r\n */\r\n associateFieldKey?: string\r\n /**\r\n * Caller widget field key associated to `associateFieldKey` of popup widget\r\n */\r\n assocValueKey?: string\r\n /**\r\n * If `true` then backend's method of association is used\r\n */\r\n active?: boolean\r\n /**\r\n * Whether popup is used as filter\r\n */\r\n isFilter?: boolean\r\n /**\r\n * Type of popup\r\n */\r\n type?: PopupType | string\r\n}>('showViewPopup')\r\n\r\n/**\r\n * TODO\r\n */\r\nexport const showFileUploadPopup = createAction<{\r\n /**\r\n * Name of the widget that initiated popup opening\r\n */\r\n widgetName: string\r\n}>('showFileUploadPopup')\r\n\r\n/**\r\n * Closes currently active popup on view\r\n */\r\nexport const closeViewPopup = createAction<{\r\n /**\r\n * Not used\r\n *\r\n * @deprecated TODO: Will be removed in 2.0.0\r\n */\r\n bcName?: string\r\n}>('closeViewPopup')\r\n\r\n/**\r\n * TODO\r\n */\r\nexport const viewPutPickMap = createAction<{\r\n map: PickMap\r\n bcName: string\r\n}>('viewPutPickMap')\r\n\r\n/**\r\n * TODO\r\n */\r\nexport const viewClearPickMap = createAction<null>('viewClearPickMap')\r\n\r\n/**\r\n * TODO\r\n */\r\nexport const saveAssociations = createAction<{\r\n bcNames: string[]\r\n /**\r\n * For usage outside Popup (without opening multivalue)\r\n */\r\n calleeBcName?: string\r\n associateFieldKey?: string\r\n}>('saveAssociations')\r\n\r\n/**\r\n * Sets intermediate state for association widget by storing associated records in pseudo-business component.\r\n *\r\n * Name for this pseudo-BC is formed as `${bcName}Delta`.\r\n */\r\nexport const changeAssociations = createAction<{\r\n /**\r\n * Assoc widget's business component\r\n */\r\n bcName: string\r\n /**\r\n * Records that marked as `associated` for this widget\r\n *\r\n * TODO: Will be mandatory in 2.0.0\r\n */\r\n records?: DataItem[]\r\n}>('cnangeAssociations')\r\n\r\n/**\r\n * TODO\r\n */\r\nexport const removeMultivalueTag = createAction<{\r\n bcName: string\r\n popupBcName: string\r\n cursor: string\r\n associateFieldKey: string\r\n dataItem: MultivalueSingleValue[]\r\n removedItem: MultivalueSingleValue\r\n}>('removeMultivalueTag')\r\n\r\n/**\r\n * TODO\r\n */\r\nexport const bcSaveDataSuccess = createAction<{\r\n bcName: string\r\n cursor: string\r\n dataItem: DataItem\r\n}>('bcSaveDataSuccess')\r\n\r\n/**\r\n * TODO\r\n */\r\nexport const bcSaveDataFail = createAction<{\r\n bcName: string\r\n bcUrl: string\r\n entityError?: OperationErrorEntity\r\n viewError?: string\r\n}>('bcSaveDataFail')\r\n\r\n/**\r\n * Save info about current operation for confirm modal\r\n */\r\nexport const operationConfirmation = createAction<{\r\n /**\r\n * Current operation\r\n */\r\n operation: {\r\n bcName: string\r\n operationType: OperationTypeCrud | string\r\n widgetName: string\r\n }\r\n /**\r\n * Text for confirm modal\r\n */\r\n confirmOperation: OperationPostInvokeConfirm\r\n}>('operationConfirmation')\r\n\r\n/**\r\n * Manually update business component by fetching its data and and row meta\r\n */\r\nexport const bcForceUpdate = createAction<{\r\n /**\r\n * @deprecated Will be removed in 2.0.0 in favor of `widgetName`\r\n */\r\n bcName: string\r\n /**\r\n * What widget requires data (widget can only request its own data here)\r\n *\r\n * TODO: Will be mandatory in 2.0.0\r\n */\r\n widgetName?: string\r\n}>('bcForceUpdate')\r\n\r\n/**\r\n * TODO\r\n */\r\nexport const uploadFile = createAction<null>('uploadFile')\r\n\r\n/**\r\n * TODO\r\n */\r\nexport const uploadFileDone = createAction<null>('uploadFileDone')\r\n\r\n/**\r\n * TODO\r\n */\r\nexport const uploadFileFailed = createAction<null>('uploadFileFailed')\r\n\r\n/**\r\n * TODO\r\n */\r\nexport const bcCancelPendingChanges = createAction<{\r\n bcNames: string[]\r\n}>('bcCancelPendingChanges')\r\n\r\n/**\r\n * TODO\r\n */\r\nexport const bcSelectRecord = createAction<{\r\n bcName: string\r\n cursor: string\r\n ignoreChildrenPageLimit?: boolean\r\n keepDelta?: boolean\r\n}>('bcSelectRecord')\r\n\r\n/**\r\n * Wrapper action to sets a cursor for the specified depth level of hierarchy widget\r\n * builded around a single business component and fetch children for that record.\r\n *\r\n * @deprecated Do not use. TODO: Will be removed in 2.0.0\r\n */\r\nexport const bcSelectDepthRecord = createAction<{\r\n /**\r\n * Business component for the hierarchy widget\r\n */\r\n bcName: string\r\n /**\r\n * Depth level for which cursor is set\r\n */\r\n depth: number\r\n /**\r\n * Cursor set for specific depth level of the hierarchy widget.\r\n *\r\n * Controls the collapsed state of the record and which data are fetched for the next level of hierarchy\r\n */\r\n cursor: string\r\n}>('bcSelectDepthRecord')\r\n\r\n/**\r\n * TODO\r\n */\r\nexport const changeAssociation = createAction<{\r\n bcName: string\r\n widgetName: string\r\n dataItem: AssociatedItem\r\n assocValueKey: string\r\n}>('changeAssociations')\r\n\r\n/**\r\n * TODO\r\n */\r\nexport const changeAssociationSameBc = createAction<{\r\n bcName: string\r\n depth: number\r\n widgetName: string\r\n dataItem: AssociatedItem\r\n assocValueKey: string\r\n}>('changeAssociationsSameBc')\r\n\r\n/**\r\n * TODO\r\n */\r\nexport const changeAssociationFull = createAction<{\r\n bcName: string\r\n depth: number\r\n widgetName: string\r\n dataItem: AssociatedItem\r\n /**\r\n * @deprecated TODO: Remove in 2.0.0 in favor of store.view.popupData.assocValueKey instead\r\n */\r\n assocValueKey?: string\r\n}>('changeAssociationFull')\r\n\r\n/**\r\n * TODO\r\n */\r\nexport const changeChildrenAssociations = createAction<{\r\n bcName: string\r\n assocValueKey: string\r\n selected: boolean\r\n}>('changeChildrenAssociations')\r\n\r\n/**\r\n * TODO\r\n */\r\nexport const changeChildrenAssociationsSameBc = createAction<{\r\n bcName: string\r\n depth: number\r\n assocValueKey: string\r\n selected: boolean\r\n}>('changeChildrenAssociationsSameBc')\r\n\r\n/**\r\n * TODO\r\n */\r\nexport const changeDescendantsAssociationsFull = createAction<{\r\n bcName: string\r\n parentId: string\r\n depth: number\r\n assocValueKey: string\r\n selected: boolean\r\n}>('changeDescendantsAssociationsFull')\r\n\r\n/**\r\n * TODO\r\n */\r\nexport const dropAllAssociations = createAction<{\r\n bcNames: string[]\r\n}>('dropAllAssociations')\r\n\r\n/**\r\n * TODO\r\n */\r\nexport const dropAllAssociationsSameBc = createAction<{\r\n bcName: string\r\n depthFrom: number\r\n}>('dropAllAssociationsSameBc')\r\n\r\n/**\r\n * TODO\r\n */\r\nexport const dropAllAssociationsFull = createAction<{\r\n bcName: string\r\n depth: number\r\n dropDescendants?: boolean\r\n}>('dropAllAssociationsFull')\r\n\r\n/**\r\n * For server side routing where {@link RouteType.router | routes are handled by Cxbox API endpoint}, this action is dispatched\r\n * to process requested route.\r\n */\r\nexport const handleRouter = createAction<{\r\n /**\r\n * An URL that will be passed to Cxbox API router endpoint\r\n */\r\n path: string\r\n /**\r\n * AJAX request parameters for the requests\r\n */\r\n params: Record<string, unknown>\r\n}>('handleRouter')\r\n\r\n/**\r\n * Used for edit list widget row\r\n */\r\nexport const selectTableRowInit = createAction<{\r\n widgetName: string\r\n rowId: string\r\n}>('selectTableRowInit')\r\n\r\n/**\r\n * TODO\r\n */\r\nexport const selectTableRow = createAction<{\r\n widgetName: string\r\n rowId: string\r\n}>('selectTableRow')\r\n\r\nexport const deselectTableRow = createAction('deselectTableRow')\r\n\r\n/**\r\n * TODO\r\n */\r\nexport const showAllTableRecordsInit = createAction<{\r\n bcName: string\r\n cursor: string\r\n /**\r\n * @deprecated Remove in 2.0 (accessible from the store)\r\n */\r\n route?: Route\r\n}>('showAllTableRecordsInit')\r\n\r\n/**\r\n * TODO\r\n */\r\nexport const showNotification = createAction<{\r\n type: AppNotificationType\r\n message: string\r\n}>('showNotification')\r\n\r\n/**\r\n * TODO\r\n */\r\nexport const closeNotification = createAction<{\r\n id: number\r\n}>('closeNotification')\r\n\r\n/**\r\n * TODO\r\n */\r\nexport const bcAddFilter = createAction<{\r\n /**\r\n * TODO: Will be mandatory in 2.0.0\r\n */\r\n widgetName?: string\r\n /**\r\n * @deprecated TODO: Remove in 2.0.0 in favor of widgetName\r\n */\r\n bcName: string\r\n filter: BcFilter\r\n}>('bcAddFilter')\r\n\r\n/**\r\n * TODO\r\n */\r\nexport const bcRemoveFilter = createAction<{\r\n bcName: string\r\n filter: BcFilter\r\n}>('bcRemoveFilter')\r\n\r\n/**\r\n * Remove all filters at once\r\n */\r\nexport const bcRemoveAllFilters = createAction<{\r\n bcName: string\r\n}>('bcRemoveAllFilters')\r\n\r\n/**\r\n * TODO\r\n */\r\nexport const bcAddSorter = createAction<{\r\n bcName: string\r\n sorter: BcSorter | BcSorter[]\r\n}>('bcAddSorter')\r\n\r\n/**\r\n * TODO\r\n */\r\nexport const bcRemoveSorter = createAction<{\r\n bcName: string\r\n sorter: BcSorter\r\n}>('bcRemoveSorter')\r\n\r\n/**\r\n * Fetches data for the new page of business component, replacing existing data\r\n */\r\nexport const bcChangePage = createAction<{\r\n /**\r\n * Business component changing the page\r\n *\r\n * @deprecated TODO: Will be removed in 2.0.0 in favor of `widgetNam`\r\n */\r\n bcName: string\r\n /**\r\n * Requested page number\r\n */\r\n page: number\r\n /**\r\n * Widget changing the page\r\n */\r\n widgetName?: string\r\n}>('bcChangePage')\r\n\r\n/**\r\n * TODO\r\n */\r\nexport const showViewError = createAction<{\r\n error: ApplicationError\r\n}>('showViewError')\r\n\r\n/**\r\n * TODO\r\n */\r\nexport const closeViewError = createAction<null>('closeViewError')\r\n\r\n/**\r\n * Close confirm modal window\r\n */\r\nexport const closeConfirmModal = createAction<null>('closeConfirmModal')\r\n\r\n/**\r\n * TODO\r\n */\r\nexport const clearValidationFails = createAction<null>('clearValidationFails')\r\n\r\n/**\r\n * TODO\r\n */\r\nexport const downloadFile = createAction<{\r\n fileId: string\r\n}>('downloadFile')\r\n\r\n/**\r\n * TODO\r\n */\r\nexport const downloadFileByUrl = createAction<{\r\n url: string\r\n name?: string\r\n}>('downloadFileByUrl')\r\n\r\n/**\r\n * Save uploaded files to the widget\r\n */\r\nexport const bulkUploadFiles = createAction<{\r\n /**\r\n * default true\r\n */\r\n isPopup?: boolean\r\n /**\r\n * If not specified, then taken from state.view.popupData.bcName\r\n */\r\n bcName?: string\r\n /**\r\n * Ids of uploaded files\r\n */\r\n fileIds: string[]\r\n}>('bulkUploadFiles')\r\n\r\n/**\r\n * An error occured during API request\r\n */\r\nexport const apiError = createAction<{\r\n /**\r\n * Axios error object\r\n * https://redux.js.org/style-guide/#do-not-put-non-serializable-values-in-state-or-actions\r\n */\r\n error: AxiosError\r\n /**\r\n * Request context\r\n */\r\n callContext: ApiCallContext\r\n}>('apiError')\r\n\r\n/**\r\n * Fires for specific HTTP status code\r\n */\r\nexport const httpError = createAction<{\r\n /**\r\n * Status code for failed request caught by `onErrorHook`\r\n */\r\n statusCode: number\r\n /**\r\n * Axios error object\r\n */\r\n error: AxiosError\r\n /**\r\n * Request context\r\n */\r\n callContext: ApiCallContext\r\n}>('httpError')\r\n\r\n/**\r\n * Enable/disable debug mode\r\n */\r\nexport const switchDebugMode = createAction<boolean>('switchDebugMode')\r\n\r\n/**\r\n * Download state to device\r\n */\r\nexport const exportState = createAction<null>('exportState')\r\n\r\n/**\r\n * TODO\r\n */\r\nexport const emptyAction = createAction<null>('emptyAction')\r\n\r\n/**\r\n * refresh screens, views and widgets meta\r\n */\r\nexport const refreshMeta = createAction('refreshMeta')\r\n/**\r\n * refresh refreshMeta was successful\r\n */\r\nexport const refreshMetaDone = createAction('refreshMetaDone')\r\n/**\r\n * refresh refreshMeta was unsuccessful\r\n */\r\nexport const refreshMetaFail = createAction('refreshMetaFail')\r\n\r\n/**\r\n * Refresh meta data (see action above) and reload page\r\n */\r\nexport const refreshMetaAndReloadPage = createAction<null>('refreshMetaAndReloadPage')\r\n\r\n/**\r\n * Switch to another user role\r\n */\r\nexport const switchRole = createAction<{\r\n role: string\r\n}>('switchRole')\r\n\r\n/**\r\n * Add pending request for tracking and blocking race conditions\r\n */\r\nexport const addPendingRequest = createAction<{\r\n request: PendingRequest\r\n}>('addPendingRequest')\r\n\r\n/**\r\n * Remove pending request\r\n */\r\nexport const removePendingRequest = createAction<{\r\n requestId: string\r\n}>('removePendingRequest')\r\n\r\nexport const addNotification = createAction<Notification>('addNotification')\r\n\r\nexport const removeNotifications = createAction<NotificationKeys>('removeNotifications')\r\n\r\nexport const waitUntil = createAction<{ bcName: string; postInvoke: Omit<OperationPostInvokeWaitUntil, 'type'> }>('waitUntil')\r\n\r\nexport const setPendingSendOperation = createAction<ISendOperation>('setPendingSendOperation')\r\n\r\nexport const associateInProgress = createAction<{ bcName: string }>('associateInProgress')\r\n\r\nexport const setOperationFinished = createAction<{ bcName: string; operationType: OperationType }>('setOperationFinished')\r\n\r\nexport const selectRows = createAction<{\r\n bcName: string\r\n dataItems: Array<Omit<DataItem, 'vstamp'>>\r\n}>('selectRows')\r\n\r\nexport const deselectRows = createAction<{\r\n bcName: string\r\n ids: string[]\r\n}>('deselectRows')\r\n\r\nexport const clearSelectedRows = createAction<{\r\n bcName: string\r\n}>('clearSelectedRows')\r\n\r\nexport const setPendingPostInvoke = createAction<{\r\n bcName: string\r\n operationType: string\r\n postInvoke: OperationPostInvokeAny\r\n}>('setPendingPostInvoke')\r\n\r\nexport const applyPendingPostInvoke = createAction<{\r\n bcName: string\r\n widgetName?: string\r\n operationType: string\r\n postInvoke: OperationPostInvokeAny\r\n}>('applyPendingPostInvoke')\r\n\r\nexport const inlinePickListFetchDataSuccess = createAction<{\r\n /**\r\n * Business component that requested data\r\n *\r\n * @deprecated TODO: 2.0.0 Remove in favor of widgetName\r\n */\r\n bcName: string\r\n /**\r\n * Data records from response for this business component\r\n */\r\n data: DataItem[]\r\n /**\r\n * BC url with respect of parents cursors\r\n */\r\n bcUrl: string\r\n /**\r\n * If there are more data to fetch (other pages etc.)\r\n */\r\n hasNext?: boolean\r\n}>('inlinePickListFetchDataSuccess')\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { ActionReducerMapBuilder, CaseReducer } from '@reduxjs/toolkit'\r\nimport { Action, AnyAction } from 'redux'\r\n\r\ninterface TypedActionCreator<Type extends string> {\r\n (...args: any[]): Action<Type>\r\n type: Type\r\n}\r\n\r\ntype TypeGuard<T> = (value: any) => value is T\r\n\r\nexport class ReducerBuilderManager<State> {\r\n private reducers: Array<[TypedActionCreator<string>, CaseReducer<State, AnyAction>]> = []\r\n private matchers: Array<[TypeGuard<any> | ((action: AnyAction) => boolean), CaseReducer<State, AnyAction>]> = []\r\n private defaultCaseReducer: CaseReducer<State, AnyAction> | undefined = undefined\r\n\r\n addCase<ActionCreator extends TypedActionCreator<string>>(\r\n action: ActionCreator,\r\n reducer: CaseReducer<State, ReturnType<ActionCreator>>\r\n ) {\r\n this.reducers.push([action, reducer])\r\n return this\r\n }\r\n\r\n removeCase<ActionCreator extends TypedActionCreator<string>>(action: ActionCreator) {\r\n this.reducers = this.reducers.filter(reducer => reducer[0].type !== action.type)\r\n return this\r\n }\r\n\r\n replaceCase<ActionCreator extends TypedActionCreator<string>>(\r\n action: ActionCreator,\r\n reducer: CaseReducer<State, ReturnType<ActionCreator>>\r\n ) {\r\n this.removeCase(action).addCase(action, reducer)\r\n return this\r\n }\r\n addMatcher<A>(\r\n matcher: TypeGuard<A> | ((action: any) => boolean),\r\n reducer: CaseReducer<State, A extends AnyAction ? A : A & AnyAction>\r\n ): Omit<ReducerBuilderManager<State>, 'addCase'> {\r\n this.matchers.push([matcher, reducer])\r\n return this\r\n }\r\n\r\n addDefaultCase(\r\n reducer: CaseReducer<State, AnyAction>\r\n ): Omit<ReducerBuilderManager<State>, 'addCase' | 'addMatcher' | 'addDefaultCase'> {\r\n this.defaultCaseReducer = reducer\r\n return this\r\n }\r\n\r\n get builder() {\r\n return (builder: ActionReducerMapBuilder<State>) => {\r\n const builderWithCases = this.reducers.reduce((acc, args) => acc.addCase(...args), builder)\r\n const builderWithMatchers = this.matchers.reduce((acc, args) => acc.addMatcher(...args), builderWithCases)\r\n return this.defaultCaseReducer !== undefined ? builderWithMatchers.addDefaultCase(this.defaultCaseReducer) : builderWithMatchers\r\n }\r\n }\r\n}\r\n","import { DataState, DataItem } from '../interfaces'\r\nimport {\r\n bcClearData,\r\n bcFetchDataSuccess,\r\n bcFetchRowMetaSuccess,\r\n bcNewDataSuccess,\r\n bcSaveDataSuccess,\r\n changeAssociations,\r\n inlinePickListFetchDataSuccess,\r\n selectView\r\n} from '../actions'\r\nimport { ReducerBuilderManager } from './ReducerBuilderManager'\r\n\r\nconst emptyData: DataItem[] = []\r\n\r\nexport const dataInitialState: DataState = {}\r\n\r\nexport const createDataReducerBuilderManager = (initialState: DataState) =>\r\n new ReducerBuilderManager<typeof initialState>()\r\n .addCase(bcFetchDataSuccess, (state, action) => {\r\n state[action.payload.bcName] = action.payload.data\r\n })\r\n .addCase(inlinePickListFetchDataSuccess, (state, action) => {\r\n state[action.payload.bcName] = action.payload.data\r\n })\r\n .addCase(bcNewDataSuccess, (state, action) => {\r\n state[action.payload.bcName] = [...(state[action.payload.bcName] || emptyData), action.payload.dataItem]\r\n })\r\n .addCase(bcSaveDataSuccess, (state, action) => {\r\n const nextDataItem = action.payload.dataItem\r\n const index = state[action.payload.bcName].findIndex(item => item.id === nextDataItem.id)\r\n state[action.payload.bcName][index] = nextDataItem\r\n })\r\n .addCase(bcFetchRowMetaSuccess, (state, action) => {\r\n const cursor = action.payload.cursor\r\n if (!cursor) {\r\n return\r\n }\r\n const prevDataItem = (state[action.payload.bcName] || emptyData).find(item => item.id === cursor)\r\n const nextDataItem: DataItem = {\r\n ...prevDataItem,\r\n id: cursor,\r\n vstamp: -1,\r\n _associate: prevDataItem && prevDataItem._associate\r\n }\r\n // BC is unable to update value from row meta if id is null\r\n const valueUpdateUnsupported = action.payload.rowMeta.fields.find(item => item.key === 'id' && !item.currentValue)\r\n if (valueUpdateUnsupported) {\r\n return\r\n }\r\n action.payload.rowMeta.fields\r\n .filter(field => {\r\n // TODO: check if previous condition covered that case\r\n return field.key !== '_associate'\r\n })\r\n .forEach(field => (nextDataItem[field.key] = field.currentValue))\r\n\r\n if (!prevDataItem) {\r\n state[action.payload.bcName] = [...(state[action.payload.bcName] || emptyData), nextDataItem]\r\n return\r\n }\r\n state[action.payload.bcName] = state[action.payload.bcName].map(item => (item === prevDataItem ? nextDataItem : item))\r\n })\r\n .addCase(changeAssociations, (state, action) => {\r\n state[`${action.payload.bcName}Delta`] = action.payload.records || []\r\n })\r\n .addCase(selectView, (state, action) => {\r\n if (action.payload.isTab) {\r\n return state\r\n }\r\n\r\n return initialState\r\n })\r\n .addCase(bcClearData, (state, action) => {\r\n action.payload.bcNames?.forEach(bcName => {\r\n delete state[bcName]\r\n })\r\n })\r\n","var p=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var h=Object.prototype.hasOwnProperty;var b=(o,a)=>{for(var d in a)p(o,d,{get:a[d],enumerable:!0})},M=(o,a,d,i)=>{if(a&&typeof a==\"object\"||typeof a==\"function\")for(let r of x(a))!h.call(o,r)&&r!==d&&p(o,r,{get:()=>a[r],enumerable:!(i=F(a,r))||i.enumerable});return o};var f=o=>M(p({},\"__esModule\",{value:!0}),o);var v={};b(v,{DrillDownType:()=>u,FieldType:()=>y,OperationTypeCrud:()=>c,PositionTypes:()=>m,RecordSnapshotState:()=>s,WidgetTypes:()=>g});module.exports=f(v);var s=(i=>(i.noChange=\"noChange\",i.new=\"new\",i.deleted=\"deleted\",i))(s||{});var c=(l=>(l.create=\"create\",l.save=\"save\",l.delete=\"delete\",l.associate=\"associate\",l.cancelCreate=\"cancel-create\",l.fileUpload=\"file-upload\",l))(c||{});var u=(n=>(n.inner=\"inner\",n.relative=\"relative\",n.relativeNew=\"relativeNew\",n.external=\"external\",n.externalNew=\"externalNew\",n))(u||{});var g=(t=>(t.Info=\"Info\",t.Form=\"Form\",t.List=\"List\",t.DataGrid=\"DataGrid\",t.AssocListPopup=\"AssocListPopup\",t.PickListPopup=\"PickListPopup\",t.HeaderWidget=\"HeaderWidget\",t.SecondLevelMenu=\"SecondLevelMenu\",t.ThirdLevelMenu=\"ThirdLevelMenu\",t.FourthLevelMenu=\"FourthLevelMenu\",t.WidgetCreator=\"WidgetCreator\",t.Pivot=\"Pivot\",t.DimFilter=\"DimFilter\",t.Text=\"Text\",t.FlatTree=\"FlatTree\",t.FlatTreePopup=\"FlatTreePopup\",t.ViewNavigation=\"ViewNavigation\",t.NavigationTabs=\"NavigationTabs\",t))(g||{}),m=(i=>(i.Top=\"Top\",i.Bottom=\"Bottom\",i.TopAndBottom=\"TopAndBottom\",i))(m||{}),y=(e=>(e.number=\"number\",e.input=\"input\",e.monthYear=\"monthYear\",e.date=\"date\",e.dateTime=\"dateTime\",e.dateTimeWithSeconds=\"dateTimeWithSeconds\",e.checkbox=\"checkbox\",e.checkboxSql=\"checkboxSql\",e.DMN=\"DMN\",e.pickList=\"pickList\",e.inlinePickList=\"inline-pickList\",e.dictionary=\"dictionary\",e.hidden=\"hidden\",e.text=\"text\",e.percent=\"percent\",e.fileUpload=\"fileUpload\",e.money=\"money\",e.comboCondition=\"combo-condition\",e.richText=\"richText\",e.printForm=\"printForm\",e.multifield=\"multifield\",e.multivalue=\"multivalue\",e.multivalueHover=\"multivalueHover\",e.hint=\"hint\",e.radio=\"radio\",e))(y||{});0&&(module.exports={DrillDownType,FieldType,OperationTypeCrud,PositionTypes,RecordSnapshotState,WidgetTypes});\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\n/**\r\n * A dictionary for a values of specified type\r\n *\r\n * @deprecated TODO: Remove in 2.0.0 in favor of native `Record` type\r\n *\r\n * @template T Value type\r\n */\r\nexport interface ObjectMap<T> {\r\n [key: string]: T | undefined\r\n}\r\n\r\n/**\r\n * Basic type for Cxbox API responses\r\n *\r\n * TODO: Move this to a an appropriate module\r\n */\r\nexport type CxboxResponse = {\r\n /**\r\n * If any response returs with this field, browser should redirect on this address\r\n */\r\n redirectUrl?: string\r\n [x: string]: any\r\n}\r\n\r\n/**\r\n * Types of notification messages\r\n */\r\nexport enum AppNotificationType {\r\n success = 'success',\r\n info = 'info',\r\n warning = 'warning',\r\n error = 'error'\r\n}\r\n\r\nexport interface SystemNotification {\r\n id: number\r\n type: AppNotificationType\r\n message: string\r\n}\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nexport { DrillDownType } from '@cxbox-ui/schema'\r\n\r\nexport interface Route {\r\n type: RouteType\r\n path: string\r\n search: string\r\n params: Record<string, unknown>\r\n screenName?: string\r\n viewName?: string\r\n bcPath?: string\r\n}\r\n\r\nexport enum RouteType {\r\n screen = 'screen',\r\n default = 'default',\r\n router = 'router',\r\n invalid = 'invalid',\r\n unknown = 'unknown'\r\n}\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { WidgetMeta } from './widget'\r\nimport { RowMeta } from './rowMeta'\r\nimport { PendingDataItem, PickMap } from './data'\r\nimport { SystemNotification } from './objectMap'\r\nimport { OperationTypeCrud, OperationPostInvokeConfirm, OperationPostInvokeAny } from './operation'\r\nimport { AxiosError } from 'axios'\r\nimport { WaitUntilPopupOptions } from '../actions'\r\nimport { DataItem } from '@cxbox-ui/schema'\r\nexport { FieldType } from '@cxbox-ui/schema'\r\n\r\nexport interface ViewSelectedRow {\r\n widgetName: string\r\n rowId: string\r\n}\r\n\r\nexport interface PendingValidationFails {\r\n [bcName: string]: {\r\n [cursor: string]: Record<string, string>\r\n }\r\n}\r\n\r\n/**\r\n * Describes format of `pendingValidationFails`\r\n * TODO remove in 2.0.0\r\n */\r\nexport enum PendingValidationFailsFormat {\r\n old = 'old',\r\n target = 'target'\r\n}\r\n\r\nexport interface ViewState extends ViewMetaResponse {\r\n rowMeta: {\r\n [bcName: string]: {\r\n [bcUrl: string]: RowMeta\r\n }\r\n }\r\n pendingPostInvoke: {\r\n [bcName: string]: {\r\n [type: string]: OperationPostInvokeAny\r\n }\r\n }\r\n pendingDataChanges: {\r\n [bcName: string]: {\r\n [cursor: string]: PendingDataItem\r\n }\r\n }\r\n pendingDataChangesNow: {\r\n [bcName: string]: {\r\n [cursor: string]: PendingDataItem\r\n }\r\n }\r\n handledForceActive: {\r\n [bcName: string]: {\r\n [cursor: string]: PendingDataItem\r\n }\r\n }\r\n metaInProgress: {\r\n [bcName: string]: boolean\r\n }\r\n popupData?: PopupData\r\n infiniteWidgets?: string[]\r\n pickMap?: PickMap\r\n selectedRow: ViewSelectedRow | null\r\n selectedRows: { [bcName: string]: Array<Omit<DataItem, 'vstamp'>> | undefined }\r\n systemNotifications?: SystemNotification[]\r\n error?: ApplicationError\r\n /**\r\n * For backward compatibility\r\n *\r\n * `old` describes `pendingValidationFails` as `Record<string, string>`\r\n * `target` describes `pendingValidationFails` as `PendingValidationFails`\r\n */\r\n pendingValidationFailsFormat?: PendingValidationFailsFormat.old | PendingValidationFailsFormat.target // TODO remove in 2.0.0\r\n // TODO 2.0.0: should be `pendingValidationFails?: PendingValidationFails`\r\n pendingValidationFails?: Record<string, string> | PendingValidationFails\r\n modalInvoke?: {\r\n operation: {\r\n bcName: string\r\n operationType: OperationTypeCrud | string\r\n widgetName: string\r\n }\r\n confirmOperation: OperationPostInvokeConfirm\r\n }\r\n}\r\n\r\n/**\r\n * View description returned by Cxbox API\r\n */\r\nexport interface ViewMetaResponse {\r\n /**\r\n * @deprecated Deprecated in favor of `name`\r\n */\r\n id?: number\r\n /**\r\n * Name of the view as specified in *.view.json file\r\n */\r\n name: string\r\n /**\r\n * Displayed title\r\n */\r\n title?: string\r\n /**\r\n * Specifies which layout template to use for the view\r\n *\r\n *Not used in Cxbox UI Core, but can used by client application\r\n */\r\n template?: string\r\n /**\r\n * @deprecated Used for dynamic view layouts (configurable from user side), which are no longer implemented\r\n */\r\n customizable?: boolean\r\n /**\r\n * @deprecated Not used\r\n */\r\n editable?: boolean\r\n /**\r\n * Url for the view (usually in form of `${screen.name}/${view.name}`)\r\n */\r\n url: string\r\n /**\r\n * Widgets present on the view\r\n */\r\n widgets: WidgetMeta[]\r\n /**\r\n * @deprecated Used for dynamic view layouts (configurable from user side), which are no longer implemented\r\n */\r\n columns?: number | null\r\n /**\r\n * @deprecated Used for dynamic view layouts (configurable from user side), which are no longer implemented\r\n */\r\n rowHeight?: number | null\r\n /**\r\n * Not used in Cxbox UI Core, but can be used by client application\r\n */\r\n readOnly?: boolean\r\n /**\r\n * Not used in Cxbox UI Core\r\n *\r\n * TODO: Need description\r\n */\r\n ignoreHistory?: boolean\r\n}\r\n\r\nexport type PopupType = 'assoc' | 'file-upload' | 'waitUntil' | null\r\n\r\n/**\r\n * Describes currently open popup\r\n *\r\n * TODO: Split interface by popup types\r\n */\r\nexport interface PopupData {\r\n /**\r\n * Business component of the widget that initiated popup\r\n *\r\n * TODO: Will me removed in favor of widgetName in 2.0.0\r\n */\r\n calleeBCName?: string\r\n /**\r\n * Name of the widget that initiated popup\r\n */\r\n calleeWidgetName?: string\r\n /**\r\n * Type of the popup\r\n *\r\n * TODO: Will not be optional in 2.0.0\r\n */\r\n type?: PopupType | string\r\n /**\r\n * Business component for widget in Popup\r\n *\r\n * TODO: Move to inherited interfaces (not all popups display widgets)\r\n */\r\n bcName?: string\r\n /**\r\n * Name of popup widget\r\n *\r\n * TODO: Move to inherited interfaces (not all popups display widgets)\r\n */\r\n widgetName?: string\r\n /**\r\n * TODO: Description + move to AssocPopupDescriptor\r\n */\r\n associateFieldKey?: string\r\n /**\r\n * TODO: Description + move to AssocPopupDescriptor\r\n */\r\n assocValueKey?: string\r\n /**\r\n * If true popup confirm button will send selected items to Cxbox API\r\n *\r\n * TODO: Move to AssocPopupDescriptor\r\n */\r\n active?: boolean\r\n /**\r\n * This popup is used as a filter\r\n *\r\n * TODO: Used only by assocs so probably move to AssocPopupDescriptor\r\n */\r\n isFilter?: boolean\r\n\r\n options?: Partial<WaitUntilPopupOptions>\r\n}\r\n\r\nexport type ApplicationError = BusinessError | SystemError | ApplicationErrorBase\r\n\r\nexport enum ApplicationErrorType {\r\n BusinessError,\r\n SystemError,\r\n NetworkError\r\n}\r\n\r\nexport interface ApplicationErrorBase {\r\n type: ApplicationErrorType\r\n code?: number\r\n}\r\n\r\nexport interface BusinessError extends ApplicationErrorBase {\r\n type: ApplicationErrorType.BusinessError\r\n message: string\r\n}\r\n\r\nexport interface SystemError extends ApplicationErrorBase {\r\n type: ApplicationErrorType.SystemError\r\n error?: AxiosError\r\n details: string\r\n}\r\n\r\nexport interface NetworkError extends ApplicationErrorBase {\r\n type: ApplicationErrorType.NetworkError\r\n}\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { WidgetShowCondition, WidgetTypes, WidgetOptions, WidgetFormField, WidgetListField, WidgetInfoField } from '@cxbox-ui/schema'\r\nimport { ComponentType } from 'react'\r\nexport type {\r\n WidgetOptions,\r\n WidgetShowCondition,\r\n LayoutRow,\r\n LayoutCol,\r\n WidgetOperations,\r\n TableOperations,\r\n WidgetTableHierarchy,\r\n WidgetFieldBase,\r\n WidgetListFieldBase,\r\n WidgetFormFieldBase,\r\n AllWidgetTypeFieldBase,\r\n NumberFieldMeta,\r\n DateFieldMeta,\r\n CheckboxFieldMeta,\r\n DateTimeFieldMeta,\r\n DateTimeWithSecondsFieldMeta,\r\n DictionaryFieldMeta,\r\n TextFieldMeta,\r\n InputFieldMeta,\r\n MultiFieldMeta,\r\n MultivalueFieldMeta,\r\n PickListFieldMeta,\r\n InlinePickListFieldMeta,\r\n FileUploadFieldMeta,\r\n WidgetFormField,\r\n WidgetListField,\r\n HiddenFieldMeta,\r\n RadioButtonFieldMeta,\r\n WidgetField,\r\n WidgetInfoField\r\n} from '@cxbox-ui/schema'\r\n\r\nexport { WidgetTypes, PositionTypes } from '@cxbox-ui/schema'\r\n/**\r\n * Different widget types that are considered `tables` in nature for purposes of applying some shared features.\r\n * For example, autofocus on missing required field should work for tables but not forms.\r\n *\r\n * TODO: Make extension point\r\n *\r\n * @category Components\r\n */\r\nexport const TableLikeWidgetTypes = [\r\n WidgetTypes.List,\r\n WidgetTypes.DataGrid,\r\n WidgetTypes.AssocListPopup,\r\n WidgetTypes.PickListPopup,\r\n WidgetTypes.FlatTree,\r\n WidgetTypes.FlatTreePopup\r\n] as const\r\n\r\n/**\r\n * Widgets that are considered `popups` and usually excluded from widgets layout grid\r\n */\r\nexport const PopupWidgetTypes: string[] = [WidgetTypes.PickListPopup, WidgetTypes.AssocListPopup, WidgetTypes.FlatTreePopup]\r\n\r\n/**\r\n * All widget types that display table-like data.ts\r\n */\r\ntype TableLikeWidgetType = (typeof TableLikeWidgetTypes)[number]\r\n\r\nexport interface WidgetInfoOptions {\r\n fieldBorderBottom?: boolean\r\n footer?: string\r\n}\r\n\r\nexport interface WidgetMeta {\r\n name: string\r\n type: WidgetTypes | string // TODO: Как учитывать типы клиентских виджетов кроме string?\r\n title: string // отображаемое название,\r\n bcName: string\r\n /**\r\n * Business components ancestors hierarchy\r\n *\r\n * TODO: Will be mandatory (but nullable) in 2.0.0\r\n *\r\n * It is declared in `WidgetDTO` of Cxbox API, can be null for widgets without\r\n * business component (headers, navigation tabs, etc.)\r\n */\r\n url?: string | null\r\n position: number\r\n limit?: number\r\n gridWidth: number // 1-24\r\n fields: unknown[]\r\n options?: WidgetOptions\r\n showCondition?: WidgetShowCondition\r\n description?: string // description for documentation\r\n}\r\n\r\n/**\r\n * Description of the list of fields of block type.\r\n *\r\n * @deprecated Used to create a block grouping of fields\r\n */\r\nexport interface WidgetFieldBlock<T> {\r\n /**\r\n * Block ID\r\n */\r\n blockId: number\r\n /**\r\n * Name of the block\r\n */\r\n name: string\r\n /**\r\n * Fields contained in the block\r\n */\r\n fields: T[]\r\n /**\r\n * @deprecated TODO: Remove in 2.0.0, used to denote a new row in old layout system for forms\r\n */\r\n newRow?: boolean\r\n /**\r\n * @deprecated TODO: Remove in 2.0.0, used to ...\r\n */\r\n break?: boolean\r\n}\r\n\r\nexport type WidgetFieldsOrBlocks<T> = Array<T | WidgetFieldBlock<T>>\r\n\r\n/**\r\n * Configuration for widgets dislaying form data.ts\r\n */\r\nexport interface WidgetFormMeta extends WidgetMeta {\r\n /**\r\n * Unambiguous marker for JSON file specifing widget type\r\n */\r\n type: WidgetTypes.Form\r\n /**\r\n * Descriptor for fields or block of fields on the form\r\n */\r\n fields: WidgetFieldsOrBlocks<WidgetFormField>\r\n}\r\n\r\n/**\r\n * Configuration for widgets displaying table-like data.ts\r\n */\r\nexport interface WidgetTableMeta extends WidgetMeta {\r\n /**\r\n * Unambiguous marker for JSON file specifing widget type\r\n */\r\n type: TableLikeWidgetType\r\n /**\r\n * Descriptor for table columns\r\n */\r\n fields: WidgetListField[]\r\n}\r\n\r\n/**\r\n * Configuration for widgets displaying read-only table data.ts\r\n */\r\nexport interface WidgetInfoMeta extends WidgetMeta {\r\n /**\r\n * Unambiguous marker for JSON file specifying widget type\r\n */\r\n type: WidgetTypes.Info\r\n /**\r\n * Descriptor for fields or block of fields on the form\r\n */\r\n fields: WidgetFieldsOrBlocks<WidgetInfoField>\r\n /**\r\n * Options for customizing widget\r\n */\r\n options?: WidgetOptions & WidgetInfoOptions\r\n}\r\n\r\n/**\r\n * Configuration for widgets displaying markdown text\r\n */\r\nexport interface WidgetTextMeta extends WidgetMeta {\r\n /**\r\n * Unambiguous marker for JSON file specifying widget type\r\n */\r\n type: WidgetTypes.Text\r\n /**\r\n * Text to display\r\n */\r\n description: string\r\n /**\r\n * Title text\r\n */\r\n descriptionTitle: string\r\n}\r\n\r\n/**\r\n * Options configuration for widgets displaying NavigationTabs\r\n */\r\nexport interface NavigationOptions extends WidgetOptions {\r\n /**\r\n * Level of menu\r\n */\r\n navigationLevel?: number\r\n}\r\n\r\n/**\r\n * Configuration for widgets displaying NavigationTabs\r\n */\r\nexport interface NavigationWidgetMeta extends WidgetMeta {\r\n /**\r\n * Unambiguous marker for JSON file specifying widget type\r\n */\r\n type: WidgetTypes.NavigationTabs | WidgetTypes.ViewNavigation\r\n /**\r\n * Options for customizing widget\r\n */\r\n options: NavigationOptions\r\n}\r\n\r\n/**\r\n * A widget configuration of any known type\r\n */\r\nexport type WidgetMetaAny = WidgetFormMeta | WidgetTableMeta | WidgetTextMeta | WidgetInfoMeta | NavigationWidgetMeta\r\n\r\n/**\r\n * Component of custom widget\r\n *\r\n * @deprecated TODO: Remove in 2.0.0\r\n */\r\nexport type CustomWidget = ComponentType<any>\r\n\r\n/**\r\n * Configuration of custom widget\r\n */\r\nexport interface CustomWidgetConfiguration {\r\n /**\r\n * Whether widget is popup\r\n */\r\n isPopup?: boolean\r\n /**\r\n * Component of custom widget\r\n */\r\n component: ComponentType<any>\r\n /**\r\n * Card of widget\r\n */\r\n card?: ComponentType<any> | null\r\n}\r\n\r\nexport type CustomWidgetDescriptor = CustomWidget | CustomWidgetConfiguration\r\n/**\r\n * Check if descriptor is just a widget, or it has additional data.ts\r\n */\r\nexport function isCustomWidget(descriptor: CustomWidgetDescriptor): descriptor is CustomWidget {\r\n return !!descriptor && !('component' in descriptor)\r\n}\r\n\r\n/**\r\n * Checks whether @param descriptor is an instance of `CustomWidgetConfiguration`\r\n *\r\n * @param descriptor custom widget descriptor\r\n */\r\nexport function isCustomWidgetConfiguration(descriptor: CustomWidgetDescriptor): descriptor is CustomWidgetConfiguration {\r\n return descriptor && 'component' in descriptor\r\n}\r\n\r\n/**\r\n * TODO\r\n *\r\n * @param item\r\n * @category Type Guards\r\n */\r\nexport function isWidgetFieldBlock(item: any): item is WidgetFieldBlock<any> {\r\n return !!item && 'blockId' in item\r\n}\r\n\r\n/**\r\n * Type of pagination, either page numbers or \"Load More\" button\r\n */\r\nexport enum PaginationMode {\r\n page = 'page',\r\n loadMore = 'loadMore'\r\n}\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { DrillDownType } from './router'\r\nimport { AppNotificationType } from './objectMap'\r\nimport { DataItem } from './data'\r\nimport { OperationTypeCrud, OperationType } from '@cxbox-ui/schema'\r\nimport { AnyAction } from '@reduxjs/toolkit'\r\nexport type { OperationType, OperationInclusionDescriptor } from '@cxbox-ui/schema'\r\n\r\nexport { OperationTypeCrud }\r\n\r\nexport const coreOperations = [\r\n OperationTypeCrud.create,\r\n OperationTypeCrud.save,\r\n OperationTypeCrud.delete,\r\n OperationTypeCrud.associate,\r\n OperationTypeCrud.cancelCreate,\r\n OperationTypeCrud.fileUpload\r\n]\r\n\r\n/**\r\n *\r\n * @param operation\r\n */\r\nexport function isOperationGroup(operation: Operation | OperationGroup): operation is OperationGroup {\r\n return Array.isArray((operation as OperationGroup).actions)\r\n}\r\n\r\n/**\r\n * User operation: CRUD or any custom business action.\r\n *\r\n * Received from record's row meta.\r\n */\r\nexport interface Operation {\r\n /**\r\n * Displayed name\r\n */\r\n text: string\r\n /**\r\n * String that uniquely identifies an operation on widget\r\n */\r\n type: OperationType\r\n /**\r\n * A hint to decide where to display an operation which is related to the record or the whole widget\r\n */\r\n scope: OperationScope\r\n /**\r\n * @deprecated TODO: Remove in 2.0.0, designation unknown\r\n */\r\n action?: string\r\n /**\r\n * An icon (https://ant.design/components/icon) to display on operation button,\r\n */\r\n icon?: string\r\n /**\r\n * @deprecated TODO: Remove in 2.0.0 in favor of client-side custom parameters\r\n */\r\n bcKey?: string\r\n /**\r\n * Omit text value of operation in favor of icon\r\n */\r\n showOnlyIcon?: boolean\r\n /**\r\n * An operation that should be fired before initiating this operation\r\n */\r\n preInvoke?: OperationPreInvoke\r\n /**\r\n * Validate the record for empty \"required\" fields before API call\r\n */\r\n autoSaveBefore?: boolean\r\n /**\r\n * ???\r\n */\r\n confirmOperation?: OperationPreInvoke\r\n /**\r\n * If custom operation needs to be processed as if it was a default crud operation,\r\n * this flag can be specified and will be used instead of real `type`\r\n */\r\n actionRole?: OperationType\r\n /**\r\n * Subtype for association popup, used for calling multiFileUploadPopup,\r\n * else has default behaviour of assoc popup\r\n */\r\n subtype?: 'bc' | 'multiFileUpload'\r\n}\r\n\r\n/**\r\n * Group of actions.\r\n *\r\n * It shows name of a group, drop down list of actions\r\n * and some actions which are shown in case list is covered.\r\n * Группа действий, показывает название группы и раскрываемые список ее действий,\r\n * а также несколько действий рядом с группой, которые видны не раскрывая список.\r\n */\r\nexport interface OperationGroup {\r\n /**\r\n * Unique identifier for the operation group\r\n */\r\n type?: string\r\n /**\r\n * Displayed name of a group\r\n */\r\n text: string\r\n /**\r\n * An icon (https://ant.design/components/icon) to display on operation button,\r\n */\r\n icon?: string\r\n /**\r\n * Omit text value of operation in favor of icon\r\n */\r\n showOnlyIcon?: boolean\r\n /**\r\n * List of group actions\r\n */\r\n actions: Operation[]\r\n /**\r\n * Number of showed actions in case list is covered\r\n */\r\n maxGroupVisualButtonsCount: number\r\n}\r\n\r\n/**\r\n * An action which fires before user's operation\r\n */\r\nexport interface OperationPreInvoke {\r\n /**\r\n * A type of operation (Pop-up message. Other types are not supported)\r\n */\r\n type: OperationPreInvokeType\r\n /**\r\n * A message shown to user before operation fires\r\n */\r\n message: string\r\n /**\r\n * The custom popup widget name\r\n */\r\n widget?: string\r\n}\r\n\r\n/**\r\n * A type of message shown to user before operation fires\r\n */\r\nexport enum OperationPreInvokeType {\r\n /**\r\n * Pop-up message contains \"Yes/No\" answers.\r\n * If user says \"Yes\" then operation fires\r\n */\r\n confirm = 'confirm',\r\n /**\r\n * Pop-up message contains some informational text with info icon\r\n */\r\n info = 'info',\r\n /**\r\n * Pop-up message contains some information about error with error icon\r\n * Перед операцией пользователя будет показано всплывающее сообщение\r\n * с иконкой ошибки и операция не будет выполнена (TODO: Будет или не будет? Проверить)\r\n */\r\n error = 'error'\r\n}\r\n\r\n/**\r\n * A type of action which fires after user's operation\r\n */\r\nexport enum OperationPostInvokeType {\r\n /**\r\n * BC's refresh. It leads to cursor dropping, data.ts refresh of current BC and its children\r\n */\r\n refreshBC = 'refreshBC',\r\n /**\r\n * File downloading by `fileId` which comes from answer to user's operation.\r\n * Вызов сохранения файла в браузере по пришедшему в ответе fileId\r\n */\r\n downloadFile = 'downloadFile',\r\n /**\r\n * File downloading by `url` which comes from answer to user's operation.\r\n * Вызов сохранения файла в браузере по пришедшему в ответе url\r\n */\r\n downloadFileByUrl = 'downloadFileByUrl',\r\n /**\r\n * Calling a browser transition to some record\r\n */\r\n drillDown = 'drillDown',\r\n /**\r\n * `Pick list` widget opening\r\n */\r\n openPickList = 'openPickList',\r\n /**\r\n * @deprecated TODO: Не работает, удалить все упоминания из Досье и убрать всех свидетелей\r\n *\r\n */\r\n // delayedRefreshBC = 'delayedRefreshBC',\r\n /**\r\n * Showing pop-up message\r\n */\r\n showMessage = 'showMessage',\r\n /**\r\n * Инициировать удаление записей\r\n *\r\n * @deprecated TODO: Remove in 2.0.0\r\n */\r\n postDelete = 'postDelete',\r\n\r\n waitUntil = 'waitUntil',\r\n\r\n drillDownAndWaitUntil = 'drillDownAndWaitUntil'\r\n}\r\n\r\n/**\r\n * The type of message that will be shown to the user for confirmation\r\n */\r\nexport enum OperationPostInvokeConfirmType {\r\n /**\r\n * Simple confirmation\r\n */\r\n confirm = 'confirm',\r\n /**\r\n * Сonfirmation with text from the user\r\n */\r\n confirmText = 'confirmText'\r\n}\r\n\r\n/**\r\n * The action that will be performed after the user confirms it\r\n */\r\nexport interface OperationPostInvokeConfirm {\r\n /**\r\n * Type of postInvokeConfirm action\r\n */\r\n type: OperationPostInvokeConfirmType | string\r\n /**\r\n * Body text of a modal actually\r\n * TODO 2.0.0 rename correctly\r\n */\r\n message: string\r\n /**\r\n * Custom modal title actually\r\n * TODO 2.0.0 rename correctly\r\n */\r\n messageContent?: string\r\n /**\r\n * Custom label of OK button\r\n */\r\n okText?: string\r\n /**\r\n * Custom label of Cancel button\r\n */\r\n cancelText?: string\r\n}\r\n\r\n/**\r\n * Modal window operation types\r\n */\r\nexport interface OperationModalInvokeConfirm extends OperationPostInvokeConfirm {\r\n /**\r\n * Type of confirm action\r\n */\r\n type: OperationPostInvokeConfirmType | OperationPreInvokeType | string\r\n}\r\n\r\n/**\r\n * An action which fires after user's operation\r\n *\r\n * @param bc Имя бизнес-компоненты, которую надо обновлять при refreshBC\r\n * @param fileId Идентификатор файла, который надо скачать при downloadFile\r\n * @param url?\r\n *\r\n * @param [key: string] ??? TODO: Это что?\r\n */\r\nexport interface OperationPostInvoke {\r\n /**\r\n * A type of action\r\n */\r\n type: OperationPostInvokeType | string\r\n}\r\n\r\n/**\r\n * BC's refresh. It leads to cursor dropping, data.ts refresh of current BC and its children\r\n */\r\nexport interface OperationPostInvokeRefreshBc extends OperationPostInvoke {\r\n /**\r\n * BC's name\r\n */\r\n bc: string\r\n}\r\n\r\n/**\r\n * File downloading by `fileId` which comes from answer.\r\n */\r\nexport interface OperationPostInvokeDownloadFile extends OperationPostInvoke {\r\n /**\r\n * Backend's file ID\r\n */\r\n fileId: string\r\n}\r\n\r\n/**\r\n * File downloading by `url` which comes from answer.\r\n */\r\nexport interface OperationPostInvokeDownloadFileByUrl extends OperationPostInvoke {\r\n /**\r\n * File's URL\r\n */\r\n url: string\r\n}\r\n\r\n/**\r\n * Calling a browser transition to some record\r\n *\r\n * @param urlName При выполнении перехода на внешнюю сущность (POST-запрос на пришедший url),\r\n * этот адрес будет передан в теле запроса (см. CBR-9320 МР и тикет)\r\n */\r\nexport interface OperationPostInvokeDrillDown extends OperationPostInvoke {\r\n /**\r\n * URL of transition\r\n */\r\n url: string\r\n /**\r\n * A type of transition\r\n */\r\n drillDownType?: DrillDownType\r\n /**\r\n * If transition performs to outer entity (POST call),\r\n * this param will be passed to request body\r\n */\r\n urlName?: string\r\n}\r\n\r\n/**\r\n * `Pick list` widget opening\r\n */\r\nexport interface OperationPostInvokeOpenPickList extends OperationPostInvoke {\r\n /**\r\n * BC name of pick list widget\r\n */\r\n pickList: string\r\n}\r\n\r\n/**\r\n * Pop-up message showing\r\n */\r\nexport interface OperationPostInvokeShowMessage extends OperationPostInvoke {\r\n /**\r\n * A type of a message\r\n */\r\n messageType: AppNotificationType\r\n /**\r\n * A text of a message\r\n */\r\n messageText: string\r\n}\r\n\r\nexport interface OperationPostInvokeWaitUntil extends OperationPostInvoke {\r\n inProgressMessage?: string\r\n successCondition_bcName: string\r\n successCondition_fieldKey: string\r\n successCondition_value: unknown\r\n successMessage?: string\r\n timeout?: number | string\r\n timeoutMaxRequests?: number | string\r\n timeoutMessage?: string\r\n}\r\n\r\nexport interface OperationPostInvokeDrilldownAndWaitUntil extends OperationPostInvokeDrillDown, OperationPostInvokeWaitUntil {}\r\n\r\n/**\r\n * A union of all action types which could be be fired after user's operation\r\n */\r\nexport type OperationPostInvokeAny =\r\n | OperationPostInvokeRefreshBc\r\n | OperationPostInvokeDownloadFile\r\n | OperationPostInvokeDownloadFileByUrl\r\n | OperationPostInvokeDrillDown\r\n | OperationPostInvokeOpenPickList\r\n | OperationPostInvokeShowMessage\r\n | OperationPostInvokeConfirm\r\n | OperationPostInvokeWaitUntil\r\n | OperationPostInvokeDrilldownAndWaitUntil\r\n\r\n/**\r\n * TODO: ???\r\n */\r\nexport type OperationScope = 'bc' | 'record' | 'page' | 'associate' | 'mass'\r\n\r\nexport interface AssociatedItem extends DataItem {\r\n _associate: boolean\r\n}\r\n\r\nexport interface OperationError {\r\n success: false\r\n error: {\r\n entity?: OperationErrorEntity\r\n popup?: string[]\r\n postActions?: OperationPostInvokeAny[]\r\n }\r\n}\r\n\r\nexport interface OperationErrorEntity {\r\n bcName: string\r\n fields: Record<string, string>\r\n id: string\r\n}\r\n\r\nexport type RequestType = 'data' | 'row-meta' | 'force-active'\r\n\r\nexport interface ISendOperation {\r\n /**\r\n * The business component to fetch data for\r\n */\r\n bcName: string\r\n /**\r\n * Type of operation to be performed\r\n */\r\n operationType: OperationTypeCrud | string\r\n /**\r\n * What widget requires data\r\n */\r\n widgetName: string\r\n /**\r\n * Any other action\r\n */\r\n onSuccessAction?: AnyAction\r\n /**\r\n * params for confirm modal\r\n */\r\n confirm?: string\r\n /**\r\n * key called bk\r\n *\r\n * @deprecated TODO: Remove in 2.0.0\r\n */\r\n bcKey?: string\r\n /**\r\n * @deprecated TODO: Remove in 2.0.0 in favor of sendOperationWithConfirm\r\n */\r\n confirmOperation?: OperationPreInvoke\r\n}\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { DataValue } from './data'\r\n\r\nexport enum FilterType {\r\n /**\r\n * Transforms into combination of 'greaterOrEqualThan' and 'lessOrEqualThan' (See src/utils/filters.ts)\r\n */\r\n range = 'range',\r\n equals = 'equals',\r\n greaterThan = 'greaterThan',\r\n lessThan = 'lessThan',\r\n greaterOrEqualThan = 'greaterOrEqualThan',\r\n lessOrEqualThan = 'lessOrEqualThan',\r\n contains = 'contains',\r\n specified = 'specified',\r\n specifiedBooleanSql = 'specifiedBooleanSql',\r\n equalsOneOf = 'equalsOneOf',\r\n containsOneOf = 'containsOneOf'\r\n}\r\n\r\nexport interface BcFilter {\r\n type: FilterType | string\r\n fieldName: string\r\n value: DataValue | DataValue[]\r\n viewName?: string\r\n widgetName?: string\r\n}\r\n\r\nexport interface BcSorter {\r\n fieldName: string\r\n direction: 'asc' | 'desc'\r\n}\r\n\r\nexport interface FilterGroup {\r\n name: string\r\n filters: string\r\n}\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { ViewNavigationGroup, MenuItem, ViewNavigationCategory, ViewNavigationItem } from '@cxbox-ui/schema'\r\nexport type { ViewNavigationGroup, MenuItem, ViewNavigationCategory, ViewNavigationItem } from '@cxbox-ui/schema'\r\n/**\r\n * Returns MenuItem if it is ViewNavigationItem\r\n *\r\n * @param item to be identified as view\r\n * @category Type Guards\r\n */\r\nexport function isViewNavigationItem(item: MenuItem): item is ViewNavigationItem {\r\n return !!item && 'viewName' in item\r\n}\r\n\r\n/**\r\n * @param item\r\n * @deprecated ViewNavigationCategory will be deleted in 2.0.0\r\n * @category Type Guards\r\n */\r\nexport function isViewNavigationCategory(item: any): item is ViewNavigationCategory {\r\n return !!item && 'categoryName' in item\r\n}\r\n\r\n/**\r\n * Returns MenuItem if it is ViewNavigationGroup\r\n *\r\n * @param item to be identified as group\r\n * @category Type Guards\r\n */\r\nexport function isViewNavigationGroup(item: MenuItem): item is ViewNavigationGroup {\r\n // TODO: remove 'categoryName' check in 2.0.0\r\n return !!item && 'child' in item && !('categoryName' in item)\r\n}\r\n\r\n/**\r\n * 1 - for static, top level navigation\r\n * 2 - `SecondLevelMenu` tab widgets\r\n * 2 - `ThirdLevelMenu` tab widgets\r\n * 2 - `FourthLevelMenu` tab widgets\r\n */\r\nexport type NavigationLevel = 1 | 2 | 3 | 4\r\n\r\n/**\r\n * Model for displayed tab item\r\n */\r\nexport interface NavigationTab {\r\n /**\r\n * View name where navigation tab will redirect the user\r\n */\r\n viewName: string\r\n /**\r\n * Displayed title: either view name or a group name\r\n */\r\n title?: string\r\n /**\r\n * When true, menu item will not be visible\r\n *\r\n * It's still will be accessible through direct link though\r\n */\r\n hidden?: boolean\r\n}\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { Route, RouteType } from '../interfaces'\r\nimport { changeLocation } from '../actions'\r\nimport { ReducerBuilderManager } from './ReducerBuilderManager'\r\n\r\nexport const initialRouterState: Route = { type: RouteType.default, path: '/', search: '', params: null, screenName: null }\r\n\r\n/**\r\n * Router reducer\r\n *\r\n * Stores information about currently active route\r\n */\r\nexport const createRouterReducerBuilderManager = <S extends Route>(initialState: S) =>\r\n new ReducerBuilderManager<S>().addCase(changeLocation, (state, action) => {\r\n const { isTab, location } = action.payload\r\n // bcPath can be considered a filter for bc. This filter should not be reset when switching tabs.\r\n return (isTab ? { ...location, bcPath: location.bcPath || state.bcPath } : location) as S\r\n })\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nexport interface ApiCallContext {\r\n widgetName: string\r\n}\r\n\r\ntype QueryParamsMap = Record<string, string | number>\r\n\r\n/**\r\n * Removes empty values from query parameters dictionary\r\n *\r\n * @param qso Query parameters dictionary\r\n */\r\nfunction dropEmptyOrWrongParams(qso: QueryParamsMap) {\r\n const result: QueryParamsMap = { ...qso }\r\n\r\n return Object.keys(result).reduce((prev, paramKey) => {\r\n if (!prev[paramKey] && typeof prev[paramKey] !== 'number') {\r\n delete prev[paramKey]\r\n }\r\n return prev\r\n }, result)\r\n}\r\n\r\n/**\r\n * Extends url with query parameters control symbol (`?` or `&`)\r\n *\r\n * @param url Url with or without `?` symbol\r\n */\r\nexport function addTailControlSequences(url: string) {\r\n return !url.includes('?') ? url + '?' : url + '&'\r\n}\r\n\r\n/**\r\n * Extends url with query parameters\r\n *\r\n * @param url Url to extend\r\n * @param qso Query parameters dictionary\r\n */\r\nexport function applyParams(url: string, qso?: QueryParamsMap) {\r\n if (!qso) {\r\n return url\r\n }\r\n return applyRawParams(url, dropEmptyOrWrongParams(qso))\r\n}\r\n\r\n/**\r\n * TODO\r\n *\r\n * @param url\r\n * @param qso\r\n */\r\nexport function applyRawParams(url: string, qso: Record<string, any>) {\r\n if (!qso) {\r\n return url\r\n }\r\n const result = new URLSearchParams(qso).toString()\r\n return `${addTailControlSequences(url)}${result && `${result}`}`\r\n}\r\n","import { AxiosError } from 'axios'\r\nimport { apiError } from '../actions'\r\nimport { EMPTY, of } from 'rxjs'\r\n\r\ninterface ApiCallContext {\r\n widgetName: string\r\n}\r\n\r\nexport function createApiError(error: AxiosError, context: ApiCallContext = { widgetName: 'unknown' }) {\r\n if (!error.isAxiosError) return undefined\r\n\r\n return apiError({ error, callContext: context })\r\n}\r\n\r\nexport function createApiErrorObservable(error: AxiosError, context?: ApiCallContext) {\r\n const newApiError = createApiError(error, context)\r\n return newApiError ? of(newApiError) : EMPTY\r\n}\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { Store } from '../interfaces/store'\r\nimport { DataItem } from '../interfaces/data'\r\n\r\n/**\r\n * TODO\r\n *\r\n * @param literals\r\n * @param placeholders\r\n */\r\nexport function getTemplate(literals: TemplateStringsArray, ...placeholders: any[]) {\r\n let result = ''\r\n for (let i = 0; i < placeholders.length; i++) {\r\n result += literals[i]\r\n result += '${' + i + '}'\r\n }\r\n result += literals[literals.length - 1]\r\n return result\r\n}\r\n\r\n/**\r\n * Forms a string representation of business components hierarchy with\r\n * respect to business components ancestors and their corresponding cursors\r\n *\r\n * @param bcName Business component name\r\n * @param includeSelf If result hierarchy should include target bc or only ancestors\r\n * @param state\r\n * @category Utils\r\n */\r\nexport function buildBcUrl(bcName: string, includeSelf = false, state: Store) {\r\n const bcMap = state.screen.bo.bc\r\n const bc = bcMap[bcName]\r\n if (!bc) {\r\n return null\r\n }\r\n const url = [bc.cursor && includeSelf ? `${bc.name}/${bc.cursor}` : bc.name]\r\n let nextBc = bc\r\n while (nextBc.parentName) {\r\n nextBc = bcMap[nextBc.parentName]\r\n url.push(`${nextBc.name}/${nextBc.cursor ?? null}`)\r\n }\r\n const bcUrl = url.reverse().join('/')\r\n return bcUrl\r\n}\r\n\r\nexport function splitBcUrl(bcUrl: string) {\r\n const bcUrlItems = bcUrl.split('/')\r\n const result = []\r\n\r\n for (let i = 0; i < bcUrlItems.length; i += 2) {\r\n const bcName = bcUrlItems[i]\r\n const bcCursor = bcUrlItems[i + 1]\r\n const includeSelf = bcName && bcCursor\r\n\r\n result.push(includeSelf ? `${bcName}/${bcCursor}` : bcName)\r\n }\r\n\r\n return result\r\n}\r\n\r\n// Token format: '${fieldName:defaultValue}'\r\nconst TAG_PLACEHOLDER = /\\${([^{}]+)}/g\r\n\r\n/**\r\n * Replaces tokens in a template string with object field values.\r\n * If the value is like a date, then convert it to the format 'DD.MM.YYYY'\r\n *\r\n * Example:\r\n * const item = { color1: 'Green', color2: 'Blue' }\r\n * const templatedString = 'Color is ${color1} ${color2:Purple} ${color3:Purple}'\r\n * format(templateString, item) // => 'Green Blue Purple'\r\n *\r\n * @param templatedString Patterned string\r\n * @param item An object in the fields of which tokens should be searched\r\n */\r\nconst formatString = (templatedString: string, item: DataItem): string => {\r\n if (!templatedString) {\r\n return ''\r\n }\r\n return templatedString.replace(TAG_PLACEHOLDER, (token, varName) => {\r\n const [key, defaultValue] = varName.split(':')\r\n const result = String(item?.[key] || defaultValue || '')\r\n // const date = moment(result, moment.ISO_8601)\r\n // return !date.isValid() ? result : date.format('DD.MM.YYYY')\r\n return result\r\n })\r\n}\r\n\r\nconst isTemplate = (templatedString: string): boolean => {\r\n if (!templatedString) {\r\n return false\r\n }\r\n return templatedString.match(TAG_PLACEHOLDER) !== null\r\n}\r\n\r\n/**\r\n * If there is a template in the field name then returns the formatted string\r\n *\r\n * @param title Field name\r\n * @param dataItem An object in the fields of which tokens should be searched\r\n */\r\nexport function getFieldTitle(title: string, dataItem?: DataItem) {\r\n if (!isTemplate(title)) {\r\n return title\r\n } else {\r\n return formatString(title, dataItem)\r\n }\r\n}\r\n\r\n/**\r\n * If there is a template in the field name then returns array of string\r\n *\r\n * Example:\r\n * splitIntoTokens(`The quick brown fox jumps over the lazy dog. If the dog reacted, was it realdogly lazy?`, 'dog')\r\n * [\"The quick brown fox jumps over the lazy \", \"dog\", \". If the \", \"dog\", \" reacted, was it real\", \"dog\", \"ly lazy?\"]\r\n *\r\n * @param source Field name\r\n * @param search An object in the fields of which tokens should be searched\r\n */\r\nexport function splitIntoTokens(source: string, search: string | RegExp) {\r\n const tokenizer = search instanceof RegExp ? search : escapedSrc(search)\r\n return source.split(tokenizer)\r\n}\r\n\r\n/**\r\n * Convert string to RegExp\r\n *\r\n * @param str Source string\r\n */\r\nexport function escapedSrc(str: string) {\r\n return new RegExp(`(${str?.replace(/[\\-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, '\\\\$&')})`, 'gi')\r\n}\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\n/**\r\n * Utilities for urls and browser history\r\n */\r\nimport { Route, RouteType } from '../interfaces'\r\nimport { getTemplate } from './strings'\r\n\r\n/**\r\n * Appends '/' in front of `absoluteUrl` argument.\r\n * If `absoluteUrl` alredy starts with `/` then argument returned without changes.\r\n *\r\n * @param absoluteUrl Url\r\n */\r\nexport function makeRelativeUrl(absoluteUrl: string) {\r\n return absoluteUrl.startsWith('/') ? absoluteUrl : `/${absoluteUrl}`\r\n}\r\n\r\n/**\r\n * Parses a business component hierarchy url into a dictionary of business components\r\n * and their cursors.\r\n *\r\n * @param bcPath Business component hierarchy url, e.g. `bcName1/cursor1/bcName2/cursor2`\r\n * @category Utils\r\n */\r\nexport function parseBcCursors(bcPath: string) {\r\n if (!bcPath) {\r\n return null\r\n }\r\n const cursors: Record<string, string> = {}\r\n const tokens = bcPath.split('/')\r\n for (let i = 0; i < tokens.length; i = i + 2) {\r\n if (tokens[i + 1]) {\r\n cursors[tokens[i]] = tokens[i + 1]\r\n }\r\n }\r\n return cursors\r\n}\r\n\r\n/**\r\n * TODO\r\n *\r\n * @param literals\r\n * @param placeholders\r\n * @category Utils\r\n */\r\nexport function buildUrl(literals: TemplateStringsArray, ...placeholders: Array<string | number>) {\r\n let result = ''\r\n\r\n for (let i = 0; i < placeholders.length; i++) {\r\n result += literals[i]\r\n const placeholder = placeholders[i]\r\n\r\n if (typeof placeholder === 'number') {\r\n result += placeholder.toString(10)\r\n } else if (typeof placeholder === 'string') {\r\n result += encodeURIComponent(placeholder)\r\n } else {\r\n const template = getTemplate(literals, placeholders)\r\n throw new Error(`Неверный тип подстановочного знака в ${template}, index: ${i}, value: ${JSON.stringify(placeholder)}`)\r\n }\r\n }\r\n\r\n result += literals[literals.length - 1]\r\n return result\r\n}\r\n\r\n/**\r\n * Default implementation for utility to parse `history`-compatible location to {@link Route | Cxbox UI route}.\r\n *\r\n * Supports three types of URLs:\r\n * - {@link RouteType.screen | RouteType.screen}, i.e. an url referencing some UI entity that can be parsed to Route directly. Example: `/screen/name/view/name/`;\r\n * - {@link RouteType.router | RouteType.router}, i.e. an url without information about entity that should be handled on server side. Example: `/router/server-entity`\r\n * - {@link RouteType.default | RouteType.default}, i.e. an url that leads to default entity of the application. Example: `/`\r\n *\r\n * Reverse function is {@link defaultBuildURL}.\r\n *\r\n * @category Utils\r\n */\r\nexport function defaultParseURL(url: URL): Route {\r\n let path: string = url.pathname\r\n\r\n if (path.startsWith('/')) {\r\n path = path.substring(1)\r\n }\r\n if (path.endsWith('/')) {\r\n path = path.substring(0, path.length - 1)\r\n }\r\n if (path?.includes('&') && !path?.includes('?')) {\r\n path = path.substring(0, path.indexOf('&'))\r\n }\r\n const params: Record<string, unknown> = {}\r\n url.searchParams.forEach((value, key) => (params[key] = value))\r\n const tokens = path.split('/').map(decodeURIComponent)\r\n\r\n let type = RouteType.unknown\r\n let screenName = null\r\n let viewName = null\r\n let bcPath = null\r\n\r\n if (tokens.length > 0 && tokens[0] === 'router') {\r\n type = RouteType.router\r\n } else if (tokens.length === 1) {\r\n type = RouteType.default\r\n } else if (tokens.length >= 2 && tokens[0] === 'screen') {\r\n let bcIndex = 2\r\n type = RouteType.screen\r\n screenName = tokens[1]\r\n if (tokens.length >= 4 && tokens[2] === 'view') {\r\n bcIndex += 2\r\n viewName = tokens[3]\r\n }\r\n bcPath = tokens.slice(bcIndex).map(encodeURIComponent).join('/')\r\n }\r\n\r\n return {\r\n type: type,\r\n path: path.length !== 0 && !path.startsWith('/') ? `/${path}` : path,\r\n search: url.search,\r\n params,\r\n screenName,\r\n viewName,\r\n bcPath\r\n }\r\n}\r\n\r\n/**\r\n * Transform {@link Route | Cxbox UI route} to string url.\r\n *\r\n * Reverse function is {@link defaultParseURL}.\r\n *\r\n * @param route Cxbox UI route\r\n * @category Utils\r\n */\r\nexport function defaultBuildURL(route: Route) {\r\n return `/screen/${route.screenName}/view/${route.viewName}/${route.bcPath}`\r\n}\r\n\r\nexport const getRouteFromString = (ulrString: string) => {\r\n const url = new URL(ulrString, window.location.origin)\r\n\r\n return defaultParseURL(url)\r\n}\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { BcFilter, BcSorter, FilterType, DataValue, FieldType } from '../interfaces'\r\n\r\n/**\r\n * Maps an input array of BcFilter objects into a dictionary of GET-request params\r\n *\r\n * Name of the param formed as field name and filter type, separated by dot,\r\n * e.g. `${filter.fieldName}.${filter.type}`\r\n *\r\n * Value of the param is:\r\n * - for non-array values, stringified filter value\r\n * - for array values, a comma-separated list of stringified elements with each element enclosed in double quotes\r\n *\r\n * @see {@link parseFilters} Reverse function\r\n *\r\n * @param filters Filters for business components\r\n * @returns Dictionary of query-params for GET-request\r\n * @category Utils\r\n */\r\nexport function getFilters(filters: BcFilter[]) {\r\n if (!filters || !filters.length) {\r\n return null\r\n }\r\n const result: Record<string, string> = {}\r\n filters.forEach(item => {\r\n if (item.type === FilterType.range) {\r\n const values = item.value as DataValue[]\r\n if (values[0]) {\r\n result[`${item.fieldName}.${FilterType.greaterOrEqualThan}`] = String(values[0])\r\n }\r\n if (values[1]) {\r\n result[`${item.fieldName}.${FilterType.lessOrEqualThan}`] = String(values[1])\r\n }\r\n } else {\r\n const value = Array.isArray(item.value) ? JSON.stringify(item.value) : String(item.value)\r\n const separator = item.fieldName ? '.' : ''\r\n result[`${item.fieldName}${separator}${item.type}`] = value\r\n }\r\n })\r\n return result\r\n}\r\n\r\n/**\r\n * Maps an input array of business component sorters into a dictionary of query params for\r\n * Cxbox API, where values are field names and keys follows the template:\r\n * `_sort.${index}.${item.direction}`\r\n *\r\n * @param sorters Array of business component sorters\r\n * @returns Dictionary of query-params for GET-request\r\n * @category Utils\r\n */\r\nexport function getSorters(sorters: BcSorter[]) {\r\n if (!sorters || !sorters.length) {\r\n return null\r\n }\r\n const result: Record<string, string> = {}\r\n sorters.forEach((item, index) => {\r\n result[`_sort.${index}.${item.direction}`] = item.fieldName\r\n })\r\n return result\r\n}\r\n\r\nconst jsonParse = <T extends string>(value: T) => {\r\n try {\r\n return JSON.parse(value)\r\n } catch (e) {\r\n console.warn(e)\r\n\r\n return null\r\n }\r\n}\r\n\r\n/**\r\n * Function for parsing filters from string into BcFilter type\r\n *\r\n * @see {@link getFilters} Reverse function\r\n * @param defaultFilters string representation of filters\r\n * @category Utils\r\n */\r\nexport function parseFilters(defaultFilters: string = '') {\r\n const result: BcFilter[] = []\r\n const urlParams = new URLSearchParams(defaultFilters)\r\n const paramKeys = Object.keys(Object.fromEntries(urlParams))\r\n\r\n paramKeys.forEach(param => {\r\n const [fieldName, type] = param.split('.')\r\n const isStandardFilter = fieldName && type && urlParams.get(param)\r\n\r\n if (isStandardFilter) {\r\n let value: string | string[] = urlParams.getAll(param)\r\n\r\n if (type === FilterType.containsOneOf || type === FilterType.equalsOneOf) {\r\n if (value.length === 1) {\r\n value = jsonParse(value[0]) ?? value\r\n }\r\n\r\n value = Array.isArray(value) ? value : []\r\n } else {\r\n value = Array.isArray(value) ? value[0] : value\r\n }\r\n\r\n result.push({\r\n fieldName,\r\n type: type as FilterType,\r\n value\r\n })\r\n } else if (defaultFilters) {\r\n let value: string | string[] = urlParams.getAll(param)\r\n\r\n if (value.length === 1) {\r\n value = jsonParse(value[0]) ?? value[0]\r\n }\r\n\r\n result.push({\r\n fieldName: '',\r\n type: param as any,\r\n value: value\r\n })\r\n }\r\n })\r\n\r\n return result.length ? result : null\r\n}\r\n\r\n/**\r\n * Parse sorter string into separate sorter objects.\r\n * String representation of sorters is url based:\r\n * \"_sort.{order}.{direction}={fieldKey}&_sort.{order}.{direction}\"\r\n *\r\n * fieldKey Sort by field\r\n * order Priority of this specfic sorter\r\n * direction \"asc\" or \"desc\"\r\n *\r\n * i.e. \"_sort.0.asc=firstName\"\r\n *\r\n * @param sorters string representation of sorters\r\n * @category Utils\r\n */\r\nexport function parseSorters(sorters?: string) {\r\n if (!sorters || !sorters.length) {\r\n return null\r\n }\r\n const result: BcSorter[] = []\r\n const dictionary = new URLSearchParams(sorters)\r\n Array.from(dictionary.entries())\r\n .map(([sort, fieldKey]) => {\r\n const [order, direction] = sort.split('.').slice(1)\r\n return { fieldName: fieldKey as string, order: Number.parseInt(order, 10), direction }\r\n })\r\n .sort((a, b) => a.order - b.order)\r\n .forEach(item => {\r\n result.push({ fieldName: item.fieldName, direction: item.direction as 'asc' | 'desc' })\r\n })\r\n return result\r\n}\r\n\r\n/**\r\n * Returns appropriate filtration type for specified field type.\r\n *\r\n * - Text-based fields use `contains`\r\n * - Checkbox fields use `specified` (boolean)\r\n * - Dictionary fiels use `equalsOneOf`\r\n *\r\n * All other field types use strict `equals`\r\n *\r\n * @param fieldType Field type\r\n */\r\nexport function getFilterType(fieldType: FieldType) {\r\n switch (fieldType) {\r\n case FieldType.dictionary: {\r\n return FilterType.equalsOneOf\r\n }\r\n case FieldType.checkbox: {\r\n return FilterType.specified\r\n }\r\n case FieldType.input:\r\n case FieldType.text: {\r\n return FilterType.contains\r\n }\r\n default:\r\n return FilterType.equals\r\n }\r\n}\r\n\r\n/**\r\n * Function for converting filters from 'moreOrEqualThan' and 'lessOrEqualThan' types to a 'range' type\r\n *\r\n * @param filters array of BcFilter objects\r\n * @category Utils\r\n */\r\nexport const processDrilldownFilters = (filters: BcFilter[]) => {\r\n const result: BcFilter[] = []\r\n const rangeFilters: Record<string, BcFilter> = {}\r\n\r\n filters.forEach(filterItem => {\r\n const { type, fieldName, value } = filterItem\r\n\r\n if (type === FilterType.greaterOrEqualThan || type === FilterType.lessOrEqualThan) {\r\n if (!rangeFilters[fieldName]) {\r\n rangeFilters[fieldName] = { ...filterItem, type: FilterType.range, value: [null, null] }\r\n }\r\n const rangeFilterValue = rangeFilters[fieldName].value as DataValue[]\r\n rangeFilterValue[type === FilterType.greaterOrEqualThan ? 0 : 1] = value as DataValue\r\n } else {\r\n result.push(filterItem)\r\n }\r\n })\r\n\r\n return [...result, ...Object.values(rangeFilters)]\r\n}\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { Operation, isOperationGroup, OperationGroup, OperationTypeCrud, coreOperations } from '../interfaces/operation'\r\nimport { buildBcUrl } from './strings'\r\nimport { Store } from '../interfaces/store'\r\nimport { sendOperation } from '../actions'\r\n\r\n/**\r\n * Extract operations from all operations groups and return them as an array of flat operations\r\n *\r\n * @param operations Operations or operation groups as received from row meta\r\n * @category Utils\r\n */\r\nexport function flattenOperations(operations: Array<Operation | OperationGroup>) {\r\n const result: Operation[] = []\r\n operations?.forEach(item => {\r\n if (isOperationGroup(item)) {\r\n const currentOperation = item\r\n currentOperation.actions.forEach(OperationItem => {\r\n result.push(OperationItem)\r\n })\r\n } else {\r\n result.push(item)\r\n }\r\n })\r\n return result\r\n}\r\n\r\n/**\r\n * Check if an operation matches a specified `role` directly by type or by `actionRole` field.\r\n *\r\n * If operation role is unavailable due to the store lacking an appropriate row meta, only `role` is checked.\r\n *\r\n * @param role Expected operation role or 'none' if operation shouldn't match any crud role\r\n * @param payload sendOperation action payload\r\n * @param store Store instance\r\n * @category Utils\r\n */\r\nexport function matchOperationRole(\r\n role: OperationTypeCrud | 'none' | string,\r\n payload: ReturnType<typeof sendOperation>['payload'],\r\n store: Store\r\n) {\r\n if (payload.operationType === role) {\r\n return true\r\n }\r\n const bcUrl = buildBcUrl(payload.bcName, true, store)\r\n const operations = flattenOperations(store.view.rowMeta[payload.bcName]?.[bcUrl]?.actions)\r\n const operation = operations.find(item => item.type === payload.operationType)\r\n if (role === 'none') {\r\n return coreOperations.every(item => item !== payload.operationType && item !== operation?.actionRole)\r\n }\r\n return operation?.actionRole === role\r\n}\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { WidgetMeta, WidgetShowCondition } from '../interfaces/widget'\r\nimport { BcMetaState } from '../interfaces/bc'\r\nimport { DataItem, PendingDataItem } from '../interfaces/data'\r\n\r\n/**\r\n * Find all widgets referencing or descendant from specified origin BC\r\n *\r\n * @param originBcName Origin business component name\r\n * @param widgets Widgets to search through\r\n * @param bcMap Business components dictionary\r\n * @returns A dictionary of business components and widgets\r\n */\r\nexport function getBcChildren(originBcName: string, widgets: WidgetMeta[], bcMap: Record<string, BcMetaState>) {\r\n // Build a dictionary with children for requested BC and widgets that need this BC\r\n const childrenBcMap: Record<string, string[]> = {}\r\n widgets\r\n .filter(widget => widget.bcName)\r\n .forEach(widget => {\r\n const widgetBcList: string[] = []\r\n // Find all BC ancestors for widget\r\n widgetBcList.push(widget.bcName)\r\n let parentName = bcMap[widget.bcName].parentName\r\n while (parentName) {\r\n widgetBcList.push(parentName)\r\n parentName = bcMap[parentName].parentName\r\n }\r\n // Put all widgets referencing this BC ancestors in dictionary\r\n widgetBcList\r\n .filter(expectedBcName => bcMap[expectedBcName].parentName === originBcName)\r\n .forEach(expectedBcName => {\r\n childrenBcMap[expectedBcName] = [...(childrenBcMap[expectedBcName] || []), widget.name]\r\n })\r\n })\r\n // If widget supports hierarchy, try to find origin BC in hierarchy options\r\n widgets\r\n .filter(item => item.options?.hierarchy)\r\n .forEach(widget => {\r\n const [hierarchyBcName, hierarchyWidgetName] = getHierarchyChildBc(originBcName, widget)\r\n if (hierarchyBcName) {\r\n childrenBcMap[hierarchyBcName] = [...(childrenBcMap[hierarchyBcName] || []), hierarchyWidgetName as string]\r\n }\r\n })\r\n\r\n return childrenBcMap\r\n}\r\n\r\nexport const isEagerWidget = (widget: WidgetMeta, lazyWidgetNames: string[], showConditionCheck?: (widget: WidgetMeta) => boolean) => {\r\n const isNotLazy = !lazyWidgetNames.includes(widget.name)\r\n const isVisible = showConditionCheck?.(widget) ?? true\r\n\r\n return isNotLazy && isVisible\r\n}\r\n\r\nexport function getEagerBcChildren(\r\n originBcName: string,\r\n widgets: WidgetMeta[],\r\n bcMap: Record<string, BcMetaState>,\r\n lazyWidgetNames: string[],\r\n showConditionCheck?: (widget: WidgetMeta) => boolean\r\n) {\r\n const childrenBcMap = getBcChildren(originBcName, widgets, bcMap)\r\n const result: Record<string, string[]> = {}\r\n\r\n for (const [childBcName, widgetNames] of Object.entries(childrenBcMap)) {\r\n const nonLazyWidget = widgets.find(item => {\r\n return widgetNames.includes(item.name) && isEagerWidget(item, lazyWidgetNames, showConditionCheck)\r\n })\r\n\r\n if (nonLazyWidget) {\r\n result[childBcName] = widgetNames\r\n }\r\n }\r\n\r\n return result\r\n}\r\n\r\n/**\r\n * Find child bc for hierarchy widget\r\n *\r\n * @param originBcName Origin business component name\r\n * @param hierarchyWidget Hierarchy widget\r\n */\r\nfunction getHierarchyChildBc(originBcName: string, hierarchyWidget: WidgetMeta) {\r\n const nestedBcNames = hierarchyWidget?.options?.hierarchy?.map(nestedItem => nestedItem.bcName)\r\n if (originBcName !== hierarchyWidget.bcName && !nestedBcNames?.includes(originBcName)) {\r\n return []\r\n }\r\n const childHierarchyBcIndex = nestedBcNames?.findIndex(item => item === originBcName) as number\r\n const childHierarchyBcName = nestedBcNames?.[childHierarchyBcIndex + 1]\r\n return [childHierarchyBcName, hierarchyWidget.name]\r\n}\r\n\r\n/**\r\n * Check specified show condition for the widget\r\n *\r\n * Condition is true (and widget is visible) if currently active record for condition business component has a value of the specific\r\n * field matching the condition; pending values are also enough for the condition to be true.\r\n * Condition is also true when it explicitly declared as default condition, if it's empty or of the legacy array format\r\n *\r\n * Otherwise the condition is false and the widget is hidden.\r\n *\r\n * @param condition Widget showCondition to check\r\n * @param cursor Id of active record for business component in condition\r\n * @param data An array of data.ts items to check for condition\r\n * @param pendingDataChanges Pending data.ts changes of the currently active view\r\n */\r\nexport function checkShowCondition(\r\n condition: WidgetShowCondition | undefined,\r\n cursor: string,\r\n data: DataItem[],\r\n pendingDataChanges: Record<string, Record<string, PendingDataItem>>\r\n) {\r\n const { bcName, isDefault, params } = condition || {}\r\n const emptyCondition = !condition || Array.isArray(condition)\r\n if (emptyCondition || isDefault) {\r\n return true\r\n }\r\n const record = cursor && data?.find(item => item.id === cursor)\r\n if (!record) {\r\n return false\r\n }\r\n const actualValue = record?.[params?.fieldKey as string]\r\n const pendingValue = pendingDataChanges?.[bcName as string]?.[cursor]?.[params?.fieldKey as string]\r\n return pendingValue !== undefined ? pendingValue === params?.value : actualValue === params?.value\r\n}\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\n/**\r\n * This module contains utilities for tree-like structures\r\n */\r\n\r\nimport { DataNode, TreeNodeBidirectional, TreeNodeDescending } from '../interfaces/tree'\r\n\r\n/**\r\n * Assigns for each element:\r\n *\r\n * - `parent` property, which is a reference to parent mode found through `parentId` match.\r\n * - `children` property, which is an array of references to child nodes.\r\n *\r\n * `parentId`: '0' considered a root pseudo-node\r\n *\r\n * Orphaned records will be excluded from result and throw a console warning.\r\n *\r\n * @param flat Flat array representation of tree structure\r\n * @returns New array\r\n */\r\nexport function assignTreeLinks<T extends DataNode>(flat: T[]) {\r\n const result = flat.map(item => ({ ...item })) as Array<T & TreeNodeBidirectional>\r\n const map: Record<string, number> = {}\r\n const orphans: string[] = []\r\n result.forEach(item => {\r\n if (!item.parentId || item.parentId === '0') {\r\n return\r\n }\r\n let parentIndex = map[item.parentId]\r\n if (typeof parentIndex !== 'number') {\r\n parentIndex = flat.findIndex(el => el.id === item.parentId)\r\n map[item.parentId] = parentIndex\r\n }\r\n if (parentIndex === -1) {\r\n orphans.push(item.parentId)\r\n console.warn(\r\n `Record with [id] = ${item.id} has [parentId] = ${item.parentId}, but no matching` +\r\n ' parent record exist. Check the service for this BC.'\r\n )\r\n return\r\n }\r\n item.parent = result[parentIndex]\r\n if (!result[parentIndex].children) {\r\n result[parentIndex].children = [item]\r\n } else {\r\n result[parentIndex]?.children?.push(item)\r\n }\r\n })\r\n if (orphans.length) {\r\n return result.filter(item => !orphans.includes(item.parentId))\r\n }\r\n return result\r\n}\r\n\r\n/**\r\n * Recursively traverse through each node and their descendant to aggregate ids of all\r\n * descendant nodes into `result` array.\r\n *\r\n * @param nodes Nodes to start search from; their ids also will be part of the result\r\n * @param result An array of ids for found descendant nodes\r\n */\r\nexport function getDescendants(nodes: TreeNodeDescending[], result: string[]) {\r\n nodes.forEach(child => {\r\n result.push(child.id)\r\n if (child.children) {\r\n getDescendants(child.children, result)\r\n }\r\n })\r\n}\r\n\r\n/**\r\n * Returns array of matching nodes, their direct children and every ancestor node\r\n *\r\n * @param nodes An array to search\r\n * @param matchingNodes Ids of the nodes to match\r\n */\r\nexport function buildSearchResultTree<T extends TreeNodeBidirectional = TreeNodeBidirectional>(nodes: T[], matchingNodes: string[]) {\r\n const result: Record<string, boolean> = {}\r\n nodes.forEach(item => {\r\n if (!matchingNodes.includes(item.id)) {\r\n return\r\n }\r\n let parent = item.parent\r\n while (parent) {\r\n result[parent.id] = true\r\n parent = parent.parent\r\n }\r\n result[item.id] = true\r\n item.children?.forEach(child => {\r\n result[child.id] = true\r\n })\r\n })\r\n // todo: iterate through result directly\r\n return nodes.filter(item => result[item.id] === true)\r\n}\r\n\r\n/**\r\n * Presort items based on their `level` property: each parent is followed by its descendant.\r\n * Items with level `1` considered to be root-level items.\r\n *\r\n * Notice: not very performant and almost always wasted as Cxbox API mostly returns already\r\n * sorted data.ts.\r\n *\r\n * @param data Unsorted data.ts\r\n */\r\nexport function presort(data: TreeNodeBidirectional[]) {\r\n const result: string[] = []\r\n data.filter(item => item.level === 1).forEach(item => {\r\n result.push(item.id)\r\n if (item.children) {\r\n getDescendants(item.children, result)\r\n }\r\n })\r\n return result.map(id => data.find(match => match.id === id))\r\n}\r\n","import { ViewMetaResponse } from '../interfaces'\r\n\r\nexport const getDefaultViewForPrimary = (primary: string, views: ViewMetaResponse[]) => {\r\n if (!primary) return null\r\n\r\n return views.find(item => item.name === primary) ?? null\r\n}\r\n","import { ViewMetaResponse } from '../interfaces'\r\n\r\nexport const getDefaultViewFromPrimaries = (primaries: string[] | null, views: ViewMetaResponse[]) => {\r\n if (!primaries) return null\r\n\r\n let primaryView: ViewMetaResponse | null = null\r\n\r\n for (const primaryViewName of primaries) {\r\n if (primaryView !== null) {\r\n break\r\n }\r\n\r\n primaryView = views.find(view => view.name === primaryViewName) ?? null\r\n }\r\n\r\n return primaryView\r\n}\r\n","import { DataValue } from '@cxbox-ui/schema'\r\nimport { RowMeta } from '../interfaces'\r\n\r\nexport const removeDisabledFieldsMutate = <Changes extends { [p: string]: DataValue }>(changes: Changes, rowMeta: RowMeta | undefined) => {\r\n // there is no row meta when parent bc custom operation's postaction triggers autosave, because custom operation call bcForceUpdate\r\n if (rowMeta) {\r\n Object.keys(changes).forEach(key => {\r\n const rowMetaOfDisabledField = rowMeta.fields.find(field => field.key === key && field.disabled)\r\n\r\n if (rowMetaOfDisabledField) {\r\n delete changes[key]\r\n\r\n if (rowMetaOfDisabledField.currentValue !== undefined) {\r\n console.error('Changes to disabled fields are not taken into account when sending')\r\n }\r\n }\r\n })\r\n }\r\n\r\n return changes\r\n}\r\n\r\nexport const removeDisabledFields = <Changes extends { [p: string]: DataValue }>(\r\n changes: Changes | undefined,\r\n rowMeta: RowMeta | undefined\r\n) => {\r\n return removeDisabledFieldsMutate({ ...changes }, rowMeta)\r\n}\r\n","import { EpicDependencyInjection, PopupWidgetTypes, WidgetMeta } from '../interfaces'\r\n\r\nexport const getWidgetsForLazyLoad = (\r\n widgets: WidgetMeta[],\r\n getInternalWidgets: EpicDependencyInjection['utils']['getInternalWidgets'],\r\n activePopupBcName?: string\r\n) => {\r\n const popupWidgets: WidgetMeta[] = []\r\n const mainWidgets: WidgetMeta[] = []\r\n\r\n for (const widget of widgets) {\r\n if (PopupWidgetTypes.includes(widget.type) && (!activePopupBcName || widget.bcName !== activePopupBcName)) {\r\n popupWidgets.push(widget)\r\n } else {\r\n mainWidgets.push(widget)\r\n }\r\n }\r\n\r\n const internalPopupWidgetsNames = getInternalWidgets?.(popupWidgets) || []\r\n const internalMainWidgetsNames = getInternalWidgets?.(mainWidgets) || []\r\n const internalNames = new Set([...internalPopupWidgetsNames, ...internalMainWidgetsNames])\r\n\r\n const externalPopupWidgets = popupWidgets.filter(widget => !internalNames.has(widget.name))\r\n const externalMainWidgets = mainWidgets.filter(widget => !internalNames.has(widget.name))\r\n\r\n const exclusionSet = new Set([...externalMainWidgets.map(widget => widget.name), ...internalMainWidgetsNames])\r\n\r\n const uniqueInternalPopupWidgetsNames = internalPopupWidgetsNames.filter(\r\n internalPopupWidgetName => !exclusionSet.has(internalPopupWidgetName)\r\n )\r\n\r\n return [...new Set([...externalPopupWidgets.map(widget => widget.name), ...uniqueInternalPopupWidgetsNames])]\r\n}\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\n/**\r\n * Search node matching the predicate on the current depth prior to moving to the next depth level\r\n *\r\n * @param root Tree root\r\n * @param predicate Search condition for the target tree node\r\n * @returns Matching node and a tree depth where this node was found\r\n */\r\nexport function breadthFirstSearch<T>(\r\n root: T,\r\n predicate: (current: any) => boolean,\r\n depth = 1,\r\n childrenProperty = 'child' as keyof T\r\n): BreadthFirstResult<T> {\r\n // Check the root if we can stop searching\r\n const rootMatch = predicate(root) && root\r\n const rootChildren = root[childrenProperty] as unknown as T[]\r\n if (!rootMatch && !rootChildren) {\r\n return null\r\n }\r\n if (rootMatch) {\r\n return { node: rootMatch, depth }\r\n }\r\n // Check all nodes on current depth\r\n let simpleLeaf = rootChildren.filter(item => !item[childrenProperty]).find(item => predicate(item))\r\n if (simpleLeaf) {\r\n return { node: simpleLeaf, depth: depth + 1 }\r\n }\r\n // Move to the next depth\r\n let resultDepth = depth\r\n rootChildren.some(item => {\r\n const search = breadthFirstSearch<T>(item, predicate, resultDepth + 1, childrenProperty ?? ('child' as keyof T))\r\n simpleLeaf = search?.node\r\n resultDepth = search?.depth\r\n return search?.node\r\n })\r\n return simpleLeaf ? { node: simpleLeaf, depth: resultDepth } : null\r\n}\r\n\r\n/**\r\n * Bredth-first search result\r\n */\r\nexport interface BreadthFirstResult<T> {\r\n /**\r\n * Matching node\r\n */\r\n node: T\r\n /**\r\n * Tree depth where this node was found\r\n */\r\n depth: number\r\n}\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nexport function deleteUndefinedFromObject(obj: Record<string, any>) {\r\n Object.keys(obj).forEach(key => {\r\n if (obj[key] === undefined) {\r\n delete obj[key]\r\n }\r\n })\r\n}\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { CustomWidgetDescriptor, isCustomWidgetConfiguration, PopupWidgetTypes } from '../interfaces/widget'\r\n\r\n/**\r\n * Add new values to `PopupWidgetTypes` from client application\r\n *\r\n * @param customWidgets client's widgets\r\n */\r\nexport function extendPopupWidgetTypes(customWidgets: Record<string, CustomWidgetDescriptor>) {\r\n if (customWidgets) {\r\n Object.entries(customWidgets).forEach(([widgetType, descriptor]) => {\r\n if (isCustomWidgetConfiguration(descriptor) && descriptor.isPopup) {\r\n if (!PopupWidgetTypes.includes(widgetType)) {\r\n PopupWidgetTypes.push(widgetType)\r\n }\r\n }\r\n })\r\n }\r\n}\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { ScreenState } from '../interfaces'\r\nimport { BcMeta, BcMetaState } from '../interfaces'\r\nimport { OperationTypeCrud } from '@cxbox-ui/schema'\r\nimport { parseFilters, parseSorters } from '../utils'\r\nimport { BcFilter, BcSorter } from '../interfaces'\r\nimport {\r\n associateInProgress,\r\n bcAddFilter,\r\n bcAddSorter,\r\n bcChangeCursors,\r\n bcChangeDepthCursor,\r\n bcChangePage,\r\n bcDeleteDataFail,\r\n bcFetchDataFail,\r\n bcFetchDataRequest,\r\n bcFetchDataSuccess,\r\n bcForceUpdate,\r\n bcLoadMore,\r\n bcNewDataSuccess,\r\n bcRemoveAllFilters,\r\n bcRemoveFilter,\r\n bcSaveDataFail,\r\n bcSaveDataSuccess,\r\n bcSelectRecord,\r\n inlinePickListFetchDataSuccess,\r\n selectScreen,\r\n selectScreenFail,\r\n selectView,\r\n sendOperation,\r\n sendOperationFail,\r\n sendOperationSuccess,\r\n setOperationFinished,\r\n showViewPopup\r\n} from '../actions'\r\nimport { ReducerBuilderManager } from './ReducerBuilderManager'\r\nimport { DepthBcType } from '../interfaces/bc'\r\n\r\nexport const initialScreenState: ScreenState = {\r\n screenName: '',\r\n bo: { activeBcName: '', bc: {} },\r\n cachedBc: {},\r\n views: [],\r\n primaryView: '',\r\n primaryViews: null,\r\n filters: {},\r\n sorters: {}\r\n}\r\n\r\nconst operationsHandledLocally: readonly string[] = [OperationTypeCrud.associate, OperationTypeCrud.fileUpload]\r\n\r\n/**\r\n * Screen reducer\r\n *\r\n * Stores information about currently active screen and various more persistent values which should be stored\r\n * until we navitage to a different screen.\r\n */\r\nexport const createScreenReducerBuilderManager = <S extends ScreenState>(initialState: S) =>\r\n new ReducerBuilderManager<S>()\r\n .addCase(selectScreen, (state, action) => {\r\n const bcDictionary: Record<string, BcMeta> = {}\r\n const bcSorters: Record<string, BcSorter[]> = {}\r\n const bcFilters: Record<string, BcFilter[]> = {}\r\n action.payload.screen.meta?.bo.bc.forEach(item => {\r\n bcDictionary[item.name] = item\r\n const sorter = parseSorters(item.defaultSort)\r\n const filter = parseFilters(item.defaultFilter)\r\n if (sorter) {\r\n bcSorters[item.name] = sorter\r\n }\r\n if (filter) {\r\n bcFilters[item.name] = filter\r\n }\r\n })\r\n state.screenName = action.payload.screen.name\r\n state.primaryView = action.payload.screen.meta?.primary ?? state.primaryView\r\n state.primaryViews = action.payload.screen.meta?.primaries ?? state.primaryViews\r\n state.views = action.payload.screen.meta?.views ?? state.views\r\n state.bo = { activeBcName: null, bc: bcDictionary }\r\n state.sorters = { ...state.sorters, ...bcSorters }\r\n state.filters = { ...state.filters, ...bcFilters }\r\n })\r\n .addCase(selectScreenFail, (state, action) => {\r\n state.screenName = action.payload.screenName\r\n state.views = []\r\n })\r\n .addCase(bcFetchDataRequest, (state, action) => {\r\n const bcName = action.payload.bcName\r\n if (action.payload.bcName) {\r\n state.bo.bc[bcName].loading = true\r\n }\r\n })\r\n .addCase(bcLoadMore, (state, action) => {\r\n const currentBc = state.bo.bc[action.payload.bcName]\r\n currentBc.page = (currentBc.page ?? 1) + 1\r\n currentBc.loading = true\r\n })\r\n .addCase(selectView, (state, action) => {\r\n if (action.payload.isTab) {\r\n return\r\n }\r\n const newBcs: Record<string, BcMetaState> = {}\r\n Array.from(\r\n new Set(action.payload.widgets?.map(widget => widget.bcName)) // БК которые есть на вьюхе\r\n )\r\n .filter(bcName => state.bo.bc[bcName])\r\n .forEach(bcName => {\r\n newBcs[bcName] = { ...state.bo.bc[bcName], page: 1 }\r\n })\r\n state.bo.bc = { ...state.bo.bc, ...newBcs }\r\n })\r\n .addCase(bcFetchDataSuccess, (state, action) => {\r\n const currentBc = state.bo.bc[action.payload.bcName]\r\n currentBc.hasNext = action.payload.hasNext\r\n currentBc.loading = false\r\n state.cachedBc[action.payload.bcName] = action.payload.bcUrl\r\n })\r\n .addCase(inlinePickListFetchDataSuccess, (state, action) => {\r\n const currentBc = state.bo.bc[action.payload.bcName]\r\n currentBc.hasNext = action.payload.hasNext\r\n currentBc.loading = false\r\n state.cachedBc[action.payload.bcName] = action.payload.bcUrl\r\n })\r\n .addCase(bcFetchDataFail, (state, action) => {\r\n const bcName = action.payload.bcName as string\r\n\r\n if (Object.values(state.bo.bc).some(bc => bc.name === bcName)) {\r\n state.bo.bc[bcName].loading = false\r\n state.cachedBc[bcName] = action.payload.bcUrl\r\n }\r\n })\r\n .addCase(sendOperation, (state, action) => {\r\n const { bcName, operationType } = action.payload\r\n if (!operationsHandledLocally.includes(action.payload.operationType)) {\r\n state.bo.bc[bcName].loading = true\r\n const prevOperationsInProgress = state.bo.bc[bcName].operationsInProgress ?? []\r\n state.bo.bc[bcName].operationsInProgress = [...prevOperationsInProgress, operationType]\r\n }\r\n })\r\n .addCase(bcNewDataSuccess, (state, action) => {\r\n state.bo.bc[action.payload.bcName].loading = false\r\n state.bo.bc[action.payload.bcName].cursor = action.payload.dataItem.id\r\n state.cachedBc[action.payload.bcName] = action.payload.bcUrl\r\n })\r\n .addCase(bcChangeCursors, (state, action) => {\r\n const newCursors: Record<string, BcMetaState> = {}\r\n const newCache: Record<string, string> = {}\r\n Object.entries(action.payload.cursorsMap).forEach(entry => {\r\n const [bcName, cursor] = entry\r\n newCursors[bcName] = { ...state.bo.bc[bcName], cursor }\r\n newCache[bcName] = cursor\r\n })\r\n // Also reset cursors of all children of requested BCs\r\n const changedParents = Object.values(newCursors).map(bc => `${bc.url}/:id`)\r\n Object.values(state.bo.bc).forEach(bc => {\r\n if (changedParents.some(item => bc.url.includes(item)) && !(bc.name in newCursors)) {\r\n newCursors[bc.name] = { ...state.bo.bc[bc.name], cursor: null }\r\n newCache[bc.name] = null\r\n }\r\n })\r\n Object.assign(state.bo.bc, newCursors)\r\n Object.assign(state.cachedBc, newCache)\r\n })\r\n .addCase(bcChangeDepthCursor, (state, action) => {\r\n if (action.payload.depth === 1) {\r\n state.bo.bc[action.payload.bcName].cursor = action.payload.cursor\r\n } else {\r\n state.bo.bc[action.payload.bcName].depthBc = state.bo.bc[action.payload.bcName].depthBc ?? {}\r\n ;(state.bo.bc[action.payload.bcName].depthBc as DepthBcType)[action.payload.depth].cursor = action.payload.cursor\r\n }\r\n })\r\n .addCase(bcSelectRecord, (state, action) => {\r\n state.bo.bc[action.payload.bcName].cursor = action.payload.cursor\r\n })\r\n .addCase(bcForceUpdate, (state, action) => {\r\n state.bo.bc[action.payload.bcName].loading = true\r\n state.cachedBc[action.payload.bcName] = null\r\n })\r\n .addCase(bcAddFilter, (state, action) => {\r\n const { bcName, filter } = action.payload\r\n const newFilter = filter\r\n const prevFilters = state.filters[bcName] || []\r\n const prevFilter = prevFilters.find(item => item.fieldName === filter.fieldName && item.type === filter.type)\r\n const newFilters = prevFilter\r\n ? prevFilters.map(item => (item === prevFilter ? { ...prevFilter, value: newFilter.value } : item))\r\n : [...prevFilters, newFilter]\r\n\r\n if (state.bo.bc[bcName]) {\r\n state.bo.bc[bcName].page = 1\r\n }\r\n\r\n state.filters[bcName] = newFilters\r\n })\r\n .addCase(bcRemoveFilter, (state, action) => {\r\n const { bcName, filter } = action.payload\r\n const prevBcFilters = state.filters[bcName] || []\r\n const newBcFilters = prevBcFilters.filter(item => item.fieldName !== filter?.fieldName || item.type !== filter.type)\r\n const newFilters = { ...state.filters, [bcName]: newBcFilters }\r\n if (!newBcFilters.length) {\r\n delete newFilters[bcName]\r\n }\r\n\r\n if (state.bo.bc[action.payload.bcName]) {\r\n state.bo.bc[action.payload.bcName].page = 1\r\n }\r\n\r\n state.filters = newFilters\r\n })\r\n .addCase(bcRemoveAllFilters, (state, action) => {\r\n delete state.filters[action.payload.bcName]\r\n\r\n if (state.bo.bc[action.payload.bcName]) {\r\n state.bo.bc[action.payload.bcName].page = 1\r\n }\r\n })\r\n .addCase(bcAddSorter, (state, action) => {\r\n state.sorters[action.payload.bcName] = Array.isArray(action.payload.sorter) ? action.payload.sorter : [action.payload.sorter]\r\n })\r\n .addCase(bcChangePage, (state, action) => {\r\n state.bo.bc[action.payload.bcName].page = action.payload.page\r\n state.bo.bc[action.payload.bcName].loading = true\r\n })\r\n .addCase(showViewPopup, (state, action) => {\r\n const currentPage = state.bo.bc[action.payload.bcName]?.page ?? 1\r\n\r\n state.bo.bc[action.payload.bcName].page = action.payload.bcName === action.payload.calleeBCName ? currentPage : 1\r\n state.bo.bc[action.payload.bcName].loading = action.payload.bcName !== action.payload.calleeBCName\r\n })\r\n //don't use matcher in prior to add more cases\r\n .addCase(sendOperationSuccess, (state, action) => {\r\n state.bo.bc[action.payload.bcName].loading = false\r\n })\r\n .addCase(bcDeleteDataFail, (state, action) => {\r\n state.bo.bc[action.payload.bcName].loading = false\r\n })\r\n .addCase(sendOperationFail, (state, action) => {\r\n state.bo.bc[action.payload.bcName].loading = false\r\n })\r\n .addCase(bcSaveDataSuccess, (state, action) => {\r\n state.bo.bc[action.payload.bcName].loading = false\r\n })\r\n .addCase(bcSaveDataFail, (state, action) => {\r\n state.bo.bc[action.payload.bcName].loading = false\r\n })\r\n .addCase(associateInProgress, (state, action) => {\r\n const bcName = action.payload.bcName\r\n if (bcName) {\r\n const prevOperationsInProgress = state.bo.bc[bcName].operationsInProgress ?? []\r\n state.bo.bc[bcName].operationsInProgress = [...prevOperationsInProgress, 'saveAssociations']\r\n }\r\n })\r\n .addCase(setOperationFinished, (state, action) => {\r\n const { bcName, operationType } = action.payload\r\n state.bo.bc[bcName].operationsInProgress = state.bo.bc[bcName].operationsInProgress?.filter(item => item !== operationType)\r\n })\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { PendingValidationFailsFormat, ViewState, PendingDataItem } from '../interfaces'\r\nimport { DataItem, OperationTypeCrud } from '@cxbox-ui/schema'\r\nimport {\r\n bcCancelPendingChanges,\r\n bcFetchRowMeta,\r\n bcFetchRowMetaFail,\r\n bcFetchRowMetaSuccess,\r\n bcLoadMore,\r\n bcNewDataFail,\r\n bcNewDataSuccess,\r\n bcSaveDataFail,\r\n bcSaveDataSuccess,\r\n changeDataItem,\r\n changeDataItems,\r\n changeLocation,\r\n clearSelectedRows,\r\n clearValidationFails,\r\n closeConfirmModal,\r\n closeNotification,\r\n closeViewError,\r\n closeViewPopup,\r\n deselectRows,\r\n deselectTableRow,\r\n dropAllAssociations,\r\n dropAllAssociationsFull,\r\n dropAllAssociationsSameBc,\r\n forceActiveChangeFail,\r\n forceActiveRmUpdate,\r\n operationConfirmation,\r\n processPostInvoke,\r\n applyPendingPostInvoke,\r\n selectRows,\r\n selectTableRow,\r\n selectView,\r\n sendOperation,\r\n sendOperationFail,\r\n sendOperationSuccess,\r\n setPendingPostInvoke,\r\n showFileUploadPopup,\r\n showNotification,\r\n showViewError,\r\n showViewPopup,\r\n viewClearPickMap,\r\n viewPutPickMap\r\n} from '../actions'\r\nimport { ReducerBuilderManager } from './ReducerBuilderManager'\r\n\r\nexport const initialViewState: ViewState = {\r\n id: undefined,\r\n name: null,\r\n url: null,\r\n widgets: [],\r\n columns: null,\r\n readOnly: false,\r\n rowHeight: null,\r\n rowMeta: {},\r\n metaInProgress: {},\r\n popupData: { bcName: null },\r\n pendingDataChanges: {},\r\n pendingPostInvoke: {},\r\n pendingDataChangesNow: {},\r\n infiniteWidgets: [],\r\n pendingValidationFailsFormat: PendingValidationFailsFormat.old,\r\n pendingValidationFails: {},\r\n handledForceActive: {},\r\n selectedRow: null,\r\n selectedRows: {},\r\n ignoreHistory: null,\r\n systemNotifications: [],\r\n error: null,\r\n modalInvoke: null\r\n}\r\n\r\nconst isEmptyFieldValue = (value: unknown) =>\r\n value === null || value === undefined || value === '' || (Array.isArray(value) && Object.keys(value).length === 0)\r\n\r\nconst getFailsByRequiredFields = (data: PendingDataItem, isRequired: (fieldKey: string) => boolean) => {\r\n const fails: Record<string, string> = {}\r\n\r\n Object.keys(data).forEach(fieldKey => {\r\n if (isRequired(fieldKey) && isEmptyFieldValue(data[fieldKey])) {\r\n fails[fieldKey] = 'This field is mandatory'\r\n }\r\n })\r\n\r\n return fails\r\n}\r\n\r\n/**\r\n * View reducer\r\n *\r\n * Stores information about currently active view and various fast-living pending values which should be stored\r\n * until we navitage to a different view.\r\n */\r\nexport const createViewReducerBuilderManager = <S extends ViewState>(initialState: S) =>\r\n new ReducerBuilderManager<S>()\r\n .addCase(selectView, (state, action) => {\r\n if (!action.payload.isTab) {\r\n state.rowMeta = initialViewState.rowMeta\r\n }\r\n Object.assign(state, action.payload)\r\n })\r\n .addCase(bcFetchRowMeta, (state, action) => {\r\n state.metaInProgress[action.payload.bcName] = true\r\n })\r\n .addCase(bcLoadMore, (state, action) => {\r\n const infiniteWidgets: string[] = state.infiniteWidgets || []\r\n if (action.payload.widgetName !== undefined) {\r\n infiniteWidgets.push(action.payload.widgetName)\r\n }\r\n state.infiniteWidgets = Array.from(new Set(infiniteWidgets))\r\n })\r\n .addCase(sendOperation, (state, action) => {\r\n if (action.payload.operationType === OperationTypeCrud.create) {\r\n state.metaInProgress[action.payload.bcName] = true\r\n }\r\n })\r\n .addCase(bcFetchRowMetaSuccess, (state, action) => {\r\n state.rowMeta[action.payload.bcName] = state.rowMeta[action.payload.bcName] ?? {}\r\n state.rowMeta[action.payload.bcName][action.payload.bcUrl] = action.payload.rowMeta\r\n state.metaInProgress[action.payload.bcName] = false\r\n })\r\n .addCase(bcNewDataSuccess, (state, action) => {\r\n state.selectedRow = initialViewState.selectedRow\r\n })\r\n .addCase(forceActiveRmUpdate, (state, action) => {\r\n const { bcName, bcUrl, currentRecordData, rowMeta, cursor } = action.payload\r\n const handledForceActive: PendingDataItem = {}\r\n const rowMetaForcedValues: PendingDataItem = {}\r\n const newPendingChangesDiff: PendingDataItem = {}\r\n const forceActiveFieldKeys: string[] = []\r\n\r\n // приведем значения переданные в forcedValue в вид дельты изменений\r\n rowMeta.fields.forEach(field => {\r\n rowMetaForcedValues[field.key] = field.currentValue\r\n if (field.forceActive) {\r\n forceActiveFieldKeys.push(field.key)\r\n }\r\n })\r\n state.pendingDataChanges[bcName] = state.pendingDataChanges[bcName] ?? {}\r\n const consolidatedFrontData: PendingDataItem = { ...currentRecordData, ...state.pendingDataChanges[bcName][cursor] }\r\n // вычислим \"разницу\" между консолид.данными и полученными forcedValue's в пользу последних\r\n Object.keys(consolidatedFrontData).forEach(key => {\r\n if (rowMetaForcedValues[key] !== undefined && consolidatedFrontData[key] !== rowMetaForcedValues[key]) {\r\n newPendingChangesDiff[key] = rowMetaForcedValues[key]\r\n }\r\n })\r\n\r\n // консолидация полученной разницы с актуальной дельтой\r\n const newPendingDataChanges = { ...state.pendingDataChanges[bcName][cursor], ...newPendingChangesDiff }\r\n\r\n const isTargetFormatPVF = state.pendingValidationFailsFormat === PendingValidationFailsFormat.target\r\n const nextValidationFails = getFailsByRequiredFields(\r\n newPendingDataChanges,\r\n fieldKey => !!state.rowMeta[bcName]?.[bcUrl]?.fields.find(item => item.required && item.key === fieldKey)\r\n )\r\n\r\n // обновление ошибок, на основе полей заполненных через роу-мету\r\n if (isTargetFormatPVF) {\r\n state.pendingValidationFails = state.pendingValidationFails ?? {}\r\n state.pendingValidationFails[bcName] = state.pendingValidationFails[bcName] ?? {}\r\n ;(state.pendingValidationFails[bcName] as { [cursor: string]: Record<string, string> })[cursor] = nextValidationFails\r\n } else {\r\n state.pendingValidationFails = nextValidationFails\r\n }\r\n\r\n // отразим в списке обработанных forceActive полей - те что содержатся в новой дельте\r\n forceActiveFieldKeys.forEach(key => {\r\n if (newPendingDataChanges[key] !== undefined) {\r\n handledForceActive[key] = newPendingDataChanges[key]\r\n }\r\n })\r\n state.handledForceActive[bcName] = state.handledForceActive[bcName] ?? {}\r\n state.handledForceActive[bcName][cursor] = state.handledForceActive[bcName][cursor] ?? {}\r\n Object.assign(state.handledForceActive[bcName][cursor], handledForceActive)\r\n state.pendingDataChanges[bcName] = state.pendingDataChanges[bcName] ?? {}\r\n state.pendingDataChanges[bcName][cursor] = newPendingDataChanges\r\n state.pendingDataChangesNow[bcName] = state.pendingDataChangesNow[bcName] ?? {}\r\n state.pendingDataChangesNow[bcName][cursor] = {}\r\n state.rowMeta[bcName] = state.rowMeta[bcName] ?? {}\r\n state.rowMeta[bcName][bcUrl] = rowMeta\r\n })\r\n .addCase(changeDataItem, (state, action) => {\r\n const actionBcName = action.payload.bcName\r\n const prevBc = state.pendingDataChanges[action.payload.bcName] || {}\r\n const prevCursor = prevBc[action.payload.cursor] || {}\r\n const prevPending = prevCursor || {}\r\n const nextPending = { ...prevPending, ...action.payload.dataItem }\r\n const bcUrl = action.payload.bcUrl\r\n\r\n state.pendingDataChanges[action.payload.bcName] = state.pendingDataChanges[action.payload.bcName] ?? {}\r\n state.pendingDataChanges[action.payload.bcName][action.payload.cursor] = nextPending\r\n const prevBcNow = state.pendingDataChangesNow[action.payload.bcName] || {}\r\n const prevCursorNow = prevBcNow[action.payload.cursor] || {}\r\n const prevPendingNow = prevCursorNow || {}\r\n state.pendingDataChangesNow[action.payload.bcName] = state.pendingDataChangesNow[action.payload.bcName] ?? {}\r\n state.pendingDataChangesNow[action.payload.bcName][action.payload.cursor] = { ...prevPendingNow, ...action.payload.dataItem }\r\n\r\n const isTargetFormatPVF = state.pendingValidationFailsFormat === PendingValidationFailsFormat.target\r\n const nextValidationFails = getFailsByRequiredFields(\r\n nextPending,\r\n fieldKey => !!state.rowMeta[actionBcName]?.[bcUrl]?.fields.find(item => item.required && item.key === fieldKey)\r\n )\r\n\r\n if (isTargetFormatPVF) {\r\n state.pendingValidationFails = state.pendingValidationFails ?? {}\r\n state.pendingValidationFails[actionBcName] = state.pendingValidationFails[actionBcName] ?? {}\r\n ;(state.pendingValidationFails[actionBcName] as { [cursor: string]: Record<string, string> })[action.payload.cursor] =\r\n nextValidationFails\r\n } else {\r\n state.pendingValidationFails = nextValidationFails\r\n }\r\n })\r\n .addCase(changeDataItems, (state, action) => {\r\n const newPendingChanges = { ...state.pendingDataChanges[action.payload.bcName] }\r\n const newPendingChangesNow = { ...state.pendingDataChangesNow[action.payload.bcName] }\r\n action.payload.cursors.forEach((cursor, index) => {\r\n newPendingChanges[cursor] = action.payload.dataItems[index]\r\n newPendingChangesNow[cursor] = action.payload.dataItems[index]\r\n })\r\n state.pendingDataChanges[action.payload.bcName] = newPendingChanges\r\n state.pendingDataChangesNow[action.payload.bcName] = newPendingChangesNow\r\n })\r\n .addCase(dropAllAssociations, (state, action) => {\r\n const pendingDataChanges = { ...state.pendingDataChanges }\r\n action.payload.bcNames.forEach(bcName => {\r\n const pendingBcChanges: Record<string, PendingDataItem> = {}\r\n // ;(store.data[bcName] || [])\r\n // .filter(item => item._associate)\r\n // .forEach(item => {\r\n // pendingBcChanges[item.id] = { id: item.id, _associate: false }\r\n // })\r\n Object.keys(pendingDataChanges[bcName] || {}).forEach(itemId => {\r\n pendingBcChanges[itemId] = { id: itemId, _associate: false }\r\n })\r\n pendingDataChanges[bcName] = pendingBcChanges\r\n })\r\n const isTargetFormatPVF = state.pendingValidationFailsFormat === PendingValidationFailsFormat.target\r\n const pendingValidationFails = state.pendingValidationFails ? { ...state.pendingValidationFails } : {}\r\n\r\n if (isTargetFormatPVF) {\r\n action.payload.bcNames.forEach(i => {\r\n pendingValidationFails[i] = {}\r\n })\r\n }\r\n state.pendingDataChanges = pendingDataChanges\r\n state.pendingValidationFails = isTargetFormatPVF ? pendingValidationFails : initialViewState.pendingValidationFails\r\n })\r\n //TODO: rewrite correctly (get data outside of reducer, place it in epic)\r\n .addCase(dropAllAssociationsSameBc, (state, action) => {\r\n // const pendingDataChanges = { ...state.pendingDataChanges }\r\n //\r\n // Object.entries({ ...store.depthData, 1: store.data }).forEach(([depthLevelKey, depthLevelData]) => {\r\n // const depthLevel = Number(depthLevelKey)\r\n // const pendingBcChanges: Record<string, PendingDataItem> = {}\r\n // if (depthLevel >= action.payload.depthFrom && depthLevelData[action.payload.bcName]) {\r\n // depthLevelData[action.payload.bcName]\r\n // .filter((item: any) => item._associate)\r\n // .forEach((item: any) => {\r\n // pendingBcChanges[item.id] = { _associate: false }\r\n // })\r\n // }\r\n // pendingDataChanges[action.payload.bcName] = pendingBcChanges\r\n // })\r\n // const isTargetFormatPVF = state.pendingValidationFailsFormat === PendingValidationFailsFormat.target\r\n //\r\n // return {\r\n // ...state,\r\n // pendingDataChanges,\r\n // pendingValidationFails: isTargetFormatPVF\r\n // ? {\r\n // ...(state.pendingValidationFails as PendingValidationFails),\r\n // [action.payload.bcName]: {}\r\n // }\r\n // : initialState.pendingValidationFails\r\n // }\r\n })\r\n //TODO: rewrite correctly (get data outside of reducer, place it in epic)\r\n .addCase(dropAllAssociationsFull, (state, action) => {\r\n // const bcName = action.payload.bcName\r\n // const pendingDataChanges = { ...state.pendingDataChanges }\r\n // const dropDesc = action.payload.dropDescendants\r\n //\r\n // const pendingBcChanges: Record<string, PendingDataItem> = {}\r\n // ;(store.data[bcName] || [])\r\n // .filter(item => item._associate)\r\n // .forEach(item => {\r\n // if ((dropDesc && item.level === action.payload.depth) || item.level >= action.payload.depth) {\r\n // pendingBcChanges[item.id] = { ...item, _associate: false }\r\n // }\r\n // })\r\n // Object.entries(pendingDataChanges[bcName] || {}).forEach(([itemId, item]) => {\r\n // if ((dropDesc && item.level === action.payload.depth) || item.level >= action.payload.depth) {\r\n // pendingBcChanges[itemId] = { ...item, _associate: false }\r\n // }\r\n // })\r\n // pendingDataChanges[bcName] = pendingBcChanges\r\n // const isTargetFormatPVF = state.pendingValidationFailsFormat === PendingValidationFailsFormat.target\r\n //\r\n // return {\r\n // ...state,\r\n // pendingDataChanges,\r\n // pendingValidationFails: isTargetFormatPVF\r\n // ? {\r\n // ...(state.pendingValidationFails as PendingValidationFails),\r\n // [action.payload.bcName]: {}\r\n // }\r\n // : initialState.pendingValidationFails\r\n // }\r\n })\r\n .addCase(bcNewDataFail, (state, action) => {\r\n state.metaInProgress[action.payload.bcName] = false\r\n })\r\n .addCase(bcFetchRowMetaFail, (state, action) => {\r\n state.metaInProgress[action.payload.bcName] = false\r\n })\r\n .addCase(forceActiveChangeFail, (state, action) => {\r\n const { bcName, bcUrl, entityError } = action.payload\r\n const errors: Record<string, string> = {}\r\n if (entityError) {\r\n Object.entries(entityError.fields).forEach(([fieldName, violation]) => {\r\n errors[fieldName] = violation\r\n })\r\n }\r\n state.rowMeta[bcName] = state.rowMeta[bcName] ?? {}\r\n state.rowMeta[bcName][bcUrl].errors = errors\r\n })\r\n .addCase(bcSaveDataFail, (state, action) => {\r\n const { bcName, bcUrl, entityError } = action.payload\r\n const errors: Record<string, string> = {}\r\n if (entityError) {\r\n Object.entries(entityError.fields).forEach(([fieldName, violation]) => {\r\n errors[fieldName] = violation\r\n })\r\n }\r\n state.rowMeta[bcName] = state.rowMeta[bcName] ?? {}\r\n state.rowMeta[bcName][bcUrl].errors = errors\r\n })\r\n .addCase(sendOperationFail, (state, action) => {\r\n const { bcName, bcUrl, entityError } = action.payload\r\n const errors: Record<string, string> = {}\r\n if (entityError) {\r\n Object.entries(entityError.fields).forEach(([fieldName, violation]) => {\r\n errors[fieldName] = violation\r\n })\r\n }\r\n state.rowMeta[bcName] = state.rowMeta[bcName] ?? {}\r\n state.rowMeta[bcName][bcUrl].errors = errors\r\n })\r\n .addCase(sendOperationSuccess, (state, action) => {\r\n const bcName = action.payload.bcName\r\n const cursor = action.payload.cursor as string\r\n\r\n const isTargetFormatPVF = state.pendingValidationFailsFormat === PendingValidationFailsFormat.target\r\n state.pendingDataChanges[bcName] = state.pendingDataChanges[bcName] ?? {}\r\n state.pendingDataChanges[bcName][cursor] = {}\r\n state.pendingDataChangesNow[bcName] = state.pendingDataChangesNow[bcName] ?? {}\r\n state.pendingDataChangesNow[bcName][cursor] = {}\r\n if (isTargetFormatPVF) {\r\n state.pendingValidationFails = state.pendingValidationFails ?? {}\r\n state.pendingValidationFails[bcName] = state.pendingValidationFails[bcName] ?? {}\r\n ;(state.pendingValidationFails[bcName] as { [cursor: string]: Record<string, string> })[cursor] = {}\r\n } else {\r\n state.pendingValidationFails = initialViewState.pendingValidationFails\r\n }\r\n state.handledForceActive[bcName] = state.handledForceActive[bcName] ?? {}\r\n state.handledForceActive[bcName][cursor] = {}\r\n })\r\n .addCase(bcSaveDataSuccess, (state, action) => {\r\n const { bcName, cursor } = action.payload\r\n const isTargetFormatPVF = state.pendingValidationFailsFormat === PendingValidationFailsFormat.target\r\n state.pendingDataChanges[bcName] = state.pendingDataChanges[bcName] ?? {}\r\n state.pendingDataChanges[bcName][cursor] = {}\r\n state.pendingDataChangesNow[bcName] = state.pendingDataChangesNow[bcName] ?? {}\r\n state.pendingDataChangesNow[bcName][cursor] = {}\r\n if (isTargetFormatPVF) {\r\n state.pendingValidationFails = state.pendingValidationFails ?? {}\r\n state.pendingValidationFails[bcName] = state.pendingValidationFails[bcName] ?? {}\r\n ;(state.pendingValidationFails[bcName] as { [cursor: string]: Record<string, string> })[cursor] = {}\r\n } else {\r\n state.pendingValidationFails = initialViewState.pendingValidationFails\r\n }\r\n state.handledForceActive[bcName] = state.handledForceActive[bcName] ?? {}\r\n state.handledForceActive[bcName][cursor] = {}\r\n })\r\n .addCase(bcCancelPendingChanges, (state, action) => {\r\n // TODO: Check if this works for hierarchy after 1.1.0\r\n const pendingDataChanges = { ...state.pendingDataChanges }\r\n const pendingDataChangesNow = state.pendingDataChangesNow\r\n for (const bcName in state.pendingDataChanges) {\r\n if (action.payload ? action.payload.bcNames.includes(bcName) : true) {\r\n pendingDataChanges[bcName] = {}\r\n pendingDataChangesNow[bcName] = {}\r\n }\r\n }\r\n const isTargetFormatPVF = state.pendingValidationFailsFormat === PendingValidationFailsFormat.target\r\n let pendingValidationFails = state.pendingValidationFails ? { ...state.pendingValidationFails } : {}\r\n\r\n if (isTargetFormatPVF) {\r\n if (action.payload?.bcNames?.length > 0) {\r\n /**\r\n * Clear a `pendingValidationFails` for specific BC names\r\n */\r\n action.payload.bcNames.forEach(i => {\r\n pendingValidationFails[i] = {}\r\n })\r\n } else {\r\n /**\r\n * Clear a `pendingValidationFails` completely\r\n */\r\n pendingValidationFails = initialViewState.pendingValidationFails as typeof pendingValidationFails\r\n }\r\n }\r\n state.pendingDataChanges = pendingDataChanges\r\n state.pendingDataChangesNow = pendingDataChangesNow\r\n state.pendingValidationFails = isTargetFormatPVF ? pendingValidationFails : initialViewState.pendingValidationFails\r\n })\r\n .addCase(clearValidationFails, state => {\r\n state.pendingValidationFails = initialViewState.pendingValidationFails\r\n })\r\n .addCase(showViewPopup, (state, action) => {\r\n const { bcName, calleeBCName, calleeWidgetName, associateFieldKey, assocValueKey, active, isFilter, type, widgetName } =\r\n action.payload\r\n\r\n state.popupData = {\r\n widgetName,\r\n type,\r\n bcName,\r\n calleeBCName,\r\n calleeWidgetName,\r\n associateFieldKey,\r\n assocValueKey,\r\n active,\r\n isFilter\r\n }\r\n })\r\n .addCase(showFileUploadPopup, (state, action) => {\r\n const bcName = state.widgets?.find(item => item.name === action.payload.widgetName)?.bcName\r\n state.popupData = {\r\n type: 'file-upload',\r\n bcName, // should be null\r\n calleeBCName: bcName\r\n }\r\n })\r\n .addCase(viewPutPickMap, (state, action) => {\r\n state.pickMap = action.payload.map\r\n })\r\n .addCase(viewClearPickMap, state => {\r\n state.pickMap = null\r\n })\r\n .addCase(closeViewPopup, state => {\r\n state.popupData = {}\r\n state.popupData.bcName = null\r\n })\r\n .addCase(selectTableRow, (state, action) => {\r\n state.selectedRow = { widgetName: action.payload.widgetName, rowId: action.payload.rowId }\r\n })\r\n .addCase(deselectTableRow, (state, action) => {\r\n state.selectedRow = null\r\n })\r\n .addCase(changeLocation, (state, action) => {\r\n if (!action.payload.isTab) {\r\n state.pendingDataChanges = initialViewState.pendingDataChanges\r\n state.pendingDataChangesNow = initialViewState.pendingDataChangesNow\r\n }\r\n state.popupData = initialViewState.popupData\r\n state.selectedRow = initialViewState.selectedRow\r\n })\r\n .addCase(showNotification, (state, action) => {\r\n state.systemNotifications = state.systemNotifications ?? []\r\n state.systemNotifications.push({\r\n type: action.payload.type,\r\n message: action.payload.message,\r\n id: state.systemNotifications?.length as number\r\n })\r\n })\r\n .addCase(closeNotification, (state, action) => {\r\n state.systemNotifications = state.systemNotifications ?? []\r\n state.systemNotifications = state.systemNotifications.filter(item => item.id !== action.payload.id)\r\n })\r\n .addCase(showViewError, (state, action) => {\r\n state.error = action.payload.error\r\n })\r\n .addCase(operationConfirmation, (state, action) => {\r\n state.modalInvoke = action.payload\r\n })\r\n .addCase(closeConfirmModal, (state, action) => {\r\n state.modalInvoke = null\r\n })\r\n .addCase(closeViewError, state => {\r\n state.error = null\r\n })\r\n .addCase(processPostInvoke, state => {\r\n state.selectedRow = null\r\n })\r\n .addCase(selectRows, (state, action) => {\r\n const { bcName, dataItems } = action.payload\r\n const selectedRowsDictionary: Record<string, Omit<DataItem, 'vstamp'>> = {}\r\n state.selectedRows[bcName] = state.selectedRows[bcName] ?? []\r\n\r\n state.selectedRows[bcName].forEach(row => {\r\n selectedRowsDictionary[row.id as string] = row\r\n })\r\n const newDataItems = dataItems\r\n const dataItemIdsToDelete: string[] = []\r\n\r\n dataItems.forEach((row, index) => {\r\n if (selectedRowsDictionary[row.id as string]) {\r\n newDataItems[index] = { ...selectedRowsDictionary[row.id as string], ...row }\r\n dataItemIdsToDelete.push(row.id as string)\r\n }\r\n })\r\n\r\n state.selectedRows[bcName] = state.selectedRows[bcName].filter(dataItem => !dataItemIdsToDelete.includes(dataItem.id as string))\r\n\r\n state.selectedRows[bcName].splice(0, 0, ...dataItems)\r\n })\r\n .addCase(deselectRows, (state, action) => {\r\n const { bcName, ids } = action.payload\r\n state.selectedRows[bcName] = state.selectedRows[bcName] ?? []\r\n state.selectedRows[bcName] = state.selectedRows[bcName].filter(dataItem => !ids.includes(dataItem.id as string))\r\n })\r\n .addCase(clearSelectedRows, (state, action) => {\r\n const { bcName } = action.payload\r\n delete state.selectedRows[bcName]\r\n })\r\n .addCase(setPendingPostInvoke, (state, action) => {\r\n const { bcName, operationType, postInvoke } = action.payload\r\n state.pendingPostInvoke[bcName] = state.pendingPostInvoke[bcName] ?? {}\r\n state.pendingPostInvoke[bcName][operationType] = postInvoke\r\n })\r\n .addCase(applyPendingPostInvoke, (state, action) => {\r\n const { bcName, operationType } = action.payload\r\n if (state.pendingPostInvoke[bcName]) {\r\n delete state.pendingPostInvoke[bcName][operationType]\r\n }\r\n })\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { DepthDataState } from '../interfaces'\r\nimport { bcFetchDataSuccess, selectView } from '../actions'\r\nimport { ReducerBuilderManager } from './ReducerBuilderManager'\r\n\r\nexport const initialDepthDataState: DepthDataState = {}\r\n\r\nexport const createDepthDataReducerBuilderManager = (initialState: DepthDataState) => {\r\n return new ReducerBuilderManager<typeof initialState>()\r\n .addCase(bcFetchDataSuccess, (state, action) => {\r\n if (!action.payload.depth || action.payload.depth < 2) {\r\n return\r\n }\r\n state[action.payload.depth] = state[action.payload.depth] ?? {}\r\n state[action.payload.depth][action.payload.bcName] = action.payload.data\r\n })\r\n .addCase(selectView, state => {\r\n return initialState\r\n })\r\n}\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { Session } from '../interfaces'\r\nimport {\r\n addNotification,\r\n addPendingRequest,\r\n login,\r\n loginDone,\r\n loginFail,\r\n logout,\r\n refreshMeta,\r\n refreshMetaDone,\r\n refreshMetaFail,\r\n removeNotifications,\r\n removePendingRequest,\r\n switchDebugMode\r\n} from '../actions'\r\nimport { ReducerBuilderManager } from './ReducerBuilderManager'\r\n\r\nexport const initialSessionState: Session = {\r\n devPanelEnabled: false,\r\n activeRole: null,\r\n roles: null,\r\n firstName: '',\r\n lastName: '',\r\n login: '',\r\n debugMode: false,\r\n exportStateEnabled: false,\r\n active: false,\r\n logout: false,\r\n loginSpin: false,\r\n errorMsg: null,\r\n screens: [],\r\n pendingRequests: [],\r\n notifications: [],\r\n isMetaRefreshing: false\r\n}\r\n\r\n/**\r\n * Session reducer\r\n *\r\n * Stores information about currently active session and dataEpics.ts that should be persistent during all period of\r\n * user interaction with application.\r\n */\r\nexport const createSessionReducerBuilderManager = <S extends Session>(initialState: S) =>\r\n new ReducerBuilderManager<S>()\r\n .addCase(login, state => {\r\n state.loginSpin = true\r\n state.errorMsg = null\r\n })\r\n .addCase(loginDone, (state, action) => {\r\n state = Object.assign(state, action.payload)\r\n state.loginSpin = false\r\n state.active = true\r\n state.logout = false\r\n })\r\n .addCase(loginFail, (state, action) => {\r\n state.loginSpin = false\r\n state.errorMsg = action.payload.errorMsg\r\n })\r\n .addCase(logout, state => {\r\n state.loginSpin = false\r\n state.active = false\r\n state.logout = true\r\n })\r\n .addCase(switchDebugMode, (state, action) => {\r\n state.debugMode = action.payload\r\n })\r\n .addCase(addPendingRequest, (state, action) => {\r\n state.pendingRequests?.push(action.payload.request)\r\n })\r\n .addCase(removePendingRequest, (state, action) => {\r\n state.pendingRequests = state.pendingRequests?.filter(item => item.requestId !== action.payload.requestId)\r\n })\r\n .addCase(addNotification, (state, action) => {\r\n state.notifications.push(action.payload)\r\n })\r\n .addCase(removeNotifications, (state, action) => {\r\n const closingKeys = action.payload\r\n state.notifications = state.notifications.filter(notification => !closingKeys.includes(notification.key))\r\n })\r\n .addCase(refreshMeta, state => {\r\n state.isMetaRefreshing = true\r\n })\r\n .addCase(refreshMetaDone, state => {\r\n state.isMetaRefreshing = false\r\n })\r\n .addCase(refreshMetaFail, state => {\r\n state.isMetaRefreshing = false\r\n })\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { OperationModalInvokeConfirm, OperationPostInvokeAny, OperationPostInvokeConfirmType, OperationPreInvoke } from '../../interfaces'\r\nimport { processPostInvoke, processPostInvokeConfirm, processPreInvoke } from '../../actions'\r\nimport { of } from 'rxjs'\r\nimport { AnyAction } from '@reduxjs/toolkit'\r\n\r\n/**\r\n * Returns an array of observables for handling post- and pre-invokes from any epics handling operations\r\n *\r\n * @param widgetName Name of the widget that initiated the operation\r\n * @param postInvoke Response post-invoke\r\n * @param preInvoke Response pre-invoke\r\n * @param operationType Which operation was performed\r\n * @param bcName\r\n * @category Utils\r\n */\r\nexport function postOperationRoutine(\r\n widgetName: string,\r\n postInvoke: OperationPostInvokeAny,\r\n preInvoke: OperationPreInvoke,\r\n operationType: string,\r\n bcName: string // TODO: Remove in 2.0.0\r\n) {\r\n const postInvokeConfirm = Object.values(OperationPostInvokeConfirmType).includes(postInvoke?.type as OperationPostInvokeConfirmType)\r\n const result: AnyAction[] = []\r\n if (postInvoke) {\r\n result.push(processPostInvoke({ bcName, postInvoke, widgetName }))\r\n }\r\n if (postInvokeConfirm) {\r\n result.push(\r\n processPostInvokeConfirm({\r\n bcName,\r\n operationType,\r\n widgetName,\r\n postInvokeConfirm: postInvoke as OperationModalInvokeConfirm\r\n })\r\n )\r\n }\r\n if (preInvoke) {\r\n result.push(\r\n processPreInvoke({\r\n bcName,\r\n operationType,\r\n widgetName,\r\n preInvoke\r\n })\r\n )\r\n }\r\n return result.map(item => of(item))\r\n}\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { CXBoxEpic, OperationError, OperationErrorEntity, OperationPostInvokeRefreshBc, OperationPostInvokeType } from '../../interfaces'\r\nimport {\r\n bcCancelPendingChanges,\r\n bcForceUpdate,\r\n changeLocation,\r\n sendOperation,\r\n sendOperationFail,\r\n sendOperationSuccess,\r\n setOperationFinished\r\n} from '../../actions'\r\nimport { catchError, concat, EMPTY, filter, mergeMap, of } from 'rxjs'\r\nimport { buildBcUrl, getFilters, getSorters, matchOperationRole } from '../../utils'\r\nimport { AxiosError } from 'axios'\r\n\r\nimport { postOperationRoutine } from '../utils/postOperationRoutine'\r\nimport { createApiErrorObservable } from '../../utils'\r\nimport { removeDisabledFields } from '../../utils/data'\r\n\r\n/**\r\n * Handle any `sendOperationEpic` action which is not part of built-in operations types\r\n *\r\n * Request will be send to `custom-action/${screenName}/${bcUrl}?_action=${action.payload.type}` endpoint,\r\n * with pending changes of the widget as requst body.\r\n *\r\n * Fires sendOperationSuccess, bcForceUpdate and postOperationRoutine\r\n */\r\nexport const sendOperationEpic: CXBoxEpic = (action$, state$, { api }) =>\r\n action$.pipe(\r\n filter(sendOperation.match),\r\n filter(action => matchOperationRole('none', action.payload, state$.value)),\r\n mergeMap(action => {\r\n const state = state$.value\r\n const screenName = state.screen.screenName\r\n const { bcName, operationType, widgetName } = action.payload\r\n // TODO: Remove conformOperation n 2.0.0\r\n const confirm = action.payload.confirmOperation?.type || action.payload.confirm\r\n const bcUrl = buildBcUrl(bcName, true, state)\r\n const bc = state.screen.bo.bc[bcName]\r\n const rowMeta = bcUrl && state.view.rowMeta[bcName]?.[bcUrl]\r\n const cursor = bc.cursor\r\n const record = state.data[bcName]?.find(item => item.id === bc.cursor)\r\n const filters = state.screen.filters[bcName]\r\n const sorters = state.screen.sorters[bcName]\r\n const pendingChanges = removeDisabledFields(state.view.pendingDataChanges[bcName]?.[bc.cursor], rowMeta)\r\n\r\n const data = record && { ...pendingChanges, vstamp: record.vstamp }\r\n const defaultSaveOperation =\r\n state.view.widgets?.find(item => item.name === widgetName)?.options?.actionGroups?.defaultSave ===\r\n action.payload.operationType && changeLocation.match(action.payload?.onSuccessAction?.type)\r\n const params: Record<string, string> = {\r\n _action: operationType,\r\n ...getFilters(filters),\r\n ...getSorters(sorters)\r\n }\r\n if (confirm) {\r\n params._confirm = confirm\r\n }\r\n const context = { widgetName: action.payload.widgetName }\r\n return api.customAction(screenName, bcUrl, data, context, params).pipe(\r\n mergeMap(response => {\r\n const postInvoke = response.postActions?.[0]\r\n const dataItem = response.record\r\n // TODO: Remove in 2.0.0 in favor of postInvokeConfirm (is this todo needed?)\r\n const preInvoke = response.preInvoke\r\n const postInvokeType = postInvoke?.type || ''\r\n const postInvokeRefreshCurrentBc =\r\n OperationPostInvokeType.refreshBC === postInvokeType && (postInvoke as OperationPostInvokeRefreshBc)?.bc === bcName\r\n const postInvokeTypesWithRefreshBc = (\r\n [OperationPostInvokeType.waitUntil, OperationPostInvokeType.drillDownAndWaitUntil] as string[]\r\n ).includes(postInvokeType)\r\n const withoutBcForceUpdate = postInvokeRefreshCurrentBc || postInvokeTypesWithRefreshBc\r\n\r\n // defaultSaveOperation mean that executed custom autosave and postAction will be ignored\r\n // drop pendingChanges and onSuccessAction execute instead\r\n return concat(\r\n of(setOperationFinished({ bcName, operationType })),\r\n defaultSaveOperation\r\n ? action?.payload?.onSuccessAction\r\n ? concat(of(bcCancelPendingChanges({ bcNames: [bcName] })), of(action.payload.onSuccessAction))\r\n : EMPTY\r\n : concat(\r\n of(sendOperationSuccess({ bcName, cursor, dataItem })),\r\n withoutBcForceUpdate ? EMPTY : of(bcForceUpdate({ bcName })),\r\n ...postOperationRoutine(widgetName, postInvoke, preInvoke, operationType, bcName)\r\n )\r\n )\r\n }),\r\n catchError((e: AxiosError) => {\r\n console.error(e)\r\n let viewError: string = null\r\n let entityError: OperationErrorEntity = null\r\n const operationError = e.response?.data as OperationError\r\n if (e.response?.data === Object(e.response?.data)) {\r\n entityError = operationError?.error?.entity\r\n viewError = operationError?.error?.popup?.[0]\r\n }\r\n return concat(\r\n of(setOperationFinished({ bcName, operationType })),\r\n of(sendOperationFail({ bcName, bcUrl, viewError, entityError })),\r\n createApiErrorObservable(e, context)\r\n )\r\n })\r\n )\r\n })\r\n )\r\n","import { BcDataResponse, BcMetaState, CXBoxEpic, OperationPostInvokeWaitUntil, Store } from '../../interfaces'\r\nimport {\r\n catchError,\r\n concat,\r\n delay,\r\n EMPTY,\r\n filter,\r\n map,\r\n mergeMap,\r\n Observable,\r\n of,\r\n switchMap,\r\n take,\r\n takeUntil,\r\n timeout,\r\n TimeoutError\r\n} from 'rxjs'\r\nimport { bcForceUpdate, closeViewPopup, showViewPopup, waitUntil, WaitUntilPopupOptions } from '../../actions'\r\nimport { buildBcUrl, createApiErrorObservable, getFilters, getSorters } from '../../utils'\r\nimport { DataItem } from '@cxbox-ui/schema'\r\nimport { Api } from '../../api'\r\nimport { StateObservable } from 'redux-observable'\r\n\r\nconst fetchDataRequest = <S extends Store, A extends Api>(bcName: string, state: S, api: A) => {\r\n const bc = state.screen.bo.bc[bcName]\r\n const limitBySelfCursor = state.router.bcPath?.includes(`${bcName}/${bc.cursor}`)\r\n const bcUrl = buildBcUrl(bcName, limitBySelfCursor, state)\r\n const fetchParams: Record<string, any> = {\r\n _page: bc.page ?? 1,\r\n _limit: bc.limit ?? 5,\r\n ...getFilters(state.screen.filters[bcName] || []),\r\n ...getSorters(state.screen.sorters[bcName])\r\n }\r\n\r\n return api.fetchBcData(state.screen.screenName, bcUrl, fetchParams)\r\n}\r\n\r\nconst successCondition = (data: DataItem[], fieldKey: string, valueForComparison: unknown) => {\r\n return data.some(dataItem => dataItem[fieldKey] === valueForComparison)\r\n}\r\n\r\nconst recursiveQueryWithRepeat = <S extends Store, A extends Api>(\r\n state: S,\r\n api: A,\r\n postInvoke: Omit<OperationPostInvokeWaitUntil, 'type'>,\r\n currentBcName: string\r\n): Observable<BcDataResponse> => {\r\n const { timeout: repeatTimeout = 5000, timeoutMaxRequests = 5 } = postInvoke\r\n const { successCondition_fieldKey, successCondition_value } = postInvoke\r\n const requestInterval = Math.floor(+repeatTimeout / +timeoutMaxRequests)\r\n\r\n return fetchDataRequest(currentBcName, state, api).pipe(\r\n mergeMap(response => {\r\n const data = response.data\r\n\r\n return successCondition(data, successCondition_fieldKey, successCondition_value)\r\n ? of(response)\r\n : of(null).pipe(\r\n delay(requestInterval),\r\n mergeMap(() => recursiveQueryWithRepeat(state, api, postInvoke, currentBcName))\r\n )\r\n }),\r\n timeout(+repeatTimeout)\r\n )\r\n}\r\n\r\nconst getBcHierarchyArr = (bcDictionary: Record<string, BcMetaState>, bcName: string): string[] => {\r\n const bcHierarchy: string[] = [bcName]\r\n let parentBcName = bcDictionary[bcName]?.parentName\r\n\r\n while (parentBcName) {\r\n bcHierarchy.push(parentBcName)\r\n\r\n parentBcName = bcDictionary[parentBcName]?.parentName\r\n }\r\n\r\n return bcHierarchy.reverse()\r\n}\r\n\r\nconst checkingReadinessForBuildBcUrl =\r\n (bcName: string) =>\r\n <S extends Store>(state: S) => {\r\n const bcDictionary = state.screen.bo.bc\r\n const bcNamesForChecking = getBcHierarchyArr(bcDictionary, bcName)\r\n\r\n return bcNamesForChecking.every(\r\n bcNameForChecking => bcDictionary[bcNameForChecking]?.loading === false && bcDictionary[bcNameForChecking]?.cursor\r\n )\r\n }\r\n\r\nconst getCheckedStateForBuildBcUrl = (state$: StateObservable<Store>, currentBcName: string) => {\r\n const currentState = state$.value\r\n\r\n return checkingReadinessForBuildBcUrl(currentBcName)(currentState)\r\n ? of(currentState)\r\n : state$.pipe(filter(checkingReadinessForBuildBcUrl(currentBcName)), take(1))\r\n}\r\n\r\nexport const waitUntilEpic: CXBoxEpic = (action$, state$, { api }) =>\r\n action$.pipe(\r\n filter(waitUntil.match),\r\n mergeMap(action => {\r\n const { bcName: actionBcName, postInvoke } = action.payload\r\n const { successCondition_bcName } = postInvoke\r\n const currentBcName = successCondition_bcName ?? actionBcName\r\n\r\n const switchPopup = (status: WaitUntilPopupOptions['status'], message?: string) => {\r\n const isProgressStatus = status === 'progress'\r\n const isFinalStatus = !isProgressStatus\r\n\r\n if (isProgressStatus || (isFinalStatus && message)) {\r\n return of(\r\n showViewPopup({\r\n type: 'waitUntil',\r\n bcName: actionBcName,\r\n calleeBCName: actionBcName,\r\n options: { status, message }\r\n })\r\n )\r\n }\r\n\r\n if (isFinalStatus && !message) {\r\n return of(closeViewPopup({ bcName: actionBcName }))\r\n }\r\n\r\n return EMPTY\r\n }\r\n\r\n const forceUpdate = (bcName: string) => {\r\n const currentBcIsExist = state$.value.screen.bo.bc[bcName]\r\n\r\n return currentBcIsExist ? of(bcForceUpdate({ bcName })) : EMPTY\r\n }\r\n\r\n const requestResult = getCheckedStateForBuildBcUrl(state$, currentBcName).pipe(\r\n switchMap(checkedState => {\r\n return recursiveQueryWithRepeat(checkedState, api, postInvoke, currentBcName).pipe(\r\n takeUntil(\r\n action$.pipe(\r\n filter(closeAction => {\r\n return closeViewPopup.match(closeAction)\r\n })\r\n )\r\n ),\r\n map(response => response.data),\r\n mergeMap(data => {\r\n return concat(forceUpdate(currentBcName), switchPopup('success', postInvoke.successMessage))\r\n }),\r\n catchError(error => {\r\n if (error instanceof TimeoutError) {\r\n return concat(forceUpdate(currentBcName), switchPopup('timeout', postInvoke.timeoutMessage))\r\n }\r\n\r\n return concat(of(closeViewPopup({ bcName: actionBcName })), createApiErrorObservable(error))\r\n })\r\n )\r\n })\r\n )\r\n\r\n return concat(switchPopup('progress', postInvoke.inProgressMessage), requestResult)\r\n })\r\n )\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { RouteType, CXBoxEpic } from '../../interfaces'\r\nimport { filter, of, switchMap } from 'rxjs'\r\nimport { changeLocation, handleRouter, loginDone } from '../../actions'\r\nimport { getRouteFromString } from '../../utils'\r\n\r\n/**\r\n * Fires `selectScreen` or `selectScreenFail` to set requested in url screen as active\r\n * after succesful login.\r\n *\r\n * For server-side router fires `handleRouter` instead.\r\n *\r\n */\r\nexport const loginDoneEpic: CXBoxEpic = (action$, state$) =>\r\n action$.pipe(\r\n filter(loginDone.match),\r\n switchMap(action => {\r\n const state = state$.value\r\n\r\n if (state.router.type === RouteType.router) {\r\n return of(handleRouter(state.router))\r\n }\r\n\r\n return of(\r\n changeLocation({\r\n location: getRouteFromString(action.payload.defaultUrl ?? window.location.hash.replace('#', '')),\r\n forceUpdate: true\r\n })\r\n )\r\n })\r\n )\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { ApplicationErrorType, CXBoxEpic } from '../../interfaces'\r\nimport { filter, map } from 'rxjs'\r\nimport { httpError, showViewError } from '../../actions'\r\n\r\nconst knownHttpErrors = [401, 409, 418, 500]\r\n\r\nexport const httpErrorDefaultEpic: CXBoxEpic = (action$, state$) =>\r\n action$.pipe(\r\n filter(httpError.match),\r\n filter(action => !knownHttpErrors.includes(action.payload.statusCode)),\r\n map(action => {\r\n const businessError = {\r\n type: ApplicationErrorType.BusinessError,\r\n code: action.payload.error.response?.status,\r\n details: action.payload.error.response?.data\r\n }\r\n return showViewError({ error: businessError })\r\n })\r\n )\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { CXBoxEpic } from '../../interfaces'\r\nimport { catchError, concat, filter, mergeMap, of, switchMap } from 'rxjs'\r\nimport { changeLocation, login, loginDone, loginFail } from '../../actions'\r\nimport { AxiosError } from 'axios'\r\nimport { defaultParseURL } from '../../utils'\r\nimport { createApiErrorObservable } from '../../utils/apiError'\r\nimport { getDefaultViewForPrimary } from '../../utils/getDefaultViewForPrimary'\r\nimport { getDefaultViewFromPrimaries } from '../../utils/getDefaultViewFromPrimaries'\r\n\r\nconst responseStatusMessages: Record<number, string> = {\r\n 401: 'Invalid credentials',\r\n 403: 'Access denied'\r\n}\r\n\r\n/**\r\n * Performed on role switching\r\n */\r\nexport const loginByAnotherRoleEpic: CXBoxEpic = (action$, state$, { api }) =>\r\n action$.pipe(\r\n filter(login.match),\r\n filter(action => !!action.payload?.role),\r\n switchMap(action => {\r\n /**\r\n * Default implementation of `loginByAnotherRoleEpic` epic\r\n *\r\n * Performs login request with `role` parameter\r\n *\r\n * If `role` changed, epic changes location to default view\r\n */\r\n\r\n const role = action.payload.role ?? ''\r\n const isSwitchRole = role && role !== state$.value.session.activeRole\r\n return api.loginByRoleRequest(role).pipe(\r\n mergeMap(data => {\r\n const result = []\r\n if (isSwitchRole) {\r\n const defaultScreen = data.screens.find(screen => screen.defaultScreen) || data.screens[0]\r\n const defaultView =\r\n getDefaultViewForPrimary(defaultScreen.primary, defaultScreen.meta.views) ??\r\n getDefaultViewFromPrimaries(defaultScreen.primaries, defaultScreen.meta.views) ??\r\n defaultScreen?.meta.views[0]\r\n\r\n if (defaultView)\r\n result.push(changeLocation({ location: defaultParseURL(new URL(defaultView.url, window.location.origin)) }))\r\n }\r\n\r\n return concat([\r\n ...result,\r\n loginDone({\r\n devPanelEnabled: data.devPanelEnabled,\r\n activeRole: data.activeRole,\r\n roles: data.roles,\r\n screens: data.screens,\r\n firstName: data.firstName,\r\n lastName: data.lastName,\r\n login: data.login\r\n })\r\n ])\r\n }),\r\n catchError((error: AxiosError) => {\r\n console.error(error)\r\n const errorMsg = error.response\r\n ? responseStatusMessages[error.response.status] || 'Server application unavailable'\r\n : 'Empty server response'\r\n return concat(of(loginFail({ errorMsg })), createApiErrorObservable(error))\r\n })\r\n )\r\n })\r\n )\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { filter, mergeMap, Observable, of, take } from 'rxjs'\r\nimport { logout, selectView } from '../actions'\r\nimport { AnyAction } from 'redux'\r\nimport { isAnyOf } from '@reduxjs/toolkit'\r\n\r\n/**\r\n * Type tweak for backward @reduxjs/toolkit compatibility\r\n */\r\ntype TypeGuard<T> = (value: any) => value is T\r\ninterface HasMatchFunction<T> {\r\n match: TypeGuard<T>\r\n}\r\n/** @public */\r\ntype Matcher<T> = HasMatchFunction<T> | TypeGuard<T>\r\n\r\nconst fullLoadViewMatcher = (action => {\r\n return selectView.match(action) && !(action as ReturnType<typeof selectView>).payload.isTab\r\n}) as Matcher<any>\r\n/**\r\n * Default list of action types which are triggers for request cancel\r\n */\r\nexport const cancelRequestActionTypes = [fullLoadViewMatcher, logout] as [Matcher<any>, ...Array<Matcher<any>>]\r\n\r\n/**\r\n * Creator of request cancel epic\r\n *\r\n * @param action$ an observable input\r\n * @param actionTypes list of action types which triggers cancel\r\n * @param cancelFn a callback of request cancelation\r\n * @param cancelActionCreator an action creator which called by request cancelation\r\n * @param filterFn a callback function which filters come actions\r\n */\r\nexport function cancelRequestEpic(\r\n action$: Observable<AnyAction>,\r\n actionTypes: Parameters<typeof isAnyOf>,\r\n cancelFn: (() => void) | undefined,\r\n cancelActionCreator: AnyAction,\r\n filterFn: (actions: AnyAction) => boolean = item => {\r\n return true\r\n }\r\n) {\r\n return action$.pipe(\r\n filter(isAnyOf(...actionTypes)),\r\n filter(filterFn),\r\n mergeMap(() => {\r\n cancelFn?.()\r\n return of(cancelActionCreator)\r\n }),\r\n take(1)\r\n )\r\n}\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { CXBoxEpic } from '../../interfaces'\r\nimport { catchError, concat, filter, mergeMap, of, race } from 'rxjs'\r\nimport { bcFetchDataFail, bcFetchDataSuccess, bcLoadMore } from '../../actions'\r\nimport { buildBcUrl, getFilters, getSorters } from '../../utils'\r\nimport { cancelRequestActionTypes, cancelRequestEpic } from '../../utils/cancelRequestEpic'\r\nimport { DataItem } from '@cxbox-ui/schema'\r\nimport { createApiErrorObservable } from '../../utils/apiError'\r\n\r\nexport const bcLoadMoreEpic: CXBoxEpic = (action$, state$, { api }) =>\r\n action$.pipe(\r\n filter(bcLoadMore.match),\r\n mergeMap(action => {\r\n const state = state$.value\r\n const bcName = action.payload.bcName\r\n const bc = state.screen.bo.bc[bcName]\r\n const { cursor, page } = bc\r\n const limit = state.view.widgets.find(i => i.bcName === bcName)?.limit || bc.limit\r\n const limitBySelfCursor = state.router.bcPath?.includes(`${bcName}/${cursor}`)\r\n const bcUrl = buildBcUrl(bcName, limitBySelfCursor, state)\r\n const filters = state.screen.filters[bcName] || []\r\n const sorters = state.screen.sorters[bcName]\r\n\r\n const fetchParams: Record<string, any> = {\r\n _page: page,\r\n _limit: limit,\r\n ...getFilters(filters),\r\n ...getSorters(sorters)\r\n }\r\n\r\n const canceler = api.createCanceler()\r\n const cancelFlow = cancelRequestEpic(action$, cancelRequestActionTypes, canceler.cancel, bcFetchDataFail({ bcName, bcUrl }))\r\n const normalFlow = api.fetchBcData(state.screen.screenName, bcUrl, fetchParams, canceler.cancelToken).pipe(\r\n mergeMap(data => {\r\n const oldBcDataIds = state.data[bcName]?.map(i => i.id)\r\n const newData = [...state.data[bcName], ...data.data.filter((i: DataItem) => !oldBcDataIds.includes(i.id))]\r\n return of(\r\n bcFetchDataSuccess({\r\n bcName,\r\n data: newData,\r\n bcUrl,\r\n hasNext: data.hasNext\r\n })\r\n )\r\n }),\r\n catchError((error: any) => {\r\n console.error(error)\r\n return concat(of(bcFetchDataFail({ bcName, bcUrl })), createApiErrorObservable(error))\r\n })\r\n )\r\n return race(cancelFlow, normalFlow)\r\n })\r\n )\r\n","import { Store } from '../interfaces'\r\n\r\nexport const selectBcNameFromPopupData = (state: Store): string | undefined => {\r\n const { bcName, widgetName } = state.view.popupData ?? {}\r\n\r\n if (bcName) {\r\n return bcName\r\n }\r\n\r\n if (widgetName) {\r\n return state.view.widgets.find(widget => widget.name === widgetName)?.bcName\r\n }\r\n\r\n return undefined\r\n}\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { catchError, concat, EMPTY, filter, mergeMap, of, race } from 'rxjs'\r\nimport { AnyAction } from 'redux'\r\nimport {\r\n buildBcUrl,\r\n checkShowCondition,\r\n getEagerBcChildren,\r\n getFilters,\r\n getSorters,\r\n getWidgetsForLazyLoad,\r\n isEagerWidget\r\n} from '../../utils'\r\nimport { cancelRequestActionTypes, cancelRequestEpic } from '../../utils/cancelRequestEpic'\r\nimport { DataItem, WidgetTypes } from '@cxbox-ui/schema'\r\nimport { BcMetaState, CXBoxEpic, EpicDependencyInjection, PopupData, PopupWidgetTypes, WidgetMeta } from '../../interfaces'\r\nimport { isAnyOf } from '@reduxjs/toolkit'\r\nimport {\r\n bcChangeCursors,\r\n bcChangePage,\r\n bcClearData,\r\n bcFetchDataFail,\r\n bcFetchDataPages,\r\n bcFetchDataRequest,\r\n bcFetchDataSuccess,\r\n bcFetchRowMeta,\r\n bcForceUpdate,\r\n bcSelectRecord,\r\n showViewPopup\r\n} from '../../actions'\r\nimport { createApiErrorObservable } from '../../utils/apiError'\r\n\r\n/**\r\n *\r\n *\r\n * Loads BC's dataEpics.ts.\r\n * In case successful download:\r\n * - dispatches action to store\r\n * - initializes rowMeta load\r\n * - initializes child BCs dataEpics.ts load\r\n *\r\n * action.payload.bcName BC's name for dataEpics.ts load\r\n *\r\n * @category Epics\r\n */\r\nexport const bcFetchDataEpic: CXBoxEpic = (action$, state$, { api, utils }) =>\r\n action$.pipe(\r\n filter(isAnyOf(bcFetchDataRequest, bcFetchDataPages, showViewPopup, bcForceUpdate, bcChangePage)),\r\n mergeMap(action => {\r\n const state = state$.value\r\n const { widgetName = '' } = action.payload\r\n const { widgets, infiniteWidgets } = state.view\r\n\r\n const widgetsWithCurrentBc = widgets?.filter(item => item.bcName === action.payload.bcName)\r\n /**\r\n * TODO: Widget name will be mandatory in 2.0.0 but until then collision-vulnerable fallback is provided\r\n * through business component match\r\n */\r\n const widget = widgets?.find(item => item.name === widgetName) ?? widgetsWithCurrentBc?.[0]\r\n /**\r\n * Missing widget means the view or screen were changed and dataEpics.ts request is no longer relevant\r\n */\r\n if (!widget) {\r\n return EMPTY\r\n }\r\n if (!action.payload.bcName) {\r\n console.warn(`No bc value found for refresh operation`)\r\n return EMPTY\r\n }\r\n const bcName = action.payload.bcName as string\r\n const bc = state.screen.bo.bc[bcName]\r\n const { cursor, page = 1 } = bc\r\n const limit = (widgets?.find(i => i.bcName === bcName)?.limit || bc.limit) ?? 5\r\n const sorters = state.screen.sorters[bcName]\r\n /**\r\n * If popup has the same bc as initiator no dataEpics.ts fetching required, it will be\r\n * handled by initiator widget instead\r\n */\r\n if (showViewPopup.match(action) && bcName === action.payload.calleeBCName) {\r\n return EMPTY\r\n }\r\n\r\n const anyHierarchyWidget = widgets?.find(item => {\r\n return item.bcName === widget.bcName && item.type === WidgetTypes.AssocListPopup && isHierarchyWidget(item)\r\n })\r\n const fullHierarchyWidget = state.view.widgets?.find(item => {\r\n return item.bcName === widget.bcName && item.type === WidgetTypes.AssocListPopup && item.options?.hierarchyFull\r\n })\r\n\r\n const limitBySelfCursor = state.router.bcPath?.includes(`${bcName}/${cursor}`)\r\n const bcUrl = buildBcUrl(bcName, limitBySelfCursor, state)\r\n\r\n // Hierarchy widgets has own filter implementation\r\n const fetchParams: Record<string, any> = {\r\n _page: page,\r\n _limit: limit,\r\n ...getFilters(fullHierarchyWidget ? [] : state.screen.filters[bcName] || []),\r\n ...getSorters(sorters)\r\n }\r\n\r\n if (bcForceUpdate.match(action)) {\r\n const infinityPaginationWidget =\r\n (widgetName && infiniteWidgets?.includes(widgetName)) ||\r\n widgets?.filter(item => item.bcName === bcName)?.find(item => infiniteWidgets?.includes(item.name))?.name\r\n if (infinityPaginationWidget) {\r\n fetchParams._page = 1\r\n fetchParams._limit = limit * page\r\n }\r\n }\r\n\r\n if (bcFetchDataPages.match(action)) {\r\n fetchParams._page = action.payload.from || 1\r\n fetchParams._limit = (action.payload.to || page - fetchParams._page) * limit\r\n }\r\n if ((bcFetchDataRequest.match(action) && action.payload.ignorePageLimit) || anyHierarchyWidget?.options?.hierarchyFull) {\r\n fetchParams._limit = 0\r\n }\r\n const canceler = api.createCanceler()\r\n const cancelFlow = cancelRequestEpic(action$, cancelRequestActionTypes, canceler.cancel, bcFetchDataFail({ bcName, bcUrl }))\r\n const cancelByParentBc = cancelRequestEpic(\r\n action$,\r\n [bcSelectRecord],\r\n canceler.cancel,\r\n bcFetchDataFail({ bcName, bcUrl }),\r\n filteredAction => {\r\n const actionBc = filteredAction.payload.bcName\r\n return bc.parentName === actionBc\r\n }\r\n )\r\n\r\n const normalFlow = api.fetchBcData(state.screen.screenName, bcUrl, fetchParams, canceler.cancelToken).pipe(\r\n mergeMap(response => {\r\n const cursorChange = getCursorChange(action, response.data, cursor, !!anyHierarchyWidget)\r\n const setDataSuccess = of(\r\n bcFetchDataSuccess({\r\n bcName,\r\n data: response.data,\r\n bcUrl,\r\n hasNext: response.hasNext\r\n })\r\n )\r\n const fetchRowMeta = of(bcFetchRowMeta({ widgetName, bcName }))\r\n\r\n const isWidgetVisible = (w: WidgetMeta) => {\r\n // check whether BC names from action payload, showCondition and current widget are relatives\r\n // if positive check skip `checkShowCondition` call\r\n if (w.showCondition?.bcName === state.screen.bo.bc[w.bcName]?.parentName) {\r\n let parentName = state.screen.bo.bc[w.showCondition?.bcName]?.parentName\r\n let parent = parentName === bcName\r\n while (!parent && parentName) {\r\n parentName = state.screen.bo.bc[parentName]?.parentName\r\n parent = parentName === bcName\r\n }\r\n if (parent) {\r\n return true\r\n }\r\n }\r\n const dataToCheck =\r\n bcName === w.showCondition?.bcName ? response.data : state.data[w.showCondition?.bcName as string]\r\n const currentCursor = dataToCheck\r\n ? getCurrentCursor(dataToCheck, state.screen.bo.bc[w.showCondition?.bcName as string]?.cursor).cursor\r\n : null\r\n return checkShowCondition(w.showCondition, currentCursor, dataToCheck, state.view.pendingDataChanges)\r\n }\r\n\r\n if (!widgetIsUsedOnView(bcName, widgets, state.screen.bo.bc, state.view.popupData, isWidgetVisible)) {\r\n return concat(cursorChange, setDataSuccess, fetchRowMeta)\r\n }\r\n const fetchChildren = response.data?.length\r\n ? getChildrenData(\r\n action,\r\n widgets,\r\n state.screen.bo.bc,\r\n !!anyHierarchyWidget,\r\n isWidgetVisible,\r\n utils?.getInternalWidgets\r\n )\r\n : EMPTY\r\n const resetOutdatedData = resetOutdatedChildrenData(bcName, state.screen.bo.bc, state.data)\r\n\r\n return concat(cursorChange, resetOutdatedData, setDataSuccess, fetchRowMeta, fetchChildren)\r\n }),\r\n catchError((error: any) => {\r\n console.error(error)\r\n return concat(of(bcFetchDataFail({ bcName: action.payload.bcName as string, bcUrl })), createApiErrorObservable(error))\r\n })\r\n )\r\n\r\n return race(cancelFlow, cancelByParentBc, normalFlow)\r\n })\r\n )\r\n\r\n/**\r\n * Determines if the argument is hierarchy widget\r\n *\r\n * TODO: Should be typeguard when hierarchy widgets will have actual distinct interfaces\r\n *\r\n * @param widget Widget to check\r\n * @returns `true` if widget option `hierarchy` or `hierarchyFull` is set; `else` otherwise\r\n */\r\nfunction isHierarchyWidget(widget: WidgetMeta) {\r\n return widget.options?.hierarchy || widget.options?.hierarchyFull\r\n}\r\n\r\nconst getCurrentCursor = (data: DataItem[], prevCursor: string | undefined) => {\r\n const newCursor = data[0]?.id\r\n const updatedCursor = !prevCursor || !data?.some(i => i.id === prevCursor)\r\n\r\n return {\r\n cursor: updatedCursor ? newCursor : prevCursor,\r\n updatedCursor\r\n }\r\n}\r\n\r\nconst getCursorChange = (action: AnyAction, data: DataItem[], prevCursor: string, isHierarchy: boolean) => {\r\n const { bcName } = action.payload\r\n const keepDelta = bcFetchDataRequest.match(action) ? action.payload.keepDelta : undefined\r\n const { cursor, updatedCursor } = getCurrentCursor(data, prevCursor)\r\n return updatedCursor\r\n ? of(\r\n bcChangeCursors({\r\n cursorsMap: {\r\n [bcName as string]: cursor\r\n },\r\n keepDelta: isHierarchy || keepDelta\r\n })\r\n )\r\n : EMPTY\r\n}\r\n\r\nconst isPopupWidget = (type: string) => PopupWidgetTypes.includes(type)\r\n\r\nconst getChildrenData = (\r\n action: AnyAction,\r\n widgets: WidgetMeta[],\r\n bcDictionary: Record<string, BcMetaState>,\r\n isHierarchy: boolean,\r\n showConditionCheck: (widget: WidgetMeta) => boolean,\r\n getInternalWidgets: EpicDependencyInjection['utils']['getInternalWidgets']\r\n) => {\r\n const { bcName, widgetName } = action.payload\r\n\r\n const lazyWidgetNames = getWidgetsForLazyLoad(\r\n widgets,\r\n getInternalWidgets,\r\n showViewPopup.match(action) ? bcName ?? widgets.find(widget => widget.name === widgetName)?.bcName : undefined\r\n )\r\n const eagerChildren = getEagerBcChildren(bcName as string, widgets, bcDictionary, lazyWidgetNames, showConditionCheck)\r\n\r\n return concat(\r\n ...Object.entries(eagerChildren).map(([childBcName, widgetNames]) => {\r\n const nonLazyWidget = widgets.find(item => {\r\n return widgetNames.includes(item.name) && isEagerWidget(item, lazyWidgetNames, showConditionCheck)\r\n })\r\n\r\n return of(\r\n bcFetchDataRequest({\r\n bcName: childBcName,\r\n widgetName: nonLazyWidget?.name ?? widgetNames[0],\r\n ignorePageLimit: action.payload?.ignorePageLimit || showViewPopup.match(action),\r\n keepDelta: isHierarchy || action.payload?.keepDelta\r\n })\r\n )\r\n })\r\n )\r\n}\r\n\r\nconst resetOutdatedChildrenData = (bcName: string, bcDictionary: Record<string, BcMetaState>, data: Record<string, DataItem[]>) => {\r\n const parentBcNames = [bcName]\r\n const parentsBcUrls = parentBcNames.map(parentBcName => `${bcDictionary[parentBcName].url}/:id`)\r\n const childBcNamesWithData = Object.keys(data).reduce<string[]>((acc, bcNameWithData) => {\r\n const bc = bcDictionary[bcNameWithData]\r\n if (parentsBcUrls.some(item => bc.url.includes(item))) {\r\n acc.push(bc.name)\r\n }\r\n\r\n return acc\r\n }, [])\r\n\r\n return childBcNamesWithData.length\r\n ? of(\r\n bcClearData({\r\n bcNames: childBcNamesWithData\r\n })\r\n )\r\n : EMPTY\r\n}\r\n\r\n/**\r\n * Checks if there is at least one visible widget with originBc or any child bc to it.\r\n * The check takes into account the visibility of popup widgets.\r\n */\r\nfunction widgetIsUsedOnView(\r\n originBcName: string,\r\n widgets: WidgetMeta[],\r\n bcDictionary: Record<string, BcMetaState>,\r\n popupData: PopupData,\r\n showConditionCheck: (widget: WidgetMeta) => boolean\r\n) {\r\n const bcWidgetsMap = widgets.reduce<Record<string, WidgetMeta[]>>((acc, widget) => {\r\n if (!widget.bcName) return acc\r\n\r\n if (!Array.isArray(acc[widget.bcName])) {\r\n acc[widget.bcName] = []\r\n }\r\n\r\n acc[widget.bcName].push(widget)\r\n\r\n return acc\r\n }, {})\r\n const bcListOnCurrentView = Object.keys(bcWidgetsMap)\r\n const originBcIsOnCurrentView = bcListOnCurrentView.includes(originBcName)\r\n\r\n const leastOneWidgetIsVisible = (currentBcName: string) =>\r\n !!bcWidgetsMap[currentBcName]?.some(widget => {\r\n const isVisiblePopup = popupData?.bcName === widget.bcName\r\n\r\n return (showConditionCheck(widget) && !isPopupWidget(widget.type)) || isVisiblePopup\r\n })\r\n\r\n const bcIsUsedInShowCondition = (currentBcName: string) =>\r\n !!bcWidgetsMap[currentBcName]?.some(widget => {\r\n return widget.showCondition.bcName === originBcName\r\n })\r\n\r\n if ((originBcIsOnCurrentView && leastOneWidgetIsVisible(originBcName)) || bcIsUsedInShowCondition(originBcName)) {\r\n return true\r\n }\r\n\r\n const isChildBcForOriginBc = (bcName: string) => {\r\n const partUrlOfChildBc = `${bcDictionary[originBcName].url}/:id`\r\n return bcDictionary[bcName].url.includes(partUrlOfChildBc)\r\n }\r\n\r\n return bcListOnCurrentView.some(bcName => {\r\n return isChildBcForOriginBc(bcName) ? leastOneWidgetIsVisible(bcName) || bcIsUsedInShowCondition(originBcName) : false\r\n })\r\n}\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { CXBoxEpic, PendingValidationFailsFormat } from '../../interfaces'\r\nimport { catchError, concat, EMPTY, filter, mergeMap, of } from 'rxjs'\r\nimport {\r\n bcCancelPendingChanges,\r\n bcDeleteDataFail,\r\n bcFetchDataRequest,\r\n processPostInvoke,\r\n sendOperation,\r\n setOperationFinished\r\n} from '../../actions'\r\nimport { buildBcUrl, matchOperationRole } from '../../utils'\r\nimport { OperationTypeCrud } from '@cxbox-ui/schema'\r\nimport { createApiErrorObservable } from '../../utils/apiError'\r\n\r\nexport const bcDeleteDataEpic: CXBoxEpic = (action$, store$, { api }) =>\r\n action$.pipe(\r\n filter(sendOperation.match),\r\n filter(action => matchOperationRole(OperationTypeCrud.delete, action.payload, store$.value)),\r\n mergeMap(action => {\r\n const widgetName = action.payload.widgetName\r\n const state = store$.value\r\n const bcName = action.payload.bcName\r\n const cursor = state.screen.bo.bc[bcName].cursor\r\n const bcUrl = buildBcUrl(bcName, true, state)\r\n const context = { widgetName: action.payload.widgetName }\r\n const isTargetFormatPVF = state.view.pendingValidationFailsFormat === PendingValidationFailsFormat.target\r\n return api.deleteBcData(state.screen.screenName, bcUrl, context).pipe(\r\n mergeMap(data => {\r\n const postInvoke = data.postActions?.[0]\r\n return concat(\r\n of(setOperationFinished({ bcName, operationType: OperationTypeCrud.delete })),\r\n isTargetFormatPVF ? of(bcCancelPendingChanges({ bcNames: [bcName] })) : EMPTY,\r\n of(bcFetchDataRequest({ bcName, widgetName })),\r\n postInvoke ? of(processPostInvoke({ bcName, postInvoke, cursor, widgetName })) : EMPTY\r\n )\r\n }),\r\n catchError((error: any) => {\r\n console.error(error)\r\n return concat(\r\n of(setOperationFinished({ bcName, operationType: OperationTypeCrud.delete })),\r\n of(bcDeleteDataFail({ bcName })),\r\n createApiErrorObservable(error, context)\r\n )\r\n })\r\n )\r\n })\r\n )\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { catchError, concat, EMPTY, filter, mergeMap, of } from 'rxjs'\r\nimport { buildBcUrl, matchOperationRole } from '../../utils'\r\nimport { OperationTypeCrud } from '@cxbox-ui/schema'\r\nimport {\r\n bcChangeCursors,\r\n bcDeleteDataFail,\r\n processPostInvoke,\r\n sendOperation,\r\n sendOperationSuccess,\r\n setOperationFinished\r\n} from '../../actions'\r\nimport { CXBoxEpic } from '../../interfaces'\r\nimport { isAnyOf } from '@reduxjs/toolkit'\r\nimport { createApiErrorObservable } from '../../utils/apiError'\r\n\r\nconst actionTypesMatcher = isAnyOf(sendOperation)\r\n\r\n/**\r\n * Sends `cancel-create` custom operation with record's pending changes and vstamp;\r\n * Dispatches `sendOperationSuccess` and `bcChangeCursors` to drop cursors, also\r\n * `processPostInvokeEpic` if received `postActions` in response.\r\n *\r\n * @category Epics\r\n */\r\n\r\nexport const bcCancelCreateDataEpic: CXBoxEpic = (action$, state$, { api }) =>\r\n action$.pipe(\r\n filter(actionTypesMatcher),\r\n filter(action => matchOperationRole(OperationTypeCrud.cancelCreate, action.payload, state$.value)),\r\n mergeMap(action => {\r\n /**\r\n * Default implementation for `bcCancelCreateDataEpic` epic\r\n *\r\n * Sends `cancel-create` custom operation with record's pending changes and vstamp;\r\n * Dispatches `sendOperationSuccess` and `bcChangeCursors` to drop cursors, also\r\n * `processPostInvokeEpic` if received `postActions` in response.\r\n *\r\n * On error dispatches `bcDeleteDataFail`.\r\n */\r\n const state = state$.value\r\n const screenName = state.screen.screenName\r\n const bcName = action.payload.bcName\r\n const bcUrl = buildBcUrl(bcName, true, state)\r\n const bc = state.screen.bo.bc[bcName]\r\n const cursor = bc?.cursor\r\n const context = { widgetName: action.payload.widgetName }\r\n const record = state.data[bcName]?.find(item => item.id === bc.cursor)\r\n const pendingRecordChange = state.view.pendingDataChanges[bcName]?.[bc.cursor as string]\r\n const data = record && { ...pendingRecordChange, vstamp: record.vstamp }\r\n const params = { _action: action.payload.operationType }\r\n const cursorsMap: Record<string, string> = { [action.payload.bcName]: null }\r\n return api.customAction(screenName, bcUrl as string, data, context, params).pipe(\r\n mergeMap(response => {\r\n const postInvoke = response.postActions?.[0]\r\n return concat(\r\n of(setOperationFinished({ bcName, operationType: OperationTypeCrud.cancelCreate })),\r\n of(sendOperationSuccess({ bcName, cursor })),\r\n of(bcChangeCursors({ cursorsMap })),\r\n postInvoke ? of(processPostInvoke({ bcName, postInvoke, cursor, widgetName: context.widgetName })) : EMPTY\r\n )\r\n }),\r\n catchError((error: any) => {\r\n console.error(error)\r\n return concat(\r\n of(setOperationFinished({ bcName, operationType: OperationTypeCrud.cancelCreate })),\r\n of(bcDeleteDataFail({ bcName })),\r\n createApiErrorObservable(error, context)\r\n )\r\n })\r\n )\r\n })\r\n )\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport axios from 'axios'\r\nimport { ApplicationErrorType, CXBoxEpic } from '../../interfaces'\r\nimport { EMPTY, filter, mergeMap, of } from 'rxjs'\r\nimport { apiError, httpError, showViewError } from '../../actions'\r\n\r\nexport const apiErrorEpic: CXBoxEpic = action$ =>\r\n action$.pipe(\r\n filter(apiError.match),\r\n mergeMap(action => {\r\n const { error, callContext } = action.payload\r\n if (error.response) {\r\n return of(\r\n httpError({\r\n statusCode: error.response.status,\r\n error,\r\n callContext\r\n })\r\n )\r\n } else if (!axios.isCancel(error)) {\r\n return of(\r\n showViewError({\r\n error: {\r\n type: ApplicationErrorType.NetworkError\r\n }\r\n })\r\n )\r\n }\r\n return EMPTY\r\n })\r\n )\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { catchError, concat, filter, map, mergeMap, of, race } from 'rxjs'\r\nimport { buildBcUrl } from '../../utils'\r\nimport { cancelRequestActionTypes, cancelRequestEpic } from '../../utils/cancelRequestEpic'\r\nimport { CXBoxEpic } from '../../interfaces'\r\nimport { bcFetchRowMeta, bcFetchRowMetaFail, bcFetchRowMetaSuccess, bcSelectRecord } from '../../actions'\r\nimport { createApiErrorObservable } from '../../utils/apiError'\r\n\r\n/**\r\n * Access `row-meta` API endpoint for business component; response will contain information\r\n * about operations available for row and additional information about row fields.\r\n *\r\n * On success, {@link ActionPayloadTypes.bcFetchRowMetaSuccess | bcFetchRowMetaSuccess} action dispatched\r\n * to store received row meta.\r\n * On failure, console.error called and {@link ActionPayloadTypes.bcFetchRowMetaFail | bcFetchRowMetaFail} action\r\n * dispatched to drop fetching state.\r\n *\r\n * If any action from `cancelRequestActionTypes` array dispatched while this epic is in progress,\r\n * this epic will be cancelled and {@link ActionPayloadTypes.bcFetchRowMetaFail | bcFetchRowMetaFail} action\r\n * will be dispatched.\r\n *\r\n * @category Epics\r\n */\r\nexport const bcFetchRowMetaRequestEpic: CXBoxEpic = (action$, state$, { api }) =>\r\n action$.pipe(\r\n filter(bcFetchRowMeta.match),\r\n mergeMap(action => {\r\n /**\r\n * Default implementation for `bcFetchRowMetaRequest` epic\r\n *\r\n * Access `row-meta` API endpoint for business component; response will contain information\r\n * about operations available for row and additional information about row fields.\r\n *\r\n * On success, {@link ActionPayloadTypes.bcFetchRowMetaSuccess | bcFetchRowMetaSuccess} action dispatched\r\n * to store received row meta.\r\n * On failure, console.error called and {@link ActionPayloadTypes.bcFetchRowMetaFail | bcFetchRowMetaFail} action\r\n * dispatched to drop fetching state.\r\n *\r\n * If any action from `cancelRequestActionTypes` array dispatched while this epic is in progress,\r\n * this epic will be cancelled and {@link ActionPayloadTypes.bcFetchRowMetaFail | bcFetchRowMetaFail} action\r\n * will be dispatched.\r\n */\r\n\r\n const state = state$.value\r\n const screenName = state.screen.screenName\r\n const bcName = action.payload.bcName\r\n const cursor = state.screen.bo.bc[bcName].cursor ?? ''\r\n const bcUrl = buildBcUrl(bcName, true, state) ?? ''\r\n const canceler = api.createCanceler()\r\n const cancelFlow = cancelRequestEpic(action$, cancelRequestActionTypes, canceler.cancel, bcFetchRowMetaFail({ bcName }))\r\n const cancelByParentBc = cancelRequestEpic(\r\n action$,\r\n [bcSelectRecord],\r\n canceler.cancel,\r\n bcFetchRowMetaFail({ bcName }),\r\n filteredAction => {\r\n const actionBc = filteredAction.payload.bcName\r\n return state.screen.bo.bc[bcName].parentName === actionBc\r\n }\r\n )\r\n const normalFlow = api.fetchRowMeta(screenName, bcUrl, undefined, canceler.cancelToken).pipe(\r\n map(rowMeta => {\r\n return bcFetchRowMetaSuccess({ bcName, rowMeta, bcUrl, cursor })\r\n }),\r\n catchError(error => {\r\n console.error(error)\r\n return concat(of(bcFetchRowMetaFail({ bcName })), createApiErrorObservable(error))\r\n })\r\n )\r\n\r\n return race(cancelFlow, cancelByParentBc, normalFlow)\r\n })\r\n )\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { catchError, concat, EMPTY, filter, mergeMap, of } from 'rxjs'\r\nimport { buildBcUrl, matchOperationRole } from '../../utils'\r\nimport { DataItem, OperationTypeCrud } from '@cxbox-ui/schema'\r\nimport { CXBoxEpic } from '../../interfaces'\r\nimport {\r\n bcFetchRowMetaSuccess,\r\n bcNewDataFail,\r\n bcNewDataSuccess,\r\n changeDataItem,\r\n processPostInvoke,\r\n selectTableRow,\r\n sendOperation,\r\n setOperationFinished\r\n} from '../../actions'\r\nimport { createApiErrorObservable } from '../../utils/apiError'\r\n\r\n/**\r\n * Access `row-meta-new` API endpoint for business component endpoint; response will contain\r\n * row meta where `currentValue` of `id` field will contain an id for newly created record.\r\n *\r\n * `bcNewDataSuccess` action dispatched with new dataEpics.ts item draft (vstamp = -1).\r\n * `bcFetchRowMetaSuccess` action dispatched to set BC cursor to this new id.\r\n * `changeDataItem` action dispatched to add this new item to pending changes.\r\n * `processPostInvokeEpic` dispatched to handle possible post invokes.\r\n *\r\n * In case of an error message is logged as warning and `bcNewDataFail` action dispatched.\r\n *\r\n */\r\nexport const bcNewDataEpic: CXBoxEpic = (action$, state$, { api }) =>\r\n action$.pipe(\r\n filter(sendOperation.match),\r\n filter(action => matchOperationRole(OperationTypeCrud.create, action.payload, state$.value)),\r\n mergeMap(action => {\r\n /**\r\n * Default implementation for `bcNewDataEpic` epic\r\n *\r\n * Access `row-meta-new` API endpoint for business component endpoint; response will contain\r\n * row meta where `currentValue` of `id` field will contain an id for newly created record.\r\n *\r\n * `bcNewDataSuccess` action dispatched with new dataEpics.ts item draft (vstamp = -1).\r\n * `bcFetchRowMetaSuccess` action dispatched to set BC cursor to this new id.\r\n * `changeDataItem` action dispatched to add this new item to pending changes.\r\n * `processPostInvokeEpic` dispatched to handle possible post invokes.\r\n *\r\n * In case of an error message is logged as warning and `bcNewDataFail` action dispatched.\r\n *\r\n */\r\n const state = state$.value\r\n const bcName = action.payload.bcName\r\n const bcUrl = buildBcUrl(bcName, false, state) ?? ''\r\n const context = { widgetName: action.payload.widgetName }\r\n const params = { _action: action.payload.operationType }\r\n return api.newBcData(state.screen.screenName, bcUrl, context, params).pipe(\r\n mergeMap(data => {\r\n const rowMeta = data.row\r\n const dataItem: DataItem = { id: null as any, vstamp: -1 }\r\n data.row.fields.forEach(field => {\r\n dataItem[field.key] = field.currentValue\r\n })\r\n const postInvoke = data.postActions?.[0]\r\n const cursor = dataItem.id\r\n return concat(\r\n of(setOperationFinished({ bcName, operationType: OperationTypeCrud.create })),\r\n of(bcNewDataSuccess({ bcName, dataItem, bcUrl })),\r\n of(bcFetchRowMetaSuccess({ bcName, bcUrl: `${bcUrl}/${cursor}`, rowMeta, cursor })),\r\n of(\r\n changeDataItem({\r\n bcName,\r\n bcUrl: buildBcUrl(bcName, true, state) ?? '',\r\n cursor: cursor,\r\n dataItem: {\r\n id: cursor\r\n }\r\n })\r\n ),\r\n of(selectTableRow({ widgetName: action.payload.widgetName, rowId: cursor })),\r\n postInvoke ? of(processPostInvoke({ bcName, postInvoke, cursor, widgetName: action.payload.widgetName })) : EMPTY\r\n )\r\n }),\r\n catchError((error: any) => {\r\n console.error(error)\r\n return concat(\r\n of(setOperationFinished({ bcName, operationType: OperationTypeCrud.create })),\r\n of(bcNewDataFail({ bcName })),\r\n createApiErrorObservable(error, context)\r\n )\r\n })\r\n )\r\n })\r\n )\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { OperationError, OperationErrorEntity, OperationTypeCrud } from '../../interfaces'\r\nimport { buildBcUrl, getEagerBcChildren, getWidgetsForLazyLoad, matchOperationRole } from '../../utils'\r\nimport { catchError, concat, EMPTY, filter, mergeMap, Observable, of } from 'rxjs'\r\nimport { CXBoxEpic } from '../../interfaces'\r\nimport {\r\n addNotification,\r\n bcCancelPendingChanges,\r\n bcFetchDataRequest,\r\n bcFetchRowMeta,\r\n bcSaveDataFail,\r\n bcSaveDataSuccess,\r\n deselectTableRow,\r\n processPostInvoke,\r\n sendOperation,\r\n setOperationFinished\r\n} from '../../actions'\r\nimport { AxiosError } from 'axios'\r\nimport { AnyAction } from '@reduxjs/toolkit'\r\nimport { createApiErrorObservable } from '../../utils/apiError'\r\nimport { removeDisabledFields } from '../../utils/data'\r\nimport { selectBcNameFromPopupData } from '../../selectors/selectors'\r\n\r\n/**\r\n * Post record's pending changes to `save dataEpics.ts` API endpoint.\r\n * Pending changes for fields disabled through row meta are not send; please notice that fields are\r\n * disabled by default.\r\n *\r\n * On success following actions are dispatched:\r\n * - {@link bcSaveDataSuccess}\r\n * - {@link bcFetchRowMeta}\r\n * - one {@link bcFetchDataRequest} for each child of saved business component\r\n * - optional {@link ActionPayloadTypes.processPostInvokeEpic | processPostInvokeEpic } if present in response\r\n * - optional `onSuccessAction` callback if provided in payload.\r\n *\r\n * On failure, console\\.error called and {@link ActionPayloadTypes.bcSaveDataFail | bcSaveDataFail} action\r\n * dispatched.\r\n *\r\n * If there was a `onSuccessAction` callback provided in action payload (and widget option\r\n * {@link WidgetOptions.disableNotification} was not set)\r\n * then a notification will be shown on failure with suggestion to cancel pending changes and a button that fires\r\n * {@link bcCancelPendingChanges}\r\n *\r\n * @category Epics\r\n */\r\n\r\nexport const bcSaveDataEpic: CXBoxEpic = (action$, state$, { api, utils }) =>\r\n action$.pipe(\r\n filter(sendOperation.match),\r\n filter(action => matchOperationRole(OperationTypeCrud.save, action.payload, state$.value)),\r\n mergeMap(action => {\r\n /**\r\n * Default implementation for `bcSaveData` epic\r\n *\r\n * Post record's pending changes to `save dataEpics.ts` API endpoint.\r\n * Pending changes for fields disabled through row meta are not send; pleace notice that fields are\r\n * disabled by default.\r\n *\r\n * On success following actions are dispatched:\r\n * - {@link ActionPayloadTypes.bcSaveDataSuccess | bcSaveDataSuccess}\r\n * - {@link ActionPayloadTypes.bcFetchRowMeta | bcFetchRowMeta}\r\n * - one {@link ActionPayloadTypes.bcFetchDataRequest | bcFetchDataRequest } for each children of saved\r\n * business component\r\n * - optional {@link ActionPayloadTypes.processPostInvokeEpic | processPostInvokeEpic } if present in response\r\n * - optional `onSuccessAction` callback if provided in payload.\r\n *\r\n * On failure, console\\.error called and {@link ActionPayloadTypes.bcSaveDataFail | bcSaveDataFail} action\r\n * dispatched.\r\n *\r\n * If there was a `onSuccessAction` callback provided in action payload (and widget option\r\n * {@link WidgetOptions.disableNotification | disableNotification } was not set)\r\n * then a notification will be shown on failure with suggestion to cancel pending changes and a button that fires\r\n * {@link ActionPayloadTypes.bcCancelPendingChanges | bcCancelPendingChanges}\r\n */\r\n const state = state$.value\r\n const bcName = action.payload.bcName\r\n const bcUrl = buildBcUrl(bcName, true, state) ?? ''\r\n const widgetName = action.payload.widgetName\r\n const cursor = state.screen.bo.bc[bcName].cursor as string\r\n const dataItem = state.data[bcName].find(item => item.id === cursor)\r\n const rowMeta = bcUrl && state.view.rowMeta[bcName]?.[bcUrl]\r\n const options = state.view.widgets.find(widget => widget.name === widgetName)?.options\r\n\r\n const pendingChanges = removeDisabledFields(state.view.pendingDataChanges[bcName]?.[cursor], rowMeta)\r\n\r\n const lazyWidgetNames = getWidgetsForLazyLoad(state.view.widgets, utils?.getInternalWidgets, selectBcNameFromPopupData(state))\r\n const fetchChildrenBcData = Object.entries(\r\n getEagerBcChildren(bcName, state.view.widgets, state.screen.bo.bc, lazyWidgetNames)\r\n ).map(entry => {\r\n const [childBcName, widgetNames] = entry\r\n return bcFetchDataRequest({ bcName: childBcName, widgetName: widgetNames[0] })\r\n })\r\n\r\n const context = { widgetName: action.payload.widgetName }\r\n return api.saveBcData(state.screen.screenName, bcUrl, { ...pendingChanges, vstamp: dataItem?.vstamp as number }, context).pipe(\r\n mergeMap(data => {\r\n const postInvoke = data.postActions?.[0]\r\n const responseDataItem = data.record\r\n return concat(\r\n of(setOperationFinished({ bcName, operationType: OperationTypeCrud.save })),\r\n of(bcSaveDataSuccess({ bcName, cursor, dataItem: responseDataItem })),\r\n of(bcFetchRowMeta({ widgetName, bcName })),\r\n of(deselectTableRow()),\r\n of(...fetchChildrenBcData),\r\n postInvoke\r\n ? of(\r\n processPostInvoke({\r\n bcName,\r\n widgetName,\r\n postInvoke,\r\n cursor: responseDataItem.id\r\n })\r\n )\r\n : EMPTY,\r\n action.payload.onSuccessAction ? of(action.payload.onSuccessAction) : EMPTY\r\n )\r\n }),\r\n catchError((e: AxiosError) => {\r\n console.error(e)\r\n let notification$: Observable<AnyAction> = EMPTY\r\n // Protection against widget blocking while autosaving\r\n if (action.payload.onSuccessAction && !options?.disableNotification) {\r\n notification$ = of(\r\n addNotification({\r\n key: 'data_autosave_undo',\r\n type: 'buttonWarningNotification',\r\n message: 'There are pending changes. Please save them or cancel.',\r\n duration: 0,\r\n options: {\r\n buttonWarningNotificationOptions: {\r\n buttonText: 'Cancel changes',\r\n actionsForClick: [bcCancelPendingChanges({ bcNames: [bcName] })]\r\n }\r\n }\r\n })\r\n )\r\n }\r\n let viewError: string = null as any\r\n let entityError: OperationErrorEntity = null as any\r\n const operationError = e.response?.data as OperationError\r\n if (e.response?.data === Object(e.response?.data)) {\r\n entityError = operationError?.error?.entity ?? entityError\r\n viewError = operationError?.error?.popup?.[0] ?? viewError\r\n }\r\n\r\n return concat(\r\n of(setOperationFinished({ bcName, operationType: OperationTypeCrud.save })),\r\n of(bcSaveDataFail({ bcName, bcUrl, viewError, entityError })),\r\n notification$,\r\n createApiErrorObservable(e, context)\r\n )\r\n })\r\n )\r\n })\r\n )\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { concat, filter, mergeMap, of } from 'rxjs'\r\nimport { CXBoxEpic } from '../../interfaces'\r\nimport { bcChangeDepthCursor, bcFetchDataRequest, bcSelectDepthRecord } from '../../actions'\r\n\r\nexport const bcSelectDepthRecordEpic: CXBoxEpic = action$ =>\r\n action$.pipe(\r\n filter(bcSelectDepthRecord.match),\r\n mergeMap(action => {\r\n /**\r\n * Set a cursor when expanding a record in hierarchy widgets builded around single business components\r\n * and fetch the dataEpics.ts for children of expanded record.\r\n *\r\n * {@link ActionPayloadTypes.bcChangeDepthCursor | bcChangeDepthCursor} action is dispatched to set the cursor\r\n * for expanded record; only one expanded record is allowed per hierarchy depth level.\r\n *\r\n * {@link ActionPayloadTypes.bcFetchDataRequest | bcFetchDataRequest} action is dispatched to fetch children dataEpics.ts\r\n * for expanded record. `ignorePageLimit`` is set as there are no controls for navigating between dataEpics.ts pages\r\n * in nested levels of hierarchy so instead all records are fetched.\r\n *\r\n * TODO: There is no apparent reason why `widgetName` is empty; probably will be mandatory and replace `bcName` in 2.0.0.\r\n *\r\n * @deprecated Do not use; TODO: Will be removed in 2.0.0\r\n */\r\n const { bcName, cursor, depth } = action.payload\r\n return concat(\r\n of(bcChangeDepthCursor({ bcName, depth, cursor })),\r\n of(\r\n bcFetchDataRequest({\r\n bcName,\r\n depth: depth + 1,\r\n widgetName: '',\r\n ignorePageLimit: true\r\n })\r\n )\r\n )\r\n })\r\n )\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { CXBoxEpic } from '../../interfaces'\r\nimport { concat, filter, mergeMap, of } from 'rxjs'\r\nimport { bcChangeCursors, bcFetchDataRequest, bcFetchRowMeta, bcSelectRecord } from '../../actions'\r\nimport { getEagerBcChildren, getWidgetsForLazyLoad } from '../../utils'\r\nimport { selectBcNameFromPopupData } from '../../selectors/selectors'\r\n\r\nexport const bcSelectRecordEpic: CXBoxEpic = (action$, state$, { utils }) =>\r\n action$.pipe(\r\n filter(bcSelectRecord.match),\r\n mergeMap(action => {\r\n const { bcName, cursor } = action.payload\r\n const widgets = state$.value.view.widgets\r\n const bcMap = state$.value.screen.bo.bc\r\n const lazyWidgetNames = getWidgetsForLazyLoad(\r\n state$.value.view.widgets,\r\n utils?.getInternalWidgets,\r\n selectBcNameFromPopupData(state$.value)\r\n )\r\n const fetchChildrenBcData = Object.entries(getEagerBcChildren(bcName, widgets, bcMap, lazyWidgetNames)).map(entry => {\r\n const [childBcName, widgetNames] = entry\r\n return bcFetchDataRequest({\r\n bcName: childBcName,\r\n widgetName: widgetNames[0],\r\n ignorePageLimit: action.payload.ignoreChildrenPageLimit,\r\n keepDelta: action.payload.keepDelta\r\n })\r\n })\r\n return concat(\r\n of(bcChangeCursors({ cursorsMap: { [bcName]: cursor }, keepDelta: action.payload.keepDelta })),\r\n of(bcFetchRowMeta({ widgetName: '', bcName })),\r\n fetchChildrenBcData\r\n )\r\n })\r\n )\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { CXBoxEpic, WidgetTableMeta } from '../../interfaces'\r\nimport { concat, filter, mergeMap, Observable, of } from 'rxjs'\r\nimport { changeAssociation, changeDataItem, dropAllAssociations } from '../../actions'\r\nimport { AnyAction } from '@reduxjs/toolkit'\r\nimport { WidgetTableHierarchy } from '@cxbox-ui/schema'\r\nimport { buildBcUrl } from '../../utils'\r\n\r\nexport const changeAssociationEpic: CXBoxEpic = (action$, state$) =>\r\n action$.pipe(\r\n filter(changeAssociation.match),\r\n mergeMap(action => {\r\n const state = state$.value\r\n const selected = action.payload.dataItem._associate\r\n const bcName = action.payload.bcName\r\n const result: Array<Observable<AnyAction>> = [\r\n of(\r\n changeDataItem({\r\n bcName,\r\n bcUrl: buildBcUrl(bcName, true, state),\r\n cursor: action.payload.dataItem.id,\r\n dataItem: action.payload.dataItem\r\n })\r\n )\r\n ]\r\n const widget = state.view.widgets.find(item => item.name === action.payload.widgetName) as WidgetTableMeta\r\n const isRoot = action.payload.bcName === widget.bcName\r\n const rootHierarchyDescriptor = {\r\n bcName: widget.bcName,\r\n radio: widget.options?.hierarchyRadio,\r\n fields: widget.fields\r\n }\r\n const hierarchy = widget.options?.hierarchy\r\n const hierarchyDescriptor: WidgetTableHierarchy = isRoot\r\n ? rootHierarchyDescriptor\r\n : hierarchy?.find(item => item.bcName === action.payload.bcName)\r\n const hierarchyGroupSelection = widget.options?.hierarchyGroupSelection\r\n const hierarchyTraverse = widget.options?.hierarchyTraverse\r\n const childrenBc = hierarchy\r\n ?.slice(hierarchy.findIndex(item => item.bcName === action.payload.bcName) + 1)\r\n .map(item => item.bcName)\r\n if (hierarchyGroupSelection && hierarchyDescriptor.radio && !selected) {\r\n result.push(\r\n of(\r\n dropAllAssociations({\r\n bcNames: childrenBc\r\n })\r\n )\r\n )\r\n }\r\n const parent: WidgetTableHierarchy = isRoot\r\n ? null\r\n : hierarchy?.find((item, index) => {\r\n return hierarchy[index + 1]?.bcName === action.payload.bcName\r\n }) || rootHierarchyDescriptor\r\n const parentItem = state.data[parent?.bcName]?.find(item => item.id === state.screen.bo.bc[parent?.bcName].cursor)\r\n if (parent && hierarchyTraverse && selected) {\r\n if (hierarchyDescriptor.radio) {\r\n result.push(\r\n of(\r\n dropAllAssociations({\r\n bcNames: [parent.bcName]\r\n })\r\n )\r\n )\r\n }\r\n result.push(\r\n of(\r\n changeAssociation({\r\n bcName: parent.bcName,\r\n widgetName: action.payload.widgetName,\r\n dataItem: {\r\n ...parentItem,\r\n _associate: true,\r\n _value: parentItem?.[parent.assocValueKey || action.payload.assocValueKey]\r\n },\r\n assocValueKey: action.payload.assocValueKey\r\n })\r\n )\r\n )\r\n }\r\n if (parent && hierarchyTraverse && !selected) {\r\n const data = state.data[action.payload.bcName]\r\n const wasLastInData = data.filter(item => item.id !== action.payload.dataItem.id).every(item => !item._associate)\r\n\r\n const delta = state.view.pendingDataChanges[action.payload.bcName]\r\n const wasLastInDelta =\r\n !delta ||\r\n !Object.values(delta).find(deltaValue => {\r\n return (\r\n deltaValue._associate === true &&\r\n deltaValue.id !== action.payload.dataItem.id &&\r\n // Filter by dataEpics.ts records, because delta can contain records from another hierarchy branch, but dataEpics.ts always contains\r\n // only target branch records, that we see in widget\r\n data.find(dataValue => dataValue.id === deltaValue.id)\r\n )\r\n })\r\n if (wasLastInData && wasLastInDelta) {\r\n result.push(\r\n of(\r\n changeAssociation({\r\n bcName: parent.bcName,\r\n widgetName: action.payload.widgetName,\r\n dataItem: { ...parentItem, _associate: false },\r\n assocValueKey: action.payload.assocValueKey\r\n })\r\n )\r\n )\r\n }\r\n }\r\n return concat(...result)\r\n })\r\n )\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { CXBoxEpic, WidgetTableMeta } from '../../interfaces'\r\nimport { concat, filter, mergeMap, Observable, of } from 'rxjs'\r\nimport { changeAssociationFull, changeDataItem, changeDescendantsAssociationsFull } from '../../actions'\r\nimport { AnyAction } from '@reduxjs/toolkit'\r\nimport { buildBcUrl } from '../../utils'\r\n\r\n/**\r\n * Change full hierarchy record association state. Also select/deselect dependent records according to widget options.\r\n */\r\nexport const changeAssociationFullEpic: CXBoxEpic = (action$, state$) =>\r\n action$.pipe(\r\n filter(changeAssociationFull.match),\r\n mergeMap(action => {\r\n const state = state$.value\r\n const result: Array<Observable<AnyAction>> = []\r\n const assocValueKey = action.payload.assocValueKey || state.view.popupData?.assocValueKey\r\n const bcName = action.payload.bcName\r\n const allData = state.data[bcName]\r\n const selected = action.payload.dataItem._associate\r\n const depth = action.payload.depth || 1\r\n const parentDepth = depth - 1\r\n const parentItem = depth > 1 && allData.find(item => item.id === action.payload.dataItem.parentId)\r\n const widget = state.view.widgets.find(item => item.name === action.payload.widgetName) as WidgetTableMeta\r\n const hierarchyTraverse = widget.options?.hierarchyTraverse\r\n const rootRadio = widget.options?.hierarchyRadio\r\n const hierarchyGroupDeselection = widget.options?.hierarchyGroupDeselection\r\n\r\n const currentLevelData = allData.filter(item => item.level === depth && (item.level === 1 || item.parentId === parentItem?.id))\r\n\r\n if (rootRadio && hierarchyGroupDeselection && depth === 1) {\r\n if (selected) {\r\n const delta = state.view.pendingDataChanges[bcName]\r\n const prevSelected = allData.find(dataItem => {\r\n if (dataItem.level === 1 && dataItem.id !== action.payload.dataItem.id) {\r\n const deltaItem = delta?.[dataItem.id]\r\n if (deltaItem?._associate || (!deltaItem && dataItem._associate)) {\r\n return true\r\n }\r\n }\r\n\r\n return false\r\n })\r\n\r\n if (prevSelected) {\r\n result.push(\r\n of(\r\n changeAssociationFull({\r\n bcName,\r\n depth: depth,\r\n widgetName: action.payload.widgetName,\r\n dataItem: { ...prevSelected, _associate: false },\r\n assocValueKey\r\n })\r\n )\r\n )\r\n }\r\n } else {\r\n // result.push(Observable.of($do.dropAllAssociationsFull({bcName, depth: depth + 1, dropDescendants: true})))\r\n result.push(\r\n of(\r\n changeDescendantsAssociationsFull({\r\n bcName,\r\n parentId: action.payload.dataItem.id,\r\n depth: depth + 1,\r\n assocValueKey,\r\n selected: false\r\n })\r\n )\r\n )\r\n }\r\n }\r\n\r\n result.push(\r\n of(\r\n changeDataItem({\r\n bcName: action.payload.bcName,\r\n bcUrl: buildBcUrl(action.payload.bcName, true, state),\r\n cursor: action.payload.dataItem.id,\r\n dataItem: action.payload.dataItem\r\n })\r\n )\r\n )\r\n\r\n if (parentDepth && hierarchyTraverse && selected) {\r\n result.push(\r\n of(\r\n changeAssociationFull({\r\n bcName,\r\n depth: parentDepth,\r\n widgetName: action.payload.widgetName,\r\n dataItem: {\r\n ...parentItem,\r\n _associate: true,\r\n _value: parentItem?.[assocValueKey]\r\n },\r\n assocValueKey\r\n })\r\n )\r\n )\r\n }\r\n\r\n if (parentDepth && hierarchyTraverse && !selected) {\r\n const delta = state.view.pendingDataChanges[bcName]\r\n const wasLastInDelta =\r\n !delta ||\r\n !Object.values(delta).find(deltaValue => {\r\n return (\r\n deltaValue._associate === true &&\r\n deltaValue.id !== action.payload.dataItem.id &&\r\n currentLevelData.find(dataValue => dataValue.id === deltaValue.id)\r\n )\r\n })\r\n const deltaFalseId =\r\n delta &&\r\n Object.values(delta)\r\n ?.filter(item => item._associate === false)\r\n .map(item => item.id)\r\n const wasLastInData = currentLevelData\r\n .filter(item => item.id !== action.payload.dataItem.id && !deltaFalseId?.includes(item.id))\r\n .every(item => !item._associate)\r\n\r\n if (wasLastInData && wasLastInDelta) {\r\n result.push(\r\n of(\r\n changeAssociationFull({\r\n bcName,\r\n depth: parentDepth,\r\n widgetName: action.payload.widgetName,\r\n dataItem: { ...parentItem, _associate: false },\r\n assocValueKey\r\n })\r\n )\r\n )\r\n }\r\n }\r\n\r\n return concat(...result)\r\n })\r\n )\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { CXBoxEpic, WidgetTableMeta } from '../../interfaces'\r\nimport { concat, filter, mergeMap, Observable, of } from 'rxjs'\r\nimport { changeAssociationSameBc, changeDataItem } from '../../actions'\r\nimport { AnyAction } from '@reduxjs/toolkit'\r\nimport { buildBcUrl } from '../../utils'\r\n\r\n/**\r\n * @category Epics\r\n */\r\nexport const changeAssociationSameBcEpic: CXBoxEpic = (action$, state$) =>\r\n action$.pipe(\r\n filter(changeAssociationSameBc.match),\r\n mergeMap(action => {\r\n const state = state$.value\r\n const bcName = action.payload.bcName\r\n const result: Array<Observable<AnyAction>> = [\r\n of(\r\n changeDataItem({\r\n bcName: bcName,\r\n bcUrl: buildBcUrl(bcName, true, state),\r\n cursor: action.payload.dataItem.id,\r\n dataItem: action.payload.dataItem\r\n })\r\n )\r\n ]\r\n\r\n const selected = action.payload.dataItem._associate\r\n const depth = action.payload.depth || 1\r\n const parentDepth = depth - 1\r\n const widget = state.view.widgets.find(item => item.name === action.payload.widgetName) as WidgetTableMeta\r\n const hierarchyTraverse = widget.options?.hierarchyTraverse\r\n\r\n const currentData = depth > 1 ? state.depthData[depth]?.[bcName] : state.data[bcName]\r\n\r\n const parentCursor = parentDepth\r\n ? parentDepth > 1\r\n ? state.screen.bo.bc[bcName].depthBc?.[parentDepth]?.cursor\r\n : state.screen.bo.bc[bcName].cursor\r\n : null\r\n\r\n const parentItem = parentCursor\r\n ? parentDepth > 1\r\n ? state.depthData[parentDepth]?.[bcName]?.find(item => item.id === parentCursor)\r\n : state.data[bcName].find(item => item.id === parentCursor)\r\n : null\r\n\r\n if (parentDepth && hierarchyTraverse && selected) {\r\n result.push(\r\n of(\r\n changeAssociationSameBc({\r\n bcName,\r\n depth: parentDepth,\r\n widgetName: action.payload.widgetName,\r\n dataItem: {\r\n ...parentItem,\r\n _associate: true,\r\n _value: parentItem?.[action.payload.assocValueKey]\r\n },\r\n assocValueKey: action.payload.assocValueKey\r\n })\r\n )\r\n )\r\n }\r\n\r\n if (parentDepth && hierarchyTraverse && !selected) {\r\n const wasLastInData = currentData.filter(item => item.id !== action.payload.dataItem.id).every(item => !item._associate)\r\n if (wasLastInData) {\r\n result.push(\r\n of(\r\n changeAssociationSameBc({\r\n bcName,\r\n depth: parentDepth,\r\n widgetName: action.payload.widgetName,\r\n dataItem: { ...parentItem, _associate: false },\r\n assocValueKey: action.payload.assocValueKey\r\n })\r\n )\r\n )\r\n }\r\n }\r\n\r\n return concat(...result)\r\n })\r\n )\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { CXBoxEpic } from '../../interfaces'\r\nimport { filter, mergeMap, of } from 'rxjs'\r\nimport { changeChildrenAssociations, changeDataItems } from '../../actions'\r\n\r\nexport const changeChildrenAssociationsEpic: CXBoxEpic = (action$, state$, { api }) =>\r\n action$.pipe(\r\n filter(changeChildrenAssociations.match),\r\n mergeMap(action => {\r\n const state = state$.value\r\n const data = state.data[action.payload.bcName]\r\n return of(\r\n changeDataItems({\r\n bcName: action.payload.bcName,\r\n cursors: data.map(item => item.id),\r\n dataItems: data.map(item => ({\r\n ...item,\r\n _value: item[action.payload.assocValueKey],\r\n _associate: action.payload.selected\r\n }))\r\n })\r\n )\r\n })\r\n )\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { CXBoxEpic } from '../../interfaces'\r\nimport { filter, mergeMap, of } from 'rxjs'\r\nimport { changeChildrenAssociationsSameBc, changeDataItems } from '../../actions'\r\n\r\nexport const changeChildrenAssociationsSameBcEpic: CXBoxEpic = (action$, state$) =>\r\n action$.pipe(\r\n filter(changeChildrenAssociationsSameBc.match),\r\n mergeMap(action => {\r\n const state = state$.value\r\n const data = state.depthData[action.payload.depth]?.[action.payload.bcName] || []\r\n return of(\r\n changeDataItems({\r\n bcName: action.payload.bcName,\r\n cursors: data.map(item => item.id),\r\n dataItems: data.map(item => ({\r\n ...item,\r\n _value: item[action.payload.assocValueKey],\r\n _associate: action.payload.selected\r\n }))\r\n })\r\n )\r\n })\r\n )\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { CXBoxEpic } from '../../interfaces'\r\nimport { concat, filter, mergeMap, Observable, of } from 'rxjs'\r\nimport { changeDataItems, changeDescendantsAssociationsFull } from '../../actions'\r\nimport { AnyAction } from '@reduxjs/toolkit'\r\n\r\n/**\r\n * Change full hierarchy descendants association state\r\n */\r\nexport const changeDescendantsAssociationsFullEpic: CXBoxEpic = (action$, state$) =>\r\n action$.pipe(\r\n filter(changeDescendantsAssociationsFull.match),\r\n mergeMap(action => {\r\n const state = state$.value\r\n const depth = action.payload.depth\r\n const data = state.data[action.payload.bcName]\r\n\r\n const targetData = (data || []).filter(item => item.level === depth && item.parentId === action.payload.parentId)\r\n\r\n const result: Array<Observable<AnyAction>> = [\r\n of(\r\n changeDataItems({\r\n bcName: action.payload.bcName,\r\n cursors: targetData.map(item => item.id),\r\n dataItems: targetData.map(item => ({\r\n ...item,\r\n _value: item[action.payload.assocValueKey],\r\n _associate: action.payload.selected\r\n }))\r\n })\r\n )\r\n ]\r\n\r\n targetData.forEach(targetDataItem => {\r\n if (data.find(dataItem => dataItem.parentId === targetDataItem.id)) {\r\n result.push(\r\n of(\r\n changeDescendantsAssociationsFull({\r\n ...action.payload,\r\n parentId: targetDataItem.id,\r\n depth: depth + 1\r\n })\r\n )\r\n )\r\n }\r\n })\r\n\r\n return concat(...result)\r\n })\r\n )\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { RouteType } from '../../interfaces'\r\nimport { parseBcCursors } from '../../utils'\r\nimport { CXBoxEpic } from '../../interfaces'\r\nimport { concat, EMPTY, filter, mergeMap, Observable, of } from 'rxjs'\r\nimport {\r\n bcChangeCursors,\r\n bcForceUpdate,\r\n changeLocation,\r\n handleRouter,\r\n selectScreen,\r\n selectScreenFail,\r\n selectView,\r\n selectViewFail\r\n} from '../../actions'\r\nimport { AnyAction } from '@reduxjs/toolkit'\r\nimport { getDefaultViewForPrimary } from '../../utils/getDefaultViewForPrimary'\r\nimport { getDefaultViewFromPrimaries } from '../../utils/getDefaultViewFromPrimaries'\r\n\r\n/**\r\n * Epic of changing the current route\r\n *\r\n * Checks route parameters (screen, view, BC cursors) relative to those\r\n * that are currently stored in the store, and in case of a mismatch\r\n * initiates reloading the screen, view or BC with new cursors.\r\n *\r\n */\r\nexport const changeLocationEpic: CXBoxEpic = (action$, state$) =>\r\n action$.pipe(\r\n filter(changeLocation.match),\r\n mergeMap(action => {\r\n const state = state$.value\r\n const { onSuccessAction } = action.payload\r\n const successAction = onSuccessAction ? of(onSuccessAction) : EMPTY\r\n\r\n // User not logged\r\n if (!state.session.active) {\r\n return EMPTY\r\n }\r\n\r\n if (state.router.type === RouteType.router) {\r\n return concat(of(handleRouter(state.router)), successAction)\r\n }\r\n\r\n // Check cursor different between store and url\r\n const nextCursors = parseBcCursors(state.router.bcPath) || {}\r\n const cursorsDiffMap: Record<string, string> = {}\r\n Object.entries(nextCursors).forEach(entry => {\r\n const [bcName, cursor] = entry\r\n const bc = state.screen.bo.bc[bcName]\r\n if (!bc || bc?.cursor !== cursor) {\r\n cursorsDiffMap[bcName] = cursor\r\n }\r\n })\r\n const needUpdateCursors = Object.keys(cursorsDiffMap).length\r\n\r\n // Reload screen if nextScreen and currentScreen not equal\r\n // With the default route type use the first default screen, if not exist then first screen\r\n const currentScreenName = state.screen.screenName\r\n const defaultScreenName = state.session.screens.find(screen => screen.defaultScreen)?.name || state.session.screens[0]?.name\r\n const nextScreenName = state.router.type === RouteType.default ? defaultScreenName : state.router.screenName\r\n\r\n if (nextScreenName !== currentScreenName || action.payload.forceUpdate) {\r\n const nextScreen = state.session.screens.find(item => item.name === nextScreenName)\r\n return nextScreen\r\n ? concat(\r\n of(selectScreen({ screen: nextScreen })),\r\n needUpdateCursors ? of(bcChangeCursors({ cursorsMap: cursorsDiffMap })) : EMPTY,\r\n successAction\r\n )\r\n : of(selectScreenFail({ screenName: nextScreenName }))\r\n }\r\n\r\n const currentViewName = state.view.name\r\n const nextViewName = state.router.viewName\r\n const needUpdateViews = nextViewName !== currentViewName\r\n const resultObservables: Array<Observable<AnyAction>> = []\r\n // if cursors have difference, then put new cursors and mark BC as \"dirty\"\r\n if (needUpdateCursors) {\r\n resultObservables.push(of(bcChangeCursors({ cursorsMap: cursorsDiffMap })))\r\n }\r\n // reload view if not equ\r\n if (needUpdateViews) {\r\n const nextView = nextViewName\r\n ? state.screen.views.find(item => item.name === nextViewName)\r\n : getDefaultViewForPrimary(state.screen.primaryView, state.screen.views) ??\r\n getDefaultViewFromPrimaries(state.screen.primaryViews, state.screen.views) ??\r\n state.screen.views[0]\r\n\r\n resultObservables.push(\r\n nextView ? of(selectView({ ...nextView, isTab: action.payload.isTab })) : of(selectViewFail({ viewName: nextViewName }))\r\n )\r\n }\r\n // If CURSOR has been updated but VIEW has`t changed, need update DATA\r\n if (needUpdateCursors && !needUpdateViews) {\r\n Object.entries(nextCursors).forEach(entry => {\r\n const [bcName, cursor] = entry\r\n if (!state.data[bcName].find(item => item.id === cursor)) {\r\n resultObservables.push(of(bcForceUpdate({ bcName })))\r\n }\r\n })\r\n }\r\n // The order is important (cursors are placed first, then the view is reloaded)\r\n return concat(...resultObservables, successAction)\r\n })\r\n )\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { CXBoxEpic } from '../../interfaces'\r\nimport { filter, of, switchMap } from 'rxjs'\r\nimport { selectScreen, selectView, selectViewFail } from '../../actions'\r\nimport { getDefaultViewForPrimary } from '../../utils/getDefaultViewForPrimary'\r\nimport { getDefaultViewFromPrimaries } from '../../utils/getDefaultViewFromPrimaries'\r\n\r\n/**\r\n *\r\n * TODO: Rename to `selectScreen` in 2.0.0\r\n *\r\n */\r\nexport const changeScreen: CXBoxEpic = (action$, state$) =>\r\n action$.pipe(\r\n filter(selectScreen.match),\r\n switchMap(action => {\r\n const state = state$.value\r\n const nextViewName = state.router.viewName\r\n const requestedView = state.screen.views.find(item => item.name === nextViewName)\r\n const defaultView = !nextViewName\r\n ? getDefaultViewForPrimary(state.screen.primaryView, state.screen.views) ??\r\n getDefaultViewFromPrimaries(state.screen.primaryViews, state.screen.views)\r\n : null\r\n const nextView = requestedView || defaultView || state.screen.views[0]\r\n return nextView ? of(selectView(nextView)) : of(selectViewFail({ viewName: nextViewName }))\r\n })\r\n )\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { parseBcCursors } from '../../utils'\r\nimport { CXBoxEpic } from '../../interfaces'\r\nimport { EMPTY, filter, of, switchMap } from 'rxjs'\r\nimport { bcChangeCursors, selectView } from '../../actions'\r\n\r\n/**\r\n *\r\n * TODO: Rename to `selectView` in 2.0.0\r\n *\r\n */\r\nexport const changeViewEpic: CXBoxEpic = (action$, state$) =>\r\n action$.pipe(\r\n filter(selectView.match),\r\n switchMap(action => {\r\n const state = state$.value\r\n const nextCursors = parseBcCursors(state.router.bcPath) || {}\r\n const cursorsDiffMap: Record<string, string> = {}\r\n Object.entries(nextCursors).forEach(entry => {\r\n const [bcName, cursor] = entry\r\n const bc = state.screen.bo.bc[bcName]\r\n if (!bc || bc.cursor !== cursor) {\r\n cursorsDiffMap[bcName] = cursor\r\n }\r\n })\r\n if (Object.keys(cursorsDiffMap).length) {\r\n return of(bcChangeCursors({ cursorsMap: cursorsDiffMap }))\r\n }\r\n return EMPTY\r\n })\r\n )\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { parseBcCursors } from '../../utils'\r\nimport { CXBoxEpic } from '../../interfaces'\r\nimport { bcChangeCursors } from '../../actions'\r\nimport { EMPTY, filter, mergeMap, of } from 'rxjs'\r\n\r\n/**\r\n * Clears descendant business components pending changes on cursor change\r\n *\r\n * TODO: Review required as it might be no longer valid due to autosave middleware implementation\r\n */\r\nexport const clearPendingDataChangesAfterCursorChangeEpic: CXBoxEpic = (action$, state$) =>\r\n action$.pipe(\r\n filter(bcChangeCursors.match),\r\n mergeMap(action => {\r\n const state = state$.value\r\n\r\n /*\r\n * Если при загрузке view курсор проставился не во всех бк\r\n * то дописать недостающие курсоры\r\n */\r\n const nextCursors = parseBcCursors(state.router.bcPath) || {}\r\n const cursorsDiffMap: Record<string, string> = {}\r\n Object.entries(nextCursors).forEach(entry => {\r\n const [bcName, cursor] = entry\r\n const bc = state.screen.bo.bc[bcName]\r\n if (!bc || bc?.cursor !== cursor) {\r\n cursorsDiffMap[bcName] = cursor\r\n }\r\n })\r\n if (Object.keys(cursorsDiffMap).length) {\r\n return of(bcChangeCursors({ cursorsMap: cursorsDiffMap }))\r\n }\r\n\r\n return EMPTY\r\n })\r\n )\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { downloadFileByUrl } from '../../actions'\r\nimport { CXBoxEpic } from '../../interfaces'\r\nimport { EMPTY, filter, mergeMap, tap } from 'rxjs'\r\n\r\nexport const downloadFileByUrlEpic: CXBoxEpic = (action$, state$) =>\r\n action$.pipe(\r\n filter(downloadFileByUrl.match),\r\n tap(action => {\r\n const { url } = action.payload\r\n const anchor = document.createElement('a')\r\n anchor.href = url\r\n anchor.style.display = 'none'\r\n document.body.appendChild(anchor)\r\n setTimeout(() => {\r\n anchor.click()\r\n document.body.removeChild(anchor)\r\n }, 100)\r\n }),\r\n mergeMap(() => EMPTY)\r\n )\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { CXBoxEpic } from '../../interfaces'\r\nimport { EMPTY, filter, mergeMap, tap } from 'rxjs'\r\nimport { downloadFile } from '../../actions'\r\n\r\nexport const downloadFileEpic: CXBoxEpic = (action$, state$, { api }) =>\r\n action$.pipe(\r\n filter(downloadFile.match),\r\n tap(action => {\r\n const { fileId } = action.payload\r\n const anchor = document.createElement('a')\r\n\r\n anchor.href = `${api.fileUploadEndpoint}?id=${encodeURIComponent(fileId)}`\r\n\r\n anchor.style.display = 'none'\r\n document.body.appendChild(anchor)\r\n\r\n setTimeout(() => {\r\n anchor.click()\r\n document.body.removeChild(anchor)\r\n }, 100)\r\n }),\r\n mergeMap(() => EMPTY)\r\n )\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { concat, EMPTY, filter, switchMap } from 'rxjs'\r\nimport { bcAddFilter, bcAddSorter, bcForceUpdate, bcRemoveAllFilters, changeLocation, drillDown } from '../../actions'\r\nimport { defaultParseURL, makeRelativeUrl, parseFilters, parseSorters, processDrilldownFilters } from '../../utils'\r\nimport { CXBoxEpic, DrillDownType } from '../../interfaces'\r\n\r\nexport const drillDownEpic: CXBoxEpic = (action$, state$) =>\r\n action$.pipe(\r\n filter(drillDown.match),\r\n switchMap(action => {\r\n // TODO: drilldown trash epic\r\n const state = state$.value\r\n const url = action.payload.url\r\n const result = []\r\n switch (action.payload.drillDownType) {\r\n case DrillDownType.external:\r\n window.location.href = url\r\n break\r\n case DrillDownType.externalNew:\r\n if (/^[a-z0-9]+:\\/\\//i.test(url)) {\r\n window.open(url)\r\n }\r\n break\r\n case DrillDownType.relative:\r\n window.location.href = `${window.location.origin}/${url}`\r\n break\r\n case DrillDownType.relativeNew:\r\n window.open(`${window.location.origin}/${url}`, '_blank')\r\n break\r\n case DrillDownType.inner:\r\n default:\r\n const [urlBase] = url.split('?')\r\n const urlObject = new URL(url, window.location.origin)\r\n const urlFilters = urlObject.searchParams.get('filters')\r\n const urlSorters = urlObject.searchParams.get('sorters')\r\n\r\n let newFilters: Record<string, string> = {}\r\n let newSorters: Record<string, string> = {}\r\n\r\n try {\r\n newFilters = JSON.parse(urlFilters) ?? newFilters\r\n } catch {\r\n urlFilters && console.warn('Failed to parse filters on drilldown')\r\n newFilters = {}\r\n }\r\n try {\r\n newSorters = JSON.parse(urlSorters) ?? newSorters\r\n } catch {\r\n urlSorters && console.warn('Failed to parse sorters on drilldown')\r\n newSorters = {}\r\n }\r\n const bcToUpdate: Record<string, boolean> = {}\r\n // If filter drilldown specifies new filters or explicitly says they are empty, drop previous filters\r\n Object.keys(state.screen.filters).forEach(bcName => {\r\n if (newFilters[bcName] === '' || newFilters[bcName]) {\r\n bcToUpdate[bcName] = true\r\n result.push(bcRemoveAllFilters({ bcName }))\r\n }\r\n })\r\n const nextState = defaultParseURL(urlObject)\r\n const viewName = nextState.viewName\r\n // Apply each new filter\r\n Object.entries(newFilters).forEach(([bcName, filterExpression]) => {\r\n const parsedFilters = parseFilters(filterExpression)?.map(item => ({ ...item, viewName }))\r\n processDrilldownFilters(parsedFilters)?.forEach(parsedFilter => {\r\n bcToUpdate[bcName] = true\r\n result.push(bcAddFilter({ bcName, filter: parsedFilter }))\r\n })\r\n })\r\n // Apply each new sorter\r\n Object.entries(newSorters).forEach(([bcName, sortExpression]) => {\r\n const sorter = parseSorters(sortExpression)\r\n result.push(bcAddSorter({ bcName, sorter }))\r\n bcToUpdate[bcName] = true\r\n })\r\n const prevState = state.router\r\n const willUpdateAnyway = shallowCompare(prevState, nextState, ['params']).length > 0\r\n // If screen or view is different all BC will update anyway so there is no need\r\n // to manually set them for update\r\n if (!willUpdateAnyway) {\r\n Object.keys(bcToUpdate).forEach(bcName => {\r\n result.push(bcForceUpdate({ bcName }))\r\n })\r\n }\r\n result.push(\r\n changeLocation({\r\n location: defaultParseURL(new URL(makeRelativeUrl(urlBase), window.location.origin)),\r\n forceUpdate: true,\r\n onSuccessAction: action.payload.onSuccessAction\r\n })\r\n )\r\n break\r\n }\r\n\r\n return result.length ? concat(result) : EMPTY\r\n })\r\n )\r\n\r\n/**\r\n * Shallow compare of two dictionaries by strict comparison.\r\n * `ignore` argument can be used to forcefully exclude some properties from result set even if their\r\n * are different.\r\n *\r\n * TODO: Check if possible to replace with `shallowEqual` from `react-redux`\r\n *\r\n * @param prevProps\r\n * @param nextProps\r\n * @param ignore\r\n */\r\nfunction shallowCompare(prevProps: Record<string, any>, nextProps: Record<string, any>, ignore: string[] = []) {\r\n const diffProps: string[] = []\r\n if (!prevProps && !nextProps) {\r\n return null\r\n }\r\n if (!prevProps) {\r\n return Object.keys(nextProps)\r\n }\r\n if (!nextProps) {\r\n return Object.keys(prevProps)\r\n }\r\n const newKeys = Object.keys(nextProps)\r\n newKeys.forEach(key => {\r\n if (prevProps[key] !== nextProps[key] && !ignore.includes(key)) {\r\n diffProps.push(key)\r\n }\r\n })\r\n Object.keys(prevProps).forEach(key => {\r\n if (!newKeys.includes(key)) {\r\n diffProps.push(key)\r\n }\r\n })\r\n return diffProps\r\n}\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { CXBoxEpic } from '../../interfaces'\r\nimport { bcForceUpdate, bulkUploadFiles, closeViewPopup, sendOperationSuccess } from '../../actions'\r\nimport { catchError, concat, EMPTY, filter, mergeMap, of } from 'rxjs'\r\nimport { buildBcUrl } from '../../utils'\r\nimport { OperationTypeCrud } from '@cxbox-ui/schema'\r\nimport { postOperationRoutine } from '../utils/postOperationRoutine'\r\nimport { createApiErrorObservable } from '../../utils/apiError'\r\n\r\n/**\r\n * It sends customAction request for `file-upload-save` endpoint with `bulkIds` dataEpics.ts\r\n * containing ids of uploaded files.\r\n * On success it fires `sendOperationSuccess`, `bcForceUpdate` and `closeViewPopup` actions\r\n * to refresh business component and close popup.\r\n *\r\n * It also launces postOperationRoutine to handle pre and post invokes.\r\n *\r\n */\r\nexport const fileUploadConfirmEpic: CXBoxEpic = (action$, state$, { api }) =>\r\n action$.pipe(\r\n filter(bulkUploadFiles.match),\r\n mergeMap(action => {\r\n /**\r\n * Default implementation for `fileUploadConfirmEpic` epic\r\n *\r\n * It sends customAction request for `file-upload-save` endpoint with `bulkIds` dataEpics.ts\r\n * containing ids of uploaded files.\r\n * On success it fires `sendOperationSuccess`, `bcForceUpdate` and `closeViewPopup` actions\r\n * to refresh business component and close popup.\r\n *\r\n * It also launces postOperationRoutine to handle pre and post invokes.\r\n */\r\n const state = state$.value\r\n const isPopup = action.payload.isPopup ?? true\r\n const bcName = action.payload.bcName ?? state.view.popupData?.bcName\r\n const bcUrl = buildBcUrl(bcName, true, state)\r\n const widgetName = state.view.widgets.find(item => item.bcName === bcName)?.name\r\n const data = action.payload.fileIds.map(id => ({\r\n id: id,\r\n _associate: true,\r\n vstamp: 0\r\n }))\r\n\r\n return api.associate(state.screen.screenName, bcUrl, data, null).pipe(\r\n mergeMap(response => {\r\n const postInvoke = response.postActions?.[0]\r\n const preInvoke = response.preInvoke\r\n return concat(\r\n of(sendOperationSuccess({ bcName, cursor: null })),\r\n of(bcForceUpdate({ bcName })),\r\n isPopup ? of(closeViewPopup(null)) : EMPTY,\r\n ...postOperationRoutine(widgetName, postInvoke, preInvoke, OperationTypeCrud.save, bcName)\r\n )\r\n }),\r\n catchError((error: any) => {\r\n console.error(error)\r\n return createApiErrorObservable(error)\r\n })\r\n )\r\n })\r\n )\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { CXBoxEpic, OperationError, OperationErrorEntity } from '../../interfaces'\r\nimport { EMPTY, concat, filter, mergeMap, of, Observable, catchError } from 'rxjs'\r\nimport {\r\n addPendingRequest,\r\n bcRemoveAllFilters,\r\n changeDataItem,\r\n closeViewPopup,\r\n forceActiveChangeFail,\r\n forceActiveRmUpdate,\r\n removePendingRequest,\r\n viewClearPickMap\r\n} from '../../actions'\r\nimport { WidgetTypes } from '@cxbox-ui/schema'\r\nimport { buildBcUrl } from '../../utils'\r\nimport { AnyAction, nanoid } from '@reduxjs/toolkit'\r\nimport { AxiosError } from 'axios'\r\nimport { createApiErrorObservable } from '../../utils/apiError'\r\n\r\n/**\r\n * Sends row meta request when `forceActive` field fires `onChange`\r\n */\r\nexport const getRowMetaByForceActiveEpic: CXBoxEpic = (action$, state$, { api }) =>\r\n action$.pipe(\r\n filter(changeDataItem.match),\r\n mergeMap(action => {\r\n const state = state$.value\r\n const initUrl = state.view.url\r\n const { bcName, cursor, disableRetry } = action.payload\r\n\r\n const isBcHierarchy = state.view.widgets.some(widget => {\r\n return (\r\n widget.bcName === bcName &&\r\n widget.type === WidgetTypes.AssocListPopup &&\r\n (widget.options?.hierarchySameBc || widget.options?.hierarchyFull)\r\n )\r\n })\r\n if (isBcHierarchy) {\r\n return EMPTY\r\n }\r\n\r\n const isPickListPopup = state.view.widgets.find(\r\n item =>\r\n item.name === state.view.popupData?.widgetName &&\r\n [WidgetTypes.PickListPopup, WidgetTypes.FlatTreePopup].includes(item.type as WidgetTypes)\r\n )\r\n\r\n const needPopupClose = isPickListPopup && !state.session.disableDeprecatedFeatures?.popupCloseAfterChangeData\r\n\r\n const bcUrl = buildBcUrl(bcName, true, state)\r\n const pendingChanges = state.view.pendingDataChanges[bcName]?.[cursor]\r\n const pendingChangesNow = state.view.pendingDataChangesNow[bcName]?.[cursor]\r\n const handledForceActive = state.view.handledForceActive[bcName]?.[cursor] || {}\r\n const currentRecordData = state.data[bcName]?.find(record => record.id === cursor)\r\n const fieldsRowMeta = state.view.rowMeta[bcName]?.[bcUrl]?.fields\r\n let changedFiledKey: string = null\r\n\r\n const closePopup = concat(of(closeViewPopup(null)), of(viewClearPickMap(null)), of(bcRemoveAllFilters({ bcName })))\r\n\r\n // среди forceActive-полей в дельте ищем то которое изменилось по отношению к обработанным forceActive\r\n // или не содержится в нем, устанавливаем флаг необходимости отправки запроса если такое поле найдено\r\n const someForceActiveChanged = fieldsRowMeta\r\n ?.filter(field => field.forceActive && pendingChanges[field.key] !== undefined)\r\n .some(field => {\r\n const result = pendingChanges[field.key] !== handledForceActive[field.key]\r\n if (result) {\r\n changedFiledKey = field.key\r\n }\r\n return result\r\n })\r\n const requestId = nanoid()\r\n if (someForceActiveChanged && !disableRetry) {\r\n return concat(\r\n of(addPendingRequest({ request: { requestId, type: 'force-active' } })),\r\n api\r\n .getRmByForceActive(\r\n state.screen.screenName,\r\n bcUrl,\r\n { ...pendingChanges, vstamp: currentRecordData?.vstamp },\r\n pendingChangesNow\r\n )\r\n .pipe(\r\n mergeMap(data => {\r\n const result: Array<Observable<AnyAction>> = [of(removePendingRequest({ requestId }))]\r\n if (state.view.url === initUrl) {\r\n result.push(\r\n of(\r\n forceActiveRmUpdate({\r\n rowMeta: data,\r\n currentRecordData,\r\n bcName,\r\n bcUrl,\r\n cursor\r\n })\r\n )\r\n )\r\n }\r\n if (needPopupClose) {\r\n result.push(closePopup)\r\n }\r\n return concat(...result)\r\n }),\r\n catchError((e: AxiosError) => {\r\n console.error(e)\r\n let viewError: string = null\r\n let entityError: OperationErrorEntity = null\r\n const operationError = e.response?.data as OperationError\r\n if (e.response?.data === Object(e.response?.data)) {\r\n entityError = operationError?.error?.entity\r\n viewError = operationError?.error?.popup?.[0]\r\n }\r\n return concat(\r\n of(removePendingRequest({ requestId })),\r\n state.view.url === initUrl\r\n ? concat(\r\n of(\r\n changeDataItem({\r\n bcName,\r\n bcUrl: buildBcUrl(bcName, true, state),\r\n cursor,\r\n dataItem: { [changedFiledKey]: currentRecordData?.[changedFiledKey] },\r\n disableRetry: true\r\n })\r\n ),\r\n of(forceActiveChangeFail({ bcName, bcUrl, viewError, entityError }))\r\n )\r\n : EMPTY,\r\n createApiErrorObservable(e)\r\n )\r\n })\r\n )\r\n )\r\n }\r\n return needPopupClose ? closePopup : EMPTY\r\n })\r\n )\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { catchError, EMPTY, filter, mergeMap, switchMap } from 'rxjs'\r\nimport { CXBoxEpic } from '../../interfaces'\r\nimport { handleRouter } from '../../actions'\r\nimport { createApiErrorObservable } from '../../utils/apiError'\r\n\r\nexport const handleRouterEpic: CXBoxEpic = (action$, state$, { api }) =>\r\n action$.pipe(\r\n filter(handleRouter.match),\r\n switchMap(action => {\r\n /**\r\n * Default implementation for `handleRouter` epic.\r\n *\r\n * If server routing is used, this epic will send a requst to Cxbox API router endpoint.\r\n * It writes a console error if request fails.\r\n *\r\n * @returns Default implementation does not throw any additional actions\r\n */\r\n const path = action.payload.path\r\n const params = action.payload.params\r\n // todo: Handle errors\r\n return api.routerRequest(path, params).pipe(\r\n mergeMap(() => {\r\n return EMPTY\r\n }),\r\n catchError(error => {\r\n console.error(error)\r\n return createApiErrorObservable(error)\r\n })\r\n )\r\n })\r\n )\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { CXBoxEpic } from '../../interfaces'\r\nimport { filter, map } from 'rxjs'\r\nimport { httpError, logoutDone } from '../../actions'\r\n\r\nexport const httpError401Epic: CXBoxEpic = action$ =>\r\n action$.pipe(\r\n filter(httpError.match),\r\n filter(action => action.payload.statusCode === 401),\r\n map(action => {\r\n return logoutDone(null)\r\n })\r\n )\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { CXBoxEpic } from '../../interfaces'\r\nimport { filter, map } from 'rxjs'\r\nimport { addNotification, httpError } from '../../actions'\r\n\r\nexport const httpError409Epic: CXBoxEpic = (action$, state$) =>\r\n action$.pipe(\r\n filter(httpError.match),\r\n filter(action => action.payload.statusCode === 409),\r\n map(action => {\r\n const notificationMessage = (action.payload.error.response?.data as Record<string, any>).error?.popup?.[0] || ''\r\n return addNotification({\r\n key: 'action_edit_error',\r\n message: notificationMessage,\r\n type: 'buttonWarningNotification',\r\n duration: 0,\r\n options: {\r\n buttonWarningNotificationOptions: {\r\n buttonText: 'OK'\r\n }\r\n }\r\n })\r\n })\r\n )\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { ApplicationErrorType, BusinessError, CXBoxEpic, OperationError } from '../../interfaces'\r\nimport { concat, EMPTY, filter, mergeMap, Observable, of } from 'rxjs'\r\nimport { httpError, processPostInvoke, showViewError } from '../../actions'\r\nimport { AnyAction } from '@reduxjs/toolkit'\r\n\r\nexport const httpError418Epic: CXBoxEpic = (action$, state$) =>\r\n action$.pipe(\r\n filter(httpError.match),\r\n filter(action => action.payload.statusCode === 418),\r\n mergeMap(action => {\r\n const { error, callContext } = action.payload\r\n const result: Array<Observable<AnyAction>> = []\r\n const typedError = error.response?.data as OperationError\r\n if (!typedError.error.popup) {\r\n return EMPTY\r\n }\r\n const businessError: BusinessError = {\r\n type: ApplicationErrorType.BusinessError,\r\n message: typedError.error.popup[0]\r\n }\r\n result.push(of(showViewError({ error: businessError })))\r\n if (typedError.error.postActions?.[0]) {\r\n const widget = state$.value.view.widgets.find(item => item.name === callContext.widgetName)\r\n const bcName = widget?.bcName\r\n result.push(\r\n of(\r\n processPostInvoke({\r\n bcName,\r\n postInvoke: typedError.error.postActions[0],\r\n widgetName: widget?.name\r\n })\r\n )\r\n )\r\n }\r\n return concat(...result)\r\n })\r\n )\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { ApplicationErrorType, CXBoxEpic, SystemError } from '../../interfaces'\r\nimport { filter, map } from 'rxjs'\r\nimport { httpError, showViewError } from '../../actions'\r\n\r\nexport const httpError500Epic: CXBoxEpic = (action$, state$) =>\r\n action$.pipe(\r\n filter(httpError.match),\r\n filter(action => action.payload.statusCode === 500),\r\n map(action => {\r\n const systemError: SystemError = {\r\n type: ApplicationErrorType.SystemError,\r\n details: action.payload.error.response?.statusText || '',\r\n error: action.payload.error\r\n }\r\n return showViewError({ error: systemError })\r\n })\r\n )\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { CXBoxEpic } from '../../interfaces'\r\nimport { catchError, filter, mergeMap, of, race } from 'rxjs'\r\nimport { bcFetchDataFail, inlinePickListFetchDataRequest, inlinePickListFetchDataSuccess } from '../../actions'\r\nimport { buildBcUrl } from '../../utils'\r\nimport { cancelRequestActionTypes, cancelRequestEpic } from '../../utils/cancelRequestEpic'\r\n\r\nexport const inlinePickListFetchDataEpic: CXBoxEpic = (action$, state$, { api }) =>\r\n action$.pipe(\r\n filter(inlinePickListFetchDataRequest.match),\r\n mergeMap(action => {\r\n const { bcName, searchSpec, searchString } = action.payload\r\n const state = state$.value\r\n const bcUrl = buildBcUrl(bcName, false, state)\r\n const canceler = api.createCanceler()\r\n const cancelFlow = cancelRequestEpic(action$, cancelRequestActionTypes, canceler.cancel, bcFetchDataFail({ bcName, bcUrl }))\r\n const normalFlow = api\r\n .fetchBcData(state$.value.screen.screenName, bcUrl, { [searchSpec + '.contains']: searchString }, canceler.cancelToken)\r\n .pipe(\r\n mergeMap(data => {\r\n return of(inlinePickListFetchDataSuccess({ bcName, data: data.data, bcUrl }))\r\n }),\r\n catchError((error: any) => {\r\n console.error(error)\r\n return of(bcFetchDataFail({ bcName: action.payload.bcName, bcUrl }))\r\n })\r\n )\r\n\r\n return race(cancelFlow, normalFlow)\r\n })\r\n )\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { CXBoxEpic } from '../../interfaces'\r\nimport { EMPTY, filter, switchMap } from 'rxjs'\r\nimport { login } from '../../actions'\r\n\r\n/**\r\n * Fires on successful login; there is no default implementation related to this epic,\r\n * but it can be used to customize successful login behaivior.\r\n */\r\nexport const loginDoneSessionEpic: CXBoxEpic = (action$, store) =>\r\n action$.pipe(\r\n filter(login.match),\r\n switchMap(action => EMPTY)\r\n )\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { CXBoxEpic, OperationPostInvokeConfirmType, OperationPreInvokeType } from '../../interfaces'\r\nimport { EMPTY, filter, mergeMap, of } from 'rxjs'\r\nimport { operationConfirmation, processPostInvokeConfirm, processPreInvoke } from '../../actions'\r\nimport { isAnyOf } from '@reduxjs/toolkit'\r\n\r\nexport const processPostInvokeConfirmEpic: CXBoxEpic = (action$, state$) =>\r\n action$.pipe(\r\n filter(isAnyOf(processPostInvokeConfirm, processPreInvoke)),\r\n mergeMap(action => {\r\n const { bcName, operationType, widgetName } = action.payload\r\n const confirm = processPostInvokeConfirm.match(action) ? action.payload.postInvokeConfirm : action.payload.preInvoke\r\n switch (confirm.type) {\r\n case OperationPostInvokeConfirmType.confirm:\r\n case OperationPreInvokeType.info:\r\n case OperationPreInvokeType.error:\r\n case OperationPostInvokeConfirmType.confirmText: {\r\n return of(\r\n operationConfirmation({\r\n operation: {\r\n bcName,\r\n operationType,\r\n widgetName\r\n },\r\n confirmOperation: confirm\r\n })\r\n )\r\n }\r\n default:\r\n return EMPTY\r\n }\r\n })\r\n )\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport {\r\n CXBoxEpic,\r\n OperationPostInvokeDownloadFile,\r\n OperationPostInvokeDownloadFileByUrl,\r\n OperationPostInvokeDrillDown,\r\n OperationPostInvokeRefreshBc,\r\n OperationPostInvokeShowMessage,\r\n OperationPostInvokeType,\r\n OperationPostInvokeWaitUntil\r\n} from '../../interfaces'\r\nimport { concat, EMPTY, filter, mergeMap, of } from 'rxjs'\r\nimport {\r\n bcChangeCursors,\r\n bcFetchDataPages,\r\n bcFetchDataRequest,\r\n changeLocation,\r\n downloadFile,\r\n downloadFileByUrl,\r\n drillDown,\r\n processPostInvoke,\r\n showNotification,\r\n waitUntil\r\n} from '../../actions'\r\nimport { AnyAction } from '@reduxjs/toolkit'\r\nimport { defaultParseURL } from '../../utils'\r\n\r\nexport const processPostInvokeEpic: CXBoxEpic = (action$, state$) =>\r\n action$.pipe(\r\n filter(processPostInvoke.match),\r\n mergeMap(action => {\r\n const state = state$.value\r\n switch (action.payload.postInvoke.type) {\r\n case OperationPostInvokeType.drillDown:\r\n return of(\r\n drillDown({\r\n ...(action.payload.postInvoke as OperationPostInvokeDrillDown),\r\n route: state.router,\r\n widgetName: action.payload.widgetName\r\n })\r\n )\r\n case OperationPostInvokeType.postDelete: {\r\n const cursorsMap: Record<string, string> = { [action.payload.bcName]: null }\r\n const result: AnyAction[] = [bcChangeCursors({ cursorsMap })]\r\n if (state.router.bcPath?.includes(`${action.payload.bcName}/`)) {\r\n const newBcUrl = state.router.bcPath.split(action.payload.bcName)[0] || ''\r\n const newUrl = `/screen/${state.router.screenName}/view/${state.router.viewName}/${newBcUrl}`\r\n\r\n result.push(changeLocation({ location: defaultParseURL(new URL(newUrl, window.location.origin)) }))\r\n } else {\r\n result.push(\r\n bcFetchDataRequest({\r\n bcName: action.payload.bcName,\r\n widgetName: action.payload.widgetName\r\n })\r\n )\r\n }\r\n return of(...result)\r\n }\r\n case OperationPostInvokeType.refreshBC: {\r\n const bo = state.screen.bo\r\n const postInvoke = action.payload.postInvoke as OperationPostInvokeRefreshBc\r\n const postInvokeBC = postInvoke.bc\r\n const postInvokeBCItem = bo.bc[postInvoke.bc]\r\n const widgetName = action.payload.widgetName || ''\r\n const infiniteWidgets: string[] = state.view.infiniteWidgets || []\r\n const infinitePagination = state.view.widgets.some(\r\n item => item.bcName === postInvokeBC && infiniteWidgets.includes(item.name)\r\n )\r\n return infinitePagination\r\n ? of(\r\n bcFetchDataPages({\r\n bcName: postInvokeBCItem?.name,\r\n widgetName: widgetName,\r\n from: 1,\r\n to: postInvokeBCItem?.page\r\n })\r\n )\r\n : of(\r\n bcFetchDataRequest({\r\n bcName: postInvokeBCItem?.name,\r\n widgetName\r\n })\r\n )\r\n }\r\n case OperationPostInvokeType.showMessage: {\r\n const postInvoke = action.payload.postInvoke as OperationPostInvokeShowMessage\r\n return of(showNotification({ type: postInvoke.messageType, message: postInvoke.messageText }))\r\n }\r\n case OperationPostInvokeType.downloadFile: {\r\n const postInvoke = action.payload.postInvoke as OperationPostInvokeDownloadFile\r\n return of(downloadFile({ fileId: postInvoke.fileId }))\r\n }\r\n case OperationPostInvokeType.downloadFileByUrl: {\r\n const postInvoke = action.payload.postInvoke as OperationPostInvokeDownloadFileByUrl\r\n return of(downloadFileByUrl({ url: postInvoke.url }))\r\n }\r\n case OperationPostInvokeType.waitUntil: {\r\n const postInvoke = action.payload.postInvoke as OperationPostInvokeWaitUntil\r\n\r\n return of(waitUntil({ bcName: action.payload.bcName, postInvoke }))\r\n }\r\n case OperationPostInvokeType.drillDownAndWaitUntil: {\r\n const postInvoke = action.payload.postInvoke as OperationPostInvokeWaitUntil\r\n\r\n return concat(\r\n of(\r\n drillDown({\r\n ...(action.payload.postInvoke as OperationPostInvokeDrillDown),\r\n route: state.router,\r\n widgetName: action.payload.widgetName,\r\n onSuccessAction: waitUntil({ bcName: action.payload.bcName, postInvoke })\r\n })\r\n )\r\n )\r\n }\r\n default:\r\n // Other types can be handled by client application\r\n return EMPTY\r\n }\r\n })\r\n )\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { loginDone, refreshMeta, refreshMetaAndReloadPage } from '../../actions'\r\nimport { CXBoxEpic } from '../../interfaces'\r\nimport { concat, EMPTY, filter, of, switchMap, take, tap } from 'rxjs'\r\n\r\nexport const refreshMetaAndReloadPageEpic: CXBoxEpic = (action$, state$) =>\r\n action$.pipe(\r\n filter(refreshMetaAndReloadPage.match),\r\n switchMap(() =>\r\n concat(\r\n of(refreshMeta()),\r\n action$.pipe(\r\n filter(loginDone.match),\r\n take(1),\r\n tap(() => location.reload()),\r\n switchMap(() => EMPTY)\r\n )\r\n )\r\n )\r\n )\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { CXBoxEpic } from '../../interfaces'\r\nimport { catchError, concat, filter, mergeMap, switchMap } from 'rxjs'\r\nimport { login, loginFail, logoutDone, refreshMeta, refreshMetaDone, refreshMetaFail } from '../../actions'\r\nimport { createApiError } from '../../utils/apiError'\r\n\r\n/**\r\n * Performed on refresh meta dataEpics.ts process.\r\n */\r\nexport const refreshMetaEpic: CXBoxEpic = (action$, state$, { api }) =>\r\n action$.pipe(\r\n filter(refreshMeta.match),\r\n mergeMap(() => {\r\n const state = state$.value\r\n const { activeRole } = state.session\r\n return api.refreshMeta().pipe(\r\n switchMap(() => concat([refreshMetaDone(), logoutDone(null), login({ login: '', password: '', role: activeRole })])),\r\n catchError(error => concat([loginFail(error), refreshMetaFail(), createApiError(error)]))\r\n )\r\n })\r\n )\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { concat, EMPTY, filter, mergeMap, of } from 'rxjs'\r\nimport { CXBoxEpic, PopupWidgetTypes, TreeAssociatedRecord } from '../../interfaces'\r\nimport { assignTreeLinks, buildBcUrl, getDescendants } from '../../utils'\r\nimport { changeDataItem, removeMultivalueTag } from '../../actions'\r\n\r\n/**\r\n * For full hierarchies it fires `changeDataItem` action to remove value from source record\r\n *\r\n * With `hierarchyGroupDeselection` widget option, parent removal also remove children; removing\r\n * last child will also remove the parent.\r\n *\r\n * With `hierarchyTraverse` widget option, descendants are used instead of children.\r\n *\r\n * When parent should be removed with both option, `removeMultivalueTag` with updated `removedItem` will\r\n * fire instead of `changeDataItem`.\r\n *\r\n * For non-full hierarchies two `changeDataItem` actions will fire, first to drop `_associate` flag\r\n * of remove item and second to update value of source record.\r\n * Widget options are not tested for non-full hierarchies.\r\n */\r\nexport const removeMultivalueTagEpic: CXBoxEpic = (action$, state$) =>\r\n action$.pipe(\r\n filter(removeMultivalueTag.match),\r\n mergeMap(action => {\r\n /**\r\n * Default implementation for `removeMultivalueTag` epic\r\n *\r\n * For full hierarchies it fires `changeDataItem` action to remove value from source record\r\n *\r\n * With `hierarchyGroupDeselection` widget option, parent removal also remove children; removing\r\n * last child will also remove the parent.\r\n *\r\n * With `hierarchyTraverse` widget option, descendants are used instead of children.\r\n *\r\n * When parent should be removed with both option, `removeMultivalueTag` with updated `removedItem` will\r\n * fire instead of `changeDataItem`.\r\n *\r\n * For non-full hierarchies two `changeDataItem` actions will fire, first to drop `_associate` flag\r\n * of remove item and second to update value of soure record.\r\n * Widget options are not tested for non-full hierarchies.\r\n *\r\n */\r\n\r\n const state = state$.value\r\n const { bcName, cursor, popupBcName, associateFieldKey } = action.payload\r\n const widget = state.view.widgets.find(item => item.bcName === popupBcName && PopupWidgetTypes.includes(item.type))\r\n const storeData = (state?.data[popupBcName] || []) as unknown as TreeAssociatedRecord[]\r\n // Merge store dataEpics.ts with pending changes\r\n let data: TreeAssociatedRecord[] = storeData.map(item => {\r\n const pendingChanges = state.view.pendingDataChanges[popupBcName]?.[item.id]\r\n return { ...item, ...pendingChanges }\r\n })\r\n const removedItem = data.find(item => item.id === action.payload.removedItem.id)\r\n /**\r\n * It seems `_associate` is always false for full hierarchies\r\n * so we rely on source record value instead\r\n */\r\n const associated = action.payload.dataItem.map(item => item.id)\r\n let removedNodes: string[] = []\r\n if (widget?.options?.hierarchyGroupDeselection) {\r\n // Builds a tree to simplify searching of descendants\r\n if (widget?.options?.hierarchyTraverse) {\r\n data = assignTreeLinks(data)\r\n }\r\n const removedItemChildren = data.filter(item => item.parentId === removedItem?.id)\r\n removedNodes = [removedItem?.id, ...removedItemChildren.filter(item => associated.includes(item.id)).map(item => item.id)]\r\n if (widget?.options?.hierarchyTraverse) {\r\n getDescendants(removedItemChildren, removedNodes)\r\n removedNodes = data.filter(item => removedNodes.includes(item.id) && associated.includes(item.id)).map(item => item.id)\r\n }\r\n const parent = data.find(item => item.id === removedItem?.parentId)\r\n const siblings = data.filter(item => item.parentId === parent?.id)\r\n const parentEmpty = siblings.every(child => removedNodes.includes(child.id) || !associated.includes(child.id))\r\n // If last child/descendant removed, parent also should be\r\n if (parent && parentEmpty) {\r\n // Last descendant\r\n if (widget?.options?.hierarchyTraverse) {\r\n const parentDescendants: string[] = []\r\n getDescendants(siblings, parentDescendants)\r\n const parentDeepEmpty = parentDescendants.every(descendant => {\r\n return removedNodes.includes(descendant) || !associated.includes(descendant)\r\n })\r\n if (parentDeepEmpty) {\r\n return concat(\r\n of(\r\n removeMultivalueTag({\r\n ...action.payload,\r\n removedItem: { id: parent.id, value: null }\r\n })\r\n )\r\n )\r\n }\r\n } else {\r\n // Last child\r\n removedNodes.push(parent.id)\r\n }\r\n }\r\n }\r\n // Full hierarchies just filter out selected records\r\n if (widget?.options?.hierarchyFull) {\r\n return of(\r\n changeDataItem({\r\n bcName,\r\n bcUrl: buildBcUrl(bcName, true, state),\r\n cursor,\r\n dataItem: { [associateFieldKey]: action.payload.dataItem.filter(item => !removedNodes.includes(item.id)) }\r\n })\r\n )\r\n }\r\n const disableSecondDataChangeForAssocPopup =\r\n state.session.disableDeprecatedFeatures?.secondDataChangeForAssocPopupWhenRemovingTagFromField\r\n\r\n // Non-full hierarchies drops removed item's `_associate` flag`\r\n // And also updates source record value\r\n if (widget?.options?.hierarchy) {\r\n const hierarchyBcName =\r\n widget?.options?.hierarchy?.find(hierarchyData => {\r\n return state.view.pendingDataChanges[hierarchyData.bcName]?.[action.payload.removedItem.id]\r\n })?.bcName ?? bcName\r\n\r\n return concat(\r\n disableSecondDataChangeForAssocPopup\r\n ? EMPTY\r\n : of(\r\n changeDataItem({\r\n /**\r\n * This is incorrect and will break if different BC has records with\r\n * identical ids.\r\n *\r\n * TODO: Record `level` should be mapped to hierarchyData index instead\r\n */\r\n bcName: hierarchyBcName,\r\n bcUrl: buildBcUrl(hierarchyBcName, true, state),\r\n\r\n cursor: action.payload.removedItem.id,\r\n dataItem: { ...(action.payload.removedItem as any), _associate: false }\r\n })\r\n ),\r\n of(\r\n changeDataItem({\r\n bcName,\r\n bcUrl: buildBcUrl(bcName, true, state),\r\n cursor,\r\n dataItem: { [associateFieldKey]: action.payload.dataItem }\r\n })\r\n )\r\n )\r\n }\r\n // Non hierarchies drops removed item's `_associate` flag` from popup BC\r\n // And also updates source record value\r\n return concat(\r\n disableSecondDataChangeForAssocPopup\r\n ? EMPTY\r\n : of(\r\n changeDataItem({\r\n bcName: popupBcName,\r\n bcUrl: buildBcUrl(popupBcName, true, state),\r\n cursor: action.payload.removedItem.id,\r\n dataItem: { ...(action.payload.removedItem as any), _associate: false }\r\n })\r\n ),\r\n of(\r\n changeDataItem({\r\n bcName,\r\n bcUrl: buildBcUrl(bcName, true, state),\r\n cursor,\r\n dataItem: { [associateFieldKey]: action.payload.dataItem }\r\n })\r\n )\r\n )\r\n })\r\n )\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { buildBcUrl } from '../../utils'\r\nimport { AssociatedItem, CXBoxEpic } from '../../interfaces'\r\nimport { catchError, concat, EMPTY, filter, mergeMap, of, switchMap } from 'rxjs'\r\nimport {\r\n associateInProgress,\r\n bcCancelPendingChanges,\r\n bcForceUpdate,\r\n processPostInvoke,\r\n saveAssociations,\r\n setOperationFinished\r\n} from '../../actions'\r\n\r\n/**\r\n * Works with assoc-lists, which does call back-end's assoc methods by click on confirm button in modal window\r\n *\r\n * @category Epics\r\n */\r\nexport const saveAssociationsActiveEpic: CXBoxEpic = (action$, state$, { api }) =>\r\n action$.pipe(\r\n filter(saveAssociations.match),\r\n filter(action => {\r\n return state$.value.view.popupData?.active\r\n }),\r\n switchMap(action => {\r\n const state = state$.value\r\n const calleeBCName = state.view.popupData?.calleeBCName\r\n const calleeWidgetName = state.view.popupData?.calleeWidgetName\r\n const popupBcName = state.view.popupData?.bcName\r\n const bcNames = action.payload.bcNames\r\n const bcUrl = buildBcUrl(calleeBCName, true, state)\r\n const pendingChanges = state.view.pendingDataChanges[bcNames[0]] || {}\r\n const params: Record<string, any> = bcNames.length ? { _bcName: bcNames[bcNames.length - 1] } : {}\r\n\r\n return concat(\r\n of(associateInProgress({ bcName: popupBcName })),\r\n api\r\n .associate(\r\n state.screen.screenName,\r\n bcUrl,\r\n (Object.values(pendingChanges) as AssociatedItem[]).filter(i => i._associate),\r\n params\r\n )\r\n .pipe(\r\n mergeMap(response => {\r\n const postInvoke = response.postActions[0]\r\n const calleeWidget = state.view.widgets.find(widgetItem => widgetItem.bcName === calleeBCName)\r\n return concat(\r\n of(setOperationFinished({ bcName: popupBcName, operationType: 'saveAssociations' })),\r\n postInvoke\r\n ? of(processPostInvoke({ bcName: calleeBCName, postInvoke, widgetName: calleeWidget?.name }))\r\n : EMPTY,\r\n of(bcCancelPendingChanges({ bcNames: bcNames })),\r\n of(bcForceUpdate({ bcName: calleeBCName, widgetName: calleeWidgetName }))\r\n )\r\n }),\r\n catchError(err => {\r\n console.error(err)\r\n return of(setOperationFinished({ bcName: popupBcName, operationType: 'saveAssociations' }))\r\n })\r\n )\r\n )\r\n })\r\n )\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { AssociatedItem, CXBoxEpic } from '../../interfaces'\r\nimport { filter, of, switchMap } from 'rxjs'\r\nimport { changeDataItem, saveAssociations } from '../../actions'\r\nimport { MultivalueSingleValue } from '@cxbox-ui/schema'\r\nimport { buildBcUrl } from '../../utils'\r\n\r\n/**\r\n * Works with assoc-lists, which doesn't call back-end's assoc methods\r\n *\r\n * @category Epics\r\n */\r\nexport const saveAssociationsPassiveEpic: CXBoxEpic = (action$, state$) =>\r\n action$.pipe(\r\n filter(saveAssociations.match),\r\n filter(() => {\r\n return !state$.value.view.popupData?.active\r\n }),\r\n switchMap(action => {\r\n const state = state$.value\r\n const { calleeBCName = action.payload.calleeBcName, associateFieldKey = action.payload.associateFieldKey } =\r\n state.view.popupData ?? {}\r\n const cursor = state.screen.bo.bc[calleeBCName].cursor\r\n const recordPrevData = (state.data[calleeBCName].find(dataStateRecord => dataStateRecord.id === cursor)[associateFieldKey] ??\r\n []) as MultivalueSingleValue[]\r\n const newValues: AssociatedItem[] = []\r\n\r\n action.payload.bcNames.forEach(pendingBc => {\r\n const pendingChanges = state.view.pendingDataChanges[pendingBc] || {}\r\n Object.entries(pendingChanges).forEach(([id, item]) => {\r\n newValues.push(item as AssociatedItem)\r\n })\r\n })\r\n\r\n const addedItems = newValues\r\n .filter(newItem => {\r\n const isNew = !recordPrevData.find(prevItem => prevItem.id === newItem.id) && newItem._associate\r\n return isNew\r\n })\r\n .map(newItem => ({\r\n id: newItem.id,\r\n options: {},\r\n value: newItem._value as string\r\n }))\r\n\r\n const result = recordPrevData\r\n .filter(prevItem => {\r\n const removedItem = newValues.find(item => item.id === prevItem.id)\r\n if (removedItem && removedItem?._associate === false) {\r\n return false\r\n }\r\n return true\r\n })\r\n .concat(...addedItems)\r\n\r\n return of(\r\n changeDataItem({\r\n bcName: calleeBCName,\r\n bcUrl: buildBcUrl(calleeBCName, true, state),\r\n cursor: cursor,\r\n dataItem: {\r\n [associateFieldKey]: result\r\n }\r\n })\r\n )\r\n })\r\n )\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { CXBoxEpic } from '../../interfaces'\r\nimport { filter, map } from 'rxjs'\r\nimport { addNotification, selectScreenFail } from '../../actions'\r\n\r\n/**\r\n * Throws a error popup when attempting to navigate to a screen which is missing for current session\r\n *\r\n * @param action$ selectViewFail\r\n */\r\nexport const selectScreenFailEpic: CXBoxEpic = action$ =>\r\n action$.pipe(\r\n filter(selectScreenFail.match),\r\n map(action => {\r\n return addNotification({\r\n type: 'error',\r\n key: 'selectScreenFail',\r\n message: 'Screen is missing or unavailable for your role',\r\n options: {\r\n messageOptions: { screenName: action.payload.screenName }\r\n },\r\n duration: 15\r\n })\r\n })\r\n )\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { bcSelectRecord, selectTableRow, selectTableRowInit } from '../../actions'\r\nimport { CXBoxEpic } from '../../interfaces'\r\nimport { concat, filter, mergeMap, Observable, of } from 'rxjs'\r\nimport { AnyAction } from '@reduxjs/toolkit'\r\n\r\nexport const selectTableRowInitEpic: CXBoxEpic = (action$, state$) =>\r\n action$.pipe(\r\n filter(selectTableRowInit.match),\r\n mergeMap(action => {\r\n const resultObservables: Array<Observable<AnyAction>> = []\r\n const state = state$.value\r\n\r\n const { rowId: nextRowId } = action.payload\r\n\r\n const nextWidget = state.view.widgets.find(widget => widget.name === action.payload.widgetName)\r\n const nextBcName = nextWidget?.bcName\r\n const nextBcCursor = state.screen.bo.bc[nextBcName]?.cursor\r\n\r\n const selectedCell = state.view.selectedRow\r\n if (nextRowId !== nextBcCursor) {\r\n resultObservables.push(of(bcSelectRecord({ bcName: nextBcName, cursor: nextRowId })))\r\n }\r\n\r\n if (!selectedCell || nextRowId !== selectedCell.rowId || nextWidget?.name !== selectedCell.widgetName) {\r\n resultObservables.push(of(selectTableRow({ widgetName: nextWidget?.name, rowId: nextRowId })))\r\n }\r\n\r\n return concat(...resultObservables)\r\n })\r\n )\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { CXBoxEpic, EpicDependencyInjection, Store, WidgetMeta } from '../../interfaces'\r\nimport { EMPTY, filter, mergeMap } from 'rxjs'\r\nimport { bcFetchDataRequest, selectView } from '../../actions'\r\nimport { getWidgetsForLazyLoad } from '../../utils'\r\n\r\n/**\r\n * Schedules dataEpics.ts fetch for every widget on the view\r\n *\r\n * After selecting a view, this epic schedules a dataEpics.ts fetch for every widget present on the view.\r\n * If business componenet for the widget has a parent, then root ancestor BC is scheduled for dataEpics.ts fetch instead\r\n * and dataEpics.ts for its descendants will be scheduled after ancestor dataEpics.ts fetch resolved.\r\n *\r\n * @see {@link src/epics/dataEpics.ts/bcFetchDataEpic.ts} for details how descendants resolved\r\n */\r\nexport const selectViewEpic: CXBoxEpic = (action$, state$, { utils }) =>\r\n action$.pipe(\r\n filter(selectView.match),\r\n mergeMap(action => {\r\n /**\r\n * Default implementation for `selectView` epic.\r\n *\r\n * Schedules dataEpics.ts fetch for every widget on the view\r\n *\r\n * After selecting a view, this epic schedules a dataEpics.ts fetch for every widget present on the view.\r\n * If business componenet for the widget has a parent, then root ancestor BC is scheduled for dataEpics.ts fetch instead\r\n * and dataEpics.ts for its descendants will be scheduled after ancestor dataEpics.ts fetch resolved.\r\n *\r\n * @see {@link src/epics/dataEpics.ts/bcFetchDataEpic.ts} for details how descendants resolved\r\n */\r\n try {\r\n const state = state$.value\r\n if (action.payload.isTab) {\r\n return lazyLoad(state, utils?.getInternalWidgets)\r\n }\r\n\r\n return fullLoad(state, utils?.getInternalWidgets)\r\n } catch (e) {\r\n console.error(`selectView Epic:: ${e}`)\r\n return EMPTY\r\n }\r\n })\r\n )\r\n\r\nfunction fullLoad<S extends Store>(state: S, getInternalWidgets: EpicDependencyInjection['utils']['getInternalWidgets']) {\r\n const bcToLoad: Record<string, WidgetMeta> = {}\r\n const lazyWidgetNames = getWidgetsForLazyLoad(state.view.widgets, getInternalWidgets)\r\n\r\n state.view.widgets\r\n .filter(widget => !lazyWidgetNames.includes(widget.name))\r\n .forEach(widget => {\r\n if (widget.bcName) {\r\n let bcName = widget.bcName\r\n let parentName = state.screen.bo.bc[widget.bcName].parentName\r\n while (parentName) {\r\n bcName = parentName\r\n parentName = state.screen.bo.bc[parentName].parentName\r\n }\r\n\r\n if (!bcToLoad[bcName]) {\r\n bcToLoad[bcName] = widget\r\n }\r\n }\r\n })\r\n\r\n return Object.entries(bcToLoad).map(([bcName, widget]) => {\r\n // TODO: Row meta request should be scheduled after `bcFetchDataSuccess` here\r\n // (now it is scheduled in bcFetchDataRequest epic)\r\n return bcFetchDataRequest({ widgetName: widget.name, bcName })\r\n })\r\n}\r\n\r\n/**\r\n * Here is a list of bc that require downloading.\r\n * Either bc that have no data are loaded, or the cursor has been reset.\r\n * It is assumed that the cursor for a non-displayed bookmaker will be reset if the parent cursor has changed.\r\n */\r\nfunction lazyLoad<S extends Store>(state: S, getInternalWidgets: EpicDependencyInjection['utils']['getInternalWidgets']) {\r\n const bcToLoad: Record<string, WidgetMeta> = {}\r\n const data = state.data\r\n const bcDictionary = state.screen.bo.bc\r\n const hasBcData = (bcName?: string) => (bcName ? bcName in data : false)\r\n const cursorIsNull = (bcName?: string) => (bcName ? bcDictionary[bcName]?.cursor === null : false)\r\n const hasBcCursor = (bcName?: string) => (bcName ? !!bcDictionary[bcName]?.cursor : false)\r\n const hasBcParent = (bcName?: string) => !!bcDictionary[bcName]?.parentName\r\n const lazyWidgetNames = getWidgetsForLazyLoad(state.view.widgets, getInternalWidgets)\r\n\r\n state.view.widgets\r\n .filter(widget => !lazyWidgetNames.includes(widget.name))\r\n .forEach(widget => {\r\n if (widget.bcName && (!hasBcData(widget.bcName) || cursorIsNull(widget.bcName))) {\r\n let bcName = widget.bcName\r\n let parentName = bcDictionary[widget.bcName].parentName\r\n\r\n while (parentName && (!hasBcData(parentName) || cursorIsNull(parentName))) {\r\n bcName = parentName\r\n parentName = bcDictionary[parentName].parentName\r\n }\r\n\r\n if (!bcToLoad[bcName] && (!hasBcParent(bcName) || hasBcCursor(bcDictionary[bcName]?.parentName))) {\r\n bcToLoad[bcName] = widget\r\n }\r\n }\r\n })\r\n\r\n return Object.entries(bcToLoad).map(([bcName, widget]) => {\r\n // TODO: Row meta request should be scheduled after `bcFetchDataSuccess` here\r\n // (now it is scheduled in bcFetchDataRequest epic)\r\n return bcFetchDataRequest({ widgetName: widget.name, bcName })\r\n })\r\n}\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { CXBoxEpic } from '../../interfaces'\r\nimport { filter, map } from 'rxjs'\r\nimport { addNotification, selectViewFail } from '../../actions'\r\n\r\n/**\r\n * Throws a error popup when attempting to navigate to the view which is missing for current session\r\n *\r\n */\r\nexport const selectViewFailEpic: CXBoxEpic = (action$, state$) =>\r\n action$.pipe(\r\n filter(selectViewFail.match),\r\n map(action => {\r\n return addNotification({\r\n type: 'error',\r\n key: 'selectViewFail',\r\n message: 'View is missing or unavailable for your role',\r\n options: {\r\n messageOptions: { viewName: action.payload.viewName }\r\n },\r\n duration: 15\r\n })\r\n })\r\n )\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { CXBoxEpic } from '../../interfaces'\r\nimport { filter, map } from 'rxjs'\r\nimport { sendOperation, showFileUploadPopup, showViewPopup } from '../../actions'\r\nimport { buildBcUrl, flattenOperations, matchOperationRole } from '../../utils'\r\nimport { OperationTypeCrud } from '@cxbox-ui/schema'\r\n\r\n/**\r\n * Opens a popup with associate component.\r\n */\r\nexport const sendOperationAssociateEpic: CXBoxEpic = (action$, state$) =>\r\n action$.pipe(\r\n filter(sendOperation.match),\r\n filter(action => matchOperationRole(OperationTypeCrud.associate, action.payload, state$.value)),\r\n map(action => {\r\n const state = state$.value\r\n const bcUrl = buildBcUrl(action.payload.bcName, true, state)\r\n const operations = flattenOperations(state.view.rowMeta[action.payload.bcName]?.[bcUrl]?.actions)\r\n const operation = operations.find(item => item.type === action.payload.operationType)\r\n if (operation.subtype === 'multiFileUpload') {\r\n return showFileUploadPopup({\r\n widgetName: action.payload.widgetName\r\n })\r\n }\r\n return showViewPopup({\r\n // TODO: 2.0.0 bcKey and bcName will be removed in favor `widgetName`\r\n bcName: action.payload.bcKey ? `${action.payload.bcKey}` : `${action.payload.bcName}Assoc`,\r\n calleeBCName: action.payload.bcName,\r\n active: true,\r\n calleeWidgetName: action.payload.widgetName\r\n })\r\n })\r\n )\r\n","import { catchError, EMPTY, filter, map, switchMap, take, withLatestFrom } from 'rxjs'\r\nimport { isAnyOf } from '@reduxjs/toolkit'\r\nimport { addNotification, forceActiveChangeFail, forceActiveRmUpdate, sendOperation, setPendingSendOperation } from '../../actions'\r\nimport { CXBoxEpic } from '../../interfaces'\r\nimport { buildBcUrl, flattenOperations } from '../../utils'\r\n\r\nexport const setPendingSendOperationEpic: CXBoxEpic = (action$, state$) =>\r\n action$.pipe(\r\n filter(setPendingSendOperation.match),\r\n switchMap(action => {\r\n return action$.pipe(\r\n filter(isAnyOf(forceActiveRmUpdate, forceActiveChangeFail)),\r\n take(1),\r\n withLatestFrom(state$),\r\n map(([_, state]) => {\r\n const { operationType, widgetName } = action.payload\r\n const bcName = state.view.widgets.find(widgetItem => widgetItem.name === widgetName)?.bcName\r\n const bcUrl = buildBcUrl(bcName, true, state)\r\n const rowMeta = bcUrl && state.view.rowMeta[bcName]?.[bcUrl]\r\n const actions = rowMeta && flattenOperations(rowMeta.actions)\r\n const operation = actions?.find(item => item.type === operationType)\r\n\r\n return operation\r\n ? sendOperation({ ...action.payload, confirmOperation: operation.preInvoke, bcKey: operation.bcKey })\r\n : addNotification({\r\n key: 'rowMetaActionMissing',\r\n type: 'error',\r\n message: 'Operation not available',\r\n options: {\r\n messageOptions: { operationType }\r\n },\r\n duration: 15\r\n })\r\n }),\r\n catchError(() => EMPTY)\r\n )\r\n })\r\n )\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { CXBoxEpic } from '../../interfaces'\r\nimport { concat, filter, mergeMap, Observable, of } from 'rxjs'\r\nimport { bcChangeCursors, bcForceUpdate, changeLocation, showAllTableRecordsInit } from '../../actions'\r\nimport { AnyAction } from '@reduxjs/toolkit'\r\nimport { defaultBuildURL, defaultParseURL } from '../../utils'\r\n\r\nexport const showAllTableRecordsInitEpic: CXBoxEpic = (action$, state$) =>\r\n action$.pipe(\r\n filter(showAllTableRecordsInit.match),\r\n mergeMap(action => {\r\n const resultObservables: Array<Observable<AnyAction>> = []\r\n\r\n const { bcName, cursor } = action.payload\r\n const state = state$.value\r\n const route = state.router\r\n\r\n resultObservables.push(of(bcChangeCursors({ cursorsMap: { [bcName]: null } })))\r\n\r\n const bcPath = route.bcPath.slice(0, route.bcPath.indexOf(`${bcName}/${cursor}`))\r\n const url = defaultBuildURL({ ...route, bcPath })\r\n\r\n resultObservables.push(of(bcForceUpdate({ bcName })))\r\n resultObservables.push(of(changeLocation({ location: defaultParseURL(new URL(url, window.location.origin)) })))\r\n\r\n return concat(...resultObservables)\r\n })\r\n )\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { CXBoxEpic, PendingDataItem } from '../../interfaces'\r\nimport { EMPTY, filter, mergeMap, of } from 'rxjs'\r\nimport { changeDataItems, showViewPopup } from '../../actions'\r\nimport { MultivalueSingleValue, WidgetTypes } from '@cxbox-ui/schema'\r\n\r\nexport const showAssocPopupEpic: CXBoxEpic = (action$, state$) =>\r\n action$.pipe(\r\n filter(showViewPopup.match),\r\n filter(action => !!(action.payload.calleeBCName && action.payload.associateFieldKey)),\r\n mergeMap(action => {\r\n const { bcName, calleeBCName } = action.payload\r\n\r\n const state = state$.value\r\n\r\n const assocWidget = state.view.widgets.find(widget => widget.bcName === bcName && widget.type === WidgetTypes.AssocListPopup)\r\n const calleeCursor = state.screen.bo.bc[calleeBCName]?.cursor\r\n const calleePendingChanges = state.view.pendingDataChanges[calleeBCName]?.[calleeCursor]\r\n const assocFieldKey = action.payload.associateFieldKey\r\n const assocFieldChanges = calleePendingChanges?.[assocFieldKey] as MultivalueSingleValue[]\r\n const somethingMissing = !assocWidget || !calleePendingChanges || !assocFieldChanges || !assocFieldChanges\r\n if (somethingMissing || (assocWidget.options && !assocWidget.options.hierarchyFull)) {\r\n return EMPTY\r\n }\r\n\r\n const popupInitPendingChanges: Record<string, PendingDataItem> = {}\r\n\r\n assocFieldChanges.forEach(record => {\r\n popupInitPendingChanges[record.id] = {\r\n id: record.id,\r\n _associate: true,\r\n _value: record.value\r\n }\r\n })\r\n\r\n const calleeData = state.data[calleeBCName]?.find(dataRecord => dataRecord.id === calleeCursor)\r\n const assocIds = (calleeData?.[assocFieldKey] as MultivalueSingleValue[])?.map(recordId => recordId.id)\r\n const assocPendingIds = assocFieldChanges.map(recordId => recordId.id)\r\n if (assocIds) {\r\n assocIds.forEach(recordId => {\r\n if (!assocPendingIds.includes(recordId)) {\r\n popupInitPendingChanges[recordId] = {\r\n id: recordId,\r\n _associate: false\r\n }\r\n }\r\n })\r\n }\r\n\r\n return of(\r\n changeDataItems({\r\n bcName,\r\n cursors: Object.keys(popupInitPendingChanges),\r\n dataItems: Object.values(popupInitPendingChanges)\r\n })\r\n )\r\n })\r\n )\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { CXBoxEpic } from '../../interfaces'\r\nimport { bcChangeCursors, sendOperation, showFileUploadPopup } from '../../actions'\r\nimport { concat, filter, mergeMap, of } from 'rxjs'\r\nimport { matchOperationRole } from '../../utils'\r\nimport { OperationTypeCrud } from '@cxbox-ui/schema'\r\n\r\n/**\r\n * Fires `bcChangeCursors` and `showFileUploadPopupEpic` to drop the cursors and show file upload popup.\r\n */\r\nexport const showFileUploadPopupEpic: CXBoxEpic = (action$, state$) =>\r\n action$.pipe(\r\n filter(sendOperation.match),\r\n filter(action => matchOperationRole(OperationTypeCrud.fileUpload, action.payload, state$.value)),\r\n mergeMap(action => {\r\n return concat(\r\n of(bcChangeCursors({ cursorsMap: { [action.payload.bcName]: null } })),\r\n of(showFileUploadPopup({ widgetName: action.payload.widgetName }))\r\n )\r\n })\r\n )\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { CXBoxEpic } from '../../interfaces'\r\nimport { login, logoutDone, switchRole } from '../../actions'\r\nimport { concat, filter, switchMap } from 'rxjs'\r\n\r\n/**\r\n * Activates process of role switching\r\n */\r\nexport const switchRoleEpic: CXBoxEpic = (action$, state$) =>\r\n action$.pipe(\r\n filter(switchRole.match),\r\n switchMap(action => {\r\n return concat([logoutDone(null), login({ login: '', password: '', role: action.payload.role })])\r\n })\r\n )\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { CXBoxEpic } from '../../interfaces'\r\nimport { filter, map } from 'rxjs'\r\nimport { bcChangeCursors, emptyAction, userDrillDown } from '../../actions'\r\n\r\nexport const userDrillDownChangeCursorsEpic: CXBoxEpic = (action$, state$) =>\r\n action$.pipe(\r\n filter(userDrillDown.match),\r\n map(action => {\r\n const state = state$.value\r\n const widget = state.view.widgets.find(item => item.name === action.payload.widgetName)\r\n const cursor = state.screen.bo.bc[widget?.bcName]?.cursor\r\n\r\n if (cursor !== action.payload.cursor) {\r\n return bcChangeCursors({ cursorsMap: { [action.payload.bcName]: action.payload.cursor } })\r\n }\r\n\r\n return emptyAction\r\n })\r\n )\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { buildBcUrl } from '../../utils'\r\nimport { CXBoxEpic, DrillDownType, WidgetFieldBase } from '../../interfaces'\r\nimport { catchError, concat, EMPTY, filter, mergeMap, of, switchMap } from 'rxjs'\r\nimport { bcFetchRowMetaSuccess, drillDown, userDrillDown, userDrillDownSuccess } from '../../actions'\r\nimport { createApiErrorObservable } from '../../utils/apiError'\r\n\r\n/**\r\n *\r\n * @category Epics\r\n */\r\n\r\nexport const userDrillDownEpic: CXBoxEpic = (action$, state$, { api }) =>\r\n action$.pipe(\r\n filter(userDrillDown.match),\r\n switchMap(action => {\r\n /**\r\n * Default implementation for `userDrillDown` epic.\r\n *\r\n * Sends a request to fetch row meta; will write a console error if request fails.\r\n * Otherwise, a chain of actions will be dispatched:\r\n *\r\n * - {@link bcFetchRowMetaSuccess} for drilldowns not of {@link DrillDownType.inner} type\r\n * - {@link userDrillDownSuccess}\r\n * - {@link drillDown}\r\n *\r\n * Drilldown url is taken from {@link WidgetFieldBase.drillDown | WidgetField.drillDown} property in widget meta configuration or from record\r\n * directly if record's property specified in {@link WidgetFieldBase.drillDownKey | WidgetField.drillDownKey}\r\n *\r\n * @param action This epic will fire on {@link ActionPayloadTypes.userDrillDown | userDrillDown} action\r\n * @param store Redux store instance\r\n * @category Epics\r\n */\r\n\r\n const state = state$.value\r\n const { bcName, fieldKey, cursor } = action.payload\r\n const bcUrl = buildBcUrl(bcName, true, state)\r\n return api.fetchRowMeta(state.screen.screenName, bcUrl).pipe(\r\n mergeMap(rowMeta => {\r\n const drillDownField = rowMeta.fields.find(field => field.key === fieldKey)\r\n const route = state.router\r\n const drillDownKey = (\r\n state.view.widgets\r\n .find(widget => widget.bcName === bcName)\r\n ?.fields.find((field: WidgetFieldBase) => field.key === fieldKey) as WidgetFieldBase\r\n )?.drillDownKey\r\n const customDrillDownUrl = state.data[bcName]?.find(record => record.id === cursor)?.[drillDownKey] as string\r\n /**\r\n * It seems that behavior is wrong here; matching route condition will probably never be hit\r\n *\r\n * TODO: Review this case and either make condition strict or remove it completely\r\n */\r\n return customDrillDownUrl || drillDownField?.drillDown || drillDownField?.drillDown !== route.path\r\n ? concat(\r\n drillDownField?.drillDownType !== DrillDownType.inner\r\n ? of(bcFetchRowMetaSuccess({ bcName, rowMeta, bcUrl, cursor }))\r\n : EMPTY,\r\n of(userDrillDownSuccess({ bcName, bcUrl, cursor })),\r\n of(\r\n drillDown({\r\n url: customDrillDownUrl || drillDownField.drillDown,\r\n drillDownType: drillDownField.drillDownType as DrillDownType,\r\n route\r\n })\r\n )\r\n )\r\n : EMPTY\r\n }),\r\n catchError(error => {\r\n console.error(error)\r\n return createApiErrorObservable(error) // TODO:\r\n })\r\n )\r\n })\r\n )\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse, Method } from 'axios'\r\nimport { CxboxResponse } from '../interfaces'\r\nimport { ApiCallContext, applyParams, parseFilters } from '../utils'\r\nimport { from, map, takeWhile } from 'rxjs'\r\n\r\nfunction redirectOccurred<R extends CxboxResponse>(value: AxiosResponse<R>) {\r\n if (value.data?.redirectUrl) {\r\n let redirectUrl = value.data.redirectUrl\r\n if (!redirectUrl.startsWith('/') && !redirectUrl.match('^http(.?)://')) {\r\n redirectUrl = `${window.location.pathname}#/${redirectUrl}`\r\n }\r\n if (redirectUrl.startsWith('/') && !redirectUrl.startsWith('//')) {\r\n redirectUrl = `${window.location.origin}${redirectUrl}`\r\n }\r\n window.location.replace(redirectUrl)\r\n return false\r\n }\r\n return true\r\n}\r\n\r\nconst mergeConfigWithData = (data: any, config?: AxiosRequestConfig) => {\r\n return { ...config, data: config?.data !== undefined ? config.data : data }\r\n}\r\n\r\nexport class ObservableApiWrapper {\r\n instance: AxiosInstance = axios.create({\r\n responseType: 'json',\r\n headers: { Pragma: 'no-cache', 'Cache-Control': 'no-cache, no-store, must-revalidate' }\r\n })\r\n\r\n maxUrlLength: number = Infinity\r\n\r\n filterTypes: string[] = []\r\n\r\n constructor(instance: AxiosInstance, maxUrlLength?: number, filterTypes?: string[]) {\r\n this.instance = instance\r\n this.maxUrlLength = maxUrlLength ?? this.maxUrlLength\r\n this.filterTypes = filterTypes ?? this.filterTypes\r\n }\r\n\r\n request<ResponsePayload extends CxboxResponse>(method: Method, path: string, config?: AxiosRequestConfig) {\r\n let params = config?.params\r\n let data = config?.data\r\n\r\n const processedConfig = { ...config }\r\n\r\n delete processedConfig['params']\r\n delete processedConfig['data']\r\n\r\n let url = applyParams(path, params)\r\n\r\n const isLongUrl = url.length > this.maxUrlLength\r\n let resultMethod = method\r\n\r\n if (isLongUrl && this.filterTypes.length) {\r\n const paramsHasFilter =\r\n typeof params === 'object' &&\r\n params !== null &&\r\n Object.keys(params).some(key => this.filterTypes.includes(key.split('.')[1]))\r\n const dataCanBeEdited = (typeof data === 'object' && data !== null) || data === undefined\r\n\r\n if (paramsHasFilter && dataCanBeEdited) {\r\n resultMethod = method.toLowerCase() === 'get' ? 'post' : method\r\n\r\n params = { ...params }\r\n\r\n const filter: Record<string, unknown> = {}\r\n\r\n Object.entries(params).forEach(([key, value]) => {\r\n if (this.filterTypes.includes(key.split('.')[1])) {\r\n filter[key] = value\r\n delete params[key]\r\n }\r\n })\r\n\r\n const processedFilter = Object.keys(filter).length\r\n ? parseFilters(applyParams('', filter as Record<string, string | number>))\r\n : undefined\r\n\r\n data = {\r\n ...data,\r\n filter: processedFilter\r\n }\r\n\r\n url = applyParams(path, params)\r\n }\r\n }\r\n\r\n return from(\r\n this.instance.request<ResponsePayload>({\r\n method: resultMethod,\r\n data,\r\n url,\r\n ...processedConfig\r\n })\r\n ).pipe(takeWhile(redirectOccurred))\r\n }\r\n\r\n get<ResponsePayload extends CxboxResponse>(path: string, config?: AxiosRequestConfig, callContext?: ApiCallContext) {\r\n return this.request<ResponsePayload>('get', path, config).pipe(map(response => response.data))\r\n }\r\n put<ResponsePayload extends CxboxResponse>(path: string, data: any, callContext?: ApiCallContext, config?: AxiosRequestConfig) {\r\n return this.request<ResponsePayload>('put', path, mergeConfigWithData(data, config)).pipe(map(response => response.data))\r\n }\r\n post<ResponsePayload extends CxboxResponse>(path: string, data: any, config?: AxiosRequestConfig, callContext?: ApiCallContext) {\r\n return this.request<ResponsePayload>('post', path, mergeConfigWithData(data, config)).pipe(map(response => response.data))\r\n }\r\n delete<ResponsePayload extends CxboxResponse>(path: string, data: any, config?: AxiosRequestConfig, callContext?: ApiCallContext) {\r\n return this.request<ResponsePayload>('delete', path, mergeConfigWithData(data, config)).pipe(map(response => response.data))\r\n }\r\n}\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { ObservableApiWrapper } from './ObservableApiWrapper'\r\nimport axios, { AxiosInstance, CancelToken } from 'axios'\r\nimport { ApiCallContext, buildUrl } from '../utils'\r\nimport { AssociatedItem, BcDataResponse, DataItem, DataItemResponse, LoginResponse, PendingDataItem, RowMetaResponse } from '../interfaces'\r\nimport { EMPTY, expand, map, reduce } from 'rxjs'\r\n\r\ntype GetParamsMap = Record<string, string | number>\r\n\r\nexport class Api {\r\n api$: ObservableApiWrapper\r\n\r\n constructor(instance: AxiosInstance, maxUrlLength?: number, filterTypes?: string[]) {\r\n this.api$ = new ObservableApiWrapper(instance, maxUrlLength, filterTypes)\r\n }\r\n\r\n routerRequest(path: string, params: Record<string, unknown>) {\r\n return this.api$.request('get', path, { params }).pipe(map(response => response.data))\r\n }\r\n\r\n fetchBcData(screenName: string, bcUrl: string, params: GetParamsMap = {}, cancelToken?: CancelToken) {\r\n const noLimit = params._limit === 0\r\n const queryStringObject = {\r\n ...params,\r\n _page: !noLimit ? ('_page' in params ? params._page : 1) : undefined,\r\n _limit: !noLimit ? ('_limit' in params ? params._limit : 30) : undefined\r\n }\r\n\r\n return this.api$\r\n .request<BcDataResponse>('get', buildUrl`data/${screenName}/` + bcUrl, { params: queryStringObject, cancelToken })\r\n .pipe(map(response => response.data))\r\n }\r\n\r\n fetchBcDataAll(screenName: string, bcUrl: string, params: GetParamsMap = {}) {\r\n let currentPage = 1\r\n\r\n return this.fetchBcData(screenName, bcUrl, { ...params, _page: currentPage }).pipe(\r\n expand(response => {\r\n return response.hasNext ? this.fetchBcData(screenName, bcUrl, { ...params, _page: ++currentPage }) : EMPTY\r\n }),\r\n reduce((items, nextResponse) => {\r\n return [...items, ...nextResponse.data]\r\n }, [] as DataItem[])\r\n )\r\n }\r\n\r\n fetchRowMeta(screenName: string, bcUrl: string, params?: GetParamsMap, cancelToken?: CancelToken) {\r\n return this.api$\r\n .request<RowMetaResponse>('get', buildUrl`row-meta/${screenName}/` + bcUrl, { params, cancelToken })\r\n .pipe(map(response => response.data.data.row))\r\n }\r\n\r\n newBcData(screenName: string, bcUrl: string, context: ApiCallContext, params?: GetParamsMap) {\r\n return this.api$\r\n .request<RowMetaResponse>('get', buildUrl`row-meta-new/${screenName}/` + bcUrl, { params })\r\n .pipe(map(response => response.data.data))\r\n }\r\n\r\n saveBcData(\r\n screenName: string,\r\n bcUrl: string,\r\n data: PendingDataItem & { vstamp: number },\r\n context: ApiCallContext,\r\n params?: GetParamsMap\r\n ) {\r\n return this.api$\r\n .request<DataItemResponse>('put', buildUrl`data/${screenName}/` + bcUrl, { data: { data }, params })\r\n .pipe(map(response => response.data.data))\r\n }\r\n\r\n deleteBcData(screenName: string, bcUrl: string = '', context: ApiCallContext, params?: GetParamsMap) {\r\n return this.api$\r\n .request<DataItemResponse>('delete', buildUrl`data/${screenName}/` + bcUrl, { params })\r\n .pipe(map(response => response.data.data))\r\n }\r\n\r\n customAction(screenName: string, bcUrl: string, data?: Record<string, any>, context?: ApiCallContext, params?: GetParamsMap) {\r\n return this.api$\r\n .request<DataItemResponse>('post', buildUrl`custom-action/${screenName}/` + bcUrl, { data: { data: data || {} }, params })\r\n .pipe(map(response => response.data.data))\r\n }\r\n\r\n associate(screenName: string, bcUrl: string, data: AssociatedItem[] | Record<string, AssociatedItem[]>, params?: GetParamsMap) {\r\n // TODO: Why Cxbox API sends underscored `_associate` but expects `associated` in return?\r\n const processedData = Array.isArray(data)\r\n ? data.map(item => ({\r\n id: item.id,\r\n vstamp: item.vstamp,\r\n associated: item._associate\r\n }))\r\n : data\r\n\r\n return this.api$\r\n .request<any>('post', buildUrl`associate/${screenName}/` + bcUrl, { data: processedData, params })\r\n .pipe(map(response => response.data.data))\r\n }\r\n\r\n getRmByForceActive(\r\n screenName: string,\r\n bcUrl: string | null,\r\n data: PendingDataItem & { vstamp: number },\r\n changedNow: PendingDataItem,\r\n params?: GetParamsMap\r\n ) {\r\n return this.api$\r\n .request<RowMetaResponse>('post', buildUrl`row-meta/${screenName}/` + (bcUrl ?? ''), {\r\n data: { data: { ...data, changedNow_: changedNow } },\r\n params\r\n })\r\n .pipe(map(response => response.data.data.row))\r\n }\r\n /**\r\n * Get Cxbox API file upload endpoint based on baseURL of axios instance\r\n *\r\n * Handles empty baseURL and trailing slash\r\n *\r\n * @returns File upload endpoint\r\n */\r\n get fileUploadEndpoint() {\r\n const instance = this.api$.instance\r\n\r\n if (!instance.defaults.baseURL) {\r\n return '/file'\r\n }\r\n\r\n return instance.defaults.baseURL.endsWith('/') ? `${instance.defaults.baseURL}file` : `${instance.defaults.baseURL}/file`\r\n }\r\n\r\n refreshMeta() {\r\n return this.api$.request('get', buildUrl`bc-registry/refresh-meta`).pipe(map(response => response.data))\r\n }\r\n\r\n loginByRoleRequest(role: string) {\r\n return this.api$.request<LoginResponse>('get', buildUrl`login?role=${role}`).pipe(map(response => response.data))\r\n }\r\n\r\n createCanceler() {\r\n let cancel: (() => void) | undefined\r\n\r\n const cancelToken = new axios.CancelToken(c => {\r\n cancel = c\r\n })\r\n\r\n return {\r\n cancel,\r\n cancelToken\r\n }\r\n }\r\n}\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { WidgetMeta } from '../interfaces/widget'\r\nimport { OperationTypeCrud } from '../interfaces/operation'\r\nimport { Store as CoreStore } from '../interfaces/store'\r\nimport { AnyAction, Dispatch, MiddlewareAPI } from '@reduxjs/toolkit'\r\nimport { sendOperation } from '../actions'\r\n\r\n/**\r\n * Performs mechanism of autosave\r\n *\r\n * @param action\r\n * @param store\r\n * @param next\r\n * @category Utils\r\n */\r\nexport function autosaveRoutine(action: AnyAction, store: MiddlewareAPI<Dispatch<AnyAction>, CoreStore>, next: Dispatch) {\r\n const state = store.getState()\r\n const dispatch = store.dispatch\r\n const pendingDataChanges = state.view.pendingDataChanges\r\n const bcList = Object.keys(pendingDataChanges)\r\n /**\r\n * Here we need to find BC with unsaved changes called `baseBcName`\r\n * because current action will be dispatched after `baseBcName` saving.\r\n * 1. We need to check out if bcName of current action is suitable for that aim\r\n * 2. Otherwise find first unsaved bcName\r\n */\r\n const baseBcNameIndex =\r\n action.payload?.bcName &&\r\n bcHasPendingAutosaveChanges(state, action.payload.bcName, state.screen.bo.bc[action.payload.bcName]?.cursor)\r\n ? bcList.findIndex(bcName => bcName === action.payload?.bcName)\r\n : bcList.findIndex(bcName => bcHasPendingAutosaveChanges(state, bcName, state.screen.bo.bc[bcName]?.cursor))\r\n const baseBcName = bcList[baseBcNameIndex]\r\n /**\r\n * Here we need to form a list of rest BC names.\r\n * We exclude `baseBcName` from `bcList`\r\n */\r\n if (baseBcNameIndex > -1) {\r\n bcList.splice(baseBcNameIndex, 1)\r\n }\r\n /**\r\n * Saving process\r\n */\r\n if (baseBcName) {\r\n /**\r\n * Save all BCs except `baseBcName`\r\n */\r\n bcList.forEach(bcName => {\r\n const widget = state.view.widgets?.find((v: WidgetMeta) => v.bcName === bcName)\r\n const cursor = state.screen.bo.bc[bcName]?.cursor\r\n if (bcHasPendingAutosaveChanges(state, bcName, cursor)) {\r\n dispatch(\r\n sendOperation({\r\n bcName: bcName,\r\n operationType: OperationTypeCrud.save,\r\n widgetName: widget?.name as string\r\n })\r\n )\r\n }\r\n })\r\n /**\r\n * save `baseBcName`'s BC\r\n */\r\n const baseWidget = state.view.widgets?.find((v: WidgetMeta) => v.bcName === baseBcName)\r\n return next(\r\n sendOperation({\r\n bcName: baseBcName,\r\n operationType: OperationTypeCrud.save,\r\n widgetName: baseWidget?.name as string,\r\n onSuccessAction: action\r\n })\r\n )\r\n }\r\n return next(action)\r\n}\r\n\r\n/**\r\n * Checks presence of pending changes suitable for autosave\r\n *\r\n * @param store\r\n * @param bcName\r\n * @param cursor\r\n */\r\nexport function bcHasPendingAutosaveChanges(store: CoreStore, bcName: string, cursor: string) {\r\n const pendingChanges = store.view.pendingDataChanges\r\n const cursorChanges = pendingChanges[bcName]?.[cursor as string]\r\n const result = cursorChanges && !Object.keys(cursorChanges).includes('_associate') && Object.values(cursorChanges).length > 0\r\n return result\r\n}\r\n\r\n/**\r\n * Checks presence of unsaved data.ts for specified BC\r\n *\r\n * @param store\r\n * @param bcName\r\n */\r\nexport function checkUnsavedChangesOfBc(store: CoreStore, bcName: string) {\r\n const pendingCursors = Object.keys(store.view.pendingDataChanges?.[bcName] ?? {})\r\n return pendingCursors.some(cursor => bcHasPendingAutosaveChanges(store, bcName, cursor))\r\n}\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\n/**\r\n * Process preInvoke operation before action sendOperation\r\n */\r\n\r\nimport { AnyAction, Dispatch, Middleware, MiddlewareAPI } from 'redux'\r\nimport { processPreInvoke, sendOperation, setPendingSendOperation } from '../actions'\r\nimport { buildBcUrl, flattenOperations } from '../utils'\r\nimport { Store } from '../interfaces'\r\n\r\nexport const preInvokeAction: Middleware =\r\n ({ getState }: MiddlewareAPI<Dispatch, Store>) =>\r\n (next: Dispatch) =>\r\n (action: AnyAction) => {\r\n if (sendOperation.match(action)) {\r\n const state = getState()\r\n const forceUpdateRowMetaPending = (state.session.pendingRequests?.filter(item => item.type === 'force-active')?.length ?? 0) > 0\r\n\r\n if (forceUpdateRowMetaPending) {\r\n return next(setPendingSendOperation(action.payload))\r\n }\r\n\r\n const { operationType, widgetName, confirm } = action.payload\r\n const bcName = state.view.widgets.find(widgetItem => widgetItem.name === widgetName)?.bcName\r\n const bcUrl = buildBcUrl(bcName, true, state)\r\n const rowMeta = bcUrl && state.view.rowMeta[bcName]?.[bcUrl]\r\n const actions = rowMeta && flattenOperations(rowMeta.actions)\r\n const preInvoke = actions?.find(item => item.type === operationType)?.preInvoke\r\n\r\n return preInvoke && !confirm\r\n ? next(\r\n processPreInvoke({\r\n bcName,\r\n operationType,\r\n widgetName,\r\n preInvoke\r\n })\r\n )\r\n : next(action)\r\n }\r\n\r\n return next(action)\r\n }\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { saveFormMiddleware } from './autosaveMiddleware'\r\nimport { requiredFields } from './requiredFieldsMiddleware'\r\nimport { preInvokeAction } from './preInvokeMiddleware'\r\nimport { popupMiddleware } from './popupMiddleware'\r\n\r\nexport const middlewares = {\r\n autosave: saveFormMiddleware,\r\n requiredFields: requiredFields,\r\n preInvoke: preInvokeAction,\r\n popup: popupMiddleware\r\n}\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { AnyAction, Dispatch, Middleware, MiddlewareAPI } from 'redux'\r\nimport { coreOperations, OperationTypeCrud } from '../interfaces'\r\nimport { Store as CoreStore } from '../interfaces/store'\r\nimport { autosaveRoutine, checkUnsavedChangesOfBc } from '../utils/autosave'\r\nimport { WidgetOperations } from '@cxbox-ui/schema'\r\nimport { changeLocation, selectTableRowInit, sendOperation } from '../actions'\r\n\r\nexport const saveFormMiddleware: Middleware =\r\n ({ getState, dispatch }: MiddlewareAPI<Dispatch, CoreStore>) =>\r\n (next: Dispatch) =>\r\n (action: AnyAction) => {\r\n const state = getState()\r\n\r\n // TODO: Should offer to save pending changes or drop them\r\n\r\n const isSendOperation = sendOperation.match(action)\r\n const isCoreSendOperation = isSendOperation && coreOperations.includes(action.payload.operationType as OperationTypeCrud)\r\n const isSelectTableRowInit = selectTableRowInit.match(action)\r\n\r\n /**\r\n * Saving actions should be ignored\r\n */\r\n const isSaveAction = isSendOperation && action.payload.operationType === OperationTypeCrud.save\r\n const isNotSaveAction = !isSaveAction\r\n\r\n /**\r\n * Checking if the action is `sendOperation` of core type which called for another BC\r\n * Also BCs having pending `_associate` should be ignored\r\n */\r\n const actionBcName = isSendOperation && action.payload.bcName\r\n const hasAnotherUnsavedBc =\r\n Object.keys(state.view.pendingDataChanges)\r\n .filter(key => key !== actionBcName)\r\n .filter(key => checkUnsavedChangesOfBc(state, key)).length > 0\r\n const isSendOperationForAnotherBc = isCoreSendOperation && hasAnotherUnsavedBc\r\n\r\n /**\r\n * Checking if the action is `selectTableCellInit` called for another row or another widget\r\n */\r\n const selectedRow = state.view.selectedRow\r\n const isSelectTableRowInitOnAnotherRowOrWidget =\r\n selectedRow &&\r\n isSelectTableRowInit &&\r\n (selectedRow.widgetName !== action.payload.widgetName || selectedRow.rowId !== action.payload.rowId)\r\n\r\n /**\r\n * Default save operation as custom action\r\n *\r\n * If widget have only custom actions, `defaultSave` option mean witch action\r\n * must be executed as save record.\r\n * Current changeLocation action as onSuccessAction\r\n */\r\n const defaultSaveWidget = state.view.widgets?.find(item => item?.options?.actionGroups?.defaultSave)\r\n const defaultCursor = state.screen.bo.bc?.[defaultSaveWidget?.bcName as string]?.cursor\r\n const pendingData = state.view?.pendingDataChanges?.[defaultSaveWidget?.bcName as string]?.[defaultCursor as string]\r\n const isChangeLocation = defaultSaveWidget && changeLocation.match(action) && Object.keys(pendingData || {}).length > 0\r\n if (isChangeLocation) {\r\n return next(\r\n sendOperation({\r\n bcName: defaultSaveWidget.bcName,\r\n operationType: (defaultSaveWidget.options?.actionGroups as WidgetOperations).defaultSave as string,\r\n widgetName: defaultSaveWidget.name,\r\n onSuccessAction: action\r\n })\r\n )\r\n }\r\n\r\n /**\r\n * final condition\r\n */\r\n const isNeedSaveCondition = isNotSaveAction && (isSendOperationForAnotherBc || isSelectTableRowInitOnAnotherRowOrWidget)\r\n /**\r\n * Default save operation CRUD\r\n */\r\n if (isNeedSaveCondition) {\r\n return autosaveRoutine(action, { getState, dispatch }, next)\r\n }\r\n\r\n return next(action)\r\n }\r\n","/*\r\n * © OOO \"SI IKS LAB\", 2022-2023\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\n/**\r\n * Handles validation of \"required fields\" for widget operations\r\n */\r\n\r\nimport { AnyAction, Dispatch, Middleware, MiddlewareAPI } from 'redux'\r\nimport {\r\n isWidgetFieldBlock,\r\n Operation,\r\n OperationGroup,\r\n OperationTypeCrud,\r\n PendingDataItem,\r\n PendingValidationFailsFormat,\r\n RowMetaField,\r\n Store,\r\n TableLikeWidgetTypes,\r\n WidgetFieldBlock,\r\n WidgetTableMeta\r\n} from '../interfaces'\r\nimport {\r\n addNotification,\r\n bcCancelPendingChanges,\r\n changeDataItem,\r\n clearValidationFails,\r\n selectTableRowInit,\r\n sendOperation\r\n} from '../actions'\r\nimport { buildBcUrl, checkShowCondition, flattenOperations } from '../utils'\r\nimport { DataItem, WidgetField } from '@cxbox-ui/schema'\r\nimport { FieldType } from '../interfaces/view'\r\n\r\nexport const requiredFields: Middleware =\r\n ({ getState, dispatch }: MiddlewareAPI<Dispatch, Store>) =>\r\n (next: Dispatch) =>\r\n (action: AnyAction) => {\r\n const state = getState()\r\n if (sendOperation.match(action)) {\r\n const { bcName, operationType, widgetName, confirmOperation } = action.payload\r\n const cursor = state.screen.bo.bc[bcName]?.cursor\r\n if (cursor) {\r\n const bcUrl = buildBcUrl(bcName, true, state)\r\n const record = state.data[bcName]?.find(item => item.id === cursor)\r\n const rowMeta = bcUrl && state.view.rowMeta[bcName]?.[bcUrl]\r\n const pendingValues = state.view.pendingDataChanges[bcName]?.[cursor]\r\n const widget = state.view.widgets.find(item => item.name === widgetName)\r\n const confirmWidgetName = confirmOperation?.widget\r\n const confirmWidget = confirmWidgetName && state.view.widgets.find(item => item.name === confirmWidgetName)\r\n // If operation marked as validation-sensetive, mark all 'required' fields which haven't been filled as dirty and invalid\r\n if (operationRequiresAutosave(operationType, rowMeta?.actions)) {\r\n // While `required` fields are assigned via rowMeta, only visually visible fields should be checked\r\n // to avoid situations when field is marked as `required` but not available for user to interact.\r\n const hiddenFieldKeys: string[] = []\r\n const fieldsToCheck: Record<string, RowMetaField> = {}\r\n const skipConfirmWidgetFieldsCheck = confirmWidget && confirmWidget.bcName === bcName\r\n // Form could be split into multiple widgets so we check all widget with the same BC as action initiator.\r\n // TODO: use visibleSameBcWidgets instead of state.view.widgets (i.e. widgets showCondition should be respected)\r\n state.view.widgets\r\n .filter(item => item.bcName === widget?.bcName)\r\n .forEach(item => {\r\n const showConditionBcName = item.showCondition?.bcName\r\n const isWidgetVisible = checkShowCondition(\r\n item.showCondition,\r\n state.screen.bo.bc[showConditionBcName]?.cursor || '',\r\n state.data[showConditionBcName],\r\n state.view.pendingDataChanges\r\n )\r\n const itemFieldsCalc = [...item.fields]\r\n if (item.fields) {\r\n item.fields.forEach((block: Record<string, unknown> | WidgetFieldBlock<unknown>) => {\r\n if (isWidgetFieldBlock(block)) {\r\n block.fields.forEach((field: []) => itemFieldsCalc.push(field))\r\n }\r\n })\r\n }\r\n itemFieldsCalc.forEach((widgetField: WidgetField) => {\r\n const matchingRowMeta = rowMeta?.fields?.find(rowMetaField => rowMetaField.key === widgetField.key)\r\n const isConfirmWidgetField =\r\n skipConfirmWidgetFieldsCheck &&\r\n confirmWidget?.fields?.find((field: WidgetField) => field.key === widgetField.key)\r\n\r\n if (!fieldsToCheck[widgetField.key] && matchingRowMeta && !isConfirmWidgetField) {\r\n fieldsToCheck[widgetField.key] = matchingRowMeta\r\n\r\n if (\r\n !isWidgetVisible ||\r\n widgetField.hidden ||\r\n widgetField.type === FieldType.hidden ||\r\n matchingRowMeta.hidden\r\n ) {\r\n hiddenFieldKeys.push(widgetField.key)\r\n }\r\n }\r\n })\r\n })\r\n const dataItem: PendingDataItem = getRequiredFieldsMissing(record, pendingValues, Object.values(fieldsToCheck))\r\n // For tables, try to autofocus on first missing field\r\n if (dataItem && TableLikeWidgetTypes.includes((widget as WidgetTableMeta)?.type)) {\r\n dispatch(selectTableRowInit({ widgetName, rowId: cursor }))\r\n }\r\n\r\n if (dataItem && hiddenFieldKeys.some(item => item in dataItem)) {\r\n dispatch(\r\n addNotification({\r\n key: 'requiredFieldHidden',\r\n type: 'error',\r\n message:\r\n 'The form contains required fields that are not available for completion. Contact your administrator.',\r\n duration: 0\r\n })\r\n )\r\n }\r\n\r\n return dataItem\r\n ? next(changeDataItem({ bcName, bcUrl: buildBcUrl(bcName, true, state), cursor, dataItem }))\r\n : next(action)\r\n }\r\n\r\n // If operation is in cancelling pool, there is no need to validate\r\n if (isOperationSkipsValidation(operationType)) {\r\n return next(action)\r\n }\r\n\r\n // If operation is not validation-sensetive and validation failed, offer to drop pending changes\r\n if (hasPendingValidationFails(state, bcName)) {\r\n return next(\r\n addNotification({\r\n key: 'requiredFieldsMissing',\r\n type: 'buttonWarningNotification',\r\n message: 'Required fields are missing',\r\n duration: 0,\r\n options: {\r\n buttonWarningNotificationOptions: {\r\n buttonText: 'Cancel changes',\r\n actionsForClick: [bcCancelPendingChanges(null), clearValidationFails(null)]\r\n }\r\n }\r\n })\r\n )\r\n }\r\n }\r\n }\r\n\r\n return next(action)\r\n }\r\n\r\n/**\r\n * Check operations and operation groups for 'autoSaveBefore' flag (i.e. operation is validation-sensetive)\r\n *\r\n * @param operationType Key of operation to check\r\n * @param actions List of operations and/or operation groups\r\n */\r\nexport function operationRequiresAutosave(operationType: string, actions: Array<Operation | OperationGroup>) {\r\n let result = false\r\n if (!actions) {\r\n console.error('rowMeta is missing in the middle of \"sendOperation\" action')\r\n return result\r\n }\r\n result = flattenOperations(actions).some(action => action.type === operationType && action.autoSaveBefore)\r\n return result\r\n}\r\n\r\n/**\r\n * Check if required records fields have a falsy value.\r\n * \"Falsy\" stands for \"undefined\", \"null\", \"\", [] and {}.\r\n *\r\n * @param record Record to check\r\n * @param pendingChanges Pending record changes which could override record values\r\n * @param fieldsMeta\r\n */\r\nexport function getRequiredFieldsMissing(record: DataItem, pendingChanges: PendingDataItem, fieldsMeta: RowMetaField[]) {\r\n const result: PendingDataItem = {}\r\n fieldsMeta.forEach(field => {\r\n const value = record?.[field.key] as string\r\n const pendingValue = pendingChanges?.[field.key]\r\n const effectiveValue = pendingValue !== undefined ? pendingValue : value\r\n let falsyValue = false\r\n if (effectiveValue === null || effectiveValue === undefined || effectiveValue === '') {\r\n falsyValue = true\r\n } else if (Array.isArray(effectiveValue) && !effectiveValue.length) {\r\n falsyValue = true\r\n } else if (effectiveValue && typeof effectiveValue === 'object' && !Object.keys(effectiveValue).length) {\r\n falsyValue = true\r\n }\r\n if (field.required && falsyValue) {\r\n result[field.key] = Array.isArray(effectiveValue) ? [] : null\r\n }\r\n })\r\n return Object.keys(result).length > 0 ? result : null\r\n}\r\n\r\n/**\r\n * Checks if `pendingValidationFails` is not empty\r\n *\r\n * @param store\r\n * @param bcName\r\n */\r\nexport function hasPendingValidationFails(store: Store, bcName: string) {\r\n // TODO 2.0.0: remove this `if` block of code\r\n if (\r\n store.view.pendingValidationFailsFormat !== PendingValidationFailsFormat.target &&\r\n store.view.pendingValidationFails &&\r\n Object.keys(store.view.pendingValidationFails).length\r\n ) {\r\n return true\r\n }\r\n let checkResult = false\r\n const bcPendingValidations = store.view.pendingValidationFails?.[bcName] as { [cursor: string]: Record<string, string> }\r\n const cursorsList = bcPendingValidations && Object.keys(bcPendingValidations)\r\n if (!cursorsList) {\r\n return false\r\n }\r\n let i = 0\r\n for (; i < cursorsList.length; i++) {\r\n if (Object.keys(bcPendingValidations[cursorsList[i]]).length) {\r\n checkResult = true\r\n break\r\n }\r\n }\r\n return checkResult\r\n}\r\n\r\nfunction isOperationSkipsValidation(operationType: string) {\r\n return [OperationTypeCrud.delete, OperationTypeCrud.cancelCreate, 'cancel'].includes(operationType)\r\n}\r\n","import { AnyAction, Dispatch, Middleware, MiddlewareAPI } from 'redux'\r\nimport { Store } from '../interfaces'\r\nimport { showViewPopup } from '../actions'\r\n\r\nexport const popupMiddleware: Middleware =\r\n ({ getState }: MiddlewareAPI<Dispatch, Store>) =>\r\n (next: Dispatch) =>\r\n (action: AnyAction) => {\r\n if (showViewPopup.match(action)) {\r\n const state = getState()\r\n const bcName = action.payload.bcName\r\n const widgetValueKey = state.view.widgets.find(item => item.bcName === bcName)?.options?.displayedValueKey\r\n const assocValueKey = action.payload.assocValueKey ?? widgetValueKey\r\n return widgetValueKey ? next(showViewPopup({ ...action.payload, assocValueKey })) : next(action)\r\n }\r\n return next(action)\r\n }\r\n"],"names":["changeLocation","createAction","login","loginDone","loginFail","logout","logoutDone","selectScreen","selectScreenFail","selectView","selectViewFail","bcFetchDataRequest","bcFetchDataPages","bcClearData","inlinePickListFetchDataRequest","bcFetchDataSuccess","bcFetchDataFail","bcLoadMore","bcFetchRowMeta","bcFetchRowMetaSuccess","bcFetchRowMetaFail","bcNewData","bcNewDataSuccess","bcNewDataFail","bcDeleteDataFail","forceActiveChangeFail","sendOperation","sendOperationFail","sendOperationSuccess","processPostInvoke","processPreInvoke","processPostInvokeConfirm","userDrillDown","userDrillDownSuccess","drillDown","bcChangeCursors","bcChangeDepthCursor","changeDataItem","changeDataItems","forceActiveRmUpdate","showViewPopup","showFileUploadPopup","closeViewPopup","viewPutPickMap","viewClearPickMap","saveAssociations","changeAssociations","removeMultivalueTag","bcSaveDataSuccess","bcSaveDataFail","operationConfirmation","bcForceUpdate","uploadFile","uploadFileDone","uploadFileFailed","bcCancelPendingChanges","bcSelectRecord","bcSelectDepthRecord","changeAssociation","changeAssociationSameBc","changeAssociationFull","changeChildrenAssociations","changeChildrenAssociationsSameBc","changeDescendantsAssociationsFull","dropAllAssociations","dropAllAssociationsSameBc","dropAllAssociationsFull","handleRouter","selectTableRowInit","selectTableRow","deselectTableRow","showAllTableRecordsInit","showNotification","closeNotification","bcAddFilter","bcRemoveFilter","bcRemoveAllFilters","bcAddSorter","bcRemoveSorter","bcChangePage","showViewError","closeViewError","closeConfirmModal","clearValidationFails","downloadFile","downloadFileByUrl","bulkUploadFiles","apiError","httpError","switchDebugMode","exportState","emptyAction","refreshMeta","refreshMetaDone","refreshMetaFail","refreshMetaAndReloadPage","switchRole","addPendingRequest","removePendingRequest","addNotification","removeNotifications","waitUntil","setPendingSendOperation","associateInProgress","setOperationFinished","selectRows","deselectRows","clearSelectedRows","setPendingPostInvoke","applyPendingPostInvoke","inlinePickListFetchDataSuccess","ReducerBuilderManager","reducers","matchers","defaultCaseReducer","undefined","addCase","action","reducer","this","push","removeCase","filter","type","replaceCase","addMatcher","matcher","addDefaultCase","builder","builderWithCases","reduce","acc","args","builderWithMatchers","emptyData","p","Object","defineProperty","F","getOwnPropertyDescriptor","x","getOwnPropertyNames","h","prototype","hasOwnProperty","v","o","a","d","get","enumerable","b","DrillDownType","u","FieldType","y","OperationTypeCrud","c","PositionTypes","m","RecordSnapshotState","s","WidgetTypes","g","i","l","n","e","t","AppNotificationType","RouteType","PendingValidationFailsFormat","ApplicationErrorType","dist","r","call","M","value","noChange","new","deleted","create","save","delete","associate","cancelCreate","fileUpload","inner","relative","relativeNew","external","externalNew","Info","Form","List","DataGrid","AssocListPopup","PickListPopup","HeaderWidget","SecondLevelMenu","ThirdLevelMenu","FourthLevelMenu","WidgetCreator","Pivot","DimFilter","Text","FlatTree","FlatTreePopup","ViewNavigation","NavigationTabs","Top","Bottom","TopAndBottom","number","input","monthYear","date","dateTime","dateTimeWithSeconds","checkbox","checkboxSql","DMN","pickList","inlinePickList","dictionary","hidden","text","percent","money","comboCondition","richText","printForm","multifield","multivalue","multivalueHover","hint","radio","TableLikeWidgetTypes","PopupWidgetTypes","isCustomWidget","descriptor","isCustomWidgetConfiguration","isWidgetFieldBlock","item","PaginationMode","coreOperations","isOperationGroup","operation","Array","isArray","actions","OperationPreInvokeType","OperationPostInvokeType","OperationPostInvokeConfirmType","FilterType","isViewNavigationItem","isViewNavigationCategory","isViewNavigationGroup","initialRouterState","default","path","search","params","screenName","addTailControlSequences","url","includes","applyParams","qso","applyRawParams","result","keys","prev","paramKey","dropEmptyOrWrongParams","URLSearchParams","toString","createApiError","error","context","widgetName","isAxiosError","callContext","createApiErrorObservable","newApiError","of","EMPTY","getTemplate","literals","placeholders","length","buildBcUrl","bcName","includeSelf","state","bcMap","screen","bo","bc","cursor","name","nextBc","parentName","reverse","join","TAG_PLACEHOLDER","escapedSrc","str","RegExp","replace","makeRelativeUrl","absoluteUrl","startsWith","parseBcCursors","bcPath","cursors","tokens","split","buildUrl","placeholder","template","Error","JSON","stringify","encodeURIComponent","defaultParseURL","pathname","substring","endsWith","indexOf","searchParams","forEach","key","map","decodeURIComponent","unknown","viewName","router","bcIndex","slice","defaultBuildURL","route","getRouteFromString","ulrString","URL","window","location","origin","getFilters","filters","range","values","fieldName","greaterOrEqualThan","String","lessOrEqualThan","separator","getSorters","sorters","index","direction","jsonParse","parse","console","warn","parseFilters","defaultFilters","urlParams","fromEntries","param","getAll","containsOneOf","equalsOneOf","parseSorters","from","entries","sort","fieldKey","order","Number","parseInt","processDrilldownFilters","rangeFilters","filterItem","flattenOperations","operations","OperationItem","matchOperationRole","role","payload","store","operationType","bcUrl","view","rowMeta","find","every","actionRole","getBcChildren","originBcName","widgets","childrenBcMap","widget","widgetBcList","expectedBcName","options","hierarchy","hierarchyBcName","hierarchyWidgetName","hierarchyWidget","nestedBcNames","nestedItem","childHierarchyBcIndex","findIndex","childHierarchyBcName","getHierarchyChildBc","isEagerWidget","lazyWidgetNames","showConditionCheck","isNotLazy","isVisible","getEagerBcChildren","childBcName","widgetNames","checkShowCondition","condition","data","pendingDataChanges","isDefault","record","id","actualValue","pendingValue","assignTreeLinks","flat","orphans","parentId","parentIndex","el","parent","children","getDescendants","nodes","child","getDefaultViewForPrimary","primary","views","getDefaultViewFromPrimaries","primaries","primaryView","primaryViewName","removeDisabledFieldsMutate","changes","rowMetaOfDisabledField","fields","field","disabled","currentValue","removeDisabledFields","getWidgetsForLazyLoad","getInternalWidgets","activePopupBcName","popupWidgets","mainWidgets","internalPopupWidgetsNames","internalMainWidgetsNames","internalNames","Set","externalPopupWidgets","has","externalMainWidgets","exclusionSet","uniqueInternalPopupWidgetsNames","internalPopupWidgetName","breadthFirstSearch","root","predicate","depth","childrenProperty","rootMatch","rootChildren","node","simpleLeaf","resultDepth","some","matchingNodes","obj","customWidgets","widgetType","isPopup","title","dataItem","templatedString","match","token","varName","defaultValue","formatString","fieldType","specified","contains","equals","level","bcUrlItems","bcCursor","source","tokenizer","operationsHandledLocally","initialViewState","columns","readOnly","rowHeight","metaInProgress","popupData","pendingPostInvoke","pendingDataChangesNow","infiniteWidgets","pendingValidationFailsFormat","old","pendingValidationFails","handledForceActive","selectedRow","selectedRows","ignoreHistory","systemNotifications","modalInvoke","getFailsByRequiredFields","isRequired","fails","initialState","nextDataItem","prevDataItem","vstamp","_associate","records","isTab","bcNames","bcDictionary","bcSorters","bcFilters","meta","sorter","defaultSort","defaultFilter","primaryViews","activeBcName","loading","currentBc","page","newBcs","hasNext","cachedBc","prevOperationsInProgress","operationsInProgress","newCursors","newCache","cursorsMap","entry","changedParents","assign","depthBc","newFilter","prevFilters","prevFilter","newFilters","newBcFilters","currentPage","calleeBCName","loginSpin","errorMsg","active","debugMode","pendingRequests","request","requestId","notifications","closingKeys","notification","isMetaRefreshing","currentRecordData","rowMetaForcedValues","newPendingChangesDiff","forceActiveFieldKeys","forceActive","consolidatedFrontData","newPendingDataChanges","isTargetFormatPVF","target","nextValidationFails","required","actionBcName","nextPending","prevPendingNow","newPendingChanges","newPendingChangesNow","dataItems","pendingBcChanges","itemId","entityError","errors","violation","calleeWidgetName","associateFieldKey","assocValueKey","isFilter","pickMap","rowId","message","selectedRowsDictionary","row","newDataItems","dataItemIdsToDelete","splice","ids","postInvoke","devPanelEnabled","activeRole","roles","firstName","lastName","exportStateEnabled","screens","postOperationRoutine","preInvoke","postInvokeConfirm","recursiveQueryWithRepeat","api","currentBcName","timeout","repeatTimeout","timeoutMaxRequests","successCondition_fieldKey","successCondition_value","requestInterval","Math","floor","limitBySelfCursor","fetchParams","_page","_limit","limit","fetchBcData","fetchDataRequest","pipe","mergeMap","response","valueForComparison","successCondition","delay","checkingReadinessForBuildBcUrl","bcNamesForChecking","bcHierarchy","parentBcName","getBcHierarchyArr","bcNameForChecking","knownHttpErrors","responseStatusMessages","cancelRequestActionTypes","cancelRequestEpic","action$","actionTypes","cancelFn","cancelActionCreator","filterFn","isAnyOf","take","selectBcNameFromPopupData","getCurrentCursor","prevCursor","newCursor","updatedCursor","getCursorChange","isHierarchy","keepDelta","isPopupWidget","getChildrenData","eagerChildren","concat","nonLazyWidget","ignorePageLimit","resetOutdatedChildrenData","parentsBcUrls","childBcNamesWithData","bcNameWithData","actionTypesMatcher","statusCode","status","axios","isCancel","NetworkError","state$","pendingRecordChange","_action","customAction","postActions","catchError","store$","deleteBcData","utils","widgetsWithCurrentBc","anyHierarchyWidget","hierarchyFull","isHierarchyWidget","fullHierarchyWidget","to","canceler","createCanceler","cancelFlow","cancel","cancelByParentBc","filteredAction","actionBc","normalFlow","cancelToken","cursorChange","setDataSuccess","fetchRowMeta","isWidgetVisible","w","showCondition","dataToCheck","currentCursor","bcWidgetsMap","bcListOnCurrentView","originBcIsOnCurrentView","leastOneWidgetIsVisible","isVisiblePopup","bcIsUsedInShowCondition","isChildBcForOriginBc","partUrlOfChildBc","widgetIsUsedOnView","fetchChildren","resetOutdatedData","race","oldBcDataIds","newData","newBcData","pendingChanges","fetchChildrenBcData","saveBcData","responseDataItem","onSuccessAction","notification$","disableNotification","duration","buttonWarningNotificationOptions","buttonText","actionsForClick","viewError","operationError","entity","popup","ignoreChildrenPageLimit","selected","isRoot","rootHierarchyDescriptor","hierarchyRadio","hierarchyDescriptor","hierarchyGroupSelection","hierarchyTraverse","childrenBc","parentItem","_value","wasLastInData","delta","wasLastInDelta","deltaValue","dataValue","allData","parentDepth","rootRadio","hierarchyGroupDeselection","currentLevelData","prevSelected","deltaItem","deltaFalseId","currentData","depthData","parentCursor","targetData","targetDataItem","successAction","session","nextCursors","cursorsDiffMap","needUpdateCursors","currentScreenName","defaultScreenName","defaultScreen","nextScreenName","forceUpdate","nextScreen","currentViewName","nextViewName","needUpdateViews","resultObservables","nextView","switchMap","requestedView","defaultView","tap","anchor","document","createElement","href","style","display","body","appendChild","setTimeout","click","removeChild","fileId","fileUploadEndpoint","drillDownType","test","open","urlBase","urlObject","urlFilters","urlSorters","newSorters","bcToUpdate","nextState","filterExpression","parsedFilters","parsedFilter","sortExpression","prevProps","nextProps","ignore","diffProps","newKeys","shallowCompare","fileIds","initUrl","disableRetry","hierarchySameBc","needPopupClose","disableDeprecatedFeatures","popupCloseAfterChangeData","pendingChangesNow","fieldsRowMeta","changedFiledKey","closePopup","someForceActiveChanged","nanoid","getRmByForceActive","routerRequest","notificationMessage","typedError","businessError","BusinessError","systemError","SystemError","details","statusText","code","searchSpec","searchString","isSwitchRole","loginByRoleRequest","defaultUrl","hash","confirm","info","confirmText","confirmOperation","postDelete","newBcUrl","newUrl","refreshBC","postInvokeBC","postInvokeBCItem","infinitePagination","showMessage","messageType","messageText","drillDownAndWaitUntil","reload","password","popupBcName","removedItem","associated","removedNodes","removedItemChildren","siblings","parentEmpty","parentDescendants","descendant","disableSecondDataChangeForAssocPopup","secondDataChangeForAssocPopupWhenRemovingTagFromField","hierarchyData","_bcName","calleeWidget","widgetItem","err","calleeBcName","recordPrevData","dataStateRecord","newValues","pendingBc","addedItems","newItem","prevItem","messageOptions","nextRowId","nextWidget","nextBcName","nextBcCursor","selectedCell","bcToLoad","hasBcData","cursorIsNull","hasBcCursor","hasBcParent","lazyLoad","fullLoad","subtype","bcKey","defaultSaveOperation","actionGroups","defaultSave","_confirm","postInvokeType","postInvokeRefreshCurrentBc","postInvokeTypesWithRefreshBc","withoutBcForceUpdate","withLatestFrom","_","assocWidget","calleeCursor","calleePendingChanges","assocFieldKey","assocFieldChanges","popupInitPendingChanges","calleeData","dataRecord","assocIds","recordId","assocPendingIds","drillDownField","drillDownKey","customDrillDownUrl","successCondition_bcName","switchPopup","isProgressStatus","isFinalStatus","requestResult","currentState","getCheckedStateForBuildBcUrl","checkedState","takeUntil","closeAction","successMessage","TimeoutError","timeoutMessage","inProgressMessage","redirectOccurred","redirectUrl","mergeConfigWithData","config","ObservableApiWrapper","instance","responseType","headers","Pragma","maxUrlLength","Infinity","filterTypes","constructor","method","processedConfig","resultMethod","toLowerCase","processedFilter","takeWhile","put","post","Api","api$","noLimit","queryStringObject","fetchBcDataAll","expand","items","nextResponse","processedData","changedNow","changedNow_","defaults","baseURL","CancelToken","bcHasPendingAutosaveChanges","cursorChanges","middlewares","autosave","getState","dispatch","next","isSendOperation","isCoreSendOperation","isSelectTableRowInit","isNotSaveAction","hasAnotherUnsavedBc","checkUnsavedChangesOfBc","isSendOperationForAnotherBc","isSelectTableRowInitOnAnotherRowOrWidget","defaultSaveWidget","defaultCursor","pendingData","bcList","baseBcNameIndex","baseBcName","baseWidget","autosaveRoutine","requiredFields","pendingValues","confirmWidgetName","confirmWidget","autoSaveBefore","operationRequiresAutosave","hiddenFieldKeys","fieldsToCheck","skipConfirmWidgetFieldsCheck","showConditionBcName","itemFieldsCalc","block","widgetField","matchingRowMeta","rowMetaField","isConfirmWidgetField","fieldsMeta","effectiveValue","falsyValue","getRequiredFieldsMissing","isOperationSkipsValidation","checkResult","bcPendingValidations","cursorsList","hasPendingValidationFails","widgetValueKey","displayedValueKey"],"mappings":"4WAsCO,MAAMA,EAAiBC,EAC1B,kBAKSC,EAAQD,EAalB,SAKUE,EAAYF,EAA4B,aAKxCG,EAAYH,EAKtB,aAKUI,EAASJ,EAAmB,UAK5BK,EAAaL,EAAmB,cAShCM,EAAeN,EAKzB,gBAKUO,EAAmBP,EAK7B,oBAQUQ,EAAaR,EAAqD,cAOlES,EAAiBT,EAE3B,kBAKUU,EAAqBV,EA2B/B,sBAKUW,EAAmBX,EAmB7B,oBAEUY,EAAcZ,EAAoC,eAKlDa,EAAiCb,EAa3C,kCAKUc,EAAqBd,EAyB/B,sBAKUe,EAAkBf,EAe5B,mBAKUgB,EAAahB,EASvB,cAKUiB,EAAiBjB,EAY3B,kBAOUkB,EAAwB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AWV,GAAkBU,EAAQhJ,SAC/CqX,EAAYrX,GAASiJ,MAAKxJ,GAAQA,EAAKxH,OAAS4Q,KAAgBwO,UAEtE,OACMwX,EADCxX,IAAciP,EAEXl0B,EAAiB,CACbsQ,SACAmG,gBACA/G,aACAuV,cAGH1f,EACd,CAED,OAAOk3B,EAAKl3B,EAAO,EC/BvB0nB,MGpBA,EAAGsP,cACFE,GACAl3B,IACG,GAAI7E,GAAcqc,MAAMxX,GAAS,CAC7B,MAAMiL,EAAQ+rB,IACRjsB,EAAS/K,EAAOgR,QAAQjG,OACxB6uB,EAAiB3uB,EAAMmG,KAAKO,QAAQL,MAAKxJ,GAAQA,EAAKiD,SAAWA,KAASiH,SAAS6nB,kBACnFvb,EAAgBte,EAAOgR,QAAQsN,eAAiBsb,EACtD,OAAwB1C,EAAjB0C,EAAsBz+B,GAAc,IAAK6E,EAAOgR,QAASsN,kBAAyBte,EAC5F,CACD,OAAOk3B,EAAKl3B,EAAO","x_google_ignoreList":[3]}
1
+ {"version":3,"file":"index.js","sources":["../src/actions/index.ts","../src/reducers/ReducerBuilderManager.ts","../src/reducers/data.ts","../node_modules/@cxbox-ui/schema/dist/index.js","../src/interfaces/objectMap.ts","../src/interfaces/router.ts","../src/interfaces/view.ts","../src/interfaces/widget.ts","../src/interfaces/operation.ts","../src/interfaces/filters.ts","../src/interfaces/navigation.ts","../src/reducers/router.ts","../src/utils/api.ts","../src/utils/apiError.ts","../src/utils/strings.ts","../src/utils/history.ts","../src/utils/filters.ts","../src/utils/operations.ts","../src/utils/bc.ts","../src/utils/tree.ts","../src/utils/getDefaultViewForPrimary.ts","../src/utils/getDefaultViewFromPrimaries.ts","../src/utils/data.ts","../src/utils/getWidgetsForLazyLoad.ts","../src/utils/breadthFirst.ts","../src/utils/deleteUndefinedFromObject.ts","../src/utils/extendPopupWidgetTypes.ts","../src/reducers/screen.ts","../src/reducers/view.ts","../src/reducers/depthData.ts","../src/reducers/session.ts","../src/epics/utils/postOperationRoutine.ts","../src/epics/view/sendOperationEpic.ts","../src/epics/view/waitUntil.ts","../src/epics/router/loginDoneEpic.ts","../src/epics/screen/httpErrorDefaultEpic.ts","../src/epics/session/loginByAnotherRoleEpic.ts","../src/utils/cancelRequestEpic.ts","../src/epics/data/bcLoadMoreEpic.ts","../src/selectors/selectors.ts","../src/epics/data/bcFetchDataEpic.ts","../src/epics/data/bcDeleteDataEpic.ts","../src/epics/data/bcCancelCreateDataEpic.ts","../src/epics/screen/apiErrorEpic.ts","../src/epics/data/bcFetchRowMetaRequestEpic.ts","../src/epics/data/bcNewDataEpic.ts","../src/epics/data/bcSaveDataEpic.ts","../src/epics/data/bcSelectDepthRecordEpic.ts","../src/epics/data/bcSelectRecordEpic.ts","../src/epics/data/changeAssociationEpic.ts","../src/epics/data/changeAssociationFullEpic.ts","../src/epics/data/changeAssociationSameBcEpic.ts","../src/epics/data/changeChildrenAssociationsEpic.ts","../src/epics/data/changeChildrenAssociationsSameBcEpic.ts","../src/epics/data/changeDescendantsAssociationsFullEpic.ts","../src/epics/router/changeLocationEpic.ts","../src/epics/router/selectScreenEpic.ts","../src/epics/router/selectViewEpic.ts","../src/epics/view/clearPendingDataChangesAfterCursorChangeEpic.ts","../src/epics/screen/downloadFileByUrlEpic.ts","../src/epics/screen/downloadFileEpic.ts","../src/epics/router/drilldownEpic.ts","../src/epics/view/fileUploadConfirmEpic.ts","../src/epics/view/getRowMetaByForceActiveEpic.ts","../src/epics/router/handleRouterEpic.ts","../src/epics/screen/httpError401Epic.ts","../src/epics/screen/httpError409Epic.ts","../src/epics/screen/httpError418Epic.ts","../src/epics/screen/httpError500Epic.ts","../src/epics/data/inlinePickListFetchDataEpic.ts","../src/epics/session/loginDoneEpic.ts","../src/epics/screen/processPostInvokeConfirmEpic.ts","../src/epics/screen/processPostInvokeEpic.ts","../src/epics/session/refreshMetaAndReloadPageEpic.ts","../src/epics/session/refreshMetaEpic.ts","../src/epics/data/removeMultivalueTagEpic.ts","../src/epics/data/saveAssociationsActiveEpic.ts","../src/epics/data/saveAssociationsPassiveEpic.ts","../src/epics/router/selectScreenFailEpic.ts","../src/epics/view/selectTableRowInitEpic.ts","../src/epics/data/selectViewEpic.ts","../src/epics/router/selectViewFailEpic.ts","../src/epics/view/sendOperationAssociateEpic.ts","../src/epics/view/setPendingSendOperationEpic.ts","../src/epics/view/showAllTableRecordsInitEpic.ts","../src/epics/view/showAssocPopupEpic.ts","../src/epics/view/showFileUploadPopupEpic.ts","../src/epics/session/switchRoleEpic.ts","../src/epics/router/userDrilldownChangeCursorsEpic.ts","../src/epics/router/userDrillDownEpic.ts","../src/api/ObservableApiWrapper.ts","../src/api/ObservableApi.ts","../src/utils/autosave.ts","../src/middlewares/preInvokeMiddleware.ts","../src/middlewares/index.ts","../src/middlewares/autosaveMiddleware.ts","../src/middlewares/requiredFieldsMiddleware.ts","../src/middlewares/popupMiddleware.ts"],"sourcesContent":["/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { SessionScreen, PendingRequest, NotificationKeys, LoginResponse, OperationPostInvokeWaitUntil, ISendOperation } from '../interfaces'\nimport { DrillDownType, Route } from '../interfaces/router'\nimport { ViewMetaResponse, ApplicationError, PopupType } from '../interfaces'\nimport { DataItem, MultivalueSingleValue, PendingDataItem, PickMap } from '../interfaces/data'\nimport {\n RowMeta,\n AppNotificationType,\n OperationPostInvokeAny,\n OperationTypeCrud,\n AssociatedItem,\n OperationErrorEntity,\n OperationPostInvokeConfirm,\n OperationPreInvoke,\n BcFilter,\n BcSorter,\n Notification\n} from '../interfaces'\nimport { AxiosError } from 'axios'\nimport { ApiCallContext } from '../utils'\nimport { createAction, AnyAction } from '@reduxjs/toolkit'\nimport { OperationType } from '@cxbox-ui/schema'\n\nexport const changeLocation = createAction<{ location: Route; forceUpdate?: boolean; isTab?: boolean; onSuccessAction?: AnyAction }>(\n 'changeLocation'\n)\n/**\n * Authentication request\n */\nexport const login = createAction<{\n /**\n * User-provided login\n */\n login: string\n /**\n * User-provided password\n */\n password: string\n /**\n * Optionally user can choose a role to authentificate with\n */\n role?: string\n}>('login')\n\n/**\n * Login was successful\n */\nexport const loginDone = createAction<LoginResponse>('loginDone')\n\n/**\n * Login was unsuccesful\n */\nexport const loginFail = createAction<{\n /**\n * Reason could be provided\n */\n errorMsg: string\n}>('loginFail')\n\n/**\n * Logout was requested, manually or through stale session\n */\nexport const logout = createAction<null>('logout')\n\n/**\n * User successfully was logged out\n */\nexport const logoutDone = createAction<null>('logoutDone')\n\n/**\n * Request to change active screen was initiated\n *\n * TODO: 2.0.0 Should be string (just the screen name) instead;\n *\n * Initially this was due to `screen` reducer did not having access to `session` part of redux store\n */\nexport const selectScreen = createAction<{\n /**\n * Request initiated with all the meta from login response\n */\n screen: SessionScreen\n}>('selectScreen')\n\n/**\n * Request to change active screen was unsuccesful (incorrect path, unknown screen, etc.)\n */\nexport const selectScreenFail = createAction<{\n /**\n * Which screen was requested originally\n */\n screenName: string\n}>('selectScreenFail')\n\n/**\n * Request to change active view was initiated\n *\n * TODO: 2.0.0 Should be string (just the view name) instead;\n * Initially this was due to `screen` and `view` reducers did not having access to `session` part of redux store\n */\nexport const selectView = createAction<ViewMetaResponse & { isTab?: boolean }>('selectView')\n\n/**\n * Request to change active view was unsuccesful (incorrect path, unknown screen, etc.)\n *\n * @param selectViewFail Which view was requested originally\n */\nexport const selectViewFail = createAction<{\n viewName: string\n}>('selectViewFail')\n\n/**\n * Fetch data request for business component was initiated\n */\nexport const bcFetchDataRequest = createAction<{\n /**\n * The business component to fetch data for\n */\n bcName?: string\n /**\n * The level of hierarchy to fetch data for\n *\n * @deprecated Do not use; TODO: Will be removed in 2.0.0\n */\n depth?: number\n /**\n * What widget requires data (widget can only request its own data here)\n */\n widgetName: string\n /**\n * Page size should be ignored\n *\n * Used mostly for hierarchy widgets which does not have controls\n * for navigating between pages aside of root level.\n */\n ignorePageLimit?: boolean\n /**\n * Pending changes should not be dropped when performing this request\n * (due to hierarchy expanging through cursor change, for same BC hierarchy this leads to data loss)\n */\n keepDelta?: boolean\n}>('bcFetchDataRequest')\n\n/**\n * Fetch data request request for specific pages range\n */\nexport const bcFetchDataPages = createAction<{\n /**\n * The business component to fetch data for\n *\n * @deprecated TODO: 2.0.0 Should be removed in favor of widgetName\n */\n bcName: string\n /**\n * Fisrt page to fetch (default is 1)\n */\n widgetName: string\n /**\n * What widget requires data (widget can only request its own data here)\n */\n from?: number\n /**\n * Last page to fetch (default is current page)\n */\n to?: number\n}>('bcFetchDataPages')\n\nexport const bcClearData = createAction<{ bcNames: string[] }>('bcClearData')\n\n/**\n * Fetch data request for searchable fields\n */\nexport const inlinePickListFetchDataRequest = createAction<{\n /**\n * The business component to fetch data for\n */\n bcName: string\n /**\n * Search expression // TODO: Check format\n */\n searchSpec: string\n /**\n * Value to search for\n */\n searchString: string\n}>('inlinePickListFetchDataRequest')\n\n/**\n * Fetch data request was succesful\n */\nexport const bcFetchDataSuccess = createAction<{\n /**\n * Business component that requested data\n *\n * @deprecated TODO: 2.0.0 Remove in favor of widgetName\n */\n bcName: string\n /**\n * Data records from response for this business component\n */\n data: DataItem[]\n /**\n * For same BC hierarchies, the level which was requested\n *\n * @deprecated TODO: 2.0.0 Should be all moved to separate hierarchy-specific action\n */\n depth?: number\n /**\n * BC url with respect of parents cursors\n */\n bcUrl: string\n /**\n * If there are more data to fetch (other pages etc.)\n */\n hasNext?: boolean\n}>('bcFetchDataSuccess')\n\n/**\n * Fetch data request wac unsuccesful\n */\nexport const bcFetchDataFail = createAction<{\n /**\n * Business component that initiated data fetch\n */\n bcName: string\n /**\n * BC url with respect of parents cursors\n */\n bcUrl: string\n /**\n * For same BC hierarchies, the level which was requested\n *\n * @deprecated TODO: 2.0.0 Should be all moved to separate hierarchy-specific action\n */\n depth?: number\n}>('bcFetchDataFail')\n\n/**\n * Fetch next chunk of data for table widgets with infinite scroll\n */\nexport const bcLoadMore = createAction<{\n /**\n * Business component that initiated data fetch\n */\n bcName: string\n /**\n * Widget that initiated row meta fetch\n */\n widgetName?: string\n}>('bcLoadMore')\n\n/**\n * Fetch meta information for active record of business component\n */\nexport const bcFetchRowMeta = createAction<{\n /**\n *\n * Business component that initiated row meta fetch\n *\n * @deprecated TODO: 2.0.0 Remove in favor of widgetName\n */\n bcName: string\n /**\n * Widget that initiated row meta fetch\n */\n widgetName: string\n}>('bcFetchRowMeta')\n\n/**\n * Puts row meta received from Cxbox API to the store.\n *\n * Updates values in `data` store slice with new values from row meta when possible.\n */\nexport const bcFetchRowMetaSuccess = createAction<{\n /**\n * Business component that initiated row meta fetch\n */\n bcName: string\n /**\n * Path to BC with respect to ancestors BC and their cursors\n */\n bcUrl: string\n /**\n * Row meta returned by Cxbox API\n */\n rowMeta: RowMeta\n /**\n * Cursor for a record that initiated row meta fetch.\n *\n * Can be empty (e.g. BC has no records) or will be set to new id for `create` operation.\n */\n cursor?: string\n}>('bcFetchRowMetaSuccess')\n\n/**\n * Fetch request for row meta was unsuccesful\n */\nexport const bcFetchRowMetaFail = createAction<{\n /**\n * Business component initiated row meta fetch\n */\n bcName: string\n}>('bcFetchRowMetaFail')\n\n/**\n * @deprecated Not used; `sendOperationEpic` with `create` role is used instead\n *\n * TODO: Remove in 2.0.0\n */\nexport const bcNewData = createAction<{\n /**\n * Business component for which to create a new record\n */\n bcName: string\n}>('bcNewData')\n\n/**\n * Put new record draft to `data` store slice\n */\nexport const bcNewDataSuccess = createAction<{\n /**\n * Business component for which new record was created\n */\n bcName: string\n /**\n * New record with `id` returned by Cxbox API and vstamp = -1 (denoting a record draft)\n */\n dataItem: DataItem\n /**\n * Path to BC with respect to ancestors BC and their cursors\n */\n bcUrl: string\n}>('bcNewDataSuccess')\n\n/**\n * Dispatched when record creation failed\n */\nexport const bcNewDataFail = createAction<{\n /**\n * Business component for which record creation failed\n */\n bcName: string\n}>('bcNewDataFail')\n\n/**\n * Delete record request was\n */\nexport const bcDeleteDataFail = createAction<{\n /**\n * Business component initiated delete record\n */\n bcName: string\n}>('bcDeleteDataFail')\n\n/**\n * Request to change Force active field was unsuccesful\n */\nexport const forceActiveChangeFail = createAction<{\n /**\n * Business component initiated force active change\n */\n bcName: string\n /**\n * Cursors hierarchy at the time of force active change to\n */\n bcUrl: string\n /**\n * Error to show in modal\n */\n viewError: string\n /**\n * Validation errors on fields\n */\n entityError: OperationErrorEntity\n}>('forceActiveChangeFail')\n\n/**\n * Perform CustomAction\n */\nexport const sendOperation = createAction<ISendOperation>('sendOperation')\n\n/**\n * Send operation request was unsuccessful\n */\nexport const sendOperationFail = createAction<{\n /**\n * Business component initiated send operation request\n */\n bcName: string\n /**\n * Cursors hierarchy at the time when request was fired\n */\n bcUrl: string\n /**\n * Error to show in modal\n */\n viewError: string\n /**\n * Validation errors on fields\n */\n entityError: OperationErrorEntity\n}>('sendOperationFail')\n\n/**\n * Send operation request was successful\n */\nexport const sendOperationSuccess = createAction<{\n /**\n * Business component initiated the request\n */\n bcName: string\n /**\n * Cursor which initiated the request\n */\n cursor: string\n /**\n * New record with `id` returned by Cxbox API and vstamp = -1 (denoting a record draft)\n */\n dataItem?: DataItem\n}>('sendOperationSuccess')\n\n/**\n * TODO\n */\nexport const processPostInvoke = createAction<{\n /**\n * @deprecated TODO: Prefer widgetName instead (2.0.0)\n */\n bcName: string\n postInvoke: OperationPostInvokeAny\n cursor?: string\n /**\n * What widget initiated original operation, TODO: mandatory in 2.0.0\n */\n widgetName?: string\n}>('processPostInvoke')\n\n/**\n * Operation to perform preInvoke actions\n */\nexport const processPreInvoke = createAction<{\n /**\n * The business component to fetch data for\n */\n bcName: string\n /**\n * Type of operation to be performed\n */\n operationType: string\n /**\n * What widget requires data\n */\n widgetName: string\n /**\n * Action that will be performed before the main operation\n */\n preInvoke: OperationPreInvoke\n}>('processPreInvoke')\n\n/**\n * Operation to perform postInvokeConfirm actions\n */\nexport const processPostInvokeConfirm = createAction<{\n /**\n * The business component to fetch data for\n */\n bcName: string\n /**\n * Type of operation to be performed\n */\n operationType: string\n /**\n * What widget requires data\n */\n widgetName: string\n /**\n * Action that will be performed after the main operation and confirmation\n */\n postInvokeConfirm: OperationPostInvokeConfirm\n}>('processPostInvokeConfirm')\n\n/**\n * TODO\n */\nexport const userDrillDown = createAction<{\n widgetName: string\n bcName: string\n cursor: string\n fieldKey: string\n}>('userDrillDown')\n\n/**\n * TODO\n */\nexport const userDrillDownSuccess = createAction<{\n bcUrl: string\n bcName: string\n cursor: string\n}>('userDrillDownSuccess')\n\n/**\n * TODO\n */\nexport const drillDown = createAction<{\n url: string\n drillDownType?: DrillDownType\n urlName?: string\n route: Route\n widgetName?: string\n onSuccessAction?: AnyAction\n}>('drillDown')\n\n/**\n * TODO\n */\nexport const bcChangeCursors = createAction<{\n cursorsMap: Record<string, string>\n keepDelta?: boolean\n}>('bcChangeCursors')\n\n/**\n * Sets a cursor for the specified depth level of hierarchy widget\n * builded around a single business component.\n */\nexport const bcChangeDepthCursor = createAction<{\n /**\n * Business component for the hierarchy widget\n */\n bcName: string\n /**\n * Depth level for which cursor is set\n */\n depth: number\n /**\n * Cursor set for specific depth level of the hierarchy widget.\n *\n * Controls the collapsed state of the record and which data are fetched for the next level of hierarchy\n */\n cursor: string\n}>('bcChangeDepthCursor')\n\n/**\n * TODO\n */\nexport const changeDataItem = createAction<{\n bcName: string\n bcUrl: string\n cursor: string\n dataItem: PendingDataItem\n disableRetry?: boolean\n}>('changeDataItem')\n\n/**\n * TODO\n */\nexport const changeDataItems = createAction<{\n bcName: string\n cursors: string[]\n dataItems: PendingDataItem[]\n}>('changeDataItems')\n\n/**\n * TODO\n */\nexport const forceActiveRmUpdate = createAction<{\n /**\n * current data for record that initiated rowMeta fetch\n */\n currentRecordData: DataItem\n rowMeta: RowMeta\n bcName: string\n bcUrl: string\n cursor: string\n}>('forceActiveRmUpdate')\n\nexport interface WaitUntilPopupOptions {\n status: 'progress' | 'success' | 'timeout'\n message: string\n}\n\n/**\n * TODO\n */\nexport const showViewPopup = createAction<{\n options?: Partial<WaitUntilPopupOptions>\n /**\n * BC name of popup widget\n *\n * @deprecated TODO: Remove in 2.0.0 in favor of widget name\n */\n bcName: string\n /**\n * Name of popup widget\n */\n widgetName?: string\n /**\n * It's BC name of `caller` widget actually\n *\n * @deprecated TODO: Remove in 2.0.0 in favor of widget name\n */\n calleeBCName?: string\n /**\n * Name of `caller` widget actually\n *\n * TODO: 2.0.0 : Rename to `callerWidgetName`\n */\n calleeWidgetName?: string\n /**\n * Popup widget field key associated to `assocValueKey` of caller widget\n */\n associateFieldKey?: string\n /**\n * Caller widget field key associated to `associateFieldKey` of popup widget\n */\n assocValueKey?: string\n /**\n * If `true` then backend's method of association is used\n */\n active?: boolean\n /**\n * Whether popup is used as filter\n */\n isFilter?: boolean\n /**\n * Type of popup\n */\n type?: PopupType | string\n}>('showViewPopup')\n\n/**\n * TODO\n */\nexport const showFileUploadPopup = createAction<{\n /**\n * Name of the widget that initiated popup opening\n */\n widgetName: string\n}>('showFileUploadPopup')\n\n/**\n * Closes currently active popup on view\n */\nexport const closeViewPopup = createAction<{\n /**\n * Not used\n *\n * @deprecated TODO: Will be removed in 2.0.0\n */\n bcName?: string\n}>('closeViewPopup')\n\n/**\n * TODO\n */\nexport const viewPutPickMap = createAction<{\n map: PickMap\n bcName: string\n}>('viewPutPickMap')\n\n/**\n * TODO\n */\nexport const viewClearPickMap = createAction<null>('viewClearPickMap')\n\n/**\n * TODO\n */\nexport const saveAssociations = createAction<{\n bcNames: string[]\n /**\n * For usage outside Popup (without opening multivalue)\n */\n calleeBcName?: string\n associateFieldKey?: string\n}>('saveAssociations')\n\n/**\n * Sets intermediate state for association widget by storing associated records in pseudo-business component.\n *\n * Name for this pseudo-BC is formed as `${bcName}Delta`.\n */\nexport const changeAssociations = createAction<{\n /**\n * Assoc widget's business component\n */\n bcName: string\n /**\n * Records that marked as `associated` for this widget\n *\n * TODO: Will be mandatory in 2.0.0\n */\n records?: DataItem[]\n}>('cnangeAssociations')\n\n/**\n * TODO\n */\nexport const removeMultivalueTag = createAction<{\n bcName: string\n popupBcName: string\n cursor: string\n associateFieldKey: string\n dataItem: MultivalueSingleValue[]\n removedItem: MultivalueSingleValue\n}>('removeMultivalueTag')\n\n/**\n * TODO\n */\nexport const bcSaveDataSuccess = createAction<{\n bcName: string\n cursor: string\n dataItem: DataItem\n}>('bcSaveDataSuccess')\n\n/**\n * TODO\n */\nexport const bcSaveDataFail = createAction<{\n bcName: string\n bcUrl: string\n entityError?: OperationErrorEntity\n viewError?: string\n}>('bcSaveDataFail')\n\n/**\n * Save info about current operation for confirm modal\n */\nexport const operationConfirmation = createAction<{\n /**\n * Current operation\n */\n operation: {\n bcName: string\n operationType: OperationTypeCrud | string\n widgetName: string\n }\n /**\n * Text for confirm modal\n */\n confirmOperation: OperationPostInvokeConfirm\n}>('operationConfirmation')\n\n/**\n * Manually update business component by fetching its data and and row meta\n */\nexport const bcForceUpdate = createAction<{\n /**\n * @deprecated Will be removed in 2.0.0 in favor of `widgetName`\n */\n bcName: string\n /**\n * What widget requires data (widget can only request its own data here)\n *\n * TODO: Will be mandatory in 2.0.0\n */\n widgetName?: string\n}>('bcForceUpdate')\n\n/**\n * TODO\n */\nexport const uploadFile = createAction<null>('uploadFile')\n\n/**\n * TODO\n */\nexport const uploadFileDone = createAction<null>('uploadFileDone')\n\n/**\n * TODO\n */\nexport const uploadFileFailed = createAction<null>('uploadFileFailed')\n\n/**\n * TODO\n */\nexport const bcCancelPendingChanges = createAction<{\n bcNames: string[]\n}>('bcCancelPendingChanges')\n\n/**\n * TODO\n */\nexport const bcSelectRecord = createAction<{\n bcName: string\n cursor: string\n ignoreChildrenPageLimit?: boolean\n keepDelta?: boolean\n}>('bcSelectRecord')\n\n/**\n * Wrapper action to sets a cursor for the specified depth level of hierarchy widget\n * builded around a single business component and fetch children for that record.\n *\n * @deprecated Do not use. TODO: Will be removed in 2.0.0\n */\nexport const bcSelectDepthRecord = createAction<{\n /**\n * Business component for the hierarchy widget\n */\n bcName: string\n /**\n * Depth level for which cursor is set\n */\n depth: number\n /**\n * Cursor set for specific depth level of the hierarchy widget.\n *\n * Controls the collapsed state of the record and which data are fetched for the next level of hierarchy\n */\n cursor: string\n}>('bcSelectDepthRecord')\n\n/**\n * TODO\n */\nexport const changeAssociation = createAction<{\n bcName: string\n widgetName: string\n dataItem: AssociatedItem\n assocValueKey: string\n}>('changeAssociations')\n\n/**\n * TODO\n */\nexport const changeAssociationSameBc = createAction<{\n bcName: string\n depth: number\n widgetName: string\n dataItem: AssociatedItem\n assocValueKey: string\n}>('changeAssociationsSameBc')\n\n/**\n * TODO\n */\nexport const changeAssociationFull = createAction<{\n bcName: string\n depth: number\n widgetName: string\n dataItem: AssociatedItem\n /**\n * @deprecated TODO: Remove in 2.0.0 in favor of store.view.popupData.assocValueKey instead\n */\n assocValueKey?: string\n}>('changeAssociationFull')\n\n/**\n * TODO\n */\nexport const changeChildrenAssociations = createAction<{\n bcName: string\n assocValueKey: string\n selected: boolean\n}>('changeChildrenAssociations')\n\n/**\n * TODO\n */\nexport const changeChildrenAssociationsSameBc = createAction<{\n bcName: string\n depth: number\n assocValueKey: string\n selected: boolean\n}>('changeChildrenAssociationsSameBc')\n\n/**\n * TODO\n */\nexport const changeDescendantsAssociationsFull = createAction<{\n bcName: string\n parentId: string\n depth: number\n assocValueKey: string\n selected: boolean\n}>('changeDescendantsAssociationsFull')\n\n/**\n * TODO\n */\nexport const dropAllAssociations = createAction<{\n bcNames: string[]\n}>('dropAllAssociations')\n\n/**\n * TODO\n */\nexport const dropAllAssociationsSameBc = createAction<{\n bcName: string\n depthFrom: number\n}>('dropAllAssociationsSameBc')\n\n/**\n * TODO\n */\nexport const dropAllAssociationsFull = createAction<{\n bcName: string\n depth: number\n dropDescendants?: boolean\n}>('dropAllAssociationsFull')\n\n/**\n * For server side routing where {@link RouteType.router | routes are handled by Cxbox API endpoint}, this action is dispatched\n * to process requested route.\n */\nexport const handleRouter = createAction<{\n /**\n * An URL that will be passed to Cxbox API router endpoint\n */\n path: string\n /**\n * AJAX request parameters for the requests\n */\n params: Record<string, unknown>\n}>('handleRouter')\n\n/**\n * Used for edit list widget row\n */\nexport const selectTableRowInit = createAction<{\n widgetName: string\n rowId: string\n}>('selectTableRowInit')\n\n/**\n * TODO\n */\nexport const selectTableRow = createAction<{\n widgetName: string\n rowId: string\n}>('selectTableRow')\n\nexport const deselectTableRow = createAction('deselectTableRow')\n\n/**\n * TODO\n */\nexport const showAllTableRecordsInit = createAction<{\n bcName: string\n cursor: string\n /**\n * @deprecated Remove in 2.0 (accessible from the store)\n */\n route?: Route\n}>('showAllTableRecordsInit')\n\n/**\n * TODO\n */\nexport const showNotification = createAction<{\n type: AppNotificationType\n message: string\n}>('showNotification')\n\n/**\n * TODO\n */\nexport const closeNotification = createAction<{\n id: number\n}>('closeNotification')\n\n/**\n * TODO\n */\nexport const bcAddFilter = createAction<{\n /**\n * TODO: Will be mandatory in 2.0.0\n */\n widgetName?: string\n /**\n * @deprecated TODO: Remove in 2.0.0 in favor of widgetName\n */\n bcName: string\n filter: BcFilter\n}>('bcAddFilter')\n\n/**\n * TODO\n */\nexport const bcRemoveFilter = createAction<{\n bcName: string\n filter: BcFilter\n}>('bcRemoveFilter')\n\n/**\n * Remove all filters at once\n */\nexport const bcRemoveAllFilters = createAction<{\n bcName: string\n}>('bcRemoveAllFilters')\n\n/**\n * TODO\n */\nexport const bcAddSorter = createAction<{\n bcName: string\n sorter: BcSorter | BcSorter[]\n}>('bcAddSorter')\n\n/**\n * TODO\n */\nexport const bcRemoveSorter = createAction<{\n bcName: string\n sorter: BcSorter\n}>('bcRemoveSorter')\n\n/**\n * Fetches data for the new page of business component, replacing existing data\n */\nexport const bcChangePage = createAction<{\n /**\n * Business component changing the page\n *\n * @deprecated TODO: Will be removed in 2.0.0 in favor of `widgetNam`\n */\n bcName: string\n /**\n * Requested page number\n */\n page: number\n /**\n * Widget changing the page\n */\n widgetName?: string\n}>('bcChangePage')\n\n/**\n * TODO\n */\nexport const showViewError = createAction<{\n error: ApplicationError\n}>('showViewError')\n\n/**\n * TODO\n */\nexport const closeViewError = createAction<null>('closeViewError')\n\n/**\n * Close confirm modal window\n */\nexport const closeConfirmModal = createAction<null>('closeConfirmModal')\n\n/**\n * TODO\n */\nexport const clearValidationFails = createAction<null>('clearValidationFails')\n\n/**\n * TODO\n */\nexport const downloadFile = createAction<{\n fileId: string\n}>('downloadFile')\n\n/**\n * TODO\n */\nexport const downloadFileByUrl = createAction<{\n url: string\n name?: string\n}>('downloadFileByUrl')\n\n/**\n * Save uploaded files to the widget\n */\nexport const bulkUploadFiles = createAction<{\n /**\n * default true\n */\n isPopup?: boolean\n /**\n * If not specified, then taken from state.view.popupData.bcName\n */\n bcName?: string\n /**\n * Ids of uploaded files\n */\n fileIds: string[]\n}>('bulkUploadFiles')\n\n/**\n * An error occured during API request\n */\nexport const apiError = createAction<{\n /**\n * Axios error object\n * https://redux.js.org/style-guide/#do-not-put-non-serializable-values-in-state-or-actions\n */\n error: AxiosError\n /**\n * Request context\n */\n callContext: ApiCallContext\n}>('apiError')\n\n/**\n * Fires for specific HTTP status code\n */\nexport const httpError = createAction<{\n /**\n * Status code for failed request caught by `onErrorHook`\n */\n statusCode: number\n /**\n * Axios error object\n */\n error: AxiosError\n /**\n * Request context\n */\n callContext: ApiCallContext\n}>('httpError')\n\n/**\n * Enable/disable debug mode\n */\nexport const switchDebugMode = createAction<boolean>('switchDebugMode')\n\n/**\n * Download state to device\n */\nexport const exportState = createAction<null>('exportState')\n\n/**\n * TODO\n */\nexport const emptyAction = createAction<null>('emptyAction')\n\n/**\n * refresh screens, views and widgets meta\n */\nexport const refreshMeta = createAction('refreshMeta')\n/**\n * refresh refreshMeta was successful\n */\nexport const refreshMetaDone = createAction('refreshMetaDone')\n/**\n * refresh refreshMeta was unsuccessful\n */\nexport const refreshMetaFail = createAction('refreshMetaFail')\n\n/**\n * Refresh meta data (see action above) and reload page\n */\nexport const refreshMetaAndReloadPage = createAction<null>('refreshMetaAndReloadPage')\n\n/**\n * Switch to another user role\n */\nexport const switchRole = createAction<{\n role: string\n}>('switchRole')\n\n/**\n * Add pending request for tracking and blocking race conditions\n */\nexport const addPendingRequest = createAction<{\n request: PendingRequest\n}>('addPendingRequest')\n\n/**\n * Remove pending request\n */\nexport const removePendingRequest = createAction<{\n requestId: string\n}>('removePendingRequest')\n\nexport const addNotification = createAction<Notification>('addNotification')\n\nexport const removeNotifications = createAction<NotificationKeys>('removeNotifications')\n\nexport const waitUntil = createAction<{ bcName: string; postInvoke: Omit<OperationPostInvokeWaitUntil, 'type'> }>('waitUntil')\n\nexport const setPendingSendOperation = createAction<ISendOperation>('setPendingSendOperation')\n\nexport const associateInProgress = createAction<{ bcName: string }>('associateInProgress')\n\nexport const setOperationFinished = createAction<{ bcName: string; operationType: OperationType }>('setOperationFinished')\n\nexport const selectRows = createAction<{\n bcName: string\n dataItems: Array<Omit<DataItem, 'vstamp'>>\n}>('selectRows')\n\nexport const deselectRows = createAction<{\n bcName: string\n ids: string[]\n}>('deselectRows')\n\nexport const clearSelectedRows = createAction<{\n bcName: string\n}>('clearSelectedRows')\n\nexport const setPendingPostInvoke = createAction<{\n bcName: string\n operationType: string\n postInvoke: OperationPostInvokeAny\n}>('setPendingPostInvoke')\n\nexport const applyPendingPostInvoke = createAction<{\n bcName: string\n widgetName?: string\n operationType: string\n postInvoke: OperationPostInvokeAny\n}>('applyPendingPostInvoke')\n\nexport const inlinePickListFetchDataSuccess = createAction<{\n /**\n * Business component that requested data\n *\n * @deprecated TODO: 2.0.0 Remove in favor of widgetName\n */\n bcName: string\n /**\n * Data records from response for this business component\n */\n data: DataItem[]\n /**\n * BC url with respect of parents cursors\n */\n bcUrl: string\n /**\n * If there are more data to fetch (other pages etc.)\n */\n hasNext?: boolean\n}>('inlinePickListFetchDataSuccess')\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ActionReducerMapBuilder, CaseReducer } from '@reduxjs/toolkit'\nimport { Action, AnyAction } from 'redux'\n\ninterface TypedActionCreator<Type extends string> {\n (...args: any[]): Action<Type>\n type: Type\n}\n\ntype TypeGuard<T> = (value: any) => value is T\n\nexport class ReducerBuilderManager<State> {\n private reducers: Array<[TypedActionCreator<string>, CaseReducer<State, AnyAction>]> = []\n private matchers: Array<[TypeGuard<any> | ((action: AnyAction) => boolean), CaseReducer<State, AnyAction>]> = []\n private defaultCaseReducer: CaseReducer<State, AnyAction> | undefined = undefined\n\n addCase<ActionCreator extends TypedActionCreator<string>>(\n action: ActionCreator,\n reducer: CaseReducer<State, ReturnType<ActionCreator>>\n ) {\n this.reducers.push([action, reducer])\n return this\n }\n\n removeCase<ActionCreator extends TypedActionCreator<string>>(action: ActionCreator) {\n this.reducers = this.reducers.filter(reducer => reducer[0].type !== action.type)\n return this\n }\n\n replaceCase<ActionCreator extends TypedActionCreator<string>>(\n action: ActionCreator,\n reducer: CaseReducer<State, ReturnType<ActionCreator>>\n ) {\n this.removeCase(action).addCase(action, reducer)\n return this\n }\n addMatcher<A>(\n matcher: TypeGuard<A> | ((action: any) => boolean),\n reducer: CaseReducer<State, A extends AnyAction ? A : A & AnyAction>\n ): Omit<ReducerBuilderManager<State>, 'addCase'> {\n this.matchers.push([matcher, reducer])\n return this\n }\n\n addDefaultCase(\n reducer: CaseReducer<State, AnyAction>\n ): Omit<ReducerBuilderManager<State>, 'addCase' | 'addMatcher' | 'addDefaultCase'> {\n this.defaultCaseReducer = reducer\n return this\n }\n\n get builder() {\n return (builder: ActionReducerMapBuilder<State>) => {\n const builderWithCases = this.reducers.reduce((acc, args) => acc.addCase(...args), builder)\n const builderWithMatchers = this.matchers.reduce((acc, args) => acc.addMatcher(...args), builderWithCases)\n return this.defaultCaseReducer !== undefined ? builderWithMatchers.addDefaultCase(this.defaultCaseReducer) : builderWithMatchers\n }\n }\n}\n","import { DataState, DataItem } from '../interfaces'\nimport {\n bcClearData,\n bcFetchDataSuccess,\n bcFetchRowMetaSuccess,\n bcNewDataSuccess,\n bcSaveDataSuccess,\n changeAssociations,\n inlinePickListFetchDataSuccess,\n selectView\n} from '../actions'\nimport { ReducerBuilderManager } from './ReducerBuilderManager'\n\nconst emptyData: DataItem[] = []\n\nexport const dataInitialState: DataState = {}\n\nexport const createDataReducerBuilderManager = (initialState: DataState) =>\n new ReducerBuilderManager<typeof initialState>()\n .addCase(bcFetchDataSuccess, (state, action) => {\n state[action.payload.bcName] = action.payload.data\n })\n .addCase(inlinePickListFetchDataSuccess, (state, action) => {\n state[action.payload.bcName] = action.payload.data\n })\n .addCase(bcNewDataSuccess, (state, action) => {\n state[action.payload.bcName] = [...(state[action.payload.bcName] || emptyData), action.payload.dataItem]\n })\n .addCase(bcSaveDataSuccess, (state, action) => {\n const nextDataItem = action.payload.dataItem\n const index = state[action.payload.bcName].findIndex(item => item.id === nextDataItem.id)\n state[action.payload.bcName][index] = nextDataItem\n })\n .addCase(bcFetchRowMetaSuccess, (state, action) => {\n const cursor = action.payload.cursor\n if (!cursor) {\n return\n }\n const prevDataItem = (state[action.payload.bcName] || emptyData).find(item => item.id === cursor)\n const nextDataItem: DataItem = {\n ...prevDataItem,\n id: cursor,\n vstamp: -1,\n _associate: prevDataItem && prevDataItem._associate\n }\n // BC is unable to update value from row meta if id is null\n const valueUpdateUnsupported = action.payload.rowMeta.fields.find(item => item.key === 'id' && !item.currentValue)\n if (valueUpdateUnsupported) {\n return\n }\n action.payload.rowMeta.fields\n .filter(field => {\n // TODO: check if previous condition covered that case\n return field.key !== '_associate'\n })\n .forEach(field => (nextDataItem[field.key] = field.currentValue))\n\n if (!prevDataItem) {\n state[action.payload.bcName] = [...(state[action.payload.bcName] || emptyData), nextDataItem]\n return\n }\n state[action.payload.bcName] = state[action.payload.bcName].map(item => (item === prevDataItem ? nextDataItem : item))\n })\n .addCase(changeAssociations, (state, action) => {\n state[`${action.payload.bcName}Delta`] = action.payload.records || []\n })\n .addCase(selectView, (state, action) => {\n if (action.payload.isTab) {\n return state\n }\n\n return initialState\n })\n .addCase(bcClearData, (state, action) => {\n action.payload.bcNames?.forEach(bcName => {\n delete state[bcName]\n })\n })\n","var p=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var h=Object.prototype.hasOwnProperty;var b=(o,a)=>{for(var d in a)p(o,d,{get:a[d],enumerable:!0})},M=(o,a,d,i)=>{if(a&&typeof a==\"object\"||typeof a==\"function\")for(let r of x(a))!h.call(o,r)&&r!==d&&p(o,r,{get:()=>a[r],enumerable:!(i=F(a,r))||i.enumerable});return o};var f=o=>M(p({},\"__esModule\",{value:!0}),o);var v={};b(v,{DrillDownType:()=>u,FieldType:()=>y,OperationTypeCrud:()=>c,PositionTypes:()=>m,RecordSnapshotState:()=>s,WidgetTypes:()=>g});module.exports=f(v);var s=(i=>(i.noChange=\"noChange\",i.new=\"new\",i.deleted=\"deleted\",i))(s||{});var c=(l=>(l.create=\"create\",l.save=\"save\",l.delete=\"delete\",l.associate=\"associate\",l.cancelCreate=\"cancel-create\",l.fileUpload=\"file-upload\",l))(c||{});var u=(n=>(n.inner=\"inner\",n.relative=\"relative\",n.relativeNew=\"relativeNew\",n.external=\"external\",n.externalNew=\"externalNew\",n))(u||{});var g=(t=>(t.Info=\"Info\",t.Form=\"Form\",t.List=\"List\",t.DataGrid=\"DataGrid\",t.AssocListPopup=\"AssocListPopup\",t.PickListPopup=\"PickListPopup\",t.HeaderWidget=\"HeaderWidget\",t.SecondLevelMenu=\"SecondLevelMenu\",t.ThirdLevelMenu=\"ThirdLevelMenu\",t.FourthLevelMenu=\"FourthLevelMenu\",t.WidgetCreator=\"WidgetCreator\",t.Pivot=\"Pivot\",t.DimFilter=\"DimFilter\",t.Text=\"Text\",t.FlatTree=\"FlatTree\",t.FlatTreePopup=\"FlatTreePopup\",t.ViewNavigation=\"ViewNavigation\",t.NavigationTabs=\"NavigationTabs\",t))(g||{}),m=(i=>(i.Top=\"Top\",i.Bottom=\"Bottom\",i.TopAndBottom=\"TopAndBottom\",i))(m||{}),y=(e=>(e.number=\"number\",e.input=\"input\",e.monthYear=\"monthYear\",e.date=\"date\",e.dateTime=\"dateTime\",e.dateTimeWithSeconds=\"dateTimeWithSeconds\",e.checkbox=\"checkbox\",e.checkboxSql=\"checkboxSql\",e.DMN=\"DMN\",e.pickList=\"pickList\",e.inlinePickList=\"inline-pickList\",e.dictionary=\"dictionary\",e.hidden=\"hidden\",e.text=\"text\",e.percent=\"percent\",e.fileUpload=\"fileUpload\",e.money=\"money\",e.comboCondition=\"combo-condition\",e.richText=\"richText\",e.printForm=\"printForm\",e.multifield=\"multifield\",e.multivalue=\"multivalue\",e.multivalueHover=\"multivalueHover\",e.hint=\"hint\",e.radio=\"radio\",e))(y||{});0&&(module.exports={DrillDownType,FieldType,OperationTypeCrud,PositionTypes,RecordSnapshotState,WidgetTypes});\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * A dictionary for a values of specified type\n *\n * @deprecated TODO: Remove in 2.0.0 in favor of native `Record` type\n *\n * @template T Value type\n */\nexport interface ObjectMap<T> {\n [key: string]: T | undefined\n}\n\n/**\n * Basic type for Cxbox API responses\n *\n * TODO: Move this to a an appropriate module\n */\nexport type CxboxResponse = {\n /**\n * If any response returs with this field, browser should redirect on this address\n */\n redirectUrl?: string\n [x: string]: any\n}\n\n/**\n * Types of notification messages\n */\nexport enum AppNotificationType {\n success = 'success',\n info = 'info',\n warning = 'warning',\n error = 'error'\n}\n\nexport interface SystemNotification {\n id: number\n type: AppNotificationType\n message: string\n}\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport { DrillDownType } from '@cxbox-ui/schema'\n\nexport interface Route {\n type: RouteType\n path: string\n search: string\n params: Record<string, unknown>\n screenName?: string\n viewName?: string\n bcPath?: string\n}\n\nexport enum RouteType {\n screen = 'screen',\n default = 'default',\n router = 'router',\n invalid = 'invalid',\n unknown = 'unknown'\n}\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { WidgetMeta } from './widget'\nimport { RowMeta } from './rowMeta'\nimport { PendingDataItem, PickMap } from './data'\nimport { SystemNotification } from './objectMap'\nimport { OperationTypeCrud, OperationPostInvokeConfirm, OperationPostInvokeAny } from './operation'\nimport { AxiosError } from 'axios'\nimport { WaitUntilPopupOptions } from '../actions'\nimport { DataItem } from '@cxbox-ui/schema'\nexport { FieldType } from '@cxbox-ui/schema'\n\nexport interface ViewSelectedRow {\n widgetName: string\n rowId: string\n}\n\nexport interface PendingValidationFails {\n [bcName: string]: {\n [cursor: string]: Record<string, string>\n }\n}\n\n/**\n * Describes format of `pendingValidationFails`\n * TODO remove in 2.0.0\n */\nexport enum PendingValidationFailsFormat {\n old = 'old',\n target = 'target'\n}\n\nexport interface ViewState extends ViewMetaResponse {\n rowMeta: {\n [bcName: string]: {\n [bcUrl: string]: RowMeta\n }\n }\n pendingPostInvoke: {\n [bcName: string]: {\n [type: string]: OperationPostInvokeAny\n }\n }\n pendingDataChanges: {\n [bcName: string]: {\n [cursor: string]: PendingDataItem\n }\n }\n pendingDataChangesNow: {\n [bcName: string]: {\n [cursor: string]: PendingDataItem\n }\n }\n handledForceActive: {\n [bcName: string]: {\n [cursor: string]: PendingDataItem\n }\n }\n metaInProgress: {\n [bcName: string]: boolean\n }\n popupData?: PopupData\n infiniteWidgets?: string[]\n pickMap?: PickMap\n selectedRow: ViewSelectedRow | null\n selectedRows: { [bcName: string]: Array<Omit<DataItem, 'vstamp'>> | undefined }\n systemNotifications?: SystemNotification[]\n error?: ApplicationError\n /**\n * For backward compatibility\n *\n * `old` describes `pendingValidationFails` as `Record<string, string>`\n * `target` describes `pendingValidationFails` as `PendingValidationFails`\n */\n pendingValidationFailsFormat?: PendingValidationFailsFormat.old | PendingValidationFailsFormat.target // TODO remove in 2.0.0\n // TODO 2.0.0: should be `pendingValidationFails?: PendingValidationFails`\n pendingValidationFails?: Record<string, string> | PendingValidationFails\n modalInvoke?: {\n operation: {\n bcName: string\n operationType: OperationTypeCrud | string\n widgetName: string\n }\n confirmOperation: OperationPostInvokeConfirm\n }\n}\n\n/**\n * View description returned by Cxbox API\n */\nexport interface ViewMetaResponse {\n /**\n * @deprecated Deprecated in favor of `name`\n */\n id?: number\n /**\n * Name of the view as specified in *.view.json file\n */\n name: string\n /**\n * Displayed title\n */\n title?: string\n /**\n * Specifies which layout template to use for the view\n *\n *Not used in Cxbox UI Core, but can used by client application\n */\n template?: string\n /**\n * @deprecated Used for dynamic view layouts (configurable from user side), which are no longer implemented\n */\n customizable?: boolean\n /**\n * @deprecated Not used\n */\n editable?: boolean\n /**\n * Url for the view (usually in form of `${screen.name}/${view.name}`)\n */\n url: string\n /**\n * Widgets present on the view\n */\n widgets: WidgetMeta[]\n /**\n * @deprecated Used for dynamic view layouts (configurable from user side), which are no longer implemented\n */\n columns?: number | null\n /**\n * @deprecated Used for dynamic view layouts (configurable from user side), which are no longer implemented\n */\n rowHeight?: number | null\n /**\n * Not used in Cxbox UI Core, but can be used by client application\n */\n readOnly?: boolean\n /**\n * Not used in Cxbox UI Core\n *\n * TODO: Need description\n */\n ignoreHistory?: boolean\n}\n\nexport type PopupType = 'assoc' | 'file-upload' | 'waitUntil' | null\n\n/**\n * Describes currently open popup\n *\n * TODO: Split interface by popup types\n */\nexport interface PopupData {\n /**\n * Business component of the widget that initiated popup\n *\n * TODO: Will me removed in favor of widgetName in 2.0.0\n */\n calleeBCName?: string\n /**\n * Name of the widget that initiated popup\n */\n calleeWidgetName?: string\n /**\n * Type of the popup\n *\n * TODO: Will not be optional in 2.0.0\n */\n type?: PopupType | string\n /**\n * Business component for widget in Popup\n *\n * TODO: Move to inherited interfaces (not all popups display widgets)\n */\n bcName?: string\n /**\n * Name of popup widget\n *\n * TODO: Move to inherited interfaces (not all popups display widgets)\n */\n widgetName?: string\n /**\n * TODO: Description + move to AssocPopupDescriptor\n */\n associateFieldKey?: string\n /**\n * TODO: Description + move to AssocPopupDescriptor\n */\n assocValueKey?: string\n /**\n * If true popup confirm button will send selected items to Cxbox API\n *\n * TODO: Move to AssocPopupDescriptor\n */\n active?: boolean\n /**\n * This popup is used as a filter\n *\n * TODO: Used only by assocs so probably move to AssocPopupDescriptor\n */\n isFilter?: boolean\n\n options?: Partial<WaitUntilPopupOptions>\n}\n\nexport type ApplicationError = BusinessError | SystemError | ApplicationErrorBase\n\nexport enum ApplicationErrorType {\n BusinessError,\n SystemError,\n NetworkError\n}\n\nexport interface ApplicationErrorBase {\n type: ApplicationErrorType\n code?: number\n}\n\nexport interface BusinessError extends ApplicationErrorBase {\n type: ApplicationErrorType.BusinessError\n message: string\n}\n\nexport interface SystemError extends ApplicationErrorBase {\n type: ApplicationErrorType.SystemError\n error?: AxiosError\n details: string\n}\n\nexport interface NetworkError extends ApplicationErrorBase {\n type: ApplicationErrorType.NetworkError\n}\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { WidgetShowCondition, WidgetTypes, WidgetOptions, WidgetFormField, WidgetListField, WidgetInfoField } from '@cxbox-ui/schema'\nimport { ComponentType } from 'react'\nexport type {\n WidgetOptions,\n WidgetShowCondition,\n LayoutRow,\n LayoutCol,\n WidgetOperations,\n TableOperations,\n WidgetTableHierarchy,\n WidgetFieldBase,\n WidgetListFieldBase,\n WidgetFormFieldBase,\n AllWidgetTypeFieldBase,\n NumberFieldMeta,\n DateFieldMeta,\n CheckboxFieldMeta,\n DateTimeFieldMeta,\n DateTimeWithSecondsFieldMeta,\n DictionaryFieldMeta,\n TextFieldMeta,\n InputFieldMeta,\n MultiFieldMeta,\n MultivalueFieldMeta,\n PickListFieldMeta,\n InlinePickListFieldMeta,\n FileUploadFieldMeta,\n WidgetFormField,\n WidgetListField,\n HiddenFieldMeta,\n RadioButtonFieldMeta,\n WidgetField,\n WidgetInfoField\n} from '@cxbox-ui/schema'\n\nexport { WidgetTypes, PositionTypes } from '@cxbox-ui/schema'\n/**\n * Different widget types that are considered `tables` in nature for purposes of applying some shared features.\n * For example, autofocus on missing required field should work for tables but not forms.\n *\n * TODO: Make extension point\n *\n * @category Components\n */\nexport const TableLikeWidgetTypes = [\n WidgetTypes.List,\n WidgetTypes.DataGrid,\n WidgetTypes.AssocListPopup,\n WidgetTypes.PickListPopup,\n WidgetTypes.FlatTree,\n WidgetTypes.FlatTreePopup\n] as const\n\n/**\n * Widgets that are considered `popups` and usually excluded from widgets layout grid\n */\nexport const PopupWidgetTypes: string[] = [WidgetTypes.PickListPopup, WidgetTypes.AssocListPopup, WidgetTypes.FlatTreePopup]\n\n/**\n * All widget types that display table-like data.ts\n */\ntype TableLikeWidgetType = (typeof TableLikeWidgetTypes)[number]\n\nexport interface WidgetInfoOptions {\n fieldBorderBottom?: boolean\n footer?: string\n}\n\nexport interface WidgetMeta {\n name: string\n type: WidgetTypes | string // TODO: Как учитывать типы клиентских виджетов кроме string?\n title: string // отображаемое название,\n bcName: string\n /**\n * Business components ancestors hierarchy\n *\n * TODO: Will be mandatory (but nullable) in 2.0.0\n *\n * It is declared in `WidgetDTO` of Cxbox API, can be null for widgets without\n * business component (headers, navigation tabs, etc.)\n */\n url?: string | null\n position: number\n limit?: number\n gridWidth: number // 1-24\n fields: unknown[]\n options?: WidgetOptions\n showCondition?: WidgetShowCondition\n description?: string // description for documentation\n}\n\n/**\n * Description of the list of fields of block type.\n *\n * @deprecated Used to create a block grouping of fields\n */\nexport interface WidgetFieldBlock<T> {\n /**\n * Block ID\n */\n blockId: number\n /**\n * Name of the block\n */\n name: string\n /**\n * Fields contained in the block\n */\n fields: T[]\n /**\n * @deprecated TODO: Remove in 2.0.0, used to denote a new row in old layout system for forms\n */\n newRow?: boolean\n /**\n * @deprecated TODO: Remove in 2.0.0, used to ...\n */\n break?: boolean\n}\n\nexport type WidgetFieldsOrBlocks<T> = Array<T | WidgetFieldBlock<T>>\n\n/**\n * Configuration for widgets dislaying form data.ts\n */\nexport interface WidgetFormMeta extends WidgetMeta {\n /**\n * Unambiguous marker for JSON file specifing widget type\n */\n type: WidgetTypes.Form\n /**\n * Descriptor for fields or block of fields on the form\n */\n fields: WidgetFieldsOrBlocks<WidgetFormField>\n}\n\n/**\n * Configuration for widgets displaying table-like data.ts\n */\nexport interface WidgetTableMeta extends WidgetMeta {\n /**\n * Unambiguous marker for JSON file specifing widget type\n */\n type: TableLikeWidgetType\n /**\n * Descriptor for table columns\n */\n fields: WidgetListField[]\n}\n\n/**\n * Configuration for widgets displaying read-only table data.ts\n */\nexport interface WidgetInfoMeta extends WidgetMeta {\n /**\n * Unambiguous marker for JSON file specifying widget type\n */\n type: WidgetTypes.Info\n /**\n * Descriptor for fields or block of fields on the form\n */\n fields: WidgetFieldsOrBlocks<WidgetInfoField>\n /**\n * Options for customizing widget\n */\n options?: WidgetOptions & WidgetInfoOptions\n}\n\n/**\n * Configuration for widgets displaying markdown text\n */\nexport interface WidgetTextMeta extends WidgetMeta {\n /**\n * Unambiguous marker for JSON file specifying widget type\n */\n type: WidgetTypes.Text\n /**\n * Text to display\n */\n description: string\n /**\n * Title text\n */\n descriptionTitle: string\n}\n\n/**\n * Options configuration for widgets displaying NavigationTabs\n */\nexport interface NavigationOptions extends WidgetOptions {\n /**\n * Level of menu\n */\n navigationLevel?: number\n}\n\n/**\n * Configuration for widgets displaying NavigationTabs\n */\nexport interface NavigationWidgetMeta extends WidgetMeta {\n /**\n * Unambiguous marker for JSON file specifying widget type\n */\n type: WidgetTypes.NavigationTabs | WidgetTypes.ViewNavigation\n /**\n * Options for customizing widget\n */\n options: NavigationOptions\n}\n\n/**\n * A widget configuration of any known type\n */\nexport type WidgetMetaAny = WidgetFormMeta | WidgetTableMeta | WidgetTextMeta | WidgetInfoMeta | NavigationWidgetMeta\n\n/**\n * Component of custom widget\n *\n * @deprecated TODO: Remove in 2.0.0\n */\nexport type CustomWidget = ComponentType<any>\n\n/**\n * Configuration of custom widget\n */\nexport interface CustomWidgetConfiguration {\n /**\n * Whether widget is popup\n */\n isPopup?: boolean\n /**\n * Component of custom widget\n */\n component: ComponentType<any>\n /**\n * Card of widget\n */\n card?: ComponentType<any> | null\n}\n\nexport type CustomWidgetDescriptor = CustomWidget | CustomWidgetConfiguration\n/**\n * Check if descriptor is just a widget, or it has additional data.ts\n */\nexport function isCustomWidget(descriptor: CustomWidgetDescriptor): descriptor is CustomWidget {\n return !!descriptor && !('component' in descriptor)\n}\n\n/**\n * Checks whether @param descriptor is an instance of `CustomWidgetConfiguration`\n *\n * @param descriptor custom widget descriptor\n */\nexport function isCustomWidgetConfiguration(descriptor: CustomWidgetDescriptor): descriptor is CustomWidgetConfiguration {\n return descriptor && 'component' in descriptor\n}\n\n/**\n * TODO\n *\n * @param item\n * @category Type Guards\n */\nexport function isWidgetFieldBlock(item: any): item is WidgetFieldBlock<any> {\n return !!item && 'blockId' in item\n}\n\n/**\n * Type of pagination, either page numbers or \"Load More\" button\n */\nexport enum PaginationMode {\n page = 'page',\n loadMore = 'loadMore'\n}\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { DrillDownType } from './router'\nimport { AppNotificationType } from './objectMap'\nimport { DataItem } from './data'\nimport { OperationTypeCrud, OperationType } from '@cxbox-ui/schema'\nimport { AnyAction } from '@reduxjs/toolkit'\nexport type { OperationType, OperationInclusionDescriptor } from '@cxbox-ui/schema'\n\nexport { OperationTypeCrud }\n\nexport const coreOperations = [\n OperationTypeCrud.create,\n OperationTypeCrud.save,\n OperationTypeCrud.delete,\n OperationTypeCrud.associate,\n OperationTypeCrud.cancelCreate,\n OperationTypeCrud.fileUpload\n]\n\n/**\n *\n * @param operation\n */\nexport function isOperationGroup(operation: Operation | OperationGroup): operation is OperationGroup {\n return Array.isArray((operation as OperationGroup).actions)\n}\n\n/**\n * User operation: CRUD or any custom business action.\n *\n * Received from record's row meta.\n */\nexport interface Operation {\n /**\n * Displayed name\n */\n text: string\n /**\n * String that uniquely identifies an operation on widget\n */\n type: OperationType\n /**\n * A hint to decide where to display an operation which is related to the record or the whole widget\n */\n scope: OperationScope\n /**\n * @deprecated TODO: Remove in 2.0.0, designation unknown\n */\n action?: string\n /**\n * An icon (https://ant.design/components/icon) to display on operation button,\n */\n icon?: string\n /**\n * @deprecated TODO: Remove in 2.0.0 in favor of client-side custom parameters\n */\n bcKey?: string\n /**\n * Omit text value of operation in favor of icon\n */\n showOnlyIcon?: boolean\n /**\n * An operation that should be fired before initiating this operation\n */\n preInvoke?: OperationPreInvoke\n /**\n * Validate the record for empty \"required\" fields before API call\n */\n autoSaveBefore?: boolean\n /**\n * ???\n */\n confirmOperation?: OperationPreInvoke\n /**\n * If custom operation needs to be processed as if it was a default crud operation,\n * this flag can be specified and will be used instead of real `type`\n */\n actionRole?: OperationType\n /**\n * Subtype for association popup, used for calling multiFileUploadPopup,\n * else has default behaviour of assoc popup\n */\n subtype?: 'bc' | 'multiFileUpload'\n}\n\n/**\n * Group of actions.\n *\n * It shows name of a group, drop down list of actions\n * and some actions which are shown in case list is covered.\n * Группа действий, показывает название группы и раскрываемые список ее действий,\n * а также несколько действий рядом с группой, которые видны не раскрывая список.\n */\nexport interface OperationGroup {\n /**\n * Unique identifier for the operation group\n */\n type?: string\n /**\n * Displayed name of a group\n */\n text: string\n /**\n * An icon (https://ant.design/components/icon) to display on operation button,\n */\n icon?: string\n /**\n * Omit text value of operation in favor of icon\n */\n showOnlyIcon?: boolean\n /**\n * List of group actions\n */\n actions: Operation[]\n /**\n * Number of showed actions in case list is covered\n */\n maxGroupVisualButtonsCount: number\n}\n\n/**\n * An action which fires before user's operation\n */\nexport interface OperationPreInvoke {\n /**\n * A type of operation (Pop-up message. Other types are not supported)\n */\n type: OperationPreInvokeType\n /**\n * A message shown to user before operation fires\n */\n message: string\n /**\n * The custom popup widget name\n */\n widget?: string\n}\n\n/**\n * A type of message shown to user before operation fires\n */\nexport enum OperationPreInvokeType {\n /**\n * Pop-up message contains \"Yes/No\" answers.\n * If user says \"Yes\" then operation fires\n */\n confirm = 'confirm',\n /**\n * Pop-up message contains some informational text with info icon\n */\n info = 'info',\n /**\n * Pop-up message contains some information about error with error icon\n * Перед операцией пользователя будет показано всплывающее сообщение\n * с иконкой ошибки и операция не будет выполнена (TODO: Будет или не будет? Проверить)\n */\n error = 'error'\n}\n\n/**\n * A type of action which fires after user's operation\n */\nexport enum OperationPostInvokeType {\n /**\n * BC's refresh. It leads to cursor dropping, data.ts refresh of current BC and its children\n */\n refreshBC = 'refreshBC',\n /**\n * File downloading by `fileId` which comes from answer to user's operation.\n * Вызов сохранения файла в браузере по пришедшему в ответе fileId\n */\n downloadFile = 'downloadFile',\n /**\n * File downloading by `url` which comes from answer to user's operation.\n * Вызов сохранения файла в браузере по пришедшему в ответе url\n */\n downloadFileByUrl = 'downloadFileByUrl',\n /**\n * Calling a browser transition to some record\n */\n drillDown = 'drillDown',\n /**\n * `Pick list` widget opening\n */\n openPickList = 'openPickList',\n /**\n * @deprecated TODO: Не работает, удалить все упоминания из Досье и убрать всех свидетелей\n *\n */\n // delayedRefreshBC = 'delayedRefreshBC',\n /**\n * Showing pop-up message\n */\n showMessage = 'showMessage',\n /**\n * Инициировать удаление записей\n *\n * @deprecated TODO: Remove in 2.0.0\n */\n postDelete = 'postDelete',\n\n waitUntil = 'waitUntil',\n\n drillDownAndWaitUntil = 'drillDownAndWaitUntil'\n}\n\n/**\n * The type of message that will be shown to the user for confirmation\n */\nexport enum OperationPostInvokeConfirmType {\n /**\n * Simple confirmation\n */\n confirm = 'confirm',\n /**\n * Сonfirmation with text from the user\n */\n confirmText = 'confirmText'\n}\n\n/**\n * The action that will be performed after the user confirms it\n */\nexport interface OperationPostInvokeConfirm {\n /**\n * Type of postInvokeConfirm action\n */\n type: OperationPostInvokeConfirmType | string\n /**\n * Body text of a modal actually\n * TODO 2.0.0 rename correctly\n */\n message: string\n /**\n * Custom modal title actually\n * TODO 2.0.0 rename correctly\n */\n messageContent?: string\n /**\n * Custom label of OK button\n */\n okText?: string\n /**\n * Custom label of Cancel button\n */\n cancelText?: string\n}\n\n/**\n * Modal window operation types\n */\nexport interface OperationModalInvokeConfirm extends OperationPostInvokeConfirm {\n /**\n * Type of confirm action\n */\n type: OperationPostInvokeConfirmType | OperationPreInvokeType | string\n}\n\n/**\n * An action which fires after user's operation\n *\n * @param bc Имя бизнес-компоненты, которую надо обновлять при refreshBC\n * @param fileId Идентификатор файла, который надо скачать при downloadFile\n * @param url?\n *\n * @param [key: string] ??? TODO: Это что?\n */\nexport interface OperationPostInvoke {\n /**\n * A type of action\n */\n type: OperationPostInvokeType | string\n}\n\n/**\n * BC's refresh. It leads to cursor dropping, data.ts refresh of current BC and its children\n */\nexport interface OperationPostInvokeRefreshBc extends OperationPostInvoke {\n /**\n * BC's name\n */\n bc: string\n}\n\n/**\n * File downloading by `fileId` which comes from answer.\n */\nexport interface OperationPostInvokeDownloadFile extends OperationPostInvoke {\n /**\n * Backend's file ID\n */\n fileId: string\n}\n\n/**\n * File downloading by `url` which comes from answer.\n */\nexport interface OperationPostInvokeDownloadFileByUrl extends OperationPostInvoke {\n /**\n * File's URL\n */\n url: string\n}\n\n/**\n * Calling a browser transition to some record\n *\n * @param urlName При выполнении перехода на внешнюю сущность (POST-запрос на пришедший url),\n * этот адрес будет передан в теле запроса (см. CBR-9320 МР и тикет)\n */\nexport interface OperationPostInvokeDrillDown extends OperationPostInvoke {\n /**\n * URL of transition\n */\n url: string\n /**\n * A type of transition\n */\n drillDownType?: DrillDownType\n /**\n * If transition performs to outer entity (POST call),\n * this param will be passed to request body\n */\n urlName?: string\n}\n\n/**\n * `Pick list` widget opening\n */\nexport interface OperationPostInvokeOpenPickList extends OperationPostInvoke {\n /**\n * BC name of pick list widget\n */\n pickList: string\n}\n\n/**\n * Pop-up message showing\n */\nexport interface OperationPostInvokeShowMessage extends OperationPostInvoke {\n /**\n * A type of a message\n */\n messageType: AppNotificationType\n /**\n * A text of a message\n */\n messageText: string\n}\n\nexport interface OperationPostInvokeWaitUntil extends OperationPostInvoke {\n inProgressMessage?: string\n successCondition_bcName: string\n successCondition_fieldKey: string\n successCondition_value: unknown\n successMessage?: string\n timeout?: number | string\n timeoutMaxRequests?: number | string\n timeoutMessage?: string\n}\n\nexport interface OperationPostInvokeDrilldownAndWaitUntil extends OperationPostInvokeDrillDown, OperationPostInvokeWaitUntil {}\n\n/**\n * A union of all action types which could be be fired after user's operation\n */\nexport type OperationPostInvokeAny =\n | OperationPostInvokeRefreshBc\n | OperationPostInvokeDownloadFile\n | OperationPostInvokeDownloadFileByUrl\n | OperationPostInvokeDrillDown\n | OperationPostInvokeOpenPickList\n | OperationPostInvokeShowMessage\n | OperationPostInvokeConfirm\n | OperationPostInvokeWaitUntil\n | OperationPostInvokeDrilldownAndWaitUntil\n\n/**\n * TODO: ???\n */\nexport type OperationScope = 'bc' | 'record' | 'page' | 'associate' | 'mass'\n\nexport interface AssociatedItem extends DataItem {\n _associate: boolean\n}\n\nexport interface OperationError {\n success: false\n error: {\n entity?: OperationErrorEntity\n popup?: string[]\n postActions?: OperationPostInvokeAny[]\n }\n}\n\nexport interface OperationErrorEntity {\n bcName: string\n fields: Record<string, string>\n id: string\n}\n\nexport type RequestType = 'data' | 'row-meta' | 'force-active'\n\nexport interface ISendOperation {\n /**\n * The business component to fetch data for\n */\n bcName: string\n /**\n * Type of operation to be performed\n */\n operationType: OperationTypeCrud | string\n /**\n * What widget requires data\n */\n widgetName: string\n /**\n * Any other action\n */\n onSuccessAction?: AnyAction\n /**\n * params for confirm modal\n */\n confirm?: string\n /**\n * key called bk\n *\n * @deprecated TODO: Remove in 2.0.0\n */\n bcKey?: string\n /**\n * @deprecated TODO: Remove in 2.0.0 in favor of sendOperationWithConfirm\n */\n confirmOperation?: OperationPreInvoke\n}\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { DataValue } from './data'\n\nexport enum FilterType {\n /**\n * Transforms into combination of 'greaterOrEqualThan' and 'lessOrEqualThan' (See src/utils/filters.ts)\n */\n range = 'range',\n equals = 'equals',\n greaterThan = 'greaterThan',\n lessThan = 'lessThan',\n greaterOrEqualThan = 'greaterOrEqualThan',\n lessOrEqualThan = 'lessOrEqualThan',\n contains = 'contains',\n specified = 'specified',\n specifiedBooleanSql = 'specifiedBooleanSql',\n equalsOneOf = 'equalsOneOf',\n containsOneOf = 'containsOneOf'\n}\n\nexport interface BcFilter {\n type: FilterType | string\n fieldName: string\n value: DataValue | DataValue[]\n viewName?: string\n widgetName?: string\n}\n\nexport interface BcSorter {\n fieldName: string\n direction: 'asc' | 'desc'\n}\n\nexport interface FilterGroup {\n name: string\n filters: string\n}\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ViewNavigationGroup, MenuItem, ViewNavigationCategory, ViewNavigationItem } from '@cxbox-ui/schema'\nexport type { ViewNavigationGroup, MenuItem, ViewNavigationCategory, ViewNavigationItem } from '@cxbox-ui/schema'\n/**\n * Returns MenuItem if it is ViewNavigationItem\n *\n * @param item to be identified as view\n * @category Type Guards\n */\nexport function isViewNavigationItem(item: MenuItem): item is ViewNavigationItem {\n return !!item && 'viewName' in item\n}\n\n/**\n * @param item\n * @deprecated ViewNavigationCategory will be deleted in 2.0.0\n * @category Type Guards\n */\nexport function isViewNavigationCategory(item: any): item is ViewNavigationCategory {\n return !!item && 'categoryName' in item\n}\n\n/**\n * Returns MenuItem if it is ViewNavigationGroup\n *\n * @param item to be identified as group\n * @category Type Guards\n */\nexport function isViewNavigationGroup(item: MenuItem): item is ViewNavigationGroup {\n // TODO: remove 'categoryName' check in 2.0.0\n return !!item && 'child' in item && !('categoryName' in item)\n}\n\n/**\n * 1 - for static, top level navigation\n * 2 - `SecondLevelMenu` tab widgets\n * 2 - `ThirdLevelMenu` tab widgets\n * 2 - `FourthLevelMenu` tab widgets\n */\nexport type NavigationLevel = 1 | 2 | 3 | 4\n\n/**\n * Model for displayed tab item\n */\nexport interface NavigationTab {\n /**\n * View name where navigation tab will redirect the user\n */\n viewName: string\n /**\n * Displayed title: either view name or a group name\n */\n title?: string\n /**\n * When true, menu item will not be visible\n *\n * It's still will be accessible through direct link though\n */\n hidden?: boolean\n}\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Route, RouteType } from '../interfaces'\nimport { changeLocation } from '../actions'\nimport { ReducerBuilderManager } from './ReducerBuilderManager'\n\nexport const initialRouterState: Route = { type: RouteType.default, path: '/', search: '', params: null, screenName: null }\n\n/**\n * Router reducer\n *\n * Stores information about currently active route\n */\nexport const createRouterReducerBuilderManager = <S extends Route>(initialState: S) =>\n new ReducerBuilderManager<S>().addCase(changeLocation, (state, action) => {\n const { isTab, location } = action.payload\n // bcPath can be considered a filter for bc. This filter should not be reset when switching tabs.\n return (isTab ? { ...location, bcPath: location.bcPath || state.bcPath } : location) as S\n })\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport interface ApiCallContext {\n widgetName: string\n}\n\ntype QueryParamsMap = Record<string, string | number>\n\n/**\n * Removes empty values from query parameters dictionary\n *\n * @param qso Query parameters dictionary\n */\nfunction dropEmptyOrWrongParams(qso: QueryParamsMap) {\n const result: QueryParamsMap = { ...qso }\n\n return Object.keys(result).reduce((prev, paramKey) => {\n if (!prev[paramKey] && typeof prev[paramKey] !== 'number') {\n delete prev[paramKey]\n }\n return prev\n }, result)\n}\n\n/**\n * Extends url with query parameters control symbol (`?` or `&`)\n *\n * @param url Url with or without `?` symbol\n */\nexport function addTailControlSequences(url: string) {\n return !url.includes('?') ? url + '?' : url + '&'\n}\n\n/**\n * Extends url with query parameters\n *\n * @param url Url to extend\n * @param qso Query parameters dictionary\n */\nexport function applyParams(url: string, qso?: QueryParamsMap) {\n if (!qso) {\n return url\n }\n return applyRawParams(url, dropEmptyOrWrongParams(qso))\n}\n\n/**\n * TODO\n *\n * @param url\n * @param qso\n */\nexport function applyRawParams(url: string, qso: Record<string, any>) {\n if (!qso) {\n return url\n }\n const result = new URLSearchParams(qso).toString()\n return `${addTailControlSequences(url)}${result && `${result}`}`\n}\n","import { AxiosError } from 'axios'\nimport { apiError } from '../actions'\nimport { EMPTY, of } from 'rxjs'\n\ninterface ApiCallContext {\n widgetName: string\n}\n\nexport function createApiError(error: AxiosError, context: ApiCallContext = { widgetName: 'unknown' }) {\n if (!error.isAxiosError) return undefined\n\n return apiError({ error, callContext: context })\n}\n\nexport function createApiErrorObservable(error: AxiosError, context?: ApiCallContext) {\n const newApiError = createApiError(error, context)\n return newApiError ? of(newApiError) : EMPTY\n}\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Store } from '../interfaces/store'\nimport { DataItem } from '../interfaces/data'\n\n/**\n * TODO\n *\n * @param literals\n * @param placeholders\n */\nexport function getTemplate(literals: TemplateStringsArray, ...placeholders: any[]) {\n let result = ''\n for (let i = 0; i < placeholders.length; i++) {\n result += literals[i]\n result += '${' + i + '}'\n }\n result += literals[literals.length - 1]\n return result\n}\n\n/**\n * Forms a string representation of business components hierarchy with\n * respect to business components ancestors and their corresponding cursors\n *\n * @param bcName Business component name\n * @param includeSelf If result hierarchy should include target bc or only ancestors\n * @param state\n * @category Utils\n */\nexport function buildBcUrl(bcName: string, includeSelf = false, state: Store) {\n const bcMap = state.screen.bo.bc\n const bc = bcMap[bcName]\n if (!bc) {\n return null\n }\n const url = [bc.cursor && includeSelf ? `${bc.name}/${bc.cursor}` : bc.name]\n let nextBc = bc\n while (nextBc.parentName) {\n nextBc = bcMap[nextBc.parentName]\n url.push(`${nextBc.name}/${nextBc.cursor ?? null}`)\n }\n const bcUrl = url.reverse().join('/')\n return bcUrl\n}\n\nexport function splitBcUrl(bcUrl: string) {\n const bcUrlItems = bcUrl.split('/')\n const result = []\n\n for (let i = 0; i < bcUrlItems.length; i += 2) {\n const bcName = bcUrlItems[i]\n const bcCursor = bcUrlItems[i + 1]\n const includeSelf = bcName && bcCursor\n\n result.push(includeSelf ? `${bcName}/${bcCursor}` : bcName)\n }\n\n return result\n}\n\n// Token format: '${fieldName:defaultValue}'\nconst TAG_PLACEHOLDER = /\\${([^{}]+)}/g\n\n/**\n * Replaces tokens in a template string with object field values.\n * If the value is like a date, then convert it to the format 'DD.MM.YYYY'\n *\n * Example:\n * const item = { color1: 'Green', color2: 'Blue' }\n * const templatedString = 'Color is ${color1} ${color2:Purple} ${color3:Purple}'\n * format(templateString, item) // => 'Green Blue Purple'\n *\n * @param templatedString Patterned string\n * @param item An object in the fields of which tokens should be searched\n */\nconst formatString = (templatedString: string, item: DataItem): string => {\n if (!templatedString) {\n return ''\n }\n return templatedString.replace(TAG_PLACEHOLDER, (token, varName) => {\n const [key, defaultValue] = varName.split(':')\n const result = String(item?.[key] || defaultValue || '')\n // const date = moment(result, moment.ISO_8601)\n // return !date.isValid() ? result : date.format('DD.MM.YYYY')\n return result\n })\n}\n\nconst isTemplate = (templatedString: string): boolean => {\n if (!templatedString) {\n return false\n }\n return templatedString.match(TAG_PLACEHOLDER) !== null\n}\n\n/**\n * If there is a template in the field name then returns the formatted string\n *\n * @param title Field name\n * @param dataItem An object in the fields of which tokens should be searched\n */\nexport function getFieldTitle(title: string, dataItem?: DataItem) {\n if (!isTemplate(title)) {\n return title\n } else {\n return formatString(title, dataItem)\n }\n}\n\n/**\n * If there is a template in the field name then returns array of string\n *\n * Example:\n * splitIntoTokens(`The quick brown fox jumps over the lazy dog. If the dog reacted, was it realdogly lazy?`, 'dog')\n * [\"The quick brown fox jumps over the lazy \", \"dog\", \". If the \", \"dog\", \" reacted, was it real\", \"dog\", \"ly lazy?\"]\n *\n * @param source Field name\n * @param search An object in the fields of which tokens should be searched\n */\nexport function splitIntoTokens(source: string, search: string | RegExp) {\n const tokenizer = search instanceof RegExp ? search : escapedSrc(search)\n return source.split(tokenizer)\n}\n\n/**\n * Convert string to RegExp\n *\n * @param str Source string\n */\nexport function escapedSrc(str: string) {\n return new RegExp(`(${str?.replace(/[\\-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, '\\\\$&')})`, 'gi')\n}\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Utilities for urls and browser history\n */\nimport { Route, RouteType } from '../interfaces'\nimport { getTemplate } from './strings'\n\n/**\n * Appends '/' in front of `absoluteUrl` argument.\n * If `absoluteUrl` alredy starts with `/` then argument returned without changes.\n *\n * @param absoluteUrl Url\n */\nexport function makeRelativeUrl(absoluteUrl: string) {\n return absoluteUrl.startsWith('/') ? absoluteUrl : `/${absoluteUrl}`\n}\n\n/**\n * Parses a business component hierarchy url into a dictionary of business components\n * and their cursors.\n *\n * @param bcPath Business component hierarchy url, e.g. `bcName1/cursor1/bcName2/cursor2`\n * @category Utils\n */\nexport function parseBcCursors(bcPath: string) {\n if (!bcPath) {\n return null\n }\n const cursors: Record<string, string> = {}\n const tokens = bcPath.split('/')\n for (let i = 0; i < tokens.length; i = i + 2) {\n if (tokens[i + 1]) {\n cursors[tokens[i]] = tokens[i + 1]\n }\n }\n return cursors\n}\n\n/**\n * TODO\n *\n * @param literals\n * @param placeholders\n * @category Utils\n */\nexport function buildUrl(literals: TemplateStringsArray, ...placeholders: Array<string | number>) {\n let result = ''\n\n for (let i = 0; i < placeholders.length; i++) {\n result += literals[i]\n const placeholder = placeholders[i]\n\n if (typeof placeholder === 'number') {\n result += placeholder.toString(10)\n } else if (typeof placeholder === 'string') {\n result += encodeURIComponent(placeholder)\n } else {\n const template = getTemplate(literals, placeholders)\n throw new Error(`Неверный тип подстановочного знака в ${template}, index: ${i}, value: ${JSON.stringify(placeholder)}`)\n }\n }\n\n result += literals[literals.length - 1]\n return result\n}\n\n/**\n * Default implementation for utility to parse `history`-compatible location to {@link Route | Cxbox UI route}.\n *\n * Supports three types of URLs:\n * - {@link RouteType.screen | RouteType.screen}, i.e. an url referencing some UI entity that can be parsed to Route directly. Example: `/screen/name/view/name/`;\n * - {@link RouteType.router | RouteType.router}, i.e. an url without information about entity that should be handled on server side. Example: `/router/server-entity`\n * - {@link RouteType.default | RouteType.default}, i.e. an url that leads to default entity of the application. Example: `/`\n *\n * Reverse function is {@link defaultBuildURL}.\n *\n * @category Utils\n */\nexport function defaultParseURL(url: URL): Route {\n let path: string = url.pathname\n\n if (path.startsWith('/')) {\n path = path.substring(1)\n }\n if (path.endsWith('/')) {\n path = path.substring(0, path.length - 1)\n }\n if (path?.includes('&') && !path?.includes('?')) {\n path = path.substring(0, path.indexOf('&'))\n }\n const params: Record<string, unknown> = {}\n url.searchParams.forEach((value, key) => (params[key] = value))\n const tokens = path.split('/').map(decodeURIComponent)\n\n let type = RouteType.unknown\n let screenName = null\n let viewName = null\n let bcPath = null\n\n if (tokens.length > 0 && tokens[0] === 'router') {\n type = RouteType.router\n } else if (tokens.length === 1) {\n type = RouteType.default\n } else if (tokens.length >= 2 && tokens[0] === 'screen') {\n let bcIndex = 2\n type = RouteType.screen\n screenName = tokens[1]\n if (tokens.length >= 4 && tokens[2] === 'view') {\n bcIndex += 2\n viewName = tokens[3]\n }\n bcPath = tokens.slice(bcIndex).map(encodeURIComponent).join('/')\n }\n\n return {\n type: type,\n path: path.length !== 0 && !path.startsWith('/') ? `/${path}` : path,\n search: url.search,\n params,\n screenName,\n viewName,\n bcPath\n }\n}\n\n/**\n * Transform {@link Route | Cxbox UI route} to string url.\n *\n * Reverse function is {@link defaultParseURL}.\n *\n * @param route Cxbox UI route\n * @category Utils\n */\nexport function defaultBuildURL(route: Route) {\n return `/screen/${route.screenName}/view/${route.viewName}/${route.bcPath}`\n}\n\nexport const getRouteFromString = (ulrString: string) => {\n const url = new URL(ulrString, window.location.origin)\n\n return defaultParseURL(url)\n}\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { BcFilter, BcSorter, FilterType, DataValue, FieldType } from '../interfaces'\n\n/**\n * Maps an input array of BcFilter objects into a dictionary of GET-request params\n *\n * Name of the param formed as field name and filter type, separated by dot,\n * e.g. `${filter.fieldName}.${filter.type}`\n *\n * Value of the param is:\n * - for non-array values, stringified filter value\n * - for array values, a comma-separated list of stringified elements with each element enclosed in double quotes\n *\n * @see {@link parseFilters} Reverse function\n *\n * @param filters Filters for business components\n * @returns Dictionary of query-params for GET-request\n * @category Utils\n */\nexport function getFilters(filters: BcFilter[]) {\n if (!filters || !filters.length) {\n return null\n }\n const result: Record<string, string> = {}\n filters.forEach(item => {\n if (item.type === FilterType.range) {\n const values = item.value as DataValue[]\n if (values[0]) {\n result[`${item.fieldName}.${FilterType.greaterOrEqualThan}`] = String(values[0])\n }\n if (values[1]) {\n result[`${item.fieldName}.${FilterType.lessOrEqualThan}`] = String(values[1])\n }\n } else {\n const value = Array.isArray(item.value) ? JSON.stringify(item.value) : String(item.value)\n const separator = item.fieldName ? '.' : ''\n result[`${item.fieldName}${separator}${item.type}`] = value\n }\n })\n return result\n}\n\n/**\n * Maps an input array of business component sorters into a dictionary of query params for\n * Cxbox API, where values are field names and keys follows the template:\n * `_sort.${index}.${item.direction}`\n *\n * @param sorters Array of business component sorters\n * @returns Dictionary of query-params for GET-request\n * @category Utils\n */\nexport function getSorters(sorters: BcSorter[]) {\n if (!sorters || !sorters.length) {\n return null\n }\n const result: Record<string, string> = {}\n sorters.forEach((item, index) => {\n result[`_sort.${index}.${item.direction}`] = item.fieldName\n })\n return result\n}\n\nconst jsonParse = <T extends string>(value: T) => {\n try {\n return JSON.parse(value)\n } catch (e) {\n console.warn(e)\n\n return null\n }\n}\n\n/**\n * Function for parsing filters from string into BcFilter type\n *\n * @see {@link getFilters} Reverse function\n * @param defaultFilters string representation of filters\n * @category Utils\n */\nexport function parseFilters(defaultFilters: string = '') {\n const result: BcFilter[] = []\n const urlParams = new URLSearchParams(defaultFilters)\n const paramKeys = Object.keys(Object.fromEntries(urlParams))\n\n paramKeys.forEach(param => {\n const [fieldName, type] = param.split('.')\n const isStandardFilter = fieldName && type && urlParams.get(param)\n\n if (isStandardFilter) {\n let value: string | string[] = urlParams.getAll(param)\n\n if (type === FilterType.containsOneOf || type === FilterType.equalsOneOf) {\n if (value.length === 1) {\n value = jsonParse(value[0]) ?? value\n }\n\n value = Array.isArray(value) ? value : []\n } else {\n value = Array.isArray(value) ? value[0] : value\n }\n\n result.push({\n fieldName,\n type: type as FilterType,\n value\n })\n } else if (defaultFilters) {\n let value: string | string[] = urlParams.getAll(param)\n\n if (value.length === 1) {\n value = jsonParse(value[0]) ?? value[0]\n }\n\n result.push({\n fieldName: '',\n type: param as any,\n value: value\n })\n }\n })\n\n return result.length ? result : null\n}\n\n/**\n * Parse sorter string into separate sorter objects.\n * String representation of sorters is url based:\n * \"_sort.{order}.{direction}={fieldKey}&_sort.{order}.{direction}\"\n *\n * fieldKey Sort by field\n * order Priority of this specfic sorter\n * direction \"asc\" or \"desc\"\n *\n * i.e. \"_sort.0.asc=firstName\"\n *\n * @param sorters string representation of sorters\n * @category Utils\n */\nexport function parseSorters(sorters?: string) {\n if (!sorters || !sorters.length) {\n return null\n }\n const result: BcSorter[] = []\n const dictionary = new URLSearchParams(sorters)\n Array.from(dictionary.entries())\n .map(([sort, fieldKey]) => {\n const [order, direction] = sort.split('.').slice(1)\n return { fieldName: fieldKey as string, order: Number.parseInt(order, 10), direction }\n })\n .sort((a, b) => a.order - b.order)\n .forEach(item => {\n result.push({ fieldName: item.fieldName, direction: item.direction as 'asc' | 'desc' })\n })\n return result\n}\n\n/**\n * Returns appropriate filtration type for specified field type.\n *\n * - Text-based fields use `contains`\n * - Checkbox fields use `specified` (boolean)\n * - Dictionary fiels use `equalsOneOf`\n *\n * All other field types use strict `equals`\n *\n * @param fieldType Field type\n */\nexport function getFilterType(fieldType: FieldType) {\n switch (fieldType) {\n case FieldType.dictionary: {\n return FilterType.equalsOneOf\n }\n case FieldType.checkbox: {\n return FilterType.specified\n }\n case FieldType.input:\n case FieldType.text: {\n return FilterType.contains\n }\n default:\n return FilterType.equals\n }\n}\n\n/**\n * Function for converting filters from 'moreOrEqualThan' and 'lessOrEqualThan' types to a 'range' type\n *\n * @param filters array of BcFilter objects\n * @category Utils\n */\nexport const processDrilldownFilters = (filters: BcFilter[]) => {\n const result: BcFilter[] = []\n const rangeFilters: Record<string, BcFilter> = {}\n\n filters.forEach(filterItem => {\n const { type, fieldName, value } = filterItem\n\n if (type === FilterType.greaterOrEqualThan || type === FilterType.lessOrEqualThan) {\n if (!rangeFilters[fieldName]) {\n rangeFilters[fieldName] = { ...filterItem, type: FilterType.range, value: [null, null] }\n }\n const rangeFilterValue = rangeFilters[fieldName].value as DataValue[]\n rangeFilterValue[type === FilterType.greaterOrEqualThan ? 0 : 1] = value as DataValue\n } else {\n result.push(filterItem)\n }\n })\n\n return [...result, ...Object.values(rangeFilters)]\n}\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Operation, isOperationGroup, OperationGroup, OperationTypeCrud, coreOperations } from '../interfaces/operation'\nimport { buildBcUrl } from './strings'\nimport { Store } from '../interfaces/store'\nimport { sendOperation } from '../actions'\n\n/**\n * Extract operations from all operations groups and return them as an array of flat operations\n *\n * @param operations Operations or operation groups as received from row meta\n * @category Utils\n */\nexport function flattenOperations(operations: Array<Operation | OperationGroup>) {\n const result: Operation[] = []\n operations?.forEach(item => {\n if (isOperationGroup(item)) {\n const currentOperation = item\n currentOperation.actions.forEach(OperationItem => {\n result.push(OperationItem)\n })\n } else {\n result.push(item)\n }\n })\n return result\n}\n\n/**\n * Check if an operation matches a specified `role` directly by type or by `actionRole` field.\n *\n * If operation role is unavailable due to the store lacking an appropriate row meta, only `role` is checked.\n *\n * @param role Expected operation role or 'none' if operation shouldn't match any crud role\n * @param payload sendOperation action payload\n * @param store Store instance\n * @category Utils\n */\nexport function matchOperationRole(\n role: OperationTypeCrud | 'none' | string,\n payload: ReturnType<typeof sendOperation>['payload'],\n store: Store\n) {\n if (payload.operationType === role) {\n return true\n }\n const bcUrl = buildBcUrl(payload.bcName, true, store)\n const operations = flattenOperations(store.view.rowMeta[payload.bcName]?.[bcUrl]?.actions)\n const operation = operations.find(item => item.type === payload.operationType)\n if (role === 'none') {\n return coreOperations.every(item => item !== payload.operationType && item !== operation?.actionRole)\n }\n return operation?.actionRole === role\n}\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { WidgetMeta, WidgetShowCondition } from '../interfaces/widget'\nimport { BcMetaState } from '../interfaces/bc'\nimport { DataItem, PendingDataItem } from '../interfaces/data'\n\n/**\n * Find all widgets referencing or descendant from specified origin BC\n *\n * @param originBcName Origin business component name\n * @param widgets Widgets to search through\n * @param bcMap Business components dictionary\n * @returns A dictionary of business components and widgets\n */\nexport function getBcChildren(originBcName: string, widgets: WidgetMeta[], bcMap: Record<string, BcMetaState>) {\n // Build a dictionary with children for requested BC and widgets that need this BC\n const childrenBcMap: Record<string, string[]> = {}\n widgets\n .filter(widget => widget.bcName)\n .forEach(widget => {\n const widgetBcList: string[] = []\n // Find all BC ancestors for widget\n widgetBcList.push(widget.bcName)\n let parentName = bcMap[widget.bcName].parentName\n while (parentName) {\n widgetBcList.push(parentName)\n parentName = bcMap[parentName].parentName\n }\n // Put all widgets referencing this BC ancestors in dictionary\n widgetBcList\n .filter(expectedBcName => bcMap[expectedBcName].parentName === originBcName)\n .forEach(expectedBcName => {\n childrenBcMap[expectedBcName] = [...(childrenBcMap[expectedBcName] || []), widget.name]\n })\n })\n // If widget supports hierarchy, try to find origin BC in hierarchy options\n widgets\n .filter(item => item.options?.hierarchy)\n .forEach(widget => {\n const [hierarchyBcName, hierarchyWidgetName] = getHierarchyChildBc(originBcName, widget)\n if (hierarchyBcName) {\n childrenBcMap[hierarchyBcName] = [...(childrenBcMap[hierarchyBcName] || []), hierarchyWidgetName as string]\n }\n })\n\n return childrenBcMap\n}\n\nexport const isEagerWidget = (widget: WidgetMeta, lazyWidgetNames: string[], showConditionCheck?: (widget: WidgetMeta) => boolean) => {\n const isNotLazy = !lazyWidgetNames.includes(widget.name)\n const isVisible = showConditionCheck?.(widget) ?? true\n\n return isNotLazy && isVisible\n}\n\nexport function getEagerBcChildren(\n originBcName: string,\n widgets: WidgetMeta[],\n bcMap: Record<string, BcMetaState>,\n lazyWidgetNames: string[],\n showConditionCheck?: (widget: WidgetMeta) => boolean\n) {\n const childrenBcMap = getBcChildren(originBcName, widgets, bcMap)\n const result: Record<string, string[]> = {}\n\n for (const [childBcName, widgetNames] of Object.entries(childrenBcMap)) {\n const nonLazyWidget = widgets.find(item => {\n return widgetNames.includes(item.name) && isEagerWidget(item, lazyWidgetNames, showConditionCheck)\n })\n\n if (nonLazyWidget) {\n result[childBcName] = widgetNames\n }\n }\n\n return result\n}\n\n/**\n * Find child bc for hierarchy widget\n *\n * @param originBcName Origin business component name\n * @param hierarchyWidget Hierarchy widget\n */\nfunction getHierarchyChildBc(originBcName: string, hierarchyWidget: WidgetMeta) {\n const nestedBcNames = hierarchyWidget?.options?.hierarchy?.map(nestedItem => nestedItem.bcName)\n if (originBcName !== hierarchyWidget.bcName && !nestedBcNames?.includes(originBcName)) {\n return []\n }\n const childHierarchyBcIndex = nestedBcNames?.findIndex(item => item === originBcName) as number\n const childHierarchyBcName = nestedBcNames?.[childHierarchyBcIndex + 1]\n return [childHierarchyBcName, hierarchyWidget.name]\n}\n\n/**\n * Check specified show condition for the widget\n *\n * Condition is true (and widget is visible) if currently active record for condition business component has a value of the specific\n * field matching the condition; pending values are also enough for the condition to be true.\n * Condition is also true when it explicitly declared as default condition, if it's empty or of the legacy array format\n *\n * Otherwise the condition is false and the widget is hidden.\n *\n * @param condition Widget showCondition to check\n * @param cursor Id of active record for business component in condition\n * @param data An array of data.ts items to check for condition\n * @param pendingDataChanges Pending data.ts changes of the currently active view\n */\nexport function checkShowCondition(\n condition: WidgetShowCondition | undefined,\n cursor: string,\n data: DataItem[],\n pendingDataChanges: Record<string, Record<string, PendingDataItem>>\n) {\n const { bcName, isDefault, params } = condition || {}\n const emptyCondition = !condition || Array.isArray(condition)\n if (emptyCondition || isDefault) {\n return true\n }\n const record = cursor && data?.find(item => item.id === cursor)\n if (!record) {\n return false\n }\n const actualValue = record?.[params?.fieldKey as string]\n const pendingValue = pendingDataChanges?.[bcName as string]?.[cursor]?.[params?.fieldKey as string]\n return pendingValue !== undefined ? pendingValue === params?.value : actualValue === params?.value\n}\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * This module contains utilities for tree-like structures\n */\n\nimport { DataNode, TreeNodeBidirectional, TreeNodeDescending } from '../interfaces/tree'\n\n/**\n * Assigns for each element:\n *\n * - `parent` property, which is a reference to parent mode found through `parentId` match.\n * - `children` property, which is an array of references to child nodes.\n *\n * `parentId`: '0' considered a root pseudo-node\n *\n * Orphaned records will be excluded from result and throw a console warning.\n *\n * @param flat Flat array representation of tree structure\n * @returns New array\n */\nexport function assignTreeLinks<T extends DataNode>(flat: T[]) {\n const result = flat.map(item => ({ ...item })) as Array<T & TreeNodeBidirectional>\n const map: Record<string, number> = {}\n const orphans: string[] = []\n result.forEach(item => {\n if (!item.parentId || item.parentId === '0') {\n return\n }\n let parentIndex = map[item.parentId]\n if (typeof parentIndex !== 'number') {\n parentIndex = flat.findIndex(el => el.id === item.parentId)\n map[item.parentId] = parentIndex\n }\n if (parentIndex === -1) {\n orphans.push(item.parentId)\n console.warn(\n `Record with [id] = ${item.id} has [parentId] = ${item.parentId}, but no matching` +\n ' parent record exist. Check the service for this BC.'\n )\n return\n }\n item.parent = result[parentIndex]\n if (!result[parentIndex].children) {\n result[parentIndex].children = [item]\n } else {\n result[parentIndex]?.children?.push(item)\n }\n })\n if (orphans.length) {\n return result.filter(item => !orphans.includes(item.parentId))\n }\n return result\n}\n\n/**\n * Recursively traverse through each node and their descendant to aggregate ids of all\n * descendant nodes into `result` array.\n *\n * @param nodes Nodes to start search from; their ids also will be part of the result\n * @param result An array of ids for found descendant nodes\n */\nexport function getDescendants(nodes: TreeNodeDescending[], result: string[]) {\n nodes.forEach(child => {\n result.push(child.id)\n if (child.children) {\n getDescendants(child.children, result)\n }\n })\n}\n\n/**\n * Returns array of matching nodes, their direct children and every ancestor node\n *\n * @param nodes An array to search\n * @param matchingNodes Ids of the nodes to match\n */\nexport function buildSearchResultTree<T extends TreeNodeBidirectional = TreeNodeBidirectional>(nodes: T[], matchingNodes: string[]) {\n const result: Record<string, boolean> = {}\n nodes.forEach(item => {\n if (!matchingNodes.includes(item.id)) {\n return\n }\n let parent = item.parent\n while (parent) {\n result[parent.id] = true\n parent = parent.parent\n }\n result[item.id] = true\n item.children?.forEach(child => {\n result[child.id] = true\n })\n })\n // todo: iterate through result directly\n return nodes.filter(item => result[item.id] === true)\n}\n\n/**\n * Presort items based on their `level` property: each parent is followed by its descendant.\n * Items with level `1` considered to be root-level items.\n *\n * Notice: not very performant and almost always wasted as Cxbox API mostly returns already\n * sorted data.ts.\n *\n * @param data Unsorted data.ts\n */\nexport function presort(data: TreeNodeBidirectional[]) {\n const result: string[] = []\n data.filter(item => item.level === 1).forEach(item => {\n result.push(item.id)\n if (item.children) {\n getDescendants(item.children, result)\n }\n })\n return result.map(id => data.find(match => match.id === id))\n}\n","import { ViewMetaResponse } from '../interfaces'\n\nexport const getDefaultViewForPrimary = (primary: string, views: ViewMetaResponse[]) => {\n if (!primary) return null\n\n return views.find(item => item.name === primary) ?? null\n}\n","import { ViewMetaResponse } from '../interfaces'\n\nexport const getDefaultViewFromPrimaries = (primaries: string[] | null, views: ViewMetaResponse[]) => {\n if (!primaries) return null\n\n let primaryView: ViewMetaResponse | null = null\n\n for (const primaryViewName of primaries) {\n if (primaryView !== null) {\n break\n }\n\n primaryView = views.find(view => view.name === primaryViewName) ?? null\n }\n\n return primaryView\n}\n","import { DataValue } from '@cxbox-ui/schema'\nimport { RowMeta } from '../interfaces'\n\nexport const removeDisabledFieldsMutate = <Changes extends { [p: string]: DataValue }>(changes: Changes, rowMeta: RowMeta | undefined) => {\n // there is no row meta when parent bc custom operation's postaction triggers autosave, because custom operation call bcForceUpdate\n if (rowMeta) {\n Object.keys(changes).forEach(key => {\n const rowMetaOfDisabledField = rowMeta.fields.find(field => field.key === key && field.disabled)\n\n if (rowMetaOfDisabledField) {\n delete changes[key]\n\n if (rowMetaOfDisabledField.currentValue !== undefined) {\n console.error('Changes to disabled fields are not taken into account when sending')\n }\n }\n })\n }\n\n return changes\n}\n\nexport const removeDisabledFields = <Changes extends { [p: string]: DataValue }>(\n changes: Changes | undefined,\n rowMeta: RowMeta | undefined\n) => {\n return removeDisabledFieldsMutate({ ...changes }, rowMeta)\n}\n","import { EpicDependencyInjection, PopupWidgetTypes, WidgetMeta } from '../interfaces'\n\nexport const getWidgetsForLazyLoad = (\n widgets: WidgetMeta[],\n getInternalWidgets: EpicDependencyInjection['utils']['getInternalWidgets'],\n activePopupBcName?: string\n) => {\n const popupWidgets: WidgetMeta[] = []\n const mainWidgets: WidgetMeta[] = []\n\n for (const widget of widgets) {\n if (PopupWidgetTypes.includes(widget.type) && (!activePopupBcName || widget.bcName !== activePopupBcName)) {\n popupWidgets.push(widget)\n } else {\n mainWidgets.push(widget)\n }\n }\n\n const internalPopupWidgetsNames = getInternalWidgets?.(popupWidgets) || []\n const internalMainWidgetsNames = getInternalWidgets?.(mainWidgets) || []\n const internalNames = new Set([...internalPopupWidgetsNames, ...internalMainWidgetsNames])\n\n const externalPopupWidgets = popupWidgets.filter(widget => !internalNames.has(widget.name))\n const externalMainWidgets = mainWidgets.filter(widget => !internalNames.has(widget.name))\n\n const exclusionSet = new Set([...externalMainWidgets.map(widget => widget.name), ...internalMainWidgetsNames])\n\n const uniqueInternalPopupWidgetsNames = internalPopupWidgetsNames.filter(\n internalPopupWidgetName => !exclusionSet.has(internalPopupWidgetName)\n )\n\n return [...new Set([...externalPopupWidgets.map(widget => widget.name), ...uniqueInternalPopupWidgetsNames])]\n}\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Search node matching the predicate on the current depth prior to moving to the next depth level\n *\n * @param root Tree root\n * @param predicate Search condition for the target tree node\n * @returns Matching node and a tree depth where this node was found\n */\nexport function breadthFirstSearch<T>(\n root: T,\n predicate: (current: any) => boolean,\n depth = 1,\n childrenProperty = 'child' as keyof T\n): BreadthFirstResult<T> {\n // Check the root if we can stop searching\n const rootMatch = predicate(root) && root\n const rootChildren = root[childrenProperty] as unknown as T[]\n if (!rootMatch && !rootChildren) {\n return null\n }\n if (rootMatch) {\n return { node: rootMatch, depth }\n }\n // Check all nodes on current depth\n let simpleLeaf = rootChildren.filter(item => !item[childrenProperty]).find(item => predicate(item))\n if (simpleLeaf) {\n return { node: simpleLeaf, depth: depth + 1 }\n }\n // Move to the next depth\n let resultDepth = depth\n rootChildren.some(item => {\n const search = breadthFirstSearch<T>(item, predicate, resultDepth + 1, childrenProperty ?? ('child' as keyof T))\n simpleLeaf = search?.node\n resultDepth = search?.depth\n return search?.node\n })\n return simpleLeaf ? { node: simpleLeaf, depth: resultDepth } : null\n}\n\n/**\n * Bredth-first search result\n */\nexport interface BreadthFirstResult<T> {\n /**\n * Matching node\n */\n node: T\n /**\n * Tree depth where this node was found\n */\n depth: number\n}\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport function deleteUndefinedFromObject(obj: Record<string, any>) {\n Object.keys(obj).forEach(key => {\n if (obj[key] === undefined) {\n delete obj[key]\n }\n })\n}\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { CustomWidgetDescriptor, isCustomWidgetConfiguration, PopupWidgetTypes } from '../interfaces/widget'\n\n/**\n * Add new values to `PopupWidgetTypes` from client application\n *\n * @param customWidgets client's widgets\n */\nexport function extendPopupWidgetTypes(customWidgets: Record<string, CustomWidgetDescriptor>) {\n if (customWidgets) {\n Object.entries(customWidgets).forEach(([widgetType, descriptor]) => {\n if (isCustomWidgetConfiguration(descriptor) && descriptor.isPopup) {\n if (!PopupWidgetTypes.includes(widgetType)) {\n PopupWidgetTypes.push(widgetType)\n }\n }\n })\n }\n}\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ScreenState } from '../interfaces'\nimport { BcMeta, BcMetaState } from '../interfaces'\nimport { OperationTypeCrud } from '@cxbox-ui/schema'\nimport { parseFilters, parseSorters } from '../utils'\nimport { BcFilter, BcSorter } from '../interfaces'\nimport {\n associateInProgress,\n bcAddFilter,\n bcAddSorter,\n bcChangeCursors,\n bcChangeDepthCursor,\n bcChangePage,\n bcDeleteDataFail,\n bcFetchDataFail,\n bcFetchDataRequest,\n bcFetchDataSuccess,\n bcForceUpdate,\n bcLoadMore,\n bcNewDataSuccess,\n bcRemoveAllFilters,\n bcRemoveFilter,\n bcSaveDataFail,\n bcSaveDataSuccess,\n bcSelectRecord,\n inlinePickListFetchDataSuccess,\n selectScreen,\n selectScreenFail,\n selectView,\n sendOperation,\n sendOperationFail,\n sendOperationSuccess,\n setOperationFinished,\n showViewPopup\n} from '../actions'\nimport { ReducerBuilderManager } from './ReducerBuilderManager'\nimport { DepthBcType } from '../interfaces/bc'\n\nexport const initialScreenState: ScreenState = {\n screenName: '',\n bo: { activeBcName: '', bc: {} },\n cachedBc: {},\n views: [],\n primaryView: '',\n primaryViews: null,\n filters: {},\n sorters: {}\n}\n\nconst operationsHandledLocally: readonly string[] = [OperationTypeCrud.associate, OperationTypeCrud.fileUpload]\n\n/**\n * Screen reducer\n *\n * Stores information about currently active screen and various more persistent values which should be stored\n * until we navitage to a different screen.\n */\nexport const createScreenReducerBuilderManager = <S extends ScreenState>(initialState: S) =>\n new ReducerBuilderManager<S>()\n .addCase(selectScreen, (state, action) => {\n const bcDictionary: Record<string, BcMeta> = {}\n const bcSorters: Record<string, BcSorter[]> = {}\n const bcFilters: Record<string, BcFilter[]> = {}\n action.payload.screen.meta?.bo.bc.forEach(item => {\n bcDictionary[item.name] = item\n const sorter = parseSorters(item.defaultSort)\n const filter = parseFilters(item.defaultFilter)\n if (sorter) {\n bcSorters[item.name] = sorter\n }\n if (filter) {\n bcFilters[item.name] = filter\n }\n })\n state.screenName = action.payload.screen.name\n state.primaryView = action.payload.screen.meta?.primary ?? state.primaryView\n state.primaryViews = action.payload.screen.meta?.primaries ?? state.primaryViews\n state.views = action.payload.screen.meta?.views ?? state.views\n state.bo = { activeBcName: null, bc: bcDictionary }\n state.sorters = { ...state.sorters, ...bcSorters }\n state.filters = { ...state.filters, ...bcFilters }\n })\n .addCase(selectScreenFail, (state, action) => {\n state.screenName = action.payload.screenName\n state.views = []\n })\n .addCase(bcFetchDataRequest, (state, action) => {\n const bcName = action.payload.bcName\n if (action.payload.bcName) {\n state.bo.bc[bcName].loading = true\n }\n })\n .addCase(bcLoadMore, (state, action) => {\n const currentBc = state.bo.bc[action.payload.bcName]\n currentBc.page = (currentBc.page ?? 1) + 1\n currentBc.loading = true\n })\n .addCase(selectView, (state, action) => {\n if (action.payload.isTab) {\n return\n }\n const newBcs: Record<string, BcMetaState> = {}\n Array.from(\n new Set(action.payload.widgets?.map(widget => widget.bcName)) // БК которые есть на вьюхе\n )\n .filter(bcName => state.bo.bc[bcName])\n .forEach(bcName => {\n newBcs[bcName] = { ...state.bo.bc[bcName], page: 1 }\n })\n state.bo.bc = { ...state.bo.bc, ...newBcs }\n })\n .addCase(bcFetchDataSuccess, (state, action) => {\n const currentBc = state.bo.bc[action.payload.bcName]\n currentBc.hasNext = action.payload.hasNext\n currentBc.loading = false\n state.cachedBc[action.payload.bcName] = action.payload.bcUrl\n })\n .addCase(inlinePickListFetchDataSuccess, (state, action) => {\n const currentBc = state.bo.bc[action.payload.bcName]\n currentBc.hasNext = action.payload.hasNext\n currentBc.loading = false\n state.cachedBc[action.payload.bcName] = action.payload.bcUrl\n })\n .addCase(bcFetchDataFail, (state, action) => {\n const bcName = action.payload.bcName as string\n\n if (Object.values(state.bo.bc).some(bc => bc.name === bcName)) {\n state.bo.bc[bcName].loading = false\n state.cachedBc[bcName] = action.payload.bcUrl\n }\n })\n .addCase(sendOperation, (state, action) => {\n const { bcName, operationType } = action.payload\n if (!operationsHandledLocally.includes(action.payload.operationType)) {\n state.bo.bc[bcName].loading = true\n const prevOperationsInProgress = state.bo.bc[bcName].operationsInProgress ?? []\n state.bo.bc[bcName].operationsInProgress = [...prevOperationsInProgress, operationType]\n }\n })\n .addCase(bcNewDataSuccess, (state, action) => {\n state.bo.bc[action.payload.bcName].loading = false\n state.bo.bc[action.payload.bcName].cursor = action.payload.dataItem.id\n state.cachedBc[action.payload.bcName] = action.payload.bcUrl\n })\n .addCase(bcChangeCursors, (state, action) => {\n const newCursors: Record<string, BcMetaState> = {}\n const newCache: Record<string, string> = {}\n Object.entries(action.payload.cursorsMap).forEach(entry => {\n const [bcName, cursor] = entry\n newCursors[bcName] = { ...state.bo.bc[bcName], cursor }\n newCache[bcName] = cursor\n })\n // Also reset cursors of all children of requested BCs\n const changedParents = Object.values(newCursors).map(bc => `${bc.url}/:id`)\n Object.values(state.bo.bc).forEach(bc => {\n if (changedParents.some(item => bc.url.includes(item)) && !(bc.name in newCursors)) {\n newCursors[bc.name] = { ...state.bo.bc[bc.name], cursor: null }\n newCache[bc.name] = null\n }\n })\n Object.assign(state.bo.bc, newCursors)\n Object.assign(state.cachedBc, newCache)\n })\n .addCase(bcChangeDepthCursor, (state, action) => {\n if (action.payload.depth === 1) {\n state.bo.bc[action.payload.bcName].cursor = action.payload.cursor\n } else {\n state.bo.bc[action.payload.bcName].depthBc = state.bo.bc[action.payload.bcName].depthBc ?? {}\n ;(state.bo.bc[action.payload.bcName].depthBc as DepthBcType)[action.payload.depth].cursor = action.payload.cursor\n }\n })\n .addCase(bcSelectRecord, (state, action) => {\n state.bo.bc[action.payload.bcName].cursor = action.payload.cursor\n })\n .addCase(bcForceUpdate, (state, action) => {\n state.bo.bc[action.payload.bcName].loading = true\n state.cachedBc[action.payload.bcName] = null\n })\n .addCase(bcAddFilter, (state, action) => {\n const { bcName, filter } = action.payload\n const newFilter = filter\n const prevFilters = state.filters[bcName] || []\n const prevFilter = prevFilters.find(item => item.fieldName === filter.fieldName && item.type === filter.type)\n const newFilters = prevFilter\n ? prevFilters.map(item => (item === prevFilter ? { ...prevFilter, value: newFilter.value } : item))\n : [...prevFilters, newFilter]\n\n if (state.bo.bc[bcName]) {\n state.bo.bc[bcName].page = 1\n }\n\n state.filters[bcName] = newFilters\n })\n .addCase(bcRemoveFilter, (state, action) => {\n const { bcName, filter } = action.payload\n const prevBcFilters = state.filters[bcName] || []\n const newBcFilters = prevBcFilters.filter(item => item.fieldName !== filter?.fieldName || item.type !== filter.type)\n const newFilters = { ...state.filters, [bcName]: newBcFilters }\n if (!newBcFilters.length) {\n delete newFilters[bcName]\n }\n\n if (state.bo.bc[action.payload.bcName]) {\n state.bo.bc[action.payload.bcName].page = 1\n }\n\n state.filters = newFilters\n })\n .addCase(bcRemoveAllFilters, (state, action) => {\n delete state.filters[action.payload.bcName]\n\n if (state.bo.bc[action.payload.bcName]) {\n state.bo.bc[action.payload.bcName].page = 1\n }\n })\n .addCase(bcAddSorter, (state, action) => {\n state.sorters[action.payload.bcName] = Array.isArray(action.payload.sorter) ? action.payload.sorter : [action.payload.sorter]\n })\n .addCase(bcChangePage, (state, action) => {\n state.bo.bc[action.payload.bcName].page = action.payload.page\n state.bo.bc[action.payload.bcName].loading = true\n })\n .addCase(showViewPopup, (state, action) => {\n const currentPage = state.bo.bc[action.payload.bcName]?.page ?? 1\n\n state.bo.bc[action.payload.bcName].page = action.payload.bcName === action.payload.calleeBCName ? currentPage : 1\n state.bo.bc[action.payload.bcName].loading = action.payload.bcName !== action.payload.calleeBCName\n })\n //don't use matcher in prior to add more cases\n .addCase(sendOperationSuccess, (state, action) => {\n state.bo.bc[action.payload.bcName].loading = false\n })\n .addCase(bcDeleteDataFail, (state, action) => {\n state.bo.bc[action.payload.bcName].loading = false\n })\n .addCase(sendOperationFail, (state, action) => {\n state.bo.bc[action.payload.bcName].loading = false\n })\n .addCase(bcSaveDataSuccess, (state, action) => {\n state.bo.bc[action.payload.bcName].loading = false\n })\n .addCase(bcSaveDataFail, (state, action) => {\n state.bo.bc[action.payload.bcName].loading = false\n })\n .addCase(associateInProgress, (state, action) => {\n const bcName = action.payload.bcName\n if (bcName) {\n const prevOperationsInProgress = state.bo.bc[bcName].operationsInProgress ?? []\n state.bo.bc[bcName].operationsInProgress = [...prevOperationsInProgress, 'saveAssociations']\n }\n })\n .addCase(setOperationFinished, (state, action) => {\n const { bcName, operationType } = action.payload\n state.bo.bc[bcName].operationsInProgress = state.bo.bc[bcName].operationsInProgress?.filter(item => item !== operationType)\n })\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { PendingValidationFailsFormat, ViewState, PendingDataItem } from '../interfaces'\nimport { DataItem, OperationTypeCrud } from '@cxbox-ui/schema'\nimport {\n bcCancelPendingChanges,\n bcFetchRowMeta,\n bcFetchRowMetaFail,\n bcFetchRowMetaSuccess,\n bcLoadMore,\n bcNewDataFail,\n bcNewDataSuccess,\n bcSaveDataFail,\n bcSaveDataSuccess,\n changeDataItem,\n changeDataItems,\n changeLocation,\n clearSelectedRows,\n clearValidationFails,\n closeConfirmModal,\n closeNotification,\n closeViewError,\n closeViewPopup,\n deselectRows,\n deselectTableRow,\n dropAllAssociations,\n dropAllAssociationsFull,\n dropAllAssociationsSameBc,\n forceActiveChangeFail,\n forceActiveRmUpdate,\n operationConfirmation,\n processPostInvoke,\n applyPendingPostInvoke,\n selectRows,\n selectTableRow,\n selectView,\n sendOperation,\n sendOperationFail,\n sendOperationSuccess,\n setPendingPostInvoke,\n showFileUploadPopup,\n showNotification,\n showViewError,\n showViewPopup,\n viewClearPickMap,\n viewPutPickMap\n} from '../actions'\nimport { ReducerBuilderManager } from './ReducerBuilderManager'\n\nexport const initialViewState: ViewState = {\n id: undefined,\n name: null,\n url: null,\n widgets: [],\n columns: null,\n readOnly: false,\n rowHeight: null,\n rowMeta: {},\n metaInProgress: {},\n popupData: { bcName: null },\n pendingDataChanges: {},\n pendingPostInvoke: {},\n pendingDataChangesNow: {},\n infiniteWidgets: [],\n pendingValidationFailsFormat: PendingValidationFailsFormat.old,\n pendingValidationFails: {},\n handledForceActive: {},\n selectedRow: null,\n selectedRows: {},\n ignoreHistory: null,\n systemNotifications: [],\n error: null,\n modalInvoke: null\n}\n\nconst isEmptyFieldValue = (value: unknown) =>\n value === null || value === undefined || value === '' || (Array.isArray(value) && Object.keys(value).length === 0)\n\nconst getFailsByRequiredFields = (data: PendingDataItem, isRequired: (fieldKey: string) => boolean) => {\n const fails: Record<string, string> = {}\n\n Object.keys(data).forEach(fieldKey => {\n if (isRequired(fieldKey) && isEmptyFieldValue(data[fieldKey])) {\n fails[fieldKey] = 'This field is mandatory'\n }\n })\n\n return fails\n}\n\n/**\n * View reducer\n *\n * Stores information about currently active view and various fast-living pending values which should be stored\n * until we navitage to a different view.\n */\nexport const createViewReducerBuilderManager = <S extends ViewState>(initialState: S) =>\n new ReducerBuilderManager<S>()\n .addCase(selectView, (state, action) => {\n if (!action.payload.isTab) {\n state.rowMeta = initialViewState.rowMeta\n }\n Object.assign(state, action.payload)\n })\n .addCase(bcFetchRowMeta, (state, action) => {\n state.metaInProgress[action.payload.bcName] = true\n })\n .addCase(bcLoadMore, (state, action) => {\n const infiniteWidgets: string[] = state.infiniteWidgets || []\n if (action.payload.widgetName !== undefined) {\n infiniteWidgets.push(action.payload.widgetName)\n }\n state.infiniteWidgets = Array.from(new Set(infiniteWidgets))\n })\n .addCase(sendOperation, (state, action) => {\n if (action.payload.operationType === OperationTypeCrud.create) {\n state.metaInProgress[action.payload.bcName] = true\n }\n })\n .addCase(bcFetchRowMetaSuccess, (state, action) => {\n state.rowMeta[action.payload.bcName] = state.rowMeta[action.payload.bcName] ?? {}\n state.rowMeta[action.payload.bcName][action.payload.bcUrl] = action.payload.rowMeta\n state.metaInProgress[action.payload.bcName] = false\n })\n .addCase(bcNewDataSuccess, (state, action) => {\n state.selectedRow = initialViewState.selectedRow\n })\n .addCase(forceActiveRmUpdate, (state, action) => {\n const { bcName, bcUrl, currentRecordData, rowMeta, cursor } = action.payload\n const handledForceActive: PendingDataItem = {}\n const rowMetaForcedValues: PendingDataItem = {}\n const newPendingChangesDiff: PendingDataItem = {}\n const forceActiveFieldKeys: string[] = []\n\n // приведем значения переданные в forcedValue в вид дельты изменений\n rowMeta.fields.forEach(field => {\n rowMetaForcedValues[field.key] = field.currentValue\n if (field.forceActive) {\n forceActiveFieldKeys.push(field.key)\n }\n })\n state.pendingDataChanges[bcName] = state.pendingDataChanges[bcName] ?? {}\n const consolidatedFrontData: PendingDataItem = { ...currentRecordData, ...state.pendingDataChanges[bcName][cursor] }\n // вычислим \"разницу\" между консолид.данными и полученными forcedValue's в пользу последних\n Object.keys(consolidatedFrontData).forEach(key => {\n if (rowMetaForcedValues[key] !== undefined && consolidatedFrontData[key] !== rowMetaForcedValues[key]) {\n newPendingChangesDiff[key] = rowMetaForcedValues[key]\n }\n })\n\n // консолидация полученной разницы с актуальной дельтой\n const newPendingDataChanges = { ...state.pendingDataChanges[bcName][cursor], ...newPendingChangesDiff }\n\n const isTargetFormatPVF = state.pendingValidationFailsFormat === PendingValidationFailsFormat.target\n const nextValidationFails = getFailsByRequiredFields(\n newPendingDataChanges,\n fieldKey => !!state.rowMeta[bcName]?.[bcUrl]?.fields.find(item => item.required && item.key === fieldKey)\n )\n\n // обновление ошибок, на основе полей заполненных через роу-мету\n if (isTargetFormatPVF) {\n state.pendingValidationFails = state.pendingValidationFails ?? {}\n state.pendingValidationFails[bcName] = state.pendingValidationFails[bcName] ?? {}\n ;(state.pendingValidationFails[bcName] as { [cursor: string]: Record<string, string> })[cursor] = nextValidationFails\n } else {\n state.pendingValidationFails = nextValidationFails\n }\n\n // отразим в списке обработанных forceActive полей - те что содержатся в новой дельте\n forceActiveFieldKeys.forEach(key => {\n if (newPendingDataChanges[key] !== undefined) {\n handledForceActive[key] = newPendingDataChanges[key]\n }\n })\n state.handledForceActive[bcName] = state.handledForceActive[bcName] ?? {}\n state.handledForceActive[bcName][cursor] = state.handledForceActive[bcName][cursor] ?? {}\n Object.assign(state.handledForceActive[bcName][cursor], handledForceActive)\n state.pendingDataChanges[bcName] = state.pendingDataChanges[bcName] ?? {}\n state.pendingDataChanges[bcName][cursor] = newPendingDataChanges\n state.pendingDataChangesNow[bcName] = state.pendingDataChangesNow[bcName] ?? {}\n state.pendingDataChangesNow[bcName][cursor] = {}\n state.rowMeta[bcName] = state.rowMeta[bcName] ?? {}\n state.rowMeta[bcName][bcUrl] = rowMeta\n })\n .addCase(changeDataItem, (state, action) => {\n const actionBcName = action.payload.bcName\n const prevBc = state.pendingDataChanges[action.payload.bcName] || {}\n const prevCursor = prevBc[action.payload.cursor] || {}\n const prevPending = prevCursor || {}\n const nextPending = { ...prevPending, ...action.payload.dataItem }\n const bcUrl = action.payload.bcUrl\n\n state.pendingDataChanges[action.payload.bcName] = state.pendingDataChanges[action.payload.bcName] ?? {}\n state.pendingDataChanges[action.payload.bcName][action.payload.cursor] = nextPending\n const prevBcNow = state.pendingDataChangesNow[action.payload.bcName] || {}\n const prevCursorNow = prevBcNow[action.payload.cursor] || {}\n const prevPendingNow = prevCursorNow || {}\n state.pendingDataChangesNow[action.payload.bcName] = state.pendingDataChangesNow[action.payload.bcName] ?? {}\n state.pendingDataChangesNow[action.payload.bcName][action.payload.cursor] = { ...prevPendingNow, ...action.payload.dataItem }\n\n const isTargetFormatPVF = state.pendingValidationFailsFormat === PendingValidationFailsFormat.target\n const nextValidationFails = getFailsByRequiredFields(\n nextPending,\n fieldKey => !!state.rowMeta[actionBcName]?.[bcUrl]?.fields.find(item => item.required && item.key === fieldKey)\n )\n\n if (isTargetFormatPVF) {\n state.pendingValidationFails = state.pendingValidationFails ?? {}\n state.pendingValidationFails[actionBcName] = state.pendingValidationFails[actionBcName] ?? {}\n ;(state.pendingValidationFails[actionBcName] as { [cursor: string]: Record<string, string> })[action.payload.cursor] =\n nextValidationFails\n } else {\n state.pendingValidationFails = nextValidationFails\n }\n })\n .addCase(changeDataItems, (state, action) => {\n const newPendingChanges = { ...state.pendingDataChanges[action.payload.bcName] }\n const newPendingChangesNow = { ...state.pendingDataChangesNow[action.payload.bcName] }\n action.payload.cursors.forEach((cursor, index) => {\n newPendingChanges[cursor] = action.payload.dataItems[index]\n newPendingChangesNow[cursor] = action.payload.dataItems[index]\n })\n state.pendingDataChanges[action.payload.bcName] = newPendingChanges\n state.pendingDataChangesNow[action.payload.bcName] = newPendingChangesNow\n })\n .addCase(dropAllAssociations, (state, action) => {\n const pendingDataChanges = { ...state.pendingDataChanges }\n action.payload.bcNames.forEach(bcName => {\n const pendingBcChanges: Record<string, PendingDataItem> = {}\n // ;(store.data[bcName] || [])\n // .filter(item => item._associate)\n // .forEach(item => {\n // pendingBcChanges[item.id] = { id: item.id, _associate: false }\n // })\n Object.keys(pendingDataChanges[bcName] || {}).forEach(itemId => {\n pendingBcChanges[itemId] = { id: itemId, _associate: false }\n })\n pendingDataChanges[bcName] = pendingBcChanges\n })\n const isTargetFormatPVF = state.pendingValidationFailsFormat === PendingValidationFailsFormat.target\n const pendingValidationFails = state.pendingValidationFails ? { ...state.pendingValidationFails } : {}\n\n if (isTargetFormatPVF) {\n action.payload.bcNames.forEach(i => {\n pendingValidationFails[i] = {}\n })\n }\n state.pendingDataChanges = pendingDataChanges\n state.pendingValidationFails = isTargetFormatPVF ? pendingValidationFails : initialViewState.pendingValidationFails\n })\n //TODO: rewrite correctly (get data outside of reducer, place it in epic)\n .addCase(dropAllAssociationsSameBc, (state, action) => {\n // const pendingDataChanges = { ...state.pendingDataChanges }\n //\n // Object.entries({ ...store.depthData, 1: store.data }).forEach(([depthLevelKey, depthLevelData]) => {\n // const depthLevel = Number(depthLevelKey)\n // const pendingBcChanges: Record<string, PendingDataItem> = {}\n // if (depthLevel >= action.payload.depthFrom && depthLevelData[action.payload.bcName]) {\n // depthLevelData[action.payload.bcName]\n // .filter((item: any) => item._associate)\n // .forEach((item: any) => {\n // pendingBcChanges[item.id] = { _associate: false }\n // })\n // }\n // pendingDataChanges[action.payload.bcName] = pendingBcChanges\n // })\n // const isTargetFormatPVF = state.pendingValidationFailsFormat === PendingValidationFailsFormat.target\n //\n // return {\n // ...state,\n // pendingDataChanges,\n // pendingValidationFails: isTargetFormatPVF\n // ? {\n // ...(state.pendingValidationFails as PendingValidationFails),\n // [action.payload.bcName]: {}\n // }\n // : initialState.pendingValidationFails\n // }\n })\n //TODO: rewrite correctly (get data outside of reducer, place it in epic)\n .addCase(dropAllAssociationsFull, (state, action) => {\n // const bcName = action.payload.bcName\n // const pendingDataChanges = { ...state.pendingDataChanges }\n // const dropDesc = action.payload.dropDescendants\n //\n // const pendingBcChanges: Record<string, PendingDataItem> = {}\n // ;(store.data[bcName] || [])\n // .filter(item => item._associate)\n // .forEach(item => {\n // if ((dropDesc && item.level === action.payload.depth) || item.level >= action.payload.depth) {\n // pendingBcChanges[item.id] = { ...item, _associate: false }\n // }\n // })\n // Object.entries(pendingDataChanges[bcName] || {}).forEach(([itemId, item]) => {\n // if ((dropDesc && item.level === action.payload.depth) || item.level >= action.payload.depth) {\n // pendingBcChanges[itemId] = { ...item, _associate: false }\n // }\n // })\n // pendingDataChanges[bcName] = pendingBcChanges\n // const isTargetFormatPVF = state.pendingValidationFailsFormat === PendingValidationFailsFormat.target\n //\n // return {\n // ...state,\n // pendingDataChanges,\n // pendingValidationFails: isTargetFormatPVF\n // ? {\n // ...(state.pendingValidationFails as PendingValidationFails),\n // [action.payload.bcName]: {}\n // }\n // : initialState.pendingValidationFails\n // }\n })\n .addCase(bcNewDataFail, (state, action) => {\n state.metaInProgress[action.payload.bcName] = false\n })\n .addCase(bcFetchRowMetaFail, (state, action) => {\n state.metaInProgress[action.payload.bcName] = false\n })\n .addCase(forceActiveChangeFail, (state, action) => {\n const { bcName, bcUrl, entityError } = action.payload\n const errors: Record<string, string> = {}\n if (entityError) {\n Object.entries(entityError.fields).forEach(([fieldName, violation]) => {\n errors[fieldName] = violation\n })\n }\n state.rowMeta[bcName] = state.rowMeta[bcName] ?? {}\n state.rowMeta[bcName][bcUrl].errors = errors\n })\n .addCase(bcSaveDataFail, (state, action) => {\n const { bcName, bcUrl, entityError } = action.payload\n const errors: Record<string, string> = {}\n if (entityError) {\n Object.entries(entityError.fields).forEach(([fieldName, violation]) => {\n errors[fieldName] = violation\n })\n }\n state.rowMeta[bcName] = state.rowMeta[bcName] ?? {}\n state.rowMeta[bcName][bcUrl].errors = errors\n })\n .addCase(sendOperationFail, (state, action) => {\n const { bcName, bcUrl, entityError } = action.payload\n const errors: Record<string, string> = {}\n if (entityError) {\n Object.entries(entityError.fields).forEach(([fieldName, violation]) => {\n errors[fieldName] = violation\n })\n }\n state.rowMeta[bcName] = state.rowMeta[bcName] ?? {}\n state.rowMeta[bcName][bcUrl].errors = errors\n })\n .addCase(sendOperationSuccess, (state, action) => {\n const bcName = action.payload.bcName\n const cursor = action.payload.cursor as string\n\n const isTargetFormatPVF = state.pendingValidationFailsFormat === PendingValidationFailsFormat.target\n state.pendingDataChanges[bcName] = state.pendingDataChanges[bcName] ?? {}\n state.pendingDataChanges[bcName][cursor] = {}\n state.pendingDataChangesNow[bcName] = state.pendingDataChangesNow[bcName] ?? {}\n state.pendingDataChangesNow[bcName][cursor] = {}\n if (isTargetFormatPVF) {\n state.pendingValidationFails = state.pendingValidationFails ?? {}\n state.pendingValidationFails[bcName] = state.pendingValidationFails[bcName] ?? {}\n ;(state.pendingValidationFails[bcName] as { [cursor: string]: Record<string, string> })[cursor] = {}\n } else {\n state.pendingValidationFails = initialViewState.pendingValidationFails\n }\n state.handledForceActive[bcName] = state.handledForceActive[bcName] ?? {}\n state.handledForceActive[bcName][cursor] = {}\n })\n .addCase(bcSaveDataSuccess, (state, action) => {\n const { bcName, cursor } = action.payload\n const isTargetFormatPVF = state.pendingValidationFailsFormat === PendingValidationFailsFormat.target\n state.pendingDataChanges[bcName] = state.pendingDataChanges[bcName] ?? {}\n state.pendingDataChanges[bcName][cursor] = {}\n state.pendingDataChangesNow[bcName] = state.pendingDataChangesNow[bcName] ?? {}\n state.pendingDataChangesNow[bcName][cursor] = {}\n if (isTargetFormatPVF) {\n state.pendingValidationFails = state.pendingValidationFails ?? {}\n state.pendingValidationFails[bcName] = state.pendingValidationFails[bcName] ?? {}\n ;(state.pendingValidationFails[bcName] as { [cursor: string]: Record<string, string> })[cursor] = {}\n } else {\n state.pendingValidationFails = initialViewState.pendingValidationFails\n }\n state.handledForceActive[bcName] = state.handledForceActive[bcName] ?? {}\n state.handledForceActive[bcName][cursor] = {}\n })\n .addCase(bcCancelPendingChanges, (state, action) => {\n // TODO: Check if this works for hierarchy after 1.1.0\n const pendingDataChanges = { ...state.pendingDataChanges }\n const pendingDataChangesNow = state.pendingDataChangesNow\n for (const bcName in state.pendingDataChanges) {\n if (action.payload ? action.payload.bcNames.includes(bcName) : true) {\n pendingDataChanges[bcName] = {}\n pendingDataChangesNow[bcName] = {}\n }\n }\n const isTargetFormatPVF = state.pendingValidationFailsFormat === PendingValidationFailsFormat.target\n let pendingValidationFails = state.pendingValidationFails ? { ...state.pendingValidationFails } : {}\n\n if (isTargetFormatPVF) {\n if (action.payload?.bcNames?.length > 0) {\n /**\n * Clear a `pendingValidationFails` for specific BC names\n */\n action.payload.bcNames.forEach(i => {\n pendingValidationFails[i] = {}\n })\n } else {\n /**\n * Clear a `pendingValidationFails` completely\n */\n pendingValidationFails = initialViewState.pendingValidationFails as typeof pendingValidationFails\n }\n }\n state.pendingDataChanges = pendingDataChanges\n state.pendingDataChangesNow = pendingDataChangesNow\n state.pendingValidationFails = isTargetFormatPVF ? pendingValidationFails : initialViewState.pendingValidationFails\n })\n .addCase(clearValidationFails, state => {\n state.pendingValidationFails = initialViewState.pendingValidationFails\n })\n .addCase(showViewPopup, (state, action) => {\n const { bcName, calleeBCName, calleeWidgetName, associateFieldKey, assocValueKey, active, isFilter, type, widgetName } =\n action.payload\n\n state.popupData = {\n widgetName,\n type,\n bcName,\n calleeBCName,\n calleeWidgetName,\n associateFieldKey,\n assocValueKey,\n active,\n isFilter\n }\n })\n .addCase(showFileUploadPopup, (state, action) => {\n const bcName = state.widgets?.find(item => item.name === action.payload.widgetName)?.bcName\n state.popupData = {\n type: 'file-upload',\n bcName, // should be null\n calleeBCName: bcName\n }\n })\n .addCase(viewPutPickMap, (state, action) => {\n state.pickMap = action.payload.map\n })\n .addCase(viewClearPickMap, state => {\n state.pickMap = null\n })\n .addCase(closeViewPopup, state => {\n state.popupData = {}\n state.popupData.bcName = null\n })\n .addCase(selectTableRow, (state, action) => {\n state.selectedRow = { widgetName: action.payload.widgetName, rowId: action.payload.rowId }\n })\n .addCase(deselectTableRow, (state, action) => {\n state.selectedRow = null\n })\n .addCase(changeLocation, (state, action) => {\n if (!action.payload.isTab) {\n state.pendingDataChanges = initialViewState.pendingDataChanges\n state.pendingDataChangesNow = initialViewState.pendingDataChangesNow\n }\n state.popupData = initialViewState.popupData\n state.selectedRow = initialViewState.selectedRow\n })\n .addCase(showNotification, (state, action) => {\n state.systemNotifications = state.systemNotifications ?? []\n state.systemNotifications.push({\n type: action.payload.type,\n message: action.payload.message,\n id: state.systemNotifications?.length as number\n })\n })\n .addCase(closeNotification, (state, action) => {\n state.systemNotifications = state.systemNotifications ?? []\n state.systemNotifications = state.systemNotifications.filter(item => item.id !== action.payload.id)\n })\n .addCase(showViewError, (state, action) => {\n state.error = action.payload.error\n })\n .addCase(operationConfirmation, (state, action) => {\n state.modalInvoke = action.payload\n })\n .addCase(closeConfirmModal, (state, action) => {\n state.modalInvoke = null\n })\n .addCase(closeViewError, state => {\n state.error = null\n })\n .addCase(processPostInvoke, state => {\n state.selectedRow = null\n })\n .addCase(selectRows, (state, action) => {\n const { bcName, dataItems } = action.payload\n const selectedRowsDictionary: Record<string, Omit<DataItem, 'vstamp'>> = {}\n state.selectedRows[bcName] = state.selectedRows[bcName] ?? []\n\n state.selectedRows[bcName].forEach(row => {\n selectedRowsDictionary[row.id as string] = row\n })\n const newDataItems = dataItems\n const dataItemIdsToDelete: string[] = []\n\n dataItems.forEach((row, index) => {\n if (selectedRowsDictionary[row.id as string]) {\n newDataItems[index] = { ...selectedRowsDictionary[row.id as string], ...row }\n dataItemIdsToDelete.push(row.id as string)\n }\n })\n\n state.selectedRows[bcName] = state.selectedRows[bcName].filter(dataItem => !dataItemIdsToDelete.includes(dataItem.id as string))\n\n state.selectedRows[bcName].splice(0, 0, ...dataItems)\n })\n .addCase(deselectRows, (state, action) => {\n const { bcName, ids } = action.payload\n state.selectedRows[bcName] = state.selectedRows[bcName] ?? []\n state.selectedRows[bcName] = state.selectedRows[bcName].filter(dataItem => !ids.includes(dataItem.id as string))\n })\n .addCase(clearSelectedRows, (state, action) => {\n const { bcName } = action.payload\n delete state.selectedRows[bcName]\n })\n .addCase(setPendingPostInvoke, (state, action) => {\n const { bcName, operationType, postInvoke } = action.payload\n state.pendingPostInvoke[bcName] = state.pendingPostInvoke[bcName] ?? {}\n state.pendingPostInvoke[bcName][operationType] = postInvoke\n })\n .addCase(applyPendingPostInvoke, (state, action) => {\n const { bcName, operationType } = action.payload\n if (state.pendingPostInvoke[bcName]) {\n delete state.pendingPostInvoke[bcName][operationType]\n }\n })\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { DepthDataState } from '../interfaces'\nimport { bcFetchDataSuccess, selectView } from '../actions'\nimport { ReducerBuilderManager } from './ReducerBuilderManager'\n\nexport const initialDepthDataState: DepthDataState = {}\n\nexport const createDepthDataReducerBuilderManager = (initialState: DepthDataState) => {\n return new ReducerBuilderManager<typeof initialState>()\n .addCase(bcFetchDataSuccess, (state, action) => {\n if (!action.payload.depth || action.payload.depth < 2) {\n return\n }\n state[action.payload.depth] = state[action.payload.depth] ?? {}\n state[action.payload.depth][action.payload.bcName] = action.payload.data\n })\n .addCase(selectView, state => {\n return initialState\n })\n}\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Session } from '../interfaces'\nimport {\n addNotification,\n addPendingRequest,\n login,\n loginDone,\n loginFail,\n logout,\n refreshMeta,\n refreshMetaDone,\n refreshMetaFail,\n removeNotifications,\n removePendingRequest,\n switchDebugMode\n} from '../actions'\nimport { ReducerBuilderManager } from './ReducerBuilderManager'\n\nexport const initialSessionState: Session = {\n devPanelEnabled: false,\n activeRole: null,\n roles: null,\n firstName: '',\n lastName: '',\n login: '',\n debugMode: false,\n exportStateEnabled: false,\n active: false,\n logout: false,\n loginSpin: false,\n errorMsg: null,\n screens: [],\n pendingRequests: [],\n notifications: [],\n isMetaRefreshing: false\n}\n\n/**\n * Session reducer\n *\n * Stores information about currently active session and dataEpics.ts that should be persistent during all period of\n * user interaction with application.\n */\nexport const createSessionReducerBuilderManager = <S extends Session>(initialState: S) =>\n new ReducerBuilderManager<S>()\n .addCase(login, state => {\n state.loginSpin = true\n state.errorMsg = null\n })\n .addCase(loginDone, (state, action) => {\n state = Object.assign(state, action.payload)\n state.loginSpin = false\n state.active = true\n state.logout = false\n })\n .addCase(loginFail, (state, action) => {\n state.loginSpin = false\n state.errorMsg = action.payload.errorMsg\n })\n .addCase(logout, state => {\n state.loginSpin = false\n state.active = false\n state.logout = true\n })\n .addCase(switchDebugMode, (state, action) => {\n state.debugMode = action.payload\n })\n .addCase(addPendingRequest, (state, action) => {\n state.pendingRequests?.push(action.payload.request)\n })\n .addCase(removePendingRequest, (state, action) => {\n state.pendingRequests = state.pendingRequests?.filter(item => item.requestId !== action.payload.requestId)\n })\n .addCase(addNotification, (state, action) => {\n state.notifications.push(action.payload)\n })\n .addCase(removeNotifications, (state, action) => {\n const closingKeys = action.payload\n state.notifications = state.notifications.filter(notification => !closingKeys.includes(notification.key))\n })\n .addCase(refreshMeta, state => {\n state.isMetaRefreshing = true\n })\n .addCase(refreshMetaDone, state => {\n state.isMetaRefreshing = false\n })\n .addCase(refreshMetaFail, state => {\n state.isMetaRefreshing = false\n })\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { OperationModalInvokeConfirm, OperationPostInvokeAny, OperationPostInvokeConfirmType, OperationPreInvoke } from '../../interfaces'\nimport { processPostInvoke, processPostInvokeConfirm, processPreInvoke } from '../../actions'\nimport { of } from 'rxjs'\nimport { AnyAction } from '@reduxjs/toolkit'\n\n/**\n * Returns an array of observables for handling post- and pre-invokes from any epics handling operations\n *\n * @param widgetName Name of the widget that initiated the operation\n * @param postInvoke Response post-invoke\n * @param preInvoke Response pre-invoke\n * @param operationType Which operation was performed\n * @param bcName\n * @category Utils\n */\nexport function postOperationRoutine(\n widgetName: string,\n postInvoke: OperationPostInvokeAny,\n preInvoke: OperationPreInvoke,\n operationType: string,\n bcName: string // TODO: Remove in 2.0.0\n) {\n const postInvokeConfirm = Object.values(OperationPostInvokeConfirmType).includes(postInvoke?.type as OperationPostInvokeConfirmType)\n const result: AnyAction[] = []\n if (postInvoke) {\n result.push(processPostInvoke({ bcName, postInvoke, widgetName }))\n }\n if (postInvokeConfirm) {\n result.push(\n processPostInvokeConfirm({\n bcName,\n operationType,\n widgetName,\n postInvokeConfirm: postInvoke as OperationModalInvokeConfirm\n })\n )\n }\n if (preInvoke) {\n result.push(\n processPreInvoke({\n bcName,\n operationType,\n widgetName,\n preInvoke\n })\n )\n }\n return result.map(item => of(item))\n}\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { CXBoxEpic, OperationError, OperationErrorEntity, OperationPostInvokeRefreshBc, OperationPostInvokeType } from '../../interfaces'\nimport {\n bcCancelPendingChanges,\n bcForceUpdate,\n changeLocation,\n sendOperation,\n sendOperationFail,\n sendOperationSuccess,\n setOperationFinished\n} from '../../actions'\nimport { catchError, concat, EMPTY, filter, mergeMap, of } from 'rxjs'\nimport { buildBcUrl, getFilters, getSorters, matchOperationRole } from '../../utils'\nimport { AxiosError } from 'axios'\n\nimport { postOperationRoutine } from '../utils/postOperationRoutine'\nimport { createApiErrorObservable } from '../../utils'\nimport { removeDisabledFields } from '../../utils/data'\n\n/**\n * Handle any `sendOperationEpic` action which is not part of built-in operations types\n *\n * Request will be send to `custom-action/${screenName}/${bcUrl}?_action=${action.payload.type}` endpoint,\n * with pending changes of the widget as requst body.\n *\n * Fires sendOperationSuccess, bcForceUpdate and postOperationRoutine\n */\nexport const sendOperationEpic: CXBoxEpic = (action$, state$, { api }) =>\n action$.pipe(\n filter(sendOperation.match),\n filter(action => matchOperationRole('none', action.payload, state$.value)),\n mergeMap(action => {\n const state = state$.value\n const screenName = state.screen.screenName\n const { bcName, operationType, widgetName } = action.payload\n // TODO: Remove conformOperation n 2.0.0\n const confirm = action.payload.confirmOperation?.type || action.payload.confirm\n const bcUrl = buildBcUrl(bcName, true, state)\n const bc = state.screen.bo.bc[bcName]\n const rowMeta = bcUrl && state.view.rowMeta[bcName]?.[bcUrl]\n const cursor = bc.cursor\n const record = state.data[bcName]?.find(item => item.id === bc.cursor)\n const filters = state.screen.filters[bcName]\n const sorters = state.screen.sorters[bcName]\n const pendingChanges = removeDisabledFields(state.view.pendingDataChanges[bcName]?.[bc.cursor], rowMeta)\n\n const data = record && { ...pendingChanges, vstamp: record.vstamp }\n const defaultSaveOperation =\n state.view.widgets?.find(item => item.name === widgetName)?.options?.actionGroups?.defaultSave ===\n action.payload.operationType && changeLocation.match(action.payload?.onSuccessAction?.type)\n const params: Record<string, string> = {\n _action: operationType,\n ...getFilters(filters),\n ...getSorters(sorters)\n }\n if (confirm) {\n params._confirm = confirm\n }\n const context = { widgetName: action.payload.widgetName }\n return api.customAction(screenName, bcUrl, data, context, params).pipe(\n mergeMap(response => {\n const postInvoke = response.postActions?.[0]\n const dataItem = response.record\n // TODO: Remove in 2.0.0 in favor of postInvokeConfirm (is this todo needed?)\n const preInvoke = response.preInvoke\n const postInvokeType = postInvoke?.type || ''\n const postInvokeRefreshCurrentBc =\n OperationPostInvokeType.refreshBC === postInvokeType && (postInvoke as OperationPostInvokeRefreshBc)?.bc === bcName\n const postInvokeTypesWithRefreshBc = (\n [OperationPostInvokeType.waitUntil, OperationPostInvokeType.drillDownAndWaitUntil] as string[]\n ).includes(postInvokeType)\n const withoutBcForceUpdate = postInvokeRefreshCurrentBc || postInvokeTypesWithRefreshBc\n\n // defaultSaveOperation mean that executed custom autosave and postAction will be ignored\n // drop pendingChanges and onSuccessAction execute instead\n return concat(\n of(setOperationFinished({ bcName, operationType })),\n defaultSaveOperation\n ? action?.payload?.onSuccessAction\n ? concat(of(bcCancelPendingChanges({ bcNames: [bcName] })), of(action.payload.onSuccessAction))\n : EMPTY\n : concat(\n of(sendOperationSuccess({ bcName, cursor, dataItem })),\n withoutBcForceUpdate ? EMPTY : of(bcForceUpdate({ bcName })),\n ...postOperationRoutine(widgetName, postInvoke, preInvoke, operationType, bcName)\n )\n )\n }),\n catchError((e: AxiosError) => {\n console.error(e)\n let viewError: string = null\n let entityError: OperationErrorEntity = null\n const operationError = e.response?.data as OperationError\n if (e.response?.data === Object(e.response?.data)) {\n entityError = operationError?.error?.entity\n viewError = operationError?.error?.popup?.[0]\n }\n return concat(\n of(setOperationFinished({ bcName, operationType })),\n of(sendOperationFail({ bcName, bcUrl, viewError, entityError })),\n createApiErrorObservable(e, context)\n )\n })\n )\n })\n )\n","import { BcDataResponse, BcMetaState, CXBoxEpic, OperationPostInvokeWaitUntil, Store } from '../../interfaces'\nimport {\n catchError,\n concat,\n delay,\n EMPTY,\n filter,\n map,\n mergeMap,\n Observable,\n of,\n switchMap,\n take,\n takeUntil,\n timeout,\n TimeoutError\n} from 'rxjs'\nimport { bcForceUpdate, closeViewPopup, showViewPopup, waitUntil, WaitUntilPopupOptions } from '../../actions'\nimport { buildBcUrl, createApiErrorObservable, getFilters, getSorters } from '../../utils'\nimport { DataItem } from '@cxbox-ui/schema'\nimport { Api } from '../../api'\nimport { StateObservable } from 'redux-observable'\n\nconst fetchDataRequest = <S extends Store, A extends Api>(bcName: string, state: S, api: A) => {\n const bc = state.screen.bo.bc[bcName]\n const limitBySelfCursor = state.router.bcPath?.includes(`${bcName}/${bc.cursor}`)\n const bcUrl = buildBcUrl(bcName, limitBySelfCursor, state)\n const fetchParams: Record<string, any> = {\n _page: bc.page ?? 1,\n _limit: bc.limit ?? 5,\n ...getFilters(state.screen.filters[bcName] || []),\n ...getSorters(state.screen.sorters[bcName])\n }\n\n return api.fetchBcData(state.screen.screenName, bcUrl, fetchParams)\n}\n\nconst successCondition = (data: DataItem[], fieldKey: string, valueForComparison: unknown) => {\n return data.some(dataItem => dataItem[fieldKey] === valueForComparison)\n}\n\nconst recursiveQueryWithRepeat = <S extends Store, A extends Api>(\n state: S,\n api: A,\n postInvoke: Omit<OperationPostInvokeWaitUntil, 'type'>,\n currentBcName: string\n): Observable<BcDataResponse> => {\n const { timeout: repeatTimeout = 5000, timeoutMaxRequests = 5 } = postInvoke\n const { successCondition_fieldKey, successCondition_value } = postInvoke\n const requestInterval = Math.floor(+repeatTimeout / +timeoutMaxRequests)\n\n return fetchDataRequest(currentBcName, state, api).pipe(\n mergeMap(response => {\n const data = response.data\n\n return successCondition(data, successCondition_fieldKey, successCondition_value)\n ? of(response)\n : of(null).pipe(\n delay(requestInterval),\n mergeMap(() => recursiveQueryWithRepeat(state, api, postInvoke, currentBcName))\n )\n }),\n timeout(+repeatTimeout)\n )\n}\n\nconst getBcHierarchyArr = (bcDictionary: Record<string, BcMetaState>, bcName: string): string[] => {\n const bcHierarchy: string[] = [bcName]\n let parentBcName = bcDictionary[bcName]?.parentName\n\n while (parentBcName) {\n bcHierarchy.push(parentBcName)\n\n parentBcName = bcDictionary[parentBcName]?.parentName\n }\n\n return bcHierarchy.reverse()\n}\n\nconst checkingReadinessForBuildBcUrl =\n (bcName: string) =>\n <S extends Store>(state: S) => {\n const bcDictionary = state.screen.bo.bc\n const bcNamesForChecking = getBcHierarchyArr(bcDictionary, bcName)\n\n return bcNamesForChecking.every(\n bcNameForChecking => bcDictionary[bcNameForChecking]?.loading === false && bcDictionary[bcNameForChecking]?.cursor\n )\n }\n\nconst getCheckedStateForBuildBcUrl = (state$: StateObservable<Store>, currentBcName: string) => {\n const currentState = state$.value\n\n return checkingReadinessForBuildBcUrl(currentBcName)(currentState)\n ? of(currentState)\n : state$.pipe(filter(checkingReadinessForBuildBcUrl(currentBcName)), take(1))\n}\n\nexport const waitUntilEpic: CXBoxEpic = (action$, state$, { api }) =>\n action$.pipe(\n filter(waitUntil.match),\n mergeMap(action => {\n const { bcName: actionBcName, postInvoke } = action.payload\n const { successCondition_bcName } = postInvoke\n const currentBcName = successCondition_bcName ?? actionBcName\n\n const switchPopup = (status: WaitUntilPopupOptions['status'], message?: string) => {\n const isProgressStatus = status === 'progress'\n const isFinalStatus = !isProgressStatus\n\n if (isProgressStatus || (isFinalStatus && message)) {\n return of(\n showViewPopup({\n type: 'waitUntil',\n bcName: actionBcName,\n calleeBCName: actionBcName,\n options: { status, message }\n })\n )\n }\n\n if (isFinalStatus && !message) {\n return of(closeViewPopup({ bcName: actionBcName }))\n }\n\n return EMPTY\n }\n\n const forceUpdate = (bcName: string) => {\n const currentBcIsExist = state$.value.screen.bo.bc[bcName]\n\n return currentBcIsExist ? of(bcForceUpdate({ bcName })) : EMPTY\n }\n\n const requestResult = getCheckedStateForBuildBcUrl(state$, currentBcName).pipe(\n switchMap(checkedState => {\n return recursiveQueryWithRepeat(checkedState, api, postInvoke, currentBcName).pipe(\n takeUntil(\n action$.pipe(\n filter(closeAction => {\n return closeViewPopup.match(closeAction)\n })\n )\n ),\n map(response => response.data),\n mergeMap(data => {\n return concat(forceUpdate(currentBcName), switchPopup('success', postInvoke.successMessage))\n }),\n catchError(error => {\n if (error instanceof TimeoutError) {\n return concat(forceUpdate(currentBcName), switchPopup('timeout', postInvoke.timeoutMessage))\n }\n\n return concat(of(closeViewPopup({ bcName: actionBcName })), createApiErrorObservable(error))\n })\n )\n })\n )\n\n return concat(switchPopup('progress', postInvoke.inProgressMessage), requestResult)\n })\n )\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { RouteType, CXBoxEpic } from '../../interfaces'\nimport { filter, of, switchMap } from 'rxjs'\nimport { changeLocation, handleRouter, loginDone } from '../../actions'\nimport { getRouteFromString } from '../../utils'\n\n/**\n * Fires `selectScreen` or `selectScreenFail` to set requested in url screen as active\n * after succesful login.\n *\n * For server-side router fires `handleRouter` instead.\n *\n */\nexport const loginDoneEpic: CXBoxEpic = (action$, state$) =>\n action$.pipe(\n filter(loginDone.match),\n switchMap(action => {\n const state = state$.value\n\n if (state.router.type === RouteType.router) {\n return of(handleRouter(state.router))\n }\n\n return of(\n changeLocation({\n location: getRouteFromString(action.payload.defaultUrl ?? window.location.hash.replace('#', '')),\n forceUpdate: true\n })\n )\n })\n )\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ApplicationErrorType, CXBoxEpic } from '../../interfaces'\nimport { filter, map } from 'rxjs'\nimport { httpError, showViewError } from '../../actions'\n\nconst knownHttpErrors = [401, 409, 418, 500]\n\nexport const httpErrorDefaultEpic: CXBoxEpic = (action$, state$) =>\n action$.pipe(\n filter(httpError.match),\n filter(action => !knownHttpErrors.includes(action.payload.statusCode)),\n map(action => {\n const businessError = {\n type: ApplicationErrorType.BusinessError,\n code: action.payload.error.response?.status,\n details: action.payload.error.response?.data\n }\n return showViewError({ error: businessError })\n })\n )\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { CXBoxEpic } from '../../interfaces'\nimport { catchError, concat, filter, mergeMap, of, switchMap } from 'rxjs'\nimport { changeLocation, login, loginDone, loginFail } from '../../actions'\nimport { AxiosError } from 'axios'\nimport { defaultParseURL } from '../../utils'\nimport { createApiErrorObservable } from '../../utils/apiError'\nimport { getDefaultViewForPrimary } from '../../utils/getDefaultViewForPrimary'\nimport { getDefaultViewFromPrimaries } from '../../utils/getDefaultViewFromPrimaries'\n\nconst responseStatusMessages: Record<number, string> = {\n 401: 'Invalid credentials',\n 403: 'Access denied'\n}\n\n/**\n * Performed on role switching\n */\nexport const loginByAnotherRoleEpic: CXBoxEpic = (action$, state$, { api }) =>\n action$.pipe(\n filter(login.match),\n filter(action => !!action.payload?.role),\n switchMap(action => {\n /**\n * Default implementation of `loginByAnotherRoleEpic` epic\n *\n * Performs login request with `role` parameter\n *\n * If `role` changed, epic changes location to default view\n */\n\n const role = action.payload.role ?? ''\n const isSwitchRole = role && role !== state$.value.session.activeRole\n return api.loginByRoleRequest(role).pipe(\n mergeMap(data => {\n const result = []\n if (isSwitchRole) {\n const defaultScreen = data.screens.find(screen => screen.defaultScreen) || data.screens[0]\n const defaultView =\n getDefaultViewForPrimary(defaultScreen.primary, defaultScreen.meta.views) ??\n getDefaultViewFromPrimaries(defaultScreen.primaries, defaultScreen.meta.views) ??\n defaultScreen?.meta.views[0]\n\n if (defaultView)\n result.push(changeLocation({ location: defaultParseURL(new URL(defaultView.url, window.location.origin)) }))\n }\n\n return concat([\n ...result,\n loginDone({\n devPanelEnabled: data.devPanelEnabled,\n activeRole: data.activeRole,\n roles: data.roles,\n screens: data.screens,\n firstName: data.firstName,\n lastName: data.lastName,\n login: data.login\n })\n ])\n }),\n catchError((error: AxiosError) => {\n console.error(error)\n const errorMsg = error.response\n ? responseStatusMessages[error.response.status] || 'Server application unavailable'\n : 'Empty server response'\n return concat(of(loginFail({ errorMsg })), createApiErrorObservable(error))\n })\n )\n })\n )\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { filter, mergeMap, Observable, of, take } from 'rxjs'\nimport { logout, selectView } from '../actions'\nimport { AnyAction } from 'redux'\nimport { isAnyOf } from '@reduxjs/toolkit'\n\n/**\n * Type tweak for backward @reduxjs/toolkit compatibility\n */\ntype TypeGuard<T> = (value: any) => value is T\ninterface HasMatchFunction<T> {\n match: TypeGuard<T>\n}\n/** @public */\ntype Matcher<T> = HasMatchFunction<T> | TypeGuard<T>\n\nconst fullLoadViewMatcher = (action => {\n return selectView.match(action) && !(action as ReturnType<typeof selectView>).payload.isTab\n}) as Matcher<any>\n/**\n * Default list of action types which are triggers for request cancel\n */\nexport const cancelRequestActionTypes = [fullLoadViewMatcher, logout] as [Matcher<any>, ...Array<Matcher<any>>]\n\n/**\n * Creator of request cancel epic\n *\n * @param action$ an observable input\n * @param actionTypes list of action types which triggers cancel\n * @param cancelFn a callback of request cancelation\n * @param cancelActionCreator an action creator which called by request cancelation\n * @param filterFn a callback function which filters come actions\n */\nexport function cancelRequestEpic(\n action$: Observable<AnyAction>,\n actionTypes: Parameters<typeof isAnyOf>,\n cancelFn: (() => void) | undefined,\n cancelActionCreator: AnyAction,\n filterFn: (actions: AnyAction) => boolean = item => {\n return true\n }\n) {\n return action$.pipe(\n filter(isAnyOf(...actionTypes)),\n filter(filterFn),\n mergeMap(() => {\n cancelFn?.()\n return of(cancelActionCreator)\n }),\n take(1)\n )\n}\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { CXBoxEpic } from '../../interfaces'\nimport { catchError, concat, filter, mergeMap, of, race } from 'rxjs'\nimport { bcFetchDataFail, bcFetchDataSuccess, bcLoadMore } from '../../actions'\nimport { buildBcUrl, getFilters, getSorters } from '../../utils'\nimport { cancelRequestActionTypes, cancelRequestEpic } from '../../utils/cancelRequestEpic'\nimport { DataItem } from '@cxbox-ui/schema'\nimport { createApiErrorObservable } from '../../utils/apiError'\n\nexport const bcLoadMoreEpic: CXBoxEpic = (action$, state$, { api }) =>\n action$.pipe(\n filter(bcLoadMore.match),\n mergeMap(action => {\n const state = state$.value\n const bcName = action.payload.bcName\n const bc = state.screen.bo.bc[bcName]\n const { cursor, page } = bc\n const limit = state.view.widgets.find(i => i.bcName === bcName)?.limit || bc.limit\n const limitBySelfCursor = state.router.bcPath?.includes(`${bcName}/${cursor}`)\n const bcUrl = buildBcUrl(bcName, limitBySelfCursor, state)\n const filters = state.screen.filters[bcName] || []\n const sorters = state.screen.sorters[bcName]\n\n const fetchParams: Record<string, any> = {\n _page: page,\n _limit: limit,\n ...getFilters(filters),\n ...getSorters(sorters)\n }\n\n const canceler = api.createCanceler()\n const cancelFlow = cancelRequestEpic(action$, cancelRequestActionTypes, canceler.cancel, bcFetchDataFail({ bcName, bcUrl }))\n const normalFlow = api.fetchBcData(state.screen.screenName, bcUrl, fetchParams, canceler.cancelToken).pipe(\n mergeMap(data => {\n const oldBcDataIds = state.data[bcName]?.map(i => i.id)\n const newData = [...state.data[bcName], ...data.data.filter((i: DataItem) => !oldBcDataIds.includes(i.id))]\n return of(\n bcFetchDataSuccess({\n bcName,\n data: newData,\n bcUrl,\n hasNext: data.hasNext\n })\n )\n }),\n catchError((error: any) => {\n console.error(error)\n return concat(of(bcFetchDataFail({ bcName, bcUrl })), createApiErrorObservable(error))\n })\n )\n return race(cancelFlow, normalFlow)\n })\n )\n","import { Store } from '../interfaces'\n\nexport const selectBcNameFromPopupData = (state: Store): string | undefined => {\n const { bcName, widgetName } = state.view.popupData ?? {}\n\n if (bcName) {\n return bcName\n }\n\n if (widgetName) {\n return state.view.widgets.find(widget => widget.name === widgetName)?.bcName\n }\n\n return undefined\n}\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { catchError, concat, EMPTY, filter, mergeMap, of, race } from 'rxjs'\nimport { AnyAction } from 'redux'\nimport {\n buildBcUrl,\n checkShowCondition,\n getEagerBcChildren,\n getFilters,\n getSorters,\n getWidgetsForLazyLoad,\n isEagerWidget\n} from '../../utils'\nimport { cancelRequestActionTypes, cancelRequestEpic } from '../../utils/cancelRequestEpic'\nimport { DataItem, WidgetTypes } from '@cxbox-ui/schema'\nimport { BcMetaState, CXBoxEpic, EpicDependencyInjection, PopupData, PopupWidgetTypes, WidgetMeta } from '../../interfaces'\nimport { isAnyOf } from '@reduxjs/toolkit'\nimport {\n bcChangeCursors,\n bcChangePage,\n bcClearData,\n bcFetchDataFail,\n bcFetchDataPages,\n bcFetchDataRequest,\n bcFetchDataSuccess,\n bcFetchRowMeta,\n bcForceUpdate,\n bcSelectRecord,\n showViewPopup\n} from '../../actions'\nimport { createApiErrorObservable } from '../../utils/apiError'\n\n/**\n *\n *\n * Loads BC's dataEpics.ts.\n * In case successful download:\n * - dispatches action to store\n * - initializes rowMeta load\n * - initializes child BCs dataEpics.ts load\n *\n * action.payload.bcName BC's name for dataEpics.ts load\n *\n * @category Epics\n */\nexport const bcFetchDataEpic: CXBoxEpic = (action$, state$, { api, utils }) =>\n action$.pipe(\n filter(isAnyOf(bcFetchDataRequest, bcFetchDataPages, showViewPopup, bcForceUpdate, bcChangePage)),\n mergeMap(action => {\n const state = state$.value\n const { widgetName = '' } = action.payload\n const { widgets, infiniteWidgets } = state.view\n\n const widgetsWithCurrentBc = widgets?.filter(item => item.bcName === action.payload.bcName)\n /**\n * TODO: Widget name will be mandatory in 2.0.0 but until then collision-vulnerable fallback is provided\n * through business component match\n */\n const widget = widgets?.find(item => item.name === widgetName) ?? widgetsWithCurrentBc?.[0]\n /**\n * Missing widget means the view or screen were changed and dataEpics.ts request is no longer relevant\n */\n if (!widget) {\n return EMPTY\n }\n if (!action.payload.bcName) {\n console.warn(`No bc value found for refresh operation`)\n return EMPTY\n }\n const bcName = action.payload.bcName as string\n const bc = state.screen.bo.bc[bcName]\n const { cursor, page = 1 } = bc\n const limit = (widgets?.find(i => i.bcName === bcName)?.limit || bc.limit) ?? 5\n const sorters = state.screen.sorters[bcName]\n /**\n * If popup has the same bc as initiator no dataEpics.ts fetching required, it will be\n * handled by initiator widget instead\n */\n if (showViewPopup.match(action) && bcName === action.payload.calleeBCName) {\n return EMPTY\n }\n\n const anyHierarchyWidget = widgets?.find(item => {\n return item.bcName === widget.bcName && item.type === WidgetTypes.AssocListPopup && isHierarchyWidget(item)\n })\n const fullHierarchyWidget = state.view.widgets?.find(item => {\n return item.bcName === widget.bcName && item.type === WidgetTypes.AssocListPopup && item.options?.hierarchyFull\n })\n\n const limitBySelfCursor = state.router.bcPath?.includes(`${bcName}/${cursor}`)\n const bcUrl = buildBcUrl(bcName, limitBySelfCursor, state)\n\n // Hierarchy widgets has own filter implementation\n const fetchParams: Record<string, any> = {\n _page: page,\n _limit: limit,\n ...getFilters(fullHierarchyWidget ? [] : state.screen.filters[bcName] || []),\n ...getSorters(sorters)\n }\n\n if (bcForceUpdate.match(action)) {\n const infinityPaginationWidget =\n (widgetName && infiniteWidgets?.includes(widgetName)) ||\n widgets?.filter(item => item.bcName === bcName)?.find(item => infiniteWidgets?.includes(item.name))?.name\n if (infinityPaginationWidget) {\n fetchParams._page = 1\n fetchParams._limit = limit * page\n }\n }\n\n if (bcFetchDataPages.match(action)) {\n fetchParams._page = action.payload.from || 1\n fetchParams._limit = (action.payload.to || page - fetchParams._page) * limit\n }\n if ((bcFetchDataRequest.match(action) && action.payload.ignorePageLimit) || anyHierarchyWidget?.options?.hierarchyFull) {\n fetchParams._limit = 0\n }\n const canceler = api.createCanceler()\n const cancelFlow = cancelRequestEpic(action$, cancelRequestActionTypes, canceler.cancel, bcFetchDataFail({ bcName, bcUrl }))\n const cancelByParentBc = cancelRequestEpic(\n action$,\n [bcSelectRecord],\n canceler.cancel,\n bcFetchDataFail({ bcName, bcUrl }),\n filteredAction => {\n const actionBc = filteredAction.payload.bcName\n return bc.parentName === actionBc\n }\n )\n\n const normalFlow = api.fetchBcData(state.screen.screenName, bcUrl, fetchParams, canceler.cancelToken).pipe(\n mergeMap(response => {\n const cursorChange = getCursorChange(action, response.data, cursor, !!anyHierarchyWidget)\n const setDataSuccess = of(\n bcFetchDataSuccess({\n bcName,\n data: response.data,\n bcUrl,\n hasNext: response.hasNext\n })\n )\n const fetchRowMeta = of(bcFetchRowMeta({ widgetName, bcName }))\n\n const isWidgetVisible = (w: WidgetMeta) => {\n // check whether BC names from action payload, showCondition and current widget are relatives\n // if positive check skip `checkShowCondition` call\n if (w.showCondition?.bcName === state.screen.bo.bc[w.bcName]?.parentName) {\n let parentName = state.screen.bo.bc[w.showCondition?.bcName]?.parentName\n let parent = parentName === bcName\n while (!parent && parentName) {\n parentName = state.screen.bo.bc[parentName]?.parentName\n parent = parentName === bcName\n }\n if (parent) {\n return true\n }\n }\n const dataToCheck =\n bcName === w.showCondition?.bcName ? response.data : state.data[w.showCondition?.bcName as string]\n const currentCursor = dataToCheck\n ? getCurrentCursor(dataToCheck, state.screen.bo.bc[w.showCondition?.bcName as string]?.cursor).cursor\n : null\n return checkShowCondition(w.showCondition, currentCursor, dataToCheck, state.view.pendingDataChanges)\n }\n\n if (!widgetIsUsedOnView(bcName, widgets, state.screen.bo.bc, state.view.popupData, isWidgetVisible)) {\n return concat(cursorChange, setDataSuccess, fetchRowMeta)\n }\n const fetchChildren = response.data?.length\n ? getChildrenData(\n action,\n widgets,\n state.screen.bo.bc,\n !!anyHierarchyWidget,\n isWidgetVisible,\n utils?.getInternalWidgets\n )\n : EMPTY\n const resetOutdatedData = resetOutdatedChildrenData(bcName, state.screen.bo.bc, state.data)\n\n return concat(cursorChange, resetOutdatedData, setDataSuccess, fetchRowMeta, fetchChildren)\n }),\n catchError((error: any) => {\n console.error(error)\n return concat(of(bcFetchDataFail({ bcName: action.payload.bcName as string, bcUrl })), createApiErrorObservable(error))\n })\n )\n\n return race(cancelFlow, cancelByParentBc, normalFlow)\n })\n )\n\n/**\n * Determines if the argument is hierarchy widget\n *\n * TODO: Should be typeguard when hierarchy widgets will have actual distinct interfaces\n *\n * @param widget Widget to check\n * @returns `true` if widget option `hierarchy` or `hierarchyFull` is set; `else` otherwise\n */\nfunction isHierarchyWidget(widget: WidgetMeta) {\n return widget.options?.hierarchy || widget.options?.hierarchyFull\n}\n\nconst getCurrentCursor = (data: DataItem[], prevCursor: string | undefined) => {\n const newCursor = data[0]?.id\n const updatedCursor = !prevCursor || !data?.some(i => i.id === prevCursor)\n\n return {\n cursor: updatedCursor ? newCursor : prevCursor,\n updatedCursor\n }\n}\n\nconst getCursorChange = (action: AnyAction, data: DataItem[], prevCursor: string, isHierarchy: boolean) => {\n const { bcName } = action.payload\n const keepDelta = bcFetchDataRequest.match(action) ? action.payload.keepDelta : undefined\n const { cursor, updatedCursor } = getCurrentCursor(data, prevCursor)\n return updatedCursor\n ? of(\n bcChangeCursors({\n cursorsMap: {\n [bcName as string]: cursor\n },\n keepDelta: isHierarchy || keepDelta\n })\n )\n : EMPTY\n}\n\nconst isPopupWidget = (type: string) => PopupWidgetTypes.includes(type)\n\nconst getChildrenData = (\n action: AnyAction,\n widgets: WidgetMeta[],\n bcDictionary: Record<string, BcMetaState>,\n isHierarchy: boolean,\n showConditionCheck: (widget: WidgetMeta) => boolean,\n getInternalWidgets: EpicDependencyInjection['utils']['getInternalWidgets']\n) => {\n const { bcName, widgetName } = action.payload\n\n const lazyWidgetNames = getWidgetsForLazyLoad(\n widgets,\n getInternalWidgets,\n showViewPopup.match(action) ? bcName ?? widgets.find(widget => widget.name === widgetName)?.bcName : undefined\n )\n const eagerChildren = getEagerBcChildren(bcName as string, widgets, bcDictionary, lazyWidgetNames, showConditionCheck)\n\n return concat(\n ...Object.entries(eagerChildren).map(([childBcName, widgetNames]) => {\n const nonLazyWidget = widgets.find(item => {\n return widgetNames.includes(item.name) && isEagerWidget(item, lazyWidgetNames, showConditionCheck)\n })\n\n return of(\n bcFetchDataRequest({\n bcName: childBcName,\n widgetName: nonLazyWidget?.name ?? widgetNames[0],\n ignorePageLimit: action.payload?.ignorePageLimit || showViewPopup.match(action),\n keepDelta: isHierarchy || action.payload?.keepDelta\n })\n )\n })\n )\n}\n\nconst resetOutdatedChildrenData = (bcName: string, bcDictionary: Record<string, BcMetaState>, data: Record<string, DataItem[]>) => {\n const parentBcNames = [bcName]\n const parentsBcUrls = parentBcNames.map(parentBcName => `${bcDictionary[parentBcName].url}/:id`)\n const childBcNamesWithData = Object.keys(data).reduce<string[]>((acc, bcNameWithData) => {\n const bc = bcDictionary[bcNameWithData]\n if (parentsBcUrls.some(item => bc.url.includes(item))) {\n acc.push(bc.name)\n }\n\n return acc\n }, [])\n\n return childBcNamesWithData.length\n ? of(\n bcClearData({\n bcNames: childBcNamesWithData\n })\n )\n : EMPTY\n}\n\n/**\n * Checks if there is at least one visible widget with originBc or any child bc to it.\n * The check takes into account the visibility of popup widgets.\n */\nfunction widgetIsUsedOnView(\n originBcName: string,\n widgets: WidgetMeta[],\n bcDictionary: Record<string, BcMetaState>,\n popupData: PopupData,\n showConditionCheck: (widget: WidgetMeta) => boolean\n) {\n const bcWidgetsMap = widgets.reduce<Record<string, WidgetMeta[]>>((acc, widget) => {\n if (!widget.bcName) return acc\n\n if (!Array.isArray(acc[widget.bcName])) {\n acc[widget.bcName] = []\n }\n\n acc[widget.bcName].push(widget)\n\n return acc\n }, {})\n const bcListOnCurrentView = Object.keys(bcWidgetsMap)\n const originBcIsOnCurrentView = bcListOnCurrentView.includes(originBcName)\n\n const leastOneWidgetIsVisible = (currentBcName: string) =>\n !!bcWidgetsMap[currentBcName]?.some(widget => {\n const isVisiblePopup = popupData?.bcName === widget.bcName\n\n return (showConditionCheck(widget) && !isPopupWidget(widget.type)) || isVisiblePopup\n })\n\n const bcIsUsedInShowCondition = (currentBcName: string) =>\n !!bcWidgetsMap[currentBcName]?.some(widget => {\n return widget.showCondition.bcName === originBcName\n })\n\n if ((originBcIsOnCurrentView && leastOneWidgetIsVisible(originBcName)) || bcIsUsedInShowCondition(originBcName)) {\n return true\n }\n\n const isChildBcForOriginBc = (bcName: string) => {\n const partUrlOfChildBc = `${bcDictionary[originBcName].url}/:id`\n return bcDictionary[bcName].url.includes(partUrlOfChildBc)\n }\n\n return bcListOnCurrentView.some(bcName => {\n return isChildBcForOriginBc(bcName) ? leastOneWidgetIsVisible(bcName) || bcIsUsedInShowCondition(originBcName) : false\n })\n}\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { CXBoxEpic, PendingValidationFailsFormat } from '../../interfaces'\nimport { catchError, concat, EMPTY, filter, mergeMap, of } from 'rxjs'\nimport {\n bcCancelPendingChanges,\n bcDeleteDataFail,\n bcFetchDataRequest,\n processPostInvoke,\n sendOperation,\n setOperationFinished\n} from '../../actions'\nimport { buildBcUrl, matchOperationRole } from '../../utils'\nimport { OperationTypeCrud } from '@cxbox-ui/schema'\nimport { createApiErrorObservable } from '../../utils/apiError'\n\nexport const bcDeleteDataEpic: CXBoxEpic = (action$, store$, { api }) =>\n action$.pipe(\n filter(sendOperation.match),\n filter(action => matchOperationRole(OperationTypeCrud.delete, action.payload, store$.value)),\n mergeMap(action => {\n const widgetName = action.payload.widgetName\n const state = store$.value\n const bcName = action.payload.bcName\n const cursor = state.screen.bo.bc[bcName].cursor\n const bcUrl = buildBcUrl(bcName, true, state)\n const context = { widgetName: action.payload.widgetName }\n const isTargetFormatPVF = state.view.pendingValidationFailsFormat === PendingValidationFailsFormat.target\n return api.deleteBcData(state.screen.screenName, bcUrl, context).pipe(\n mergeMap(data => {\n const postInvoke = data.postActions?.[0]\n return concat(\n of(setOperationFinished({ bcName, operationType: OperationTypeCrud.delete })),\n isTargetFormatPVF ? of(bcCancelPendingChanges({ bcNames: [bcName] })) : EMPTY,\n of(bcFetchDataRequest({ bcName, widgetName })),\n postInvoke ? of(processPostInvoke({ bcName, postInvoke, cursor, widgetName })) : EMPTY\n )\n }),\n catchError((error: any) => {\n console.error(error)\n return concat(\n of(setOperationFinished({ bcName, operationType: OperationTypeCrud.delete })),\n of(bcDeleteDataFail({ bcName })),\n createApiErrorObservable(error, context)\n )\n })\n )\n })\n )\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { catchError, concat, EMPTY, filter, mergeMap, of } from 'rxjs'\nimport { buildBcUrl, matchOperationRole } from '../../utils'\nimport { OperationTypeCrud } from '@cxbox-ui/schema'\nimport {\n bcChangeCursors,\n bcDeleteDataFail,\n processPostInvoke,\n sendOperation,\n sendOperationSuccess,\n setOperationFinished\n} from '../../actions'\nimport { CXBoxEpic } from '../../interfaces'\nimport { isAnyOf } from '@reduxjs/toolkit'\nimport { createApiErrorObservable } from '../../utils/apiError'\n\nconst actionTypesMatcher = isAnyOf(sendOperation)\n\n/**\n * Sends `cancel-create` custom operation with record's pending changes and vstamp;\n * Dispatches `sendOperationSuccess` and `bcChangeCursors` to drop cursors, also\n * `processPostInvokeEpic` if received `postActions` in response.\n *\n * @category Epics\n */\n\nexport const bcCancelCreateDataEpic: CXBoxEpic = (action$, state$, { api }) =>\n action$.pipe(\n filter(actionTypesMatcher),\n filter(action => matchOperationRole(OperationTypeCrud.cancelCreate, action.payload, state$.value)),\n mergeMap(action => {\n /**\n * Default implementation for `bcCancelCreateDataEpic` epic\n *\n * Sends `cancel-create` custom operation with record's pending changes and vstamp;\n * Dispatches `sendOperationSuccess` and `bcChangeCursors` to drop cursors, also\n * `processPostInvokeEpic` if received `postActions` in response.\n *\n * On error dispatches `bcDeleteDataFail`.\n */\n const state = state$.value\n const screenName = state.screen.screenName\n const bcName = action.payload.bcName\n const bcUrl = buildBcUrl(bcName, true, state)\n const bc = state.screen.bo.bc[bcName]\n const cursor = bc?.cursor\n const context = { widgetName: action.payload.widgetName }\n const record = state.data[bcName]?.find(item => item.id === bc.cursor)\n const pendingRecordChange = state.view.pendingDataChanges[bcName]?.[bc.cursor as string]\n const data = record && { ...pendingRecordChange, vstamp: record.vstamp }\n const params = { _action: action.payload.operationType }\n const cursorsMap: Record<string, string> = { [action.payload.bcName]: null }\n return api.customAction(screenName, bcUrl as string, data, context, params).pipe(\n mergeMap(response => {\n const postInvoke = response.postActions?.[0]\n return concat(\n of(setOperationFinished({ bcName, operationType: OperationTypeCrud.cancelCreate })),\n of(sendOperationSuccess({ bcName, cursor })),\n of(bcChangeCursors({ cursorsMap })),\n postInvoke ? of(processPostInvoke({ bcName, postInvoke, cursor, widgetName: context.widgetName })) : EMPTY\n )\n }),\n catchError((error: any) => {\n console.error(error)\n return concat(\n of(setOperationFinished({ bcName, operationType: OperationTypeCrud.cancelCreate })),\n of(bcDeleteDataFail({ bcName })),\n createApiErrorObservable(error, context)\n )\n })\n )\n })\n )\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport axios from 'axios'\nimport { ApplicationErrorType, CXBoxEpic } from '../../interfaces'\nimport { EMPTY, filter, mergeMap, of } from 'rxjs'\nimport { apiError, httpError, showViewError } from '../../actions'\n\nexport const apiErrorEpic: CXBoxEpic = action$ =>\n action$.pipe(\n filter(apiError.match),\n mergeMap(action => {\n const { error, callContext } = action.payload\n if (error.response) {\n return of(\n httpError({\n statusCode: error.response.status,\n error,\n callContext\n })\n )\n } else if (!axios.isCancel(error)) {\n return of(\n showViewError({\n error: {\n type: ApplicationErrorType.NetworkError\n }\n })\n )\n }\n return EMPTY\n })\n )\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { catchError, concat, filter, map, mergeMap, of, race } from 'rxjs'\nimport { buildBcUrl } from '../../utils'\nimport { cancelRequestActionTypes, cancelRequestEpic } from '../../utils/cancelRequestEpic'\nimport { CXBoxEpic } from '../../interfaces'\nimport { bcFetchRowMeta, bcFetchRowMetaFail, bcFetchRowMetaSuccess, bcSelectRecord } from '../../actions'\nimport { createApiErrorObservable } from '../../utils/apiError'\n\n/**\n * Access `row-meta` API endpoint for business component; response will contain information\n * about operations available for row and additional information about row fields.\n *\n * On success, {@link ActionPayloadTypes.bcFetchRowMetaSuccess | bcFetchRowMetaSuccess} action dispatched\n * to store received row meta.\n * On failure, console.error called and {@link ActionPayloadTypes.bcFetchRowMetaFail | bcFetchRowMetaFail} action\n * dispatched to drop fetching state.\n *\n * If any action from `cancelRequestActionTypes` array dispatched while this epic is in progress,\n * this epic will be cancelled and {@link ActionPayloadTypes.bcFetchRowMetaFail | bcFetchRowMetaFail} action\n * will be dispatched.\n *\n * @category Epics\n */\nexport const bcFetchRowMetaRequestEpic: CXBoxEpic = (action$, state$, { api }) =>\n action$.pipe(\n filter(bcFetchRowMeta.match),\n mergeMap(action => {\n /**\n * Default implementation for `bcFetchRowMetaRequest` epic\n *\n * Access `row-meta` API endpoint for business component; response will contain information\n * about operations available for row and additional information about row fields.\n *\n * On success, {@link ActionPayloadTypes.bcFetchRowMetaSuccess | bcFetchRowMetaSuccess} action dispatched\n * to store received row meta.\n * On failure, console.error called and {@link ActionPayloadTypes.bcFetchRowMetaFail | bcFetchRowMetaFail} action\n * dispatched to drop fetching state.\n *\n * If any action from `cancelRequestActionTypes` array dispatched while this epic is in progress,\n * this epic will be cancelled and {@link ActionPayloadTypes.bcFetchRowMetaFail | bcFetchRowMetaFail} action\n * will be dispatched.\n */\n\n const state = state$.value\n const screenName = state.screen.screenName\n const bcName = action.payload.bcName\n const cursor = state.screen.bo.bc[bcName].cursor ?? ''\n const bcUrl = buildBcUrl(bcName, true, state) ?? ''\n const canceler = api.createCanceler()\n const cancelFlow = cancelRequestEpic(action$, cancelRequestActionTypes, canceler.cancel, bcFetchRowMetaFail({ bcName }))\n const cancelByParentBc = cancelRequestEpic(\n action$,\n [bcSelectRecord],\n canceler.cancel,\n bcFetchRowMetaFail({ bcName }),\n filteredAction => {\n const actionBc = filteredAction.payload.bcName\n return state.screen.bo.bc[bcName].parentName === actionBc\n }\n )\n const normalFlow = api.fetchRowMeta(screenName, bcUrl, undefined, canceler.cancelToken).pipe(\n map(rowMeta => {\n return bcFetchRowMetaSuccess({ bcName, rowMeta, bcUrl, cursor })\n }),\n catchError(error => {\n console.error(error)\n return concat(of(bcFetchRowMetaFail({ bcName })), createApiErrorObservable(error))\n })\n )\n\n return race(cancelFlow, cancelByParentBc, normalFlow)\n })\n )\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { catchError, concat, EMPTY, filter, mergeMap, of } from 'rxjs'\nimport { buildBcUrl, matchOperationRole } from '../../utils'\nimport { DataItem, OperationTypeCrud } from '@cxbox-ui/schema'\nimport { CXBoxEpic } from '../../interfaces'\nimport {\n bcFetchRowMetaSuccess,\n bcNewDataFail,\n bcNewDataSuccess,\n changeDataItem,\n processPostInvoke,\n selectTableRow,\n sendOperation,\n setOperationFinished\n} from '../../actions'\nimport { createApiErrorObservable } from '../../utils/apiError'\n\n/**\n * Access `row-meta-new` API endpoint for business component endpoint; response will contain\n * row meta where `currentValue` of `id` field will contain an id for newly created record.\n *\n * `bcNewDataSuccess` action dispatched with new dataEpics.ts item draft (vstamp = -1).\n * `bcFetchRowMetaSuccess` action dispatched to set BC cursor to this new id.\n * `changeDataItem` action dispatched to add this new item to pending changes.\n * `processPostInvokeEpic` dispatched to handle possible post invokes.\n *\n * In case of an error message is logged as warning and `bcNewDataFail` action dispatched.\n *\n */\nexport const bcNewDataEpic: CXBoxEpic = (action$, state$, { api }) =>\n action$.pipe(\n filter(sendOperation.match),\n filter(action => matchOperationRole(OperationTypeCrud.create, action.payload, state$.value)),\n mergeMap(action => {\n /**\n * Default implementation for `bcNewDataEpic` epic\n *\n * Access `row-meta-new` API endpoint for business component endpoint; response will contain\n * row meta where `currentValue` of `id` field will contain an id for newly created record.\n *\n * `bcNewDataSuccess` action dispatched with new dataEpics.ts item draft (vstamp = -1).\n * `bcFetchRowMetaSuccess` action dispatched to set BC cursor to this new id.\n * `changeDataItem` action dispatched to add this new item to pending changes.\n * `processPostInvokeEpic` dispatched to handle possible post invokes.\n *\n * In case of an error message is logged as warning and `bcNewDataFail` action dispatched.\n *\n */\n const state = state$.value\n const bcName = action.payload.bcName\n const bcUrl = buildBcUrl(bcName, false, state) ?? ''\n const context = { widgetName: action.payload.widgetName }\n const params = { _action: action.payload.operationType }\n return api.newBcData(state.screen.screenName, bcUrl, context, params).pipe(\n mergeMap(data => {\n const rowMeta = data.row\n const dataItem: DataItem = { id: null as any, vstamp: -1 }\n data.row.fields.forEach(field => {\n dataItem[field.key] = field.currentValue\n })\n const postInvoke = data.postActions?.[0]\n const cursor = dataItem.id\n return concat(\n of(setOperationFinished({ bcName, operationType: OperationTypeCrud.create })),\n of(bcNewDataSuccess({ bcName, dataItem, bcUrl })),\n of(bcFetchRowMetaSuccess({ bcName, bcUrl: `${bcUrl}/${cursor}`, rowMeta, cursor })),\n of(\n changeDataItem({\n bcName,\n bcUrl: buildBcUrl(bcName, true, state) ?? '',\n cursor: cursor,\n dataItem: {\n id: cursor\n }\n })\n ),\n of(selectTableRow({ widgetName: action.payload.widgetName, rowId: cursor })),\n postInvoke ? of(processPostInvoke({ bcName, postInvoke, cursor, widgetName: action.payload.widgetName })) : EMPTY\n )\n }),\n catchError((error: any) => {\n console.error(error)\n return concat(\n of(setOperationFinished({ bcName, operationType: OperationTypeCrud.create })),\n of(bcNewDataFail({ bcName })),\n createApiErrorObservable(error, context)\n )\n })\n )\n })\n )\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { OperationError, OperationErrorEntity, OperationTypeCrud } from '../../interfaces'\nimport { buildBcUrl, getEagerBcChildren, getWidgetsForLazyLoad, matchOperationRole } from '../../utils'\nimport { catchError, concat, EMPTY, filter, mergeMap, Observable, of } from 'rxjs'\nimport { CXBoxEpic } from '../../interfaces'\nimport {\n addNotification,\n bcCancelPendingChanges,\n bcFetchDataRequest,\n bcFetchRowMeta,\n bcSaveDataFail,\n bcSaveDataSuccess,\n deselectTableRow,\n processPostInvoke,\n sendOperation,\n setOperationFinished\n} from '../../actions'\nimport { AxiosError } from 'axios'\nimport { AnyAction } from '@reduxjs/toolkit'\nimport { createApiErrorObservable } from '../../utils/apiError'\nimport { removeDisabledFields } from '../../utils/data'\nimport { selectBcNameFromPopupData } from '../../selectors/selectors'\n\n/**\n * Post record's pending changes to `save dataEpics.ts` API endpoint.\n * Pending changes for fields disabled through row meta are not send; please notice that fields are\n * disabled by default.\n *\n * On success following actions are dispatched:\n * - {@link bcSaveDataSuccess}\n * - {@link bcFetchRowMeta}\n * - one {@link bcFetchDataRequest} for each child of saved business component\n * - optional {@link ActionPayloadTypes.processPostInvokeEpic | processPostInvokeEpic } if present in response\n * - optional `onSuccessAction` callback if provided in payload.\n *\n * On failure, console\\.error called and {@link ActionPayloadTypes.bcSaveDataFail | bcSaveDataFail} action\n * dispatched.\n *\n * If there was a `onSuccessAction` callback provided in action payload (and widget option\n * {@link WidgetOptions.disableNotification} was not set)\n * then a notification will be shown on failure with suggestion to cancel pending changes and a button that fires\n * {@link bcCancelPendingChanges}\n *\n * @category Epics\n */\n\nexport const bcSaveDataEpic: CXBoxEpic = (action$, state$, { api, utils }) =>\n action$.pipe(\n filter(sendOperation.match),\n filter(action => matchOperationRole(OperationTypeCrud.save, action.payload, state$.value)),\n mergeMap(action => {\n /**\n * Default implementation for `bcSaveData` epic\n *\n * Post record's pending changes to `save dataEpics.ts` API endpoint.\n * Pending changes for fields disabled through row meta are not send; pleace notice that fields are\n * disabled by default.\n *\n * On success following actions are dispatched:\n * - {@link ActionPayloadTypes.bcSaveDataSuccess | bcSaveDataSuccess}\n * - {@link ActionPayloadTypes.bcFetchRowMeta | bcFetchRowMeta}\n * - one {@link ActionPayloadTypes.bcFetchDataRequest | bcFetchDataRequest } for each children of saved\n * business component\n * - optional {@link ActionPayloadTypes.processPostInvokeEpic | processPostInvokeEpic } if present in response\n * - optional `onSuccessAction` callback if provided in payload.\n *\n * On failure, console\\.error called and {@link ActionPayloadTypes.bcSaveDataFail | bcSaveDataFail} action\n * dispatched.\n *\n * If there was a `onSuccessAction` callback provided in action payload (and widget option\n * {@link WidgetOptions.disableNotification | disableNotification } was not set)\n * then a notification will be shown on failure with suggestion to cancel pending changes and a button that fires\n * {@link ActionPayloadTypes.bcCancelPendingChanges | bcCancelPendingChanges}\n */\n const state = state$.value\n const bcName = action.payload.bcName\n const bcUrl = buildBcUrl(bcName, true, state) ?? ''\n const widgetName = action.payload.widgetName\n const cursor = state.screen.bo.bc[bcName].cursor as string\n const dataItem = state.data[bcName].find(item => item.id === cursor)\n const rowMeta = bcUrl && state.view.rowMeta[bcName]?.[bcUrl]\n const options = state.view.widgets.find(widget => widget.name === widgetName)?.options\n\n const pendingChanges = removeDisabledFields(state.view.pendingDataChanges[bcName]?.[cursor], rowMeta)\n\n const lazyWidgetNames = getWidgetsForLazyLoad(state.view.widgets, utils?.getInternalWidgets, selectBcNameFromPopupData(state))\n const fetchChildrenBcData = Object.entries(\n getEagerBcChildren(bcName, state.view.widgets, state.screen.bo.bc, lazyWidgetNames)\n ).map(entry => {\n const [childBcName, widgetNames] = entry\n return bcFetchDataRequest({ bcName: childBcName, widgetName: widgetNames[0] })\n })\n\n const context = { widgetName: action.payload.widgetName }\n return api.saveBcData(state.screen.screenName, bcUrl, { ...pendingChanges, vstamp: dataItem?.vstamp as number }, context).pipe(\n mergeMap(data => {\n const postInvoke = data.postActions?.[0]\n const responseDataItem = data.record\n return concat(\n of(setOperationFinished({ bcName, operationType: OperationTypeCrud.save })),\n of(bcSaveDataSuccess({ bcName, cursor, dataItem: responseDataItem })),\n of(bcFetchRowMeta({ widgetName, bcName })),\n of(deselectTableRow()),\n of(...fetchChildrenBcData),\n postInvoke\n ? of(\n processPostInvoke({\n bcName,\n widgetName,\n postInvoke,\n cursor: responseDataItem.id\n })\n )\n : EMPTY,\n action.payload.onSuccessAction ? of(action.payload.onSuccessAction) : EMPTY\n )\n }),\n catchError((e: AxiosError) => {\n console.error(e)\n let notification$: Observable<AnyAction> = EMPTY\n // Protection against widget blocking while autosaving\n if (action.payload.onSuccessAction && !options?.disableNotification) {\n notification$ = of(\n addNotification({\n key: 'data_autosave_undo',\n type: 'buttonWarningNotification',\n message: 'There are pending changes. Please save them or cancel.',\n duration: 0,\n options: {\n buttonWarningNotificationOptions: {\n buttonText: 'Cancel changes',\n actionsForClick: [bcCancelPendingChanges({ bcNames: [bcName] })]\n }\n }\n })\n )\n }\n let viewError: string = null as any\n let entityError: OperationErrorEntity = null as any\n const operationError = e.response?.data as OperationError\n if (e.response?.data === Object(e.response?.data)) {\n entityError = operationError?.error?.entity ?? entityError\n viewError = operationError?.error?.popup?.[0] ?? viewError\n }\n\n return concat(\n of(setOperationFinished({ bcName, operationType: OperationTypeCrud.save })),\n of(bcSaveDataFail({ bcName, bcUrl, viewError, entityError })),\n notification$,\n createApiErrorObservable(e, context)\n )\n })\n )\n })\n )\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { concat, filter, mergeMap, of } from 'rxjs'\nimport { CXBoxEpic } from '../../interfaces'\nimport { bcChangeDepthCursor, bcFetchDataRequest, bcSelectDepthRecord } from '../../actions'\n\nexport const bcSelectDepthRecordEpic: CXBoxEpic = action$ =>\n action$.pipe(\n filter(bcSelectDepthRecord.match),\n mergeMap(action => {\n /**\n * Set a cursor when expanding a record in hierarchy widgets builded around single business components\n * and fetch the dataEpics.ts for children of expanded record.\n *\n * {@link ActionPayloadTypes.bcChangeDepthCursor | bcChangeDepthCursor} action is dispatched to set the cursor\n * for expanded record; only one expanded record is allowed per hierarchy depth level.\n *\n * {@link ActionPayloadTypes.bcFetchDataRequest | bcFetchDataRequest} action is dispatched to fetch children dataEpics.ts\n * for expanded record. `ignorePageLimit`` is set as there are no controls for navigating between dataEpics.ts pages\n * in nested levels of hierarchy so instead all records are fetched.\n *\n * TODO: There is no apparent reason why `widgetName` is empty; probably will be mandatory and replace `bcName` in 2.0.0.\n *\n * @deprecated Do not use; TODO: Will be removed in 2.0.0\n */\n const { bcName, cursor, depth } = action.payload\n return concat(\n of(bcChangeDepthCursor({ bcName, depth, cursor })),\n of(\n bcFetchDataRequest({\n bcName,\n depth: depth + 1,\n widgetName: '',\n ignorePageLimit: true\n })\n )\n )\n })\n )\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { CXBoxEpic } from '../../interfaces'\nimport { concat, filter, mergeMap, of } from 'rxjs'\nimport { bcChangeCursors, bcFetchDataRequest, bcFetchRowMeta, bcSelectRecord } from '../../actions'\nimport { getEagerBcChildren, getWidgetsForLazyLoad } from '../../utils'\nimport { selectBcNameFromPopupData } from '../../selectors/selectors'\n\nexport const bcSelectRecordEpic: CXBoxEpic = (action$, state$, { utils }) =>\n action$.pipe(\n filter(bcSelectRecord.match),\n mergeMap(action => {\n const { bcName, cursor } = action.payload\n const widgets = state$.value.view.widgets\n const bcMap = state$.value.screen.bo.bc\n const lazyWidgetNames = getWidgetsForLazyLoad(\n state$.value.view.widgets,\n utils?.getInternalWidgets,\n selectBcNameFromPopupData(state$.value)\n )\n const fetchChildrenBcData = Object.entries(getEagerBcChildren(bcName, widgets, bcMap, lazyWidgetNames)).map(entry => {\n const [childBcName, widgetNames] = entry\n return bcFetchDataRequest({\n bcName: childBcName,\n widgetName: widgetNames[0],\n ignorePageLimit: action.payload.ignoreChildrenPageLimit,\n keepDelta: action.payload.keepDelta\n })\n })\n return concat(\n of(bcChangeCursors({ cursorsMap: { [bcName]: cursor }, keepDelta: action.payload.keepDelta })),\n of(bcFetchRowMeta({ widgetName: '', bcName })),\n fetchChildrenBcData\n )\n })\n )\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { CXBoxEpic, WidgetTableMeta } from '../../interfaces'\nimport { concat, filter, mergeMap, Observable, of } from 'rxjs'\nimport { changeAssociation, changeDataItem, dropAllAssociations } from '../../actions'\nimport { AnyAction } from '@reduxjs/toolkit'\nimport { WidgetTableHierarchy } from '@cxbox-ui/schema'\nimport { buildBcUrl } from '../../utils'\n\nexport const changeAssociationEpic: CXBoxEpic = (action$, state$) =>\n action$.pipe(\n filter(changeAssociation.match),\n mergeMap(action => {\n const state = state$.value\n const selected = action.payload.dataItem._associate\n const bcName = action.payload.bcName\n const result: Array<Observable<AnyAction>> = [\n of(\n changeDataItem({\n bcName,\n bcUrl: buildBcUrl(bcName, true, state),\n cursor: action.payload.dataItem.id,\n dataItem: action.payload.dataItem\n })\n )\n ]\n const widget = state.view.widgets.find(item => item.name === action.payload.widgetName) as WidgetTableMeta\n const isRoot = action.payload.bcName === widget.bcName\n const rootHierarchyDescriptor = {\n bcName: widget.bcName,\n radio: widget.options?.hierarchyRadio,\n fields: widget.fields\n }\n const hierarchy = widget.options?.hierarchy\n const hierarchyDescriptor: WidgetTableHierarchy = isRoot\n ? rootHierarchyDescriptor\n : hierarchy?.find(item => item.bcName === action.payload.bcName)\n const hierarchyGroupSelection = widget.options?.hierarchyGroupSelection\n const hierarchyTraverse = widget.options?.hierarchyTraverse\n const childrenBc = hierarchy\n ?.slice(hierarchy.findIndex(item => item.bcName === action.payload.bcName) + 1)\n .map(item => item.bcName)\n if (hierarchyGroupSelection && hierarchyDescriptor.radio && !selected) {\n result.push(\n of(\n dropAllAssociations({\n bcNames: childrenBc\n })\n )\n )\n }\n const parent: WidgetTableHierarchy = isRoot\n ? null\n : hierarchy?.find((item, index) => {\n return hierarchy[index + 1]?.bcName === action.payload.bcName\n }) || rootHierarchyDescriptor\n const parentItem = state.data[parent?.bcName]?.find(item => item.id === state.screen.bo.bc[parent?.bcName].cursor)\n if (parent && hierarchyTraverse && selected) {\n if (hierarchyDescriptor.radio) {\n result.push(\n of(\n dropAllAssociations({\n bcNames: [parent.bcName]\n })\n )\n )\n }\n result.push(\n of(\n changeAssociation({\n bcName: parent.bcName,\n widgetName: action.payload.widgetName,\n dataItem: {\n ...parentItem,\n _associate: true,\n _value: parentItem?.[parent.assocValueKey || action.payload.assocValueKey]\n },\n assocValueKey: action.payload.assocValueKey\n })\n )\n )\n }\n if (parent && hierarchyTraverse && !selected) {\n const data = state.data[action.payload.bcName]\n const wasLastInData = data.filter(item => item.id !== action.payload.dataItem.id).every(item => !item._associate)\n\n const delta = state.view.pendingDataChanges[action.payload.bcName]\n const wasLastInDelta =\n !delta ||\n !Object.values(delta).find(deltaValue => {\n return (\n deltaValue._associate === true &&\n deltaValue.id !== action.payload.dataItem.id &&\n // Filter by dataEpics.ts records, because delta can contain records from another hierarchy branch, but dataEpics.ts always contains\n // only target branch records, that we see in widget\n data.find(dataValue => dataValue.id === deltaValue.id)\n )\n })\n if (wasLastInData && wasLastInDelta) {\n result.push(\n of(\n changeAssociation({\n bcName: parent.bcName,\n widgetName: action.payload.widgetName,\n dataItem: { ...parentItem, _associate: false },\n assocValueKey: action.payload.assocValueKey\n })\n )\n )\n }\n }\n return concat(...result)\n })\n )\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { CXBoxEpic, WidgetTableMeta } from '../../interfaces'\nimport { concat, filter, mergeMap, Observable, of } from 'rxjs'\nimport { changeAssociationFull, changeDataItem, changeDescendantsAssociationsFull } from '../../actions'\nimport { AnyAction } from '@reduxjs/toolkit'\nimport { buildBcUrl } from '../../utils'\n\n/**\n * Change full hierarchy record association state. Also select/deselect dependent records according to widget options.\n */\nexport const changeAssociationFullEpic: CXBoxEpic = (action$, state$) =>\n action$.pipe(\n filter(changeAssociationFull.match),\n mergeMap(action => {\n const state = state$.value\n const result: Array<Observable<AnyAction>> = []\n const assocValueKey = action.payload.assocValueKey || state.view.popupData?.assocValueKey\n const bcName = action.payload.bcName\n const allData = state.data[bcName]\n const selected = action.payload.dataItem._associate\n const depth = action.payload.depth || 1\n const parentDepth = depth - 1\n const parentItem = depth > 1 && allData.find(item => item.id === action.payload.dataItem.parentId)\n const widget = state.view.widgets.find(item => item.name === action.payload.widgetName) as WidgetTableMeta\n const hierarchyTraverse = widget.options?.hierarchyTraverse\n const rootRadio = widget.options?.hierarchyRadio\n const hierarchyGroupDeselection = widget.options?.hierarchyGroupDeselection\n\n const currentLevelData = allData.filter(item => item.level === depth && (item.level === 1 || item.parentId === parentItem?.id))\n\n if (rootRadio && hierarchyGroupDeselection && depth === 1) {\n if (selected) {\n const delta = state.view.pendingDataChanges[bcName]\n const prevSelected = allData.find(dataItem => {\n if (dataItem.level === 1 && dataItem.id !== action.payload.dataItem.id) {\n const deltaItem = delta?.[dataItem.id]\n if (deltaItem?._associate || (!deltaItem && dataItem._associate)) {\n return true\n }\n }\n\n return false\n })\n\n if (prevSelected) {\n result.push(\n of(\n changeAssociationFull({\n bcName,\n depth: depth,\n widgetName: action.payload.widgetName,\n dataItem: { ...prevSelected, _associate: false },\n assocValueKey\n })\n )\n )\n }\n } else {\n // result.push(Observable.of($do.dropAllAssociationsFull({bcName, depth: depth + 1, dropDescendants: true})))\n result.push(\n of(\n changeDescendantsAssociationsFull({\n bcName,\n parentId: action.payload.dataItem.id,\n depth: depth + 1,\n assocValueKey,\n selected: false\n })\n )\n )\n }\n }\n\n result.push(\n of(\n changeDataItem({\n bcName: action.payload.bcName,\n bcUrl: buildBcUrl(action.payload.bcName, true, state),\n cursor: action.payload.dataItem.id,\n dataItem: action.payload.dataItem\n })\n )\n )\n\n if (parentDepth && hierarchyTraverse && selected) {\n result.push(\n of(\n changeAssociationFull({\n bcName,\n depth: parentDepth,\n widgetName: action.payload.widgetName,\n dataItem: {\n ...parentItem,\n _associate: true,\n _value: parentItem?.[assocValueKey]\n },\n assocValueKey\n })\n )\n )\n }\n\n if (parentDepth && hierarchyTraverse && !selected) {\n const delta = state.view.pendingDataChanges[bcName]\n const wasLastInDelta =\n !delta ||\n !Object.values(delta).find(deltaValue => {\n return (\n deltaValue._associate === true &&\n deltaValue.id !== action.payload.dataItem.id &&\n currentLevelData.find(dataValue => dataValue.id === deltaValue.id)\n )\n })\n const deltaFalseId =\n delta &&\n Object.values(delta)\n ?.filter(item => item._associate === false)\n .map(item => item.id)\n const wasLastInData = currentLevelData\n .filter(item => item.id !== action.payload.dataItem.id && !deltaFalseId?.includes(item.id))\n .every(item => !item._associate)\n\n if (wasLastInData && wasLastInDelta) {\n result.push(\n of(\n changeAssociationFull({\n bcName,\n depth: parentDepth,\n widgetName: action.payload.widgetName,\n dataItem: { ...parentItem, _associate: false },\n assocValueKey\n })\n )\n )\n }\n }\n\n return concat(...result)\n })\n )\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { CXBoxEpic, WidgetTableMeta } from '../../interfaces'\nimport { concat, filter, mergeMap, Observable, of } from 'rxjs'\nimport { changeAssociationSameBc, changeDataItem } from '../../actions'\nimport { AnyAction } from '@reduxjs/toolkit'\nimport { buildBcUrl } from '../../utils'\n\n/**\n * @category Epics\n */\nexport const changeAssociationSameBcEpic: CXBoxEpic = (action$, state$) =>\n action$.pipe(\n filter(changeAssociationSameBc.match),\n mergeMap(action => {\n const state = state$.value\n const bcName = action.payload.bcName\n const result: Array<Observable<AnyAction>> = [\n of(\n changeDataItem({\n bcName: bcName,\n bcUrl: buildBcUrl(bcName, true, state),\n cursor: action.payload.dataItem.id,\n dataItem: action.payload.dataItem\n })\n )\n ]\n\n const selected = action.payload.dataItem._associate\n const depth = action.payload.depth || 1\n const parentDepth = depth - 1\n const widget = state.view.widgets.find(item => item.name === action.payload.widgetName) as WidgetTableMeta\n const hierarchyTraverse = widget.options?.hierarchyTraverse\n\n const currentData = depth > 1 ? state.depthData[depth]?.[bcName] : state.data[bcName]\n\n const parentCursor = parentDepth\n ? parentDepth > 1\n ? state.screen.bo.bc[bcName].depthBc?.[parentDepth]?.cursor\n : state.screen.bo.bc[bcName].cursor\n : null\n\n const parentItem = parentCursor\n ? parentDepth > 1\n ? state.depthData[parentDepth]?.[bcName]?.find(item => item.id === parentCursor)\n : state.data[bcName].find(item => item.id === parentCursor)\n : null\n\n if (parentDepth && hierarchyTraverse && selected) {\n result.push(\n of(\n changeAssociationSameBc({\n bcName,\n depth: parentDepth,\n widgetName: action.payload.widgetName,\n dataItem: {\n ...parentItem,\n _associate: true,\n _value: parentItem?.[action.payload.assocValueKey]\n },\n assocValueKey: action.payload.assocValueKey\n })\n )\n )\n }\n\n if (parentDepth && hierarchyTraverse && !selected) {\n const wasLastInData = currentData.filter(item => item.id !== action.payload.dataItem.id).every(item => !item._associate)\n if (wasLastInData) {\n result.push(\n of(\n changeAssociationSameBc({\n bcName,\n depth: parentDepth,\n widgetName: action.payload.widgetName,\n dataItem: { ...parentItem, _associate: false },\n assocValueKey: action.payload.assocValueKey\n })\n )\n )\n }\n }\n\n return concat(...result)\n })\n )\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { CXBoxEpic } from '../../interfaces'\nimport { filter, mergeMap, of } from 'rxjs'\nimport { changeChildrenAssociations, changeDataItems } from '../../actions'\n\nexport const changeChildrenAssociationsEpic: CXBoxEpic = (action$, state$, { api }) =>\n action$.pipe(\n filter(changeChildrenAssociations.match),\n mergeMap(action => {\n const state = state$.value\n const data = state.data[action.payload.bcName]\n return of(\n changeDataItems({\n bcName: action.payload.bcName,\n cursors: data.map(item => item.id),\n dataItems: data.map(item => ({\n ...item,\n _value: item[action.payload.assocValueKey],\n _associate: action.payload.selected\n }))\n })\n )\n })\n )\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { CXBoxEpic } from '../../interfaces'\nimport { filter, mergeMap, of } from 'rxjs'\nimport { changeChildrenAssociationsSameBc, changeDataItems } from '../../actions'\n\nexport const changeChildrenAssociationsSameBcEpic: CXBoxEpic = (action$, state$) =>\n action$.pipe(\n filter(changeChildrenAssociationsSameBc.match),\n mergeMap(action => {\n const state = state$.value\n const data = state.depthData[action.payload.depth]?.[action.payload.bcName] || []\n return of(\n changeDataItems({\n bcName: action.payload.bcName,\n cursors: data.map(item => item.id),\n dataItems: data.map(item => ({\n ...item,\n _value: item[action.payload.assocValueKey],\n _associate: action.payload.selected\n }))\n })\n )\n })\n )\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { CXBoxEpic } from '../../interfaces'\nimport { concat, filter, mergeMap, Observable, of } from 'rxjs'\nimport { changeDataItems, changeDescendantsAssociationsFull } from '../../actions'\nimport { AnyAction } from '@reduxjs/toolkit'\n\n/**\n * Change full hierarchy descendants association state\n */\nexport const changeDescendantsAssociationsFullEpic: CXBoxEpic = (action$, state$) =>\n action$.pipe(\n filter(changeDescendantsAssociationsFull.match),\n mergeMap(action => {\n const state = state$.value\n const depth = action.payload.depth\n const data = state.data[action.payload.bcName]\n\n const targetData = (data || []).filter(item => item.level === depth && item.parentId === action.payload.parentId)\n\n const result: Array<Observable<AnyAction>> = [\n of(\n changeDataItems({\n bcName: action.payload.bcName,\n cursors: targetData.map(item => item.id),\n dataItems: targetData.map(item => ({\n ...item,\n _value: item[action.payload.assocValueKey],\n _associate: action.payload.selected\n }))\n })\n )\n ]\n\n targetData.forEach(targetDataItem => {\n if (data.find(dataItem => dataItem.parentId === targetDataItem.id)) {\n result.push(\n of(\n changeDescendantsAssociationsFull({\n ...action.payload,\n parentId: targetDataItem.id,\n depth: depth + 1\n })\n )\n )\n }\n })\n\n return concat(...result)\n })\n )\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { RouteType } from '../../interfaces'\nimport { parseBcCursors } from '../../utils'\nimport { CXBoxEpic } from '../../interfaces'\nimport { concat, EMPTY, filter, mergeMap, Observable, of } from 'rxjs'\nimport {\n bcChangeCursors,\n bcForceUpdate,\n changeLocation,\n handleRouter,\n selectScreen,\n selectScreenFail,\n selectView,\n selectViewFail\n} from '../../actions'\nimport { AnyAction } from '@reduxjs/toolkit'\nimport { getDefaultViewForPrimary } from '../../utils/getDefaultViewForPrimary'\nimport { getDefaultViewFromPrimaries } from '../../utils/getDefaultViewFromPrimaries'\n\n/**\n * Epic of changing the current route\n *\n * Checks route parameters (screen, view, BC cursors) relative to those\n * that are currently stored in the store, and in case of a mismatch\n * initiates reloading the screen, view or BC with new cursors.\n *\n */\nexport const changeLocationEpic: CXBoxEpic = (action$, state$) =>\n action$.pipe(\n filter(changeLocation.match),\n mergeMap(action => {\n const state = state$.value\n const { onSuccessAction } = action.payload\n const successAction = onSuccessAction ? of(onSuccessAction) : EMPTY\n\n // User not logged\n if (!state.session.active) {\n return EMPTY\n }\n\n if (state.router.type === RouteType.router) {\n return concat(of(handleRouter(state.router)), successAction)\n }\n\n // Check cursor different between store and url\n const nextCursors = parseBcCursors(state.router.bcPath) || {}\n const cursorsDiffMap: Record<string, string> = {}\n Object.entries(nextCursors).forEach(entry => {\n const [bcName, cursor] = entry\n const bc = state.screen.bo.bc[bcName]\n if (!bc || bc?.cursor !== cursor) {\n cursorsDiffMap[bcName] = cursor\n }\n })\n const needUpdateCursors = Object.keys(cursorsDiffMap).length\n\n // Reload screen if nextScreen and currentScreen not equal\n // With the default route type use the first default screen, if not exist then first screen\n const currentScreenName = state.screen.screenName\n const defaultScreenName = state.session.screens.find(screen => screen.defaultScreen)?.name || state.session.screens[0]?.name\n const nextScreenName = state.router.type === RouteType.default ? defaultScreenName : state.router.screenName\n\n if (nextScreenName !== currentScreenName || action.payload.forceUpdate) {\n const nextScreen = state.session.screens.find(item => item.name === nextScreenName)\n return nextScreen\n ? concat(\n of(selectScreen({ screen: nextScreen })),\n needUpdateCursors ? of(bcChangeCursors({ cursorsMap: cursorsDiffMap })) : EMPTY,\n successAction\n )\n : of(selectScreenFail({ screenName: nextScreenName }))\n }\n\n const currentViewName = state.view.name\n const nextViewName = state.router.viewName\n const needUpdateViews = nextViewName !== currentViewName\n const resultObservables: Array<Observable<AnyAction>> = []\n // if cursors have difference, then put new cursors and mark BC as \"dirty\"\n if (needUpdateCursors) {\n resultObservables.push(of(bcChangeCursors({ cursorsMap: cursorsDiffMap })))\n }\n // reload view if not equ\n if (needUpdateViews) {\n const nextView = nextViewName\n ? state.screen.views.find(item => item.name === nextViewName)\n : getDefaultViewForPrimary(state.screen.primaryView, state.screen.views) ??\n getDefaultViewFromPrimaries(state.screen.primaryViews, state.screen.views) ??\n state.screen.views[0]\n\n resultObservables.push(\n nextView ? of(selectView({ ...nextView, isTab: action.payload.isTab })) : of(selectViewFail({ viewName: nextViewName }))\n )\n }\n // If CURSOR has been updated but VIEW has`t changed, need update DATA\n if (needUpdateCursors && !needUpdateViews) {\n Object.entries(nextCursors).forEach(entry => {\n const [bcName, cursor] = entry\n if (!state.data[bcName].find(item => item.id === cursor)) {\n resultObservables.push(of(bcForceUpdate({ bcName })))\n }\n })\n }\n // The order is important (cursors are placed first, then the view is reloaded)\n return concat(...resultObservables, successAction)\n })\n )\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { CXBoxEpic } from '../../interfaces'\nimport { filter, of, switchMap } from 'rxjs'\nimport { selectScreen, selectView, selectViewFail } from '../../actions'\nimport { getDefaultViewForPrimary } from '../../utils/getDefaultViewForPrimary'\nimport { getDefaultViewFromPrimaries } from '../../utils/getDefaultViewFromPrimaries'\n\n/**\n *\n * TODO: Rename to `selectScreen` in 2.0.0\n *\n */\nexport const changeScreen: CXBoxEpic = (action$, state$) =>\n action$.pipe(\n filter(selectScreen.match),\n switchMap(action => {\n const state = state$.value\n const nextViewName = state.router.viewName\n const requestedView = state.screen.views.find(item => item.name === nextViewName)\n const defaultView = !nextViewName\n ? getDefaultViewForPrimary(state.screen.primaryView, state.screen.views) ??\n getDefaultViewFromPrimaries(state.screen.primaryViews, state.screen.views)\n : null\n const nextView = requestedView || defaultView || state.screen.views[0]\n return nextView ? of(selectView(nextView)) : of(selectViewFail({ viewName: nextViewName }))\n })\n )\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { parseBcCursors } from '../../utils'\nimport { CXBoxEpic } from '../../interfaces'\nimport { EMPTY, filter, of, switchMap } from 'rxjs'\nimport { bcChangeCursors, selectView } from '../../actions'\n\n/**\n *\n * TODO: Rename to `selectView` in 2.0.0\n *\n */\nexport const changeViewEpic: CXBoxEpic = (action$, state$) =>\n action$.pipe(\n filter(selectView.match),\n switchMap(action => {\n const state = state$.value\n const nextCursors = parseBcCursors(state.router.bcPath) || {}\n const cursorsDiffMap: Record<string, string> = {}\n Object.entries(nextCursors).forEach(entry => {\n const [bcName, cursor] = entry\n const bc = state.screen.bo.bc[bcName]\n if (!bc || bc.cursor !== cursor) {\n cursorsDiffMap[bcName] = cursor\n }\n })\n if (Object.keys(cursorsDiffMap).length) {\n return of(bcChangeCursors({ cursorsMap: cursorsDiffMap }))\n }\n return EMPTY\n })\n )\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { parseBcCursors } from '../../utils'\nimport { CXBoxEpic } from '../../interfaces'\nimport { bcChangeCursors } from '../../actions'\nimport { EMPTY, filter, mergeMap, of } from 'rxjs'\n\n/**\n * Clears descendant business components pending changes on cursor change\n *\n * TODO: Review required as it might be no longer valid due to autosave middleware implementation\n */\nexport const clearPendingDataChangesAfterCursorChangeEpic: CXBoxEpic = (action$, state$) =>\n action$.pipe(\n filter(bcChangeCursors.match),\n mergeMap(action => {\n const state = state$.value\n\n /*\n * Если при загрузке view курсор проставился не во всех бк\n * то дописать недостающие курсоры\n */\n const nextCursors = parseBcCursors(state.router.bcPath) || {}\n const cursorsDiffMap: Record<string, string> = {}\n Object.entries(nextCursors).forEach(entry => {\n const [bcName, cursor] = entry\n const bc = state.screen.bo.bc[bcName]\n if (!bc || bc?.cursor !== cursor) {\n cursorsDiffMap[bcName] = cursor\n }\n })\n if (Object.keys(cursorsDiffMap).length) {\n return of(bcChangeCursors({ cursorsMap: cursorsDiffMap }))\n }\n\n return EMPTY\n })\n )\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { downloadFileByUrl } from '../../actions'\nimport { CXBoxEpic } from '../../interfaces'\nimport { EMPTY, filter, mergeMap, tap } from 'rxjs'\n\nexport const downloadFileByUrlEpic: CXBoxEpic = (action$, state$) =>\n action$.pipe(\n filter(downloadFileByUrl.match),\n tap(action => {\n const { url } = action.payload\n const anchor = document.createElement('a')\n anchor.href = url\n anchor.style.display = 'none'\n document.body.appendChild(anchor)\n setTimeout(() => {\n anchor.click()\n document.body.removeChild(anchor)\n }, 100)\n }),\n mergeMap(() => EMPTY)\n )\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { CXBoxEpic } from '../../interfaces'\nimport { EMPTY, filter, mergeMap, tap } from 'rxjs'\nimport { downloadFile } from '../../actions'\n\nexport const downloadFileEpic: CXBoxEpic = (action$, state$, { api }) =>\n action$.pipe(\n filter(downloadFile.match),\n tap(action => {\n const { fileId } = action.payload\n const anchor = document.createElement('a')\n\n anchor.href = `${api.fileUploadEndpoint}?id=${encodeURIComponent(fileId)}`\n\n anchor.style.display = 'none'\n document.body.appendChild(anchor)\n\n setTimeout(() => {\n anchor.click()\n document.body.removeChild(anchor)\n }, 100)\n }),\n mergeMap(() => EMPTY)\n )\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { concat, EMPTY, filter, switchMap } from 'rxjs'\nimport { bcAddFilter, bcAddSorter, bcForceUpdate, bcRemoveAllFilters, changeLocation, drillDown } from '../../actions'\nimport { defaultParseURL, makeRelativeUrl, parseFilters, parseSorters, processDrilldownFilters } from '../../utils'\nimport { CXBoxEpic, DrillDownType } from '../../interfaces'\n\nexport const drillDownEpic: CXBoxEpic = (action$, state$) =>\n action$.pipe(\n filter(drillDown.match),\n switchMap(action => {\n // TODO: drilldown trash epic\n const state = state$.value\n const url = action.payload.url\n const result = []\n switch (action.payload.drillDownType) {\n case DrillDownType.external:\n window.location.href = url\n break\n case DrillDownType.externalNew:\n if (/^[a-z0-9]+:\\/\\//i.test(url)) {\n window.open(url)\n }\n break\n case DrillDownType.relative:\n window.location.href = `${window.location.origin}/${url}`\n break\n case DrillDownType.relativeNew:\n window.open(`${window.location.origin}/${url}`, '_blank')\n break\n case DrillDownType.inner:\n default:\n const [urlBase] = url.split('?')\n const urlObject = new URL(url, window.location.origin)\n const urlFilters = urlObject.searchParams.get('filters')\n const urlSorters = urlObject.searchParams.get('sorters')\n\n let newFilters: Record<string, string> = {}\n let newSorters: Record<string, string> = {}\n\n try {\n newFilters = JSON.parse(urlFilters) ?? newFilters\n } catch {\n urlFilters && console.warn('Failed to parse filters on drilldown')\n newFilters = {}\n }\n try {\n newSorters = JSON.parse(urlSorters) ?? newSorters\n } catch {\n urlSorters && console.warn('Failed to parse sorters on drilldown')\n newSorters = {}\n }\n const bcToUpdate: Record<string, boolean> = {}\n // If filter drilldown specifies new filters or explicitly says they are empty, drop previous filters\n Object.keys(state.screen.filters).forEach(bcName => {\n if (newFilters[bcName] === '' || newFilters[bcName]) {\n bcToUpdate[bcName] = true\n result.push(bcRemoveAllFilters({ bcName }))\n }\n })\n const nextState = defaultParseURL(urlObject)\n const viewName = nextState.viewName\n // Apply each new filter\n Object.entries(newFilters).forEach(([bcName, filterExpression]) => {\n const parsedFilters = parseFilters(filterExpression)?.map(item => ({ ...item, viewName }))\n processDrilldownFilters(parsedFilters)?.forEach(parsedFilter => {\n bcToUpdate[bcName] = true\n result.push(bcAddFilter({ bcName, filter: parsedFilter }))\n })\n })\n // Apply each new sorter\n Object.entries(newSorters).forEach(([bcName, sortExpression]) => {\n const sorter = parseSorters(sortExpression)\n result.push(bcAddSorter({ bcName, sorter }))\n bcToUpdate[bcName] = true\n })\n const prevState = state.router\n const willUpdateAnyway = shallowCompare(prevState, nextState, ['params']).length > 0\n // If screen or view is different all BC will update anyway so there is no need\n // to manually set them for update\n if (!willUpdateAnyway) {\n Object.keys(bcToUpdate).forEach(bcName => {\n result.push(bcForceUpdate({ bcName }))\n })\n }\n result.push(\n changeLocation({\n location: defaultParseURL(new URL(makeRelativeUrl(urlBase), window.location.origin)),\n forceUpdate: true,\n onSuccessAction: action.payload.onSuccessAction\n })\n )\n break\n }\n\n return result.length ? concat(result) : EMPTY\n })\n )\n\n/**\n * Shallow compare of two dictionaries by strict comparison.\n * `ignore` argument can be used to forcefully exclude some properties from result set even if their\n * are different.\n *\n * TODO: Check if possible to replace with `shallowEqual` from `react-redux`\n *\n * @param prevProps\n * @param nextProps\n * @param ignore\n */\nfunction shallowCompare(prevProps: Record<string, any>, nextProps: Record<string, any>, ignore: string[] = []) {\n const diffProps: string[] = []\n if (!prevProps && !nextProps) {\n return null\n }\n if (!prevProps) {\n return Object.keys(nextProps)\n }\n if (!nextProps) {\n return Object.keys(prevProps)\n }\n const newKeys = Object.keys(nextProps)\n newKeys.forEach(key => {\n if (prevProps[key] !== nextProps[key] && !ignore.includes(key)) {\n diffProps.push(key)\n }\n })\n Object.keys(prevProps).forEach(key => {\n if (!newKeys.includes(key)) {\n diffProps.push(key)\n }\n })\n return diffProps\n}\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { CXBoxEpic } from '../../interfaces'\nimport { bcForceUpdate, bulkUploadFiles, closeViewPopup, sendOperationSuccess } from '../../actions'\nimport { catchError, concat, EMPTY, filter, mergeMap, of } from 'rxjs'\nimport { buildBcUrl } from '../../utils'\nimport { OperationTypeCrud } from '@cxbox-ui/schema'\nimport { postOperationRoutine } from '../utils/postOperationRoutine'\nimport { createApiErrorObservable } from '../../utils/apiError'\n\n/**\n * It sends customAction request for `file-upload-save` endpoint with `bulkIds` dataEpics.ts\n * containing ids of uploaded files.\n * On success it fires `sendOperationSuccess`, `bcForceUpdate` and `closeViewPopup` actions\n * to refresh business component and close popup.\n *\n * It also launces postOperationRoutine to handle pre and post invokes.\n *\n */\nexport const fileUploadConfirmEpic: CXBoxEpic = (action$, state$, { api }) =>\n action$.pipe(\n filter(bulkUploadFiles.match),\n mergeMap(action => {\n /**\n * Default implementation for `fileUploadConfirmEpic` epic\n *\n * It sends customAction request for `file-upload-save` endpoint with `bulkIds` dataEpics.ts\n * containing ids of uploaded files.\n * On success it fires `sendOperationSuccess`, `bcForceUpdate` and `closeViewPopup` actions\n * to refresh business component and close popup.\n *\n * It also launces postOperationRoutine to handle pre and post invokes.\n */\n const state = state$.value\n const isPopup = action.payload.isPopup ?? true\n const bcName = action.payload.bcName ?? state.view.popupData?.bcName\n const bcUrl = buildBcUrl(bcName, true, state)\n const widgetName = state.view.widgets.find(item => item.bcName === bcName)?.name\n const data = action.payload.fileIds.map(id => ({\n id: id,\n _associate: true,\n vstamp: 0\n }))\n\n return api.associate(state.screen.screenName, bcUrl, data, null).pipe(\n mergeMap(response => {\n const postInvoke = response.postActions?.[0]\n const preInvoke = response.preInvoke\n return concat(\n of(sendOperationSuccess({ bcName, cursor: null })),\n of(bcForceUpdate({ bcName })),\n isPopup ? of(closeViewPopup(null)) : EMPTY,\n ...postOperationRoutine(widgetName, postInvoke, preInvoke, OperationTypeCrud.save, bcName)\n )\n }),\n catchError((error: any) => {\n console.error(error)\n return createApiErrorObservable(error)\n })\n )\n })\n )\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { CXBoxEpic, OperationError, OperationErrorEntity } from '../../interfaces'\nimport { EMPTY, concat, filter, mergeMap, of, Observable, catchError } from 'rxjs'\nimport {\n addPendingRequest,\n bcRemoveAllFilters,\n changeDataItem,\n closeViewPopup,\n forceActiveChangeFail,\n forceActiveRmUpdate,\n removePendingRequest,\n viewClearPickMap\n} from '../../actions'\nimport { WidgetTypes } from '@cxbox-ui/schema'\nimport { buildBcUrl } from '../../utils'\nimport { AnyAction, nanoid } from '@reduxjs/toolkit'\nimport { AxiosError } from 'axios'\nimport { createApiErrorObservable } from '../../utils/apiError'\n\n/**\n * Sends row meta request when `forceActive` field fires `onChange`\n */\nexport const getRowMetaByForceActiveEpic: CXBoxEpic = (action$, state$, { api }) =>\n action$.pipe(\n filter(changeDataItem.match),\n mergeMap(action => {\n const state = state$.value\n const initUrl = state.view.url\n const { bcName, cursor, disableRetry } = action.payload\n\n const isBcHierarchy = state.view.widgets.some(widget => {\n return (\n widget.bcName === bcName &&\n widget.type === WidgetTypes.AssocListPopup &&\n (widget.options?.hierarchySameBc || widget.options?.hierarchyFull)\n )\n })\n if (isBcHierarchy) {\n return EMPTY\n }\n\n const isPickListPopup = state.view.widgets.find(\n item =>\n item.name === state.view.popupData?.widgetName &&\n [WidgetTypes.PickListPopup, WidgetTypes.FlatTreePopup].includes(item.type as WidgetTypes)\n )\n\n const needPopupClose = isPickListPopup && !state.session.disableDeprecatedFeatures?.popupCloseAfterChangeData\n\n const bcUrl = buildBcUrl(bcName, true, state)\n const pendingChanges = state.view.pendingDataChanges[bcName]?.[cursor]\n const pendingChangesNow = state.view.pendingDataChangesNow[bcName]?.[cursor]\n const handledForceActive = state.view.handledForceActive[bcName]?.[cursor] || {}\n const currentRecordData = state.data[bcName]?.find(record => record.id === cursor)\n const fieldsRowMeta = state.view.rowMeta[bcName]?.[bcUrl]?.fields\n let changedFiledKey: string = null\n\n const closePopup = concat(of(closeViewPopup(null)), of(viewClearPickMap(null)), of(bcRemoveAllFilters({ bcName })))\n\n // среди forceActive-полей в дельте ищем то которое изменилось по отношению к обработанным forceActive\n // или не содержится в нем, устанавливаем флаг необходимости отправки запроса если такое поле найдено\n const someForceActiveChanged = fieldsRowMeta\n ?.filter(field => field.forceActive && pendingChanges[field.key] !== undefined)\n .some(field => {\n const result = pendingChanges[field.key] !== handledForceActive[field.key]\n if (result) {\n changedFiledKey = field.key\n }\n return result\n })\n const requestId = nanoid()\n if (someForceActiveChanged && !disableRetry) {\n return concat(\n of(addPendingRequest({ request: { requestId, type: 'force-active' } })),\n api\n .getRmByForceActive(\n state.screen.screenName,\n bcUrl,\n { ...pendingChanges, vstamp: currentRecordData?.vstamp },\n pendingChangesNow\n )\n .pipe(\n mergeMap(data => {\n const result: Array<Observable<AnyAction>> = [of(removePendingRequest({ requestId }))]\n if (state.view.url === initUrl) {\n result.push(\n of(\n forceActiveRmUpdate({\n rowMeta: data,\n currentRecordData,\n bcName,\n bcUrl,\n cursor\n })\n )\n )\n }\n if (needPopupClose) {\n result.push(closePopup)\n }\n return concat(...result)\n }),\n catchError((e: AxiosError) => {\n console.error(e)\n let viewError: string = null\n let entityError: OperationErrorEntity = null\n const operationError = e.response?.data as OperationError\n if (e.response?.data === Object(e.response?.data)) {\n entityError = operationError?.error?.entity\n viewError = operationError?.error?.popup?.[0]\n }\n return concat(\n of(removePendingRequest({ requestId })),\n state.view.url === initUrl\n ? concat(\n of(\n changeDataItem({\n bcName,\n bcUrl: buildBcUrl(bcName, true, state),\n cursor,\n dataItem: { [changedFiledKey]: currentRecordData?.[changedFiledKey] },\n disableRetry: true\n })\n ),\n of(forceActiveChangeFail({ bcName, bcUrl, viewError, entityError }))\n )\n : EMPTY,\n createApiErrorObservable(e)\n )\n })\n )\n )\n }\n return needPopupClose ? closePopup : EMPTY\n })\n )\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { catchError, EMPTY, filter, mergeMap, switchMap } from 'rxjs'\nimport { CXBoxEpic } from '../../interfaces'\nimport { handleRouter } from '../../actions'\nimport { createApiErrorObservable } from '../../utils/apiError'\n\nexport const handleRouterEpic: CXBoxEpic = (action$, state$, { api }) =>\n action$.pipe(\n filter(handleRouter.match),\n switchMap(action => {\n /**\n * Default implementation for `handleRouter` epic.\n *\n * If server routing is used, this epic will send a requst to Cxbox API router endpoint.\n * It writes a console error if request fails.\n *\n * @returns Default implementation does not throw any additional actions\n */\n const path = action.payload.path\n const params = action.payload.params\n // todo: Handle errors\n return api.routerRequest(path, params).pipe(\n mergeMap(() => {\n return EMPTY\n }),\n catchError(error => {\n console.error(error)\n return createApiErrorObservable(error)\n })\n )\n })\n )\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { CXBoxEpic } from '../../interfaces'\nimport { filter, map } from 'rxjs'\nimport { httpError, logoutDone } from '../../actions'\n\nexport const httpError401Epic: CXBoxEpic = action$ =>\n action$.pipe(\n filter(httpError.match),\n filter(action => action.payload.statusCode === 401),\n map(action => {\n return logoutDone(null)\n })\n )\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { CXBoxEpic } from '../../interfaces'\nimport { filter, map } from 'rxjs'\nimport { addNotification, httpError } from '../../actions'\n\nexport const httpError409Epic: CXBoxEpic = (action$, state$) =>\n action$.pipe(\n filter(httpError.match),\n filter(action => action.payload.statusCode === 409),\n map(action => {\n const notificationMessage = (action.payload.error.response?.data as Record<string, any>).error?.popup?.[0] || ''\n return addNotification({\n key: 'action_edit_error',\n message: notificationMessage,\n type: 'buttonWarningNotification',\n duration: 0,\n options: {\n buttonWarningNotificationOptions: {\n buttonText: 'OK'\n }\n }\n })\n })\n )\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ApplicationErrorType, BusinessError, CXBoxEpic, OperationError } from '../../interfaces'\nimport { concat, EMPTY, filter, mergeMap, Observable, of } from 'rxjs'\nimport { httpError, processPostInvoke, showViewError } from '../../actions'\nimport { AnyAction } from '@reduxjs/toolkit'\n\nexport const httpError418Epic: CXBoxEpic = (action$, state$) =>\n action$.pipe(\n filter(httpError.match),\n filter(action => action.payload.statusCode === 418),\n mergeMap(action => {\n const { error, callContext } = action.payload\n const result: Array<Observable<AnyAction>> = []\n const typedError = error.response?.data as OperationError\n if (!typedError.error.popup) {\n return EMPTY\n }\n const businessError: BusinessError = {\n type: ApplicationErrorType.BusinessError,\n message: typedError.error.popup[0]\n }\n result.push(of(showViewError({ error: businessError })))\n if (typedError.error.postActions?.[0]) {\n const widget = state$.value.view.widgets.find(item => item.name === callContext.widgetName)\n const bcName = widget?.bcName\n result.push(\n of(\n processPostInvoke({\n bcName,\n postInvoke: typedError.error.postActions[0],\n widgetName: widget?.name\n })\n )\n )\n }\n return concat(...result)\n })\n )\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ApplicationErrorType, CXBoxEpic, SystemError } from '../../interfaces'\nimport { filter, map } from 'rxjs'\nimport { httpError, showViewError } from '../../actions'\n\nexport const httpError500Epic: CXBoxEpic = (action$, state$) =>\n action$.pipe(\n filter(httpError.match),\n filter(action => action.payload.statusCode === 500),\n map(action => {\n const systemError: SystemError = {\n type: ApplicationErrorType.SystemError,\n details: action.payload.error.response?.statusText || '',\n error: action.payload.error\n }\n return showViewError({ error: systemError })\n })\n )\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { CXBoxEpic } from '../../interfaces'\nimport { catchError, filter, mergeMap, of, race } from 'rxjs'\nimport { bcFetchDataFail, inlinePickListFetchDataRequest, inlinePickListFetchDataSuccess } from '../../actions'\nimport { buildBcUrl } from '../../utils'\nimport { cancelRequestActionTypes, cancelRequestEpic } from '../../utils/cancelRequestEpic'\n\nexport const inlinePickListFetchDataEpic: CXBoxEpic = (action$, state$, { api }) =>\n action$.pipe(\n filter(inlinePickListFetchDataRequest.match),\n mergeMap(action => {\n const { bcName, searchSpec, searchString } = action.payload\n const state = state$.value\n const bcUrl = buildBcUrl(bcName, false, state)\n const canceler = api.createCanceler()\n const cancelFlow = cancelRequestEpic(action$, cancelRequestActionTypes, canceler.cancel, bcFetchDataFail({ bcName, bcUrl }))\n const normalFlow = api\n .fetchBcData(state$.value.screen.screenName, bcUrl, { [searchSpec + '.contains']: searchString }, canceler.cancelToken)\n .pipe(\n mergeMap(data => {\n return of(inlinePickListFetchDataSuccess({ bcName, data: data.data, bcUrl }))\n }),\n catchError((error: any) => {\n console.error(error)\n return of(bcFetchDataFail({ bcName: action.payload.bcName, bcUrl }))\n })\n )\n\n return race(cancelFlow, normalFlow)\n })\n )\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { CXBoxEpic } from '../../interfaces'\nimport { EMPTY, filter, switchMap } from 'rxjs'\nimport { login } from '../../actions'\n\n/**\n * Fires on successful login; there is no default implementation related to this epic,\n * but it can be used to customize successful login behaivior.\n */\nexport const loginDoneSessionEpic: CXBoxEpic = (action$, store) =>\n action$.pipe(\n filter(login.match),\n switchMap(action => EMPTY)\n )\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { CXBoxEpic, OperationPostInvokeConfirmType, OperationPreInvokeType } from '../../interfaces'\nimport { EMPTY, filter, mergeMap, of } from 'rxjs'\nimport { operationConfirmation, processPostInvokeConfirm, processPreInvoke } from '../../actions'\nimport { isAnyOf } from '@reduxjs/toolkit'\n\nexport const processPostInvokeConfirmEpic: CXBoxEpic = (action$, state$) =>\n action$.pipe(\n filter(isAnyOf(processPostInvokeConfirm, processPreInvoke)),\n mergeMap(action => {\n const { bcName, operationType, widgetName } = action.payload\n const confirm = processPostInvokeConfirm.match(action) ? action.payload.postInvokeConfirm : action.payload.preInvoke\n switch (confirm.type) {\n case OperationPostInvokeConfirmType.confirm:\n case OperationPreInvokeType.info:\n case OperationPreInvokeType.error:\n case OperationPostInvokeConfirmType.confirmText: {\n return of(\n operationConfirmation({\n operation: {\n bcName,\n operationType,\n widgetName\n },\n confirmOperation: confirm\n })\n )\n }\n default:\n return EMPTY\n }\n })\n )\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n CXBoxEpic,\n OperationPostInvokeDownloadFile,\n OperationPostInvokeDownloadFileByUrl,\n OperationPostInvokeDrillDown,\n OperationPostInvokeRefreshBc,\n OperationPostInvokeShowMessage,\n OperationPostInvokeType,\n OperationPostInvokeWaitUntil\n} from '../../interfaces'\nimport { concat, EMPTY, filter, mergeMap, of } from 'rxjs'\nimport {\n bcChangeCursors,\n bcFetchDataPages,\n bcFetchDataRequest,\n changeLocation,\n downloadFile,\n downloadFileByUrl,\n drillDown,\n processPostInvoke,\n showNotification,\n waitUntil\n} from '../../actions'\nimport { AnyAction } from '@reduxjs/toolkit'\nimport { defaultParseURL } from '../../utils'\n\nexport const processPostInvokeEpic: CXBoxEpic = (action$, state$) =>\n action$.pipe(\n filter(processPostInvoke.match),\n mergeMap(action => {\n const state = state$.value\n switch (action.payload.postInvoke.type) {\n case OperationPostInvokeType.drillDown:\n return of(\n drillDown({\n ...(action.payload.postInvoke as OperationPostInvokeDrillDown),\n route: state.router,\n widgetName: action.payload.widgetName\n })\n )\n case OperationPostInvokeType.postDelete: {\n const cursorsMap: Record<string, string> = { [action.payload.bcName]: null }\n const result: AnyAction[] = [bcChangeCursors({ cursorsMap })]\n if (state.router.bcPath?.includes(`${action.payload.bcName}/`)) {\n const newBcUrl = state.router.bcPath.split(action.payload.bcName)[0] || ''\n const newUrl = `/screen/${state.router.screenName}/view/${state.router.viewName}/${newBcUrl}`\n\n result.push(changeLocation({ location: defaultParseURL(new URL(newUrl, window.location.origin)) }))\n } else {\n result.push(\n bcFetchDataRequest({\n bcName: action.payload.bcName,\n widgetName: action.payload.widgetName\n })\n )\n }\n return of(...result)\n }\n case OperationPostInvokeType.refreshBC: {\n const bo = state.screen.bo\n const postInvoke = action.payload.postInvoke as OperationPostInvokeRefreshBc\n const postInvokeBC = postInvoke.bc\n const postInvokeBCItem = bo.bc[postInvoke.bc]\n const widgetName = action.payload.widgetName || ''\n const infiniteWidgets: string[] = state.view.infiniteWidgets || []\n const infinitePagination = state.view.widgets.some(\n item => item.bcName === postInvokeBC && infiniteWidgets.includes(item.name)\n )\n return infinitePagination\n ? of(\n bcFetchDataPages({\n bcName: postInvokeBCItem?.name,\n widgetName: widgetName,\n from: 1,\n to: postInvokeBCItem?.page\n })\n )\n : of(\n bcFetchDataRequest({\n bcName: postInvokeBCItem?.name,\n widgetName\n })\n )\n }\n case OperationPostInvokeType.showMessage: {\n const postInvoke = action.payload.postInvoke as OperationPostInvokeShowMessage\n return of(showNotification({ type: postInvoke.messageType, message: postInvoke.messageText }))\n }\n case OperationPostInvokeType.downloadFile: {\n const postInvoke = action.payload.postInvoke as OperationPostInvokeDownloadFile\n return of(downloadFile({ fileId: postInvoke.fileId }))\n }\n case OperationPostInvokeType.downloadFileByUrl: {\n const postInvoke = action.payload.postInvoke as OperationPostInvokeDownloadFileByUrl\n return of(downloadFileByUrl({ url: postInvoke.url }))\n }\n case OperationPostInvokeType.waitUntil: {\n const postInvoke = action.payload.postInvoke as OperationPostInvokeWaitUntil\n\n return of(waitUntil({ bcName: action.payload.bcName, postInvoke }))\n }\n case OperationPostInvokeType.drillDownAndWaitUntil: {\n const postInvoke = action.payload.postInvoke as OperationPostInvokeWaitUntil\n\n return concat(\n of(\n drillDown({\n ...(action.payload.postInvoke as OperationPostInvokeDrillDown),\n route: state.router,\n widgetName: action.payload.widgetName,\n onSuccessAction: waitUntil({ bcName: action.payload.bcName, postInvoke })\n })\n )\n )\n }\n default:\n // Other types can be handled by client application\n return EMPTY\n }\n })\n )\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { loginDone, refreshMeta, refreshMetaAndReloadPage } from '../../actions'\nimport { CXBoxEpic } from '../../interfaces'\nimport { concat, EMPTY, filter, of, switchMap, take, tap } from 'rxjs'\n\nexport const refreshMetaAndReloadPageEpic: CXBoxEpic = (action$, state$) =>\n action$.pipe(\n filter(refreshMetaAndReloadPage.match),\n switchMap(() =>\n concat(\n of(refreshMeta()),\n action$.pipe(\n filter(loginDone.match),\n take(1),\n tap(() => location.reload()),\n switchMap(() => EMPTY)\n )\n )\n )\n )\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { CXBoxEpic } from '../../interfaces'\nimport { catchError, concat, filter, mergeMap, switchMap } from 'rxjs'\nimport { login, loginFail, logoutDone, refreshMeta, refreshMetaDone, refreshMetaFail } from '../../actions'\nimport { createApiError } from '../../utils/apiError'\n\n/**\n * Performed on refresh meta dataEpics.ts process.\n */\nexport const refreshMetaEpic: CXBoxEpic = (action$, state$, { api }) =>\n action$.pipe(\n filter(refreshMeta.match),\n mergeMap(() => {\n const state = state$.value\n const { activeRole } = state.session\n return api.refreshMeta().pipe(\n switchMap(() => concat([refreshMetaDone(), logoutDone(null), login({ login: '', password: '', role: activeRole })])),\n catchError(error => concat([loginFail(error), refreshMetaFail(), createApiError(error)]))\n )\n })\n )\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { concat, EMPTY, filter, mergeMap, of } from 'rxjs'\nimport { CXBoxEpic, PopupWidgetTypes, TreeAssociatedRecord } from '../../interfaces'\nimport { assignTreeLinks, buildBcUrl, getDescendants } from '../../utils'\nimport { changeDataItem, removeMultivalueTag } from '../../actions'\n\n/**\n * For full hierarchies it fires `changeDataItem` action to remove value from source record\n *\n * With `hierarchyGroupDeselection` widget option, parent removal also remove children; removing\n * last child will also remove the parent.\n *\n * With `hierarchyTraverse` widget option, descendants are used instead of children.\n *\n * When parent should be removed with both option, `removeMultivalueTag` with updated `removedItem` will\n * fire instead of `changeDataItem`.\n *\n * For non-full hierarchies two `changeDataItem` actions will fire, first to drop `_associate` flag\n * of remove item and second to update value of source record.\n * Widget options are not tested for non-full hierarchies.\n */\nexport const removeMultivalueTagEpic: CXBoxEpic = (action$, state$) =>\n action$.pipe(\n filter(removeMultivalueTag.match),\n mergeMap(action => {\n /**\n * Default implementation for `removeMultivalueTag` epic\n *\n * For full hierarchies it fires `changeDataItem` action to remove value from source record\n *\n * With `hierarchyGroupDeselection` widget option, parent removal also remove children; removing\n * last child will also remove the parent.\n *\n * With `hierarchyTraverse` widget option, descendants are used instead of children.\n *\n * When parent should be removed with both option, `removeMultivalueTag` with updated `removedItem` will\n * fire instead of `changeDataItem`.\n *\n * For non-full hierarchies two `changeDataItem` actions will fire, first to drop `_associate` flag\n * of remove item and second to update value of soure record.\n * Widget options are not tested for non-full hierarchies.\n *\n */\n\n const state = state$.value\n const { bcName, cursor, popupBcName, associateFieldKey } = action.payload\n const widget = state.view.widgets.find(item => item.bcName === popupBcName && PopupWidgetTypes.includes(item.type))\n const storeData = (state?.data[popupBcName] || []) as unknown as TreeAssociatedRecord[]\n // Merge store dataEpics.ts with pending changes\n let data: TreeAssociatedRecord[] = storeData.map(item => {\n const pendingChanges = state.view.pendingDataChanges[popupBcName]?.[item.id]\n return { ...item, ...pendingChanges }\n })\n const removedItem = data.find(item => item.id === action.payload.removedItem.id)\n /**\n * It seems `_associate` is always false for full hierarchies\n * so we rely on source record value instead\n */\n const associated = action.payload.dataItem.map(item => item.id)\n let removedNodes: string[] = []\n if (widget?.options?.hierarchyGroupDeselection) {\n // Builds a tree to simplify searching of descendants\n if (widget?.options?.hierarchyTraverse) {\n data = assignTreeLinks(data)\n }\n const removedItemChildren = data.filter(item => item.parentId === removedItem?.id)\n removedNodes = [removedItem?.id, ...removedItemChildren.filter(item => associated.includes(item.id)).map(item => item.id)]\n if (widget?.options?.hierarchyTraverse) {\n getDescendants(removedItemChildren, removedNodes)\n removedNodes = data.filter(item => removedNodes.includes(item.id) && associated.includes(item.id)).map(item => item.id)\n }\n const parent = data.find(item => item.id === removedItem?.parentId)\n const siblings = data.filter(item => item.parentId === parent?.id)\n const parentEmpty = siblings.every(child => removedNodes.includes(child.id) || !associated.includes(child.id))\n // If last child/descendant removed, parent also should be\n if (parent && parentEmpty) {\n // Last descendant\n if (widget?.options?.hierarchyTraverse) {\n const parentDescendants: string[] = []\n getDescendants(siblings, parentDescendants)\n const parentDeepEmpty = parentDescendants.every(descendant => {\n return removedNodes.includes(descendant) || !associated.includes(descendant)\n })\n if (parentDeepEmpty) {\n return concat(\n of(\n removeMultivalueTag({\n ...action.payload,\n removedItem: { id: parent.id, value: null }\n })\n )\n )\n }\n } else {\n // Last child\n removedNodes.push(parent.id)\n }\n }\n }\n // Full hierarchies just filter out selected records\n if (widget?.options?.hierarchyFull) {\n return of(\n changeDataItem({\n bcName,\n bcUrl: buildBcUrl(bcName, true, state),\n cursor,\n dataItem: { [associateFieldKey]: action.payload.dataItem.filter(item => !removedNodes.includes(item.id)) }\n })\n )\n }\n const disableSecondDataChangeForAssocPopup =\n state.session.disableDeprecatedFeatures?.secondDataChangeForAssocPopupWhenRemovingTagFromField\n\n // Non-full hierarchies drops removed item's `_associate` flag`\n // And also updates source record value\n if (widget?.options?.hierarchy) {\n const hierarchyBcName =\n widget?.options?.hierarchy?.find(hierarchyData => {\n return state.view.pendingDataChanges[hierarchyData.bcName]?.[action.payload.removedItem.id]\n })?.bcName ?? bcName\n\n return concat(\n disableSecondDataChangeForAssocPopup\n ? EMPTY\n : of(\n changeDataItem({\n /**\n * This is incorrect and will break if different BC has records with\n * identical ids.\n *\n * TODO: Record `level` should be mapped to hierarchyData index instead\n */\n bcName: hierarchyBcName,\n bcUrl: buildBcUrl(hierarchyBcName, true, state),\n\n cursor: action.payload.removedItem.id,\n dataItem: { ...(action.payload.removedItem as any), _associate: false }\n })\n ),\n of(\n changeDataItem({\n bcName,\n bcUrl: buildBcUrl(bcName, true, state),\n cursor,\n dataItem: { [associateFieldKey]: action.payload.dataItem }\n })\n )\n )\n }\n // Non hierarchies drops removed item's `_associate` flag` from popup BC\n // And also updates source record value\n return concat(\n disableSecondDataChangeForAssocPopup\n ? EMPTY\n : of(\n changeDataItem({\n bcName: popupBcName,\n bcUrl: buildBcUrl(popupBcName, true, state),\n cursor: action.payload.removedItem.id,\n dataItem: { ...(action.payload.removedItem as any), _associate: false }\n })\n ),\n of(\n changeDataItem({\n bcName,\n bcUrl: buildBcUrl(bcName, true, state),\n cursor,\n dataItem: { [associateFieldKey]: action.payload.dataItem }\n })\n )\n )\n })\n )\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { buildBcUrl } from '../../utils'\nimport { AssociatedItem, CXBoxEpic } from '../../interfaces'\nimport { catchError, concat, EMPTY, filter, mergeMap, of, switchMap } from 'rxjs'\nimport {\n associateInProgress,\n bcCancelPendingChanges,\n bcForceUpdate,\n processPostInvoke,\n saveAssociations,\n setOperationFinished\n} from '../../actions'\n\n/**\n * Works with assoc-lists, which does call back-end's assoc methods by click on confirm button in modal window\n *\n * @category Epics\n */\nexport const saveAssociationsActiveEpic: CXBoxEpic = (action$, state$, { api }) =>\n action$.pipe(\n filter(saveAssociations.match),\n filter(action => {\n return state$.value.view.popupData?.active\n }),\n switchMap(action => {\n const state = state$.value\n const calleeBCName = state.view.popupData?.calleeBCName\n const calleeWidgetName = state.view.popupData?.calleeWidgetName\n const popupBcName = state.view.popupData?.bcName\n const bcNames = action.payload.bcNames\n const bcUrl = buildBcUrl(calleeBCName, true, state)\n const pendingChanges = state.view.pendingDataChanges[bcNames[0]] || {}\n const params: Record<string, any> = bcNames.length ? { _bcName: bcNames[bcNames.length - 1] } : {}\n\n return concat(\n of(associateInProgress({ bcName: popupBcName })),\n api\n .associate(\n state.screen.screenName,\n bcUrl,\n (Object.values(pendingChanges) as AssociatedItem[]).filter(i => i._associate),\n params\n )\n .pipe(\n mergeMap(response => {\n const postInvoke = response.postActions[0]\n const calleeWidget = state.view.widgets.find(widgetItem => widgetItem.bcName === calleeBCName)\n return concat(\n of(setOperationFinished({ bcName: popupBcName, operationType: 'saveAssociations' })),\n postInvoke\n ? of(processPostInvoke({ bcName: calleeBCName, postInvoke, widgetName: calleeWidget?.name }))\n : EMPTY,\n of(bcCancelPendingChanges({ bcNames: bcNames })),\n of(bcForceUpdate({ bcName: calleeBCName, widgetName: calleeWidgetName }))\n )\n }),\n catchError(err => {\n console.error(err)\n return of(setOperationFinished({ bcName: popupBcName, operationType: 'saveAssociations' }))\n })\n )\n )\n })\n )\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { AssociatedItem, CXBoxEpic } from '../../interfaces'\nimport { filter, of, switchMap } from 'rxjs'\nimport { changeDataItem, saveAssociations } from '../../actions'\nimport { MultivalueSingleValue } from '@cxbox-ui/schema'\nimport { buildBcUrl } from '../../utils'\n\n/**\n * Works with assoc-lists, which doesn't call back-end's assoc methods\n *\n * @category Epics\n */\nexport const saveAssociationsPassiveEpic: CXBoxEpic = (action$, state$) =>\n action$.pipe(\n filter(saveAssociations.match),\n filter(() => {\n return !state$.value.view.popupData?.active\n }),\n switchMap(action => {\n const state = state$.value\n const { calleeBCName = action.payload.calleeBcName, associateFieldKey = action.payload.associateFieldKey } =\n state.view.popupData ?? {}\n const cursor = state.screen.bo.bc[calleeBCName].cursor\n const recordPrevData = (state.data[calleeBCName].find(dataStateRecord => dataStateRecord.id === cursor)[associateFieldKey] ??\n []) as MultivalueSingleValue[]\n const newValues: AssociatedItem[] = []\n\n action.payload.bcNames.forEach(pendingBc => {\n const pendingChanges = state.view.pendingDataChanges[pendingBc] || {}\n Object.entries(pendingChanges).forEach(([id, item]) => {\n newValues.push(item as AssociatedItem)\n })\n })\n\n const addedItems = newValues\n .filter(newItem => {\n const isNew = !recordPrevData.find(prevItem => prevItem.id === newItem.id) && newItem._associate\n return isNew\n })\n .map(newItem => ({\n id: newItem.id,\n options: {},\n value: newItem._value as string\n }))\n\n const result = recordPrevData\n .filter(prevItem => {\n const removedItem = newValues.find(item => item.id === prevItem.id)\n if (removedItem && removedItem?._associate === false) {\n return false\n }\n return true\n })\n .concat(...addedItems)\n\n return of(\n changeDataItem({\n bcName: calleeBCName,\n bcUrl: buildBcUrl(calleeBCName, true, state),\n cursor: cursor,\n dataItem: {\n [associateFieldKey]: result\n }\n })\n )\n })\n )\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { CXBoxEpic } from '../../interfaces'\nimport { filter, map } from 'rxjs'\nimport { addNotification, selectScreenFail } from '../../actions'\n\n/**\n * Throws a error popup when attempting to navigate to a screen which is missing for current session\n *\n * @param action$ selectViewFail\n */\nexport const selectScreenFailEpic: CXBoxEpic = action$ =>\n action$.pipe(\n filter(selectScreenFail.match),\n map(action => {\n return addNotification({\n type: 'error',\n key: 'selectScreenFail',\n message: 'Screen is missing or unavailable for your role',\n options: {\n messageOptions: { screenName: action.payload.screenName }\n },\n duration: 15\n })\n })\n )\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { bcSelectRecord, selectTableRow, selectTableRowInit } from '../../actions'\nimport { CXBoxEpic } from '../../interfaces'\nimport { concat, filter, mergeMap, Observable, of } from 'rxjs'\nimport { AnyAction } from '@reduxjs/toolkit'\n\nexport const selectTableRowInitEpic: CXBoxEpic = (action$, state$) =>\n action$.pipe(\n filter(selectTableRowInit.match),\n mergeMap(action => {\n const resultObservables: Array<Observable<AnyAction>> = []\n const state = state$.value\n\n const { rowId: nextRowId } = action.payload\n\n const nextWidget = state.view.widgets.find(widget => widget.name === action.payload.widgetName)\n const nextBcName = nextWidget?.bcName\n const nextBcCursor = state.screen.bo.bc[nextBcName]?.cursor\n\n const selectedCell = state.view.selectedRow\n if (nextRowId !== nextBcCursor) {\n resultObservables.push(of(bcSelectRecord({ bcName: nextBcName, cursor: nextRowId })))\n }\n\n if (!selectedCell || nextRowId !== selectedCell.rowId || nextWidget?.name !== selectedCell.widgetName) {\n resultObservables.push(of(selectTableRow({ widgetName: nextWidget?.name, rowId: nextRowId })))\n }\n\n return concat(...resultObservables)\n })\n )\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { CXBoxEpic, EpicDependencyInjection, Store, WidgetMeta } from '../../interfaces'\nimport { EMPTY, filter, mergeMap } from 'rxjs'\nimport { bcFetchDataRequest, selectView } from '../../actions'\nimport { getWidgetsForLazyLoad } from '../../utils'\n\n/**\n * Schedules dataEpics.ts fetch for every widget on the view\n *\n * After selecting a view, this epic schedules a dataEpics.ts fetch for every widget present on the view.\n * If business componenet for the widget has a parent, then root ancestor BC is scheduled for dataEpics.ts fetch instead\n * and dataEpics.ts for its descendants will be scheduled after ancestor dataEpics.ts fetch resolved.\n *\n * @see {@link src/epics/dataEpics.ts/bcFetchDataEpic.ts} for details how descendants resolved\n */\nexport const selectViewEpic: CXBoxEpic = (action$, state$, { utils }) =>\n action$.pipe(\n filter(selectView.match),\n mergeMap(action => {\n /**\n * Default implementation for `selectView` epic.\n *\n * Schedules dataEpics.ts fetch for every widget on the view\n *\n * After selecting a view, this epic schedules a dataEpics.ts fetch for every widget present on the view.\n * If business componenet for the widget has a parent, then root ancestor BC is scheduled for dataEpics.ts fetch instead\n * and dataEpics.ts for its descendants will be scheduled after ancestor dataEpics.ts fetch resolved.\n *\n * @see {@link src/epics/dataEpics.ts/bcFetchDataEpic.ts} for details how descendants resolved\n */\n try {\n const state = state$.value\n if (action.payload.isTab) {\n return lazyLoad(state, utils?.getInternalWidgets)\n }\n\n return fullLoad(state, utils?.getInternalWidgets)\n } catch (e) {\n console.error(`selectView Epic:: ${e}`)\n return EMPTY\n }\n })\n )\n\nfunction fullLoad<S extends Store>(state: S, getInternalWidgets: EpicDependencyInjection['utils']['getInternalWidgets']) {\n const bcToLoad: Record<string, WidgetMeta> = {}\n const lazyWidgetNames = getWidgetsForLazyLoad(state.view.widgets, getInternalWidgets)\n\n state.view.widgets\n .filter(widget => !lazyWidgetNames.includes(widget.name))\n .forEach(widget => {\n if (widget.bcName) {\n let bcName = widget.bcName\n let parentName = state.screen.bo.bc[widget.bcName].parentName\n while (parentName) {\n bcName = parentName\n parentName = state.screen.bo.bc[parentName].parentName\n }\n\n if (!bcToLoad[bcName]) {\n bcToLoad[bcName] = widget\n }\n }\n })\n\n return Object.entries(bcToLoad).map(([bcName, widget]) => {\n // TODO: Row meta request should be scheduled after `bcFetchDataSuccess` here\n // (now it is scheduled in bcFetchDataRequest epic)\n return bcFetchDataRequest({ widgetName: widget.name, bcName })\n })\n}\n\n/**\n * Here is a list of bc that require downloading.\n * Either bc that have no data are loaded, or the cursor has been reset.\n * It is assumed that the cursor for a non-displayed bookmaker will be reset if the parent cursor has changed.\n */\nfunction lazyLoad<S extends Store>(state: S, getInternalWidgets: EpicDependencyInjection['utils']['getInternalWidgets']) {\n const bcToLoad: Record<string, WidgetMeta> = {}\n const data = state.data\n const bcDictionary = state.screen.bo.bc\n const hasBcData = (bcName?: string) => (bcName ? bcName in data : false)\n const cursorIsNull = (bcName?: string) => (bcName ? bcDictionary[bcName]?.cursor === null : false)\n const hasBcCursor = (bcName?: string) => (bcName ? !!bcDictionary[bcName]?.cursor : false)\n const hasBcParent = (bcName?: string) => !!bcDictionary[bcName]?.parentName\n const lazyWidgetNames = getWidgetsForLazyLoad(state.view.widgets, getInternalWidgets)\n\n state.view.widgets\n .filter(widget => !lazyWidgetNames.includes(widget.name))\n .forEach(widget => {\n if (widget.bcName && (!hasBcData(widget.bcName) || cursorIsNull(widget.bcName))) {\n let bcName = widget.bcName\n let parentName = bcDictionary[widget.bcName].parentName\n\n while (parentName && (!hasBcData(parentName) || cursorIsNull(parentName))) {\n bcName = parentName\n parentName = bcDictionary[parentName].parentName\n }\n\n if (!bcToLoad[bcName] && (!hasBcParent(bcName) || hasBcCursor(bcDictionary[bcName]?.parentName))) {\n bcToLoad[bcName] = widget\n }\n }\n })\n\n return Object.entries(bcToLoad).map(([bcName, widget]) => {\n // TODO: Row meta request should be scheduled after `bcFetchDataSuccess` here\n // (now it is scheduled in bcFetchDataRequest epic)\n return bcFetchDataRequest({ widgetName: widget.name, bcName })\n })\n}\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { CXBoxEpic } from '../../interfaces'\nimport { filter, map } from 'rxjs'\nimport { addNotification, selectViewFail } from '../../actions'\n\n/**\n * Throws a error popup when attempting to navigate to the view which is missing for current session\n *\n */\nexport const selectViewFailEpic: CXBoxEpic = (action$, state$) =>\n action$.pipe(\n filter(selectViewFail.match),\n map(action => {\n return addNotification({\n type: 'error',\n key: 'selectViewFail',\n message: 'View is missing or unavailable for your role',\n options: {\n messageOptions: { viewName: action.payload.viewName }\n },\n duration: 15\n })\n })\n )\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { CXBoxEpic } from '../../interfaces'\nimport { filter, map } from 'rxjs'\nimport { sendOperation, showFileUploadPopup, showViewPopup } from '../../actions'\nimport { buildBcUrl, flattenOperations, matchOperationRole } from '../../utils'\nimport { OperationTypeCrud } from '@cxbox-ui/schema'\n\n/**\n * Opens a popup with associate component.\n */\nexport const sendOperationAssociateEpic: CXBoxEpic = (action$, state$) =>\n action$.pipe(\n filter(sendOperation.match),\n filter(action => matchOperationRole(OperationTypeCrud.associate, action.payload, state$.value)),\n map(action => {\n const state = state$.value\n const bcUrl = buildBcUrl(action.payload.bcName, true, state)\n const operations = flattenOperations(state.view.rowMeta[action.payload.bcName]?.[bcUrl]?.actions)\n const operation = operations.find(item => item.type === action.payload.operationType)\n if (operation.subtype === 'multiFileUpload') {\n return showFileUploadPopup({\n widgetName: action.payload.widgetName\n })\n }\n return showViewPopup({\n // TODO: 2.0.0 bcKey and bcName will be removed in favor `widgetName`\n bcName: action.payload.bcKey ? `${action.payload.bcKey}` : `${action.payload.bcName}Assoc`,\n calleeBCName: action.payload.bcName,\n active: true,\n calleeWidgetName: action.payload.widgetName\n })\n })\n )\n","import { catchError, EMPTY, filter, map, switchMap, take, withLatestFrom } from 'rxjs'\nimport { isAnyOf } from '@reduxjs/toolkit'\nimport { addNotification, forceActiveChangeFail, forceActiveRmUpdate, sendOperation, setPendingSendOperation } from '../../actions'\nimport { CXBoxEpic } from '../../interfaces'\nimport { buildBcUrl, flattenOperations } from '../../utils'\n\nexport const setPendingSendOperationEpic: CXBoxEpic = (action$, state$) =>\n action$.pipe(\n filter(setPendingSendOperation.match),\n switchMap(action => {\n return action$.pipe(\n filter(isAnyOf(forceActiveRmUpdate, forceActiveChangeFail)),\n take(1),\n withLatestFrom(state$),\n map(([_, state]) => {\n const { operationType, widgetName } = action.payload\n const bcName = state.view.widgets.find(widgetItem => widgetItem.name === widgetName)?.bcName\n const bcUrl = buildBcUrl(bcName, true, state)\n const rowMeta = bcUrl && state.view.rowMeta[bcName]?.[bcUrl]\n const actions = rowMeta && flattenOperations(rowMeta.actions)\n const operation = actions?.find(item => item.type === operationType)\n\n return operation\n ? sendOperation({ ...action.payload, confirmOperation: operation.preInvoke, bcKey: operation.bcKey })\n : addNotification({\n key: 'rowMetaActionMissing',\n type: 'error',\n message: 'Operation not available',\n options: {\n messageOptions: { operationType }\n },\n duration: 15\n })\n }),\n catchError(() => EMPTY)\n )\n })\n )\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { CXBoxEpic } from '../../interfaces'\nimport { concat, filter, mergeMap, Observable, of } from 'rxjs'\nimport { bcChangeCursors, bcForceUpdate, changeLocation, showAllTableRecordsInit } from '../../actions'\nimport { AnyAction } from '@reduxjs/toolkit'\nimport { defaultBuildURL, defaultParseURL } from '../../utils'\n\nexport const showAllTableRecordsInitEpic: CXBoxEpic = (action$, state$) =>\n action$.pipe(\n filter(showAllTableRecordsInit.match),\n mergeMap(action => {\n const resultObservables: Array<Observable<AnyAction>> = []\n\n const { bcName, cursor } = action.payload\n const state = state$.value\n const route = state.router\n\n resultObservables.push(of(bcChangeCursors({ cursorsMap: { [bcName]: null } })))\n\n const bcPath = route.bcPath.slice(0, route.bcPath.indexOf(`${bcName}/${cursor}`))\n const url = defaultBuildURL({ ...route, bcPath })\n\n resultObservables.push(of(bcForceUpdate({ bcName })))\n resultObservables.push(of(changeLocation({ location: defaultParseURL(new URL(url, window.location.origin)) })))\n\n return concat(...resultObservables)\n })\n )\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { CXBoxEpic, PendingDataItem } from '../../interfaces'\nimport { EMPTY, filter, mergeMap, of } from 'rxjs'\nimport { changeDataItems, showViewPopup } from '../../actions'\nimport { MultivalueSingleValue, WidgetTypes } from '@cxbox-ui/schema'\n\nexport const showAssocPopupEpic: CXBoxEpic = (action$, state$) =>\n action$.pipe(\n filter(showViewPopup.match),\n filter(action => !!(action.payload.calleeBCName && action.payload.associateFieldKey)),\n mergeMap(action => {\n const { bcName, calleeBCName } = action.payload\n\n const state = state$.value\n\n const assocWidget = state.view.widgets.find(widget => widget.bcName === bcName && widget.type === WidgetTypes.AssocListPopup)\n const calleeCursor = state.screen.bo.bc[calleeBCName]?.cursor\n const calleePendingChanges = state.view.pendingDataChanges[calleeBCName]?.[calleeCursor]\n const assocFieldKey = action.payload.associateFieldKey\n const assocFieldChanges = calleePendingChanges?.[assocFieldKey] as MultivalueSingleValue[]\n const somethingMissing = !assocWidget || !calleePendingChanges || !assocFieldChanges || !assocFieldChanges\n if (somethingMissing || (assocWidget.options && !assocWidget.options.hierarchyFull)) {\n return EMPTY\n }\n\n const popupInitPendingChanges: Record<string, PendingDataItem> = {}\n\n assocFieldChanges.forEach(record => {\n popupInitPendingChanges[record.id] = {\n id: record.id,\n _associate: true,\n _value: record.value\n }\n })\n\n const calleeData = state.data[calleeBCName]?.find(dataRecord => dataRecord.id === calleeCursor)\n const assocIds = (calleeData?.[assocFieldKey] as MultivalueSingleValue[])?.map(recordId => recordId.id)\n const assocPendingIds = assocFieldChanges.map(recordId => recordId.id)\n if (assocIds) {\n assocIds.forEach(recordId => {\n if (!assocPendingIds.includes(recordId)) {\n popupInitPendingChanges[recordId] = {\n id: recordId,\n _associate: false\n }\n }\n })\n }\n\n return of(\n changeDataItems({\n bcName,\n cursors: Object.keys(popupInitPendingChanges),\n dataItems: Object.values(popupInitPendingChanges)\n })\n )\n })\n )\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { CXBoxEpic } from '../../interfaces'\nimport { bcChangeCursors, sendOperation, showFileUploadPopup } from '../../actions'\nimport { concat, filter, mergeMap, of } from 'rxjs'\nimport { matchOperationRole } from '../../utils'\nimport { OperationTypeCrud } from '@cxbox-ui/schema'\n\n/**\n * Fires `bcChangeCursors` and `showFileUploadPopupEpic` to drop the cursors and show file upload popup.\n */\nexport const showFileUploadPopupEpic: CXBoxEpic = (action$, state$) =>\n action$.pipe(\n filter(sendOperation.match),\n filter(action => matchOperationRole(OperationTypeCrud.fileUpload, action.payload, state$.value)),\n mergeMap(action => {\n return concat(\n of(bcChangeCursors({ cursorsMap: { [action.payload.bcName]: null } })),\n of(showFileUploadPopup({ widgetName: action.payload.widgetName }))\n )\n })\n )\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { CXBoxEpic } from '../../interfaces'\nimport { login, logoutDone, switchRole } from '../../actions'\nimport { concat, filter, switchMap } from 'rxjs'\n\n/**\n * Activates process of role switching\n */\nexport const switchRoleEpic: CXBoxEpic = (action$, state$) =>\n action$.pipe(\n filter(switchRole.match),\n switchMap(action => {\n return concat([logoutDone(null), login({ login: '', password: '', role: action.payload.role })])\n })\n )\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { CXBoxEpic } from '../../interfaces'\nimport { filter, map } from 'rxjs'\nimport { bcChangeCursors, emptyAction, userDrillDown } from '../../actions'\n\nexport const userDrillDownChangeCursorsEpic: CXBoxEpic = (action$, state$) =>\n action$.pipe(\n filter(userDrillDown.match),\n map(action => {\n const state = state$.value\n const widget = state.view.widgets.find(item => item.name === action.payload.widgetName)\n const cursor = state.screen.bo.bc[widget?.bcName]?.cursor\n\n if (cursor !== action.payload.cursor) {\n return bcChangeCursors({ cursorsMap: { [action.payload.bcName]: action.payload.cursor } })\n }\n\n return emptyAction\n })\n )\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { buildBcUrl } from '../../utils'\nimport { CXBoxEpic, DrillDownType, WidgetFieldBase } from '../../interfaces'\nimport { catchError, concat, EMPTY, filter, mergeMap, of, switchMap } from 'rxjs'\nimport { bcFetchRowMetaSuccess, drillDown, userDrillDown, userDrillDownSuccess } from '../../actions'\nimport { createApiErrorObservable } from '../../utils/apiError'\n\n/**\n *\n * @category Epics\n */\n\nexport const userDrillDownEpic: CXBoxEpic = (action$, state$, { api }) =>\n action$.pipe(\n filter(userDrillDown.match),\n switchMap(action => {\n /**\n * Default implementation for `userDrillDown` epic.\n *\n * Sends a request to fetch row meta; will write a console error if request fails.\n * Otherwise, a chain of actions will be dispatched:\n *\n * - {@link bcFetchRowMetaSuccess} for drilldowns not of {@link DrillDownType.inner} type\n * - {@link userDrillDownSuccess}\n * - {@link drillDown}\n *\n * Drilldown url is taken from {@link WidgetFieldBase.drillDown | WidgetField.drillDown} property in widget meta configuration or from record\n * directly if record's property specified in {@link WidgetFieldBase.drillDownKey | WidgetField.drillDownKey}\n *\n * @param action This epic will fire on {@link ActionPayloadTypes.userDrillDown | userDrillDown} action\n * @param store Redux store instance\n * @category Epics\n */\n\n const state = state$.value\n const { bcName, fieldKey, cursor } = action.payload\n const bcUrl = buildBcUrl(bcName, true, state)\n return api.fetchRowMeta(state.screen.screenName, bcUrl).pipe(\n mergeMap(rowMeta => {\n const drillDownField = rowMeta.fields.find(field => field.key === fieldKey)\n const route = state.router\n const drillDownKey = (\n state.view.widgets\n .find(widget => widget.bcName === bcName)\n ?.fields.find((field: WidgetFieldBase) => field.key === fieldKey) as WidgetFieldBase\n )?.drillDownKey\n const customDrillDownUrl = state.data[bcName]?.find(record => record.id === cursor)?.[drillDownKey] as string\n /**\n * It seems that behavior is wrong here; matching route condition will probably never be hit\n *\n * TODO: Review this case and either make condition strict or remove it completely\n */\n return customDrillDownUrl || drillDownField?.drillDown || drillDownField?.drillDown !== route.path\n ? concat(\n drillDownField?.drillDownType !== DrillDownType.inner\n ? of(bcFetchRowMetaSuccess({ bcName, rowMeta, bcUrl, cursor }))\n : EMPTY,\n of(userDrillDownSuccess({ bcName, bcUrl, cursor })),\n of(\n drillDown({\n url: customDrillDownUrl || drillDownField.drillDown,\n drillDownType: drillDownField.drillDownType as DrillDownType,\n route\n })\n )\n )\n : EMPTY\n }),\n catchError(error => {\n console.error(error)\n return createApiErrorObservable(error) // TODO:\n })\n )\n })\n )\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse, Method } from 'axios'\nimport { CxboxResponse } from '../interfaces'\nimport { ApiCallContext, applyParams, parseFilters } from '../utils'\nimport { from, map, takeWhile } from 'rxjs'\n\nfunction redirectOccurred<R extends CxboxResponse>(value: AxiosResponse<R>) {\n if (value.data?.redirectUrl) {\n let redirectUrl = value.data.redirectUrl\n if (!redirectUrl.startsWith('/') && !redirectUrl.match('^http(.?)://')) {\n redirectUrl = `${window.location.pathname}#/${redirectUrl}`\n }\n if (redirectUrl.startsWith('/') && !redirectUrl.startsWith('//')) {\n redirectUrl = `${window.location.origin}${redirectUrl}`\n }\n window.location.replace(redirectUrl)\n return false\n }\n return true\n}\n\nconst mergeConfigWithData = (data: any, config?: AxiosRequestConfig) => {\n return { ...config, data: config?.data !== undefined ? config.data : data }\n}\n\nexport class ObservableApiWrapper {\n instance: AxiosInstance = axios.create({\n responseType: 'json',\n headers: { Pragma: 'no-cache', 'Cache-Control': 'no-cache, no-store, must-revalidate' }\n })\n\n maxUrlLength: number = Infinity\n\n filterTypes: string[] = []\n\n constructor(instance: AxiosInstance, maxUrlLength?: number, filterTypes?: string[]) {\n this.instance = instance\n this.maxUrlLength = maxUrlLength ?? this.maxUrlLength\n this.filterTypes = filterTypes ?? this.filterTypes\n }\n\n request<ResponsePayload extends CxboxResponse>(method: Method, path: string, config?: AxiosRequestConfig) {\n let params = config?.params\n let data = config?.data\n\n const processedConfig = { ...config }\n\n delete processedConfig['params']\n delete processedConfig['data']\n\n let url = applyParams(path, params)\n\n const isLongUrl = url.length > this.maxUrlLength\n let resultMethod = method\n\n if (isLongUrl && this.filterTypes.length) {\n const paramsHasFilter =\n typeof params === 'object' &&\n params !== null &&\n Object.keys(params).some(key => this.filterTypes.includes(key.split('.')[1]))\n const dataCanBeEdited = (typeof data === 'object' && data !== null) || data === undefined\n\n if (paramsHasFilter && dataCanBeEdited) {\n resultMethod = method.toLowerCase() === 'get' ? 'post' : method\n\n params = { ...params }\n\n const filter: Record<string, unknown> = {}\n\n Object.entries(params).forEach(([key, value]) => {\n if (this.filterTypes.includes(key.split('.')[1])) {\n filter[key] = value\n delete params[key]\n }\n })\n\n const processedFilter = Object.keys(filter).length\n ? parseFilters(applyParams('', filter as Record<string, string | number>))\n : undefined\n\n data = {\n ...data,\n filter: processedFilter\n }\n\n url = applyParams(path, params)\n }\n }\n\n return from(\n this.instance.request<ResponsePayload>({\n method: resultMethod,\n data,\n url,\n ...processedConfig\n })\n ).pipe(takeWhile(redirectOccurred))\n }\n\n get<ResponsePayload extends CxboxResponse>(path: string, config?: AxiosRequestConfig, callContext?: ApiCallContext) {\n return this.request<ResponsePayload>('get', path, config).pipe(map(response => response.data))\n }\n put<ResponsePayload extends CxboxResponse>(path: string, data: any, callContext?: ApiCallContext, config?: AxiosRequestConfig) {\n return this.request<ResponsePayload>('put', path, mergeConfigWithData(data, config)).pipe(map(response => response.data))\n }\n post<ResponsePayload extends CxboxResponse>(path: string, data: any, config?: AxiosRequestConfig, callContext?: ApiCallContext) {\n return this.request<ResponsePayload>('post', path, mergeConfigWithData(data, config)).pipe(map(response => response.data))\n }\n delete<ResponsePayload extends CxboxResponse>(path: string, data: any, config?: AxiosRequestConfig, callContext?: ApiCallContext) {\n return this.request<ResponsePayload>('delete', path, mergeConfigWithData(data, config)).pipe(map(response => response.data))\n }\n}\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ObservableApiWrapper } from './ObservableApiWrapper'\nimport axios, { AxiosInstance, CancelToken } from 'axios'\nimport { ApiCallContext, buildUrl } from '../utils'\nimport { AssociatedItem, BcDataResponse, DataItem, DataItemResponse, LoginResponse, PendingDataItem, RowMetaResponse } from '../interfaces'\nimport { EMPTY, expand, map, reduce } from 'rxjs'\n\ntype GetParamsMap = Record<string, string | number>\n\nexport class Api {\n api$: ObservableApiWrapper\n\n constructor(instance: AxiosInstance, maxUrlLength?: number, filterTypes?: string[]) {\n this.api$ = new ObservableApiWrapper(instance, maxUrlLength, filterTypes)\n }\n\n routerRequest(path: string, params: Record<string, unknown>) {\n return this.api$.request('get', path, { params }).pipe(map(response => response.data))\n }\n\n fetchBcData(screenName: string, bcUrl: string, params: GetParamsMap = {}, cancelToken?: CancelToken) {\n const noLimit = params._limit === 0\n const queryStringObject = {\n ...params,\n _page: !noLimit ? ('_page' in params ? params._page : 1) : undefined,\n _limit: !noLimit ? ('_limit' in params ? params._limit : 30) : undefined\n }\n\n return this.api$\n .request<BcDataResponse>('get', buildUrl`data/${screenName}/` + bcUrl, { params: queryStringObject, cancelToken })\n .pipe(map(response => response.data))\n }\n\n fetchBcDataAll(screenName: string, bcUrl: string, params: GetParamsMap = {}) {\n let currentPage = 1\n\n return this.fetchBcData(screenName, bcUrl, { ...params, _page: currentPage }).pipe(\n expand(response => {\n return response.hasNext ? this.fetchBcData(screenName, bcUrl, { ...params, _page: ++currentPage }) : EMPTY\n }),\n reduce((items, nextResponse) => {\n return [...items, ...nextResponse.data]\n }, [] as DataItem[])\n )\n }\n\n fetchRowMeta(screenName: string, bcUrl: string, params?: GetParamsMap, cancelToken?: CancelToken) {\n return this.api$\n .request<RowMetaResponse>('get', buildUrl`row-meta/${screenName}/` + bcUrl, { params, cancelToken })\n .pipe(map(response => response.data.data.row))\n }\n\n newBcData(screenName: string, bcUrl: string, context: ApiCallContext, params?: GetParamsMap) {\n return this.api$\n .request<RowMetaResponse>('get', buildUrl`row-meta-new/${screenName}/` + bcUrl, { params })\n .pipe(map(response => response.data.data))\n }\n\n saveBcData(\n screenName: string,\n bcUrl: string,\n data: PendingDataItem & { vstamp: number },\n context: ApiCallContext,\n params?: GetParamsMap\n ) {\n return this.api$\n .request<DataItemResponse>('put', buildUrl`data/${screenName}/` + bcUrl, { data: { data }, params })\n .pipe(map(response => response.data.data))\n }\n\n deleteBcData(screenName: string, bcUrl: string = '', context: ApiCallContext, params?: GetParamsMap) {\n return this.api$\n .request<DataItemResponse>('delete', buildUrl`data/${screenName}/` + bcUrl, { params })\n .pipe(map(response => response.data.data))\n }\n\n customAction(screenName: string, bcUrl: string, data?: Record<string, any>, context?: ApiCallContext, params?: GetParamsMap) {\n return this.api$\n .request<DataItemResponse>('post', buildUrl`custom-action/${screenName}/` + bcUrl, { data: { data: data || {} }, params })\n .pipe(map(response => response.data.data))\n }\n\n associate(screenName: string, bcUrl: string, data: AssociatedItem[] | Record<string, AssociatedItem[]>, params?: GetParamsMap) {\n // TODO: Why Cxbox API sends underscored `_associate` but expects `associated` in return?\n const processedData = Array.isArray(data)\n ? data.map(item => ({\n id: item.id,\n vstamp: item.vstamp,\n associated: item._associate\n }))\n : data\n\n return this.api$\n .request<any>('post', buildUrl`associate/${screenName}/` + bcUrl, { data: processedData, params })\n .pipe(map(response => response.data.data))\n }\n\n getRmByForceActive(\n screenName: string,\n bcUrl: string | null,\n data: PendingDataItem & { vstamp: number },\n changedNow: PendingDataItem,\n params?: GetParamsMap\n ) {\n return this.api$\n .request<RowMetaResponse>('post', buildUrl`row-meta/${screenName}/` + (bcUrl ?? ''), {\n data: { data: { ...data, changedNow_: changedNow } },\n params\n })\n .pipe(map(response => response.data.data.row))\n }\n /**\n * Get Cxbox API file upload endpoint based on baseURL of axios instance\n *\n * Handles empty baseURL and trailing slash\n *\n * @returns File upload endpoint\n */\n get fileUploadEndpoint() {\n const instance = this.api$.instance\n\n if (!instance.defaults.baseURL) {\n return '/file'\n }\n\n return instance.defaults.baseURL.endsWith('/') ? `${instance.defaults.baseURL}file` : `${instance.defaults.baseURL}/file`\n }\n\n refreshMeta() {\n return this.api$.request('get', buildUrl`bc-registry/refresh-meta`).pipe(map(response => response.data))\n }\n\n loginByRoleRequest(role: string) {\n return this.api$.request<LoginResponse>('get', buildUrl`login?role=${role}`).pipe(map(response => response.data))\n }\n\n createCanceler() {\n let cancel: (() => void) | undefined\n\n const cancelToken = new axios.CancelToken(c => {\n cancel = c\n })\n\n return {\n cancel,\n cancelToken\n }\n }\n}\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { WidgetMeta } from '../interfaces/widget'\nimport { OperationTypeCrud } from '../interfaces/operation'\nimport { Store as CoreStore } from '../interfaces/store'\nimport { AnyAction, Dispatch, MiddlewareAPI } from '@reduxjs/toolkit'\nimport { sendOperation } from '../actions'\n\n/**\n * Performs mechanism of autosave\n *\n * @param action\n * @param store\n * @param next\n * @category Utils\n */\nexport function autosaveRoutine(action: AnyAction, store: MiddlewareAPI<Dispatch<AnyAction>, CoreStore>, next: Dispatch) {\n const state = store.getState()\n const dispatch = store.dispatch\n const pendingDataChanges = state.view.pendingDataChanges\n const bcList = Object.keys(pendingDataChanges)\n /**\n * Here we need to find BC with unsaved changes called `baseBcName`\n * because current action will be dispatched after `baseBcName` saving.\n * 1. We need to check out if bcName of current action is suitable for that aim\n * 2. Otherwise find first unsaved bcName\n */\n const baseBcNameIndex =\n action.payload?.bcName &&\n bcHasPendingAutosaveChanges(state, action.payload.bcName, state.screen.bo.bc[action.payload.bcName]?.cursor)\n ? bcList.findIndex(bcName => bcName === action.payload?.bcName)\n : bcList.findIndex(bcName => bcHasPendingAutosaveChanges(state, bcName, state.screen.bo.bc[bcName]?.cursor))\n const baseBcName = bcList[baseBcNameIndex]\n /**\n * Here we need to form a list of rest BC names.\n * We exclude `baseBcName` from `bcList`\n */\n if (baseBcNameIndex > -1) {\n bcList.splice(baseBcNameIndex, 1)\n }\n /**\n * Saving process\n */\n if (baseBcName) {\n /**\n * Save all BCs except `baseBcName`\n */\n bcList.forEach(bcName => {\n const widget = state.view.widgets?.find((v: WidgetMeta) => v.bcName === bcName)\n const cursor = state.screen.bo.bc[bcName]?.cursor\n if (bcHasPendingAutosaveChanges(state, bcName, cursor)) {\n dispatch(\n sendOperation({\n bcName: bcName,\n operationType: OperationTypeCrud.save,\n widgetName: widget?.name as string\n })\n )\n }\n })\n /**\n * save `baseBcName`'s BC\n */\n const baseWidget = state.view.widgets?.find((v: WidgetMeta) => v.bcName === baseBcName)\n return next(\n sendOperation({\n bcName: baseBcName,\n operationType: OperationTypeCrud.save,\n widgetName: baseWidget?.name as string,\n onSuccessAction: action\n })\n )\n }\n return next(action)\n}\n\n/**\n * Checks presence of pending changes suitable for autosave\n *\n * @param store\n * @param bcName\n * @param cursor\n */\nexport function bcHasPendingAutosaveChanges(store: CoreStore, bcName: string, cursor: string) {\n const pendingChanges = store.view.pendingDataChanges\n const cursorChanges = pendingChanges[bcName]?.[cursor as string]\n const result = cursorChanges && !Object.keys(cursorChanges).includes('_associate') && Object.values(cursorChanges).length > 0\n return result\n}\n\n/**\n * Checks presence of unsaved data.ts for specified BC\n *\n * @param store\n * @param bcName\n */\nexport function checkUnsavedChangesOfBc(store: CoreStore, bcName: string) {\n const pendingCursors = Object.keys(store.view.pendingDataChanges?.[bcName] ?? {})\n return pendingCursors.some(cursor => bcHasPendingAutosaveChanges(store, bcName, cursor))\n}\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Process preInvoke operation before action sendOperation\n */\n\nimport { AnyAction, Dispatch, Middleware, MiddlewareAPI } from 'redux'\nimport { processPreInvoke, sendOperation, setPendingSendOperation } from '../actions'\nimport { buildBcUrl, flattenOperations } from '../utils'\nimport { Store } from '../interfaces'\n\nexport const preInvokeAction: Middleware =\n ({ getState }: MiddlewareAPI<Dispatch, Store>) =>\n (next: Dispatch) =>\n (action: AnyAction) => {\n if (sendOperation.match(action)) {\n const state = getState()\n const forceUpdateRowMetaPending = (state.session.pendingRequests?.filter(item => item.type === 'force-active')?.length ?? 0) > 0\n\n if (forceUpdateRowMetaPending) {\n return next(setPendingSendOperation(action.payload))\n }\n\n const { operationType, widgetName, confirm } = action.payload\n const bcName = state.view.widgets.find(widgetItem => widgetItem.name === widgetName)?.bcName\n const bcUrl = buildBcUrl(bcName, true, state)\n const rowMeta = bcUrl && state.view.rowMeta[bcName]?.[bcUrl]\n const actions = rowMeta && flattenOperations(rowMeta.actions)\n const preInvoke = actions?.find(item => item.type === operationType)?.preInvoke\n\n return preInvoke && !confirm\n ? next(\n processPreInvoke({\n bcName,\n operationType,\n widgetName,\n preInvoke\n })\n )\n : next(action)\n }\n\n return next(action)\n }\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { saveFormMiddleware } from './autosaveMiddleware'\nimport { requiredFields } from './requiredFieldsMiddleware'\nimport { preInvokeAction } from './preInvokeMiddleware'\nimport { popupMiddleware } from './popupMiddleware'\n\nexport const middlewares = {\n autosave: saveFormMiddleware,\n requiredFields: requiredFields,\n preInvoke: preInvokeAction,\n popup: popupMiddleware\n}\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { AnyAction, Dispatch, Middleware, MiddlewareAPI } from 'redux'\nimport { coreOperations, OperationTypeCrud } from '../interfaces'\nimport { Store as CoreStore } from '../interfaces/store'\nimport { autosaveRoutine, checkUnsavedChangesOfBc } from '../utils/autosave'\nimport { WidgetOperations } from '@cxbox-ui/schema'\nimport { changeLocation, selectTableRowInit, sendOperation } from '../actions'\n\nexport const saveFormMiddleware: Middleware =\n ({ getState, dispatch }: MiddlewareAPI<Dispatch, CoreStore>) =>\n (next: Dispatch) =>\n (action: AnyAction) => {\n const state = getState()\n\n // TODO: Should offer to save pending changes or drop them\n\n const isSendOperation = sendOperation.match(action)\n const isCoreSendOperation = isSendOperation && coreOperations.includes(action.payload.operationType as OperationTypeCrud)\n const isSelectTableRowInit = selectTableRowInit.match(action)\n\n /**\n * Saving actions should be ignored\n */\n const isSaveAction = isSendOperation && action.payload.operationType === OperationTypeCrud.save\n const isNotSaveAction = !isSaveAction\n\n /**\n * Checking if the action is `sendOperation` of core type which called for another BC\n * Also BCs having pending `_associate` should be ignored\n */\n const actionBcName = isSendOperation && action.payload.bcName\n const hasAnotherUnsavedBc =\n Object.keys(state.view.pendingDataChanges)\n .filter(key => key !== actionBcName)\n .filter(key => checkUnsavedChangesOfBc(state, key)).length > 0\n const isSendOperationForAnotherBc = isCoreSendOperation && hasAnotherUnsavedBc\n\n /**\n * Checking if the action is `selectTableCellInit` called for another row or another widget\n */\n const selectedRow = state.view.selectedRow\n const isSelectTableRowInitOnAnotherRowOrWidget =\n selectedRow &&\n isSelectTableRowInit &&\n (selectedRow.widgetName !== action.payload.widgetName || selectedRow.rowId !== action.payload.rowId)\n\n /**\n * Default save operation as custom action\n *\n * If widget have only custom actions, `defaultSave` option mean witch action\n * must be executed as save record.\n * Current changeLocation action as onSuccessAction\n */\n const defaultSaveWidget = state.view.widgets?.find(item => item?.options?.actionGroups?.defaultSave)\n const defaultCursor = state.screen.bo.bc?.[defaultSaveWidget?.bcName as string]?.cursor\n const pendingData = state.view?.pendingDataChanges?.[defaultSaveWidget?.bcName as string]?.[defaultCursor as string]\n const isChangeLocation = defaultSaveWidget && changeLocation.match(action) && Object.keys(pendingData || {}).length > 0\n if (isChangeLocation) {\n return next(\n sendOperation({\n bcName: defaultSaveWidget.bcName,\n operationType: (defaultSaveWidget.options?.actionGroups as WidgetOperations).defaultSave as string,\n widgetName: defaultSaveWidget.name,\n onSuccessAction: action\n })\n )\n }\n\n /**\n * final condition\n */\n const isNeedSaveCondition = isNotSaveAction && (isSendOperationForAnotherBc || isSelectTableRowInitOnAnotherRowOrWidget)\n /**\n * Default save operation CRUD\n */\n if (isNeedSaveCondition) {\n return autosaveRoutine(action, { getState, dispatch }, next)\n }\n\n return next(action)\n }\n","/*\n * © OOO \"SI IKS LAB\", 2022-2023\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Handles validation of \"required fields\" for widget operations\n */\n\nimport { AnyAction, Dispatch, Middleware, MiddlewareAPI } from 'redux'\nimport {\n isWidgetFieldBlock,\n Operation,\n OperationGroup,\n OperationTypeCrud,\n PendingDataItem,\n PendingValidationFailsFormat,\n RowMetaField,\n Store,\n TableLikeWidgetTypes,\n WidgetFieldBlock,\n WidgetTableMeta\n} from '../interfaces'\nimport {\n addNotification,\n bcCancelPendingChanges,\n changeDataItem,\n clearValidationFails,\n selectTableRowInit,\n sendOperation\n} from '../actions'\nimport { buildBcUrl, checkShowCondition, flattenOperations } from '../utils'\nimport { DataItem, WidgetField } from '@cxbox-ui/schema'\nimport { FieldType } from '../interfaces/view'\n\nexport const requiredFields: Middleware =\n ({ getState, dispatch }: MiddlewareAPI<Dispatch, Store>) =>\n (next: Dispatch) =>\n (action: AnyAction) => {\n const state = getState()\n if (sendOperation.match(action)) {\n const { bcName, operationType, widgetName, confirmOperation } = action.payload\n const cursor = state.screen.bo.bc[bcName]?.cursor\n if (cursor) {\n const bcUrl = buildBcUrl(bcName, true, state)\n const record = state.data[bcName]?.find(item => item.id === cursor)\n const rowMeta = bcUrl && state.view.rowMeta[bcName]?.[bcUrl]\n const pendingValues = state.view.pendingDataChanges[bcName]?.[cursor]\n const widget = state.view.widgets.find(item => item.name === widgetName)\n const confirmWidgetName = confirmOperation?.widget\n const confirmWidget = confirmWidgetName && state.view.widgets.find(item => item.name === confirmWidgetName)\n // If operation marked as validation-sensetive, mark all 'required' fields which haven't been filled as dirty and invalid\n if (operationRequiresAutosave(operationType, rowMeta?.actions)) {\n // While `required` fields are assigned via rowMeta, only visually visible fields should be checked\n // to avoid situations when field is marked as `required` but not available for user to interact.\n const hiddenFieldKeys: string[] = []\n const fieldsToCheck: Record<string, RowMetaField> = {}\n const skipConfirmWidgetFieldsCheck = confirmWidget && confirmWidget.bcName === bcName\n // Form could be split into multiple widgets so we check all widget with the same BC as action initiator.\n // TODO: use visibleSameBcWidgets instead of state.view.widgets (i.e. widgets showCondition should be respected)\n state.view.widgets\n .filter(item => item.bcName === widget?.bcName)\n .forEach(item => {\n const showConditionBcName = item.showCondition?.bcName\n const isWidgetVisible = checkShowCondition(\n item.showCondition,\n state.screen.bo.bc[showConditionBcName]?.cursor || '',\n state.data[showConditionBcName],\n state.view.pendingDataChanges\n )\n const itemFieldsCalc = [...item.fields]\n if (item.fields) {\n item.fields.forEach((block: Record<string, unknown> | WidgetFieldBlock<unknown>) => {\n if (isWidgetFieldBlock(block)) {\n block.fields.forEach((field: []) => itemFieldsCalc.push(field))\n }\n })\n }\n itemFieldsCalc.forEach((widgetField: WidgetField) => {\n const matchingRowMeta = rowMeta?.fields?.find(rowMetaField => rowMetaField.key === widgetField.key)\n const isConfirmWidgetField =\n skipConfirmWidgetFieldsCheck &&\n confirmWidget?.fields?.find((field: WidgetField) => field.key === widgetField.key)\n\n if (!fieldsToCheck[widgetField.key] && matchingRowMeta && !isConfirmWidgetField) {\n fieldsToCheck[widgetField.key] = matchingRowMeta\n\n if (\n !isWidgetVisible ||\n widgetField.hidden ||\n widgetField.type === FieldType.hidden ||\n matchingRowMeta.hidden\n ) {\n hiddenFieldKeys.push(widgetField.key)\n }\n }\n })\n })\n const dataItem: PendingDataItem = getRequiredFieldsMissing(record, pendingValues, Object.values(fieldsToCheck))\n // For tables, try to autofocus on first missing field\n if (dataItem && TableLikeWidgetTypes.includes((widget as WidgetTableMeta)?.type)) {\n dispatch(selectTableRowInit({ widgetName, rowId: cursor }))\n }\n\n const requiredHiddenFieldKeys = dataItem && hiddenFieldKeys.filter(item => item in dataItem)\n const requiredHiddenFieldKeysLength = requiredHiddenFieldKeys?.length\n\n if (requiredHiddenFieldKeysLength) {\n dispatch(\n addNotification({\n key: 'requiredFieldHidden',\n type: 'error',\n message:\n requiredHiddenFieldKeysLength === 1\n ? 'The form contains a required field that is not available for completion. Contact your administrator.'\n : 'The form contains required fields that are not available for completion. Contact your administrator.',\n duration: 0,\n options: {\n messageOptions: { value: requiredHiddenFieldKeys.join('\", \"') }\n }\n })\n )\n }\n\n return dataItem\n ? next(changeDataItem({ bcName, bcUrl: buildBcUrl(bcName, true, state), cursor, dataItem }))\n : next(action)\n }\n\n // If operation is in cancelling pool, there is no need to validate\n if (isOperationSkipsValidation(operationType)) {\n return next(action)\n }\n\n // If operation is not validation-sensetive and validation failed, offer to drop pending changes\n if (hasPendingValidationFails(state, bcName)) {\n return next(\n addNotification({\n key: 'requiredFieldsMissing',\n type: 'buttonWarningNotification',\n message: 'Required fields are missing',\n duration: 0,\n options: {\n buttonWarningNotificationOptions: {\n buttonText: 'Cancel changes',\n actionsForClick: [bcCancelPendingChanges(null), clearValidationFails(null)]\n }\n }\n })\n )\n }\n }\n }\n\n return next(action)\n }\n\n/**\n * Check operations and operation groups for 'autoSaveBefore' flag (i.e. operation is validation-sensetive)\n *\n * @param operationType Key of operation to check\n * @param actions List of operations and/or operation groups\n */\nexport function operationRequiresAutosave(operationType: string, actions: Array<Operation | OperationGroup>) {\n let result = false\n if (!actions) {\n console.error('rowMeta is missing in the middle of \"sendOperation\" action')\n return result\n }\n result = flattenOperations(actions).some(action => action.type === operationType && action.autoSaveBefore)\n return result\n}\n\n/**\n * Check if required records fields have a falsy value.\n * \"Falsy\" stands for \"undefined\", \"null\", \"\", [] and {}.\n *\n * @param record Record to check\n * @param pendingChanges Pending record changes which could override record values\n * @param fieldsMeta\n */\nexport function getRequiredFieldsMissing(record: DataItem, pendingChanges: PendingDataItem, fieldsMeta: RowMetaField[]) {\n const result: PendingDataItem = {}\n fieldsMeta.forEach(field => {\n const value = record?.[field.key] as string\n const pendingValue = pendingChanges?.[field.key]\n const effectiveValue = pendingValue !== undefined ? pendingValue : value\n let falsyValue = false\n if (effectiveValue === null || effectiveValue === undefined || effectiveValue === '') {\n falsyValue = true\n } else if (Array.isArray(effectiveValue) && !effectiveValue.length) {\n falsyValue = true\n } else if (effectiveValue && typeof effectiveValue === 'object' && !Object.keys(effectiveValue).length) {\n falsyValue = true\n }\n if (field.required && falsyValue) {\n result[field.key] = Array.isArray(effectiveValue) ? [] : null\n }\n })\n return Object.keys(result).length > 0 ? result : null\n}\n\n/**\n * Checks if `pendingValidationFails` is not empty\n *\n * @param store\n * @param bcName\n */\nexport function hasPendingValidationFails(store: Store, bcName: string) {\n // TODO 2.0.0: remove this `if` block of code\n if (\n store.view.pendingValidationFailsFormat !== PendingValidationFailsFormat.target &&\n store.view.pendingValidationFails &&\n Object.keys(store.view.pendingValidationFails).length\n ) {\n return true\n }\n let checkResult = false\n const bcPendingValidations = store.view.pendingValidationFails?.[bcName] as { [cursor: string]: Record<string, string> }\n const cursorsList = bcPendingValidations && Object.keys(bcPendingValidations)\n if (!cursorsList) {\n return false\n }\n let i = 0\n for (; i < cursorsList.length; i++) {\n if (Object.keys(bcPendingValidations[cursorsList[i]]).length) {\n checkResult = true\n break\n }\n }\n return checkResult\n}\n\nfunction isOperationSkipsValidation(operationType: string) {\n return [OperationTypeCrud.delete, OperationTypeCrud.cancelCreate, 'cancel'].includes(operationType)\n}\n","import { AnyAction, Dispatch, Middleware, MiddlewareAPI } from 'redux'\nimport { Store } from '../interfaces'\nimport { showViewPopup } from '../actions'\n\nexport const popupMiddleware: Middleware =\n ({ getState }: MiddlewareAPI<Dispatch, Store>) =>\n (next: Dispatch) =>\n (action: AnyAction) => {\n if (showViewPopup.match(action)) {\n const state = getState()\n const bcName = action.payload.bcName\n const widgetValueKey = state.view.widgets.find(item => item.bcName === bcName)?.options?.displayedValueKey\n const assocValueKey = action.payload.assocValueKey ?? widgetValueKey\n return widgetValueKey ? next(showViewPopup({ ...action.payload, assocValueKey })) : next(action)\n }\n return next(action)\n }\n"],"names":["changeLocation","createAction","login","loginDone","loginFail","logout","logoutDone","selectScreen","selectScreenFail","selectView","selectViewFail","bcFetchDataRequest","bcFetchDataPages","bcClearData","inlinePickListFetchDataRequest","bcFetchDataSuccess","bcFetchDataFail","bcLoadMore","bcFetchRowMeta","bcFetchRowMetaSuccess","bcFetchRowMetaFail","bcNewData","bcNewDataSuccess","bcNewDataFail","bcDeleteDataFail","forceActiveChangeFail","sendOperation","sendOperationFail","sendOperationSuccess","processPostInvoke","processPreInvoke","processPostInvokeConfirm","userDrillDown","userDrillDownSuccess","drillDown","bcChangeCursors","bcChangeDepthCursor","changeDataItem","changeDataItems","forceActiveRmUpdate","showViewPopup","showFileUploadPopup","closeViewPopup","viewPutPickMap","viewClearPickMap","saveAssociations","changeAssociations","removeMultivalueTag","bcSaveDataSuccess","bcSaveDataFail","operationConfirmation","bcForceUpdate","uploadFile","uploadFileDone","uploadFileFailed","bcCancelPendingChanges","bcSelectRecord","bcSelectDepthRecord","changeAssociation","changeAssociationSameBc","changeAssociationFull","changeChildrenAssociations","changeChildrenAssociationsSameBc","changeDescendantsAssociationsFull","dropAllAssociations","dropAllAssociationsSameBc","dropAllAssociationsFull","handleRouter","selectTableRowInit","selectTableRow","deselectTableRow","showAllTableRecordsInit","showNotification","closeNotification","bcAddFilter","bcRemoveFilter","bcRemoveAllFilters","bcAddSorter","bcRemoveSorter","bcChangePage","showViewError","closeViewError","closeConfirmModal","clearValidationFails","downloadFile","downloadFileByUrl","bulkUploadFiles","apiError","httpError","switchDebugMode","exportState","emptyAction","refreshMeta","refreshMetaDone","refreshMetaFail","refreshMetaAndReloadPage","switchRole","addPendingRequest","removePendingRequest","addNotification","removeNotifications","waitUntil","setPendingSendOperation","associateInProgress","setOperationFinished","selectRows","deselectRows","clearSelectedRows","setPendingPostInvoke","applyPendingPostInvoke","inlinePickListFetchDataSuccess","ReducerBuilderManager","reducers","matchers","defaultCaseReducer","undefined","addCase","action","reducer","this","push","removeCase","filter","type","replaceCase","addMatcher","matcher","addDefaultCase","builder","builderWithCases","reduce","acc","args","builderWithMatchers","emptyData","p","Object","defineProperty","F","getOwnPropertyDescriptor","x","getOwnPropertyNames","h","prototype","hasOwnProperty","v","o","a","d","get","enumerable","b","DrillDownType","u","FieldType","y","OperationTypeCrud","c","PositionTypes","m","RecordSnapshotState","s","WidgetTypes","g","i","l","n","e","t","AppNotificationType","RouteType","PendingValidationFailsFormat","ApplicationErrorType","dist","r","call","M","value","noChange","new","deleted","create","save","delete","associate","cancelCreate","fileUpload","inner","relative","relativeNew","external","externalNew","Info","Form","List","DataGrid","AssocListPopup","PickListPopup","HeaderWidget","SecondLevelMenu","ThirdLevelMenu","FourthLevelMenu","WidgetCreator","Pivot","DimFilter","Text","FlatTree","FlatTreePopup","ViewNavigation","NavigationTabs","Top","Bottom","TopAndBottom","number","input","monthYear","date","dateTime","dateTimeWithSeconds","checkbox","checkboxSql","DMN","pickList","inlinePickList","dictionary","hidden","text","percent","money","comboCondition","richText","printForm","multifield","multivalue","multivalueHover","hint","radio","TableLikeWidgetTypes","PopupWidgetTypes","isCustomWidget","descriptor","isCustomWidgetConfiguration","isWidgetFieldBlock","item","PaginationMode","coreOperations","isOperationGroup","operation","Array","isArray","actions","OperationPreInvokeType","OperationPostInvokeType","OperationPostInvokeConfirmType","FilterType","isViewNavigationItem","isViewNavigationCategory","isViewNavigationGroup","initialRouterState","default","path","search","params","screenName","addTailControlSequences","url","includes","applyParams","qso","applyRawParams","result","keys","prev","paramKey","dropEmptyOrWrongParams","URLSearchParams","toString","createApiError","error","context","widgetName","isAxiosError","callContext","createApiErrorObservable","newApiError","of","EMPTY","getTemplate","literals","placeholders","length","buildBcUrl","bcName","includeSelf","state","bcMap","screen","bo","bc","cursor","name","nextBc","parentName","reverse","join","TAG_PLACEHOLDER","escapedSrc","str","RegExp","replace","makeRelativeUrl","absoluteUrl","startsWith","parseBcCursors","bcPath","cursors","tokens","split","buildUrl","placeholder","template","Error","JSON","stringify","encodeURIComponent","defaultParseURL","pathname","substring","endsWith","indexOf","searchParams","forEach","key","map","decodeURIComponent","unknown","viewName","router","bcIndex","slice","defaultBuildURL","route","getRouteFromString","ulrString","URL","window","location","origin","getFilters","filters","range","values","fieldName","greaterOrEqualThan","String","lessOrEqualThan","separator","getSorters","sorters","index","direction","jsonParse","parse","console","warn","parseFilters","defaultFilters","urlParams","fromEntries","param","getAll","containsOneOf","equalsOneOf","parseSorters","from","entries","sort","fieldKey","order","Number","parseInt","processDrilldownFilters","rangeFilters","filterItem","flattenOperations","operations","OperationItem","matchOperationRole","role","payload","store","operationType","bcUrl","view","rowMeta","find","every","actionRole","getBcChildren","originBcName","widgets","childrenBcMap","widget","widgetBcList","expectedBcName","options","hierarchy","hierarchyBcName","hierarchyWidgetName","hierarchyWidget","nestedBcNames","nestedItem","childHierarchyBcIndex","findIndex","childHierarchyBcName","getHierarchyChildBc","isEagerWidget","lazyWidgetNames","showConditionCheck","isNotLazy","isVisible","getEagerBcChildren","childBcName","widgetNames","checkShowCondition","condition","data","pendingDataChanges","isDefault","record","id","actualValue","pendingValue","assignTreeLinks","flat","orphans","parentId","parentIndex","el","parent","children","getDescendants","nodes","child","getDefaultViewForPrimary","primary","views","getDefaultViewFromPrimaries","primaries","primaryView","primaryViewName","removeDisabledFieldsMutate","changes","rowMetaOfDisabledField","fields","field","disabled","currentValue","removeDisabledFields","getWidgetsForLazyLoad","getInternalWidgets","activePopupBcName","popupWidgets","mainWidgets","internalPopupWidgetsNames","internalMainWidgetsNames","internalNames","Set","externalPopupWidgets","has","externalMainWidgets","exclusionSet","uniqueInternalPopupWidgetsNames","internalPopupWidgetName","breadthFirstSearch","root","predicate","depth","childrenProperty","rootMatch","rootChildren","node","simpleLeaf","resultDepth","some","matchingNodes","obj","customWidgets","widgetType","isPopup","title","dataItem","templatedString","match","token","varName","defaultValue","formatString","fieldType","specified","contains","equals","level","bcUrlItems","bcCursor","source","tokenizer","operationsHandledLocally","initialViewState","columns","readOnly","rowHeight","metaInProgress","popupData","pendingPostInvoke","pendingDataChangesNow","infiniteWidgets","pendingValidationFailsFormat","old","pendingValidationFails","handledForceActive","selectedRow","selectedRows","ignoreHistory","systemNotifications","modalInvoke","getFailsByRequiredFields","isRequired","fails","initialState","nextDataItem","prevDataItem","vstamp","_associate","records","isTab","bcNames","bcDictionary","bcSorters","bcFilters","meta","sorter","defaultSort","defaultFilter","primaryViews","activeBcName","loading","currentBc","page","newBcs","hasNext","cachedBc","prevOperationsInProgress","operationsInProgress","newCursors","newCache","cursorsMap","entry","changedParents","assign","depthBc","newFilter","prevFilters","prevFilter","newFilters","newBcFilters","currentPage","calleeBCName","loginSpin","errorMsg","active","debugMode","pendingRequests","request","requestId","notifications","closingKeys","notification","isMetaRefreshing","currentRecordData","rowMetaForcedValues","newPendingChangesDiff","forceActiveFieldKeys","forceActive","consolidatedFrontData","newPendingDataChanges","isTargetFormatPVF","target","nextValidationFails","required","actionBcName","nextPending","prevPendingNow","newPendingChanges","newPendingChangesNow","dataItems","pendingBcChanges","itemId","entityError","errors","violation","calleeWidgetName","associateFieldKey","assocValueKey","isFilter","pickMap","rowId","message","selectedRowsDictionary","row","newDataItems","dataItemIdsToDelete","splice","ids","postInvoke","devPanelEnabled","activeRole","roles","firstName","lastName","exportStateEnabled","screens","postOperationRoutine","preInvoke","postInvokeConfirm","recursiveQueryWithRepeat","api","currentBcName","timeout","repeatTimeout","timeoutMaxRequests","successCondition_fieldKey","successCondition_value","requestInterval","Math","floor","limitBySelfCursor","fetchParams","_page","_limit","limit","fetchBcData","fetchDataRequest","pipe","mergeMap","response","valueForComparison","successCondition","delay","checkingReadinessForBuildBcUrl","bcNamesForChecking","bcHierarchy","parentBcName","getBcHierarchyArr","bcNameForChecking","knownHttpErrors","responseStatusMessages","cancelRequestActionTypes","cancelRequestEpic","action$","actionTypes","cancelFn","cancelActionCreator","filterFn","isAnyOf","take","selectBcNameFromPopupData","getCurrentCursor","prevCursor","newCursor","updatedCursor","getCursorChange","isHierarchy","keepDelta","isPopupWidget","getChildrenData","eagerChildren","concat","nonLazyWidget","ignorePageLimit","resetOutdatedChildrenData","parentsBcUrls","childBcNamesWithData","bcNameWithData","actionTypesMatcher","statusCode","status","axios","isCancel","NetworkError","state$","pendingRecordChange","_action","customAction","postActions","catchError","store$","deleteBcData","utils","widgetsWithCurrentBc","anyHierarchyWidget","hierarchyFull","isHierarchyWidget","fullHierarchyWidget","to","canceler","createCanceler","cancelFlow","cancel","cancelByParentBc","filteredAction","actionBc","normalFlow","cancelToken","cursorChange","setDataSuccess","fetchRowMeta","isWidgetVisible","w","showCondition","dataToCheck","currentCursor","bcWidgetsMap","bcListOnCurrentView","originBcIsOnCurrentView","leastOneWidgetIsVisible","isVisiblePopup","bcIsUsedInShowCondition","isChildBcForOriginBc","partUrlOfChildBc","widgetIsUsedOnView","fetchChildren","resetOutdatedData","race","oldBcDataIds","newData","newBcData","pendingChanges","fetchChildrenBcData","saveBcData","responseDataItem","onSuccessAction","notification$","disableNotification","duration","buttonWarningNotificationOptions","buttonText","actionsForClick","viewError","operationError","entity","popup","ignoreChildrenPageLimit","selected","isRoot","rootHierarchyDescriptor","hierarchyRadio","hierarchyDescriptor","hierarchyGroupSelection","hierarchyTraverse","childrenBc","parentItem","_value","wasLastInData","delta","wasLastInDelta","deltaValue","dataValue","allData","parentDepth","rootRadio","hierarchyGroupDeselection","currentLevelData","prevSelected","deltaItem","deltaFalseId","currentData","depthData","parentCursor","targetData","targetDataItem","successAction","session","nextCursors","cursorsDiffMap","needUpdateCursors","currentScreenName","defaultScreenName","defaultScreen","nextScreenName","forceUpdate","nextScreen","currentViewName","nextViewName","needUpdateViews","resultObservables","nextView","switchMap","requestedView","defaultView","tap","anchor","document","createElement","href","style","display","body","appendChild","setTimeout","click","removeChild","fileId","fileUploadEndpoint","drillDownType","test","open","urlBase","urlObject","urlFilters","urlSorters","newSorters","bcToUpdate","nextState","filterExpression","parsedFilters","parsedFilter","sortExpression","prevProps","nextProps","ignore","diffProps","newKeys","shallowCompare","fileIds","initUrl","disableRetry","hierarchySameBc","needPopupClose","disableDeprecatedFeatures","popupCloseAfterChangeData","pendingChangesNow","fieldsRowMeta","changedFiledKey","closePopup","someForceActiveChanged","nanoid","getRmByForceActive","routerRequest","notificationMessage","typedError","businessError","BusinessError","systemError","SystemError","details","statusText","code","searchSpec","searchString","isSwitchRole","loginByRoleRequest","defaultUrl","hash","confirm","info","confirmText","confirmOperation","postDelete","newBcUrl","newUrl","refreshBC","postInvokeBC","postInvokeBCItem","infinitePagination","showMessage","messageType","messageText","drillDownAndWaitUntil","reload","password","popupBcName","removedItem","associated","removedNodes","removedItemChildren","siblings","parentEmpty","parentDescendants","descendant","disableSecondDataChangeForAssocPopup","secondDataChangeForAssocPopupWhenRemovingTagFromField","hierarchyData","_bcName","calleeWidget","widgetItem","err","calleeBcName","recordPrevData","dataStateRecord","newValues","pendingBc","addedItems","newItem","prevItem","messageOptions","nextRowId","nextWidget","nextBcName","nextBcCursor","selectedCell","bcToLoad","hasBcData","cursorIsNull","hasBcCursor","hasBcParent","lazyLoad","fullLoad","subtype","bcKey","defaultSaveOperation","actionGroups","defaultSave","_confirm","postInvokeType","postInvokeRefreshCurrentBc","postInvokeTypesWithRefreshBc","withoutBcForceUpdate","withLatestFrom","_","assocWidget","calleeCursor","calleePendingChanges","assocFieldKey","assocFieldChanges","popupInitPendingChanges","calleeData","dataRecord","assocIds","recordId","assocPendingIds","drillDownField","drillDownKey","customDrillDownUrl","successCondition_bcName","switchPopup","isProgressStatus","isFinalStatus","requestResult","currentState","getCheckedStateForBuildBcUrl","checkedState","takeUntil","closeAction","successMessage","TimeoutError","timeoutMessage","inProgressMessage","redirectOccurred","redirectUrl","mergeConfigWithData","config","ObservableApiWrapper","instance","responseType","headers","Pragma","maxUrlLength","Infinity","filterTypes","constructor","method","processedConfig","resultMethod","toLowerCase","processedFilter","takeWhile","put","post","Api","api$","noLimit","queryStringObject","fetchBcDataAll","expand","items","nextResponse","processedData","changedNow","changedNow_","defaults","baseURL","CancelToken","bcHasPendingAutosaveChanges","cursorChanges","middlewares","autosave","getState","dispatch","next","isSendOperation","isCoreSendOperation","isSelectTableRowInit","isNotSaveAction","hasAnotherUnsavedBc","checkUnsavedChangesOfBc","isSendOperationForAnotherBc","isSelectTableRowInitOnAnotherRowOrWidget","defaultSaveWidget","defaultCursor","pendingData","bcList","baseBcNameIndex","baseBcName","baseWidget","autosaveRoutine","requiredFields","pendingValues","confirmWidgetName","confirmWidget","autoSaveBefore","operationRequiresAutosave","hiddenFieldKeys","fieldsToCheck","skipConfirmWidgetFieldsCheck","showConditionBcName","itemFieldsCalc","block","widgetField","matchingRowMeta","rowMetaField","isConfirmWidgetField","fieldsMeta","effectiveValue","falsyValue","getRequiredFieldsMissing","requiredHiddenFieldKeys","requiredHiddenFieldKeysLength","isOperationSkipsValidation","checkResult","bcPendingValidations","cursorsList","hasPendingValidationFails","widgetValueKey","displayedValueKey"],"mappings":"4WAsCO,MAAMA,EAAiBC,EAC1B,kBAKSC,EAAQD,EAalB,SAKUE,EAAYF,EAA4B,aAKxCG,EAAYH,EAKtB,aAKUI,EAASJ,EAAmB,UAK5BK,EAAaL,EAAmB,cAShCM,EAAeN,EAKzB,gBAKUO,EAAmBP,EAK7B,oBAQUQ,EAAaR,EAAqD,cAOlES,EAAiBT,EAE3B,kBAKUU,EAAqBV,EA2B/B,sBAKUW,EAAmBX,EAmB7B,oBAEUY,EAAcZ,EAAoC,eAKlDa,EAAiCb,EAa3C,kCAKUc,EAAqBd,EAyB/B,sBAKUe,EAAkBf,EAe5B,mBAKUgB,EAAahB,EASvB,cAKUiB,EAAiBjB,EAY3B,kBAOUkB,EAAwBlB,EAmBlC,yBAKUmB,EAAqBnB,EAK/B,sBAOUoB,EAAYpB,EAKtB,a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