@zeniai/client-epic-state 5.2.35 → 5.2.36
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/commonPayloadTypes/classesView/reportByClassPayloadV2.d.ts +1 -13
- package/lib/entity/sectionClassesViewV2/sectionClassesViewEpic.js +7 -10
- package/lib/entity/sectionClassesViewV2/sectionClassesViewReducer.d.ts +3 -3
- package/lib/entity/sectionProjectView/sectionProjectViewEpic.js +2 -6
- package/lib/entity/sectionProjectView/sectionProjectViewReducer.d.ts +3 -3
- package/lib/entity/sectionProjectView/sectionProjectViewReducer.js +3 -4
- package/lib/epic.js +0 -12
- package/lib/esm/entity/class/classReducer.js +1 -1
- package/lib/esm/entity/sectionClassesViewV2/sectionClassesViewEpic.js +7 -10
- package/lib/esm/entity/sectionProjectView/sectionProjectViewEpic.js +2 -6
- package/lib/esm/entity/sectionProjectView/sectionProjectViewReducer.js +4 -5
- package/lib/esm/epic.js +0 -12
- package/lib/esm/index.js +2 -2
- package/lib/esm/view/aiCfoView/aiCfoViewReducer.js +1 -266
- package/lib/esm/view/aiCfoView/aiCfoViewSelector.js +0 -50
- package/lib/esm/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewPayload.js +0 -4
- package/lib/index.d.ts +4 -4
- package/lib/index.js +40 -55
- package/lib/view/aiCfoView/aiCfoViewPayload.d.ts +0 -90
- package/lib/view/aiCfoView/aiCfoViewReducer.d.ts +123 -164
- package/lib/view/aiCfoView/aiCfoViewReducer.js +3 -268
- package/lib/view/aiCfoView/aiCfoViewSelector.d.ts +1 -13
- package/lib/view/aiCfoView/aiCfoViewSelector.js +0 -55
- package/lib/view/aiCfoView/aiCfoViewState.d.ts +0 -157
- package/lib/view/cashFlowClassesView/cashFlowClassesViewPayload.d.ts +4 -4
- package/lib/view/cashFlowProjectView/cashFlowProjectViewPayload.d.ts +4 -4
- package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewPayload.d.ts +11 -1
- package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewPayload.js +0 -4
- package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewReducer.d.ts +2 -1
- package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewSelector.d.ts +2 -1
- package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewState.d.ts +1 -15
- package/lib/view/invoicing/invoicingCustomerListView/invoicingCustomerListViewReducer.d.ts +1 -1
- package/lib/view/invoicing/invoicingCustomerListView/invoicingCustomerListViewState.d.ts +1 -1
- package/lib/view/profitAndLossProjectView/profitAndLossProjectViewPayload.d.ts +0 -12
- package/package.json +1 -1
- package/lib/esm/view/aiCfoView/epics/deleteRoutineEpic.js +0 -35
- package/lib/esm/view/aiCfoView/epics/fetchRoutineRunsEpic.js +0 -35
- package/lib/esm/view/aiCfoView/epics/fetchRoutinesEpic.js +0 -37
- package/lib/esm/view/aiCfoView/epics/runRoutineEpic.js +0 -34
- package/lib/esm/view/aiCfoView/epics/saveRoutineEpic.js +0 -65
- package/lib/esm/view/aiCfoView/epics/setRoutineEnabledEpic.js +0 -28
- package/lib/esm/view/aiCfoView/epics/toRoutine.js +0 -64
- package/lib/esm/view/aiCfoView/epics/toRoutineRun.js +0 -42
- package/lib/view/aiCfoView/epics/deleteRoutineEpic.d.ts +0 -18
- package/lib/view/aiCfoView/epics/deleteRoutineEpic.js +0 -39
- package/lib/view/aiCfoView/epics/fetchRoutineRunsEpic.d.ts +0 -13
- package/lib/view/aiCfoView/epics/fetchRoutineRunsEpic.js +0 -39
- package/lib/view/aiCfoView/epics/fetchRoutinesEpic.d.ts +0 -7
- package/lib/view/aiCfoView/epics/fetchRoutinesEpic.js +0 -41
- package/lib/view/aiCfoView/epics/runRoutineEpic.d.ts +0 -14
- package/lib/view/aiCfoView/epics/runRoutineEpic.js +0 -38
- package/lib/view/aiCfoView/epics/saveRoutineEpic.d.ts +0 -13
- package/lib/view/aiCfoView/epics/saveRoutineEpic.js +0 -69
- package/lib/view/aiCfoView/epics/setRoutineEnabledEpic.d.ts +0 -15
- package/lib/view/aiCfoView/epics/setRoutineEnabledEpic.js +0 -32
- package/lib/view/aiCfoView/epics/toRoutine.d.ts +0 -17
- package/lib/view/aiCfoView/epics/toRoutine.js +0 -69
- package/lib/view/aiCfoView/epics/toRoutineRun.d.ts +0 -12
- package/lib/view/aiCfoView/epics/toRoutineRun.js +0 -47
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fetchRoutinesEpic = 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
|
-
const toRoutine_1 = require("./toRoutine");
|
|
9
|
-
/** GET /1.0/routines — the caller's own scheduled runs. */
|
|
10
|
-
const fetchRoutinesEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(aiCfoViewReducer_1.fetchRoutines.match),
|
|
11
|
-
// switchMap: a read. A newer list request makes an older one's answer
|
|
12
|
-
// irrelevant, and letting both land means the older can arrive second and
|
|
13
|
-
// overwrite the newer — which matters here because every write refetches,
|
|
14
|
-
// so two GETs in flight is the normal case rather than the exotic one. It
|
|
15
|
-
// also widens the delete tombstone's race window.
|
|
16
|
-
(0, operators_1.switchMap)(() => zeniAPI
|
|
17
|
-
.getJSON(`${zeniAPI.apiEndPoints.aiCfoMicroServiceBaseUrl}/1.0/routines`)
|
|
18
|
-
.pipe((0, operators_1.mergeMap)((response) => {
|
|
19
|
-
// The explicit `data == null` is what narrows the type — the
|
|
20
|
-
// helper returns a plain boolean, not a type guard — and it means a
|
|
21
|
-
// malformed 2xx becomes a failure rather than a silent empty list,
|
|
22
|
-
// which would read as "you have no routines" when you do.
|
|
23
|
-
if (!(0, responsePayload_1.isSuccessResponse)(response) || response.data == null) {
|
|
24
|
-
return (0, rxjs_1.of)((0, aiCfoViewReducer_1.fetchRoutinesFailure)(response.status));
|
|
25
|
-
}
|
|
26
|
-
const { data } = response;
|
|
27
|
-
return (0, rxjs_1.of)((0, aiCfoViewReducer_1.fetchRoutinesSuccess)({
|
|
28
|
-
// Malformed rows are dropped, not defaulted into existence: a
|
|
29
|
-
// routine with no id cannot be opened, paused or deleted, so
|
|
30
|
-
// rendering one offers controls that cannot work.
|
|
31
|
-
routines: (data.routines ?? [])
|
|
32
|
-
.filter(toRoutine_1.isRoutinePayload)
|
|
33
|
-
.map(toRoutine_1.toRoutine),
|
|
34
|
-
maxRoutines: data.max_routines ?? 0,
|
|
35
|
-
// Absent reads as OFF, matching the server's fail-closed gate:
|
|
36
|
-
// an older backend that does not send it should hide the entry,
|
|
37
|
-
// not show one whose endpoints 404.
|
|
38
|
-
routinesEnabled: data.routines_enabled === true,
|
|
39
|
-
}));
|
|
40
|
-
}), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, aiCfoViewReducer_1.fetchRoutinesFailure)((0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Fetch routines REST API call failed', error instanceof Error ? { message: error.message } : undefined)))))));
|
|
41
|
-
exports.fetchRoutinesEpic = fetchRoutinesEpic;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { ActionsObservable } from 'redux-observable';
|
|
2
|
-
import { Observable } from 'rxjs';
|
|
3
|
-
import { ZeniAPI } from '../../../zeniAPI';
|
|
4
|
-
import { fetchRoutineRuns, fetchRoutines, runRoutine, runRoutineFailure, runRoutineSuccess } from '../aiCfoViewReducer';
|
|
5
|
-
export type ActionType = ReturnType<typeof runRoutine> | ReturnType<typeof runRoutineSuccess> | ReturnType<typeof runRoutineFailure> | ReturnType<typeof fetchRoutineRuns> | ReturnType<typeof fetchRoutines>;
|
|
6
|
-
/**
|
|
7
|
-
* POST /1.0/routines/{scheduleId}/run — run a routine now.
|
|
8
|
-
*
|
|
9
|
-
* The response says the run was QUEUED, not that it finished: the answer is
|
|
10
|
-
* emailed a minute or two later. So nothing is spliced in — both refetches are
|
|
11
|
-
* what show the new run, and the outcome arrives on a later fetch rather than
|
|
12
|
-
* being polled for.
|
|
13
|
-
*/
|
|
14
|
-
export declare const runRoutineEpic: (actions$: ActionsObservable<ActionType>, _state$: unknown, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.runRoutineEpic = 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
|
-
* POST /1.0/routines/{scheduleId}/run — run a routine now.
|
|
10
|
-
*
|
|
11
|
-
* The response says the run was QUEUED, not that it finished: the answer is
|
|
12
|
-
* emailed a minute or two later. So nothing is spliced in — both refetches are
|
|
13
|
-
* what show the new run, and the outcome arrives on a later fetch rather than
|
|
14
|
-
* being polled for.
|
|
15
|
-
*/
|
|
16
|
-
const runRoutineEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(aiCfoViewReducer_1.runRoutine.match),
|
|
17
|
-
// mergeMap, not exhaustMap: these target different rows, so running one
|
|
18
|
-
// routine must not swallow a request to run another. A double-click on the
|
|
19
|
-
// SAME row is already harmless — the server keys a manual run by the
|
|
20
|
-
// minute, so the second press finds the first run and reports it.
|
|
21
|
-
(0, operators_1.mergeMap)((action) => {
|
|
22
|
-
const { scheduleId } = action.payload;
|
|
23
|
-
return zeniAPI
|
|
24
|
-
.postAndGetJSON(`${zeniAPI.apiEndPoints.aiCfoMicroServiceBaseUrl}/1.0/routines/${encodeURIComponent(scheduleId)}/run`, {})
|
|
25
|
-
.pipe((0, operators_1.mergeMap)((response) =>
|
|
26
|
-
// isSuccessStatus, not isSuccessResponse: "already_running" is a
|
|
27
|
-
// legitimate 200 whose body carries no routine, and treating a
|
|
28
|
-
// second press as a failure would be a lie about what happened.
|
|
29
|
-
(0, responsePayload_1.isSuccessStatus)(response)
|
|
30
|
-
? (0, rxjs_1.of)((0, aiCfoViewReducer_1.runRoutineSuccess)(), (0, aiCfoViewReducer_1.fetchRoutines)(),
|
|
31
|
-
// The run history too, or the panel the user is looking at
|
|
32
|
-
// keeps showing the runs from before they pressed Run. The
|
|
33
|
-
// new row comes back as claimed/running — the run has been
|
|
34
|
-
// queued, not finished — which is the honest thing to show.
|
|
35
|
-
(0, aiCfoViewReducer_1.fetchRoutineRuns)({ scheduleId }))
|
|
36
|
-
: (0, rxjs_1.of)((0, aiCfoViewReducer_1.runRoutineFailure)(response.status))), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, aiCfoViewReducer_1.runRoutineFailure)((0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Run routine REST API call failed', error instanceof Error ? { message: error.message } : undefined)))));
|
|
37
|
-
}));
|
|
38
|
-
exports.runRoutineEpic = runRoutineEpic;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { ActionsObservable } from 'redux-observable';
|
|
2
|
-
import { Observable } from 'rxjs';
|
|
3
|
-
import { ZeniAPI } from '../../../zeniAPI';
|
|
4
|
-
import { fetchRoutines, saveRoutine, saveRoutineFailure, saveRoutineSuccess } from '../aiCfoViewReducer';
|
|
5
|
-
export type ActionType = ReturnType<typeof saveRoutine> | ReturnType<typeof saveRoutineSuccess> | ReturnType<typeof saveRoutineFailure> | ReturnType<typeof fetchRoutines>;
|
|
6
|
-
/**
|
|
7
|
-
* POST /1.0/routines (create) or PUT /1.0/routines/{scheduleId} (update).
|
|
8
|
-
*
|
|
9
|
-
* One epic for both: to a user they are the same act, and the server answers
|
|
10
|
-
* both with the routine. Splitting them would duplicate the body mapping and
|
|
11
|
-
* the error handling for a difference the form does not have.
|
|
12
|
-
*/
|
|
13
|
-
export declare const saveRoutineEpic: (actions$: ActionsObservable<ActionType>, _state$: unknown, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.saveRoutineEpic = 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
|
-
* POST /1.0/routines (create) or PUT /1.0/routines/{scheduleId} (update).
|
|
10
|
-
*
|
|
11
|
-
* One epic for both: to a user they are the same act, and the server answers
|
|
12
|
-
* both with the routine. Splitting them would duplicate the body mapping and
|
|
13
|
-
* the error handling for a difference the form does not have.
|
|
14
|
-
*/
|
|
15
|
-
const saveRoutineEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(aiCfoViewReducer_1.saveRoutine.match),
|
|
16
|
-
// exhaustMap, and neither of the obvious two.
|
|
17
|
-
//
|
|
18
|
-
// switchMap is wrong: it cancels the client's subscription, not the request
|
|
19
|
-
// that already left the browser. The routine is still created; the client
|
|
20
|
-
// just stops listening and never tells the user.
|
|
21
|
-
//
|
|
22
|
-
// mergeMap is wrong for the same reason in reverse: a double-clicked Save
|
|
23
|
-
// sends two POSTs, and the user gets two routines that both email them the
|
|
24
|
-
// company's financials on the same schedule.
|
|
25
|
-
//
|
|
26
|
-
// exhaustMap ignores further saves while one is in flight, which is exactly
|
|
27
|
-
// what a submit button should do.
|
|
28
|
-
(0, operators_1.exhaustMap)((action) => {
|
|
29
|
-
const { draft, scheduleId } = action.payload;
|
|
30
|
-
const base = `${zeniAPI.apiEndPoints.aiCfoMicroServiceBaseUrl}/1.0/routines`;
|
|
31
|
-
const isUpdate = scheduleId != null && scheduleId !== '';
|
|
32
|
-
const body = {
|
|
33
|
-
name: draft.name,
|
|
34
|
-
recurrence: draft.recurrence,
|
|
35
|
-
hour: draft.hour,
|
|
36
|
-
minute: draft.minute ?? 0,
|
|
37
|
-
tz_name: draft.tzName,
|
|
38
|
-
// Spread rather than sent as null. `weekday` and `day_of_month` are
|
|
39
|
-
// meaningful only for their own recurrence, and the server validates
|
|
40
|
-
// that pairing — sending a stale weekday alongside a monthly cadence is
|
|
41
|
-
// a 400 rather than a field politely ignored.
|
|
42
|
-
...(draft.recurrence === 'weekly' &&
|
|
43
|
-
draft.weekday != null && { weekday: draft.weekday }),
|
|
44
|
-
...(draft.recurrence === 'monthly' &&
|
|
45
|
-
draft.dayOfMonth != null && { day_of_month: draft.dayOfMonth }),
|
|
46
|
-
...(draft.enabled != null && { enabled: draft.enabled }),
|
|
47
|
-
// `macro_id` is create-only: re-sending it on an update would let an
|
|
48
|
-
// edit silently repoint a schedule at a different skill.
|
|
49
|
-
...(!isUpdate && draft.macroId != null && { macro_id: draft.macroId }),
|
|
50
|
-
// `prompt` is allowed on both. On update the server accepts it only for
|
|
51
|
-
// a one-off, where it saves a new version of the routine's own
|
|
52
|
-
// instructions — that is editing what this routine says, not repointing
|
|
53
|
-
// it at someone else's skill.
|
|
54
|
-
...(draft.prompt != null && { prompt: draft.prompt }),
|
|
55
|
-
};
|
|
56
|
-
const request$ = isUpdate
|
|
57
|
-
? zeniAPI.putAndGetJSON(`${base}/${encodeURIComponent(scheduleId)}`, body)
|
|
58
|
-
: zeniAPI.postAndGetJSON(base, body);
|
|
59
|
-
return request$.pipe((0, operators_1.mergeMap)((response) => {
|
|
60
|
-
if (!(0, responsePayload_1.isSuccessResponse)(response)) {
|
|
61
|
-
return (0, rxjs_1.of)((0, aiCfoViewReducer_1.saveRoutineFailure)(response.status));
|
|
62
|
-
}
|
|
63
|
-
// Refetch rather than splice the response in: a create changes the
|
|
64
|
-
// list's ordering, and the server recomputes `next_run_at` on every
|
|
65
|
-
// write, so a local insert would show a time the next load moves.
|
|
66
|
-
return (0, rxjs_1.of)((0, aiCfoViewReducer_1.saveRoutineSuccess)(), (0, aiCfoViewReducer_1.fetchRoutines)());
|
|
67
|
-
}), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, aiCfoViewReducer_1.saveRoutineFailure)((0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Save routine REST API call failed', error instanceof Error ? { message: error.message } : undefined)))));
|
|
68
|
-
}));
|
|
69
|
-
exports.saveRoutineEpic = saveRoutineEpic;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { ActionsObservable } from 'redux-observable';
|
|
2
|
-
import { Observable } from 'rxjs';
|
|
3
|
-
import { ZeniAPI } from '../../../zeniAPI';
|
|
4
|
-
import { fetchRoutines, saveRoutineFailure, saveRoutineSuccess, setRoutineEnabled } from '../aiCfoViewReducer';
|
|
5
|
-
export type ActionType = ReturnType<typeof setRoutineEnabled> | ReturnType<typeof saveRoutineSuccess> | ReturnType<typeof saveRoutineFailure> | ReturnType<typeof fetchRoutines>;
|
|
6
|
-
/**
|
|
7
|
-
* PUT /1.0/routines/{scheduleId} with nothing but `enabled`.
|
|
8
|
-
*
|
|
9
|
-
* Separate from `saveRoutineEpic` because pausing is not editing. A routine
|
|
10
|
-
* whose cadence this client version does not recognise has `recurrence: null`
|
|
11
|
-
* and cannot produce a `RoutineDraft` — and that is precisely the routine
|
|
12
|
-
* someone most needs to be able to stop. Sending only `enabled` also means a
|
|
13
|
-
* pause can never rewrite a schedule as a side effect.
|
|
14
|
-
*/
|
|
15
|
-
export declare const setRoutineEnabledEpic: (actions$: ActionsObservable<ActionType>, _state$: unknown, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.setRoutineEnabledEpic = 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
|
-
* PUT /1.0/routines/{scheduleId} with nothing but `enabled`.
|
|
10
|
-
*
|
|
11
|
-
* Separate from `saveRoutineEpic` because pausing is not editing. A routine
|
|
12
|
-
* whose cadence this client version does not recognise has `recurrence: null`
|
|
13
|
-
* and cannot produce a `RoutineDraft` — and that is precisely the routine
|
|
14
|
-
* someone most needs to be able to stop. Sending only `enabled` also means a
|
|
15
|
-
* pause can never rewrite a schedule as a side effect.
|
|
16
|
-
*/
|
|
17
|
-
const setRoutineEnabledEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(aiCfoViewReducer_1.setRoutineEnabled.match),
|
|
18
|
-
// mergeMap: pausing one routine must not cancel pausing another, and these
|
|
19
|
-
// target different rows so they cannot collide the way two saves of one
|
|
20
|
-
// form would.
|
|
21
|
-
(0, operators_1.mergeMap)((action) => {
|
|
22
|
-
const { enabled, scheduleId } = action.payload;
|
|
23
|
-
return zeniAPI
|
|
24
|
-
.putAndGetJSON(`${zeniAPI.apiEndPoints.aiCfoMicroServiceBaseUrl}/1.0/routines/${encodeURIComponent(scheduleId)}`, { enabled })
|
|
25
|
-
.pipe((0, operators_1.mergeMap)((response) => (0, responsePayload_1.isSuccessResponse)(response)
|
|
26
|
-
? (0, rxjs_1.of)((0, aiCfoViewReducer_1.saveRoutineSuccess)(), (0, aiCfoViewReducer_1.fetchRoutines)())
|
|
27
|
-
: // Refetch on failure too: the switch was flipped optimistically,
|
|
28
|
-
// and leaving it showing "paused" for a routine that is still
|
|
29
|
-
// running would be the one lie this list must not tell.
|
|
30
|
-
(0, rxjs_1.of)((0, aiCfoViewReducer_1.saveRoutineFailure)(response.status), (0, aiCfoViewReducer_1.fetchRoutines)())), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, aiCfoViewReducer_1.saveRoutineFailure)((0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Set routine enabled REST API call failed', error instanceof Error ? { message: error.message } : undefined)), (0, aiCfoViewReducer_1.fetchRoutines)())));
|
|
31
|
-
}));
|
|
32
|
-
exports.setRoutineEnabledEpic = setRoutineEnabledEpic;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { RoutinePayload } from '../aiCfoViewPayload';
|
|
2
|
-
import { Routine } from '../aiCfoViewState';
|
|
3
|
-
/**
|
|
4
|
-
* A routine is usable if it has an identity. That is the whole bar.
|
|
5
|
-
*
|
|
6
|
-
* `schedule_id` and `name` are what every consumer dereferences, so those are
|
|
7
|
-
* what this establishes.
|
|
8
|
-
*
|
|
9
|
-
* Deliberately NOT also requiring `macro_id`. A routine whose skill was deleted
|
|
10
|
-
* can come back without one — and it is still an active schedule emailing the
|
|
11
|
-
* user's financials. Dropping it here would make it invisible in the UI while
|
|
12
|
-
* it kept running, with no way for anyone to turn it off. Showing a broken row
|
|
13
|
-
* that can be paused or deleted is strictly better than hiding a live one.
|
|
14
|
-
*/
|
|
15
|
-
export declare const isRoutinePayload: (value: unknown) => value is RoutinePayload;
|
|
16
|
-
/** Map one routine off the wire. Every default here is a deliberate reading. */
|
|
17
|
-
export declare const toRoutine: (payload: RoutinePayload) => Routine;
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toRoutine = exports.isRoutinePayload = void 0;
|
|
4
|
-
const RECURRENCES = ['daily', 'weekly', 'monthly'];
|
|
5
|
-
const STATUSES = ['succeeded', 'failed', 'timeout'];
|
|
6
|
-
/**
|
|
7
|
-
* A routine is usable if it has an identity. That is the whole bar.
|
|
8
|
-
*
|
|
9
|
-
* `schedule_id` and `name` are what every consumer dereferences, so those are
|
|
10
|
-
* what this establishes.
|
|
11
|
-
*
|
|
12
|
-
* Deliberately NOT also requiring `macro_id`. A routine whose skill was deleted
|
|
13
|
-
* can come back without one — and it is still an active schedule emailing the
|
|
14
|
-
* user's financials. Dropping it here would make it invisible in the UI while
|
|
15
|
-
* it kept running, with no way for anyone to turn it off. Showing a broken row
|
|
16
|
-
* that can be paused or deleted is strictly better than hiding a live one.
|
|
17
|
-
*/
|
|
18
|
-
const isRoutinePayload = (value) => {
|
|
19
|
-
const candidate = value;
|
|
20
|
-
return (typeof candidate?.schedule_id === 'string' &&
|
|
21
|
-
candidate.schedule_id !== '' &&
|
|
22
|
-
typeof candidate.name === 'string');
|
|
23
|
-
};
|
|
24
|
-
exports.isRoutinePayload = isRoutinePayload;
|
|
25
|
-
/**
|
|
26
|
-
* Narrow a server string to a known recurrence, or null.
|
|
27
|
-
*
|
|
28
|
-
* Null, NOT a fallback to 'daily'. A read-side default becomes a write-side
|
|
29
|
-
* value the moment the user opens that routine and saves it — so guessing here
|
|
30
|
-
* would quietly convert a cadence this client does not understand into a daily
|
|
31
|
-
* one, and the owner would find out from the volume of email. Null says "this
|
|
32
|
-
* client does not know", and the UI shows the row so it can still be paused or
|
|
33
|
-
* deleted while refusing to edit its schedule.
|
|
34
|
-
*/
|
|
35
|
-
const toRecurrence = (value) => RECURRENCES.includes(value)
|
|
36
|
-
? value
|
|
37
|
-
: null;
|
|
38
|
-
const toStatus = (value) => STATUSES.includes(value) ? value : null;
|
|
39
|
-
/** Map one routine off the wire. Every default here is a deliberate reading. */
|
|
40
|
-
const toRoutine = (payload) => ({
|
|
41
|
-
unreadRuns: payload.unread_runs ?? 0,
|
|
42
|
-
consecutiveFailures: payload.consecutive_failures ?? 0,
|
|
43
|
-
dayOfMonth: payload.day_of_month ?? null,
|
|
44
|
-
// Absent reads as enabled: a routine the server returned without the flag is
|
|
45
|
-
// one it intends to run, and defaulting to false would show every row paused.
|
|
46
|
-
enabled: payload.enabled !== false,
|
|
47
|
-
hour: payload.hour ?? 0,
|
|
48
|
-
isAdHoc: payload.is_ad_hoc === true,
|
|
49
|
-
lastRunAt: payload.last_run_at ?? null,
|
|
50
|
-
lastStatus: toStatus(payload.last_status),
|
|
51
|
-
// '' is the sanctioned "unset ID" (CLAUDE.md), not a papered-over absence:
|
|
52
|
-
// the row still renders, and the UI reads this to show it as broken rather
|
|
53
|
-
// than offering to open a skill that is not there.
|
|
54
|
-
macroId: payload.macro_id ?? '',
|
|
55
|
-
minute: payload.minute ?? 0,
|
|
56
|
-
name: payload.name,
|
|
57
|
-
nextRunAt: payload.next_run_at ?? null,
|
|
58
|
-
pinnedVersion: payload.pinned_version ?? null,
|
|
59
|
-
recurrence: toRecurrence(payload.recurrence),
|
|
60
|
-
scheduleId: payload.schedule_id,
|
|
61
|
-
sessionId: payload.session_id ?? null,
|
|
62
|
-
// Null, not a guessed 'UTC'. Same trap as `recurrence`: a read-side default
|
|
63
|
-
// is written straight back on the next save, silently moving the routine's
|
|
64
|
-
// delivery by however many hours the real zone differed by. The server always
|
|
65
|
-
// sends this, so null means something is wrong and the UI should say so.
|
|
66
|
-
tzName: payload.tz_name ?? null,
|
|
67
|
-
weekday: payload.weekday ?? null,
|
|
68
|
-
});
|
|
69
|
-
exports.toRoutine = toRoutine;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { RoutineRunPayload } from '../aiCfoViewPayload';
|
|
2
|
-
import { RoutineRun } from '../aiCfoViewState';
|
|
3
|
-
/**
|
|
4
|
-
* A run is usable if it has an identity — the same bar `isRoutinePayload` sets.
|
|
5
|
-
*
|
|
6
|
-
* Nothing else is required. A run that is still in flight has no `finished_at`,
|
|
7
|
-
* a claimed one has no `started_at`, and a failed one may have neither an error
|
|
8
|
-
* nor an answer to link to. Requiring any of those would drop exactly the rows
|
|
9
|
-
* the history exists to show.
|
|
10
|
-
*/
|
|
11
|
-
export declare const isRoutineRunPayload: (value: unknown) => value is RoutineRunPayload;
|
|
12
|
-
export declare const toRoutineRun: (payload: RoutineRunPayload) => RoutineRun;
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toRoutineRun = exports.isRoutineRunPayload = void 0;
|
|
4
|
-
const STATUSES = [
|
|
5
|
-
'claimed',
|
|
6
|
-
'running',
|
|
7
|
-
'succeeded',
|
|
8
|
-
'failed',
|
|
9
|
-
'timeout',
|
|
10
|
-
];
|
|
11
|
-
/**
|
|
12
|
-
* A run is usable if it has an identity — the same bar `isRoutinePayload` sets.
|
|
13
|
-
*
|
|
14
|
-
* Nothing else is required. A run that is still in flight has no `finished_at`,
|
|
15
|
-
* a claimed one has no `started_at`, and a failed one may have neither an error
|
|
16
|
-
* nor an answer to link to. Requiring any of those would drop exactly the rows
|
|
17
|
-
* the history exists to show.
|
|
18
|
-
*/
|
|
19
|
-
const isRoutineRunPayload = (value) => {
|
|
20
|
-
const candidate = value;
|
|
21
|
-
return typeof candidate?.run_id === 'string' && candidate.run_id !== '';
|
|
22
|
-
};
|
|
23
|
-
exports.isRoutineRunPayload = isRoutineRunPayload;
|
|
24
|
-
/**
|
|
25
|
-
* Narrow a server status to one this client knows, or null.
|
|
26
|
-
*
|
|
27
|
-
* Null rather than a fallback, for the same reason `toRecurrence` returns null:
|
|
28
|
-
* a guess here would badge an unknown state as something specific, and on a run
|
|
29
|
-
* history the difference between "failed" and "we don't know" is the whole
|
|
30
|
-
* message. The UI shows an unknown status as neither succeeded nor failed.
|
|
31
|
-
*/
|
|
32
|
-
const toStatus = (value) => STATUSES.find((status) => status === value) ?? null;
|
|
33
|
-
/** Empty strings become null: the server sends '' for an absent deep link. */
|
|
34
|
-
const toId = (value) => value != null && value !== '' ? value : null;
|
|
35
|
-
const toRoutineRun = (payload) => ({
|
|
36
|
-
runId: payload.run_id,
|
|
37
|
-
attempt: payload.attempt ?? 1,
|
|
38
|
-
isManual: payload.is_manual === true,
|
|
39
|
-
error: toId(payload.error),
|
|
40
|
-
finishedAt: toId(payload.finished_at),
|
|
41
|
-
questionAnswerId: toId(payload.question_answer_id),
|
|
42
|
-
sessionId: toId(payload.session_id),
|
|
43
|
-
scheduledFor: toId(payload.scheduled_for),
|
|
44
|
-
startedAt: toId(payload.started_at),
|
|
45
|
-
status: toStatus(payload.status),
|
|
46
|
-
});
|
|
47
|
-
exports.toRoutineRun = toRoutineRun;
|