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

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 (189) hide show
  1. package/lib/common/aiCfo/aiCfoSuggestedQuestionsPageContext.d.ts +1 -1
  2. package/lib/commonStateTypes/viewAndReport/viewAndReport.d.ts +2 -2
  3. package/lib/commonStateTypes/viewAndReport/viewAndReport.js +0 -2
  4. package/lib/entity/account/accountSelector.d.ts +0 -9
  5. package/lib/entity/account/accountSelector.js +1 -14
  6. package/lib/entity/account/accountState.d.ts +1 -1
  7. package/lib/entity/accountGroup/accountGroupState.d.ts +1 -1
  8. package/lib/entity/aiCfo/aiCfoPayload.d.ts +171 -1
  9. package/lib/entity/aiCfo/aiCfoReducer.d.ts +22 -2
  10. package/lib/entity/aiCfo/aiCfoReducer.js +291 -4
  11. package/lib/entity/aiCfo/aiCfoSelector.d.ts +3 -1
  12. package/lib/entity/aiCfo/aiCfoSelector.js +11 -1
  13. package/lib/entity/aiCfo/aiCfoState.d.ts +186 -4
  14. package/lib/entity/aiCfo/aiCfoState.js +23 -1
  15. package/lib/entity/cardPolicy/cardPolicyPayload.d.ts +277 -0
  16. package/lib/entity/cardPolicy/cardPolicyPayload.js +143 -0
  17. package/lib/entity/cardPolicy/cardPolicyReducer.d.ts +19 -0
  18. package/lib/entity/cardPolicy/cardPolicyReducer.js +256 -0
  19. package/lib/entity/cardPolicy/cardPolicySelector.d.ts +32 -0
  20. package/lib/entity/cardPolicy/cardPolicySelector.js +103 -0
  21. package/lib/entity/cardPolicy/cardPolicyState.d.ts +205 -0
  22. package/lib/entity/cardPolicy/cardPolicyState.js +14 -0
  23. package/lib/entity/cardPolicy/extractPolicyDocumentEpic.d.ts +18 -0
  24. package/lib/entity/cardPolicy/extractPolicyDocumentEpic.js +54 -0
  25. package/lib/entity/cardPolicy/fetchCardPolicyVendorOptionsEpic.d.ts +26 -0
  26. package/lib/entity/cardPolicy/fetchCardPolicyVendorOptionsEpic.js +47 -0
  27. package/lib/entity/cardPolicy/policyDocumentExtractionToRecommendationBridgeEpic.d.ts +25 -0
  28. package/lib/entity/cardPolicy/policyDocumentExtractionToRecommendationBridgeEpic.js +39 -0
  29. package/lib/entity/cardPolicy/policyRecommendationFromUploadEpic.d.ts +23 -0
  30. package/lib/entity/cardPolicy/policyRecommendationFromUploadEpic.js +92 -0
  31. package/lib/entity/class/classReducer.d.ts +4 -4
  32. package/lib/entity/class/classState.d.ts +1 -1
  33. package/lib/entity/forecast/forecastState.d.ts +1 -1
  34. package/lib/entity/jeSchedules/jeSchedulesTypes.d.ts +1 -1
  35. package/lib/entity/monthEndCloseChecks/monthEndCloseChecksState.d.ts +1 -1
  36. package/lib/entity/sectionAccountsView/sectionAccountsView.d.ts +1 -1
  37. package/lib/entity/sectionClassesViewV2/sectionClassesView.d.ts +1 -1
  38. package/lib/entity/sectionClassesViewV2/sectionClassesViewReducer.d.ts +2 -2
  39. package/lib/entity/sectionProjectView/sectionProjectView.d.ts +1 -1
  40. package/lib/entity/sectionProjectView/sectionProjectViewReducer.d.ts +2 -2
  41. package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
  42. package/lib/entity/snackbar/snackbarTypes.js +2 -1
  43. package/lib/entity/tenant/clearAllEpic.d.ts +6 -3
  44. package/lib/entity/tenant/clearAllEpic.js +8 -2
  45. package/lib/entity/transaction/payloadTypes/transactionPayload.d.ts +0 -4
  46. package/lib/entity/transaction/payloadTypes/transactionPayload.js +10 -18
  47. package/lib/entity/transaction/stateTypes/transaction.d.ts +0 -3
  48. package/lib/epic.d.ts +11 -3
  49. package/lib/epic.js +11 -3
  50. package/lib/esm/commonStateTypes/viewAndReport/viewAndReport.js +0 -2
  51. package/lib/esm/entity/account/accountSelector.js +0 -11
  52. package/lib/esm/entity/aiCfo/aiCfoReducer.js +291 -4
  53. package/lib/esm/entity/aiCfo/aiCfoSelector.js +10 -1
  54. package/lib/esm/entity/aiCfo/aiCfoState.js +20 -0
  55. package/lib/esm/entity/cardPolicy/cardPolicyPayload.js +130 -0
  56. package/lib/esm/entity/cardPolicy/cardPolicyReducer.js +252 -0
  57. package/lib/esm/entity/cardPolicy/cardPolicySelector.js +79 -0
  58. package/lib/esm/entity/cardPolicy/cardPolicyState.js +9 -0
  59. package/lib/esm/entity/cardPolicy/extractPolicyDocumentEpic.js +50 -0
  60. package/lib/esm/entity/cardPolicy/fetchCardPolicyVendorOptionsEpic.js +43 -0
  61. package/lib/esm/entity/cardPolicy/policyDocumentExtractionToRecommendationBridgeEpic.js +35 -0
  62. package/lib/esm/entity/cardPolicy/policyRecommendationFromUploadEpic.js +88 -0
  63. package/lib/esm/entity/snackbar/snackbarTypes.js +2 -1
  64. package/lib/esm/entity/tenant/clearAllEpic.js +8 -2
  65. package/lib/esm/entity/transaction/payloadTypes/transactionPayload.js +10 -18
  66. package/lib/esm/epic.js +11 -3
  67. package/lib/esm/index.js +26 -12
  68. package/lib/esm/reducer.js +12 -3
  69. package/lib/esm/view/aiCfoView/aiCfoViewReducer.js +6 -3
  70. package/lib/esm/view/aiCfoView/epics/createSessionAndSubmitEpic.js +5 -2
  71. package/lib/esm/view/aiCfoView/epics/createSessionEpic.js +2 -1
  72. package/lib/esm/view/aiCfoView/epics/fetchSuggestedQuestionsEpic.js +12 -2
  73. package/lib/esm/view/expenseAutomationView/reducers/transactionsViewReducer.js +1 -13
  74. package/lib/esm/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +1 -9
  75. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailReducer.js +70 -0
  76. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailSelector.js +22 -0
  77. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailState.js +1 -0
  78. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/fetchCardPolicyDetailEpic.js +56 -0
  79. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/updateCardPolicyEpic.js +49 -0
  80. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/archiveCardPolicyEpic.js +42 -0
  81. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListReducer.js +72 -0
  82. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListSelector.js +21 -0
  83. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListState.js +1 -0
  84. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/fetchCardPolicyListEpic.js +56 -0
  85. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyReducer.js +62 -0
  86. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicySelector.js +39 -0
  87. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyState.js +1 -0
  88. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyTemplateEpic.js +53 -0
  89. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/fetchCardPolicyMccCategoriesEpic.js +25 -0
  90. package/lib/esm/view/spendManagement/chargeCards/chargeCardList/chargeCardListSelector.js +25 -0
  91. package/lib/esm/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardEpic.js +2 -2
  92. package/lib/esm/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardReducer.js +16 -4
  93. package/lib/esm/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardSelector.js +38 -0
  94. package/lib/esm/view/transactionDetail/transactionDetailSelector.js +1 -6
  95. package/lib/index.d.ts +24 -12
  96. package/lib/index.js +147 -43
  97. package/lib/reducer.d.ts +12 -3
  98. package/lib/reducer.js +12 -3
  99. package/lib/view/aiCfoView/aiCfoViewReducer.d.ts +11 -2
  100. package/lib/view/aiCfoView/aiCfoViewReducer.js +6 -3
  101. package/lib/view/aiCfoView/epics/createSessionAndSubmitEpic.js +5 -2
  102. package/lib/view/aiCfoView/epics/createSessionEpic.js +2 -1
  103. package/lib/view/aiCfoView/epics/fetchSuggestedQuestionsEpic.d.ts +8 -1
  104. package/lib/view/aiCfoView/epics/fetchSuggestedQuestionsEpic.js +12 -2
  105. package/lib/view/auditReportView/auditReportViewState.d.ts +1 -1
  106. package/lib/view/billPayCard/billPayCardSelector.d.ts +1 -1
  107. package/lib/view/cardBalance/cardBalanceSelector.d.ts +1 -1
  108. package/lib/view/cashBalance/cashBalanceSelector.d.ts +1 -1
  109. package/lib/view/cashInCashOut/cashInCashOutSelector.d.ts +1 -1
  110. package/lib/view/cashPosition/cashPositionSelector.d.ts +1 -1
  111. package/lib/view/dashboard/dashboardReducer.d.ts +2 -2
  112. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
  113. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +1 -3
  114. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.js +2 -14
  115. package/lib/view/expenseAutomationView/selectorTypes/transactionsViewSelectorTypes.d.ts +1 -4
  116. package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.d.ts +0 -1
  117. package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +2 -11
  118. package/lib/view/expenseAutomationView/types/jeSchedulesViewState.d.ts +1 -1
  119. package/lib/view/expenseAutomationView/types/missingReceiptsViewState.d.ts +2 -2
  120. package/lib/view/expenseAutomationView/types/reconciliationViewState.d.ts +1 -1
  121. package/lib/view/expenseAutomationView/types/transactionsViewState.d.ts +1 -1
  122. package/lib/view/financeStatement/financeStatementReducer.d.ts +1 -1
  123. package/lib/view/globalMerchantView/globalMerchantViewReducer.d.ts +2 -2
  124. package/lib/view/people/peopleTypes.d.ts +1 -1
  125. package/lib/view/reimbursementCard/reimbursementCardSelector.d.ts +1 -1
  126. package/lib/view/reportsResync/reportsResyncReducer.d.ts +2 -2
  127. package/lib/view/scheduleView/scheduleListView/scheduleListTypes.d.ts +1 -1
  128. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailReducer.d.ts +14 -0
  129. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailReducer.js +74 -0
  130. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailSelector.d.ts +21 -0
  131. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailSelector.js +28 -0
  132. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailState.d.ts +25 -0
  133. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailState.js +2 -0
  134. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/fetchCardPolicyDetailEpic.d.ts +19 -0
  135. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/fetchCardPolicyDetailEpic.js +60 -0
  136. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/updateCardPolicyEpic.d.ts +18 -0
  137. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/updateCardPolicyEpic.js +53 -0
  138. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/archiveCardPolicyEpic.d.ts +16 -0
  139. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/archiveCardPolicyEpic.js +46 -0
  140. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListReducer.d.ts +15 -0
  141. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListReducer.js +76 -0
  142. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListSelector.d.ts +21 -0
  143. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListSelector.js +27 -0
  144. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListState.d.ts +19 -0
  145. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListState.js +2 -0
  146. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/fetchCardPolicyListEpic.d.ts +19 -0
  147. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/fetchCardPolicyListEpic.js +60 -0
  148. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyReducer.d.ts +13 -0
  149. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyReducer.js +66 -0
  150. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicySelector.d.ts +32 -0
  151. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicySelector.js +46 -0
  152. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyState.d.ts +45 -0
  153. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyState.js +2 -0
  154. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyTemplateEpic.d.ts +25 -0
  155. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyTemplateEpic.js +57 -0
  156. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/fetchCardPolicyMccCategoriesEpic.d.ts +15 -0
  157. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/fetchCardPolicyMccCategoriesEpic.js +29 -0
  158. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardList.d.ts +1 -1
  159. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListSelector.d.ts +14 -0
  160. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListSelector.js +27 -1
  161. package/lib/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardEpic.d.ts +2 -2
  162. package/lib/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardEpic.js +1 -1
  163. package/lib/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardReducer.d.ts +5 -1
  164. package/lib/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardReducer.js +17 -5
  165. package/lib/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardSelector.d.ts +27 -0
  166. package/lib/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardSelector.js +43 -1
  167. package/lib/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardState.d.ts +2 -0
  168. package/lib/view/taskManager/taskListView/taskListReducer.d.ts +1 -1
  169. package/lib/view/tasksCard/tasksCardSelector.d.ts +1 -1
  170. package/lib/view/topEx/topExSelector.d.ts +1 -1
  171. package/lib/view/transactionDetail/transactionDetailPayload.d.ts +1 -1
  172. package/lib/view/transactionDetail/transactionDetailSelector.d.ts +1 -6
  173. package/lib/view/transactionDetail/transactionDetailSelector.js +1 -6
  174. package/package.json +1 -1
  175. package/lib/esm/view/createTransferEntry/createTransferEntryReducer.js +0 -82
  176. package/lib/esm/view/createTransferEntry/createTransferEntrySelector.js +0 -64
  177. package/lib/esm/view/createTransferEntry/createTransferEntryState.js +0 -17
  178. package/lib/esm/view/createTransferEntry/epics/createTransferEntryEpic.js +0 -130
  179. package/lib/esm/view/createTransferEntry/epics/fetchTransferAccountsEpic.js +0 -37
  180. package/lib/view/createTransferEntry/createTransferEntryReducer.d.ts +0 -32
  181. package/lib/view/createTransferEntry/createTransferEntryReducer.js +0 -86
  182. package/lib/view/createTransferEntry/createTransferEntrySelector.d.ts +0 -39
  183. package/lib/view/createTransferEntry/createTransferEntrySelector.js +0 -69
  184. package/lib/view/createTransferEntry/createTransferEntryState.d.ts +0 -30
  185. package/lib/view/createTransferEntry/createTransferEntryState.js +0 -20
  186. package/lib/view/createTransferEntry/epics/createTransferEntryEpic.d.ts +0 -11
  187. package/lib/view/createTransferEntry/epics/createTransferEntryEpic.js +0 -134
  188. package/lib/view/createTransferEntry/epics/fetchTransferAccountsEpic.d.ts +0 -14
  189. package/lib/view/createTransferEntry/epics/fetchTransferAccountsEpic.js +0 -41
@@ -9,9 +9,13 @@ export interface AiCfoAnswerParagraph {
9
9
  }>;
10
10
  }
11
11
  export declare const ALL_AI_CFO_CHARTS_TYPES: readonly ["bar_chart", "pie_chart", "line_chart"];
12
- export declare const ALL_AI_CFO_VISUALIZATION_TYPES: readonly ["bar_chart", "pie_chart", "line_chart", "table"];
13
- export declare const toAiCfoVisualizationType: (v: string) => "bar_chart" | "pie_chart" | "line_chart" | "table";
14
- export declare const toAiCfoVisualizationTypeStrict: (v: string) => "bar_chart" | "pie_chart" | "line_chart" | "table" | undefined;
12
+ export declare const ALL_AI_CFO_VISUALIZATION_TYPES: readonly ["bar_chart", "pie_chart", "line_chart", "table", "interactive_form"];
13
+ export declare const ALL_INTERACTIVE_FORM_TYPES: readonly ["cards_creation", "card_policy"];
14
+ export declare const toInteractiveFormType: (v: string) => "cards_creation" | "card_policy";
15
+ export declare const toInteractiveFormTypeStrict: (v: string) => "cards_creation" | "card_policy" | undefined;
16
+ export type InteractiveFormType = ReturnType<typeof toInteractiveFormType>;
17
+ export declare const toAiCfoVisualizationType: (v: string) => "bar_chart" | "pie_chart" | "line_chart" | "table" | "interactive_form";
18
+ export declare const toAiCfoVisualizationTypeStrict: (v: string) => "bar_chart" | "pie_chart" | "line_chart" | "table" | "interactive_form" | undefined;
15
19
  export type AiCfoVisualizationType = ReturnType<typeof toAiCfoVisualizationType>;
16
20
  export declare const toAiCfoChartType: (v: string) => "bar_chart" | "pie_chart" | "line_chart";
17
21
  export declare const toAiCfoChartTypeStrict: (v: string) => "bar_chart" | "pie_chart" | "line_chart" | undefined;
@@ -53,8 +57,163 @@ export interface ChartVisualization {
53
57
  lines?: string[];
54
58
  yFormat?: YFormat;
55
59
  }
60
+ export interface CardsCardOption {
61
+ id: string;
62
+ label: string;
63
+ description?: string;
64
+ }
65
+ /**
66
+ * Card kind for AI Card Creation rows. `vendor` = vendor-bound card,
67
+ * `class` = department-scoped card. The wire format ships `department`;
68
+ * the reducer maps it to `class` (the FE-side term for accounting class /
69
+ * department) so it lines up with the rest of the codebase.
70
+ */
71
+ export type CardsCardKind = 'vendor' | 'class';
72
+ /**
73
+ * Single entry in the unified vendor + department dropdown universe shipped
74
+ * by the AI controller for the `review` flow. Powers both the
75
+ * step-2 Card cell dropdown (filtered to entries with matching `kind`) and
76
+ * the step-1 "Add something else" search (no kind filter — user can add
77
+ * either).
78
+ */
79
+ export interface CardNameOption {
80
+ id: string;
81
+ kind: CardsCardKind;
82
+ label: string;
83
+ }
84
+ /**
85
+ * Initial data for the AI Card Creation interactive form. Discriminated on
86
+ * `mode`:
87
+ *
88
+ * - `review` (default): AI suggests rows (mix of vendors +
89
+ * departments); user reviews them in step 1, then configures one card per
90
+ * row in step 2. `cardNameOptions` is the full universe (suggested +
91
+ * not-suggested) used to populate the dropdown / search.
92
+ * - `create` (1-step): AI has already chosen cards; user lands directly
93
+ * on the editable card table for confirmation.
94
+ */
95
+ export type CardsCreationInitialData = {
96
+ cardNameOptions: CardNameOption[];
97
+ cardOptions: CardsCardOption[];
98
+ mode: 'review';
99
+ /**
100
+ * Map of `teamRow.id` -> suggested owner `userId`. Resolved against
101
+ * `allUsers` (sourced from the tenant) at render time.
102
+ */
103
+ suggestedOwnerUserIdByTeamId: Record<string, ID | undefined>;
104
+ teamRows: Array<{
105
+ avgMonthlySpend: string;
106
+ cardKind: CardsCardKind;
107
+ id: string;
108
+ label: string;
109
+ recommendedLimit: string;
110
+ recommendedLimitCadence?: string;
111
+ }>;
112
+ } | {
113
+ cardOptions: CardsCardOption[];
114
+ cardRows: Array<{
115
+ cardOptionId: string;
116
+ id: string;
117
+ /**
118
+ * Optional team-derived display label rendered in the card cell
119
+ * trigger (e.g. "Engineering"). Drives the row's first-letter avatar
120
+ * in step 2.
121
+ */
122
+ label?: string;
123
+ recommendedLimit?: number;
124
+ suggestedOwnerUserId?: ID;
125
+ }>;
126
+ mode: 'create';
127
+ };
128
+ /**
129
+ * Per-policy allow / block bucket. CamelCase mirror of
130
+ * `DraftPolicyEntityPayload`.
131
+ */
132
+ export interface CardPolicyDraftPolicyEntity {
133
+ categoryCodes: string[];
134
+ merchantNames: string[];
135
+ }
136
+ /**
137
+ * Spend-limit bucket per policy. `transaction` is the only cadence the
138
+ * BE ships today.
139
+ */
140
+ export interface CardPolicySpendLimits {
141
+ transaction: number;
142
+ }
143
+ /**
144
+ * Single draft policy in FE state. Identity is positional — the reducer
145
+ * synthesizes a stable `id` (`draft-0`, `draft-1`, ...) at decode time
146
+ * since the BE doesn't ship one today.
147
+ */
148
+ export interface CardPolicyDraftPolicy {
149
+ allowedEntity: CardPolicyDraftPolicyEntity;
150
+ applyToCards: string[];
151
+ blockedEntity: CardPolicyDraftPolicyEntity;
152
+ description: string;
153
+ id: string;
154
+ /** Enforcement mode (e.g. `"strict"`). Carried for guided submit;
155
+ * ignored by auto / upload submit. */
156
+ mode: string;
157
+ name: string;
158
+ requiredReceiptThreshold: number;
159
+ spendLimits: CardPolicySpendLimits;
160
+ }
161
+ export interface CardPolicyStep5Review {
162
+ draftPolicies: CardPolicyDraftPolicy[];
163
+ groupingSource: string;
164
+ prompt: string;
165
+ }
166
+ export interface CardPolicyWizardPlan {
167
+ step5Review: CardPolicyStep5Review;
168
+ }
169
+ /**
170
+ * Upload-mode metadata returned by the
171
+ * `policy-recommendation-from-upload` API alongside the wizard plan.
172
+ */
173
+ export interface CardPolicyUploadSource {
174
+ confidenceScore: number;
175
+ fileName: string;
176
+ lowConfidenceFields: string[];
177
+ }
178
+ /**
179
+ * Initial data for the AI Card Policy interactive form. Discriminated on
180
+ * `policyKind`. All three modes consume the same `wizardPlan.step5Review`
181
+ * envelope; the wizard renders different surfaces per mode.
182
+ *
183
+ * - `auto` (1-step review): chip groups built directly from each draft
184
+ * policy. Submit omits `mode` + `spend_limits` + `required_receipt_threshold`.
185
+ * - `guided` (5-step wizard): Steps 1–4 seeded from `draftPolicies[0]`,
186
+ * Step 5 lists every draft. Submit includes all keys.
187
+ * - `upload` (3-step): upload → cards → review. `wizardPlan` is
188
+ * `undefined` until the upload-recommendation API succeeds, then
189
+ * populated alongside `source` metadata. Submit includes
190
+ * `spend_limits` + `required_receipt_threshold`; omits `mode`.
191
+ */
192
+ export type CardPolicyInitialData = {
193
+ policyKind: 'auto';
194
+ wizardPlan: CardPolicyWizardPlan;
195
+ } | {
196
+ policyKind: 'guided';
197
+ wizardPlan: CardPolicyWizardPlan;
198
+ } | {
199
+ policyKind: 'upload';
200
+ source?: CardPolicyUploadSource;
201
+ wizardPlan?: CardPolicyWizardPlan;
202
+ };
203
+ /**
204
+ * Visualization variant rendered as an interactive RHF form (in lieu of a
205
+ * chart or table). Discriminated on `formType`; each branch carries its own
206
+ * payload shape.
207
+ */
208
+ export type InteractiveFormVisualization = {
209
+ formType: 'cards_creation';
210
+ payload: CardsCreationInitialData;
211
+ } | {
212
+ formType: 'card_policy';
213
+ payload: CardPolicyInitialData;
214
+ };
56
215
  export interface AiCfoVisualization {
57
- data: TableVisualization | ChartVisualization;
216
+ data: TableVisualization | ChartVisualization | InteractiveFormVisualization;
58
217
  type: AiCfoVisualizationType;
59
218
  }
60
219
  export declare const toMessageSender: (v: string) => "user" | "agent";
@@ -112,7 +271,30 @@ export interface ChatSessionWithMessages {
112
271
  chatSession: ChatSession;
113
272
  questionAnswers: AiCfoQuestionWithAnswer[];
114
273
  }
274
+ /**
275
+ * Discriminator for client-synthesized AI CFO answer bubbles. These are not
276
+ * Q/A pairs streamed from the backend — they are pushed locally by the AI
277
+ * CFO flow when it kicks off a cards or policy create from an interactive
278
+ * form, so the drawer can render a "Creating…" placeholder and later a
279
+ * "Created" success bubble while the corresponding mutation epic runs.
280
+ */
281
+ export declare const ALL_SYNTHETIC_AI_CFO_ANSWER_KINDS: readonly ["creating_cards", "creating_policy", "created_cards", "created_policy"];
282
+ export type SyntheticAiCfoAnswerKind = (typeof ALL_SYNTHETIC_AI_CFO_ANSWER_KINDS)[number];
283
+ /**
284
+ * A locally-synthesized answer bubble (e.g. "Creating cards…", or "2 policies
285
+ * are created and saved" with preview tiles). Lives parallel to the streamed
286
+ * `questionAnswers` to keep the conversation shape pristine; the AI CFO
287
+ * renderer appends these at the bottom of the conversation in order of
288
+ * `createdAt`.
289
+ */
290
+ export interface SyntheticAiCfoAnswer {
291
+ createdAt: ZeniDate;
292
+ entityIds: ID[];
293
+ id: ID;
294
+ kind: SyntheticAiCfoAnswerKind;
295
+ }
115
296
  export interface AiCfoState {
116
297
  aiCfoByChatSessionId: Record<ID, ChatSessionWithMessages>;
117
298
  partialQuestionAnswers: Record<ID, AiCfoQuestionWithAnswer | undefined>;
299
+ syntheticAnswersByChatSessionId: Record<ID, SyntheticAiCfoAnswer[]>;
118
300
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toMessageTypeStrict = exports.toMessageSenderStrict = exports.toMessageType = exports.toMessageSender = exports.toAiCfoAnswerResponseTypeStrict = exports.toAiCfoAnswerStateTypeStrict = exports.toAiCfoAnswerResponseType = exports.toAiCfoAnswerStateType = exports.toYFormatScaleStrict = exports.toYFormatUnitStrict = exports.toYFormatTypeStrict = exports.toYFormatScale = exports.toYFormatUnit = exports.toYFormatType = exports.ALL_Y_FORMAT_SCALES = exports.ALL_Y_FORMAT_NON_CURRENCY_UNITS = exports.ALL_Y_FORMAT_TYPES = exports.ALL_AI_CFO_ANSWER_RESPONSE_TYPES = exports.ALL_AI_CFO_ANSWER_STATE_TYPES = exports.toAiCfoChartTypeStrict = exports.toAiCfoChartType = exports.toAiCfoVisualizationTypeStrict = exports.toAiCfoVisualizationType = exports.ALL_AI_CFO_VISUALIZATION_TYPES = exports.ALL_AI_CFO_CHARTS_TYPES = void 0;
3
+ exports.ALL_SYNTHETIC_AI_CFO_ANSWER_KINDS = exports.toMessageTypeStrict = exports.toMessageSenderStrict = exports.toMessageType = exports.toMessageSender = exports.toAiCfoAnswerResponseTypeStrict = exports.toAiCfoAnswerStateTypeStrict = exports.toAiCfoAnswerResponseType = exports.toAiCfoAnswerStateType = exports.toYFormatScaleStrict = exports.toYFormatUnitStrict = exports.toYFormatTypeStrict = exports.toYFormatScale = exports.toYFormatUnit = exports.toYFormatType = exports.ALL_Y_FORMAT_SCALES = exports.ALL_Y_FORMAT_NON_CURRENCY_UNITS = exports.ALL_Y_FORMAT_TYPES = exports.ALL_AI_CFO_ANSWER_RESPONSE_TYPES = exports.ALL_AI_CFO_ANSWER_STATE_TYPES = exports.toAiCfoChartTypeStrict = exports.toAiCfoChartType = exports.toAiCfoVisualizationTypeStrict = exports.toAiCfoVisualizationType = exports.toInteractiveFormTypeStrict = exports.toInteractiveFormType = exports.ALL_INTERACTIVE_FORM_TYPES = exports.ALL_AI_CFO_VISUALIZATION_TYPES = exports.ALL_AI_CFO_CHARTS_TYPES = void 0;
4
4
  const stringToUnion_1 = require("../../commonStateTypes/stringToUnion");
5
5
  exports.ALL_AI_CFO_CHARTS_TYPES = [
6
6
  'bar_chart',
@@ -10,7 +10,16 @@ exports.ALL_AI_CFO_CHARTS_TYPES = [
10
10
  exports.ALL_AI_CFO_VISUALIZATION_TYPES = [
11
11
  ...exports.ALL_AI_CFO_CHARTS_TYPES,
12
12
  'table',
13
+ 'interactive_form',
13
14
  ];
15
+ exports.ALL_INTERACTIVE_FORM_TYPES = [
16
+ 'cards_creation',
17
+ 'card_policy',
18
+ ];
19
+ const toInteractiveFormType = (v) => (0, stringToUnion_1.stringToUnion)(v, exports.ALL_INTERACTIVE_FORM_TYPES);
20
+ exports.toInteractiveFormType = toInteractiveFormType;
21
+ const toInteractiveFormTypeStrict = (v) => (0, stringToUnion_1.stringToUnionStrict)(v, exports.ALL_INTERACTIVE_FORM_TYPES);
22
+ exports.toInteractiveFormTypeStrict = toInteractiveFormTypeStrict;
14
23
  const toAiCfoVisualizationType = (v) => (0, stringToUnion_1.stringToUnion)(v, exports.ALL_AI_CFO_VISUALIZATION_TYPES);
15
24
  exports.toAiCfoVisualizationType = toAiCfoVisualizationType;
16
25
  const toAiCfoVisualizationTypeStrict = (v) => (0, stringToUnion_1.stringToUnionStrict)(v, exports.ALL_AI_CFO_VISUALIZATION_TYPES);
@@ -79,3 +88,16 @@ const toMessageSenderStrict = (v) => (0, stringToUnion_1.stringToUnionStrict)(v,
79
88
  exports.toMessageSenderStrict = toMessageSenderStrict;
80
89
  const toMessageTypeStrict = (v) => (0, stringToUnion_1.stringToUnionStrict)(v, ALL_MESSAGE_TYPES);
81
90
  exports.toMessageTypeStrict = toMessageTypeStrict;
91
+ /**
92
+ * Discriminator for client-synthesized AI CFO answer bubbles. These are not
93
+ * Q/A pairs streamed from the backend — they are pushed locally by the AI
94
+ * CFO flow when it kicks off a cards or policy create from an interactive
95
+ * form, so the drawer can render a "Creating…" placeholder and later a
96
+ * "Created" success bubble while the corresponding mutation epic runs.
97
+ */
98
+ exports.ALL_SYNTHETIC_AI_CFO_ANSWER_KINDS = [
99
+ 'creating_cards',
100
+ 'creating_policy',
101
+ 'created_cards',
102
+ 'created_policy',
103
+ ];
@@ -0,0 +1,277 @@
1
+ import { ID } from '../../commonStateTypes/common';
2
+ import { ZeniAPIResponse } from '../../responsePayload';
3
+ import { CardPolicyStats, CardPolicyTemplate, CardPolicyTemplateEntityList, CardPolicyTemplateMode, CardPolicyTemplateSpendLimits, ExtractedCardPolicyRules, MccCategory } from './cardPolicyState';
4
+ export interface MccCategoryPayload {
5
+ count: number;
6
+ mcc_codes: string[];
7
+ name: string;
8
+ }
9
+ /**
10
+ * Wire shape for `GET /cards/1.0/cards/mcc-codes`. Beyond the universe of
11
+ * MCC categories used to populate the category search dropdown, the
12
+ * endpoint also ships **suggested** allow / block merchants and categories
13
+ * that the chip-pickers seed into their cloud body before the user starts
14
+ * editing.
15
+ *
16
+ * Field spellings (`*_catagories`) preserve the BE wire format verbatim;
17
+ * the camelCase mapper below corrects to `Categories`.
18
+ */
19
+ export interface CardPolicyMccCategoriesPayload {
20
+ categories: MccCategoryPayload[];
21
+ suggested_allow_catagories?: MccCategoryPayload[];
22
+ suggested_allow_merchants?: string[];
23
+ suggested_block_catagories?: MccCategoryPayload[];
24
+ suggested_block_merchants?: string[];
25
+ }
26
+ export type CardPolicyMccCategoriesResponse = ZeniAPIResponse<CardPolicyMccCategoriesPayload>;
27
+ export declare const toMccCategory: (payload: MccCategoryPayload) => MccCategory;
28
+ /**
29
+ * Vendor row returned by `/accounting/1.0/vendors`. The card-policy
30
+ * vendor search dropdown only needs `vendor_id` + `vendor_name`; we
31
+ * deliberately ignore the rest of the payload to keep this slice
32
+ * independent of the heavy `vendor` entity store.
33
+ */
34
+ export interface CardPolicyVendorSearchVendorPayload {
35
+ vendor_id: string;
36
+ vendor_name: string;
37
+ }
38
+ export interface CardPolicyVendorSearchData {
39
+ vendors: CardPolicyVendorSearchVendorPayload[];
40
+ }
41
+ export type CardPolicyVendorSearchResponse = ZeniAPIResponse<CardPolicyVendorSearchData>;
42
+ export interface CardPolicyVendorSearchOption {
43
+ name: string;
44
+ vendorId: string;
45
+ }
46
+ export declare const toCardPolicyVendorSearchOption: (payload: CardPolicyVendorSearchVendorPayload) => CardPolicyVendorSearchOption;
47
+ interface CardPolicyTemplateEntityListPayload {
48
+ category_codes: string[];
49
+ merchant_names: string[];
50
+ }
51
+ interface CardPolicyTemplateSpendLimitsPayload {
52
+ transaction: number | null;
53
+ }
54
+ /**
55
+ * Per-template request shape. `POST /cards/1.0/policy-templates` now
56
+ * accepts a bulk wrapper (`CreateCardPolicyTemplatesRequest`); this
57
+ * interface describes a single entry inside the `templates` array.
58
+ *
59
+ * `PUT /cards/1.0/policy-templates/{id}` (update) still consumes this
60
+ * shape directly — see `UpdateCardPolicyTemplateRequest` below.
61
+ */
62
+ export interface CreateCardPolicyTemplateRequest {
63
+ allowedEntity: CardPolicyTemplateEntityList;
64
+ applyToCards: ID[];
65
+ blockedEntity: CardPolicyTemplateEntityList;
66
+ description: string;
67
+ mode: CardPolicyTemplateMode;
68
+ name: string;
69
+ /**
70
+ * `null` indicates the require-receipt toggle is off (no threshold
71
+ * configured). The BE accepts `null` and treats it as "no requirement";
72
+ * `0` means the user explicitly entered zero with the toggle on.
73
+ */
74
+ requiredReceiptThreshold: number | null;
75
+ spendLimits: CardPolicyTemplateSpendLimits;
76
+ }
77
+ export interface CreateCardPolicyTemplateRequestBody {
78
+ allowed_entity: CardPolicyTemplateEntityListPayload;
79
+ apply_to_cards: ID[];
80
+ blocked_entity: CardPolicyTemplateEntityListPayload;
81
+ description: string;
82
+ mode: string;
83
+ name: string;
84
+ required_receipt_threshold: number | null;
85
+ spend_limits: CardPolicyTemplateSpendLimitsPayload;
86
+ }
87
+ /**
88
+ * Bulk request for `POST /cards/1.0/policy-templates`. The single-policy
89
+ * create flow wraps its one request in a length-1 `templates` array;
90
+ * future multi-policy submit (AI CFO review step) sends N entries in a
91
+ * single round-trip.
92
+ *
93
+ * `sourceChatSessionId` ties the submit back to an AI CFO chat session so
94
+ * the BE can attribute the created templates to it. Manual create-page
95
+ * callers omit it.
96
+ */
97
+ export interface CreateCardPolicyTemplatesRequest {
98
+ templates: CreateCardPolicyTemplateRequest[];
99
+ sourceChatSessionId?: string;
100
+ }
101
+ export interface CreateCardPolicyTemplatesRequestBody {
102
+ templates: CreateCardPolicyTemplateRequestBody[];
103
+ source_chat_session_id?: string;
104
+ }
105
+ export interface CardPolicyTemplatePayload {
106
+ allowed_entity: CardPolicyTemplateEntityListPayload;
107
+ applied_cards: ID[];
108
+ blocked_entity: CardPolicyTemplateEntityListPayload;
109
+ cards_count: number;
110
+ category_restrictions: unknown[];
111
+ created_at: string;
112
+ created_by: ID;
113
+ description: string;
114
+ mode: string;
115
+ name: string;
116
+ required_receipt_threshold: number | null;
117
+ spend_limits: CardPolicyTemplateSpendLimitsPayload;
118
+ status: string;
119
+ template_id: ID;
120
+ tenant_id: ID;
121
+ updated_at: string;
122
+ }
123
+ /**
124
+ * Per-template response envelope. Still returned by `PUT /policy-templates/{id}`,
125
+ * `GET /policy-templates/{id}`, and (as the row payload) the list endpoint.
126
+ * Also nested inside `CreateCardPolicyTemplatesResponseData.templates_created`.
127
+ */
128
+ export interface CreateCardPolicyTemplateResponseData {
129
+ cards_applied: number;
130
+ template: CardPolicyTemplatePayload;
131
+ }
132
+ export type CreateCardPolicyTemplateResponse = ZeniAPIResponse<CreateCardPolicyTemplateResponseData>;
133
+ /**
134
+ * Per-item error returned by the bulk POST when one or more templates in
135
+ * the request fail validation / persistence. The exact field shape is
136
+ * **TBD** with the BE — `message` is the only guaranteed field today; the
137
+ * rest are best-effort placeholders that callers should not assume to be
138
+ * present.
139
+ *
140
+ * TODO: lock down the shape (`index`, `name`, `code`) once the BE
141
+ * documents it. See plan §"Open question to resolve with BE".
142
+ */
143
+ export interface BulkCreateCardPolicyTemplateErrorPayload {
144
+ message: string;
145
+ code?: string;
146
+ index?: number;
147
+ name?: string;
148
+ }
149
+ /**
150
+ * Wire shape returned by the bulk `POST /cards/1.0/policy-templates`.
151
+ * Partial success is allowed — `templates_created` holds the successfully
152
+ * created rows (each in the same envelope as the single endpoint), and
153
+ * `errors` holds per-item failures for the rest. `status.message` follows
154
+ * the "N of M templates created" convention.
155
+ */
156
+ export interface CreateCardPolicyTemplatesResponseData {
157
+ errors: BulkCreateCardPolicyTemplateErrorPayload[];
158
+ templates_created: CreateCardPolicyTemplateResponseData[];
159
+ }
160
+ export type CreateCardPolicyTemplatesResponse = ZeniAPIResponse<CreateCardPolicyTemplatesResponseData>;
161
+ /**
162
+ * Camel-cased mirror of `BulkCreateCardPolicyTemplateErrorPayload` stored
163
+ * on the create-card-policy view slice so the UI can render a partial-success
164
+ * banner without re-touching the wire types.
165
+ */
166
+ export interface BulkCreateCardPolicyTemplateError {
167
+ message: string;
168
+ code?: string;
169
+ index?: number;
170
+ name?: string;
171
+ }
172
+ export type UpdateCardPolicyTemplateRequest = CreateCardPolicyTemplateRequest;
173
+ export type UpdateCardPolicyTemplateRequestBody = CreateCardPolicyTemplateRequestBody;
174
+ export type UpdateCardPolicyTemplateResponseData = CreateCardPolicyTemplateResponseData;
175
+ export type UpdateCardPolicyTemplateResponse = CreateCardPolicyTemplateResponse;
176
+ export type CardPolicyDetailResponseData = CreateCardPolicyTemplateResponseData;
177
+ export type CardPolicyDetailResponse = CreateCardPolicyTemplateResponse;
178
+ /**
179
+ * Aggregate counters returned alongside the templates list. Stored on
180
+ * the entity slice (alongside `cardPolicyTemplateById`) so any list
181
+ * surface can read it without re-fetching.
182
+ */
183
+ export interface CardPolicyStatsPayload {
184
+ active_policies: number;
185
+ total_cards: number;
186
+ total_templates: number;
187
+ }
188
+ /**
189
+ * Each list row is wrapped in the same `{cards_applied, template}`
190
+ * envelope the create endpoint returns. Only the `template` portion is
191
+ * stored on the entity slice; `cards_applied` is a one-shot summary
192
+ * carried over from create and not surfaced in the list state today.
193
+ */
194
+ export interface CardPolicyListRowPayload {
195
+ data: CreateCardPolicyTemplateResponseData;
196
+ }
197
+ export interface ListCardPolicyTemplatesResponseData {
198
+ stats: CardPolicyStatsPayload;
199
+ templates: CardPolicyListRowPayload[];
200
+ }
201
+ export type ListCardPolicyTemplatesResponse = ZeniAPIResponse<ListCardPolicyTemplatesResponseData>;
202
+ export declare const toCardPolicyStats: (payload: CardPolicyStatsPayload) => CardPolicyStats;
203
+ export declare const toCardPolicyTemplateList: (data: ListCardPolicyTemplatesResponseData) => CardPolicyTemplate[];
204
+ export declare const toCardPolicyTemplate: (payload: CardPolicyTemplatePayload) => CardPolicyTemplate;
205
+ /**
206
+ * Re-shape a single camelCase create request into the snake_case wire
207
+ * body. Used by the bulk-create mapper to build each entry of the
208
+ * `templates` array, and directly by the update epic (PUT) since the
209
+ * update endpoint still consumes a single object.
210
+ */
211
+ export declare const toCreateCardPolicyTemplateRequestBody: (request: CreateCardPolicyTemplateRequest) => CreateCardPolicyTemplateRequestBody;
212
+ /**
213
+ * Re-shape a bulk create request into the snake_case wire body for
214
+ * `POST /cards/1.0/policy-templates`. Maps each entry through
215
+ * `toCreateCardPolicyTemplateRequestBody` and only emits
216
+ * `source_chat_session_id` when the camelCase counterpart is defined,
217
+ * so manual-create callers don't ship a stray `undefined` over the wire.
218
+ */
219
+ export declare const toCreateCardPolicyTemplatesRequestBody: (request: CreateCardPolicyTemplatesRequest) => CreateCardPolicyTemplatesRequestBody;
220
+ /**
221
+ * Map a single bulk-response error payload to its camelCased view shape.
222
+ * Defensive against missing optional fields (see `BulkCreateCardPolicyTemplateErrorPayload`
223
+ * docstring — the BE contract isn't fully locked yet).
224
+ */
225
+ export declare const toBulkCreateCardPolicyTemplateError: (payload: BulkCreateCardPolicyTemplateErrorPayload) => BulkCreateCardPolicyTemplateError;
226
+ export declare const toUpdateCardPolicyTemplateRequestBody: (request: CreateCardPolicyTemplateRequest) => CreateCardPolicyTemplateRequestBody;
227
+ /**
228
+ * Seed an edit-form draft (`CreateCardPolicyTemplateRequest`) from an
229
+ * existing camelCased `CardPolicyTemplate`. Used by the detail-fetch
230
+ * epic so the edit page can render with the saved values pre-populated.
231
+ */
232
+ export declare const toCardPolicyEditFormDraft: (template: CardPolicyTemplate) => CreateCardPolicyTemplateRequest;
233
+ /**
234
+ * Wire shape returned by `POST /cards/1.0/policy-documents/extract`.
235
+ * The backend OCRs / parses an uploaded policy document (PDF, image, etc.)
236
+ * and returns a best-effort set of policy rules + a confidence score.
237
+ *
238
+ * Consumers (manual `CardPolicyCreatePage` + AI CFO `CardPolicyInteractiveForm`)
239
+ * use `toExtractedCardPolicyRules` to map this onto the camelCase FE shape
240
+ * and then feed the result through `applyExtractedPolicyRulesToFormValues`
241
+ * (`@zeniai/web-components`) to seed the RHF form.
242
+ */
243
+ export interface ExtractedCardPolicyRulesPayload {
244
+ allowed_entity: CardPolicyTemplateEntityListPayload;
245
+ blocked_entity: CardPolicyTemplateEntityListPayload;
246
+ confidence_score: number;
247
+ policy_name: string;
248
+ required_receipt_threshold: number;
249
+ transaction_limit: number;
250
+ }
251
+ export interface PolicyDocumentExtractResponseData {
252
+ extracted_rules: ExtractedCardPolicyRulesPayload;
253
+ message: string;
254
+ }
255
+ export type PolicyDocumentExtractResponse = ZeniAPIResponse<PolicyDocumentExtractResponseData>;
256
+ export declare const toExtractedCardPolicyRules: (payload: ExtractedCardPolicyRulesPayload) => ExtractedCardPolicyRules;
257
+ /**
258
+ * Wire shape returned by `POST /cards/1.0/ai-cfo/policy-recommendation-from-upload`.
259
+ * Chained after `extractPolicyDocument` succeeds in the AI CFO `upload`
260
+ * flow: the FE forwards the just-returned `extracted_rules` and the BE
261
+ * synthesizes a wizard plan + upload source metadata.
262
+ *
263
+ * The response mirrors the same `mode`-discriminated envelope the
264
+ * controller API ships for `auto` / `guided`, but always with `mode:
265
+ * "upload"` and a populated `wizard_plan.step_5_review`. The FE merges
266
+ * the returned `wizard_plan` + `source` into the in-flight AI CFO
267
+ * answer's `CardPolicyInitialData` via
268
+ * `updateAiCfoAnswerCardPolicyWizardPlan`.
269
+ */
270
+ export interface CardPolicyRecommendationFromUploadResponseData {
271
+ mode: 'upload';
272
+ source: import('../aiCfo/aiCfoPayload').CardPolicyUploadSourcePayload;
273
+ tenant_id: string;
274
+ wizard_plan: import('../aiCfo/aiCfoPayload').CardPolicyWizardPlanPayload;
275
+ }
276
+ export type CardPolicyRecommendationFromUploadResponse = ZeniAPIResponse<CardPolicyRecommendationFromUploadResponseData>;
277
+ export {};
@@ -0,0 +1,143 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toExtractedCardPolicyRules = exports.toCardPolicyEditFormDraft = exports.toUpdateCardPolicyTemplateRequestBody = exports.toBulkCreateCardPolicyTemplateError = exports.toCreateCardPolicyTemplatesRequestBody = exports.toCreateCardPolicyTemplateRequestBody = exports.toCardPolicyTemplate = exports.toCardPolicyTemplateList = exports.toCardPolicyStats = exports.toCardPolicyVendorSearchOption = exports.toMccCategory = void 0;
4
+ const zeniDayJS_1 = require("../../zeniDayJS");
5
+ const cardPolicyState_1 = require("./cardPolicyState");
6
+ const toMccCategory = (payload) => ({
7
+ count: payload.count,
8
+ mccCodes: payload.mcc_codes ?? [],
9
+ name: payload.name,
10
+ });
11
+ exports.toMccCategory = toMccCategory;
12
+ const toCardPolicyVendorSearchOption = (payload) => ({
13
+ vendorId: payload.vendor_id,
14
+ name: payload.vendor_name,
15
+ });
16
+ exports.toCardPolicyVendorSearchOption = toCardPolicyVendorSearchOption;
17
+ const toCardPolicyStats = (payload) => ({
18
+ activePolicies: payload.active_policies,
19
+ totalCards: payload.total_cards,
20
+ totalTemplates: payload.total_templates,
21
+ });
22
+ exports.toCardPolicyStats = toCardPolicyStats;
23
+ const toCardPolicyTemplateList = (data) => (data.templates ?? []).map((row) => (0, exports.toCardPolicyTemplate)(row.data.template));
24
+ exports.toCardPolicyTemplateList = toCardPolicyTemplateList;
25
+ const toCardPolicyTemplateEntityList = (payload) => ({
26
+ categoryCodes: payload.category_codes ?? [],
27
+ merchantNames: payload.merchant_names ?? [],
28
+ });
29
+ const toCardPolicyTemplate = (payload) => ({
30
+ allowedEntity: toCardPolicyTemplateEntityList(payload.allowed_entity),
31
+ appliedCards: payload.applied_cards ?? [],
32
+ blockedEntity: toCardPolicyTemplateEntityList(payload.blocked_entity),
33
+ cardsCount: payload.cards_count,
34
+ categoryRestrictions: payload.category_restrictions ?? [],
35
+ createdAt: (0, zeniDayJS_1.date)(payload.created_at),
36
+ createdBy: payload.created_by,
37
+ description: payload.description,
38
+ mode: (0, cardPolicyState_1.toCardPolicyTemplateMode)(payload.mode),
39
+ name: payload.name,
40
+ requiredReceiptThreshold: payload.required_receipt_threshold,
41
+ spendLimits: {
42
+ transaction: payload.spend_limits.transaction,
43
+ },
44
+ status: (0, cardPolicyState_1.toCardPolicyTemplateStatus)(payload.status),
45
+ templateId: payload.template_id,
46
+ tenantId: payload.tenant_id,
47
+ updatedAt: (0, zeniDayJS_1.date)(payload.updated_at),
48
+ });
49
+ exports.toCardPolicyTemplate = toCardPolicyTemplate;
50
+ /**
51
+ * Re-shape a single camelCase create request into the snake_case wire
52
+ * body. Used by the bulk-create mapper to build each entry of the
53
+ * `templates` array, and directly by the update epic (PUT) since the
54
+ * update endpoint still consumes a single object.
55
+ */
56
+ const toCreateCardPolicyTemplateRequestBody = (request) => ({
57
+ allowed_entity: {
58
+ category_codes: request.allowedEntity.categoryCodes,
59
+ merchant_names: request.allowedEntity.merchantNames,
60
+ },
61
+ apply_to_cards: request.applyToCards,
62
+ blocked_entity: {
63
+ category_codes: request.blockedEntity.categoryCodes,
64
+ merchant_names: request.blockedEntity.merchantNames,
65
+ },
66
+ description: request.description,
67
+ mode: request.mode ?? 'strict',
68
+ name: request.name,
69
+ required_receipt_threshold: request.requiredReceiptThreshold,
70
+ spend_limits: {
71
+ transaction: request.spendLimits.transaction,
72
+ },
73
+ });
74
+ exports.toCreateCardPolicyTemplateRequestBody = toCreateCardPolicyTemplateRequestBody;
75
+ /**
76
+ * Re-shape a bulk create request into the snake_case wire body for
77
+ * `POST /cards/1.0/policy-templates`. Maps each entry through
78
+ * `toCreateCardPolicyTemplateRequestBody` and only emits
79
+ * `source_chat_session_id` when the camelCase counterpart is defined,
80
+ * so manual-create callers don't ship a stray `undefined` over the wire.
81
+ */
82
+ const toCreateCardPolicyTemplatesRequestBody = (request) => {
83
+ const body = {
84
+ templates: request.templates.map(exports.toCreateCardPolicyTemplateRequestBody),
85
+ };
86
+ if (request.sourceChatSessionId != null) {
87
+ body.source_chat_session_id = request.sourceChatSessionId;
88
+ }
89
+ return body;
90
+ };
91
+ exports.toCreateCardPolicyTemplatesRequestBody = toCreateCardPolicyTemplatesRequestBody;
92
+ /**
93
+ * Map a single bulk-response error payload to its camelCased view shape.
94
+ * Defensive against missing optional fields (see `BulkCreateCardPolicyTemplateErrorPayload`
95
+ * docstring — the BE contract isn't fully locked yet).
96
+ */
97
+ const toBulkCreateCardPolicyTemplateError = (payload) => ({
98
+ message: payload.message,
99
+ code: payload.code,
100
+ index: payload.index,
101
+ name: payload.name,
102
+ });
103
+ exports.toBulkCreateCardPolicyTemplateError = toBulkCreateCardPolicyTemplateError;
104
+ // Update body uses the exact same wire shape as create — the PUT
105
+ // endpoint is a full replace and was not affected by the bulk migration.
106
+ exports.toUpdateCardPolicyTemplateRequestBody = exports.toCreateCardPolicyTemplateRequestBody;
107
+ /**
108
+ * Seed an edit-form draft (`CreateCardPolicyTemplateRequest`) from an
109
+ * existing camelCased `CardPolicyTemplate`. Used by the detail-fetch
110
+ * epic so the edit page can render with the saved values pre-populated.
111
+ */
112
+ const toCardPolicyEditFormDraft = (template) => ({
113
+ allowedEntity: {
114
+ categoryCodes: [...template.allowedEntity.categoryCodes],
115
+ merchantNames: [...template.allowedEntity.merchantNames],
116
+ },
117
+ applyToCards: [...template.appliedCards],
118
+ blockedEntity: {
119
+ categoryCodes: [...template.blockedEntity.categoryCodes],
120
+ merchantNames: [...template.blockedEntity.merchantNames],
121
+ },
122
+ description: template.description,
123
+ mode: template.mode,
124
+ name: template.name,
125
+ requiredReceiptThreshold: template.requiredReceiptThreshold,
126
+ spendLimits: { transaction: template.spendLimits.transaction },
127
+ });
128
+ exports.toCardPolicyEditFormDraft = toCardPolicyEditFormDraft;
129
+ const toExtractedCardPolicyRules = (payload) => ({
130
+ allowedEntity: {
131
+ categoryCodes: payload.allowed_entity?.category_codes ?? [],
132
+ merchantNames: payload.allowed_entity?.merchant_names ?? [],
133
+ },
134
+ blockedEntity: {
135
+ categoryCodes: payload.blocked_entity?.category_codes ?? [],
136
+ merchantNames: payload.blocked_entity?.merchant_names ?? [],
137
+ },
138
+ confidenceScore: payload.confidence_score,
139
+ policyName: payload.policy_name,
140
+ requiredReceiptThreshold: payload.required_receipt_threshold,
141
+ transactionLimit: payload.transaction_limit,
142
+ });
143
+ exports.toExtractedCardPolicyRules = toExtractedCardPolicyRules;