@zeniai/client-epic-state 5.0.3-beta0ND → 5.0.3-betaND3

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 (41) hide show
  1. package/lib/coreEpics.js +1 -2
  2. package/lib/entity/task/taskPayload.d.ts +1 -0
  3. package/lib/entity/task/taskPayload.js +46 -39
  4. package/lib/entity/task/taskState.d.ts +2 -0
  5. package/lib/entity/tenant/tenantReducer.d.ts +1 -5
  6. package/lib/entity/tenant/tenantReducer.js +2 -23
  7. package/lib/entity/tenant/tenantState.d.ts +0 -1
  8. package/lib/esm/coreEpics.js +1 -2
  9. package/lib/esm/entity/task/taskPayload.js +46 -39
  10. package/lib/esm/entity/tenant/tenantReducer.js +1 -21
  11. package/lib/esm/index.js +2 -5
  12. package/lib/esm/view/taskManager/taskListView/epics/bulkUpdateTaskListEpic.js +4 -0
  13. package/lib/esm/view/taskManager/taskListView/epics/fetchTaskListEpic.js +6 -3
  14. package/lib/esm/view/taskManager/taskListView/epics/updateTaskFromListViewEpic.js +6 -2
  15. package/lib/esm/view/taskManager/taskListView/taskListPayload.js +5 -1
  16. package/lib/esm/view/taskManager/taskListView/taskListReducer.js +11 -0
  17. package/lib/esm/view/taskManager/taskListView/taskListSelector.js +27 -4
  18. package/lib/index.d.ts +2 -5
  19. package/lib/index.js +30 -36
  20. package/lib/tsconfig.typecheck.tsbuildinfo +1 -1
  21. package/lib/view/taskManager/taskListView/epics/bulkUpdateTaskListEpic.d.ts +2 -0
  22. package/lib/view/taskManager/taskListView/epics/bulkUpdateTaskListEpic.js +4 -0
  23. package/lib/view/taskManager/taskListView/epics/fetchTaskListEpic.js +6 -3
  24. package/lib/view/taskManager/taskListView/epics/updateTaskFromListViewEpic.js +6 -2
  25. package/lib/view/taskManager/taskListView/taskList.d.ts +2 -0
  26. package/lib/view/taskManager/taskListView/taskListPayload.d.ts +10 -1
  27. package/lib/view/taskManager/taskListView/taskListPayload.js +7 -0
  28. package/lib/view/taskManager/taskListView/taskListReducer.d.ts +4 -1
  29. package/lib/view/taskManager/taskListView/taskListReducer.js +11 -0
  30. package/lib/view/taskManager/taskListView/taskListSelector.d.ts +4 -1
  31. package/lib/view/taskManager/taskListView/taskListSelector.js +27 -4
  32. package/package.json +1 -1
  33. package/lib/entity/tenant/SessionManager.d.ts +0 -38
  34. package/lib/entity/tenant/SessionManager.js +0 -171
  35. package/lib/entity/tenant/epic/sessionHeartbeatEpic.d.ts +0 -16
  36. package/lib/entity/tenant/epic/sessionHeartbeatEpic.js +0 -16
  37. package/lib/entity/tenant/sessionTypes.d.ts +0 -26
  38. package/lib/entity/tenant/sessionTypes.js +0 -12
  39. package/lib/esm/entity/tenant/SessionManager.js +0 -167
  40. package/lib/esm/entity/tenant/epic/sessionHeartbeatEpic.js +0 -12
  41. package/lib/esm/entity/tenant/sessionTypes.js +0 -9
@@ -1,167 +0,0 @@
1
- /**
2
- * SessionManager — Central session lifecycle manager.
3
- *
4
- * Responsibilities:
5
- * 1. Track user activity (mousemove, keydown, click, scroll, touch)
6
- * 2. Send heartbeat at configurable intervals while user is active
7
- * 3. Show warning popup after idle timeout
8
- * 4. Auto-logout after warning countdown expires
9
- */
10
- import { DEFAULT_SESSION_CONFIG, } from './sessionTypes';
11
- /** Events that indicate user activity. */
12
- const ACTIVITY_EVENTS = [
13
- 'mousemove',
14
- 'mousedown',
15
- 'keydown',
16
- 'scroll',
17
- 'touchstart',
18
- 'click',
19
- ];
20
- /** Debounce interval for activity events (ms). */
21
- const ACTIVITY_DEBOUNCE_MS = 1000;
22
- export class SessionManager {
23
- constructor() {
24
- this.config = DEFAULT_SESSION_CONFIG;
25
- this.callbacks = null;
26
- /** Timestamps and timers */
27
- this.lastActivityTime = 0;
28
- this.idleCheckInterval = null;
29
- this.heartbeatInterval = null;
30
- this.countdownInterval = null;
31
- this.activityDebounceTimer = null;
32
- /** State */
33
- this.running = false;
34
- this.warningActive = false;
35
- this.secondsRemaining = 0;
36
- /** Bound handler for event listener cleanup. */
37
- this.boundOnActivity = this.onActivity.bind(this);
38
- this.boundOnVisibilityChange = this.onVisibilityChange.bind(this);
39
- }
40
- // ─── Public API ────────────────────────────────────────────
41
- start(config = {}, callbacks) {
42
- if (this.running) {
43
- this.stop();
44
- }
45
- this.config = { ...DEFAULT_SESSION_CONFIG, ...config };
46
- this.callbacks = callbacks;
47
- this.running = true;
48
- this.warningActive = false;
49
- this.lastActivityTime = Date.now();
50
- if (!this.config.isAutoLogoutEnabled) {
51
- return;
52
- }
53
- ACTIVITY_EVENTS.forEach((event) => {
54
- document.addEventListener(event, this.boundOnActivity, {
55
- capture: true,
56
- passive: true,
57
- });
58
- });
59
- document.addEventListener('visibilitychange', this.boundOnVisibilityChange);
60
- this.startHeartbeat();
61
- this.callbacks?.onHeartbeat();
62
- this.idleCheckInterval = setInterval(() => this.checkIdle(), 1000);
63
- }
64
- stop() {
65
- this.running = false;
66
- this.warningActive = false;
67
- ACTIVITY_EVENTS.forEach((event) => {
68
- document.removeEventListener(event, this.boundOnActivity, {
69
- capture: true,
70
- });
71
- });
72
- document.removeEventListener('visibilitychange', this.boundOnVisibilityChange);
73
- this.clearTimer('idleCheckInterval');
74
- this.clearTimer('heartbeatInterval');
75
- this.clearTimer('countdownInterval');
76
- this.clearTimer('activityDebounceTimer');
77
- }
78
- continueSession() {
79
- if (!this.running) {
80
- return;
81
- }
82
- this.warningActive = false;
83
- this.secondsRemaining = 0;
84
- this.lastActivityTime = Date.now();
85
- this.clearTimer('countdownInterval');
86
- this.callbacks?.onHeartbeat();
87
- this.callbacks?.onSessionExtended();
88
- this.startHeartbeat();
89
- }
90
- isWarningActive() {
91
- return this.warningActive;
92
- }
93
- getSecondsRemaining() {
94
- return this.secondsRemaining;
95
- }
96
- // ─── Private ───────────────────────────────────────────────
97
- onActivity() {
98
- if (!this.running || this.warningActive) {
99
- return;
100
- }
101
- if (this.activityDebounceTimer != null) {
102
- return;
103
- }
104
- this.lastActivityTime = Date.now();
105
- this.activityDebounceTimer = setTimeout(() => {
106
- this.activityDebounceTimer = null;
107
- }, ACTIVITY_DEBOUNCE_MS);
108
- }
109
- onVisibilityChange() {
110
- if (!this.running) {
111
- return;
112
- }
113
- if (document.visibilityState === 'visible') {
114
- this.lastActivityTime = Date.now();
115
- this.checkIdle();
116
- }
117
- }
118
- checkIdle() {
119
- if (!this.running || this.warningActive) {
120
- return;
121
- }
122
- const idleMs = Date.now() - this.lastActivityTime;
123
- const idleTimeoutMs = this.config.idleTimeoutMinutes * 60 * 1000;
124
- if (idleMs >= idleTimeoutMs) {
125
- this.startWarning();
126
- }
127
- }
128
- startWarning() {
129
- this.warningActive = true;
130
- this.secondsRemaining = this.config.warningDurationSeconds;
131
- this.clearTimer('heartbeatInterval');
132
- this.callbacks?.onWarningStart(this.secondsRemaining);
133
- this.countdownInterval = setInterval(() => {
134
- this.secondsRemaining -= 1;
135
- if (this.secondsRemaining <= 0) {
136
- this.clearTimer('countdownInterval');
137
- this.warningActive = false;
138
- this.callbacks?.onAutoLogout();
139
- }
140
- else {
141
- this.callbacks?.onWarningTick(this.secondsRemaining);
142
- }
143
- }, 1000);
144
- }
145
- startHeartbeat() {
146
- this.clearTimer('heartbeatInterval');
147
- const intervalMs = this.config.heartbeatIntervalMinutes * 60 * 1000;
148
- this.heartbeatInterval = setInterval(() => {
149
- if (!this.running || this.warningActive) {
150
- return;
151
- }
152
- this.callbacks?.onHeartbeat();
153
- }, intervalMs);
154
- }
155
- clearTimer(name) {
156
- const timer = this[name];
157
- if (timer != null) {
158
- if (name === 'activityDebounceTimer') {
159
- clearTimeout(timer);
160
- }
161
- else {
162
- clearInterval(timer);
163
- }
164
- this[name] = null;
165
- }
166
- }
167
- }
@@ -1,12 +0,0 @@
1
- import { of } from 'rxjs';
2
- import { catchError, filter, mergeMap, switchMap } from 'rxjs/operators';
3
- import { createZeniAPIStatus, isSuccessResponse, } from '../../../responsePayload';
4
- import { sendSessionHeartbeat, sessionHeartbeatFailure, sessionHeartbeatSuccess, } from '../tenantReducer';
5
- export const sessionHeartbeatEpic = (actions$, _, zeniAPI) => actions$.pipe(filter(sendSessionHeartbeat.match), switchMap(() => zeniAPI
6
- .postAndGetJSON(`${zeniAPI.apiEndPoints.authMicroServiceBaseUrl}/1.0/sessions/heartbeat`)
7
- .pipe(mergeMap((response) => {
8
- if (isSuccessResponse(response)) {
9
- return of(sessionHeartbeatSuccess(response.data?.expiry ?? ''));
10
- }
11
- return of(sessionHeartbeatFailure(response.status));
12
- }), catchError((error) => of(sessionHeartbeatFailure(createZeniAPIStatus('Heartbeat failed', 'Session heartbeat API call errored: ' + JSON.stringify(error))))))));
@@ -1,9 +0,0 @@
1
- /**
2
- * Session management types for idle timeout and heartbeat.
3
- */
4
- export const DEFAULT_SESSION_CONFIG = {
5
- heartbeatIntervalMinutes: 10,
6
- idleTimeoutMinutes: 30,
7
- isAutoLogoutEnabled: true,
8
- warningDurationSeconds: 60,
9
- };