@zeniai/client-epic-state 5.0.65-betaRR7 → 5.0.65

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 (117) 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 +1 -7
  4. package/lib/entity/aiCfo/aiCfoReducer.js +4 -219
  5. package/lib/entity/aiCfo/aiCfoState.d.ts +4 -163
  6. package/lib/entity/aiCfo/aiCfoState.js +1 -10
  7. package/lib/entity/jeSchedules/jeSchedulesTypes.d.ts +1 -1
  8. package/lib/entity/monthEndCloseChecks/monthEndCloseChecksState.d.ts +1 -1
  9. package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
  10. package/lib/entity/snackbar/snackbarTypes.js +0 -2
  11. package/lib/entity/tenant/clearAllEpic.d.ts +2 -6
  12. package/lib/entity/tenant/clearAllEpic.js +0 -8
  13. package/lib/epic.d.ts +1 -11
  14. package/lib/epic.js +1 -11
  15. package/lib/esm/entity/aiCfo/aiCfoReducer.js +4 -219
  16. package/lib/esm/entity/aiCfo/aiCfoState.js +0 -7
  17. package/lib/esm/entity/snackbar/snackbarTypes.js +0 -2
  18. package/lib/esm/entity/tenant/clearAllEpic.js +0 -8
  19. package/lib/esm/epic.js +1 -11
  20. package/lib/esm/index.js +4 -19
  21. package/lib/esm/reducer.js +0 -12
  22. package/lib/esm/view/aiCfoView/aiCfoViewReducer.js +3 -6
  23. package/lib/esm/view/aiCfoView/epics/createSessionAndSubmitEpic.js +2 -5
  24. package/lib/esm/view/aiCfoView/epics/createSessionEpic.js +1 -2
  25. package/lib/esm/view/aiCfoView/epics/fetchSuggestedQuestionsEpic.js +2 -12
  26. package/lib/esm/view/spendManagement/chargeCards/chargeCardList/chargeCardListSelector.js +0 -25
  27. package/lib/index.d.ts +4 -17
  28. package/lib/index.js +11 -112
  29. package/lib/reducer.d.ts +0 -12
  30. package/lib/reducer.js +0 -12
  31. package/lib/tsconfig.typecheck.tsbuildinfo +1 -0
  32. package/lib/view/aiCfoView/aiCfoViewReducer.d.ts +2 -11
  33. package/lib/view/aiCfoView/aiCfoViewReducer.js +3 -6
  34. package/lib/view/aiCfoView/epics/createSessionAndSubmitEpic.js +2 -5
  35. package/lib/view/aiCfoView/epics/createSessionEpic.js +1 -2
  36. package/lib/view/aiCfoView/epics/fetchSuggestedQuestionsEpic.d.ts +1 -8
  37. package/lib/view/aiCfoView/epics/fetchSuggestedQuestionsEpic.js +2 -12
  38. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
  39. package/lib/view/expenseAutomationView/types/jeSchedulesViewState.d.ts +1 -1
  40. package/lib/view/expenseAutomationView/types/missingReceiptsViewState.d.ts +2 -2
  41. package/lib/view/expenseAutomationView/types/transactionsViewState.d.ts +1 -1
  42. package/lib/view/people/peopleTypes.d.ts +1 -1
  43. package/lib/view/scheduleView/scheduleListView/scheduleListTypes.d.ts +1 -1
  44. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardList.d.ts +1 -1
  45. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListSelector.d.ts +0 -14
  46. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListSelector.js +1 -27
  47. package/lib/view/taskManager/taskListView/taskListReducer.d.ts +1 -1
  48. package/package.json +1 -1
  49. package/lib/entity/cardPolicy/cardPolicyPayload.d.ts +0 -277
  50. package/lib/entity/cardPolicy/cardPolicyPayload.js +0 -143
  51. package/lib/entity/cardPolicy/cardPolicyReducer.d.ts +0 -19
  52. package/lib/entity/cardPolicy/cardPolicyReducer.js +0 -256
  53. package/lib/entity/cardPolicy/cardPolicySelector.d.ts +0 -32
  54. package/lib/entity/cardPolicy/cardPolicySelector.js +0 -103
  55. package/lib/entity/cardPolicy/cardPolicyState.d.ts +0 -205
  56. package/lib/entity/cardPolicy/cardPolicyState.js +0 -14
  57. package/lib/entity/cardPolicy/extractPolicyDocumentEpic.d.ts +0 -18
  58. package/lib/entity/cardPolicy/extractPolicyDocumentEpic.js +0 -54
  59. package/lib/entity/cardPolicy/fetchCardPolicyVendorOptionsEpic.d.ts +0 -26
  60. package/lib/entity/cardPolicy/fetchCardPolicyVendorOptionsEpic.js +0 -47
  61. package/lib/entity/cardPolicy/policyDocumentExtractionToRecommendationBridgeEpic.d.ts +0 -25
  62. package/lib/entity/cardPolicy/policyDocumentExtractionToRecommendationBridgeEpic.js +0 -39
  63. package/lib/entity/cardPolicy/policyRecommendationFromUploadEpic.d.ts +0 -23
  64. package/lib/entity/cardPolicy/policyRecommendationFromUploadEpic.js +0 -92
  65. package/lib/esm/entity/cardPolicy/cardPolicyPayload.js +0 -130
  66. package/lib/esm/entity/cardPolicy/cardPolicyReducer.js +0 -252
  67. package/lib/esm/entity/cardPolicy/cardPolicySelector.js +0 -79
  68. package/lib/esm/entity/cardPolicy/cardPolicyState.js +0 -9
  69. package/lib/esm/entity/cardPolicy/extractPolicyDocumentEpic.js +0 -50
  70. package/lib/esm/entity/cardPolicy/fetchCardPolicyVendorOptionsEpic.js +0 -43
  71. package/lib/esm/entity/cardPolicy/policyDocumentExtractionToRecommendationBridgeEpic.js +0 -35
  72. package/lib/esm/entity/cardPolicy/policyRecommendationFromUploadEpic.js +0 -88
  73. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailReducer.js +0 -70
  74. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailSelector.js +0 -22
  75. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailState.js +0 -1
  76. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/fetchCardPolicyDetailEpic.js +0 -56
  77. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/updateCardPolicyEpic.js +0 -49
  78. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/archiveCardPolicyEpic.js +0 -42
  79. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListReducer.js +0 -72
  80. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListSelector.js +0 -21
  81. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListState.js +0 -1
  82. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/fetchCardPolicyListEpic.js +0 -56
  83. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyReducer.js +0 -59
  84. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicySelector.js +0 -31
  85. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyState.js +0 -1
  86. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyTemplateEpic.js +0 -53
  87. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/fetchCardPolicyMccCategoriesEpic.js +0 -25
  88. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailReducer.d.ts +0 -14
  89. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailReducer.js +0 -74
  90. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailSelector.d.ts +0 -21
  91. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailSelector.js +0 -28
  92. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailState.d.ts +0 -25
  93. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailState.js +0 -2
  94. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/fetchCardPolicyDetailEpic.d.ts +0 -19
  95. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/fetchCardPolicyDetailEpic.js +0 -60
  96. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/updateCardPolicyEpic.d.ts +0 -18
  97. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/updateCardPolicyEpic.js +0 -53
  98. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/archiveCardPolicyEpic.d.ts +0 -16
  99. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/archiveCardPolicyEpic.js +0 -46
  100. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListReducer.d.ts +0 -15
  101. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListReducer.js +0 -76
  102. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListSelector.d.ts +0 -21
  103. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListSelector.js +0 -27
  104. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListState.d.ts +0 -19
  105. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListState.js +0 -2
  106. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/fetchCardPolicyListEpic.d.ts +0 -19
  107. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/fetchCardPolicyListEpic.js +0 -60
  108. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyReducer.d.ts +0 -13
  109. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyReducer.js +0 -63
  110. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicySelector.d.ts +0 -26
  111. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicySelector.js +0 -37
  112. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyState.d.ts +0 -36
  113. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyState.js +0 -2
  114. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyTemplateEpic.d.ts +0 -25
  115. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyTemplateEpic.js +0 -57
  116. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/fetchCardPolicyMccCategoriesEpic.d.ts +0 -15
  117. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/fetchCardPolicyMccCategoriesEpic.js +0 -29
@@ -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 { extractPolicyDocument, updatePolicyDocumentExtractionFailure, updatePolicyDocumentExtractionSuccess } from './cardPolicyReducer';
6
- export type ActionType = ReturnType<typeof extractPolicyDocument> | ReturnType<typeof updatePolicyDocumentExtractionSuccess> | ReturnType<typeof updatePolicyDocumentExtractionFailure>;
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>;
@@ -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;