@zeniai/client-epic-state 5.0.81-betaRR0 → 5.0.81

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 (130) hide show
  1. package/lib/common/aiCfo/aiCfoSuggestedQuestionsPageContext.d.ts +1 -1
  2. package/lib/entity/aiCfo/aiCfoPayload.d.ts +1 -171
  3. package/lib/entity/aiCfo/aiCfoReducer.d.ts +2 -22
  4. package/lib/entity/aiCfo/aiCfoReducer.js +4 -291
  5. package/lib/entity/aiCfo/aiCfoSelector.d.ts +1 -3
  6. package/lib/entity/aiCfo/aiCfoSelector.js +1 -11
  7. package/lib/entity/aiCfo/aiCfoState.d.ts +4 -186
  8. package/lib/entity/aiCfo/aiCfoState.js +1 -23
  9. package/lib/entity/jeSchedules/jeSchedulesTypes.d.ts +1 -1
  10. package/lib/entity/monthEndCloseChecks/monthEndCloseChecksState.d.ts +1 -1
  11. package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
  12. package/lib/entity/snackbar/snackbarTypes.js +0 -2
  13. package/lib/entity/tenant/clearAllEpic.d.ts +2 -6
  14. package/lib/entity/tenant/clearAllEpic.js +0 -8
  15. package/lib/epic.d.ts +1 -11
  16. package/lib/epic.js +1 -11
  17. package/lib/esm/entity/aiCfo/aiCfoReducer.js +4 -291
  18. package/lib/esm/entity/aiCfo/aiCfoSelector.js +1 -10
  19. package/lib/esm/entity/aiCfo/aiCfoState.js +0 -20
  20. package/lib/esm/entity/snackbar/snackbarTypes.js +0 -2
  21. package/lib/esm/entity/tenant/clearAllEpic.js +0 -8
  22. package/lib/esm/epic.js +1 -11
  23. package/lib/esm/index.js +7 -22
  24. package/lib/esm/reducer.js +0 -12
  25. package/lib/esm/view/aiCfoView/aiCfoViewReducer.js +3 -6
  26. package/lib/esm/view/aiCfoView/epics/createSessionAndSubmitEpic.js +2 -5
  27. package/lib/esm/view/aiCfoView/epics/createSessionEpic.js +1 -2
  28. package/lib/esm/view/aiCfoView/epics/fetchSuggestedQuestionsEpic.js +2 -12
  29. package/lib/esm/view/spendManagement/chargeCards/chargeCardList/chargeCardListSelector.js +0 -25
  30. package/lib/esm/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardEpic.js +2 -2
  31. package/lib/esm/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardReducer.js +4 -16
  32. package/lib/esm/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardSelector.js +0 -38
  33. package/lib/index.d.ts +7 -20
  34. package/lib/index.js +10 -124
  35. package/lib/reducer.d.ts +0 -12
  36. package/lib/reducer.js +0 -12
  37. package/lib/view/aiCfoView/aiCfoViewReducer.d.ts +2 -11
  38. package/lib/view/aiCfoView/aiCfoViewReducer.js +3 -6
  39. package/lib/view/aiCfoView/epics/createSessionAndSubmitEpic.js +2 -5
  40. package/lib/view/aiCfoView/epics/createSessionEpic.js +1 -2
  41. package/lib/view/aiCfoView/epics/fetchSuggestedQuestionsEpic.d.ts +1 -8
  42. package/lib/view/aiCfoView/epics/fetchSuggestedQuestionsEpic.js +2 -12
  43. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
  44. package/lib/view/expenseAutomationView/types/jeSchedulesViewState.d.ts +1 -1
  45. package/lib/view/expenseAutomationView/types/missingReceiptsViewState.d.ts +2 -2
  46. package/lib/view/expenseAutomationView/types/reconciliationViewState.d.ts +1 -1
  47. package/lib/view/expenseAutomationView/types/transactionsViewState.d.ts +1 -1
  48. package/lib/view/people/peopleTypes.d.ts +1 -1
  49. package/lib/view/scheduleView/scheduleListView/scheduleListTypes.d.ts +1 -1
  50. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardList.d.ts +1 -1
  51. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListSelector.d.ts +0 -14
  52. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListSelector.js +1 -27
  53. package/lib/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardEpic.d.ts +2 -2
  54. package/lib/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardEpic.js +1 -1
  55. package/lib/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardReducer.d.ts +1 -5
  56. package/lib/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardReducer.js +5 -17
  57. package/lib/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardSelector.d.ts +0 -27
  58. package/lib/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardSelector.js +1 -43
  59. package/lib/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardState.d.ts +0 -2
  60. package/lib/view/taskManager/taskListView/taskListReducer.d.ts +1 -1
  61. package/package.json +62 -34
  62. package/lib/entity/cardPolicy/cardPolicyPayload.d.ts +0 -277
  63. package/lib/entity/cardPolicy/cardPolicyPayload.js +0 -143
  64. package/lib/entity/cardPolicy/cardPolicyReducer.d.ts +0 -19
  65. package/lib/entity/cardPolicy/cardPolicyReducer.js +0 -256
  66. package/lib/entity/cardPolicy/cardPolicySelector.d.ts +0 -32
  67. package/lib/entity/cardPolicy/cardPolicySelector.js +0 -103
  68. package/lib/entity/cardPolicy/cardPolicyState.d.ts +0 -205
  69. package/lib/entity/cardPolicy/cardPolicyState.js +0 -14
  70. package/lib/entity/cardPolicy/extractPolicyDocumentEpic.d.ts +0 -18
  71. package/lib/entity/cardPolicy/extractPolicyDocumentEpic.js +0 -54
  72. package/lib/entity/cardPolicy/fetchCardPolicyVendorOptionsEpic.d.ts +0 -26
  73. package/lib/entity/cardPolicy/fetchCardPolicyVendorOptionsEpic.js +0 -47
  74. package/lib/entity/cardPolicy/policyDocumentExtractionToRecommendationBridgeEpic.d.ts +0 -25
  75. package/lib/entity/cardPolicy/policyDocumentExtractionToRecommendationBridgeEpic.js +0 -39
  76. package/lib/entity/cardPolicy/policyRecommendationFromUploadEpic.d.ts +0 -23
  77. package/lib/entity/cardPolicy/policyRecommendationFromUploadEpic.js +0 -92
  78. package/lib/esm/entity/cardPolicy/cardPolicyPayload.js +0 -130
  79. package/lib/esm/entity/cardPolicy/cardPolicyReducer.js +0 -252
  80. package/lib/esm/entity/cardPolicy/cardPolicySelector.js +0 -79
  81. package/lib/esm/entity/cardPolicy/cardPolicyState.js +0 -9
  82. package/lib/esm/entity/cardPolicy/extractPolicyDocumentEpic.js +0 -50
  83. package/lib/esm/entity/cardPolicy/fetchCardPolicyVendorOptionsEpic.js +0 -43
  84. package/lib/esm/entity/cardPolicy/policyDocumentExtractionToRecommendationBridgeEpic.js +0 -35
  85. package/lib/esm/entity/cardPolicy/policyRecommendationFromUploadEpic.js +0 -88
  86. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailReducer.js +0 -70
  87. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailSelector.js +0 -22
  88. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailState.js +0 -1
  89. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/fetchCardPolicyDetailEpic.js +0 -56
  90. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/updateCardPolicyEpic.js +0 -49
  91. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/archiveCardPolicyEpic.js +0 -42
  92. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListReducer.js +0 -72
  93. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListSelector.js +0 -21
  94. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListState.js +0 -1
  95. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/fetchCardPolicyListEpic.js +0 -56
  96. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyReducer.js +0 -62
  97. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicySelector.js +0 -39
  98. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyState.js +0 -1
  99. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyTemplateEpic.js +0 -53
  100. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/fetchCardPolicyMccCategoriesEpic.js +0 -25
  101. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailReducer.d.ts +0 -14
  102. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailReducer.js +0 -74
  103. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailSelector.d.ts +0 -21
  104. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailSelector.js +0 -28
  105. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailState.d.ts +0 -25
  106. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailState.js +0 -2
  107. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/fetchCardPolicyDetailEpic.d.ts +0 -19
  108. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/fetchCardPolicyDetailEpic.js +0 -60
  109. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/updateCardPolicyEpic.d.ts +0 -18
  110. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/updateCardPolicyEpic.js +0 -53
  111. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/archiveCardPolicyEpic.d.ts +0 -16
  112. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/archiveCardPolicyEpic.js +0 -46
  113. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListReducer.d.ts +0 -15
  114. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListReducer.js +0 -76
  115. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListSelector.d.ts +0 -21
  116. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListSelector.js +0 -27
  117. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListState.d.ts +0 -19
  118. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListState.js +0 -2
  119. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/fetchCardPolicyListEpic.d.ts +0 -19
  120. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/fetchCardPolicyListEpic.js +0 -60
  121. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyReducer.d.ts +0 -13
  122. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyReducer.js +0 -66
  123. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicySelector.d.ts +0 -32
  124. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicySelector.js +0 -46
  125. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyState.d.ts +0 -45
  126. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyState.js +0 -2
  127. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyTemplateEpic.d.ts +0 -25
  128. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyTemplateEpic.js +0 -57
  129. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/fetchCardPolicyMccCategoriesEpic.d.ts +0 -15
  130. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/fetchCardPolicyMccCategoriesEpic.js +0 -29
@@ -1,54 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.extractPolicyDocumentEpic = void 0;
4
- const rxjs_1 = require("rxjs");
5
- const operators_1 = require("rxjs/operators");
6
- const responsePayload_1 = require("../../responsePayload");
7
- const cardPolicyReducer_1 = require("./cardPolicyReducer");
8
- /**
9
- * Build a multipart `FormData` body for `POST /cards/1.0/policy-documents/extract`.
10
- *
11
- * Uses the same `attachment_file_<i>` / `attachment_json_<i>` field-naming
12
- * convention as the charge-card receipt upload (`uploadReceipts.ts` in
13
- * `web-components`) so backends that already support that wire shape
14
- * accept this endpoint without bespoke parsing.
15
- */
16
- const buildPolicyDocumentFormData = (files) => {
17
- const data = new FormData();
18
- files.forEach((file, index) => {
19
- data.append(`attachment_file_${index}`, file);
20
- const attachmentJson = JSON.stringify({
21
- file_name: file.name,
22
- content_type: file.type,
23
- size: file.size,
24
- });
25
- data.append(`attachment_json_${index}`, attachmentJson);
26
- });
27
- return data;
28
- };
29
- /**
30
- * Listens for `extractPolicyDocument`, POSTs the file(s) as multipart
31
- * form-data to the cards micro-service's policy-document extract endpoint,
32
- * and dispatches success / failure into the entity slice.
33
- *
34
- * Consumed by:
35
- * - Manual `CardPolicyCreatePage` (read result via
36
- * `getExtractedCardPolicyRules` then pre-fill the RHF form via
37
- * `applyExtractedPolicyRulesToFormValues` from `@zeniai/web-components`).
38
- * - (Future) AI CFO upload surface — same action + selector contract.
39
- */
40
- const extractPolicyDocumentEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(cardPolicyReducer_1.extractPolicyDocument.match), (0, operators_1.mergeMap)((action) => {
41
- const formData = buildPolicyDocumentFormData(action.payload.files);
42
- return zeniAPI
43
- .postFormData(`${zeniAPI.apiEndPoints.cardMicroServiceBaseUrl}/1.0/policy-documents/extract`, formData)
44
- .pipe((0, operators_1.mergeMap)((response) => {
45
- if ((0, responsePayload_1.isSuccessStatus)(response) &&
46
- response.data != null &&
47
- response.data.extracted_rules != null) {
48
- return (0, rxjs_1.of)((0, cardPolicyReducer_1.updatePolicyDocumentExtractionSuccess)(response.data.extracted_rules));
49
- }
50
- return (0, rxjs_1.of)((0, cardPolicyReducer_1.updatePolicyDocumentExtractionFailure)(response.status));
51
- }), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, cardPolicyReducer_1.updatePolicyDocumentExtractionFailure)((0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Extract card-policy document REST API call errored out' +
52
- JSON.stringify(error))))));
53
- }));
54
- exports.extractPolicyDocumentEpic = extractPolicyDocumentEpic;
@@ -1,26 +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 { fetchCardPolicyVendorOptions, updateCardPolicyVendorOptions, updateCardPolicyVendorOptionsFailure } from './cardPolicyReducer';
6
- export type ActionType = ReturnType<typeof fetchCardPolicyVendorOptions> | ReturnType<typeof updateCardPolicyVendorOptions> | ReturnType<typeof updateCardPolicyVendorOptionsFailure>;
7
- /**
8
- * Card-policy vendor search.
9
- *
10
- * Listens for `fetchCardPolicyVendorOptions` and hits the same
11
- * `/accounting/1.0/vendors` endpoint the Vendors-tab uses, but writes
12
- * results onto the dedicated `cardPolicyState.vendorSearch` slice — no
13
- * fan-out to the global `vendor` / `account` / `class` / `vendorList`
14
- * entities. That isolation is important: the user may be configuring a
15
- * card policy in parallel with browsing the Vendors tab, and we don't
16
- * want either flow to clobber the other's list state.
17
- *
18
- * Uses `switchMap` so the latest typed search wins — earlier in-flight
19
- * requests are abandoned, which is the right semantics for a
20
- * search-as-you-type UX.
21
- *
22
- * Consumers:
23
- * - Manual `CardPolicyCreate / EditScreen`
24
- * - AI CFO `CardPolicyInteractiveForm` (vendor step)
25
- */
26
- export declare const fetchCardPolicyVendorOptionsEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -1,47 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fetchCardPolicyVendorOptionsEpic = void 0;
4
- const rxjs_1 = require("rxjs");
5
- const operators_1 = require("rxjs/operators");
6
- const responsePayload_1 = require("../../responsePayload");
7
- const cardPolicyReducer_1 = require("./cardPolicyReducer");
8
- const buildQuery = (searchString) => ({
9
- view: 'vendor_list',
10
- page_token: null,
11
- sort_by: 'year_to_date_spend',
12
- sort_order: 'desc',
13
- search_text: searchString,
14
- vendor_name: searchString,
15
- });
16
- /**
17
- * Card-policy vendor search.
18
- *
19
- * Listens for `fetchCardPolicyVendorOptions` and hits the same
20
- * `/accounting/1.0/vendors` endpoint the Vendors-tab uses, but writes
21
- * results onto the dedicated `cardPolicyState.vendorSearch` slice — no
22
- * fan-out to the global `vendor` / `account` / `class` / `vendorList`
23
- * entities. That isolation is important: the user may be configuring a
24
- * card policy in parallel with browsing the Vendors tab, and we don't
25
- * want either flow to clobber the other's list state.
26
- *
27
- * Uses `switchMap` so the latest typed search wins — earlier in-flight
28
- * requests are abandoned, which is the right semantics for a
29
- * search-as-you-type UX.
30
- *
31
- * Consumers:
32
- * - Manual `CardPolicyCreate / EditScreen`
33
- * - AI CFO `CardPolicyInteractiveForm` (vendor step)
34
- */
35
- const fetchCardPolicyVendorOptionsEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(cardPolicyReducer_1.fetchCardPolicyVendorOptions.match), (0, operators_1.switchMap)((action) => {
36
- const query = buildQuery(action.payload.searchString);
37
- const apiUrl = `${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/vendors` +
38
- `?query=${encodeURIComponent(JSON.stringify(query))}`;
39
- return zeniAPI.getJSON(apiUrl).pipe((0, operators_1.switchMap)((response) => {
40
- if ((0, responsePayload_1.isSuccessStatus)(response) && response.data != null) {
41
- return (0, rxjs_1.of)((0, cardPolicyReducer_1.updateCardPolicyVendorOptions)(response.data));
42
- }
43
- return (0, rxjs_1.of)((0, cardPolicyReducer_1.updateCardPolicyVendorOptionsFailure)(response.status));
44
- }), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, cardPolicyReducer_1.updateCardPolicyVendorOptionsFailure)((0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Fetch card policy vendor options REST API call errored out' +
45
- JSON.stringify(error))))));
46
- }));
47
- exports.fetchCardPolicyVendorOptionsEpic = fetchCardPolicyVendorOptionsEpic;
@@ -1,25 +0,0 @@
1
- import { ActionsObservable, StateObservable } from 'redux-observable';
2
- import { Observable } from 'rxjs';
3
- import { RootState } from '../../reducer';
4
- import { fetchCardPolicyRecommendationFromUpload, updatePolicyDocumentExtractionSuccess } from './cardPolicyReducer';
5
- export type ActionType = ReturnType<typeof updatePolicyDocumentExtractionSuccess> | ReturnType<typeof fetchCardPolicyRecommendationFromUpload>;
6
- /**
7
- * Bridge epic — chains the AI CFO `upload`-mode flow's two API hops.
8
- *
9
- * The first hop (`extractPolicyDocument` → multipart POST to
10
- * `policy-documents/extract`) lives on the cardPolicy slice and is
11
- * shared with the manual `CardPolicyCreatePage`. The second hop
12
- * (`fetchCardPolicyRecommendationFromUpload` → JSON POST to
13
- * `ai-cfo/policy-recommendation-from-upload`) is AI-CFO only.
14
- *
15
- * The chain is gated on `policyDocumentExtraction.aiCfoAnswerId` being
16
- * populated — manual callers leave it undefined, so the bridge is a
17
- * silent no-op there.
18
- *
19
- * Splitting this off from `policyRecommendationFromUploadEpic` keeps
20
- * the wizard component a pure renderer: it dispatches
21
- * `extractPolicyDocument(files, answerId, chatSessionId)` once, then
22
- * subscribes to `cardPolicyState` lifecycle flags to drive its
23
- * "Extracting…" / "Recommending…" pill.
24
- */
25
- export declare const policyDocumentExtractionToRecommendationBridgeEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>) => Observable<ActionType>;
@@ -1,39 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.policyDocumentExtractionToRecommendationBridgeEpic = void 0;
4
- const rxjs_1 = require("rxjs");
5
- const operators_1 = require("rxjs/operators");
6
- const cardPolicyReducer_1 = require("./cardPolicyReducer");
7
- /**
8
- * Bridge epic — chains the AI CFO `upload`-mode flow's two API hops.
9
- *
10
- * The first hop (`extractPolicyDocument` → multipart POST to
11
- * `policy-documents/extract`) lives on the cardPolicy slice and is
12
- * shared with the manual `CardPolicyCreatePage`. The second hop
13
- * (`fetchCardPolicyRecommendationFromUpload` → JSON POST to
14
- * `ai-cfo/policy-recommendation-from-upload`) is AI-CFO only.
15
- *
16
- * The chain is gated on `policyDocumentExtraction.aiCfoAnswerId` being
17
- * populated — manual callers leave it undefined, so the bridge is a
18
- * silent no-op there.
19
- *
20
- * Splitting this off from `policyRecommendationFromUploadEpic` keeps
21
- * the wizard component a pure renderer: it dispatches
22
- * `extractPolicyDocument(files, answerId, chatSessionId)` once, then
23
- * subscribes to `cardPolicyState` lifecycle flags to drive its
24
- * "Extracting…" / "Recommending…" pill.
25
- */
26
- const policyDocumentExtractionToRecommendationBridgeEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)(cardPolicyReducer_1.updatePolicyDocumentExtractionSuccess.match), (0, operators_1.mergeMap)((action) => {
27
- const extraction = state$.value.cardPolicyState.policyDocumentExtraction;
28
- const aiCfoAnswerId = extraction.aiCfoAnswerId;
29
- const aiCfoChatSessionId = extraction.aiCfoChatSessionId;
30
- const extractedRules = extraction.extractedRules;
31
- if (aiCfoAnswerId == null ||
32
- aiCfoChatSessionId == null ||
33
- extractedRules == null) {
34
- return rxjs_1.EMPTY;
35
- }
36
- void action;
37
- return (0, rxjs_1.of)((0, cardPolicyReducer_1.fetchCardPolicyRecommendationFromUpload)(aiCfoAnswerId, aiCfoChatSessionId, extractedRules));
38
- }));
39
- exports.policyDocumentExtractionToRecommendationBridgeEpic = policyDocumentExtractionToRecommendationBridgeEpic;
@@ -1,23 +0,0 @@
1
- import { ActionsObservable, StateObservable } from 'redux-observable';
2
- import { Observable } from 'rxjs';
3
- import { updateAiCfoAnswerCardPolicyWizardPlan } from '../aiCfo/aiCfoReducer';
4
- import { RootState } from '../../reducer';
5
- import { ZeniAPI } from '../../zeniAPI';
6
- import { fetchCardPolicyRecommendationFromUpload, updatePolicyRecommendationFromUploadFailure, updatePolicyRecommendationFromUploadSuccess } from './cardPolicyReducer';
7
- export type ActionType = ReturnType<typeof fetchCardPolicyRecommendationFromUpload> | ReturnType<typeof updatePolicyRecommendationFromUploadSuccess> | ReturnType<typeof updatePolicyRecommendationFromUploadFailure> | ReturnType<typeof updateAiCfoAnswerCardPolicyWizardPlan>;
8
- /**
9
- * Listens for `fetchCardPolicyRecommendationFromUpload` and POSTs the
10
- * just-extracted policy rules to the AI-CFO recommendation endpoint.
11
- *
12
- * On success — dispatches BOTH:
13
- * - `updatePolicyRecommendationFromUploadSuccess` (flips the
14
- * cardPolicy slice's recommendation lifecycle to `Completed`), and
15
- * - `updateAiCfoAnswerCardPolicyWizardPlan` (patches the in-flight AI
16
- * CFO answer's `CardPolicyInitialData` so the wizard can advance from
17
- * Step 1 → Step 2 in the upload variant).
18
- *
19
- * The reducer payload originally captured at kickoff (`answerId` +
20
- * `chatSessionId`) re-enters via the action so the patch can find the
21
- * right answer to merge into.
22
- */
23
- export declare const policyRecommendationFromUploadEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -1,92 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.policyRecommendationFromUploadEpic = void 0;
4
- const rxjs_1 = require("rxjs");
5
- const operators_1 = require("rxjs/operators");
6
- const aiCfoReducer_1 = require("../aiCfo/aiCfoReducer");
7
- const responsePayload_1 = require("../../responsePayload");
8
- const cardPolicyReducer_1 = require("./cardPolicyReducer");
9
- /**
10
- * Listens for `fetchCardPolicyRecommendationFromUpload` and POSTs the
11
- * just-extracted policy rules to the AI-CFO recommendation endpoint.
12
- *
13
- * On success — dispatches BOTH:
14
- * - `updatePolicyRecommendationFromUploadSuccess` (flips the
15
- * cardPolicy slice's recommendation lifecycle to `Completed`), and
16
- * - `updateAiCfoAnswerCardPolicyWizardPlan` (patches the in-flight AI
17
- * CFO answer's `CardPolicyInitialData` so the wizard can advance from
18
- * Step 1 → Step 2 in the upload variant).
19
- *
20
- * The reducer payload originally captured at kickoff (`answerId` +
21
- * `chatSessionId`) re-enters via the action so the patch can find the
22
- * right answer to merge into.
23
- */
24
- const policyRecommendationFromUploadEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(cardPolicyReducer_1.fetchCardPolicyRecommendationFromUpload.match), (0, operators_1.mergeMap)((action) => {
25
- const { answerId, chatSessionId, extractedRules } = action.payload;
26
- const body = {
27
- extracted_rules: {
28
- allowed_entity: {
29
- category_codes: extractedRules.allowedEntity.categoryCodes,
30
- merchant_names: extractedRules.allowedEntity.merchantNames,
31
- },
32
- blocked_entity: {
33
- category_codes: extractedRules.blockedEntity.categoryCodes,
34
- merchant_names: extractedRules.blockedEntity.merchantNames,
35
- },
36
- confidence_score: extractedRules.confidenceScore,
37
- policy_name: extractedRules.policyName,
38
- required_receipt_threshold: extractedRules.requiredReceiptThreshold,
39
- transaction_limit: extractedRules.transactionLimit,
40
- },
41
- };
42
- return zeniAPI
43
- .postAndGetJSON(`${zeniAPI.apiEndPoints.cardMicroServiceBaseUrl}/1.0/ai-cfo/policy-recommendation-from-upload`, body)
44
- .pipe((0, operators_1.mergeMap)((response) => {
45
- if (!(0, responsePayload_1.isSuccessStatus)(response) ||
46
- response.data?.wizard_plan?.step_5_review == null) {
47
- return (0, rxjs_1.of)((0, cardPolicyReducer_1.updatePolicyRecommendationFromUploadFailure)(response.status));
48
- }
49
- const data = response.data;
50
- const review = data.wizard_plan.step_5_review;
51
- const wizardPlan = {
52
- step5Review: {
53
- draftPolicies: (review.draft_policies ?? []).map((draft, index) => ({
54
- id: `draft-${index}`,
55
- name: draft.name,
56
- description: draft.description ?? '',
57
- mode: draft.mode,
58
- allowedEntity: {
59
- categoryCodes: draft.allowed_entity?.category_codes ?? [],
60
- merchantNames: draft.allowed_entity?.merchant_names ?? [],
61
- },
62
- blockedEntity: {
63
- categoryCodes: draft.blocked_entity?.category_codes ?? [],
64
- merchantNames: draft.blocked_entity?.merchant_names ?? [],
65
- },
66
- applyToCards: draft.apply_to_cards ?? [],
67
- requiredReceiptThreshold: draft.required_receipt_threshold ?? 0,
68
- spendLimits: {
69
- transaction: draft.spend_limits?.transaction ?? 0,
70
- },
71
- })),
72
- groupingSource: review.grouping_source ?? 'none',
73
- prompt: review.prompt ?? '',
74
- },
75
- };
76
- const source = data.source != null
77
- ? {
78
- confidenceScore: data.source.confidence_score,
79
- fileName: data.source.file_name,
80
- lowConfidenceFields: data.source.low_confidence_fields ?? [],
81
- }
82
- : undefined;
83
- return (0, rxjs_1.of)((0, cardPolicyReducer_1.updatePolicyRecommendationFromUploadSuccess)(), (0, aiCfoReducer_1.updateAiCfoAnswerCardPolicyWizardPlan)({
84
- answerId,
85
- chatSessionId,
86
- wizardPlan,
87
- source,
88
- }));
89
- }), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, cardPolicyReducer_1.updatePolicyRecommendationFromUploadFailure)((0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Policy recommendation from upload REST API call errored out' +
90
- JSON.stringify(error))))));
91
- }));
92
- exports.policyRecommendationFromUploadEpic = policyRecommendationFromUploadEpic;
@@ -1,130 +0,0 @@
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
- });