@zeniai/client-epic-state 5.0.65-betaML1 → 5.0.65-betaRR1

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 (115) hide show
  1. package/lib/entity/aiCfo/aiCfoPayload.d.ts +135 -1
  2. package/lib/entity/aiCfo/aiCfoReducer.js +111 -2
  3. package/lib/entity/aiCfo/aiCfoState.d.ts +141 -4
  4. package/lib/entity/aiCfo/aiCfoState.js +10 -1
  5. package/lib/entity/cardPolicy/cardPolicyPayload.d.ts +171 -0
  6. package/lib/entity/cardPolicy/cardPolicyPayload.js +112 -0
  7. package/lib/entity/cardPolicy/cardPolicyReducer.d.ts +13 -0
  8. package/lib/entity/cardPolicy/cardPolicyReducer.js +184 -0
  9. package/lib/entity/cardPolicy/cardPolicySelector.d.ts +28 -0
  10. package/lib/entity/cardPolicy/cardPolicySelector.js +86 -0
  11. package/lib/entity/cardPolicy/cardPolicyState.d.ts +162 -0
  12. package/lib/entity/cardPolicy/cardPolicyState.js +14 -0
  13. package/lib/entity/cardPolicy/extractPolicyDocumentEpic.d.ts +18 -0
  14. package/lib/entity/cardPolicy/extractPolicyDocumentEpic.js +54 -0
  15. package/lib/entity/cardPolicy/fetchCardPolicyVendorOptionsEpic.d.ts +26 -0
  16. package/lib/entity/cardPolicy/fetchCardPolicyVendorOptionsEpic.js +47 -0
  17. package/lib/entity/tenant/clearAllEpic.d.ts +6 -2
  18. package/lib/entity/tenant/clearAllEpic.js +8 -0
  19. package/lib/epic.d.ts +9 -2
  20. package/lib/epic.js +9 -2
  21. package/lib/esm/entity/aiCfo/aiCfoReducer.js +112 -3
  22. package/lib/esm/entity/aiCfo/aiCfoState.js +7 -0
  23. package/lib/esm/entity/cardPolicy/cardPolicyPayload.js +101 -0
  24. package/lib/esm/entity/cardPolicy/cardPolicyReducer.js +180 -0
  25. package/lib/esm/entity/cardPolicy/cardPolicySelector.js +66 -0
  26. package/lib/esm/entity/cardPolicy/cardPolicyState.js +9 -0
  27. package/lib/esm/entity/cardPolicy/extractPolicyDocumentEpic.js +50 -0
  28. package/lib/esm/entity/cardPolicy/fetchCardPolicyVendorOptionsEpic.js +43 -0
  29. package/lib/esm/entity/tenant/clearAllEpic.js +8 -0
  30. package/lib/esm/epic.js +9 -2
  31. package/lib/esm/index.js +21 -7
  32. package/lib/esm/reducer.js +12 -0
  33. package/lib/esm/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.js +1 -21
  34. package/lib/esm/view/expenseAutomationView/reducers/transactionsViewReducer.js +14 -117
  35. package/lib/esm/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +0 -28
  36. package/lib/esm/view/recommendation/recommendationHelper.js +0 -29
  37. package/lib/esm/view/recommendation/recommendationReducer.js +1 -36
  38. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailReducer.js +70 -0
  39. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailSelector.js +22 -0
  40. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailState.js +1 -0
  41. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/fetchCardPolicyDetailEpic.js +44 -0
  42. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/updateCardPolicyEpic.js +49 -0
  43. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/archiveCardPolicyEpic.js +42 -0
  44. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListReducer.js +72 -0
  45. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListSelector.js +21 -0
  46. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListState.js +1 -0
  47. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/fetchCardPolicyListEpic.js +46 -0
  48. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyReducer.js +50 -0
  49. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicySelector.js +6 -0
  50. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyState.js +1 -0
  51. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyTemplateEpic.js +34 -0
  52. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/fetchCardPolicyMccCategoriesEpic.js +17 -0
  53. package/lib/esm/view/transactionDetail/transactionDetailReducer.js +1 -94
  54. package/lib/esm/view/transactionDetail/transactionDetailSelector.js +0 -22
  55. package/lib/index.d.ts +20 -8
  56. package/lib/index.js +119 -35
  57. package/lib/reducer.d.ts +12 -0
  58. package/lib/reducer.js +12 -0
  59. package/lib/view/companyHealthMetricView/companyHealthMetricViewSelector.d.ts +1 -1
  60. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +0 -1
  61. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.js +2 -23
  62. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +1 -14
  63. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.js +14 -117
  64. package/lib/view/expenseAutomationView/selectorTypes/transactionsViewSelectorTypes.d.ts +0 -2
  65. package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.d.ts +0 -3
  66. package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +0 -29
  67. package/lib/view/expenseAutomationView/types/transactionsViewState.d.ts +0 -1
  68. package/lib/view/onboardingView/cockpitView/types/onboardingCockpitViewTypes.d.ts +1 -1
  69. package/lib/view/people/peopleTypes.d.ts +1 -1
  70. package/lib/view/recommendation/recommendationHelper.d.ts +0 -9
  71. package/lib/view/recommendation/recommendationHelper.js +1 -31
  72. package/lib/view/recommendation/recommendationReducer.d.ts +1 -18
  73. package/lib/view/recommendation/recommendationReducer.js +2 -37
  74. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailReducer.d.ts +14 -0
  75. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailReducer.js +74 -0
  76. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailSelector.d.ts +21 -0
  77. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailSelector.js +28 -0
  78. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailState.d.ts +25 -0
  79. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailState.js +2 -0
  80. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/fetchCardPolicyDetailEpic.d.ts +19 -0
  81. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/fetchCardPolicyDetailEpic.js +48 -0
  82. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/updateCardPolicyEpic.d.ts +18 -0
  83. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/updateCardPolicyEpic.js +53 -0
  84. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/archiveCardPolicyEpic.d.ts +16 -0
  85. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/archiveCardPolicyEpic.js +46 -0
  86. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListReducer.d.ts +15 -0
  87. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListReducer.js +76 -0
  88. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListSelector.d.ts +21 -0
  89. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListSelector.js +27 -0
  90. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListState.d.ts +19 -0
  91. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListState.js +2 -0
  92. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/fetchCardPolicyListEpic.d.ts +19 -0
  93. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/fetchCardPolicyListEpic.js +50 -0
  94. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyReducer.d.ts +12 -0
  95. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyReducer.js +54 -0
  96. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicySelector.d.ts +4 -0
  97. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicySelector.js +10 -0
  98. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyState.d.ts +15 -0
  99. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyState.js +2 -0
  100. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyTemplateEpic.d.ts +8 -0
  101. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyTemplateEpic.js +38 -0
  102. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/fetchCardPolicyMccCategoriesEpic.d.ts +15 -0
  103. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/fetchCardPolicyMccCategoriesEpic.js +21 -0
  104. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardList.d.ts +1 -1
  105. package/lib/view/taskManager/taskListView/taskListReducer.d.ts +1 -1
  106. package/lib/view/transactionDetail/transactionDetailReducer.d.ts +1 -11
  107. package/lib/view/transactionDetail/transactionDetailReducer.js +2 -95
  108. package/lib/view/transactionDetail/transactionDetailSelector.d.ts +0 -2
  109. package/lib/view/transactionDetail/transactionDetailSelector.js +1 -24
  110. package/lib/view/transactionDetail/transactionDetailTypes.d.ts +0 -1
  111. package/package.json +1 -1
  112. package/lib/esm/view/recommendation/fetchEntityRecommendationsForLineUpdateEpic.js +0 -78
  113. package/lib/tsconfig.typecheck.tsbuildinfo +0 -1
  114. package/lib/view/recommendation/fetchEntityRecommendationsForLineUpdateEpic.d.ts +0 -9
  115. package/lib/view/recommendation/fetchEntityRecommendationsForLineUpdateEpic.js +0 -82
@@ -20,8 +20,142 @@ 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
+ * Discriminated payload for the AI Card Creation interactive form. The wire
30
+ * format mirrors the FE-side `CardsCreationInitialData` field-for-field
31
+ * (with snake_case field names converted to camelCase by the reducer).
32
+ *
33
+ * - `team-then-cards` (legacy): the AI suggests teams; user reviews them in
34
+ * step 1, then configures cards in step 2.
35
+ * - `cards-only` (1-step): the AI has already chosen cards; user lands
36
+ * directly on the editable card table for confirmation.
37
+ */
38
+ export type CardsCreationInitialDataPayload = {
39
+ card_options: CardsCardOptionPayload[];
40
+ mode: 'team-then-cards';
41
+ suggested_owner_user_id_by_team_id: Record<string, string | null>;
42
+ team_rows: Array<{
43
+ avg_monthly_spend: string;
44
+ id: string;
45
+ label: string;
46
+ recommended_limit: string;
47
+ recommended_limit_cadence?: string | null;
48
+ }>;
49
+ } | {
50
+ card_options: CardsCardOptionPayload[];
51
+ card_rows: Array<{
52
+ card_option_id: string;
53
+ id: string;
54
+ /**
55
+ * Optional team-derived display label rendered in the card cell
56
+ * trigger (e.g. "Engineering"). Drives the row's first-letter avatar
57
+ * in step 2.
58
+ */
59
+ label?: string | null;
60
+ recommended_limit?: number | null;
61
+ suggested_owner_user_id?: string | null;
62
+ }>;
63
+ mode: 'cards-only';
64
+ };
65
+ /**
66
+ * Vendor / category seed for the AI Card Policy interactive form.
67
+ * `optional_code` carries the MCC (e.g. "6051") for category items; vendor
68
+ * items omit it.
69
+ */
70
+ export interface CardPolicyTagSeedPayload {
71
+ id: string;
72
+ is_selected: boolean;
73
+ label: string;
74
+ optional_code?: string | null;
75
+ }
76
+ export interface CardPolicyOwnerSeedPayload {
77
+ display_name: string;
78
+ user_id: string;
79
+ role_label?: string | null;
80
+ }
81
+ export interface CardPolicyCardRowSeedPayload {
82
+ card_name: string;
83
+ id: string;
84
+ is_checked: boolean;
85
+ last4: string;
86
+ limit_amount: number;
87
+ owner: CardPolicyOwnerSeedPayload;
88
+ utilization_amount: number;
89
+ limit_cadence?: string | null;
90
+ }
91
+ export interface CardPolicyLimitRowSeedPayload {
92
+ id: string;
93
+ is_enabled: boolean;
94
+ amount?: number | null;
95
+ }
96
+ /**
97
+ * Suggested-policy seed for the 1-step `review-only` variant and Step 5 of
98
+ * the `full-builder` variant. Each chip group is a flat list rendered inside
99
+ * the expandable policy card; the FE classifies them visually via the
100
+ * `chip_kind` discriminator.
101
+ */
102
+ export interface CardPolicySuggestedPolicyChipPayload {
103
+ chip_kind: 'positive' | 'negative' | 'avatar';
104
+ id: string;
105
+ label: string;
106
+ }
107
+ export interface CardPolicySuggestedPolicyChipGroupPayload {
108
+ chips: CardPolicySuggestedPolicyChipPayload[];
109
+ id: string;
110
+ label: string;
111
+ }
112
+ export interface CardPolicySuggestedPolicyPayload {
113
+ chip_groups: CardPolicySuggestedPolicyChipGroupPayload[];
114
+ id: string;
115
+ is_checked: boolean;
116
+ name: string;
117
+ }
118
+ /**
119
+ * Discriminated payload for the AI Card Policy interactive form. Mirrors
120
+ * the FE-side `CardPolicyInitialData`.
121
+ *
122
+ * - `review-only` (1-step): AI auto-applied default rules; user sees only
123
+ * the policy review.
124
+ * - `full-builder` (5-step): vendors → categories → cards → limits →
125
+ * review.
126
+ * - `doc-upload` (3-step): upload → cards → review. Vendors / categories
127
+ * / limits are filled in by the policy-document-extract API on the FE,
128
+ * so the payload only carries `cards` (still user-picked) and any
129
+ * optional suggested-policy seed.
130
+ */
131
+ export type CardPolicyInitialDataPayload = {
132
+ policy_kind: 'review-only';
133
+ suggested_policies: CardPolicySuggestedPolicyPayload[];
134
+ } | {
135
+ cards: CardPolicyCardRowSeedPayload[];
136
+ categories: CardPolicyTagSeedPayload[];
137
+ default_limits: CardPolicyLimitRowSeedPayload[];
138
+ policy_kind: 'full-builder';
139
+ suggested_policies: CardPolicySuggestedPolicyPayload[];
140
+ vendors: CardPolicyTagSeedPayload[];
141
+ } | {
142
+ cards: CardPolicyCardRowSeedPayload[];
143
+ policy_kind: 'doc-upload';
144
+ suggested_policies: CardPolicySuggestedPolicyPayload[];
145
+ };
146
+ /**
147
+ * Discriminated visualization payload. The FE narrows on `form_type` and
148
+ * casts `payload` to the matching shape.
149
+ */
150
+ export type InteractiveFormVisualizationPayload = {
151
+ form_type: 'cards_creation';
152
+ payload: CardsCreationInitialDataPayload;
153
+ } | {
154
+ form_type: 'card_policy';
155
+ payload: CardPolicyInitialDataPayload;
156
+ };
23
157
  export interface AiCfoVisualizationPayload {
24
- data: TableVisualizationPayload | ChartVisualizationPayload | null;
158
+ data: TableVisualizationPayload | ChartVisualizationPayload | InteractiveFormVisualizationPayload | null;
25
159
  type: string | null;
26
160
  }
27
161
  export interface AiCfoAnswerPayload {
@@ -139,12 +139,121 @@ 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';
142
143
  return {
143
- type: (0, aiCfoState_1.toAiCfoVisualizationTypeStrict)(visualization.type) ?? 'table',
144
- data: toAiCfoVisualizationData(visualization.data),
144
+ type: normalizedType,
145
+ data: normalizedType === 'interactive_form'
146
+ ? toInteractiveFormVisualization(visualization.data)
147
+ : toAiCfoVisualizationData(visualization.data),
145
148
  };
146
149
  };
147
150
  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
+ return {
184
+ mode: 'team-then-cards',
185
+ cardOptions,
186
+ suggestedOwnerUserIdByTeamId: Object.fromEntries(Object.entries(payload.suggested_owner_user_id_by_team_id ?? {}).map(([teamId, userId]) => [teamId, userId ?? undefined])),
187
+ teamRows: (payload.team_rows ?? []).map((row) => ({
188
+ avgMonthlySpend: row.avg_monthly_spend,
189
+ id: row.id,
190
+ label: row.label,
191
+ recommendedLimit: row.recommended_limit,
192
+ recommendedLimitCadence: row.recommended_limit_cadence ?? undefined,
193
+ })),
194
+ };
195
+ };
196
+ const toCardPolicyInitialData = (payload) => {
197
+ const suggestedPolicies = (payload.suggested_policies ?? []).map((policy) => ({
198
+ id: policy.id,
199
+ isChecked: policy.is_checked,
200
+ name: policy.name,
201
+ chipGroups: (policy.chip_groups ?? []).map((group) => ({
202
+ id: group.id,
203
+ label: group.label,
204
+ chips: (group.chips ?? []).map((chip) => ({
205
+ id: chip.id,
206
+ label: chip.label,
207
+ chipKind: chip.chip_kind,
208
+ })),
209
+ })),
210
+ }));
211
+ if (payload.policy_kind === 'review-only') {
212
+ return {
213
+ policyKind: 'review-only',
214
+ suggestedPolicies,
215
+ };
216
+ }
217
+ const toCardRowSeed = (card) => ({
218
+ cardName: card.card_name,
219
+ id: card.id,
220
+ isChecked: card.is_checked,
221
+ last4: card.last4,
222
+ limitAmount: card.limit_amount,
223
+ limitCadence: card.limit_cadence ?? undefined,
224
+ owner: {
225
+ userId: card.owner.user_id,
226
+ displayName: card.owner.display_name,
227
+ roleLabel: card.owner.role_label ?? undefined,
228
+ },
229
+ utilizationAmount: card.utilization_amount,
230
+ });
231
+ if (payload.policy_kind === 'doc-upload') {
232
+ return {
233
+ policyKind: 'doc-upload',
234
+ suggestedPolicies,
235
+ cards: (payload.cards ?? []).map(toCardRowSeed),
236
+ };
237
+ }
238
+ return {
239
+ policyKind: 'full-builder',
240
+ suggestedPolicies,
241
+ vendors: (payload.vendors ?? []).map(toCardPolicyTagSeed),
242
+ categories: (payload.categories ?? []).map(toCardPolicyTagSeed),
243
+ cards: (payload.cards ?? []).map(toCardRowSeed),
244
+ defaultLimits: (payload.default_limits ?? []).map((row) => ({
245
+ id: row.id,
246
+ isEnabled: row.is_enabled,
247
+ amount: row.amount ?? undefined,
248
+ })),
249
+ };
250
+ };
251
+ const toCardPolicyTagSeed = (tag) => ({
252
+ id: tag.id,
253
+ isSelected: tag.is_selected,
254
+ label: tag.label,
255
+ optionalCode: tag.optional_code ?? undefined,
256
+ });
148
257
  const toAiCfoVisualizationData = (data) => {
149
258
  if ('x' in data && 'y' in data) {
150
259
  // Normalize y to always be an array
@@ -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,141 @@ 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
+ * Initial data for the AI Card Creation interactive form. Discriminated on
67
+ * `mode`:
68
+ *
69
+ * - `team-then-cards` (default): AI suggests teams; user reviews them in
70
+ * step 1, then configures one card per team in step 2.
71
+ * - `cards-only` (1-step): AI has already chosen cards; user lands directly
72
+ * on the editable card table for confirmation.
73
+ */
74
+ export type CardsCreationInitialData = {
75
+ cardOptions: CardsCardOption[];
76
+ mode: 'team-then-cards';
77
+ /**
78
+ * Map of `teamRow.id` -> suggested owner `userId`. Resolved against
79
+ * `allUsers` (sourced from the tenant) at render time.
80
+ */
81
+ suggestedOwnerUserIdByTeamId: Record<string, ID | undefined>;
82
+ teamRows: Array<{
83
+ avgMonthlySpend: string;
84
+ id: string;
85
+ label: string;
86
+ recommendedLimit: string;
87
+ recommendedLimitCadence?: string;
88
+ }>;
89
+ } | {
90
+ cardOptions: CardsCardOption[];
91
+ cardRows: Array<{
92
+ cardOptionId: string;
93
+ id: string;
94
+ /**
95
+ * Optional team-derived display label rendered in the card cell
96
+ * trigger (e.g. "Engineering"). Drives the row's first-letter avatar
97
+ * in step 2.
98
+ */
99
+ label?: string;
100
+ recommendedLimit?: number;
101
+ suggestedOwnerUserId?: ID;
102
+ }>;
103
+ mode: 'cards-only';
104
+ };
105
+ /**
106
+ * Vendor / category seed for the AI Card Policy interactive form.
107
+ * `optionalCode` carries the MCC (e.g. "6051") for category items; vendor
108
+ * items omit it.
109
+ */
110
+ export interface CardPolicyTagSeed {
111
+ id: string;
112
+ isSelected: boolean;
113
+ label: string;
114
+ optionalCode?: string;
115
+ }
116
+ export interface CardPolicyOwnerSeed {
117
+ displayName: string;
118
+ userId: ID;
119
+ roleLabel?: string;
120
+ }
121
+ export interface CardPolicyCardRowSeed {
122
+ cardName: string;
123
+ id: string;
124
+ isChecked: boolean;
125
+ last4: string;
126
+ limitAmount: number;
127
+ owner: CardPolicyOwnerSeed;
128
+ utilizationAmount: number;
129
+ limitCadence?: string;
130
+ }
131
+ export interface CardPolicyLimitRowSeed {
132
+ id: string;
133
+ isEnabled: boolean;
134
+ amount?: number;
135
+ }
136
+ export interface CardPolicySuggestedPolicyChip {
137
+ chipKind: 'positive' | 'negative' | 'avatar';
138
+ id: string;
139
+ label: string;
140
+ }
141
+ export interface CardPolicySuggestedPolicyChipGroup {
142
+ chips: CardPolicySuggestedPolicyChip[];
143
+ id: string;
144
+ label: string;
145
+ }
146
+ export interface CardPolicySuggestedPolicy {
147
+ chipGroups: CardPolicySuggestedPolicyChipGroup[];
148
+ id: string;
149
+ isChecked: boolean;
150
+ name: string;
151
+ }
152
+ /**
153
+ * Initial data for the AI Card Policy interactive form. Discriminated on
154
+ * `policyKind`:
155
+ *
156
+ * - `review-only` (1-step): AI auto-applied default rules; user sees the
157
+ * policy review only.
158
+ * - `full-builder` (5-step): vendors → categories → cards → limits →
159
+ * review.
160
+ * - `doc-upload` (3-step): upload → cards → review. The user uploads a
161
+ * policy document on Step 1; the cards micro-service extracts the rules
162
+ * and the form is pre-filled via the `policyDocumentExtraction` slice
163
+ * before the user lands on Step 2. `cards` is still required because
164
+ * the user picks which cards the policy applies to in Step 2.
165
+ */
166
+ export type CardPolicyInitialData = {
167
+ policyKind: 'review-only';
168
+ suggestedPolicies: CardPolicySuggestedPolicy[];
169
+ } | {
170
+ cards: CardPolicyCardRowSeed[];
171
+ categories: CardPolicyTagSeed[];
172
+ defaultLimits: CardPolicyLimitRowSeed[];
173
+ policyKind: 'full-builder';
174
+ suggestedPolicies: CardPolicySuggestedPolicy[];
175
+ vendors: CardPolicyTagSeed[];
176
+ } | {
177
+ cards: CardPolicyCardRowSeed[];
178
+ policyKind: 'doc-upload';
179
+ suggestedPolicies: CardPolicySuggestedPolicy[];
180
+ };
181
+ /**
182
+ * Visualization variant rendered as an interactive RHF form (in lieu of a
183
+ * chart or table). Discriminated on `formType`; each branch carries its own
184
+ * payload shape.
185
+ */
186
+ export type InteractiveFormVisualization = {
187
+ formType: 'cards_creation';
188
+ payload: CardsCreationInitialData;
189
+ } | {
190
+ formType: 'card_policy';
191
+ payload: CardPolicyInitialData;
192
+ };
56
193
  export interface AiCfoVisualization {
57
- data: TableVisualization | ChartVisualization;
194
+ data: TableVisualization | ChartVisualization | InteractiveFormVisualization;
58
195
  type: AiCfoVisualizationType;
59
196
  }
60
197
  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.ALL_AI_CFO_VISUALIZATION_TYPES = exports.ALL_AI_CFO_CHARTS_TYPES = void 0;
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.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);
@@ -0,0 +1,171 @@
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` + `name`; we deliberately
31
+ * ignore the rest of the payload to keep this slice independent of the
32
+ * heavy `vendor` entity store.
33
+ */
34
+ export interface CardPolicyVendorSearchVendorPayload {
35
+ name: string;
36
+ vendor_id: 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;
53
+ }
54
+ /**
55
+ * Request body for `POST /cards/1.0/policy-templates`. Consumers pass the
56
+ * already-camelCased payload to the action creator; the epic re-maps it to
57
+ * the snake_case wire format before sending.
58
+ */
59
+ export interface CreateCardPolicyTemplateRequest {
60
+ allowedEntity: CardPolicyTemplateEntityList;
61
+ applyToCards: ID[];
62
+ blockedEntity: CardPolicyTemplateEntityList;
63
+ description: string;
64
+ mode: CardPolicyTemplateMode;
65
+ name: string;
66
+ requiredReceiptThreshold: number;
67
+ spendLimits: CardPolicyTemplateSpendLimits;
68
+ }
69
+ export interface CreateCardPolicyTemplateRequestBody {
70
+ allowed_entity: CardPolicyTemplateEntityListPayload;
71
+ apply_to_cards: ID[];
72
+ blocked_entity: CardPolicyTemplateEntityListPayload;
73
+ description: string;
74
+ mode: string;
75
+ name: string;
76
+ required_receipt_threshold: number;
77
+ spend_limits: CardPolicyTemplateSpendLimitsPayload;
78
+ }
79
+ export interface CardPolicyTemplatePayload {
80
+ allowed_entity: CardPolicyTemplateEntityListPayload;
81
+ applied_cards: ID[];
82
+ blocked_entity: CardPolicyTemplateEntityListPayload;
83
+ cards_count: number;
84
+ category_restrictions: unknown[];
85
+ created_at: string;
86
+ created_by: ID;
87
+ description: string;
88
+ mode: string;
89
+ name: string;
90
+ required_receipt_threshold: number;
91
+ spend_limits: CardPolicyTemplateSpendLimitsPayload;
92
+ status: string;
93
+ template_id: ID;
94
+ tenant_id: ID;
95
+ updated_at: string;
96
+ }
97
+ export interface CreateCardPolicyTemplateResponseData {
98
+ cards_applied: number;
99
+ template: CardPolicyTemplatePayload;
100
+ }
101
+ export type CreateCardPolicyTemplateResponse = ZeniAPIResponse<CreateCardPolicyTemplateResponseData>;
102
+ export type UpdateCardPolicyTemplateRequest = CreateCardPolicyTemplateRequest;
103
+ export type UpdateCardPolicyTemplateRequestBody = CreateCardPolicyTemplateRequestBody;
104
+ export type UpdateCardPolicyTemplateResponseData = CreateCardPolicyTemplateResponseData;
105
+ export type UpdateCardPolicyTemplateResponse = CreateCardPolicyTemplateResponse;
106
+ export type CardPolicyDetailResponseData = CreateCardPolicyTemplateResponseData;
107
+ export type CardPolicyDetailResponse = CreateCardPolicyTemplateResponse;
108
+ /**
109
+ * Aggregate counters returned alongside the templates list. Stored on
110
+ * the entity slice (alongside `cardPolicyTemplateById`) so any list
111
+ * surface can read it without re-fetching.
112
+ */
113
+ export interface CardPolicyStatsPayload {
114
+ active_policies: number;
115
+ total_cards: number;
116
+ total_templates: number;
117
+ }
118
+ /**
119
+ * Each list row is wrapped in the same `{cards_applied, template}`
120
+ * envelope the create endpoint returns. Only the `template` portion is
121
+ * stored on the entity slice; `cards_applied` is a one-shot summary
122
+ * carried over from create and not surfaced in the list state today.
123
+ */
124
+ export interface CardPolicyListRowPayload {
125
+ data: CreateCardPolicyTemplateResponseData;
126
+ }
127
+ export interface ListCardPolicyTemplatesResponseData {
128
+ stats: CardPolicyStatsPayload;
129
+ templates: CardPolicyListRowPayload[];
130
+ }
131
+ export type ListCardPolicyTemplatesResponse = ZeniAPIResponse<ListCardPolicyTemplatesResponseData>;
132
+ export declare const toCardPolicyStats: (payload: CardPolicyStatsPayload) => CardPolicyStats;
133
+ export declare const toCardPolicyTemplateList: (data: ListCardPolicyTemplatesResponseData) => CardPolicyTemplate[];
134
+ export declare const toCardPolicyTemplate: (payload: CardPolicyTemplatePayload) => CardPolicyTemplate;
135
+ /**
136
+ * Re-shape a camelCase create request into the snake_case wire body.
137
+ * Used by the epic at request time.
138
+ */
139
+ export declare const toCreateCardPolicyTemplateRequestBody: (request: CreateCardPolicyTemplateRequest) => CreateCardPolicyTemplateRequestBody;
140
+ export declare const toUpdateCardPolicyTemplateRequestBody: (request: CreateCardPolicyTemplateRequest) => CreateCardPolicyTemplateRequestBody;
141
+ /**
142
+ * Seed an edit-form draft (`CreateCardPolicyTemplateRequest`) from an
143
+ * existing camelCased `CardPolicyTemplate`. Used by the detail-fetch
144
+ * epic so the edit page can render with the saved values pre-populated.
145
+ */
146
+ export declare const toCardPolicyEditFormDraft: (template: CardPolicyTemplate) => CreateCardPolicyTemplateRequest;
147
+ /**
148
+ * Wire shape returned by `POST /cards/1.0/policy-documents/extract`.
149
+ * The backend OCRs / parses an uploaded policy document (PDF, image, etc.)
150
+ * and returns a best-effort set of policy rules + a confidence score.
151
+ *
152
+ * Consumers (manual `CardPolicyCreatePage` + AI CFO `CardPolicyInteractiveForm`)
153
+ * use `toExtractedCardPolicyRules` to map this onto the camelCase FE shape
154
+ * and then feed the result through `applyExtractedPolicyRulesToFormValues`
155
+ * (`@zeniai/web-components`) to seed the RHF form.
156
+ */
157
+ export interface ExtractedCardPolicyRulesPayload {
158
+ allowed_entity: CardPolicyTemplateEntityListPayload;
159
+ blocked_entity: CardPolicyTemplateEntityListPayload;
160
+ confidence_score: number;
161
+ policy_name: string;
162
+ required_receipt_threshold: number;
163
+ transaction_limit: number;
164
+ }
165
+ export interface PolicyDocumentExtractResponseData {
166
+ extracted_rules: ExtractedCardPolicyRulesPayload;
167
+ message: string;
168
+ }
169
+ export type PolicyDocumentExtractResponse = ZeniAPIResponse<PolicyDocumentExtractResponseData>;
170
+ export declare const toExtractedCardPolicyRules: (payload: ExtractedCardPolicyRulesPayload) => ExtractedCardPolicyRules;
171
+ export {};