@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.
- package/lib/entity/aiCfo/aiCfoPayload.d.ts +135 -1
- package/lib/entity/aiCfo/aiCfoReducer.js +111 -2
- package/lib/entity/aiCfo/aiCfoState.d.ts +141 -4
- package/lib/entity/aiCfo/aiCfoState.js +10 -1
- package/lib/entity/cardPolicy/cardPolicyPayload.d.ts +171 -0
- package/lib/entity/cardPolicy/cardPolicyPayload.js +112 -0
- package/lib/entity/cardPolicy/cardPolicyReducer.d.ts +13 -0
- package/lib/entity/cardPolicy/cardPolicyReducer.js +184 -0
- package/lib/entity/cardPolicy/cardPolicySelector.d.ts +28 -0
- package/lib/entity/cardPolicy/cardPolicySelector.js +86 -0
- package/lib/entity/cardPolicy/cardPolicyState.d.ts +162 -0
- package/lib/entity/cardPolicy/cardPolicyState.js +14 -0
- package/lib/entity/cardPolicy/extractPolicyDocumentEpic.d.ts +18 -0
- package/lib/entity/cardPolicy/extractPolicyDocumentEpic.js +54 -0
- package/lib/entity/cardPolicy/fetchCardPolicyVendorOptionsEpic.d.ts +26 -0
- package/lib/entity/cardPolicy/fetchCardPolicyVendorOptionsEpic.js +47 -0
- package/lib/entity/tenant/clearAllEpic.d.ts +6 -2
- package/lib/entity/tenant/clearAllEpic.js +8 -0
- package/lib/epic.d.ts +9 -2
- package/lib/epic.js +9 -2
- package/lib/esm/entity/aiCfo/aiCfoReducer.js +112 -3
- package/lib/esm/entity/aiCfo/aiCfoState.js +7 -0
- package/lib/esm/entity/cardPolicy/cardPolicyPayload.js +101 -0
- package/lib/esm/entity/cardPolicy/cardPolicyReducer.js +180 -0
- package/lib/esm/entity/cardPolicy/cardPolicySelector.js +66 -0
- package/lib/esm/entity/cardPolicy/cardPolicyState.js +9 -0
- package/lib/esm/entity/cardPolicy/extractPolicyDocumentEpic.js +50 -0
- package/lib/esm/entity/cardPolicy/fetchCardPolicyVendorOptionsEpic.js +43 -0
- package/lib/esm/entity/tenant/clearAllEpic.js +8 -0
- package/lib/esm/epic.js +9 -2
- package/lib/esm/index.js +21 -7
- package/lib/esm/reducer.js +12 -0
- package/lib/esm/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.js +1 -21
- package/lib/esm/view/expenseAutomationView/reducers/transactionsViewReducer.js +14 -117
- package/lib/esm/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +0 -28
- package/lib/esm/view/recommendation/recommendationHelper.js +0 -29
- package/lib/esm/view/recommendation/recommendationReducer.js +1 -36
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailReducer.js +70 -0
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailSelector.js +22 -0
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailState.js +1 -0
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/fetchCardPolicyDetailEpic.js +44 -0
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/updateCardPolicyEpic.js +49 -0
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/archiveCardPolicyEpic.js +42 -0
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListReducer.js +72 -0
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListSelector.js +21 -0
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListState.js +1 -0
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/fetchCardPolicyListEpic.js +46 -0
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyReducer.js +50 -0
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicySelector.js +6 -0
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyState.js +1 -0
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyTemplateEpic.js +34 -0
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/fetchCardPolicyMccCategoriesEpic.js +17 -0
- package/lib/esm/view/transactionDetail/transactionDetailReducer.js +1 -94
- package/lib/esm/view/transactionDetail/transactionDetailSelector.js +0 -22
- package/lib/index.d.ts +20 -8
- package/lib/index.js +119 -35
- package/lib/reducer.d.ts +12 -0
- package/lib/reducer.js +12 -0
- package/lib/view/companyHealthMetricView/companyHealthMetricViewSelector.d.ts +1 -1
- package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +0 -1
- package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.js +2 -23
- package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +1 -14
- package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.js +14 -117
- package/lib/view/expenseAutomationView/selectorTypes/transactionsViewSelectorTypes.d.ts +0 -2
- package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.d.ts +0 -3
- package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +0 -29
- package/lib/view/expenseAutomationView/types/transactionsViewState.d.ts +0 -1
- package/lib/view/onboardingView/cockpitView/types/onboardingCockpitViewTypes.d.ts +1 -1
- package/lib/view/people/peopleTypes.d.ts +1 -1
- package/lib/view/recommendation/recommendationHelper.d.ts +0 -9
- package/lib/view/recommendation/recommendationHelper.js +1 -31
- package/lib/view/recommendation/recommendationReducer.d.ts +1 -18
- package/lib/view/recommendation/recommendationReducer.js +2 -37
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailReducer.d.ts +14 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailReducer.js +74 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailSelector.d.ts +21 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailSelector.js +28 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailState.d.ts +25 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailState.js +2 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/fetchCardPolicyDetailEpic.d.ts +19 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/fetchCardPolicyDetailEpic.js +48 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/updateCardPolicyEpic.d.ts +18 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/updateCardPolicyEpic.js +53 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/archiveCardPolicyEpic.d.ts +16 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/archiveCardPolicyEpic.js +46 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListReducer.d.ts +15 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListReducer.js +76 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListSelector.d.ts +21 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListSelector.js +27 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListState.d.ts +19 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListState.js +2 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/fetchCardPolicyListEpic.d.ts +19 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/fetchCardPolicyListEpic.js +50 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyReducer.d.ts +12 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyReducer.js +54 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicySelector.d.ts +4 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicySelector.js +10 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyState.d.ts +15 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyState.js +2 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyTemplateEpic.d.ts +8 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyTemplateEpic.js +38 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/fetchCardPolicyMccCategoriesEpic.d.ts +15 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/fetchCardPolicyMccCategoriesEpic.js +21 -0
- package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardList.d.ts +1 -1
- package/lib/view/taskManager/taskListView/taskListReducer.d.ts +1 -1
- package/lib/view/transactionDetail/transactionDetailReducer.d.ts +1 -11
- package/lib/view/transactionDetail/transactionDetailReducer.js +2 -95
- package/lib/view/transactionDetail/transactionDetailSelector.d.ts +0 -2
- package/lib/view/transactionDetail/transactionDetailSelector.js +1 -24
- package/lib/view/transactionDetail/transactionDetailTypes.d.ts +0 -1
- package/package.json +1 -1
- package/lib/esm/view/recommendation/fetchEntityRecommendationsForLineUpdateEpic.js +0 -78
- package/lib/tsconfig.typecheck.tsbuildinfo +0 -1
- package/lib/view/recommendation/fetchEntityRecommendationsForLineUpdateEpic.d.ts +0 -9
- package/lib/view/recommendation/fetchEntityRecommendationsForLineUpdateEpic.js +0 -82
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toExtractedCardPolicyRules = exports.toCardPolicyEditFormDraft = exports.toUpdateCardPolicyTemplateRequestBody = 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.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 camelCase create request into the snake_case wire body.
|
|
52
|
+
* Used by the epic at request time.
|
|
53
|
+
*/
|
|
54
|
+
const toCreateCardPolicyTemplateRequestBody = (request) => ({
|
|
55
|
+
allowed_entity: {
|
|
56
|
+
category_codes: request.allowedEntity.categoryCodes,
|
|
57
|
+
merchant_names: request.allowedEntity.merchantNames,
|
|
58
|
+
},
|
|
59
|
+
apply_to_cards: request.applyToCards,
|
|
60
|
+
blocked_entity: {
|
|
61
|
+
category_codes: request.blockedEntity.categoryCodes,
|
|
62
|
+
merchant_names: request.blockedEntity.merchantNames,
|
|
63
|
+
},
|
|
64
|
+
description: request.description,
|
|
65
|
+
mode: request.mode ?? 'strict',
|
|
66
|
+
name: request.name,
|
|
67
|
+
required_receipt_threshold: request.requiredReceiptThreshold,
|
|
68
|
+
spend_limits: {
|
|
69
|
+
transaction: request.spendLimits.transaction,
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
exports.toCreateCardPolicyTemplateRequestBody = toCreateCardPolicyTemplateRequestBody;
|
|
73
|
+
// Update body uses the exact same wire shape as create — the PUT
|
|
74
|
+
// endpoint is a full replace.
|
|
75
|
+
exports.toUpdateCardPolicyTemplateRequestBody = exports.toCreateCardPolicyTemplateRequestBody;
|
|
76
|
+
/**
|
|
77
|
+
* Seed an edit-form draft (`CreateCardPolicyTemplateRequest`) from an
|
|
78
|
+
* existing camelCased `CardPolicyTemplate`. Used by the detail-fetch
|
|
79
|
+
* epic so the edit page can render with the saved values pre-populated.
|
|
80
|
+
*/
|
|
81
|
+
const toCardPolicyEditFormDraft = (template) => ({
|
|
82
|
+
allowedEntity: {
|
|
83
|
+
categoryCodes: [...template.allowedEntity.categoryCodes],
|
|
84
|
+
merchantNames: [...template.allowedEntity.merchantNames],
|
|
85
|
+
},
|
|
86
|
+
applyToCards: [...template.appliedCards],
|
|
87
|
+
blockedEntity: {
|
|
88
|
+
categoryCodes: [...template.blockedEntity.categoryCodes],
|
|
89
|
+
merchantNames: [...template.blockedEntity.merchantNames],
|
|
90
|
+
},
|
|
91
|
+
description: template.description,
|
|
92
|
+
mode: template.mode,
|
|
93
|
+
name: template.name,
|
|
94
|
+
requiredReceiptThreshold: template.requiredReceiptThreshold,
|
|
95
|
+
spendLimits: { transaction: template.spendLimits.transaction },
|
|
96
|
+
});
|
|
97
|
+
exports.toCardPolicyEditFormDraft = toCardPolicyEditFormDraft;
|
|
98
|
+
const toExtractedCardPolicyRules = (payload) => ({
|
|
99
|
+
allowedEntity: {
|
|
100
|
+
categoryCodes: payload.allowed_entity?.category_codes ?? [],
|
|
101
|
+
merchantNames: payload.allowed_entity?.merchant_names ?? [],
|
|
102
|
+
},
|
|
103
|
+
blockedEntity: {
|
|
104
|
+
categoryCodes: payload.blocked_entity?.category_codes ?? [],
|
|
105
|
+
merchantNames: payload.blocked_entity?.merchant_names ?? [],
|
|
106
|
+
},
|
|
107
|
+
confidenceScore: payload.confidence_score,
|
|
108
|
+
policyName: payload.policy_name,
|
|
109
|
+
requiredReceiptThreshold: payload.required_receipt_threshold,
|
|
110
|
+
transactionLimit: payload.transaction_limit,
|
|
111
|
+
});
|
|
112
|
+
exports.toExtractedCardPolicyRules = toExtractedCardPolicyRules;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ZeniAPIStatus } from '../../responsePayload';
|
|
2
|
+
import { CardPolicyMccCategoriesPayload, CardPolicyTemplatePayload, CardPolicyVendorSearchData, ExtractedCardPolicyRulesPayload } from './cardPolicyPayload';
|
|
3
|
+
import { CardPolicyState, CardPolicyStats, CardPolicyTemplate } 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[]], {
|
|
8
|
+
files: File[];
|
|
9
|
+
}, "cardPolicy/extractPolicyDocument", never, {
|
|
10
|
+
uploadedFileName: string;
|
|
11
|
+
}>, 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">, clearCardPolicy: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"cardPolicy/clearCardPolicy">;
|
|
12
|
+
declare const _default: import("redux").Reducer<CardPolicyState>;
|
|
13
|
+
export default _default;
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.clearCardPolicy = 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
|
+
const initialPolicyDocumentExtractionState = {
|
|
8
|
+
fetchState: 'Not-Started',
|
|
9
|
+
error: undefined,
|
|
10
|
+
extractedRules: undefined,
|
|
11
|
+
uploadedFileName: undefined,
|
|
12
|
+
};
|
|
13
|
+
const initialVendorSearchState = {
|
|
14
|
+
fetchState: 'Not-Started',
|
|
15
|
+
searchString: '',
|
|
16
|
+
vendors: [],
|
|
17
|
+
error: undefined,
|
|
18
|
+
};
|
|
19
|
+
exports.initialState = {
|
|
20
|
+
cardPolicyTemplateById: {},
|
|
21
|
+
mccCategories: [],
|
|
22
|
+
mccCategoriesError: undefined,
|
|
23
|
+
mccCategoriesFetchState: 'Not-Started',
|
|
24
|
+
policyDocumentExtraction: initialPolicyDocumentExtractionState,
|
|
25
|
+
suggestedAllowCategories: [],
|
|
26
|
+
suggestedAllowMerchants: [],
|
|
27
|
+
suggestedBlockCategories: [],
|
|
28
|
+
suggestedBlockMerchants: [],
|
|
29
|
+
vendorSearch: initialVendorSearchState,
|
|
30
|
+
cardPolicyStats: undefined,
|
|
31
|
+
};
|
|
32
|
+
const cardPolicy = (0, toolkit_1.createSlice)({
|
|
33
|
+
name: 'cardPolicy',
|
|
34
|
+
initialState: exports.initialState,
|
|
35
|
+
reducers: {
|
|
36
|
+
fetchCardPolicyMccCategories(draft) {
|
|
37
|
+
draft.mccCategoriesFetchState = 'In-Progress';
|
|
38
|
+
draft.mccCategoriesError = undefined;
|
|
39
|
+
},
|
|
40
|
+
updateCardPolicyMccCategories(draft, action) {
|
|
41
|
+
draft.mccCategories = (action.payload.categories ?? []).map(cardPolicyPayload_1.toMccCategory);
|
|
42
|
+
// Persist BE-suggested allow / block seeds alongside the universe.
|
|
43
|
+
// Both flows (manual create page + AI CFO interactive form) read
|
|
44
|
+
// these to pre-populate the chip cloud body before the user edits.
|
|
45
|
+
draft.suggestedAllowMerchants =
|
|
46
|
+
action.payload.suggested_allow_merchants ?? [];
|
|
47
|
+
draft.suggestedBlockMerchants =
|
|
48
|
+
action.payload.suggested_block_merchants ?? [];
|
|
49
|
+
draft.suggestedAllowCategories = (action.payload.suggested_allow_catagories ?? []).map(cardPolicyPayload_1.toMccCategory);
|
|
50
|
+
draft.suggestedBlockCategories = (action.payload.suggested_block_catagories ?? []).map(cardPolicyPayload_1.toMccCategory);
|
|
51
|
+
draft.mccCategoriesFetchState = 'Completed';
|
|
52
|
+
draft.mccCategoriesError = undefined;
|
|
53
|
+
},
|
|
54
|
+
updateCardPolicyMccCategoriesFailure(draft, action) {
|
|
55
|
+
draft.mccCategoriesFetchState = 'Error';
|
|
56
|
+
draft.mccCategoriesError = action.payload;
|
|
57
|
+
},
|
|
58
|
+
/**
|
|
59
|
+
* Store a newly-created (or refreshed) card-policy template keyed by
|
|
60
|
+
* `templateId`. Dispatched by the create / list / get epics; consumed
|
|
61
|
+
* by both manual and AI-CFO policy flows via `getCardPolicyTemplateById`.
|
|
62
|
+
*/
|
|
63
|
+
updateCreatedCardPolicyTemplate(draft, action) {
|
|
64
|
+
const template = (0, cardPolicyPayload_1.toCardPolicyTemplate)(action.payload);
|
|
65
|
+
draft.cardPolicyTemplateById[template.templateId] = template;
|
|
66
|
+
},
|
|
67
|
+
/**
|
|
68
|
+
* Replace the entity store's `cardPolicyTemplateById` map with the
|
|
69
|
+
* full list returned by the templates-list endpoint. Full replace is
|
|
70
|
+
* intentional — templates that no longer exist on the server should be
|
|
71
|
+
* dropped from local state too. The view slice keeps the server-order
|
|
72
|
+
* ID list separately for stable list rendering.
|
|
73
|
+
*/
|
|
74
|
+
updateCardPolicyTemplates(draft, action) {
|
|
75
|
+
const byId = {};
|
|
76
|
+
for (const template of action.payload) {
|
|
77
|
+
byId[template.templateId] = template;
|
|
78
|
+
}
|
|
79
|
+
draft.cardPolicyTemplateById = byId;
|
|
80
|
+
},
|
|
81
|
+
/**
|
|
82
|
+
* Drop a single template from the entity map. Dispatched by the
|
|
83
|
+
* archive (DELETE) epic on success; also usable by any future flow
|
|
84
|
+
* that needs to evict a template (e.g. AI-CFO rejection).
|
|
85
|
+
*/
|
|
86
|
+
removeCardPolicyTemplate(draft, action) {
|
|
87
|
+
delete draft.cardPolicyTemplateById[action.payload];
|
|
88
|
+
},
|
|
89
|
+
/**
|
|
90
|
+
* Replace the tenant-wide policy stats. Dispatched alongside
|
|
91
|
+
* `updateCardPolicyTemplates` from the list epic, but lives on the
|
|
92
|
+
* entity slice so any consumer can read it without re-fetching the
|
|
93
|
+
* list.
|
|
94
|
+
*/
|
|
95
|
+
updateCardPolicyStats(draft, action) {
|
|
96
|
+
draft.cardPolicyStats = action.payload;
|
|
97
|
+
},
|
|
98
|
+
/**
|
|
99
|
+
* Kick off the `POST /cards/1.0/policy-documents/extract` request.
|
|
100
|
+
*
|
|
101
|
+
* Synchronously flips the sub-slice to `In-Progress` and captures the
|
|
102
|
+
* first uploaded file's name (used by the manual `CardPolicyCreatePage`
|
|
103
|
+
* to render the "Policy.pdf ×" pill once the request completes) so
|
|
104
|
+
* downstream callers don't have to keep their own file refs.
|
|
105
|
+
*
|
|
106
|
+
* The accompanying `extractPolicyDocumentEpic` listens for this action,
|
|
107
|
+
* POSTs multipart form-data to the cards micro-service, and dispatches
|
|
108
|
+
* either `updatePolicyDocumentExtractionSuccess` or
|
|
109
|
+
* `updatePolicyDocumentExtractionFailure`.
|
|
110
|
+
*
|
|
111
|
+
* Designed to be dispatched from both the manual create page and a
|
|
112
|
+
* future AI CFO composer/upload surface — selectors return a single
|
|
113
|
+
* source of truth.
|
|
114
|
+
*/
|
|
115
|
+
extractPolicyDocument: {
|
|
116
|
+
reducer(draft, action) {
|
|
117
|
+
draft.policyDocumentExtraction.fetchState = 'In-Progress';
|
|
118
|
+
draft.policyDocumentExtraction.error = undefined;
|
|
119
|
+
draft.policyDocumentExtraction.extractedRules = undefined;
|
|
120
|
+
draft.policyDocumentExtraction.uploadedFileName =
|
|
121
|
+
action.meta.uploadedFileName;
|
|
122
|
+
},
|
|
123
|
+
prepare(files) {
|
|
124
|
+
return {
|
|
125
|
+
payload: { files },
|
|
126
|
+
meta: { uploadedFileName: files[0]?.name },
|
|
127
|
+
};
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
updatePolicyDocumentExtractionSuccess(draft, action) {
|
|
131
|
+
draft.policyDocumentExtraction.fetchState = 'Completed';
|
|
132
|
+
draft.policyDocumentExtraction.error = undefined;
|
|
133
|
+
draft.policyDocumentExtraction.extractedRules =
|
|
134
|
+
(0, cardPolicyPayload_1.toExtractedCardPolicyRules)(action.payload);
|
|
135
|
+
},
|
|
136
|
+
updatePolicyDocumentExtractionFailure(draft, action) {
|
|
137
|
+
draft.policyDocumentExtraction.fetchState = 'Error';
|
|
138
|
+
draft.policyDocumentExtraction.error = action.payload;
|
|
139
|
+
draft.policyDocumentExtraction.extractedRules = undefined;
|
|
140
|
+
},
|
|
141
|
+
clearPolicyDocumentExtraction(draft) {
|
|
142
|
+
draft.policyDocumentExtraction = {
|
|
143
|
+
...initialPolicyDocumentExtractionState,
|
|
144
|
+
};
|
|
145
|
+
},
|
|
146
|
+
/**
|
|
147
|
+
* Kick off `GET /accounting/1.0/vendors` (card-policy mode). When
|
|
148
|
+
* `searchString` is empty the BE returns the top vendors sorted by
|
|
149
|
+
* year-to-date spend; with a non-empty value it filters server-side.
|
|
150
|
+
*
|
|
151
|
+
* The accompanying `fetchCardPolicyVendorOptionsEpic` listens for
|
|
152
|
+
* this action, builds the `query` JSON (matching `fetchVendorsList`'s
|
|
153
|
+
* `view: "vendor_list"` shape) and dispatches success / failure.
|
|
154
|
+
*
|
|
155
|
+
* Designed to be dispatched from both the manual `CardPolicyCreate /
|
|
156
|
+
* EditScreen` (on mount + on every chip-picker keystroke, debounced)
|
|
157
|
+
* and the AI CFO interactive form's vendor step.
|
|
158
|
+
*/
|
|
159
|
+
fetchCardPolicyVendorOptions: {
|
|
160
|
+
reducer(draft, action) {
|
|
161
|
+
draft.vendorSearch.fetchState = 'In-Progress';
|
|
162
|
+
draft.vendorSearch.searchString = action.payload.searchString;
|
|
163
|
+
draft.vendorSearch.error = undefined;
|
|
164
|
+
},
|
|
165
|
+
prepare(searchString) {
|
|
166
|
+
return { payload: { searchString: searchString ?? '' } };
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
updateCardPolicyVendorOptions(draft, action) {
|
|
170
|
+
draft.vendorSearch.vendors = (action.payload.vendors ?? []).map(cardPolicyPayload_1.toCardPolicyVendorSearchOption);
|
|
171
|
+
draft.vendorSearch.fetchState = 'Completed';
|
|
172
|
+
draft.vendorSearch.error = undefined;
|
|
173
|
+
},
|
|
174
|
+
updateCardPolicyVendorOptionsFailure(draft, action) {
|
|
175
|
+
draft.vendorSearch.fetchState = 'Error';
|
|
176
|
+
draft.vendorSearch.error = action.payload;
|
|
177
|
+
},
|
|
178
|
+
clearCardPolicy(draft) {
|
|
179
|
+
Object.assign(draft, exports.initialState);
|
|
180
|
+
},
|
|
181
|
+
},
|
|
182
|
+
});
|
|
183
|
+
_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.clearCardPolicy = _a.clearCardPolicy;
|
|
184
|
+
exports.default = cardPolicy.reducer;
|
|
@@ -0,0 +1,28 @@
|
|
|
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 getCardPolicySuggestedAllowMerchants(state: CardPolicyState): string[];
|
|
23
|
+
export declare function getCardPolicySuggestedBlockMerchants(state: CardPolicyState): string[];
|
|
24
|
+
export declare function getCardPolicySuggestedAllowCategories(state: CardPolicyState): MccCategory[];
|
|
25
|
+
export declare function getCardPolicySuggestedBlockCategories(state: CardPolicyState): MccCategory[];
|
|
26
|
+
export declare function getCardPolicyVendorSearchOptions(state: CardPolicyState): CardPolicyVendorSearchEntry[];
|
|
27
|
+
export declare function getCardPolicyVendorSearchFetchState(state: CardPolicyState): FetchState;
|
|
28
|
+
export declare function getCardPolicyVendorSearchString(state: CardPolicyState): string;
|
|
@@ -0,0 +1,86 @@
|
|
|
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.getCardPolicySuggestedAllowMerchants = getCardPolicySuggestedAllowMerchants;
|
|
15
|
+
exports.getCardPolicySuggestedBlockMerchants = getCardPolicySuggestedBlockMerchants;
|
|
16
|
+
exports.getCardPolicySuggestedAllowCategories = getCardPolicySuggestedAllowCategories;
|
|
17
|
+
exports.getCardPolicySuggestedBlockCategories = getCardPolicySuggestedBlockCategories;
|
|
18
|
+
exports.getCardPolicyVendorSearchOptions = getCardPolicyVendorSearchOptions;
|
|
19
|
+
exports.getCardPolicyVendorSearchFetchState = getCardPolicyVendorSearchFetchState;
|
|
20
|
+
exports.getCardPolicyVendorSearchString = getCardPolicyVendorSearchString;
|
|
21
|
+
function getCardPolicyMccCategories(state) {
|
|
22
|
+
return state.mccCategories;
|
|
23
|
+
}
|
|
24
|
+
function getCardPolicyMccCategoriesFetchState(state) {
|
|
25
|
+
return state.mccCategoriesFetchState;
|
|
26
|
+
}
|
|
27
|
+
function getCardPolicyMccCategoriesError(state) {
|
|
28
|
+
return state.mccCategoriesError;
|
|
29
|
+
}
|
|
30
|
+
function getCardPolicyTemplateById(state, templateId) {
|
|
31
|
+
return state.cardPolicyTemplateById[templateId];
|
|
32
|
+
}
|
|
33
|
+
function getAllCardPolicyTemplates(state) {
|
|
34
|
+
return Object.values(state.cardPolicyTemplateById);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Resolve an ordered list of `templateId`s against the entity store and
|
|
38
|
+
* return the corresponding `CardPolicyTemplate[]` in the same order.
|
|
39
|
+
* Missing IDs (e.g. stale local state during a refetch) are silently
|
|
40
|
+
* dropped. Pair with `getCardPolicyTemplateIds` from the view slice to
|
|
41
|
+
* render the Policy List page in server order.
|
|
42
|
+
*/
|
|
43
|
+
function getCardPolicyTemplatesByIds(state, templateIds) {
|
|
44
|
+
return templateIds
|
|
45
|
+
.map((id) => state.cardPolicyTemplateById[id])
|
|
46
|
+
.filter((template) => template != null);
|
|
47
|
+
}
|
|
48
|
+
function getCardPolicyStats(state) {
|
|
49
|
+
return state.cardPolicyStats;
|
|
50
|
+
}
|
|
51
|
+
// ── Policy document extraction ───────────────────────────────────────
|
|
52
|
+
function getPolicyDocumentExtractionFetchState(state) {
|
|
53
|
+
return state.policyDocumentExtraction.fetchState;
|
|
54
|
+
}
|
|
55
|
+
function getPolicyDocumentExtractionError(state) {
|
|
56
|
+
return state.policyDocumentExtraction.error;
|
|
57
|
+
}
|
|
58
|
+
function getExtractedCardPolicyRules(state) {
|
|
59
|
+
return state.policyDocumentExtraction.extractedRules;
|
|
60
|
+
}
|
|
61
|
+
function getUploadedPolicyDocumentFileName(state) {
|
|
62
|
+
return state.policyDocumentExtraction.uploadedFileName;
|
|
63
|
+
}
|
|
64
|
+
// ── Suggested allow / block seeds (shipped alongside MCC categories) ─
|
|
65
|
+
function getCardPolicySuggestedAllowMerchants(state) {
|
|
66
|
+
return state.suggestedAllowMerchants;
|
|
67
|
+
}
|
|
68
|
+
function getCardPolicySuggestedBlockMerchants(state) {
|
|
69
|
+
return state.suggestedBlockMerchants;
|
|
70
|
+
}
|
|
71
|
+
function getCardPolicySuggestedAllowCategories(state) {
|
|
72
|
+
return state.suggestedAllowCategories;
|
|
73
|
+
}
|
|
74
|
+
function getCardPolicySuggestedBlockCategories(state) {
|
|
75
|
+
return state.suggestedBlockCategories;
|
|
76
|
+
}
|
|
77
|
+
// ── Vendor search dropdown ───────────────────────────────────────────
|
|
78
|
+
function getCardPolicyVendorSearchOptions(state) {
|
|
79
|
+
return state.vendorSearch.vendors;
|
|
80
|
+
}
|
|
81
|
+
function getCardPolicyVendorSearchFetchState(state) {
|
|
82
|
+
return state.vendorSearch.fetchState;
|
|
83
|
+
}
|
|
84
|
+
function getCardPolicyVendorSearchString(state) {
|
|
85
|
+
return state.vendorSearch.searchString;
|
|
86
|
+
}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { FetchState, ID } from '../../commonStateTypes/common';
|
|
2
|
+
import { ZeniAPIStatus } from '../../responsePayload';
|
|
3
|
+
import { ZeniDate } from '../../zeniDayJS';
|
|
4
|
+
/**
|
|
5
|
+
* A category grouping merchant category codes (MCCs) used while configuring
|
|
6
|
+
* card policies (e.g. "Apparel", "AC Refrigeration Repair"). The same data
|
|
7
|
+
* is consumed by both the manual policy-creation flow and the AI-CFO-driven
|
|
8
|
+
* flow.
|
|
9
|
+
*/
|
|
10
|
+
export interface MccCategory {
|
|
11
|
+
count: number;
|
|
12
|
+
mccCodes: string[];
|
|
13
|
+
name: string;
|
|
14
|
+
}
|
|
15
|
+
export declare const ALL_CARD_POLICY_TEMPLATE_MODES: readonly ["strict", "flexible"];
|
|
16
|
+
export declare const toCardPolicyTemplateMode: (v: string) => "strict" | "flexible";
|
|
17
|
+
export type CardPolicyTemplateMode = ReturnType<typeof toCardPolicyTemplateMode>;
|
|
18
|
+
export declare const ALL_CARD_POLICY_TEMPLATE_STATUSES: readonly ["active", "inactive", "archived"];
|
|
19
|
+
export declare const toCardPolicyTemplateStatus: (v: string) => "active" | "inactive" | "archived";
|
|
20
|
+
export type CardPolicyTemplateStatus = ReturnType<typeof toCardPolicyTemplateStatus>;
|
|
21
|
+
/**
|
|
22
|
+
* Allow- / block-list pair scoped to a card-policy template. Empty arrays
|
|
23
|
+
* mean "no restrictions on this dimension".
|
|
24
|
+
*/
|
|
25
|
+
export interface CardPolicyTemplateEntityList {
|
|
26
|
+
categoryCodes: string[];
|
|
27
|
+
merchantNames: string[];
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Spend-limit caps configured per template. Only `transaction` is modeled
|
|
31
|
+
* today; additional cadences (e.g. daily, monthly) will be added if/when
|
|
32
|
+
* the backend exposes them.
|
|
33
|
+
*/
|
|
34
|
+
export interface CardPolicyTemplateSpendLimits {
|
|
35
|
+
transaction: number;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Mapped (camelCase) representation of a card-policy template returned by
|
|
39
|
+
* the cards micro-service. Stored on the entity slice keyed by
|
|
40
|
+
* `templateId` so both the manual policy-creation UI and the AI-CFO flow
|
|
41
|
+
* can read it.
|
|
42
|
+
*/
|
|
43
|
+
export interface CardPolicyTemplate {
|
|
44
|
+
allowedEntity: CardPolicyTemplateEntityList;
|
|
45
|
+
appliedCards: ID[];
|
|
46
|
+
blockedEntity: CardPolicyTemplateEntityList;
|
|
47
|
+
cardsCount: number;
|
|
48
|
+
categoryRestrictions: unknown[];
|
|
49
|
+
createdAt: ZeniDate;
|
|
50
|
+
createdBy: ID;
|
|
51
|
+
description: string;
|
|
52
|
+
mode: CardPolicyTemplateMode;
|
|
53
|
+
name: string;
|
|
54
|
+
requiredReceiptThreshold: number;
|
|
55
|
+
spendLimits: CardPolicyTemplateSpendLimits;
|
|
56
|
+
status: CardPolicyTemplateStatus;
|
|
57
|
+
templateId: ID;
|
|
58
|
+
tenantId: ID;
|
|
59
|
+
updatedAt: ZeniDate;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Aggregate counters returned by the list endpoint and reused across
|
|
63
|
+
* any surface that wants to display tenant-wide policy stats without
|
|
64
|
+
* triggering an extra fetch.
|
|
65
|
+
*/
|
|
66
|
+
export interface CardPolicyStats {
|
|
67
|
+
activePolicies: number;
|
|
68
|
+
totalCards: number;
|
|
69
|
+
totalTemplates: number;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* FE-side (camelCase) mirror of the wire payload
|
|
73
|
+
* `ExtractedCardPolicyRulesPayload`. Field names align slice-wise with
|
|
74
|
+
* `CardPolicyTemplate` (`allowedEntity`, `blockedEntity`,
|
|
75
|
+
* `requiredReceiptThreshold`) so the pre-fill mapper consumed by both
|
|
76
|
+
* `CardPolicyCreatePage` (manual) and `CardPolicyInteractiveForm`
|
|
77
|
+
* (AI CFO) can read either shape uniformly.
|
|
78
|
+
*/
|
|
79
|
+
export interface ExtractedCardPolicyRules {
|
|
80
|
+
allowedEntity: CardPolicyTemplateEntityList;
|
|
81
|
+
blockedEntity: CardPolicyTemplateEntityList;
|
|
82
|
+
confidenceScore: number;
|
|
83
|
+
policyName: string;
|
|
84
|
+
requiredReceiptThreshold: number;
|
|
85
|
+
transactionLimit: number;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Lifecycle for the `POST /cards/1.0/policy-documents/extract` request.
|
|
89
|
+
* Lives on the entity slice (rather than a view slice) so both the manual
|
|
90
|
+
* `CardPolicyCreatePage` and the AI CFO `CardPolicyInteractiveForm` can
|
|
91
|
+
* read the extracted rules from a single source of truth.
|
|
92
|
+
*
|
|
93
|
+
* `uploadedFileName` is captured at request-kickoff time so the UI can
|
|
94
|
+
* render the "Policy.pdf ×" pill once the request completes without
|
|
95
|
+
* having to keep a separate local copy of the file.
|
|
96
|
+
*/
|
|
97
|
+
export interface PolicyDocumentExtractionState {
|
|
98
|
+
fetchState: FetchState;
|
|
99
|
+
error?: ZeniAPIStatus;
|
|
100
|
+
extractedRules?: ExtractedCardPolicyRules;
|
|
101
|
+
uploadedFileName?: string;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Lightweight `{vendorId, name}` row stored on the card-policy slice for
|
|
105
|
+
* the chip-picker's vendor search dropdown. Sourced from
|
|
106
|
+
* `/accounting/1.0/vendors` via `fetchCardPolicyVendorOptionsEpic`.
|
|
107
|
+
*
|
|
108
|
+
* Intentionally a subset of the full `Vendor` entity — populating this
|
|
109
|
+
* slice does NOT touch the global `vendor`/`account`/`vendorList`
|
|
110
|
+
* entities, so a card-policy search session never disturbs the user's
|
|
111
|
+
* Vendors-tab list state.
|
|
112
|
+
*/
|
|
113
|
+
export interface CardPolicyVendorSearchEntry {
|
|
114
|
+
name: string;
|
|
115
|
+
vendorId: ID;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Lifecycle for the `GET /accounting/1.0/vendors` (card-policy mode)
|
|
119
|
+
* request. Only one in-flight search at a time; the latest typed search
|
|
120
|
+
* wins (via `switchMap` in the epic). `searchString` is the text that
|
|
121
|
+
* produced `vendors`, useful for stale-result guards in the UI.
|
|
122
|
+
*/
|
|
123
|
+
export interface CardPolicyVendorSearchState {
|
|
124
|
+
fetchState: FetchState;
|
|
125
|
+
searchString: string;
|
|
126
|
+
vendors: CardPolicyVendorSearchEntry[];
|
|
127
|
+
error?: ZeniAPIStatus;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Slice state for card-policy reference data shared across the manual and
|
|
131
|
+
* AI-driven policy-creation flows. Each sub-resource tracks its own
|
|
132
|
+
* `fetchState`/`error` so additional card-policy APIs can be added
|
|
133
|
+
* alongside without coupling.
|
|
134
|
+
*/
|
|
135
|
+
export interface CardPolicyState {
|
|
136
|
+
cardPolicyTemplateById: Record<ID, CardPolicyTemplate>;
|
|
137
|
+
mccCategories: MccCategory[];
|
|
138
|
+
mccCategoriesFetchState: FetchState;
|
|
139
|
+
policyDocumentExtraction: PolicyDocumentExtractionState;
|
|
140
|
+
/**
|
|
141
|
+
* MCC categories suggested by the BE as a default "Allow" seed for the
|
|
142
|
+
* category chip cloud. Empty when the user lands without prior spend
|
|
143
|
+
* history. See `suggested_allow_catagories` on the wire payload.
|
|
144
|
+
*/
|
|
145
|
+
suggestedAllowCategories: MccCategory[];
|
|
146
|
+
/**
|
|
147
|
+
* Merchant names suggested by the BE as a default "Allow" seed for the
|
|
148
|
+
* vendor chip cloud. Empty when the BE has no recommendation. See
|
|
149
|
+
* `suggested_allow_merchants` on the wire payload.
|
|
150
|
+
*/
|
|
151
|
+
suggestedAllowMerchants: string[];
|
|
152
|
+
suggestedBlockCategories: MccCategory[];
|
|
153
|
+
suggestedBlockMerchants: string[];
|
|
154
|
+
/**
|
|
155
|
+
* Server-driven vendor search results powering the chip picker's
|
|
156
|
+
* search dropdown. Distinct from the global vendor entity store so
|
|
157
|
+
* the card-policy flow never disturbs the user's Vendors-tab list.
|
|
158
|
+
*/
|
|
159
|
+
vendorSearch: CardPolicyVendorSearchState;
|
|
160
|
+
cardPolicyStats?: CardPolicyStats;
|
|
161
|
+
mccCategoriesError?: ZeniAPIStatus;
|
|
162
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toCardPolicyTemplateStatus = exports.ALL_CARD_POLICY_TEMPLATE_STATUSES = exports.toCardPolicyTemplateMode = exports.ALL_CARD_POLICY_TEMPLATE_MODES = void 0;
|
|
4
|
+
const stringToUnion_1 = require("../../commonStateTypes/stringToUnion");
|
|
5
|
+
exports.ALL_CARD_POLICY_TEMPLATE_MODES = ['strict', 'flexible'];
|
|
6
|
+
const toCardPolicyTemplateMode = (v) => (0, stringToUnion_1.stringToUnion)(v, exports.ALL_CARD_POLICY_TEMPLATE_MODES);
|
|
7
|
+
exports.toCardPolicyTemplateMode = toCardPolicyTemplateMode;
|
|
8
|
+
exports.ALL_CARD_POLICY_TEMPLATE_STATUSES = [
|
|
9
|
+
'active',
|
|
10
|
+
'inactive',
|
|
11
|
+
'archived',
|
|
12
|
+
];
|
|
13
|
+
const toCardPolicyTemplateStatus = (v) => (0, stringToUnion_1.stringToUnion)(v, exports.ALL_CARD_POLICY_TEMPLATE_STATUSES);
|
|
14
|
+
exports.toCardPolicyTemplateStatus = toCardPolicyTemplateStatus;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { RootState } from '../../reducer';
|
|
4
|
+
import { ZeniAPI } from '../../zeniAPI';
|
|
5
|
+
import { extractPolicyDocument, updatePolicyDocumentExtractionFailure, updatePolicyDocumentExtractionSuccess } from './cardPolicyReducer';
|
|
6
|
+
export type ActionType = ReturnType<typeof extractPolicyDocument> | ReturnType<typeof updatePolicyDocumentExtractionSuccess> | ReturnType<typeof updatePolicyDocumentExtractionFailure>;
|
|
7
|
+
/**
|
|
8
|
+
* Listens for `extractPolicyDocument`, POSTs the file(s) as multipart
|
|
9
|
+
* form-data to the cards micro-service's policy-document extract endpoint,
|
|
10
|
+
* and dispatches success / failure into the entity slice.
|
|
11
|
+
*
|
|
12
|
+
* Consumed by:
|
|
13
|
+
* - Manual `CardPolicyCreatePage` (read result via
|
|
14
|
+
* `getExtractedCardPolicyRules` then pre-fill the RHF form via
|
|
15
|
+
* `applyExtractedPolicyRulesToFormValues` from `@zeniai/web-components`).
|
|
16
|
+
* - (Future) AI CFO upload surface — same action + selector contract.
|
|
17
|
+
*/
|
|
18
|
+
export declare const extractPolicyDocumentEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|