@zeniai/client-epic-state 5.0.93-betaAK1 → 5.0.93

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 (244) hide show
  1. package/lib/common/aiCfo/aiCfoSuggestedQuestionsPageContext.d.ts +1 -1
  2. package/lib/commonStateTypes/amount.d.ts +0 -1
  3. package/lib/commonStateTypes/amount.js +1 -3
  4. package/lib/commonStateTypes/workingDayHelper.d.ts +0 -9
  5. package/lib/commonStateTypes/workingDayHelper.js +1 -28
  6. package/lib/entity/aiCfo/aiCfoPayload.d.ts +63 -5
  7. package/lib/entity/aiCfo/aiCfoReducer.d.ts +23 -2
  8. package/lib/entity/aiCfo/aiCfoReducer.js +249 -9
  9. package/lib/entity/aiCfo/aiCfoSelector.d.ts +4 -1
  10. package/lib/entity/aiCfo/aiCfoSelector.js +19 -1
  11. package/lib/entity/aiCfo/aiCfoState.d.ts +97 -4
  12. package/lib/entity/aiCfo/aiCfoState.js +18 -1
  13. package/lib/entity/cardPolicy/cardPolicyPayload.d.ts +277 -0
  14. package/lib/entity/cardPolicy/cardPolicyPayload.js +143 -0
  15. package/lib/entity/cardPolicy/cardPolicyReducer.d.ts +19 -0
  16. package/lib/entity/cardPolicy/cardPolicyReducer.js +175 -0
  17. package/lib/entity/cardPolicy/cardPolicySelector.d.ts +32 -0
  18. package/lib/entity/cardPolicy/cardPolicySelector.js +99 -0
  19. package/lib/entity/cardPolicy/cardPolicyState.d.ts +205 -0
  20. package/lib/entity/cardPolicy/cardPolicyState.js +14 -0
  21. package/lib/entity/cardPolicy/extractPolicyDocumentEpic.d.ts +18 -0
  22. package/lib/entity/cardPolicy/extractPolicyDocumentEpic.js +68 -0
  23. package/lib/entity/cardPolicy/fetchCardPolicyVendorOptionsEpic.d.ts +26 -0
  24. package/lib/entity/cardPolicy/fetchCardPolicyVendorOptionsEpic.js +47 -0
  25. package/lib/entity/cardPolicy/policyDocumentExtractionToRecommendationBridgeEpic.d.ts +25 -0
  26. package/lib/entity/cardPolicy/policyDocumentExtractionToRecommendationBridgeEpic.js +39 -0
  27. package/lib/entity/cardPolicy/policyRecommendationFromUploadEpic.d.ts +24 -0
  28. package/lib/entity/cardPolicy/policyRecommendationFromUploadEpic.js +105 -0
  29. package/lib/entity/jeSchedules/jeSchedulesTypes.d.ts +1 -1
  30. package/lib/entity/monthEndCloseChecks/monthEndCloseChecksState.d.ts +1 -1
  31. package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
  32. package/lib/entity/snackbar/snackbarTypes.js +3 -0
  33. package/lib/entity/tenant/clearAllEpic.d.ts +6 -4
  34. package/lib/entity/tenant/clearAllEpic.js +8 -4
  35. package/lib/epic.d.ts +14 -7
  36. package/lib/epic.js +14 -7
  37. package/lib/esm/commonStateTypes/amount.js +0 -1
  38. package/lib/esm/commonStateTypes/workingDayHelper.js +0 -26
  39. package/lib/esm/entity/aiCfo/aiCfoReducer.js +249 -9
  40. package/lib/esm/entity/aiCfo/aiCfoSelector.js +17 -1
  41. package/lib/esm/entity/aiCfo/aiCfoState.js +15 -0
  42. package/lib/esm/entity/cardPolicy/cardPolicyPayload.js +130 -0
  43. package/lib/esm/entity/cardPolicy/cardPolicyReducer.js +171 -0
  44. package/lib/esm/entity/cardPolicy/cardPolicySelector.js +75 -0
  45. package/lib/esm/entity/cardPolicy/cardPolicyState.js +9 -0
  46. package/lib/esm/entity/cardPolicy/extractPolicyDocumentEpic.js +64 -0
  47. package/lib/esm/entity/cardPolicy/fetchCardPolicyVendorOptionsEpic.js +43 -0
  48. package/lib/esm/entity/cardPolicy/policyDocumentExtractionToRecommendationBridgeEpic.js +35 -0
  49. package/lib/esm/entity/cardPolicy/policyRecommendationFromUploadEpic.js +101 -0
  50. package/lib/esm/entity/snackbar/snackbarTypes.js +3 -0
  51. package/lib/esm/entity/tenant/clearAllEpic.js +8 -4
  52. package/lib/esm/epic.js +14 -7
  53. package/lib/esm/index.js +39 -14
  54. package/lib/esm/reducer.js +12 -6
  55. package/lib/esm/view/aiCfoView/aiCfoViewReducer.js +6 -3
  56. package/lib/esm/view/aiCfoView/epics/createSessionAndSubmitEpic.js +5 -2
  57. package/lib/esm/view/aiCfoView/epics/createSessionEpic.js +2 -1
  58. package/lib/esm/view/aiCfoView/epics/fetchSuggestedQuestionsEpic.js +12 -2
  59. package/lib/esm/view/spendManagement/autotransferRules/autoTransferRulesSelector.js +2 -22
  60. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailReducer.js +52 -0
  61. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailSelector.js +22 -0
  62. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailState.js +1 -0
  63. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/fetchCardPolicyDetailEpic.js +36 -0
  64. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/updateCardPolicyEpic.js +39 -0
  65. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/archiveCardPolicyEpic.js +34 -0
  66. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListReducer.js +58 -0
  67. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListSelector.js +21 -0
  68. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListState.js +1 -0
  69. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/fetchCardPolicyListEpic.js +38 -0
  70. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/applyAiCardPolicyFormDraftUpdate.js +289 -0
  71. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/applyExtractedPolicyToAiCardPolicyDraft.js +109 -0
  72. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/applyExtractedPolicyToDraftEpic.js +44 -0
  73. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/applyExtractedPolicyToManualCardPolicyDraft.js +111 -0
  74. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/applyUploadPlanToAiCardPolicyDraft.js +25 -0
  75. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/buildAiCardPolicyFormDraftSeed.js +363 -0
  76. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/buildManualCardPolicyFormDraftSeed.js +36 -0
  77. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/cardPolicyChipIds.js +19 -0
  78. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/cardPolicyFormDraftTypes.js +6 -0
  79. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/cardPolicyRequestParts.js +119 -0
  80. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyReducer.js +154 -0
  81. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicySelector.js +22 -0
  82. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyState.js +1 -0
  83. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyTemplateEpic.js +39 -0
  84. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/deriveAiPolicyReviewRowsFromInputs.js +140 -0
  85. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/fetchCardPolicyMccCategoriesEpic.js +20 -0
  86. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/seedAiCardPolicyFormDraftEpic.js +100 -0
  87. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/toBulkCardPolicyTemplateRequestsFromDraft.js +96 -0
  88. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/toCardPolicyTemplateRequestFromDraft.js +59 -0
  89. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/toManualCardPolicyTemplateRequestFromDraft.js +24 -0
  90. package/lib/esm/view/spendManagement/chargeCards/chargeCardList/chargeCardListSelector.js +25 -0
  91. package/lib/esm/view/spendManagement/chargeCards/issueChargeCard/aiCardCreationFormDraftTypes.js +1 -0
  92. package/lib/esm/view/spendManagement/chargeCards/issueChargeCard/applyAiCardCreationFormDraftUpdate.js +34 -0
  93. package/lib/esm/view/spendManagement/chargeCards/issueChargeCard/buildAiCardCreationFormDraftSeed.js +57 -0
  94. package/lib/esm/view/spendManagement/chargeCards/issueChargeCard/deriveAiCardRowsFromTeams.js +35 -0
  95. package/lib/esm/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardEpic.js +2 -2
  96. package/lib/esm/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardReducer.js +42 -4
  97. package/lib/esm/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardSelector.js +35 -0
  98. package/lib/esm/view/spendManagement/chargeCards/issueChargeCard/seedAiCardCreationFormDraftEpic.js +62 -0
  99. package/lib/esm/view/spendManagement/chargeCards/issueChargeCard/toIssueChargeCardLocalDataFromDraft.js +44 -0
  100. package/lib/index.d.ts +44 -19
  101. package/lib/index.js +183 -34
  102. package/lib/reducer.d.ts +12 -6
  103. package/lib/reducer.js +12 -6
  104. package/lib/view/aiCfoView/aiCfoViewReducer.d.ts +11 -2
  105. package/lib/view/aiCfoView/aiCfoViewReducer.js +6 -3
  106. package/lib/view/aiCfoView/epics/createSessionAndSubmitEpic.js +5 -2
  107. package/lib/view/aiCfoView/epics/createSessionEpic.js +2 -1
  108. package/lib/view/aiCfoView/epics/fetchSuggestedQuestionsEpic.d.ts +8 -1
  109. package/lib/view/aiCfoView/epics/fetchSuggestedQuestionsEpic.js +12 -2
  110. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
  111. package/lib/view/expenseAutomationView/types/reconciliationViewState.d.ts +1 -1
  112. package/lib/view/people/peopleTypes.d.ts +1 -1
  113. package/lib/view/scheduleView/scheduleListView/scheduleListTypes.d.ts +1 -1
  114. package/lib/view/spendManagement/autotransferRules/autoTransferRulesSelector.d.ts +1 -8
  115. package/lib/view/spendManagement/autotransferRules/autoTransferRulesSelector.js +1 -21
  116. package/lib/view/spendManagement/autotransferRules/autoTransferRulesState.d.ts +0 -22
  117. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailReducer.d.ts +14 -0
  118. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailReducer.js +56 -0
  119. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailSelector.d.ts +15 -0
  120. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailSelector.js +28 -0
  121. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailState.d.ts +8 -0
  122. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailState.js +2 -0
  123. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/fetchCardPolicyDetailEpic.d.ts +8 -0
  124. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/fetchCardPolicyDetailEpic.js +40 -0
  125. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/updateCardPolicyEpic.d.ts +8 -0
  126. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/updateCardPolicyEpic.js +43 -0
  127. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/archiveCardPolicyEpic.d.ts +8 -0
  128. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/archiveCardPolicyEpic.js +38 -0
  129. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListReducer.d.ts +15 -0
  130. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListReducer.js +62 -0
  131. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListSelector.d.ts +15 -0
  132. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListSelector.js +27 -0
  133. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListState.d.ts +7 -0
  134. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListState.js +2 -0
  135. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/fetchCardPolicyListEpic.d.ts +8 -0
  136. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/fetchCardPolicyListEpic.js +42 -0
  137. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/applyAiCardPolicyFormDraftUpdate.d.ts +8 -0
  138. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/applyAiCardPolicyFormDraftUpdate.js +294 -0
  139. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/applyExtractedPolicyToAiCardPolicyDraft.d.ts +8 -0
  140. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/applyExtractedPolicyToAiCardPolicyDraft.js +113 -0
  141. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/applyExtractedPolicyToDraftEpic.d.ts +9 -0
  142. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/applyExtractedPolicyToDraftEpic.js +48 -0
  143. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/applyExtractedPolicyToManualCardPolicyDraft.d.ts +8 -0
  144. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/applyExtractedPolicyToManualCardPolicyDraft.js +115 -0
  145. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/applyUploadPlanToAiCardPolicyDraft.d.ts +13 -0
  146. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/applyUploadPlanToAiCardPolicyDraft.js +29 -0
  147. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/buildAiCardPolicyFormDraftSeed.d.ts +14 -0
  148. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/buildAiCardPolicyFormDraftSeed.js +369 -0
  149. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/buildManualCardPolicyFormDraftSeed.d.ts +6 -0
  150. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/buildManualCardPolicyFormDraftSeed.js +40 -0
  151. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/cardPolicyChipIds.d.ts +7 -0
  152. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/cardPolicyChipIds.js +26 -0
  153. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/cardPolicyFormDraftTypes.d.ts +116 -0
  154. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/cardPolicyFormDraftTypes.js +10 -0
  155. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/cardPolicyRequestParts.d.ts +33 -0
  156. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/cardPolicyRequestParts.js +126 -0
  157. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyReducer.d.ts +52 -0
  158. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyReducer.js +158 -0
  159. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicySelector.d.ts +11 -0
  160. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicySelector.js +31 -0
  161. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyState.d.ts +12 -0
  162. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyState.js +2 -0
  163. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyTemplateEpic.d.ts +8 -0
  164. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyTemplateEpic.js +43 -0
  165. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/deriveAiPolicyReviewRowsFromInputs.d.ts +10 -0
  166. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/deriveAiPolicyReviewRowsFromInputs.js +144 -0
  167. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/fetchCardPolicyMccCategoriesEpic.d.ts +7 -0
  168. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/fetchCardPolicyMccCategoriesEpic.js +24 -0
  169. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/seedAiCardPolicyFormDraftEpic.d.ts +11 -0
  170. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/seedAiCardPolicyFormDraftEpic.js +104 -0
  171. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/toBulkCardPolicyTemplateRequestsFromDraft.d.ts +22 -0
  172. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/toBulkCardPolicyTemplateRequestsFromDraft.js +100 -0
  173. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/toCardPolicyTemplateRequestFromDraft.d.ts +8 -0
  174. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/toCardPolicyTemplateRequestFromDraft.js +63 -0
  175. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/toManualCardPolicyTemplateRequestFromDraft.d.ts +3 -0
  176. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/toManualCardPolicyTemplateRequestFromDraft.js +28 -0
  177. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardList.d.ts +1 -1
  178. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListSelector.d.ts +14 -0
  179. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListSelector.js +27 -1
  180. package/lib/view/spendManagement/chargeCards/issueChargeCard/aiCardCreationFormDraftTypes.d.ts +34 -0
  181. package/lib/view/spendManagement/chargeCards/issueChargeCard/aiCardCreationFormDraftTypes.js +2 -0
  182. package/lib/view/spendManagement/chargeCards/issueChargeCard/applyAiCardCreationFormDraftUpdate.d.ts +7 -0
  183. package/lib/view/spendManagement/chargeCards/issueChargeCard/applyAiCardCreationFormDraftUpdate.js +38 -0
  184. package/lib/view/spendManagement/chargeCards/issueChargeCard/buildAiCardCreationFormDraftSeed.d.ts +12 -0
  185. package/lib/view/spendManagement/chargeCards/issueChargeCard/buildAiCardCreationFormDraftSeed.js +61 -0
  186. package/lib/view/spendManagement/chargeCards/issueChargeCard/deriveAiCardRowsFromTeams.d.ts +9 -0
  187. package/lib/view/spendManagement/chargeCards/issueChargeCard/deriveAiCardRowsFromTeams.js +39 -0
  188. package/lib/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardEpic.d.ts +2 -2
  189. package/lib/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardEpic.js +1 -1
  190. package/lib/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardReducer.d.ts +12 -2
  191. package/lib/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardReducer.js +43 -5
  192. package/lib/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardSelector.d.ts +7 -0
  193. package/lib/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardSelector.js +42 -1
  194. package/lib/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardState.d.ts +5 -0
  195. package/lib/view/spendManagement/chargeCards/issueChargeCard/seedAiCardCreationFormDraftEpic.d.ts +11 -0
  196. package/lib/view/spendManagement/chargeCards/issueChargeCard/seedAiCardCreationFormDraftEpic.js +66 -0
  197. package/lib/view/spendManagement/chargeCards/issueChargeCard/toIssueChargeCardLocalDataFromDraft.d.ts +3 -0
  198. package/lib/view/spendManagement/chargeCards/issueChargeCard/toIssueChargeCardLocalDataFromDraft.js +48 -0
  199. package/lib/view/taskManager/taskListView/taskListReducer.d.ts +1 -1
  200. package/lib/view/transactionDetail/journalEntryLinesViewModel.d.ts +1 -1
  201. package/lib/zeniAPI.d.ts +0 -1
  202. package/package.json +1 -1
  203. package/lib/esm/view/spendManagement/cashManagement/autoSweepFlow/autoSweepFlowPayload.js +0 -31
  204. package/lib/esm/view/spendManagement/cashManagement/autoSweepFlow/autoSweepFlowReducer.js +0 -69
  205. package/lib/esm/view/spendManagement/cashManagement/autoSweepFlow/autoSweepFlowSelector.js +0 -29
  206. package/lib/esm/view/spendManagement/cashManagement/autoSweepFlow/autoSweepFlowState.js +0 -47
  207. package/lib/esm/view/spendManagement/cashManagement/autoSweepFlow/epics/fetchCashManagementSettingsEpic.js +0 -34
  208. package/lib/esm/view/spendManagement/cashManagement/autoSweepFlow/epics/saveAutoSweepSettingsEpic.js +0 -32
  209. package/lib/esm/view/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewPayload.js +0 -54
  210. package/lib/esm/view/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewReducer.js +0 -92
  211. package/lib/esm/view/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewSelector.js +0 -225
  212. package/lib/esm/view/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewState.js +0 -10
  213. package/lib/esm/view/spendManagement/cashManagement/cashManagementOverview/epics/fetchCashManagementBannerEpic.js +0 -39
  214. package/lib/esm/view/spendManagement/cashManagement/cashManagementOverview/epics/fetchCashManagementOverviewPageEpic.js +0 -36
  215. package/lib/esm/view/spendManagement/cashManagement/cashManagementOverview/epics/fetchCashManagementRecommendationEpic.js +0 -27
  216. package/lib/esm/view/spendManagement/cashManagement/cashManagementOverview/epics/fetchRecentTransferEpic.js +0 -28
  217. package/lib/view/spendManagement/cashManagement/autoSweepFlow/autoSweepFlowPayload.d.ts +0 -48
  218. package/lib/view/spendManagement/cashManagement/autoSweepFlow/autoSweepFlowPayload.js +0 -36
  219. package/lib/view/spendManagement/cashManagement/autoSweepFlow/autoSweepFlowReducer.d.ts +0 -21
  220. package/lib/view/spendManagement/cashManagement/autoSweepFlow/autoSweepFlowReducer.js +0 -73
  221. package/lib/view/spendManagement/cashManagement/autoSweepFlow/autoSweepFlowSelector.d.ts +0 -40
  222. package/lib/view/spendManagement/cashManagement/autoSweepFlow/autoSweepFlowSelector.js +0 -33
  223. package/lib/view/spendManagement/cashManagement/autoSweepFlow/autoSweepFlowState.d.ts +0 -37
  224. package/lib/view/spendManagement/cashManagement/autoSweepFlow/autoSweepFlowState.js +0 -53
  225. package/lib/view/spendManagement/cashManagement/autoSweepFlow/epics/fetchCashManagementSettingsEpic.d.ts +0 -14
  226. package/lib/view/spendManagement/cashManagement/autoSweepFlow/epics/fetchCashManagementSettingsEpic.js +0 -38
  227. package/lib/view/spendManagement/cashManagement/autoSweepFlow/epics/saveAutoSweepSettingsEpic.d.ts +0 -7
  228. package/lib/view/spendManagement/cashManagement/autoSweepFlow/epics/saveAutoSweepSettingsEpic.js +0 -36
  229. package/lib/view/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewPayload.d.ts +0 -56
  230. package/lib/view/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewPayload.js +0 -60
  231. package/lib/view/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewReducer.d.ts +0 -22
  232. package/lib/view/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewReducer.js +0 -96
  233. package/lib/view/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewSelector.d.ts +0 -59
  234. package/lib/view/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewSelector.js +0 -230
  235. package/lib/view/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewState.d.ts +0 -122
  236. package/lib/view/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewState.js +0 -13
  237. package/lib/view/spendManagement/cashManagement/cashManagementOverview/epics/fetchCashManagementBannerEpic.d.ts +0 -23
  238. package/lib/view/spendManagement/cashManagement/cashManagementOverview/epics/fetchCashManagementBannerEpic.js +0 -43
  239. package/lib/view/spendManagement/cashManagement/cashManagementOverview/epics/fetchCashManagementOverviewPageEpic.d.ts +0 -9
  240. package/lib/view/spendManagement/cashManagement/cashManagementOverview/epics/fetchCashManagementOverviewPageEpic.js +0 -40
  241. package/lib/view/spendManagement/cashManagement/cashManagementOverview/epics/fetchCashManagementRecommendationEpic.d.ts +0 -7
  242. package/lib/view/spendManagement/cashManagement/cashManagementOverview/epics/fetchCashManagementRecommendationEpic.js +0 -31
  243. package/lib/view/spendManagement/cashManagement/cashManagementOverview/epics/fetchRecentTransferEpic.d.ts +0 -15
  244. package/lib/view/spendManagement/cashManagement/cashManagementOverview/epics/fetchRecentTransferEpic.js +0 -32
@@ -1,9 +1,10 @@
1
1
  import { createSlice } from '@reduxjs/toolkit';
2
2
  import { date as zeniDate } from '../../zeniDayJS';
3
- import { ALL_AI_CFO_ANSWER_RESPONSE_TYPES, toAiCfoAnswerResponseType, toAiCfoAnswerResponseTypeStrict, toAiCfoAnswerStateType, toAiCfoVisualizationTypeStrict, toMessageSender, toMessageType, toYFormatScaleStrict, toYFormatTypeStrict, toYFormatUnitStrict, } from './aiCfoState';
3
+ import { ALL_AI_CFO_ANSWER_RESPONSE_TYPES, toAiCfoAnswerResponseType, toAiCfoAnswerResponseTypeStrict, toAiCfoAnswerStateType, toAiCfoVisualizationTypeStrict, toInteractiveFormTypeStrict, toMessageSender, toMessageType, toYFormatScaleStrict, toYFormatTypeStrict, toYFormatUnitStrict, } from './aiCfoState';
4
4
  export const initialAiCfoState = {
5
5
  aiCfoByChatSessionId: {},
6
6
  partialQuestionAnswers: {},
7
+ syntheticAnswersByChatSessionId: {},
7
8
  };
8
9
  // Utility: Merge two arrays of Q&A pairs, combining responses for the same question
9
10
  function mergeQuestionAnswerPairs(existing, newQAs) {
@@ -135,9 +136,171 @@ export const toAiCfoVisualization = (visualization) => {
135
136
  if (visualization.type == null || visualization.data == null) {
136
137
  return undefined;
137
138
  }
139
+ // Reject unknown viz types; `?? 'table'` used to throw in the chart/table decoder
140
+ // when interactive-form payloads (no `values`) hit it.
141
+ const normalizedType = toAiCfoVisualizationTypeStrict(visualization.type);
142
+ if (normalizedType == null) {
143
+ return undefined;
144
+ }
145
+ return {
146
+ type: normalizedType,
147
+ data: normalizedType === 'interactive_form'
148
+ ? toInteractiveFormVisualization(visualization.data)
149
+ : toAiCfoVisualizationData(visualization.data),
150
+ };
151
+ };
152
+ const toInteractiveFormVisualization = (data) => {
153
+ // When `form_type` is missing / mistyped, infer from payload shape so a malformed
154
+ // card-policy answer doesn't get decoded as cards_creation (wrong form + submit path).
155
+ const formType = toInteractiveFormTypeStrict(data.form_type) ??
156
+ inferInteractiveFormTypeFromPayload(data.payload);
157
+ if (formType === 'card_policy') {
158
+ return {
159
+ formType: 'card_policy',
160
+ payload: toCardPolicyInitialData(data.payload),
161
+ };
162
+ }
163
+ return {
164
+ formType: 'cards_creation',
165
+ payload: toCardsCreationInitialData(data.payload),
166
+ };
167
+ };
168
+ const inferInteractiveFormTypeFromPayload = (payload) => {
169
+ if (payload != null && typeof payload === 'object' && 'mode' in payload) {
170
+ const mode = payload.mode;
171
+ if (mode === 'auto' || mode === 'guided' || mode === 'upload') {
172
+ return 'card_policy';
173
+ }
174
+ }
175
+ return 'cards_creation';
176
+ };
177
+ const toCardsCreationInitialData = (payload) => {
178
+ const suggestedCards = payload.suggested_cards ?? [];
179
+ const ordered = [...suggestedCards].sort((a, b) => KIND_RANK[a.card_type] - KIND_RANK[b.card_type]);
180
+ const withUniqueIds = withSynthesizedIds(ordered);
181
+ const suggestedOnly = withUniqueIds.filter(({ card }) => card.is_suggested);
182
+ const cardNameOptions = withUniqueIds.map(({ card, uniqueId }) => ({
183
+ id: uniqueId,
184
+ kind: toCardKind(card.card_type),
185
+ label: card.card_name,
186
+ }));
187
+ const suggestedOwnerUserIdByTeamId = Object.fromEntries(suggestedOnly.map(({ card, uniqueId }) => [
188
+ uniqueId,
189
+ normalizeOwnerId(card.owner_id),
190
+ ]));
191
+ const common = {
192
+ cardNameOptions,
193
+ suggestedOwnerUserIdByTeamId,
194
+ };
195
+ if (payload.mode === 'create') {
196
+ return {
197
+ ...common,
198
+ mode: 'create',
199
+ cardRows: suggestedOnly.map(({ card, uniqueId }) => ({
200
+ cardKind: toCardKind(card.card_type),
201
+ id: uniqueId,
202
+ label: card.card_name,
203
+ recommendedLimit: card.credit_limit > 0 ? card.credit_limit : undefined,
204
+ suggestedOwnerUserId: normalizeOwnerId(card.owner_id),
205
+ })),
206
+ };
207
+ }
138
208
  return {
139
- type: toAiCfoVisualizationTypeStrict(visualization.type) ?? 'table',
140
- data: toAiCfoVisualizationData(visualization.data),
209
+ ...common,
210
+ mode: 'review',
211
+ teamRows: suggestedOnly.map(({ card, uniqueId }) => ({
212
+ avgMonthlySpend: CURRENCY_FORMATTER.format(card.avg_spend),
213
+ cardKind: toCardKind(card.card_type),
214
+ id: uniqueId,
215
+ label: card.card_name,
216
+ recommendedLimit: CURRENCY_FORMATTER.format(card.credit_limit),
217
+ recommendedLimitCadence: 'Monthly',
218
+ })),
219
+ };
220
+ };
221
+ const CURRENCY_FORMATTER = new Intl.NumberFormat('en-US', {
222
+ style: 'currency',
223
+ currency: 'USD',
224
+ maximumFractionDigits: 0,
225
+ });
226
+ // BE emits `null` or `""` for "no owner picked"; collapse both to `undefined`.
227
+ const normalizeOwnerId = (ownerId) => (ownerId != null && ownerId !== '' ? ownerId : undefined);
228
+ const KIND_RANK = {
229
+ vendor: 0,
230
+ category: 1,
231
+ department: 2,
232
+ };
233
+ const toCardKind = (cardType) => {
234
+ if (cardType === 'department') {
235
+ return 'class';
236
+ }
237
+ if (cardType === 'category') {
238
+ return 'category';
239
+ }
240
+ return 'vendor';
241
+ };
242
+ // Falls back to `${kind}__${card_name_id}__${index}` when `card_name_id` collides
243
+ // (sample payloads ship the literal `"vendor_uuid"`), to keep RHF row keys unique.
244
+ const withSynthesizedIds = (cards) => {
245
+ const seen = new Set();
246
+ return cards.map((card, index) => {
247
+ const preferred = card.card_name_id;
248
+ if (preferred != null && preferred !== '' && !seen.has(preferred)) {
249
+ seen.add(preferred);
250
+ return { card, uniqueId: preferred };
251
+ }
252
+ const synthesized = `${card.card_type}__${preferred ?? 'unknown'}__${index}`;
253
+ seen.add(synthesized);
254
+ return { card, uniqueId: synthesized };
255
+ });
256
+ };
257
+ const toCardPolicyDraftPolicy = (payload, index) => ({
258
+ id: `draft-${index}`,
259
+ name: payload.name,
260
+ description: payload.description ?? '',
261
+ mode: payload.mode,
262
+ allowedEntity: {
263
+ categoryCodes: payload.allowed_entity?.category_codes ?? [],
264
+ merchantNames: payload.allowed_entity?.merchant_names ?? [],
265
+ },
266
+ blockedEntity: {
267
+ categoryCodes: payload.blocked_entity?.category_codes ?? [],
268
+ merchantNames: payload.blocked_entity?.merchant_names ?? [],
269
+ },
270
+ applyToCards: payload.apply_to_cards ?? [],
271
+ requiredReceiptThreshold: payload.required_receipt_threshold ?? 0,
272
+ spendLimits: {
273
+ transaction: payload.spend_limits?.transaction ?? 0,
274
+ },
275
+ });
276
+ const toCardPolicyStep5Review = (payload) => ({
277
+ draftPolicies: (payload.draft_policies ?? []).map(toCardPolicyDraftPolicy),
278
+ groupingSource: payload.grouping_source ?? 'none',
279
+ prompt: payload.prompt ?? '',
280
+ });
281
+ const toCardPolicyWizardPlan = (payload) => ({
282
+ step5Review: toCardPolicyStep5Review(payload.step_5_review),
283
+ });
284
+ const toCardPolicyUploadSource = (payload) => ({
285
+ confidenceScore: payload.confidence_score,
286
+ fileName: payload.file_name,
287
+ lowConfidenceFields: payload.low_confidence_fields ?? [],
288
+ });
289
+ const toCardPolicyInitialData = (payload) => {
290
+ if (payload.mode === 'upload') {
291
+ return {
292
+ policyKind: 'upload',
293
+ wizardPlan: payload.wizard_plan != null
294
+ ? toCardPolicyWizardPlan(payload.wizard_plan)
295
+ : undefined,
296
+ source: payload.source != null
297
+ ? toCardPolicyUploadSource(payload.source)
298
+ : undefined,
299
+ };
300
+ }
301
+ return {
302
+ policyKind: payload.mode,
303
+ wizardPlan: toCardPolicyWizardPlan(payload.wizard_plan),
141
304
  };
142
305
  };
143
306
  const toAiCfoVisualizationData = (data) => {
@@ -373,10 +536,8 @@ const aiCfo = createSlice({
373
536
  // Update state - append new complete Q&As to existing ones
374
537
  session.questionAnswers = mergeQuestionAnswerPairs(session.questionAnswers, completeQAs);
375
538
  },
376
- /**
377
- * Upsert a Q/A pair: if the questionAnswerId exists, upsert the response block; if not, add a new Q/A entry.
378
- * Used for push notification payloads that may introduce a new question.
379
- */
539
+ // Upserts the response block when `questionAnswerId` exists; otherwise adds the Q/A
540
+ // entry. Used for push notification payloads that may introduce a new question.
380
541
  upsertOrAddQuestionAnswerPayload(draft, action) {
381
542
  const { chatSessionId, questionAnswerId, question: { questionId, createdAt, text }, answerPayload, userId, insertQuestionAnswer, } = action.payload;
382
543
  const session = draft.aiCfoByChatSessionId[chatSessionId];
@@ -453,10 +614,82 @@ const aiCfo = createSlice({
453
614
  session.questionAnswers.push(qa);
454
615
  }
455
616
  },
617
+ // Patches an upload-mode card-policy answer with the wizard plan + source returned
618
+ // by `policy-recommendation-from-upload`. No-op for non-upload / missing targets.
619
+ updateAiCfoAnswerCardPolicyWizardPlan(draft, action) {
620
+ const { answerId, chatSessionId, source, wizardPlan } = action.payload;
621
+ const session = draft.aiCfoByChatSessionId[chatSessionId];
622
+ if (session == null) {
623
+ return;
624
+ }
625
+ const qa = session.questionAnswers.find((entry) => entry.questionAnswerId === answerId);
626
+ if (qa == null) {
627
+ return;
628
+ }
629
+ for (const response of Object.values(qa.responses)) {
630
+ const visualization = response?.content.visualization;
631
+ if (visualization == null ||
632
+ visualization.type !== 'interactive_form') {
633
+ continue;
634
+ }
635
+ const data = visualization.data;
636
+ if (data.formType !== 'card_policy' ||
637
+ data.payload.policyKind !== 'upload') {
638
+ continue;
639
+ }
640
+ data.payload = {
641
+ ...data.payload,
642
+ wizardPlan,
643
+ source: source ?? data.payload.source,
644
+ };
645
+ }
646
+ },
647
+ // Renders a "Creating…" placeholder while the cards/policy create mutation runs.
648
+ // Caller supplies a stable `id` (updated in place by `updateSyntheticAiCfoAnswer`).
649
+ appendSyntheticAiCfoAnswer(draft, action) {
650
+ const { chatSessionId, id, kind, createdAt, entityIds, sourceQuestionAnswerId, } = action.payload;
651
+ if (draft.syntheticAnswersByChatSessionId[chatSessionId] == null) {
652
+ draft.syntheticAnswersByChatSessionId[chatSessionId] = [];
653
+ }
654
+ draft.syntheticAnswersByChatSessionId[chatSessionId].push({
655
+ id,
656
+ kind,
657
+ entityIds: entityIds ?? [],
658
+ createdAt,
659
+ sourceQuestionAnswerId,
660
+ });
661
+ },
662
+ // Transitions a bubble from `creating_*` to `created_*` once the mutation completes.
663
+ updateSyntheticAiCfoAnswer(draft, action) {
664
+ const { chatSessionId, id, kind, entityIds } = action.payload;
665
+ const list = draft.syntheticAnswersByChatSessionId[chatSessionId];
666
+ if (list == null) {
667
+ return;
668
+ }
669
+ const entry = list.find((item) => item.id === id);
670
+ if (entry == null) {
671
+ return;
672
+ }
673
+ entry.kind = kind;
674
+ if (entityIds != null) {
675
+ entry.entityIds = entityIds;
676
+ }
677
+ },
678
+ removeSyntheticAiCfoAnswer(draft, action) {
679
+ const { chatSessionId, id } = action.payload;
680
+ const list = draft.syntheticAnswersByChatSessionId[chatSessionId];
681
+ if (list == null) {
682
+ return;
683
+ }
684
+ draft.syntheticAnswersByChatSessionId[chatSessionId] = list.filter((item) => item.id !== id);
685
+ },
686
+ clearSyntheticAiCfoAnswers(draft, action) {
687
+ delete draft.syntheticAnswersByChatSessionId[action.payload];
688
+ },
456
689
  clearSession(draft, action) {
457
690
  const sessionId = action.payload;
458
691
  delete draft.aiCfoByChatSessionId[sessionId];
459
- // Clear partial Q&A if it belongs to the cleared session
692
+ delete draft.syntheticAnswersByChatSessionId[sessionId];
460
693
  if (draft.partialQuestionAnswers?.[sessionId] != null) {
461
694
  draft.partialQuestionAnswers[sessionId] = undefined;
462
695
  }
@@ -464,6 +697,7 @@ const aiCfo = createSlice({
464
697
  clearAiCfo(draft) {
465
698
  draft.aiCfoByChatSessionId = {};
466
699
  draft.partialQuestionAnswers = {};
700
+ draft.syntheticAnswersByChatSessionId = {};
467
701
  },
468
702
  deleteQuestion(draft, action) {
469
703
  const { chatSessionId, questionAnswerId } = action.payload;
@@ -476,6 +710,12 @@ const aiCfo = createSlice({
476
710
  if (idx !== -1) {
477
711
  session.questionAnswers.splice(idx, 1);
478
712
  }
713
+ // Drop synthetic bubbles whose sourceQuestionAnswerId is the deleted Q/A; otherwise "Creating…" / "Created" tiles outlive their Q/A.
714
+ const syntheticAnswers = draft.syntheticAnswersByChatSessionId[chatSessionId];
715
+ if (syntheticAnswers != null) {
716
+ draft.syntheticAnswersByChatSessionId[chatSessionId] =
717
+ syntheticAnswers.filter((answer) => answer.sourceQuestionAnswerId !== questionAnswerId);
718
+ }
479
719
  },
480
720
  },
481
721
  });
@@ -488,5 +728,5 @@ const toChatSession = (chatSessionPayload) => {
488
728
  createdAt: zeniDate(created_at),
489
729
  };
490
730
  };
491
- export const { setNewSession, clearSession, setSessions, setChatHistory, upsertAnswerPayload, upsertOrAddQuestionAnswerPayload, addQuestionPayload, clearAiCfo, deleteQuestion, } = aiCfo.actions;
731
+ export const { setNewSession, clearSession, setSessions, setChatHistory, upsertAnswerPayload, upsertOrAddQuestionAnswerPayload, addQuestionPayload, clearAiCfo, deleteQuestion, updateAiCfoAnswerCardPolicyWizardPlan, appendSyntheticAiCfoAnswer, updateSyntheticAiCfoAnswer, removeSyntheticAiCfoAnswer, clearSyntheticAiCfoAnswers, } = aiCfo.actions;
492
732
  export default aiCfo.reducer;
@@ -32,5 +32,21 @@ export function getAiCfoSelectorView(state) {
32
32
  : [],
33
33
  }))
34
34
  .sort((a, b) => b.chatSession.createdAt.valueOf() - a.chatSession.createdAt.valueOf());
35
- return { allSessionsWithOrderedQuestionAnswers };
35
+ return {
36
+ allSessionsWithOrderedQuestionAnswers,
37
+ syntheticAnswersByChatSessionId: state.syntheticAnswersByChatSessionId ?? {},
38
+ };
39
+ }
40
+ export function getSyntheticAiCfoAnswersForChatSession(state, chatSessionId) {
41
+ const arr = state.syntheticAnswersByChatSessionId?.[chatSessionId] ?? [];
42
+ return arr
43
+ .slice()
44
+ .sort((a, b) => a.createdAt.valueOf() - b.createdAt.valueOf());
45
+ }
46
+ export function getSyntheticAiCfoAnswerByQuestionAnswerId(state, chatSessionId, questionAnswerId) {
47
+ const arr = state.syntheticAnswersByChatSessionId?.[chatSessionId];
48
+ if (arr == null) {
49
+ return undefined;
50
+ }
51
+ return arr.find((answer) => answer.sourceQuestionAnswerId === questionAnswerId);
36
52
  }
@@ -7,7 +7,14 @@ export const ALL_AI_CFO_CHARTS_TYPES = [
7
7
  export const ALL_AI_CFO_VISUALIZATION_TYPES = [
8
8
  ...ALL_AI_CFO_CHARTS_TYPES,
9
9
  'table',
10
+ 'interactive_form',
10
11
  ];
12
+ export const ALL_INTERACTIVE_FORM_TYPES = [
13
+ 'cards_creation',
14
+ 'card_policy',
15
+ ];
16
+ export const toInteractiveFormType = (v) => stringToUnion(v, ALL_INTERACTIVE_FORM_TYPES);
17
+ export const toInteractiveFormTypeStrict = (v) => stringToUnionStrict(v, ALL_INTERACTIVE_FORM_TYPES);
11
18
  export const toAiCfoVisualizationType = (v) => stringToUnion(v, ALL_AI_CFO_VISUALIZATION_TYPES);
12
19
  export const toAiCfoVisualizationTypeStrict = (v) => stringToUnionStrict(v, ALL_AI_CFO_VISUALIZATION_TYPES);
13
20
  export const toAiCfoChartType = (v) => stringToUnion(v, ALL_AI_CFO_CHARTS_TYPES);
@@ -58,3 +65,11 @@ export const toMessageSender = (v) => stringToUnion(v, ALL_MESSAGE_SENDERS);
58
65
  export const toMessageType = (v) => stringToUnion(v, ALL_MESSAGE_TYPES);
59
66
  export const toMessageSenderStrict = (v) => stringToUnionStrict(v, ALL_MESSAGE_SENDERS);
60
67
  export const toMessageTypeStrict = (v) => stringToUnionStrict(v, ALL_MESSAGE_TYPES);
68
+ // Client-synthesized AI CFO answer bubbles (Creating…/Created) pushed when the user
69
+ // submits an interactive form; not streamed from the backend.
70
+ export const ALL_SYNTHETIC_AI_CFO_ANSWER_KINDS = [
71
+ 'creating_cards',
72
+ 'creating_policy',
73
+ 'created_cards',
74
+ 'created_policy',
75
+ ];
@@ -0,0 +1,130 @@
1
+ import { date } from '../../zeniDayJS';
2
+ import { toCardPolicyTemplateMode, toCardPolicyTemplateStatus, } from './cardPolicyState';
3
+ export const toMccCategory = (payload) => ({
4
+ count: payload.count,
5
+ mccCodes: payload.mcc_codes ?? [],
6
+ name: payload.name,
7
+ });
8
+ export const toCardPolicyVendorSearchOption = (payload) => ({
9
+ vendorId: payload.vendor_id,
10
+ name: payload.vendor_name,
11
+ });
12
+ export const toCardPolicyStats = (payload) => ({
13
+ activePolicies: payload.active_policies,
14
+ totalCards: payload.total_cards,
15
+ totalTemplates: payload.total_templates,
16
+ });
17
+ export const toCardPolicyTemplateList = (data) => (data.templates ?? []).map((row) => toCardPolicyTemplate(row.data.template));
18
+ const toCardPolicyTemplateEntityList = (payload) => ({
19
+ categoryCodes: payload.category_codes ?? [],
20
+ merchantNames: payload.merchant_names ?? [],
21
+ });
22
+ export const toCardPolicyTemplate = (payload) => ({
23
+ allowedEntity: toCardPolicyTemplateEntityList(payload.allowed_entity),
24
+ appliedCards: payload.applied_cards ?? [],
25
+ blockedEntity: toCardPolicyTemplateEntityList(payload.blocked_entity),
26
+ cardsCount: payload.cards_count,
27
+ categoryRestrictions: payload.category_restrictions ?? [],
28
+ createdAt: date(payload.created_at),
29
+ createdBy: payload.created_by,
30
+ description: payload.description,
31
+ mode: toCardPolicyTemplateMode(payload.mode),
32
+ name: payload.name,
33
+ requiredReceiptThreshold: payload.required_receipt_threshold,
34
+ spendLimits: {
35
+ transaction: payload.spend_limits.transaction,
36
+ },
37
+ status: toCardPolicyTemplateStatus(payload.status),
38
+ templateId: payload.template_id,
39
+ tenantId: payload.tenant_id,
40
+ updatedAt: date(payload.updated_at),
41
+ });
42
+ /**
43
+ * Re-shape a single camelCase create request into the snake_case wire
44
+ * body. Used by the bulk-create mapper to build each entry of the
45
+ * `templates` array, and directly by the update epic (PUT) since the
46
+ * update endpoint still consumes a single object.
47
+ */
48
+ export const toCreateCardPolicyTemplateRequestBody = (request) => ({
49
+ allowed_entity: {
50
+ category_codes: request.allowedEntity.categoryCodes,
51
+ merchant_names: request.allowedEntity.merchantNames,
52
+ },
53
+ apply_to_cards: request.applyToCards,
54
+ blocked_entity: {
55
+ category_codes: request.blockedEntity.categoryCodes,
56
+ merchant_names: request.blockedEntity.merchantNames,
57
+ },
58
+ description: request.description,
59
+ mode: request.mode ?? 'strict',
60
+ name: request.name,
61
+ required_receipt_threshold: request.requiredReceiptThreshold,
62
+ spend_limits: {
63
+ transaction: request.spendLimits.transaction,
64
+ },
65
+ });
66
+ /**
67
+ * Re-shape a bulk create request into the snake_case wire body for
68
+ * `POST /cards/1.0/policy-templates`. Maps each entry through
69
+ * `toCreateCardPolicyTemplateRequestBody` and only emits
70
+ * `source_chat_session_id` when the camelCase counterpart is defined,
71
+ * so manual-create callers don't ship a stray `undefined` over the wire.
72
+ */
73
+ export const toCreateCardPolicyTemplatesRequestBody = (request) => {
74
+ const body = {
75
+ templates: request.templates.map(toCreateCardPolicyTemplateRequestBody),
76
+ };
77
+ if (request.sourceChatSessionId != null) {
78
+ body.source_chat_session_id = request.sourceChatSessionId;
79
+ }
80
+ return body;
81
+ };
82
+ /**
83
+ * Map a single bulk-response error payload to its camelCased view shape.
84
+ * Defensive against missing optional fields (see `BulkCreateCardPolicyTemplateErrorPayload`
85
+ * docstring — the BE contract isn't fully locked yet).
86
+ */
87
+ export const toBulkCreateCardPolicyTemplateError = (payload) => ({
88
+ message: payload.message,
89
+ code: payload.code,
90
+ index: payload.index,
91
+ name: payload.name,
92
+ });
93
+ // Update body uses the exact same wire shape as create — the PUT
94
+ // endpoint is a full replace and was not affected by the bulk migration.
95
+ export const toUpdateCardPolicyTemplateRequestBody = toCreateCardPolicyTemplateRequestBody;
96
+ /**
97
+ * Seed an edit-form draft (`CreateCardPolicyTemplateRequest`) from an
98
+ * existing camelCased `CardPolicyTemplate`. Used by the detail-fetch
99
+ * epic so the edit page can render with the saved values pre-populated.
100
+ */
101
+ export const toCardPolicyEditFormDraft = (template) => ({
102
+ allowedEntity: {
103
+ categoryCodes: [...template.allowedEntity.categoryCodes],
104
+ merchantNames: [...template.allowedEntity.merchantNames],
105
+ },
106
+ applyToCards: [...template.appliedCards],
107
+ blockedEntity: {
108
+ categoryCodes: [...template.blockedEntity.categoryCodes],
109
+ merchantNames: [...template.blockedEntity.merchantNames],
110
+ },
111
+ description: template.description,
112
+ mode: template.mode,
113
+ name: template.name,
114
+ requiredReceiptThreshold: template.requiredReceiptThreshold,
115
+ spendLimits: { transaction: template.spendLimits.transaction },
116
+ });
117
+ export const toExtractedCardPolicyRules = (payload) => ({
118
+ allowedEntity: {
119
+ categoryCodes: payload.allowed_entity?.category_codes ?? [],
120
+ merchantNames: payload.allowed_entity?.merchant_names ?? [],
121
+ },
122
+ blockedEntity: {
123
+ categoryCodes: payload.blocked_entity?.category_codes ?? [],
124
+ merchantNames: payload.blocked_entity?.merchant_names ?? [],
125
+ },
126
+ confidenceScore: payload.confidence_score,
127
+ policyName: payload.policy_name,
128
+ requiredReceiptThreshold: payload.required_receipt_threshold,
129
+ transactionLimit: payload.transaction_limit,
130
+ });
@@ -0,0 +1,171 @@
1
+ import { createSlice } from '@reduxjs/toolkit';
2
+ import { toCardPolicyTemplate, toCardPolicyVendorSearchOption, toExtractedCardPolicyRules, toMccCategory, } from './cardPolicyPayload';
3
+ // `buildVendorChipId(name)` calls `name.trim().toLowerCase()`; empty/whitespace names would crash or collapse into one colliding chip-id.
4
+ const isUsableMerchantName = (name) => typeof name === 'string' && name.trim() !== '';
5
+ const initialPolicyDocumentExtractionState = {
6
+ fetchState: 'Not-Started',
7
+ error: undefined,
8
+ extractedRules: undefined,
9
+ uploadedFileName: undefined,
10
+ };
11
+ const initialPolicyRecommendationFromUploadState = {
12
+ fetchState: 'Not-Started',
13
+ answerId: undefined,
14
+ chatSessionId: undefined,
15
+ error: undefined,
16
+ };
17
+ const initialVendorSearchState = {
18
+ fetchState: 'Not-Started',
19
+ searchString: '',
20
+ vendors: [],
21
+ error: undefined,
22
+ };
23
+ export const initialState = {
24
+ cardPolicyTemplateById: {},
25
+ mccCategories: [],
26
+ mccCategoriesError: undefined,
27
+ mccCategoriesFetchState: 'Not-Started',
28
+ policyDocumentExtraction: initialPolicyDocumentExtractionState,
29
+ policyRecommendationFromUpload: initialPolicyRecommendationFromUploadState,
30
+ suggestedAllowCategories: [],
31
+ suggestedAllowMerchants: [],
32
+ suggestedBlockCategories: [],
33
+ suggestedBlockMerchants: [],
34
+ vendorSearch: initialVendorSearchState,
35
+ cardPolicyStats: undefined,
36
+ };
37
+ const cardPolicy = createSlice({
38
+ name: 'cardPolicy',
39
+ initialState,
40
+ reducers: {
41
+ fetchCardPolicyMccCategories(draft) {
42
+ draft.mccCategoriesFetchState = 'In-Progress';
43
+ draft.mccCategoriesError = undefined;
44
+ },
45
+ updateCardPolicyMccCategories(draft, action) {
46
+ draft.mccCategories = (action.payload.categories ?? []).map(toMccCategory);
47
+ // BE-suggested seeds pre-populate the chip cloud; `isUsableMerchantName` drops names that would break `buildVendorChipId`.
48
+ draft.suggestedAllowMerchants = (action.payload.suggested_allow_merchants ?? []).filter(isUsableMerchantName);
49
+ draft.suggestedBlockMerchants = (action.payload.suggested_block_merchants ?? []).filter(isUsableMerchantName);
50
+ draft.suggestedAllowCategories = (action.payload.suggested_allow_catagories ?? []).map(toMccCategory);
51
+ draft.suggestedBlockCategories = (action.payload.suggested_block_catagories ?? []).map(toMccCategory);
52
+ draft.mccCategoriesFetchState = 'Completed';
53
+ draft.mccCategoriesError = undefined;
54
+ },
55
+ updateCardPolicyMccCategoriesFailure(draft, action) {
56
+ draft.mccCategoriesFetchState = 'Error';
57
+ draft.mccCategoriesError = action.payload;
58
+ },
59
+ updateCreatedCardPolicyTemplate(draft, action) {
60
+ const template = toCardPolicyTemplate(action.payload);
61
+ draft.cardPolicyTemplateById[template.templateId] = template;
62
+ },
63
+ // Full replace so server-side deletes evict locally too; the view slice owns the ordered ID list.
64
+ updateCardPolicyTemplates(draft, action) {
65
+ const byId = {};
66
+ for (const template of action.payload) {
67
+ byId[template.templateId] = template;
68
+ }
69
+ draft.cardPolicyTemplateById = byId;
70
+ },
71
+ removeCardPolicyTemplate(draft, action) {
72
+ delete draft.cardPolicyTemplateById[action.payload];
73
+ },
74
+ updateCardPolicyStats(draft, action) {
75
+ draft.cardPolicyStats = action.payload;
76
+ },
77
+ // Captures the first file name so the upload pill can render without callers retaining a File ref.
78
+ extractPolicyDocument: {
79
+ reducer(draft, action) {
80
+ draft.policyDocumentExtraction.fetchState = 'In-Progress';
81
+ draft.policyDocumentExtraction.error = undefined;
82
+ draft.policyDocumentExtraction.extractedRules = undefined;
83
+ draft.policyDocumentExtraction.uploadedFileName =
84
+ action.meta.uploadedFileName;
85
+ draft.policyDocumentExtraction.aiCfoAnswerId =
86
+ action.payload.aiCfoAnswerId;
87
+ draft.policyDocumentExtraction.aiCfoChatSessionId =
88
+ action.payload.aiCfoChatSessionId;
89
+ // Extraction + recommendation model one upload lifecycle; reset together so a re-upload doesn't read stale lifecycle from the prior chain.
90
+ draft.policyRecommendationFromUpload = {
91
+ ...initialPolicyRecommendationFromUploadState,
92
+ };
93
+ },
94
+ prepare(files, aiCfoAnswerId, aiCfoChatSessionId) {
95
+ return {
96
+ payload: { files, aiCfoAnswerId, aiCfoChatSessionId },
97
+ meta: { uploadedFileName: files[0]?.name },
98
+ };
99
+ },
100
+ },
101
+ updatePolicyDocumentExtractionSuccess(draft, action) {
102
+ draft.policyDocumentExtraction.fetchState = 'Completed';
103
+ draft.policyDocumentExtraction.error = undefined;
104
+ draft.policyDocumentExtraction.extractedRules =
105
+ toExtractedCardPolicyRules(action.payload);
106
+ },
107
+ updatePolicyDocumentExtractionFailure(draft, action) {
108
+ draft.policyDocumentExtraction.fetchState = 'Error';
109
+ draft.policyDocumentExtraction.error = action.payload;
110
+ draft.policyDocumentExtraction.extractedRules = undefined;
111
+ },
112
+ clearPolicyDocumentExtraction(draft) {
113
+ draft.policyDocumentExtraction = {
114
+ ...initialPolicyDocumentExtractionState,
115
+ };
116
+ // Pair with extractPolicyDocument: the two sub-slices reset and advance together.
117
+ draft.policyRecommendationFromUpload = {
118
+ ...initialPolicyRecommendationFromUploadState,
119
+ };
120
+ },
121
+ // Chained after extractPolicyDocument; epic merges the returned wizard plan into the AI CFO answer identified by answerId + chatSessionId.
122
+ fetchCardPolicyRecommendationFromUpload: {
123
+ reducer(draft, action) {
124
+ draft.policyRecommendationFromUpload.fetchState = 'In-Progress';
125
+ draft.policyRecommendationFromUpload.answerId = action.payload.answerId;
126
+ draft.policyRecommendationFromUpload.chatSessionId =
127
+ action.payload.chatSessionId;
128
+ draft.policyRecommendationFromUpload.error = undefined;
129
+ },
130
+ prepare(answerId, chatSessionId, extractedRules) {
131
+ return { payload: { answerId, chatSessionId, extractedRules } };
132
+ },
133
+ },
134
+ updatePolicyRecommendationFromUploadSuccess(draft) {
135
+ draft.policyRecommendationFromUpload.fetchState = 'Completed';
136
+ draft.policyRecommendationFromUpload.error = undefined;
137
+ },
138
+ updatePolicyRecommendationFromUploadFailure(draft, action) {
139
+ draft.policyRecommendationFromUpload.fetchState = 'Error';
140
+ draft.policyRecommendationFromUpload.error = action.payload;
141
+ },
142
+ // Empty searchString = top vendors by YTD spend; non-empty filters server-side.
143
+ fetchCardPolicyVendorOptions: {
144
+ reducer(draft, action) {
145
+ draft.vendorSearch.fetchState = 'In-Progress';
146
+ draft.vendorSearch.searchString = action.payload.searchString;
147
+ draft.vendorSearch.error = undefined;
148
+ },
149
+ prepare(searchString) {
150
+ return { payload: { searchString: searchString ?? '' } };
151
+ },
152
+ },
153
+ updateCardPolicyVendorOptions(draft, action) {
154
+ // Same `buildVendorChipId` guard as the suggested-merchants seeds above.
155
+ draft.vendorSearch.vendors = (action.payload.vendors ?? [])
156
+ .map(toCardPolicyVendorSearchOption)
157
+ .filter((vendor) => isUsableMerchantName(vendor.name));
158
+ draft.vendorSearch.fetchState = 'Completed';
159
+ draft.vendorSearch.error = undefined;
160
+ },
161
+ updateCardPolicyVendorOptionsFailure(draft, action) {
162
+ draft.vendorSearch.fetchState = 'Error';
163
+ draft.vendorSearch.error = action.payload;
164
+ },
165
+ clearCardPolicy(draft) {
166
+ Object.assign(draft, initialState);
167
+ },
168
+ },
169
+ });
170
+ export const { fetchCardPolicyMccCategories, fetchCardPolicyVendorOptions, updateCardPolicyMccCategories, updateCardPolicyMccCategoriesFailure, updateCardPolicyVendorOptions, updateCardPolicyVendorOptionsFailure, updateCreatedCardPolicyTemplate, updateCardPolicyTemplates, removeCardPolicyTemplate, updateCardPolicyStats, extractPolicyDocument, updatePolicyDocumentExtractionSuccess, updatePolicyDocumentExtractionFailure, clearPolicyDocumentExtraction, fetchCardPolicyRecommendationFromUpload, updatePolicyRecommendationFromUploadSuccess, updatePolicyRecommendationFromUploadFailure, clearCardPolicy, } = cardPolicy.actions;
171
+ export default cardPolicy.reducer;