@zeniai/client-epic-state 5.0.65-betaRR5 → 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.
Files changed (51) hide show
  1. package/lib/entity/aiCfo/aiCfoPayload.d.ts +67 -64
  2. package/lib/entity/aiCfo/aiCfoReducer.d.ts +7 -1
  3. package/lib/entity/aiCfo/aiCfoReducer.js +87 -56
  4. package/lib/entity/aiCfo/aiCfoState.d.ts +58 -59
  5. package/lib/entity/cardPolicy/cardPolicyPayload.d.ts +106 -5
  6. package/lib/entity/cardPolicy/cardPolicyPayload.js +35 -4
  7. package/lib/entity/cardPolicy/cardPolicyReducer.d.ts +9 -3
  8. package/lib/entity/cardPolicy/cardPolicyReducer.js +57 -4
  9. package/lib/entity/cardPolicy/cardPolicySelector.d.ts +4 -0
  10. package/lib/entity/cardPolicy/cardPolicySelector.js +17 -0
  11. package/lib/entity/cardPolicy/cardPolicyState.d.ts +33 -0
  12. package/lib/entity/cardPolicy/policyDocumentExtractionToRecommendationBridgeEpic.d.ts +25 -0
  13. package/lib/entity/cardPolicy/policyDocumentExtractionToRecommendationBridgeEpic.js +39 -0
  14. package/lib/entity/cardPolicy/policyRecommendationFromUploadEpic.d.ts +23 -0
  15. package/lib/entity/cardPolicy/policyRecommendationFromUploadEpic.js +92 -0
  16. package/lib/epic.d.ts +3 -1
  17. package/lib/epic.js +3 -1
  18. package/lib/esm/entity/aiCfo/aiCfoReducer.js +86 -55
  19. package/lib/esm/entity/cardPolicy/cardPolicyPayload.js +32 -3
  20. package/lib/esm/entity/cardPolicy/cardPolicyReducer.js +56 -3
  21. package/lib/esm/entity/cardPolicy/cardPolicySelector.js +13 -0
  22. package/lib/esm/entity/cardPolicy/policyDocumentExtractionToRecommendationBridgeEpic.js +35 -0
  23. package/lib/esm/entity/cardPolicy/policyRecommendationFromUploadEpic.js +88 -0
  24. package/lib/esm/epic.js +4 -2
  25. package/lib/esm/index.js +10 -9
  26. package/lib/esm/view/aiCfoView/aiCfoViewReducer.js +6 -3
  27. package/lib/esm/view/aiCfoView/epics/createSessionAndSubmitEpic.js +5 -2
  28. package/lib/esm/view/aiCfoView/epics/createSessionEpic.js +2 -1
  29. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyReducer.js +22 -13
  30. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicySelector.js +26 -1
  31. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyTemplateEpic.js +27 -8
  32. package/lib/esm/view/spendManagement/chargeCards/chargeCardList/chargeCardListSelector.js +25 -0
  33. package/lib/index.d.ts +10 -10
  34. package/lib/index.js +29 -15
  35. package/lib/view/aiCfoView/aiCfoViewReducer.d.ts +4 -2
  36. package/lib/view/aiCfoView/aiCfoViewReducer.js +6 -3
  37. package/lib/view/aiCfoView/epics/createSessionAndSubmitEpic.js +5 -2
  38. package/lib/view/aiCfoView/epics/createSessionEpic.js +2 -1
  39. package/lib/view/companyHealthMetricView/companyHealthMetricViewSelector.d.ts +1 -1
  40. package/lib/view/onboardingView/cockpitView/types/onboardingCockpitViewTypes.d.ts +1 -1
  41. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyReducer.d.ts +4 -3
  42. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyReducer.js +23 -14
  43. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicySelector.d.ts +22 -0
  44. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicySelector.js +28 -1
  45. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyState.d.ts +29 -8
  46. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyTemplateEpic.d.ts +20 -3
  47. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyTemplateEpic.js +27 -8
  48. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardList.d.ts +1 -1
  49. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListSelector.d.ts +14 -0
  50. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListSelector.js +27 -1
  51. package/package.json +1 -1
@@ -1,24 +1,43 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createCardPolicyTemplateEpic = void 0;
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
- const createCardPolicyTemplateEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(createCardPolicyReducer_1.createCardPolicyTemplate.match), (0, operators_1.mergeMap)((action) => {
11
- const body = (0, cardPolicyPayload_1.toCreateCardPolicyTemplateRequestBody)(action.payload);
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 { template } = response.data;
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
- templateId: template.template_id,
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 template REST API call errored out' +
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.createCardPolicyTemplateEpic = createCardPolicyTemplateEpic;
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" | "cardName" | "owner" | "accountType" | "limit" | "cardType" | "utilisation";
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";
@@ -54,7 +54,21 @@ export interface MyPendingActivationChargeCardListSelectorView extends SelectorV
54
54
  export interface ChargeCardListWithShippingAddressSelectorView extends SelectorView {
55
55
  cards: ChargeCardWithUserAndShippingAddress[];
56
56
  }
57
+ export interface AllChargeCardsWithUserSelectorView extends SelectorView {
58
+ cards: ChargeCardWithUser[];
59
+ }
57
60
  export declare const getChargeCardListView: (state: RootState, includeCreditAccountDebitSummaryAndCashbackInfo: boolean, isDebitCardEnabled: boolean, isCreditCardEnabled: boolean) => ChargeCardListSelectorView;
61
+ /**
62
+ * Returns every enriched `ChargeCardWithUser` for the tenant, without
63
+ * applying the cards-list screen's `searchText` filter or its column
64
+ * `sortKey/sortOrder`. Used by surfaces that need the raw card universe
65
+ * decoupled from whatever the user has typed/sorted on the cards list
66
+ * (e.g. the Card Policy "Apply to Cards" picker, which owns its own
67
+ * search + sort UI). The list-screen's filter/sort state is intentionally
68
+ * left untouched so revisits to the cards list still restore the user's
69
+ * search.
70
+ */
71
+ export declare const getAllChargeCardsWithUser: (state: RootState) => AllChargeCardsWithUserSelectorView;
58
72
  export declare const getMyPendingActivationChargeCardListView: (state: RootState) => MyPendingActivationChargeCardListSelectorView;
59
73
  export declare const getMyRequestOnHoldChargeCardListWithShippingAddress: (state: RootState) => ChargeCardListWithShippingAddressSelectorView;
60
74
  /**
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getChargeCardBulkActionView = exports.getChargeCardRowActionView = exports.getChargeCardRecurringExpensesByCardIds = exports.getDebitCardSummary = exports.getDebitCardList = exports.getDepositAccountListWithDebitCardIssued = exports.getCreditAccountDetails = exports.anyCardOnHold = exports.getMyRequestOnHoldChargeCardListWithShippingAddress = exports.getMyPendingActivationChargeCardListView = exports.getChargeCardListView = void 0;
6
+ exports.getChargeCardBulkActionView = exports.getChargeCardRowActionView = exports.getChargeCardRecurringExpensesByCardIds = exports.getDebitCardSummary = exports.getDebitCardList = exports.getDepositAccountListWithDebitCardIssued = exports.getCreditAccountDetails = exports.anyCardOnHold = exports.getMyRequestOnHoldChargeCardListWithShippingAddress = exports.getMyPendingActivationChargeCardListView = exports.getAllChargeCardsWithUser = exports.getChargeCardListView = void 0;
7
7
  const toolkit_1 = require("@reduxjs/toolkit");
8
8
  const orderBy_1 = __importDefault(require("lodash/orderBy"));
9
9
  const sortOrderPayload_1 = require("../../../../commonPayloadTypes/sortOrderPayload");
@@ -94,6 +94,32 @@ const getChargeCardListView = (state, includeCreditAccountDebitSummaryAndCashbac
94
94
  };
95
95
  };
96
96
  exports.getChargeCardListView = getChargeCardListView;
97
+ /**
98
+ * Returns every enriched `ChargeCardWithUser` for the tenant, without
99
+ * applying the cards-list screen's `searchText` filter or its column
100
+ * `sortKey/sortOrder`. Used by surfaces that need the raw card universe
101
+ * decoupled from whatever the user has typed/sorted on the cards list
102
+ * (e.g. the Card Policy "Apply to Cards" picker, which owns its own
103
+ * search + sort UI). The list-screen's filter/sort state is intentionally
104
+ * left untouched so revisits to the cards list still restore the user's
105
+ * search.
106
+ */
107
+ const getAllChargeCardsWithUser = (state) => {
108
+ const { chargeCardListState, chargeCardState, chargeCardConfigState } = state;
109
+ const cards = (0, chargeCardSelector_1.getChargeCardsByIds)(chargeCardState, chargeCardListState.cardIds);
110
+ const chargeCardsWithUser = getChargeCardsWithUser(cards, state);
111
+ const fetchState = (0, reduceFetchState_1.reduceFetchState)([
112
+ chargeCardListState,
113
+ chargeCardConfigState,
114
+ ]).fetchState;
115
+ return {
116
+ fetchState,
117
+ error: chargeCardListState.error,
118
+ cards: chargeCardsWithUser,
119
+ version: '1.0',
120
+ };
121
+ };
122
+ exports.getAllChargeCardsWithUser = getAllChargeCardsWithUser;
97
123
  const getMyPendingActivationChargeCardListView = (state) => {
98
124
  const { tenantState, chargeCardListState, chargeCardState } = state;
99
125
  const cards = (0, chargeCardSelector_1.getChargeCardsByIds)(chargeCardState, chargeCardListState.cardIds);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "5.0.65-betaRR5",
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",