@zeniai/client-epic-state 5.1.68-betaDI2 → 5.1.68-betaNB1

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 (54) hide show
  1. package/lib/entity/accountRecon/accountReconReducer.js +4 -0
  2. package/lib/entity/accountRecon/accountReconState.d.ts +4 -1
  3. package/lib/entity/accountRecon/accountReconState.js +1 -0
  4. package/lib/epic.d.ts +2 -1
  5. package/lib/epic.js +2 -1
  6. package/lib/esm/entity/accountRecon/accountReconReducer.js +4 -0
  7. package/lib/esm/entity/accountRecon/accountReconState.js +1 -0
  8. package/lib/esm/epic.js +2 -1
  9. package/lib/esm/index.js +5 -5
  10. package/lib/esm/view/expenseAutomationView/epics/accountRecon/confirmStatementMappingEpic.js +37 -0
  11. package/lib/esm/view/expenseAutomationView/epics/accountRecon/updateStatementInfoEpic.js +74 -5
  12. package/lib/esm/view/expenseAutomationView/epics/accountRecon/uploadAccountStatementDocumentAIHelper.js +12 -4
  13. package/lib/esm/view/expenseAutomationView/epics/accountRecon/uploadAccountStatementEpic.js +10 -2
  14. package/lib/esm/view/expenseAutomationView/helpers/mapStatementUpdateLocalDataToRequestBody.js +29 -5
  15. package/lib/esm/view/expenseAutomationView/payload/reconciliationPayload.js +106 -0
  16. package/lib/esm/view/expenseAutomationView/reducers/reconciliationViewReducer.js +86 -13
  17. package/lib/esm/view/expenseAutomationView/selectors/reconciliationViewSelector.js +29 -6
  18. package/lib/esm/view/expenseAutomationView/selectors/statementParseViewSelector.js +51 -10
  19. package/lib/esm/view/expenseAutomationView/types/reconciliationViewState.js +15 -1
  20. package/lib/esm/view/notificationPreferencesView/epics/saveNotificationPreferencesEpic.js +12 -9
  21. package/lib/esm/view/notificationPreferencesView/notificationPreferencesViewPayload.js +2 -7
  22. package/lib/esm/view/notificationPreferencesView/notificationPreferencesViewReducer.js +2 -47
  23. package/lib/esm/view/notificationPreferencesView/notificationPreferencesViewSelector.js +0 -9
  24. package/lib/esm/view/notificationPreferencesView/notificationPreferencesViewState.js +0 -1
  25. package/lib/index.d.ts +5 -5
  26. package/lib/index.js +54 -47
  27. package/lib/view/expenseAutomationView/epics/accountRecon/confirmStatementMappingEpic.d.ts +21 -0
  28. package/lib/view/expenseAutomationView/epics/accountRecon/confirmStatementMappingEpic.js +41 -0
  29. package/lib/view/expenseAutomationView/epics/accountRecon/updateStatementInfoEpic.js +73 -4
  30. package/lib/view/expenseAutomationView/epics/accountRecon/uploadAccountStatementDocumentAIHelper.d.ts +1 -1
  31. package/lib/view/expenseAutomationView/epics/accountRecon/uploadAccountStatementDocumentAIHelper.js +12 -4
  32. package/lib/view/expenseAutomationView/epics/accountRecon/uploadAccountStatementEpic.js +9 -1
  33. package/lib/view/expenseAutomationView/helpers/mapStatementUpdateLocalDataToRequestBody.d.ts +2 -0
  34. package/lib/view/expenseAutomationView/helpers/mapStatementUpdateLocalDataToRequestBody.js +30 -4
  35. package/lib/view/expenseAutomationView/payload/reconciliationPayload.d.ts +98 -4
  36. package/lib/view/expenseAutomationView/payload/reconciliationPayload.js +113 -0
  37. package/lib/view/expenseAutomationView/reducers/reconciliationViewReducer.d.ts +31 -4
  38. package/lib/view/expenseAutomationView/reducers/reconciliationViewReducer.js +87 -14
  39. package/lib/view/expenseAutomationView/selectorTypes/reconciliationViewSelectorTypes.d.ts +4 -1
  40. package/lib/view/expenseAutomationView/selectors/reconciliationViewSelector.js +29 -6
  41. package/lib/view/expenseAutomationView/selectors/statementParseViewSelector.d.ts +4 -2
  42. package/lib/view/expenseAutomationView/selectors/statementParseViewSelector.js +53 -10
  43. package/lib/view/expenseAutomationView/types/reconciliationViewState.d.ts +66 -0
  44. package/lib/view/expenseAutomationView/types/reconciliationViewState.js +19 -1
  45. package/lib/view/notificationPreferencesView/epics/saveNotificationPreferencesEpic.d.ts +8 -2
  46. package/lib/view/notificationPreferencesView/epics/saveNotificationPreferencesEpic.js +9 -6
  47. package/lib/view/notificationPreferencesView/notificationPreferencesViewPayload.d.ts +0 -1
  48. package/lib/view/notificationPreferencesView/notificationPreferencesViewPayload.js +2 -7
  49. package/lib/view/notificationPreferencesView/notificationPreferencesViewReducer.d.ts +1 -6
  50. package/lib/view/notificationPreferencesView/notificationPreferencesViewReducer.js +3 -48
  51. package/lib/view/notificationPreferencesView/notificationPreferencesViewSelector.js +0 -9
  52. package/lib/view/notificationPreferencesView/notificationPreferencesViewState.d.ts +0 -1
  53. package/lib/view/notificationPreferencesView/notificationPreferencesViewState.js +0 -1
  54. package/package.json +1 -1
@@ -9,7 +9,12 @@ const notificationPreferencesEndpoint_1 = require("../notificationPreferencesEnd
9
9
  const notificationPreferencesViewPayload_1 = require("../notificationPreferencesViewPayload");
10
10
  const notificationPreferencesViewReducer_1 = require("../notificationPreferencesViewReducer");
11
11
  const notificationPreferencesViewSelector_1 = require("../notificationPreferencesViewSelector");
12
- const saveNotificationPreferencesEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)((action) => notificationPreferencesViewReducer_1.saveNotificationPreferences.match(action)), (0, operators_1.withLatestFrom)(state$),
12
+ const DEBOUNCE_MS = 300;
13
+ const saveNotificationPreferencesEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)((action) => notificationPreferencesViewReducer_1.toggleEventChannel.match(action) || notificationPreferencesViewReducer_1.setGroupFrequency.match(action)),
14
+ // Coalesce bursts of toggles into a single PUT. Trade-off: rapid clickers
15
+ // defer saves until they pause. Consider a max-wait wrapper if this
16
+ // becomes a UX problem.
17
+ (0, operators_1.debounceTime)(DEBOUNCE_MS), (0, operators_1.withLatestFrom)(state$),
13
18
  // `switchMap` unsubscribes from any in-flight PUT observable when a new
14
19
  // debounced batch fires. The prior HTTP request has already left the
15
20
  // client — the network call is NOT cancelled — but its response is
@@ -108,10 +113,8 @@ const saveNotificationPreferencesEpic = (actions$, state$, zeniAPI) => actions$.
108
113
  // under patch-semantic LWW. Cursor Bugbot 3637969823 + 3641372002.
109
114
  (0, operators_1.takeUntil)(actions$.pipe((0, operators_1.filter)((action) => notificationPreferencesViewReducer_1.clearNotificationPreferencesLocalOverrides.match(action) ||
110
115
  notificationPreferencesViewReducer_1.clearAllNotificationPreferencesView.match(action)))));
111
- // `saveNotificationPreferences` (the trigger) already flipped
112
- // savePreferencesState to In-Progress via its reducer case, so the PUT
113
- // observable is returned directly — re-emitting the trigger here would
114
- // loop the epic on itself.
115
- return request$;
116
+ // Flip savePreferencesState to In-Progress BEFORE the network call so
117
+ // any "saving…" UI can render.
118
+ return (0, rxjs_1.concat)((0, rxjs_1.of)((0, notificationPreferencesViewReducer_1.saveNotificationPreferences)()), request$);
116
119
  }));
117
120
  exports.saveNotificationPreferencesEpic = saveNotificationPreferencesEpic;
@@ -1,7 +1,6 @@
1
1
  import { NotificationPreferences } from './notificationPreferencesViewState';
2
2
  export interface NotificationPreferencesPayload {
3
3
  event_enabled_by_channel?: Record<string, Record<string, boolean>>;
4
- group_channel_enabled_by_group_id?: Record<string, Record<string, boolean>>;
5
4
  group_frequency_by_group_id?: Record<string, string>;
6
5
  }
7
6
  export declare const mapPayloadToPreferences: (payload?: NotificationPreferencesPayload) => NotificationPreferences;
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.mapPreferencesToPayload = exports.mapPayloadToPreferences = void 0;
4
4
  const notificationRegistryState_1 = require("../../entity/notificationRegistry/notificationRegistryState");
5
- const mapChannelEnabledMap = (raw) => {
5
+ const mapEventEnabledByChannel = (raw) => {
6
6
  if (raw == null) {
7
7
  return {};
8
8
  }
@@ -23,8 +23,7 @@ const mapPayloadToPreferences = (payload) => {
23
23
  (0, notificationRegistryState_1.toNotificationFrequency)(frequency),
24
24
  ]));
25
25
  return {
26
- eventEnabledByChannel: mapChannelEnabledMap(payload?.event_enabled_by_channel),
27
- groupChannelEnabledByGroupId: mapChannelEnabledMap(payload?.group_channel_enabled_by_group_id),
26
+ eventEnabledByChannel: mapEventEnabledByChannel(payload?.event_enabled_by_channel),
28
27
  groupFrequencyByGroupId,
29
28
  };
30
29
  };
@@ -34,10 +33,6 @@ const mapPreferencesToPayload = (preferences) => {
34
33
  if (Object.keys(preferences.eventEnabledByChannel).length > 0) {
35
34
  payload.event_enabled_by_channel = preferences.eventEnabledByChannel;
36
35
  }
37
- if (Object.keys(preferences.groupChannelEnabledByGroupId).length > 0) {
38
- payload.group_channel_enabled_by_group_id =
39
- preferences.groupChannelEnabledByGroupId;
40
- }
41
36
  if (Object.keys(preferences.groupFrequencyByGroupId).length > 0) {
42
37
  payload.group_frequency_by_group_id = preferences.groupFrequencyByGroupId;
43
38
  }
@@ -12,11 +12,6 @@ export interface TogglePreferencePayload {
12
12
  enabled: boolean;
13
13
  eventId: string;
14
14
  }
15
- export interface SetGroupChannelMasterPayload {
16
- channel: NotificationChannel;
17
- enabled: boolean;
18
- groupId: string;
19
- }
20
15
  export interface FetchNotificationPreferencesSuccessPayload {
21
16
  preferences: NotificationPreferencesPayload | undefined;
22
17
  saveEpochAtDispatch: number;
@@ -30,6 +25,6 @@ export interface SaveNotificationPreferencesFailurePayload {
30
25
  cancelEpochAtDispatch: number;
31
26
  error?: ZeniAPIStatus;
32
27
  }
33
- export declare const clearAllNotificationPreferencesView: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"notificationPreferencesView/clearAllNotificationPreferencesView">, clearNotificationPreferencesLocalOverrides: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"notificationPreferencesView/clearNotificationPreferencesLocalOverrides">, fetchNotificationPreferencesSuccess: import("@reduxjs/toolkit").ActionCreatorWithPayload<FetchNotificationPreferencesSuccessPayload, "notificationPreferencesView/fetchNotificationPreferencesSuccess">, saveNotificationPreferences: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"notificationPreferencesView/saveNotificationPreferences">, saveNotificationPreferencesFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<SaveNotificationPreferencesFailurePayload, "notificationPreferencesView/saveNotificationPreferencesFailure">, saveNotificationPreferencesSuccess: import("@reduxjs/toolkit").ActionCreatorWithPayload<SaveNotificationPreferencesSuccessPayload, "notificationPreferencesView/saveNotificationPreferencesSuccess">, setGroupChannelMaster: import("@reduxjs/toolkit").ActionCreatorWithPayload<SetGroupChannelMasterPayload, "notificationPreferencesView/setGroupChannelMaster">, setGroupFrequency: import("@reduxjs/toolkit").ActionCreatorWithPayload<SetFrequencyPayload, "notificationPreferencesView/setGroupFrequency">, toggleEventChannel: import("@reduxjs/toolkit").ActionCreatorWithPayload<TogglePreferencePayload, "notificationPreferencesView/toggleEventChannel">;
28
+ export declare const clearAllNotificationPreferencesView: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"notificationPreferencesView/clearAllNotificationPreferencesView">, clearNotificationPreferencesLocalOverrides: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"notificationPreferencesView/clearNotificationPreferencesLocalOverrides">, fetchNotificationPreferencesSuccess: import("@reduxjs/toolkit").ActionCreatorWithPayload<FetchNotificationPreferencesSuccessPayload, "notificationPreferencesView/fetchNotificationPreferencesSuccess">, saveNotificationPreferences: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"notificationPreferencesView/saveNotificationPreferences">, saveNotificationPreferencesFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<SaveNotificationPreferencesFailurePayload, "notificationPreferencesView/saveNotificationPreferencesFailure">, saveNotificationPreferencesSuccess: import("@reduxjs/toolkit").ActionCreatorWithPayload<SaveNotificationPreferencesSuccessPayload, "notificationPreferencesView/saveNotificationPreferencesSuccess">, setGroupFrequency: import("@reduxjs/toolkit").ActionCreatorWithPayload<SetFrequencyPayload, "notificationPreferencesView/setGroupFrequency">, toggleEventChannel: import("@reduxjs/toolkit").ActionCreatorWithPayload<TogglePreferencePayload, "notificationPreferencesView/toggleEventChannel">;
34
29
  declare const _default: import("redux").Reducer<NotificationPreferencesViewState>;
35
30
  export default _default;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  var _a;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.toggleEventChannel = exports.setGroupFrequency = exports.setGroupChannelMaster = exports.saveNotificationPreferencesSuccess = exports.saveNotificationPreferencesFailure = exports.saveNotificationPreferences = exports.fetchNotificationPreferencesSuccess = exports.clearNotificationPreferencesLocalOverrides = exports.clearAllNotificationPreferencesView = exports.initialState = void 0;
4
+ exports.toggleEventChannel = exports.setGroupFrequency = exports.saveNotificationPreferencesSuccess = exports.saveNotificationPreferencesFailure = exports.saveNotificationPreferences = exports.fetchNotificationPreferencesSuccess = exports.clearNotificationPreferencesLocalOverrides = exports.clearAllNotificationPreferencesView = exports.initialState = void 0;
5
5
  const toolkit_1 = require("@reduxjs/toolkit");
6
6
  const notificationPreferencesViewPayload_1 = require("./notificationPreferencesViewPayload");
7
7
  const notificationPreferencesViewState_1 = require("./notificationPreferencesViewState");
@@ -22,18 +22,8 @@ const mergePreferences = (base, patch) => {
22
22
  ...channels,
23
23
  };
24
24
  });
25
- const groupChannelEnabledByGroupId = {
26
- ...base.groupChannelEnabledByGroupId,
27
- };
28
- Object.entries(patch.groupChannelEnabledByGroupId).forEach(([groupId, channels]) => {
29
- groupChannelEnabledByGroupId[groupId] = {
30
- ...(base.groupChannelEnabledByGroupId[groupId] ?? {}),
31
- ...channels,
32
- };
33
- });
34
25
  return {
35
26
  eventEnabledByChannel,
36
- groupChannelEnabledByGroupId,
37
27
  groupFrequencyByGroupId: {
38
28
  ...base.groupFrequencyByGroupId,
39
29
  ...patch.groupFrequencyByGroupId,
@@ -75,38 +65,13 @@ const subtractSavedOverrides = (current, saved) => {
75
65
  eventEnabledByChannel[eventId] = remainingChannels;
76
66
  }
77
67
  });
78
- // Same value-equality subtraction as eventEnabledByChannel above — a
79
- // group-channel master the user re-flipped while a PUT was in flight must
80
- // survive so the next debounce cycle re-sends it.
81
- const groupChannelEnabledByGroupId = {};
82
- Object.entries(current.groupChannelEnabledByGroupId).forEach(([groupId, channels]) => {
83
- const savedChannels = saved.groupChannelEnabledByGroupId[groupId];
84
- if (savedChannels == null) {
85
- groupChannelEnabledByGroupId[groupId] = channels;
86
- return;
87
- }
88
- const remainingChannels = {};
89
- Object.keys(channels).forEach((channel) => {
90
- if (!(channel in savedChannels) ||
91
- channels[channel] !== savedChannels[channel]) {
92
- remainingChannels[channel] = channels[channel];
93
- }
94
- });
95
- if (Object.keys(remainingChannels).length > 0) {
96
- groupChannelEnabledByGroupId[groupId] = remainingChannels;
97
- }
98
- });
99
68
  const groupFrequencyByGroupId = {};
100
69
  Object.entries(current.groupFrequencyByGroupId).forEach(([groupId, frequency]) => {
101
70
  if (saved.groupFrequencyByGroupId[groupId] !== frequency) {
102
71
  groupFrequencyByGroupId[groupId] = frequency;
103
72
  }
104
73
  });
105
- return {
106
- eventEnabledByChannel,
107
- groupChannelEnabledByGroupId,
108
- groupFrequencyByGroupId,
109
- };
74
+ return { eventEnabledByChannel, groupFrequencyByGroupId };
110
75
  };
111
76
  const notificationPreferencesView = (0, toolkit_1.createSlice)({
112
77
  name: 'notificationPreferencesView',
@@ -243,16 +208,6 @@ const notificationPreferencesView = (0, toolkit_1.createSlice)({
243
208
  draft.preferences = mergePreferences(draft.preferences, patch);
244
209
  draft.localOverrides = subtractSavedOverrides(draft.localOverrides, action.payload.savedOverrides);
245
210
  },
246
- setGroupChannelMaster(draft, action) {
247
- // Mirror of `toggleEventChannel` but scoped to the group-channel master
248
- // held under `groupChannelEnabledByGroupId[groupId][channel]`.
249
- const { channel, enabled, groupId } = action.payload;
250
- const groupMap = {
251
- ...(draft.localOverrides.groupChannelEnabledByGroupId[groupId] ?? {}),
252
- };
253
- groupMap[channel] = enabled;
254
- draft.localOverrides.groupChannelEnabledByGroupId[groupId] = groupMap;
255
- },
256
211
  setGroupFrequency(draft, action) {
257
212
  draft.localOverrides.groupFrequencyByGroupId[action.payload.groupId] =
258
213
  action.payload.frequency;
@@ -267,5 +222,5 @@ const notificationPreferencesView = (0, toolkit_1.createSlice)({
267
222
  },
268
223
  },
269
224
  });
270
- _a = notificationPreferencesView.actions, exports.clearAllNotificationPreferencesView = _a.clearAllNotificationPreferencesView, exports.clearNotificationPreferencesLocalOverrides = _a.clearNotificationPreferencesLocalOverrides, exports.fetchNotificationPreferencesSuccess = _a.fetchNotificationPreferencesSuccess, exports.saveNotificationPreferences = _a.saveNotificationPreferences, exports.saveNotificationPreferencesFailure = _a.saveNotificationPreferencesFailure, exports.saveNotificationPreferencesSuccess = _a.saveNotificationPreferencesSuccess, exports.setGroupChannelMaster = _a.setGroupChannelMaster, exports.setGroupFrequency = _a.setGroupFrequency, exports.toggleEventChannel = _a.toggleEventChannel;
225
+ _a = notificationPreferencesView.actions, exports.clearAllNotificationPreferencesView = _a.clearAllNotificationPreferencesView, exports.clearNotificationPreferencesLocalOverrides = _a.clearNotificationPreferencesLocalOverrides, exports.fetchNotificationPreferencesSuccess = _a.fetchNotificationPreferencesSuccess, exports.saveNotificationPreferences = _a.saveNotificationPreferences, exports.saveNotificationPreferencesFailure = _a.saveNotificationPreferencesFailure, exports.saveNotificationPreferencesSuccess = _a.saveNotificationPreferencesSuccess, exports.setGroupFrequency = _a.setGroupFrequency, exports.toggleEventChannel = _a.toggleEventChannel;
271
226
  exports.default = notificationPreferencesView.reducer;
@@ -13,16 +13,8 @@ const getEffectiveNotificationPreferences = (state) => {
13
13
  ...channels,
14
14
  };
15
15
  });
16
- const mergedGroupChannelEnabledByGroupId = { ...view.preferences.groupChannelEnabledByGroupId };
17
- Object.entries(view.localOverrides.groupChannelEnabledByGroupId).forEach(([groupId, channels]) => {
18
- mergedGroupChannelEnabledByGroupId[groupId] = {
19
- ...(view.preferences.groupChannelEnabledByGroupId[groupId] ?? {}),
20
- ...channels,
21
- };
22
- });
23
16
  return {
24
17
  eventEnabledByChannel: mergedEventEnabledByChannel,
25
- groupChannelEnabledByGroupId: mergedGroupChannelEnabledByGroupId,
26
18
  groupFrequencyByGroupId: {
27
19
  ...view.preferences.groupFrequencyByGroupId,
28
20
  ...view.localOverrides.groupFrequencyByGroupId,
@@ -35,7 +27,6 @@ exports.getNotificationLocalOverrides = getNotificationLocalOverrides;
35
27
  const hasUnsavedNotificationPreferences = (state) => {
36
28
  const overrides = getView(state).localOverrides;
37
29
  return (Object.keys(overrides.eventEnabledByChannel).length > 0 ||
38
- Object.keys(overrides.groupChannelEnabledByGroupId).length > 0 ||
39
30
  Object.keys(overrides.groupFrequencyByGroupId).length > 0);
40
31
  };
41
32
  exports.hasUnsavedNotificationPreferences = hasUnsavedNotificationPreferences;
@@ -2,7 +2,6 @@ import { FetchStateAndError } from '../../commonStateTypes/common';
2
2
  import { NotificationChannel, NotificationFrequency } from '../../entity/notificationRegistry/notificationRegistryState';
3
3
  export interface NotificationPreferences {
4
4
  eventEnabledByChannel: Record<string, Partial<Record<NotificationChannel, boolean>>>;
5
- groupChannelEnabledByGroupId: Record<string, Partial<Record<NotificationChannel, boolean>>>;
6
5
  groupFrequencyByGroupId: Record<string, NotificationFrequency>;
7
6
  }
8
7
  export interface NotificationPreferencesViewState {
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.emptyNotificationPreferences = void 0;
4
4
  const emptyNotificationPreferences = () => ({
5
5
  eventEnabledByChannel: {},
6
- groupChannelEnabledByGroupId: {},
7
6
  groupFrequencyByGroupId: {},
8
7
  });
9
8
  exports.emptyNotificationPreferences = emptyNotificationPreferences;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "5.1.68-betaDI2",
3
+ "version": "5.1.68-betaNB1",
4
4
  "description": "Shared module between Web & Mobile containing required abstractions for state management, async network communication. ",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/esm/index.js",