@zeniai/client-epic-state 5.0.92 → 5.0.93-beta0ND

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 (260) hide show
  1. package/lib/common/aiCfo/aiCfoSuggestedQuestionsPageContext.d.ts +1 -1
  2. package/lib/commonStateTypes/animations.d.ts +1 -1
  3. package/lib/commonStateTypes/animations.js +1 -0
  4. package/lib/entity/aiCfo/aiCfoPayload.d.ts +63 -5
  5. package/lib/entity/aiCfo/aiCfoReducer.d.ts +23 -2
  6. package/lib/entity/aiCfo/aiCfoReducer.js +249 -9
  7. package/lib/entity/aiCfo/aiCfoSelector.d.ts +4 -1
  8. package/lib/entity/aiCfo/aiCfoSelector.js +19 -1
  9. package/lib/entity/aiCfo/aiCfoState.d.ts +97 -4
  10. package/lib/entity/aiCfo/aiCfoState.js +18 -1
  11. package/lib/entity/cardPolicy/cardPolicyPayload.d.ts +277 -0
  12. package/lib/entity/cardPolicy/cardPolicyPayload.js +143 -0
  13. package/lib/entity/cardPolicy/cardPolicyReducer.d.ts +19 -0
  14. package/lib/entity/cardPolicy/cardPolicyReducer.js +175 -0
  15. package/lib/entity/cardPolicy/cardPolicySelector.d.ts +32 -0
  16. package/lib/entity/cardPolicy/cardPolicySelector.js +99 -0
  17. package/lib/entity/cardPolicy/cardPolicyState.d.ts +205 -0
  18. package/lib/entity/cardPolicy/cardPolicyState.js +14 -0
  19. package/lib/entity/cardPolicy/extractPolicyDocumentEpic.d.ts +18 -0
  20. package/lib/entity/cardPolicy/extractPolicyDocumentEpic.js +68 -0
  21. package/lib/entity/cardPolicy/fetchCardPolicyVendorOptionsEpic.d.ts +26 -0
  22. package/lib/entity/cardPolicy/fetchCardPolicyVendorOptionsEpic.js +47 -0
  23. package/lib/entity/cardPolicy/policyDocumentExtractionToRecommendationBridgeEpic.d.ts +25 -0
  24. package/lib/entity/cardPolicy/policyDocumentExtractionToRecommendationBridgeEpic.js +39 -0
  25. package/lib/entity/cardPolicy/policyRecommendationFromUploadEpic.d.ts +24 -0
  26. package/lib/entity/cardPolicy/policyRecommendationFromUploadEpic.js +105 -0
  27. package/lib/entity/company/companyPayload.d.ts +4 -0
  28. package/lib/entity/company/companyPayload.js +4 -0
  29. package/lib/entity/company/companyStateTypes.d.ts +4 -0
  30. package/lib/entity/jeSchedules/jeSchedulesTypes.d.ts +1 -1
  31. package/lib/entity/monthEndCloseChecks/monthEndCloseChecksState.d.ts +1 -1
  32. package/lib/entity/paymentAccount/paymentAccountSelector.d.ts +1 -0
  33. package/lib/entity/paymentAccount/paymentAccountSelector.js +4 -0
  34. package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
  35. package/lib/entity/snackbar/snackbarTypes.js +3 -0
  36. package/lib/entity/tenant/clearAllEpic.d.ts +6 -2
  37. package/lib/entity/tenant/clearAllEpic.js +8 -0
  38. package/lib/entity/tenant/epic/deleteConnectionEpic.d.ts +1 -1
  39. package/lib/entity/tenant/epic/initEmailConnectOAuthEpic.d.ts +21 -0
  40. package/lib/entity/tenant/epic/initEmailConnectOAuthEpic.js +54 -0
  41. package/lib/entity/tenant/epic/saveAPIKeyConnectionEpic.d.ts +1 -1
  42. package/lib/entity/tenant/epic/saveConnectorCredentialsEpic.d.ts +3 -3
  43. package/lib/entity/tenant/epic/saveOAuthConnectionEpic.d.ts +1 -1
  44. package/lib/entity/tenant/tenantPayload.d.ts +1 -0
  45. package/lib/entity/tenant/tenantReducer.d.ts +38 -25
  46. package/lib/entity/tenant/tenantReducer.js +65 -5
  47. package/lib/entity/tenant/tenantState.d.ts +1 -0
  48. package/lib/epic.d.ts +19 -1
  49. package/lib/epic.js +20 -1
  50. package/lib/esm/commonStateTypes/animations.js +1 -0
  51. package/lib/esm/entity/aiCfo/aiCfoReducer.js +249 -9
  52. package/lib/esm/entity/aiCfo/aiCfoSelector.js +17 -1
  53. package/lib/esm/entity/aiCfo/aiCfoState.js +15 -0
  54. package/lib/esm/entity/cardPolicy/cardPolicyPayload.js +130 -0
  55. package/lib/esm/entity/cardPolicy/cardPolicyReducer.js +171 -0
  56. package/lib/esm/entity/cardPolicy/cardPolicySelector.js +75 -0
  57. package/lib/esm/entity/cardPolicy/cardPolicyState.js +9 -0
  58. package/lib/esm/entity/cardPolicy/extractPolicyDocumentEpic.js +64 -0
  59. package/lib/esm/entity/cardPolicy/fetchCardPolicyVendorOptionsEpic.js +43 -0
  60. package/lib/esm/entity/cardPolicy/policyDocumentExtractionToRecommendationBridgeEpic.js +35 -0
  61. package/lib/esm/entity/cardPolicy/policyRecommendationFromUploadEpic.js +101 -0
  62. package/lib/esm/entity/company/companyPayload.js +4 -0
  63. package/lib/esm/entity/paymentAccount/paymentAccountSelector.js +3 -0
  64. package/lib/esm/entity/snackbar/snackbarTypes.js +3 -0
  65. package/lib/esm/entity/tenant/clearAllEpic.js +8 -0
  66. package/lib/esm/entity/tenant/epic/initEmailConnectOAuthEpic.js +50 -0
  67. package/lib/esm/entity/tenant/tenantReducer.js +63 -3
  68. package/lib/esm/epic.js +20 -1
  69. package/lib/esm/index.js +46 -13
  70. package/lib/esm/reducer.js +12 -0
  71. package/lib/esm/view/aiCfoView/aiCfoViewReducer.js +6 -3
  72. package/lib/esm/view/aiCfoView/epics/createSessionAndSubmitEpic.js +5 -2
  73. package/lib/esm/view/aiCfoView/epics/createSessionEpic.js +2 -1
  74. package/lib/esm/view/aiCfoView/epics/fetchSuggestedQuestionsEpic.js +12 -2
  75. package/lib/esm/view/fileView/epic/deleteFileEpic.js +2 -2
  76. package/lib/esm/view/fileView/epic/deleteFileListEpic.js +2 -2
  77. package/lib/esm/view/fileView/epic/updateFileNameEpic.js +2 -2
  78. package/lib/esm/view/onboardingView/customerView/epic/aiAgentsActivation/fetchAiAgentsActivationStatusEpic.js +42 -0
  79. package/lib/esm/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiActivationViewedEpic.js +29 -0
  80. package/lib/esm/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiFinanceTeamEpic.js +40 -0
  81. package/lib/esm/view/onboardingView/customerView/onboardingCustomerViewReducer.js +217 -50
  82. package/lib/esm/view/onboardingView/customerView/onboardingCustomerViewSelector.js +7 -1
  83. package/lib/esm/view/onboardingView/customerView/onboardingCustomerViewState.js +12 -0
  84. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailReducer.js +52 -0
  85. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailSelector.js +22 -0
  86. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailState.js +1 -0
  87. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/fetchCardPolicyDetailEpic.js +36 -0
  88. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/updateCardPolicyEpic.js +39 -0
  89. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/archiveCardPolicyEpic.js +34 -0
  90. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListReducer.js +58 -0
  91. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListSelector.js +21 -0
  92. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListState.js +1 -0
  93. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/fetchCardPolicyListEpic.js +38 -0
  94. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/applyAiCardPolicyFormDraftUpdate.js +289 -0
  95. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/applyExtractedPolicyToAiCardPolicyDraft.js +109 -0
  96. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/applyExtractedPolicyToDraftEpic.js +44 -0
  97. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/applyExtractedPolicyToManualCardPolicyDraft.js +111 -0
  98. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/applyUploadPlanToAiCardPolicyDraft.js +25 -0
  99. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/buildAiCardPolicyFormDraftSeed.js +363 -0
  100. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/buildManualCardPolicyFormDraftSeed.js +36 -0
  101. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/cardPolicyChipIds.js +19 -0
  102. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/cardPolicyFormDraftTypes.js +6 -0
  103. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/cardPolicyRequestParts.js +119 -0
  104. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyReducer.js +154 -0
  105. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicySelector.js +22 -0
  106. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyState.js +1 -0
  107. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyTemplateEpic.js +39 -0
  108. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/deriveAiPolicyReviewRowsFromInputs.js +140 -0
  109. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/fetchCardPolicyMccCategoriesEpic.js +20 -0
  110. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/seedAiCardPolicyFormDraftEpic.js +100 -0
  111. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/toBulkCardPolicyTemplateRequestsFromDraft.js +96 -0
  112. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/toCardPolicyTemplateRequestFromDraft.js +59 -0
  113. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/toManualCardPolicyTemplateRequestFromDraft.js +24 -0
  114. package/lib/esm/view/spendManagement/chargeCards/chargeCardList/chargeCardListSelector.js +25 -0
  115. package/lib/esm/view/spendManagement/chargeCards/issueChargeCard/aiCardCreationFormDraftTypes.js +1 -0
  116. package/lib/esm/view/spendManagement/chargeCards/issueChargeCard/applyAiCardCreationFormDraftUpdate.js +34 -0
  117. package/lib/esm/view/spendManagement/chargeCards/issueChargeCard/buildAiCardCreationFormDraftSeed.js +57 -0
  118. package/lib/esm/view/spendManagement/chargeCards/issueChargeCard/deriveAiCardRowsFromTeams.js +35 -0
  119. package/lib/esm/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardEpic.js +2 -2
  120. package/lib/esm/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardReducer.js +42 -4
  121. package/lib/esm/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardSelector.js +35 -0
  122. package/lib/esm/view/spendManagement/chargeCards/issueChargeCard/seedAiCardCreationFormDraftEpic.js +62 -0
  123. package/lib/esm/view/spendManagement/chargeCards/issueChargeCard/toIssueChargeCardLocalDataFromDraft.js +44 -0
  124. package/lib/esm/view/spendManagement/commonSetup/epic/setup/parseUploadedKybDocumentEpic.js +58 -0
  125. package/lib/esm/view/spendManagement/commonSetup/epic/setup/parseUploadedKycDocumentEpic.js +67 -0
  126. package/lib/esm/view/spendManagement/commonSetup/kycKybAutofillActions.js +14 -0
  127. package/lib/esm/view/spendManagement/commonSetup/kycKybParseMapper.js +205 -0
  128. package/lib/esm/view/spendManagement/commonSetup/setupViewReducer.js +105 -52
  129. package/lib/esm/view/spendManagement/commonSetup/setupViewSelector.js +6 -1
  130. package/lib/esm/view/spendManagement/commonSetup/types/kycKybAutofill.js +28 -0
  131. package/lib/index.d.ts +52 -14
  132. package/lib/index.js +219 -31
  133. package/lib/reducer.d.ts +12 -0
  134. package/lib/reducer.js +12 -0
  135. package/lib/view/aiCfoView/aiCfoViewReducer.d.ts +11 -2
  136. package/lib/view/aiCfoView/aiCfoViewReducer.js +6 -3
  137. package/lib/view/aiCfoView/epics/createSessionAndSubmitEpic.js +5 -2
  138. package/lib/view/aiCfoView/epics/createSessionEpic.js +2 -1
  139. package/lib/view/aiCfoView/epics/fetchSuggestedQuestionsEpic.d.ts +8 -1
  140. package/lib/view/aiCfoView/epics/fetchSuggestedQuestionsEpic.js +12 -2
  141. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
  142. package/lib/view/expenseAutomationView/types/reconciliationViewState.d.ts +1 -1
  143. package/lib/view/fileView/epic/deleteFileEpic.js +1 -1
  144. package/lib/view/fileView/epic/deleteFileListEpic.js +1 -1
  145. package/lib/view/fileView/epic/updateFileNameEpic.js +1 -1
  146. package/lib/view/onboardingView/customerView/epic/aiAgentsActivation/fetchAiAgentsActivationStatusEpic.d.ts +7 -0
  147. package/lib/view/onboardingView/customerView/epic/aiAgentsActivation/fetchAiAgentsActivationStatusEpic.js +46 -0
  148. package/lib/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiActivationViewedEpic.d.ts +8 -0
  149. package/lib/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiActivationViewedEpic.js +33 -0
  150. package/lib/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiFinanceTeamEpic.d.ts +9 -0
  151. package/lib/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiFinanceTeamEpic.js +44 -0
  152. package/lib/view/onboardingView/customerView/onboardingCustomerViewPayload.d.ts +3 -0
  153. package/lib/view/onboardingView/customerView/onboardingCustomerViewReducer.d.ts +41 -4
  154. package/lib/view/onboardingView/customerView/onboardingCustomerViewReducer.js +219 -51
  155. package/lib/view/onboardingView/customerView/onboardingCustomerViewSelector.d.ts +5 -1
  156. package/lib/view/onboardingView/customerView/onboardingCustomerViewSelector.js +11 -2
  157. package/lib/view/onboardingView/customerView/onboardingCustomerViewState.d.ts +40 -0
  158. package/lib/view/onboardingView/customerView/onboardingCustomerViewState.js +13 -1
  159. package/lib/view/people/peopleTypes.d.ts +1 -1
  160. package/lib/view/scheduleView/scheduleListView/scheduleListTypes.d.ts +1 -1
  161. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailReducer.d.ts +14 -0
  162. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailReducer.js +56 -0
  163. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailSelector.d.ts +15 -0
  164. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailSelector.js +28 -0
  165. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailState.d.ts +8 -0
  166. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailState.js +2 -0
  167. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/fetchCardPolicyDetailEpic.d.ts +8 -0
  168. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/fetchCardPolicyDetailEpic.js +40 -0
  169. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/updateCardPolicyEpic.d.ts +8 -0
  170. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/updateCardPolicyEpic.js +43 -0
  171. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/archiveCardPolicyEpic.d.ts +8 -0
  172. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/archiveCardPolicyEpic.js +38 -0
  173. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListReducer.d.ts +15 -0
  174. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListReducer.js +62 -0
  175. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListSelector.d.ts +15 -0
  176. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListSelector.js +27 -0
  177. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListState.d.ts +7 -0
  178. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListState.js +2 -0
  179. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/fetchCardPolicyListEpic.d.ts +8 -0
  180. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/fetchCardPolicyListEpic.js +42 -0
  181. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/applyAiCardPolicyFormDraftUpdate.d.ts +8 -0
  182. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/applyAiCardPolicyFormDraftUpdate.js +294 -0
  183. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/applyExtractedPolicyToAiCardPolicyDraft.d.ts +8 -0
  184. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/applyExtractedPolicyToAiCardPolicyDraft.js +113 -0
  185. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/applyExtractedPolicyToDraftEpic.d.ts +9 -0
  186. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/applyExtractedPolicyToDraftEpic.js +48 -0
  187. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/applyExtractedPolicyToManualCardPolicyDraft.d.ts +8 -0
  188. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/applyExtractedPolicyToManualCardPolicyDraft.js +115 -0
  189. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/applyUploadPlanToAiCardPolicyDraft.d.ts +13 -0
  190. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/applyUploadPlanToAiCardPolicyDraft.js +29 -0
  191. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/buildAiCardPolicyFormDraftSeed.d.ts +14 -0
  192. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/buildAiCardPolicyFormDraftSeed.js +369 -0
  193. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/buildManualCardPolicyFormDraftSeed.d.ts +6 -0
  194. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/buildManualCardPolicyFormDraftSeed.js +40 -0
  195. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/cardPolicyChipIds.d.ts +7 -0
  196. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/cardPolicyChipIds.js +26 -0
  197. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/cardPolicyFormDraftTypes.d.ts +116 -0
  198. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/cardPolicyFormDraftTypes.js +10 -0
  199. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/cardPolicyRequestParts.d.ts +33 -0
  200. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/cardPolicyRequestParts.js +126 -0
  201. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyReducer.d.ts +52 -0
  202. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyReducer.js +158 -0
  203. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicySelector.d.ts +11 -0
  204. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicySelector.js +31 -0
  205. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyState.d.ts +12 -0
  206. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyState.js +2 -0
  207. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyTemplateEpic.d.ts +8 -0
  208. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyTemplateEpic.js +43 -0
  209. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/deriveAiPolicyReviewRowsFromInputs.d.ts +10 -0
  210. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/deriveAiPolicyReviewRowsFromInputs.js +144 -0
  211. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/fetchCardPolicyMccCategoriesEpic.d.ts +7 -0
  212. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/fetchCardPolicyMccCategoriesEpic.js +24 -0
  213. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/seedAiCardPolicyFormDraftEpic.d.ts +11 -0
  214. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/seedAiCardPolicyFormDraftEpic.js +104 -0
  215. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/toBulkCardPolicyTemplateRequestsFromDraft.d.ts +22 -0
  216. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/toBulkCardPolicyTemplateRequestsFromDraft.js +100 -0
  217. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/toCardPolicyTemplateRequestFromDraft.d.ts +8 -0
  218. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/toCardPolicyTemplateRequestFromDraft.js +63 -0
  219. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/toManualCardPolicyTemplateRequestFromDraft.d.ts +3 -0
  220. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/toManualCardPolicyTemplateRequestFromDraft.js +28 -0
  221. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardList.d.ts +1 -1
  222. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListSelector.d.ts +14 -0
  223. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListSelector.js +27 -1
  224. package/lib/view/spendManagement/chargeCards/issueChargeCard/aiCardCreationFormDraftTypes.d.ts +34 -0
  225. package/lib/view/spendManagement/chargeCards/issueChargeCard/aiCardCreationFormDraftTypes.js +2 -0
  226. package/lib/view/spendManagement/chargeCards/issueChargeCard/applyAiCardCreationFormDraftUpdate.d.ts +7 -0
  227. package/lib/view/spendManagement/chargeCards/issueChargeCard/applyAiCardCreationFormDraftUpdate.js +38 -0
  228. package/lib/view/spendManagement/chargeCards/issueChargeCard/buildAiCardCreationFormDraftSeed.d.ts +12 -0
  229. package/lib/view/spendManagement/chargeCards/issueChargeCard/buildAiCardCreationFormDraftSeed.js +61 -0
  230. package/lib/view/spendManagement/chargeCards/issueChargeCard/deriveAiCardRowsFromTeams.d.ts +9 -0
  231. package/lib/view/spendManagement/chargeCards/issueChargeCard/deriveAiCardRowsFromTeams.js +39 -0
  232. package/lib/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardEpic.d.ts +2 -2
  233. package/lib/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardEpic.js +1 -1
  234. package/lib/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardReducer.d.ts +12 -2
  235. package/lib/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardReducer.js +43 -5
  236. package/lib/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardSelector.d.ts +7 -0
  237. package/lib/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardSelector.js +42 -1
  238. package/lib/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardState.d.ts +5 -0
  239. package/lib/view/spendManagement/chargeCards/issueChargeCard/seedAiCardCreationFormDraftEpic.d.ts +11 -0
  240. package/lib/view/spendManagement/chargeCards/issueChargeCard/seedAiCardCreationFormDraftEpic.js +66 -0
  241. package/lib/view/spendManagement/chargeCards/issueChargeCard/toIssueChargeCardLocalDataFromDraft.d.ts +3 -0
  242. package/lib/view/spendManagement/chargeCards/issueChargeCard/toIssueChargeCardLocalDataFromDraft.js +48 -0
  243. package/lib/view/spendManagement/commonSetup/epic/setup/parseUploadedKybDocumentEpic.d.ts +28 -0
  244. package/lib/view/spendManagement/commonSetup/epic/setup/parseUploadedKybDocumentEpic.js +62 -0
  245. package/lib/view/spendManagement/commonSetup/epic/setup/parseUploadedKycDocumentEpic.d.ts +30 -0
  246. package/lib/view/spendManagement/commonSetup/epic/setup/parseUploadedKycDocumentEpic.js +71 -0
  247. package/lib/view/spendManagement/commonSetup/kycKybAutofillActions.d.ts +33 -0
  248. package/lib/view/spendManagement/commonSetup/kycKybAutofillActions.js +17 -0
  249. package/lib/view/spendManagement/commonSetup/kycKybParseMapper.d.ts +24 -0
  250. package/lib/view/spendManagement/commonSetup/kycKybParseMapper.js +213 -0
  251. package/lib/view/spendManagement/commonSetup/setupViewReducer.d.ts +28 -2
  252. package/lib/view/spendManagement/commonSetup/setupViewReducer.js +106 -53
  253. package/lib/view/spendManagement/commonSetup/setupViewSelector.d.ts +7 -2
  254. package/lib/view/spendManagement/commonSetup/setupViewSelector.js +6 -1
  255. package/lib/view/spendManagement/commonSetup/setupViewState.d.ts +19 -0
  256. package/lib/view/spendManagement/commonSetup/types/kycKybAutofill.d.ts +142 -0
  257. package/lib/view/spendManagement/commonSetup/types/kycKybAutofill.js +32 -0
  258. package/lib/view/taskManager/taskListView/taskListReducer.d.ts +1 -1
  259. package/lib/view/transactionDetail/journalEntryLinesViewModel.d.ts +1 -1
  260. package/package.json +1 -1
@@ -0,0 +1,19 @@
1
+ // All chip-id producers MUST funnel through here — the picker's dedupe is content-blind
2
+ // (`existing.id === option.id`), so vendors collapse on display name and MCC ids must
3
+ // match the legacy convention saved templates use.
4
+ export const VENDOR_CHIP_ID_PREFIX = 'vendor-';
5
+ export const MCC_CHIP_ID_PREFIX = 'mcc-';
6
+ export const buildVendorChipId = (name) => `${VENDOR_CHIP_ID_PREFIX}${name.trim().toLowerCase()}`;
7
+ export const buildMccCategoryChipId = (name) => `${MCC_CHIP_ID_PREFIX}${name}`;
8
+ export const toVendorChipFieldValue = (name, isSelected) => ({
9
+ id: buildVendorChipId(name),
10
+ label: name,
11
+ isSelected,
12
+ });
13
+ export const toMccCategoryChipFieldValue = (category, isSelected) => ({
14
+ id: buildMccCategoryChipId(category.name),
15
+ label: category.name,
16
+ isSelected,
17
+ optionalCode: category.mccCodes[0],
18
+ optionalCodes: [...category.mccCodes],
19
+ });
@@ -0,0 +1,6 @@
1
+ export const CARD_POLICY_LIMIT_ROW_ID_TRANSACTION = 'transactionLimit';
2
+ export const CARD_POLICY_LIMIT_ROW_ID_REQUIRE_RECEIPT = 'requireReceipt';
3
+ export const toMccCategoryLike = (category) => ({
4
+ name: category.name,
5
+ mccCodes: category.mccCodes,
6
+ });
@@ -0,0 +1,119 @@
1
+ // Wire builders shared by manual and AI CFO drafts.
2
+ // Inactive-side chips stay in form state for fast mode-flip but never go on the wire.
3
+ export const collectMerchantNames = (field, forMode) => {
4
+ if (field.mode !== forMode) {
5
+ return [];
6
+ }
7
+ const items = forMode === 'allow' ? field.allowItems : field.blockItems;
8
+ return items.filter((item) => item.isSelected).map((item) => item.label);
9
+ };
10
+ // `optionalCodes` (plural) emits every code; falls back to the singular
11
+ // `optionalCode`; chips with neither are dropped silently.
12
+ export const collectCategoryCodes = (field, forMode) => {
13
+ if (field.mode !== forMode) {
14
+ return [];
15
+ }
16
+ const items = forMode === 'allow' ? field.allowItems : field.blockItems;
17
+ return items
18
+ .filter((item) => item.isSelected)
19
+ .flatMap((item) => {
20
+ if (item.optionalCodes != null && item.optionalCodes.length > 0) {
21
+ return item.optionalCodes;
22
+ }
23
+ return item.optionalCode != null ? [item.optionalCode] : [];
24
+ });
25
+ };
26
+ // `null` when the toggle is off (BE: "no threshold"); else `amount` (or 0).
27
+ export const amountFromLimitRow = (limits, rowId) => {
28
+ const row = limits.find((entry) => entry.id === rowId);
29
+ if (row == null || !row.isEnabled) {
30
+ return null;
31
+ }
32
+ return row.amount ?? 0;
33
+ };
34
+ const REVIEW_GROUP_ID_ALLOWED_VENDORS = 'allowed-vendors';
35
+ const REVIEW_GROUP_ID_BLOCKED_VENDORS = 'blocked-vendors';
36
+ const REVIEW_GROUP_ID_ALLOWED_CATEGORIES = 'allowed-categories';
37
+ const REVIEW_GROUP_ID_RESTRICTED_CATEGORIES = 'restricted-categories';
38
+ const REVIEW_GROUP_ID_APPLIED_TO_CARDS = 'applied-to-cards';
39
+ const REVIEW_GROUP_ID_LIMITS = 'limits';
40
+ const REVIEW_LIMIT_CHIP_ID_TRANSACTION = 'limit-transaction';
41
+ const REVIEW_LIMIT_CHIP_ID_RECEIPT = 'limit-receipt';
42
+ const isChipOn = (chip) => chip.isSelected !== false;
43
+ const findGroup = (row, groupId) => row.chipGroups.find((group) => group.id === groupId);
44
+ const projectMerchantNamesFromGroup = (group) => group == null ? [] : group.chips.filter(isChipOn).map((chip) => chip.label);
45
+ const projectCategoryCodesFromGroup = (group) => {
46
+ if (group == null) {
47
+ return [];
48
+ }
49
+ const codes = [];
50
+ for (const chip of group.chips) {
51
+ if (!isChipOn(chip)) {
52
+ continue;
53
+ }
54
+ if (chip.optionalCode != null && chip.optionalCode.length > 0) {
55
+ codes.push(chip.optionalCode);
56
+ }
57
+ }
58
+ return codes;
59
+ };
60
+ const projectApplyToCardsFromGroup = (group) => {
61
+ if (group == null) {
62
+ return [];
63
+ }
64
+ const cardIds = [];
65
+ for (const chip of group.chips) {
66
+ if (!isChipOn(chip)) {
67
+ continue;
68
+ }
69
+ if (chip.cardIds != null && chip.cardIds.length > 0) {
70
+ cardIds.push(...chip.cardIds);
71
+ continue;
72
+ }
73
+ cardIds.push(chip.id);
74
+ }
75
+ return cardIds;
76
+ };
77
+ const amountFromLimitsChip = (chip) => {
78
+ if (chip == null || chip.isSelected !== true) {
79
+ return null;
80
+ }
81
+ if (chip.optionalCode == null || chip.optionalCode.length === 0) {
82
+ return 0;
83
+ }
84
+ const parsed = Number(chip.optionalCode);
85
+ return Number.isFinite(parsed) ? parsed : 0;
86
+ };
87
+ // Used when `policyKind === "auto"`, where the row's chip groups are canonical
88
+ // and source slices are empty.
89
+ export const projectAutoReviewRowToCardPolicyRequestParts = (row) => {
90
+ const limitsGroup = findGroup(row, REVIEW_GROUP_ID_LIMITS);
91
+ const transactionChip = limitsGroup?.chips.find((chip) => chip.id === REVIEW_LIMIT_CHIP_ID_TRANSACTION);
92
+ const receiptChip = limitsGroup?.chips.find((chip) => chip.id === REVIEW_LIMIT_CHIP_ID_RECEIPT);
93
+ return {
94
+ allowedEntity: {
95
+ merchantNames: projectMerchantNamesFromGroup(findGroup(row, REVIEW_GROUP_ID_ALLOWED_VENDORS)),
96
+ categoryCodes: projectCategoryCodesFromGroup(findGroup(row, REVIEW_GROUP_ID_ALLOWED_CATEGORIES)),
97
+ },
98
+ blockedEntity: {
99
+ merchantNames: projectMerchantNamesFromGroup(findGroup(row, REVIEW_GROUP_ID_BLOCKED_VENDORS)),
100
+ categoryCodes: projectCategoryCodesFromGroup(findGroup(row, REVIEW_GROUP_ID_RESTRICTED_CATEGORIES)),
101
+ },
102
+ applyToCards: projectApplyToCardsFromGroup(findGroup(row, REVIEW_GROUP_ID_APPLIED_TO_CARDS)),
103
+ spendLimits: { transaction: amountFromLimitsChip(transactionChip) },
104
+ requiredReceiptThreshold: amountFromLimitsChip(receiptChip),
105
+ };
106
+ };
107
+ // Shared by both auto and bulk wire builders.
108
+ export const REVIEW_GROUP_IDS = {
109
+ allowedVendors: REVIEW_GROUP_ID_ALLOWED_VENDORS,
110
+ blockedVendors: REVIEW_GROUP_ID_BLOCKED_VENDORS,
111
+ allowedCategories: REVIEW_GROUP_ID_ALLOWED_CATEGORIES,
112
+ restrictedCategories: REVIEW_GROUP_ID_RESTRICTED_CATEGORIES,
113
+ appliedToCards: REVIEW_GROUP_ID_APPLIED_TO_CARDS,
114
+ limits: REVIEW_GROUP_ID_LIMITS,
115
+ };
116
+ export const REVIEW_LIMIT_CHIP_IDS = {
117
+ transaction: REVIEW_LIMIT_CHIP_ID_TRANSACTION,
118
+ receipt: REVIEW_LIMIT_CHIP_ID_RECEIPT,
119
+ };
@@ -0,0 +1,154 @@
1
+ import { createSlice } from '@reduxjs/toolkit';
2
+ import { applyAiCardPolicyFormDraftUpdate } from './applyAiCardPolicyFormDraftUpdate';
3
+ import { applyExtractedPolicyToAiCardPolicyDraft as applyExtractedToAiDraftHelper } from './applyExtractedPolicyToAiCardPolicyDraft';
4
+ import { applyExtractedPolicyToManualCardPolicyDraft as applyExtractedToManualDraftHelper } from './applyExtractedPolicyToManualCardPolicyDraft';
5
+ import { applyUploadPlanToAiCardPolicyDraft as applyUploadPlanToAiDraftHelper } from './applyUploadPlanToAiCardPolicyDraft';
6
+ import { buildAiCardPolicyFormDraftSeed } from './buildAiCardPolicyFormDraftSeed';
7
+ import { buildManualCardPolicyFormDraftSeed, } from './buildManualCardPolicyFormDraftSeed';
8
+ import { toMccCategoryLike, } from './cardPolicyFormDraftTypes';
9
+ export const initialState = {
10
+ createCardPolicyTemplateRequestState: {
11
+ fetchState: 'Not-Started',
12
+ error: undefined,
13
+ },
14
+ lastCreatedCardPolicyTemplateIds: [],
15
+ lastCreateCardPolicyTemplateErrors: [],
16
+ };
17
+ const createCardPolicy = createSlice({
18
+ name: 'createCardPolicy',
19
+ initialState,
20
+ reducers: {
21
+ createCardPolicyTemplates: {
22
+ reducer(draft, action) {
23
+ draft.createCardPolicyTemplateRequestState.fetchState = 'In-Progress';
24
+ draft.createCardPolicyTemplateRequestState.error = undefined;
25
+ draft.lastCreatedCardPolicyTemplateIds = [];
26
+ draft.lastCreateCardPolicyTemplateErrors = [];
27
+ // Lets list/drawer attribute the in-flight create to its AI CFO session.
28
+ draft.lastCreateCardPolicySourceChatSessionId =
29
+ action.payload.sourceChatSessionId;
30
+ },
31
+ prepare(request) {
32
+ return { payload: request };
33
+ },
34
+ },
35
+ updateCreateCardPolicyTemplateRequestState(draft, action) {
36
+ draft.createCardPolicyTemplateRequestState.fetchState =
37
+ action.payload.fetchState;
38
+ draft.createCardPolicyTemplateRequestState.error = action.payload.error;
39
+ if (action.payload.templateIds != null) {
40
+ draft.lastCreatedCardPolicyTemplateIds = action.payload.templateIds;
41
+ }
42
+ if (action.payload.perItemErrors != null) {
43
+ draft.lastCreateCardPolicyTemplateErrors = action.payload.perItemErrors;
44
+ }
45
+ },
46
+ // Dispatched by `seedAiCardPolicyFormDraftEpic` when the AI answer lands.
47
+ seedAiCardPolicyFormDraft: {
48
+ reducer(draft, action) {
49
+ const { draft: nextDraft, context } = buildAiCardPolicyFormDraftSeed({
50
+ initialData: action.payload.initialData,
51
+ cardsMasterList: action.payload.cardsMasterList,
52
+ categorySearchOptions: action.payload.mccCategories.map(toMccCategoryLike),
53
+ suggestedAllowMerchants: action.payload.suggestedAllowMerchants,
54
+ suggestedBlockMerchants: action.payload.suggestedBlockMerchants,
55
+ suggestedAllowCategories: (action.payload.suggestedAllowCategories ?? []).map(toMccCategoryLike),
56
+ suggestedBlockCategories: (action.payload.suggestedBlockCategories ?? []).map(toMccCategoryLike),
57
+ });
58
+ draft.aiCardPolicyFormDraft = nextDraft;
59
+ draft.aiCardPolicyFormDraftContext = context;
60
+ },
61
+ prepare(payload) {
62
+ return { payload };
63
+ },
64
+ },
65
+ // Per-mode behavior lives in `applyAiCardPolicyFormDraftUpdate`.
66
+ updateAiCardPolicyFormDraft(draft, action) {
67
+ draft.aiCardPolicyFormDraft = applyAiCardPolicyFormDraftUpdate({
68
+ prev: draft.aiCardPolicyFormDraft,
69
+ next: action.payload,
70
+ context: draft.aiCardPolicyFormDraftContext,
71
+ });
72
+ },
73
+ // No-op when the draft isn't in `upload` mode.
74
+ updateAiCardPolicyFormDraftFromUploadPlan: {
75
+ reducer(draft, action) {
76
+ if (draft.aiCardPolicyFormDraft == null ||
77
+ draft.aiCardPolicyFormDraftContext == null) {
78
+ return;
79
+ }
80
+ const { draft: nextDraft, context } = applyUploadPlanToAiDraftHelper({
81
+ current: draft.aiCardPolicyFormDraft,
82
+ context: draft.aiCardPolicyFormDraftContext,
83
+ wizardPlan: action.payload.wizardPlan,
84
+ source: action.payload.source,
85
+ });
86
+ draft.aiCardPolicyFormDraft = nextDraft;
87
+ draft.aiCardPolicyFormDraftContext = context;
88
+ },
89
+ prepare(wizardPlan, source) {
90
+ return { payload: { wizardPlan, source } };
91
+ },
92
+ },
93
+ // Dispatched by the extract-success bridge when the upload originated from
94
+ // inside an AI CFO card-policy form.
95
+ applyExtractedPolicyToAiCardPolicyDraft: {
96
+ reducer(draft, action) {
97
+ if (draft.aiCardPolicyFormDraft == null) {
98
+ return;
99
+ }
100
+ draft.aiCardPolicyFormDraft = applyExtractedToAiDraftHelper({
101
+ current: draft.aiCardPolicyFormDraft,
102
+ extracted: action.payload.extracted,
103
+ vendorSearchOptions: action.payload.vendorSearchOptions,
104
+ categorySearchOptions: action.payload.categorySearchOptions,
105
+ });
106
+ },
107
+ prepare(payload) {
108
+ return { payload };
109
+ },
110
+ },
111
+ clearAiCardPolicyFormDraft(draft) {
112
+ draft.aiCardPolicyFormDraft = undefined;
113
+ draft.aiCardPolicyFormDraftContext = undefined;
114
+ },
115
+ // Dispatched on the manual create-page mount.
116
+ seedManualCardPolicyFormDraft: {
117
+ reducer(draft, action) {
118
+ draft.manualCardPolicyFormDraft = buildManualCardPolicyFormDraftSeed(action.payload);
119
+ },
120
+ prepare(payload) {
121
+ return { payload };
122
+ },
123
+ },
124
+ updateManualCardPolicyFormDraft(draft, action) {
125
+ draft.manualCardPolicyFormDraft = action.payload;
126
+ },
127
+ // Dispatched by the extract-success bridge when the upload originated from
128
+ // the manual `CardPolicyCreatePage`.
129
+ applyExtractedPolicyToManualCardPolicyDraft: {
130
+ reducer(draft, action) {
131
+ if (draft.manualCardPolicyFormDraft == null) {
132
+ return;
133
+ }
134
+ draft.manualCardPolicyFormDraft = applyExtractedToManualDraftHelper({
135
+ current: draft.manualCardPolicyFormDraft,
136
+ extracted: action.payload.extracted,
137
+ vendorSearchOptions: action.payload.vendorSearchOptions,
138
+ categorySearchOptions: action.payload.categorySearchOptions,
139
+ });
140
+ },
141
+ prepare(payload) {
142
+ return { payload };
143
+ },
144
+ },
145
+ clearManualCardPolicyFormDraft(draft) {
146
+ draft.manualCardPolicyFormDraft = undefined;
147
+ },
148
+ clearCreateCardPolicy(draft) {
149
+ Object.assign(draft, initialState);
150
+ },
151
+ },
152
+ });
153
+ export const { createCardPolicyTemplates, updateCreateCardPolicyTemplateRequestState, seedAiCardPolicyFormDraft, updateAiCardPolicyFormDraft, updateAiCardPolicyFormDraftFromUploadPlan, applyExtractedPolicyToAiCardPolicyDraft, clearAiCardPolicyFormDraft, seedManualCardPolicyFormDraft, updateManualCardPolicyFormDraft, applyExtractedPolicyToManualCardPolicyDraft, clearManualCardPolicyFormDraft, clearCreateCardPolicy, } = createCardPolicy.actions;
154
+ export default createCardPolicy.reducer;
@@ -0,0 +1,22 @@
1
+ export function getCreateCardPolicyTemplateRequestState(state) {
2
+ return state.createCardPolicyTemplateRequestState;
3
+ }
4
+ export function getLastCreatedCardPolicyTemplateIds(state) {
5
+ return state.lastCreatedCardPolicyTemplateIds;
6
+ }
7
+ // First id; single-create pages use this for navigate-to-detail.
8
+ export function getLastCreatedCardPolicyTemplateId(state) {
9
+ return state.lastCreatedCardPolicyTemplateIds[0];
10
+ }
11
+ export function getLastCreateCardPolicyTemplateErrors(state) {
12
+ return state.lastCreateCardPolicyTemplateErrors;
13
+ }
14
+ export function getLastCreateCardPolicySourceChatSessionId(state) {
15
+ return state.lastCreateCardPolicySourceChatSessionId;
16
+ }
17
+ export function getAiCardPolicyFormDraft(state) {
18
+ return state.aiCardPolicyFormDraft;
19
+ }
20
+ export function getManualCardPolicyFormDraft(state) {
21
+ return state.manualCardPolicyFormDraft;
22
+ }
@@ -0,0 +1,39 @@
1
+ import { from, of } from 'rxjs';
2
+ import { catchError, filter, mergeMap } from 'rxjs/operators';
3
+ import { updateCreatedCardPolicyTemplate } from '../../../../../entity/cardPolicy/cardPolicyReducer';
4
+ import { toBulkCreateCardPolicyTemplateError, toCreateCardPolicyTemplatesRequestBody, } from '../../../../../entity/cardPolicy/cardPolicyPayload';
5
+ import { createZeniAPIStatus, isSuccessStatus } from '../../../../../responsePayload';
6
+ import { createCardPolicyTemplates, updateCreateCardPolicyTemplateRequestState, } from './createCardPolicyReducer';
7
+ // `POST /cards/1.0/policy-templates` (bulk). On success fans entity hydrations
8
+ // + a single state update with ids + per-item errors. Partial success is
9
+ // `Completed`; the UI inspects the slice's per-item errors for partial-success UX.
10
+ export const createCardPolicyTemplatesEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(createCardPolicyTemplates.match), mergeMap((action) => {
11
+ const body = toCreateCardPolicyTemplatesRequestBody(action.payload);
12
+ return zeniAPI
13
+ .postAndGetJSON(`${zeniAPI.apiEndPoints.cardMicroServiceBaseUrl}/1.0/policy-templates`, body)
14
+ .pipe(mergeMap((response) => {
15
+ if (isSuccessStatus(response) && response.data != null) {
16
+ const { templates_created, errors } = response.data;
17
+ const createdTemplates = templates_created.map((row) => row.template);
18
+ const actions = [
19
+ ...createdTemplates.map((template) => updateCreatedCardPolicyTemplate(template)),
20
+ updateCreateCardPolicyTemplateRequestState({
21
+ fetchState: 'Completed',
22
+ perItemErrors: (errors ?? []).map(toBulkCreateCardPolicyTemplateError),
23
+ templateIds: createdTemplates.map((template) => template.template_id),
24
+ }),
25
+ ];
26
+ return from(actions);
27
+ }
28
+ else {
29
+ return of(updateCreateCardPolicyTemplateRequestState({
30
+ fetchState: 'Error',
31
+ error: response.status,
32
+ }));
33
+ }
34
+ }), catchError((error) => of(updateCreateCardPolicyTemplateRequestState({
35
+ fetchState: 'Error',
36
+ error: createZeniAPIStatus('Unexpected Error', 'Create card-policy templates REST API call errored out' +
37
+ JSON.stringify(error)),
38
+ }))));
39
+ }));
@@ -0,0 +1,140 @@
1
+ // Composes Step 5 review rows from live Step 1–4 form state. Per-row `isChecked`
2
+ // and per-chip `isSelected` are merged from `prevPoliciesReview` so user-removed
3
+ // chips don't snap back when an upstream slice changes.
4
+ export const deriveAiPolicyReviewRowsFromInputs = ({ vendorPolicy, categoryPolicy, cardSelections, limits, suggestedPoliciesSeed, prevPoliciesReview, }) => {
5
+ const prevById = new Map(prevPoliciesReview.map((row) => [row.id, row]));
6
+ const groups = deriveSharedChipGroups({
7
+ vendorPolicy,
8
+ categoryPolicy,
9
+ cardSelections,
10
+ limits,
11
+ });
12
+ return suggestedPoliciesSeed.map((seed) => {
13
+ const previous = prevById.get(seed.id);
14
+ return {
15
+ id: seed.id,
16
+ name: seed.name,
17
+ isChecked: previous?.isChecked ?? seed.isChecked,
18
+ chipGroups: previous != null
19
+ ? mergeChipSelections(groups, previous.chipGroups)
20
+ : groups,
21
+ };
22
+ });
23
+ };
24
+ const mergeChipSelections = (next, prev) => {
25
+ const prevByGroupId = new Map(prev.map((group) => [group.id, group]));
26
+ return next.map((group) => {
27
+ const prevGroup = prevByGroupId.get(group.id);
28
+ if (prevGroup == null) {
29
+ return group;
30
+ }
31
+ const prevSelectedById = new Map(prevGroup.chips.map((chip) => [chip.id, chip.isSelected]));
32
+ return {
33
+ ...group,
34
+ chips: group.chips.map((chip) => {
35
+ const prevSelected = prevSelectedById.get(chip.id);
36
+ return prevSelected === undefined
37
+ ? chip
38
+ : { ...chip, isSelected: prevSelected };
39
+ }),
40
+ };
41
+ });
42
+ };
43
+ const deriveSharedChipGroups = ({ vendorPolicy, categoryPolicy, cardSelections, limits, }) => {
44
+ const groups = [];
45
+ const vendorChips = chipsFromAllowBlock(vendorPolicy);
46
+ if (vendorChips.length > 0) {
47
+ groups.push({
48
+ id: 'vendors',
49
+ label: vendorPolicy.mode === 'allow' ? 'Allowed vendors' : 'Blocked vendors',
50
+ chips: vendorChips,
51
+ });
52
+ }
53
+ const categoryChips = chipsFromAllowBlock(categoryPolicy);
54
+ if (categoryChips.length > 0) {
55
+ groups.push({
56
+ id: 'categories',
57
+ label: categoryPolicy.mode === 'allow'
58
+ ? 'Allowed categories'
59
+ : 'Blocked categories',
60
+ chips: categoryChips,
61
+ });
62
+ }
63
+ const cardChips = cardSelections
64
+ .filter((row) => row.isChecked)
65
+ .map((row) => ({
66
+ id: row.id,
67
+ label: row.owner.displayName,
68
+ chipKind: 'avatar',
69
+ }));
70
+ if (cardChips.length > 0) {
71
+ groups.push({ id: 'cardholders', label: 'Cardholders', chips: cardChips });
72
+ }
73
+ const limitChips = limits.map((row) => ({
74
+ id: limitChipIdForRowId(row.id),
75
+ label: limitDisplayLabelForRowId(row.id),
76
+ helperText: limitHelperTextForRowId(row.id),
77
+ placeholder: '$0',
78
+ chipKind: 'positive',
79
+ isSelected: row.isEnabled,
80
+ optionalCode: row.isEnabled && row.amount != null ? String(row.amount) : undefined,
81
+ }));
82
+ if (limitChips.length > 0) {
83
+ groups.push({
84
+ id: 'limits',
85
+ label: 'Limits',
86
+ kind: 'limits',
87
+ chips: limitChips,
88
+ });
89
+ }
90
+ return groups;
91
+ };
92
+ const chipsFromAllowBlock = (field) => {
93
+ const items = field.mode === 'allow' ? field.allowItems : field.blockItems;
94
+ return items
95
+ .filter((item) => item.isSelected)
96
+ .map((item) => ({
97
+ id: item.id,
98
+ label: item.optionalCode != null
99
+ ? `${item.label} (${item.optionalCode})`
100
+ : item.label,
101
+ chipKind: field.mode === 'allow' ? 'positive' : 'negative',
102
+ }));
103
+ };
104
+ const limitChipIdForRowId = (rowId) => {
105
+ if (rowId === 'transactionLimit') {
106
+ return 'limit-transaction';
107
+ }
108
+ if (rowId === 'requireReceipt') {
109
+ return 'limit-receipt';
110
+ }
111
+ return rowId;
112
+ };
113
+ const limitDisplayLabelForRowId = (rowId) => {
114
+ if (rowId === 'transactionLimit') {
115
+ return 'Transaction Limit';
116
+ }
117
+ if (rowId === 'requireReceipt') {
118
+ return 'Require Receipt';
119
+ }
120
+ return humanizeLimitId(rowId);
121
+ };
122
+ const limitHelperTextForRowId = (rowId) => {
123
+ if (rowId === 'transactionLimit') {
124
+ return 'Maximum amount per single transaction';
125
+ }
126
+ if (rowId === 'requireReceipt') {
127
+ return 'Require a receipt above this amount';
128
+ }
129
+ return undefined;
130
+ };
131
+ const humanizeLimitId = (id) => {
132
+ const spaced = id
133
+ .replace(/([A-Z])/g, ' $1')
134
+ .replace(/[_-]+/g, ' ')
135
+ .trim();
136
+ if (spaced.length === 0) {
137
+ return id;
138
+ }
139
+ return spaced.charAt(0).toUpperCase() + spaced.slice(1).toLowerCase();
140
+ };
@@ -0,0 +1,20 @@
1
+ import { from, of } from 'rxjs';
2
+ import { catchError, exhaustMap, filter, mergeMap } from 'rxjs/operators';
3
+ import { fetchCardPolicyMccCategories, updateCardPolicyMccCategories, updateCardPolicyMccCategoriesFailure, } from '../../../../../entity/cardPolicy/cardPolicyReducer';
4
+ import { createZeniAPIStatus, isSuccessStatus, } from '../../../../../responsePayload';
5
+ export const fetchCardPolicyMccCategoriesEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(fetchCardPolicyMccCategories.match),
6
+ // `exhaustMap` dedupes the React 18 StrictMode double-mount fetch on
7
+ // both Create and Edit screens, which would otherwise yield two HTTP calls.
8
+ exhaustMap(() => {
9
+ return zeniAPI
10
+ .getJSON(`${zeniAPI.apiEndPoints.cardMicroServiceBaseUrl}/1.0/cards/mcc-codes`)
11
+ .pipe(mergeMap((response) => {
12
+ if (isSuccessStatus(response) && response.data != null) {
13
+ return from([updateCardPolicyMccCategories(response.data)]);
14
+ }
15
+ else {
16
+ return of(updateCardPolicyMccCategoriesFailure(response.status));
17
+ }
18
+ }), catchError((error) => of(updateCardPolicyMccCategoriesFailure(createZeniAPIStatus('Unexpected Error', 'Fetch card policy MCC categories REST API call errored out' +
19
+ JSON.stringify(error))))));
20
+ }));
@@ -0,0 +1,100 @@
1
+ import { EMPTY, concat, of } from 'rxjs';
2
+ import { distinctUntilChanged, filter, map, mergeMap, take, } from 'rxjs/operators';
3
+ import { upsertAnswerPayload, upsertOrAddQuestionAnswerPayload, } from '../../../../../entity/aiCfo/aiCfoReducer';
4
+ import { getQuestionAnswerByIdForChatSession } from '../../../../../entity/aiCfo/aiCfoSelector';
5
+ import { fetchCardPolicyMccCategories } from '../../../../../entity/cardPolicy/cardPolicyReducer';
6
+ import { getAllChargeCardsWithUser } from '../../chargeCardList/chargeCardListSelector';
7
+ import { clearAiCardPolicyFormDraft, seedAiCardPolicyFormDraft, updateCreateCardPolicyTemplateRequestState, } from './createCardPolicyReducer';
8
+ const isClosedChargeCardStatusCode = (code) => code === 'closed' || code === 'closed_by_customer';
9
+ const toCardPolicyCardSelectionRow = (card) => {
10
+ const user = card.cardHolderUser;
11
+ const displayName = `${user.firstName ?? ''} ${user.lastName ?? ''}`.trim() ||
12
+ user.email ||
13
+ user.userId;
14
+ return {
15
+ id: card.id,
16
+ isChecked: false,
17
+ cardName: card.cardName,
18
+ last4: card.accountLast4,
19
+ limitAmount: card.limit?.amount ?? 0,
20
+ limitCadence: card.creditLimitFrequency?.code,
21
+ owner: {
22
+ userId: user.userId,
23
+ displayName,
24
+ roleLabel: card.cardHolderRoles?.titleAtCompany,
25
+ },
26
+ utilizationAmount: (card.limit?.amount ?? 0) - (card.available?.amount ?? 0),
27
+ };
28
+ };
29
+ const readCardsMasterList = (state) => {
30
+ const view = getAllChargeCardsWithUser(state);
31
+ return view.cards
32
+ .filter((card) => !isClosedChargeCardStatusCode(card.status?.code))
33
+ .map(toCardPolicyCardSelectionRow);
34
+ };
35
+ const readMccCategoriesAvailable = (state) => state.cardPolicyState.mccCategoriesFetchState === 'Completed';
36
+ const readCardPolicyPayload = (state, chatSessionId, questionAnswerId) => {
37
+ const qa = getQuestionAnswerByIdForChatSession(state.aiCfoState, chatSessionId, questionAnswerId);
38
+ const visualization = qa?.responses.answer?.content.visualization;
39
+ if (visualization?.type !== 'interactive_form') {
40
+ return undefined;
41
+ }
42
+ const data = visualization.data;
43
+ if (!('formType' in data) || data.formType !== 'card_policy') {
44
+ return undefined;
45
+ }
46
+ return data.payload;
47
+ };
48
+ const resolveQuestionAnswerId = (state, action) => {
49
+ if (action.payload.questionAnswerId != null) {
50
+ return action.payload.questionAnswerId;
51
+ }
52
+ const session = state.aiCfoState.aiCfoByChatSessionId[action.payload.chatSessionId];
53
+ return session?.questionAnswers.slice(-1)[0]?.questionAnswerId;
54
+ };
55
+ const isSeedTrigger = (action) => upsertAnswerPayload.match(action) ||
56
+ upsertOrAddQuestionAnswerPayload.match(action);
57
+ const isCreateSuccess = (action) => updateCreateCardPolicyTemplateRequestState.match(action) &&
58
+ action.payload.fetchState === 'Completed';
59
+ const buildSeedAction = (state, payload) => {
60
+ const cardsMasterList = readCardsMasterList(state);
61
+ const mccCategories = state.cardPolicyState.mccCategories;
62
+ return seedAiCardPolicyFormDraft({
63
+ initialData: payload,
64
+ cardsMasterList,
65
+ mccCategories,
66
+ suggestedAllowMerchants: state.cardPolicyState.suggestedAllowMerchants,
67
+ suggestedBlockMerchants: state.cardPolicyState.suggestedBlockMerchants,
68
+ suggestedAllowCategories: state.cardPolicyState.suggestedAllowCategories,
69
+ suggestedBlockCategories: state.cardPolicyState.suggestedBlockCategories,
70
+ });
71
+ };
72
+ // Seeds the AI card-policy draft from `interactive_form` answers with
73
+ // `formType === "card_policy"`, clearing on bulk-create success. Defers seeding
74
+ // until MCC categories load so category chips can resolve to human labels.
75
+ export const seedAiCardPolicyFormDraftEpic = (actions$, state$) => actions$.pipe(mergeMap((action) => {
76
+ if (isCreateSuccess(action)) {
77
+ return of(clearAiCardPolicyFormDraft());
78
+ }
79
+ if (!isSeedTrigger(action)) {
80
+ return EMPTY;
81
+ }
82
+ const state = state$.value;
83
+ const questionAnswerId = resolveQuestionAnswerId(state, action);
84
+ if (questionAnswerId == null) {
85
+ return EMPTY;
86
+ }
87
+ const payload = readCardPolicyPayload(state, action.payload.chatSessionId, questionAnswerId);
88
+ if (payload == null) {
89
+ return EMPTY;
90
+ }
91
+ if (readMccCategoriesAvailable(state)) {
92
+ return of(buildSeedAction(state, payload));
93
+ }
94
+ const seedWhenMccLoaded$ = state$.pipe(map((rs) => readMccCategoriesAvailable(rs)), distinctUntilChanged(), filter((available) => available), take(1), map(() => buildSeedAction(state$.value, payload)));
95
+ const mccFetchState = state.cardPolicyState.mccCategoriesFetchState;
96
+ if (mccFetchState === 'In-Progress') {
97
+ return seedWhenMccLoaded$;
98
+ }
99
+ return concat(of(fetchCardPolicyMccCategories()), seedWhenMccLoaded$);
100
+ }));