@zeniai/client-epic-state 5.0.83 → 5.0.84-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 (199) 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 +1 -140
  5. package/lib/entity/aiCfo/aiCfoReducer.d.ts +2 -23
  6. package/lib/entity/aiCfo/aiCfoReducer.js +4 -332
  7. package/lib/entity/aiCfo/aiCfoSelector.d.ts +1 -13
  8. package/lib/entity/aiCfo/aiCfoSelector.js +1 -28
  9. package/lib/entity/aiCfo/aiCfoState.d.ts +4 -225
  10. package/lib/entity/aiCfo/aiCfoState.js +1 -30
  11. package/lib/entity/company/companyPayload.d.ts +2 -0
  12. package/lib/entity/company/companyPayload.js +2 -0
  13. package/lib/entity/company/companyStateTypes.d.ts +2 -0
  14. package/lib/entity/jeSchedules/jeSchedulesTypes.d.ts +1 -1
  15. package/lib/entity/monthEndCloseChecks/monthEndCloseChecksState.d.ts +1 -1
  16. package/lib/entity/paymentAccount/paymentAccountSelector.d.ts +1 -0
  17. package/lib/entity/paymentAccount/paymentAccountSelector.js +4 -0
  18. package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
  19. package/lib/entity/snackbar/snackbarTypes.js +1 -3
  20. package/lib/entity/tenant/clearAllEpic.d.ts +2 -6
  21. package/lib/entity/tenant/clearAllEpic.js +0 -8
  22. package/lib/entity/tenant/epic/deleteConnectionEpic.d.ts +1 -1
  23. package/lib/entity/tenant/epic/initEmailConnectOAuthEpic.d.ts +21 -0
  24. package/lib/entity/tenant/epic/initEmailConnectOAuthEpic.js +54 -0
  25. package/lib/entity/tenant/epic/saveAPIKeyConnectionEpic.d.ts +1 -1
  26. package/lib/entity/tenant/epic/saveConnectorCredentialsEpic.d.ts +3 -3
  27. package/lib/entity/tenant/epic/saveOAuthConnectionEpic.d.ts +1 -1
  28. package/lib/entity/tenant/tenantPayload.d.ts +19 -0
  29. package/lib/entity/tenant/tenantReducer.d.ts +49 -28
  30. package/lib/entity/tenant/tenantReducer.js +111 -5
  31. package/lib/entity/tenant/tenantState.d.ts +21 -0
  32. package/lib/epic.d.ts +6 -11
  33. package/lib/epic.js +7 -11
  34. package/lib/esm/commonStateTypes/animations.js +1 -0
  35. package/lib/esm/entity/aiCfo/aiCfoReducer.js +4 -332
  36. package/lib/esm/entity/aiCfo/aiCfoSelector.js +1 -26
  37. package/lib/esm/entity/aiCfo/aiCfoState.js +0 -27
  38. package/lib/esm/entity/company/companyPayload.js +2 -0
  39. package/lib/esm/entity/paymentAccount/paymentAccountSelector.js +3 -0
  40. package/lib/esm/entity/snackbar/snackbarTypes.js +1 -3
  41. package/lib/esm/entity/tenant/clearAllEpic.js +0 -8
  42. package/lib/esm/entity/tenant/epic/initEmailConnectOAuthEpic.js +50 -0
  43. package/lib/esm/entity/tenant/tenantReducer.js +108 -3
  44. package/lib/esm/epic.js +7 -11
  45. package/lib/esm/index.js +16 -28
  46. package/lib/esm/reducer.js +0 -12
  47. package/lib/esm/view/aiCfoView/aiCfoViewReducer.js +3 -6
  48. package/lib/esm/view/aiCfoView/epics/createSessionAndSubmitEpic.js +2 -5
  49. package/lib/esm/view/aiCfoView/epics/createSessionEpic.js +1 -2
  50. package/lib/esm/view/aiCfoView/epics/fetchSuggestedQuestionsEpic.js +2 -12
  51. package/lib/esm/view/companyView/companyViewReducer.js +45 -1
  52. package/lib/esm/view/companyView/epic/companyPassport/dismissCapitalizationOnboardingEpic.js +25 -0
  53. package/lib/esm/view/companyView/epic/companyPassport/updateCapitalizationThresholdEpic.js +79 -0
  54. package/lib/esm/view/companyView/types/companyPassport/companyPassportViewState.js +4 -0
  55. package/lib/esm/view/onboardingView/customerView/epic/aiAgentsActivation/fetchAiAgentsActivationStatusEpic.js +45 -0
  56. package/lib/esm/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiFinanceTeamEpic.js +40 -0
  57. package/lib/esm/view/onboardingView/customerView/onboardingCustomerViewReducer.js +168 -50
  58. package/lib/esm/view/onboardingView/customerView/onboardingCustomerViewSelector.js +14 -0
  59. package/lib/esm/view/onboardingView/customerView/onboardingCustomerViewState.js +13 -0
  60. package/lib/esm/view/spendManagement/chargeCards/chargeCardList/chargeCardListSelector.js +0 -25
  61. package/lib/esm/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardEpic.js +2 -2
  62. package/lib/esm/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardReducer.js +4 -16
  63. package/lib/esm/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardSelector.js +0 -38
  64. package/lib/esm/view/spendManagement/commonSetup/epic/setup/parseUploadedKybDocumentEpic.js +49 -0
  65. package/lib/esm/view/spendManagement/commonSetup/epic/setup/parseUploadedKycDocumentEpic.js +58 -0
  66. package/lib/esm/view/spendManagement/commonSetup/kycKybAutofillActions.js +12 -0
  67. package/lib/esm/view/spendManagement/commonSetup/kycKybParseMapper.js +205 -0
  68. package/lib/esm/view/spendManagement/commonSetup/setupViewReducer.js +71 -52
  69. package/lib/esm/view/spendManagement/commonSetup/setupViewSelector.js +2 -0
  70. package/lib/esm/view/spendManagement/commonSetup/types/kycKybAutofill.js +28 -0
  71. package/lib/index.d.ts +19 -28
  72. package/lib/index.js +36 -136
  73. package/lib/reducer.d.ts +0 -12
  74. package/lib/reducer.js +0 -12
  75. package/lib/view/aiCfoView/aiCfoViewReducer.d.ts +2 -11
  76. package/lib/view/aiCfoView/aiCfoViewReducer.js +3 -6
  77. package/lib/view/aiCfoView/epics/createSessionAndSubmitEpic.js +2 -5
  78. package/lib/view/aiCfoView/epics/createSessionEpic.js +1 -2
  79. package/lib/view/aiCfoView/epics/fetchSuggestedQuestionsEpic.d.ts +1 -8
  80. package/lib/view/aiCfoView/epics/fetchSuggestedQuestionsEpic.js +2 -12
  81. package/lib/view/companyView/companyViewReducer.d.ts +11 -1
  82. package/lib/view/companyView/companyViewReducer.js +47 -3
  83. package/lib/view/companyView/epic/companyPassport/dismissCapitalizationOnboardingEpic.d.ts +9 -0
  84. package/lib/view/companyView/epic/companyPassport/dismissCapitalizationOnboardingEpic.js +29 -0
  85. package/lib/view/companyView/epic/companyPassport/updateCapitalizationThresholdEpic.d.ts +10 -0
  86. package/lib/view/companyView/epic/companyPassport/updateCapitalizationThresholdEpic.js +83 -0
  87. package/lib/view/companyView/types/companyPassport/companyPassportViewState.d.ts +1 -0
  88. package/lib/view/companyView/types/companyPassport/companyPassportViewState.js +4 -0
  89. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
  90. package/lib/view/expenseAutomationView/types/reconciliationViewState.d.ts +1 -1
  91. package/lib/view/onboardingView/customerView/epic/aiAgentsActivation/fetchAiAgentsActivationStatusEpic.d.ts +7 -0
  92. package/lib/view/onboardingView/customerView/epic/aiAgentsActivation/fetchAiAgentsActivationStatusEpic.js +49 -0
  93. package/lib/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiFinanceTeamEpic.d.ts +9 -0
  94. package/lib/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiFinanceTeamEpic.js +44 -0
  95. package/lib/view/onboardingView/customerView/onboardingCustomerViewPayload.d.ts +3 -0
  96. package/lib/view/onboardingView/customerView/onboardingCustomerViewReducer.d.ts +41 -4
  97. package/lib/view/onboardingView/customerView/onboardingCustomerViewReducer.js +170 -51
  98. package/lib/view/onboardingView/customerView/onboardingCustomerViewSelector.d.ts +7 -1
  99. package/lib/view/onboardingView/customerView/onboardingCustomerViewSelector.js +21 -1
  100. package/lib/view/onboardingView/customerView/onboardingCustomerViewState.d.ts +37 -0
  101. package/lib/view/onboardingView/customerView/onboardingCustomerViewState.js +14 -1
  102. package/lib/view/people/peopleTypes.d.ts +1 -1
  103. package/lib/view/scheduleView/scheduleListView/scheduleListTypes.d.ts +1 -1
  104. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardList.d.ts +1 -1
  105. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListSelector.d.ts +0 -14
  106. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListSelector.js +1 -27
  107. package/lib/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardEpic.d.ts +2 -2
  108. package/lib/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardEpic.js +1 -1
  109. package/lib/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardReducer.d.ts +1 -5
  110. package/lib/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardReducer.js +5 -17
  111. package/lib/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardSelector.d.ts +0 -27
  112. package/lib/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardSelector.js +1 -43
  113. package/lib/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardState.d.ts +0 -2
  114. package/lib/view/spendManagement/commonSetup/epic/setup/parseUploadedKybDocumentEpic.d.ts +8 -0
  115. package/lib/view/spendManagement/commonSetup/epic/setup/parseUploadedKybDocumentEpic.js +53 -0
  116. package/lib/view/spendManagement/commonSetup/epic/setup/parseUploadedKycDocumentEpic.d.ts +8 -0
  117. package/lib/view/spendManagement/commonSetup/epic/setup/parseUploadedKycDocumentEpic.js +62 -0
  118. package/lib/view/spendManagement/commonSetup/kycKybAutofillActions.d.ts +27 -0
  119. package/lib/view/spendManagement/commonSetup/kycKybAutofillActions.js +15 -0
  120. package/lib/view/spendManagement/commonSetup/kycKybParseMapper.d.ts +24 -0
  121. package/lib/view/spendManagement/commonSetup/kycKybParseMapper.js +213 -0
  122. package/lib/view/spendManagement/commonSetup/setupViewReducer.d.ts +24 -2
  123. package/lib/view/spendManagement/commonSetup/setupViewReducer.js +72 -53
  124. package/lib/view/spendManagement/commonSetup/setupViewSelector.d.ts +4 -0
  125. package/lib/view/spendManagement/commonSetup/setupViewSelector.js +2 -0
  126. package/lib/view/spendManagement/commonSetup/setupViewState.d.ts +12 -0
  127. package/lib/view/spendManagement/commonSetup/types/kycKybAutofill.d.ts +125 -0
  128. package/lib/view/spendManagement/commonSetup/types/kycKybAutofill.js +32 -0
  129. package/lib/view/taskManager/taskListView/taskListReducer.d.ts +1 -1
  130. package/package.json +1 -1
  131. package/lib/entity/cardPolicy/cardPolicyPayload.d.ts +0 -277
  132. package/lib/entity/cardPolicy/cardPolicyPayload.js +0 -143
  133. package/lib/entity/cardPolicy/cardPolicyReducer.d.ts +0 -19
  134. package/lib/entity/cardPolicy/cardPolicyReducer.js +0 -265
  135. package/lib/entity/cardPolicy/cardPolicySelector.d.ts +0 -32
  136. package/lib/entity/cardPolicy/cardPolicySelector.js +0 -103
  137. package/lib/entity/cardPolicy/cardPolicyState.d.ts +0 -205
  138. package/lib/entity/cardPolicy/cardPolicyState.js +0 -14
  139. package/lib/entity/cardPolicy/extractPolicyDocumentEpic.d.ts +0 -18
  140. package/lib/entity/cardPolicy/extractPolicyDocumentEpic.js +0 -68
  141. package/lib/entity/cardPolicy/fetchCardPolicyVendorOptionsEpic.d.ts +0 -26
  142. package/lib/entity/cardPolicy/fetchCardPolicyVendorOptionsEpic.js +0 -47
  143. package/lib/entity/cardPolicy/policyDocumentExtractionToRecommendationBridgeEpic.d.ts +0 -25
  144. package/lib/entity/cardPolicy/policyDocumentExtractionToRecommendationBridgeEpic.js +0 -39
  145. package/lib/entity/cardPolicy/policyRecommendationFromUploadEpic.d.ts +0 -23
  146. package/lib/entity/cardPolicy/policyRecommendationFromUploadEpic.js +0 -111
  147. package/lib/esm/entity/cardPolicy/cardPolicyPayload.js +0 -130
  148. package/lib/esm/entity/cardPolicy/cardPolicyReducer.js +0 -261
  149. package/lib/esm/entity/cardPolicy/cardPolicySelector.js +0 -79
  150. package/lib/esm/entity/cardPolicy/cardPolicyState.js +0 -9
  151. package/lib/esm/entity/cardPolicy/extractPolicyDocumentEpic.js +0 -64
  152. package/lib/esm/entity/cardPolicy/fetchCardPolicyVendorOptionsEpic.js +0 -43
  153. package/lib/esm/entity/cardPolicy/policyDocumentExtractionToRecommendationBridgeEpic.js +0 -35
  154. package/lib/esm/entity/cardPolicy/policyRecommendationFromUploadEpic.js +0 -107
  155. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailReducer.js +0 -70
  156. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailSelector.js +0 -22
  157. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailState.js +0 -1
  158. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/fetchCardPolicyDetailEpic.js +0 -56
  159. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/updateCardPolicyEpic.js +0 -49
  160. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/archiveCardPolicyEpic.js +0 -42
  161. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListReducer.js +0 -72
  162. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListSelector.js +0 -21
  163. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListState.js +0 -1
  164. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/fetchCardPolicyListEpic.js +0 -56
  165. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyReducer.js +0 -62
  166. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicySelector.js +0 -39
  167. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyState.js +0 -1
  168. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyTemplateEpic.js +0 -53
  169. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/fetchCardPolicyMccCategoriesEpic.js +0 -25
  170. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailReducer.d.ts +0 -14
  171. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailReducer.js +0 -74
  172. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailSelector.d.ts +0 -21
  173. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailSelector.js +0 -28
  174. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailState.d.ts +0 -25
  175. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailState.js +0 -2
  176. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/fetchCardPolicyDetailEpic.d.ts +0 -19
  177. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/fetchCardPolicyDetailEpic.js +0 -60
  178. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/updateCardPolicyEpic.d.ts +0 -18
  179. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/updateCardPolicyEpic.js +0 -53
  180. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/archiveCardPolicyEpic.d.ts +0 -16
  181. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/archiveCardPolicyEpic.js +0 -46
  182. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListReducer.d.ts +0 -15
  183. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListReducer.js +0 -76
  184. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListSelector.d.ts +0 -21
  185. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListSelector.js +0 -27
  186. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListState.d.ts +0 -19
  187. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListState.js +0 -2
  188. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/fetchCardPolicyListEpic.d.ts +0 -19
  189. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/fetchCardPolicyListEpic.js +0 -60
  190. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyReducer.d.ts +0 -13
  191. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyReducer.js +0 -66
  192. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicySelector.d.ts +0 -32
  193. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicySelector.js +0 -46
  194. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyState.d.ts +0 -45
  195. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyState.js +0 -2
  196. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyTemplateEpic.d.ts +0 -25
  197. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyTemplateEpic.js +0 -57
  198. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/fetchCardPolicyMccCategoriesEpic.d.ts +0 -15
  199. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/fetchCardPolicyMccCategoriesEpic.js +0 -29
@@ -1,265 +0,0 @@
1
- "use strict";
2
- var _a;
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.clearCardPolicy = exports.updatePolicyRecommendationFromUploadFailure = exports.updatePolicyRecommendationFromUploadSuccess = exports.fetchCardPolicyRecommendationFromUpload = exports.clearPolicyDocumentExtraction = exports.updatePolicyDocumentExtractionFailure = exports.updatePolicyDocumentExtractionSuccess = exports.extractPolicyDocument = exports.updateCardPolicyStats = exports.removeCardPolicyTemplate = exports.updateCardPolicyTemplates = exports.updateCreatedCardPolicyTemplate = exports.updateCardPolicyVendorOptionsFailure = exports.updateCardPolicyVendorOptions = exports.updateCardPolicyMccCategoriesFailure = exports.updateCardPolicyMccCategories = exports.fetchCardPolicyVendorOptions = exports.fetchCardPolicyMccCategories = exports.initialState = void 0;
5
- const toolkit_1 = require("@reduxjs/toolkit");
6
- const cardPolicyPayload_1 = require("./cardPolicyPayload");
7
- /**
8
- * Defensive predicate for vendor / merchant names that flow into
9
- * `buildVendorChipId(name)` (in `@zeniai/web-components`). That helper
10
- * calls `name.trim().toLowerCase()`, so a null / undefined / whitespace-
11
- * only value would throw at render time, and an empty string would
12
- * collapse every nameless row into a single colliding `vendor-` chip-id.
13
- * Used at the redux ingestion boundary for both the vendor-search results
14
- * and the BE-suggested merchant seed arrays.
15
- */
16
- const isUsableMerchantName = (name) => typeof name === 'string' && name.trim() !== '';
17
- const initialPolicyDocumentExtractionState = {
18
- fetchState: 'Not-Started',
19
- error: undefined,
20
- extractedRules: undefined,
21
- uploadedFileName: undefined,
22
- };
23
- const initialPolicyRecommendationFromUploadState = {
24
- fetchState: 'Not-Started',
25
- answerId: undefined,
26
- chatSessionId: undefined,
27
- error: undefined,
28
- };
29
- const initialVendorSearchState = {
30
- fetchState: 'Not-Started',
31
- searchString: '',
32
- vendors: [],
33
- error: undefined,
34
- };
35
- exports.initialState = {
36
- cardPolicyTemplateById: {},
37
- mccCategories: [],
38
- mccCategoriesError: undefined,
39
- mccCategoriesFetchState: 'Not-Started',
40
- policyDocumentExtraction: initialPolicyDocumentExtractionState,
41
- policyRecommendationFromUpload: initialPolicyRecommendationFromUploadState,
42
- suggestedAllowCategories: [],
43
- suggestedAllowMerchants: [],
44
- suggestedBlockCategories: [],
45
- suggestedBlockMerchants: [],
46
- vendorSearch: initialVendorSearchState,
47
- cardPolicyStats: undefined,
48
- };
49
- const cardPolicy = (0, toolkit_1.createSlice)({
50
- name: 'cardPolicy',
51
- initialState: exports.initialState,
52
- reducers: {
53
- fetchCardPolicyMccCategories(draft) {
54
- draft.mccCategoriesFetchState = 'In-Progress';
55
- draft.mccCategoriesError = undefined;
56
- },
57
- updateCardPolicyMccCategories(draft, action) {
58
- draft.mccCategories = (action.payload.categories ?? []).map(cardPolicyPayload_1.toMccCategory);
59
- // Persist BE-suggested allow / block seeds alongside the universe.
60
- // Both flows (manual create page + AI CFO interactive form) read
61
- // these to pre-populate the chip cloud body before the user edits.
62
- // Drop empty / nullish merchant names defensively — they feed
63
- // `buildVendorChipId(name)` (in @zeniai/web-components) which calls
64
- // `.trim().toLowerCase()` and would crash the chip-picker render
65
- // path if any entry slipped through as undefined / "".
66
- draft.suggestedAllowMerchants = (action.payload.suggested_allow_merchants ?? []).filter(isUsableMerchantName);
67
- draft.suggestedBlockMerchants = (action.payload.suggested_block_merchants ?? []).filter(isUsableMerchantName);
68
- draft.suggestedAllowCategories = (action.payload.suggested_allow_catagories ?? []).map(cardPolicyPayload_1.toMccCategory);
69
- draft.suggestedBlockCategories = (action.payload.suggested_block_catagories ?? []).map(cardPolicyPayload_1.toMccCategory);
70
- draft.mccCategoriesFetchState = 'Completed';
71
- draft.mccCategoriesError = undefined;
72
- },
73
- updateCardPolicyMccCategoriesFailure(draft, action) {
74
- draft.mccCategoriesFetchState = 'Error';
75
- draft.mccCategoriesError = action.payload;
76
- },
77
- /**
78
- * Store a newly-created (or refreshed) card-policy template keyed by
79
- * `templateId`. Dispatched by the create / list / get epics; consumed
80
- * by both manual and AI-CFO policy flows via `getCardPolicyTemplateById`.
81
- */
82
- updateCreatedCardPolicyTemplate(draft, action) {
83
- const template = (0, cardPolicyPayload_1.toCardPolicyTemplate)(action.payload);
84
- draft.cardPolicyTemplateById[template.templateId] = template;
85
- },
86
- /**
87
- * Replace the entity store's `cardPolicyTemplateById` map with the
88
- * full list returned by the templates-list endpoint. Full replace is
89
- * intentional — templates that no longer exist on the server should be
90
- * dropped from local state too. The view slice keeps the server-order
91
- * ID list separately for stable list rendering.
92
- */
93
- updateCardPolicyTemplates(draft, action) {
94
- const byId = {};
95
- for (const template of action.payload) {
96
- byId[template.templateId] = template;
97
- }
98
- draft.cardPolicyTemplateById = byId;
99
- },
100
- /**
101
- * Drop a single template from the entity map. Dispatched by the
102
- * archive (DELETE) epic on success; also usable by any future flow
103
- * that needs to evict a template (e.g. AI-CFO rejection).
104
- */
105
- removeCardPolicyTemplate(draft, action) {
106
- delete draft.cardPolicyTemplateById[action.payload];
107
- },
108
- /**
109
- * Replace the tenant-wide policy stats. Dispatched alongside
110
- * `updateCardPolicyTemplates` from the list epic, but lives on the
111
- * entity slice so any consumer can read it without re-fetching the
112
- * list.
113
- */
114
- updateCardPolicyStats(draft, action) {
115
- draft.cardPolicyStats = action.payload;
116
- },
117
- /**
118
- * Kick off the `POST /cards/1.0/policy-documents/extract` request.
119
- *
120
- * Synchronously flips the sub-slice to `In-Progress` and captures the
121
- * first uploaded file's name (used by the manual `CardPolicyCreatePage`
122
- * to render the "Policy.pdf ×" pill once the request completes) so
123
- * downstream callers don't have to keep their own file refs.
124
- *
125
- * The accompanying `extractPolicyDocumentEpic` listens for this action,
126
- * POSTs multipart form-data to the cards micro-service, and dispatches
127
- * either `updatePolicyDocumentExtractionSuccess` or
128
- * `updatePolicyDocumentExtractionFailure`.
129
- *
130
- * Designed to be dispatched from both the manual create page and a
131
- * future AI CFO composer/upload surface — selectors return a single
132
- * source of truth.
133
- */
134
- extractPolicyDocument: {
135
- reducer(draft, action) {
136
- draft.policyDocumentExtraction.fetchState = 'In-Progress';
137
- draft.policyDocumentExtraction.error = undefined;
138
- draft.policyDocumentExtraction.extractedRules = undefined;
139
- draft.policyDocumentExtraction.uploadedFileName =
140
- action.meta.uploadedFileName;
141
- draft.policyDocumentExtraction.aiCfoAnswerId =
142
- action.payload.aiCfoAnswerId;
143
- draft.policyDocumentExtraction.aiCfoChatSessionId =
144
- action.payload.aiCfoChatSessionId;
145
- // Reset the chained recommendation slice too — without this a
146
- // second upload in the same AI CFO session can read `Completed` or
147
- // `Error` from the prior chain while extraction is still
148
- // `In-Progress`, leaving lifecycle UI/gating wrong until the new
149
- // chain finishes. The two sub-slices model the upload lifecycle
150
- // together (see `clearPolicyDocumentExtraction` below).
151
- draft.policyRecommendationFromUpload = {
152
- ...initialPolicyRecommendationFromUploadState,
153
- };
154
- },
155
- prepare(files, aiCfoAnswerId, aiCfoChatSessionId) {
156
- return {
157
- payload: { files, aiCfoAnswerId, aiCfoChatSessionId },
158
- meta: { uploadedFileName: files[0]?.name },
159
- };
160
- },
161
- },
162
- updatePolicyDocumentExtractionSuccess(draft, action) {
163
- draft.policyDocumentExtraction.fetchState = 'Completed';
164
- draft.policyDocumentExtraction.error = undefined;
165
- draft.policyDocumentExtraction.extractedRules =
166
- (0, cardPolicyPayload_1.toExtractedCardPolicyRules)(action.payload);
167
- },
168
- updatePolicyDocumentExtractionFailure(draft, action) {
169
- draft.policyDocumentExtraction.fetchState = 'Error';
170
- draft.policyDocumentExtraction.error = action.payload;
171
- draft.policyDocumentExtraction.extractedRules = undefined;
172
- },
173
- clearPolicyDocumentExtraction(draft) {
174
- draft.policyDocumentExtraction = {
175
- ...initialPolicyDocumentExtractionState,
176
- };
177
- // Clear the chained recommendation slice too — the two together
178
- // model the upload lifecycle and either both reset (× pill,
179
- // unmount) or both advance (drop file → extract → recommend).
180
- draft.policyRecommendationFromUpload = {
181
- ...initialPolicyRecommendationFromUploadState,
182
- };
183
- },
184
- /**
185
- * Kick off `POST /cards/1.0/ai-cfo/policy-recommendation-from-upload`.
186
- *
187
- * Chained after `extractPolicyDocument` succeeds in the AI CFO
188
- * `upload`-mode flow. The accompanying epic forwards the
189
- * just-returned `extracted_rules` to the BE and dispatches success /
190
- * failure into this slice; on success, a sibling action
191
- * (`updateAiCfoAnswerCardPolicyWizardPlan` on the aiCfo slice) is
192
- * dispatched by the epic to merge the returned `wizard_plan` + `source`
193
- * into the in-flight AI CFO answer's `CardPolicyInitialData`.
194
- *
195
- * `answerId` + `chatSessionId` identify which AI CFO answer should
196
- * receive the patch. Both are required so the wizard reads a single
197
- * source of truth for its lifecycle pill (`fetchState`) and the
198
- * bridge epic can correlate against the originating answer.
199
- */
200
- fetchCardPolicyRecommendationFromUpload: {
201
- reducer(draft, action) {
202
- draft.policyRecommendationFromUpload.fetchState = 'In-Progress';
203
- draft.policyRecommendationFromUpload.answerId = action.payload.answerId;
204
- draft.policyRecommendationFromUpload.chatSessionId =
205
- action.payload.chatSessionId;
206
- draft.policyRecommendationFromUpload.error = undefined;
207
- },
208
- prepare(answerId, chatSessionId, extractedRules) {
209
- return { payload: { answerId, chatSessionId, extractedRules } };
210
- },
211
- },
212
- updatePolicyRecommendationFromUploadSuccess(draft) {
213
- draft.policyRecommendationFromUpload.fetchState = 'Completed';
214
- draft.policyRecommendationFromUpload.error = undefined;
215
- },
216
- updatePolicyRecommendationFromUploadFailure(draft, action) {
217
- draft.policyRecommendationFromUpload.fetchState = 'Error';
218
- draft.policyRecommendationFromUpload.error = action.payload;
219
- },
220
- /**
221
- * Kick off `GET /accounting/1.0/vendors` (card-policy mode). When
222
- * `searchString` is empty the BE returns the top vendors sorted by
223
- * year-to-date spend; with a non-empty value it filters server-side.
224
- *
225
- * The accompanying `fetchCardPolicyVendorOptionsEpic` listens for
226
- * this action, builds the `query` JSON (matching `fetchVendorsList`'s
227
- * `view: "vendor_list"` shape) and dispatches success / failure.
228
- *
229
- * Designed to be dispatched from both the manual `CardPolicyCreate /
230
- * EditScreen` (on mount + on every chip-picker keystroke, debounced)
231
- * and the AI CFO interactive form's vendor step.
232
- */
233
- fetchCardPolicyVendorOptions: {
234
- reducer(draft, action) {
235
- draft.vendorSearch.fetchState = 'In-Progress';
236
- draft.vendorSearch.searchString = action.payload.searchString;
237
- draft.vendorSearch.error = undefined;
238
- },
239
- prepare(searchString) {
240
- return { payload: { searchString: searchString ?? '' } };
241
- },
242
- },
243
- updateCardPolicyVendorOptions(draft, action) {
244
- // Drop rows with no usable name. The chip-picker keys vendors by
245
- // `buildVendorChipId(name)` (in @zeniai/web-components), which calls
246
- // `name.trim().toLowerCase()`. A null / undefined / whitespace-only
247
- // name would either throw at render time or collapse every nameless
248
- // row into a single colliding `vendor-` chip-id.
249
- draft.vendorSearch.vendors = (action.payload.vendors ?? [])
250
- .map(cardPolicyPayload_1.toCardPolicyVendorSearchOption)
251
- .filter((vendor) => isUsableMerchantName(vendor.name));
252
- draft.vendorSearch.fetchState = 'Completed';
253
- draft.vendorSearch.error = undefined;
254
- },
255
- updateCardPolicyVendorOptionsFailure(draft, action) {
256
- draft.vendorSearch.fetchState = 'Error';
257
- draft.vendorSearch.error = action.payload;
258
- },
259
- clearCardPolicy(draft) {
260
- Object.assign(draft, exports.initialState);
261
- },
262
- },
263
- });
264
- _a = cardPolicy.actions, exports.fetchCardPolicyMccCategories = _a.fetchCardPolicyMccCategories, exports.fetchCardPolicyVendorOptions = _a.fetchCardPolicyVendorOptions, exports.updateCardPolicyMccCategories = _a.updateCardPolicyMccCategories, exports.updateCardPolicyMccCategoriesFailure = _a.updateCardPolicyMccCategoriesFailure, exports.updateCardPolicyVendorOptions = _a.updateCardPolicyVendorOptions, exports.updateCardPolicyVendorOptionsFailure = _a.updateCardPolicyVendorOptionsFailure, exports.updateCreatedCardPolicyTemplate = _a.updateCreatedCardPolicyTemplate, exports.updateCardPolicyTemplates = _a.updateCardPolicyTemplates, exports.removeCardPolicyTemplate = _a.removeCardPolicyTemplate, exports.updateCardPolicyStats = _a.updateCardPolicyStats, exports.extractPolicyDocument = _a.extractPolicyDocument, exports.updatePolicyDocumentExtractionSuccess = _a.updatePolicyDocumentExtractionSuccess, exports.updatePolicyDocumentExtractionFailure = _a.updatePolicyDocumentExtractionFailure, exports.clearPolicyDocumentExtraction = _a.clearPolicyDocumentExtraction, exports.fetchCardPolicyRecommendationFromUpload = _a.fetchCardPolicyRecommendationFromUpload, exports.updatePolicyRecommendationFromUploadSuccess = _a.updatePolicyRecommendationFromUploadSuccess, exports.updatePolicyRecommendationFromUploadFailure = _a.updatePolicyRecommendationFromUploadFailure, exports.clearCardPolicy = _a.clearCardPolicy;
265
- exports.default = cardPolicy.reducer;
@@ -1,32 +0,0 @@
1
- import { FetchState, ID } from '../../commonStateTypes/common';
2
- import { ZeniAPIStatus } from '../../responsePayload';
3
- import { CardPolicyState, CardPolicyStats, CardPolicyTemplate, CardPolicyVendorSearchEntry, ExtractedCardPolicyRules, MccCategory } from './cardPolicyState';
4
- export declare function getCardPolicyMccCategories(state: CardPolicyState): MccCategory[];
5
- export declare function getCardPolicyMccCategoriesFetchState(state: CardPolicyState): FetchState;
6
- export declare function getCardPolicyMccCategoriesError(state: CardPolicyState): ZeniAPIStatus | undefined;
7
- export declare function getCardPolicyTemplateById(state: CardPolicyState, templateId: ID): CardPolicyTemplate | undefined;
8
- export declare function getAllCardPolicyTemplates(state: CardPolicyState): CardPolicyTemplate[];
9
- /**
10
- * Resolve an ordered list of `templateId`s against the entity store and
11
- * return the corresponding `CardPolicyTemplate[]` in the same order.
12
- * Missing IDs (e.g. stale local state during a refetch) are silently
13
- * dropped. Pair with `getCardPolicyTemplateIds` from the view slice to
14
- * render the Policy List page in server order.
15
- */
16
- export declare function getCardPolicyTemplatesByIds(state: CardPolicyState, templateIds: ID[]): CardPolicyTemplate[];
17
- export declare function getCardPolicyStats(state: CardPolicyState): CardPolicyStats | undefined;
18
- export declare function getPolicyDocumentExtractionFetchState(state: CardPolicyState): FetchState;
19
- export declare function getPolicyDocumentExtractionError(state: CardPolicyState): ZeniAPIStatus | undefined;
20
- export declare function getExtractedCardPolicyRules(state: CardPolicyState): ExtractedCardPolicyRules | undefined;
21
- export declare function getUploadedPolicyDocumentFileName(state: CardPolicyState): string | undefined;
22
- export declare function getPolicyRecommendationFromUploadFetchState(state: CardPolicyState): FetchState;
23
- export declare function getPolicyRecommendationFromUploadError(state: CardPolicyState): ZeniAPIStatus | undefined;
24
- export declare function getPolicyRecommendationFromUploadAnswerId(state: CardPolicyState): ID | undefined;
25
- export declare function getPolicyRecommendationFromUploadChatSessionId(state: CardPolicyState): ID | undefined;
26
- export declare function getCardPolicySuggestedAllowMerchants(state: CardPolicyState): string[];
27
- export declare function getCardPolicySuggestedBlockMerchants(state: CardPolicyState): string[];
28
- export declare function getCardPolicySuggestedAllowCategories(state: CardPolicyState): MccCategory[];
29
- export declare function getCardPolicySuggestedBlockCategories(state: CardPolicyState): MccCategory[];
30
- export declare function getCardPolicyVendorSearchOptions(state: CardPolicyState): CardPolicyVendorSearchEntry[];
31
- export declare function getCardPolicyVendorSearchFetchState(state: CardPolicyState): FetchState;
32
- export declare function getCardPolicyVendorSearchString(state: CardPolicyState): string;
@@ -1,103 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getCardPolicyMccCategories = getCardPolicyMccCategories;
4
- exports.getCardPolicyMccCategoriesFetchState = getCardPolicyMccCategoriesFetchState;
5
- exports.getCardPolicyMccCategoriesError = getCardPolicyMccCategoriesError;
6
- exports.getCardPolicyTemplateById = getCardPolicyTemplateById;
7
- exports.getAllCardPolicyTemplates = getAllCardPolicyTemplates;
8
- exports.getCardPolicyTemplatesByIds = getCardPolicyTemplatesByIds;
9
- exports.getCardPolicyStats = getCardPolicyStats;
10
- exports.getPolicyDocumentExtractionFetchState = getPolicyDocumentExtractionFetchState;
11
- exports.getPolicyDocumentExtractionError = getPolicyDocumentExtractionError;
12
- exports.getExtractedCardPolicyRules = getExtractedCardPolicyRules;
13
- exports.getUploadedPolicyDocumentFileName = getUploadedPolicyDocumentFileName;
14
- exports.getPolicyRecommendationFromUploadFetchState = getPolicyRecommendationFromUploadFetchState;
15
- exports.getPolicyRecommendationFromUploadError = getPolicyRecommendationFromUploadError;
16
- exports.getPolicyRecommendationFromUploadAnswerId = getPolicyRecommendationFromUploadAnswerId;
17
- exports.getPolicyRecommendationFromUploadChatSessionId = getPolicyRecommendationFromUploadChatSessionId;
18
- exports.getCardPolicySuggestedAllowMerchants = getCardPolicySuggestedAllowMerchants;
19
- exports.getCardPolicySuggestedBlockMerchants = getCardPolicySuggestedBlockMerchants;
20
- exports.getCardPolicySuggestedAllowCategories = getCardPolicySuggestedAllowCategories;
21
- exports.getCardPolicySuggestedBlockCategories = getCardPolicySuggestedBlockCategories;
22
- exports.getCardPolicyVendorSearchOptions = getCardPolicyVendorSearchOptions;
23
- exports.getCardPolicyVendorSearchFetchState = getCardPolicyVendorSearchFetchState;
24
- exports.getCardPolicyVendorSearchString = getCardPolicyVendorSearchString;
25
- function getCardPolicyMccCategories(state) {
26
- return state.mccCategories;
27
- }
28
- function getCardPolicyMccCategoriesFetchState(state) {
29
- return state.mccCategoriesFetchState;
30
- }
31
- function getCardPolicyMccCategoriesError(state) {
32
- return state.mccCategoriesError;
33
- }
34
- function getCardPolicyTemplateById(state, templateId) {
35
- return state.cardPolicyTemplateById[templateId];
36
- }
37
- function getAllCardPolicyTemplates(state) {
38
- return Object.values(state.cardPolicyTemplateById);
39
- }
40
- /**
41
- * Resolve an ordered list of `templateId`s against the entity store and
42
- * return the corresponding `CardPolicyTemplate[]` in the same order.
43
- * Missing IDs (e.g. stale local state during a refetch) are silently
44
- * dropped. Pair with `getCardPolicyTemplateIds` from the view slice to
45
- * render the Policy List page in server order.
46
- */
47
- function getCardPolicyTemplatesByIds(state, templateIds) {
48
- return templateIds
49
- .map((id) => state.cardPolicyTemplateById[id])
50
- .filter((template) => template != null);
51
- }
52
- function getCardPolicyStats(state) {
53
- return state.cardPolicyStats;
54
- }
55
- // ── Policy document extraction ───────────────────────────────────────
56
- function getPolicyDocumentExtractionFetchState(state) {
57
- return state.policyDocumentExtraction.fetchState;
58
- }
59
- function getPolicyDocumentExtractionError(state) {
60
- return state.policyDocumentExtraction.error;
61
- }
62
- function getExtractedCardPolicyRules(state) {
63
- return state.policyDocumentExtraction.extractedRules;
64
- }
65
- function getUploadedPolicyDocumentFileName(state) {
66
- return state.policyDocumentExtraction.uploadedFileName;
67
- }
68
- // ── Policy recommendation from upload (AI CFO upload mode) ───────────
69
- function getPolicyRecommendationFromUploadFetchState(state) {
70
- return state.policyRecommendationFromUpload.fetchState;
71
- }
72
- function getPolicyRecommendationFromUploadError(state) {
73
- return state.policyRecommendationFromUpload.error;
74
- }
75
- function getPolicyRecommendationFromUploadAnswerId(state) {
76
- return state.policyRecommendationFromUpload.answerId;
77
- }
78
- function getPolicyRecommendationFromUploadChatSessionId(state) {
79
- return state.policyRecommendationFromUpload.chatSessionId;
80
- }
81
- // ── Suggested allow / block seeds (shipped alongside MCC categories) ─
82
- function getCardPolicySuggestedAllowMerchants(state) {
83
- return state.suggestedAllowMerchants;
84
- }
85
- function getCardPolicySuggestedBlockMerchants(state) {
86
- return state.suggestedBlockMerchants;
87
- }
88
- function getCardPolicySuggestedAllowCategories(state) {
89
- return state.suggestedAllowCategories;
90
- }
91
- function getCardPolicySuggestedBlockCategories(state) {
92
- return state.suggestedBlockCategories;
93
- }
94
- // ── Vendor search dropdown ───────────────────────────────────────────
95
- function getCardPolicyVendorSearchOptions(state) {
96
- return state.vendorSearch.vendors;
97
- }
98
- function getCardPolicyVendorSearchFetchState(state) {
99
- return state.vendorSearch.fetchState;
100
- }
101
- function getCardPolicyVendorSearchString(state) {
102
- return state.vendorSearch.searchString;
103
- }
@@ -1,205 +0,0 @@
1
- import { FetchState, ID } from '../../commonStateTypes/common';
2
- import { ZeniAPIStatus } from '../../responsePayload';
3
- import { ZeniDate } from '../../zeniDayJS';
4
- /**
5
- * A category grouping merchant category codes (MCCs) used while configuring
6
- * card policies (e.g. "Apparel", "AC Refrigeration Repair"). The same data
7
- * is consumed by both the manual policy-creation flow and the AI-CFO-driven
8
- * flow.
9
- */
10
- export interface MccCategory {
11
- count: number;
12
- mccCodes: string[];
13
- name: string;
14
- }
15
- export declare const ALL_CARD_POLICY_TEMPLATE_MODES: readonly ["strict", "flexible"];
16
- export declare const toCardPolicyTemplateMode: (v: string) => "strict" | "flexible";
17
- export type CardPolicyTemplateMode = ReturnType<typeof toCardPolicyTemplateMode>;
18
- export declare const ALL_CARD_POLICY_TEMPLATE_STATUSES: readonly ["active", "inactive", "archived"];
19
- export declare const toCardPolicyTemplateStatus: (v: string) => "active" | "inactive" | "archived";
20
- export type CardPolicyTemplateStatus = ReturnType<typeof toCardPolicyTemplateStatus>;
21
- /**
22
- * Allow- / block-list pair scoped to a card-policy template. Empty arrays
23
- * mean "no restrictions on this dimension".
24
- */
25
- export interface CardPolicyTemplateEntityList {
26
- categoryCodes: string[];
27
- merchantNames: string[];
28
- }
29
- /**
30
- * Spend-limit caps configured per template. Only `transaction` is modeled
31
- * today; additional cadences (e.g. daily, monthly) will be added if/when
32
- * the backend exposes them.
33
- *
34
- * `transaction` is `number | null`: `null` means the row's toggle is off
35
- * (no limit configured), `0` means the user explicitly entered zero with
36
- * the toggle on, and any positive value is the configured per-transaction
37
- * cap.
38
- */
39
- export interface CardPolicyTemplateSpendLimits {
40
- transaction: number | null;
41
- }
42
- /**
43
- * Mapped (camelCase) representation of a card-policy template returned by
44
- * the cards micro-service. Stored on the entity slice keyed by
45
- * `templateId` so both the manual policy-creation UI and the AI-CFO flow
46
- * can read it.
47
- */
48
- export interface CardPolicyTemplate {
49
- allowedEntity: CardPolicyTemplateEntityList;
50
- appliedCards: ID[];
51
- blockedEntity: CardPolicyTemplateEntityList;
52
- cardsCount: number;
53
- categoryRestrictions: unknown[];
54
- createdAt: ZeniDate;
55
- createdBy: ID;
56
- description: string;
57
- mode: CardPolicyTemplateMode;
58
- name: string;
59
- /**
60
- * Receipt-required threshold in dollars. `null` means the toggle is off
61
- * (no receipt requirement); `0` means the user explicitly entered zero
62
- * with the toggle on; any positive value is the configured threshold.
63
- */
64
- requiredReceiptThreshold: number | null;
65
- spendLimits: CardPolicyTemplateSpendLimits;
66
- status: CardPolicyTemplateStatus;
67
- templateId: ID;
68
- tenantId: ID;
69
- updatedAt: ZeniDate;
70
- }
71
- /**
72
- * Aggregate counters returned by the list endpoint and reused across
73
- * any surface that wants to display tenant-wide policy stats without
74
- * triggering an extra fetch.
75
- */
76
- export interface CardPolicyStats {
77
- activePolicies: number;
78
- totalCards: number;
79
- totalTemplates: number;
80
- }
81
- /**
82
- * FE-side (camelCase) mirror of the wire payload
83
- * `ExtractedCardPolicyRulesPayload`. Field names align slice-wise with
84
- * `CardPolicyTemplate` (`allowedEntity`, `blockedEntity`,
85
- * `requiredReceiptThreshold`) so the pre-fill mapper consumed by both
86
- * `CardPolicyCreatePage` (manual) and `CardPolicyInteractiveForm`
87
- * (AI CFO) can read either shape uniformly.
88
- */
89
- export interface ExtractedCardPolicyRules {
90
- allowedEntity: CardPolicyTemplateEntityList;
91
- blockedEntity: CardPolicyTemplateEntityList;
92
- confidenceScore: number;
93
- policyName: string;
94
- requiredReceiptThreshold: number;
95
- transactionLimit: number;
96
- }
97
- /**
98
- * Lifecycle for the `POST /cards/1.0/policy-documents/extract` request.
99
- * Lives on the entity slice (rather than a view slice) so both the manual
100
- * `CardPolicyCreatePage` and the AI CFO `CardPolicyInteractiveForm` can
101
- * read the extracted rules from a single source of truth.
102
- *
103
- * `uploadedFileName` is captured at request-kickoff time so the UI can
104
- * render the "Policy.pdf ×" pill once the request completes without
105
- * having to keep a separate local copy of the file.
106
- */
107
- export interface PolicyDocumentExtractionState {
108
- fetchState: FetchState;
109
- /**
110
- * AI CFO answer that owns the in-flight upload, when the extraction
111
- * was kicked off from inside an `upload`-mode `CardPolicyInteractiveForm`.
112
- * Captured at request-kickoff and read by the bridge epic to chain
113
- * `fetchCardPolicyRecommendationFromUpload` against the right answer.
114
- * `undefined` for manual `CardPolicyCreatePage` callers.
115
- */
116
- aiCfoAnswerId?: ID;
117
- aiCfoChatSessionId?: ID;
118
- error?: ZeniAPIStatus;
119
- extractedRules?: ExtractedCardPolicyRules;
120
- uploadedFileName?: string;
121
- }
122
- /**
123
- * Lifecycle for `POST /cards/1.0/ai-cfo/policy-recommendation-from-upload`.
124
- * Chained after `extractPolicyDocument` succeeds in the AI CFO `upload`
125
- * mode — the FE forwards the just-returned `extracted_rules` and the BE
126
- * synthesizes a wizard plan + upload source metadata.
127
- *
128
- * `answerId` captures which AI CFO answer's `card_policy` payload should
129
- * receive the resulting `wizard_plan` patch (via
130
- * `updateAiCfoAnswerCardPolicyWizardPlan`). Stored here rather than on
131
- * the answer slice so the bridge epic can correlate the extract success
132
- * → recommendation kickoff without re-deriving it from the visualization.
133
- */
134
- export interface PolicyRecommendationFromUploadState {
135
- fetchState: FetchState;
136
- answerId?: ID;
137
- chatSessionId?: ID;
138
- error?: ZeniAPIStatus;
139
- }
140
- /**
141
- * Lightweight `{vendorId, name}` row stored on the card-policy slice for
142
- * the chip-picker's vendor search dropdown. Sourced from
143
- * `/accounting/1.0/vendors` via `fetchCardPolicyVendorOptionsEpic`.
144
- *
145
- * Intentionally a subset of the full `Vendor` entity — populating this
146
- * slice does NOT touch the global `vendor`/`account`/`vendorList`
147
- * entities, so a card-policy search session never disturbs the user's
148
- * Vendors-tab list state.
149
- */
150
- export interface CardPolicyVendorSearchEntry {
151
- name: string;
152
- vendorId: ID;
153
- }
154
- /**
155
- * Lifecycle for the `GET /accounting/1.0/vendors` (card-policy mode)
156
- * request. Only one in-flight search at a time; the latest typed search
157
- * wins (via `switchMap` in the epic). `searchString` is the text that
158
- * produced `vendors`, useful for stale-result guards in the UI.
159
- */
160
- export interface CardPolicyVendorSearchState {
161
- fetchState: FetchState;
162
- searchString: string;
163
- vendors: CardPolicyVendorSearchEntry[];
164
- error?: ZeniAPIStatus;
165
- }
166
- /**
167
- * Slice state for card-policy reference data shared across the manual and
168
- * AI-driven policy-creation flows. Each sub-resource tracks its own
169
- * `fetchState`/`error` so additional card-policy APIs can be added
170
- * alongside without coupling.
171
- */
172
- export interface CardPolicyState {
173
- cardPolicyTemplateById: Record<ID, CardPolicyTemplate>;
174
- mccCategories: MccCategory[];
175
- mccCategoriesFetchState: FetchState;
176
- policyDocumentExtraction: PolicyDocumentExtractionState;
177
- /**
178
- * Lifecycle for the AI CFO `upload`-mode follow-up call. Sibling of
179
- * `policyDocumentExtraction`; the two together describe the full
180
- * upload chain: drop file → extract → recommend → wizard plan ready.
181
- */
182
- policyRecommendationFromUpload: PolicyRecommendationFromUploadState;
183
- /**
184
- * MCC categories suggested by the BE as a default "Allow" seed for the
185
- * category chip cloud. Empty when the user lands without prior spend
186
- * history. See `suggested_allow_catagories` on the wire payload.
187
- */
188
- suggestedAllowCategories: MccCategory[];
189
- /**
190
- * Merchant names suggested by the BE as a default "Allow" seed for the
191
- * vendor chip cloud. Empty when the BE has no recommendation. See
192
- * `suggested_allow_merchants` on the wire payload.
193
- */
194
- suggestedAllowMerchants: string[];
195
- suggestedBlockCategories: MccCategory[];
196
- suggestedBlockMerchants: string[];
197
- /**
198
- * Server-driven vendor search results powering the chip picker's
199
- * search dropdown. Distinct from the global vendor entity store so
200
- * the card-policy flow never disturbs the user's Vendors-tab list.
201
- */
202
- vendorSearch: CardPolicyVendorSearchState;
203
- cardPolicyStats?: CardPolicyStats;
204
- mccCategoriesError?: ZeniAPIStatus;
205
- }
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toCardPolicyTemplateStatus = exports.ALL_CARD_POLICY_TEMPLATE_STATUSES = exports.toCardPolicyTemplateMode = exports.ALL_CARD_POLICY_TEMPLATE_MODES = void 0;
4
- const stringToUnion_1 = require("../../commonStateTypes/stringToUnion");
5
- exports.ALL_CARD_POLICY_TEMPLATE_MODES = ['strict', 'flexible'];
6
- const toCardPolicyTemplateMode = (v) => (0, stringToUnion_1.stringToUnion)(v, exports.ALL_CARD_POLICY_TEMPLATE_MODES);
7
- exports.toCardPolicyTemplateMode = toCardPolicyTemplateMode;
8
- exports.ALL_CARD_POLICY_TEMPLATE_STATUSES = [
9
- 'active',
10
- 'inactive',
11
- 'archived',
12
- ];
13
- const toCardPolicyTemplateStatus = (v) => (0, stringToUnion_1.stringToUnion)(v, exports.ALL_CARD_POLICY_TEMPLATE_STATUSES);
14
- exports.toCardPolicyTemplateStatus = toCardPolicyTemplateStatus;
@@ -1,18 +0,0 @@
1
- import { ActionsObservable, StateObservable } from 'redux-observable';
2
- import { Observable } from 'rxjs';
3
- import { RootState } from '../../reducer';
4
- import { ZeniAPI } from '../../zeniAPI';
5
- import { clearPolicyDocumentExtraction, extractPolicyDocument, updatePolicyDocumentExtractionFailure, updatePolicyDocumentExtractionSuccess } from './cardPolicyReducer';
6
- export type ActionType = ReturnType<typeof extractPolicyDocument> | ReturnType<typeof updatePolicyDocumentExtractionSuccess> | ReturnType<typeof updatePolicyDocumentExtractionFailure> | ReturnType<typeof clearPolicyDocumentExtraction>;
7
- /**
8
- * Listens for `extractPolicyDocument`, POSTs the file(s) as multipart
9
- * form-data to the cards micro-service's policy-document extract endpoint,
10
- * and dispatches success / failure into the entity slice.
11
- *
12
- * Consumed by:
13
- * - Manual `CardPolicyCreatePage` (read result via
14
- * `getExtractedCardPolicyRules` then pre-fill the RHF form via
15
- * `applyExtractedPolicyRulesToFormValues` from `@zeniai/web-components`).
16
- * - (Future) AI CFO upload surface — same action + selector contract.
17
- */
18
- export declare const extractPolicyDocumentEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;