@zeniai/client-epic-state 5.0.65-betaRR6 → 5.0.65-betaRR7
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 +67 -64
- package/lib/entity/aiCfo/aiCfoReducer.d.ts +7 -1
- package/lib/entity/aiCfo/aiCfoReducer.js +87 -56
- package/lib/entity/aiCfo/aiCfoState.d.ts +58 -59
- package/lib/entity/cardPolicy/cardPolicyPayload.d.ts +106 -5
- package/lib/entity/cardPolicy/cardPolicyPayload.js +35 -4
- package/lib/entity/cardPolicy/cardPolicyReducer.d.ts +9 -3
- package/lib/entity/cardPolicy/cardPolicyReducer.js +57 -4
- package/lib/entity/cardPolicy/cardPolicySelector.d.ts +4 -0
- package/lib/entity/cardPolicy/cardPolicySelector.js +17 -0
- package/lib/entity/cardPolicy/cardPolicyState.d.ts +33 -0
- package/lib/entity/cardPolicy/policyDocumentExtractionToRecommendationBridgeEpic.d.ts +25 -0
- package/lib/entity/cardPolicy/policyDocumentExtractionToRecommendationBridgeEpic.js +39 -0
- package/lib/entity/cardPolicy/policyRecommendationFromUploadEpic.d.ts +23 -0
- package/lib/entity/cardPolicy/policyRecommendationFromUploadEpic.js +92 -0
- package/lib/epic.d.ts +3 -1
- package/lib/epic.js +3 -1
- package/lib/esm/entity/aiCfo/aiCfoReducer.js +86 -55
- package/lib/esm/entity/cardPolicy/cardPolicyPayload.js +32 -3
- package/lib/esm/entity/cardPolicy/cardPolicyReducer.js +56 -3
- package/lib/esm/entity/cardPolicy/cardPolicySelector.js +13 -0
- package/lib/esm/entity/cardPolicy/policyDocumentExtractionToRecommendationBridgeEpic.js +35 -0
- package/lib/esm/entity/cardPolicy/policyRecommendationFromUploadEpic.js +88 -0
- package/lib/esm/epic.js +4 -2
- package/lib/esm/index.js +8 -7
- package/lib/esm/view/aiCfoView/aiCfoViewReducer.js +6 -3
- package/lib/esm/view/aiCfoView/epics/createSessionAndSubmitEpic.js +5 -2
- package/lib/esm/view/aiCfoView/epics/createSessionEpic.js +2 -1
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyReducer.js +22 -13
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicySelector.js +26 -1
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyTemplateEpic.js +27 -8
- package/lib/index.d.ts +8 -8
- package/lib/index.js +19 -6
- package/lib/view/aiCfoView/aiCfoViewReducer.d.ts +4 -2
- package/lib/view/aiCfoView/aiCfoViewReducer.js +6 -3
- package/lib/view/aiCfoView/epics/createSessionAndSubmitEpic.js +5 -2
- package/lib/view/aiCfoView/epics/createSessionEpic.js +2 -1
- package/lib/view/companyHealthMetricView/companyHealthMetricViewSelector.d.ts +1 -1
- package/lib/view/onboardingView/cockpitView/types/onboardingCockpitViewTypes.d.ts +1 -1
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyReducer.d.ts +4 -3
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyReducer.js +23 -14
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicySelector.d.ts +22 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicySelector.js +28 -1
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyState.d.ts +29 -8
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyTemplateEpic.d.ts +20 -3
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyTemplateEpic.js +27 -8
- package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardList.d.ts +1 -1
- package/package.json +1 -1
|
@@ -69,8 +69,11 @@ function waitForChannelSubscription(pusherInstance, channelName, timeoutMs = 500
|
|
|
69
69
|
}));
|
|
70
70
|
}
|
|
71
71
|
const createSessionAndSubmitEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(aiCfoViewReducer_1.createSessionAndSubmit.match), (0, operators_1.switchMap)((action) => {
|
|
72
|
-
const { agentId, userId, questionAnswerId, questionId, createdAt, question, files, } = action.payload;
|
|
73
|
-
const payload = {
|
|
72
|
+
const { agentId, userId, questionAnswerId, questionId, createdAt, question, files, pageContext, } = action.payload;
|
|
73
|
+
const payload = {
|
|
74
|
+
agent_id: agentId,
|
|
75
|
+
...(pageContext != null && { page_context: pageContext }),
|
|
76
|
+
};
|
|
74
77
|
return zeniAPI
|
|
75
78
|
.postAndGetJSON(`${zeniAPI.apiEndPoints.aiCfoMicroServiceBaseUrl}/1.0/sessions`, payload)
|
|
76
79
|
.pipe((0, operators_1.mergeMap)((response) => {
|
|
@@ -8,11 +8,12 @@ const responsePayload_1 = require("../../../responsePayload");
|
|
|
8
8
|
const zeniDayJS_1 = require("../../../zeniDayJS");
|
|
9
9
|
const aiCfoViewReducer_1 = require("../aiCfoViewReducer");
|
|
10
10
|
const createSessionEpic = (actions$, _, zeniAPI) => actions$.pipe((0, operators_1.filter)(aiCfoViewReducer_1.createSession.match), (0, operators_1.switchMap)((action) => {
|
|
11
|
-
const { agentId, contextRefId, contextType, userId } = action.payload;
|
|
11
|
+
const { agentId, contextRefId, contextType, pageContext, userId } = action.payload;
|
|
12
12
|
const payload = {
|
|
13
13
|
agent_id: agentId,
|
|
14
14
|
...(contextRefId != null && { context_ref_id: contextRefId }),
|
|
15
15
|
...(contextType != null && { context_type: contextType }),
|
|
16
|
+
...(pageContext != null && { page_context: pageContext }),
|
|
16
17
|
};
|
|
17
18
|
return zeniAPI
|
|
18
19
|
.postAndGetJSON(`${zeniAPI.apiEndPoints.aiCfoMicroServiceBaseUrl}/1.0/sessions`, payload)
|
|
@@ -13,7 +13,7 @@ declare const toFrequencyLabelType: (v: string) => "High" | "Low" | "Very Low" |
|
|
|
13
13
|
type FrequencyLabelType = ReturnType<typeof toFrequencyLabelType>;
|
|
14
14
|
declare const toFrequencyValueType: (v: string) => "high" | "low" | "very_low" | "mid" | "very_high";
|
|
15
15
|
type FrequencyValueType = ReturnType<typeof toFrequencyValueType>;
|
|
16
|
-
declare const toProductServiceKeyType: (v: string) => "reimbursement" | "
|
|
16
|
+
declare const toProductServiceKeyType: (v: string) => "reimbursement" | "accounts" | "cards" | "billpay" | "zeni_tax_plan" | "cfo_plan" | "payroll_manager_service_plan";
|
|
17
17
|
export type ProductServiceKey = ReturnType<typeof toProductServiceKeyType>;
|
|
18
18
|
export type CompanyHealthMetricDropDownOption = {
|
|
19
19
|
label: FrequencyLabelType;
|
|
@@ -3,7 +3,7 @@ import { CompanyWithSchema } from '../../../../entity/company/companySelector';
|
|
|
3
3
|
import { OnboardingCustomerInfo } from '../../../../entity/onboardingCustomer/onboardingCustomerState';
|
|
4
4
|
import { Tenant } from '../../../../entity/tenant/tenantState';
|
|
5
5
|
import { CompanyDetailsLocalData, PrimaryContactLocalData } from '../../../spendManagement/commonSetup/setupViewState';
|
|
6
|
-
declare const toProductGroupType: (v: string) => "
|
|
6
|
+
declare const toProductGroupType: (v: string) => "other" | "bookkeeping" | "banking" | "spend_management" | "cards";
|
|
7
7
|
export type ProductGroupType = ReturnType<typeof toProductGroupType>;
|
|
8
8
|
export declare const toProductType: (v: string) => "zeni_treasury" | "other" | "bookkeeping" | "zeni_checking" | "zeni_bill_pay" | "zeni_reimbursements" | "zeni_cards" | "zeni_payroll" | "zeni_cfo" | "zeni_tax";
|
|
9
9
|
export declare const toProductTypeStrict: (v: string) => "zeni_treasury" | "other" | "bookkeeping" | "zeni_checking" | "zeni_bill_pay" | "zeni_reimbursements" | "zeni_cards" | "zeni_payroll" | "zeni_cfo" | "zeni_tax" | undefined;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { FetchState, ID } from '../../../../../commonStateTypes/common';
|
|
2
|
-
import {
|
|
2
|
+
import { BulkCreateCardPolicyTemplateError, CreateCardPolicyTemplatesRequest } from '../../../../../entity/cardPolicy/cardPolicyPayload';
|
|
3
3
|
import { ZeniAPIStatus } from '../../../../../responsePayload';
|
|
4
4
|
import { CreateCardPolicyState } from './createCardPolicyState';
|
|
5
5
|
export declare const initialState: CreateCardPolicyState;
|
|
6
|
-
export declare const
|
|
6
|
+
export declare const createCardPolicyTemplates: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[request: CreateCardPolicyTemplatesRequest], CreateCardPolicyTemplatesRequest, "createCardPolicy/createCardPolicyTemplates", never, never>, updateCreateCardPolicyTemplateRequestState: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
7
7
|
fetchState: FetchState;
|
|
8
8
|
error?: ZeniAPIStatus;
|
|
9
|
-
|
|
9
|
+
perItemErrors?: BulkCreateCardPolicyTemplateError[];
|
|
10
|
+
templateIds?: ID[];
|
|
10
11
|
}, "createCardPolicy/updateCreateCardPolicyTemplateRequestState">, clearCreateCardPolicy: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"createCardPolicy/clearCreateCardPolicy">;
|
|
11
12
|
declare const _default: import("redux").Reducer<CreateCardPolicyState>;
|
|
12
13
|
export default _default;
|
package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyReducer.js
CHANGED
|
@@ -1,37 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var _a;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.clearCreateCardPolicy = exports.updateCreateCardPolicyTemplateRequestState = exports.
|
|
4
|
+
exports.clearCreateCardPolicy = exports.updateCreateCardPolicyTemplateRequestState = exports.createCardPolicyTemplates = exports.initialState = void 0;
|
|
5
5
|
const toolkit_1 = require("@reduxjs/toolkit");
|
|
6
6
|
exports.initialState = {
|
|
7
7
|
createCardPolicyTemplateRequestState: {
|
|
8
8
|
fetchState: 'Not-Started',
|
|
9
9
|
error: undefined,
|
|
10
10
|
},
|
|
11
|
-
|
|
11
|
+
lastCreatedCardPolicyTemplateIds: [],
|
|
12
|
+
lastCreateCardPolicyTemplateErrors: [],
|
|
12
13
|
};
|
|
13
14
|
const createCardPolicy = (0, toolkit_1.createSlice)({
|
|
14
15
|
name: 'createCardPolicy',
|
|
15
16
|
initialState: exports.initialState,
|
|
16
17
|
reducers: {
|
|
17
18
|
/**
|
|
18
|
-
* Kick off the `POST /cards/1.0/policy-templates` request.
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
19
|
+
* Kick off the bulk `POST /cards/1.0/policy-templates` request.
|
|
20
|
+
* Single-create callers pass a length-1 `templates` array; AI CFO
|
|
21
|
+
* multi-policy callers pass N entries in one round-trip. Setting the
|
|
22
|
+
* request state to `In-Progress` synchronously here matches how every
|
|
23
|
+
* other "create" slice in this repo wires its kickoff (see
|
|
24
|
+
* `issueChargeCards`, `fetchChargeCardConfig`, etc.).
|
|
22
25
|
*
|
|
23
26
|
* The accompanying epic listens for this action, performs the POST,
|
|
24
|
-
* dispatches `updateCreatedCardPolicyTemplate` on the entity
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
+
* dispatches one `updateCreatedCardPolicyTemplate` on the entity
|
|
28
|
+
* slice per row returned in `templates_created`, and dispatches
|
|
29
|
+
* `updateCreateCardPolicyTemplateRequestState` here to flip the
|
|
30
|
+
* lifecycle to `Completed` (with the created ids + any per-item
|
|
31
|
+
* errors) or `Error` (transport-level failure).
|
|
27
32
|
*/
|
|
28
|
-
|
|
33
|
+
createCardPolicyTemplates: {
|
|
29
34
|
reducer(draft,
|
|
30
35
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
31
36
|
_action) {
|
|
32
37
|
draft.createCardPolicyTemplateRequestState.fetchState = 'In-Progress';
|
|
33
38
|
draft.createCardPolicyTemplateRequestState.error = undefined;
|
|
34
|
-
draft.
|
|
39
|
+
draft.lastCreatedCardPolicyTemplateIds = [];
|
|
40
|
+
draft.lastCreateCardPolicyTemplateErrors = [];
|
|
35
41
|
},
|
|
36
42
|
prepare(request) {
|
|
37
43
|
return { payload: request };
|
|
@@ -41,8 +47,11 @@ const createCardPolicy = (0, toolkit_1.createSlice)({
|
|
|
41
47
|
draft.createCardPolicyTemplateRequestState.fetchState =
|
|
42
48
|
action.payload.fetchState;
|
|
43
49
|
draft.createCardPolicyTemplateRequestState.error = action.payload.error;
|
|
44
|
-
if (action.payload.
|
|
45
|
-
draft.
|
|
50
|
+
if (action.payload.templateIds != null) {
|
|
51
|
+
draft.lastCreatedCardPolicyTemplateIds = action.payload.templateIds;
|
|
52
|
+
}
|
|
53
|
+
if (action.payload.perItemErrors != null) {
|
|
54
|
+
draft.lastCreateCardPolicyTemplateErrors = action.payload.perItemErrors;
|
|
46
55
|
}
|
|
47
56
|
},
|
|
48
57
|
clearCreateCardPolicy(draft) {
|
|
@@ -50,5 +59,5 @@ const createCardPolicy = (0, toolkit_1.createSlice)({
|
|
|
50
59
|
},
|
|
51
60
|
},
|
|
52
61
|
});
|
|
53
|
-
_a = createCardPolicy.actions, exports.
|
|
62
|
+
_a = createCardPolicy.actions, exports.createCardPolicyTemplates = _a.createCardPolicyTemplates, exports.updateCreateCardPolicyTemplateRequestState = _a.updateCreateCardPolicyTemplateRequestState, exports.clearCreateCardPolicy = _a.clearCreateCardPolicy;
|
|
54
63
|
exports.default = createCardPolicy.reducer;
|
|
@@ -1,4 +1,26 @@
|
|
|
1
1
|
import { FetchStateAndError, ID } from '../../../../../commonStateTypes/common';
|
|
2
|
+
import { BulkCreateCardPolicyTemplateError } from '../../../../../entity/cardPolicy/cardPolicyPayload';
|
|
2
3
|
import { CreateCardPolicyState } from './createCardPolicyState';
|
|
3
4
|
export declare function getCreateCardPolicyTemplateRequestState(state: CreateCardPolicyState): FetchStateAndError;
|
|
5
|
+
/**
|
|
6
|
+
* All template ids created by the most recent successful bulk submit
|
|
7
|
+
* (in BE return order). Empty array before any submit or after
|
|
8
|
+
* `clearCreateCardPolicy`. Multi-policy AI CFO submit reads this; the
|
|
9
|
+
* single-policy `getLastCreatedCardPolicyTemplateId` selector below is a
|
|
10
|
+
* convenience for the manual-create routing flow.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getLastCreatedCardPolicyTemplateIds(state: CreateCardPolicyState): ID[];
|
|
13
|
+
/**
|
|
14
|
+
* Convenience selector returning the first id of the most recent submit
|
|
15
|
+
* — kept ergonomic for the single-create page's "navigate to detail on
|
|
16
|
+
* success" logic, which only ever creates one template. Returns
|
|
17
|
+
* `undefined` when no submit has succeeded or when the list is empty.
|
|
18
|
+
*/
|
|
4
19
|
export declare function getLastCreatedCardPolicyTemplateId(state: CreateCardPolicyState): ID | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Per-item errors returned by the bulk POST when one or more templates
|
|
22
|
+
* failed to persist. Empty on full success; populated on partial success
|
|
23
|
+
* so the UI can render a "N of M created" banner alongside the navigate /
|
|
24
|
+
* close behaviour driven by the lifecycle selector.
|
|
25
|
+
*/
|
|
26
|
+
export declare function getLastCreateCardPolicyTemplateErrors(state: CreateCardPolicyState): BulkCreateCardPolicyTemplateError[];
|
package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicySelector.js
CHANGED
|
@@ -1,10 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getCreateCardPolicyTemplateRequestState = getCreateCardPolicyTemplateRequestState;
|
|
4
|
+
exports.getLastCreatedCardPolicyTemplateIds = getLastCreatedCardPolicyTemplateIds;
|
|
4
5
|
exports.getLastCreatedCardPolicyTemplateId = getLastCreatedCardPolicyTemplateId;
|
|
6
|
+
exports.getLastCreateCardPolicyTemplateErrors = getLastCreateCardPolicyTemplateErrors;
|
|
5
7
|
function getCreateCardPolicyTemplateRequestState(state) {
|
|
6
8
|
return state.createCardPolicyTemplateRequestState;
|
|
7
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* All template ids created by the most recent successful bulk submit
|
|
12
|
+
* (in BE return order). Empty array before any submit or after
|
|
13
|
+
* `clearCreateCardPolicy`. Multi-policy AI CFO submit reads this; the
|
|
14
|
+
* single-policy `getLastCreatedCardPolicyTemplateId` selector below is a
|
|
15
|
+
* convenience for the manual-create routing flow.
|
|
16
|
+
*/
|
|
17
|
+
function getLastCreatedCardPolicyTemplateIds(state) {
|
|
18
|
+
return state.lastCreatedCardPolicyTemplateIds;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Convenience selector returning the first id of the most recent submit
|
|
22
|
+
* — kept ergonomic for the single-create page's "navigate to detail on
|
|
23
|
+
* success" logic, which only ever creates one template. Returns
|
|
24
|
+
* `undefined` when no submit has succeeded or when the list is empty.
|
|
25
|
+
*/
|
|
8
26
|
function getLastCreatedCardPolicyTemplateId(state) {
|
|
9
|
-
return state.
|
|
27
|
+
return state.lastCreatedCardPolicyTemplateIds[0];
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Per-item errors returned by the bulk POST when one or more templates
|
|
31
|
+
* failed to persist. Empty on full success; populated on partial success
|
|
32
|
+
* so the UI can render a "N of M created" banner alongside the navigate /
|
|
33
|
+
* close behaviour driven by the lifecycle selector.
|
|
34
|
+
*/
|
|
35
|
+
function getLastCreateCardPolicyTemplateErrors(state) {
|
|
36
|
+
return state.lastCreateCardPolicyTemplateErrors;
|
|
10
37
|
}
|
package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyState.d.ts
CHANGED
|
@@ -1,15 +1,36 @@
|
|
|
1
1
|
import { FetchStateAndError, ID } from '../../../../../commonStateTypes/common';
|
|
2
|
+
import { BulkCreateCardPolicyTemplateError } from '../../../../../entity/cardPolicy/cardPolicyPayload';
|
|
2
3
|
/**
|
|
3
|
-
* View-side scaffolding for the
|
|
4
|
+
* View-side scaffolding for the Card Policy "create" flow.
|
|
4
5
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* and
|
|
6
|
+
* `POST /cards/1.0/policy-templates` is now a bulk endpoint — both the
|
|
7
|
+
* manual create page and the AI CFO submit pass an array of templates
|
|
8
|
+
* (single-element today; multi-element when AI CFO multi-policy review
|
|
9
|
+
* lands). The slice tracks one request lifecycle for the whole submit
|
|
10
|
+
* and captures the per-template ids + errors on success.
|
|
11
|
+
*
|
|
12
|
+
* List + edit lifecycles live in sibling slices (`cardPolicyList`,
|
|
13
|
+
* `cardPolicyDetail`); MCC categories used by the create form live on
|
|
14
|
+
* the entity slice (shared with the AI-CFO flow) and are fetched via the
|
|
15
|
+
* co-located `fetchCardPolicyMccCategoriesEpic`.
|
|
10
16
|
*/
|
|
11
17
|
export interface CreateCardPolicyState {
|
|
12
18
|
createCardPolicyTemplateRequestState: FetchStateAndError;
|
|
13
|
-
/**
|
|
14
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Per-item failures returned alongside `templates_created` on the bulk
|
|
21
|
+
* response. Empty on full success; populated on partial success so the
|
|
22
|
+
* UI can render a "N of M created" banner. Cleared when a new submit
|
|
23
|
+
* starts and by `clearCreateCardPolicy`.
|
|
24
|
+
*/
|
|
25
|
+
lastCreateCardPolicyTemplateErrors: BulkCreateCardPolicyTemplateError[];
|
|
26
|
+
/**
|
|
27
|
+
* `templateId`s of the templates created by the most recent successful
|
|
28
|
+
* bulk submit, in the order they were returned by the BE. Empty when no
|
|
29
|
+
* submit has succeeded yet or after `clearCreateCardPolicy`.
|
|
30
|
+
*
|
|
31
|
+
* For the single-policy case this holds exactly one id; the
|
|
32
|
+
* `getLastCreatedCardPolicyTemplateId` selector returns `[0]` for
|
|
33
|
+
* ergonomic single-create routing.
|
|
34
|
+
*/
|
|
35
|
+
lastCreatedCardPolicyTemplateIds: ID[];
|
|
15
36
|
}
|
|
@@ -3,6 +3,23 @@ import { Observable } from 'rxjs';
|
|
|
3
3
|
import { updateCreatedCardPolicyTemplate } from '../../../../../entity/cardPolicy/cardPolicyReducer';
|
|
4
4
|
import { RootState } from '../../../../../reducer';
|
|
5
5
|
import { ZeniAPI } from '../../../../../zeniAPI';
|
|
6
|
-
import {
|
|
7
|
-
export type ActionType = ReturnType<typeof
|
|
8
|
-
|
|
6
|
+
import { createCardPolicyTemplates, updateCreateCardPolicyTemplateRequestState } from './createCardPolicyReducer';
|
|
7
|
+
export type ActionType = ReturnType<typeof createCardPolicyTemplates> | ReturnType<typeof updateCreatedCardPolicyTemplate> | ReturnType<typeof updateCreateCardPolicyTemplateRequestState>;
|
|
8
|
+
/**
|
|
9
|
+
* `POST /cards/1.0/policy-templates` (bulk). Builds the bulk wire body
|
|
10
|
+
* from the camelCased action payload, sends one round-trip, and on
|
|
11
|
+
* success fans out:
|
|
12
|
+
* - one `updateCreatedCardPolicyTemplate` on the entity slice per row
|
|
13
|
+
* in `templates_created` (so the entity store is hydrated with every
|
|
14
|
+
* created template), and
|
|
15
|
+
* - one `updateCreateCardPolicyTemplateRequestState` with the ordered
|
|
16
|
+
* id list + per-item errors so the view can render partial-success
|
|
17
|
+
* UX without re-touching the wire types.
|
|
18
|
+
*
|
|
19
|
+
* Partial success (`errors.length > 0` with at least one template
|
|
20
|
+
* created) is still treated as `Completed` — the lifecycle is binary
|
|
21
|
+
* and the per-item errors live on the slice for the UI to inspect.
|
|
22
|
+
* Hard failures (non-success `status` or thrown errors) map to `Error`
|
|
23
|
+
* the same way they did pre-bulk.
|
|
24
|
+
*/
|
|
25
|
+
export declare const createCardPolicyTemplatesEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
|
@@ -1,24 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.createCardPolicyTemplatesEpic = void 0;
|
|
4
4
|
const rxjs_1 = require("rxjs");
|
|
5
5
|
const operators_1 = require("rxjs/operators");
|
|
6
6
|
const cardPolicyReducer_1 = require("../../../../../entity/cardPolicy/cardPolicyReducer");
|
|
7
7
|
const cardPolicyPayload_1 = require("../../../../../entity/cardPolicy/cardPolicyPayload");
|
|
8
8
|
const responsePayload_1 = require("../../../../../responsePayload");
|
|
9
9
|
const createCardPolicyReducer_1 = require("./createCardPolicyReducer");
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
/**
|
|
11
|
+
* `POST /cards/1.0/policy-templates` (bulk). Builds the bulk wire body
|
|
12
|
+
* from the camelCased action payload, sends one round-trip, and on
|
|
13
|
+
* success fans out:
|
|
14
|
+
* - one `updateCreatedCardPolicyTemplate` on the entity slice per row
|
|
15
|
+
* in `templates_created` (so the entity store is hydrated with every
|
|
16
|
+
* created template), and
|
|
17
|
+
* - one `updateCreateCardPolicyTemplateRequestState` with the ordered
|
|
18
|
+
* id list + per-item errors so the view can render partial-success
|
|
19
|
+
* UX without re-touching the wire types.
|
|
20
|
+
*
|
|
21
|
+
* Partial success (`errors.length > 0` with at least one template
|
|
22
|
+
* created) is still treated as `Completed` — the lifecycle is binary
|
|
23
|
+
* and the per-item errors live on the slice for the UI to inspect.
|
|
24
|
+
* Hard failures (non-success `status` or thrown errors) map to `Error`
|
|
25
|
+
* the same way they did pre-bulk.
|
|
26
|
+
*/
|
|
27
|
+
const createCardPolicyTemplatesEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(createCardPolicyReducer_1.createCardPolicyTemplates.match), (0, operators_1.mergeMap)((action) => {
|
|
28
|
+
const body = (0, cardPolicyPayload_1.toCreateCardPolicyTemplatesRequestBody)(action.payload);
|
|
12
29
|
return zeniAPI
|
|
13
30
|
.postAndGetJSON(`${zeniAPI.apiEndPoints.cardMicroServiceBaseUrl}/1.0/policy-templates`, body)
|
|
14
31
|
.pipe((0, operators_1.mergeMap)((response) => {
|
|
15
32
|
if ((0, responsePayload_1.isSuccessStatus)(response) && response.data != null) {
|
|
16
|
-
const {
|
|
33
|
+
const { templates_created, errors } = response.data;
|
|
34
|
+
const createdTemplates = templates_created.map((row) => row.template);
|
|
17
35
|
const actions = [
|
|
18
|
-
(0, cardPolicyReducer_1.updateCreatedCardPolicyTemplate)(template),
|
|
36
|
+
...createdTemplates.map((template) => (0, cardPolicyReducer_1.updateCreatedCardPolicyTemplate)(template)),
|
|
19
37
|
(0, createCardPolicyReducer_1.updateCreateCardPolicyTemplateRequestState)({
|
|
20
38
|
fetchState: 'Completed',
|
|
21
|
-
|
|
39
|
+
perItemErrors: (errors ?? []).map(cardPolicyPayload_1.toBulkCreateCardPolicyTemplateError),
|
|
40
|
+
templateIds: createdTemplates.map((template) => template.template_id),
|
|
22
41
|
}),
|
|
23
42
|
];
|
|
24
43
|
return (0, rxjs_1.from)(actions);
|
|
@@ -31,8 +50,8 @@ const createCardPolicyTemplateEpic = (actions$, _state$, zeniAPI) => actions$.pi
|
|
|
31
50
|
}
|
|
32
51
|
}), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, createCardPolicyReducer_1.updateCreateCardPolicyTemplateRequestState)({
|
|
33
52
|
fetchState: 'Error',
|
|
34
|
-
error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Create card-policy
|
|
53
|
+
error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Create card-policy templates REST API call errored out' +
|
|
35
54
|
JSON.stringify(error)),
|
|
36
55
|
}))));
|
|
37
56
|
}));
|
|
38
|
-
exports.
|
|
57
|
+
exports.createCardPolicyTemplatesEpic = createCardPolicyTemplatesEpic;
|
|
@@ -61,7 +61,7 @@ export declare const initialCreditAcc: CreditAccount;
|
|
|
61
61
|
export declare const initialDebitCardSummaries: DebitCardSummaries;
|
|
62
62
|
export declare const initialResendRevokeCardInvite: ResendRevokeCardInvite;
|
|
63
63
|
export declare const initialCreditAccountRepayment: CreditAccountRepayment;
|
|
64
|
-
export declare const toChargeCardSortKeyType: (v: string) => "status" | "department" | "
|
|
64
|
+
export declare const toChargeCardSortKeyType: (v: string) => "status" | "department" | "accountType" | "owner" | "cardName" | "limit" | "cardType" | "utilisation";
|
|
65
65
|
export declare type ChargeCardViewSortKey = ReturnType<typeof toChargeCardSortKeyType>;
|
|
66
66
|
export declare const ALL_CASHBACK_SORT_KEYS: readonly ["month", "cashback"];
|
|
67
67
|
export declare const toCashbackSortKeyType: (v: string) => "month" | "cashback";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeniai/client-epic-state",
|
|
3
|
-
"version": "5.0.65-
|
|
3
|
+
"version": "5.0.65-betaRR7",
|
|
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",
|