@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
package/lib/esm/view/spendManagement/chargeCards/issueChargeCard/buildAiCardCreationFormDraftSeed.js
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
|
+
import { deriveAiCardRowsFromTeams } from './deriveAiCardRowsFromTeams';
|
|
1
2
|
/**
|
|
2
3
|
* Build the initial `CardsFormDraft` + companion seed context for a
|
|
3
4
|
* fresh AI card-creation session. Used by the `seedAiCardCreationFormDraft`
|
|
4
5
|
* reducer.
|
|
5
6
|
*
|
|
6
7
|
* Branches on `initialData.mode`:
|
|
7
|
-
* - `review`: step-1 team rows start fully checked
|
|
8
|
-
*
|
|
9
|
-
*
|
|
8
|
+
* - `review`: step-1 team rows start fully checked and step-2 `cardRows`
|
|
9
|
+
* are seeded by `deriveAiCardRowsFromTeams` so the table is populated
|
|
10
|
+
* on first render. `applyAiCardCreationFormDraftUpdate` only re-derives
|
|
11
|
+
* when a team is toggled in step 1, so without this initial seed the
|
|
12
|
+
* happy path (user proceeds to step 2 without un/re-checking) would
|
|
13
|
+
* land on an empty table.
|
|
10
14
|
* - `create`: no step-1 list — seed `cardRows` directly from the AI's
|
|
11
15
|
* suggested cards (resolving owners via `allUsers`) and leave
|
|
12
16
|
* `teamRows` empty.
|
|
@@ -14,7 +18,6 @@
|
|
|
14
18
|
export const buildAiCardCreationFormDraftSeed = ({ initialData, allUsers, }) => {
|
|
15
19
|
const context = {
|
|
16
20
|
allUsers,
|
|
17
|
-
defaultCardOptionId: initialData.cardOptions[0]?.id,
|
|
18
21
|
mode: initialData.mode,
|
|
19
22
|
suggestedOwnerUserIdByTeamId: initialData.suggestedOwnerUserIdByTeamId,
|
|
20
23
|
};
|
|
@@ -40,7 +43,12 @@ export const buildAiCardCreationFormDraftSeed = ({ initialData, allUsers, }) =>
|
|
|
40
43
|
context,
|
|
41
44
|
draft: {
|
|
42
45
|
teamRows,
|
|
43
|
-
cardRows:
|
|
46
|
+
cardRows: deriveAiCardRowsFromTeams({
|
|
47
|
+
teamRows,
|
|
48
|
+
prevCardRows: [],
|
|
49
|
+
allUsers,
|
|
50
|
+
suggestedOwnerUserIdByTeamId: initialData.suggestedOwnerUserIdByTeamId,
|
|
51
|
+
}),
|
|
44
52
|
},
|
|
45
53
|
};
|
|
46
54
|
};
|
|
@@ -52,7 +60,6 @@ const buildCardRowFromSeed = (seed, allUsers) => {
|
|
|
52
60
|
cardKind: seed.cardKind,
|
|
53
61
|
id: seed.id,
|
|
54
62
|
label: seed.label,
|
|
55
|
-
cardOptionId: seed.cardOptionId,
|
|
56
63
|
owner: {
|
|
57
64
|
allUsers,
|
|
58
65
|
selectedUser,
|
package/lib/esm/view/spendManagement/chargeCards/issueChargeCard/deriveAiCardRowsFromTeams.js
CHANGED
|
@@ -7,11 +7,10 @@
|
|
|
7
7
|
* previous row is preserved verbatim — so user edits made in step 2
|
|
8
8
|
* aren't blown away when an upstream watchHandler re-derives.
|
|
9
9
|
* - Newly-included teams fall back to:
|
|
10
|
-
* - `cardOptionId = defaultCardOptionId`
|
|
11
10
|
* - `selectedUser = the User whose userId === suggestedOwnerUserIdByTeamId[teamId]`
|
|
12
11
|
* - `recommendedLimit = numeric parse of `teamRow.rightLabel` (e.g. "$20,000")`
|
|
13
12
|
*/
|
|
14
|
-
export const deriveAiCardRowsFromTeams = ({ teamRows, prevCardRows = [], allUsers,
|
|
13
|
+
export const deriveAiCardRowsFromTeams = ({ teamRows, prevCardRows = [], allUsers, suggestedOwnerUserIdByTeamId, }) => {
|
|
15
14
|
const prevById = new Map(prevCardRows.map((row) => [row.id, row]));
|
|
16
15
|
const userById = new Map(allUsers.map((user) => [user.userId, user]));
|
|
17
16
|
return teamRows
|
|
@@ -27,7 +26,6 @@ export const deriveAiCardRowsFromTeams = ({ teamRows, prevCardRows = [], allUser
|
|
|
27
26
|
cardKind: teamRow.cardKind,
|
|
28
27
|
id: teamRow.id,
|
|
29
28
|
label: teamRow.label,
|
|
30
|
-
cardOptionId: defaultCardOptionId ?? '',
|
|
31
29
|
owner: {
|
|
32
30
|
allUsers,
|
|
33
31
|
selectedUser,
|
|
@@ -16,11 +16,6 @@ const DEFAULT_CURRENCY_SYMBOL = '$';
|
|
|
16
16
|
* - `creditCard.cardType` is hard-coded to `'business_virtual_credit_card'`
|
|
17
17
|
* - the physicalCard / debitCard.* slots are populated with empty
|
|
18
18
|
* defaults that the epic ignores.
|
|
19
|
-
*
|
|
20
|
-
* The form's `cardOptionId` is intentionally ignored: it's a UI-only
|
|
21
|
-
* selector ("physical" / "virtual") that the AI uses to suggest a
|
|
22
|
-
* flavour, but the bulk-create wire contract only supports the virtual
|
|
23
|
-
* branch in this iteration.
|
|
24
19
|
*/
|
|
25
20
|
const mapCardRow = (row) => {
|
|
26
21
|
const ownerUserId = row.owner.selectedUser?.userId;
|
package/lib/index.d.ts
CHANGED
|
@@ -474,9 +474,9 @@ import { ChargeCardStatement } from './view/spendManagement/chargeCards/chargeCa
|
|
|
474
474
|
import { fetchChargeCardStatementList } from './view/spendManagement/chargeCards/chargeCardStatementList/chargeCardStatementListReducer';
|
|
475
475
|
import { ChargeCardStatementsSelectorView, getChargeCardStatements } from './view/spendManagement/chargeCards/chargeCardStatementList/chargeCardStatementListSelector';
|
|
476
476
|
import { AiCardCreationFormDraftSeedContext, CardsCardRow, CardsFormDraft, CardsOwnerFieldValue, CardsTeamRow } from './view/spendManagement/chargeCards/issueChargeCard/aiCardCreationFormDraftTypes';
|
|
477
|
+
import { type ApplyAiCardCreationFormDraftUpdateArgs, applyAiCardCreationFormDraftUpdate } from './view/spendManagement/chargeCards/issueChargeCard/applyAiCardCreationFormDraftUpdate';
|
|
477
478
|
import { type BuildAiCardCreationFormDraftSeedArgs, type BuildAiCardCreationFormDraftSeedResult, buildAiCardCreationFormDraftSeed } from './view/spendManagement/chargeCards/issueChargeCard/buildAiCardCreationFormDraftSeed';
|
|
478
479
|
import { type DeriveAiCardRowsFromTeamsArgs, deriveAiCardRowsFromTeams } from './view/spendManagement/chargeCards/issueChargeCard/deriveAiCardRowsFromTeams';
|
|
479
|
-
import { type ApplyAiCardCreationFormDraftUpdateArgs, applyAiCardCreationFormDraftUpdate } from './view/spendManagement/chargeCards/issueChargeCard/applyAiCardCreationFormDraftUpdate';
|
|
480
480
|
import { clearAiCardCreationFormDraft, fetchDepositAccountListForCards, fetchIssueCardPage, issueChargeCards, resetIssueChargeCardForm, seedAiCardCreationFormDraft, updateAiCardCreationFormDraft, updateChargeCardsLocalStore, updateCustomAddressId, updateLastIssuedCardIds } from './view/spendManagement/chargeCards/issueChargeCard/issueChargeCardReducer';
|
|
481
481
|
import { IssueChargeCardSelectorView, getAiCardCreationFormDraft, getInFlightIssueChargeCardsCount, getIssueChargeCardView, getIssueChargeCardsSaveStatus, getLastIssueChargeCardsSourceChatSessionId, getLastIssuedChargeCardIds, selectIssueChargeCardLocalDataFromDraft } from './view/spendManagement/chargeCards/issueChargeCard/issueChargeCardSelector';
|
|
482
482
|
import { ActiveChargeCardCount, ActiveDebitCardCount, ActiveDebitCardCountByUserId, IssueChargeCardLocalData, IssueChargeCardState, PhysicalCreditCardData, PhysicalDebitCardData, VirtualCreditCardData, VirtualDebitCardData } from './view/spendManagement/chargeCards/issueChargeCard/issueChargeCardState';
|
|
@@ -918,14 +918,30 @@ export { AiCfoViewSelector, getAiCfoView, getSuggestedQuestionsForPageContext, }
|
|
|
918
918
|
export { MessagePayload, ChatSessionPayload, AiCfoAnswerPayload, } from './entity/aiCfo/aiCfoPayload';
|
|
919
919
|
export { setNewSession, setSessions, updateAiCfoAnswerCardPolicyWizardPlan, upsertAnswerPayload, upsertOrAddQuestionAnswerPayload, addQuestionPayload, clearSession, clearAiCfo, toAiCfoVisualization, appendSyntheticAiCfoAnswer, updateSyntheticAiCfoAnswer, removeSyntheticAiCfoAnswer, clearSyntheticAiCfoAnswers, } from './entity/aiCfo/aiCfoReducer';
|
|
920
920
|
export { AiCfoSelectorView, getAllQuestionAnswersForChatSession, getQuestionAnswerByIdForChatSession, getAllQuestionsForChatSession, getAiCfoSelectorView, getSyntheticAiCfoAnswersForChatSession, getSyntheticAiCfoAnswerByQuestionAnswerId, ChatSessionWithOrderedQuestionAnswers, } from './entity/aiCfo/aiCfoSelector';
|
|
921
|
-
export { AiCfoQuestionWithAnswer, AiCfoAnswerParagraph, AiCfoAnswerStateType, AiCfoChartType, AiCfoAnswerResponseType, TableVisualization, ChartVisualization, CardNameOption, CardsCardKind,
|
|
921
|
+
export { AiCfoQuestionWithAnswer, AiCfoAnswerParagraph, AiCfoAnswerStateType, AiCfoChartType, AiCfoAnswerResponseType, TableVisualization, ChartVisualization, CardNameOption, CardsCardKind, CardsCreationInitialData, CardPolicyDraftPolicy, CardPolicyDraftPolicyEntity, CardPolicyInitialData, CardPolicySpendLimits, CardPolicyStep5Review, CardPolicyUploadSource, CardPolicyWizardPlan, InteractiveFormType, InteractiveFormVisualization, AiCfoVisualization, AiCfoVisualizationType, AiCfoState, ChatSession, ALL_AI_CFO_CHARTS_TYPES, ALL_AI_CFO_VISUALIZATION_TYPES, ALL_AI_CFO_ANSWER_STATE_TYPES, ALL_AI_CFO_ANSWER_RESPONSE_TYPES, ALL_INTERACTIVE_FORM_TYPES, toAiCfoVisualizationType, toAiCfoVisualizationTypeStrict, toAiCfoChartType, toAiCfoChartTypeStrict, toAiCfoAnswerStateType, toAiCfoAnswerStateTypeStrict, toAiCfoAnswerResponseType, toAiCfoAnswerResponseTypeStrict, toInteractiveFormType, toInteractiveFormTypeStrict, ChatSessionWithMessages, ResponseBlockBase, AnswerContentBlockBase, FileAttachmentMetadata, QuestionContentBlockBase, ResponseBlockType, SyntheticAiCfoAnswer, SyntheticAiCfoAnswerKind, ALL_SYNTHETIC_AI_CFO_ANSWER_KINDS, toMessageSender, toMessageType, MessageSender, MessageType, } from './entity/aiCfo/aiCfoState';
|
|
922
922
|
export { clearPolicyDocumentExtraction, extractPolicyDocument, fetchCardPolicyMccCategories, fetchCardPolicyRecommendationFromUpload, fetchCardPolicyVendorOptions, removeCardPolicyTemplate, updateCardPolicyMccCategories, updateCardPolicyMccCategoriesFailure, updateCardPolicyStats, updateCardPolicyTemplates, updateCardPolicyVendorOptions, updateCardPolicyVendorOptionsFailure, updateCreatedCardPolicyTemplate, updatePolicyDocumentExtractionFailure, updatePolicyDocumentExtractionSuccess, updatePolicyRecommendationFromUploadFailure, updatePolicyRecommendationFromUploadSuccess, clearCardPolicy, } from './entity/cardPolicy/cardPolicyReducer';
|
|
923
923
|
export { getAllCardPolicyTemplates, getCardPolicyMccCategories, getCardPolicyMccCategoriesError, getCardPolicyMccCategoriesFetchState, getCardPolicyStats, getCardPolicySuggestedAllowCategories, getCardPolicySuggestedAllowMerchants, getCardPolicySuggestedBlockCategories, getCardPolicySuggestedBlockMerchants, getCardPolicyTemplateById, getCardPolicyTemplatesByIds, getCardPolicyVendorSearchFetchState, getCardPolicyVendorSearchOptions, getCardPolicyVendorSearchString, getExtractedCardPolicyRules, getPolicyDocumentExtractionError, getPolicyDocumentExtractionFetchState, getPolicyRecommendationFromUploadAnswerId, getPolicyRecommendationFromUploadChatSessionId, getPolicyRecommendationFromUploadError, getPolicyRecommendationFromUploadFetchState, getUploadedPolicyDocumentFileName, } from './entity/cardPolicy/cardPolicySelector';
|
|
924
924
|
export { ALL_CARD_POLICY_TEMPLATE_MODES, ALL_CARD_POLICY_TEMPLATE_STATUSES, CardPolicyState, CardPolicyStats, CardPolicyTemplate, CardPolicyTemplateEntityList, CardPolicyTemplateMode, CardPolicyTemplateSpendLimits, CardPolicyTemplateStatus, CardPolicyVendorSearchEntry, CardPolicyVendorSearchState, ExtractedCardPolicyRules, MccCategory, PolicyDocumentExtractionState, PolicyRecommendationFromUploadState, toCardPolicyTemplateMode, toCardPolicyTemplateStatus, } from './entity/cardPolicy/cardPolicyState';
|
|
925
925
|
export { BulkCreateCardPolicyTemplateError, BulkCreateCardPolicyTemplateErrorPayload, CardPolicyDetailResponse, CardPolicyDetailResponseData, CardPolicyMccCategoriesPayload, CardPolicyMccCategoriesResponse, CardPolicyStatsPayload, CardPolicyTemplatePayload, CardPolicyVendorSearchData, CardPolicyVendorSearchOption, CardPolicyVendorSearchResponse, CardPolicyVendorSearchVendorPayload, CreateCardPolicyTemplateRequest, CreateCardPolicyTemplateRequestBody, CreateCardPolicyTemplateResponse, CreateCardPolicyTemplateResponseData, CreateCardPolicyTemplatesRequest, CreateCardPolicyTemplatesRequestBody, CreateCardPolicyTemplatesResponse, CreateCardPolicyTemplatesResponseData, ExtractedCardPolicyRulesPayload, ListCardPolicyTemplatesResponse, ListCardPolicyTemplatesResponseData, MccCategoryPayload, PolicyDocumentExtractResponse, PolicyDocumentExtractResponseData, UpdateCardPolicyTemplateRequest, UpdateCardPolicyTemplateRequestBody, UpdateCardPolicyTemplateResponse, UpdateCardPolicyTemplateResponseData, toBulkCreateCardPolicyTemplateError, toCardPolicyEditFormDraft, toCardPolicyStats, toCardPolicyTemplate, toCardPolicyTemplateList, toCardPolicyVendorSearchOption, toCreateCardPolicyTemplateRequestBody, toCreateCardPolicyTemplatesRequestBody, toExtractedCardPolicyRules, toUpdateCardPolicyTemplateRequestBody, } from './entity/cardPolicy/cardPolicyPayload';
|
|
926
|
-
export { clearCreateCardPolicy, createCardPolicyTemplates, updateCreateCardPolicyTemplateRequestState, } from './view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyReducer';
|
|
927
|
-
export { getCreateCardPolicyTemplateRequestState, getLastCreateCardPolicySourceChatSessionId, getLastCreateCardPolicyTemplateErrors, getLastCreatedCardPolicyTemplateId, getLastCreatedCardPolicyTemplateIds, } from './view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicySelector';
|
|
926
|
+
export { applyExtractedPolicyToAiCardPolicyDraft, applyExtractedPolicyToManualCardPolicyDraft, clearAiCardPolicyFormDraft, clearCreateCardPolicy, clearManualCardPolicyFormDraft, createCardPolicyTemplates, seedAiCardPolicyFormDraft, seedManualCardPolicyFormDraft, updateAiCardPolicyFormDraft, updateAiCardPolicyFormDraftFromUploadPlan, updateCreateCardPolicyTemplateRequestState, updateManualCardPolicyFormDraft, } from './view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyReducer';
|
|
927
|
+
export { getAiCardPolicyFormDraft, getCreateCardPolicyTemplateRequestState, getLastCreateCardPolicySourceChatSessionId, getLastCreateCardPolicyTemplateErrors, getLastCreatedCardPolicyTemplateId, getLastCreatedCardPolicyTemplateIds, getManualCardPolicyFormDraft, } from './view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicySelector';
|
|
928
928
|
export { CreateCardPolicyState } from './view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyState';
|
|
929
|
+
export { CARD_POLICY_LIMIT_ROW_ID_REQUIRE_RECEIPT, CARD_POLICY_LIMIT_ROW_ID_TRANSACTION, toMccCategoryLike, } from './view/spendManagement/chargeCards/cardPolicy/createCardPolicy/cardPolicyFormDraftTypes';
|
|
930
|
+
export type { AiCardPolicyFormDraftSeedContext, CardPolicyAllowBlockFieldValue, CardPolicyCardSelectionRow, CardPolicyChipFieldValue, CardPolicyCreateFormDraft, CardPolicyDefaultSeedSuggestions, CardPolicyFormDraft, CardPolicyLimitFieldValue, CardPolicyModeValue, CardPolicyOwnerSeed, CardPolicyReviewChip, CardPolicyReviewChipGroup, CardPolicyReviewRow, CardPolicySuggestedPolicySeed, ChipKind, ExtractedCardPolicyDataView, MccCategoryLike, } from './view/spendManagement/chargeCards/cardPolicy/createCardPolicy/cardPolicyFormDraftTypes';
|
|
931
|
+
export { MCC_CHIP_ID_PREFIX, VENDOR_CHIP_ID_PREFIX, buildMccCategoryChipId, buildVendorChipId, toMccCategoryChipFieldValue, toVendorChipFieldValue, } from './view/spendManagement/chargeCards/cardPolicy/createCardPolicy/cardPolicyChipIds';
|
|
932
|
+
export { buildAiCardPolicyFormDraftSeed, buildEmptyLimitRows, buildUploadReviewRows, } from './view/spendManagement/chargeCards/cardPolicy/createCardPolicy/buildAiCardPolicyFormDraftSeed';
|
|
933
|
+
export type { BuildAiCardPolicyFormDraftSeedArgs, BuildAiCardPolicyFormDraftSeedResult, } from './view/spendManagement/chargeCards/cardPolicy/createCardPolicy/buildAiCardPolicyFormDraftSeed';
|
|
934
|
+
export { buildManualCardPolicyFormDraftSeed } from './view/spendManagement/chargeCards/cardPolicy/createCardPolicy/buildManualCardPolicyFormDraftSeed';
|
|
935
|
+
export type { BuildManualCardPolicyFormDraftSeedArgs } from './view/spendManagement/chargeCards/cardPolicy/createCardPolicy/buildManualCardPolicyFormDraftSeed';
|
|
936
|
+
export { deriveAiPolicyReviewRowsFromInputs } from './view/spendManagement/chargeCards/cardPolicy/createCardPolicy/deriveAiPolicyReviewRowsFromInputs';
|
|
937
|
+
export type { DeriveAiPolicyReviewRowsFromInputsArgs } from './view/spendManagement/chargeCards/cardPolicy/createCardPolicy/deriveAiPolicyReviewRowsFromInputs';
|
|
938
|
+
export { applyAiCardPolicyFormDraftUpdate } from './view/spendManagement/chargeCards/cardPolicy/createCardPolicy/applyAiCardPolicyFormDraftUpdate';
|
|
939
|
+
export type { ApplyAiCardPolicyFormDraftUpdateArgs } from './view/spendManagement/chargeCards/cardPolicy/createCardPolicy/applyAiCardPolicyFormDraftUpdate';
|
|
940
|
+
export { toCardPolicyTemplateRequestFromDraft } from './view/spendManagement/chargeCards/cardPolicy/createCardPolicy/toCardPolicyTemplateRequestFromDraft';
|
|
941
|
+
export type { ToCardPolicyTemplateRequestFromDraftArgs } from './view/spendManagement/chargeCards/cardPolicy/createCardPolicy/toCardPolicyTemplateRequestFromDraft';
|
|
942
|
+
export { toBulkCardPolicyTemplateRequestsFromDraft } from './view/spendManagement/chargeCards/cardPolicy/createCardPolicy/toBulkCardPolicyTemplateRequestsFromDraft';
|
|
943
|
+
export type { BulkCreateCardPolicyTemplateEntry, CardPolicyBulkSubmitKind, ToBulkCardPolicyTemplateRequestsFromDraftArgs, } from './view/spendManagement/chargeCards/cardPolicy/createCardPolicy/toBulkCardPolicyTemplateRequestsFromDraft';
|
|
944
|
+
export { toManualCardPolicyTemplateRequestFromDraft } from './view/spendManagement/chargeCards/cardPolicy/createCardPolicy/toManualCardPolicyTemplateRequestFromDraft';
|
|
929
945
|
export { archiveCardPolicy, clearCardPolicyList, fetchCardPolicyList, updateArchiveCardPolicyFetchStatus, updateCardPolicyListFetchStatus, } from './view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListReducer';
|
|
930
946
|
export { CardPolicyListSelectorView, getArchiveCardPolicyFetchState, getCardPolicyListFetchState, getCardPolicyListView, getCardPolicyTemplateIds, } from './view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListSelector';
|
|
931
947
|
export { CardPolicyListState } from './view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListState';
|
package/lib/index.js
CHANGED
|
@@ -72,8 +72,9 @@ exports.getRegisteredInterestsByFeature = exports.getRegisteredInterests = expor
|
|
|
72
72
|
exports.toAiAccountantJobStatus = exports.toAiAccountantEnrollmentStatus = exports.getAllowedOperationsForStatus = exports.getTreasuryFundsMaximumYield = exports.getTreasurySetupViewDetails = exports.updateTreasuryVideoViewed = exports.updateFundAllocationLocalData = exports.fetchPortfolioAllocation = exports.updatePortfolioAllocation = exports.fetchTreasuryFunds = exports.clearTreasurySetupView = exports.fetchTreasurySetupView = exports.acceptTreasuryTerms = exports.getExpressPayView = exports.resetExpressPayLocalData = exports.submitExpressPay = exports.updateExpressPayFormLocalData = exports.fetchExpressPayInitialDetails = exports.getIntlWireVerificationView = exports.updateVerificationFormLocalData = exports.submitInternationalVerificationForm = exports.fetchInternationalVerificationForm = exports.createTaskFromTaskGroupTemplate = exports.getCompanyTaskManagerView = exports.fetchTaskManagerMetrics = exports.fetchCompanyTaskManagerView = exports.toRecurringFrequency = exports.toDayOfWeek = exports.getRecurringEndDateFromCount = exports.getMinAllowedEndDate = exports.SEMI_WEEKLY_REQUIRED_DAYS_COUNT = exports.ALL_WEEK_DAYS = exports.updateReferViewed = exports.getRewardsPlanCard = exports.fetchRewardsPlan = exports.resendReferralInvite = exports.updateReferralListSortUiState = exports.saveReferralFormDataInLocalStore = exports.clearReferrals = exports.sendReferralInvite = exports.fetchReferrals = exports.AmountStatusTypes = exports.StatusTypes = exports.toReferralListViewSortKeyType = exports.getInviteFormView = exports.getReferralListView = exports.getNotifications = exports.getLastNotificationTime = exports.pushToastNotification = exports.isFeatureInterestRegistered = void 0;
|
|
73
73
|
exports.addQuestionPayload = exports.upsertOrAddQuestionAnswerPayload = exports.upsertAnswerPayload = exports.updateAiCfoAnswerCardPolicyWizardPlan = exports.setSessions = exports.setNewSession = exports.getSuggestedQuestionsForPageContext = exports.getAiCfoView = exports.clearAiCfoSidePanelHostPageContext = exports.applyAiCfoSidePanelHostPageTransition = exports.fetchSuggestedQuestionsFailure = exports.fetchSuggestedQuestionsSuccess = exports.fetchSuggestedQuestions = exports.updateResponseState = exports.deleteChatSession = exports.acceptMasterTOS = exports.fetchChatHistory = exports.stopSubmitQuestion = exports.stopSubmit = exports.createSessionAndSubmit = exports.clearLastContextMessage = exports.clearDeleteChatSessionStatus = exports.clearCurrentSessionId = exports.clearAiCfoView = exports.setSession = exports.clearInput = exports.updateCotCollapsedState = exports.updateCurrentInput = exports.updateAiCfoViewScrollPosition = exports.submitQuestion = exports.createSession = exports.fetchChatSessionsForUser = exports.getAiAccountantCockpitView = exports.updateAiAccountantUIState = exports.triggerAiAccountantJob = exports.setSelectedTenantIdsForJobTrigger = exports.fetchAiAccountantJobs = exports.fetchAiAccountantCustomers = exports.clearAiAccountantView = exports.cancelAiAccountantOnboarding = exports.getAiAccountantJobsByTenantId = exports.getAiAccountantCustomers = exports.updateAiAccountantJobs = exports.updateAiAccountantCustomer = exports.updateAiAccountantCustomers = exports.clearAllAiAccountantCustomers = exports.toAiAccountantJob = exports.toAiAccountantEnrollment = exports.toAiAccountantCustomer = exports.toAiAccountantOperationType = void 0;
|
|
74
74
|
exports.getAllCardPolicyTemplates = exports.clearCardPolicy = exports.updatePolicyRecommendationFromUploadSuccess = exports.updatePolicyRecommendationFromUploadFailure = exports.updatePolicyDocumentExtractionSuccess = exports.updatePolicyDocumentExtractionFailure = exports.updateCreatedCardPolicyTemplate = exports.updateCardPolicyVendorOptionsFailure = exports.updateCardPolicyVendorOptions = exports.updateCardPolicyTemplates = exports.updateCardPolicyStats = exports.updateCardPolicyMccCategoriesFailure = exports.updateCardPolicyMccCategories = exports.removeCardPolicyTemplate = exports.fetchCardPolicyVendorOptions = exports.fetchCardPolicyRecommendationFromUpload = exports.fetchCardPolicyMccCategories = exports.extractPolicyDocument = exports.clearPolicyDocumentExtraction = exports.toMessageType = exports.toMessageSender = exports.ALL_SYNTHETIC_AI_CFO_ANSWER_KINDS = exports.toInteractiveFormTypeStrict = exports.toInteractiveFormType = exports.toAiCfoAnswerResponseTypeStrict = exports.toAiCfoAnswerResponseType = exports.toAiCfoAnswerStateTypeStrict = exports.toAiCfoAnswerStateType = exports.toAiCfoChartTypeStrict = exports.toAiCfoChartType = exports.toAiCfoVisualizationTypeStrict = exports.toAiCfoVisualizationType = exports.ALL_INTERACTIVE_FORM_TYPES = exports.ALL_AI_CFO_ANSWER_RESPONSE_TYPES = exports.ALL_AI_CFO_ANSWER_STATE_TYPES = exports.ALL_AI_CFO_VISUALIZATION_TYPES = exports.ALL_AI_CFO_CHARTS_TYPES = exports.getSyntheticAiCfoAnswerByQuestionAnswerId = exports.getSyntheticAiCfoAnswersForChatSession = exports.getAiCfoSelectorView = exports.getAllQuestionsForChatSession = exports.getQuestionAnswerByIdForChatSession = exports.getAllQuestionAnswersForChatSession = exports.clearSyntheticAiCfoAnswers = exports.removeSyntheticAiCfoAnswer = exports.updateSyntheticAiCfoAnswer = exports.appendSyntheticAiCfoAnswer = exports.toAiCfoVisualization = exports.clearAiCfo = exports.clearSession = void 0;
|
|
75
|
-
exports.
|
|
76
|
-
exports.
|
|
75
|
+
exports.getLastCreateCardPolicySourceChatSessionId = exports.getCreateCardPolicyTemplateRequestState = exports.getAiCardPolicyFormDraft = exports.updateManualCardPolicyFormDraft = exports.updateCreateCardPolicyTemplateRequestState = exports.updateAiCardPolicyFormDraftFromUploadPlan = exports.updateAiCardPolicyFormDraft = exports.seedManualCardPolicyFormDraft = exports.seedAiCardPolicyFormDraft = exports.createCardPolicyTemplates = exports.clearManualCardPolicyFormDraft = exports.clearCreateCardPolicy = exports.clearAiCardPolicyFormDraft = exports.applyExtractedPolicyToManualCardPolicyDraft = exports.applyExtractedPolicyToAiCardPolicyDraft = exports.toUpdateCardPolicyTemplateRequestBody = exports.toExtractedCardPolicyRules = exports.toCreateCardPolicyTemplatesRequestBody = exports.toCreateCardPolicyTemplateRequestBody = exports.toCardPolicyVendorSearchOption = exports.toCardPolicyTemplateList = exports.toCardPolicyTemplate = exports.toCardPolicyStats = exports.toCardPolicyEditFormDraft = exports.toBulkCreateCardPolicyTemplateError = exports.toCardPolicyTemplateStatus = exports.toCardPolicyTemplateMode = exports.ALL_CARD_POLICY_TEMPLATE_STATUSES = exports.ALL_CARD_POLICY_TEMPLATE_MODES = exports.getUploadedPolicyDocumentFileName = exports.getPolicyRecommendationFromUploadFetchState = exports.getPolicyRecommendationFromUploadError = exports.getPolicyRecommendationFromUploadChatSessionId = exports.getPolicyRecommendationFromUploadAnswerId = exports.getPolicyDocumentExtractionFetchState = exports.getPolicyDocumentExtractionError = exports.getExtractedCardPolicyRules = exports.getCardPolicyVendorSearchString = exports.getCardPolicyVendorSearchOptions = exports.getCardPolicyVendorSearchFetchState = exports.getCardPolicyTemplatesByIds = exports.getCardPolicyTemplateById = exports.getCardPolicySuggestedBlockMerchants = exports.getCardPolicySuggestedBlockCategories = exports.getCardPolicySuggestedAllowMerchants = exports.getCardPolicySuggestedAllowCategories = exports.getCardPolicyStats = exports.getCardPolicyMccCategoriesFetchState = exports.getCardPolicyMccCategoriesError = exports.getCardPolicyMccCategories = void 0;
|
|
76
|
+
exports.fetchTreasuryStatementList = exports.getTreasuryTransferMoney = exports.clearTreasuryTransferMoney = exports.updateTreasuryTransferMoneyLocalData = exports.executeTreasuryTransferMoney = exports.getTreasuryDetail = exports.updateTreasuryTransactionListUIState = exports.fetchTreasuryTransactionList = exports.fetchTreasuryOverviewDetail = exports.getUpdateCardPolicyFetchState = exports.getCardPolicyFormDraft = exports.getCardPolicyDetailView = exports.getCardPolicyDetailFetchState = exports.updateCardPolicyFormDraft = exports.updateCardPolicyFetchStatus = exports.updateCardPolicyDetailFetchStatus = exports.updateCardPolicy = exports.fetchCardPolicyDetail = exports.clearCardPolicyDetail = exports.getCardPolicyTemplateIds = exports.getCardPolicyListView = exports.getCardPolicyListFetchState = exports.getArchiveCardPolicyFetchState = exports.updateCardPolicyListFetchStatus = exports.updateArchiveCardPolicyFetchStatus = exports.fetchCardPolicyList = exports.clearCardPolicyList = exports.archiveCardPolicy = exports.toManualCardPolicyTemplateRequestFromDraft = exports.toBulkCardPolicyTemplateRequestsFromDraft = exports.toCardPolicyTemplateRequestFromDraft = exports.applyAiCardPolicyFormDraftUpdate = exports.deriveAiPolicyReviewRowsFromInputs = exports.buildManualCardPolicyFormDraftSeed = exports.buildUploadReviewRows = exports.buildEmptyLimitRows = exports.buildAiCardPolicyFormDraftSeed = exports.toVendorChipFieldValue = exports.toMccCategoryChipFieldValue = exports.buildVendorChipId = exports.buildMccCategoryChipId = exports.VENDOR_CHIP_ID_PREFIX = exports.MCC_CHIP_ID_PREFIX = exports.toMccCategoryLike = exports.CARD_POLICY_LIMIT_ROW_ID_TRANSACTION = exports.CARD_POLICY_LIMIT_ROW_ID_REQUIRE_RECEIPT = exports.getManualCardPolicyFormDraft = exports.getLastCreatedCardPolicyTemplateIds = exports.getLastCreatedCardPolicyTemplateId = exports.getLastCreateCardPolicyTemplateErrors = void 0;
|
|
77
|
+
exports.DEFAULT_SESSION_CONFIG = exports.SessionManager = exports.getTransactionActivityLogView = exports.fetchTransactionActivityLog = exports.BULK_UPLOAD_BAR_COMPLETE_HOLD_MS = exports.BULK_UPLOAD_AUTOMATCHING_TIMEOUT_MS = exports.getAutoTransferRuleHistory = exports.getAutoTransferRuleById = exports.getAutoTransferRules = exports.clearRuleUpdateLocalData = exports.updateRuleLocalData = exports.fetchAutoTransferReviewDetail = exports.fetchAutoTransferRuleHistory = exports.deleteAutoTransferRule = exports.updateAutoTransferRule = exports.createAutoTransferRule = exports.fetchAutoTransferRules = exports.getTreasuryTaxLetters = exports.fetchTreasuryTaxLetterList = exports.getTreasuryStatements = void 0;
|
|
77
78
|
const allowedValue_1 = require("./commonStateTypes/allowedValue");
|
|
78
79
|
Object.defineProperty(exports, "isAllowedValueWithCode", { enumerable: true, get: function () { return allowedValue_1.isAllowedValueWithCode; } });
|
|
79
80
|
Object.defineProperty(exports, "isAllowedValueWithID", { enumerable: true, get: function () { return allowedValue_1.isAllowedValueWithID; } });
|
|
@@ -1611,12 +1612,12 @@ const chargeCardStatementListReducer_1 = require("./view/spendManagement/chargeC
|
|
|
1611
1612
|
Object.defineProperty(exports, "fetchChargeCardStatementList", { enumerable: true, get: function () { return chargeCardStatementListReducer_1.fetchChargeCardStatementList; } });
|
|
1612
1613
|
const chargeCardStatementListSelector_1 = require("./view/spendManagement/chargeCards/chargeCardStatementList/chargeCardStatementListSelector");
|
|
1613
1614
|
Object.defineProperty(exports, "getChargeCardStatements", { enumerable: true, get: function () { return chargeCardStatementListSelector_1.getChargeCardStatements; } });
|
|
1615
|
+
const applyAiCardCreationFormDraftUpdate_1 = require("./view/spendManagement/chargeCards/issueChargeCard/applyAiCardCreationFormDraftUpdate");
|
|
1616
|
+
Object.defineProperty(exports, "applyAiCardCreationFormDraftUpdate", { enumerable: true, get: function () { return applyAiCardCreationFormDraftUpdate_1.applyAiCardCreationFormDraftUpdate; } });
|
|
1614
1617
|
const buildAiCardCreationFormDraftSeed_1 = require("./view/spendManagement/chargeCards/issueChargeCard/buildAiCardCreationFormDraftSeed");
|
|
1615
1618
|
Object.defineProperty(exports, "buildAiCardCreationFormDraftSeed", { enumerable: true, get: function () { return buildAiCardCreationFormDraftSeed_1.buildAiCardCreationFormDraftSeed; } });
|
|
1616
1619
|
const deriveAiCardRowsFromTeams_1 = require("./view/spendManagement/chargeCards/issueChargeCard/deriveAiCardRowsFromTeams");
|
|
1617
1620
|
Object.defineProperty(exports, "deriveAiCardRowsFromTeams", { enumerable: true, get: function () { return deriveAiCardRowsFromTeams_1.deriveAiCardRowsFromTeams; } });
|
|
1618
|
-
const applyAiCardCreationFormDraftUpdate_1 = require("./view/spendManagement/chargeCards/issueChargeCard/applyAiCardCreationFormDraftUpdate");
|
|
1619
|
-
Object.defineProperty(exports, "applyAiCardCreationFormDraftUpdate", { enumerable: true, get: function () { return applyAiCardCreationFormDraftUpdate_1.applyAiCardCreationFormDraftUpdate; } });
|
|
1620
1621
|
const issueChargeCardReducer_1 = require("./view/spendManagement/chargeCards/issueChargeCard/issueChargeCardReducer");
|
|
1621
1622
|
Object.defineProperty(exports, "clearAiCardCreationFormDraft", { enumerable: true, get: function () { return issueChargeCardReducer_1.clearAiCardCreationFormDraft; } });
|
|
1622
1623
|
Object.defineProperty(exports, "fetchDepositAccountListForCards", { enumerable: true, get: function () { return issueChargeCardReducer_1.fetchDepositAccountListForCards; } });
|
|
@@ -2380,15 +2381,55 @@ Object.defineProperty(exports, "toUpdateCardPolicyTemplateRequestBody", { enumer
|
|
|
2380
2381
|
// Create flow (bulk POST /policy-templates — single-policy callers wrap
|
|
2381
2382
|
// their one request in a length-1 `templates` array).
|
|
2382
2383
|
var createCardPolicyReducer_1 = require("./view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyReducer");
|
|
2384
|
+
Object.defineProperty(exports, "applyExtractedPolicyToAiCardPolicyDraft", { enumerable: true, get: function () { return createCardPolicyReducer_1.applyExtractedPolicyToAiCardPolicyDraft; } });
|
|
2385
|
+
Object.defineProperty(exports, "applyExtractedPolicyToManualCardPolicyDraft", { enumerable: true, get: function () { return createCardPolicyReducer_1.applyExtractedPolicyToManualCardPolicyDraft; } });
|
|
2386
|
+
Object.defineProperty(exports, "clearAiCardPolicyFormDraft", { enumerable: true, get: function () { return createCardPolicyReducer_1.clearAiCardPolicyFormDraft; } });
|
|
2383
2387
|
Object.defineProperty(exports, "clearCreateCardPolicy", { enumerable: true, get: function () { return createCardPolicyReducer_1.clearCreateCardPolicy; } });
|
|
2388
|
+
Object.defineProperty(exports, "clearManualCardPolicyFormDraft", { enumerable: true, get: function () { return createCardPolicyReducer_1.clearManualCardPolicyFormDraft; } });
|
|
2384
2389
|
Object.defineProperty(exports, "createCardPolicyTemplates", { enumerable: true, get: function () { return createCardPolicyReducer_1.createCardPolicyTemplates; } });
|
|
2390
|
+
Object.defineProperty(exports, "seedAiCardPolicyFormDraft", { enumerable: true, get: function () { return createCardPolicyReducer_1.seedAiCardPolicyFormDraft; } });
|
|
2391
|
+
Object.defineProperty(exports, "seedManualCardPolicyFormDraft", { enumerable: true, get: function () { return createCardPolicyReducer_1.seedManualCardPolicyFormDraft; } });
|
|
2392
|
+
Object.defineProperty(exports, "updateAiCardPolicyFormDraft", { enumerable: true, get: function () { return createCardPolicyReducer_1.updateAiCardPolicyFormDraft; } });
|
|
2393
|
+
Object.defineProperty(exports, "updateAiCardPolicyFormDraftFromUploadPlan", { enumerable: true, get: function () { return createCardPolicyReducer_1.updateAiCardPolicyFormDraftFromUploadPlan; } });
|
|
2385
2394
|
Object.defineProperty(exports, "updateCreateCardPolicyTemplateRequestState", { enumerable: true, get: function () { return createCardPolicyReducer_1.updateCreateCardPolicyTemplateRequestState; } });
|
|
2395
|
+
Object.defineProperty(exports, "updateManualCardPolicyFormDraft", { enumerable: true, get: function () { return createCardPolicyReducer_1.updateManualCardPolicyFormDraft; } });
|
|
2386
2396
|
var createCardPolicySelector_1 = require("./view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicySelector");
|
|
2397
|
+
Object.defineProperty(exports, "getAiCardPolicyFormDraft", { enumerable: true, get: function () { return createCardPolicySelector_1.getAiCardPolicyFormDraft; } });
|
|
2387
2398
|
Object.defineProperty(exports, "getCreateCardPolicyTemplateRequestState", { enumerable: true, get: function () { return createCardPolicySelector_1.getCreateCardPolicyTemplateRequestState; } });
|
|
2388
2399
|
Object.defineProperty(exports, "getLastCreateCardPolicySourceChatSessionId", { enumerable: true, get: function () { return createCardPolicySelector_1.getLastCreateCardPolicySourceChatSessionId; } });
|
|
2389
2400
|
Object.defineProperty(exports, "getLastCreateCardPolicyTemplateErrors", { enumerable: true, get: function () { return createCardPolicySelector_1.getLastCreateCardPolicyTemplateErrors; } });
|
|
2390
2401
|
Object.defineProperty(exports, "getLastCreatedCardPolicyTemplateId", { enumerable: true, get: function () { return createCardPolicySelector_1.getLastCreatedCardPolicyTemplateId; } });
|
|
2391
2402
|
Object.defineProperty(exports, "getLastCreatedCardPolicyTemplateIds", { enumerable: true, get: function () { return createCardPolicySelector_1.getLastCreatedCardPolicyTemplateIds; } });
|
|
2403
|
+
Object.defineProperty(exports, "getManualCardPolicyFormDraft", { enumerable: true, get: function () { return createCardPolicySelector_1.getManualCardPolicyFormDraft; } });
|
|
2404
|
+
// Card policy form draft types + helpers (consumed by the AI CFO
|
|
2405
|
+
// `CardPolicyInteractiveForm` and the manual `CardPolicyCreatePage`).
|
|
2406
|
+
var cardPolicyFormDraftTypes_1 = require("./view/spendManagement/chargeCards/cardPolicy/createCardPolicy/cardPolicyFormDraftTypes");
|
|
2407
|
+
Object.defineProperty(exports, "CARD_POLICY_LIMIT_ROW_ID_REQUIRE_RECEIPT", { enumerable: true, get: function () { return cardPolicyFormDraftTypes_1.CARD_POLICY_LIMIT_ROW_ID_REQUIRE_RECEIPT; } });
|
|
2408
|
+
Object.defineProperty(exports, "CARD_POLICY_LIMIT_ROW_ID_TRANSACTION", { enumerable: true, get: function () { return cardPolicyFormDraftTypes_1.CARD_POLICY_LIMIT_ROW_ID_TRANSACTION; } });
|
|
2409
|
+
Object.defineProperty(exports, "toMccCategoryLike", { enumerable: true, get: function () { return cardPolicyFormDraftTypes_1.toMccCategoryLike; } });
|
|
2410
|
+
var cardPolicyChipIds_1 = require("./view/spendManagement/chargeCards/cardPolicy/createCardPolicy/cardPolicyChipIds");
|
|
2411
|
+
Object.defineProperty(exports, "MCC_CHIP_ID_PREFIX", { enumerable: true, get: function () { return cardPolicyChipIds_1.MCC_CHIP_ID_PREFIX; } });
|
|
2412
|
+
Object.defineProperty(exports, "VENDOR_CHIP_ID_PREFIX", { enumerable: true, get: function () { return cardPolicyChipIds_1.VENDOR_CHIP_ID_PREFIX; } });
|
|
2413
|
+
Object.defineProperty(exports, "buildMccCategoryChipId", { enumerable: true, get: function () { return cardPolicyChipIds_1.buildMccCategoryChipId; } });
|
|
2414
|
+
Object.defineProperty(exports, "buildVendorChipId", { enumerable: true, get: function () { return cardPolicyChipIds_1.buildVendorChipId; } });
|
|
2415
|
+
Object.defineProperty(exports, "toMccCategoryChipFieldValue", { enumerable: true, get: function () { return cardPolicyChipIds_1.toMccCategoryChipFieldValue; } });
|
|
2416
|
+
Object.defineProperty(exports, "toVendorChipFieldValue", { enumerable: true, get: function () { return cardPolicyChipIds_1.toVendorChipFieldValue; } });
|
|
2417
|
+
var buildAiCardPolicyFormDraftSeed_1 = require("./view/spendManagement/chargeCards/cardPolicy/createCardPolicy/buildAiCardPolicyFormDraftSeed");
|
|
2418
|
+
Object.defineProperty(exports, "buildAiCardPolicyFormDraftSeed", { enumerable: true, get: function () { return buildAiCardPolicyFormDraftSeed_1.buildAiCardPolicyFormDraftSeed; } });
|
|
2419
|
+
Object.defineProperty(exports, "buildEmptyLimitRows", { enumerable: true, get: function () { return buildAiCardPolicyFormDraftSeed_1.buildEmptyLimitRows; } });
|
|
2420
|
+
Object.defineProperty(exports, "buildUploadReviewRows", { enumerable: true, get: function () { return buildAiCardPolicyFormDraftSeed_1.buildUploadReviewRows; } });
|
|
2421
|
+
var buildManualCardPolicyFormDraftSeed_1 = require("./view/spendManagement/chargeCards/cardPolicy/createCardPolicy/buildManualCardPolicyFormDraftSeed");
|
|
2422
|
+
Object.defineProperty(exports, "buildManualCardPolicyFormDraftSeed", { enumerable: true, get: function () { return buildManualCardPolicyFormDraftSeed_1.buildManualCardPolicyFormDraftSeed; } });
|
|
2423
|
+
var deriveAiPolicyReviewRowsFromInputs_1 = require("./view/spendManagement/chargeCards/cardPolicy/createCardPolicy/deriveAiPolicyReviewRowsFromInputs");
|
|
2424
|
+
Object.defineProperty(exports, "deriveAiPolicyReviewRowsFromInputs", { enumerable: true, get: function () { return deriveAiPolicyReviewRowsFromInputs_1.deriveAiPolicyReviewRowsFromInputs; } });
|
|
2425
|
+
var applyAiCardPolicyFormDraftUpdate_1 = require("./view/spendManagement/chargeCards/cardPolicy/createCardPolicy/applyAiCardPolicyFormDraftUpdate");
|
|
2426
|
+
Object.defineProperty(exports, "applyAiCardPolicyFormDraftUpdate", { enumerable: true, get: function () { return applyAiCardPolicyFormDraftUpdate_1.applyAiCardPolicyFormDraftUpdate; } });
|
|
2427
|
+
var toCardPolicyTemplateRequestFromDraft_1 = require("./view/spendManagement/chargeCards/cardPolicy/createCardPolicy/toCardPolicyTemplateRequestFromDraft");
|
|
2428
|
+
Object.defineProperty(exports, "toCardPolicyTemplateRequestFromDraft", { enumerable: true, get: function () { return toCardPolicyTemplateRequestFromDraft_1.toCardPolicyTemplateRequestFromDraft; } });
|
|
2429
|
+
var toBulkCardPolicyTemplateRequestsFromDraft_1 = require("./view/spendManagement/chargeCards/cardPolicy/createCardPolicy/toBulkCardPolicyTemplateRequestsFromDraft");
|
|
2430
|
+
Object.defineProperty(exports, "toBulkCardPolicyTemplateRequestsFromDraft", { enumerable: true, get: function () { return toBulkCardPolicyTemplateRequestsFromDraft_1.toBulkCardPolicyTemplateRequestsFromDraft; } });
|
|
2431
|
+
var toManualCardPolicyTemplateRequestFromDraft_1 = require("./view/spendManagement/chargeCards/cardPolicy/createCardPolicy/toManualCardPolicyTemplateRequestFromDraft");
|
|
2432
|
+
Object.defineProperty(exports, "toManualCardPolicyTemplateRequestFromDraft", { enumerable: true, get: function () { return toManualCardPolicyTemplateRequestFromDraft_1.toManualCardPolicyTemplateRequestFromDraft; } });
|
|
2392
2433
|
// List
|
|
2393
2434
|
var cardPolicyListReducer_1 = require("./view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListReducer");
|
|
2394
2435
|
Object.defineProperty(exports, "archiveCardPolicy", { enumerable: true, get: function () { return cardPolicyListReducer_1.archiveCardPolicy; } });
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { AiCardPolicyFormDraftSeedContext, CardPolicyCardSelectionRow, CardPolicyFormDraft, CardPolicyReviewRow } from './cardPolicyFormDraftTypes';
|
|
2
|
+
export interface ApplyAiCardPolicyFormDraftUpdateArgs {
|
|
3
|
+
context: AiCardPolicyFormDraftSeedContext | undefined;
|
|
4
|
+
next: CardPolicyFormDraft;
|
|
5
|
+
prev: CardPolicyFormDraft | undefined;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Single source of truth for "what the next AI card-policy form draft
|
|
9
|
+
* should look like after a `watchHandler` flush".
|
|
10
|
+
*
|
|
11
|
+
* Branches on `next.policyKind`:
|
|
12
|
+
*
|
|
13
|
+
* - `auto`: pass-through. Chip groups on `policiesReview` are the
|
|
14
|
+
* canonical source of truth; the source slices stay empty.
|
|
15
|
+
*
|
|
16
|
+
* - `guided`: mirrors review-step chip edits (diffed against
|
|
17
|
+
* `prev.policiesReview`) back into the source slices
|
|
18
|
+
* (`vendorPolicy` / `categoryPolicy` / `cardSelections` / `limits`),
|
|
19
|
+
* then re-derives `policiesReview` from the bridged source slices
|
|
20
|
+
* via `deriveAiPolicyReviewRowsFromInputs` so the review always
|
|
21
|
+
* reflects the freshest live state. Replaces the
|
|
22
|
+
* `useReviewChipEditBridge` hook that previously lived in
|
|
23
|
+
* `CardPolicyInteractiveForm`.
|
|
24
|
+
*
|
|
25
|
+
* - `upload`: passes through the user's chip edits on
|
|
26
|
+
* `policiesReview` (the wire reads from those chip groups). The
|
|
27
|
+
* "Applied to Cards" chip group is patched in-place from
|
|
28
|
+
* `cardSelections` (the user's Step 2 picks).
|
|
29
|
+
*/
|
|
30
|
+
export declare const applyAiCardPolicyFormDraftUpdate: ({ next, prev, context, }: ApplyAiCardPolicyFormDraftUpdateArgs) => CardPolicyFormDraft;
|
|
31
|
+
/**
|
|
32
|
+
* Replace (or insert) the "Applied to Cards" chip group on every
|
|
33
|
+
* upload review row with avatar chips derived from the current
|
|
34
|
+
* `cardSelections`. The new group is inserted before the "Limits"
|
|
35
|
+
* group so the visual order stays Vendors → Categories → Cards →
|
|
36
|
+
* Limits.
|
|
37
|
+
*/
|
|
38
|
+
export declare const patchUploadReviewWithAppliedCards: (reviewRows: CardPolicyReviewRow[], cardSelections: CardPolicyCardSelectionRow[]) => CardPolicyReviewRow[];
|
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.patchUploadReviewWithAppliedCards = exports.applyAiCardPolicyFormDraftUpdate = void 0;
|
|
4
|
+
const deriveAiPolicyReviewRowsFromInputs_1 = require("./deriveAiPolicyReviewRowsFromInputs");
|
|
5
|
+
/**
|
|
6
|
+
* Single source of truth for "what the next AI card-policy form draft
|
|
7
|
+
* should look like after a `watchHandler` flush".
|
|
8
|
+
*
|
|
9
|
+
* Branches on `next.policyKind`:
|
|
10
|
+
*
|
|
11
|
+
* - `auto`: pass-through. Chip groups on `policiesReview` are the
|
|
12
|
+
* canonical source of truth; the source slices stay empty.
|
|
13
|
+
*
|
|
14
|
+
* - `guided`: mirrors review-step chip edits (diffed against
|
|
15
|
+
* `prev.policiesReview`) back into the source slices
|
|
16
|
+
* (`vendorPolicy` / `categoryPolicy` / `cardSelections` / `limits`),
|
|
17
|
+
* then re-derives `policiesReview` from the bridged source slices
|
|
18
|
+
* via `deriveAiPolicyReviewRowsFromInputs` so the review always
|
|
19
|
+
* reflects the freshest live state. Replaces the
|
|
20
|
+
* `useReviewChipEditBridge` hook that previously lived in
|
|
21
|
+
* `CardPolicyInteractiveForm`.
|
|
22
|
+
*
|
|
23
|
+
* - `upload`: passes through the user's chip edits on
|
|
24
|
+
* `policiesReview` (the wire reads from those chip groups). The
|
|
25
|
+
* "Applied to Cards" chip group is patched in-place from
|
|
26
|
+
* `cardSelections` (the user's Step 2 picks).
|
|
27
|
+
*/
|
|
28
|
+
const applyAiCardPolicyFormDraftUpdate = ({ next, prev, context, }) => {
|
|
29
|
+
if (next.policyKind === 'auto') {
|
|
30
|
+
return next;
|
|
31
|
+
}
|
|
32
|
+
if (next.policyKind === 'upload') {
|
|
33
|
+
return applyUploadUpdate({ next, prev });
|
|
34
|
+
}
|
|
35
|
+
return applyGuidedUpdate({ next, prev, context });
|
|
36
|
+
};
|
|
37
|
+
exports.applyAiCardPolicyFormDraftUpdate = applyAiCardPolicyFormDraftUpdate;
|
|
38
|
+
const applyGuidedUpdate = ({ next, prev, context, }) => {
|
|
39
|
+
const bridged = bridgeGuidedPoliciesReviewToSources({ next, prev });
|
|
40
|
+
if (context == null) {
|
|
41
|
+
return bridged;
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
...bridged,
|
|
45
|
+
policiesReview: (0, deriveAiPolicyReviewRowsFromInputs_1.deriveAiPolicyReviewRowsFromInputs)({
|
|
46
|
+
vendorPolicy: bridged.vendorPolicy,
|
|
47
|
+
categoryPolicy: bridged.categoryPolicy,
|
|
48
|
+
cardSelections: bridged.cardSelections,
|
|
49
|
+
limits: bridged.limits,
|
|
50
|
+
suggestedPoliciesSeed: context.suggestedPoliciesSeed,
|
|
51
|
+
prevPoliciesReview: bridged.policiesReview,
|
|
52
|
+
}),
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
const APPLIED_TO_CARDS_GROUP_ID = 'applied-to-cards';
|
|
56
|
+
const LIMITS_GROUP_ID = 'limits';
|
|
57
|
+
const applyUploadUpdate = ({ next, prev, }) => {
|
|
58
|
+
// Mirror review-side avatar / limits edits into source slices so the
|
|
59
|
+
// bulk-submit builder (which reads `cardSelections` for upload's
|
|
60
|
+
// applyToCards) sees the user's latest intent.
|
|
61
|
+
const bridged = bridgeUploadPoliciesReviewToSources({ next, prev });
|
|
62
|
+
if (!haveCardSelectionsChanged(prev?.cardSelections, bridged.cardSelections)) {
|
|
63
|
+
return bridged;
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
...bridged,
|
|
67
|
+
policiesReview: (0, exports.patchUploadReviewWithAppliedCards)(bridged.policiesReview, bridged.cardSelections),
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
const haveCardSelectionsChanged = (prevSelections, nextSelections) => {
|
|
71
|
+
const prevCheckedIds = (prevSelections ?? [])
|
|
72
|
+
.filter((row) => row.isChecked)
|
|
73
|
+
.map((row) => row.id);
|
|
74
|
+
const nextCheckedIds = nextSelections
|
|
75
|
+
.filter((row) => row.isChecked)
|
|
76
|
+
.map((row) => row.id);
|
|
77
|
+
if (prevCheckedIds.length !== nextCheckedIds.length) {
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
return prevCheckedIds.some((id, idx) => id !== nextCheckedIds[idx]);
|
|
81
|
+
};
|
|
82
|
+
const buildAppliedOwnerSummaries = (cardSelections) => {
|
|
83
|
+
const summaries = new Map();
|
|
84
|
+
for (const card of cardSelections) {
|
|
85
|
+
if (!card.isChecked) {
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
const existing = summaries.get(card.owner.userId);
|
|
89
|
+
if (existing != null) {
|
|
90
|
+
existing.cardIds.push(card.id);
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
summaries.set(card.owner.userId, {
|
|
94
|
+
userId: card.owner.userId,
|
|
95
|
+
displayName: card.owner.displayName,
|
|
96
|
+
cardIds: [card.id],
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
return Array.from(summaries.values());
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* Replace (or insert) the "Applied to Cards" chip group on every
|
|
103
|
+
* upload review row with avatar chips derived from the current
|
|
104
|
+
* `cardSelections`. The new group is inserted before the "Limits"
|
|
105
|
+
* group so the visual order stays Vendors → Categories → Cards →
|
|
106
|
+
* Limits.
|
|
107
|
+
*/
|
|
108
|
+
const patchUploadReviewWithAppliedCards = (reviewRows, cardSelections) => {
|
|
109
|
+
const owners = buildAppliedOwnerSummaries(cardSelections);
|
|
110
|
+
const cardChips = owners.map((owner) => ({
|
|
111
|
+
id: owner.userId,
|
|
112
|
+
label: owner.displayName,
|
|
113
|
+
chipKind: 'avatar',
|
|
114
|
+
cardIds: owner.cardIds,
|
|
115
|
+
isSelected: true,
|
|
116
|
+
}));
|
|
117
|
+
const cardsGroup = cardChips.length > 0
|
|
118
|
+
? {
|
|
119
|
+
id: APPLIED_TO_CARDS_GROUP_ID,
|
|
120
|
+
label: 'Applied to Cards',
|
|
121
|
+
chips: cardChips,
|
|
122
|
+
}
|
|
123
|
+
: null;
|
|
124
|
+
return reviewRows.map((row) => {
|
|
125
|
+
const withoutCards = row.chipGroups.filter((group) => group.id !== APPLIED_TO_CARDS_GROUP_ID);
|
|
126
|
+
if (cardsGroup == null) {
|
|
127
|
+
return { ...row, chipGroups: withoutCards };
|
|
128
|
+
}
|
|
129
|
+
const limitsIdx = withoutCards.findIndex((group) => group.id === LIMITS_GROUP_ID);
|
|
130
|
+
if (limitsIdx === -1) {
|
|
131
|
+
return { ...row, chipGroups: [...withoutCards, cardsGroup] };
|
|
132
|
+
}
|
|
133
|
+
const before = withoutCards.slice(0, limitsIdx);
|
|
134
|
+
const after = withoutCards.slice(limitsIdx);
|
|
135
|
+
return { ...row, chipGroups: [...before, cardsGroup, ...after] };
|
|
136
|
+
});
|
|
137
|
+
};
|
|
138
|
+
exports.patchUploadReviewWithAppliedCards = patchUploadReviewWithAppliedCards;
|
|
139
|
+
/**
|
|
140
|
+
* Mirror diffs in `next.policiesReview` chips back into the source
|
|
141
|
+
* slices for guided mode. Detects per-chip `isSelected` and
|
|
142
|
+
* `optionalCode` changes vs `prev` and writes them to:
|
|
143
|
+
* - `limits` for `kind: "limits"` group chips,
|
|
144
|
+
* - `cardSelections` for avatar chips, and
|
|
145
|
+
* - `vendorPolicy` / `categoryPolicy` for positive/negative chips.
|
|
146
|
+
*/
|
|
147
|
+
const bridgeGuidedPoliciesReviewToSources = ({ next, prev, }) => {
|
|
148
|
+
if (prev == null || prev.policiesReview.length === 0) {
|
|
149
|
+
return next;
|
|
150
|
+
}
|
|
151
|
+
const reviewDiffs = collectReviewChipDiffs(prev.policiesReview, next.policiesReview);
|
|
152
|
+
if (reviewDiffs.length === 0) {
|
|
153
|
+
return next;
|
|
154
|
+
}
|
|
155
|
+
let limits = next.limits;
|
|
156
|
+
let cardSelections = next.cardSelections;
|
|
157
|
+
let vendorPolicy = next.vendorPolicy;
|
|
158
|
+
let categoryPolicy = next.categoryPolicy;
|
|
159
|
+
for (const diff of reviewDiffs) {
|
|
160
|
+
if (diff.groupKind === 'limits' || diff.chip.id.startsWith('limit-')) {
|
|
161
|
+
limits = applyLimitChipDiffToLimits(limits, diff);
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
if (diff.chip.chipKind === 'avatar') {
|
|
165
|
+
cardSelections = applyAvatarChipDiffToCardSelections(cardSelections, diff);
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
if (diff.changedFields.has('isSelected')) {
|
|
169
|
+
const writtenToVendor = tryWriteAllowBlock(vendorPolicy, diff);
|
|
170
|
+
if (writtenToVendor != null) {
|
|
171
|
+
vendorPolicy = writtenToVendor;
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
const writtenToCategory = tryWriteAllowBlock(categoryPolicy, diff);
|
|
175
|
+
if (writtenToCategory != null) {
|
|
176
|
+
categoryPolicy = writtenToCategory;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
return {
|
|
181
|
+
...next,
|
|
182
|
+
limits,
|
|
183
|
+
cardSelections,
|
|
184
|
+
vendorPolicy,
|
|
185
|
+
categoryPolicy,
|
|
186
|
+
};
|
|
187
|
+
};
|
|
188
|
+
/**
|
|
189
|
+
* Upload-mode bridge — narrower than guided. Vendor / category chips in
|
|
190
|
+
* the review are the wire's source of truth (no source slice to write
|
|
191
|
+
* back to); avatar chips mirror into `cardSelections` (the wire's
|
|
192
|
+
* `applyToCards` projection for upload reads from there); limit chips
|
|
193
|
+
* are read from the review chip group directly by the wire, so no
|
|
194
|
+
* mirror is needed.
|
|
195
|
+
*/
|
|
196
|
+
const bridgeUploadPoliciesReviewToSources = ({ next, prev, }) => {
|
|
197
|
+
if (prev == null || prev.policiesReview.length === 0) {
|
|
198
|
+
return next;
|
|
199
|
+
}
|
|
200
|
+
const reviewDiffs = collectReviewChipDiffs(prev.policiesReview, next.policiesReview);
|
|
201
|
+
if (reviewDiffs.length === 0) {
|
|
202
|
+
return next;
|
|
203
|
+
}
|
|
204
|
+
let cardSelections = next.cardSelections;
|
|
205
|
+
for (const diff of reviewDiffs) {
|
|
206
|
+
if (diff.chip.chipKind === 'avatar') {
|
|
207
|
+
cardSelections = applyAvatarChipDiffToCardSelections(cardSelections, diff);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
if (cardSelections === next.cardSelections) {
|
|
211
|
+
return next;
|
|
212
|
+
}
|
|
213
|
+
return { ...next, cardSelections };
|
|
214
|
+
};
|
|
215
|
+
const collectReviewChipDiffs = (prevRows, nextRows) => {
|
|
216
|
+
const prevById = new Map(prevRows.map((row) => [row.id, row]));
|
|
217
|
+
const diffs = [];
|
|
218
|
+
for (const row of nextRows) {
|
|
219
|
+
const prevRow = prevById.get(row.id);
|
|
220
|
+
if (prevRow == null) {
|
|
221
|
+
continue;
|
|
222
|
+
}
|
|
223
|
+
const prevGroupsById = new Map(prevRow.chipGroups.map((group) => [group.id, group]));
|
|
224
|
+
for (const group of row.chipGroups) {
|
|
225
|
+
const prevGroup = prevGroupsById.get(group.id);
|
|
226
|
+
if (prevGroup == null) {
|
|
227
|
+
continue;
|
|
228
|
+
}
|
|
229
|
+
const prevChipsById = new Map(prevGroup.chips.map((chip) => [chip.id, chip]));
|
|
230
|
+
for (const chip of group.chips) {
|
|
231
|
+
const prevChip = prevChipsById.get(chip.id);
|
|
232
|
+
if (prevChip == null) {
|
|
233
|
+
continue;
|
|
234
|
+
}
|
|
235
|
+
const changed = new Set();
|
|
236
|
+
if (chip.isSelected !== prevChip.isSelected) {
|
|
237
|
+
changed.add('isSelected');
|
|
238
|
+
}
|
|
239
|
+
if (chip.optionalCode !== prevChip.optionalCode) {
|
|
240
|
+
changed.add('optionalCode');
|
|
241
|
+
}
|
|
242
|
+
if (changed.size > 0) {
|
|
243
|
+
diffs.push({ chip, changedFields: changed, groupKind: group.kind });
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
return diffs;
|
|
249
|
+
};
|
|
250
|
+
const REVIEW_LIMIT_CHIP_ID_TO_LIMIT_ROW_ID = {
|
|
251
|
+
'limit-transaction': 'transactionLimit',
|
|
252
|
+
'limit-receipt': 'requireReceipt',
|
|
253
|
+
};
|
|
254
|
+
const applyLimitChipDiffToLimits = (limits, diff) => {
|
|
255
|
+
const mapped = REVIEW_LIMIT_CHIP_ID_TO_LIMIT_ROW_ID[diff.chip.id];
|
|
256
|
+
const directMatch = limits.find((row) => row.id === diff.chip.id) != null;
|
|
257
|
+
const rowId = mapped ?? (directMatch ? diff.chip.id : undefined);
|
|
258
|
+
if (rowId == null) {
|
|
259
|
+
return limits;
|
|
260
|
+
}
|
|
261
|
+
const idx = limits.findIndex((row) => row.id === rowId);
|
|
262
|
+
if (idx === -1) {
|
|
263
|
+
return limits;
|
|
264
|
+
}
|
|
265
|
+
let nextRow = limits[idx];
|
|
266
|
+
if (diff.changedFields.has('isSelected')) {
|
|
267
|
+
nextRow = { ...nextRow, isEnabled: diff.chip.isSelected === true };
|
|
268
|
+
}
|
|
269
|
+
if (diff.changedFields.has('optionalCode')) {
|
|
270
|
+
const raw = diff.chip.optionalCode;
|
|
271
|
+
const numericNext = raw != null && raw !== '' ? Number(raw) : undefined;
|
|
272
|
+
nextRow = { ...nextRow, amount: numericNext };
|
|
273
|
+
}
|
|
274
|
+
if (nextRow === limits[idx]) {
|
|
275
|
+
return limits;
|
|
276
|
+
}
|
|
277
|
+
const copy = limits.slice();
|
|
278
|
+
copy[idx] = nextRow;
|
|
279
|
+
return copy;
|
|
280
|
+
};
|
|
281
|
+
const applyAvatarChipDiffToCardSelections = (cardSelections, diff) => {
|
|
282
|
+
if (!diff.changedFields.has('isSelected')) {
|
|
283
|
+
return cardSelections;
|
|
284
|
+
}
|
|
285
|
+
const targetIds = diff.chip.cardIds != null && diff.chip.cardIds.length > 0
|
|
286
|
+
? diff.chip.cardIds
|
|
287
|
+
: [diff.chip.id];
|
|
288
|
+
const targetSet = new Set(targetIds);
|
|
289
|
+
let mutated = false;
|
|
290
|
+
const next = cardSelections.map((row) => {
|
|
291
|
+
if (!targetSet.has(row.id)) {
|
|
292
|
+
return row;
|
|
293
|
+
}
|
|
294
|
+
const desired = diff.chip.isSelected === true;
|
|
295
|
+
if (row.isChecked === desired) {
|
|
296
|
+
return row;
|
|
297
|
+
}
|
|
298
|
+
mutated = true;
|
|
299
|
+
return { ...row, isChecked: desired };
|
|
300
|
+
});
|
|
301
|
+
return mutated ? next : cardSelections;
|
|
302
|
+
};
|
|
303
|
+
const tryWriteAllowBlock = (field, diff) => {
|
|
304
|
+
const desired = diff.chip.isSelected === true;
|
|
305
|
+
const written = tryFlipItemInSide(field.allowItems, diff, desired);
|
|
306
|
+
if (written != null) {
|
|
307
|
+
return { ...field, allowItems: written };
|
|
308
|
+
}
|
|
309
|
+
const writtenBlock = tryFlipItemInSide(field.blockItems, diff, desired);
|
|
310
|
+
if (writtenBlock != null) {
|
|
311
|
+
return { ...field, blockItems: writtenBlock };
|
|
312
|
+
}
|
|
313
|
+
return null;
|
|
314
|
+
};
|
|
315
|
+
const tryFlipItemInSide = (items, diff, desired) => {
|
|
316
|
+
let idx = items.findIndex((item) => item.id === diff.chip.id);
|
|
317
|
+
if (idx === -1 && diff.chip.optionalCode != null) {
|
|
318
|
+
// Auto / upload mode category chips use the raw MCC code as
|
|
319
|
+
// `chip.id` while the source items use `mcc-{name}`; fall back to
|
|
320
|
+
// matching by code so the bridge round-trips both shapes.
|
|
321
|
+
idx = items.findIndex((item) => item.optionalCode === diff.chip.optionalCode ||
|
|
322
|
+
(item.optionalCodes ?? []).includes(diff.chip.optionalCode ?? ''));
|
|
323
|
+
}
|
|
324
|
+
if (idx === -1) {
|
|
325
|
+
return null;
|
|
326
|
+
}
|
|
327
|
+
if (items[idx].isSelected === desired) {
|
|
328
|
+
return items;
|
|
329
|
+
}
|
|
330
|
+
const copy = items.slice();
|
|
331
|
+
copy[idx] = { ...items[idx], isSelected: desired };
|
|
332
|
+
return copy;
|
|
333
|
+
};
|