@zeniai/client-epic-state 5.1.69-betaAK0 → 5.1.70

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.
@@ -16,7 +16,7 @@ const shouldFetch = (fetchStateAndError, cacheOverride) => cacheOverride ||
16
16
  export const fetchInvoiceListPageEpic = (actions$, state$) => actions$.pipe(filter(fetchInvoiceListPage.match), mergeMap((action) => {
17
17
  const { cacheOverride, filters, sort } = action.payload;
18
18
  const state = state$.value.invoicingInvoiceListState;
19
- const activeTabState = state.byTab[state.activeTab];
19
+ const activeTabState = state.invoiceByTab[state.activeTab];
20
20
  const pageActions = [];
21
21
  if (shouldFetch({ fetchState: activeTabState.fetchState, error: activeTabState.error }, cacheOverride)) {
22
22
  pageActions.push(fetchInvoiceList({ filters, sort }));
@@ -1,5 +1,5 @@
1
1
  import { createSlice } from '@reduxjs/toolkit';
2
- import { ALL_INVOICING_INVOICE_TAB_IDS, makeInvoiceIdsByTab, } from './invoiceListState';
2
+ import { ALL_INVOICING_INVOICE_TAB_IDS, makeInvoiceByTab, } from './invoiceListState';
3
3
  /**
4
4
  * Whether two invoice-list queries share the same base (tab-independent) query.
5
5
  * The status tab is server-side per-tab, so it is excluded here — when the base
@@ -23,7 +23,7 @@ const statusToTabId = (status) => ALL_INVOICING_INVOICE_TAB_IDS.includes(status)
23
23
  : undefined;
24
24
  export const initialState = {
25
25
  activeTab: 'all',
26
- byTab: makeInvoiceIdsByTab(),
26
+ invoiceByTab: makeInvoiceByTab(),
27
27
  filters: {},
28
28
  counts: { all: 0 },
29
29
  countsFetchState: { fetchState: 'Not-Started', error: undefined },
@@ -36,9 +36,9 @@ const invoiceList = createSlice({
36
36
  reducers: {
37
37
  fetchInvoiceList: {
38
38
  reducer(draft, action) {
39
- const tab = draft.byTab[draft.activeTab];
39
+ const tab = draft.invoiceByTab[draft.activeTab];
40
40
  if (!action.payload.keepExistingListItems) {
41
- tab.ids = [];
41
+ tab.invoiceIds = [];
42
42
  tab.nextCursor = null;
43
43
  }
44
44
  draft.filters = action.payload.filters;
@@ -63,7 +63,7 @@ const invoiceList = createSlice({
63
63
  // page epic's shouldFetch refetches the active tab instead of showing
64
64
  // rows fetched under a stale search/customer/subscription/dates/sort.
65
65
  if (!sameInvoiceListQuery(draft, action.payload)) {
66
- draft.byTab = makeInvoiceIdsByTab();
66
+ draft.invoiceByTab = makeInvoiceByTab();
67
67
  }
68
68
  draft.filters = action.payload.filters;
69
69
  draft.sort = action.payload.sort;
@@ -79,17 +79,17 @@ const invoiceList = createSlice({
79
79
  },
80
80
  },
81
81
  updateInvoiceList(draft, action) {
82
- const tab = draft.byTab[draft.activeTab];
82
+ const tab = draft.invoiceByTab[draft.activeTab];
83
83
  const newIds = action.payload.invoices.map((invoice) => invoice.id);
84
- tab.ids = action.payload.keepExistingListItems
85
- ? [...new Set([...tab.ids, ...newIds])]
84
+ tab.invoiceIds = action.payload.keepExistingListItems
85
+ ? [...new Set([...tab.invoiceIds, ...newIds])]
86
86
  : newIds;
87
87
  tab.nextCursor = action.payload.nextCursor;
88
88
  tab.fetchState = 'Completed';
89
89
  tab.error = undefined;
90
90
  },
91
91
  updateInvoiceListFailure(draft, action) {
92
- const tab = draft.byTab[draft.activeTab];
92
+ const tab = draft.invoiceByTab[draft.activeTab];
93
93
  tab.fetchState = 'Error';
94
94
  tab.error = action.payload;
95
95
  },
@@ -135,16 +135,16 @@ const invoiceList = createSlice({
135
135
  // are left untouched and refetched lazily.
136
136
  addInvoiceToList(draft, action) {
137
137
  const { id, status } = action.payload;
138
- const allTab = draft.byTab['all'];
139
- if (allTab.ids.includes(id)) {
138
+ const allTab = draft.invoiceByTab['all'];
139
+ if (allTab.invoiceIds.includes(id)) {
140
140
  return;
141
141
  }
142
- allTab.ids = [id, ...allTab.ids];
142
+ allTab.invoiceIds = [id, ...allTab.invoiceIds];
143
143
  const statusTab = statusToTabId(status);
144
144
  if (statusTab != null) {
145
- const tab = draft.byTab[statusTab];
146
- if (!tab.ids.includes(id)) {
147
- tab.ids = [id, ...tab.ids];
145
+ const tab = draft.invoiceByTab[statusTab];
146
+ if (!tab.invoiceIds.includes(id)) {
147
+ tab.invoiceIds = [id, ...tab.invoiceIds];
148
148
  }
149
149
  }
150
150
  draft.counts.all += 1;
@@ -152,7 +152,7 @@ const invoiceList = createSlice({
152
152
  },
153
153
  clearInvoiceList(draft) {
154
154
  draft.activeTab = 'all';
155
- draft.byTab = makeInvoiceIdsByTab();
155
+ draft.invoiceByTab = makeInvoiceByTab();
156
156
  draft.filters = {};
157
157
  draft.sort = undefined;
158
158
  draft.counts = { all: 0 };
@@ -7,10 +7,10 @@ import { INVOICING_INVOICE_TABS, } from './invoiceListState';
7
7
  * invoice entity slice or the list-view slice actually change.
8
8
  */
9
9
  export const getInvoiceListView = createSelector((state) => state.invoicingInvoiceState, (state) => state.invoicingInvoiceListState, (invoiceState, listViewState) => {
10
- const activeTabState = listViewState.byTab[listViewState.activeTab];
10
+ const activeTabState = listViewState.invoiceByTab[listViewState.activeTab];
11
11
  return {
12
12
  activeTab: listViewState.activeTab,
13
- invoices: activeTabState.ids
13
+ invoices: activeTabState.invoiceIds
14
14
  .map((id) => invoiceState.invoiceByID[id])
15
15
  .filter((item) => item != null),
16
16
  counts: listViewState.counts,
@@ -18,12 +18,12 @@ export const INVOICING_INVOICE_TABS = [
18
18
  ...ALL_INVOICING_INVOICE_TAB_IDS,
19
19
  ];
20
20
  export const makeInvoiceTabState = () => ({
21
- ids: [],
21
+ invoiceIds: [],
22
22
  nextCursor: null,
23
23
  fetchState: 'Not-Started',
24
24
  error: undefined,
25
25
  });
26
- export const makeInvoiceIdsByTab = () => ALL_INVOICING_INVOICE_TAB_IDS.reduce((acc, tabId) => {
26
+ export const makeInvoiceByTab = () => ALL_INVOICING_INVOICE_TAB_IDS.reduce((acc, tabId) => {
27
27
  acc[tabId] = makeInvoiceTabState();
28
28
  return acc;
29
29
  }, {});
@@ -20,7 +20,7 @@ export const fetchInvoicingCustomerDetailPageEpic = (actions$, state$) => action
20
20
  const { cacheOverride, id } = action.payload;
21
21
  const customerDetail = state$.value.invoicingCustomerDetailViewState.detailById[id];
22
22
  const invoiceListState = state$.value.invoicingInvoiceListState;
23
- const invoiceListTabState = invoiceListState.byTab[invoiceListState.activeTab];
23
+ const invoiceListTabState = invoiceListState.invoiceByTab[invoiceListState.activeTab];
24
24
  const settingsState = state$.value.invoicingSettingsViewState;
25
25
  const pageActions = [];
26
26
  if (shouldFetch({
@@ -10,7 +10,7 @@ export const getInvoicingCustomerDetail = (state, invoicingCustomerID) => {
10
10
  const settings = getInvoicingSettings(state);
11
11
  return {
12
12
  invoicingCustomer: getInvoicingCustomerById(invoicingCustomerState, invoicingCustomerID),
13
- invoices: getInvoicesByIds(state.invoicingInvoiceState, state.invoicingInvoiceListState.byTab[state.invoicingInvoiceListState.activeTab].ids),
13
+ invoices: getInvoicesByIds(state.invoicingInvoiceState, state.invoicingInvoiceListState.invoiceByTab[state.invoicingInvoiceListState.activeTab].invoiceIds),
14
14
  setupIntent: getInvoicingSetupIntent(state),
15
15
  setupIntentFetchState: getInvoicingSetupIntentFetchState(state),
16
16
  plaidLinkToken: getInvoicingPlaidLinkToken(state),
@@ -19,7 +19,7 @@ const shouldFetch = (fetchStateAndError, cacheOverride) => cacheOverride ||
19
19
  const fetchInvoiceListPageEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)(invoiceListReducer_1.fetchInvoiceListPage.match), (0, operators_1.mergeMap)((action) => {
20
20
  const { cacheOverride, filters, sort } = action.payload;
21
21
  const state = state$.value.invoicingInvoiceListState;
22
- const activeTabState = state.byTab[state.activeTab];
22
+ const activeTabState = state.invoiceByTab[state.activeTab];
23
23
  const pageActions = [];
24
24
  if (shouldFetch({ fetchState: activeTabState.fetchState, error: activeTabState.error }, cacheOverride)) {
25
25
  pageActions.push((0, invoiceListReducer_1.fetchInvoiceList)({ filters, sort }));
@@ -28,7 +28,7 @@ const statusToTabId = (status) => invoiceListState_1.ALL_INVOICING_INVOICE_TAB_I
28
28
  : undefined;
29
29
  exports.initialState = {
30
30
  activeTab: 'all',
31
- byTab: (0, invoiceListState_1.makeInvoiceIdsByTab)(),
31
+ invoiceByTab: (0, invoiceListState_1.makeInvoiceByTab)(),
32
32
  filters: {},
33
33
  counts: { all: 0 },
34
34
  countsFetchState: { fetchState: 'Not-Started', error: undefined },
@@ -41,9 +41,9 @@ const invoiceList = (0, toolkit_1.createSlice)({
41
41
  reducers: {
42
42
  fetchInvoiceList: {
43
43
  reducer(draft, action) {
44
- const tab = draft.byTab[draft.activeTab];
44
+ const tab = draft.invoiceByTab[draft.activeTab];
45
45
  if (!action.payload.keepExistingListItems) {
46
- tab.ids = [];
46
+ tab.invoiceIds = [];
47
47
  tab.nextCursor = null;
48
48
  }
49
49
  draft.filters = action.payload.filters;
@@ -68,7 +68,7 @@ const invoiceList = (0, toolkit_1.createSlice)({
68
68
  // page epic's shouldFetch refetches the active tab instead of showing
69
69
  // rows fetched under a stale search/customer/subscription/dates/sort.
70
70
  if (!(0, exports.sameInvoiceListQuery)(draft, action.payload)) {
71
- draft.byTab = (0, invoiceListState_1.makeInvoiceIdsByTab)();
71
+ draft.invoiceByTab = (0, invoiceListState_1.makeInvoiceByTab)();
72
72
  }
73
73
  draft.filters = action.payload.filters;
74
74
  draft.sort = action.payload.sort;
@@ -84,17 +84,17 @@ const invoiceList = (0, toolkit_1.createSlice)({
84
84
  },
85
85
  },
86
86
  updateInvoiceList(draft, action) {
87
- const tab = draft.byTab[draft.activeTab];
87
+ const tab = draft.invoiceByTab[draft.activeTab];
88
88
  const newIds = action.payload.invoices.map((invoice) => invoice.id);
89
- tab.ids = action.payload.keepExistingListItems
90
- ? [...new Set([...tab.ids, ...newIds])]
89
+ tab.invoiceIds = action.payload.keepExistingListItems
90
+ ? [...new Set([...tab.invoiceIds, ...newIds])]
91
91
  : newIds;
92
92
  tab.nextCursor = action.payload.nextCursor;
93
93
  tab.fetchState = 'Completed';
94
94
  tab.error = undefined;
95
95
  },
96
96
  updateInvoiceListFailure(draft, action) {
97
- const tab = draft.byTab[draft.activeTab];
97
+ const tab = draft.invoiceByTab[draft.activeTab];
98
98
  tab.fetchState = 'Error';
99
99
  tab.error = action.payload;
100
100
  },
@@ -140,16 +140,16 @@ const invoiceList = (0, toolkit_1.createSlice)({
140
140
  // are left untouched and refetched lazily.
141
141
  addInvoiceToList(draft, action) {
142
142
  const { id, status } = action.payload;
143
- const allTab = draft.byTab['all'];
144
- if (allTab.ids.includes(id)) {
143
+ const allTab = draft.invoiceByTab['all'];
144
+ if (allTab.invoiceIds.includes(id)) {
145
145
  return;
146
146
  }
147
- allTab.ids = [id, ...allTab.ids];
147
+ allTab.invoiceIds = [id, ...allTab.invoiceIds];
148
148
  const statusTab = statusToTabId(status);
149
149
  if (statusTab != null) {
150
- const tab = draft.byTab[statusTab];
151
- if (!tab.ids.includes(id)) {
152
- tab.ids = [id, ...tab.ids];
150
+ const tab = draft.invoiceByTab[statusTab];
151
+ if (!tab.invoiceIds.includes(id)) {
152
+ tab.invoiceIds = [id, ...tab.invoiceIds];
153
153
  }
154
154
  }
155
155
  draft.counts.all += 1;
@@ -157,7 +157,7 @@ const invoiceList = (0, toolkit_1.createSlice)({
157
157
  },
158
158
  clearInvoiceList(draft) {
159
159
  draft.activeTab = 'all';
160
- draft.byTab = (0, invoiceListState_1.makeInvoiceIdsByTab)();
160
+ draft.invoiceByTab = (0, invoiceListState_1.makeInvoiceByTab)();
161
161
  draft.filters = {};
162
162
  draft.sort = undefined;
163
163
  draft.counts = { all: 0 };
@@ -10,10 +10,10 @@ const invoiceListState_1 = require("./invoiceListState");
10
10
  * invoice entity slice or the list-view slice actually change.
11
11
  */
12
12
  exports.getInvoiceListView = (0, toolkit_1.createSelector)((state) => state.invoicingInvoiceState, (state) => state.invoicingInvoiceListState, (invoiceState, listViewState) => {
13
- const activeTabState = listViewState.byTab[listViewState.activeTab];
13
+ const activeTabState = listViewState.invoiceByTab[listViewState.activeTab];
14
14
  return {
15
15
  activeTab: listViewState.activeTab,
16
- invoices: activeTabState.ids
16
+ invoices: activeTabState.invoiceIds
17
17
  .map((id) => invoiceState.invoiceByID[id])
18
18
  .filter((item) => item != null),
19
19
  counts: listViewState.counts,
@@ -26,20 +26,19 @@ export interface InvoiceListFilters {
26
26
  * cached independently. Mirrors the transaction-list per-tab cache pattern.
27
27
  */
28
28
  export interface InvoiceTabState extends FetchStateAndError {
29
- ids: ID[];
29
+ invoiceIds: ID[];
30
30
  nextCursor: string | null;
31
31
  }
32
- export type InvoiceIdsByTab = Record<InvoicingInvoiceTabId, InvoiceTabState>;
33
32
  export interface InvoiceListState {
34
33
  /** Selected status tab (CES-owned so it persists across page revisits). */
35
34
  activeTab: InvoicingInvoiceTabId;
36
- /** Per-tab cached ids + cursor + fetch state. */
37
- byTab: InvoiceIdsByTab;
38
35
  /** Tab-independent list counts. */
39
36
  counts: InvoicingListCounts;
40
37
  countsFetchState: FetchStateAndError;
41
38
  /** Base query shared across tabs (search / customer / subscription / dates). */
42
39
  filters: InvoiceListFilters;
40
+ /** Per-tab cached invoice ids + cursor + fetch state. */
41
+ invoiceByTab: Record<InvoicingInvoiceTabId, InvoiceTabState>;
43
42
  kpisFetchState: FetchStateAndError;
44
43
  /** Tab-independent money KPIs. */
45
44
  kpis?: InvoicingInvoiceKPIs;
@@ -47,4 +46,4 @@ export interface InvoiceListState {
47
46
  sort?: InvoicingListSort;
48
47
  }
49
48
  export declare const makeInvoiceTabState: () => InvoiceTabState;
50
- export declare const makeInvoiceIdsByTab: () => InvoiceIdsByTab;
49
+ export declare const makeInvoiceByTab: () => Record<InvoicingInvoiceTabId, InvoiceTabState>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.makeInvoiceIdsByTab = exports.makeInvoiceTabState = exports.INVOICING_INVOICE_TABS = exports.toInvoicingInvoiceTabId = exports.ALL_INVOICING_INVOICE_TAB_IDS = void 0;
3
+ exports.makeInvoiceByTab = exports.makeInvoiceTabState = exports.INVOICING_INVOICE_TABS = exports.toInvoicingInvoiceTabId = exports.ALL_INVOICING_INVOICE_TAB_IDS = void 0;
4
4
  const stringToUnion_1 = require("../../../commonStateTypes/stringToUnion");
5
5
  exports.ALL_INVOICING_INVOICE_TAB_IDS = [
6
6
  'all',
@@ -22,14 +22,14 @@ exports.INVOICING_INVOICE_TABS = [
22
22
  ...exports.ALL_INVOICING_INVOICE_TAB_IDS,
23
23
  ];
24
24
  const makeInvoiceTabState = () => ({
25
- ids: [],
25
+ invoiceIds: [],
26
26
  nextCursor: null,
27
27
  fetchState: 'Not-Started',
28
28
  error: undefined,
29
29
  });
30
30
  exports.makeInvoiceTabState = makeInvoiceTabState;
31
- const makeInvoiceIdsByTab = () => exports.ALL_INVOICING_INVOICE_TAB_IDS.reduce((acc, tabId) => {
31
+ const makeInvoiceByTab = () => exports.ALL_INVOICING_INVOICE_TAB_IDS.reduce((acc, tabId) => {
32
32
  acc[tabId] = (0, exports.makeInvoiceTabState)();
33
33
  return acc;
34
34
  }, {});
35
- exports.makeInvoiceIdsByTab = makeInvoiceIdsByTab;
35
+ exports.makeInvoiceByTab = makeInvoiceByTab;
@@ -23,7 +23,7 @@ const fetchInvoicingCustomerDetailPageEpic = (actions$, state$) => actions$.pipe
23
23
  const { cacheOverride, id } = action.payload;
24
24
  const customerDetail = state$.value.invoicingCustomerDetailViewState.detailById[id];
25
25
  const invoiceListState = state$.value.invoicingInvoiceListState;
26
- const invoiceListTabState = invoiceListState.byTab[invoiceListState.activeTab];
26
+ const invoiceListTabState = invoiceListState.invoiceByTab[invoiceListState.activeTab];
27
27
  const settingsState = state$.value.invoicingSettingsViewState;
28
28
  const pageActions = [];
29
29
  if (shouldFetch({
@@ -16,7 +16,7 @@ const getInvoicingCustomerDetail = (state, invoicingCustomerID) => {
16
16
  const settings = (0, settingsViewSelector_1.getInvoicingSettings)(state);
17
17
  return {
18
18
  invoicingCustomer: (0, invoicingCustomerSelector_1.getInvoicingCustomerById)(invoicingCustomerState, invoicingCustomerID),
19
- invoices: (0, invoiceSelector_1.getInvoicesByIds)(state.invoicingInvoiceState, state.invoicingInvoiceListState.byTab[state.invoicingInvoiceListState.activeTab].ids),
19
+ invoices: (0, invoiceSelector_1.getInvoicesByIds)(state.invoicingInvoiceState, state.invoicingInvoiceListState.invoiceByTab[state.invoicingInvoiceListState.activeTab].invoiceIds),
20
20
  setupIntent: (0, customerPaymentMethodSelector_1.getInvoicingSetupIntent)(state),
21
21
  setupIntentFetchState: (0, customerPaymentMethodSelector_1.getInvoicingSetupIntentFetchState)(state),
22
22
  plaidLinkToken: (0, customerPaymentMethodSelector_1.getInvoicingPlaidLinkToken)(state),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "5.1.69-betaAK0",
3
+ "version": "5.1.70",
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",