@legalplace/wizardx-core 2.6.3 → 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.
Files changed (357) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/dist/App.js +13 -4
  3. package/dist/PluginLoader.d.ts +3 -1
  4. package/dist/PluginLoader.js +12 -0
  5. package/dist/ThemeLoader.d.ts +2 -2
  6. package/dist/componentsConnectors/connectBox.d.ts +3 -1
  7. package/dist/componentsConnectors/connectDocument.d.ts +3 -1
  8. package/dist/componentsConnectors/connectHeader.d.ts +3 -1
  9. package/dist/componentsConnectors/connectMetaTitle.d.ts +3 -1
  10. package/dist/componentsConnectors/connectOption.d.ts +6 -2
  11. package/dist/componentsConnectors/connectOption.js +1 -1
  12. package/dist/componentsConnectors/connectPagination.d.ts +3 -1
  13. package/dist/componentsConnectors/connectPreview.d.ts +3 -1
  14. package/dist/componentsConnectors/connectProgress.d.ts +3 -1
  15. package/dist/componentsConnectors/connectRootOption.d.ts +3 -1
  16. package/dist/componentsConnectors/connectSection.d.ts +3 -1
  17. package/dist/componentsConnectors/connectSection.js +7 -10
  18. package/dist/componentsConnectors/connectSummary.d.ts +3 -1
  19. package/dist/componentsConnectors/connectSummaryItem.d.ts +3 -1
  20. package/dist/componentsConnectors/connectVariable.d.ts +6 -2
  21. package/dist/componentsConnectors/connectVariable.js +1 -1
  22. package/dist/componentsConnectors/connectWizardWrapper.d.ts +3 -1
  23. package/dist/componentsConnectors/connector/componentConnector.d.ts +5 -1
  24. package/dist/componentsConnectors/connector/componentConnector.js +44 -4
  25. package/dist/componentsConnectors/connector/index.d.ts +1 -0
  26. package/dist/componentsConnectors/connector/index.js +1 -0
  27. package/dist/componentsConnectors/index.d.ts +17 -0
  28. package/dist/componentsConnectors/index.js +17 -0
  29. package/dist/componentsConnectors/library.d.ts +43 -15
  30. package/dist/constants/phoneValidation.d.ts +0 -1
  31. package/dist/constants/phoneValidation.js +0 -1
  32. package/dist/helpers/apiEndpoint.d.ts +1 -0
  33. package/dist/helpers/apiEndpoint.js +4 -0
  34. package/dist/helpers/index.d.ts +4 -0
  35. package/dist/helpers/index.js +4 -0
  36. package/dist/helpers/propsEqualityCheck.d.ts +1 -0
  37. package/dist/helpers/propsEqualityCheck.js +9 -0
  38. package/dist/hooks/index.d.ts +4 -0
  39. package/dist/hooks/index.js +4 -0
  40. package/dist/hooks/useActions.d.ts +2 -0
  41. package/dist/hooks/useActions.js +4 -0
  42. package/dist/hooks/useDispatch.d.ts +1 -0
  43. package/dist/hooks/useDispatch.js +4 -0
  44. package/dist/hooks/useSelectors.d.ts +2 -0
  45. package/dist/hooks/useSelectors.js +4 -0
  46. package/dist/index.d.ts +13 -0
  47. package/dist/index.js +13 -0
  48. package/dist/libs/EventsTracking.d.ts +0 -1
  49. package/dist/libs/EventsTracking.js +0 -18
  50. package/dist/libs/PathReader.d.ts +10 -6
  51. package/dist/libs/PathReader.js +47 -28
  52. package/dist/libs/index.d.ts +5 -0
  53. package/dist/libs/index.js +5 -0
  54. package/dist/redux/actions/index.d.ts +9 -0
  55. package/dist/redux/actions/index.js +9 -0
  56. package/dist/redux/actions/library.d.ts +59 -63
  57. package/dist/redux/actions/sagas/index.d.ts +3 -0
  58. package/dist/redux/actions/sagas/index.js +3 -0
  59. package/dist/redux/actions/sagas/model.d.ts +1 -5
  60. package/dist/redux/constants/app.d.ts +2 -0
  61. package/dist/redux/constants/app.js +2 -0
  62. package/dist/redux/constants/index.d.ts +8 -0
  63. package/dist/redux/constants/index.js +8 -0
  64. package/dist/redux/constants/sagas/index.d.ts +3 -0
  65. package/dist/redux/constants/sagas/index.js +3 -0
  66. package/dist/redux/index.d.ts +5 -0
  67. package/dist/redux/index.js +5 -0
  68. package/dist/redux/middlewares/conditionsWatcherMiddleware.js +11 -5
  69. package/dist/redux/middlewares/conditionsWatcherMiddleware.test.js +120 -113
  70. package/dist/redux/middlewares/paginationWatcherMiddleware.js +2 -2
  71. package/dist/redux/middlewares/smartscriptMiddleware.js +8 -0
  72. package/dist/redux/reducers/pluginsStore.d.ts +3 -0
  73. package/dist/redux/reducers/pluginsStore.js +12 -0
  74. package/dist/redux/routerHistory.js +2 -2
  75. package/dist/redux/sagas/fetchModel.js +22 -6
  76. package/dist/redux/sagas/initInputs.js +6 -7
  77. package/dist/redux/sagas/saveData.js +3 -46
  78. package/dist/redux/sagas/setUserEmail.js +1 -28
  79. package/dist/redux/selectors/app.js +13 -18
  80. package/dist/redux/selectors/cache.d.ts +17 -0
  81. package/dist/redux/selectors/cache.js +35 -0
  82. package/dist/redux/selectors/conditions.js +7 -7
  83. package/dist/redux/selectors/index.d.ts +8 -0
  84. package/dist/redux/selectors/index.js +8 -0
  85. package/dist/redux/selectors/inputs.js +3 -3
  86. package/dist/redux/selectors/library.d.ts +2 -2
  87. package/dist/redux/selectors/references.js +26 -26
  88. package/dist/redux/selectors/selectors.d.ts +2 -2
  89. package/dist/redux/selectors/selectors.js +19 -8
  90. package/dist/redux/selectors/selectors.test.js +6 -6
  91. package/dist/redux/selectors/user.js +5 -5
  92. package/dist/redux/store.d.ts +1 -1
  93. package/dist/redux/store.js +12 -4
  94. package/dist/service/api.manager.d.ts +1 -6
  95. package/dist/service/index.d.ts +3 -0
  96. package/dist/service/index.js +3 -0
  97. package/dist/types/PluginConfig.type.d.ts +57 -0
  98. package/dist/types/PluginConfig.type.js +1 -0
  99. package/dist/types/State.type.d.ts +6 -0
  100. package/dist/types/config.type.d.ts +3 -1
  101. package/dist/types/index.d.ts +11 -0
  102. package/dist/types/index.js +11 -0
  103. package/package.json +11 -12
  104. package/.depcheckrc +0 -1
  105. package/.eslintignore +0 -2
  106. package/.eslintrc +0 -5
  107. package/__mocks__/fileMock.js +0 -1
  108. package/babel.config.json +0 -3
  109. package/dist/helpers/sendinblueHelper.d.ts +0 -4
  110. package/dist/helpers/sendinblueHelper.js +0 -46
  111. package/dist/libs/Extracts.d.ts +0 -20
  112. package/dist/libs/Extracts.js +0 -110
  113. package/jest.config.ts +0 -193
  114. package/setupJest.ts +0 -8
  115. package/src/App.test.tsx +0 -41
  116. package/src/App.tsx +0 -152
  117. package/src/Globals.ts +0 -69
  118. package/src/Loader.tsx +0 -8
  119. package/src/PluginLoader.test.tsx +0 -70
  120. package/src/PluginLoader.tsx +0 -407
  121. package/src/Shimmer.tsx +0 -108
  122. package/src/ThemeLoader.test.tsx +0 -82
  123. package/src/ThemeLoader.tsx +0 -95
  124. package/src/components/PluginRoute.tsx +0 -48
  125. package/src/components/SmartScript.tsx +0 -166
  126. package/src/components/UserLocked/UserLockedComponent.tsx +0 -33
  127. package/src/components/View.test.tsx +0 -110
  128. package/src/components/View.tsx +0 -114
  129. package/src/componentsConnectors/connectBox.test.tsx +0 -226
  130. package/src/componentsConnectors/connectBox.tsx +0 -70
  131. package/src/componentsConnectors/connectDocument.test.tsx +0 -108
  132. package/src/componentsConnectors/connectDocument.tsx +0 -64
  133. package/src/componentsConnectors/connectHeader.tsx +0 -21
  134. package/src/componentsConnectors/connectMetaTitle.test.tsx +0 -40
  135. package/src/componentsConnectors/connectMetaTitle.tsx +0 -8
  136. package/src/componentsConnectors/connectOption.tsx +0 -222
  137. package/src/componentsConnectors/connectPagination.tsx +0 -102
  138. package/src/componentsConnectors/connectPreview.tsx +0 -5
  139. package/src/componentsConnectors/connectProgress.tsx +0 -59
  140. package/src/componentsConnectors/connectRootOption.tsx +0 -95
  141. package/src/componentsConnectors/connectSection.tsx +0 -79
  142. package/src/componentsConnectors/connectSummary.tsx +0 -21
  143. package/src/componentsConnectors/connectSummaryItem.tsx +0 -102
  144. package/src/componentsConnectors/connectTermsheet.tsx +0 -359
  145. package/src/componentsConnectors/connectVariable.tsx +0 -191
  146. package/src/componentsConnectors/connectWizardWrapper.tsx +0 -30
  147. package/src/componentsConnectors/connector/componentConnector.tsx +0 -219
  148. package/src/componentsConnectors/library.ts +0 -35
  149. package/src/config.test.ts +0 -63
  150. package/src/config.ts +0 -11
  151. package/src/constants/emailValidation.ts +0 -2
  152. package/src/constants/phoneValidation.ts +0 -6
  153. package/src/definitions/path.join.d.ts +0 -4
  154. package/src/helpers/outputsParsing.ts +0 -412
  155. package/src/helpers/preloadTheme.ts +0 -17
  156. package/src/helpers/scriptsLoader.ts +0 -20
  157. package/src/helpers/sendinblueHelper.ts +0 -65
  158. package/src/hooks/usePrevious.ts +0 -9
  159. package/src/libs/ConditionsInitiator.ts +0 -164
  160. package/src/libs/ConditionsRunner/DataPopulator.ts +0 -266
  161. package/src/libs/ConditionsRunner.ts +0 -454
  162. package/src/libs/DocumentsOutputs.ts +0 -171
  163. package/src/libs/Eval/EvalBase.ts +0 -116
  164. package/src/libs/Eval/EvalFunctions.ts +0 -724
  165. package/src/libs/Eval/NumbersToLetters.ts +0 -185
  166. package/src/libs/EvalVariable.ts +0 -265
  167. package/src/libs/EventsTracking.ts +0 -276
  168. package/src/libs/Extracts.ts +0 -159
  169. package/src/libs/InputsInitiator.ts +0 -136
  170. package/src/libs/NumAuto.test.ts +0 -55
  171. package/src/libs/NumAuto.ts +0 -56
  172. package/src/libs/OvcConverter.ts +0 -285
  173. package/src/libs/PathReader.ts +0 -272
  174. package/src/libs/SectionValidity.test.ts +0 -146
  175. package/src/libs/SectionValidity.ts +0 -110
  176. package/src/libs/SmartScriptStore.ts +0 -492
  177. package/src/misc/test_model.ts +0 -14603
  178. package/src/misc/test_models/connectDocumen.testmodel.json +0 -178
  179. package/src/misc/test_models/setDefaults.testmodel.json +0 -279
  180. package/src/misc/test_models/testmodel.json +0 -1
  181. package/src/polyfills/index.ts +0 -5
  182. package/src/polyfills/objectValues.ts +0 -4
  183. package/src/polyfills/prepend.ts +0 -31
  184. package/src/polyfills/stringRepeat.ts +0 -44
  185. package/src/redux/actions/app.test.ts +0 -123
  186. package/src/redux/actions/app.ts +0 -249
  187. package/src/redux/actions/conditions.test.ts +0 -84
  188. package/src/redux/actions/conditions.ts +0 -135
  189. package/src/redux/actions/inputs.test.ts +0 -85
  190. package/src/redux/actions/inputs.ts +0 -111
  191. package/src/redux/actions/library.ts +0 -23
  192. package/src/redux/actions/mandatories.ts +0 -98
  193. package/src/redux/actions/references.test.ts +0 -48
  194. package/src/redux/actions/references.ts +0 -37
  195. package/src/redux/actions/sagas/data.test.ts +0 -11
  196. package/src/redux/actions/sagas/data.ts +0 -18
  197. package/src/redux/actions/sagas/model.test.ts +0 -14
  198. package/src/redux/actions/sagas/model.ts +0 -48
  199. package/src/redux/actions/sagas/user.ts +0 -25
  200. package/src/redux/actions/smartscript.ts +0 -55
  201. package/src/redux/actions/user.test.ts +0 -18
  202. package/src/redux/actions/user.ts +0 -41
  203. package/src/redux/constants/app.ts +0 -36
  204. package/src/redux/constants/conditions.ts +0 -25
  205. package/src/redux/constants/inputs.ts +0 -15
  206. package/src/redux/constants/mandatories.ts +0 -11
  207. package/src/redux/constants/references.ts +0 -7
  208. package/src/redux/constants/sagas/data.ts +0 -1
  209. package/src/redux/constants/sagas/model.ts +0 -2
  210. package/src/redux/constants/sagas/user.ts +0 -2
  211. package/src/redux/constants/smartscript.ts +0 -9
  212. package/src/redux/constants/user.ts +0 -6
  213. package/src/redux/listeners/subscriber.test.ts +0 -45
  214. package/src/redux/listeners/subscriber.ts +0 -29
  215. package/src/redux/middlewares/conditionsWatcherMiddleware.test.ts +0 -370
  216. package/src/redux/middlewares/conditionsWatcherMiddleware.ts +0 -321
  217. package/src/redux/middlewares/evaluationsWatcherMiddleware.test.ts +0 -323
  218. package/src/redux/middlewares/evaluationsWatcherMiddleware.ts +0 -250
  219. package/src/redux/middlewares/mandatoriesWatcherMiddleware.ts +0 -473
  220. package/src/redux/middlewares/multiplesActionsMiddleware.test.ts +0 -230
  221. package/src/redux/middlewares/multiplesActionsMiddleware.ts +0 -121
  222. package/src/redux/middlewares/paginationWatcherMiddleware.ts +0 -251
  223. package/src/redux/middlewares/pluginsHookMiddleware.ts +0 -24
  224. package/src/redux/middlewares/prefillerWatcherMiddleware.test.ts +0 -118
  225. package/src/redux/middlewares/prefillerWatcherMiddleware.ts +0 -462
  226. package/src/redux/middlewares/smartscriptMiddleware.ts +0 -228
  227. package/src/redux/middlewares/thirdpartyScriptsMiddleware.ts +0 -41
  228. package/src/redux/reducers/app/customizations/initCustomizationAutoDefault.ts +0 -16
  229. package/src/redux/reducers/app/customizations/initCustomizationMeta.ts +0 -16
  230. package/src/redux/reducers/app/instance/initInstance.ts +0 -29
  231. package/src/redux/reducers/app/instance/setDataStatus.ts +0 -16
  232. package/src/redux/reducers/app/instance/updateInstance.ts +0 -30
  233. package/src/redux/reducers/app/instance/updateInstancePaid.ts +0 -20
  234. package/src/redux/reducers/app/instance.test.ts +0 -106
  235. package/src/redux/reducers/app/meta/fetchModelFailed.ts +0 -11
  236. package/src/redux/reducers/app/meta/fetchModelNonBlocking.ts +0 -11
  237. package/src/redux/reducers/app/meta/fetchModelSucceeded.ts +0 -11
  238. package/src/redux/reducers/app/meta/fetchModelUnhealthy.ts +0 -18
  239. package/src/redux/reducers/app/meta/fetchModelUserLocked.ts +0 -11
  240. package/src/redux/reducers/app/meta/initMeta.ts +0 -22
  241. package/src/redux/reducers/app/meta/setModelUuid.ts +0 -17
  242. package/src/redux/reducers/app/meta.test.ts +0 -90
  243. package/src/redux/reducers/app/pagination/goNextPage.ts +0 -69
  244. package/src/redux/reducers/app/pagination/goPage.ts +0 -81
  245. package/src/redux/reducers/app/pagination/goPreviousPage.ts +0 -60
  246. package/src/redux/reducers/app/pagination/initPagination.ts +0 -46
  247. package/src/redux/reducers/app/pagination/updateAvailableAppStates.ts +0 -77
  248. package/src/redux/reducers/app/pagination.test.ts +0 -363
  249. package/src/redux/reducers/app/wizard/updateAvailableSections.ts +0 -40
  250. package/src/redux/reducers/app/wizard.test.ts +0 -84
  251. package/src/redux/reducers/app.test.ts +0 -336
  252. package/src/redux/reducers/app.ts +0 -150
  253. package/src/redux/reducers/conditions/addMultipleOccurency.test.ts +0 -131
  254. package/src/redux/reducers/conditions/addMultipleOccurency.ts +0 -155
  255. package/src/redux/reducers/conditions/deleteMultipleOccurency.test.ts +0 -95
  256. package/src/redux/reducers/conditions/deleteMultipleOccurency.ts +0 -141
  257. package/src/redux/reducers/conditions/initConditions.ts +0 -18
  258. package/src/redux/reducers/conditions/updateDocumentConditions.test.ts +0 -47
  259. package/src/redux/reducers/conditions/updateDocumentConditions.ts +0 -21
  260. package/src/redux/reducers/conditions/updateOptionConditions.ts +0 -24
  261. package/src/redux/reducers/conditions/updateOptionValidatorCondition.test.ts +0 -50
  262. package/src/redux/reducers/conditions/updateOptionValidatorCondition.ts +0 -28
  263. package/src/redux/reducers/conditions/updatePrefillerConditions.ts +0 -29
  264. package/src/redux/reducers/conditions/updateSectionConditions.ts +0 -28
  265. package/src/redux/reducers/conditions/updateVariableConditions.ts +0 -25
  266. package/src/redux/reducers/conditions/updateVariableValidatorCondition.test.ts +0 -50
  267. package/src/redux/reducers/conditions/updateVariableValidatorCondition.ts +0 -28
  268. package/src/redux/reducers/conditions.test.ts +0 -241
  269. package/src/redux/reducers/conditions.ts +0 -68
  270. package/src/redux/reducers/inputs/addMultipleOccurency.test.ts +0 -117
  271. package/src/redux/reducers/inputs/addMultipleOccurency.ts +0 -50
  272. package/src/redux/reducers/inputs/deleteMultipleOccurency.test.ts +0 -70
  273. package/src/redux/reducers/inputs/deleteMultipleOccurency.ts +0 -50
  274. package/src/redux/reducers/inputs/initOption.ts +0 -16
  275. package/src/redux/reducers/inputs/initVariable.ts +0 -16
  276. package/src/redux/reducers/inputs/updateOptionInput.ts +0 -24
  277. package/src/redux/reducers/inputs/updateVariableInput.ts +0 -24
  278. package/src/redux/reducers/inputs.test.ts +0 -221
  279. package/src/redux/reducers/inputs.ts +0 -51
  280. package/src/redux/reducers/mandatories/addMultipleOccurency.ts +0 -52
  281. package/src/redux/reducers/mandatories/deleteMultipleOccurency.ts +0 -55
  282. package/src/redux/reducers/mandatories/initMandatoryOption.ts +0 -17
  283. package/src/redux/reducers/mandatories/initMandatoryVariable.ts +0 -17
  284. package/src/redux/reducers/mandatories/setMandatoryIgnore.ts +0 -17
  285. package/src/redux/reducers/mandatories/setMandatoryOption.ts +0 -25
  286. package/src/redux/reducers/mandatories/setMandatorySection.ts +0 -20
  287. package/src/redux/reducers/mandatories/setMandatoryVariable.ts +0 -24
  288. package/src/redux/reducers/mandatories.ts +0 -56
  289. package/src/redux/reducers/references/initReferences.ts +0 -37
  290. package/src/redux/reducers/references/updateOptionMeta.ts +0 -73
  291. package/src/redux/reducers/references/updateVariableMeta.ts +0 -72
  292. package/src/redux/reducers/references.ts +0 -59
  293. package/src/redux/reducers/smartscript/enableSmartScript.ts +0 -13
  294. package/src/redux/reducers/smartscript/initSmartScriptTriggers.ts +0 -14
  295. package/src/redux/reducers/smartscript/updateSmartscriptOptionHidden.ts +0 -30
  296. package/src/redux/reducers/smartscript/updateSmartscriptVariableHidden.ts +0 -30
  297. package/src/redux/reducers/smartscript.ts +0 -47
  298. package/src/redux/reducers/user/initUser.ts +0 -15
  299. package/src/redux/reducers/user/setUserStatus.ts +0 -13
  300. package/src/redux/reducers/user/setUserValidToken.ts +0 -13
  301. package/src/redux/reducers/user.test.ts +0 -51
  302. package/src/redux/reducers/user.ts +0 -40
  303. package/src/redux/routerHistore.test.ts +0 -19
  304. package/src/redux/routerHistory.ts +0 -26
  305. package/src/redux/sagas/fetchModel.test.ts +0 -76
  306. package/src/redux/sagas/fetchModel.ts +0 -683
  307. package/src/redux/sagas/homogeneousRadioInputsSaga.ts +0 -42
  308. package/src/redux/sagas/initInputs.ts +0 -110
  309. package/src/redux/sagas/runner.test.ts +0 -12
  310. package/src/redux/sagas/runner.ts +0 -26
  311. package/src/redux/sagas/saveData.test.ts +0 -125
  312. package/src/redux/sagas/saveData.ts +0 -116
  313. package/src/redux/sagas/setDefaults.test.ts +0 -100
  314. package/src/redux/sagas/setDefaults.ts +0 -167
  315. package/src/redux/sagas/setUserEmail.ts +0 -221
  316. package/src/redux/selectors/app.test.ts +0 -162
  317. package/src/redux/selectors/app.ts +0 -331
  318. package/src/redux/selectors/conditions.test.ts +0 -92
  319. package/src/redux/selectors/conditions.ts +0 -293
  320. package/src/redux/selectors/inputs.test.ts +0 -72
  321. package/src/redux/selectors/inputs.ts +0 -76
  322. package/src/redux/selectors/library.ts +0 -17
  323. package/src/redux/selectors/mandatories.ts +0 -83
  324. package/src/redux/selectors/references.test.ts +0 -660
  325. package/src/redux/selectors/references.ts +0 -413
  326. package/src/redux/selectors/selectors.test.ts +0 -21
  327. package/src/redux/selectors/selectors.ts +0 -87
  328. package/src/redux/selectors/smartscript.ts +0 -30
  329. package/src/redux/selectors/user.test.ts +0 -39
  330. package/src/redux/selectors/user.ts +0 -45
  331. package/src/redux/store.test.ts +0 -22
  332. package/src/redux/store.ts +0 -100
  333. package/src/service/api.manager.ts +0 -261
  334. package/src/service/auth.service.ts +0 -5
  335. package/src/service/pardot.service.ts +0 -10
  336. package/src/tests-misc/plugins/jestTestPlugin/after.tsx +0 -5
  337. package/src/tests-misc/plugins/jestTestPlugin/before.tsx +0 -11
  338. package/src/tests-misc/plugins/jestTestPlugin/index.ts +0 -11
  339. package/src/tests-misc/plugins/jestTestPlugin/title.tsx +0 -8
  340. package/src/tests-misc/themes/jestTestTheme/components/EmailComponent.tsx +0 -5
  341. package/src/tests-misc/themes/jestTestTheme/components/TermsheetComponent.tsx +0 -5
  342. package/src/tests-misc/themes/jestTestTheme/components/WizardComponent.tsx +0 -5
  343. package/src/tests-misc/themes/jestTestTheme/faltyIndex.ts +0 -3
  344. package/src/tests-misc/themes/jestTestTheme/faltyIndexLoader.ts +0 -1
  345. package/src/tests-misc/themes/jestTestTheme/index.ts +0 -13
  346. package/src/types/Actions.type.ts +0 -612
  347. package/src/types/Components.type.ts +0 -181
  348. package/src/types/State.type.ts +0 -323
  349. package/src/types/Termsheet.type.ts +0 -28
  350. package/src/types/api.type.ts +0 -37
  351. package/src/types/config.type.ts +0 -55
  352. package/src/types/env.type.ts +0 -5
  353. package/src/types/getActions.type.ts +0 -3
  354. package/src/types/getConnectors.type.ts +0 -5
  355. package/src/types/getSelectors.type.ts +0 -3
  356. package/src/wizard-params.ts +0 -56
  357. package/tsconfig.json +0 -43
@@ -1,370 +0,0 @@
1
- import conditionsWatcherMiddleware from './conditionsWatcherMiddleware';
2
- import {
3
- addMultipleOccurencyAction,
4
- deleteMultipleOccurencyAction,
5
- updateOptionAction,
6
- updateVariableAction,
7
- } from '../actions/inputs';
8
- import { StateType } from '../../types/State.type';
9
- import { initConditionsAction } from '../actions/conditions';
10
-
11
- const mockInputs: StateType.Inputs = {
12
- variables: {
13
- 1: ['Hello'],
14
- 2: [],
15
- 3: [],
16
- },
17
- options: {
18
- 1: [true],
19
- 2: [true, true],
20
- 3: [true, false],
21
- 4: [false, true],
22
- 7: [true, true],
23
- 8: [true, true],
24
- },
25
- };
26
-
27
- // Mocking MPI
28
- const mpi = {
29
- dispatch: jest.fn(),
30
- getState: () => ({
31
- inputs: mockInputs,
32
- }),
33
- };
34
-
35
- // Mocking Next
36
- const next = jest.fn();
37
-
38
- const initialConditions = {
39
- options: {},
40
- variables: {},
41
- documents: {},
42
- sections: {},
43
- prefillers: {},
44
- validators: {
45
- options: {},
46
- variables: {},
47
- },
48
- };
49
-
50
- const mockOptionsRelations: StateType.References.Relations['options'] = {
51
- 2: {
52
- options: [],
53
- variables: [],
54
- sections: {},
55
- documents: [],
56
- prefillers: [],
57
- validators: {
58
- options: [],
59
- variables: [],
60
- },
61
- parents: [],
62
- children: {
63
- options: [3, 4],
64
- variables: [2, 3],
65
- },
66
- dependants: [7, 8],
67
- },
68
- };
69
-
70
- // Mocking reference selecteor
71
- // ../selectors/inputs.ts
72
- jest.mock('../selectors/inputs', () => ({
73
- __esModule: true,
74
- selectOptionInput: (id: number) => mockInputs.options[id],
75
- selectOptionInputByIndex: (id: number, index: number) =>
76
- mockInputs.options[id][index],
77
- selectVariableInput: (id: number) => mockInputs.variables[id],
78
- selectVariableInputByIndex: (id: number, index: number) =>
79
- mockInputs.variables[id][index],
80
- }));
81
-
82
- jest.mock('../../libs/ConditionsRunner', () => {
83
- class ConditionsRunnerMock {
84
- dispatch: any;
85
-
86
- constructor(dispatch: any) {
87
- this.dispatch = dispatch;
88
- }
89
-
90
- executeHooks(...args: any[]) {
91
- this.dispatch({
92
- type: 'EXEC_HOOKS_MOCK',
93
- arguments: args,
94
- });
95
- }
96
- }
97
- return {
98
- __esModule: true,
99
- ConditionsRunner: ConditionsRunnerMock,
100
- };
101
- });
102
-
103
- const mockOptionsConditions: Record<string, any> = {};
104
- const mockVariablesConditions: Record<string, any> = {};
105
-
106
- // Mocking reference selecteor
107
- // ../selectors/references.ts
108
- jest.mock('../selectors/references', () => ({
109
- __esModule: true,
110
- selectOptionRelations: (id: number) => mockOptionsRelations[id],
111
- selectOptionConditionsObject: (id: number) => mockOptionsConditions[id],
112
- selectVariableConditionsObject: (id: number) => mockVariablesConditions[id],
113
- }));
114
-
115
- describe('Conditions Watcher Middleware Test suit', () => {
116
- beforeEach(() => {
117
- jest.clearAllMocks();
118
- });
119
-
120
- it('Completes INIT_CONDITIONS action correctly', () => {
121
- // Running watcher
122
- conditionsWatcherMiddleware(mpi)(next)(
123
- initConditionsAction(initialConditions)
124
- );
125
-
126
- expect(next.mock.calls.length).toBe(1);
127
- expect(next.mock.calls[0][0]).toStrictEqual({
128
- type: 'INIT_CONDITIONS',
129
- ...initialConditions,
130
- });
131
- expect(mpi.dispatch.mock.calls.length).toBe(12);
132
- expect(mpi.dispatch.mock.calls[0][0]).toStrictEqual({
133
- type: 'EXEC_HOOKS_MOCK',
134
- arguments: ['options', 1, 0],
135
- });
136
- expect(mpi.dispatch.mock.calls[1][0]).toStrictEqual({
137
- type: 'EXEC_HOOKS_MOCK',
138
- arguments: ['options', 2, 0],
139
- });
140
- expect(mpi.dispatch.mock.calls[2][0]).toStrictEqual({
141
- type: 'EXEC_HOOKS_MOCK',
142
- arguments: ['options', 2, 1],
143
- });
144
- expect(mpi.dispatch.mock.calls[3][0]).toStrictEqual({
145
- type: 'EXEC_HOOKS_MOCK',
146
- arguments: ['options', 3, 0],
147
- });
148
- expect(mpi.dispatch.mock.calls[4][0]).toStrictEqual({
149
- type: 'EXEC_HOOKS_MOCK',
150
- arguments: ['options', 3, 1],
151
- });
152
- expect(mpi.dispatch.mock.calls[5][0]).toStrictEqual({
153
- type: 'EXEC_HOOKS_MOCK',
154
- arguments: ['options', 4, 0],
155
- });
156
- expect(mpi.dispatch.mock.calls[6][0]).toStrictEqual({
157
- type: 'EXEC_HOOKS_MOCK',
158
- arguments: ['options', 4, 1],
159
- });
160
- expect(mpi.dispatch.mock.calls[7][0]).toStrictEqual({
161
- type: 'EXEC_HOOKS_MOCK',
162
- arguments: ['options', 7, 0],
163
- });
164
- expect(mpi.dispatch.mock.calls[8][0]).toStrictEqual({
165
- type: 'EXEC_HOOKS_MOCK',
166
- arguments: ['options', 7, 1],
167
- });
168
- expect(mpi.dispatch.mock.calls[9][0]).toStrictEqual({
169
- type: 'EXEC_HOOKS_MOCK',
170
- arguments: ['options', 8, 0],
171
- });
172
- expect(mpi.dispatch.mock.calls[10][0]).toStrictEqual({
173
- type: 'EXEC_HOOKS_MOCK',
174
- arguments: ['options', 8, 1],
175
- });
176
- expect(mpi.dispatch.mock.calls[11][0]).toStrictEqual({
177
- type: 'EXEC_HOOKS_MOCK',
178
- arguments: ['variables', 1, 0],
179
- });
180
- });
181
-
182
- it('Completes UPDATE_OPTION_INPUT action correctly', () => {
183
- // Running watcher
184
- conditionsWatcherMiddleware(mpi)(next)(updateOptionAction(3, false, 0));
185
-
186
- expect(next.mock.calls.length).toBe(1);
187
- expect(next.mock.calls[0][0]).toStrictEqual({
188
- type: 'UPDATE_OPTION_INPUT',
189
- id: 3,
190
- index: 0,
191
- value: false,
192
- });
193
- expect(mpi.dispatch.mock.calls.length).toBe(2);
194
- expect(mpi.dispatch.mock.calls[0][0]).toStrictEqual({
195
- type: 'SET_DATA_STATUS',
196
- dataStatus: 'unsaved',
197
- });
198
- expect(mpi.dispatch.mock.calls[1][0]).toStrictEqual({
199
- type: 'EXEC_HOOKS_MOCK',
200
- arguments: ['options', 3, 0],
201
- });
202
- });
203
-
204
- it('Completes UPDATE_VARIABLE_INPUT action correctly', () => {
205
- // Running watcher
206
- conditionsWatcherMiddleware(mpi)(next)(updateVariableAction(1, 'Hey', 0));
207
-
208
- expect(next.mock.calls.length).toBe(1);
209
- expect(next.mock.calls[0][0]).toStrictEqual({
210
- type: 'UPDATE_VARIABLE_INPUT',
211
- id: 1,
212
- index: 0,
213
- value: 'Hey',
214
- });
215
- expect(mpi.dispatch.mock.calls.length).toBe(2);
216
- expect(mpi.dispatch.mock.calls[0][0]).toStrictEqual({
217
- type: 'SET_DATA_STATUS',
218
- dataStatus: 'unsaved',
219
- });
220
- expect(mpi.dispatch.mock.calls[1][0]).toStrictEqual({
221
- type: 'EXEC_HOOKS_MOCK',
222
- arguments: ['variables', 1, 0],
223
- });
224
- });
225
-
226
- it('Completes ADD_MULTIPLE_OCCURENCY action correctly', () => {
227
- // Running watcher
228
- conditionsWatcherMiddleware(mpi)(next)(addMultipleOccurencyAction(2));
229
-
230
- expect(next.mock.calls.length).toBe(1);
231
- expect(next.mock.calls[0][0]).toStrictEqual({
232
- type: 'ADD_MULTIPLE_OCCURENCY',
233
- id: 2,
234
- });
235
- expect(mpi.dispatch.mock.calls.length).toBe(15);
236
- expect(mpi.dispatch.mock.calls[0][0]).toStrictEqual({
237
- type: 'SET_DATA_STATUS',
238
- dataStatus: 'unsaved',
239
- });
240
- expect(mpi.dispatch.mock.calls[1][0]).toStrictEqual({
241
- type: 'EXEC_HOOKS_MOCK',
242
- arguments: ['options', 2, 0],
243
- });
244
- expect(mpi.dispatch.mock.calls[2][0]).toStrictEqual({
245
- type: 'EXEC_HOOKS_MOCK',
246
- arguments: ['options', 2, 1],
247
- });
248
- expect(mpi.dispatch.mock.calls[3][0]).toStrictEqual({
249
- type: 'EXEC_HOOKS_MOCK',
250
- arguments: ['options', 3, 0],
251
- });
252
- expect(mpi.dispatch.mock.calls[4][0]).toStrictEqual({
253
- type: 'EXEC_HOOKS_MOCK',
254
- arguments: ['options', 3, 1],
255
- });
256
- expect(mpi.dispatch.mock.calls[5][0]).toStrictEqual({
257
- type: 'EXEC_HOOKS_MOCK',
258
- arguments: ['options', 4, 0],
259
- });
260
- expect(mpi.dispatch.mock.calls[6][0]).toStrictEqual({
261
- type: 'EXEC_HOOKS_MOCK',
262
- arguments: ['options', 4, 1],
263
- });
264
- expect(mpi.dispatch.mock.calls[7][0]).toStrictEqual({
265
- type: 'EXEC_HOOKS_MOCK',
266
- arguments: ['options', 7, 0],
267
- });
268
- expect(mpi.dispatch.mock.calls[8][0]).toStrictEqual({
269
- type: 'EXEC_HOOKS_MOCK',
270
- arguments: ['options', 7, 1],
271
- });
272
- expect(mpi.dispatch.mock.calls[9][0]).toStrictEqual({
273
- type: 'EXEC_HOOKS_MOCK',
274
- arguments: ['options', 8, 0],
275
- });
276
- expect(mpi.dispatch.mock.calls[10][0]).toStrictEqual({
277
- type: 'EXEC_HOOKS_MOCK',
278
- arguments: ['options', 8, 1],
279
- });
280
- expect(mpi.dispatch.mock.calls[11][0]).toStrictEqual({
281
- type: 'EXEC_HOOKS_MOCK',
282
- arguments: ['variables', 2, 0],
283
- });
284
- expect(mpi.dispatch.mock.calls[12][0]).toStrictEqual({
285
- type: 'EXEC_HOOKS_MOCK',
286
- arguments: ['variables', 2, 1],
287
- });
288
- expect(mpi.dispatch.mock.calls[13][0]).toStrictEqual({
289
- type: 'EXEC_HOOKS_MOCK',
290
- arguments: ['variables', 3, 0],
291
- });
292
- expect(mpi.dispatch.mock.calls[14][0]).toStrictEqual({
293
- type: 'EXEC_HOOKS_MOCK',
294
- arguments: ['variables', 3, 1],
295
- });
296
- });
297
-
298
- it('Completes DELETE_MULTIPLE_OCCURENCY action correctly', () => {
299
- // Running watcher
300
- conditionsWatcherMiddleware(mpi)(next)(deleteMultipleOccurencyAction(2, 1));
301
-
302
- expect(next.mock.calls.length).toBe(1);
303
- expect(next.mock.calls[0][0]).toStrictEqual({
304
- type: 'DELETE_MULTIPLE_OCCURENCY',
305
- id: 2,
306
- index: 1,
307
- });
308
- expect(mpi.dispatch.mock.calls.length).toBe(15);
309
- expect(mpi.dispatch.mock.calls[0][0]).toStrictEqual({
310
- type: 'SET_DATA_STATUS',
311
- dataStatus: 'unsaved',
312
- });
313
- expect(mpi.dispatch.mock.calls[1][0]).toStrictEqual({
314
- type: 'EXEC_HOOKS_MOCK',
315
- arguments: ['options', 2, 0],
316
- });
317
- expect(mpi.dispatch.mock.calls[2][0]).toStrictEqual({
318
- type: 'EXEC_HOOKS_MOCK',
319
- arguments: ['options', 2, 1],
320
- });
321
- expect(mpi.dispatch.mock.calls[3][0]).toStrictEqual({
322
- type: 'EXEC_HOOKS_MOCK',
323
- arguments: ['options', 3, 0],
324
- });
325
- expect(mpi.dispatch.mock.calls[4][0]).toStrictEqual({
326
- type: 'EXEC_HOOKS_MOCK',
327
- arguments: ['options', 3, 1],
328
- });
329
- expect(mpi.dispatch.mock.calls[5][0]).toStrictEqual({
330
- type: 'EXEC_HOOKS_MOCK',
331
- arguments: ['options', 4, 0],
332
- });
333
- expect(mpi.dispatch.mock.calls[6][0]).toStrictEqual({
334
- type: 'EXEC_HOOKS_MOCK',
335
- arguments: ['options', 4, 1],
336
- });
337
- expect(mpi.dispatch.mock.calls[7][0]).toStrictEqual({
338
- type: 'EXEC_HOOKS_MOCK',
339
- arguments: ['options', 7, 0],
340
- });
341
- expect(mpi.dispatch.mock.calls[8][0]).toStrictEqual({
342
- type: 'EXEC_HOOKS_MOCK',
343
- arguments: ['options', 7, 1],
344
- });
345
- expect(mpi.dispatch.mock.calls[9][0]).toStrictEqual({
346
- type: 'EXEC_HOOKS_MOCK',
347
- arguments: ['options', 8, 0],
348
- });
349
- expect(mpi.dispatch.mock.calls[10][0]).toStrictEqual({
350
- type: 'EXEC_HOOKS_MOCK',
351
- arguments: ['options', 8, 1],
352
- });
353
- expect(mpi.dispatch.mock.calls[11][0]).toStrictEqual({
354
- type: 'EXEC_HOOKS_MOCK',
355
- arguments: ['variables', 2, 0],
356
- });
357
- expect(mpi.dispatch.mock.calls[12][0]).toStrictEqual({
358
- type: 'EXEC_HOOKS_MOCK',
359
- arguments: ['variables', 2, 1],
360
- });
361
- expect(mpi.dispatch.mock.calls[13][0]).toStrictEqual({
362
- type: 'EXEC_HOOKS_MOCK',
363
- arguments: ['variables', 3, 0],
364
- });
365
- expect(mpi.dispatch.mock.calls[14][0]).toStrictEqual({
366
- type: 'EXEC_HOOKS_MOCK',
367
- arguments: ['variables', 3, 1],
368
- });
369
- });
370
- });
@@ -1,321 +0,0 @@
1
- import { Dispatch, MiddlewareAPI } from "redux";
2
- import {
3
- UPDATE_OPTION_INPUT,
4
- UPDATE_VARIABLE_INPUT,
5
- ADD_MULTIPLE_OCCURENCY,
6
- DELETE_MULTIPLE_OCCURENCY,
7
- } from "../constants/inputs";
8
- import {
9
- selectOptionInput,
10
- selectOptionInputByIndex,
11
- selectVariableInputByIndex,
12
- selectVariableInput,
13
- } from "../selectors/inputs";
14
- import { ActionsType } from "../../types/Actions.type";
15
- import { ConditionsRunner } from "../../libs/ConditionsRunner";
16
- import {
17
- INIT_CONDITIONS,
18
- UPDATE_SECTION_CONDITION,
19
- UPDATE_OPTION_CONDITION,
20
- UPDATE_VARIABLE_CONDITION,
21
- } from "../constants/conditions";
22
- import {
23
- selectOptionRelations,
24
- selectOptionConditionsObject,
25
- selectVariableConditionsObject,
26
- } from "../selectors/references";
27
- import { setDataStatus } from "../actions/app";
28
- import {
29
- selectSectionConditionValue,
30
- selectOptionConditionValue,
31
- selectVariableConditionValue,
32
- } from "../selectors/conditions";
33
- import { StateType } from "../../types/State.type";
34
-
35
- export type WatcherActions =
36
- | ActionsType.Inputs.updateOptionInput
37
- | ActionsType.Inputs.updateVariableInput
38
- | ActionsType.Inputs.addMultipleOccurency
39
- | ActionsType.Inputs.deleteMultipleOccurency
40
- | ActionsType.Conditions.initConditions;
41
-
42
- /**
43
- * Watching UPDATE_OPTION_INPUT action
44
- * @param mpi MiddlewareAPI
45
- * @param next Dispatch function
46
- * @param action Actions
47
- */
48
- const watchUpdateOptionInput = (
49
- mpi: MiddlewareAPI<Dispatch, StateType>,
50
- next: Dispatch,
51
- action: ActionsType.Inputs.updateOptionInput
52
- ) => {
53
- const { id, index, value } = action;
54
- const oldValue = selectOptionInputByIndex(id, index);
55
-
56
- const nextResult = next(action);
57
- if (value !== oldValue) {
58
- mpi.dispatch(setDataStatus("unsaved"));
59
- const Conditions = new ConditionsRunner(mpi.dispatch);
60
- Conditions.executeHooks("options", id, index);
61
- }
62
- return nextResult;
63
- };
64
-
65
- /**
66
- * Watching UPDATE_OPTION_CONDITION action
67
- * @param mpi MiddlewareAPI
68
- * @param next Dispatch function
69
- * @param action Actions
70
- */
71
- const watchUpdateOptionCondition = (
72
- mpi: MiddlewareAPI<Dispatch, StateType>,
73
- next: Dispatch,
74
- action: ActionsType.Conditions.updateOptionCondition
75
- ) => {
76
- const { id, index, value } = action;
77
- const oldValue = selectOptionConditionValue(id, index);
78
-
79
- const nextResult = next(action);
80
- if (value !== oldValue) {
81
- mpi.dispatch(setDataStatus("unsaved"));
82
- const Conditions = new ConditionsRunner(mpi.dispatch);
83
- Conditions.executeHooks("options", id, index);
84
- }
85
- return nextResult;
86
- };
87
-
88
- /**
89
- * Watching UPDATE_VARIALE_INPUT action
90
- * @param mpi MiddlewareAPI
91
- * @param next Dispatch function
92
- * @param action Actions
93
- */
94
-
95
- const watchUpdateVariableInput = (
96
- mpi: MiddlewareAPI<Dispatch, StateType>,
97
- next: Dispatch,
98
- action: ActionsType.Inputs.updateVariableInput
99
- ) => {
100
- const { id, index, value } = action;
101
- const oldValue = selectVariableInputByIndex(id, index);
102
-
103
- const nextResult = next(action);
104
- if (value !== oldValue) {
105
- mpi.dispatch(setDataStatus("unsaved"));
106
- const Conditions = new ConditionsRunner(mpi.dispatch);
107
- Conditions.executeHooks("variables", id, index);
108
- }
109
- return nextResult;
110
- };
111
-
112
- /**
113
- * Watching UPDATE_VARIALE_INPUT action
114
- * @param mpi MiddlewareAPI
115
- * @param next Dispatch function
116
- * @param action Actions
117
- */
118
-
119
- const watchUpdateVariableCondition = (
120
- mpi: MiddlewareAPI<Dispatch, StateType>,
121
- next: Dispatch,
122
- action: ActionsType.Conditions.updateVariableCondition
123
- ) => {
124
- const { id, index, value } = action;
125
- const oldValue = selectVariableConditionValue(id, index);
126
-
127
- const nextResult = next(action);
128
- if (value !== oldValue) {
129
- mpi.dispatch(setDataStatus("unsaved"));
130
- const Conditions = new ConditionsRunner(mpi.dispatch);
131
- Conditions.executeHooks("variables", id, index);
132
- }
133
- return nextResult;
134
- };
135
-
136
- /**
137
- * Watching UPDATE_SECTION_CONDITION action
138
- * @param mpi MiddlewareAPI
139
- * @param next Dispatch function
140
- * @param action Actions
141
- */
142
- const watchUpdateSectionCondition = (
143
- mpi: MiddlewareAPI<Dispatch, StateType>,
144
- next: Dispatch,
145
- action: ActionsType.Conditions.updateSectionCondition
146
- ) => {
147
- const Conditions = new ConditionsRunner(mpi.dispatch);
148
-
149
- if (action.document !== "main") {
150
- return next(action);
151
- }
152
-
153
- const { id, value } = action;
154
- const oldValue = selectSectionConditionValue(id);
155
-
156
- const nextResult = next(action);
157
- if (value !== oldValue) {
158
- Conditions.executeHooks("sections", id, 0);
159
- }
160
- return nextResult;
161
- };
162
-
163
- /**
164
- * Watching ADD_MULTIPLE_OCCURENCY && DELETE_MULTIPLE_OCCURENCY action
165
- * @param mpi MiddlewareAPI
166
- * @param next Dispatch function
167
- * @param action Actions
168
- */
169
-
170
- const watchMultipleOccurenciesChange = (
171
- mpi: MiddlewareAPI<Dispatch, StateType>,
172
- next: Dispatch,
173
- action: ActionsType.Inputs.deleteMultipleOccurency
174
- ) => {
175
- const nextResult = next(action);
176
- const Conditions = new ConditionsRunner(mpi.dispatch);
177
- mpi.dispatch(setDataStatus("unsaved"));
178
-
179
- const { id } = action;
180
-
181
- // Getting multiple children
182
- const optionRelations = selectOptionRelations(id);
183
- if (optionRelations === undefined)
184
- throw new Error(`Options relations for option ${id} do not exist`);
185
-
186
- // Adding values to input's arrays
187
- const options: number[] = [
188
- id,
189
- ...optionRelations.children.options,
190
- ...optionRelations.dependants,
191
- ];
192
- const { variables } = optionRelations.children;
193
-
194
- // Executing self conditions for options
195
- for (let i = 0; i < options.length; i += 1) {
196
- // Getting the condition object
197
- const condition = selectOptionConditionsObject(options[i]);
198
- if (typeof condition === "object") {
199
- // Executing hooks on options
200
- condition.dataMap.o.forEach((optionId: number) => {
201
- selectOptionInput(optionId).forEach((input, index) =>
202
- Conditions.executeHooks("options", optionId, index)
203
- );
204
- });
205
-
206
- // Executing hooks on variables
207
- condition.dataMap.v.forEach((variableId: number) =>
208
- selectVariableInput(variableId).forEach((input, index) =>
209
- Conditions.executeHooks("variables", variableId, index)
210
- )
211
- );
212
- }
213
- }
214
-
215
- // Executing self conditions for variables
216
- for (let i = 0; i < variables.length; i += 1) {
217
- // Getting the condition object
218
- const condition = selectVariableConditionsObject(variables[i]);
219
- if (typeof condition === "object") {
220
- // Executing hooks on options
221
- condition.dataMap.o.forEach((optionId: number) =>
222
- selectOptionInput(optionId).forEach((input, index) =>
223
- Conditions.executeHooks("options", optionId, index)
224
- )
225
- );
226
-
227
- // Executing hooks on variables
228
- condition.dataMap.v.forEach((variableId: number) =>
229
- selectVariableInput(variableId).forEach((input, index) =>
230
- Conditions.executeHooks("variables", variableId, index)
231
- )
232
- );
233
- }
234
-
235
- // Prefillier
236
- }
237
-
238
- // Getting occurencies
239
- const occurencies = selectOptionInput(id).length;
240
-
241
- // Executing hooks on options
242
- for (let i = 0; i < options.length; i += 1) {
243
- for (let index = 0; index < occurencies; index += 1) {
244
- Conditions.executeHooks("options", options[i], index);
245
- }
246
- }
247
-
248
- // Executing hooks on variables
249
- for (let i = 0; i < variables.length; i += 1) {
250
- for (let index = 0; index < occurencies; index += 1) {
251
- Conditions.executeHooks("variables", variables[i], index);
252
- }
253
- }
254
- return nextResult;
255
- };
256
-
257
- /**
258
- * Watching INIT_CONDITIONS action
259
- * @param mpi MiddlewareAPI
260
- * @param next Dispatch function
261
- * @param action Actions
262
- */
263
- const watchInitConditions = (
264
- mpi: MiddlewareAPI<Dispatch, StateType>,
265
- next: Dispatch,
266
- action: WatcherActions
267
- ) => {
268
- const nextResult = next(action);
269
- const Conditions = new ConditionsRunner(mpi.dispatch);
270
- const stateInputs = mpi.getState().inputs;
271
- const options = Object.keys(stateInputs.options);
272
- const variables = Object.keys(stateInputs.variables);
273
-
274
- // Executing conditions on options
275
- for (let i = 0; i < options.length; i += 1) {
276
- const values = mpi.getState().inputs.options[parseInt(options[i], 10)];
277
- for (let index = 0; index < values.length; index += 1) {
278
- Conditions.executeHooks("options", parseInt(options[i], 10), index);
279
- }
280
- }
281
-
282
- // Executing conditions on variables
283
- for (let i = 0; i < variables.length; i += 1) {
284
- const values = mpi.getState().inputs.variables[parseInt(variables[i], 10)];
285
- for (let index = 0; index < values.length; index += 1) {
286
- Conditions.executeHooks("variables", parseInt(variables[i], 10), index);
287
- }
288
- }
289
- return nextResult;
290
- };
291
-
292
- // Enumerating watchers
293
- const watchersEnum: Record<
294
- string,
295
- (mpi: MiddlewareAPI<Dispatch, StateType>, next: Dispatch, action: any) => void
296
- > = {
297
- [UPDATE_OPTION_INPUT]: watchUpdateOptionInput,
298
- [UPDATE_OPTION_CONDITION]: watchUpdateOptionCondition,
299
- [UPDATE_VARIABLE_INPUT]: watchUpdateVariableInput,
300
- [UPDATE_VARIABLE_CONDITION]: watchUpdateVariableCondition,
301
- [UPDATE_SECTION_CONDITION]: watchUpdateSectionCondition,
302
- [INIT_CONDITIONS]: watchInitConditions,
303
- [ADD_MULTIPLE_OCCURENCY]: watchMultipleOccurenciesChange,
304
- [DELETE_MULTIPLE_OCCURENCY]: watchMultipleOccurenciesChange,
305
- };
306
-
307
- /**
308
- * Condition Watcher Middleware
309
- * @param mpi MiddlewareAPI
310
- * @param next Dispatch function
311
- * @param action Actions
312
- */
313
- const conditionsWatcherMiddleware =
314
- (mpi: MiddlewareAPI) => (next: Dispatch) => (action: WatcherActions) => {
315
- if (Object.prototype.hasOwnProperty.call(watchersEnum, action.type)) {
316
- return watchersEnum[action.type].apply(null, [mpi, next, action]);
317
- }
318
- return next(action);
319
- };
320
-
321
- export default conditionsWatcherMiddleware;