@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.
- package/lib/common/aiCfo/aiCfoSuggestedQuestionsPageContext.d.ts +1 -1
- package/lib/entity/aiCfo/aiCfoPayload.d.ts +1 -171
- package/lib/entity/aiCfo/aiCfoReducer.d.ts +1 -7
- package/lib/entity/aiCfo/aiCfoReducer.js +4 -219
- package/lib/entity/aiCfo/aiCfoState.d.ts +4 -163
- package/lib/entity/aiCfo/aiCfoState.js +1 -10
- package/lib/entity/jeSchedules/jeSchedulesTypes.d.ts +1 -1
- package/lib/entity/monthEndCloseChecks/monthEndCloseChecksState.d.ts +1 -1
- package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
- package/lib/entity/snackbar/snackbarTypes.js +0 -2
- package/lib/entity/tenant/clearAllEpic.d.ts +2 -6
- package/lib/entity/tenant/clearAllEpic.js +0 -8
- package/lib/epic.d.ts +1 -11
- package/lib/epic.js +1 -11
- package/lib/esm/entity/aiCfo/aiCfoReducer.js +4 -219
- package/lib/esm/entity/aiCfo/aiCfoState.js +0 -7
- package/lib/esm/entity/snackbar/snackbarTypes.js +0 -2
- package/lib/esm/entity/tenant/clearAllEpic.js +0 -8
- package/lib/esm/epic.js +1 -11
- package/lib/esm/index.js +4 -19
- package/lib/esm/reducer.js +0 -12
- package/lib/esm/view/aiCfoView/aiCfoViewReducer.js +3 -6
- package/lib/esm/view/aiCfoView/epics/createSessionAndSubmitEpic.js +2 -5
- package/lib/esm/view/aiCfoView/epics/createSessionEpic.js +1 -2
- package/lib/esm/view/aiCfoView/epics/fetchSuggestedQuestionsEpic.js +2 -12
- package/lib/esm/view/spendManagement/chargeCards/chargeCardList/chargeCardListSelector.js +0 -25
- package/lib/index.d.ts +4 -17
- package/lib/index.js +11 -112
- package/lib/reducer.d.ts +0 -12
- package/lib/reducer.js +0 -12
- package/lib/tsconfig.typecheck.tsbuildinfo +1 -0
- package/lib/view/aiCfoView/aiCfoViewReducer.d.ts +2 -11
- package/lib/view/aiCfoView/aiCfoViewReducer.js +3 -6
- package/lib/view/aiCfoView/epics/createSessionAndSubmitEpic.js +2 -5
- package/lib/view/aiCfoView/epics/createSessionEpic.js +1 -2
- package/lib/view/aiCfoView/epics/fetchSuggestedQuestionsEpic.d.ts +1 -8
- package/lib/view/aiCfoView/epics/fetchSuggestedQuestionsEpic.js +2 -12
- package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
- package/lib/view/expenseAutomationView/types/jeSchedulesViewState.d.ts +1 -1
- package/lib/view/expenseAutomationView/types/missingReceiptsViewState.d.ts +2 -2
- package/lib/view/expenseAutomationView/types/transactionsViewState.d.ts +1 -1
- package/lib/view/people/peopleTypes.d.ts +1 -1
- package/lib/view/scheduleView/scheduleListView/scheduleListTypes.d.ts +1 -1
- package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardList.d.ts +1 -1
- package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListSelector.d.ts +0 -14
- package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListSelector.js +1 -27
- package/lib/view/taskManager/taskListView/taskListReducer.d.ts +1 -1
- package/package.json +1 -1
- package/lib/entity/cardPolicy/cardPolicyPayload.d.ts +0 -277
- package/lib/entity/cardPolicy/cardPolicyPayload.js +0 -143
- package/lib/entity/cardPolicy/cardPolicyReducer.d.ts +0 -19
- package/lib/entity/cardPolicy/cardPolicyReducer.js +0 -256
- package/lib/entity/cardPolicy/cardPolicySelector.d.ts +0 -32
- package/lib/entity/cardPolicy/cardPolicySelector.js +0 -103
- package/lib/entity/cardPolicy/cardPolicyState.d.ts +0 -205
- package/lib/entity/cardPolicy/cardPolicyState.js +0 -14
- package/lib/entity/cardPolicy/extractPolicyDocumentEpic.d.ts +0 -18
- package/lib/entity/cardPolicy/extractPolicyDocumentEpic.js +0 -54
- package/lib/entity/cardPolicy/fetchCardPolicyVendorOptionsEpic.d.ts +0 -26
- package/lib/entity/cardPolicy/fetchCardPolicyVendorOptionsEpic.js +0 -47
- package/lib/entity/cardPolicy/policyDocumentExtractionToRecommendationBridgeEpic.d.ts +0 -25
- package/lib/entity/cardPolicy/policyDocumentExtractionToRecommendationBridgeEpic.js +0 -39
- package/lib/entity/cardPolicy/policyRecommendationFromUploadEpic.d.ts +0 -23
- package/lib/entity/cardPolicy/policyRecommendationFromUploadEpic.js +0 -92
- package/lib/esm/entity/cardPolicy/cardPolicyPayload.js +0 -130
- package/lib/esm/entity/cardPolicy/cardPolicyReducer.js +0 -252
- package/lib/esm/entity/cardPolicy/cardPolicySelector.js +0 -79
- package/lib/esm/entity/cardPolicy/cardPolicyState.js +0 -9
- package/lib/esm/entity/cardPolicy/extractPolicyDocumentEpic.js +0 -50
- package/lib/esm/entity/cardPolicy/fetchCardPolicyVendorOptionsEpic.js +0 -43
- package/lib/esm/entity/cardPolicy/policyDocumentExtractionToRecommendationBridgeEpic.js +0 -35
- package/lib/esm/entity/cardPolicy/policyRecommendationFromUploadEpic.js +0 -88
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailReducer.js +0 -70
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailSelector.js +0 -22
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailState.js +0 -1
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/fetchCardPolicyDetailEpic.js +0 -56
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/updateCardPolicyEpic.js +0 -49
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/archiveCardPolicyEpic.js +0 -42
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListReducer.js +0 -72
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListSelector.js +0 -21
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListState.js +0 -1
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/fetchCardPolicyListEpic.js +0 -56
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyReducer.js +0 -59
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicySelector.js +0 -31
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyState.js +0 -1
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyTemplateEpic.js +0 -53
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/fetchCardPolicyMccCategoriesEpic.js +0 -25
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailReducer.d.ts +0 -14
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailReducer.js +0 -74
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailSelector.d.ts +0 -21
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailSelector.js +0 -28
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailState.d.ts +0 -25
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailState.js +0 -2
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/fetchCardPolicyDetailEpic.d.ts +0 -19
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/fetchCardPolicyDetailEpic.js +0 -60
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/updateCardPolicyEpic.d.ts +0 -18
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/updateCardPolicyEpic.js +0 -53
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/archiveCardPolicyEpic.d.ts +0 -16
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/archiveCardPolicyEpic.js +0 -46
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListReducer.d.ts +0 -15
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListReducer.js +0 -76
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListSelector.d.ts +0 -21
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListSelector.js +0 -27
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListState.d.ts +0 -19
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListState.js +0 -2
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/fetchCardPolicyListEpic.d.ts +0 -19
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/fetchCardPolicyListEpic.js +0 -60
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyReducer.d.ts +0 -13
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyReducer.js +0 -63
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicySelector.d.ts +0 -26
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicySelector.js +0 -37
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyState.d.ts +0 -36
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyState.js +0 -2
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyTemplateEpic.d.ts +0 -25
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyTemplateEpic.js +0 -57
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/fetchCardPolicyMccCategoriesEpic.d.ts +0 -15
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/fetchCardPolicyMccCategoriesEpic.js +0 -29
|
@@ -16,4 +16,4 @@
|
|
|
16
16
|
*
|
|
17
17
|
* @see README.md in this directory for maintenance expectations.
|
|
18
18
|
*/
|
|
19
|
-
export type AiCfoSuggestedQuestionsPageContext = 'balance_sheet' | 'profit_loss' | 'vendors' | 'transactions' | 'cash_flow' | 'accounts_receivable' | 'accounts_payable' | 'transaction_details' | 'dashboard' | 'cash_balance' | 'card_balance' | 'cash_in_cash_out' | 'net_burn_or_income' | 'cash_position' | 'top_expenses' | 'revenue' | 'operating_expenses' | 'command_centre' | 'je_schedules' | 'reconciliation' | 'flux_analysis' | 'receipts' | 'mei' | 'task_checklist' | 'performance' | 'bills_list' | 'bills_details' | 'reimbursement_list' | 'reimbursement_details' | 'vendors_summary' | 'opex_by_vendor' | 'prepaid_expenses' | 'fixed_assets' | 'form_1099' | 'accrued_expenses' | 'forecast' | 'checking' | 'checking_details' | 'treasury' | 'cards' | '
|
|
19
|
+
export type AiCfoSuggestedQuestionsPageContext = 'balance_sheet' | 'profit_loss' | 'vendors' | 'transactions' | 'cash_flow' | 'accounts_receivable' | 'accounts_payable' | 'transaction_details' | 'dashboard' | 'cash_balance' | 'card_balance' | 'cash_in_cash_out' | 'net_burn_or_income' | 'cash_position' | 'top_expenses' | 'revenue' | 'operating_expenses' | 'command_centre' | 'je_schedules' | 'reconciliation' | 'flux_analysis' | 'receipts' | 'mei' | 'task_checklist' | 'performance' | 'bills_list' | 'bills_details' | 'reimbursement_list' | 'reimbursement_details' | 'vendors_summary' | 'opex_by_vendor' | 'prepaid_expenses' | 'fixed_assets' | 'form_1099' | 'accrued_expenses' | 'forecast' | 'checking' | 'checking_details' | 'treasury' | 'cards' | 'cards_detail' | 'people' | 'rewards' | 'notifications';
|
|
@@ -20,178 +20,8 @@ export interface ChartVisualizationPayload {
|
|
|
20
20
|
lines?: string[] | null;
|
|
21
21
|
y_format?: YFormatPayload;
|
|
22
22
|
}
|
|
23
|
-
export interface CardsCardOptionPayload {
|
|
24
|
-
id: string;
|
|
25
|
-
label: string;
|
|
26
|
-
description?: string | null;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Single AI-suggested card on the wire. The controller ships an array of
|
|
30
|
-
* these mixing vendor and department entries; entries with
|
|
31
|
-
* `is_suggested: true` seed step 1 of the form pre-checked, while entries
|
|
32
|
-
* with `is_suggested: false` are available in the step-2 Card dropdown and
|
|
33
|
-
* step-1 search but don't appear as initial rows.
|
|
34
|
-
*/
|
|
35
|
-
export interface SuggestedCardPayload {
|
|
36
|
-
avg_spend: number;
|
|
37
|
-
card_name: string;
|
|
38
|
-
card_name_id: string;
|
|
39
|
-
card_type: 'vendor' | 'department';
|
|
40
|
-
credit_limit: number;
|
|
41
|
-
is_suggested: boolean;
|
|
42
|
-
owner_id: string;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Discriminated payload for the AI Card Creation interactive form. The wire
|
|
46
|
-
* format mirrors the FE-side `CardsCreationInitialData` field-for-field
|
|
47
|
-
* (with snake_case field names converted to camelCase by the reducer).
|
|
48
|
-
*
|
|
49
|
-
* - `team-then-cards` (default): the AI suggests rows (vendors + departments);
|
|
50
|
-
* user reviews them in step 1, then configures cards in step 2. The wire
|
|
51
|
-
* format ships a flat `suggested_cards` array. Both suggested and
|
|
52
|
-
* not-suggested entries are included; the reducer splits them into seed
|
|
53
|
-
* rows vs. dropdown options. The legacy `team_rows` /
|
|
54
|
-
* `suggested_owner_user_id_by_team_id` shape is also accepted for
|
|
55
|
-
* backward compatibility with mocks and tests.
|
|
56
|
-
* - `cards-only` (1-step): the AI has already chosen cards; user lands
|
|
57
|
-
* directly on the editable card table for confirmation.
|
|
58
|
-
*/
|
|
59
|
-
export type CardsCreationInitialDataPayload = {
|
|
60
|
-
card_options: CardsCardOptionPayload[];
|
|
61
|
-
mode: 'team-then-cards';
|
|
62
|
-
/**
|
|
63
|
-
* Preferred wire format: flat list of vendor/department cards with an
|
|
64
|
-
* `is_suggested` discriminator. The reducer derives `team_rows`,
|
|
65
|
-
* `suggested_owner_user_id_by_team_id`, and the full `cardNameOptions`
|
|
66
|
-
* universe from this single array.
|
|
67
|
-
*/
|
|
68
|
-
suggested_cards?: SuggestedCardPayload[];
|
|
69
|
-
/**
|
|
70
|
-
* Legacy/test shape — pre-shaped seed rows. Mutually exclusive with
|
|
71
|
-
* `suggested_cards`; when both are present, `suggested_cards` wins.
|
|
72
|
-
*/
|
|
73
|
-
suggested_owner_user_id_by_team_id?: Record<string, string | null>;
|
|
74
|
-
team_rows?: Array<{
|
|
75
|
-
avg_monthly_spend: string;
|
|
76
|
-
id: string;
|
|
77
|
-
label: string;
|
|
78
|
-
recommended_limit: string;
|
|
79
|
-
card_kind?: 'vendor' | 'class' | null;
|
|
80
|
-
recommended_limit_cadence?: string | null;
|
|
81
|
-
}>;
|
|
82
|
-
} | {
|
|
83
|
-
card_options: CardsCardOptionPayload[];
|
|
84
|
-
card_rows: Array<{
|
|
85
|
-
card_option_id: string;
|
|
86
|
-
id: string;
|
|
87
|
-
/**
|
|
88
|
-
* Optional team-derived display label rendered in the card cell
|
|
89
|
-
* trigger (e.g. "Engineering"). Drives the row's first-letter avatar
|
|
90
|
-
* in step 2.
|
|
91
|
-
*/
|
|
92
|
-
label?: string | null;
|
|
93
|
-
recommended_limit?: number | null;
|
|
94
|
-
suggested_owner_user_id?: string | null;
|
|
95
|
-
}>;
|
|
96
|
-
mode: 'cards-only';
|
|
97
|
-
};
|
|
98
|
-
/**
|
|
99
|
-
* Per-policy allow / block bucket on the wire. The two arrays are
|
|
100
|
-
* independent (a draft policy may populate both, only one, or neither).
|
|
101
|
-
*/
|
|
102
|
-
export interface DraftPolicyEntityPayload {
|
|
103
|
-
category_codes: string[];
|
|
104
|
-
merchant_names: string[];
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Spend-limit bucket per policy. `transaction` is the only cadence the
|
|
108
|
-
* BE ships today; left open-ended for future cadences (e.g.
|
|
109
|
-
* `monthly`, `quarterly`).
|
|
110
|
-
*/
|
|
111
|
-
export interface DraftPolicySpendLimitsPayload {
|
|
112
|
-
transaction: number;
|
|
113
|
-
[cadence: string]: number | undefined;
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* Single draft policy on the wire. The controller emits one of these
|
|
117
|
-
* per recommended policy in `step_5_review.draft_policies`. Identity is
|
|
118
|
-
* positional (no stable `id` from the BE); the FE synthesizes one on
|
|
119
|
-
* decode.
|
|
120
|
-
*/
|
|
121
|
-
export interface DraftPolicyPayload {
|
|
122
|
-
allowed_entity: DraftPolicyEntityPayload;
|
|
123
|
-
apply_to_cards: string[];
|
|
124
|
-
blocked_entity: DraftPolicyEntityPayload;
|
|
125
|
-
description: string;
|
|
126
|
-
/** Enforcement mode for the policy (e.g. `"strict"`). Carried into
|
|
127
|
-
* state for guided submit; ignored for `auto` / `upload`. */
|
|
128
|
-
mode: string;
|
|
129
|
-
name: string;
|
|
130
|
-
required_receipt_threshold: number;
|
|
131
|
-
spend_limits: DraftPolicySpendLimitsPayload;
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* `step_5_review` block — the only step in `wizard_plan` the FE reads.
|
|
135
|
-
* Steps 1–4 are intentionally not modeled.
|
|
136
|
-
*/
|
|
137
|
-
export interface CardPolicyStep5ReviewPayload {
|
|
138
|
-
draft_policies: DraftPolicyPayload[];
|
|
139
|
-
/** Header text shown above the review list / wizard. */
|
|
140
|
-
prompt: string;
|
|
141
|
-
/** How the BE grouped the suggested policies. `"none"` today; may
|
|
142
|
-
* surface as a header banner in a future iteration. */
|
|
143
|
-
grouping_source?: string;
|
|
144
|
-
}
|
|
145
|
-
export interface CardPolicyWizardPlanPayload {
|
|
146
|
-
step_5_review: CardPolicyStep5ReviewPayload;
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* Upload-mode metadata that the `policy-recommendation-from-upload` API
|
|
150
|
-
* returns alongside the wizard plan. Absent on the initial controller
|
|
151
|
-
* response; populated after the file upload + recommendation chain.
|
|
152
|
-
*/
|
|
153
|
-
export interface CardPolicyUploadSourcePayload {
|
|
154
|
-
confidence_score: number;
|
|
155
|
-
file_name: string;
|
|
156
|
-
low_confidence_fields: string[];
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* Discriminated payload for the AI Card Policy interactive form.
|
|
160
|
-
* All three modes share the same `wizard_plan.step_5_review.draft_policies`
|
|
161
|
-
* envelope; the FE renders different forms based on `mode`.
|
|
162
|
-
*
|
|
163
|
-
* - `auto` (1-step review): user reviews suggested policies and submits.
|
|
164
|
-
* - `guided` (5-step wizard): Steps 1–4 seeded from `draft_policies[0]`,
|
|
165
|
-
* Step 5 lists every draft policy.
|
|
166
|
-
* - `upload` (3-step): upload doc → pick cards → review. Controller
|
|
167
|
-
* responses for `mode === "upload"` arrive *before* the user uploads,
|
|
168
|
-
* so `wizard_plan` is optional; populated after the upload-recommendation
|
|
169
|
-
* API returns.
|
|
170
|
-
*/
|
|
171
|
-
export type CardPolicyInitialDataPayload = {
|
|
172
|
-
mode: 'auto';
|
|
173
|
-
wizard_plan: CardPolicyWizardPlanPayload;
|
|
174
|
-
} | {
|
|
175
|
-
mode: 'guided';
|
|
176
|
-
wizard_plan: CardPolicyWizardPlanPayload;
|
|
177
|
-
} | {
|
|
178
|
-
mode: 'upload';
|
|
179
|
-
source?: CardPolicyUploadSourcePayload;
|
|
180
|
-
wizard_plan?: CardPolicyWizardPlanPayload;
|
|
181
|
-
};
|
|
182
|
-
/**
|
|
183
|
-
* Discriminated visualization payload. The FE narrows on `form_type` and
|
|
184
|
-
* casts `payload` to the matching shape.
|
|
185
|
-
*/
|
|
186
|
-
export type InteractiveFormVisualizationPayload = {
|
|
187
|
-
form_type: 'cards_creation';
|
|
188
|
-
payload: CardsCreationInitialDataPayload;
|
|
189
|
-
} | {
|
|
190
|
-
form_type: 'card_policy';
|
|
191
|
-
payload: CardPolicyInitialDataPayload;
|
|
192
|
-
};
|
|
193
23
|
export interface AiCfoVisualizationPayload {
|
|
194
|
-
data: TableVisualizationPayload | ChartVisualizationPayload |
|
|
24
|
+
data: TableVisualizationPayload | ChartVisualizationPayload | null;
|
|
195
25
|
type: string | null;
|
|
196
26
|
}
|
|
197
27
|
export interface AiCfoAnswerPayload {
|
|
@@ -2,7 +2,6 @@ import { ID } from '../../commonStateTypes/common';
|
|
|
2
2
|
import { ZeniDate } from '../../zeniDayJS';
|
|
3
3
|
import { AiCfoAnswerPayload, AiCfoVisualizationPayload, ChatSessionPayload, MessagePayload } from './aiCfoPayload';
|
|
4
4
|
import { AiCfoState, AiCfoVisualization, FileAttachmentMetadata } from './aiCfoState';
|
|
5
|
-
import type { CardPolicyUploadSource, CardPolicyWizardPlan } from './aiCfoState';
|
|
6
5
|
export declare const initialAiCfoState: AiCfoState;
|
|
7
6
|
export declare const toAiCfoVisualization: (visualization: AiCfoVisualizationPayload) => AiCfoVisualization | undefined;
|
|
8
7
|
export declare const setNewSession: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
@@ -42,11 +41,6 @@ export declare const setNewSession: import("@reduxjs/toolkit").ActionCreatorWith
|
|
|
42
41
|
}, "aiCfo/addQuestionPayload">, clearAiCfo: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"aiCfo/clearAiCfo">, deleteQuestion: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
43
42
|
chatSessionId: ID;
|
|
44
43
|
questionAnswerId: ID;
|
|
45
|
-
}, "aiCfo/deleteQuestion"
|
|
46
|
-
answerId: ID;
|
|
47
|
-
chatSessionId: ID;
|
|
48
|
-
wizardPlan: CardPolicyWizardPlan;
|
|
49
|
-
source?: CardPolicyUploadSource;
|
|
50
|
-
}, "aiCfo/updateAiCfoAnswerCardPolicyWizardPlan">;
|
|
44
|
+
}, "aiCfo/deleteQuestion">;
|
|
51
45
|
declare const _default: import("redux").Reducer<AiCfoState>;
|
|
52
46
|
export default _default;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var _a;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.
|
|
4
|
+
exports.deleteQuestion = exports.clearAiCfo = exports.addQuestionPayload = exports.upsertOrAddQuestionAnswerPayload = exports.upsertAnswerPayload = exports.setChatHistory = exports.setSessions = exports.clearSession = exports.setNewSession = exports.toAiCfoVisualization = exports.initialAiCfoState = void 0;
|
|
5
5
|
const toolkit_1 = require("@reduxjs/toolkit");
|
|
6
6
|
const zeniDayJS_1 = require("../../zeniDayJS");
|
|
7
7
|
const aiCfoState_1 = require("./aiCfoState");
|
|
@@ -139,184 +139,12 @@ const toAiCfoVisualization = (visualization) => {
|
|
|
139
139
|
if (visualization.type == null || visualization.data == null) {
|
|
140
140
|
return undefined;
|
|
141
141
|
}
|
|
142
|
-
const normalizedType = (0, aiCfoState_1.toAiCfoVisualizationTypeStrict)(visualization.type) ?? 'table';
|
|
143
142
|
return {
|
|
144
|
-
type:
|
|
145
|
-
data:
|
|
146
|
-
? toInteractiveFormVisualization(visualization.data)
|
|
147
|
-
: toAiCfoVisualizationData(visualization.data),
|
|
143
|
+
type: (0, aiCfoState_1.toAiCfoVisualizationTypeStrict)(visualization.type) ?? 'table',
|
|
144
|
+
data: toAiCfoVisualizationData(visualization.data),
|
|
148
145
|
};
|
|
149
146
|
};
|
|
150
147
|
exports.toAiCfoVisualization = toAiCfoVisualization;
|
|
151
|
-
const toInteractiveFormVisualization = (data) => {
|
|
152
|
-
const formType = (0, aiCfoState_1.toInteractiveFormTypeStrict)(data.form_type) ?? 'cards_creation';
|
|
153
|
-
if (formType === 'card_policy') {
|
|
154
|
-
return {
|
|
155
|
-
formType: 'card_policy',
|
|
156
|
-
payload: toCardPolicyInitialData(data.payload),
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
return {
|
|
160
|
-
formType: 'cards_creation',
|
|
161
|
-
payload: toCardsCreationInitialData(data.payload),
|
|
162
|
-
};
|
|
163
|
-
};
|
|
164
|
-
const toCardsCreationInitialData = (payload) => {
|
|
165
|
-
const cardOptions = (payload.card_options ?? []).map((option) => ({
|
|
166
|
-
id: option.id,
|
|
167
|
-
label: option.label,
|
|
168
|
-
description: option.description ?? undefined,
|
|
169
|
-
}));
|
|
170
|
-
if (payload.mode === 'cards-only') {
|
|
171
|
-
return {
|
|
172
|
-
mode: 'cards-only',
|
|
173
|
-
cardOptions,
|
|
174
|
-
cardRows: (payload.card_rows ?? []).map((row) => ({
|
|
175
|
-
cardOptionId: row.card_option_id,
|
|
176
|
-
id: row.id,
|
|
177
|
-
label: row.label ?? undefined,
|
|
178
|
-
recommendedLimit: row.recommended_limit ?? undefined,
|
|
179
|
-
suggestedOwnerUserId: row.suggested_owner_user_id ?? undefined,
|
|
180
|
-
})),
|
|
181
|
-
};
|
|
182
|
-
}
|
|
183
|
-
// Preferred wire format: a flat `suggested_cards` array with an
|
|
184
|
-
// `is_suggested` discriminator. The adapter splits it into seed rows,
|
|
185
|
-
// owner map, and the full dropdown universe.
|
|
186
|
-
if (payload.suggested_cards != null) {
|
|
187
|
-
return fromSuggestedCards(payload.suggested_cards, cardOptions);
|
|
188
|
-
}
|
|
189
|
-
// Legacy / test shape: backend already pre-shapes seeds. Synthesize an
|
|
190
|
-
// empty `cardNameOptions` (step 2 dropdown still works via row-self ids).
|
|
191
|
-
const teamRows = (payload.team_rows ?? []).map((row) => ({
|
|
192
|
-
avgMonthlySpend: row.avg_monthly_spend,
|
|
193
|
-
cardKind: (row.card_kind ?? 'vendor'),
|
|
194
|
-
id: row.id,
|
|
195
|
-
label: row.label,
|
|
196
|
-
recommendedLimit: row.recommended_limit,
|
|
197
|
-
recommendedLimitCadence: row.recommended_limit_cadence ?? undefined,
|
|
198
|
-
}));
|
|
199
|
-
return {
|
|
200
|
-
mode: 'team-then-cards',
|
|
201
|
-
cardOptions,
|
|
202
|
-
cardNameOptions: teamRows.map((row) => ({
|
|
203
|
-
id: row.id,
|
|
204
|
-
kind: row.cardKind,
|
|
205
|
-
label: row.label,
|
|
206
|
-
})),
|
|
207
|
-
suggestedOwnerUserIdByTeamId: Object.fromEntries(Object.entries(payload.suggested_owner_user_id_by_team_id ?? {}).map(([teamId, userId]) => [teamId, userId ?? undefined])),
|
|
208
|
-
teamRows,
|
|
209
|
-
};
|
|
210
|
-
};
|
|
211
|
-
const CURRENCY_FORMATTER = new Intl.NumberFormat('en-US', {
|
|
212
|
-
style: 'currency',
|
|
213
|
-
currency: 'USD',
|
|
214
|
-
maximumFractionDigits: 0,
|
|
215
|
-
});
|
|
216
|
-
const fromSuggestedCards = (suggestedCards, cardOptions) => {
|
|
217
|
-
const ordered = [...suggestedCards].sort((a, b) => {
|
|
218
|
-
if (a.card_type === b.card_type) {
|
|
219
|
-
return 0;
|
|
220
|
-
}
|
|
221
|
-
return a.card_type === 'vendor' ? -1 : 1;
|
|
222
|
-
});
|
|
223
|
-
const withUniqueIds = withSynthesizedIds(ordered);
|
|
224
|
-
const teamRows = withUniqueIds
|
|
225
|
-
.filter(({ card }) => card.is_suggested)
|
|
226
|
-
.map(({ card, uniqueId }) => ({
|
|
227
|
-
avgMonthlySpend: CURRENCY_FORMATTER.format(card.avg_spend),
|
|
228
|
-
cardKind: card.card_type === 'department' ? 'class' : 'vendor',
|
|
229
|
-
id: uniqueId,
|
|
230
|
-
label: card.card_name,
|
|
231
|
-
recommendedLimit: CURRENCY_FORMATTER.format(card.credit_limit),
|
|
232
|
-
recommendedLimitCadence: 'Monthly',
|
|
233
|
-
}));
|
|
234
|
-
const suggestedOwnerUserIdByTeamId = Object.fromEntries(withUniqueIds
|
|
235
|
-
.filter(({ card }) => card.is_suggested)
|
|
236
|
-
.map(({ card, uniqueId }) => [uniqueId, card.owner_id]));
|
|
237
|
-
const cardNameOptions = withUniqueIds.map(({ card, uniqueId }) => ({
|
|
238
|
-
id: uniqueId,
|
|
239
|
-
kind: card.card_type === 'department' ? 'class' : 'vendor',
|
|
240
|
-
label: card.card_name,
|
|
241
|
-
}));
|
|
242
|
-
return {
|
|
243
|
-
mode: 'team-then-cards',
|
|
244
|
-
cardOptions,
|
|
245
|
-
cardNameOptions,
|
|
246
|
-
suggestedOwnerUserIdByTeamId,
|
|
247
|
-
teamRows,
|
|
248
|
-
};
|
|
249
|
-
};
|
|
250
|
-
/**
|
|
251
|
-
* Stamp each suggested card with a stable unique id derived from its
|
|
252
|
-
* `card_name_id`. If two cards in the same payload share the same
|
|
253
|
-
* `card_name_id` (which happens in the current sample payload where
|
|
254
|
-
* `card_name_id` is the literal `"vendor_uuid"`), fall back to a
|
|
255
|
-
* synthesized id `${kind}__${card_name_id}__${index}` so RHF row keying
|
|
256
|
-
* stays unique.
|
|
257
|
-
*/
|
|
258
|
-
const withSynthesizedIds = (cards) => {
|
|
259
|
-
const seen = new Set();
|
|
260
|
-
return cards.map((card, index) => {
|
|
261
|
-
const preferred = card.card_name_id;
|
|
262
|
-
if (preferred != null && preferred !== '' && !seen.has(preferred)) {
|
|
263
|
-
seen.add(preferred);
|
|
264
|
-
return { card, uniqueId: preferred };
|
|
265
|
-
}
|
|
266
|
-
const synthesized = `${card.card_type}__${preferred ?? 'unknown'}__${index}`;
|
|
267
|
-
seen.add(synthesized);
|
|
268
|
-
return { card, uniqueId: synthesized };
|
|
269
|
-
});
|
|
270
|
-
};
|
|
271
|
-
const toCardPolicyDraftPolicy = (payload, index) => ({
|
|
272
|
-
id: `draft-${index}`,
|
|
273
|
-
name: payload.name,
|
|
274
|
-
description: payload.description ?? '',
|
|
275
|
-
mode: payload.mode,
|
|
276
|
-
allowedEntity: {
|
|
277
|
-
categoryCodes: payload.allowed_entity?.category_codes ?? [],
|
|
278
|
-
merchantNames: payload.allowed_entity?.merchant_names ?? [],
|
|
279
|
-
},
|
|
280
|
-
blockedEntity: {
|
|
281
|
-
categoryCodes: payload.blocked_entity?.category_codes ?? [],
|
|
282
|
-
merchantNames: payload.blocked_entity?.merchant_names ?? [],
|
|
283
|
-
},
|
|
284
|
-
applyToCards: payload.apply_to_cards ?? [],
|
|
285
|
-
requiredReceiptThreshold: payload.required_receipt_threshold ?? 0,
|
|
286
|
-
spendLimits: {
|
|
287
|
-
transaction: payload.spend_limits?.transaction ?? 0,
|
|
288
|
-
},
|
|
289
|
-
});
|
|
290
|
-
const toCardPolicyStep5Review = (payload) => ({
|
|
291
|
-
draftPolicies: (payload.draft_policies ?? []).map(toCardPolicyDraftPolicy),
|
|
292
|
-
groupingSource: payload.grouping_source ?? 'none',
|
|
293
|
-
prompt: payload.prompt ?? '',
|
|
294
|
-
});
|
|
295
|
-
const toCardPolicyWizardPlan = (payload) => ({
|
|
296
|
-
step5Review: toCardPolicyStep5Review(payload.step_5_review),
|
|
297
|
-
});
|
|
298
|
-
const toCardPolicyUploadSource = (payload) => ({
|
|
299
|
-
confidenceScore: payload.confidence_score,
|
|
300
|
-
fileName: payload.file_name,
|
|
301
|
-
lowConfidenceFields: payload.low_confidence_fields ?? [],
|
|
302
|
-
});
|
|
303
|
-
const toCardPolicyInitialData = (payload) => {
|
|
304
|
-
if (payload.mode === 'upload') {
|
|
305
|
-
return {
|
|
306
|
-
policyKind: 'upload',
|
|
307
|
-
wizardPlan: payload.wizard_plan != null
|
|
308
|
-
? toCardPolicyWizardPlan(payload.wizard_plan)
|
|
309
|
-
: undefined,
|
|
310
|
-
source: payload.source != null
|
|
311
|
-
? toCardPolicyUploadSource(payload.source)
|
|
312
|
-
: undefined,
|
|
313
|
-
};
|
|
314
|
-
}
|
|
315
|
-
return {
|
|
316
|
-
policyKind: payload.mode,
|
|
317
|
-
wizardPlan: toCardPolicyWizardPlan(payload.wizard_plan),
|
|
318
|
-
};
|
|
319
|
-
};
|
|
320
148
|
const toAiCfoVisualizationData = (data) => {
|
|
321
149
|
if ('x' in data && 'y' in data) {
|
|
322
150
|
// Normalize y to always be an array
|
|
@@ -630,49 +458,6 @@ const aiCfo = (0, toolkit_1.createSlice)({
|
|
|
630
458
|
session.questionAnswers.push(qa);
|
|
631
459
|
}
|
|
632
460
|
},
|
|
633
|
-
/**
|
|
634
|
-
* Patch the `card_policy` interactive-form payload for a specific
|
|
635
|
-
* answer in a chat session to merge in the wizard plan + upload
|
|
636
|
-
* source metadata returned by
|
|
637
|
-
* `POST /cards/1.0/ai-cfo/policy-recommendation-from-upload`.
|
|
638
|
-
*
|
|
639
|
-
* Dispatched by the recommendation epic after a successful response;
|
|
640
|
-
* the wizard re-renders Steps 2 + 3 of the upload variant once the
|
|
641
|
-
* payload becomes a populated `CardPolicyInitialData` with
|
|
642
|
-
* `policyKind: "upload"` + `wizardPlan` + `source`.
|
|
643
|
-
*
|
|
644
|
-
* No-op when the target answer / chat session / form payload is
|
|
645
|
-
* missing or isn't an upload-mode card-policy interactive form —
|
|
646
|
-
* the bridge epic is best-effort and silently drops in edge cases
|
|
647
|
-
* (e.g. the user closed the chat before recommendation returned).
|
|
648
|
-
*/
|
|
649
|
-
updateAiCfoAnswerCardPolicyWizardPlan(draft, action) {
|
|
650
|
-
const { answerId, chatSessionId, source, wizardPlan } = action.payload;
|
|
651
|
-
const session = draft.aiCfoByChatSessionId[chatSessionId];
|
|
652
|
-
if (session == null) {
|
|
653
|
-
return;
|
|
654
|
-
}
|
|
655
|
-
const qa = session.questionAnswers.find((entry) => entry.questionAnswerId === answerId);
|
|
656
|
-
if (qa == null) {
|
|
657
|
-
return;
|
|
658
|
-
}
|
|
659
|
-
for (const response of Object.values(qa.responses)) {
|
|
660
|
-
const visualization = response?.content.visualization;
|
|
661
|
-
if (visualization == null || visualization.type !== 'interactive_form') {
|
|
662
|
-
continue;
|
|
663
|
-
}
|
|
664
|
-
const data = visualization.data;
|
|
665
|
-
if (data.formType !== 'card_policy' ||
|
|
666
|
-
data.payload.policyKind !== 'upload') {
|
|
667
|
-
continue;
|
|
668
|
-
}
|
|
669
|
-
data.payload = {
|
|
670
|
-
...data.payload,
|
|
671
|
-
wizardPlan,
|
|
672
|
-
source: source ?? data.payload.source,
|
|
673
|
-
};
|
|
674
|
-
}
|
|
675
|
-
},
|
|
676
461
|
clearSession(draft, action) {
|
|
677
462
|
const sessionId = action.payload;
|
|
678
463
|
delete draft.aiCfoByChatSessionId[sessionId];
|
|
@@ -708,5 +493,5 @@ const toChatSession = (chatSessionPayload) => {
|
|
|
708
493
|
createdAt: (0, zeniDayJS_1.date)(created_at),
|
|
709
494
|
};
|
|
710
495
|
};
|
|
711
|
-
_a = aiCfo.actions, exports.setNewSession = _a.setNewSession, exports.clearSession = _a.clearSession, exports.setSessions = _a.setSessions, exports.setChatHistory = _a.setChatHistory, exports.upsertAnswerPayload = _a.upsertAnswerPayload, exports.upsertOrAddQuestionAnswerPayload = _a.upsertOrAddQuestionAnswerPayload, exports.addQuestionPayload = _a.addQuestionPayload, exports.clearAiCfo = _a.clearAiCfo, exports.deleteQuestion = _a.deleteQuestion
|
|
496
|
+
_a = aiCfo.actions, exports.setNewSession = _a.setNewSession, exports.clearSession = _a.clearSession, exports.setSessions = _a.setSessions, exports.setChatHistory = _a.setChatHistory, exports.upsertAnswerPayload = _a.upsertAnswerPayload, exports.upsertOrAddQuestionAnswerPayload = _a.upsertOrAddQuestionAnswerPayload, exports.addQuestionPayload = _a.addQuestionPayload, exports.clearAiCfo = _a.clearAiCfo, exports.deleteQuestion = _a.deleteQuestion;
|
|
712
497
|
exports.default = aiCfo.reducer;
|
|
@@ -9,13 +9,9 @@ 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
|
|
14
|
-
export declare const
|
|
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;
|
|
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;
|
|
19
15
|
export type AiCfoVisualizationType = ReturnType<typeof toAiCfoVisualizationType>;
|
|
20
16
|
export declare const toAiCfoChartType: (v: string) => "bar_chart" | "pie_chart" | "line_chart";
|
|
21
17
|
export declare const toAiCfoChartTypeStrict: (v: string) => "bar_chart" | "pie_chart" | "line_chart" | undefined;
|
|
@@ -57,163 +53,8 @@ export interface ChartVisualization {
|
|
|
57
53
|
lines?: string[];
|
|
58
54
|
yFormat?: YFormat;
|
|
59
55
|
}
|
|
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 `team-then-cards` 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
|
-
* - `team-then-cards` (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
|
-
* - `cards-only` (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: 'team-then-cards';
|
|
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: 'cards-only';
|
|
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
|
-
};
|
|
215
56
|
export interface AiCfoVisualization {
|
|
216
|
-
data: TableVisualization | ChartVisualization
|
|
57
|
+
data: TableVisualization | ChartVisualization;
|
|
217
58
|
type: AiCfoVisualizationType;
|
|
218
59
|
}
|
|
219
60
|
export declare const toMessageSender: (v: string) => "user" | "agent";
|
|
@@ -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.
|
|
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;
|
|
4
4
|
const stringToUnion_1 = require("../../commonStateTypes/stringToUnion");
|
|
5
5
|
exports.ALL_AI_CFO_CHARTS_TYPES = [
|
|
6
6
|
'bar_chart',
|
|
@@ -10,16 +10,7 @@ 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',
|
|
14
13
|
];
|
|
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;
|
|
23
14
|
const toAiCfoVisualizationType = (v) => (0, stringToUnion_1.stringToUnion)(v, exports.ALL_AI_CFO_VISUALIZATION_TYPES);
|
|
24
15
|
exports.toAiCfoVisualizationType = toAiCfoVisualizationType;
|
|
25
16
|
const toAiCfoVisualizationTypeStrict = (v) => (0, stringToUnion_1.stringToUnionStrict)(v, exports.ALL_AI_CFO_VISUALIZATION_TYPES);
|