@legalplace/wizardx-core 2.6.4 → 2.7.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/CHANGELOG.md +35 -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/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 +44 -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 +9 -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 +11 -11
- 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
|
@@ -1,492 +0,0 @@
|
|
|
1
|
-
import { Action } from "redux";
|
|
2
|
-
import {
|
|
3
|
-
updateOptionAction,
|
|
4
|
-
updateVariableAction,
|
|
5
|
-
} from "../redux/actions/inputs";
|
|
6
|
-
import {
|
|
7
|
-
updateOptionMetaAction,
|
|
8
|
-
updateVariableMetaAction,
|
|
9
|
-
} from "../redux/actions/references";
|
|
10
|
-
import {
|
|
11
|
-
updateSmartscriptOptionHiddenAction,
|
|
12
|
-
updateSmartscriptVariableHiddenAction,
|
|
13
|
-
} from "../redux/actions/smartscript";
|
|
14
|
-
import { ActionsType } from "../types/Actions.type";
|
|
15
|
-
import { StateType } from "../types/State.type";
|
|
16
|
-
|
|
17
|
-
export type CallbackType = () => void;
|
|
18
|
-
|
|
19
|
-
export class SmartScriptStore {
|
|
20
|
-
static hooks: {
|
|
21
|
-
variables: Record<string, CallbackType[]>;
|
|
22
|
-
options: Record<string, CallbackType[]>;
|
|
23
|
-
init?: CallbackType[];
|
|
24
|
-
load?: CallbackType[];
|
|
25
|
-
} = {
|
|
26
|
-
options: {},
|
|
27
|
-
variables: {},
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
static actionsQueue: Action[] = [];
|
|
31
|
-
|
|
32
|
-
static inputs: StateType.Inputs = {
|
|
33
|
-
options: {},
|
|
34
|
-
variables: {},
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Return actions queue and flush it
|
|
39
|
-
*/
|
|
40
|
-
static grabActions() {
|
|
41
|
-
const actions = [...SmartScriptStore.actionsQueue];
|
|
42
|
-
SmartScriptStore.actionsQueue = [];
|
|
43
|
-
return actions;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
static get triggers() {
|
|
47
|
-
const triggers: StateType.SmartScript["triggers"] = {
|
|
48
|
-
options: [],
|
|
49
|
-
variables: [],
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
Object.keys(SmartScriptStore.hooks.options).forEach((strId) => {
|
|
53
|
-
const id = parseInt(strId, 10);
|
|
54
|
-
triggers.options.push(id);
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
Object.keys(SmartScriptStore.hooks.variables).forEach((strId) => {
|
|
58
|
-
const id = parseInt(strId, 10);
|
|
59
|
-
triggers.variables.push(id);
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
return triggers;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Return option's input
|
|
67
|
-
* @param id
|
|
68
|
-
* @param index
|
|
69
|
-
*/
|
|
70
|
-
static getOptionInput(id: number, index = 0) {
|
|
71
|
-
return SmartScriptStore.inputs.options[id][index];
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Return all option inputs
|
|
76
|
-
* @param id
|
|
77
|
-
*/
|
|
78
|
-
static getOptionAllInput(id: number) {
|
|
79
|
-
return SmartScriptStore.inputs.options[id];
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Return variable's input
|
|
84
|
-
* @param id
|
|
85
|
-
* @param index
|
|
86
|
-
*/
|
|
87
|
-
static getVariableInput(id: number, index = 0) {
|
|
88
|
-
const value = SmartScriptStore.inputs.variables[id][index];
|
|
89
|
-
|
|
90
|
-
// If value is a string but contains a number we parse it
|
|
91
|
-
if (
|
|
92
|
-
typeof value === "string" &&
|
|
93
|
-
// eslint-disable-next-line no-restricted-globals
|
|
94
|
-
!isNaN(value.replace(",", ".") as any) &&
|
|
95
|
-
value.trim().length > 0
|
|
96
|
-
) {
|
|
97
|
-
const result =
|
|
98
|
-
value.replace(",", ".").indexOf(".") > -1
|
|
99
|
-
? parseFloat(value)
|
|
100
|
-
: parseInt(value, 10);
|
|
101
|
-
return result;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
return value;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Return all variable inputs
|
|
109
|
-
* @param id
|
|
110
|
-
*/
|
|
111
|
-
static getVariableAllInput(id: number) {
|
|
112
|
-
let values: (string | number)[] = [];
|
|
113
|
-
|
|
114
|
-
if (Array.isArray(SmartScriptStore.inputs.variables[id])) {
|
|
115
|
-
values = SmartScriptStore.inputs.variables[id].map((value) => {
|
|
116
|
-
// If value is a string but contains a number we parse it
|
|
117
|
-
if (
|
|
118
|
-
typeof value === "string" &&
|
|
119
|
-
// eslint-disable-next-line no-restricted-globals
|
|
120
|
-
!isNaN(value.replace(",", ".") as any) &&
|
|
121
|
-
value.trim().length > 0
|
|
122
|
-
) {
|
|
123
|
-
const result =
|
|
124
|
-
value.replace(",", ".").indexOf(".") > -1
|
|
125
|
-
? parseFloat(value)
|
|
126
|
-
: parseInt(value, 10);
|
|
127
|
-
return result;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
return value;
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
return values;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* Adds callback to trigger change
|
|
139
|
-
* @param inputType
|
|
140
|
-
* @param id
|
|
141
|
-
* @param callback
|
|
142
|
-
*/
|
|
143
|
-
static onChange(
|
|
144
|
-
inputType: "option" | "variable",
|
|
145
|
-
id: number | number[],
|
|
146
|
-
callback: CallbackType
|
|
147
|
-
) {
|
|
148
|
-
const hooks =
|
|
149
|
-
SmartScriptStore.hooks[inputType === "option" ? "options" : "variables"];
|
|
150
|
-
|
|
151
|
-
if (Array.isArray(id)) {
|
|
152
|
-
id.forEach((_id) => {
|
|
153
|
-
hooks[_id] = [...(hooks[_id] || []), callback];
|
|
154
|
-
});
|
|
155
|
-
} else {
|
|
156
|
-
hooks[id] = [...(hooks[id] || []), callback];
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* Add on init listener
|
|
162
|
-
* @param callback
|
|
163
|
-
*/
|
|
164
|
-
static onInit(callback: CallbackType) {
|
|
165
|
-
if (typeof SmartScriptStore.hooks.init === "undefined")
|
|
166
|
-
SmartScriptStore.hooks.init = [];
|
|
167
|
-
SmartScriptStore.hooks.init.push(callback);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* Executes onInit callbacks
|
|
172
|
-
* @param callback
|
|
173
|
-
*/
|
|
174
|
-
static execOnInit() {
|
|
175
|
-
try {
|
|
176
|
-
if (Array.isArray(SmartScriptStore.hooks.init)) {
|
|
177
|
-
SmartScriptStore.hooks.init.forEach((_cb) => {
|
|
178
|
-
_cb();
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
} catch (e) {
|
|
182
|
-
// eslint-disable-next-line no-console
|
|
183
|
-
console.error("SmartScript (onInit) error: ", e.message);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* Add on load listener
|
|
189
|
-
* @param callback
|
|
190
|
-
*/
|
|
191
|
-
static onLoad(callback: CallbackType) {
|
|
192
|
-
try {
|
|
193
|
-
if (typeof SmartScriptStore.hooks.load === "undefined")
|
|
194
|
-
SmartScriptStore.hooks.load = [];
|
|
195
|
-
SmartScriptStore.hooks.load.push(callback);
|
|
196
|
-
} catch (e) {
|
|
197
|
-
// eslint-disable-next-line no-console
|
|
198
|
-
console.error("SmartScript (onLoad) error: ", e.message);
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
/**
|
|
203
|
-
* Executes onLoad callbacks
|
|
204
|
-
* @param callback
|
|
205
|
-
*/
|
|
206
|
-
static execOnLoad() {
|
|
207
|
-
if (Array.isArray(SmartScriptStore.hooks.load)) {
|
|
208
|
-
SmartScriptStore.hooks.load.forEach((_cb) => {
|
|
209
|
-
_cb();
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
/**
|
|
215
|
-
* Option's change listener
|
|
216
|
-
* @param id
|
|
217
|
-
* @param callback
|
|
218
|
-
*/
|
|
219
|
-
static onOptionChange(id: number | number[], callback: CallbackType) {
|
|
220
|
-
return SmartScriptStore.onChange("option", id, callback);
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
/**
|
|
224
|
-
* Variable's change listener
|
|
225
|
-
* @param id
|
|
226
|
-
* @param callback
|
|
227
|
-
*/
|
|
228
|
-
static onVariableChange(id: number | number[], callback: CallbackType) {
|
|
229
|
-
return SmartScriptStore.onChange("variable", id, callback);
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
static updateVariableInput = (
|
|
233
|
-
id: number,
|
|
234
|
-
value: string | number,
|
|
235
|
-
index = 0
|
|
236
|
-
) => {
|
|
237
|
-
// Making sure variable exists
|
|
238
|
-
if (
|
|
239
|
-
!Object.prototype.hasOwnProperty.call(
|
|
240
|
-
SmartScriptStore.inputs.variables,
|
|
241
|
-
id
|
|
242
|
-
)
|
|
243
|
-
) {
|
|
244
|
-
// eslint-disable-next-line no-console
|
|
245
|
-
console.error(
|
|
246
|
-
`SmartScript error: trying to update meta for undefined variable ${id}`
|
|
247
|
-
);
|
|
248
|
-
return;
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
if (SmartScriptStore.inputs.variables[id]?.[index] !== value) {
|
|
252
|
-
if (typeof SmartScriptStore.inputs.variables[id] === "undefined")
|
|
253
|
-
SmartScriptStore.inputs.variables[id] = [];
|
|
254
|
-
SmartScriptStore.inputs.variables[id][index] = value;
|
|
255
|
-
SmartScriptStore.actionsQueue.push(
|
|
256
|
-
updateVariableAction(id, value, index)
|
|
257
|
-
);
|
|
258
|
-
}
|
|
259
|
-
};
|
|
260
|
-
|
|
261
|
-
static updateOptionInput = (id: number, value: boolean, index = 0) => {
|
|
262
|
-
// Making sure option exists
|
|
263
|
-
if (
|
|
264
|
-
!Object.prototype.hasOwnProperty.call(SmartScriptStore.inputs.options, id)
|
|
265
|
-
) {
|
|
266
|
-
// eslint-disable-next-line no-console
|
|
267
|
-
console.error(
|
|
268
|
-
`SmartScript error: trying to update input for undefined option ${id}`
|
|
269
|
-
);
|
|
270
|
-
return;
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
if (SmartScriptStore.inputs?.options[id]?.[index] !== value) {
|
|
274
|
-
if (typeof SmartScriptStore.inputs.options[id] === "undefined")
|
|
275
|
-
SmartScriptStore.inputs.options[id] = [];
|
|
276
|
-
SmartScriptStore.inputs.options[id][index] = value;
|
|
277
|
-
SmartScriptStore.actionsQueue.push(updateOptionAction(id, value, index));
|
|
278
|
-
}
|
|
279
|
-
};
|
|
280
|
-
|
|
281
|
-
/**
|
|
282
|
-
* Updates variable's meta
|
|
283
|
-
* @param id
|
|
284
|
-
* @param _meta
|
|
285
|
-
*/
|
|
286
|
-
static updateVariableMeta = (
|
|
287
|
-
id: number,
|
|
288
|
-
_meta: ActionsType.References.updateVariableMeta["meta"]
|
|
289
|
-
) => {
|
|
290
|
-
// Making sure variable exists
|
|
291
|
-
if (
|
|
292
|
-
!Object.prototype.hasOwnProperty.call(
|
|
293
|
-
SmartScriptStore.inputs.variables,
|
|
294
|
-
id
|
|
295
|
-
)
|
|
296
|
-
) {
|
|
297
|
-
// eslint-disable-next-line no-console
|
|
298
|
-
console.error(
|
|
299
|
-
`SmartScript error: trying to update meta for undefined variable ${id}`
|
|
300
|
-
);
|
|
301
|
-
return;
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
const meta = { ..._meta };
|
|
305
|
-
|
|
306
|
-
// Deleting all banned meta params
|
|
307
|
-
// @ts-expect-error: Meta should not have banned prop
|
|
308
|
-
if (typeof meta.id !== "undefined") delete meta.id;
|
|
309
|
-
// @ts-expect-error: Meta should not have banned prop
|
|
310
|
-
if (typeof meta.type !== "undefined") delete meta.type;
|
|
311
|
-
// @ts-expect-error: Meta should not have banned prop
|
|
312
|
-
if (typeof meta.conditions !== "undefined") delete meta.conditions;
|
|
313
|
-
// @ts-expect-error: Meta should not have banned prop
|
|
314
|
-
if (typeof meta.prefillings !== "undefined") delete meta.prefillings;
|
|
315
|
-
// @ts-expect-error: Meta should not have banned prop
|
|
316
|
-
if (typeof meta.validator?.conditions !== "undefined")
|
|
317
|
-
// @ts-expect-error: Meta should not have banned prop
|
|
318
|
-
delete meta.validator.conditions;
|
|
319
|
-
|
|
320
|
-
SmartScriptStore.actionsQueue.push(updateVariableMetaAction(id, meta));
|
|
321
|
-
};
|
|
322
|
-
|
|
323
|
-
/**
|
|
324
|
-
* Updates option's meta
|
|
325
|
-
* @param id
|
|
326
|
-
* @param _meta
|
|
327
|
-
*/
|
|
328
|
-
static updateOptionMeta = (
|
|
329
|
-
id: number,
|
|
330
|
-
_meta: ActionsType.References.updateOptionMeta["meta"]
|
|
331
|
-
) => {
|
|
332
|
-
// Making sure option exists
|
|
333
|
-
if (
|
|
334
|
-
!Object.prototype.hasOwnProperty.call(SmartScriptStore.inputs.options, id)
|
|
335
|
-
) {
|
|
336
|
-
// eslint-disable-next-line no-console
|
|
337
|
-
console.error(
|
|
338
|
-
`SmartScript error: trying to update meta for undefined option ${id}`
|
|
339
|
-
);
|
|
340
|
-
return;
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
const meta = { ..._meta };
|
|
344
|
-
|
|
345
|
-
// Deleting all banned meta params
|
|
346
|
-
// @ts-expect-error: Meta should not have banned prop
|
|
347
|
-
if (typeof meta.id !== "undefined") delete meta.id;
|
|
348
|
-
// @ts-expect-error: Meta should not have banned prop
|
|
349
|
-
if (typeof meta.type !== "undefined") delete meta.type;
|
|
350
|
-
// @ts-expect-error: Meta should not have banned prop
|
|
351
|
-
if (typeof meta.conditions !== "undefined") delete meta.conditions;
|
|
352
|
-
// @ts-expect-error: Meta should not have banned prop
|
|
353
|
-
if (typeof meta.repeatOption !== "undefined") delete meta.repeatOption;
|
|
354
|
-
// @ts-expect-error: Meta should not have banned prop
|
|
355
|
-
if (typeof meta.validator?.conditions !== "undefined")
|
|
356
|
-
// @ts-expect-error: Meta should not have banned prop
|
|
357
|
-
delete meta.validator.conditions;
|
|
358
|
-
// @ts-expect-error: Meta should not have banned prop
|
|
359
|
-
if (typeof meta.multiple?.enabled !== "undefined")
|
|
360
|
-
// @ts-expect-error: Meta should not have banned prop
|
|
361
|
-
delete meta.multiple.enabled;
|
|
362
|
-
|
|
363
|
-
SmartScriptStore.actionsQueue.push(updateOptionMetaAction(id, meta));
|
|
364
|
-
};
|
|
365
|
-
|
|
366
|
-
/**
|
|
367
|
-
* Hides option
|
|
368
|
-
* @param id
|
|
369
|
-
* @param index Will hide all options if not given
|
|
370
|
-
*/
|
|
371
|
-
static hideOption = (id: number, index?: number) => {
|
|
372
|
-
// Making sure option exists
|
|
373
|
-
if (
|
|
374
|
-
!Object.prototype.hasOwnProperty.call(SmartScriptStore.inputs.options, id)
|
|
375
|
-
) {
|
|
376
|
-
// eslint-disable-next-line no-console
|
|
377
|
-
console.error(`SmartScript error: trying to hide undefined option ${id}`);
|
|
378
|
-
return;
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
if (typeof index === "undefined") {
|
|
382
|
-
SmartScriptStore.updateOptionMeta(id, { hidden: true });
|
|
383
|
-
SmartScriptStore.inputs.options[id].forEach((_, _index) => {
|
|
384
|
-
SmartScriptStore.actionsQueue.push(
|
|
385
|
-
updateSmartscriptOptionHiddenAction(id, _index, true)
|
|
386
|
-
);
|
|
387
|
-
});
|
|
388
|
-
} else {
|
|
389
|
-
SmartScriptStore.actionsQueue.push(
|
|
390
|
-
updateSmartscriptOptionHiddenAction(id, index, true)
|
|
391
|
-
);
|
|
392
|
-
}
|
|
393
|
-
};
|
|
394
|
-
|
|
395
|
-
/**
|
|
396
|
-
* Displays option
|
|
397
|
-
* @param id
|
|
398
|
-
* @param index Will display all options if not given
|
|
399
|
-
*/
|
|
400
|
-
static displayOption = (id: number, index?: number) => {
|
|
401
|
-
// Making sure option exists
|
|
402
|
-
if (
|
|
403
|
-
!Object.prototype.hasOwnProperty.call(SmartScriptStore.inputs.options, id)
|
|
404
|
-
) {
|
|
405
|
-
// eslint-disable-next-line no-console
|
|
406
|
-
console.error(
|
|
407
|
-
`SmartScript error: trying to display undefined option ${id}`
|
|
408
|
-
);
|
|
409
|
-
return;
|
|
410
|
-
}
|
|
411
|
-
if (typeof index === "undefined") {
|
|
412
|
-
SmartScriptStore.updateOptionMeta(id, { hidden: false });
|
|
413
|
-
SmartScriptStore.inputs.options[id].forEach((_, _index) => {
|
|
414
|
-
SmartScriptStore.actionsQueue.push(
|
|
415
|
-
updateSmartscriptOptionHiddenAction(id, _index, false)
|
|
416
|
-
);
|
|
417
|
-
});
|
|
418
|
-
} else {
|
|
419
|
-
SmartScriptStore.actionsQueue.push(
|
|
420
|
-
updateSmartscriptOptionHiddenAction(id, index, false)
|
|
421
|
-
);
|
|
422
|
-
}
|
|
423
|
-
};
|
|
424
|
-
|
|
425
|
-
/**
|
|
426
|
-
* Hides variable
|
|
427
|
-
* @param id
|
|
428
|
-
* @param index Will hide all variables if not given
|
|
429
|
-
*/
|
|
430
|
-
static hideVariable = (id: number, index?: number) => {
|
|
431
|
-
// Making sure variable exists
|
|
432
|
-
if (
|
|
433
|
-
!Object.prototype.hasOwnProperty.call(
|
|
434
|
-
SmartScriptStore.inputs.variables,
|
|
435
|
-
id
|
|
436
|
-
)
|
|
437
|
-
) {
|
|
438
|
-
// eslint-disable-next-line no-console
|
|
439
|
-
console.error(
|
|
440
|
-
`SmartScript error: trying to hide undefined variable ${id}`
|
|
441
|
-
);
|
|
442
|
-
return;
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
if (typeof index === "undefined") {
|
|
446
|
-
SmartScriptStore.updateVariableMeta(id, { hidden: true });
|
|
447
|
-
SmartScriptStore.inputs.variables[id].forEach((_, _index) => {
|
|
448
|
-
SmartScriptStore.actionsQueue.push(
|
|
449
|
-
updateSmartscriptVariableHiddenAction(id, _index, true)
|
|
450
|
-
);
|
|
451
|
-
});
|
|
452
|
-
} else {
|
|
453
|
-
SmartScriptStore.actionsQueue.push(
|
|
454
|
-
updateSmartscriptVariableHiddenAction(id, index, true)
|
|
455
|
-
);
|
|
456
|
-
}
|
|
457
|
-
};
|
|
458
|
-
|
|
459
|
-
/**
|
|
460
|
-
* Displays variable
|
|
461
|
-
* @param id
|
|
462
|
-
* @param index Will display all variables if not given
|
|
463
|
-
*/
|
|
464
|
-
static displayVariable = (id: number, index?: number) => {
|
|
465
|
-
// Making sure variable exists
|
|
466
|
-
if (
|
|
467
|
-
!Object.prototype.hasOwnProperty.call(
|
|
468
|
-
SmartScriptStore.inputs.variables,
|
|
469
|
-
id
|
|
470
|
-
)
|
|
471
|
-
) {
|
|
472
|
-
// eslint-disable-next-line no-console
|
|
473
|
-
console.error(
|
|
474
|
-
`SmartScript error: trying to display undefined variable ${id}`
|
|
475
|
-
);
|
|
476
|
-
return;
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
if (typeof index === "undefined") {
|
|
480
|
-
SmartScriptStore.updateVariableMeta(id, { hidden: false });
|
|
481
|
-
SmartScriptStore.inputs.variables[id].forEach((_, _index) => {
|
|
482
|
-
SmartScriptStore.actionsQueue.push(
|
|
483
|
-
updateSmartscriptVariableHiddenAction(id, _index, false)
|
|
484
|
-
);
|
|
485
|
-
});
|
|
486
|
-
} else {
|
|
487
|
-
SmartScriptStore.actionsQueue.push(
|
|
488
|
-
updateSmartscriptVariableHiddenAction(id, index, false)
|
|
489
|
-
);
|
|
490
|
-
}
|
|
491
|
-
};
|
|
492
|
-
}
|