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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/lib/common/aiCfo/aiCfoSuggestedQuestionsPageContext.d.ts +1 -1
  2. package/lib/entity/aiCfo/aiCfoPayload.d.ts +1 -171
  3. package/lib/entity/aiCfo/aiCfoReducer.d.ts +1 -7
  4. package/lib/entity/aiCfo/aiCfoReducer.js +4 -219
  5. package/lib/entity/aiCfo/aiCfoState.d.ts +4 -163
  6. package/lib/entity/aiCfo/aiCfoState.js +1 -10
  7. package/lib/entity/jeSchedules/jeSchedulesTypes.d.ts +1 -1
  8. package/lib/entity/monthEndCloseChecks/monthEndCloseChecksState.d.ts +1 -1
  9. package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
  10. package/lib/entity/snackbar/snackbarTypes.js +0 -2
  11. package/lib/entity/tenant/clearAllEpic.d.ts +2 -6
  12. package/lib/entity/tenant/clearAllEpic.js +0 -8
  13. package/lib/epic.d.ts +1 -11
  14. package/lib/epic.js +1 -11
  15. package/lib/esm/entity/aiCfo/aiCfoReducer.js +4 -219
  16. package/lib/esm/entity/aiCfo/aiCfoState.js +0 -7
  17. package/lib/esm/entity/snackbar/snackbarTypes.js +0 -2
  18. package/lib/esm/entity/tenant/clearAllEpic.js +0 -8
  19. package/lib/esm/epic.js +1 -11
  20. package/lib/esm/index.js +4 -19
  21. package/lib/esm/reducer.js +0 -12
  22. package/lib/esm/view/aiCfoView/aiCfoViewReducer.js +3 -6
  23. package/lib/esm/view/aiCfoView/epics/createSessionAndSubmitEpic.js +2 -5
  24. package/lib/esm/view/aiCfoView/epics/createSessionEpic.js +1 -2
  25. package/lib/esm/view/aiCfoView/epics/fetchSuggestedQuestionsEpic.js +2 -12
  26. package/lib/esm/view/spendManagement/chargeCards/chargeCardList/chargeCardListSelector.js +0 -25
  27. package/lib/index.d.ts +4 -17
  28. package/lib/index.js +11 -112
  29. package/lib/reducer.d.ts +0 -12
  30. package/lib/reducer.js +0 -12
  31. package/lib/tsconfig.typecheck.tsbuildinfo +1 -0
  32. package/lib/view/aiCfoView/aiCfoViewReducer.d.ts +2 -11
  33. package/lib/view/aiCfoView/aiCfoViewReducer.js +3 -6
  34. package/lib/view/aiCfoView/epics/createSessionAndSubmitEpic.js +2 -5
  35. package/lib/view/aiCfoView/epics/createSessionEpic.js +1 -2
  36. package/lib/view/aiCfoView/epics/fetchSuggestedQuestionsEpic.d.ts +1 -8
  37. package/lib/view/aiCfoView/epics/fetchSuggestedQuestionsEpic.js +2 -12
  38. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
  39. package/lib/view/expenseAutomationView/types/jeSchedulesViewState.d.ts +1 -1
  40. package/lib/view/expenseAutomationView/types/missingReceiptsViewState.d.ts +2 -2
  41. package/lib/view/expenseAutomationView/types/transactionsViewState.d.ts +1 -1
  42. package/lib/view/people/peopleTypes.d.ts +1 -1
  43. package/lib/view/scheduleView/scheduleListView/scheduleListTypes.d.ts +1 -1
  44. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardList.d.ts +1 -1
  45. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListSelector.d.ts +0 -14
  46. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListSelector.js +1 -27
  47. package/lib/view/taskManager/taskListView/taskListReducer.d.ts +1 -1
  48. package/package.json +1 -1
  49. package/lib/entity/cardPolicy/cardPolicyPayload.d.ts +0 -277
  50. package/lib/entity/cardPolicy/cardPolicyPayload.js +0 -143
  51. package/lib/entity/cardPolicy/cardPolicyReducer.d.ts +0 -19
  52. package/lib/entity/cardPolicy/cardPolicyReducer.js +0 -256
  53. package/lib/entity/cardPolicy/cardPolicySelector.d.ts +0 -32
  54. package/lib/entity/cardPolicy/cardPolicySelector.js +0 -103
  55. package/lib/entity/cardPolicy/cardPolicyState.d.ts +0 -205
  56. package/lib/entity/cardPolicy/cardPolicyState.js +0 -14
  57. package/lib/entity/cardPolicy/extractPolicyDocumentEpic.d.ts +0 -18
  58. package/lib/entity/cardPolicy/extractPolicyDocumentEpic.js +0 -54
  59. package/lib/entity/cardPolicy/fetchCardPolicyVendorOptionsEpic.d.ts +0 -26
  60. package/lib/entity/cardPolicy/fetchCardPolicyVendorOptionsEpic.js +0 -47
  61. package/lib/entity/cardPolicy/policyDocumentExtractionToRecommendationBridgeEpic.d.ts +0 -25
  62. package/lib/entity/cardPolicy/policyDocumentExtractionToRecommendationBridgeEpic.js +0 -39
  63. package/lib/entity/cardPolicy/policyRecommendationFromUploadEpic.d.ts +0 -23
  64. package/lib/entity/cardPolicy/policyRecommendationFromUploadEpic.js +0 -92
  65. package/lib/esm/entity/cardPolicy/cardPolicyPayload.js +0 -130
  66. package/lib/esm/entity/cardPolicy/cardPolicyReducer.js +0 -252
  67. package/lib/esm/entity/cardPolicy/cardPolicySelector.js +0 -79
  68. package/lib/esm/entity/cardPolicy/cardPolicyState.js +0 -9
  69. package/lib/esm/entity/cardPolicy/extractPolicyDocumentEpic.js +0 -50
  70. package/lib/esm/entity/cardPolicy/fetchCardPolicyVendorOptionsEpic.js +0 -43
  71. package/lib/esm/entity/cardPolicy/policyDocumentExtractionToRecommendationBridgeEpic.js +0 -35
  72. package/lib/esm/entity/cardPolicy/policyRecommendationFromUploadEpic.js +0 -88
  73. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailReducer.js +0 -70
  74. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailSelector.js +0 -22
  75. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailState.js +0 -1
  76. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/fetchCardPolicyDetailEpic.js +0 -56
  77. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/updateCardPolicyEpic.js +0 -49
  78. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/archiveCardPolicyEpic.js +0 -42
  79. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListReducer.js +0 -72
  80. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListSelector.js +0 -21
  81. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListState.js +0 -1
  82. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/fetchCardPolicyListEpic.js +0 -56
  83. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyReducer.js +0 -59
  84. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicySelector.js +0 -31
  85. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyState.js +0 -1
  86. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyTemplateEpic.js +0 -53
  87. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/fetchCardPolicyMccCategoriesEpic.js +0 -25
  88. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailReducer.d.ts +0 -14
  89. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailReducer.js +0 -74
  90. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailSelector.d.ts +0 -21
  91. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailSelector.js +0 -28
  92. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailState.d.ts +0 -25
  93. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailState.js +0 -2
  94. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/fetchCardPolicyDetailEpic.d.ts +0 -19
  95. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/fetchCardPolicyDetailEpic.js +0 -60
  96. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/updateCardPolicyEpic.d.ts +0 -18
  97. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/updateCardPolicyEpic.js +0 -53
  98. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/archiveCardPolicyEpic.d.ts +0 -16
  99. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/archiveCardPolicyEpic.js +0 -46
  100. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListReducer.d.ts +0 -15
  101. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListReducer.js +0 -76
  102. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListSelector.d.ts +0 -21
  103. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListSelector.js +0 -27
  104. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListState.d.ts +0 -19
  105. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListState.js +0 -2
  106. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/fetchCardPolicyListEpic.d.ts +0 -19
  107. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/fetchCardPolicyListEpic.js +0 -60
  108. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyReducer.d.ts +0 -13
  109. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyReducer.js +0 -63
  110. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicySelector.d.ts +0 -26
  111. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicySelector.js +0 -37
  112. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyState.d.ts +0 -36
  113. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyState.js +0 -2
  114. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyTemplateEpic.d.ts +0 -25
  115. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyTemplateEpic.js +0 -57
  116. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/fetchCardPolicyMccCategoriesEpic.d.ts +0 -15
  117. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/fetchCardPolicyMccCategoriesEpic.js +0 -29
@@ -1,143 +0,0 @@
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;
@@ -1,19 +0,0 @@
1
- import { ZeniAPIStatus } from '../../responsePayload';
2
- import { CardPolicyMccCategoriesPayload, CardPolicyTemplatePayload, CardPolicyVendorSearchData, ExtractedCardPolicyRulesPayload } from './cardPolicyPayload';
3
- import { CardPolicyState, CardPolicyStats, CardPolicyTemplate, ExtractedCardPolicyRules } from './cardPolicyState';
4
- export declare const initialState: CardPolicyState;
5
- export declare const fetchCardPolicyMccCategories: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"cardPolicy/fetchCardPolicyMccCategories">, fetchCardPolicyVendorOptions: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[searchString?: string | undefined], {
6
- searchString: string;
7
- }, "cardPolicy/fetchCardPolicyVendorOptions", never, never>, updateCardPolicyMccCategories: import("@reduxjs/toolkit").ActionCreatorWithPayload<CardPolicyMccCategoriesPayload, "cardPolicy/updateCardPolicyMccCategories">, updateCardPolicyMccCategoriesFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "cardPolicy/updateCardPolicyMccCategoriesFailure">, updateCardPolicyVendorOptions: import("@reduxjs/toolkit").ActionCreatorWithPayload<CardPolicyVendorSearchData, "cardPolicy/updateCardPolicyVendorOptions">, updateCardPolicyVendorOptionsFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "cardPolicy/updateCardPolicyVendorOptionsFailure">, updateCreatedCardPolicyTemplate: import("@reduxjs/toolkit").ActionCreatorWithPayload<CardPolicyTemplatePayload, "cardPolicy/updateCreatedCardPolicyTemplate">, updateCardPolicyTemplates: import("@reduxjs/toolkit").ActionCreatorWithPayload<CardPolicyTemplate[], "cardPolicy/updateCardPolicyTemplates">, removeCardPolicyTemplate: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, "cardPolicy/removeCardPolicyTemplate">, updateCardPolicyStats: import("@reduxjs/toolkit").ActionCreatorWithPayload<CardPolicyStats, "cardPolicy/updateCardPolicyStats">, extractPolicyDocument: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[files: File[], aiCfoAnswerId?: string | undefined, aiCfoChatSessionId?: string | undefined], {
8
- files: File[];
9
- aiCfoAnswerId: string | undefined;
10
- aiCfoChatSessionId: string | undefined;
11
- }, "cardPolicy/extractPolicyDocument", never, {
12
- uploadedFileName: string;
13
- }>, updatePolicyDocumentExtractionSuccess: import("@reduxjs/toolkit").ActionCreatorWithPayload<ExtractedCardPolicyRulesPayload, "cardPolicy/updatePolicyDocumentExtractionSuccess">, updatePolicyDocumentExtractionFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "cardPolicy/updatePolicyDocumentExtractionFailure">, clearPolicyDocumentExtraction: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"cardPolicy/clearPolicyDocumentExtraction">, fetchCardPolicyRecommendationFromUpload: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[answerId: string, chatSessionId: string, extractedRules: ExtractedCardPolicyRules], {
14
- answerId: string;
15
- chatSessionId: string;
16
- extractedRules: ExtractedCardPolicyRules;
17
- }, "cardPolicy/fetchCardPolicyRecommendationFromUpload", never, never>, updatePolicyRecommendationFromUploadSuccess: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"cardPolicy/updatePolicyRecommendationFromUploadSuccess">, updatePolicyRecommendationFromUploadFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "cardPolicy/updatePolicyRecommendationFromUploadFailure">, clearCardPolicy: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"cardPolicy/clearCardPolicy">;
18
- declare const _default: import("redux").Reducer<CardPolicyState>;
19
- export default _default;
@@ -1,256 +0,0 @@
1
- "use strict";
2
- var _a;
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.clearCardPolicy = exports.updatePolicyRecommendationFromUploadFailure = exports.updatePolicyRecommendationFromUploadSuccess = exports.fetchCardPolicyRecommendationFromUpload = exports.clearPolicyDocumentExtraction = exports.updatePolicyDocumentExtractionFailure = exports.updatePolicyDocumentExtractionSuccess = exports.extractPolicyDocument = exports.updateCardPolicyStats = exports.removeCardPolicyTemplate = exports.updateCardPolicyTemplates = exports.updateCreatedCardPolicyTemplate = exports.updateCardPolicyVendorOptionsFailure = exports.updateCardPolicyVendorOptions = exports.updateCardPolicyMccCategoriesFailure = exports.updateCardPolicyMccCategories = exports.fetchCardPolicyVendorOptions = exports.fetchCardPolicyMccCategories = exports.initialState = void 0;
5
- const toolkit_1 = require("@reduxjs/toolkit");
6
- const cardPolicyPayload_1 = require("./cardPolicyPayload");
7
- /**
8
- * Defensive predicate for vendor / merchant names that flow into
9
- * `buildVendorChipId(name)` (in `@zeniai/web-components`). That helper
10
- * calls `name.trim().toLowerCase()`, so a null / undefined / whitespace-
11
- * only value would throw at render time, and an empty string would
12
- * collapse every nameless row into a single colliding `vendor-` chip-id.
13
- * Used at the redux ingestion boundary for both the vendor-search results
14
- * and the BE-suggested merchant seed arrays.
15
- */
16
- const isUsableMerchantName = (name) => typeof name === 'string' && name.trim() !== '';
17
- const initialPolicyDocumentExtractionState = {
18
- fetchState: 'Not-Started',
19
- error: undefined,
20
- extractedRules: undefined,
21
- uploadedFileName: undefined,
22
- };
23
- const initialPolicyRecommendationFromUploadState = {
24
- fetchState: 'Not-Started',
25
- answerId: undefined,
26
- chatSessionId: undefined,
27
- error: undefined,
28
- };
29
- const initialVendorSearchState = {
30
- fetchState: 'Not-Started',
31
- searchString: '',
32
- vendors: [],
33
- error: undefined,
34
- };
35
- exports.initialState = {
36
- cardPolicyTemplateById: {},
37
- mccCategories: [],
38
- mccCategoriesError: undefined,
39
- mccCategoriesFetchState: 'Not-Started',
40
- policyDocumentExtraction: initialPolicyDocumentExtractionState,
41
- policyRecommendationFromUpload: initialPolicyRecommendationFromUploadState,
42
- suggestedAllowCategories: [],
43
- suggestedAllowMerchants: [],
44
- suggestedBlockCategories: [],
45
- suggestedBlockMerchants: [],
46
- vendorSearch: initialVendorSearchState,
47
- cardPolicyStats: undefined,
48
- };
49
- const cardPolicy = (0, toolkit_1.createSlice)({
50
- name: 'cardPolicy',
51
- initialState: exports.initialState,
52
- reducers: {
53
- fetchCardPolicyMccCategories(draft) {
54
- draft.mccCategoriesFetchState = 'In-Progress';
55
- draft.mccCategoriesError = undefined;
56
- },
57
- updateCardPolicyMccCategories(draft, action) {
58
- draft.mccCategories = (action.payload.categories ?? []).map(cardPolicyPayload_1.toMccCategory);
59
- // Persist BE-suggested allow / block seeds alongside the universe.
60
- // Both flows (manual create page + AI CFO interactive form) read
61
- // these to pre-populate the chip cloud body before the user edits.
62
- // Drop empty / nullish merchant names defensively — they feed
63
- // `buildVendorChipId(name)` (in @zeniai/web-components) which calls
64
- // `.trim().toLowerCase()` and would crash the chip-picker render
65
- // path if any entry slipped through as undefined / "".
66
- draft.suggestedAllowMerchants = (action.payload.suggested_allow_merchants ?? []).filter(isUsableMerchantName);
67
- draft.suggestedBlockMerchants = (action.payload.suggested_block_merchants ?? []).filter(isUsableMerchantName);
68
- draft.suggestedAllowCategories = (action.payload.suggested_allow_catagories ?? []).map(cardPolicyPayload_1.toMccCategory);
69
- draft.suggestedBlockCategories = (action.payload.suggested_block_catagories ?? []).map(cardPolicyPayload_1.toMccCategory);
70
- draft.mccCategoriesFetchState = 'Completed';
71
- draft.mccCategoriesError = undefined;
72
- },
73
- updateCardPolicyMccCategoriesFailure(draft, action) {
74
- draft.mccCategoriesFetchState = 'Error';
75
- draft.mccCategoriesError = action.payload;
76
- },
77
- /**
78
- * Store a newly-created (or refreshed) card-policy template keyed by
79
- * `templateId`. Dispatched by the create / list / get epics; consumed
80
- * by both manual and AI-CFO policy flows via `getCardPolicyTemplateById`.
81
- */
82
- updateCreatedCardPolicyTemplate(draft, action) {
83
- const template = (0, cardPolicyPayload_1.toCardPolicyTemplate)(action.payload);
84
- draft.cardPolicyTemplateById[template.templateId] = template;
85
- },
86
- /**
87
- * Replace the entity store's `cardPolicyTemplateById` map with the
88
- * full list returned by the templates-list endpoint. Full replace is
89
- * intentional — templates that no longer exist on the server should be
90
- * dropped from local state too. The view slice keeps the server-order
91
- * ID list separately for stable list rendering.
92
- */
93
- updateCardPolicyTemplates(draft, action) {
94
- const byId = {};
95
- for (const template of action.payload) {
96
- byId[template.templateId] = template;
97
- }
98
- draft.cardPolicyTemplateById = byId;
99
- },
100
- /**
101
- * Drop a single template from the entity map. Dispatched by the
102
- * archive (DELETE) epic on success; also usable by any future flow
103
- * that needs to evict a template (e.g. AI-CFO rejection).
104
- */
105
- removeCardPolicyTemplate(draft, action) {
106
- delete draft.cardPolicyTemplateById[action.payload];
107
- },
108
- /**
109
- * Replace the tenant-wide policy stats. Dispatched alongside
110
- * `updateCardPolicyTemplates` from the list epic, but lives on the
111
- * entity slice so any consumer can read it without re-fetching the
112
- * list.
113
- */
114
- updateCardPolicyStats(draft, action) {
115
- draft.cardPolicyStats = action.payload;
116
- },
117
- /**
118
- * Kick off the `POST /cards/1.0/policy-documents/extract` request.
119
- *
120
- * Synchronously flips the sub-slice to `In-Progress` and captures the
121
- * first uploaded file's name (used by the manual `CardPolicyCreatePage`
122
- * to render the "Policy.pdf ×" pill once the request completes) so
123
- * downstream callers don't have to keep their own file refs.
124
- *
125
- * The accompanying `extractPolicyDocumentEpic` listens for this action,
126
- * POSTs multipart form-data to the cards micro-service, and dispatches
127
- * either `updatePolicyDocumentExtractionSuccess` or
128
- * `updatePolicyDocumentExtractionFailure`.
129
- *
130
- * Designed to be dispatched from both the manual create page and a
131
- * future AI CFO composer/upload surface — selectors return a single
132
- * source of truth.
133
- */
134
- extractPolicyDocument: {
135
- reducer(draft, action) {
136
- draft.policyDocumentExtraction.fetchState = 'In-Progress';
137
- draft.policyDocumentExtraction.error = undefined;
138
- draft.policyDocumentExtraction.extractedRules = undefined;
139
- draft.policyDocumentExtraction.uploadedFileName =
140
- action.meta.uploadedFileName;
141
- draft.policyDocumentExtraction.aiCfoAnswerId =
142
- action.payload.aiCfoAnswerId;
143
- draft.policyDocumentExtraction.aiCfoChatSessionId =
144
- action.payload.aiCfoChatSessionId;
145
- },
146
- prepare(files, aiCfoAnswerId, aiCfoChatSessionId) {
147
- return {
148
- payload: { files, aiCfoAnswerId, aiCfoChatSessionId },
149
- meta: { uploadedFileName: files[0]?.name },
150
- };
151
- },
152
- },
153
- updatePolicyDocumentExtractionSuccess(draft, action) {
154
- draft.policyDocumentExtraction.fetchState = 'Completed';
155
- draft.policyDocumentExtraction.error = undefined;
156
- draft.policyDocumentExtraction.extractedRules =
157
- (0, cardPolicyPayload_1.toExtractedCardPolicyRules)(action.payload);
158
- },
159
- updatePolicyDocumentExtractionFailure(draft, action) {
160
- draft.policyDocumentExtraction.fetchState = 'Error';
161
- draft.policyDocumentExtraction.error = action.payload;
162
- draft.policyDocumentExtraction.extractedRules = undefined;
163
- },
164
- clearPolicyDocumentExtraction(draft) {
165
- draft.policyDocumentExtraction = {
166
- ...initialPolicyDocumentExtractionState,
167
- };
168
- // Clear the chained recommendation slice too — the two together
169
- // model the upload lifecycle and either both reset (× pill,
170
- // unmount) or both advance (drop file → extract → recommend).
171
- draft.policyRecommendationFromUpload = {
172
- ...initialPolicyRecommendationFromUploadState,
173
- };
174
- },
175
- /**
176
- * Kick off `POST /cards/1.0/ai-cfo/policy-recommendation-from-upload`.
177
- *
178
- * Chained after `extractPolicyDocument` succeeds in the AI CFO
179
- * `upload`-mode flow. The accompanying epic forwards the
180
- * just-returned `extracted_rules` to the BE and dispatches success /
181
- * failure into this slice; on success, a sibling action
182
- * (`updateAiCfoAnswerCardPolicyWizardPlan` on the aiCfo slice) is
183
- * dispatched by the epic to merge the returned `wizard_plan` + `source`
184
- * into the in-flight AI CFO answer's `CardPolicyInitialData`.
185
- *
186
- * `answerId` + `chatSessionId` identify which AI CFO answer should
187
- * receive the patch. Both are required so the wizard reads a single
188
- * source of truth for its lifecycle pill (`fetchState`) and the
189
- * bridge epic can correlate against the originating answer.
190
- */
191
- fetchCardPolicyRecommendationFromUpload: {
192
- reducer(draft, action) {
193
- draft.policyRecommendationFromUpload.fetchState = 'In-Progress';
194
- draft.policyRecommendationFromUpload.answerId = action.payload.answerId;
195
- draft.policyRecommendationFromUpload.chatSessionId =
196
- action.payload.chatSessionId;
197
- draft.policyRecommendationFromUpload.error = undefined;
198
- },
199
- prepare(answerId, chatSessionId, extractedRules) {
200
- return { payload: { answerId, chatSessionId, extractedRules } };
201
- },
202
- },
203
- updatePolicyRecommendationFromUploadSuccess(draft) {
204
- draft.policyRecommendationFromUpload.fetchState = 'Completed';
205
- draft.policyRecommendationFromUpload.error = undefined;
206
- },
207
- updatePolicyRecommendationFromUploadFailure(draft, action) {
208
- draft.policyRecommendationFromUpload.fetchState = 'Error';
209
- draft.policyRecommendationFromUpload.error = action.payload;
210
- },
211
- /**
212
- * Kick off `GET /accounting/1.0/vendors` (card-policy mode). When
213
- * `searchString` is empty the BE returns the top vendors sorted by
214
- * year-to-date spend; with a non-empty value it filters server-side.
215
- *
216
- * The accompanying `fetchCardPolicyVendorOptionsEpic` listens for
217
- * this action, builds the `query` JSON (matching `fetchVendorsList`'s
218
- * `view: "vendor_list"` shape) and dispatches success / failure.
219
- *
220
- * Designed to be dispatched from both the manual `CardPolicyCreate /
221
- * EditScreen` (on mount + on every chip-picker keystroke, debounced)
222
- * and the AI CFO interactive form's vendor step.
223
- */
224
- fetchCardPolicyVendorOptions: {
225
- reducer(draft, action) {
226
- draft.vendorSearch.fetchState = 'In-Progress';
227
- draft.vendorSearch.searchString = action.payload.searchString;
228
- draft.vendorSearch.error = undefined;
229
- },
230
- prepare(searchString) {
231
- return { payload: { searchString: searchString ?? '' } };
232
- },
233
- },
234
- updateCardPolicyVendorOptions(draft, action) {
235
- // Drop rows with no usable name. The chip-picker keys vendors by
236
- // `buildVendorChipId(name)` (in @zeniai/web-components), which calls
237
- // `name.trim().toLowerCase()`. A null / undefined / whitespace-only
238
- // name would either throw at render time or collapse every nameless
239
- // row into a single colliding `vendor-` chip-id.
240
- draft.vendorSearch.vendors = (action.payload.vendors ?? [])
241
- .map(cardPolicyPayload_1.toCardPolicyVendorSearchOption)
242
- .filter((vendor) => isUsableMerchantName(vendor.name));
243
- draft.vendorSearch.fetchState = 'Completed';
244
- draft.vendorSearch.error = undefined;
245
- },
246
- updateCardPolicyVendorOptionsFailure(draft, action) {
247
- draft.vendorSearch.fetchState = 'Error';
248
- draft.vendorSearch.error = action.payload;
249
- },
250
- clearCardPolicy(draft) {
251
- Object.assign(draft, exports.initialState);
252
- },
253
- },
254
- });
255
- _a = cardPolicy.actions, exports.fetchCardPolicyMccCategories = _a.fetchCardPolicyMccCategories, exports.fetchCardPolicyVendorOptions = _a.fetchCardPolicyVendorOptions, exports.updateCardPolicyMccCategories = _a.updateCardPolicyMccCategories, exports.updateCardPolicyMccCategoriesFailure = _a.updateCardPolicyMccCategoriesFailure, exports.updateCardPolicyVendorOptions = _a.updateCardPolicyVendorOptions, exports.updateCardPolicyVendorOptionsFailure = _a.updateCardPolicyVendorOptionsFailure, exports.updateCreatedCardPolicyTemplate = _a.updateCreatedCardPolicyTemplate, exports.updateCardPolicyTemplates = _a.updateCardPolicyTemplates, exports.removeCardPolicyTemplate = _a.removeCardPolicyTemplate, exports.updateCardPolicyStats = _a.updateCardPolicyStats, exports.extractPolicyDocument = _a.extractPolicyDocument, exports.updatePolicyDocumentExtractionSuccess = _a.updatePolicyDocumentExtractionSuccess, exports.updatePolicyDocumentExtractionFailure = _a.updatePolicyDocumentExtractionFailure, exports.clearPolicyDocumentExtraction = _a.clearPolicyDocumentExtraction, exports.fetchCardPolicyRecommendationFromUpload = _a.fetchCardPolicyRecommendationFromUpload, exports.updatePolicyRecommendationFromUploadSuccess = _a.updatePolicyRecommendationFromUploadSuccess, exports.updatePolicyRecommendationFromUploadFailure = _a.updatePolicyRecommendationFromUploadFailure, exports.clearCardPolicy = _a.clearCardPolicy;
256
- exports.default = cardPolicy.reducer;
@@ -1,32 +0,0 @@
1
- import { FetchState, ID } from '../../commonStateTypes/common';
2
- import { ZeniAPIStatus } from '../../responsePayload';
3
- import { CardPolicyState, CardPolicyStats, CardPolicyTemplate, CardPolicyVendorSearchEntry, ExtractedCardPolicyRules, MccCategory } from './cardPolicyState';
4
- export declare function getCardPolicyMccCategories(state: CardPolicyState): MccCategory[];
5
- export declare function getCardPolicyMccCategoriesFetchState(state: CardPolicyState): FetchState;
6
- export declare function getCardPolicyMccCategoriesError(state: CardPolicyState): ZeniAPIStatus | undefined;
7
- export declare function getCardPolicyTemplateById(state: CardPolicyState, templateId: ID): CardPolicyTemplate | undefined;
8
- export declare function getAllCardPolicyTemplates(state: CardPolicyState): CardPolicyTemplate[];
9
- /**
10
- * Resolve an ordered list of `templateId`s against the entity store and
11
- * return the corresponding `CardPolicyTemplate[]` in the same order.
12
- * Missing IDs (e.g. stale local state during a refetch) are silently
13
- * dropped. Pair with `getCardPolicyTemplateIds` from the view slice to
14
- * render the Policy List page in server order.
15
- */
16
- export declare function getCardPolicyTemplatesByIds(state: CardPolicyState, templateIds: ID[]): CardPolicyTemplate[];
17
- export declare function getCardPolicyStats(state: CardPolicyState): CardPolicyStats | undefined;
18
- export declare function getPolicyDocumentExtractionFetchState(state: CardPolicyState): FetchState;
19
- export declare function getPolicyDocumentExtractionError(state: CardPolicyState): ZeniAPIStatus | undefined;
20
- export declare function getExtractedCardPolicyRules(state: CardPolicyState): ExtractedCardPolicyRules | undefined;
21
- export declare function getUploadedPolicyDocumentFileName(state: CardPolicyState): string | undefined;
22
- export declare function getPolicyRecommendationFromUploadFetchState(state: CardPolicyState): FetchState;
23
- export declare function getPolicyRecommendationFromUploadError(state: CardPolicyState): ZeniAPIStatus | undefined;
24
- export declare function getPolicyRecommendationFromUploadAnswerId(state: CardPolicyState): ID | undefined;
25
- export declare function getPolicyRecommendationFromUploadChatSessionId(state: CardPolicyState): ID | undefined;
26
- export declare function getCardPolicySuggestedAllowMerchants(state: CardPolicyState): string[];
27
- export declare function getCardPolicySuggestedBlockMerchants(state: CardPolicyState): string[];
28
- export declare function getCardPolicySuggestedAllowCategories(state: CardPolicyState): MccCategory[];
29
- export declare function getCardPolicySuggestedBlockCategories(state: CardPolicyState): MccCategory[];
30
- export declare function getCardPolicyVendorSearchOptions(state: CardPolicyState): CardPolicyVendorSearchEntry[];
31
- export declare function getCardPolicyVendorSearchFetchState(state: CardPolicyState): FetchState;
32
- export declare function getCardPolicyVendorSearchString(state: CardPolicyState): string;
@@ -1,103 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getCardPolicyMccCategories = getCardPolicyMccCategories;
4
- exports.getCardPolicyMccCategoriesFetchState = getCardPolicyMccCategoriesFetchState;
5
- exports.getCardPolicyMccCategoriesError = getCardPolicyMccCategoriesError;
6
- exports.getCardPolicyTemplateById = getCardPolicyTemplateById;
7
- exports.getAllCardPolicyTemplates = getAllCardPolicyTemplates;
8
- exports.getCardPolicyTemplatesByIds = getCardPolicyTemplatesByIds;
9
- exports.getCardPolicyStats = getCardPolicyStats;
10
- exports.getPolicyDocumentExtractionFetchState = getPolicyDocumentExtractionFetchState;
11
- exports.getPolicyDocumentExtractionError = getPolicyDocumentExtractionError;
12
- exports.getExtractedCardPolicyRules = getExtractedCardPolicyRules;
13
- exports.getUploadedPolicyDocumentFileName = getUploadedPolicyDocumentFileName;
14
- exports.getPolicyRecommendationFromUploadFetchState = getPolicyRecommendationFromUploadFetchState;
15
- exports.getPolicyRecommendationFromUploadError = getPolicyRecommendationFromUploadError;
16
- exports.getPolicyRecommendationFromUploadAnswerId = getPolicyRecommendationFromUploadAnswerId;
17
- exports.getPolicyRecommendationFromUploadChatSessionId = getPolicyRecommendationFromUploadChatSessionId;
18
- exports.getCardPolicySuggestedAllowMerchants = getCardPolicySuggestedAllowMerchants;
19
- exports.getCardPolicySuggestedBlockMerchants = getCardPolicySuggestedBlockMerchants;
20
- exports.getCardPolicySuggestedAllowCategories = getCardPolicySuggestedAllowCategories;
21
- exports.getCardPolicySuggestedBlockCategories = getCardPolicySuggestedBlockCategories;
22
- exports.getCardPolicyVendorSearchOptions = getCardPolicyVendorSearchOptions;
23
- exports.getCardPolicyVendorSearchFetchState = getCardPolicyVendorSearchFetchState;
24
- exports.getCardPolicyVendorSearchString = getCardPolicyVendorSearchString;
25
- function getCardPolicyMccCategories(state) {
26
- return state.mccCategories;
27
- }
28
- function getCardPolicyMccCategoriesFetchState(state) {
29
- return state.mccCategoriesFetchState;
30
- }
31
- function getCardPolicyMccCategoriesError(state) {
32
- return state.mccCategoriesError;
33
- }
34
- function getCardPolicyTemplateById(state, templateId) {
35
- return state.cardPolicyTemplateById[templateId];
36
- }
37
- function getAllCardPolicyTemplates(state) {
38
- return Object.values(state.cardPolicyTemplateById);
39
- }
40
- /**
41
- * Resolve an ordered list of `templateId`s against the entity store and
42
- * return the corresponding `CardPolicyTemplate[]` in the same order.
43
- * Missing IDs (e.g. stale local state during a refetch) are silently
44
- * dropped. Pair with `getCardPolicyTemplateIds` from the view slice to
45
- * render the Policy List page in server order.
46
- */
47
- function getCardPolicyTemplatesByIds(state, templateIds) {
48
- return templateIds
49
- .map((id) => state.cardPolicyTemplateById[id])
50
- .filter((template) => template != null);
51
- }
52
- function getCardPolicyStats(state) {
53
- return state.cardPolicyStats;
54
- }
55
- // ── Policy document extraction ───────────────────────────────────────
56
- function getPolicyDocumentExtractionFetchState(state) {
57
- return state.policyDocumentExtraction.fetchState;
58
- }
59
- function getPolicyDocumentExtractionError(state) {
60
- return state.policyDocumentExtraction.error;
61
- }
62
- function getExtractedCardPolicyRules(state) {
63
- return state.policyDocumentExtraction.extractedRules;
64
- }
65
- function getUploadedPolicyDocumentFileName(state) {
66
- return state.policyDocumentExtraction.uploadedFileName;
67
- }
68
- // ── Policy recommendation from upload (AI CFO upload mode) ───────────
69
- function getPolicyRecommendationFromUploadFetchState(state) {
70
- return state.policyRecommendationFromUpload.fetchState;
71
- }
72
- function getPolicyRecommendationFromUploadError(state) {
73
- return state.policyRecommendationFromUpload.error;
74
- }
75
- function getPolicyRecommendationFromUploadAnswerId(state) {
76
- return state.policyRecommendationFromUpload.answerId;
77
- }
78
- function getPolicyRecommendationFromUploadChatSessionId(state) {
79
- return state.policyRecommendationFromUpload.chatSessionId;
80
- }
81
- // ── Suggested allow / block seeds (shipped alongside MCC categories) ─
82
- function getCardPolicySuggestedAllowMerchants(state) {
83
- return state.suggestedAllowMerchants;
84
- }
85
- function getCardPolicySuggestedBlockMerchants(state) {
86
- return state.suggestedBlockMerchants;
87
- }
88
- function getCardPolicySuggestedAllowCategories(state) {
89
- return state.suggestedAllowCategories;
90
- }
91
- function getCardPolicySuggestedBlockCategories(state) {
92
- return state.suggestedBlockCategories;
93
- }
94
- // ── Vendor search dropdown ───────────────────────────────────────────
95
- function getCardPolicyVendorSearchOptions(state) {
96
- return state.vendorSearch.vendors;
97
- }
98
- function getCardPolicyVendorSearchFetchState(state) {
99
- return state.vendorSearch.fetchState;
100
- }
101
- function getCardPolicyVendorSearchString(state) {
102
- return state.vendorSearch.searchString;
103
- }