@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,221 +0,0 @@
1
- import { call, fork, put, takeLatest } from "redux-saga/effects";
2
- import { getContractFunnelGAEvent } from "@legalplace/lp-events";
3
- import { v4 as uuid } from "uuid";
4
- import { getConfig } from "../../config";
5
- import {
6
- selectPermalink,
7
- selectInstanceUniqid,
8
- selectDocumentTitle,
9
- selectAvailableAppStates,
10
- selectDocumentModelVersion,
11
- } from "../selectors/app";
12
- import { selectInputs } from "../selectors/inputs";
13
- import { SET_USER_EMAIL } from "../constants/sagas/user";
14
- import { setUserStatusAction, initUserAction } from "../actions/user";
15
- import { ActionsType } from "../../types/Actions.type";
16
- import { IInstanceCreationResponse } from "../../types/api.type";
17
- import {
18
- updateAvailableAppStatesAction,
19
- initInstanceAction,
20
- goNextPageAction,
21
- } from "../actions/app";
22
-
23
- import { OvcConverter } from "../../libs/OvcConverter";
24
- import { getSendinblueIdentifyAttributes } from "../../helpers/sendinblueHelper";
25
- import { setUserEmailSucceeded } from "../actions/sagas/user";
26
- import { EMAIL_REGEX } from "../../constants/emailValidation";
27
-
28
- const canalHeaders = {
29
- "lp-referrer": window.document.referrer,
30
- "lp-origin": window.location.href,
31
- };
32
-
33
- function* setUserEmailDecorator(action: ActionsType.User.setUserEmail): any {
34
- try {
35
- /**
36
- * Validating email
37
- */
38
- const { email, tags, inBackground } = action;
39
- if (!EMAIL_REGEX.test(email)) {
40
- if (!inBackground) yield put(setUserStatusAction("failed"));
41
- return;
42
- }
43
-
44
- yield put(setUserStatusAction("inprogress"));
45
-
46
- // Getting Permalink & uniqid
47
- const permalink = selectPermalink();
48
- const instanceUniqid = selectInstanceUniqid();
49
-
50
- // Getting OVC
51
- const ovc = OvcConverter.convertToOvc(selectInputs());
52
-
53
- // Counting filled variables
54
- const nbFilledVars = Object.keys(ovc.v).reduce((p, c) => {
55
- const currentValue = ovc.v[c];
56
- // eslint-disable-next-line no-nested-ternary
57
- const o: number = Array.isArray(currentValue)
58
- ? currentValue.reduce((_p: number, _c) => _p + (_c !== "" ? 1 : 0), 0)
59
- : currentValue !== ""
60
- ? 1
61
- : 0;
62
- return p + o;
63
- }, 0);
64
-
65
- // Request Body
66
- let body: Record<string, any> = {
67
- ovc,
68
- nb_filled_vars: nbFilledVars,
69
- nb_chosen_options: 0,
70
- email,
71
- tags,
72
- };
73
-
74
- // Creating a new instance if we don't have a uniqid
75
- if (instanceUniqid === undefined || instanceUniqid.length === 0) {
76
- body = {
77
- ...body,
78
- app_type: "wizardx",
79
- draft: 1,
80
- contract_version: selectDocumentModelVersion(),
81
- };
82
- }
83
-
84
- const apiEndpoint =
85
- getConfig().apiEndpoint +
86
- (/\/$/.test(getConfig().apiEndpoint) ? "" : "/");
87
-
88
- const instanceResponse = yield call(
89
- fetch,
90
- `${apiEndpoint}wizard/instance/${permalink}/${instanceUniqid || ""}`,
91
- {
92
- method:
93
- instanceUniqid === undefined || instanceUniqid.length === 0
94
- ? "POST"
95
- : "PUT",
96
- credentials: "include",
97
- headers: {
98
- "Content-Type": "application/json",
99
- ...canalHeaders,
100
- },
101
- body: JSON.stringify(body),
102
- }
103
- );
104
- const response: IInstanceCreationResponse = yield call([
105
- instanceResponse,
106
- "json",
107
- ]);
108
-
109
- /**
110
- * Redirecting user in case we recieved a redirect order
111
- */
112
- const { redirect_to: redirectTo, user, uniqid, isPaid } = response;
113
- if (typeof redirectTo !== "string" || action.disableRedirect) {
114
- if (!instanceUniqid?.length) {
115
- yield put(
116
- initInstanceAction({
117
- dataStatus: "saved",
118
- uniqid,
119
- isPaid: isPaid || false,
120
- steps: [1],
121
- })
122
- );
123
- }
124
- yield put(setUserStatusAction("authenticated"));
125
- if (user) {
126
- yield put(
127
- initUserAction({
128
- ...user,
129
- level: user.role || user.level,
130
- })
131
- );
132
- }
133
- }
134
-
135
- // Identifying user
136
- if (typeof window.sendinblue !== "undefined" && response.user) {
137
- const attributes = yield getSendinblueIdentifyAttributes(
138
- uniqid,
139
- selectDocumentTitle(),
140
- nbFilledVars,
141
- false,
142
- window.location.host
143
- );
144
- window.sendinblue.identify(email, attributes);
145
- const fetchParams = {
146
- method: "POST",
147
- credentials: "include",
148
- headers: {
149
- "Content-Type": "application/json",
150
- },
151
- body: JSON.stringify({
152
- email,
153
- attributes,
154
- }),
155
- };
156
- try {
157
- // if we redirect afterwards we wait for the call to finish otherwise we do it in background
158
- if (typeof redirectTo === "string" && !action.disableRedirect) {
159
- yield call(
160
- // @ts-ignore for some reason saga doesn't like fetchParams being in a seperate variable
161
- fetch,
162
- `${apiEndpoint}event/create/${uniqid}/${uuid()}`,
163
- fetchParams
164
- );
165
- } else {
166
- yield fork(
167
- // @ts-ignore for some reason saga doesn't like fetchParams being in a seperate variable
168
- fetch,
169
- `${apiEndpoint}event/create/${uniqid}/${uuid()}`,
170
- fetchParams
171
- );
172
- }
173
- } catch (error) {
174
- // keep going in case the request fail for now
175
- }
176
- }
177
-
178
- try {
179
- if (redirectTo && redirectTo.includes("generation"))
180
- window.dataLayer.push(
181
- getContractFunnelGAEvent({
182
- currentStep: 1,
183
- contractName: selectDocumentTitle(),
184
- sectionTitle: "Choississez votre pack",
185
- pageAction: "Confirmation avant paiement 1 | 2",
186
- })
187
- );
188
- } catch (error) {
189
- // eslint-disable-next-line
190
- console.error(error);
191
- }
192
- // Redirecting user
193
- if (typeof redirectTo === "string" && !action.disableRedirect) {
194
- // Disabling onbeforeunload
195
- window.onbeforeunload = () => {};
196
-
197
- // Add 1 second before redirection to wait for all HTTP requests to finish
198
- setTimeout(() => {
199
- window.location.href = redirectTo;
200
- }, 1000);
201
- }
202
-
203
- const availableAppStates = [...selectAvailableAppStates()];
204
- availableAppStates.splice(availableAppStates.indexOf("email"), 1);
205
-
206
- // Updating appstates
207
- yield put(updateAvailableAppStatesAction(availableAppStates));
208
- if (!inBackground) yield put(goNextPageAction());
209
- yield put(setUserEmailSucceeded());
210
- } catch (e) {
211
- // eslint-disable-next-line no-console
212
- console.error(e);
213
- yield put(setUserStatusAction("inprogress"));
214
- }
215
- }
216
-
217
- function* setUserEmailSaga() {
218
- yield takeLatest(SET_USER_EMAIL, setUserEmailDecorator);
219
- }
220
-
221
- export default setUserEmailSaga;
@@ -1,162 +0,0 @@
1
- import { createAppStore, getStore } from '../store';
2
- import {
3
- initPaginationAction,
4
- initMetaAction,
5
- initInstanceAction,
6
- } from '../actions/app';
7
- import {
8
- selectCurrentPage,
9
- selectCurrentSectionId,
10
- selectAvailableSections,
11
- selectPermalink,
12
- selectDocumentId,
13
- selectDocumentTitle,
14
- selectInstanceUniqid,
15
- selectInstanceIsPaid,
16
- } from './app';
17
-
18
- // Initiating state
19
- createAppStore('memory');
20
- const store = getStore();
21
-
22
- describe('App selectors test suit', () => {
23
- it('Returns current page correctly', () => {
24
- // Initiating pagination
25
- store.dispatch(
26
- initPaginationAction({
27
- currentSectionId: 1,
28
- currentPage: 13,
29
- greatestPage: 1,
30
- availableSections: [1, 2, 3],
31
- availableAppStates: ['wizard'],
32
- currentAppState: 'wizard',
33
- })
34
- );
35
-
36
- const selector = selectCurrentPage();
37
-
38
- expect(selector).toBe(13);
39
- });
40
-
41
- it('Returns current section id correctly', () => {
42
- // Initiating pagination
43
- store.dispatch(
44
- initPaginationAction({
45
- currentSectionId: 32,
46
- currentPage: 13,
47
- greatestPage: 13,
48
- availableSections: [1, 2, 3],
49
- availableAppStates: ['wizard'],
50
- currentAppState: 'wizard',
51
- })
52
- );
53
-
54
- const selector = selectCurrentSectionId();
55
-
56
- expect(selector).toBe(32);
57
- });
58
-
59
- it('Returns available sections correctly', () => {
60
- // Initiating pagination
61
- store.dispatch(
62
- initPaginationAction({
63
- currentSectionId: 32,
64
- currentPage: 13,
65
- greatestPage: 13,
66
- availableSections: [1, 2, 3],
67
- availableAppStates: ['wizard'],
68
- currentAppState: 'wizard',
69
- })
70
- );
71
-
72
- const selector = selectAvailableSections();
73
-
74
- expect(selector).toEqual([1, 2, 3]);
75
- });
76
-
77
- it('Returns permalink correctly', () => {
78
- // Initiating pagination
79
- store.dispatch(
80
- initMetaAction({
81
- permalink: 'some-permalink',
82
- title: 'Some title',
83
- prefix: '',
84
- id: 123,
85
- modelVersion: 1,
86
- productType: 'demarche',
87
- })
88
- );
89
-
90
- const selector = selectPermalink();
91
-
92
- expect(selector).toBe('some-permalink');
93
- });
94
-
95
- it('Returns document id correctly', () => {
96
- // Initiating pagination
97
- store.dispatch(
98
- initMetaAction({
99
- permalink: 'some-permalink',
100
- title: 'Some title',
101
- prefix: '',
102
- id: 123,
103
- modelVersion: 1,
104
- productType: 'demarche',
105
- })
106
- );
107
-
108
- const selector = selectDocumentId();
109
-
110
- expect(selector).toBe(123);
111
- });
112
-
113
- it('Returns document title correctly', () => {
114
- // Initiating pagination
115
- store.dispatch(
116
- initMetaAction({
117
- permalink: 'some-permalink',
118
- title: 'Some title',
119
- prefix: '',
120
- id: 123,
121
- modelVersion: 1,
122
- productType: 'demarche',
123
- })
124
- );
125
-
126
- const selector = selectDocumentTitle();
127
-
128
- expect(selector).toBe('Some title');
129
- });
130
-
131
- it('Returns instance uniqid correctly', () => {
132
- // Initiating pagination
133
- store.dispatch(
134
- initInstanceAction({
135
- dataStatus: 'saved',
136
- uniqid: 'SomeUNiqID',
137
- isPaid: false,
138
- steps: '*',
139
- })
140
- );
141
-
142
- const selector = selectInstanceUniqid();
143
-
144
- expect(selector).toBe('SomeUNiqID');
145
- });
146
-
147
- it('Returns instance isPaid correctly', () => {
148
- // Initiating pagination
149
- store.dispatch(
150
- initInstanceAction({
151
- dataStatus: 'saved',
152
- uniqid: 'SomeUNiqID',
153
- isPaid: true,
154
- steps: '*',
155
- })
156
- );
157
-
158
- const selector = selectInstanceIsPaid();
159
-
160
- expect(selector).toBeTruthy();
161
- });
162
- });
@@ -1,331 +0,0 @@
1
- import { createSelector } from "./selectors";
2
- import { selectOptionInput } from "./inputs";
3
- import { StateType } from "../../types/State.type";
4
-
5
- /**
6
- * Returns current page number
7
- */
8
- export const selectCurrentPage = createSelector(
9
- (state: StateType) => state.app.pagination.currentPage,
10
- (state: StateType) => state.app.pagination.currentPage.toString()
11
- );
12
-
13
- /**
14
- * Returns availableAppStates
15
- */
16
- export const selectAvailableAppStates = createSelector(
17
- (state: StateType) => state.app.pagination.availableAppStates,
18
- (state: StateType) => state.app.pagination.availableAppStates.join("-")
19
- );
20
-
21
- /**
22
- * Returns currentAppState
23
- */
24
- export const selectCurrentAppState = createSelector(
25
- (state: StateType) => state.app.pagination.currentAppState,
26
- (state: StateType) => state.app.pagination.currentAppState
27
- );
28
-
29
- /**
30
- * Returns isFirstPage
31
- */
32
- export const selectIsFirstPage = createSelector(
33
- (state: StateType) => state.app.pagination.isFirstPage,
34
- (state: StateType) => state.app.pagination.isFirstPage.toString()
35
- );
36
-
37
- /**
38
- * Returns isLastPage
39
- */
40
- export const selectIsLastPage = createSelector(
41
- (state: StateType) => state.app.pagination.isLastPage,
42
- (state: StateType) => state.app.pagination.isLastPage.toString()
43
- );
44
-
45
- export const selectIsLastWizardPage = createSelector(
46
- (state: StateType) =>
47
- state.app.pagination.currentPage ===
48
- state.app.wizard.availableSections.length,
49
- (state: StateType) => state.app.pagination.currentPage.toString()
50
- );
51
-
52
- /**
53
- * Returns greatest page user went to
54
- */
55
- export const selectGreatestPage = createSelector(
56
- (state: StateType) => state.app.pagination.greatestPage,
57
- (state: StateType) => state.app.pagination.greatestPage
58
- );
59
-
60
- /**
61
- * Returns current section id
62
- */
63
- export const selectCurrentSectionId = createSelector(
64
- (state: StateType) => state.app.wizard.currentSectionId,
65
- (state: StateType) => state.app.wizard.currentSectionId
66
- );
67
-
68
- /**
69
- * Returns current available sections
70
- */
71
- export const selectAvailableSections = createSelector(
72
- (state: StateType) => [...state.app.wizard.availableSections],
73
- (state: StateType) =>
74
- state.app.wizard.availableSections.reduce((p, c) => p + c, 0)
75
- );
76
-
77
- /**
78
- * Returns all available options
79
- */
80
- export const selectAvailableOptions = createSelector(
81
- (state: StateType, document = "main") => {
82
- let availableOptions: number[] = [];
83
-
84
- const { availableSections } = state.app.wizard;
85
- const documentSections = Object.keys(
86
- state.references.sections[document]
87
- ).map((id) => parseInt(id, 10));
88
- const sections = document === "main" ? availableSections : documentSections;
89
-
90
- sections.forEach((sectionId) => {
91
- const { options } = state.references.sections[document][sectionId];
92
- availableOptions = [...availableOptions, ...options];
93
- });
94
- return availableOptions;
95
- },
96
- (state: StateType, document = "main") => {
97
- if (document === "main")
98
- return state.app.wizard.availableSections.reduce(
99
- (a, b) => `${a}${b}`,
100
- ""
101
- );
102
- return document;
103
- }
104
- );
105
-
106
- /**
107
- * Returns all multiples occurencies
108
- */
109
- export const selectMultipleOccurencies = createSelector(
110
- (state: StateType) => {
111
- const multipleOptionsOccurencies: Record<string, number> = {};
112
- const availableOptions = selectAvailableOptions("main");
113
- if (availableOptions === undefined) return {};
114
- availableOptions.forEach((optionId) => {
115
- const ref = state.references.options[optionId];
116
- if (ref.meta.multiple?.enabled === true) {
117
- multipleOptionsOccurencies[optionId] =
118
- selectOptionInput(optionId).length;
119
- }
120
- });
121
- return multipleOptionsOccurencies;
122
- },
123
- () => Math.random()
124
- );
125
-
126
- export const selectOutputsIds = createSelector(
127
- (state: StateType, document: string): [number, string][] => {
128
- const availableOptions = selectAvailableOptions(document);
129
- if (availableOptions === undefined) return [];
130
- const outputs = availableOptions.map((optionId): [number, string] => {
131
- const ref = state.references.options[optionId];
132
- return [optionId, ref.meta.type];
133
- });
134
-
135
- return outputs;
136
- },
137
- (state: StateType, document: string) => {
138
- if (document !== "main") return document;
139
- return state.app.wizard.availableSections.reduce((a, b) => `${a}${b}`, "");
140
- }
141
- );
142
-
143
- /**
144
- * Returns permalink
145
- */
146
- export const selectPermalink = createSelector(
147
- (state: StateType) => state.app.meta.permalink,
148
- (state: StateType) => state.app.meta.permalink
149
- );
150
-
151
- /**
152
- * Returns title
153
- */
154
- export const selectDocumentTitle = createSelector(
155
- (state: StateType) => state.app.meta.title,
156
- (state: StateType) => state.app.meta.title
157
- );
158
-
159
- /**
160
- * Returns title
161
- */
162
- export const selectDocumentId = createSelector(
163
- (state: StateType) => state.app.meta.id,
164
- (state: StateType) => state.app.meta.id
165
- );
166
-
167
- /**
168
- * Returns modelVersion
169
- */
170
- export const selectDocumentModelVersion = createSelector(
171
- (state: StateType) => state.app.meta.modelVersion,
172
- (state: StateType) => state.app.meta.modelVersion
173
- );
174
-
175
- /**
176
- * Returns productType
177
- */
178
- export const selectDocumentProductType = createSelector(
179
- (state: StateType) => state.app.meta.productType,
180
- (state: StateType) => state.app.meta.productType
181
- );
182
-
183
- /**
184
- * Returns product title
185
- */
186
- export const selectMeta = createSelector(
187
- (state: StateType) => state.app.meta,
188
- (state: StateType) => state.app.meta.title
189
- );
190
-
191
- /**
192
- * Returns meta Fetch status
193
- */
194
- export const selectMetaFetchStatus = createSelector(
195
- (state: StateType) => state.app.meta.fetchStatus,
196
- (state: StateType) => state.app.meta.fetchStatus
197
- );
198
-
199
- /**
200
- * Returns organization prefix
201
- */
202
- export const selectPrefix = createSelector(
203
- (state: StateType) => (!state.app.meta ? undefined : state.app.meta.prefix),
204
- (state: StateType) => (!state.app.meta ? "0" : state.app.meta.permalink)
205
- );
206
-
207
- /**
208
- * Returns instance's uniqid
209
- */
210
- export const selectInstanceUniqid = createSelector(
211
- (state: StateType) =>
212
- !state.app.instance ? undefined : state.app.instance.uniqid,
213
- (state: StateType) => (!state.app.instance ? "0" : state.app.instance.uniqid)
214
- );
215
-
216
- /**
217
- * Returns instance's companyId
218
- */
219
- export const selectInstanceCompanyId = createSelector(
220
- (state: StateType) =>
221
- !state.app.instance ? undefined : state.app.instance.companyId,
222
- (state: StateType) =>
223
- !state.app.instance || !state.app.instance.companyId
224
- ? "0"
225
- : state.app.instance.companyId
226
- );
227
-
228
- /**
229
- * Returns instance's employeeId
230
- */
231
- export const selectInstanceEmployeeId = createSelector(
232
- (state: StateType) =>
233
- !state.app.instance ? undefined : state.app.instance.employeeId,
234
- (state: StateType) =>
235
- !state.app.instance || !state.app.instance.employeeId
236
- ? "0"
237
- : state.app.instance.employeeId
238
- );
239
-
240
- /**
241
- * Returns instance's data status
242
- */
243
- export const selectDataStatus = createSelector(
244
- (state: StateType) =>
245
- !state.app.instance ? "unsaved" : state.app.instance.dataStatus,
246
- (state: StateType) =>
247
- !state.app.instance ? "0" : state.app.instance.dataStatus
248
- );
249
-
250
- /**
251
- * Returns instance's uniqid
252
- */
253
- export const selectInstanceIsPaid = createSelector(
254
- (state: StateType) => !!(state.app.instance && state.app.instance.isPaid),
255
- (state: StateType) =>
256
- state.app.instance && state.app.instance.isPaid
257
- ? state.app.instance.isPaid.toString()
258
- : "0"
259
- );
260
-
261
- /**
262
- * Returns instance's steps
263
- */
264
- export const selectInstanceSteps = createSelector(
265
- (state: StateType) => !!(state.app.instance && state.app.instance.steps),
266
- (state: StateType) =>
267
- state.app.instance && state.app.instance.steps
268
- ? state.app.instance.steps.toString()
269
- : "0"
270
- );
271
-
272
- /**
273
- * Verifies whether step is available for insatnce
274
- */
275
- export const isStepAvailable = createSelector(
276
- (state: StateType, steps: "*" | number[] | undefined) => {
277
- if (steps === undefined) return true;
278
-
279
- // If instance isn't defined
280
- if (state.app.instance === undefined)
281
- return steps === "*" ? true : steps.includes(1);
282
-
283
- // If step is accessible by all
284
- if (steps === "*") return true;
285
-
286
- // If instance gives access to all steps
287
- if (state.app.instance.steps === "*") return true;
288
- return state.app.instance.steps
289
- .map((c) => steps.includes(c))
290
- .reduce((a, b) => a || b, false);
291
- },
292
- (state: StateType, steps) =>
293
- state.app.instance && state.app.instance.steps && steps
294
- ? `${state.app.instance.steps.toString()}-${steps.toString()}`
295
- : "0"
296
- );
297
-
298
- /**
299
- * Returns customization extracts
300
- */
301
- export const selectCustomizationMeta = createSelector(
302
- (state: StateType) => state.app.customization.meta,
303
- (state: StateType) =>
304
- state.app.customization.meta !== undefined ? "1" : Math.random()
305
- );
306
-
307
- /**
308
- * Returns customization disableAutoDefault
309
- */
310
- export const selectCustomizationAutoDefaultType = createSelector(
311
- (state: StateType) => state.app.customization.disableAutoDefault,
312
- (state: StateType) =>
313
- state.app.customization.disableAutoDefault !== undefined
314
- ? "1"
315
- : Math.random()
316
- );
317
-
318
- /**
319
- * Returns Model's UUID
320
- */
321
- export const selectModelUuid = createSelector(
322
- (state: StateType) => state.app.meta.modelUuid,
323
- (state: StateType) =>
324
- state.app.meta.modelUuid !== undefined ? "1" : Math.random()
325
- );
326
-
327
- export const CompletelyUnusedSelector = createSelector(
328
- (state: StateType) => state.app.meta.modelUuid,
329
- (state: StateType) =>
330
- state.app.meta.modelUuid !== undefined ? "1" : Math.random()
331
- );