@jmruthers/pace-core 0.6.4 → 0.6.5
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/dist/{DataTable-E7YQZD7D.js → DataTable-AOVNCPTX.js} +8 -8
- package/dist/{PublicPageProvider-DEMpysFR.d.ts → PublicPageProvider-QTFVrL-Z.d.ts} +65 -83
- package/dist/{UnifiedAuthProvider-QPXO24B4.js → UnifiedAuthProvider-4SBX4LU5.js} +4 -4
- package/dist/{api-6LVZTHDS.js → api-O6HTBX5Y.js} +3 -3
- package/dist/{chunk-I6DAQMWX.js → chunk-6COVEUS7.js} +130 -106
- package/dist/chunk-6COVEUS7.js.map +1 -0
- package/dist/{chunk-36LVWXB2.js → chunk-AFVQODI2.js} +37 -1
- package/dist/{chunk-36LVWXB2.js.map → chunk-AFVQODI2.js.map} +1 -1
- package/dist/{chunk-3LPHPB62.js → chunk-EFN2EIMK.js} +2 -2
- package/dist/{chunk-ATKZM7RX.js → chunk-G7QEZTYQ.js} +31 -31
- package/dist/{chunk-ATKZM7RX.js.map → chunk-G7QEZTYQ.js.map} +1 -1
- package/dist/{chunk-NN6WWZ5U.js → chunk-HU2C6SSC.js} +29 -18
- package/dist/chunk-HU2C6SSC.js.map +1 -0
- package/dist/{chunk-AVMLPIM7.js → chunk-IHB5DR3H.js} +102 -51
- package/dist/chunk-IHB5DR3H.js.map +1 -0
- package/dist/{chunk-7JPAB3T5.js → chunk-IVOFDYWT.js} +364 -208
- package/dist/chunk-IVOFDYWT.js.map +1 -0
- package/dist/{chunk-6SOIHG6Z.js → chunk-JGRYX5UX.js} +120 -20
- package/dist/chunk-JGRYX5UX.js.map +1 -0
- package/dist/{chunk-OEWDTMG7.js → chunk-NTM7ZSB6.js} +4 -4
- package/dist/chunk-NTM7ZSB6.js.map +1 -0
- package/dist/{chunk-5EC5MEWX.js → chunk-RGAWHO7N.js} +4 -4
- package/dist/chunk-RGAWHO7N.js.map +1 -0
- package/dist/{chunk-YKRAFF5K.js → chunk-UPPMRMYG.js} +3 -3
- package/dist/{chunk-YKRAFF5K.js.map → chunk-UPPMRMYG.js.map} +1 -1
- package/dist/components.d.ts +2 -3
- package/dist/components.js +24 -28
- package/dist/components.js.map +1 -1
- package/dist/{contextValidator-OOPCLPZW.js → contextValidator-5OGXSPKS.js} +2 -2
- package/dist/hooks.d.ts +3 -3
- package/dist/hooks.js +41 -139
- package/dist/hooks.js.map +1 -1
- package/dist/index.d.ts +27 -18
- package/dist/index.js +41 -50
- package/dist/index.js.map +1 -1
- package/dist/providers.js +3 -3
- package/dist/rbac/index.d.ts +16 -9
- package/dist/rbac/index.js +6 -6
- package/dist/{usePublicRouteParams-i3qtoBgg.d.ts → usePublicRouteParams-ClnV4tnv.d.ts} +8 -8
- package/dist/utils.js +1 -1
- package/docs/api/modules.md +210 -100
- package/package.json +1 -2
- package/scripts/validate-master.js +1 -1
- package/src/components/DataTable/__tests__/keyboard.test.tsx +15 -2
- package/src/components/DataTable/components/ImportModal.tsx +4 -6
- package/src/components/DataTable/components/ViewRowModal.tsx +4 -4
- package/src/components/DataTable/components/__tests__/ImportModal.test.tsx +455 -96
- package/src/components/DataTable/components/__tests__/ViewRowModal.test.tsx +122 -58
- package/src/components/DataTable/core/DataTableContext.tsx +1 -1
- package/src/components/DateTimeField/DateTimeField.tsx +17 -19
- package/src/components/DateTimeField/README.md +5 -2
- package/src/components/Dialog/Dialog.test.tsx +248 -228
- package/src/components/Dialog/Dialog.tsx +455 -325
- package/src/components/Dialog/index.ts +3 -3
- package/src/components/FileDisplay/FileDisplay.test.tsx +41 -0
- package/src/components/FileDisplay/FileDisplay.tsx +5 -5
- package/src/components/Form/Form.test.tsx +3 -2
- package/src/components/Form/Form.tsx +4 -5
- package/src/components/InactivityWarningModal/InactivityWarningModal.test.tsx +28 -28
- package/src/components/InactivityWarningModal/InactivityWarningModal.tsx +40 -54
- package/src/components/LoginForm/LoginForm.tsx +2 -2
- package/src/components/NavigationMenu/NavigationMenu.tsx +2 -2
- package/src/components/PaceAppLayout/PaceAppLayout.tsx +32 -39
- package/src/components/PaceAppLayout/README.md +10 -9
- package/src/components/PaceAppLayout/test-setup.tsx +40 -31
- package/src/components/PasswordChange/PasswordChangeForm.test.tsx +61 -0
- package/src/components/PasswordChange/PasswordChangeForm.tsx +20 -13
- package/src/components/PublicLayout/PublicLayout.test.tsx +7 -3
- package/src/components/PublicLayout/PublicPageLayout.tsx +5 -8
- package/src/components/UserMenu/UserMenu.test.tsx +38 -6
- package/src/components/UserMenu/UserMenu.tsx +36 -34
- package/src/components/index.ts +3 -4
- package/src/hooks/useEventTheme.ts +4 -4
- package/src/hooks/useEvents.ts +11 -7
- package/src/hooks/useKeyboardShortcuts.ts +1 -1
- package/src/hooks/useOrganisationPermissions.ts +4 -4
- package/src/hooks/useOrganisations.ts +13 -7
- package/src/index.ts +11 -1
- package/src/rbac/README.md +20 -20
- package/src/rbac/hooks/useRBAC.test.ts +21 -3
- package/src/rbac/hooks/useRBAC.ts +4 -3
- package/src/rbac/hooks/useResourcePermissions.test.ts +125 -30
- package/src/rbac/hooks/useResourcePermissions.ts +57 -29
- package/src/rbac/permissions.ts +17 -17
- package/src/rbac/utils/contextValidator.ts +36 -0
- package/src/services/AuthService.ts +2 -5
- package/src/services/InactivityService.ts +139 -58
- package/src/styles/core.css +4 -0
- package/src/utils/formatting/formatTime.test.ts +3 -2
- package/dist/chunk-5EC5MEWX.js.map +0 -1
- package/dist/chunk-6SOIHG6Z.js.map +0 -1
- package/dist/chunk-7JPAB3T5.js.map +0 -1
- package/dist/chunk-AVMLPIM7.js.map +0 -1
- package/dist/chunk-I6DAQMWX.js.map +0 -1
- package/dist/chunk-NN6WWZ5U.js.map +0 -1
- package/dist/chunk-OEWDTMG7.js.map +0 -1
- /package/dist/{DataTable-E7YQZD7D.js.map → DataTable-AOVNCPTX.js.map} +0 -0
- /package/dist/{UnifiedAuthProvider-QPXO24B4.js.map → UnifiedAuthProvider-4SBX4LU5.js.map} +0 -0
- /package/dist/{api-6LVZTHDS.js.map → api-O6HTBX5Y.js.map} +0 -0
- /package/dist/{chunk-3LPHPB62.js.map → chunk-EFN2EIMK.js.map} +0 -0
- /package/dist/{contextValidator-OOPCLPZW.js.map → contextValidator-5OGXSPKS.js.map} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isRBACInitialized,
|
|
3
3
|
setupRBAC
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-EFN2EIMK.js";
|
|
5
5
|
import {
|
|
6
6
|
assertOrganisationId,
|
|
7
7
|
assertUserId
|
|
@@ -126,11 +126,6 @@ var _AuthService = class _AuthService extends BaseService {
|
|
|
126
126
|
}
|
|
127
127
|
// Auth state getters
|
|
128
128
|
getUser() {
|
|
129
|
-
if (this.user) {
|
|
130
|
-
logger.debug("AuthService", `getUser() [ID:${this.instanceId}] returning user: ${this.user.id}`);
|
|
131
|
-
} else {
|
|
132
|
-
logger.debug("AuthService", `getUser() [ID:${this.instanceId}] returning null`);
|
|
133
|
-
}
|
|
134
129
|
return this.user;
|
|
135
130
|
}
|
|
136
131
|
getSession() {
|
|
@@ -1016,7 +1011,7 @@ var _OrganisationService = class _OrganisationService extends BaseService {
|
|
|
1016
1011
|
let userIsSuperAdmin = false;
|
|
1017
1012
|
if (this.user?.id) {
|
|
1018
1013
|
try {
|
|
1019
|
-
const { isSuperAdmin: checkSuperAdmin, isRBACInitialized: isRBACInitialized2, setupRBAC: setupRBAC2 } = await import("./api-
|
|
1014
|
+
const { isSuperAdmin: checkSuperAdmin, isRBACInitialized: isRBACInitialized2, setupRBAC: setupRBAC2 } = await import("./api-O6HTBX5Y.js");
|
|
1020
1015
|
if (!isRBACInitialized2() && this.supabaseClient) {
|
|
1021
1016
|
setupRBAC2(this.supabaseClient);
|
|
1022
1017
|
}
|
|
@@ -1291,7 +1286,7 @@ var _EventService = class _EventService extends BaseService {
|
|
|
1291
1286
|
this.setSelectedEventId = setSelectedEventId;
|
|
1292
1287
|
if (user?.id) {
|
|
1293
1288
|
try {
|
|
1294
|
-
const { isRBACInitialized: isRBACInitialized2, isSuperAdmin: checkSuperAdmin, setupRBAC: setupRBAC2 } = await import("./api-
|
|
1289
|
+
const { isRBACInitialized: isRBACInitialized2, isSuperAdmin: checkSuperAdmin, setupRBAC: setupRBAC2 } = await import("./api-O6HTBX5Y.js");
|
|
1295
1290
|
if (!isRBACInitialized2() && this.supabaseClient) {
|
|
1296
1291
|
setupRBAC2(this.supabaseClient);
|
|
1297
1292
|
}
|
|
@@ -1533,7 +1528,7 @@ var _EventService = class _EventService extends BaseService {
|
|
|
1533
1528
|
let organisationIdForRpc = null;
|
|
1534
1529
|
let userIsSuperAdmin = this.isSuperAdmin;
|
|
1535
1530
|
try {
|
|
1536
|
-
const { isRBACInitialized: isRBACInitialized2, isSuperAdmin: checkSuperAdmin, setupRBAC: setupRBAC2 } = await import("./api-
|
|
1531
|
+
const { isRBACInitialized: isRBACInitialized2, isSuperAdmin: checkSuperAdmin, setupRBAC: setupRBAC2 } = await import("./api-O6HTBX5Y.js");
|
|
1537
1532
|
if (!isRBACInitialized2() && this.supabaseClient) {
|
|
1538
1533
|
setupRBAC2(this.supabaseClient);
|
|
1539
1534
|
}
|
|
@@ -2070,27 +2065,34 @@ var InactivityService = class extends BaseService {
|
|
|
2070
2065
|
}
|
|
2071
2066
|
setupEventHandlers() {
|
|
2072
2067
|
if (typeof window === "undefined") return;
|
|
2073
|
-
let idleTimer = null;
|
|
2074
2068
|
let warningTimer = null;
|
|
2069
|
+
let logoutTimer = null;
|
|
2070
|
+
let countdownInterval = null;
|
|
2075
2071
|
let lastActivity = Date.now();
|
|
2076
|
-
let pollInterval = null;
|
|
2077
2072
|
let prevIsIdle = false;
|
|
2078
2073
|
let prevShowWarning = false;
|
|
2079
2074
|
let prevShowInactivityWarning = false;
|
|
2080
2075
|
let prevInactivityTimeRemaining = 0;
|
|
2081
2076
|
let prevTimeRemaining = this.idleTimeoutMs;
|
|
2082
|
-
const
|
|
2077
|
+
const getTimeUntilWarning = () => {
|
|
2078
|
+
const timeSinceActivity = Date.now() - lastActivity;
|
|
2079
|
+
return Math.max(0, this.idleTimeoutMs - this.warnBeforeMs - timeSinceActivity);
|
|
2080
|
+
};
|
|
2081
|
+
const getTimeUntilLogout = () => {
|
|
2082
|
+
const timeSinceActivity = Date.now() - lastActivity;
|
|
2083
|
+
return Math.max(0, this.idleTimeoutMs - timeSinceActivity);
|
|
2084
|
+
};
|
|
2085
|
+
const updateState = (forceNotify = false) => {
|
|
2083
2086
|
const now = Date.now();
|
|
2084
2087
|
const timeSinceActivity = now - lastActivity;
|
|
2085
2088
|
const timeUntilIdle = this.idleTimeoutMs - timeSinceActivity;
|
|
2086
|
-
const
|
|
2087
|
-
const
|
|
2088
|
-
const newShowWarning = newIsIdle && timeSinceActivity < this.idleTimeoutMs;
|
|
2089
|
+
const newIsIdle = timeSinceActivity >= this.idleTimeoutMs;
|
|
2090
|
+
const newShowWarning = timeSinceActivity >= this.idleTimeoutMs - this.warnBeforeMs && !newIsIdle;
|
|
2089
2091
|
const newShowInactivityWarning = newShowWarning;
|
|
2090
|
-
const newInactivityTimeRemaining = newShowWarning ? Math.ceil(
|
|
2092
|
+
const newInactivityTimeRemaining = newShowWarning ? Math.ceil(timeUntilIdle / 1e3) : 0;
|
|
2091
2093
|
const newTimeRemaining = Math.max(0, timeUntilIdle);
|
|
2092
|
-
const stateChanged = prevIsIdle !== newIsIdle || prevShowWarning !== newShowWarning || prevShowInactivityWarning !== newShowInactivityWarning || prevInactivityTimeRemaining !== newInactivityTimeRemaining || prevTimeRemaining !== newTimeRemaining;
|
|
2093
|
-
if (stateChanged) {
|
|
2094
|
+
const stateChanged = prevIsIdle !== newIsIdle || prevShowWarning !== newShowWarning || prevShowInactivityWarning !== newShowInactivityWarning || newShowWarning && prevInactivityTimeRemaining !== newInactivityTimeRemaining || prevTimeRemaining !== newTimeRemaining;
|
|
2095
|
+
if (stateChanged || forceNotify) {
|
|
2094
2096
|
this._isIdle = newIsIdle;
|
|
2095
2097
|
this._showWarning = newShowWarning;
|
|
2096
2098
|
this._showInactivityWarning = newShowInactivityWarning;
|
|
@@ -2101,73 +2103,123 @@ var InactivityService = class extends BaseService {
|
|
|
2101
2103
|
prevShowInactivityWarning = newShowInactivityWarning;
|
|
2102
2104
|
prevInactivityTimeRemaining = newInactivityTimeRemaining;
|
|
2103
2105
|
prevTimeRemaining = newTimeRemaining;
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
+
if (stateChanged) {
|
|
2107
|
+
this.notify();
|
|
2108
|
+
}
|
|
2109
|
+
if (newIsIdle) {
|
|
2106
2110
|
this.handleIdleLogout();
|
|
2107
2111
|
}
|
|
2108
2112
|
}
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
idleTimer = null;
|
|
2112
|
-
}
|
|
2113
|
+
};
|
|
2114
|
+
const scheduleNextCheck = () => {
|
|
2113
2115
|
if (warningTimer) {
|
|
2114
2116
|
clearTimeout(warningTimer);
|
|
2115
2117
|
warningTimer = null;
|
|
2116
2118
|
}
|
|
2117
|
-
if (
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2119
|
+
if (logoutTimer) {
|
|
2120
|
+
clearTimeout(logoutTimer);
|
|
2121
|
+
logoutTimer = null;
|
|
2122
|
+
}
|
|
2123
|
+
if (countdownInterval) {
|
|
2124
|
+
clearInterval(countdownInterval);
|
|
2125
|
+
countdownInterval = null;
|
|
2126
|
+
}
|
|
2127
|
+
const timeUntilWarning = getTimeUntilWarning();
|
|
2128
|
+
const timeUntilLogout = getTimeUntilLogout();
|
|
2129
|
+
const timeSinceActivity = Date.now() - lastActivity;
|
|
2130
|
+
if (timeSinceActivity >= this.idleTimeoutMs) {
|
|
2131
|
+
return;
|
|
2132
|
+
}
|
|
2133
|
+
if (timeSinceActivity >= this.idleTimeoutMs - this.warnBeforeMs) {
|
|
2134
|
+
updateState();
|
|
2135
|
+
countdownInterval = setInterval(() => {
|
|
2136
|
+
updateState();
|
|
2137
|
+
if (Date.now() - lastActivity >= this.idleTimeoutMs) {
|
|
2138
|
+
if (countdownInterval) {
|
|
2139
|
+
clearInterval(countdownInterval);
|
|
2140
|
+
countdownInterval = null;
|
|
2141
|
+
}
|
|
2142
|
+
this.handleIdleLogout();
|
|
2143
|
+
}
|
|
2144
|
+
}, 1e3);
|
|
2145
|
+
logoutTimer = setTimeout(() => {
|
|
2146
|
+
if (countdownInterval) {
|
|
2147
|
+
clearInterval(countdownInterval);
|
|
2148
|
+
countdownInterval = null;
|
|
2149
|
+
}
|
|
2124
2150
|
this.handleIdleLogout();
|
|
2125
|
-
},
|
|
2151
|
+
}, timeUntilLogout);
|
|
2152
|
+
} else {
|
|
2153
|
+
const timeUntilWarningMs = timeUntilWarning;
|
|
2154
|
+
const adaptiveInterval = timeUntilWarningMs > 5 * 60 * 1e3 ? 60 * 1e3 : timeUntilWarningMs > 60 * 1e3 ? 10 * 1e3 : 1e3;
|
|
2155
|
+
warningTimer = setTimeout(() => {
|
|
2156
|
+
updateState();
|
|
2157
|
+
scheduleNextCheck();
|
|
2158
|
+
}, Math.min(adaptiveInterval, timeUntilWarningMs));
|
|
2126
2159
|
}
|
|
2127
2160
|
};
|
|
2128
2161
|
const resetTimers = () => {
|
|
2129
2162
|
lastActivity = Date.now();
|
|
2130
|
-
if (idleTimer) {
|
|
2131
|
-
clearTimeout(idleTimer);
|
|
2132
|
-
idleTimer = null;
|
|
2133
|
-
}
|
|
2134
2163
|
if (warningTimer) {
|
|
2135
2164
|
clearTimeout(warningTimer);
|
|
2136
2165
|
warningTimer = null;
|
|
2137
2166
|
}
|
|
2167
|
+
if (logoutTimer) {
|
|
2168
|
+
clearTimeout(logoutTimer);
|
|
2169
|
+
logoutTimer = null;
|
|
2170
|
+
}
|
|
2171
|
+
if (countdownInterval) {
|
|
2172
|
+
clearInterval(countdownInterval);
|
|
2173
|
+
countdownInterval = null;
|
|
2174
|
+
}
|
|
2175
|
+
const hadWarning = this._showWarning || this._showInactivityWarning;
|
|
2138
2176
|
this._showInactivityWarning = false;
|
|
2139
2177
|
this._inactivityTimeRemaining = 0;
|
|
2140
2178
|
this._isIdle = false;
|
|
2141
2179
|
this._showWarning = false;
|
|
2180
|
+
this._timeRemaining = this.idleTimeoutMs;
|
|
2142
2181
|
prevIsIdle = false;
|
|
2143
2182
|
prevShowWarning = false;
|
|
2144
2183
|
prevShowInactivityWarning = false;
|
|
2145
2184
|
prevInactivityTimeRemaining = 0;
|
|
2146
2185
|
prevTimeRemaining = this.idleTimeoutMs;
|
|
2186
|
+
if (hadWarning) {
|
|
2187
|
+
this.notify();
|
|
2188
|
+
}
|
|
2189
|
+
scheduleNextCheck();
|
|
2147
2190
|
};
|
|
2148
2191
|
const activityEvents = ["mousedown", "mousemove", "keypress", "scroll", "touchstart", "click"];
|
|
2192
|
+
let activityThrottleTimer = null;
|
|
2149
2193
|
const handleActivity = () => {
|
|
2150
|
-
|
|
2194
|
+
if (activityThrottleTimer) {
|
|
2195
|
+
return;
|
|
2196
|
+
}
|
|
2197
|
+
activityThrottleTimer = setTimeout(() => {
|
|
2198
|
+
activityThrottleTimer = null;
|
|
2199
|
+
resetTimers();
|
|
2200
|
+
}, 1e3);
|
|
2151
2201
|
};
|
|
2152
2202
|
activityEvents.forEach((event) => {
|
|
2153
2203
|
document.addEventListener(event, handleActivity, true);
|
|
2154
2204
|
});
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
}, 1e4);
|
|
2158
|
-
pollInactivityState();
|
|
2205
|
+
updateState(true);
|
|
2206
|
+
scheduleNextCheck();
|
|
2159
2207
|
this.cleanupHandlers = () => {
|
|
2160
|
-
if (idleTimer) {
|
|
2161
|
-
clearTimeout(idleTimer);
|
|
2162
|
-
idleTimer = null;
|
|
2163
|
-
}
|
|
2164
2208
|
if (warningTimer) {
|
|
2165
2209
|
clearTimeout(warningTimer);
|
|
2166
2210
|
warningTimer = null;
|
|
2167
2211
|
}
|
|
2168
|
-
if (
|
|
2169
|
-
|
|
2170
|
-
|
|
2212
|
+
if (logoutTimer) {
|
|
2213
|
+
clearTimeout(logoutTimer);
|
|
2214
|
+
logoutTimer = null;
|
|
2215
|
+
}
|
|
2216
|
+
if (countdownInterval) {
|
|
2217
|
+
clearInterval(countdownInterval);
|
|
2218
|
+
countdownInterval = null;
|
|
2219
|
+
}
|
|
2220
|
+
if (activityThrottleTimer) {
|
|
2221
|
+
clearTimeout(activityThrottleTimer);
|
|
2222
|
+
activityThrottleTimer = null;
|
|
2171
2223
|
}
|
|
2172
2224
|
activityEvents.forEach((event) => {
|
|
2173
2225
|
document.removeEventListener(event, handleActivity, true);
|
|
@@ -2180,7 +2232,6 @@ var InactivityService = class extends BaseService {
|
|
|
2180
2232
|
this._inactivityTimeRemaining = 0;
|
|
2181
2233
|
};
|
|
2182
2234
|
this._isTracking = true;
|
|
2183
|
-
this.notify();
|
|
2184
2235
|
}
|
|
2185
2236
|
};
|
|
2186
2237
|
|
|
@@ -2494,7 +2545,7 @@ function UnifiedAuthContextProvider({
|
|
|
2494
2545
|
resolvedUserIdRef.current = currentUserId;
|
|
2495
2546
|
const userId = currentUserId;
|
|
2496
2547
|
const appNameValue = appName;
|
|
2497
|
-
import("./api-
|
|
2548
|
+
import("./api-O6HTBX5Y.js").then(async ({ resolveAppContext, setupRBAC: setupRBAC2 }) => {
|
|
2498
2549
|
try {
|
|
2499
2550
|
setupRBAC2(supabase);
|
|
2500
2551
|
const result = await resolveAppContext({
|
|
@@ -2961,4 +3012,4 @@ export {
|
|
|
2961
3012
|
useUnifiedAuth,
|
|
2962
3013
|
UnifiedAuthProvider
|
|
2963
3014
|
};
|
|
2964
|
-
//# sourceMappingURL=chunk-
|
|
3015
|
+
//# sourceMappingURL=chunk-IHB5DR3H.js.map
|