@zeniai/client-epic-state 5.0.83-betaRR3 → 5.0.83-betaRR5
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 +1 -4
- package/lib/entity/aiCfo/aiCfoReducer.js +3 -11
- package/lib/entity/aiCfo/aiCfoState.d.ts +0 -19
- package/lib/entity/aiCfo/aiCfoState.js +1 -8
- package/lib/entity/cardPolicy/policyRecommendationFromUploadEpic.d.ts +3 -2
- package/lib/entity/cardPolicy/policyRecommendationFromUploadEpic.js +3 -2
- package/lib/epic.d.ts +14 -12
- package/lib/epic.js +14 -12
- package/lib/esm/entity/aiCfo/aiCfoReducer.js +4 -12
- package/lib/esm/entity/aiCfo/aiCfoState.js +0 -7
- package/lib/esm/entity/cardPolicy/policyRecommendationFromUploadEpic.js +4 -3
- package/lib/esm/epic.js +14 -12
- package/lib/esm/index.js +14 -3
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/applyAiCardPolicyFormDraftUpdate.js +328 -0
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/applyExtractedPolicyToAiCardPolicyDraft.js +120 -0
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/applyExtractedPolicyToDraftEpic.js +60 -0
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/applyExtractedPolicyToManualCardPolicyDraft.js +118 -0
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/applyUploadPlanToAiCardPolicyDraft.js +33 -0
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/buildAiCardPolicyFormDraftSeed.js +385 -0
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/buildManualCardPolicyFormDraftSeed.js +34 -0
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/cardPolicyChipIds.js +33 -0
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/cardPolicyFormDraftTypes.js +17 -0
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/cardPolicyRequestParts.js +144 -0
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyReducer.js +137 -1
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicySelector.js +18 -0
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/deriveAiPolicyReviewRowsFromInputs.js +148 -0
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/seedAiCardPolicyFormDraftEpic.js +112 -0
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/toBulkCardPolicyTemplateRequestsFromDraft.js +101 -0
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/toCardPolicyTemplateRequestFromDraft.js +71 -0
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/toManualCardPolicyTemplateRequestFromDraft.js +34 -0
- package/lib/esm/view/spendManagement/chargeCards/issueChargeCard/applyAiCardCreationFormDraftUpdate.js +0 -1
- package/lib/esm/view/spendManagement/chargeCards/issueChargeCard/buildAiCardCreationFormDraftSeed.js +13 -6
- package/lib/esm/view/spendManagement/chargeCards/issueChargeCard/deriveAiCardRowsFromTeams.js +1 -3
- package/lib/esm/view/spendManagement/chargeCards/issueChargeCard/toIssueChargeCardLocalDataFromDraft.js +0 -5
- package/lib/index.d.ts +20 -4
- package/lib/index.js +45 -4
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/applyAiCardPolicyFormDraftUpdate.d.ts +38 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/applyAiCardPolicyFormDraftUpdate.js +333 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/applyExtractedPolicyToAiCardPolicyDraft.d.ts +25 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/applyExtractedPolicyToAiCardPolicyDraft.js +124 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/applyExtractedPolicyToDraftEpic.d.ts +28 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/applyExtractedPolicyToDraftEpic.js +64 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/applyExtractedPolicyToManualCardPolicyDraft.d.ts +17 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/applyExtractedPolicyToManualCardPolicyDraft.js +122 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/applyUploadPlanToAiCardPolicyDraft.d.ts +23 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/applyUploadPlanToAiCardPolicyDraft.js +37 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/buildAiCardPolicyFormDraftSeed.d.ts +38 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/buildAiCardPolicyFormDraftSeed.js +391 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/buildManualCardPolicyFormDraftSeed.d.ts +11 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/buildManualCardPolicyFormDraftSeed.js +38 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/cardPolicyChipIds.d.ts +24 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/cardPolicyChipIds.js +40 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/cardPolicyFormDraftTypes.d.ts +253 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/cardPolicyFormDraftTypes.js +21 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/cardPolicyRequestParts.d.ts +66 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/cardPolicyRequestParts.js +151 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyReducer.d.ts +40 -1
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyReducer.js +138 -2
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicySelector.d.ts +15 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicySelector.js +20 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyState.d.ts +28 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/deriveAiPolicyReviewRowsFromInputs.d.ts +30 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/deriveAiPolicyReviewRowsFromInputs.js +152 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/seedAiCardPolicyFormDraftEpic.d.ts +26 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/seedAiCardPolicyFormDraftEpic.js +116 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/toBulkCardPolicyTemplateRequestsFromDraft.d.ts +35 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/toBulkCardPolicyTemplateRequestsFromDraft.js +105 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/toCardPolicyTemplateRequestFromDraft.d.ts +23 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/toCardPolicyTemplateRequestFromDraft.js +75 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/toManualCardPolicyTemplateRequestFromDraft.d.ts +15 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/toManualCardPolicyTemplateRequestFromDraft.js +38 -0
- package/lib/view/spendManagement/chargeCards/issueChargeCard/aiCardCreationFormDraftTypes.d.ts +3 -6
- package/lib/view/spendManagement/chargeCards/issueChargeCard/applyAiCardCreationFormDraftUpdate.js +0 -1
- package/lib/view/spendManagement/chargeCards/issueChargeCard/buildAiCardCreationFormDraftSeed.d.ts +6 -3
- package/lib/view/spendManagement/chargeCards/issueChargeCard/buildAiCardCreationFormDraftSeed.js +13 -6
- package/lib/view/spendManagement/chargeCards/issueChargeCard/deriveAiCardRowsFromTeams.d.ts +1 -4
- package/lib/view/spendManagement/chargeCards/issueChargeCard/deriveAiCardRowsFromTeams.js +1 -3
- package/lib/view/spendManagement/chargeCards/issueChargeCard/toIssueChargeCardLocalDataFromDraft.js +0 -5
- package/package.json +1 -1
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toBulkCardPolicyTemplateRequestsFromDraft = void 0;
|
|
4
|
+
const cardPolicyFormDraftTypes_1 = require("./cardPolicyFormDraftTypes");
|
|
5
|
+
const cardPolicyRequestParts_1 = require("./cardPolicyRequestParts");
|
|
6
|
+
const isSelectedChip = (chip) => chip.isSelected !== false;
|
|
7
|
+
const chipsInGroup = (row, groupId) => {
|
|
8
|
+
const group = row.chipGroups.find((g) => g.id === groupId);
|
|
9
|
+
if (group == null) {
|
|
10
|
+
return [];
|
|
11
|
+
}
|
|
12
|
+
return group.chips.filter(isSelectedChip);
|
|
13
|
+
};
|
|
14
|
+
const collectVendorLabelsFromReviewRow = (row, groupId) => chipsInGroup(row, groupId).map((chip) => chip.label);
|
|
15
|
+
const collectCategoryCodesFromReviewRow = (row, groupId) => chipsInGroup(row, groupId).map((chip) => chip.optionalCode ?? chip.id);
|
|
16
|
+
const collectCardIdsFromReviewRow = (row) => chipsInGroup(row, cardPolicyRequestParts_1.REVIEW_GROUP_IDS.appliedToCards).flatMap((chip) => chip.cardIds ?? []);
|
|
17
|
+
const limitValueFromReviewRow = (row, chipId) => {
|
|
18
|
+
const group = row.chipGroups.find((g) => g.id === cardPolicyRequestParts_1.REVIEW_GROUP_IDS.limits);
|
|
19
|
+
if (group == null) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
const chip = group.chips.find((c) => c.id === chipId && isSelectedChip(c));
|
|
23
|
+
if (chip == null) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
if (chip.optionalCode != null) {
|
|
27
|
+
const parsed = Number(chip.optionalCode);
|
|
28
|
+
return Number.isFinite(parsed) ? parsed : null;
|
|
29
|
+
}
|
|
30
|
+
const labelDigits = chip.label.match(/\d+(?:\.\d+)?/);
|
|
31
|
+
if (labelDigits == null) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
const parsed = Number(labelDigits[0]);
|
|
35
|
+
return Number.isFinite(parsed) ? parsed : null;
|
|
36
|
+
};
|
|
37
|
+
const buildGuidedEntry = (row, draft, guidedMode, description) => ({
|
|
38
|
+
allowedEntity: {
|
|
39
|
+
categoryCodes: (0, cardPolicyRequestParts_1.collectCategoryCodes)(draft.categoryPolicy, 'allow'),
|
|
40
|
+
merchantNames: (0, cardPolicyRequestParts_1.collectMerchantNames)(draft.vendorPolicy, 'allow'),
|
|
41
|
+
},
|
|
42
|
+
applyToCards: draft.cardSelections
|
|
43
|
+
.filter((card) => card.isChecked)
|
|
44
|
+
.map((card) => card.id),
|
|
45
|
+
blockedEntity: {
|
|
46
|
+
categoryCodes: (0, cardPolicyRequestParts_1.collectCategoryCodes)(draft.categoryPolicy, 'block'),
|
|
47
|
+
merchantNames: (0, cardPolicyRequestParts_1.collectMerchantNames)(draft.vendorPolicy, 'block'),
|
|
48
|
+
},
|
|
49
|
+
description: description.trim(),
|
|
50
|
+
mode: guidedMode,
|
|
51
|
+
name: row.name.trim(),
|
|
52
|
+
requiredReceiptThreshold: (0, cardPolicyRequestParts_1.amountFromLimitRow)(draft.limits, cardPolicyFormDraftTypes_1.CARD_POLICY_LIMIT_ROW_ID_REQUIRE_RECEIPT),
|
|
53
|
+
spendLimits: {
|
|
54
|
+
transaction: (0, cardPolicyRequestParts_1.amountFromLimitRow)(draft.limits, cardPolicyFormDraftTypes_1.CARD_POLICY_LIMIT_ROW_ID_TRANSACTION),
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
const buildAutoEntry = (row, description) => ({
|
|
58
|
+
allowedEntity: {
|
|
59
|
+
categoryCodes: collectCategoryCodesFromReviewRow(row, cardPolicyRequestParts_1.REVIEW_GROUP_IDS.allowedCategories),
|
|
60
|
+
merchantNames: collectVendorLabelsFromReviewRow(row, cardPolicyRequestParts_1.REVIEW_GROUP_IDS.allowedVendors),
|
|
61
|
+
},
|
|
62
|
+
applyToCards: collectCardIdsFromReviewRow(row),
|
|
63
|
+
blockedEntity: {
|
|
64
|
+
categoryCodes: collectCategoryCodesFromReviewRow(row, cardPolicyRequestParts_1.REVIEW_GROUP_IDS.restrictedCategories),
|
|
65
|
+
merchantNames: collectVendorLabelsFromReviewRow(row, cardPolicyRequestParts_1.REVIEW_GROUP_IDS.blockedVendors),
|
|
66
|
+
},
|
|
67
|
+
description: description.trim(),
|
|
68
|
+
name: row.name.trim(),
|
|
69
|
+
});
|
|
70
|
+
const buildUploadEntry = (row, draft, description) => ({
|
|
71
|
+
allowedEntity: {
|
|
72
|
+
categoryCodes: collectCategoryCodesFromReviewRow(row, cardPolicyRequestParts_1.REVIEW_GROUP_IDS.allowedCategories),
|
|
73
|
+
merchantNames: collectVendorLabelsFromReviewRow(row, cardPolicyRequestParts_1.REVIEW_GROUP_IDS.allowedVendors),
|
|
74
|
+
},
|
|
75
|
+
applyToCards: draft.cardSelections
|
|
76
|
+
.filter((card) => card.isChecked)
|
|
77
|
+
.map((card) => card.id),
|
|
78
|
+
blockedEntity: {
|
|
79
|
+
categoryCodes: collectCategoryCodesFromReviewRow(row, cardPolicyRequestParts_1.REVIEW_GROUP_IDS.restrictedCategories),
|
|
80
|
+
merchantNames: collectVendorLabelsFromReviewRow(row, cardPolicyRequestParts_1.REVIEW_GROUP_IDS.blockedVendors),
|
|
81
|
+
},
|
|
82
|
+
description: description.trim(),
|
|
83
|
+
name: row.name.trim(),
|
|
84
|
+
requiredReceiptThreshold: limitValueFromReviewRow(row, cardPolicyRequestParts_1.REVIEW_LIMIT_CHIP_IDS.receipt),
|
|
85
|
+
spendLimits: {
|
|
86
|
+
transaction: limitValueFromReviewRow(row, cardPolicyRequestParts_1.REVIEW_LIMIT_CHIP_IDS.transaction),
|
|
87
|
+
},
|
|
88
|
+
});
|
|
89
|
+
/**
|
|
90
|
+
* Build the array of per-row entries for the bulk
|
|
91
|
+
* `createCardPolicyTemplates` action from the AI CFO form draft.
|
|
92
|
+
* Iterates checked review rows and emits one entry per row, with the
|
|
93
|
+
* per-mode key contract enforced internally.
|
|
94
|
+
*/
|
|
95
|
+
const toBulkCardPolicyTemplateRequestsFromDraft = ({ draft, description = '', guidedMode = 'strict', }) => {
|
|
96
|
+
const checkedRows = draft.policiesReview.filter((row) => row.isChecked);
|
|
97
|
+
if (draft.policyKind === 'guided') {
|
|
98
|
+
return checkedRows.map((row) => buildGuidedEntry(row, draft, guidedMode, description));
|
|
99
|
+
}
|
|
100
|
+
if (draft.policyKind === 'upload') {
|
|
101
|
+
return checkedRows.map((row) => buildUploadEntry(row, draft, description));
|
|
102
|
+
}
|
|
103
|
+
return checkedRows.map((row) => buildAutoEntry(row, description));
|
|
104
|
+
};
|
|
105
|
+
exports.toBulkCardPolicyTemplateRequestsFromDraft = toBulkCardPolicyTemplateRequestsFromDraft;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { CreateCardPolicyTemplateRequest } from '../../../../../entity/cardPolicy/cardPolicyPayload';
|
|
2
|
+
import { CardPolicyFormDraft, CardPolicyModeValue } from './cardPolicyFormDraftTypes';
|
|
3
|
+
export interface ToCardPolicyTemplateRequestFromDraftArgs {
|
|
4
|
+
draft: CardPolicyFormDraft;
|
|
5
|
+
description?: string;
|
|
6
|
+
/** Defaults to `"strict"`; only consumed by guided submit. */
|
|
7
|
+
mode?: CardPolicyModeValue;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Map the AI CFO `CardPolicyFormDraft` to the wire-ready
|
|
11
|
+
* `CreateCardPolicyTemplateRequest`. Branches on `draft.policyKind`:
|
|
12
|
+
*
|
|
13
|
+
* - `auto` / `upload`: active review row's chip groups are canonical;
|
|
14
|
+
* project via `projectAutoReviewRowToCardPolicyRequestParts`. Active
|
|
15
|
+
* row = "first checked, fallback to first".
|
|
16
|
+
* - `guided`: source slices are canonical (the
|
|
17
|
+
* `applyAiCardPolicyFormDraftUpdate` reducer mirrors review-chip
|
|
18
|
+
* edits back into them); read directly from the source slices.
|
|
19
|
+
*
|
|
20
|
+
* Name picking: first checked row of `policiesReview`, fallback to the
|
|
21
|
+
* first row, fallback to empty.
|
|
22
|
+
*/
|
|
23
|
+
export declare const toCardPolicyTemplateRequestFromDraft: ({ draft, description, mode, }: ToCardPolicyTemplateRequestFromDraftArgs) => CreateCardPolicyTemplateRequest;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toCardPolicyTemplateRequestFromDraft = void 0;
|
|
4
|
+
const cardPolicyFormDraftTypes_1 = require("./cardPolicyFormDraftTypes");
|
|
5
|
+
const cardPolicyRequestParts_1 = require("./cardPolicyRequestParts");
|
|
6
|
+
/**
|
|
7
|
+
* Map the AI CFO `CardPolicyFormDraft` to the wire-ready
|
|
8
|
+
* `CreateCardPolicyTemplateRequest`. Branches on `draft.policyKind`:
|
|
9
|
+
*
|
|
10
|
+
* - `auto` / `upload`: active review row's chip groups are canonical;
|
|
11
|
+
* project via `projectAutoReviewRowToCardPolicyRequestParts`. Active
|
|
12
|
+
* row = "first checked, fallback to first".
|
|
13
|
+
* - `guided`: source slices are canonical (the
|
|
14
|
+
* `applyAiCardPolicyFormDraftUpdate` reducer mirrors review-chip
|
|
15
|
+
* edits back into them); read directly from the source slices.
|
|
16
|
+
*
|
|
17
|
+
* Name picking: first checked row of `policiesReview`, fallback to the
|
|
18
|
+
* first row, fallback to empty.
|
|
19
|
+
*/
|
|
20
|
+
const toCardPolicyTemplateRequestFromDraft = ({ draft, description = '', mode = 'strict', }) => {
|
|
21
|
+
const name = pickPolicyName(draft);
|
|
22
|
+
const base = {
|
|
23
|
+
description: description.trim(),
|
|
24
|
+
mode,
|
|
25
|
+
name: name.trim(),
|
|
26
|
+
};
|
|
27
|
+
if (draft.policyKind === 'auto' || draft.policyKind === 'upload') {
|
|
28
|
+
const activeRow = draft.policiesReview.find((row) => row.isChecked) ??
|
|
29
|
+
draft.policiesReview[0];
|
|
30
|
+
if (activeRow == null) {
|
|
31
|
+
return {
|
|
32
|
+
...base,
|
|
33
|
+
allowedEntity: { categoryCodes: [], merchantNames: [] },
|
|
34
|
+
applyToCards: [],
|
|
35
|
+
blockedEntity: { categoryCodes: [], merchantNames: [] },
|
|
36
|
+
requiredReceiptThreshold: null,
|
|
37
|
+
spendLimits: { transaction: null },
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
...base,
|
|
42
|
+
...(0, cardPolicyRequestParts_1.projectAutoReviewRowToCardPolicyRequestParts)(activeRow),
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
// Guided
|
|
46
|
+
return {
|
|
47
|
+
...base,
|
|
48
|
+
allowedEntity: {
|
|
49
|
+
categoryCodes: (0, cardPolicyRequestParts_1.collectCategoryCodes)(draft.categoryPolicy, 'allow'),
|
|
50
|
+
merchantNames: (0, cardPolicyRequestParts_1.collectMerchantNames)(draft.vendorPolicy, 'allow'),
|
|
51
|
+
},
|
|
52
|
+
applyToCards: draft.cardSelections
|
|
53
|
+
.filter((row) => row.isChecked)
|
|
54
|
+
.map((row) => row.id),
|
|
55
|
+
blockedEntity: {
|
|
56
|
+
categoryCodes: (0, cardPolicyRequestParts_1.collectCategoryCodes)(draft.categoryPolicy, 'block'),
|
|
57
|
+
merchantNames: (0, cardPolicyRequestParts_1.collectMerchantNames)(draft.vendorPolicy, 'block'),
|
|
58
|
+
},
|
|
59
|
+
requiredReceiptThreshold: (0, cardPolicyRequestParts_1.amountFromLimitRow)(draft.limits, cardPolicyFormDraftTypes_1.CARD_POLICY_LIMIT_ROW_ID_REQUIRE_RECEIPT),
|
|
60
|
+
spendLimits: {
|
|
61
|
+
transaction: (0, cardPolicyRequestParts_1.amountFromLimitRow)(draft.limits, cardPolicyFormDraftTypes_1.CARD_POLICY_LIMIT_ROW_ID_TRANSACTION),
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
exports.toCardPolicyTemplateRequestFromDraft = toCardPolicyTemplateRequestFromDraft;
|
|
66
|
+
const pickPolicyName = (draft) => {
|
|
67
|
+
const checked = draft.policiesReview.find((row) => row.isChecked);
|
|
68
|
+
if (checked != null) {
|
|
69
|
+
return checked.name;
|
|
70
|
+
}
|
|
71
|
+
if (draft.policiesReview.length > 0) {
|
|
72
|
+
return draft.policiesReview[0].name;
|
|
73
|
+
}
|
|
74
|
+
return '';
|
|
75
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CreateCardPolicyTemplateRequest } from '../../../../../entity/cardPolicy/cardPolicyPayload';
|
|
2
|
+
import { CardPolicyCreateFormDraft } from './cardPolicyFormDraftTypes';
|
|
3
|
+
/**
|
|
4
|
+
* Map the manual `CardPolicyCreateFormDraft` onto the wire-ready
|
|
5
|
+
* `CreateCardPolicyTemplateRequest` payload consumed by the
|
|
6
|
+
* `createCardPolicyTemplates` epic.
|
|
7
|
+
*
|
|
8
|
+
* Mirrors the AI guided builder minus the `policiesReview` projection:
|
|
9
|
+
* - `vendorPolicy` / `categoryPolicy` are read directly; `mode` is
|
|
10
|
+
* forwarded from the form.
|
|
11
|
+
* - `applyToCards` is the id list of checked rows in `cardSelections`.
|
|
12
|
+
* - `spendLimits.transaction` / `requiredReceiptThreshold` are `null`
|
|
13
|
+
* when their toggle is off (BE: "not configured").
|
|
14
|
+
*/
|
|
15
|
+
export declare const toManualCardPolicyTemplateRequestFromDraft: (draft: CardPolicyCreateFormDraft) => CreateCardPolicyTemplateRequest;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toManualCardPolicyTemplateRequestFromDraft = void 0;
|
|
4
|
+
const cardPolicyFormDraftTypes_1 = require("./cardPolicyFormDraftTypes");
|
|
5
|
+
const cardPolicyRequestParts_1 = require("./cardPolicyRequestParts");
|
|
6
|
+
/**
|
|
7
|
+
* Map the manual `CardPolicyCreateFormDraft` onto the wire-ready
|
|
8
|
+
* `CreateCardPolicyTemplateRequest` payload consumed by the
|
|
9
|
+
* `createCardPolicyTemplates` epic.
|
|
10
|
+
*
|
|
11
|
+
* Mirrors the AI guided builder minus the `policiesReview` projection:
|
|
12
|
+
* - `vendorPolicy` / `categoryPolicy` are read directly; `mode` is
|
|
13
|
+
* forwarded from the form.
|
|
14
|
+
* - `applyToCards` is the id list of checked rows in `cardSelections`.
|
|
15
|
+
* - `spendLimits.transaction` / `requiredReceiptThreshold` are `null`
|
|
16
|
+
* when their toggle is off (BE: "not configured").
|
|
17
|
+
*/
|
|
18
|
+
const toManualCardPolicyTemplateRequestFromDraft = (draft) => ({
|
|
19
|
+
allowedEntity: {
|
|
20
|
+
categoryCodes: (0, cardPolicyRequestParts_1.collectCategoryCodes)(draft.categoryPolicy, 'allow'),
|
|
21
|
+
merchantNames: (0, cardPolicyRequestParts_1.collectMerchantNames)(draft.vendorPolicy, 'allow'),
|
|
22
|
+
},
|
|
23
|
+
applyToCards: draft.cardSelections
|
|
24
|
+
.filter((row) => row.isChecked)
|
|
25
|
+
.map((row) => row.id),
|
|
26
|
+
blockedEntity: {
|
|
27
|
+
categoryCodes: (0, cardPolicyRequestParts_1.collectCategoryCodes)(draft.categoryPolicy, 'block'),
|
|
28
|
+
merchantNames: (0, cardPolicyRequestParts_1.collectMerchantNames)(draft.vendorPolicy, 'block'),
|
|
29
|
+
},
|
|
30
|
+
description: draft.description.trim(),
|
|
31
|
+
mode: draft.mode,
|
|
32
|
+
name: draft.name.trim(),
|
|
33
|
+
requiredReceiptThreshold: (0, cardPolicyRequestParts_1.amountFromLimitRow)(draft.limits, cardPolicyFormDraftTypes_1.CARD_POLICY_LIMIT_ROW_ID_REQUIRE_RECEIPT),
|
|
34
|
+
spendLimits: {
|
|
35
|
+
transaction: (0, cardPolicyRequestParts_1.amountFromLimitRow)(draft.limits, cardPolicyFormDraftTypes_1.CARD_POLICY_LIMIT_ROW_ID_TRANSACTION),
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
exports.toManualCardPolicyTemplateRequestFromDraft = toManualCardPolicyTemplateRequestFromDraft;
|
package/lib/view/spendManagement/chargeCards/issueChargeCard/aiCardCreationFormDraftTypes.d.ts
CHANGED
|
@@ -9,8 +9,8 @@ import { User } from '../../../../entity/user/userState';
|
|
|
9
9
|
* `IssueChargeCardState.aiCardCreationFormDraft` and emits every
|
|
10
10
|
* change back via `onFormChange` → `updateAiCardCreationFormDraft`.
|
|
11
11
|
*
|
|
12
|
-
* The AI-payload-side types (`CardsCardKind`, `
|
|
13
|
-
* `
|
|
12
|
+
* The AI-payload-side types (`CardsCardKind`, `CardNameOption`,
|
|
13
|
+
* `CardsCreationInitialData`, etc.) are defined on
|
|
14
14
|
* `entity/aiCfo/aiCfoState.ts` and consumed directly from there — this
|
|
15
15
|
* file only declares the FE-side form draft shapes and the companion
|
|
16
16
|
* seed context the reducer keeps for re-derivation.
|
|
@@ -46,12 +46,10 @@ export interface CardsOwnerFieldValue {
|
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
48
48
|
* Step-2 row: the configured card for one of the teams the user kept
|
|
49
|
-
* in step 1.
|
|
50
|
-
* `CardsCreationInitialData.cardOptions`.
|
|
49
|
+
* in step 1.
|
|
51
50
|
*/
|
|
52
51
|
export interface CardsCardRow {
|
|
53
52
|
cardKind: CardsCardKind;
|
|
54
|
-
cardOptionId: string;
|
|
55
53
|
id: string;
|
|
56
54
|
label: string;
|
|
57
55
|
owner: CardsOwnerFieldValue;
|
|
@@ -75,5 +73,4 @@ export interface AiCardCreationFormDraftSeedContext {
|
|
|
75
73
|
allUsers: User[];
|
|
76
74
|
mode: CardsCreationInitialData['mode'];
|
|
77
75
|
suggestedOwnerUserIdByTeamId: Record<ID, string | undefined>;
|
|
78
|
-
defaultCardOptionId?: string;
|
|
79
76
|
}
|
package/lib/view/spendManagement/chargeCards/issueChargeCard/applyAiCardCreationFormDraftUpdate.js
CHANGED
|
@@ -27,7 +27,6 @@ const applyAiCardCreationFormDraftUpdate = ({ next, prev, context, }) => {
|
|
|
27
27
|
teamRows: next.teamRows,
|
|
28
28
|
prevCardRows: next.cardRows,
|
|
29
29
|
allUsers: context.allUsers,
|
|
30
|
-
defaultCardOptionId: context.defaultCardOptionId,
|
|
31
30
|
suggestedOwnerUserIdByTeamId: context.suggestedOwnerUserIdByTeamId,
|
|
32
31
|
}),
|
|
33
32
|
};
|
package/lib/view/spendManagement/chargeCards/issueChargeCard/buildAiCardCreationFormDraftSeed.d.ts
CHANGED
|
@@ -15,9 +15,12 @@ export interface BuildAiCardCreationFormDraftSeedResult {
|
|
|
15
15
|
* reducer.
|
|
16
16
|
*
|
|
17
17
|
* Branches on `initialData.mode`:
|
|
18
|
-
* - `review`: step-1 team rows start fully checked
|
|
19
|
-
*
|
|
20
|
-
*
|
|
18
|
+
* - `review`: step-1 team rows start fully checked and step-2 `cardRows`
|
|
19
|
+
* are seeded by `deriveAiCardRowsFromTeams` so the table is populated
|
|
20
|
+
* on first render. `applyAiCardCreationFormDraftUpdate` only re-derives
|
|
21
|
+
* when a team is toggled in step 1, so without this initial seed the
|
|
22
|
+
* happy path (user proceeds to step 2 without un/re-checking) would
|
|
23
|
+
* land on an empty table.
|
|
21
24
|
* - `create`: no step-1 list — seed `cardRows` directly from the AI's
|
|
22
25
|
* suggested cards (resolving owners via `allUsers`) and leave
|
|
23
26
|
* `teamRows` empty.
|
package/lib/view/spendManagement/chargeCards/issueChargeCard/buildAiCardCreationFormDraftSeed.js
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.buildAiCardCreationFormDraftSeed = void 0;
|
|
4
|
+
const deriveAiCardRowsFromTeams_1 = require("./deriveAiCardRowsFromTeams");
|
|
4
5
|
/**
|
|
5
6
|
* Build the initial `CardsFormDraft` + companion seed context for a
|
|
6
7
|
* fresh AI card-creation session. Used by the `seedAiCardCreationFormDraft`
|
|
7
8
|
* reducer.
|
|
8
9
|
*
|
|
9
10
|
* Branches on `initialData.mode`:
|
|
10
|
-
* - `review`: step-1 team rows start fully checked
|
|
11
|
-
*
|
|
12
|
-
*
|
|
11
|
+
* - `review`: step-1 team rows start fully checked and step-2 `cardRows`
|
|
12
|
+
* are seeded by `deriveAiCardRowsFromTeams` so the table is populated
|
|
13
|
+
* on first render. `applyAiCardCreationFormDraftUpdate` only re-derives
|
|
14
|
+
* when a team is toggled in step 1, so without this initial seed the
|
|
15
|
+
* happy path (user proceeds to step 2 without un/re-checking) would
|
|
16
|
+
* land on an empty table.
|
|
13
17
|
* - `create`: no step-1 list — seed `cardRows` directly from the AI's
|
|
14
18
|
* suggested cards (resolving owners via `allUsers`) and leave
|
|
15
19
|
* `teamRows` empty.
|
|
@@ -17,7 +21,6 @@ exports.buildAiCardCreationFormDraftSeed = void 0;
|
|
|
17
21
|
const buildAiCardCreationFormDraftSeed = ({ initialData, allUsers, }) => {
|
|
18
22
|
const context = {
|
|
19
23
|
allUsers,
|
|
20
|
-
defaultCardOptionId: initialData.cardOptions[0]?.id,
|
|
21
24
|
mode: initialData.mode,
|
|
22
25
|
suggestedOwnerUserIdByTeamId: initialData.suggestedOwnerUserIdByTeamId,
|
|
23
26
|
};
|
|
@@ -43,7 +46,12 @@ const buildAiCardCreationFormDraftSeed = ({ initialData, allUsers, }) => {
|
|
|
43
46
|
context,
|
|
44
47
|
draft: {
|
|
45
48
|
teamRows,
|
|
46
|
-
cardRows:
|
|
49
|
+
cardRows: (0, deriveAiCardRowsFromTeams_1.deriveAiCardRowsFromTeams)({
|
|
50
|
+
teamRows,
|
|
51
|
+
prevCardRows: [],
|
|
52
|
+
allUsers,
|
|
53
|
+
suggestedOwnerUserIdByTeamId: initialData.suggestedOwnerUserIdByTeamId,
|
|
54
|
+
}),
|
|
47
55
|
},
|
|
48
56
|
};
|
|
49
57
|
};
|
|
@@ -56,7 +64,6 @@ const buildCardRowFromSeed = (seed, allUsers) => {
|
|
|
56
64
|
cardKind: seed.cardKind,
|
|
57
65
|
id: seed.id,
|
|
58
66
|
label: seed.label,
|
|
59
|
-
cardOptionId: seed.cardOptionId,
|
|
60
67
|
owner: {
|
|
61
68
|
allUsers,
|
|
62
69
|
selectedUser,
|
|
@@ -2,8 +2,6 @@ import { User } from '../../../../entity/user/userState';
|
|
|
2
2
|
import { CardsCardRow, CardsTeamRow } from './aiCardCreationFormDraftTypes';
|
|
3
3
|
export interface DeriveAiCardRowsFromTeamsArgs {
|
|
4
4
|
allUsers: User[];
|
|
5
|
-
/** First card option id; used as the per-row default when nothing else applies. */
|
|
6
|
-
defaultCardOptionId: string | undefined;
|
|
7
5
|
/** Map of teamId -> suggested owner userId surfaced by the AI. */
|
|
8
6
|
suggestedOwnerUserIdByTeamId: Record<string, string | undefined>;
|
|
9
7
|
teamRows: CardsTeamRow[];
|
|
@@ -19,8 +17,7 @@ export interface DeriveAiCardRowsFromTeamsArgs {
|
|
|
19
17
|
* previous row is preserved verbatim — so user edits made in step 2
|
|
20
18
|
* aren't blown away when an upstream watchHandler re-derives.
|
|
21
19
|
* - Newly-included teams fall back to:
|
|
22
|
-
* - `cardOptionId = defaultCardOptionId`
|
|
23
20
|
* - `selectedUser = the User whose userId === suggestedOwnerUserIdByTeamId[teamId]`
|
|
24
21
|
* - `recommendedLimit = numeric parse of `teamRow.rightLabel` (e.g. "$20,000")`
|
|
25
22
|
*/
|
|
26
|
-
export declare const deriveAiCardRowsFromTeams: ({ teamRows, prevCardRows, allUsers,
|
|
23
|
+
export declare const deriveAiCardRowsFromTeams: ({ teamRows, prevCardRows, allUsers, suggestedOwnerUserIdByTeamId, }: DeriveAiCardRowsFromTeamsArgs) => CardsCardRow[];
|
|
@@ -10,11 +10,10 @@ exports.deriveAiCardRowsFromTeams = void 0;
|
|
|
10
10
|
* previous row is preserved verbatim — so user edits made in step 2
|
|
11
11
|
* aren't blown away when an upstream watchHandler re-derives.
|
|
12
12
|
* - Newly-included teams fall back to:
|
|
13
|
-
* - `cardOptionId = defaultCardOptionId`
|
|
14
13
|
* - `selectedUser = the User whose userId === suggestedOwnerUserIdByTeamId[teamId]`
|
|
15
14
|
* - `recommendedLimit = numeric parse of `teamRow.rightLabel` (e.g. "$20,000")`
|
|
16
15
|
*/
|
|
17
|
-
const deriveAiCardRowsFromTeams = ({ teamRows, prevCardRows = [], allUsers,
|
|
16
|
+
const deriveAiCardRowsFromTeams = ({ teamRows, prevCardRows = [], allUsers, suggestedOwnerUserIdByTeamId, }) => {
|
|
18
17
|
const prevById = new Map(prevCardRows.map((row) => [row.id, row]));
|
|
19
18
|
const userById = new Map(allUsers.map((user) => [user.userId, user]));
|
|
20
19
|
return teamRows
|
|
@@ -30,7 +29,6 @@ const deriveAiCardRowsFromTeams = ({ teamRows, prevCardRows = [], allUsers, defa
|
|
|
30
29
|
cardKind: teamRow.cardKind,
|
|
31
30
|
id: teamRow.id,
|
|
32
31
|
label: teamRow.label,
|
|
33
|
-
cardOptionId: defaultCardOptionId ?? '',
|
|
34
32
|
owner: {
|
|
35
33
|
allUsers,
|
|
36
34
|
selectedUser,
|
package/lib/view/spendManagement/chargeCards/issueChargeCard/toIssueChargeCardLocalDataFromDraft.js
CHANGED
|
@@ -19,11 +19,6 @@ const DEFAULT_CURRENCY_SYMBOL = '$';
|
|
|
19
19
|
* - `creditCard.cardType` is hard-coded to `'business_virtual_credit_card'`
|
|
20
20
|
* - the physicalCard / debitCard.* slots are populated with empty
|
|
21
21
|
* defaults that the epic ignores.
|
|
22
|
-
*
|
|
23
|
-
* The form's `cardOptionId` is intentionally ignored: it's a UI-only
|
|
24
|
-
* selector ("physical" / "virtual") that the AI uses to suggest a
|
|
25
|
-
* flavour, but the bulk-create wire contract only supports the virtual
|
|
26
|
-
* branch in this iteration.
|
|
27
22
|
*/
|
|
28
23
|
const mapCardRow = (row) => {
|
|
29
24
|
const ownerUserId = row.owner.selectedUser?.userId;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeniai/client-epic-state",
|
|
3
|
-
"version": "5.0.83-
|
|
3
|
+
"version": "5.0.83-betaRR5",
|
|
4
4
|
"description": "Shared module between Web & Mobile containing required abstractions for state management, async network communication. ",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib/esm/index.js",
|