@legalplace/wizardx-core 2.6.4 → 2.7.1
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/CHANGELOG.md +49 -0
- package/dist/App.js +13 -4
- package/dist/PluginLoader.d.ts +3 -1
- package/dist/PluginLoader.js +12 -0
- package/dist/ThemeLoader.d.ts +2 -2
- package/dist/components/SmartScript.d.ts +2 -2
- package/dist/components/SmartScript.js +2 -0
- package/dist/componentsConnectors/connectBox.d.ts +3 -1
- package/dist/componentsConnectors/connectDocument.d.ts +3 -1
- package/dist/componentsConnectors/connectHeader.d.ts +3 -1
- package/dist/componentsConnectors/connectMetaTitle.d.ts +3 -1
- package/dist/componentsConnectors/connectOption.d.ts +6 -2
- package/dist/componentsConnectors/connectOption.js +1 -1
- package/dist/componentsConnectors/connectPagination.d.ts +3 -1
- package/dist/componentsConnectors/connectPreview.d.ts +3 -1
- package/dist/componentsConnectors/connectProgress.d.ts +3 -1
- package/dist/componentsConnectors/connectRootOption.d.ts +3 -1
- package/dist/componentsConnectors/connectSection.d.ts +3 -1
- package/dist/componentsConnectors/connectSection.js +7 -10
- package/dist/componentsConnectors/connectSummary.d.ts +3 -1
- package/dist/componentsConnectors/connectSummaryItem.d.ts +3 -1
- package/dist/componentsConnectors/connectVariable.d.ts +6 -2
- package/dist/componentsConnectors/connectVariable.js +1 -1
- package/dist/componentsConnectors/connectWizardWrapper.d.ts +3 -1
- package/dist/componentsConnectors/connector/componentConnector.d.ts +5 -1
- package/dist/componentsConnectors/connector/componentConnector.js +43 -4
- package/dist/componentsConnectors/connector/index.d.ts +1 -0
- package/dist/componentsConnectors/connector/index.js +1 -0
- package/dist/componentsConnectors/index.d.ts +17 -0
- package/dist/componentsConnectors/index.js +17 -0
- package/dist/componentsConnectors/library.d.ts +43 -15
- package/dist/helpers/apiEndpoint.d.ts +1 -0
- package/dist/helpers/apiEndpoint.js +4 -0
- package/dist/helpers/index.d.ts +4 -0
- package/dist/helpers/index.js +4 -0
- package/dist/helpers/propsEqualityCheck.d.ts +1 -0
- package/dist/helpers/propsEqualityCheck.js +10 -0
- package/dist/hooks/index.d.ts +4 -0
- package/dist/hooks/index.js +4 -0
- package/dist/hooks/useActions.d.ts +2 -0
- package/dist/hooks/useActions.js +4 -0
- package/dist/hooks/useDispatch.d.ts +1 -0
- package/dist/hooks/useDispatch.js +4 -0
- package/dist/hooks/useSelectors.d.ts +2 -0
- package/dist/hooks/useSelectors.js +4 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +13 -0
- package/dist/libs/PathReader.d.ts +10 -6
- package/dist/libs/PathReader.js +47 -28
- package/dist/libs/index.d.ts +5 -0
- package/dist/libs/index.js +5 -0
- package/dist/redux/actions/index.d.ts +9 -0
- package/dist/redux/actions/index.js +9 -0
- package/dist/redux/actions/library.d.ts +59 -63
- package/dist/redux/actions/sagas/index.d.ts +3 -0
- package/dist/redux/actions/sagas/index.js +3 -0
- package/dist/redux/actions/sagas/model.d.ts +1 -5
- package/dist/redux/constants/app.d.ts +2 -0
- package/dist/redux/constants/app.js +2 -0
- package/dist/redux/constants/index.d.ts +8 -0
- package/dist/redux/constants/index.js +8 -0
- package/dist/redux/constants/sagas/index.d.ts +3 -0
- package/dist/redux/constants/sagas/index.js +3 -0
- package/dist/redux/index.d.ts +5 -0
- package/dist/redux/index.js +5 -0
- package/dist/redux/middlewares/conditionsWatcherMiddleware.js +11 -5
- package/dist/redux/middlewares/conditionsWatcherMiddleware.test.js +120 -113
- package/dist/redux/middlewares/paginationWatcherMiddleware.js +2 -2
- package/dist/redux/middlewares/smartscriptMiddleware.js +8 -0
- package/dist/redux/reducers/pluginsStore.d.ts +3 -0
- package/dist/redux/reducers/pluginsStore.js +12 -0
- package/dist/redux/routerHistory.js +2 -2
- package/dist/redux/sagas/fetchModel.js +22 -6
- package/dist/redux/sagas/initInputs.js +6 -7
- package/dist/redux/sagas/saveData.js +2 -0
- package/dist/redux/selectors/app.js +13 -18
- package/dist/redux/selectors/cache.d.ts +17 -0
- package/dist/redux/selectors/cache.js +35 -0
- package/dist/redux/selectors/conditions.js +7 -7
- package/dist/redux/selectors/index.d.ts +8 -0
- package/dist/redux/selectors/index.js +8 -0
- package/dist/redux/selectors/inputs.js +3 -3
- package/dist/redux/selectors/library.d.ts +2 -2
- package/dist/redux/selectors/references.js +26 -26
- package/dist/redux/selectors/selectors.d.ts +2 -2
- package/dist/redux/selectors/selectors.js +19 -8
- package/dist/redux/selectors/selectors.test.js +6 -6
- package/dist/redux/selectors/user.js +5 -5
- package/dist/redux/store.d.ts +1 -1
- package/dist/redux/store.js +12 -4
- package/dist/service/api.manager.d.ts +1 -6
- package/dist/service/index.d.ts +3 -0
- package/dist/service/index.js +3 -0
- package/dist/types/PluginConfig.type.d.ts +57 -0
- package/dist/types/PluginConfig.type.js +1 -0
- package/dist/types/State.type.d.ts +6 -0
- package/dist/types/config.type.d.ts +3 -1
- package/dist/types/index.d.ts +11 -0
- package/dist/types/index.js +11 -0
- package/package.json +13 -13
- package/.depcheckrc +0 -1
- package/.eslintignore +0 -2
- package/.eslintrc +0 -5
- package/__mocks__/fileMock.js +0 -1
- package/babel.config.json +0 -3
- package/jest.config.ts +0 -193
- package/setupJest.ts +0 -8
- package/src/App.test.tsx +0 -41
- package/src/App.tsx +0 -152
- package/src/Globals.ts +0 -69
- package/src/Loader.tsx +0 -8
- package/src/PluginLoader.test.tsx +0 -70
- package/src/PluginLoader.tsx +0 -407
- package/src/Shimmer.tsx +0 -108
- package/src/ThemeLoader.test.tsx +0 -82
- package/src/ThemeLoader.tsx +0 -95
- package/src/components/PluginRoute.tsx +0 -48
- package/src/components/SmartScript.tsx +0 -166
- package/src/components/UserLocked/UserLockedComponent.tsx +0 -33
- package/src/components/View.test.tsx +0 -110
- package/src/components/View.tsx +0 -114
- package/src/componentsConnectors/connectBox.test.tsx +0 -226
- package/src/componentsConnectors/connectBox.tsx +0 -70
- package/src/componentsConnectors/connectDocument.test.tsx +0 -108
- package/src/componentsConnectors/connectDocument.tsx +0 -64
- package/src/componentsConnectors/connectHeader.tsx +0 -21
- package/src/componentsConnectors/connectMetaTitle.test.tsx +0 -40
- package/src/componentsConnectors/connectMetaTitle.tsx +0 -8
- package/src/componentsConnectors/connectOption.tsx +0 -222
- package/src/componentsConnectors/connectPagination.tsx +0 -102
- package/src/componentsConnectors/connectPreview.tsx +0 -5
- package/src/componentsConnectors/connectProgress.tsx +0 -59
- package/src/componentsConnectors/connectRootOption.tsx +0 -95
- package/src/componentsConnectors/connectSection.tsx +0 -79
- package/src/componentsConnectors/connectSummary.tsx +0 -21
- package/src/componentsConnectors/connectSummaryItem.tsx +0 -102
- package/src/componentsConnectors/connectTermsheet.tsx +0 -359
- package/src/componentsConnectors/connectVariable.tsx +0 -191
- package/src/componentsConnectors/connectWizardWrapper.tsx +0 -30
- package/src/componentsConnectors/connector/componentConnector.tsx +0 -219
- package/src/componentsConnectors/library.ts +0 -35
- package/src/config.test.ts +0 -63
- package/src/config.ts +0 -11
- package/src/constants/emailValidation.ts +0 -2
- package/src/constants/phoneValidation.ts +0 -4
- package/src/definitions/path.join.d.ts +0 -4
- package/src/helpers/outputsParsing.ts +0 -412
- package/src/helpers/preloadTheme.ts +0 -17
- package/src/helpers/scriptsLoader.ts +0 -20
- package/src/hooks/usePrevious.ts +0 -9
- package/src/libs/ConditionsInitiator.ts +0 -164
- package/src/libs/ConditionsRunner/DataPopulator.ts +0 -266
- package/src/libs/ConditionsRunner.ts +0 -454
- package/src/libs/DocumentsOutputs.ts +0 -171
- package/src/libs/Eval/EvalBase.ts +0 -116
- package/src/libs/Eval/EvalFunctions.ts +0 -724
- package/src/libs/Eval/NumbersToLetters.ts +0 -185
- package/src/libs/EvalVariable.ts +0 -265
- package/src/libs/EventsTracking.ts +0 -250
- package/src/libs/InputsInitiator.ts +0 -136
- package/src/libs/NumAuto.test.ts +0 -55
- package/src/libs/NumAuto.ts +0 -56
- package/src/libs/OvcConverter.ts +0 -285
- package/src/libs/PathReader.ts +0 -272
- package/src/libs/SectionValidity.test.ts +0 -146
- package/src/libs/SectionValidity.ts +0 -110
- package/src/libs/SmartScriptStore.ts +0 -492
- package/src/misc/test_model.ts +0 -14603
- package/src/misc/test_models/connectDocumen.testmodel.json +0 -178
- package/src/misc/test_models/setDefaults.testmodel.json +0 -279
- package/src/misc/test_models/testmodel.json +0 -1
- package/src/polyfills/index.ts +0 -5
- package/src/polyfills/objectValues.ts +0 -4
- package/src/polyfills/prepend.ts +0 -31
- package/src/polyfills/stringRepeat.ts +0 -44
- package/src/redux/actions/app.test.ts +0 -123
- package/src/redux/actions/app.ts +0 -249
- package/src/redux/actions/conditions.test.ts +0 -84
- package/src/redux/actions/conditions.ts +0 -135
- package/src/redux/actions/inputs.test.ts +0 -85
- package/src/redux/actions/inputs.ts +0 -111
- package/src/redux/actions/library.ts +0 -23
- package/src/redux/actions/mandatories.ts +0 -98
- package/src/redux/actions/references.test.ts +0 -48
- package/src/redux/actions/references.ts +0 -37
- package/src/redux/actions/sagas/data.test.ts +0 -11
- package/src/redux/actions/sagas/data.ts +0 -18
- package/src/redux/actions/sagas/model.test.ts +0 -14
- package/src/redux/actions/sagas/model.ts +0 -48
- package/src/redux/actions/sagas/user.ts +0 -25
- package/src/redux/actions/smartscript.ts +0 -55
- package/src/redux/actions/user.test.ts +0 -18
- package/src/redux/actions/user.ts +0 -41
- package/src/redux/constants/app.ts +0 -36
- package/src/redux/constants/conditions.ts +0 -25
- package/src/redux/constants/inputs.ts +0 -15
- package/src/redux/constants/mandatories.ts +0 -11
- package/src/redux/constants/references.ts +0 -7
- package/src/redux/constants/sagas/data.ts +0 -1
- package/src/redux/constants/sagas/model.ts +0 -2
- package/src/redux/constants/sagas/user.ts +0 -2
- package/src/redux/constants/smartscript.ts +0 -9
- package/src/redux/constants/user.ts +0 -6
- package/src/redux/listeners/subscriber.test.ts +0 -45
- package/src/redux/listeners/subscriber.ts +0 -29
- package/src/redux/middlewares/conditionsWatcherMiddleware.test.ts +0 -370
- package/src/redux/middlewares/conditionsWatcherMiddleware.ts +0 -321
- package/src/redux/middlewares/evaluationsWatcherMiddleware.test.ts +0 -323
- package/src/redux/middlewares/evaluationsWatcherMiddleware.ts +0 -250
- package/src/redux/middlewares/mandatoriesWatcherMiddleware.ts +0 -473
- package/src/redux/middlewares/multiplesActionsMiddleware.test.ts +0 -230
- package/src/redux/middlewares/multiplesActionsMiddleware.ts +0 -121
- package/src/redux/middlewares/paginationWatcherMiddleware.ts +0 -251
- package/src/redux/middlewares/pluginsHookMiddleware.ts +0 -24
- package/src/redux/middlewares/prefillerWatcherMiddleware.test.ts +0 -118
- package/src/redux/middlewares/prefillerWatcherMiddleware.ts +0 -462
- package/src/redux/middlewares/smartscriptMiddleware.ts +0 -228
- package/src/redux/middlewares/thirdpartyScriptsMiddleware.ts +0 -41
- package/src/redux/reducers/app/customizations/initCustomizationAutoDefault.ts +0 -16
- package/src/redux/reducers/app/customizations/initCustomizationMeta.ts +0 -16
- package/src/redux/reducers/app/instance/initInstance.ts +0 -29
- package/src/redux/reducers/app/instance/setDataStatus.ts +0 -16
- package/src/redux/reducers/app/instance/updateInstance.ts +0 -30
- package/src/redux/reducers/app/instance/updateInstancePaid.ts +0 -20
- package/src/redux/reducers/app/instance.test.ts +0 -106
- package/src/redux/reducers/app/meta/fetchModelFailed.ts +0 -11
- package/src/redux/reducers/app/meta/fetchModelNonBlocking.ts +0 -11
- package/src/redux/reducers/app/meta/fetchModelSucceeded.ts +0 -11
- package/src/redux/reducers/app/meta/fetchModelUnhealthy.ts +0 -18
- package/src/redux/reducers/app/meta/fetchModelUserLocked.ts +0 -11
- package/src/redux/reducers/app/meta/initMeta.ts +0 -22
- package/src/redux/reducers/app/meta/setModelUuid.ts +0 -17
- package/src/redux/reducers/app/meta.test.ts +0 -90
- package/src/redux/reducers/app/pagination/goNextPage.ts +0 -69
- package/src/redux/reducers/app/pagination/goPage.ts +0 -81
- package/src/redux/reducers/app/pagination/goPreviousPage.ts +0 -60
- package/src/redux/reducers/app/pagination/initPagination.ts +0 -46
- package/src/redux/reducers/app/pagination/updateAvailableAppStates.ts +0 -77
- package/src/redux/reducers/app/pagination.test.ts +0 -363
- package/src/redux/reducers/app/wizard/updateAvailableSections.ts +0 -40
- package/src/redux/reducers/app/wizard.test.ts +0 -84
- package/src/redux/reducers/app.test.ts +0 -336
- package/src/redux/reducers/app.ts +0 -150
- package/src/redux/reducers/conditions/addMultipleOccurency.test.ts +0 -131
- package/src/redux/reducers/conditions/addMultipleOccurency.ts +0 -155
- package/src/redux/reducers/conditions/deleteMultipleOccurency.test.ts +0 -95
- package/src/redux/reducers/conditions/deleteMultipleOccurency.ts +0 -141
- package/src/redux/reducers/conditions/initConditions.ts +0 -18
- package/src/redux/reducers/conditions/updateDocumentConditions.test.ts +0 -47
- package/src/redux/reducers/conditions/updateDocumentConditions.ts +0 -21
- package/src/redux/reducers/conditions/updateOptionConditions.ts +0 -24
- package/src/redux/reducers/conditions/updateOptionValidatorCondition.test.ts +0 -50
- package/src/redux/reducers/conditions/updateOptionValidatorCondition.ts +0 -28
- package/src/redux/reducers/conditions/updatePrefillerConditions.ts +0 -29
- package/src/redux/reducers/conditions/updateSectionConditions.ts +0 -28
- package/src/redux/reducers/conditions/updateVariableConditions.ts +0 -25
- package/src/redux/reducers/conditions/updateVariableValidatorCondition.test.ts +0 -50
- package/src/redux/reducers/conditions/updateVariableValidatorCondition.ts +0 -28
- package/src/redux/reducers/conditions.test.ts +0 -241
- package/src/redux/reducers/conditions.ts +0 -68
- package/src/redux/reducers/inputs/addMultipleOccurency.test.ts +0 -117
- package/src/redux/reducers/inputs/addMultipleOccurency.ts +0 -50
- package/src/redux/reducers/inputs/deleteMultipleOccurency.test.ts +0 -70
- package/src/redux/reducers/inputs/deleteMultipleOccurency.ts +0 -50
- package/src/redux/reducers/inputs/initOption.ts +0 -16
- package/src/redux/reducers/inputs/initVariable.ts +0 -16
- package/src/redux/reducers/inputs/updateOptionInput.ts +0 -24
- package/src/redux/reducers/inputs/updateVariableInput.ts +0 -24
- package/src/redux/reducers/inputs.test.ts +0 -221
- package/src/redux/reducers/inputs.ts +0 -51
- package/src/redux/reducers/mandatories/addMultipleOccurency.ts +0 -52
- package/src/redux/reducers/mandatories/deleteMultipleOccurency.ts +0 -55
- package/src/redux/reducers/mandatories/initMandatoryOption.ts +0 -17
- package/src/redux/reducers/mandatories/initMandatoryVariable.ts +0 -17
- package/src/redux/reducers/mandatories/setMandatoryIgnore.ts +0 -17
- package/src/redux/reducers/mandatories/setMandatoryOption.ts +0 -25
- package/src/redux/reducers/mandatories/setMandatorySection.ts +0 -20
- package/src/redux/reducers/mandatories/setMandatoryVariable.ts +0 -24
- package/src/redux/reducers/mandatories.ts +0 -56
- package/src/redux/reducers/references/initReferences.ts +0 -37
- package/src/redux/reducers/references/updateOptionMeta.ts +0 -73
- package/src/redux/reducers/references/updateVariableMeta.ts +0 -72
- package/src/redux/reducers/references.ts +0 -59
- package/src/redux/reducers/smartscript/enableSmartScript.ts +0 -13
- package/src/redux/reducers/smartscript/initSmartScriptTriggers.ts +0 -14
- package/src/redux/reducers/smartscript/updateSmartscriptOptionHidden.ts +0 -30
- package/src/redux/reducers/smartscript/updateSmartscriptVariableHidden.ts +0 -30
- package/src/redux/reducers/smartscript.ts +0 -47
- package/src/redux/reducers/user/initUser.ts +0 -15
- package/src/redux/reducers/user/setUserStatus.ts +0 -13
- package/src/redux/reducers/user/setUserValidToken.ts +0 -13
- package/src/redux/reducers/user.test.ts +0 -51
- package/src/redux/reducers/user.ts +0 -40
- package/src/redux/routerHistore.test.ts +0 -19
- package/src/redux/routerHistory.ts +0 -26
- package/src/redux/sagas/fetchModel.test.ts +0 -76
- package/src/redux/sagas/fetchModel.ts +0 -683
- package/src/redux/sagas/homogeneousRadioInputsSaga.ts +0 -42
- package/src/redux/sagas/initInputs.ts +0 -110
- package/src/redux/sagas/runner.test.ts +0 -12
- package/src/redux/sagas/runner.ts +0 -26
- package/src/redux/sagas/saveData.test.ts +0 -125
- package/src/redux/sagas/saveData.ts +0 -55
- package/src/redux/sagas/setDefaults.test.ts +0 -100
- package/src/redux/sagas/setDefaults.ts +0 -167
- package/src/redux/sagas/setUserEmail.ts +0 -175
- package/src/redux/selectors/app.test.ts +0 -162
- package/src/redux/selectors/app.ts +0 -331
- package/src/redux/selectors/conditions.test.ts +0 -92
- package/src/redux/selectors/conditions.ts +0 -293
- package/src/redux/selectors/inputs.test.ts +0 -72
- package/src/redux/selectors/inputs.ts +0 -76
- package/src/redux/selectors/library.ts +0 -17
- package/src/redux/selectors/mandatories.ts +0 -83
- package/src/redux/selectors/references.test.ts +0 -660
- package/src/redux/selectors/references.ts +0 -413
- package/src/redux/selectors/selectors.test.ts +0 -21
- package/src/redux/selectors/selectors.ts +0 -87
- package/src/redux/selectors/smartscript.ts +0 -30
- package/src/redux/selectors/user.test.ts +0 -39
- package/src/redux/selectors/user.ts +0 -45
- package/src/redux/store.test.ts +0 -22
- package/src/redux/store.ts +0 -100
- package/src/service/api.manager.ts +0 -261
- package/src/service/auth.service.ts +0 -5
- package/src/service/pardot.service.ts +0 -10
- package/src/tests-misc/plugins/jestTestPlugin/after.tsx +0 -5
- package/src/tests-misc/plugins/jestTestPlugin/before.tsx +0 -11
- package/src/tests-misc/plugins/jestTestPlugin/index.ts +0 -11
- package/src/tests-misc/plugins/jestTestPlugin/title.tsx +0 -8
- package/src/tests-misc/themes/jestTestTheme/components/EmailComponent.tsx +0 -5
- package/src/tests-misc/themes/jestTestTheme/components/TermsheetComponent.tsx +0 -5
- package/src/tests-misc/themes/jestTestTheme/components/WizardComponent.tsx +0 -5
- package/src/tests-misc/themes/jestTestTheme/faltyIndex.ts +0 -3
- package/src/tests-misc/themes/jestTestTheme/faltyIndexLoader.ts +0 -1
- package/src/tests-misc/themes/jestTestTheme/index.ts +0 -13
- package/src/types/Actions.type.ts +0 -612
- package/src/types/Components.type.ts +0 -181
- package/src/types/State.type.ts +0 -323
- package/src/types/Termsheet.type.ts +0 -28
- package/src/types/api.type.ts +0 -37
- package/src/types/config.type.ts +0 -55
- package/src/types/env.type.ts +0 -5
- package/src/types/getActions.type.ts +0 -3
- package/src/types/getConnectors.type.ts +0 -5
- package/src/types/getSelectors.type.ts +0 -3
- package/src/wizard-params.ts +0 -56
- package/tsconfig.json +0 -43
|
@@ -15,12 +15,10 @@ export function* initInputsDecorator(action) {
|
|
|
15
15
|
yield put(initConditionsAction(conditions));
|
|
16
16
|
const optionsIds = Object.keys(inputs.options);
|
|
17
17
|
for (let i = 0; i < optionsIds.length; i += 1) {
|
|
18
|
-
|
|
18
|
+
const optionId = parseInt(optionsIds[i], 10);
|
|
19
19
|
let values = inputs.options[optionId];
|
|
20
20
|
yield put(initOptionAction(optionId, values));
|
|
21
|
-
const {
|
|
22
|
-
const { type } = meta2;
|
|
23
|
-
let { mandatory } = meta2;
|
|
21
|
+
const { type, mandatory } = references.options[optionId].meta;
|
|
24
22
|
let sendOptionAction = true;
|
|
25
23
|
if (["checkbox", "radio"].includes(type)) {
|
|
26
24
|
if (type === "radio") {
|
|
@@ -39,10 +37,11 @@ export function* initInputsDecorator(action) {
|
|
|
39
37
|
}
|
|
40
38
|
}
|
|
41
39
|
}
|
|
42
|
-
mandatory = references.options[parentId].meta
|
|
43
|
-
|
|
40
|
+
const { mandatory: parentMandatory } = references.options[parentId].meta;
|
|
41
|
+
if (parentMandatory && sendOptionAction)
|
|
42
|
+
yield put(initMandatoryOptionAction(parentId, values));
|
|
44
43
|
}
|
|
45
|
-
if (mandatory
|
|
44
|
+
else if (mandatory && sendOptionAction) {
|
|
46
45
|
yield put(initMandatoryOptionAction(optionId, values));
|
|
47
46
|
}
|
|
48
47
|
}
|
|
@@ -10,6 +10,8 @@ function* saveDataDecorator(action) {
|
|
|
10
10
|
yield put(setDataStatus("saving"));
|
|
11
11
|
const permalink = selectPermalink();
|
|
12
12
|
const uniqid = selectInstanceUniqid();
|
|
13
|
+
if (uniqid === undefined)
|
|
14
|
+
throw new Error(`Cannot save data, uniqid is not defined`);
|
|
13
15
|
const response = yield call(fetch, ...updateInstanceArguments(permalink, uniqid, OvcConverter.convertToOvc(selectInputs()), action.confirmAnswer ? 0 : 1, action.additionalProperties));
|
|
14
16
|
const responseData = yield call([response, "json"]);
|
|
15
17
|
if (action.redirect === true) {
|
|
@@ -7,9 +7,9 @@ export const selectIsFirstPage = createSelector((state) => state.app.pagination.
|
|
|
7
7
|
export const selectIsLastPage = createSelector((state) => state.app.pagination.isLastPage, (state) => state.app.pagination.isLastPage.toString());
|
|
8
8
|
export const selectIsLastWizardPage = createSelector((state) => state.app.pagination.currentPage ===
|
|
9
9
|
state.app.wizard.availableSections.length, (state) => state.app.pagination.currentPage.toString());
|
|
10
|
-
export const selectGreatestPage = createSelector((state) => state.app.pagination.greatestPage, (state) => state.app.pagination.greatestPage);
|
|
11
|
-
export const selectCurrentSectionId = createSelector((state) => state.app.wizard.currentSectionId, (state) => state.app.wizard.currentSectionId);
|
|
12
|
-
export const selectAvailableSections = createSelector((state) => [...state.app.wizard.availableSections], (state) => state.app.wizard.availableSections.reduce((p, c) => p
|
|
10
|
+
export const selectGreatestPage = createSelector((state) => state.app.pagination.greatestPage, (state) => state.app.pagination.greatestPage.toString());
|
|
11
|
+
export const selectCurrentSectionId = createSelector((state) => state.app.wizard.currentSectionId, (state) => state.app.wizard.currentSectionId.toString());
|
|
12
|
+
export const selectAvailableSections = createSelector((state) => [...state.app.wizard.availableSections], (state) => state.app.wizard.availableSections.reduce((p, c) => `${p}.${c}`, "0"));
|
|
13
13
|
export const selectAvailableOptions = createSelector((state, document = "main") => {
|
|
14
14
|
let availableOptions = [];
|
|
15
15
|
const { availableSections } = state.app.wizard;
|
|
@@ -28,18 +28,15 @@ export const selectAvailableOptions = createSelector((state, document = "main")
|
|
|
28
28
|
export const selectMultipleOccurencies = createSelector((state) => {
|
|
29
29
|
const multipleOptionsOccurencies = {};
|
|
30
30
|
const availableOptions = selectAvailableOptions("main");
|
|
31
|
-
if (availableOptions === undefined)
|
|
32
|
-
return {};
|
|
33
31
|
availableOptions.forEach((optionId) => {
|
|
34
32
|
var _a;
|
|
35
33
|
const ref = state.references.options[optionId];
|
|
36
34
|
if (((_a = ref.meta.multiple) === null || _a === void 0 ? void 0 : _a.enabled) === true) {
|
|
37
|
-
multipleOptionsOccurencies[optionId] =
|
|
38
|
-
selectOptionInput(optionId).length;
|
|
35
|
+
multipleOptionsOccurencies[optionId] = selectOptionInput(optionId).length;
|
|
39
36
|
}
|
|
40
37
|
});
|
|
41
38
|
return multipleOptionsOccurencies;
|
|
42
|
-
},
|
|
39
|
+
}, false);
|
|
43
40
|
export const selectOutputsIds = createSelector((state, document) => {
|
|
44
41
|
const availableOptions = selectAvailableOptions(document);
|
|
45
42
|
if (availableOptions === undefined)
|
|
@@ -56,8 +53,8 @@ export const selectOutputsIds = createSelector((state, document) => {
|
|
|
56
53
|
});
|
|
57
54
|
export const selectPermalink = createSelector((state) => state.app.meta.permalink, (state) => state.app.meta.permalink);
|
|
58
55
|
export const selectDocumentTitle = createSelector((state) => state.app.meta.title, (state) => state.app.meta.title);
|
|
59
|
-
export const selectDocumentId = createSelector((state) => state.app.meta.id, (state) => state.app.meta.id);
|
|
60
|
-
export const selectDocumentModelVersion = createSelector((state) => state.app.meta.modelVersion, (state) => state.app.meta.modelVersion);
|
|
56
|
+
export const selectDocumentId = createSelector((state) => state.app.meta.id, (state) => state.app.meta.id.toString());
|
|
57
|
+
export const selectDocumentModelVersion = createSelector((state) => state.app.meta.modelVersion, (state) => state.app.meta.modelVersion.toString());
|
|
61
58
|
export const selectDocumentProductType = createSelector((state) => state.app.meta.productType, (state) => state.app.meta.productType);
|
|
62
59
|
export const selectMeta = createSelector((state) => state.app.meta, (state) => state.app.meta.title);
|
|
63
60
|
export const selectMetaFetchStatus = createSelector((state) => state.app.meta.fetchStatus, (state) => state.app.meta.fetchStatus);
|
|
@@ -65,10 +62,10 @@ export const selectPrefix = createSelector((state) => (!state.app.meta ? undefin
|
|
|
65
62
|
export const selectInstanceUniqid = createSelector((state) => !state.app.instance ? undefined : state.app.instance.uniqid, (state) => (!state.app.instance ? "0" : state.app.instance.uniqid));
|
|
66
63
|
export const selectInstanceCompanyId = createSelector((state) => !state.app.instance ? undefined : state.app.instance.companyId, (state) => !state.app.instance || !state.app.instance.companyId
|
|
67
64
|
? "0"
|
|
68
|
-
: state.app.instance.companyId);
|
|
65
|
+
: state.app.instance.companyId.toString());
|
|
69
66
|
export const selectInstanceEmployeeId = createSelector((state) => !state.app.instance ? undefined : state.app.instance.employeeId, (state) => !state.app.instance || !state.app.instance.employeeId
|
|
70
67
|
? "0"
|
|
71
|
-
: state.app.instance.employeeId);
|
|
68
|
+
: state.app.instance.employeeId.toString());
|
|
72
69
|
export const selectDataStatus = createSelector((state) => !state.app.instance ? "unsaved" : state.app.instance.dataStatus, (state) => !state.app.instance ? "0" : state.app.instance.dataStatus);
|
|
73
70
|
export const selectInstanceIsPaid = createSelector((state) => !!(state.app.instance && state.app.instance.isPaid), (state) => state.app.instance && state.app.instance.isPaid
|
|
74
71
|
? state.app.instance.isPaid.toString()
|
|
@@ -91,9 +88,7 @@ export const isStepAvailable = createSelector((state, steps) => {
|
|
|
91
88
|
}, (state, steps) => state.app.instance && state.app.instance.steps && steps
|
|
92
89
|
? `${state.app.instance.steps.toString()}-${steps.toString()}`
|
|
93
90
|
: "0");
|
|
94
|
-
export const selectCustomizationMeta = createSelector((state) => state.app.customization.meta, (state) => state.app.customization.meta
|
|
95
|
-
export const selectCustomizationAutoDefaultType = createSelector((state) => state.app.customization.disableAutoDefault, (state) => state.app.customization.disableAutoDefault !== undefined
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
export const selectModelUuid = createSelector((state) => state.app.meta.modelUuid, (state) => state.app.meta.modelUuid !== undefined ? "1" : Math.random());
|
|
99
|
-
export const CompletelyUnusedSelector = createSelector((state) => state.app.meta.modelUuid, (state) => state.app.meta.modelUuid !== undefined ? "1" : Math.random());
|
|
91
|
+
export const selectCustomizationMeta = createSelector((state) => state.app.customization.meta, (state) => (!state.app.customization.meta ? "1" : false));
|
|
92
|
+
export const selectCustomizationAutoDefaultType = createSelector((state) => state.app.customization.disableAutoDefault, (state) => state.app.customization.disableAutoDefault !== undefined ? "1" : false);
|
|
93
|
+
export const selectModelUuid = createSelector((state) => state.app.meta.modelUuid, (state) => (state.app.meta.modelUuid !== undefined ? "1" : false));
|
|
94
|
+
export const CompletelyUnusedSelector = createSelector((state) => state.app.meta.modelUuid, (state) => (state.app.meta.modelUuid !== undefined ? "1" : false));
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
declare class SelectorsCache {
|
|
2
|
+
private cache;
|
|
3
|
+
private idsCounter;
|
|
4
|
+
create(): {
|
|
5
|
+
has: (key: string) => boolean;
|
|
6
|
+
get: (key: string) => any;
|
|
7
|
+
add: (key: string, value: any) => void;
|
|
8
|
+
remove: (key: string) => void;
|
|
9
|
+
};
|
|
10
|
+
private get;
|
|
11
|
+
private add;
|
|
12
|
+
private remove;
|
|
13
|
+
private has;
|
|
14
|
+
clear(): void;
|
|
15
|
+
}
|
|
16
|
+
declare const _default: SelectorsCache;
|
|
17
|
+
export default _default;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
class SelectorsCache {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.cache = {};
|
|
4
|
+
this.idsCounter = 0;
|
|
5
|
+
}
|
|
6
|
+
create() {
|
|
7
|
+
this.idsCounter += 1;
|
|
8
|
+
const cacheId = this.idsCounter.toString();
|
|
9
|
+
this.cache[cacheId] = {};
|
|
10
|
+
return {
|
|
11
|
+
has: (key) => this.has(cacheId, key),
|
|
12
|
+
get: (key) => this.get(cacheId, key),
|
|
13
|
+
add: (key, value) => this.add(cacheId, key, value),
|
|
14
|
+
remove: (key) => this.remove(cacheId, key),
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
get(cacheId, key) {
|
|
18
|
+
return this.cache[cacheId][key];
|
|
19
|
+
}
|
|
20
|
+
add(cacheId, key, value) {
|
|
21
|
+
this.cache[cacheId][key] = value;
|
|
22
|
+
}
|
|
23
|
+
remove(cacheId, key) {
|
|
24
|
+
delete this.cache[cacheId][key];
|
|
25
|
+
}
|
|
26
|
+
has(cacheId, key) {
|
|
27
|
+
return Object.prototype.hasOwnProperty.call(this.cache[cacheId], key);
|
|
28
|
+
}
|
|
29
|
+
clear() {
|
|
30
|
+
Object.keys(this.cache).forEach((cacheId) => {
|
|
31
|
+
this.cache[cacheId] = {};
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export default new SelectorsCache();
|
|
@@ -9,7 +9,7 @@ const optionConditionValueSelector = createSelector((state, id, index) => {
|
|
|
9
9
|
: state.conditions.options[id];
|
|
10
10
|
}, (state, id, index) => {
|
|
11
11
|
if (typeof state.conditions.options[id] === "undefined")
|
|
12
|
-
return
|
|
12
|
+
return false;
|
|
13
13
|
return `${state.conditions.options[id].reduce((p, c) => p + (c ? "1" : "0"), "")}_${id}_${index}`;
|
|
14
14
|
});
|
|
15
15
|
export function selectOptionConditionValue(id, index) {
|
|
@@ -25,7 +25,7 @@ const variableConditionValueSelector = createSelector((state, id, index) => {
|
|
|
25
25
|
: state.conditions.variables[id];
|
|
26
26
|
}, (state, id, index) => {
|
|
27
27
|
if (typeof state.conditions.variables[id] === "undefined")
|
|
28
|
-
return
|
|
28
|
+
return false;
|
|
29
29
|
return `${state.conditions.variables[id].reduce((p, c) => p + (c ? "1" : "0"), "")}_${id}_${index}`;
|
|
30
30
|
});
|
|
31
31
|
export function selectVariableConditionValue(id, index) {
|
|
@@ -47,7 +47,7 @@ export const selectDocumentConditionValue = createSelector((state, name) => {
|
|
|
47
47
|
return state.conditions.documents[name];
|
|
48
48
|
}, (state, name) => {
|
|
49
49
|
if (typeof state.conditions.documents[name] === "undefined")
|
|
50
|
-
return
|
|
50
|
+
return false;
|
|
51
51
|
return state.conditions.documents[name] ? "true" : "false";
|
|
52
52
|
});
|
|
53
53
|
const prefillerConditionValueSelector = createSelector((state, id, index) => {
|
|
@@ -78,7 +78,7 @@ const optionValidatorConditionValueSelector = createSelector((state, id, index)
|
|
|
78
78
|
: state.conditions.validators.options[id];
|
|
79
79
|
}, (state, id, index) => {
|
|
80
80
|
if (typeof state.conditions.validators.options[id] === "undefined")
|
|
81
|
-
return
|
|
81
|
+
return false;
|
|
82
82
|
return `${state.conditions.validators.options[id].reduce((p, c) => p + (c ? "1" : "0"), "")}-${id.toString()}${index ? index.toString() : ""}`;
|
|
83
83
|
});
|
|
84
84
|
export function selectOptionValidatorConditionValue(id, index) {
|
|
@@ -94,7 +94,7 @@ const variableValidatorConditionValueSelector = createSelector((state, id, index
|
|
|
94
94
|
: state.conditions.validators.variables[id];
|
|
95
95
|
}, (state, id, index) => {
|
|
96
96
|
if (typeof state.conditions.validators.variables[id] === "undefined")
|
|
97
|
-
return
|
|
97
|
+
return false;
|
|
98
98
|
return `${state.conditions.validators.variables[id].reduce((p, c) => p + (c ? "1" : "0"), "")}-${id.toString()}${index ? index.toString() : ""}`;
|
|
99
99
|
});
|
|
100
100
|
export function selectVariableValidatorConditionValue(id, index) {
|
|
@@ -115,7 +115,7 @@ export const selectIsOptionDisplayed = createSelector((state, id, index) => {
|
|
|
115
115
|
...parentsConditions,
|
|
116
116
|
...parentsInputs,
|
|
117
117
|
].filter((c) => c !== true).length === 0);
|
|
118
|
-
},
|
|
118
|
+
}, false);
|
|
119
119
|
export const selectIsVariableDisplayed = createSelector((state, id, index) => {
|
|
120
120
|
const variableCondition = selectVariableConditionValue(id, index) !== false;
|
|
121
121
|
const variableParents = selectVariableParents(id);
|
|
@@ -129,4 +129,4 @@ export const selectIsVariableDisplayed = createSelector((state, id, index) => {
|
|
|
129
129
|
...parentsConditions,
|
|
130
130
|
...parentsInputs,
|
|
131
131
|
].filter((c) => c !== true).length === 0);
|
|
132
|
-
},
|
|
132
|
+
}, false);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createSelector } from "./selectors";
|
|
2
|
-
export const selectInputs = createSelector((state) => state.inputs,
|
|
2
|
+
export const selectInputs = createSelector((state) => state.inputs, false);
|
|
3
3
|
export const selectOptionInput = createSelector((state, id) => state.inputs.options[id], (state, id) => `${state.inputs.options[id].reduce((p, c) => p + (c ? "1" : "0"), "")}_${id.toString()}`);
|
|
4
4
|
export const selectOptionInputByIndex = createSelector((state, id, index) => {
|
|
5
5
|
if (state.inputs.options[id] === undefined)
|
|
@@ -7,14 +7,14 @@ export const selectOptionInputByIndex = createSelector((state, id, index) => {
|
|
|
7
7
|
return state.inputs.options[id][index];
|
|
8
8
|
}, (state, id, index) => state.inputs.options[id] !== undefined
|
|
9
9
|
? `${state.inputs.options[id].reduce((p, c) => p + (c ? "1" : "0"), "")}_${id.toString()}_${index}`
|
|
10
|
-
:
|
|
10
|
+
: false);
|
|
11
11
|
export const selectVariableInput = createSelector((state, id) => {
|
|
12
12
|
if (typeof state.inputs.variables[id] === "undefined")
|
|
13
13
|
return [""];
|
|
14
14
|
return state.inputs.variables[id];
|
|
15
15
|
}, (state, id) => {
|
|
16
16
|
if (typeof state.inputs.variables[id] === "undefined")
|
|
17
|
-
return
|
|
17
|
+
return false;
|
|
18
18
|
return `${state.inputs.variables[id].reduce((p, c) => `${p}-${c}`, "")}_${id.toString()}`;
|
|
19
19
|
});
|
|
20
20
|
export const selectVariableInputByIndex = createSelector((state, id, index) => state.inputs.variables[id][index], (state, id, index) => `${state.inputs.variables[id].reduce((p, c) => `${p}-${c}`, "")}_${id.toString()}_${index}`);
|
|
@@ -81,7 +81,7 @@ export declare const selectorsLibrary: {
|
|
|
81
81
|
selectDocumentId: () => number;
|
|
82
82
|
selectDocumentModelVersion: () => number;
|
|
83
83
|
selectDocumentProductType: () => string;
|
|
84
|
-
selectMeta: () => Readonly<import("
|
|
84
|
+
selectMeta: () => Readonly<import("../..").AppMetaType>;
|
|
85
85
|
selectMetaFetchStatus: () => Readonly<"failed" | "waiting" | "succeeded" | "unhealthy" | "userLocked" | "nonBlocking">;
|
|
86
86
|
selectPrefix: () => Readonly<string | undefined>;
|
|
87
87
|
selectInstanceUniqid: () => Readonly<string | undefined>;
|
|
@@ -91,7 +91,7 @@ export declare const selectorsLibrary: {
|
|
|
91
91
|
selectInstanceIsPaid: () => Readonly<boolean>;
|
|
92
92
|
selectInstanceSteps: () => Readonly<boolean>;
|
|
93
93
|
isStepAvailable: (steps: number[] | "*" | undefined) => Readonly<boolean>;
|
|
94
|
-
selectCustomizationMeta: () => Readonly<import("
|
|
94
|
+
selectCustomizationMeta: () => Readonly<import("../..").AppCustomizationMetaType | undefined>;
|
|
95
95
|
selectCustomizationAutoDefaultType: () => Readonly<boolean | undefined>;
|
|
96
96
|
selectModelUuid: () => Readonly<string | undefined>;
|
|
97
97
|
CompletelyUnusedSelector: () => Readonly<string | undefined>;
|
|
@@ -4,74 +4,74 @@ export const selectOutputReference = createSelector((state, id) => {
|
|
|
4
4
|
if (typeof state.references === "undefined")
|
|
5
5
|
return undefined;
|
|
6
6
|
return state.references.outputs[id];
|
|
7
|
-
}, (state, id) => (!state.references ?
|
|
7
|
+
}, (state, id) => (!state.references ? false : id.toString()));
|
|
8
8
|
export const selectBoxReference = createSelector((state, id) => {
|
|
9
9
|
if (state.references.boxes[id] === undefined)
|
|
10
10
|
throw new Error(`Box ${id} does not exist`);
|
|
11
11
|
return state.references.boxes[id];
|
|
12
|
-
},
|
|
12
|
+
}, false);
|
|
13
13
|
export const isOptionMultiple = createSelector((state, id) => {
|
|
14
14
|
var _a;
|
|
15
15
|
if (typeof state.references === "undefined")
|
|
16
16
|
return undefined;
|
|
17
17
|
return ((_a = state.references.options[id].meta.multiple) === null || _a === void 0 ? void 0 : _a.enabled) === true;
|
|
18
|
-
}, (state, id) => (!state.references ?
|
|
18
|
+
}, (state, id) => (!state.references ? false : id.toString()));
|
|
19
19
|
export const selectOptionReference = createSelector((state, id) => {
|
|
20
20
|
if (state.references.options[id] === undefined)
|
|
21
21
|
throw new Error(`Option ${id} does not exist`);
|
|
22
22
|
return state.references.options[id];
|
|
23
|
-
},
|
|
23
|
+
}, false);
|
|
24
24
|
export const selectOptionRelations = createSelector((state, id) => {
|
|
25
25
|
if (state.references.relations.options[id] === undefined)
|
|
26
26
|
throw new Error(`Option ${id} relations do not exist`);
|
|
27
27
|
return state.references.relations.options[id];
|
|
28
|
-
}, (state, id) => (!state.references ?
|
|
28
|
+
}, (state, id) => (!state.references ? false : id.toString()));
|
|
29
29
|
export const selectSectionRelations = createSelector((state, id) => {
|
|
30
30
|
if (state.references.relations.sections[id] === undefined)
|
|
31
31
|
throw new Error(`Section ${id} relations do not exist`);
|
|
32
32
|
return state.references.relations.sections[id];
|
|
33
|
-
}, (state, id) => (!state.references ?
|
|
33
|
+
}, (state, id) => (!state.references ? false : id.toString()));
|
|
34
34
|
export const selectOptionParents = createSelector((state, id) => {
|
|
35
35
|
if (state.references.relations.options[id].parents === undefined)
|
|
36
36
|
throw new Error(`Option ${id} parent relations are undefined`);
|
|
37
37
|
return state.references.relations.options[id].parents;
|
|
38
|
-
}, (state, id) => (!state.references ?
|
|
38
|
+
}, (state, id) => (!state.references ? false : id.toString()));
|
|
39
39
|
export const selectRadioSiblings = createSelector((state, id) => {
|
|
40
40
|
if (state.references.relations.options[id] === undefined)
|
|
41
41
|
throw new Error(`Option ${id} relations do not exist`);
|
|
42
42
|
const { radioSiblings } = state.references.relations.options[id];
|
|
43
43
|
return radioSiblings;
|
|
44
|
-
}, (state, id) => (!state.references ?
|
|
44
|
+
}, (state, id) => (!state.references ? false : id.toString()));
|
|
45
45
|
export const selectVariableReference = createSelector((state, id, noThrow = false) => {
|
|
46
46
|
if (state.references.variables[id] === undefined && noThrow === false)
|
|
47
47
|
throw new Error(`Variable ${id} does not exist`);
|
|
48
48
|
return state.references.variables[id];
|
|
49
|
-
},
|
|
49
|
+
}, false);
|
|
50
50
|
export const selectVariableRelations = createSelector((state, id) => {
|
|
51
51
|
if (state.references.relations.variables[id] === undefined)
|
|
52
52
|
throw new Error(`Variable ${id} relations do not exist`);
|
|
53
53
|
return state.references.relations.variables[id];
|
|
54
|
-
}, (state, id) => (!state.references ?
|
|
54
|
+
}, (state, id) => (!state.references ? false : id.toString()));
|
|
55
55
|
export const selectVariableParents = createSelector((state, id) => {
|
|
56
56
|
if (state.references.relations.variables[id] === undefined)
|
|
57
57
|
throw new Error(`Variable ${id} parents relations is undefined`);
|
|
58
58
|
return state.references.relations.variables[id].parents;
|
|
59
|
-
}, (state, id) => (!state.references ?
|
|
59
|
+
}, (state, id) => (!state.references ? false : id.toString()));
|
|
60
60
|
export const selectAllDocumentsReferences = createSelector((state) => {
|
|
61
61
|
if (state.references.documents === undefined)
|
|
62
62
|
throw new Error(`Documents references do not exist`);
|
|
63
63
|
return state.references.documents;
|
|
64
|
-
}, (state) => (!state.references ?
|
|
64
|
+
}, (state) => (!state.references ? false : "1"));
|
|
65
65
|
export const selectDocumentReference = createSelector((state, document) => {
|
|
66
66
|
if (state.references.documents === undefined)
|
|
67
67
|
throw new Error(`Documents references do not exist`);
|
|
68
68
|
return state.references.documents[document];
|
|
69
|
-
}, (state) => (!state.references ?
|
|
69
|
+
}, (state) => (!state.references ? false : "1"));
|
|
70
70
|
export const selectAllSectionsReferences = createSelector((state, document = "main") => {
|
|
71
71
|
if (typeof state.references === "undefined")
|
|
72
72
|
return undefined;
|
|
73
73
|
return state.references.sections[document];
|
|
74
|
-
}, (state, document = "main") => !state.references ?
|
|
74
|
+
}, (state, document = "main") => !state.references ? false : document);
|
|
75
75
|
export const selectSectionReference = createSelector((state, id, document = "main") => {
|
|
76
76
|
if (state.references.sections[document] === undefined)
|
|
77
77
|
throw new Error(`Document ${document} does not exist`);
|
|
@@ -79,43 +79,43 @@ export const selectSectionReference = createSelector((state, id, document = "mai
|
|
|
79
79
|
throw new Error(`Section ${id} does not exist in document ${document}`);
|
|
80
80
|
}
|
|
81
81
|
return state.references.sections[document][id];
|
|
82
|
-
}, (state, id, document = "main") => !state.references ?
|
|
82
|
+
}, (state, id, document = "main") => !state.references ? false : `${id}-${document}`);
|
|
83
83
|
export const selectSectionDefaults = createSelector((state, id) => {
|
|
84
84
|
if (typeof state.references === "undefined")
|
|
85
85
|
return undefined;
|
|
86
86
|
return state.references.defaults[id];
|
|
87
|
-
}, (state, id) => (!state.references ?
|
|
87
|
+
}, (state, id) => (!state.references ? false : id.toString()));
|
|
88
88
|
export const selectOptionConditionsObject = createSelector((state, id) => {
|
|
89
89
|
if (typeof state.references === "undefined")
|
|
90
90
|
return undefined;
|
|
91
91
|
return state.references.conditions.options[id];
|
|
92
|
-
}, (state, id) => (!state.references ?
|
|
92
|
+
}, (state, id) => (!state.references ? false : id.toString()));
|
|
93
93
|
export const selectVariableConditionsObject = createSelector((state, id) => {
|
|
94
94
|
if (typeof state.references === "undefined")
|
|
95
95
|
return undefined;
|
|
96
96
|
return state.references.conditions.variables[id];
|
|
97
|
-
}, (state, id) => (!state.references ?
|
|
97
|
+
}, (state, id) => (!state.references ? false : id.toString()));
|
|
98
98
|
export const selectDocumentConditionsObject = createSelector((state, name) => {
|
|
99
99
|
if (typeof state.references === "undefined")
|
|
100
100
|
return undefined;
|
|
101
101
|
return state.references.conditions.documents[name];
|
|
102
|
-
}, (state, name) => (!state.references ?
|
|
103
|
-
export const selectSectionConditionsObject = createSelector((state, id, document = "main") => state.references.conditions.sections[document][id], (state, id, document = "main") => !state.references ?
|
|
102
|
+
}, (state, name) => (!state.references ? false : name));
|
|
103
|
+
export const selectSectionConditionsObject = createSelector((state, id, document = "main") => state.references.conditions.sections[document][id], (state, id, document = "main") => !state.references ? false : `${id}-${document}`);
|
|
104
104
|
export const selectPrefillerConditionsObject = createSelector((state, id) => {
|
|
105
105
|
if (typeof state.references === "undefined")
|
|
106
106
|
return undefined;
|
|
107
107
|
return state.references.conditions.prefillers[id];
|
|
108
|
-
}, (state, id) => (!state.references ?
|
|
108
|
+
}, (state, id) => (!state.references ? false : id.toString()));
|
|
109
109
|
export const selectOptionValidatorConditionsObject = createSelector((state, id) => {
|
|
110
110
|
if (typeof state.references === "undefined")
|
|
111
111
|
return undefined;
|
|
112
112
|
return state.references.conditions.validators.options[id];
|
|
113
|
-
}, (state, id) => (!state.references ?
|
|
113
|
+
}, (state, id) => (!state.references ? false : id.toString()));
|
|
114
114
|
export const selectVariableValidatorConditionsObject = createSelector((state, id) => {
|
|
115
115
|
if (typeof state.references === "undefined")
|
|
116
116
|
return undefined;
|
|
117
117
|
return state.references.conditions.validators.variables[id];
|
|
118
|
-
}, (state, id) => (!state.references ?
|
|
118
|
+
}, (state, id) => (!state.references ? false : id.toString()));
|
|
119
119
|
export const areVariablesSiblings = createSelector((state, ...args) => {
|
|
120
120
|
if (typeof state.references === "undefined")
|
|
121
121
|
return undefined;
|
|
@@ -159,7 +159,7 @@ export const selectOptionParentSection = createSelector((state, id) => {
|
|
|
159
159
|
return sections[i].id;
|
|
160
160
|
}
|
|
161
161
|
throw new Error(`Cannot find parent section for option ${id} (Root option id: ${rootId})`);
|
|
162
|
-
}, (state, id) => (!state.references ?
|
|
162
|
+
}, (state, id) => (!state.references ? false : id.toString()));
|
|
163
163
|
export const selectVariableParentSection = createSelector((state, id) => {
|
|
164
164
|
const { parents } = state.references.relations.variables[id];
|
|
165
165
|
if (parents === undefined)
|
|
@@ -171,9 +171,9 @@ export const selectVariableParentSection = createSelector((state, id) => {
|
|
|
171
171
|
return sections[i].id;
|
|
172
172
|
}
|
|
173
173
|
throw new Error(`Cannot find parent section for variable ${id} (Root option id: ${rootId})`);
|
|
174
|
-
}, (state, id) => (!state.references ?
|
|
174
|
+
}, (state, id) => (!state.references ? false : id.toString()));
|
|
175
175
|
export const selectUserEmailSectionVariableIds = createSelector((state, sectionId) => {
|
|
176
176
|
const { variables } = state.references;
|
|
177
177
|
const userEmailVariables = Object.keys(variables).filter((variableId) => variables[variableId].type === "user_email");
|
|
178
178
|
return userEmailVariables.filter((variableId) => selectVariableParentSection(parseInt(variableId, 10)) === sectionId);
|
|
179
|
-
}, (state, sectionId) => !state.references ?
|
|
179
|
+
}, (state, sectionId) => !state.references ? false : sectionId.toString());
|
|
@@ -3,6 +3,6 @@ import { StateType } from "../../types/State.type";
|
|
|
3
3
|
export declare type SelectorFunction = (state: StateType, ...args: any[]) => any;
|
|
4
4
|
export declare type SelectorArguments<F extends SelectorFunction> = F extends (state: StateType, ...a: infer A) => any ? A : never;
|
|
5
5
|
export declare type SelectorReturn<F extends SelectorFunction> = F extends (state: StateType, ...a: any[]) => infer R ? R : never;
|
|
6
|
-
export declare type
|
|
7
|
-
export declare function createSelector<T extends SelectorFunction, R = SelectorReturn<T>>(selector: T,
|
|
6
|
+
export declare type SelectorCacheKeyFunction<T extends SelectorFunction> = (state: StateType, ...a: SelectorArguments<T>) => string | false;
|
|
7
|
+
export declare function createSelector<T extends SelectorFunction, R = SelectorReturn<T>>(selector: T, cacheKey?: SelectorCacheKeyFunction<T> | false): (...args: SelectorArguments<T>) => Readonly<R>;
|
|
8
8
|
export declare const selectorsMiddleware: (mpi: MiddlewareAPI) => (next: Dispatch) => (action: Action) => Action<any>;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { DANGEROUS_DESTORY_STORE } from "../constants/app";
|
|
2
|
+
import selectorsCache from "./cache";
|
|
1
3
|
let SelectorsStateTrack = -1;
|
|
2
4
|
let globalMPI;
|
|
3
|
-
export function createSelector(selector,
|
|
4
|
-
const cache =
|
|
5
|
+
export function createSelector(selector, cacheKey) {
|
|
6
|
+
const cache = selectorsCache.create();
|
|
5
7
|
return (...args) => {
|
|
6
8
|
let state;
|
|
7
9
|
if (SelectorsStateTrack === -1)
|
|
@@ -12,17 +14,26 @@ export function createSelector(selector, equalityFn) {
|
|
|
12
14
|
catch (e) {
|
|
13
15
|
throw new Error("You may not use selectors while the reducer is executing. (Try sagas or middlewares)");
|
|
14
16
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
: [SelectorsStateTrack, ...args].reduce((v, c) => v + c);
|
|
18
|
-
if (!Object.prototype.hasOwnProperty.call(cache, currentKey)) {
|
|
19
|
-
cache[currentKey] = selector(state, ...args);
|
|
17
|
+
if (cacheKey === false) {
|
|
18
|
+
return selector(state, ...args);
|
|
20
19
|
}
|
|
21
|
-
|
|
20
|
+
const currentKey = typeof cacheKey === "function"
|
|
21
|
+
? cacheKey(state, ...args)
|
|
22
|
+
: [SelectorsStateTrack, ...args].reduce((v, c) => v + c, "");
|
|
23
|
+
if (!currentKey)
|
|
24
|
+
return selector(state, ...args);
|
|
25
|
+
if (!cache.has(currentKey)) {
|
|
26
|
+
const value = selector(state, ...args);
|
|
27
|
+
cache.add(currentKey, value);
|
|
28
|
+
}
|
|
29
|
+
return cache.get(currentKey);
|
|
22
30
|
};
|
|
23
31
|
}
|
|
24
32
|
export const selectorsMiddleware = (mpi) => (next) => (action) => {
|
|
25
33
|
const result = next(action);
|
|
34
|
+
if (action.type === DANGEROUS_DESTORY_STORE) {
|
|
35
|
+
selectorsCache.clear();
|
|
36
|
+
}
|
|
26
37
|
globalMPI = mpi;
|
|
27
38
|
SelectorsStateTrack += 1;
|
|
28
39
|
return result;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import configureMockStore from
|
|
2
|
-
import { createSelector, selectorsMiddleware } from
|
|
3
|
-
describe(
|
|
4
|
-
it(
|
|
1
|
+
import configureMockStore from "redux-mock-store";
|
|
2
|
+
import { createSelector, selectorsMiddleware } from "./selectors";
|
|
3
|
+
describe("Selectors Test", () => {
|
|
4
|
+
it("Middleware", () => {
|
|
5
5
|
const mockStore = configureMockStore([selectorsMiddleware]);
|
|
6
6
|
const store = mockStore({});
|
|
7
7
|
const myFakeFunction = jest.fn();
|
|
8
|
-
const selector = createSelector(myFakeFunction);
|
|
9
|
-
store.dispatch({ type:
|
|
8
|
+
const selector = createSelector(myFakeFunction, () => "myFakeCacheKey");
|
|
9
|
+
store.dispatch({ type: "FAKE_ACTION" });
|
|
10
10
|
selector();
|
|
11
11
|
selector();
|
|
12
12
|
selector();
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { createSelector } from "./selectors";
|
|
2
|
-
export const selectCurrentUserLevel = createSelector((state) => (state.user ? state.user.level : undefined), (state) => (state.user ? state.user.level :
|
|
3
|
-
export const selectUserStatus = createSelector((state) => (state.user ? state.user.status : "unauthenticated"), (state) => (state.user ? state.user.status :
|
|
4
|
-
export const selectUserValidToken = createSelector((state) => { var _a; return ((_a = state.user) === null || _a === void 0 ? void 0 : _a.validToken) || false; }, (state) => state.user ? (state.user.validToken || false).toString() :
|
|
2
|
+
export const selectCurrentUserLevel = createSelector((state) => (state.user ? state.user.level : undefined), (state) => (state.user ? state.user.level : false));
|
|
3
|
+
export const selectUserStatus = createSelector((state) => (state.user ? state.user.status : "unauthenticated"), (state) => (state.user ? state.user.status : false));
|
|
4
|
+
export const selectUserValidToken = createSelector((state) => { var _a; return ((_a = state.user) === null || _a === void 0 ? void 0 : _a.validToken) || false; }, (state) => state.user ? (state.user.validToken || false).toString() : false);
|
|
5
5
|
export const selectUserEmail = createSelector((state) => state.user && state.user.email && state.user.email.length > 0
|
|
6
6
|
? state.user.email
|
|
7
7
|
: "", (state) => state.user && state.user.email && state.user.email.length > 0
|
|
8
8
|
? state.user.email
|
|
9
|
-
:
|
|
9
|
+
: false);
|
|
10
10
|
export const isLevelAccessibleForUser = createSelector((state, level) => {
|
|
11
11
|
const currentUserLevel = state.user ? state.user.level : "GUEST";
|
|
12
12
|
const levelEnum = ["GUEST", "USER", "MANAGER", "ADMIN", "SUPER"];
|
|
13
13
|
return levelEnum.indexOf(level) <= levelEnum.indexOf(currentUserLevel);
|
|
14
|
-
}, (state, level) => state.user ? `${state.user.level}-${level}` :
|
|
14
|
+
}, (state, level) => state.user ? `${state.user.level}-${level}` : false);
|
package/dist/redux/store.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Store, EmptyObject, AnyAction } from "redux";
|
|
2
2
|
import { StateType } from "../types/State.type";
|
|
3
3
|
export declare const createAppStore: (historyType?: "browser" | "memory") => void;
|
|
4
|
-
export declare const getStore: () => Store<EmptyObject & StateType, AnyAction> & {
|
|
4
|
+
export declare const getStore: (throwIfDoesNotExist?: boolean) => Store<EmptyObject & StateType, AnyAction> & {
|
|
5
5
|
dispatch: unknown;
|
|
6
6
|
};
|
package/dist/redux/store.js
CHANGED
|
@@ -23,11 +23,13 @@ import mandatoriesWatcherMiddleware from "./middlewares/mandatoriesWatcherMiddle
|
|
|
23
23
|
import { smartscriptReducer } from "./reducers/smartscript";
|
|
24
24
|
import smartscriptMiddleware from "./middlewares/smartscriptMiddleware";
|
|
25
25
|
import thirdPartyScriptsMiddleware from "./middlewares/thirdpartyScriptsMiddleware";
|
|
26
|
+
import { pluginsStoreReducer } from "./reducers/pluginsStore";
|
|
27
|
+
import { DANGEROUS_DESTORY_STORE } from "./constants/app";
|
|
26
28
|
let store;
|
|
27
29
|
let history = null;
|
|
28
30
|
export const createAppStore = (historyType = "browser") => {
|
|
29
31
|
history = createHistory(historyType);
|
|
30
|
-
const
|
|
32
|
+
const wizardxReducers = combineReducers({
|
|
31
33
|
router: connectRouter(history),
|
|
32
34
|
app: appReducer,
|
|
33
35
|
user: userReducer,
|
|
@@ -36,18 +38,24 @@ export const createAppStore = (historyType = "browser") => {
|
|
|
36
38
|
mandatories: mandatoriesReducer,
|
|
37
39
|
conditions: conditionsReducer,
|
|
38
40
|
smartscript: smartscriptReducer,
|
|
41
|
+
pluginsStore: pluginsStoreReducer,
|
|
39
42
|
});
|
|
43
|
+
const rootReducer = (state, action) => {
|
|
44
|
+
if (action.type === DANGEROUS_DESTORY_STORE)
|
|
45
|
+
return wizardxReducers(undefined, action);
|
|
46
|
+
return wizardxReducers(state, action);
|
|
47
|
+
};
|
|
40
48
|
const sagaMiddleware = createSagaMiddleware();
|
|
41
49
|
const appliedMiddlewares = applyMiddleware(pluginsHookMiddleware, routerMiddleware(history), sagaMiddleware, paginationWatcherMiddleware, selectorsMiddleware, conditionsWatcherMiddleware, prefillerWatcherMiddleware, evaluationsWatcherMiddleware, multiplesActionsMiddleware, mandatoriesWatcherMiddleware, smartscriptMiddleware, thirdPartyScriptsMiddleware);
|
|
42
50
|
const middlewares = Globals.appEnv !== "production"
|
|
43
51
|
? composeWithDevTools(appliedMiddlewares)
|
|
44
52
|
: appliedMiddlewares;
|
|
45
|
-
store = createStore(
|
|
53
|
+
store = createStore(rootReducer, middlewares);
|
|
46
54
|
sagasRunner(sagaMiddleware);
|
|
47
55
|
subscribeListeners(store);
|
|
48
56
|
};
|
|
49
|
-
export const getStore = () => {
|
|
50
|
-
if (store === undefined)
|
|
57
|
+
export const getStore = (throwIfDoesNotExist = true) => {
|
|
58
|
+
if (store === undefined && throwIfDoesNotExist)
|
|
51
59
|
throw new Error("Store not yet created");
|
|
52
60
|
return store;
|
|
53
61
|
};
|
|
@@ -6,9 +6,4 @@ export declare const getFetchModelArguments: (permalink: string, uniqidParam: st
|
|
|
6
6
|
export declare const getCreateInstanceArguments: (permalink: string, searchParams: string, modelVersion: string) => (RequestInfo | RequestInit)[];
|
|
7
7
|
export declare const getClientConfigArguments: (permalink?: string | undefined, uniqid?: string | undefined) => [RequestInfo, RequestInit?];
|
|
8
8
|
export declare const getUserProfileArguments: () => [RequestInfo, RequestInit?];
|
|
9
|
-
export declare const updateInstanceArguments: (permalink: string, uniqid: string | undefined, ovc: OvcType, draft: number, additionalProperties?: Record<string, string | number> | undefined) =>
|
|
10
|
-
method: string;
|
|
11
|
-
credentials: string;
|
|
12
|
-
headers: Record<string, string>;
|
|
13
|
-
body: string;
|
|
14
|
-
})[];
|
|
9
|
+
export declare const updateInstanceArguments: (permalink: string, uniqid: string | undefined, ovc: OvcType, draft: number, additionalProperties?: Record<string, string | number> | undefined) => [RequestInfo, RequestInit?];
|