@zeniai/client-epic-state 4.19.55 → 4.19.56-betaAR2

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.
@@ -43,6 +43,8 @@ const extension_1 = require("@redux-devtools/extension");
43
43
  const redux_1 = require("redux");
44
44
  const redux_observable_1 = require("redux-observable");
45
45
  const coreEpics_1 = __importDefault(require("./coreEpics"));
46
+ const reduxDebuggerMiddleware_1 = require("./debugger/reduxDebuggerMiddleware");
47
+ const wrapRootEpic_1 = require("./debugger/wrapRootEpic");
46
48
  const epicManager_1 = require("./epicManager");
47
49
  const reducer_1 = __importDefault(require("./reducer"));
48
50
  let storeEpicManager;
@@ -66,14 +68,14 @@ function configureNewStore(zeniAPI, includeReduxDevTools = false) {
66
68
  //
67
69
  // Reducer code is lightweight (just createSlice definitions). The heavy
68
70
  // code lives in epics (RxJS chains, API calls) which ARE deferred below.
69
- const store = (0, redux_1.createStore)(reducer_1.default, composeEnhancers((0, redux_1.applyMiddleware)(epicMiddleware)));
71
+ const store = (0, redux_1.createStore)(reducer_1.default, composeEnhancers((0, redux_1.applyMiddleware)(reduxDebuggerMiddleware_1.reduxDebuggerMiddleware, epicMiddleware)));
70
72
  // Attach epic manager to store for external access
71
73
  store.epicManager = storeEpicManager;
72
74
  // Start the dynamic root epic (BehaviorSubject + switchMap)
73
75
  epicMiddleware.run(storeEpicManager.rootEpic);
74
76
  // Inject only core epics at startup (24 out of ~526)
75
77
  // Feature epics are loaded lazily via injectFeatureModules()
76
- storeEpicManager.setEpic(coreEpics_1.default);
78
+ storeEpicManager.setEpic((0, wrapRootEpic_1.wrapRootEpic)(coreEpics_1.default));
77
79
  return store;
78
80
  }
79
81
  /**
@@ -105,7 +107,7 @@ function injectFeatureModules() {
105
107
  return _featureModulesPromise;
106
108
  }
107
109
  _featureModulesPromise = Promise.resolve().then(() => __importStar(require('./epic'))).then((epicModule) => {
108
- storeEpicManager.setEpic(epicModule.default);
110
+ storeEpicManager.setEpic((0, wrapRootEpic_1.wrapRootEpic)(epicModule.default));
109
111
  });
110
112
  return _featureModulesPromise;
111
113
  }
@@ -0,0 +1,13 @@
1
+ import { DebugEvent } from './types';
2
+ /**
3
+ * In-memory store for debug events. Subscribers are notified whenever a new event is added.
4
+ */
5
+ declare class DebugEventStore {
6
+ private events;
7
+ private listeners;
8
+ add(event: DebugEvent): void;
9
+ getEvents(): DebugEvent[];
10
+ subscribe(listener: (events: DebugEvent[]) => void): () => void;
11
+ }
12
+ export declare const debugEventStore: DebugEventStore;
13
+ export {};
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.debugEventStore = void 0;
4
+ /**
5
+ * In-memory store for debug events. Subscribers are notified whenever a new event is added.
6
+ */
7
+ class DebugEventStore {
8
+ constructor() {
9
+ this.events = [];
10
+ this.listeners = [];
11
+ }
12
+ add(event) {
13
+ this.events.push(event);
14
+ this.listeners.forEach((l) => l(this.events));
15
+ }
16
+ getEvents() {
17
+ return this.events;
18
+ }
19
+ subscribe(listener) {
20
+ this.listeners.push(listener);
21
+ return () => {
22
+ this.listeners = this.listeners.filter((l) => l !== listener);
23
+ };
24
+ }
25
+ }
26
+ exports.debugEventStore = new DebugEventStore();
@@ -0,0 +1,6 @@
1
+ import { Middleware } from 'redux';
2
+ /**
3
+ * Redux middleware that records ACTION_DISPATCHED before the action is processed
4
+ * and STATE_CHANGED after reducers have run.
5
+ */
6
+ export declare const reduxDebuggerMiddleware: Middleware;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.reduxDebuggerMiddleware = void 0;
4
+ const eventStore_1 = require("./eventStore");
5
+ /**
6
+ * Redux middleware that records ACTION_DISPATCHED before the action is processed
7
+ * and STATE_CHANGED after reducers have run.
8
+ */
9
+ const reduxDebuggerMiddleware = (store) => (next) => (action) => {
10
+ void store;
11
+ eventStore_1.debugEventStore.add({
12
+ type: 'ACTION_DISPATCHED',
13
+ actionType: action.type,
14
+ payload: action.payload,
15
+ timestamp: Date.now(),
16
+ });
17
+ const result = next(action);
18
+ eventStore_1.debugEventStore.add({
19
+ type: 'STATE_CHANGED',
20
+ actionType: action.type,
21
+ timestamp: Date.now(),
22
+ });
23
+ return result;
24
+ };
25
+ exports.reduxDebuggerMiddleware = reduxDebuggerMiddleware;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Debug event types for the Redux + RxJS Time Machine Debugger.
3
+ * Every action, epic emission, and reducer change leaves a breadcrumb in the timeline.
4
+ */
5
+ export type DebugEvent = {
6
+ actionType: string;
7
+ timestamp: number;
8
+ type: 'ACTION_DISPATCHED';
9
+ payload?: unknown;
10
+ } | {
11
+ actionType: string;
12
+ epicName: string;
13
+ timestamp: number;
14
+ type: 'EPIC_TRIGGERED';
15
+ } | {
16
+ actionType: string;
17
+ epicName: string;
18
+ timestamp: number;
19
+ type: 'EPIC_EMIT';
20
+ } | {
21
+ actionType: string;
22
+ timestamp: number;
23
+ type: 'STATE_CHANGED';
24
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,7 @@
1
+ import { Action } from 'redux';
2
+ import { Epic } from 'redux-observable';
3
+ /**
4
+ * Wraps a root epic so that every action emitted by the epic is recorded as EPIC_EMIT.
5
+ * Used to instrument the combined epic tree without modifying individual epics.
6
+ */
7
+ export declare function wrapRootEpic<T extends Action, O extends T, S, D>(epic: Epic<T, O, S, D>, epicName?: string): Epic<T, O, S, D>;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.wrapRootEpic = wrapRootEpic;
4
+ const operators_1 = require("rxjs/operators");
5
+ const eventStore_1 = require("./eventStore");
6
+ /**
7
+ * Wraps a root epic so that every action emitted by the epic is recorded as EPIC_EMIT.
8
+ * Used to instrument the combined epic tree without modifying individual epics.
9
+ */
10
+ function wrapRootEpic(epic, epicName = 'root') {
11
+ return (action$, state$, dependencies) => epic(action$, state$, dependencies).pipe((0, operators_1.tap)((action) => {
12
+ eventStore_1.debugEventStore.add({
13
+ type: 'EPIC_EMIT',
14
+ epicName,
15
+ actionType: action.type,
16
+ timestamp: Date.now(),
17
+ });
18
+ }));
19
+ }
@@ -2,6 +2,8 @@ import { composeWithDevTools } from '@redux-devtools/extension';
2
2
  import { applyMiddleware, compose, createStore } from 'redux';
3
3
  import { createEpicMiddleware } from 'redux-observable';
4
4
  import coreRootEpic from './coreEpics';
5
+ import { reduxDebuggerMiddleware } from './debugger/reduxDebuggerMiddleware';
6
+ import { wrapRootEpic } from './debugger/wrapRootEpic';
5
7
  import { createEpicManager } from './epicManager';
6
8
  import rootReducer from './reducer';
7
9
  let storeEpicManager;
@@ -25,14 +27,14 @@ export default function configureNewStore(zeniAPI, includeReduxDevTools = false)
25
27
  //
26
28
  // Reducer code is lightweight (just createSlice definitions). The heavy
27
29
  // code lives in epics (RxJS chains, API calls) which ARE deferred below.
28
- const store = createStore(rootReducer, composeEnhancers(applyMiddleware(epicMiddleware)));
30
+ const store = createStore(rootReducer, composeEnhancers(applyMiddleware(reduxDebuggerMiddleware, epicMiddleware)));
29
31
  // Attach epic manager to store for external access
30
32
  store.epicManager = storeEpicManager;
31
33
  // Start the dynamic root epic (BehaviorSubject + switchMap)
32
34
  epicMiddleware.run(storeEpicManager.rootEpic);
33
35
  // Inject only core epics at startup (24 out of ~526)
34
36
  // Feature epics are loaded lazily via injectFeatureModules()
35
- storeEpicManager.setEpic(coreRootEpic);
37
+ storeEpicManager.setEpic(wrapRootEpic(coreRootEpic));
36
38
  return store;
37
39
  }
38
40
  /**
@@ -64,7 +66,7 @@ export function injectFeatureModules() {
64
66
  return _featureModulesPromise;
65
67
  }
66
68
  _featureModulesPromise = import('./epic').then((epicModule) => {
67
- storeEpicManager.setEpic(epicModule.default);
69
+ storeEpicManager.setEpic(wrapRootEpic(epicModule.default));
68
70
  });
69
71
  return _featureModulesPromise;
70
72
  }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * In-memory store for debug events. Subscribers are notified whenever a new event is added.
3
+ */
4
+ class DebugEventStore {
5
+ constructor() {
6
+ this.events = [];
7
+ this.listeners = [];
8
+ }
9
+ add(event) {
10
+ this.events.push(event);
11
+ this.listeners.forEach((l) => l(this.events));
12
+ }
13
+ getEvents() {
14
+ return this.events;
15
+ }
16
+ subscribe(listener) {
17
+ this.listeners.push(listener);
18
+ return () => {
19
+ this.listeners = this.listeners.filter((l) => l !== listener);
20
+ };
21
+ }
22
+ }
23
+ export const debugEventStore = new DebugEventStore();
@@ -0,0 +1,21 @@
1
+ import { debugEventStore } from './eventStore';
2
+ /**
3
+ * Redux middleware that records ACTION_DISPATCHED before the action is processed
4
+ * and STATE_CHANGED after reducers have run.
5
+ */
6
+ export const reduxDebuggerMiddleware = (store) => (next) => (action) => {
7
+ void store;
8
+ debugEventStore.add({
9
+ type: 'ACTION_DISPATCHED',
10
+ actionType: action.type,
11
+ payload: action.payload,
12
+ timestamp: Date.now(),
13
+ });
14
+ const result = next(action);
15
+ debugEventStore.add({
16
+ type: 'STATE_CHANGED',
17
+ actionType: action.type,
18
+ timestamp: Date.now(),
19
+ });
20
+ return result;
21
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,16 @@
1
+ import { tap } from 'rxjs/operators';
2
+ import { debugEventStore } from './eventStore';
3
+ /**
4
+ * Wraps a root epic so that every action emitted by the epic is recorded as EPIC_EMIT.
5
+ * Used to instrument the combined epic tree without modifying individual epics.
6
+ */
7
+ export function wrapRootEpic(epic, epicName = 'root') {
8
+ return (action$, state$, dependencies) => epic(action$, state$, dependencies).pipe(tap((action) => {
9
+ debugEventStore.add({
10
+ type: 'EPIC_EMIT',
11
+ epicName,
12
+ actionType: action.type,
13
+ timestamp: Date.now(),
14
+ });
15
+ }));
16
+ }
package/lib/esm/index.js CHANGED
@@ -404,6 +404,7 @@ import { Dayjs, date, dateFromYearMonthDate, dateInLocal, dateLocal, dateNow, ge
404
404
  import { toZeniUrl, toZeniUrlWithoutBaseURL } from './zeniUrl';
405
405
  export { saveJeAccountSettings, saveJeAccountSettingsLocalData };
406
406
  export default initialize;
407
+ export { debugEventStore } from './debugger/eventStore';
407
408
  export { initializePusher, disconnectPusher, Dayjs, dateInLocal as zeniDateInLocal, date as zeniDate, dateLocal, dateNow, getBusinessDayOfDate, formatZeniDateFY as formatZeniDate, getFYMonths, getFYQuarterAndYear, getStartOfAndEndOfTimeframeForFY, getActualPeriodOfFYQtr, getActualPeriodOfFY, getLocalTimezone, addPeriod, subtractPeriod, setLocalTimezone, updateZeniDateLocaleID, toZeniUrl, toZeniUrlWithoutBaseURL, updateZeniAPIClientConfig, zeniAPIClientConfig, injectFeatureEpics, injectFeatureModules, initializeWithNewStore, getTimeframeTickTag, isIncompleteMonthPresentInTimeframeTick, getLastMonthOfFYQuarter, getLastMonthOfFYYear, getMonthIndex, dateFromYearMonthDate, getMinDate, };
408
409
  export { toAmount };
409
410
  export { toReportID, toReportFormatStrict, isCashFlowOrBalanceSheetReport, isDashboardReport, isDashboardClassesViewReport, isPAndLReport, isPAndLClassesViewReport, isAgingReport, isOpExByVendorReport, isFluxAnalysisOpExReport, };
@@ -33,6 +33,7 @@ export const saveReconciliationReviewEpic = (actions$, state$, zeniAPI) => actio
33
33
  reconciliation_id: reconciliationId ?? '',
34
34
  ref_account_id: selectedAccountId,
35
35
  ref_account_name: reconciliationData?.account.accountName,
36
+ ref_account_type: reconciliationData?.account.accountType,
36
37
  };
37
38
  let payload = {};
38
39
  if (reconciliationData != null &&
package/lib/index.d.ts CHANGED
@@ -599,6 +599,8 @@ import { ZeniUrl, toZeniUrl, toZeniUrlWithoutBaseURL } from './zeniUrl';
599
599
  export { AccountSettingsLocalData };
600
600
  export { saveJeAccountSettings, saveJeAccountSettingsLocalData };
601
601
  export default initialize;
602
+ export { debugEventStore } from './debugger/eventStore';
603
+ export type { DebugEvent } from './debugger/types';
602
604
  export { initializePusher, disconnectPusher, Dayjs, ZeniDate, dateInLocal as zeniDateInLocal, date as zeniDate, dateLocal, dateNow, getBusinessDayOfDate, formatZeniDateFY as formatZeniDate, getFYMonths, getFYQuarterAndYear, getStartOfAndEndOfTimeframeForFY, getActualPeriodOfFYQtr, getActualPeriodOfFY, getLocalTimezone, addPeriod, subtractPeriod, setLocalTimezone, updateZeniDateLocaleID, ZeniUrl, toZeniUrl, toZeniUrlWithoutBaseURL, RESTAPIEndpoints, RootState, updateZeniAPIClientConfig, zeniAPIClientConfig, injectFeatureEpics, injectFeatureModules, initializeWithNewStore, ZeniStore, ZeniAPIStatus, getTimeframeTickTag, TimeFrameTickTag, isIncompleteMonthPresentInTimeframeTick, getLastMonthOfFYQuarter, getLastMonthOfFYYear, getMonthIndex, dateFromYearMonthDate, getMinDate, ExternalAPIEndpoints, };
603
605
  export { ID, FetchState, FetchStateAndError, FetchedState, UpdateType, Mode, AccountViewMode, CompletionStatusType, };
604
606
  export { Amount, toAmount, Currency };