@zeniai/client-epic-state 4.13.0 → 4.13.2

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 (29) hide show
  1. package/lib/commonStateTypes/fileType.d.ts +2 -2
  2. package/lib/commonStateTypes/fileType.js +1 -1
  3. package/lib/epic.d.ts +2 -1
  4. package/lib/epic.js +2 -1
  5. package/lib/index.d.ts +4 -3
  6. package/lib/index.js +9 -8
  7. package/lib/view/commonVendorView/vendorView/epics/fetchVendorDetailsEpic.js +2 -2
  8. package/lib/view/commonVendorView/vendorView/epics/fetchVendorEpic.js +1 -1
  9. package/lib/view/commonVendorView/vendorView/vendorViewReducer.d.ts +4 -2
  10. package/lib/view/commonVendorView/vendorView/vendorViewReducer.js +4 -3
  11. package/lib/view/vendorFiling1099/__mock__/json/vendorFiling1099DownloadSuccess.json +574 -0
  12. package/lib/view/vendorFiling1099/__mock__/vendorFiling1099DownloadMock.d.ts +7 -0
  13. package/lib/view/vendorFiling1099/__mock__/vendorFiling1099DownloadMock.js +94 -0
  14. package/lib/view/vendorFiling1099/__mock__/vendorFiling1099ListMock.js +90 -5
  15. package/lib/view/vendorFiling1099/__mock__/vendorFiling1099ListSelectorMock.js +18 -1
  16. package/lib/view/vendorFiling1099/vendorFiling1099List/fetchVendorsFiling1099DownloadEpic.d.ts +7 -0
  17. package/lib/view/vendorFiling1099/vendorFiling1099List/fetchVendorsFiling1099DownloadEpic.js +50 -0
  18. package/lib/view/vendorFiling1099/vendorFiling1099List/vendorFiling1099ListPayload.d.ts +13 -0
  19. package/lib/view/vendorFiling1099/vendorFiling1099List/vendorFiling1099ListReducer.d.ts +8 -2
  20. package/lib/view/vendorFiling1099/vendorFiling1099List/vendorFiling1099ListReducer.js +40 -3
  21. package/lib/view/vendorFiling1099/vendorFiling1099List/vendorFiling1099ListSelector.d.ts +2 -0
  22. package/lib/view/vendorFiling1099/vendorFiling1099List/vendorFiling1099ListSelector.js +1 -0
  23. package/lib/view/vendorFiling1099/vendorFiling1099List/vendorFiling1099ListState.d.ts +5 -2
  24. package/lib/view/vendorFiling1099/vendorFiling1099UploadDetails/vendorFiling1099UploadDetailsReducer.d.ts +2 -1
  25. package/lib/view/vendorFiling1099/vendorFiling1099UploadDetails/vendorFiling1099UploadDetailsReducer.js +6 -1
  26. package/lib/view/vendorFiling1099/vendorFiling1099UploadDetails/vendorFiling1099UploadDetailsSaveEpic.js +2 -1
  27. package/lib/zeniAPI.d.ts +12 -12
  28. package/lib/zeniAPI.js +12 -6
  29. package/package.json +2 -2
@@ -20,7 +20,10 @@ exports.vendorFiling1099ListInProgressState = {
20
20
  sortKey: 'total',
21
21
  sortOrder: 'descending',
22
22
  scrollYOffset: 0,
23
- downloadState: 'Not-Started',
23
+ downloadState: {
24
+ fetchState: 'Not-Started',
25
+ error: undefined,
26
+ },
24
27
  searchString: '',
25
28
  },
26
29
  fetchState: 'In-Progress',
@@ -28,6 +31,20 @@ exports.vendorFiling1099ListInProgressState = {
28
31
  hasValidState: vendorFiling1099ListReducer_1.initialState.hasValidState,
29
32
  lastRefreshSuccessTime: undefined,
30
33
  isVendor1099Populated: true,
34
+ vendorFiling1099DownloadData: {
35
+ nec: {
36
+ data: [],
37
+ customHeaders: [],
38
+ },
39
+ misc: {
40
+ data: [],
41
+ customHeaders: [],
42
+ },
43
+ int: {
44
+ data: [],
45
+ customHeaders: [],
46
+ },
47
+ },
31
48
  };
32
49
  exports.vendorFiling1099ListInProgressInitialState = {
33
50
  vendorIds: [],
@@ -35,7 +52,10 @@ exports.vendorFiling1099ListInProgressInitialState = {
35
52
  sortKey: 'total',
36
53
  sortOrder: 'descending',
37
54
  scrollYOffset: 0,
38
- downloadState: 'Not-Started',
55
+ downloadState: {
56
+ fetchState: 'Not-Started',
57
+ error: undefined,
58
+ },
39
59
  searchString: '',
40
60
  },
41
61
  fetchState: 'In-Progress',
@@ -43,6 +63,20 @@ exports.vendorFiling1099ListInProgressInitialState = {
43
63
  hasValidState: vendorFiling1099ListReducer_1.initialState.hasValidState,
44
64
  lastRefreshSuccessTime: undefined,
45
65
  isVendor1099Populated: false,
66
+ vendorFiling1099DownloadData: {
67
+ nec: {
68
+ data: [],
69
+ customHeaders: [],
70
+ },
71
+ misc: {
72
+ data: [],
73
+ customHeaders: [],
74
+ },
75
+ int: {
76
+ data: [],
77
+ customHeaders: [],
78
+ },
79
+ },
46
80
  };
47
81
  exports.vendorFiling1099ListSuccessState = {
48
82
  vendorIds: ['vendor_j12jh1g2g12jg3jh12:12'],
@@ -50,7 +84,10 @@ exports.vendorFiling1099ListSuccessState = {
50
84
  sortKey: 'total',
51
85
  sortOrder: 'descending',
52
86
  scrollYOffset: 0,
53
- downloadState: 'Not-Started',
87
+ downloadState: {
88
+ fetchState: 'Not-Started',
89
+ error: undefined,
90
+ },
54
91
  searchString: '',
55
92
  },
56
93
  fetchState: 'Completed',
@@ -58,6 +95,20 @@ exports.vendorFiling1099ListSuccessState = {
58
95
  hasValidState: vendorFiling1099ListReducer_1.initialState.hasValidState,
59
96
  lastRefreshSuccessTime: (0, zeniDayJS_1.date)('2024-09-26T07:44:02.150Z'),
60
97
  isVendor1099Populated: true,
98
+ vendorFiling1099DownloadData: {
99
+ nec: {
100
+ data: [],
101
+ customHeaders: [],
102
+ },
103
+ misc: {
104
+ data: [],
105
+ customHeaders: [],
106
+ },
107
+ int: {
108
+ data: [],
109
+ customHeaders: [],
110
+ },
111
+ },
61
112
  };
62
113
  exports.vendorFiling1099ListFailureState = {
63
114
  vendorIds: [],
@@ -65,7 +116,10 @@ exports.vendorFiling1099ListFailureState = {
65
116
  sortKey: 'total',
66
117
  sortOrder: 'descending',
67
118
  scrollYOffset: 0,
68
- downloadState: 'Not-Started',
119
+ downloadState: {
120
+ fetchState: 'Not-Started',
121
+ error: undefined,
122
+ },
69
123
  searchString: '',
70
124
  },
71
125
  lastRefreshSuccessTime: undefined,
@@ -76,6 +130,20 @@ exports.vendorFiling1099ListFailureState = {
76
130
  },
77
131
  hasValidState: vendorFiling1099ListReducer_1.initialState.hasValidState,
78
132
  isVendor1099Populated: false,
133
+ vendorFiling1099DownloadData: {
134
+ nec: {
135
+ data: [],
136
+ customHeaders: [],
137
+ },
138
+ misc: {
139
+ data: [],
140
+ customHeaders: [],
141
+ },
142
+ int: {
143
+ data: [],
144
+ customHeaders: [],
145
+ },
146
+ },
79
147
  };
80
148
  exports.rootStateWithVendorFiling1099List = Object.assign({}, reducer_1.initialRootState, {
81
149
  vendorState: {
@@ -91,12 +159,29 @@ exports.rootStateWithVendorFiling1099List = Object.assign({}, reducer_1.initialR
91
159
  sortKey: 'total',
92
160
  sortOrder: 'descending',
93
161
  scrollYOffset: 0,
94
- downloadState: 'Not-Started',
162
+ downloadState: {
163
+ fetchState: 'Not-Started',
164
+ error: undefined,
165
+ },
95
166
  searchString: '',
96
167
  },
97
168
  lastRefreshSuccessTime: undefined,
98
169
  hasValidState: vendorFiling1099ListReducer_1.initialState.hasValidState,
99
170
  isVendor1099Populated: true,
171
+ vendorFiling1099DownloadData: {
172
+ nec: {
173
+ data: [],
174
+ customHeaders: [],
175
+ },
176
+ misc: {
177
+ data: [],
178
+ customHeaders: [],
179
+ },
180
+ int: {
181
+ data: [],
182
+ customHeaders: [],
183
+ },
184
+ },
100
185
  },
101
186
  vendorTypeListState: {
102
187
  fetchState: 'Completed',
@@ -14,9 +14,26 @@ exports.vendorFiling1099ListSelectorMock = {
14
14
  sortKey: 'total',
15
15
  sortOrder: 'descending',
16
16
  scrollYOffset: 0,
17
- downloadState: 'Not-Started',
17
+ downloadState: {
18
+ fetchState: 'Not-Started',
19
+ error: undefined,
20
+ },
18
21
  searchString: '',
19
22
  },
23
+ vendorFiling1099DownloadData: {
24
+ nec: {
25
+ data: [],
26
+ customHeaders: [],
27
+ },
28
+ misc: {
29
+ data: [],
30
+ customHeaders: [],
31
+ },
32
+ int: {
33
+ data: [],
34
+ customHeaders: [],
35
+ },
36
+ },
20
37
  isVendor1099Populated: true,
21
38
  vendorTypeList: [
22
39
  {
@@ -0,0 +1,7 @@
1
+ import { ActionsObservable, StateObservable } from 'redux-observable';
2
+ import { Observable } from 'rxjs';
3
+ import { ZeniAPI } from '../../../zeniAPI';
4
+ import { RootState } from '../../../reducer';
5
+ import { fetchVendorsFiling1099Download, updateVendorFiling1099DownloadData } from './vendorFiling1099ListReducer';
6
+ export declare type ActionType = ReturnType<typeof fetchVendorsFiling1099Download> | ReturnType<typeof updateVendorFiling1099DownloadData>;
7
+ export declare const fetchVendorsFiling1099DownloadEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fetchVendorsFiling1099DownloadEpic = void 0;
4
+ const rxjs_1 = require("rxjs");
5
+ const operators_1 = require("rxjs/operators");
6
+ const responsePayload_1 = require("../../../responsePayload");
7
+ const vendorFiling1099ListReducer_1 = require("./vendorFiling1099ListReducer");
8
+ const vendorFiling1099ListReducer_2 = require("./vendorFiling1099ListReducer");
9
+ const fetchVendorsFiling1099DownloadEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(vendorFiling1099ListReducer_1.fetchVendorsFiling1099Download.match), (0, operators_1.switchMap)((action) => {
10
+ const type1099Download = action.payload.type1099;
11
+ const queryParams = {
12
+ type_1099: type1099Download,
13
+ report_id: 'vendor_1099',
14
+ };
15
+ const apiUrl = `${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/vendor-1099/download?query=${encodeURIComponent(JSON.stringify(queryParams))}`;
16
+ return zeniAPI.getJSON(apiUrl).pipe((0, operators_1.switchMap)((response) => {
17
+ if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
18
+ const actions = [];
19
+ actions.push((0, vendorFiling1099ListReducer_1.updateVendorFiling1099DownloadData)({
20
+ response: response.data,
21
+ downloadState: {
22
+ fetchState: 'Completed',
23
+ error: undefined,
24
+ },
25
+ }));
26
+ return actions;
27
+ }
28
+ else {
29
+ return (0, rxjs_1.of)((0, vendorFiling1099ListReducer_1.updateVendorFiling1099DownloadData)({
30
+ response: vendorFiling1099ListReducer_2.initialState.vendorFiling1099DownloadData,
31
+ downloadState: {
32
+ fetchState: 'Error',
33
+ },
34
+ }));
35
+ }
36
+ }), (0, operators_1.catchError)((err) => {
37
+ return (0, rxjs_1.of)((0, vendorFiling1099ListReducer_1.updateVendorFiling1099DownloadData)({
38
+ response: vendorFiling1099ListReducer_2.initialState.vendorFiling1099DownloadData,
39
+ downloadState: {
40
+ fetchState: 'Error',
41
+ error: {
42
+ code: 500,
43
+ message: 'Fetch vendors 1099 Download REST API call errored out' +
44
+ JSON.stringify(err),
45
+ },
46
+ },
47
+ }));
48
+ }));
49
+ }));
50
+ exports.fetchVendorsFiling1099DownloadEpic = fetchVendorsFiling1099DownloadEpic;
@@ -11,3 +11,16 @@ export interface ReportVendorFiling1099Payload extends ReportPayload {
11
11
  is_vendor_1099_populated: boolean;
12
12
  }
13
13
  export declare type VendorFiling1099ListResponse = ZeniAPIResponse<FetchVendorFiling1099Payload>;
14
+ export interface VendorFiling1099DownloadDataForType {
15
+ data: Record<string, string | number | null>[];
16
+ customHeaders: {
17
+ label: string;
18
+ key: string;
19
+ }[];
20
+ }
21
+ export interface VendorFiling1099DownloadData {
22
+ nec: VendorFiling1099DownloadDataForType;
23
+ misc: VendorFiling1099DownloadDataForType;
24
+ int: VendorFiling1099DownloadDataForType;
25
+ }
26
+ export declare type VendorFiling1099DownloadResponse = ZeniAPIResponse<VendorFiling1099DownloadData>;
@@ -1,7 +1,8 @@
1
1
  import { SortOrder } from '../../../commonStateTypes/selectorTypes/sortOrderTypes';
2
2
  import { ZeniAPIStatus } from '../../../responsePayload';
3
- import { VendorFiling1099ListResponse } from './vendorFiling1099ListPayload';
4
- import { VendorFiling1099ListState, VendorFiling1099ListViewSortKey } from './vendorFiling1099ListState';
3
+ import { VendorFiling1099DownloadData, VendorFiling1099ListResponse } from './vendorFiling1099ListPayload';
4
+ import { Type1099Download, VendorFiling1099ListState, VendorFiling1099ListViewSortKey } from './vendorFiling1099ListState';
5
+ import { FetchStateAndError } from '../../../commonStateTypes/common';
5
6
  export declare const initialState: VendorFiling1099ListState;
6
7
  export declare const fetchVendorsFiling1099All: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[cacheOverride: boolean], {
7
8
  cacheOverride: boolean;
@@ -18,6 +19,11 @@ export declare const fetchVendorsFiling1099All: import("@reduxjs/toolkit").Actio
18
19
  sortKey: VendorFiling1099ListViewSortKey;
19
20
  }, string>, updateFiling1099SearchUIState: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
20
21
  searchString: string;
22
+ }, string>, fetchVendorsFiling1099Download: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[type1099: Type1099Download[]], {
23
+ type1099: Type1099Download[];
24
+ }, string, never, never>, updateVendorFiling1099DownloadData: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
25
+ downloadState: FetchStateAndError;
26
+ response: VendorFiling1099DownloadData;
21
27
  }, string>;
22
28
  declare const _default: import("@reduxjs/toolkit").Reducer<VendorFiling1099ListState, import("@reduxjs/toolkit").AnyAction>;
23
29
  export default _default;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  var _a;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.updateFiling1099SearchUIState = exports.updateFiling1099SortUIState = exports.updateFiling1099ScrollYOffset = exports.clearVendorsFiling1099List = exports.updateVendorFiling1099ListFailure = exports.updateVendorsFiling1099List = exports.fetchVendorsFiling1099List = exports.fetchVendorsFiling1099All = exports.initialState = void 0;
4
+ exports.updateVendorFiling1099DownloadData = exports.fetchVendorsFiling1099Download = exports.updateFiling1099SearchUIState = exports.updateFiling1099SortUIState = exports.updateFiling1099ScrollYOffset = exports.clearVendorsFiling1099List = exports.updateVendorFiling1099ListFailure = exports.updateVendorsFiling1099List = exports.fetchVendorsFiling1099List = exports.fetchVendorsFiling1099All = exports.initialState = void 0;
5
5
  const toolkit_1 = require("@reduxjs/toolkit");
6
6
  const zeniDayJS_1 = require("../../../zeniDayJS");
7
7
  exports.initialState = {
@@ -17,9 +17,26 @@ exports.initialState = {
17
17
  sortKey: 'total',
18
18
  sortOrder: 'descending',
19
19
  scrollYOffset: 0,
20
- downloadState: 'Not-Started',
20
+ downloadState: {
21
+ fetchState: 'Not-Started',
22
+ error: undefined,
23
+ },
21
24
  searchString: '',
22
25
  },
26
+ vendorFiling1099DownloadData: {
27
+ nec: {
28
+ data: [],
29
+ customHeaders: [],
30
+ },
31
+ misc: {
32
+ data: [],
33
+ customHeaders: [],
34
+ },
35
+ int: {
36
+ data: [],
37
+ customHeaders: [],
38
+ },
39
+ },
23
40
  };
24
41
  const vendorFiling1099List = (0, toolkit_1.createSlice)({
25
42
  name: 'vendorFiling1099List',
@@ -74,10 +91,30 @@ const vendorFiling1099List = (0, toolkit_1.createSlice)({
74
91
  draft.fetchState = 'Error';
75
92
  draft.error = action.payload.status;
76
93
  },
94
+ //Reducers for VendorFiling1099Download
95
+ fetchVendorsFiling1099Download: {
96
+ reducer(draft) {
97
+ draft.uiState.downloadState.fetchState = 'In-Progress';
98
+ draft.uiState.downloadState.error = undefined;
99
+ },
100
+ prepare(type1099) {
101
+ return {
102
+ payload: { type1099 },
103
+ };
104
+ },
105
+ },
106
+ updateVendorFiling1099DownloadData(draft, action) {
107
+ draft.uiState.downloadState.fetchState =
108
+ action.payload.downloadState.fetchState;
109
+ draft.uiState.downloadState.error = undefined;
110
+ draft.vendorFiling1099DownloadData.nec = action.payload.response.nec;
111
+ draft.vendorFiling1099DownloadData.misc = action.payload.response.misc;
112
+ draft.vendorFiling1099DownloadData.int = action.payload.response.int;
113
+ },
77
114
  clearVendorsFiling1099List(draft) {
78
115
  Object.assign(draft, exports.initialState);
79
116
  },
80
117
  },
81
118
  });
82
- _a = vendorFiling1099List.actions, exports.fetchVendorsFiling1099All = _a.fetchVendorsFiling1099All, exports.fetchVendorsFiling1099List = _a.fetchVendorsFiling1099List, exports.updateVendorsFiling1099List = _a.updateVendorsFiling1099List, exports.updateVendorFiling1099ListFailure = _a.updateVendorFiling1099ListFailure, exports.clearVendorsFiling1099List = _a.clearVendorsFiling1099List, exports.updateFiling1099ScrollYOffset = _a.updateFiling1099ScrollYOffset, exports.updateFiling1099SortUIState = _a.updateFiling1099SortUIState, exports.updateFiling1099SearchUIState = _a.updateFiling1099SearchUIState;
119
+ _a = vendorFiling1099List.actions, exports.fetchVendorsFiling1099All = _a.fetchVendorsFiling1099All, exports.fetchVendorsFiling1099List = _a.fetchVendorsFiling1099List, exports.updateVendorsFiling1099List = _a.updateVendorsFiling1099List, exports.updateVendorFiling1099ListFailure = _a.updateVendorFiling1099ListFailure, exports.clearVendorsFiling1099List = _a.clearVendorsFiling1099List, exports.updateFiling1099ScrollYOffset = _a.updateFiling1099ScrollYOffset, exports.updateFiling1099SortUIState = _a.updateFiling1099SortUIState, exports.updateFiling1099SearchUIState = _a.updateFiling1099SearchUIState, exports.fetchVendorsFiling1099Download = _a.fetchVendorsFiling1099Download, exports.updateVendorFiling1099DownloadData = _a.updateVendorFiling1099DownloadData;
83
120
  exports.default = vendorFiling1099List.reducer;
@@ -5,11 +5,13 @@ import { ZeniDate } from '../../../zeniDayJS';
5
5
  import { VendorFiling1099ListViewSortKey, VendorFiling1099ViewUIState } from './vendorFiling1099ListState';
6
6
  import { SortOrder } from '../../../commonStateTypes/selectorTypes/sortOrderTypes';
7
7
  import { VendorType } from '../../vendorTypeList/vendorTypeListPayload';
8
+ import { VendorFiling1099DownloadData } from './vendorFiling1099ListPayload';
8
9
  export interface VendorFiling1099ListSelectorView extends SelectorView {
9
10
  vendors: Vendor[];
10
11
  vendorTypeList: VendorType[];
11
12
  isVendor1099Populated: boolean;
12
13
  uiState: VendorFiling1099ViewUIState;
14
+ vendorFiling1099DownloadData: VendorFiling1099DownloadData;
13
15
  searchString?: string;
14
16
  lastRefreshSuccessTime?: ZeniDate;
15
17
  }
@@ -39,6 +39,7 @@ const getVendorFiling1099List = (state) => {
39
39
  vendorTypeList: vendorTypeList,
40
40
  isVendor1099Populated: (_a = vendorFiling1099ListState.isVendor1099Populated) !== null && _a !== void 0 ? _a : true,
41
41
  uiState: vendorFiling1099ListState.uiState,
42
+ vendorFiling1099DownloadData: vendorFiling1099ListState.vendorFiling1099DownloadData,
42
43
  fetchState: fetchStatus.fetchState,
43
44
  lastRefreshSuccessTime: vendorFiling1099ListState.lastRefreshSuccessTime,
44
45
  error: vendorFiling1099ListState.error,
@@ -1,17 +1,19 @@
1
- import { FetchedState, FetchState, ID } from '../../../commonStateTypes/common';
1
+ import { FetchedState, FetchStateAndError, ID } from '../../../commonStateTypes/common';
2
2
  import { SortOrder } from '../../../commonStateTypes/selectorTypes/sortOrderTypes';
3
3
  import { ZeniDate } from '../../../zeniDayJS';
4
+ import { VendorFiling1099DownloadData } from './vendorFiling1099ListPayload';
4
5
  export interface VendorFiling1099ViewUIState {
5
6
  sortKey: VendorFiling1099ListViewSortKey;
6
7
  sortOrder: SortOrder;
7
8
  scrollYOffset: number;
8
- downloadState: FetchState;
9
+ downloadState: FetchStateAndError;
9
10
  searchString: string;
10
11
  }
11
12
  export interface VendorFiling1099ListState extends FetchedState {
12
13
  vendorIds: ID[];
13
14
  uiState: VendorFiling1099ViewUIState;
14
15
  isVendor1099Populated: boolean;
16
+ vendorFiling1099DownloadData: VendorFiling1099DownloadData;
15
17
  lastRefreshSuccessTime?: ZeniDate;
16
18
  }
17
19
  export interface VendorFiling1099ListQuery {
@@ -20,4 +22,5 @@ export interface VendorFiling1099ListQuery {
20
22
  }
21
23
  declare const toVendorFiling1099ListViewSortKey: (v: string) => "total" | "status" | "w9" | "legal_name" | "tax_classification";
22
24
  export declare type VendorFiling1099ListViewSortKey = ReturnType<typeof toVendorFiling1099ListViewSortKey>;
25
+ export declare type Type1099Download = 'nec' | 'misc' | 'int';
23
26
  export {};
@@ -8,8 +8,9 @@ import { Contact } from '../../../entity/billPay/contact/contact';
8
8
  export declare const initialState: VendorFiling1099UploadDetailsState;
9
9
  export declare const updateW9FormUploadFile: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
10
10
  w9FormFile: FilePayload;
11
- }, string>, updateW9FormUploadFetchState: import("@reduxjs/toolkit").ActionCreatorWithPayload<FetchStateAndError, string>, vendorFiling1099UploadDetailsSave: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[vendorId: string], {
11
+ }, string>, updateW9FormUploadFetchState: import("@reduxjs/toolkit").ActionCreatorWithPayload<FetchStateAndError, string>, vendorFiling1099UploadDetailsSave: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[vendorId: string, signal?: AbortSignal | undefined], {
12
12
  vendorId: string;
13
+ signal: AbortSignal | undefined;
13
14
  }, string, never, never>, vendorFiling1099UploadDetailsResetLocalData: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[vendorId: string], {
14
15
  vendorId: string;
15
16
  }, string, never, never>, vendorFiling1099UploadDetailsSuccessOrFailure: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[fetchState: FetchState, error?: ZeniAPIStatus<Record<string, unknown>> | undefined], {
@@ -121,10 +121,15 @@ const vendorFiling1099UploadDetails = (0, toolkit_1.createSlice)({
121
121
  error: undefined,
122
122
  };
123
123
  },
124
- prepare(vendorId) {
124
+ /*
125
+ @param signal is used to abort the request if needed.
126
+ We have to pass it as a parameter to the reducer-action function from the component (web-app-ui/cockpit-ui/web-c)
127
+ */
128
+ prepare(vendorId, signal) {
125
129
  return {
126
130
  payload: {
127
131
  vendorId,
132
+ signal,
128
133
  },
129
134
  };
130
135
  },
@@ -16,10 +16,11 @@ const vendorFiling1099UploadDetailsSaveEpic = (actions$, state$, zeniAPI) => act
16
16
  var _a;
17
17
  const state = state$.value;
18
18
  const vendorFiling1099ViewState = state.vendorFiling1099UploadDetailsState;
19
+ const signal = action.payload.signal;
19
20
  const address = (_a = state$.value.addressViewState.newAddressState) === null || _a === void 0 ? void 0 : _a.vendor_address.addressToCreate;
20
21
  const vendorId = action.payload.vendorId;
21
22
  const payload = (0, vendorFiling1099UploadDetailsPayload_1.prepareEditVendor1099DetailsPayload)(state, vendorFiling1099ViewState.vendor1099DetailsLocalData, vendorId, address);
22
- const saveVendorApi = zeniAPI.putAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/vendors/${vendorId}`, payload);
23
+ const saveVendorApi = zeniAPI.putAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/vendors/${vendorId}`, payload, {}, signal);
23
24
  return saveVendorApi.pipe((0, operators_1.mergeMap)((response) => {
24
25
  var _a;
25
26
  if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
package/lib/zeniAPI.d.ts CHANGED
@@ -25,12 +25,12 @@ export interface ZeniAPI<ResponseType = FetchResponse> {
25
25
  readonly sessionId?: string;
26
26
  readonly tenantId?: string;
27
27
  update(userId?: string, sessionId?: string, tenantId?: string): void;
28
- getJSON<T>(path: string, headers?: Record<string, unknown>): Observable<T>;
29
- postJSON(restEndPoint: string, body?: Record<string, unknown>, headers?: Record<string, unknown>): Observable<ResponseType>;
30
- postAndGetJSON<T>(restEndPoint: string, body?: Record<string, unknown>, headers?: Record<string, unknown>): Observable<T>;
31
- deleteAndGetJSON<T>(path: string, body?: Record<string, unknown>, headers?: Record<string, unknown>): Observable<T>;
32
- putAndGetJSON<T>(restEndPoint: string, body?: Record<string, unknown>, headers?: Record<string, unknown>): Observable<T>;
33
- patchAndGetJSON<T>(restEndPoint: string, body?: Record<string, unknown>, headers?: Record<string, unknown>): Observable<T>;
28
+ getJSON<T>(path: string, headers?: Record<string, unknown>, signal?: AbortSignal): Observable<T>;
29
+ postJSON(restEndPoint: string, body?: Record<string, unknown>, headers?: Record<string, unknown>, signal?: AbortSignal): Observable<ResponseType>;
30
+ postAndGetJSON<T>(restEndPoint: string, body?: Record<string, unknown>, headers?: Record<string, unknown>, signal?: AbortSignal): Observable<T>;
31
+ deleteAndGetJSON<T>(path: string, body?: Record<string, unknown>, headers?: Record<string, unknown>, signal?: AbortSignal): Observable<T>;
32
+ putAndGetJSON<T>(restEndPoint: string, body?: Record<string, unknown>, headers?: Record<string, unknown>, signal?: AbortSignal): Observable<T>;
33
+ patchAndGetJSON<T>(restEndPoint: string, body?: Record<string, unknown>, headers?: Record<string, unknown>, signal?: AbortSignal): Observable<T>;
34
34
  }
35
35
  export declare class ZeniAPIClient implements ZeniAPI {
36
36
  readonly apiEndPoints: RESTAPIEndpoints;
@@ -39,12 +39,12 @@ export declare class ZeniAPIClient implements ZeniAPI {
39
39
  tenantId?: string | undefined;
40
40
  constructor(apiEndPoints: RESTAPIEndpoints, userId?: string | undefined, sessionId?: string | undefined, tenantId?: string | undefined);
41
41
  update(userId?: string, sessionId?: string, tenantId?: string): void;
42
- getJSON<T>(restEndPoint: string, headers?: Record<string, unknown>): Observable<T>;
43
- postJSON(restEndPoint: string, body?: Record<string, unknown>, headers?: Record<string, unknown>): Observable<FetchResponse>;
44
- postAndGetJSON<T>(restEndPoint: string, body?: Record<string, unknown>, headers?: Record<string, unknown>): Observable<T>;
45
- deleteAndGetJSON<T>(restEndPoint: string, body?: Record<string, unknown>, headers?: Record<string, unknown>): Observable<T>;
46
- putAndGetJSON<T>(restEndPoint: string, body?: Record<string, unknown>, headers?: Record<string, unknown>): Observable<T>;
47
- patchAndGetJSON<T>(restEndPoint: string, body?: Record<string, unknown>, headers?: Record<string, unknown>): Observable<T>;
42
+ getJSON<T>(restEndPoint: string, headers?: Record<string, unknown>, signal?: AbortSignal): Observable<T>;
43
+ postJSON(restEndPoint: string, body?: Record<string, unknown>, headers?: Record<string, unknown>, signal?: AbortSignal): Observable<FetchResponse>;
44
+ postAndGetJSON<T>(restEndPoint: string, body?: Record<string, unknown>, headers?: Record<string, unknown>, signal?: AbortSignal): Observable<T>;
45
+ deleteAndGetJSON<T>(restEndPoint: string, body?: Record<string, unknown>, headers?: Record<string, unknown>, signal?: AbortSignal): Observable<T>;
46
+ putAndGetJSON<T>(restEndPoint: string, body?: Record<string, unknown>, headers?: Record<string, unknown>, signal?: AbortSignal): Observable<T>;
47
+ patchAndGetJSON<T>(restEndPoint: string, body?: Record<string, unknown>, headers?: Record<string, unknown>, signal?: AbortSignal): Observable<T>;
48
48
  private apiHeaders;
49
49
  }
50
50
  export {};
package/lib/zeniAPI.js CHANGED
@@ -16,30 +16,33 @@ class ZeniAPIClient {
16
16
  this.sessionId = sessionId;
17
17
  this.tenantId = tenantId;
18
18
  }
19
- getJSON(restEndPoint, headers) {
19
+ getJSON(restEndPoint, headers, signal) {
20
20
  const promise = (0, cross_fetch_1.fetch)(restEndPoint, {
21
21
  method: 'GET',
22
22
  headers: this.apiHeaders(headers),
23
+ signal,
23
24
  }).then((response) => response.json());
24
25
  return (0, rxjs_1.from)(promise);
25
26
  }
26
- postJSON(restEndPoint, body, headers) {
27
+ postJSON(restEndPoint, body, headers, signal) {
27
28
  const promise = (0, cross_fetch_1.fetch)(restEndPoint, {
28
29
  method: 'POST',
29
30
  body: body != null ? JSON.stringify(body) : undefined,
30
31
  headers: Object.assign({ 'Content-Type': 'application/json' }, this.apiHeaders(headers)),
32
+ signal,
31
33
  });
32
34
  return (0, rxjs_1.from)(promise);
33
35
  }
34
- postAndGetJSON(restEndPoint, body, headers) {
36
+ postAndGetJSON(restEndPoint, body, headers, signal) {
35
37
  const promise = (0, cross_fetch_1.fetch)(restEndPoint, {
36
38
  method: 'POST',
37
39
  body: body != null ? JSON.stringify(body) : undefined,
38
40
  headers: Object.assign({ 'Content-Type': 'application/json' }, this.apiHeaders(headers)),
41
+ signal,
39
42
  }).then((response) => response.json());
40
43
  return (0, rxjs_1.from)(promise);
41
44
  }
42
- deleteAndGetJSON(restEndPoint, body, headers) {
45
+ deleteAndGetJSON(restEndPoint, body, headers, signal) {
43
46
  let apiHeaders = this.apiHeaders(headers);
44
47
  if (body != null) {
45
48
  apiHeaders = Object.assign({ 'Content-Type': 'application/json' }, apiHeaders);
@@ -48,22 +51,25 @@ class ZeniAPIClient {
48
51
  method: 'DELETE',
49
52
  body: body != null ? JSON.stringify(body) : undefined,
50
53
  headers: apiHeaders,
54
+ signal,
51
55
  }).then((response) => response.json());
52
56
  return (0, rxjs_1.from)(promise);
53
57
  }
54
- putAndGetJSON(restEndPoint, body, headers) {
58
+ putAndGetJSON(restEndPoint, body, headers, signal) {
55
59
  const promise = (0, cross_fetch_1.fetch)(restEndPoint, {
56
60
  method: 'PUT',
57
61
  body: body != null ? JSON.stringify(body) : undefined,
58
62
  headers: Object.assign({ 'Content-Type': 'application/json' }, this.apiHeaders(headers)),
63
+ signal,
59
64
  }).then((response) => response.json());
60
65
  return (0, rxjs_1.from)(promise);
61
66
  }
62
- patchAndGetJSON(restEndPoint, body, headers) {
67
+ patchAndGetJSON(restEndPoint, body, headers, signal) {
63
68
  const promise = (0, cross_fetch_1.fetch)(restEndPoint, {
64
69
  method: 'PATCH',
65
70
  body: body != null ? JSON.stringify(body) : undefined,
66
71
  headers: Object.assign({ 'Content-Type': 'application/json' }, this.apiHeaders(headers)),
72
+ signal,
67
73
  }).then((response) => response.json());
68
74
  return (0, rxjs_1.from)(promise);
69
75
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "4.13.0",
3
+ "version": "4.13.2",
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
  "types": "lib/index.d.ts",
@@ -88,7 +88,7 @@
88
88
  "build": "concurrently --kill-others-on-fail \"eslint . --ext .js,.jsx,.ts,.tsx\" \"tsc\" \"jest --config jest.config.json\"",
89
89
  "onlybuild": "concurrently --kill-others-on-fail \"eslint . --ext .js,.jsx,.ts,.tsx\" \"tsc\"",
90
90
  "format": "prettier --write --ignore-unknown \"src/**/*\"",
91
- "format-watch": "git diff --name-only --cached --diff-filter=ACM | grep -E '\\.(ts|tsx)$' | xargs prettier --write",
91
+ "format-watch": "(git diff --name-only --diff-filter=ACM && git ls-files --others --exclude-standard) | grep -E '\\.(ts|tsx)$' | xargs prettier --write",
92
92
  "check-version": "ts-node ./scripts/check-version.ts",
93
93
  "version": "git add -A src",
94
94
  "postversion": "git push && git push --tags",