@zeniai/client-epic-state 5.2.49-betaAK0 → 5.2.50-beta0ND

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 (46) hide show
  1. package/lib/entity/notificationRegistry/notificationRegistryReducer.d.ts +2 -1
  2. package/lib/entity/notificationRegistry/notificationRegistryReducer.js +20 -9
  3. package/lib/entity/notificationRegistry/notificationRegistrySelector.d.ts +2 -1
  4. package/lib/entity/notificationRegistry/notificationRegistrySelector.js +7 -1
  5. package/lib/entity/notificationRegistry/notificationRegistryState.d.ts +5 -0
  6. package/lib/entity/notificationRegistry/notificationRegistryState.js +7 -1
  7. package/lib/entity/sectionProjectView/sectionProjectViewReducer.js +3 -1
  8. package/lib/epic.js +4 -4
  9. package/lib/esm/entity/notificationRegistry/notificationRegistryReducer.js +20 -9
  10. package/lib/esm/entity/notificationRegistry/notificationRegistrySelector.js +5 -0
  11. package/lib/esm/entity/notificationRegistry/notificationRegistryState.js +5 -0
  12. package/lib/esm/entity/sectionProjectView/sectionProjectViewReducer.js +3 -1
  13. package/lib/esm/epic.js +4 -4
  14. package/lib/esm/index.js +4 -4
  15. package/lib/esm/view/aiCfoView/aiCfoViewReducer.js +4 -2
  16. package/lib/esm/view/aiCfoView/epics/fetchRoutineRunsEpic.js +3 -1
  17. package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/seedInvoicingCatalogItemFormDraftEpic.js +14 -4
  18. package/lib/esm/view/invoicing/editInvoicingCouponDetailView/seedInvoicingCouponFormDraftEpic.js +13 -3
  19. package/lib/esm/view/invoicing/editInvoicingCustomerDetailView/seedInvoicingCustomerFormDraftEpic.js +25 -6
  20. package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/seedInvoicingSubscriptionFormDraftEpic.js +13 -1
  21. package/lib/esm/view/invoicing/invoicingFormDraft.js +15 -6
  22. package/lib/esm/view/notificationPreferencesView/epics/saveNotificationPreferencesEpic.js +20 -7
  23. package/lib/esm/view/notificationPreferencesView/notificationPreferencesViewReducer.js +43 -17
  24. package/lib/esm/view/notificationPreferencesView/notificationPreferencesViewSelector.js +24 -4
  25. package/lib/esm/view/settingsView/epic/fetchNotificationSettingsEpic.js +12 -2
  26. package/lib/index.d.ts +4 -4
  27. package/lib/index.js +21 -14
  28. package/lib/view/aiCfoView/aiCfoViewReducer.js +4 -2
  29. package/lib/view/aiCfoView/aiCfoViewSelector.d.ts +1 -1
  30. package/lib/view/aiCfoView/epics/fetchRoutineRunsEpic.js +3 -1
  31. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/seedInvoicingCatalogItemFormDraftEpic.js +14 -4
  32. package/lib/view/invoicing/editInvoicingCouponDetailView/seedInvoicingCouponFormDraftEpic.js +13 -3
  33. package/lib/view/invoicing/editInvoicingCustomerDetailView/seedInvoicingCustomerFormDraftEpic.d.ts +10 -6
  34. package/lib/view/invoicing/editInvoicingCustomerDetailView/seedInvoicingCustomerFormDraftEpic.js +24 -5
  35. package/lib/view/invoicing/editInvoicingSubscriptionDetailView/seedInvoicingSubscriptionFormDraftEpic.js +13 -1
  36. package/lib/view/invoicing/invoicingFormDraft.d.ts +8 -4
  37. package/lib/view/invoicing/invoicingFormDraft.js +15 -6
  38. package/lib/view/notificationPreferencesView/epics/saveNotificationPreferencesEpic.js +19 -6
  39. package/lib/view/notificationPreferencesView/notificationPreferencesViewReducer.d.ts +8 -5
  40. package/lib/view/notificationPreferencesView/notificationPreferencesViewReducer.js +43 -17
  41. package/lib/view/notificationPreferencesView/notificationPreferencesViewSelector.d.ts +4 -0
  42. package/lib/view/notificationPreferencesView/notificationPreferencesViewSelector.js +30 -5
  43. package/lib/view/notificationPreferencesView/notificationPreferencesViewState.d.ts +4 -3
  44. package/lib/view/settingsView/epic/fetchNotificationSettingsEpic.js +12 -2
  45. package/lib/view/settingsView/settingsViewPayload.d.ts +2 -0
  46. package/package.json +1 -1
@@ -1,9 +1,10 @@
1
1
  import { NotificationRegistryPayload } from './notificationRegistryPayload';
2
- import { NotificationRegistryState } from './notificationRegistryState';
2
+ import { NotificationDomain, NotificationRegistryState } from './notificationRegistryState';
3
3
  export declare const initialState: NotificationRegistryState;
4
4
  export interface UpdateNotificationRegistryPayload {
5
5
  registry: NotificationRegistryPayload | undefined;
6
6
  registryEpochAtDispatch: number;
7
+ registriesByDomain?: Partial<Record<NotificationDomain, NotificationRegistryPayload | undefined>>;
7
8
  }
8
9
  export declare const updateNotificationRegistry: import("@reduxjs/toolkit").ActionCreatorWithPayload<UpdateNotificationRegistryPayload, "notificationRegistry/updateNotificationRegistry">;
9
10
  declare const _default: import("redux").Reducer<NotificationRegistryState>;
@@ -4,6 +4,7 @@ exports.updateNotificationRegistry = exports.initialState = void 0;
4
4
  const toolkit_1 = require("@reduxjs/toolkit");
5
5
  const rootActions_1 = require("../../rootActions");
6
6
  const notificationRegistryPayload_1 = require("./notificationRegistryPayload");
7
+ const notificationRegistryState_1 = require("./notificationRegistryState");
7
8
  exports.initialState = { registryEpoch: 0 };
8
9
  const notificationRegistry = (0, toolkit_1.createSlice)({
9
10
  name: 'notificationRegistry',
@@ -22,16 +23,24 @@ const notificationRegistry = (0, toolkit_1.createSlice)({
22
23
  // `task_checklist_registry` CLEARS so tenant B doesn't inherit A's
23
24
  // Task Checklist section. Guarded by the epoch check above so a stale
24
25
  // absent-response can't wipe a fresh registry.
25
- if (action.payload.registry == null) {
26
- draft.registry = undefined;
27
- return;
26
+ const { registriesByDomain } = action.payload;
27
+ // Absent `registriesByDomain` means a pre-domain caller: treat `registry`
28
+ // as the task_checklist snapshot so their behaviour is unchanged.
29
+ const snapshots = registriesByDomain ?? { task_checklist: action.payload.registry };
30
+ draft.registryByDomain = {};
31
+ for (const domain of notificationRegistryState_1.NOTIFICATION_DOMAINS) {
32
+ const payload = snapshots[domain];
33
+ // Full-replace per domain, and an absent snapshot CLEARS that domain so
34
+ // tenant B never inherits A's section. The gates are independent
35
+ // server-side, so one domain clearing must not touch the other.
36
+ if (payload != null) {
37
+ draft.registryByDomain[domain] =
38
+ (0, notificationRegistryPayload_1.mapNotificationRegistryPayloadToRegistry)(payload);
39
+ }
28
40
  }
29
- // Full-replace contract: the registry payload is atomic — every fetch
30
- // returns the complete group/event tree. If the backend ever ships a
31
- // partial registry response, this write MUST switch to a merge (mirror
32
- // the preferences slice's `mergePreferences`). Do not assume the
33
- // current payload is partial without also updating this reducer.
34
- draft.registry = (0, notificationRegistryPayload_1.mapNotificationRegistryPayloadToRegistry)(action.payload.registry);
41
+ // Mirrored for consumers that predate the domain-keyed map.
42
+ draft.registry = draft.registryByDomain.task_checklist;
43
+ return;
35
44
  },
36
45
  },
37
46
  extraReducers: (builder) => {
@@ -44,6 +53,8 @@ const notificationRegistry = (0, toolkit_1.createSlice)({
44
53
  // — Cursor Bugbot 67d6918e. Returning `initialState` verbatim would
45
54
  // rewind the counter and let a stale in-flight GET restore A's
46
55
  // registry over B's.
56
+ // Drops `registry` and `registryByDomain` together: a tenant switch must
57
+ // not leave one domain's section behind.
47
58
  return { registryEpoch: draft.registryEpoch + 1 };
48
59
  });
49
60
  },
@@ -1,2 +1,3 @@
1
- import { NotificationRegistry, NotificationRegistryState } from './notificationRegistryState';
1
+ import { NotificationDomain, NotificationRegistry, NotificationRegistryState } from './notificationRegistryState';
2
2
  export declare const getNotificationRegistry: (slice: NotificationRegistryState) => NotificationRegistry | undefined;
3
+ export declare const getNotificationRegistryForDomain: (slice: NotificationRegistryState, domain: NotificationDomain) => NotificationRegistry | undefined;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getNotificationRegistry = void 0;
3
+ exports.getNotificationRegistryForDomain = exports.getNotificationRegistry = void 0;
4
4
  // Current behavior: a null / undefined registry means the whole notification
5
5
  // section is hidden by consumers. This conflates two distinct states —
6
6
  // "user has no saved preferences yet" vs "the Task Checklist feature gate is
@@ -8,3 +8,9 @@ exports.getNotificationRegistry = void 0;
8
8
  // them (e.g. an explicit `gate_off` signal from the server) is a follow-up.
9
9
  const getNotificationRegistry = (slice) => slice.registry;
10
10
  exports.getNotificationRegistry = getNotificationRegistry;
11
+ // `undefined` conflates gate-off with no-preferences-yet; consumers hide the
12
+ // section either way. Falls back to `registry` for task_checklist so state built
13
+ // in the pre-domain shape (consumer mocks, older callers) still resolves.
14
+ const getNotificationRegistryForDomain = (slice, domain) => slice.registryByDomain?.[domain] ??
15
+ (domain === 'task_checklist' ? slice.registry : undefined);
16
+ exports.getNotificationRegistryForDomain = getNotificationRegistryForDomain;
@@ -1,3 +1,7 @@
1
+ export declare const NOTIFICATION_DOMAINS: readonly ["task_checklist", "commenting"];
2
+ export type NotificationDomain = (typeof NOTIFICATION_DOMAINS)[number];
3
+ export declare const DEFAULT_NOTIFICATION_DOMAIN: NotificationDomain;
4
+ export declare const toNotificationDomain: (raw: string) => NotificationDomain;
1
5
  export declare const NOTIFICATION_CHANNELS: readonly ["email", "slack", "in_app"];
2
6
  export type NotificationChannel = (typeof NOTIFICATION_CHANNELS)[number];
3
7
  export declare const toNotificationChannel: (raw: string) => NotificationChannel;
@@ -30,4 +34,5 @@ export interface NotificationRegistry {
30
34
  export interface NotificationRegistryState {
31
35
  registryEpoch: number;
32
36
  registry?: NotificationRegistry;
37
+ registryByDomain?: Partial<Record<NotificationDomain, NotificationRegistry>>;
33
38
  }
@@ -1,7 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toNotificationFrequency = exports.NOTIFICATION_FREQUENCIES = exports.toNotificationChannel = exports.NOTIFICATION_CHANNELS = void 0;
3
+ exports.toNotificationFrequency = exports.NOTIFICATION_FREQUENCIES = exports.toNotificationChannel = exports.NOTIFICATION_CHANNELS = exports.toNotificationDomain = exports.DEFAULT_NOTIFICATION_DOMAIN = exports.NOTIFICATION_DOMAINS = void 0;
4
4
  const stringToUnion_1 = require("../../commonStateTypes/stringToUnion");
5
+ // Wire vocabulary owned by the notifications service, not by this slice.
6
+ exports.NOTIFICATION_DOMAINS = ['task_checklist', 'commenting'];
7
+ // Callers that predate the domain split mean Task Checklist.
8
+ exports.DEFAULT_NOTIFICATION_DOMAIN = 'task_checklist';
9
+ const toNotificationDomain = (raw) => (0, stringToUnion_1.stringToUnion)(raw, exports.NOTIFICATION_DOMAINS);
10
+ exports.toNotificationDomain = toNotificationDomain;
5
11
  exports.NOTIFICATION_CHANNELS = ['email', 'slack', 'in_app'];
6
12
  const toNotificationChannel = (raw) => (0, stringToUnion_1.stringToUnion)(raw, exports.NOTIFICATION_CHANNELS);
7
13
  exports.toNotificationChannel = toNotificationChannel;
@@ -35,7 +35,9 @@ const sectionProjectView = (0, toolkit_1.createSlice)({
35
35
  Object.keys(sectionPayload.projects).forEach((projectId) => {
36
36
  const projectPayload = sectionPayload.projects[projectId];
37
37
  // A calculated section is grouped by project with no accounts under it.
38
- const projectAccounts = 'accounts' in projectPayload ? projectPayload.accounts : undefined;
38
+ const projectAccounts = 'accounts' in projectPayload
39
+ ? projectPayload.accounts
40
+ : undefined;
39
41
  const nestedAccountIds = projectAccounts != null
40
42
  ? (0, getNestedAccountIDHierarchyForSection_1.getNestedAccountIDHierarchyForAccounts)(Object.keys(projectAccounts), accountsMetadata)
41
43
  : [];
package/lib/epic.js CHANGED
@@ -53,21 +53,21 @@ const acceptMasterTOSEpic_1 = require("./view/aiCfoView/epics/acceptMasterTOSEpi
53
53
  const createSessionAndSubmitEpic_1 = require("./view/aiCfoView/epics/createSessionAndSubmitEpic");
54
54
  const createSessionEpic_1 = require("./view/aiCfoView/epics/createSessionEpic");
55
55
  const deleteChatSessionEpic_1 = require("./view/aiCfoView/epics/deleteChatSessionEpic");
56
+ const deleteRoutineEpic_1 = require("./view/aiCfoView/epics/deleteRoutineEpic");
56
57
  const deleteSkillEpic_1 = require("./view/aiCfoView/epics/deleteSkillEpic");
57
58
  const fetchChatHistoryEpic_1 = require("./view/aiCfoView/epics/fetchChatHistoryEpic");
58
59
  const fetchChatSessionsForUserEpic_1 = require("./view/aiCfoView/epics/fetchChatSessionsForUserEpic");
60
+ const fetchRoutineRunsEpic_1 = require("./view/aiCfoView/epics/fetchRoutineRunsEpic");
61
+ const fetchRoutinesEpic_1 = require("./view/aiCfoView/epics/fetchRoutinesEpic");
59
62
  const fetchSkillDetailEpic_1 = require("./view/aiCfoView/epics/fetchSkillDetailEpic");
60
63
  const fetchSkillVersionBodyEpic_1 = require("./view/aiCfoView/epics/fetchSkillVersionBodyEpic");
61
64
  const fetchSkillVersionsEpic_1 = require("./view/aiCfoView/epics/fetchSkillVersionsEpic");
62
65
  const fetchSkillsEpic_1 = require("./view/aiCfoView/epics/fetchSkillsEpic");
63
66
  const fetchSuggestedQuestionsEpic_1 = require("./view/aiCfoView/epics/fetchSuggestedQuestionsEpic");
64
- const deleteRoutineEpic_1 = require("./view/aiCfoView/epics/deleteRoutineEpic");
65
- const fetchRoutineRunsEpic_1 = require("./view/aiCfoView/epics/fetchRoutineRunsEpic");
66
- const fetchRoutinesEpic_1 = require("./view/aiCfoView/epics/fetchRoutinesEpic");
67
67
  const runRoutineEpic_1 = require("./view/aiCfoView/epics/runRoutineEpic");
68
68
  const saveRoutineEpic_1 = require("./view/aiCfoView/epics/saveRoutineEpic");
69
- const setRoutineEnabledEpic_1 = require("./view/aiCfoView/epics/setRoutineEnabledEpic");
70
69
  const saveSkillEpic_1 = require("./view/aiCfoView/epics/saveSkillEpic");
70
+ const setRoutineEnabledEpic_1 = require("./view/aiCfoView/epics/setRoutineEnabledEpic");
71
71
  const setSkillVisibilityEpic_1 = require("./view/aiCfoView/epics/setSkillVisibilityEpic");
72
72
  const stopSubmitEpic_1 = require("./view/aiCfoView/epics/stopSubmitEpic");
73
73
  const stopSubmitQuestionEpic_1 = require("./view/aiCfoView/epics/stopSubmitQuestionEpic");
@@ -1,6 +1,7 @@
1
1
  import { createSlice } from '@reduxjs/toolkit';
2
2
  import { clearAll } from '../../rootActions';
3
3
  import { mapNotificationRegistryPayloadToRegistry, } from './notificationRegistryPayload';
4
+ import { NOTIFICATION_DOMAINS, } from './notificationRegistryState';
4
5
  export const initialState = { registryEpoch: 0 };
5
6
  const notificationRegistry = createSlice({
6
7
  name: 'notificationRegistry',
@@ -19,16 +20,24 @@ const notificationRegistry = createSlice({
19
20
  // `task_checklist_registry` CLEARS so tenant B doesn't inherit A's
20
21
  // Task Checklist section. Guarded by the epoch check above so a stale
21
22
  // absent-response can't wipe a fresh registry.
22
- if (action.payload.registry == null) {
23
- draft.registry = undefined;
24
- return;
23
+ const { registriesByDomain } = action.payload;
24
+ // Absent `registriesByDomain` means a pre-domain caller: treat `registry`
25
+ // as the task_checklist snapshot so their behaviour is unchanged.
26
+ const snapshots = registriesByDomain ?? { task_checklist: action.payload.registry };
27
+ draft.registryByDomain = {};
28
+ for (const domain of NOTIFICATION_DOMAINS) {
29
+ const payload = snapshots[domain];
30
+ // Full-replace per domain, and an absent snapshot CLEARS that domain so
31
+ // tenant B never inherits A's section. The gates are independent
32
+ // server-side, so one domain clearing must not touch the other.
33
+ if (payload != null) {
34
+ draft.registryByDomain[domain] =
35
+ mapNotificationRegistryPayloadToRegistry(payload);
36
+ }
25
37
  }
26
- // Full-replace contract: the registry payload is atomic — every fetch
27
- // returns the complete group/event tree. If the backend ever ships a
28
- // partial registry response, this write MUST switch to a merge (mirror
29
- // the preferences slice's `mergePreferences`). Do not assume the
30
- // current payload is partial without also updating this reducer.
31
- draft.registry = mapNotificationRegistryPayloadToRegistry(action.payload.registry);
38
+ // Mirrored for consumers that predate the domain-keyed map.
39
+ draft.registry = draft.registryByDomain.task_checklist;
40
+ return;
32
41
  },
33
42
  },
34
43
  extraReducers: (builder) => {
@@ -41,6 +50,8 @@ const notificationRegistry = createSlice({
41
50
  // — Cursor Bugbot 67d6918e. Returning `initialState` verbatim would
42
51
  // rewind the counter and let a stale in-flight GET restore A's
43
52
  // registry over B's.
53
+ // Drops `registry` and `registryByDomain` together: a tenant switch must
54
+ // not leave one domain's section behind.
44
55
  return { registryEpoch: draft.registryEpoch + 1 };
45
56
  });
46
57
  },
@@ -4,3 +4,8 @@
4
4
  // off for this tenant". Both currently surface as `undefined`. Distinguishing
5
5
  // them (e.g. an explicit `gate_off` signal from the server) is a follow-up.
6
6
  export const getNotificationRegistry = (slice) => slice.registry;
7
+ // `undefined` conflates gate-off with no-preferences-yet; consumers hide the
8
+ // section either way. Falls back to `registry` for task_checklist so state built
9
+ // in the pre-domain shape (consumer mocks, older callers) still resolves.
10
+ export const getNotificationRegistryForDomain = (slice, domain) => slice.registryByDomain?.[domain] ??
11
+ (domain === 'task_checklist' ? slice.registry : undefined);
@@ -1,4 +1,9 @@
1
1
  import { stringToUnion } from '../../commonStateTypes/stringToUnion';
2
+ // Wire vocabulary owned by the notifications service, not by this slice.
3
+ export const NOTIFICATION_DOMAINS = ['task_checklist', 'commenting'];
4
+ // Callers that predate the domain split mean Task Checklist.
5
+ export const DEFAULT_NOTIFICATION_DOMAIN = 'task_checklist';
6
+ export const toNotificationDomain = (raw) => stringToUnion(raw, NOTIFICATION_DOMAINS);
2
7
  export const NOTIFICATION_CHANNELS = ['email', 'slack', 'in_app'];
3
8
  export const toNotificationChannel = (raw) => stringToUnion(raw, NOTIFICATION_CHANNELS);
4
9
  export const NOTIFICATION_FREQUENCIES = ['instant', 'daily'];
@@ -32,7 +32,9 @@ const sectionProjectView = createSlice({
32
32
  Object.keys(sectionPayload.projects).forEach((projectId) => {
33
33
  const projectPayload = sectionPayload.projects[projectId];
34
34
  // A calculated section is grouped by project with no accounts under it.
35
- const projectAccounts = 'accounts' in projectPayload ? projectPayload.accounts : undefined;
35
+ const projectAccounts = 'accounts' in projectPayload
36
+ ? projectPayload.accounts
37
+ : undefined;
36
38
  const nestedAccountIds = projectAccounts != null
37
39
  ? getNestedAccountIDHierarchyForAccounts(Object.keys(projectAccounts), accountsMetadata)
38
40
  : [];
package/lib/esm/epic.js CHANGED
@@ -50,21 +50,21 @@ import { acceptMasterTOSEpic, } from './view/aiCfoView/epics/acceptMasterTOSEpic
50
50
  import { createSessionAndSubmitEpic, } from './view/aiCfoView/epics/createSessionAndSubmitEpic';
51
51
  import { createSessionEpic, } from './view/aiCfoView/epics/createSessionEpic';
52
52
  import { deleteChatSessionEpic, } from './view/aiCfoView/epics/deleteChatSessionEpic';
53
+ import { deleteRoutineEpic } from './view/aiCfoView/epics/deleteRoutineEpic';
53
54
  import { deleteSkillEpic } from './view/aiCfoView/epics/deleteSkillEpic';
54
55
  import { fetchChatHistoryEpic, } from './view/aiCfoView/epics/fetchChatHistoryEpic';
55
56
  import { fetchChatSessionsForUserEpic, } from './view/aiCfoView/epics/fetchChatSessionsForUserEpic';
57
+ import { fetchRoutineRunsEpic } from './view/aiCfoView/epics/fetchRoutineRunsEpic';
58
+ import { fetchRoutinesEpic } from './view/aiCfoView/epics/fetchRoutinesEpic';
56
59
  import { fetchSkillDetailEpic } from './view/aiCfoView/epics/fetchSkillDetailEpic';
57
60
  import { fetchSkillVersionBodyEpic } from './view/aiCfoView/epics/fetchSkillVersionBodyEpic';
58
61
  import { fetchSkillVersionsEpic } from './view/aiCfoView/epics/fetchSkillVersionsEpic';
59
62
  import { fetchSkillsEpic, } from './view/aiCfoView/epics/fetchSkillsEpic';
60
63
  import { fetchSuggestedQuestionsEpic, } from './view/aiCfoView/epics/fetchSuggestedQuestionsEpic';
61
- import { deleteRoutineEpic } from './view/aiCfoView/epics/deleteRoutineEpic';
62
- import { fetchRoutineRunsEpic } from './view/aiCfoView/epics/fetchRoutineRunsEpic';
63
- import { fetchRoutinesEpic } from './view/aiCfoView/epics/fetchRoutinesEpic';
64
64
  import { runRoutineEpic } from './view/aiCfoView/epics/runRoutineEpic';
65
65
  import { saveRoutineEpic } from './view/aiCfoView/epics/saveRoutineEpic';
66
- import { setRoutineEnabledEpic } from './view/aiCfoView/epics/setRoutineEnabledEpic';
67
66
  import { saveSkillEpic } from './view/aiCfoView/epics/saveSkillEpic';
67
+ import { setRoutineEnabledEpic } from './view/aiCfoView/epics/setRoutineEnabledEpic';
68
68
  import { setSkillVisibilityEpic } from './view/aiCfoView/epics/setSkillVisibilityEpic';
69
69
  import { stopSubmitEpic, } from './view/aiCfoView/epics/stopSubmitEpic';
70
70
  import { stopSubmitQuestionEpic, } from './view/aiCfoView/epics/stopSubmitQuestionEpic';
package/lib/esm/index.js CHANGED
@@ -64,8 +64,8 @@ import { ALL_JE_SCHEDULE_IGNORE_REASONS, ALL_JE_SCHEDULE_REVERT_REASONS, ALL_ONE
64
64
  import { ALL_MONTH_END_CLOSE_CHECKS_FREQUENCY, } from './entity/monthEndCloseChecks/monthEndCloseChecksState';
65
65
  import { updateCommentsNotifications, updateCommentsNotificationsStatuses, } from './entity/notification/notificationReducer';
66
66
  import { toNotificationModeStrict, } from './entity/notification/types/notificationTypes';
67
- import { getNotificationRegistry } from './entity/notificationRegistry/notificationRegistrySelector';
68
- import { toNotificationChannel, toNotificationFrequency, } from './entity/notificationRegistry/notificationRegistryState';
67
+ import { getNotificationRegistry, getNotificationRegistryForDomain, } from './entity/notificationRegistry/notificationRegistrySelector';
68
+ import { DEFAULT_NOTIFICATION_DOMAIN, NOTIFICATION_DOMAINS, toNotificationChannel, toNotificationDomain, toNotificationFrequency, } from './entity/notificationRegistry/notificationRegistryState';
69
69
  import { getPlaidPaymentAccounts } from './entity/paymentAccount/paymentAccountSelector';
70
70
  import { VERIFIED_PAYMENT_ACCOUNT_PROVIDER_VERIFICATION_STATUS, } from './entity/paymentAccount/paymentAccountState';
71
71
  import { closeSnackbar, openSnackbar } from './entity/snackbar/snackbarReducer';
@@ -236,7 +236,7 @@ import { toAverageMonthsCount } from './view/netBurnOrIncomeStoryCard/epic/updat
236
236
  import { fetchNetBurnOrIncomeStoryCard, updateNetBurnOrIncomeStoryCardSettings, } from './view/netBurnOrIncomeStoryCard/netBurnOrIncomeStoryCardReducer';
237
237
  import { getNetBurnOrIncomeStoryCardReport } from './view/netBurnOrIncomeStoryCard/netBurnOrIncomeStoryCardSelector';
238
238
  import { clearAllNotificationPreferencesView, clearNotificationPreferencesLocalOverrides, saveNotificationPreferences, setGroupChannelMaster, setGroupFrequency, toggleEventChannel, } from './view/notificationPreferencesView/notificationPreferencesViewReducer';
239
- import { getEffectiveNotificationPreferences, getNotificationLocalOverrides, getNotificationPreferencesSaveState, hasUnsavedNotificationPreferences, } from './view/notificationPreferencesView/notificationPreferencesViewSelector';
239
+ import { getEffectiveNotificationPreferences, getEffectiveNotificationPreferencesForDomain, getNotificationLocalOverrides, getNotificationLocalOverridesForDomain, getNotificationPreferencesSaveState, hasUnsavedNotificationPreferences, hasUnsavedNotificationPreferencesForDomain, } from './view/notificationPreferencesView/notificationPreferencesViewSelector';
240
240
  import { fetchNotificationUnreadCount, fetchNotificationUnreadCountSuccess, fetchNotificationView, updateNotificationViewAllNotificationsStatus, updateNotificationViewCurrentTabAndSubTab, updateNotificationViewNotificationStatus, updateNotificationViewSubTab, updateNotificationViewTabState, updateNotificationViewUIState, } from './view/notificationView/notificationViewReducer';
241
241
  import { getExternalNotificationsForSelectedSubTab, getNotificationView, getNotificationsForSelectedSubTab, } from './view/notificationView/notificationViewSelector';
242
242
  import { toNotificationSubTabTypeStrict, toNotificationTabTypeStrict, } from './view/notificationView/notificationViewState';
@@ -680,7 +680,7 @@ export { toNotificationModeStrict, updateCommentsNotifications, updateCommentsNo
680
680
  export { toNotificationSubTabTypeStrict, toNotificationTabTypeStrict, fetchNotificationView, fetchNotificationUnreadCount, fetchNotificationUnreadCountSuccess, updateNotificationViewAllNotificationsStatus, updateNotificationViewNotificationStatus, updateNotificationViewTabState, updateNotificationViewCurrentTabAndSubTab, updateNotificationViewSubTab, updateNotificationViewUIState, getNotificationView, getExternalNotificationsForSelectedSubTab, getNotificationsForSelectedSubTab, };
681
681
  export { fetchRegisteredInterests, notifyMeForFeature, getFeatureNotificationView, getRegisteredInterests, getRegisteredInterestsByFeature, isFeatureInterestRegistered, };
682
682
  export { pushToastNotification, getLastNotificationTime, getNotifications, };
683
- export { getEffectiveNotificationPreferences, getNotificationLocalOverrides, getNotificationPreferencesSaveState, getNotificationRegistry, hasUnsavedNotificationPreferences, clearAllNotificationPreferencesView, clearNotificationPreferencesLocalOverrides, saveNotificationPreferences, setGroupChannelMaster, setGroupFrequency, toggleEventChannel, toNotificationChannel, toNotificationFrequency, };
683
+ export { getEffectiveNotificationPreferences, getEffectiveNotificationPreferencesForDomain, getNotificationLocalOverrides, getNotificationLocalOverridesForDomain, getNotificationPreferencesSaveState, getNotificationRegistry, getNotificationRegistryForDomain, hasUnsavedNotificationPreferences, hasUnsavedNotificationPreferencesForDomain, NOTIFICATION_DOMAINS, DEFAULT_NOTIFICATION_DOMAIN, clearAllNotificationPreferencesView, clearNotificationPreferencesLocalOverrides, saveNotificationPreferences, setGroupChannelMaster, setGroupFrequency, toggleEventChannel, toNotificationChannel, toNotificationDomain, toNotificationFrequency, };
684
684
  export { getReferralListView, getInviteFormView, toReferralListViewSortKeyType, StatusTypes, AmountStatusTypes, DEFAULT_REFERRER_AMOUNT, fetchReferrals, sendReferralInvite, clearReferrals, saveReferralFormDataInLocalStore, updateReferralListSortUiState, resendReferralInvite, fetchRewardsPlan, getRewardsPlanCard, updateReferViewed, };
685
685
  export { ALL_WEEK_DAYS, SEMI_WEEKLY_REQUIRED_DAYS_COUNT, getMinAllowedEndDate, getRecurringEndDateFromCount, toDayOfWeek, toRecurringFrequency, };
686
686
  export { fetchCockpitContext, fetchCompanyTaskManagerView, fetchTaskManagerMetrics, getCompanyTaskManagerView, createTaskFromTaskGroupTemplate, };
@@ -835,7 +835,8 @@ const aiCfoView = createSlice({
835
835
  // The server has it. Nothing it sends from here on will contain this row,
836
836
  // so the tombstone has done its job and holding it any longer is what
837
837
  // makes a routine recreated under the same id invisible forever.
838
- draft.routines.deletedScheduleIds = draft.routines.deletedScheduleIds.filter((id) => id !== action.payload.scheduleId);
838
+ draft.routines.deletedScheduleIds =
839
+ draft.routines.deletedScheduleIds.filter((id) => id !== action.payload.scheduleId);
839
840
  draft.routineMutation = {
840
841
  fetchState: 'Completed',
841
842
  error: undefined,
@@ -847,7 +848,8 @@ const aiCfoView = createSlice({
847
848
  // is what lets the refetch put the row back — leaving it hidden would
848
849
  // tell the user they had stopped something they had not, which is the
849
850
  // worst outcome this list can produce.
850
- draft.routines.deletedScheduleIds = draft.routines.deletedScheduleIds.filter((id) => id !== action.payload.scheduleId);
851
+ draft.routines.deletedScheduleIds =
852
+ draft.routines.deletedScheduleIds.filter((id) => id !== action.payload.scheduleId);
851
853
  // Its own slice: the refetch that puts the row back would otherwise wipe
852
854
  // this error, leaving the row silently reappearing with no explanation.
853
855
  draft.routineMutation = {
@@ -27,7 +27,9 @@ export const fetchRoutineRunsEpic = (actions$, _state$, zeniAPI) => actions$.pip
27
27
  // Filtered, not trusted: one malformed row must not take the
28
28
  // whole history down, and a run without an id is not addressable
29
29
  // by anything the UI does with it.
30
- runs: (data.runs ?? []).filter(isRoutineRunPayload).map(toRoutineRun),
30
+ runs: (data.runs ?? [])
31
+ .filter(isRoutineRunPayload)
32
+ .map(toRoutineRun),
31
33
  scheduleId,
32
34
  sessionId: data.session_id ?? null,
33
35
  });
@@ -16,12 +16,22 @@ import { entityToInvoicingCatalogItemFormLocalData } from './invoicingCatalogIte
16
16
  export const seedInvoicingCatalogItemFormDraftEpic = (actions$, state$) => actions$.pipe(filter((action) => updateInvoicingCatalogItemDetail.match(action) ||
17
17
  fetchInvoicingCatalogItemDetailPage.match(action)), withLatestFrom(state$), mergeMap(([action, state]) => {
18
18
  const id = action.payload.id;
19
+ if (id == null) {
20
+ return EMPTY;
21
+ }
22
+ // The entity alone does not say the whole record is loaded — the list
23
+ // endpoints merge their own list-shaped rows into the same store. Only a
24
+ // completed detail load does, which is also exactly when the page's
25
+ // cache-guarded fetch issues no request and this is the sole seed.
26
+ if (fetchInvoicingCatalogItemDetailPage.match(action) &&
27
+ state.editInvoicingCatalogItemDetailViewState.recordStateById[id]
28
+ ?.fetchState !== 'Completed') {
29
+ return EMPTY;
30
+ }
19
31
  // Nothing to seed from on a cold open; the detail response triggers this
20
32
  // again once it lands.
21
- const plan = id != null
22
- ? getInvoicingPlanById(state.invoicingPlanState, id)
23
- : undefined;
24
- if (id == null || plan == null) {
33
+ const plan = getInvoicingPlanById(state.invoicingPlanState, id);
34
+ if (plan == null) {
25
35
  return EMPTY;
26
36
  }
27
37
  return of(seedInvoicingCatalogItemFormDraft({
@@ -16,11 +16,21 @@ import { entityToInvoicingCouponFormLocalData } from './editInvoicingCouponDetai
16
16
  export const seedInvoicingCouponFormDraftEpic = (actions$, state$) => actions$.pipe(filter((action) => updateInvoicingCouponDetail.match(action) ||
17
17
  fetchInvoicingCouponDetailPage.match(action)), withLatestFrom(state$), mergeMap(([action, state]) => {
18
18
  const { id } = action.payload;
19
+ if (id == null) {
20
+ return EMPTY;
21
+ }
22
+ // The entity alone does not say the whole record is loaded — the list
23
+ // endpoints merge their own list-shaped rows into the same store. Only a
24
+ // completed detail load does, which is also exactly when the page's
25
+ // cache-guarded fetch issues no request and this is the sole seed.
26
+ if (fetchInvoicingCouponDetailPage.match(action) &&
27
+ state.editInvoicingCouponDetailViewState.recordStateById[id]
28
+ ?.fetchState !== 'Completed') {
29
+ return EMPTY;
30
+ }
19
31
  // Nothing to seed from on a cold open; the detail response triggers this
20
32
  // again once it lands.
21
- const coupon = id != null
22
- ? getInvoicingCouponById(state.invoicingCouponState, id)
23
- : undefined;
33
+ const coupon = getInvoicingCouponById(state.invoicingCouponState, id);
24
34
  if (coupon == null) {
25
35
  return EMPTY;
26
36
  }
@@ -1,16 +1,35 @@
1
1
  import { EMPTY, of } from 'rxjs';
2
2
  import { filter, mergeMap, withLatestFrom } from 'rxjs/operators';
3
3
  import { getInvoicingCustomerById } from '../../../entity/invoicing/invoicingCustomer/invoicingCustomerSelector';
4
- import { seedInvoicingCustomerFormDraft, updateInvoicingCustomerDetail, } from './editInvoicingCustomerDetailViewReducer';
4
+ import { fetchInvoicingCustomerDetailPage, seedInvoicingCustomerFormDraft, updateInvoicingCustomerDetail, } from './editInvoicingCustomerDetailViewReducer';
5
5
  import { entityToInvoicingCustomerFormLocalData } from './invoicingCustomerFormConfig';
6
6
  /**
7
- * Seeds the edit draft from the record the moment the detail fetch lands, so
8
- * the form has its values before it mounts. The reducer ignores the seed when a
9
- * draft already exists, which is what stops a background refetch from
10
- * overwriting edits in progress.
7
+ * Seeds the edit draft from the record, so the form has its values before it
8
+ * mounts. The reducer ignores a seed once the draft holds the record, which is
9
+ * what stops a background refetch from overwriting edits in progress.
10
+ *
11
+ * Opening the page counts as a trigger, not just the detail response: the page
12
+ * fetch is cache-guarded, so re-opening for a record already loaded this
13
+ * session issues no request at all — and a draft cleared in between (by a save
14
+ * or a cancel) would have nothing left to seed it.
11
15
  */
12
- export const seedInvoicingCustomerFormDraftEpic = (actions$, state$) => actions$.pipe(filter(updateInvoicingCustomerDetail.match), withLatestFrom(state$), mergeMap(([action, state]) => {
16
+ export const seedInvoicingCustomerFormDraftEpic = (actions$, state$) => actions$.pipe(filter((action) => updateInvoicingCustomerDetail.match(action) ||
17
+ fetchInvoicingCustomerDetailPage.match(action)), withLatestFrom(state$), mergeMap(([action, state]) => {
13
18
  const { id } = action.payload;
19
+ if (id == null) {
20
+ return EMPTY;
21
+ }
22
+ // The entity alone does not say the whole record is loaded — the list
23
+ // endpoints merge their own list-shaped rows into the same store. Only a
24
+ // completed detail load does, which is also exactly when the page's
25
+ // cache-guarded fetch issues no request and this is the sole seed.
26
+ if (fetchInvoicingCustomerDetailPage.match(action) &&
27
+ state.editInvoicingCustomerDetailViewState.recordStateById[id]
28
+ ?.fetchState !== 'Completed') {
29
+ return EMPTY;
30
+ }
31
+ // Nothing to seed from on a cold open; the detail response triggers this
32
+ // again once it lands.
14
33
  const customer = getInvoicingCustomerById(state.invoicingCustomerState, id);
15
34
  if (customer == null) {
16
35
  return EMPTY;
@@ -18,10 +18,22 @@ export const seedInvoicingSubscriptionFormDraftEpic = (actions$, state$) => acti
18
18
  const id = updateInvoicingSubscriptionDetail.match(action)
19
19
  ? action.payload.id
20
20
  : action.payload.subscriptionId;
21
+ if (id == null) {
22
+ return EMPTY;
23
+ }
24
+ // The entity alone does not say the whole record is loaded — the list
25
+ // endpoints merge their own list-shaped rows into the same store. Only a
26
+ // completed detail load does, which is also exactly when the page's
27
+ // cache-guarded fetch issues no request and this is the sole seed.
28
+ if (fetchInvoicingSubscriptionFormPage.match(action) &&
29
+ state.editInvoicingSubscriptionDetailViewState.recordStateById[id]
30
+ ?.fetchState !== 'Completed') {
31
+ return EMPTY;
32
+ }
21
33
  // Nothing to seed from on a cold open; the detail response triggers this
22
34
  // again once it lands.
23
35
  const subscription = id != null ? getInvoicingSubscriptionById(state, id) : undefined;
24
- if (id == null || subscription == null) {
36
+ if (subscription == null) {
25
37
  return EMPTY;
26
38
  }
27
39
  return of(seedInvoicingSubscriptionFormDraft({
@@ -21,16 +21,25 @@ export function applyInvoicingFormDraftSeed(draftById, id, localData) {
21
21
  draftById[id] = { fetchState: 'Completed', localData };
22
22
  }
23
23
  /**
24
- * Stand the draft up blank when the record's fetch fails, so the form renders
25
- * instead of waiting behind a skeleton that will never resolve. A draft that
26
- * already exists is left alone: a background refetch failing is no reason to
27
- * discard what the user has.
24
+ * Record that the fetch failed, so the form renders instead of waiting behind a
25
+ * skeleton that will never resolve.
26
+ *
27
+ * Mirrors the seed: a draft holding the record is left alone, since a
28
+ * background refetch failing is no reason to discard it, and anything else is
29
+ * marked failed. A draft the form wrote before the record landed keeps its
30
+ * values — there is no reason to throw away what the user typed — but stops
31
+ * counting as still loading, and a later successful fetch can still seed it.
28
32
  */
29
33
  export function applyInvoicingFormDraftFailure(draftById, id, blankLocalData) {
30
- if (draftById[id] != null) {
34
+ const existing = draftById[id];
35
+ if (existing == null) {
36
+ draftById[id] = { fetchState: 'Error', localData: blankLocalData };
37
+ return;
38
+ }
39
+ if (existing.fetchState === 'Completed') {
31
40
  return;
32
41
  }
33
- draftById[id] = { fetchState: 'Error', localData: blankLocalData };
42
+ existing.fetchState = 'Error';
34
43
  }
35
44
  /** The draft's values, or the blank form when nothing is drafted yet. */
36
45
  export function getInvoicingFormDraftLocalData(draftById, id, blankLocalData) {
@@ -1,11 +1,12 @@
1
1
  import { EMPTY, of } from 'rxjs';
2
2
  import { catchError, filter, finalize, mergeMap, switchMap, takeUntil, withLatestFrom, } from 'rxjs/operators';
3
+ import { NOTIFICATION_DOMAINS } from '../../../entity/notificationRegistry/notificationRegistryState';
3
4
  import { openSnackbar } from '../../../entity/snackbar/snackbarReducer';
4
5
  import { createZeniAPIStatus, isSuccessResponse, } from '../../../responsePayload';
5
6
  import { notificationPreferencesUrl } from '../notificationPreferencesEndpoint';
6
7
  import { mapPreferencesToPayload, } from '../notificationPreferencesViewPayload';
7
8
  import { clearAllNotificationPreferencesView, clearNotificationPreferencesLocalOverrides, saveNotificationPreferences, saveNotificationPreferencesFailure, saveNotificationPreferencesSuccess, } from '../notificationPreferencesViewReducer';
8
- import { getNotificationLocalOverrides } from '../notificationPreferencesViewSelector';
9
+ import { getNotificationLocalOverridesForDomain } from '../notificationPreferencesViewSelector';
9
10
  export const saveNotificationPreferencesEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter((action) => saveNotificationPreferences.match(action)), withLatestFrom(state$),
10
11
  // `switchMap` unsubscribes from any in-flight PUT observable when a newer
11
12
  // Save fires. The prior HTTP request has already left the
@@ -13,9 +14,19 @@ export const saveNotificationPreferencesEpic = (actions$, state$, zeniAPI) => ac
13
14
  // ignored, so stale success/failure actions cannot clobber the newer
14
15
  // batch's state. Server-side ordering is arrival-order LWW.
15
16
  switchMap(([, state]) => {
16
- const overrides = getNotificationLocalOverrides(state);
17
- const preferencesPatch = mapPreferencesToPayload(overrides);
18
- if (Object.keys(preferencesPatch).length === 0) {
17
+ // A clean domain is omitted entirely: an empty patch is still a write against it.
18
+ const overridesByDomain = {};
19
+ const body = {};
20
+ NOTIFICATION_DOMAINS.forEach((domain) => {
21
+ const overrides = getNotificationLocalOverridesForDomain(state, domain);
22
+ const preferencesPatch = mapPreferencesToPayload(overrides);
23
+ if (Object.keys(preferencesPatch).length === 0) {
24
+ return;
25
+ }
26
+ overridesByDomain[domain] = overrides;
27
+ body[`${domain}_preferences`] = preferencesPatch;
28
+ });
29
+ if (Object.keys(body).length === 0) {
19
30
  // No diff → do not dispatch a synthetic success (that would wipe
20
31
  // stored preferences via the reducer). Simply no-op.
21
32
  return EMPTY;
@@ -28,7 +39,6 @@ switchMap(([, state]) => {
28
39
  // in-flight save's response (Success/Failure never dispatched, so
29
40
  // the counter never drained and future saves got their merge dropped).
30
41
  const cancelEpochAtDispatch = state.notificationPreferencesViewState.cancelEpoch;
31
- const body = { task_checklist_preferences: preferencesPatch };
32
42
  // Suppress the error snackbar when the response lands AFTER the user
33
43
  // pressed Cancel — the Failure reducer already swallows the state
34
44
  // update, so the toast would be a stale error for a save the user
@@ -57,8 +67,11 @@ switchMap(([, state]) => {
57
67
  if (isSuccessResponse(response)) {
58
68
  return of(saveNotificationPreferencesSuccess({
59
69
  cancelEpochAtDispatch,
60
- savedOverrides: overrides,
61
- serverEcho: response.data?.task_checklist_preferences,
70
+ savedOverridesByDomain: overridesByDomain,
71
+ serverEchoByDomain: {
72
+ task_checklist: response.data?.task_checklist_preferences,
73
+ commenting: response.data?.commenting_preferences,
74
+ },
62
75
  }));
63
76
  }
64
77
  const actions = [