@zeniai/client-epic-state 5.1.45-betaDI2 → 5.1.45
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/snackbar/snackbarTypes.d.ts +1 -1
- package/lib/entity/snackbar/snackbarTypes.js +0 -3
- package/lib/entity/task/taskPayload.d.ts +1 -3
- package/lib/entity/task/taskPayload.js +1 -16
- package/lib/entity/task/taskReducer.d.ts +1 -8
- package/lib/entity/task/taskReducer.js +4 -29
- package/lib/entity/task/taskState.d.ts +0 -2
- package/lib/entity/tenant/epic/saveExternalConnectionEpic.d.ts +1 -2
- package/lib/entity/tenant/epic/saveExternalConnectionEpic.js +0 -17
- package/lib/epic.d.ts +3 -6
- package/lib/epic.js +3 -6
- package/lib/esm/entity/snackbar/snackbarTypes.js +0 -3
- package/lib/esm/entity/task/taskPayload.js +1 -16
- package/lib/esm/entity/task/taskReducer.js +3 -28
- package/lib/esm/entity/tenant/epic/saveExternalConnectionEpic.js +0 -17
- package/lib/esm/epic.js +3 -6
- package/lib/esm/index.js +8 -8
- package/lib/esm/view/aiCfoView/aiCfoViewReducer.js +1 -31
- package/lib/esm/view/aiCfoView/epics/fetchSkillsEpic.js +8 -33
- package/lib/esm/view/companyTaskManagerView/epics/fetchCompanyTaskManagerViewEpic.js +0 -3
- package/lib/esm/view/companyTaskManagerView/epics/fetchTaskManagerMetricsEpic.js +1 -7
- package/lib/esm/view/expenseAutomationView/reducers/transactionsViewReducer.js +0 -7
- package/lib/esm/view/taskManager/taskDetailView/epics/initializeTaskToLocalStoreEpic.js +0 -2
- package/lib/esm/view/taskManager/taskDetailView/epics/saveTaskDetailEpic.js +9 -70
- package/lib/esm/view/taskManager/taskDetailView/taskDetailReducer.js +2 -56
- package/lib/esm/view/taskManager/taskDetailView/taskDetailSelector.js +9 -32
- package/lib/esm/view/taskManager/taskListView/epics/fetchTaskListEpic.js +1 -3
- package/lib/esm/view/taskManager/taskListView/taskList.js +0 -1
- package/lib/esm/view/taskManager/taskListView/taskListReducer.js +13 -266
- package/lib/esm/view/taskManager/taskListView/taskListSelector.js +0 -1
- package/lib/esm/view/taskManager/taskListView/taskListViewHelpers.js +0 -58
- package/lib/esm/view/transactionDetail/epics/saveTransactionHelper.js +0 -22
- package/lib/esm/view/transactionDetail/epics/updateTransactionDetailEpic.js +3 -75
- package/lib/esm/view/transactionDetail/journalEntryLinesViewModel.js +0 -58
- package/lib/esm/view/transactionDetail/transactionDetailLocalDataHelper.js +8 -10
- package/lib/esm/view/transactionDetail/transactionDetailReducer.js +1 -66
- package/lib/index.d.ts +11 -12
- package/lib/index.js +28 -37
- package/lib/view/aiCfoView/aiCfoViewPayload.d.ts +0 -10
- package/lib/view/aiCfoView/aiCfoViewReducer.d.ts +2 -7
- package/lib/view/aiCfoView/aiCfoViewReducer.js +2 -32
- package/lib/view/aiCfoView/aiCfoViewState.d.ts +1 -5
- package/lib/view/aiCfoView/epics/fetchSkillsEpic.js +8 -33
- package/lib/view/companyTaskManagerView/epics/fetchCompanyTaskManagerViewEpic.js +0 -3
- package/lib/view/companyTaskManagerView/epics/fetchTaskManagerMetricsEpic.js +1 -7
- package/lib/view/companyView/types/cockpitTypes.d.ts +0 -3
- package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
- package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.js +0 -7
- package/lib/view/taskManager/taskDetailView/epics/initializeTaskToLocalStoreEpic.js +0 -2
- package/lib/view/taskManager/taskDetailView/epics/saveTaskDetailEpic.d.ts +2 -2
- package/lib/view/taskManager/taskDetailView/epics/saveTaskDetailEpic.js +8 -69
- package/lib/view/taskManager/taskDetailView/taskDetail.d.ts +0 -16
- package/lib/view/taskManager/taskDetailView/taskDetailReducer.d.ts +2 -14
- package/lib/view/taskManager/taskDetailView/taskDetailReducer.js +3 -57
- package/lib/view/taskManager/taskDetailView/taskDetailSelector.d.ts +1 -2
- package/lib/view/taskManager/taskDetailView/taskDetailSelector.js +7 -30
- package/lib/view/taskManager/taskListView/epics/fetchTaskListEpic.js +1 -3
- package/lib/view/taskManager/taskListView/taskList.d.ts +1 -1
- package/lib/view/taskManager/taskListView/taskList.js +0 -1
- package/lib/view/taskManager/taskListView/taskListPayload.d.ts +0 -4
- package/lib/view/taskManager/taskListView/taskListReducer.d.ts +2 -6
- package/lib/view/taskManager/taskListView/taskListReducer.js +14 -267
- package/lib/view/taskManager/taskListView/taskListSelector.js +0 -1
- package/lib/view/taskManager/taskListView/taskListViewHelpers.d.ts +0 -11
- package/lib/view/taskManager/taskListView/taskListViewHelpers.js +1 -60
- package/lib/view/transactionDetail/epics/saveTransactionHelper.js +0 -22
- package/lib/view/transactionDetail/epics/updateTransactionDetailEpic.d.ts +1 -5
- package/lib/view/transactionDetail/epics/updateTransactionDetailEpic.js +4 -77
- package/lib/view/transactionDetail/journalEntryLinesViewModel.d.ts +0 -27
- package/lib/view/transactionDetail/journalEntryLinesViewModel.js +1 -61
- package/lib/view/transactionDetail/transactionDetailLocalDataHelper.js +8 -10
- package/lib/view/transactionDetail/transactionDetailReducer.d.ts +2 -11
- package/lib/view/transactionDetail/transactionDetailReducer.js +2 -67
- package/lib/view/transactionDetail/transactionDetailState.d.ts +1 -8
- package/lib/view/transactionDetail/transactionDetailTypes.d.ts +0 -2
- package/package.json +1 -1
- package/lib/esm/view/aiCfoView/epics/submitFeedbackEpic.js +0 -39
- package/lib/esm/view/taskManager/taskDetailView/epics/createSubTaskEpic.js +0 -96
- package/lib/esm/view/taskManager/taskDetailView/epics/fetchSubTasksEpic.js +0 -53
- package/lib/view/aiCfoView/epics/submitFeedbackEpic.d.ts +0 -13
- package/lib/view/aiCfoView/epics/submitFeedbackEpic.js +0 -43
- package/lib/view/taskManager/taskDetailView/epics/createSubTaskEpic.d.ts +0 -9
- package/lib/view/taskManager/taskDetailView/epics/createSubTaskEpic.js +0 -100
- package/lib/view/taskManager/taskDetailView/epics/fetchSubTasksEpic.d.ts +0 -8
- package/lib/view/taskManager/taskDetailView/epics/fetchSubTasksEpic.js +0 -57
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { of } from 'rxjs';
|
|
2
|
-
import { catchError, filter, mergeMap } from 'rxjs/operators';
|
|
3
|
-
import { setSubTaskIds, updateTasks } from '../../../../entity/task/taskReducer';
|
|
4
|
-
import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
|
|
5
|
-
import { fetchSubTasks, updateSubTasks, updateSubTasksFetchStatus, } from '../taskDetailReducer';
|
|
6
|
-
export const fetchSubTasksEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(fetchSubTasks.match),
|
|
7
|
-
// Use mergeMap, not switchMap: switchMap cancels in-flight requests for
|
|
8
|
-
// the previous parent without dispatching success or failure, leaving
|
|
9
|
-
// subTaskListFetchStatusByParentId stuck at In-Progress and blocking the
|
|
10
|
-
// detail page's combined fetchStatus via reduceAnyFetchState. Per-parent
|
|
11
|
-
// races on the same parentTaskId are handled last-write-wins downstream.
|
|
12
|
-
mergeMap((action) => {
|
|
13
|
-
const { parentTaskId } = action.payload;
|
|
14
|
-
const query = JSON.stringify({
|
|
15
|
-
task_type: 'subtasks',
|
|
16
|
-
parent_task_id: parentTaskId,
|
|
17
|
-
});
|
|
18
|
-
return zeniAPI
|
|
19
|
-
.getJSON(`${zeniAPI.apiEndPoints.taskMicroServiceBaseUrl}/1.0/task-manager/tasks?query=${encodeURIComponent(query)}`)
|
|
20
|
-
.pipe(mergeMap((response) => {
|
|
21
|
-
if (isSuccessResponse(response) && response.data != null) {
|
|
22
|
-
const { tasks } = response.data;
|
|
23
|
-
// Keep the parent's `subTasksIds` in sync with the fetched
|
|
24
|
-
// bucket. Without this, the parent entity record can drift
|
|
25
|
-
// out of sync with what the children fetch returned —
|
|
26
|
-
// e.g. a server-side delete won't drop from the parent
|
|
27
|
-
// record until the next list re-fetch.
|
|
28
|
-
const fetchedChildIds = tasks
|
|
29
|
-
.filter((t) => t.parent_task_id === parentTaskId)
|
|
30
|
-
.map((t) => t.task_id);
|
|
31
|
-
return of(updateTasks(tasks), setSubTaskIds({
|
|
32
|
-
parentTaskId,
|
|
33
|
-
subTaskIds: fetchedChildIds,
|
|
34
|
-
}), updateSubTasks({
|
|
35
|
-
parentTaskId,
|
|
36
|
-
}));
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
return of(updateSubTasksFetchStatus({
|
|
40
|
-
parentTaskId,
|
|
41
|
-
fetchState: 'Error',
|
|
42
|
-
error: response.status,
|
|
43
|
-
}));
|
|
44
|
-
}
|
|
45
|
-
}), catchError((error) => {
|
|
46
|
-
return of(updateSubTasksFetchStatus({
|
|
47
|
-
parentTaskId,
|
|
48
|
-
fetchState: 'Error',
|
|
49
|
-
error: createZeniAPIStatus('Unexpected Error', 'Fetch Sub Tasks REST API call errored out' +
|
|
50
|
-
JSON.stringify(error)),
|
|
51
|
-
}));
|
|
52
|
-
}));
|
|
53
|
-
}));
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
|
-
import { Observable } from 'rxjs';
|
|
3
|
-
import { RootState } from '../../../reducer';
|
|
4
|
-
import { ZeniAPI } from '../../../zeniAPI';
|
|
5
|
-
import { submitFeedback, submitFeedbackFailure, submitFeedbackSuccess } from '../aiCfoViewReducer';
|
|
6
|
-
export type ActionType = ReturnType<typeof submitFeedback> | ReturnType<typeof submitFeedbackSuccess> | ReturnType<typeof submitFeedbackFailure>;
|
|
7
|
-
/**
|
|
8
|
-
* Thin wiring for AI CFO answer feedback (👍/👎). Dispatch `submitFeedback(...)` (defined on the
|
|
9
|
-
* aiCfoView slice) to POST to the AI CFO micro-service `/1.0/feedback` endpoint, which emits the
|
|
10
|
-
* analytics event server-side and routes negatives to the review queue. The capture-prompt UI
|
|
11
|
-
* that dispatches this lands in a fast-follow PR.
|
|
12
|
-
*/
|
|
13
|
-
export declare const submitFeedbackEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.submitFeedbackEpic = void 0;
|
|
4
|
-
const rxjs_1 = require("rxjs");
|
|
5
|
-
const operators_1 = require("rxjs/operators");
|
|
6
|
-
const responsePayload_1 = require("../../../responsePayload");
|
|
7
|
-
const aiCfoViewReducer_1 = require("../aiCfoViewReducer");
|
|
8
|
-
/**
|
|
9
|
-
* Thin wiring for AI CFO answer feedback (👍/👎). Dispatch `submitFeedback(...)` (defined on the
|
|
10
|
-
* aiCfoView slice) to POST to the AI CFO micro-service `/1.0/feedback` endpoint, which emits the
|
|
11
|
-
* analytics event server-side and routes negatives to the review queue. The capture-prompt UI
|
|
12
|
-
* that dispatches this lands in a fast-follow PR.
|
|
13
|
-
*/
|
|
14
|
-
const submitFeedbackEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(aiCfoViewReducer_1.submitFeedback.match),
|
|
15
|
-
// Per-message dedup: group by chatMessageId so rapid repeat clicks on the SAME answer cancel
|
|
16
|
-
// the in-flight request (switchMap) — no duplicate POST / analytics / Slack row — while
|
|
17
|
-
// feedback on different answers still runs concurrently (separate groups under mergeMap).
|
|
18
|
-
(0, operators_1.groupBy)((action) => action.payload.chatMessageId), (0, operators_1.mergeMap)((perMessage$) => perMessage$.pipe((0, operators_1.switchMap)((action) => {
|
|
19
|
-
const { chatMessageId, chatSessionId, feedbackType, answerText, model, questionText, } = action.payload;
|
|
20
|
-
const body = {
|
|
21
|
-
chat_message_id: chatMessageId,
|
|
22
|
-
chat_session_id: chatSessionId,
|
|
23
|
-
feedback_type: feedbackType,
|
|
24
|
-
...(answerText != null && { answer_text: answerText }),
|
|
25
|
-
...(model != null && { model }),
|
|
26
|
-
...(questionText != null && { question_text: questionText }),
|
|
27
|
-
};
|
|
28
|
-
return zeniAPI
|
|
29
|
-
.postAndGetJSON(`${zeniAPI.apiEndPoints.aiCfoMicroServiceBaseUrl}/1.0/feedback`, body)
|
|
30
|
-
.pipe(
|
|
31
|
-
// Status-only success check (no `data`): /1.0/feedback returns a 2xx with status and no
|
|
32
|
-
// body, so isSuccessResponse (which requires response.data) would wrongly fail it.
|
|
33
|
-
(0, operators_1.mergeMap)((response) => (0, responsePayload_1.isSuccessStatus)(response)
|
|
34
|
-
? (0, rxjs_1.of)((0, aiCfoViewReducer_1.submitFeedbackSuccess)(chatMessageId))
|
|
35
|
-
: (0, rxjs_1.of)((0, aiCfoViewReducer_1.submitFeedbackFailure)(chatMessageId, response.status))), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, aiCfoViewReducer_1.submitFeedbackFailure)(chatMessageId, (0, responsePayload_1.createZeniAPIStatus)(
|
|
36
|
-
// message (detailed) first, then the short title — per createZeniAPIStatus(message, title).
|
|
37
|
-
// JSON.stringify(Error) drops the (non-enumerable) message — extract it explicitly.
|
|
38
|
-
'Feedback REST API call errored out: ' +
|
|
39
|
-
(error instanceof Error
|
|
40
|
-
? error.message
|
|
41
|
-
: String(error)), 'Unexpected Error')))));
|
|
42
|
-
}))));
|
|
43
|
-
exports.submitFeedbackEpic = submitFeedbackEpic;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
|
-
import { openSnackbar } from '../../../../entity/snackbar/snackbarReducer';
|
|
3
|
-
import { appendSubTaskId, updateTasks } from '../../../../entity/task/taskReducer';
|
|
4
|
-
import { RootState } from '../../../../reducer';
|
|
5
|
-
import { ZeniAPI } from '../../../../zeniAPI';
|
|
6
|
-
import { updateTaskListOnNewTaskCreationSuccess } from '../../taskListView/taskListReducer';
|
|
7
|
-
import { createSubTask, createSubTaskSuccessOrFailure } from '../taskDetailReducer';
|
|
8
|
-
export type ActionType = ReturnType<typeof createSubTask> | ReturnType<typeof updateTasks> | ReturnType<typeof appendSubTaskId> | ReturnType<typeof openSnackbar> | ReturnType<typeof updateTaskListOnNewTaskCreationSuccess> | ReturnType<typeof createSubTaskSuccessOrFailure>;
|
|
9
|
-
export declare const createSubTaskEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => import("rxjs").Observable<ActionType>;
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createSubTaskEpic = void 0;
|
|
4
|
-
const rxjs_1 = require("rxjs");
|
|
5
|
-
const operators_1 = require("rxjs/operators");
|
|
6
|
-
const formatMinutesToFromHHMM_1 = require("../../../../commonStateTypes/fiscalYearHelpers/formatMinutesToFromHHMM");
|
|
7
|
-
const snackbarReducer_1 = require("../../../../entity/snackbar/snackbarReducer");
|
|
8
|
-
const taskReducer_1 = require("../../../../entity/task/taskReducer");
|
|
9
|
-
const taskSelector_1 = require("../../../../entity/task/taskSelector");
|
|
10
|
-
const responsePayload_1 = require("../../../../responsePayload");
|
|
11
|
-
const taskListReducer_1 = require("../../taskListView/taskListReducer");
|
|
12
|
-
const taskDetailReducer_1 = require("../taskDetailReducer");
|
|
13
|
-
const createSubTaskEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(taskDetailReducer_1.createSubTask.match), (0, operators_1.mergeMap)((action) => {
|
|
14
|
-
const state = state$.value;
|
|
15
|
-
const parentTask = (0, taskSelector_1.getTaskById)(state.taskState, action.payload.parentTaskId);
|
|
16
|
-
// Subtasks inherit every parent group membership, not just the first,
|
|
17
|
-
// so the subtask surfaces in all the same buckets as its parent.
|
|
18
|
-
const parentTaskGroupIds = parentTask?.taskGroupIds ?? [];
|
|
19
|
-
const parentTaskGroupId = parentTaskGroupIds[0];
|
|
20
|
-
const isTaskListFetched = state.taskListState.fetchState === 'Completed';
|
|
21
|
-
const payload = prepareSubTaskPayload(action.payload, parentTaskGroupIds);
|
|
22
|
-
return zeniAPI
|
|
23
|
-
.postAndGetJSON(`${zeniAPI.apiEndPoints.taskMicroServiceBaseUrl}/1.0/task-manager/tasks`, payload)
|
|
24
|
-
.pipe((0, operators_1.mergeMap)((response) => {
|
|
25
|
-
if ((0, responsePayload_1.isSuccessResponse)(response) &&
|
|
26
|
-
response.data != null &&
|
|
27
|
-
response.data.tasks.length > 0) {
|
|
28
|
-
const newTaskId = response.data.tasks[0].task_id;
|
|
29
|
-
const actions = [
|
|
30
|
-
(0, taskReducer_1.updateTasks)(response.data.tasks),
|
|
31
|
-
(0, taskReducer_1.appendSubTaskId)({
|
|
32
|
-
parentTaskId: action.payload.parentTaskId,
|
|
33
|
-
subTaskId: newTaskId,
|
|
34
|
-
}),
|
|
35
|
-
(0, taskDetailReducer_1.createSubTaskSuccessOrFailure)({
|
|
36
|
-
fetchState: 'Completed',
|
|
37
|
-
newTaskId,
|
|
38
|
-
}),
|
|
39
|
-
(0, snackbarReducer_1.openSnackbar)({
|
|
40
|
-
messageSection: 'create_sub_task',
|
|
41
|
-
messageText: 'success',
|
|
42
|
-
type: 'success',
|
|
43
|
-
}),
|
|
44
|
-
];
|
|
45
|
-
// The task list is keyed on parent tasks (no parent_task_id)
|
|
46
|
-
// — subtasks belong to their parent's children list, not the
|
|
47
|
-
// top-level list. Pushing a subtask into the list would
|
|
48
|
-
// surface it as an orphan row at the top of the group.
|
|
49
|
-
// Only fire the list-update for actual parent tasks.
|
|
50
|
-
const createdTask = response.data.tasks[0];
|
|
51
|
-
const isSubtask = createdTask.parent_task_id != null &&
|
|
52
|
-
createdTask.parent_task_id !== '';
|
|
53
|
-
if (!isSubtask &&
|
|
54
|
-
isTaskListFetched === true &&
|
|
55
|
-
parentTaskGroupId != null) {
|
|
56
|
-
actions.push((0, taskListReducer_1.updateTaskListOnNewTaskCreationSuccess)({
|
|
57
|
-
taskGroupId: parentTaskGroupId,
|
|
58
|
-
task: createdTask,
|
|
59
|
-
}));
|
|
60
|
-
}
|
|
61
|
-
return (0, rxjs_1.from)(actions);
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
return (0, rxjs_1.of)((0, taskDetailReducer_1.createSubTaskSuccessOrFailure)({
|
|
65
|
-
fetchState: 'Error',
|
|
66
|
-
error: response.status,
|
|
67
|
-
}), (0, snackbarReducer_1.openSnackbar)({
|
|
68
|
-
messageSection: 'create_sub_task',
|
|
69
|
-
messageText: 'failed',
|
|
70
|
-
type: 'error',
|
|
71
|
-
variables: [
|
|
72
|
-
{
|
|
73
|
-
variableName: '_api-error_',
|
|
74
|
-
variableValue: response.status.message,
|
|
75
|
-
},
|
|
76
|
-
],
|
|
77
|
-
}));
|
|
78
|
-
}
|
|
79
|
-
}), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, taskDetailReducer_1.createSubTaskSuccessOrFailure)({
|
|
80
|
-
fetchState: 'Error',
|
|
81
|
-
error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Create Sub Task REST API call errored out' +
|
|
82
|
-
JSON.stringify(error)),
|
|
83
|
-
}))));
|
|
84
|
-
}));
|
|
85
|
-
exports.createSubTaskEpic = createSubTaskEpic;
|
|
86
|
-
const prepareSubTaskPayload = (subTask, parentTaskGroupIds) => ({
|
|
87
|
-
name: subTask.name,
|
|
88
|
-
assignees: subTask.assignee,
|
|
89
|
-
description: subTask.description,
|
|
90
|
-
priority: subTask.priority,
|
|
91
|
-
status: subTask.status,
|
|
92
|
-
tags: subTask.tagIds,
|
|
93
|
-
time_spent: (0, formatMinutesToFromHHMM_1.convertHHMMStrToMinutes)(subTask.timeSpent),
|
|
94
|
-
group_assignees: subTask.groupAssignees,
|
|
95
|
-
parent_task_id: subTask.parentTaskId,
|
|
96
|
-
// Inherit every parent group, not just the first — see callsite for
|
|
97
|
-
// the two-scope rationale.
|
|
98
|
-
task_group_ids: parentTaskGroupIds,
|
|
99
|
-
due_date: subTask.dueDate?.format('YYYY-MM-DD') ?? null,
|
|
100
|
-
});
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
|
-
import { Observable } from 'rxjs';
|
|
3
|
-
import { setSubTaskIds, updateTasks } from '../../../../entity/task/taskReducer';
|
|
4
|
-
import { RootState } from '../../../../reducer';
|
|
5
|
-
import { ZeniAPI } from '../../../../zeniAPI';
|
|
6
|
-
import { fetchSubTasks, updateSubTasks, updateSubTasksFetchStatus } from '../taskDetailReducer';
|
|
7
|
-
export type ActionType = ReturnType<typeof fetchSubTasks> | ReturnType<typeof updateTasks> | ReturnType<typeof setSubTaskIds> | ReturnType<typeof updateSubTasks> | ReturnType<typeof updateSubTasksFetchStatus>;
|
|
8
|
-
export declare const fetchSubTasksEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fetchSubTasksEpic = void 0;
|
|
4
|
-
const rxjs_1 = require("rxjs");
|
|
5
|
-
const operators_1 = require("rxjs/operators");
|
|
6
|
-
const taskReducer_1 = require("../../../../entity/task/taskReducer");
|
|
7
|
-
const responsePayload_1 = require("../../../../responsePayload");
|
|
8
|
-
const taskDetailReducer_1 = require("../taskDetailReducer");
|
|
9
|
-
const fetchSubTasksEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(taskDetailReducer_1.fetchSubTasks.match),
|
|
10
|
-
// Use mergeMap, not switchMap: switchMap cancels in-flight requests for
|
|
11
|
-
// the previous parent without dispatching success or failure, leaving
|
|
12
|
-
// subTaskListFetchStatusByParentId stuck at In-Progress and blocking the
|
|
13
|
-
// detail page's combined fetchStatus via reduceAnyFetchState. Per-parent
|
|
14
|
-
// races on the same parentTaskId are handled last-write-wins downstream.
|
|
15
|
-
(0, operators_1.mergeMap)((action) => {
|
|
16
|
-
const { parentTaskId } = action.payload;
|
|
17
|
-
const query = JSON.stringify({
|
|
18
|
-
task_type: 'subtasks',
|
|
19
|
-
parent_task_id: parentTaskId,
|
|
20
|
-
});
|
|
21
|
-
return zeniAPI
|
|
22
|
-
.getJSON(`${zeniAPI.apiEndPoints.taskMicroServiceBaseUrl}/1.0/task-manager/tasks?query=${encodeURIComponent(query)}`)
|
|
23
|
-
.pipe((0, operators_1.mergeMap)((response) => {
|
|
24
|
-
if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
|
|
25
|
-
const { tasks } = response.data;
|
|
26
|
-
// Keep the parent's `subTasksIds` in sync with the fetched
|
|
27
|
-
// bucket. Without this, the parent entity record can drift
|
|
28
|
-
// out of sync with what the children fetch returned —
|
|
29
|
-
// e.g. a server-side delete won't drop from the parent
|
|
30
|
-
// record until the next list re-fetch.
|
|
31
|
-
const fetchedChildIds = tasks
|
|
32
|
-
.filter((t) => t.parent_task_id === parentTaskId)
|
|
33
|
-
.map((t) => t.task_id);
|
|
34
|
-
return (0, rxjs_1.of)((0, taskReducer_1.updateTasks)(tasks), (0, taskReducer_1.setSubTaskIds)({
|
|
35
|
-
parentTaskId,
|
|
36
|
-
subTaskIds: fetchedChildIds,
|
|
37
|
-
}), (0, taskDetailReducer_1.updateSubTasks)({
|
|
38
|
-
parentTaskId,
|
|
39
|
-
}));
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
return (0, rxjs_1.of)((0, taskDetailReducer_1.updateSubTasksFetchStatus)({
|
|
43
|
-
parentTaskId,
|
|
44
|
-
fetchState: 'Error',
|
|
45
|
-
error: response.status,
|
|
46
|
-
}));
|
|
47
|
-
}
|
|
48
|
-
}), (0, operators_1.catchError)((error) => {
|
|
49
|
-
return (0, rxjs_1.of)((0, taskDetailReducer_1.updateSubTasksFetchStatus)({
|
|
50
|
-
parentTaskId,
|
|
51
|
-
fetchState: 'Error',
|
|
52
|
-
error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Fetch Sub Tasks REST API call errored out' +
|
|
53
|
-
JSON.stringify(error)),
|
|
54
|
-
}));
|
|
55
|
-
}));
|
|
56
|
-
}));
|
|
57
|
-
exports.fetchSubTasksEpic = fetchSubTasksEpic;
|