@zeniai/client-epic-state 4.19.99-betaRD3 → 4.19.99-betaRD4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/entity/aiAccountantCustomer/aiAccountantCustomerReducer.d.ts +2 -1
- package/lib/entity/aiAccountantCustomer/aiAccountantCustomerReducer.js +13 -4
- package/lib/esm/entity/aiAccountantCustomer/aiAccountantCustomerReducer.js +13 -4
- package/lib/esm/view/aiAccountantView/aiAccountantViewReducer.js +6 -4
- package/lib/esm/view/aiAccountantView/epics/fetchAiAccountantJobsEpic.js +16 -6
- package/lib/tsconfig.typecheck.tsbuildinfo +1 -1
- package/lib/view/aiAccountantView/aiAccountantViewPayload.d.ts +1 -0
- package/lib/view/aiAccountantView/aiAccountantViewReducer.d.ts +4 -2
- package/lib/view/aiAccountantView/aiAccountantViewReducer.js +6 -4
- package/lib/view/aiAccountantView/aiAccountantViewState.d.ts +1 -0
- package/lib/view/aiAccountantView/epics/fetchAiAccountantJobsEpic.d.ts +10 -3
- package/lib/view/aiAccountantView/epics/fetchAiAccountantJobsEpic.js +15 -5
- package/package.json +1 -1
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { AiAccountantCustomerPayload, AiAccountantJobPayload } from './aiAccountantCustomerPayload';
|
|
2
2
|
import { AiAccountantCustomerState } from './aiAccountantCustomerState';
|
|
3
3
|
export declare const initialAiAccountantCustomerState: AiAccountantCustomerState;
|
|
4
|
-
export declare const clearAllAiAccountantCustomers: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"aiAccountantCustomer/clearAllAiAccountantCustomers">, updateAiAccountantCustomers: import("@reduxjs/toolkit").ActionCreatorWithPayload<AiAccountantCustomerPayload[], "aiAccountantCustomer/updateAiAccountantCustomers">, updateAiAccountantCustomer: import("@reduxjs/toolkit").ActionCreatorWithPayload<AiAccountantCustomerPayload, "aiAccountantCustomer/updateAiAccountantCustomer">, updateAiAccountantJobs: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[tenantId: string, jobs: AiAccountantJobPayload[]], {
|
|
4
|
+
export declare const clearAllAiAccountantCustomers: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"aiAccountantCustomer/clearAllAiAccountantCustomers">, updateAiAccountantCustomers: import("@reduxjs/toolkit").ActionCreatorWithPayload<AiAccountantCustomerPayload[], "aiAccountantCustomer/updateAiAccountantCustomers">, updateAiAccountantCustomer: import("@reduxjs/toolkit").ActionCreatorWithPayload<AiAccountantCustomerPayload, "aiAccountantCustomer/updateAiAccountantCustomer">, updateAiAccountantJobs: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[tenantId: string, jobs: AiAccountantJobPayload[], append?: boolean | undefined], {
|
|
5
5
|
tenantId: string;
|
|
6
6
|
jobs: AiAccountantJobPayload[];
|
|
7
|
+
append: boolean;
|
|
7
8
|
}, "aiAccountantCustomer/updateAiAccountantJobs", never, never>;
|
|
8
9
|
declare const _default: import("redux").Reducer<AiAccountantCustomerState>;
|
|
9
10
|
export default _default;
|
|
@@ -24,11 +24,20 @@ const aiAccountantCustomer = (0, toolkit_1.createSlice)({
|
|
|
24
24
|
},
|
|
25
25
|
updateAiAccountantJobs: {
|
|
26
26
|
reducer(draft, action) {
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
const mappedJobs = action.payload.jobs.map(aiAccountantCustomerPayload_1.toAiAccountantJob);
|
|
28
|
+
if (action.payload.append) {
|
|
29
|
+
const existing = draft.jobsByTenantId[action.payload.tenantId] ?? [];
|
|
30
|
+
draft.jobsByTenantId[action.payload.tenantId] = [
|
|
31
|
+
...existing,
|
|
32
|
+
...mappedJobs,
|
|
33
|
+
];
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
draft.jobsByTenantId[action.payload.tenantId] = mappedJobs;
|
|
37
|
+
}
|
|
29
38
|
},
|
|
30
|
-
prepare(tenantId, jobs) {
|
|
31
|
-
return { payload: { tenantId, jobs } };
|
|
39
|
+
prepare(tenantId, jobs, append = false) {
|
|
40
|
+
return { payload: { tenantId, jobs, append } };
|
|
32
41
|
},
|
|
33
42
|
},
|
|
34
43
|
clearAllAiAccountantCustomers(draft) {
|
|
@@ -20,11 +20,20 @@ const aiAccountantCustomer = createSlice({
|
|
|
20
20
|
},
|
|
21
21
|
updateAiAccountantJobs: {
|
|
22
22
|
reducer(draft, action) {
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
const mappedJobs = action.payload.jobs.map(toAiAccountantJob);
|
|
24
|
+
if (action.payload.append) {
|
|
25
|
+
const existing = draft.jobsByTenantId[action.payload.tenantId] ?? [];
|
|
26
|
+
draft.jobsByTenantId[action.payload.tenantId] = [
|
|
27
|
+
...existing,
|
|
28
|
+
...mappedJobs,
|
|
29
|
+
];
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
draft.jobsByTenantId[action.payload.tenantId] = mappedJobs;
|
|
33
|
+
}
|
|
25
34
|
},
|
|
26
|
-
prepare(tenantId, jobs) {
|
|
27
|
-
return { payload: { tenantId, jobs } };
|
|
35
|
+
prepare(tenantId, jobs, append = false) {
|
|
36
|
+
return { payload: { tenantId, jobs, append } };
|
|
28
37
|
},
|
|
29
38
|
},
|
|
30
39
|
clearAllAiAccountantCustomers(draft) {
|
|
@@ -38,8 +38,8 @@ const aiAccountantView = createSlice({
|
|
|
38
38
|
customerView.jobsFetchStatus = { fetchState: 'In-Progress' };
|
|
39
39
|
}
|
|
40
40
|
},
|
|
41
|
-
prepare(tenantId) {
|
|
42
|
-
return { payload: { tenantId } };
|
|
41
|
+
prepare(tenantId, fetchNextPage) {
|
|
42
|
+
return { payload: { tenantId, fetchNextPage: fetchNextPage ?? false } };
|
|
43
43
|
},
|
|
44
44
|
},
|
|
45
45
|
updateAiAccountantJobs: {
|
|
@@ -47,10 +47,11 @@ const aiAccountantView = createSlice({
|
|
|
47
47
|
const customerView = draft.customersByTenantId[action.payload.tenantId];
|
|
48
48
|
if (customerView != null) {
|
|
49
49
|
customerView.jobsFetchStatus = { fetchState: 'Completed' };
|
|
50
|
+
customerView.jobsPageToken = action.payload.nextPageToken;
|
|
50
51
|
}
|
|
51
52
|
},
|
|
52
|
-
prepare(tenantId) {
|
|
53
|
-
return { payload: { tenantId } };
|
|
53
|
+
prepare(tenantId, nextPageToken) {
|
|
54
|
+
return { payload: { tenantId, nextPageToken: nextPageToken ?? null } };
|
|
54
55
|
},
|
|
55
56
|
},
|
|
56
57
|
updateAiAccountantJobsFailure(draft, action) {
|
|
@@ -138,6 +139,7 @@ const toCustomersByTenantId = (customers) => {
|
|
|
138
139
|
result[payload.tenant_id] = {
|
|
139
140
|
cancelOnboardingStatus: { fetchState: 'Not-Started' },
|
|
140
141
|
jobsFetchStatus: { fetchState: 'Not-Started' },
|
|
142
|
+
jobsPageToken: null,
|
|
141
143
|
tenantId: payload.tenant_id,
|
|
142
144
|
};
|
|
143
145
|
}
|
|
@@ -3,14 +3,21 @@ import { catchError, filter, mergeMap, switchMap } from 'rxjs/operators';
|
|
|
3
3
|
import { updateAiAccountantJobs as updateAiAccountantJobEntities } from '../../../entity/aiAccountantCustomer/aiAccountantCustomerReducer';
|
|
4
4
|
import { updateAllUsers } from '../../../entity/user/userReducer';
|
|
5
5
|
import { createZeniAPIStatus, isSuccessResponse } from '../../../responsePayload';
|
|
6
|
-
import { fetchAiAccountantJobs, updateAiAccountantJobsFailure, } from '../aiAccountantViewReducer';
|
|
7
|
-
export const fetchAiAccountantJobsEpic = (actions$,
|
|
8
|
-
const { tenantId } = action.payload;
|
|
6
|
+
import { fetchAiAccountantJobs, updateAiAccountantJobs, updateAiAccountantJobsFailure, } from '../aiAccountantViewReducer';
|
|
7
|
+
export const fetchAiAccountantJobsEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(fetchAiAccountantJobs.match), switchMap((action) => {
|
|
8
|
+
const { tenantId, fetchNextPage } = action.payload;
|
|
9
|
+
const rootState = state$.value;
|
|
10
|
+
const customerView = rootState.aiAccountantViewState.customersByTenantId[tenantId];
|
|
11
|
+
const pageToken = fetchNextPage && customerView?.jobsPageToken != null
|
|
12
|
+
? customerView.jobsPageToken
|
|
13
|
+
: null;
|
|
9
14
|
const params = new URLSearchParams({
|
|
10
|
-
page: '1',
|
|
11
15
|
limit: '50',
|
|
12
16
|
tenant_id: tenantId,
|
|
13
17
|
});
|
|
18
|
+
if (pageToken != null) {
|
|
19
|
+
params.set('page_token', pageToken);
|
|
20
|
+
}
|
|
14
21
|
const base = `${zeniAPI.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/cockpit-panels`;
|
|
15
22
|
const url = `${base}/ai-accountant/jobs?${params.toString()}`;
|
|
16
23
|
return zeniAPI
|
|
@@ -19,9 +26,11 @@ export const fetchAiAccountantJobsEpic = (actions$, _, zeniAPI) => actions$.pipe
|
|
|
19
26
|
if (isSuccessResponse(response)) {
|
|
20
27
|
const jobs = response.data?.jobs ?? [];
|
|
21
28
|
const users = response.data?.users ?? [];
|
|
29
|
+
const nextPageToken = response.data?.next_page_token ?? null;
|
|
22
30
|
return from([
|
|
23
31
|
updateAllUsers({ users }),
|
|
24
|
-
updateAiAccountantJobEntities(tenantId, jobs),
|
|
32
|
+
updateAiAccountantJobEntities(tenantId, jobs, fetchNextPage),
|
|
33
|
+
updateAiAccountantJobs(tenantId, nextPageToken),
|
|
25
34
|
]);
|
|
26
35
|
}
|
|
27
36
|
else {
|
|
@@ -32,6 +41,7 @@ export const fetchAiAccountantJobsEpic = (actions$, _, zeniAPI) => actions$.pipe
|
|
|
32
41
|
}
|
|
33
42
|
}), catchError((error) => of(updateAiAccountantJobsFailure({
|
|
34
43
|
tenantId,
|
|
35
|
-
error: createZeniAPIStatus('Unexpected error', 'AI Accountant jobs fetch failed: ' +
|
|
44
|
+
error: createZeniAPIStatus('Unexpected error', 'AI Accountant jobs fetch failed: ' +
|
|
45
|
+
JSON.stringify(error)),
|
|
36
46
|
}))));
|
|
37
47
|
}));
|