@zeniai/client-epic-state 5.0.65-betaML2 → 5.0.65-betaRR1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/lib/entity/aiCfo/aiCfoPayload.d.ts +135 -1
  2. package/lib/entity/aiCfo/aiCfoReducer.js +111 -2
  3. package/lib/entity/aiCfo/aiCfoState.d.ts +141 -4
  4. package/lib/entity/aiCfo/aiCfoState.js +10 -1
  5. package/lib/entity/cardPolicy/cardPolicyPayload.d.ts +171 -0
  6. package/lib/entity/cardPolicy/cardPolicyPayload.js +112 -0
  7. package/lib/entity/cardPolicy/cardPolicyReducer.d.ts +13 -0
  8. package/lib/entity/cardPolicy/cardPolicyReducer.js +184 -0
  9. package/lib/entity/cardPolicy/cardPolicySelector.d.ts +28 -0
  10. package/lib/entity/cardPolicy/cardPolicySelector.js +86 -0
  11. package/lib/entity/cardPolicy/cardPolicyState.d.ts +162 -0
  12. package/lib/entity/cardPolicy/cardPolicyState.js +14 -0
  13. package/lib/entity/cardPolicy/extractPolicyDocumentEpic.d.ts +18 -0
  14. package/lib/entity/cardPolicy/extractPolicyDocumentEpic.js +54 -0
  15. package/lib/entity/cardPolicy/fetchCardPolicyVendorOptionsEpic.d.ts +26 -0
  16. package/lib/entity/cardPolicy/fetchCardPolicyVendorOptionsEpic.js +47 -0
  17. package/lib/entity/tenant/clearAllEpic.d.ts +6 -2
  18. package/lib/entity/tenant/clearAllEpic.js +8 -0
  19. package/lib/epic.d.ts +9 -2
  20. package/lib/epic.js +9 -2
  21. package/lib/esm/entity/aiCfo/aiCfoReducer.js +112 -3
  22. package/lib/esm/entity/aiCfo/aiCfoState.js +7 -0
  23. package/lib/esm/entity/cardPolicy/cardPolicyPayload.js +101 -0
  24. package/lib/esm/entity/cardPolicy/cardPolicyReducer.js +180 -0
  25. package/lib/esm/entity/cardPolicy/cardPolicySelector.js +66 -0
  26. package/lib/esm/entity/cardPolicy/cardPolicyState.js +9 -0
  27. package/lib/esm/entity/cardPolicy/extractPolicyDocumentEpic.js +50 -0
  28. package/lib/esm/entity/cardPolicy/fetchCardPolicyVendorOptionsEpic.js +43 -0
  29. package/lib/esm/entity/tenant/clearAllEpic.js +8 -0
  30. package/lib/esm/epic.js +9 -2
  31. package/lib/esm/index.js +21 -7
  32. package/lib/esm/reducer.js +12 -0
  33. package/lib/esm/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.js +1 -21
  34. package/lib/esm/view/expenseAutomationView/reducers/transactionsViewReducer.js +14 -117
  35. package/lib/esm/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +0 -28
  36. package/lib/esm/view/recommendation/recommendationHelper.js +0 -29
  37. package/lib/esm/view/recommendation/recommendationReducer.js +1 -36
  38. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailReducer.js +70 -0
  39. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailSelector.js +22 -0
  40. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailState.js +1 -0
  41. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/fetchCardPolicyDetailEpic.js +44 -0
  42. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/updateCardPolicyEpic.js +49 -0
  43. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/archiveCardPolicyEpic.js +42 -0
  44. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListReducer.js +72 -0
  45. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListSelector.js +21 -0
  46. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListState.js +1 -0
  47. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/fetchCardPolicyListEpic.js +46 -0
  48. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyReducer.js +50 -0
  49. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicySelector.js +6 -0
  50. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyState.js +1 -0
  51. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyTemplateEpic.js +34 -0
  52. package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/fetchCardPolicyMccCategoriesEpic.js +17 -0
  53. package/lib/esm/view/transactionDetail/transactionDetailReducer.js +1 -110
  54. package/lib/esm/view/transactionDetail/transactionDetailSelector.js +0 -22
  55. package/lib/index.d.ts +20 -8
  56. package/lib/index.js +119 -35
  57. package/lib/reducer.d.ts +12 -0
  58. package/lib/reducer.js +12 -0
  59. package/lib/view/companyHealthMetricView/companyHealthMetricViewSelector.d.ts +1 -1
  60. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +0 -1
  61. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.js +2 -23
  62. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +1 -14
  63. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.js +14 -117
  64. package/lib/view/expenseAutomationView/selectorTypes/transactionsViewSelectorTypes.d.ts +0 -2
  65. package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.d.ts +0 -3
  66. package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +0 -29
  67. package/lib/view/expenseAutomationView/types/transactionsViewState.d.ts +0 -1
  68. package/lib/view/onboardingView/cockpitView/types/onboardingCockpitViewTypes.d.ts +1 -1
  69. package/lib/view/people/peopleTypes.d.ts +1 -1
  70. package/lib/view/recommendation/recommendationHelper.d.ts +0 -9
  71. package/lib/view/recommendation/recommendationHelper.js +1 -31
  72. package/lib/view/recommendation/recommendationReducer.d.ts +1 -18
  73. package/lib/view/recommendation/recommendationReducer.js +2 -37
  74. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailReducer.d.ts +14 -0
  75. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailReducer.js +74 -0
  76. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailSelector.d.ts +21 -0
  77. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailSelector.js +28 -0
  78. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailState.d.ts +25 -0
  79. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailState.js +2 -0
  80. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/fetchCardPolicyDetailEpic.d.ts +19 -0
  81. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/fetchCardPolicyDetailEpic.js +48 -0
  82. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/updateCardPolicyEpic.d.ts +18 -0
  83. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/updateCardPolicyEpic.js +53 -0
  84. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/archiveCardPolicyEpic.d.ts +16 -0
  85. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/archiveCardPolicyEpic.js +46 -0
  86. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListReducer.d.ts +15 -0
  87. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListReducer.js +76 -0
  88. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListSelector.d.ts +21 -0
  89. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListSelector.js +27 -0
  90. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListState.d.ts +19 -0
  91. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListState.js +2 -0
  92. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/fetchCardPolicyListEpic.d.ts +19 -0
  93. package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/fetchCardPolicyListEpic.js +50 -0
  94. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyReducer.d.ts +12 -0
  95. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyReducer.js +54 -0
  96. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicySelector.d.ts +4 -0
  97. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicySelector.js +10 -0
  98. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyState.d.ts +15 -0
  99. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyState.js +2 -0
  100. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyTemplateEpic.d.ts +8 -0
  101. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyTemplateEpic.js +38 -0
  102. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/fetchCardPolicyMccCategoriesEpic.d.ts +15 -0
  103. package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/fetchCardPolicyMccCategoriesEpic.js +21 -0
  104. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardList.d.ts +1 -1
  105. package/lib/view/taskManager/taskListView/taskListReducer.d.ts +1 -1
  106. package/lib/view/transactionDetail/transactionDetailReducer.d.ts +1 -11
  107. package/lib/view/transactionDetail/transactionDetailReducer.js +2 -111
  108. package/lib/view/transactionDetail/transactionDetailSelector.d.ts +0 -2
  109. package/lib/view/transactionDetail/transactionDetailSelector.js +1 -24
  110. package/lib/view/transactionDetail/transactionDetailTypes.d.ts +0 -1
  111. package/package.json +1 -1
  112. package/lib/esm/view/recommendation/fetchEntityRecommendationsForLineUpdateEpic.js +0 -88
  113. package/lib/tsconfig.typecheck.tsbuildinfo +0 -1
  114. package/lib/view/recommendation/fetchEntityRecommendationsForLineUpdateEpic.d.ts +0 -9
  115. package/lib/view/recommendation/fetchEntityRecommendationsForLineUpdateEpic.js +0 -92
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  var _a;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.clearRecommendation = exports.indicateReadyToInitializeRecommendation = exports.updateRecommendationForEntityFailure = exports.updateRecommendationForEntity = exports.fetchRecommendationByEntityId = exports.fetchRecommendationByEntityName = exports.fetchEntityRecommendationsForLineUpdate = exports.fetchEntityRecommendationsByTransactionId = exports.initialState = void 0;
4
+ exports.clearRecommendation = exports.indicateReadyToInitializeRecommendation = exports.updateRecommendationForEntityFailure = exports.updateRecommendationForEntity = exports.fetchRecommendationByEntityId = exports.fetchRecommendationByEntityName = exports.fetchEntityRecommendationsByTransactionId = exports.initialState = void 0;
5
5
  const toolkit_1 = require("@reduxjs/toolkit");
6
6
  const recommendationState_1 = require("./recommendationState");
7
7
  exports.initialState = {
@@ -37,41 +37,6 @@ const recommendation = (0, toolkit_1.createSlice)({
37
37
  };
38
38
  },
39
39
  },
40
- // Targeted recommendations fetch fired when the user changes the
41
- // payee/customer on a single transaction line (or the JE sibling set
42
- // for that change). Routed by `fetchEntityRecommendationsForLineUpdateEpic`
43
- // which uses groupBy + switchMap to keep fetches for distinct targets
44
- // running in parallel while same-target re-fetches still cancel each
45
- // other. The flowType discriminator selects the categorization vs
46
- // detail slice for the per-line In-Progress / Completed / Error state.
47
- fetchEntityRecommendationsForLineUpdate: {
48
- reducer(draft, action) {
49
- const { entity } = action.payload;
50
- const key = (0, recommendationState_1.getEntityRecommendationKey)(entity.type, entity.id);
51
- // Unconditional flip to In-Progress; the previous variant only
52
- // seeded when missing, which left stale fetchStates when a prior
53
- // fetch had already populated the entity entry.
54
- draft.recommendationByEntity[key] = {
55
- ...(draft.recommendationByEntity[key] ??
56
- recommendationState_1.initialEntityRecommendationState),
57
- fetchState: 'In-Progress',
58
- error: undefined,
59
- };
60
- },
61
- prepare(entity, amount, transactionDetails, flowType, selectedTab, isFetchCOT = false, isUncategorizedExpenseCategoryEnabled) {
62
- return {
63
- payload: {
64
- entity,
65
- amount,
66
- transactionDetails,
67
- flowType,
68
- selectedTab,
69
- isFetchCOT,
70
- isUncategorizedExpenseCategoryEnabled,
71
- },
72
- };
73
- },
74
- },
75
40
  fetchRecommendationByEntityName: {
76
41
  reducer(draft, action) {
77
42
  const { entityName, entityType } = action.payload;
@@ -150,7 +115,7 @@ const recommendation = (0, toolkit_1.createSlice)({
150
115
  },
151
116
  },
152
117
  });
153
- _a = recommendation.actions, exports.fetchEntityRecommendationsByTransactionId = _a.fetchEntityRecommendationsByTransactionId, exports.fetchEntityRecommendationsForLineUpdate = _a.fetchEntityRecommendationsForLineUpdate, exports.fetchRecommendationByEntityName = _a.fetchRecommendationByEntityName, exports.fetchRecommendationByEntityId = _a.fetchRecommendationByEntityId, exports.updateRecommendationForEntity = _a.updateRecommendationForEntity, exports.updateRecommendationForEntityFailure = _a.updateRecommendationForEntityFailure, exports.indicateReadyToInitializeRecommendation = _a.indicateReadyToInitializeRecommendation, exports.clearRecommendation = _a.clearRecommendation;
118
+ _a = recommendation.actions, exports.fetchEntityRecommendationsByTransactionId = _a.fetchEntityRecommendationsByTransactionId, exports.fetchRecommendationByEntityName = _a.fetchRecommendationByEntityName, exports.fetchRecommendationByEntityId = _a.fetchRecommendationByEntityId, exports.updateRecommendationForEntity = _a.updateRecommendationForEntity, exports.updateRecommendationForEntityFailure = _a.updateRecommendationForEntityFailure, exports.indicateReadyToInitializeRecommendation = _a.indicateReadyToInitializeRecommendation, exports.clearRecommendation = _a.clearRecommendation;
154
119
  exports.default = recommendation.reducer;
155
120
  const doUpdateRecommendationForEntity = (draft, entityId, entityType, payload) => {
156
121
  const key = (0, recommendationState_1.getEntityRecommendationKey)(entityType, entityId);
@@ -0,0 +1,14 @@
1
+ import { FetchState } from '../../../../../commonStateTypes/common';
2
+ import { CreateCardPolicyTemplateRequest } from '../../../../../entity/cardPolicy/cardPolicyPayload';
3
+ import { ZeniAPIStatus } from '../../../../../responsePayload';
4
+ import { CardPolicyDetailState } from './cardPolicyDetailState';
5
+ export declare const initialState: CardPolicyDetailState;
6
+ export declare const fetchCardPolicyDetail: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[templateId: string], string, "cardPolicyDetail/fetchCardPolicyDetail", never, never>, updateCardPolicyDetailFetchStatus: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
7
+ fetchState: FetchState;
8
+ error?: ZeniAPIStatus;
9
+ }, "cardPolicyDetail/updateCardPolicyDetailFetchStatus">, updateCardPolicyFormDraft: import("@reduxjs/toolkit").ActionCreatorWithPayload<CreateCardPolicyTemplateRequest, "cardPolicyDetail/updateCardPolicyFormDraft">, updateCardPolicy: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[templateId: string], string, "cardPolicyDetail/updateCardPolicy", never, never>, updateCardPolicyFetchStatus: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
10
+ fetchState: FetchState;
11
+ error?: ZeniAPIStatus;
12
+ }, "cardPolicyDetail/updateCardPolicyFetchStatus">, clearCardPolicyDetail: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"cardPolicyDetail/clearCardPolicyDetail">;
13
+ declare const _default: import("redux").Reducer<CardPolicyDetailState>;
14
+ export default _default;
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ var _a;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.clearCardPolicyDetail = exports.updateCardPolicyFetchStatus = exports.updateCardPolicy = exports.updateCardPolicyFormDraft = exports.updateCardPolicyDetailFetchStatus = exports.fetchCardPolicyDetail = exports.initialState = void 0;
5
+ const toolkit_1 = require("@reduxjs/toolkit");
6
+ exports.initialState = {
7
+ detailTemplateId: undefined,
8
+ detailFetchState: { fetchState: 'Not-Started', error: undefined },
9
+ updateFetchState: { fetchState: 'Not-Started', error: undefined },
10
+ formDraft: undefined,
11
+ };
12
+ const cardPolicyDetail = (0, toolkit_1.createSlice)({
13
+ name: 'cardPolicyDetail',
14
+ initialState: exports.initialState,
15
+ reducers: {
16
+ /**
17
+ * Kick off the `GET /cards/1.0/policy-templates/{id}` request. The
18
+ * accompanying epic dispatches `updateCreatedCardPolicyTemplate` on
19
+ * the entity slice + `updateCardPolicyFormDraft` (seeded from the
20
+ * template) + `updateCardPolicyDetailFetchStatus` here.
21
+ */
22
+ fetchCardPolicyDetail: {
23
+ reducer(draft, action) {
24
+ draft.detailTemplateId = action.payload;
25
+ draft.detailFetchState.fetchState = 'In-Progress';
26
+ draft.detailFetchState.error = undefined;
27
+ // Reset the draft so a stale form from a previous template
28
+ // doesn't leak into the new edit session.
29
+ draft.formDraft = undefined;
30
+ },
31
+ prepare(templateId) {
32
+ return { payload: templateId };
33
+ },
34
+ },
35
+ updateCardPolicyDetailFetchStatus(draft, action) {
36
+ draft.detailFetchState.fetchState = action.payload.fetchState;
37
+ draft.detailFetchState.error = action.payload.error;
38
+ },
39
+ /**
40
+ * Replace (or seed) the local edit-form draft. Dispatched by the
41
+ * detail-fetch epic with the camelCased values pulled from the
42
+ * fetched template, and by the edit page itself as the user types.
43
+ */
44
+ updateCardPolicyFormDraft(draft, action) {
45
+ draft.formDraft = action.payload;
46
+ },
47
+ /**
48
+ * Kick off the `PUT /cards/1.0/policy-templates/{id}` save. The
49
+ * epic reads the current `formDraft` from state, posts the wire
50
+ * body, then dispatches `updateCreatedCardPolicyTemplate` (entity)
51
+ * + `updateCardPolicyFetchStatus({fetchState: 'Completed'})` here.
52
+ */
53
+ updateCardPolicy: {
54
+ reducer(draft,
55
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
56
+ _action) {
57
+ draft.updateFetchState.fetchState = 'In-Progress';
58
+ draft.updateFetchState.error = undefined;
59
+ },
60
+ prepare(templateId) {
61
+ return { payload: templateId };
62
+ },
63
+ },
64
+ updateCardPolicyFetchStatus(draft, action) {
65
+ draft.updateFetchState.fetchState = action.payload.fetchState;
66
+ draft.updateFetchState.error = action.payload.error;
67
+ },
68
+ clearCardPolicyDetail(draft) {
69
+ Object.assign(draft, exports.initialState);
70
+ },
71
+ },
72
+ });
73
+ _a = cardPolicyDetail.actions, exports.fetchCardPolicyDetail = _a.fetchCardPolicyDetail, exports.updateCardPolicyDetailFetchStatus = _a.updateCardPolicyDetailFetchStatus, exports.updateCardPolicyFormDraft = _a.updateCardPolicyFormDraft, exports.updateCardPolicy = _a.updateCardPolicy, exports.updateCardPolicyFetchStatus = _a.updateCardPolicyFetchStatus, exports.clearCardPolicyDetail = _a.clearCardPolicyDetail;
74
+ exports.default = cardPolicyDetail.reducer;
@@ -0,0 +1,21 @@
1
+ import { FetchStateAndError, ID } from '../../../../../commonStateTypes/common';
2
+ import { CreateCardPolicyTemplateRequest } from '../../../../../entity/cardPolicy/cardPolicyPayload';
3
+ import { CardPolicyTemplate } from '../../../../../entity/cardPolicy/cardPolicyState';
4
+ import { RootState } from '../../../../../reducer';
5
+ /**
6
+ * Composite view returned by `getCardPolicyDetailView` — the only
7
+ * public shape the Card Policy edit page should consume. Mirrors how
8
+ * `chargeCardDetailSelector` joins the view-side lifecycle slots with
9
+ * the entity-store template.
10
+ */
11
+ export interface CardPolicyDetailSelectorView {
12
+ detailFetchState: FetchStateAndError;
13
+ updateFetchState: FetchStateAndError;
14
+ formDraft?: CreateCardPolicyTemplateRequest;
15
+ template?: CardPolicyTemplate;
16
+ templateId?: ID;
17
+ }
18
+ export declare function getCardPolicyDetailView(state: RootState): CardPolicyDetailSelectorView;
19
+ export declare function getCardPolicyFormDraft(state: RootState): CreateCardPolicyTemplateRequest | undefined;
20
+ export declare function getCardPolicyDetailFetchState(state: RootState): FetchStateAndError;
21
+ export declare function getUpdateCardPolicyFetchState(state: RootState): FetchStateAndError;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getCardPolicyDetailView = getCardPolicyDetailView;
4
+ exports.getCardPolicyFormDraft = getCardPolicyFormDraft;
5
+ exports.getCardPolicyDetailFetchState = getCardPolicyDetailFetchState;
6
+ exports.getUpdateCardPolicyFetchState = getUpdateCardPolicyFetchState;
7
+ const cardPolicySelector_1 = require("../../../../../entity/cardPolicy/cardPolicySelector");
8
+ function getCardPolicyDetailView(state) {
9
+ const { cardPolicyDetailState, cardPolicyState } = state;
10
+ return {
11
+ templateId: cardPolicyDetailState.detailTemplateId,
12
+ template: cardPolicyDetailState.detailTemplateId != null
13
+ ? (0, cardPolicySelector_1.getCardPolicyTemplateById)(cardPolicyState, cardPolicyDetailState.detailTemplateId)
14
+ : undefined,
15
+ formDraft: cardPolicyDetailState.formDraft,
16
+ detailFetchState: cardPolicyDetailState.detailFetchState,
17
+ updateFetchState: cardPolicyDetailState.updateFetchState,
18
+ };
19
+ }
20
+ function getCardPolicyFormDraft(state) {
21
+ return state.cardPolicyDetailState.formDraft;
22
+ }
23
+ function getCardPolicyDetailFetchState(state) {
24
+ return state.cardPolicyDetailState.detailFetchState;
25
+ }
26
+ function getUpdateCardPolicyFetchState(state) {
27
+ return state.cardPolicyDetailState.updateFetchState;
28
+ }
@@ -0,0 +1,25 @@
1
+ import { FetchStateAndError, ID } from '../../../../../commonStateTypes/common';
2
+ import { CreateCardPolicyTemplateRequest } from '../../../../../entity/cardPolicy/cardPolicyPayload';
3
+ /**
4
+ * View-side state for the Card Policy edit page.
5
+ *
6
+ * Mirrors `issueChargeCard` (a single page that owns a local form
7
+ * draft + commits on save). There is no separate read-only "detail"
8
+ * surface today — the same page loads the existing template and offers
9
+ * inline edits. The saved template itself lives on the entity slice;
10
+ * the page joins via `getCardPolicyDetailView`.
11
+ */
12
+ export interface CardPolicyDetailState {
13
+ /** Lifecycle for the initial `GET /policy-templates/{id}` request. */
14
+ detailFetchState: FetchStateAndError;
15
+ /** Lifecycle for the `PUT /policy-templates/{id}` save. */
16
+ updateFetchState: FetchStateAndError;
17
+ /** Template currently being edited; cleared when the page unmounts. */
18
+ detailTemplateId?: ID;
19
+ /**
20
+ * Local form draft seeded from the entity template on fetch success
21
+ * and mutated as the user edits. `undefined` until the detail fetch
22
+ * lands so the page can render a skeleton until then.
23
+ */
24
+ formDraft?: CreateCardPolicyTemplateRequest;
25
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,19 @@
1
+ import { ActionsObservable, StateObservable } from 'redux-observable';
2
+ import { Observable } from 'rxjs';
3
+ import { updateCreatedCardPolicyTemplate } from '../../../../../entity/cardPolicy/cardPolicyReducer';
4
+ import { RootState } from '../../../../../reducer';
5
+ import { ZeniAPI } from '../../../../../zeniAPI';
6
+ import { fetchCardPolicyDetail, updateCardPolicyDetailFetchStatus, updateCardPolicyFormDraft } from './cardPolicyDetailReducer';
7
+ export type ActionType = ReturnType<typeof fetchCardPolicyDetail> | ReturnType<typeof updateCreatedCardPolicyTemplate> | ReturnType<typeof updateCardPolicyFormDraft> | ReturnType<typeof updateCardPolicyDetailFetchStatus>;
8
+ /**
9
+ * `GET /cards/1.0/policy-templates/{id}`. Response is the same
10
+ * `{cards_applied, template}` envelope the create endpoint returns.
11
+ * We:
12
+ *
13
+ * 1. Cache the template on the entity slice (so the list page picks
14
+ * up any drift from the server).
15
+ * 2. Seed the local edit-form draft from the camelCased template so
16
+ * the page can render with the existing values pre-populated.
17
+ * 3. Flip the view lifecycle to `Completed` / `Error`.
18
+ */
19
+ export declare const fetchCardPolicyDetailEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fetchCardPolicyDetailEpic = void 0;
4
+ const rxjs_1 = require("rxjs");
5
+ const operators_1 = require("rxjs/operators");
6
+ const cardPolicyPayload_1 = require("../../../../../entity/cardPolicy/cardPolicyPayload");
7
+ const cardPolicyReducer_1 = require("../../../../../entity/cardPolicy/cardPolicyReducer");
8
+ const responsePayload_1 = require("../../../../../responsePayload");
9
+ const cardPolicyDetailReducer_1 = require("./cardPolicyDetailReducer");
10
+ /**
11
+ * `GET /cards/1.0/policy-templates/{id}`. Response is the same
12
+ * `{cards_applied, template}` envelope the create endpoint returns.
13
+ * We:
14
+ *
15
+ * 1. Cache the template on the entity slice (so the list page picks
16
+ * up any drift from the server).
17
+ * 2. Seed the local edit-form draft from the camelCased template so
18
+ * the page can render with the existing values pre-populated.
19
+ * 3. Flip the view lifecycle to `Completed` / `Error`.
20
+ */
21
+ const fetchCardPolicyDetailEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(cardPolicyDetailReducer_1.fetchCardPolicyDetail.match), (0, operators_1.mergeMap)((action) => {
22
+ const templateId = action.payload;
23
+ return zeniAPI
24
+ .getJSON(`${zeniAPI.apiEndPoints.cardMicroServiceBaseUrl}/1.0/policy-templates/${templateId}`)
25
+ .pipe((0, operators_1.mergeMap)((response) => {
26
+ if ((0, responsePayload_1.isSuccessStatus)(response) && response.data != null) {
27
+ const { template } = response.data;
28
+ const formDraft = (0, cardPolicyPayload_1.toCardPolicyEditFormDraft)((0, cardPolicyPayload_1.toCardPolicyTemplate)(template));
29
+ const actions = [
30
+ (0, cardPolicyReducer_1.updateCreatedCardPolicyTemplate)(template),
31
+ (0, cardPolicyDetailReducer_1.updateCardPolicyFormDraft)(formDraft),
32
+ (0, cardPolicyDetailReducer_1.updateCardPolicyDetailFetchStatus)({ fetchState: 'Completed' }),
33
+ ];
34
+ return (0, rxjs_1.from)(actions);
35
+ }
36
+ else {
37
+ return (0, rxjs_1.of)((0, cardPolicyDetailReducer_1.updateCardPolicyDetailFetchStatus)({
38
+ fetchState: 'Error',
39
+ error: response.status,
40
+ }));
41
+ }
42
+ }), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, cardPolicyDetailReducer_1.updateCardPolicyDetailFetchStatus)({
43
+ fetchState: 'Error',
44
+ error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Fetch card-policy detail REST API call errored out' +
45
+ JSON.stringify(error)),
46
+ }))));
47
+ }));
48
+ exports.fetchCardPolicyDetailEpic = fetchCardPolicyDetailEpic;
@@ -0,0 +1,18 @@
1
+ import { ActionsObservable, StateObservable } from 'redux-observable';
2
+ import { Observable } from 'rxjs';
3
+ import { updateCreatedCardPolicyTemplate } from '../../../../../entity/cardPolicy/cardPolicyReducer';
4
+ import { RootState } from '../../../../../reducer';
5
+ import { ZeniAPI } from '../../../../../zeniAPI';
6
+ import { updateCardPolicy, updateCardPolicyFetchStatus } from './cardPolicyDetailReducer';
7
+ export type ActionType = ReturnType<typeof updateCardPolicy> | ReturnType<typeof updateCreatedCardPolicyTemplate> | ReturnType<typeof updateCardPolicyFetchStatus>;
8
+ /**
9
+ * `PUT /cards/1.0/policy-templates/{id}`. Reads the current `formDraft`
10
+ * off the `cardPolicyDetail` slice, converts it to the snake_case wire
11
+ * body (same shape as create), and submits. On success the entity
12
+ * slice picks up the refreshed template and the view lifecycle flips
13
+ * to `Completed`.
14
+ *
15
+ * If the action fires before a draft is seeded (e.g. user clicks save
16
+ * before the detail fetch lands), we short-circuit with an Error.
17
+ */
18
+ export declare const updateCardPolicyEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateCardPolicyEpic = void 0;
4
+ const rxjs_1 = require("rxjs");
5
+ const operators_1 = require("rxjs/operators");
6
+ const cardPolicyPayload_1 = require("../../../../../entity/cardPolicy/cardPolicyPayload");
7
+ const cardPolicyReducer_1 = require("../../../../../entity/cardPolicy/cardPolicyReducer");
8
+ const responsePayload_1 = require("../../../../../responsePayload");
9
+ const cardPolicyDetailReducer_1 = require("./cardPolicyDetailReducer");
10
+ /**
11
+ * `PUT /cards/1.0/policy-templates/{id}`. Reads the current `formDraft`
12
+ * off the `cardPolicyDetail` slice, converts it to the snake_case wire
13
+ * body (same shape as create), and submits. On success the entity
14
+ * slice picks up the refreshed template and the view lifecycle flips
15
+ * to `Completed`.
16
+ *
17
+ * If the action fires before a draft is seeded (e.g. user clicks save
18
+ * before the detail fetch lands), we short-circuit with an Error.
19
+ */
20
+ const updateCardPolicyEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(cardPolicyDetailReducer_1.updateCardPolicy.match), (0, operators_1.mergeMap)((action) => {
21
+ const templateId = action.payload;
22
+ const formDraft = state$.value.cardPolicyDetailState.formDraft;
23
+ if (formDraft == null) {
24
+ return (0, rxjs_1.of)((0, cardPolicyDetailReducer_1.updateCardPolicyFetchStatus)({
25
+ fetchState: 'Error',
26
+ error: (0, responsePayload_1.createZeniAPIStatus)('Missing form draft', `Cannot update card-policy ${templateId} — no formDraft is loaded.`),
27
+ }));
28
+ }
29
+ const body = (0, cardPolicyPayload_1.toUpdateCardPolicyTemplateRequestBody)(formDraft);
30
+ return zeniAPI
31
+ .putAndGetJSON(`${zeniAPI.apiEndPoints.cardMicroServiceBaseUrl}/1.0/policy-templates/${templateId}`, body)
32
+ .pipe((0, operators_1.mergeMap)((response) => {
33
+ if ((0, responsePayload_1.isSuccessStatus)(response) && response.data != null) {
34
+ const { template } = response.data;
35
+ const actions = [
36
+ (0, cardPolicyReducer_1.updateCreatedCardPolicyTemplate)(template),
37
+ (0, cardPolicyDetailReducer_1.updateCardPolicyFetchStatus)({ fetchState: 'Completed' }),
38
+ ];
39
+ return (0, rxjs_1.from)(actions);
40
+ }
41
+ else {
42
+ return (0, rxjs_1.of)((0, cardPolicyDetailReducer_1.updateCardPolicyFetchStatus)({
43
+ fetchState: 'Error',
44
+ error: response.status,
45
+ }));
46
+ }
47
+ }), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, cardPolicyDetailReducer_1.updateCardPolicyFetchStatus)({
48
+ fetchState: 'Error',
49
+ error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Update card-policy REST API call errored out' +
50
+ JSON.stringify(error)),
51
+ }))));
52
+ }));
53
+ exports.updateCardPolicyEpic = updateCardPolicyEpic;
@@ -0,0 +1,16 @@
1
+ import { ActionsObservable, StateObservable } from 'redux-observable';
2
+ import { Observable } from 'rxjs';
3
+ import { removeCardPolicyTemplate } from '../../../../../entity/cardPolicy/cardPolicyReducer';
4
+ import { RootState } from '../../../../../reducer';
5
+ import { ZeniAPI } from '../../../../../zeniAPI';
6
+ import { archiveCardPolicy, updateArchiveCardPolicyFetchStatus } from './cardPolicyListReducer';
7
+ export type ActionType = ReturnType<typeof archiveCardPolicy> | ReturnType<typeof removeCardPolicyTemplate> | ReturnType<typeof updateArchiveCardPolicyFetchStatus>;
8
+ /**
9
+ * `DELETE /cards/1.0/policy-templates/{id}`. Modeled like
10
+ * `deleteBillEpic`: typed as bare `ZeniAPIResponse` (no `data` body
11
+ * expected) with `isSuccessStatus` driving the success branch. On
12
+ * success the entity slice drops the template via
13
+ * `removeCardPolicyTemplate(templateId)` and the view slice records
14
+ * `Completed` (also pruning the ID from `templateIds`).
15
+ */
16
+ export declare const archiveCardPolicyEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.archiveCardPolicyEpic = void 0;
4
+ const rxjs_1 = require("rxjs");
5
+ const operators_1 = require("rxjs/operators");
6
+ const cardPolicyReducer_1 = require("../../../../../entity/cardPolicy/cardPolicyReducer");
7
+ const responsePayload_1 = require("../../../../../responsePayload");
8
+ const cardPolicyListReducer_1 = require("./cardPolicyListReducer");
9
+ /**
10
+ * `DELETE /cards/1.0/policy-templates/{id}`. Modeled like
11
+ * `deleteBillEpic`: typed as bare `ZeniAPIResponse` (no `data` body
12
+ * expected) with `isSuccessStatus` driving the success branch. On
13
+ * success the entity slice drops the template via
14
+ * `removeCardPolicyTemplate(templateId)` and the view slice records
15
+ * `Completed` (also pruning the ID from `templateIds`).
16
+ */
17
+ const archiveCardPolicyEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(cardPolicyListReducer_1.archiveCardPolicy.match), (0, operators_1.mergeMap)((action) => {
18
+ const templateId = action.payload;
19
+ return zeniAPI
20
+ .deleteAndGetJSON(`${zeniAPI.apiEndPoints.cardMicroServiceBaseUrl}/1.0/policy-templates/${templateId}`)
21
+ .pipe((0, operators_1.mergeMap)((response) => {
22
+ if ((0, responsePayload_1.isSuccessStatus)(response)) {
23
+ const actions = [
24
+ (0, cardPolicyReducer_1.removeCardPolicyTemplate)(templateId),
25
+ (0, cardPolicyListReducer_1.updateArchiveCardPolicyFetchStatus)({
26
+ fetchState: 'Completed',
27
+ templateId,
28
+ }),
29
+ ];
30
+ return (0, rxjs_1.from)(actions);
31
+ }
32
+ else {
33
+ return (0, rxjs_1.of)((0, cardPolicyListReducer_1.updateArchiveCardPolicyFetchStatus)({
34
+ fetchState: 'Error',
35
+ error: response.status,
36
+ templateId,
37
+ }));
38
+ }
39
+ }), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, cardPolicyListReducer_1.updateArchiveCardPolicyFetchStatus)({
40
+ fetchState: 'Error',
41
+ error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Archive card-policy REST API call errored out' +
42
+ JSON.stringify(error)),
43
+ templateId,
44
+ }))));
45
+ }));
46
+ exports.archiveCardPolicyEpic = archiveCardPolicyEpic;
@@ -0,0 +1,15 @@
1
+ import { FetchState, ID } from '../../../../../commonStateTypes/common';
2
+ import { ZeniAPIStatus } from '../../../../../responsePayload';
3
+ import { CardPolicyListState } from './cardPolicyListState';
4
+ export declare const initialState: CardPolicyListState;
5
+ export declare const fetchCardPolicyList: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"cardPolicyList/fetchCardPolicyList">, updateCardPolicyListFetchStatus: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
6
+ fetchState: FetchState;
7
+ error?: ZeniAPIStatus;
8
+ templateIds?: ID[];
9
+ }, "cardPolicyList/updateCardPolicyListFetchStatus">, archiveCardPolicy: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[templateId: string], string, "cardPolicyList/archiveCardPolicy", never, never>, updateArchiveCardPolicyFetchStatus: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
10
+ fetchState: FetchState;
11
+ error?: ZeniAPIStatus;
12
+ templateId?: ID;
13
+ }, "cardPolicyList/updateArchiveCardPolicyFetchStatus">, clearCardPolicyList: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"cardPolicyList/clearCardPolicyList">;
14
+ declare const _default: import("redux").Reducer<CardPolicyListState>;
15
+ export default _default;
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ var _a;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.clearCardPolicyList = exports.updateArchiveCardPolicyFetchStatus = exports.archiveCardPolicy = exports.updateCardPolicyListFetchStatus = exports.fetchCardPolicyList = exports.initialState = void 0;
5
+ const toolkit_1 = require("@reduxjs/toolkit");
6
+ exports.initialState = {
7
+ templateIds: [],
8
+ fetchState: {
9
+ fetchState: 'Not-Started',
10
+ error: undefined,
11
+ },
12
+ archiveFetchState: {
13
+ fetchState: 'Not-Started',
14
+ error: undefined,
15
+ },
16
+ archiveTargetTemplateId: undefined,
17
+ };
18
+ const cardPolicyList = (0, toolkit_1.createSlice)({
19
+ name: 'cardPolicyList',
20
+ initialState: exports.initialState,
21
+ reducers: {
22
+ /**
23
+ * Kick off the `GET /cards/1.0/policy-templates` request. The
24
+ * accompanying epic dispatches `updateCardPolicyTemplates(templates)`
25
+ * + `updateCardPolicyStats(stats)` on the entity slice and
26
+ * `updateCardPolicyListFetchStatus` here (also supplying the ordered
27
+ * `templateIds` on success).
28
+ */
29
+ fetchCardPolicyList(draft) {
30
+ draft.fetchState.fetchState = 'In-Progress';
31
+ draft.fetchState.error = undefined;
32
+ },
33
+ updateCardPolicyListFetchStatus(draft, action) {
34
+ draft.fetchState.fetchState = action.payload.fetchState;
35
+ draft.fetchState.error = action.payload.error;
36
+ if (action.payload.templateIds != null) {
37
+ draft.templateIds = action.payload.templateIds;
38
+ }
39
+ },
40
+ /**
41
+ * Kick off the `DELETE /cards/1.0/policy-templates/{id}` request.
42
+ * The accompanying epic dispatches `removeCardPolicyTemplate(id)` on
43
+ * the entity slice on success + `updateArchiveCardPolicyFetchStatus`
44
+ * here. The view layer also drops the ID from `templateIds` so the
45
+ * list stays in sync without re-fetching.
46
+ */
47
+ archiveCardPolicy: {
48
+ reducer(draft, action) {
49
+ draft.archiveFetchState.fetchState = 'In-Progress';
50
+ draft.archiveFetchState.error = undefined;
51
+ draft.archiveTargetTemplateId = action.payload;
52
+ },
53
+ prepare(templateId) {
54
+ return { payload: templateId };
55
+ },
56
+ },
57
+ updateArchiveCardPolicyFetchStatus(draft, action) {
58
+ draft.archiveFetchState.fetchState = action.payload.fetchState;
59
+ draft.archiveFetchState.error = action.payload.error;
60
+ if (action.payload.fetchState === 'Completed') {
61
+ if (action.payload.templateId != null) {
62
+ draft.templateIds = draft.templateIds.filter((id) => id !== action.payload.templateId);
63
+ }
64
+ draft.archiveTargetTemplateId = undefined;
65
+ }
66
+ else if (action.payload.fetchState === 'Error') {
67
+ draft.archiveTargetTemplateId = undefined;
68
+ }
69
+ },
70
+ clearCardPolicyList(draft) {
71
+ Object.assign(draft, exports.initialState);
72
+ },
73
+ },
74
+ });
75
+ _a = cardPolicyList.actions, exports.fetchCardPolicyList = _a.fetchCardPolicyList, exports.updateCardPolicyListFetchStatus = _a.updateCardPolicyListFetchStatus, exports.archiveCardPolicy = _a.archiveCardPolicy, exports.updateArchiveCardPolicyFetchStatus = _a.updateArchiveCardPolicyFetchStatus, exports.clearCardPolicyList = _a.clearCardPolicyList;
76
+ exports.default = cardPolicyList.reducer;
@@ -0,0 +1,21 @@
1
+ import { FetchStateAndError, ID } from '../../../../../commonStateTypes/common';
2
+ import { CardPolicyStats, CardPolicyTemplate } from '../../../../../entity/cardPolicy/cardPolicyState';
3
+ import { RootState } from '../../../../../reducer';
4
+ /**
5
+ * Composite view returned by `getCardPolicyListView` — the only public
6
+ * shape the Card Policy list page should consume. Mirrors how
7
+ * `chargeCardListSelector` joins the view ID list with the entity store
8
+ * and exposes ancillary lifecycle slots in a single object.
9
+ */
10
+ export interface CardPolicyListSelectorView {
11
+ archiveFetchState: FetchStateAndError;
12
+ fetchState: FetchStateAndError;
13
+ templateIds: ID[];
14
+ templates: CardPolicyTemplate[];
15
+ archiveTargetTemplateId?: ID;
16
+ stats?: CardPolicyStats;
17
+ }
18
+ export declare function getCardPolicyListView(state: RootState): CardPolicyListSelectorView;
19
+ export declare function getCardPolicyListFetchState(state: RootState): FetchStateAndError;
20
+ export declare function getArchiveCardPolicyFetchState(state: RootState): FetchStateAndError;
21
+ export declare function getCardPolicyTemplateIds(state: RootState): ID[];
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getCardPolicyListView = getCardPolicyListView;
4
+ exports.getCardPolicyListFetchState = getCardPolicyListFetchState;
5
+ exports.getArchiveCardPolicyFetchState = getArchiveCardPolicyFetchState;
6
+ exports.getCardPolicyTemplateIds = getCardPolicyTemplateIds;
7
+ const cardPolicySelector_1 = require("../../../../../entity/cardPolicy/cardPolicySelector");
8
+ function getCardPolicyListView(state) {
9
+ const { cardPolicyListState, cardPolicyState } = state;
10
+ return {
11
+ templates: (0, cardPolicySelector_1.getCardPolicyTemplatesByIds)(cardPolicyState, cardPolicyListState.templateIds),
12
+ templateIds: cardPolicyListState.templateIds,
13
+ fetchState: cardPolicyListState.fetchState,
14
+ archiveFetchState: cardPolicyListState.archiveFetchState,
15
+ archiveTargetTemplateId: cardPolicyListState.archiveTargetTemplateId,
16
+ stats: (0, cardPolicySelector_1.getCardPolicyStats)(cardPolicyState),
17
+ };
18
+ }
19
+ function getCardPolicyListFetchState(state) {
20
+ return state.cardPolicyListState.fetchState;
21
+ }
22
+ function getArchiveCardPolicyFetchState(state) {
23
+ return state.cardPolicyListState.archiveFetchState;
24
+ }
25
+ function getCardPolicyTemplateIds(state) {
26
+ return state.cardPolicyListState.templateIds;
27
+ }
@@ -0,0 +1,19 @@
1
+ import { FetchStateAndError, ID } from '../../../../../commonStateTypes/common';
2
+ /**
3
+ * View-side state for the Card Policy list page. Mirrors the
4
+ * `chargeCardList` pattern: server-order ID list + sibling
5
+ * `FetchStateAndError` slots for each long-running mutation the page
6
+ * owns. The actual `CardPolicyTemplate` objects (and tenant-wide stats)
7
+ * live on the `cardPolicy` entity slice so any reader can join via
8
+ * `getCardPolicyTemplatesByIds` / `getCardPolicyStats`.
9
+ */
10
+ export interface CardPolicyListState {
11
+ /** Lifecycle for the `DELETE /policy-templates/{id}` request. */
12
+ archiveFetchState: FetchStateAndError;
13
+ /** Lifecycle for the `GET /policy-templates` request. */
14
+ fetchState: FetchStateAndError;
15
+ /** Ordered list of template IDs as returned by the list endpoint. */
16
+ templateIds: ID[];
17
+ /** ID of the template currently being archived (cleared on completion). */
18
+ archiveTargetTemplateId?: ID;
19
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,19 @@
1
+ import { ActionsObservable, StateObservable } from 'redux-observable';
2
+ import { Observable } from 'rxjs';
3
+ import { updateCardPolicyStats, updateCardPolicyTemplates } from '../../../../../entity/cardPolicy/cardPolicyReducer';
4
+ import { RootState } from '../../../../../reducer';
5
+ import { ZeniAPI } from '../../../../../zeniAPI';
6
+ import { fetchCardPolicyList, updateCardPolicyListFetchStatus } from './cardPolicyListReducer';
7
+ export type ActionType = ReturnType<typeof fetchCardPolicyList> | ReturnType<typeof updateCardPolicyTemplates> | ReturnType<typeof updateCardPolicyStats> | ReturnType<typeof updateCardPolicyListFetchStatus>;
8
+ /**
9
+ * `GET /cards/1.0/policy-templates`. On success the response carries
10
+ * both the tenant-wide `stats` block and a `templates[]` array whose
11
+ * rows are wrapped in `{data: {cards_applied, template}}` (the same
12
+ * envelope the create endpoint returns). We split the result into
13
+ * three actions:
14
+ *
15
+ * 1. `updateCardPolicyTemplates` — full replace of the entity map.
16
+ * 2. `updateCardPolicyStats` — entity-level cached stats.
17
+ * 3. `updateCardPolicyListFetchStatus` — view lifecycle + ordered IDs.
18
+ */
19
+ export declare const fetchCardPolicyListEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;