@goralys/core 1.6.2 → 1.6.4

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/index.d.ts CHANGED
@@ -10,6 +10,7 @@ interface StorageAdapter {
10
10
  getItem(key: string): string | null;
11
11
  getSize(): number;
12
12
  keyAt(ids: number): string | undefined;
13
+ keys(): string[];
13
14
  setItem(key: string, value: string): void;
14
15
  removeItem(key: string): void;
15
16
  }
@@ -18,6 +19,7 @@ declare const storageGet: (key: string) => string | null;
18
19
  declare const storageSet: (key: string, value: string) => void;
19
20
  declare const storageSize: () => number;
20
21
  declare const storageKeyAt: (idx: number) => string | undefined;
22
+ declare const storageKeys: () => string[];
21
23
  declare const storageRemove: (key: string) => void;
22
24
 
23
25
  interface PHPDateTime {
@@ -355,4 +357,4 @@ declare function fetchVirtualUsersClient(): Promise<Response>;
355
357
  declare function fetchAdminsClient(): Promise<Response>;
356
358
  declare function fetchVirtualAdminsClient(): Promise<Response>;
357
359
 
358
- export { ADMIN_CACHE_RADIX, ADMIN_SYNC_RADIX, AUTH_TOKEN_CACHES, AUTH_TOKEN_CACHE_RADIX, AUTH_TOKEN_SYNCS, AUTH_TOKEN_SYNC_RADIX, type AuthEvent, type AuthToken, type AuthTokenContext, COOKIES_DISMISSED_KEY, type CheckAuthImpl, type ConfirmOptions, type CookieValue, type CookiesAdapter, type DraftModalResult, EMAIL_KEY, FLASH_TOAST_KEY, FULL_NAME_KEY, GoralysActionHandler, type GoralysClientConfig, type GoralysFetchOptions, HTTP_METHODS, type HttpMethod, LOGO_PATH, PERSISTANT_COOKIES, PERSISTANT_LOCALS, type PHPDateTime, PUB_ID_KEY, ROLE_KEY, SUBJECT_CACHES, SUBJECT_CACHE_RADIX, SUBJECT_SYNCS, SUBJECT_SYNC_RADIX, SUPPORT_TICKET_CACHE, SUPPORT_TICKET_SYNC, type StorageAdapter, type Subject, type SubjectStatus, SubjectStatusConfig, type SubjectsSearchField, type SupportReasons, type SupportTicket, type Toast, type ToastConfig, type ToastFn, USERNAME_KEY, USER_CACHES, USER_CACHE_RADIX, USER_ROLES, USER_SYNCS, USER_SYNC_RADIX, type UseSyncedResourceOptions, type User, type UserData, type UserEvent, type UserProfile, type UserRole, type UserType, buildApiUrl, buildArray, cacheUserDataClient, configGoralysCore, configureCheckAuth, configureCookies, configureGoralysClient, configureStorage, configureToast, cookiesGet, cookiesGetAll, cookiesOnChange, cookiesRemove, cookiesSet, emitAuthEvent, emitNavigationEvent, emitUserEvent, emptyUserCacheClient, fetchAdminsClient, fetchAuthTokensForContext, fetchCsrfClient, fetchSubjectsForRoleClient, fetchTokensAdminPanel, fetchTokensProfile, fetchUsersClient, fetchVirtualAdminsClient, fetchVirtualUsersClient, fromPhpDate, getGoralysClientConfig, getLongFromShort, getShortFromLong, getStatusHelper, getStatusLabel, getToastConfig, goralysFetchClient, handleToastRequest, helpContent, isAuthenticated, isFoolsDay, isHTTPMethod, onAuthEvent, onNavigationEvent, onUserEvent, parsePhpDateTime, reasonsConfig, searchFields, separateNames, storageGet, storageKeyAt, storageRemove, storageSet, storageSize, useAdmins, useAuthTokens, useSubjects, useSupportTickets, useSyncedResource, useUsers, useVirtualAdmins, useVirtualUsers };
360
+ export { ADMIN_CACHE_RADIX, ADMIN_SYNC_RADIX, AUTH_TOKEN_CACHES, AUTH_TOKEN_CACHE_RADIX, AUTH_TOKEN_SYNCS, AUTH_TOKEN_SYNC_RADIX, type AuthEvent, type AuthToken, type AuthTokenContext, COOKIES_DISMISSED_KEY, type CheckAuthImpl, type ConfirmOptions, type CookieValue, type CookiesAdapter, type DraftModalResult, EMAIL_KEY, FLASH_TOAST_KEY, FULL_NAME_KEY, GoralysActionHandler, type GoralysClientConfig, type GoralysFetchOptions, HTTP_METHODS, type HttpMethod, LOGO_PATH, PERSISTANT_COOKIES, PERSISTANT_LOCALS, type PHPDateTime, PUB_ID_KEY, ROLE_KEY, SUBJECT_CACHES, SUBJECT_CACHE_RADIX, SUBJECT_SYNCS, SUBJECT_SYNC_RADIX, SUPPORT_TICKET_CACHE, SUPPORT_TICKET_SYNC, type StorageAdapter, type Subject, type SubjectStatus, SubjectStatusConfig, type SubjectsSearchField, type SupportReasons, type SupportTicket, type Toast, type ToastConfig, type ToastFn, USERNAME_KEY, USER_CACHES, USER_CACHE_RADIX, USER_ROLES, USER_SYNCS, USER_SYNC_RADIX, type UseSyncedResourceOptions, type User, type UserData, type UserEvent, type UserProfile, type UserRole, type UserType, buildApiUrl, buildArray, cacheUserDataClient, configGoralysCore, configureCheckAuth, configureCookies, configureGoralysClient, configureStorage, configureToast, cookiesGet, cookiesGetAll, cookiesOnChange, cookiesRemove, cookiesSet, emitAuthEvent, emitNavigationEvent, emitUserEvent, emptyUserCacheClient, fetchAdminsClient, fetchAuthTokensForContext, fetchCsrfClient, fetchSubjectsForRoleClient, fetchTokensAdminPanel, fetchTokensProfile, fetchUsersClient, fetchVirtualAdminsClient, fetchVirtualUsersClient, fromPhpDate, getGoralysClientConfig, getLongFromShort, getShortFromLong, getStatusHelper, getStatusLabel, getToastConfig, goralysFetchClient, handleToastRequest, helpContent, isAuthenticated, isFoolsDay, isHTTPMethod, onAuthEvent, onNavigationEvent, onUserEvent, parsePhpDateTime, reasonsConfig, searchFields, separateNames, storageGet, storageKeyAt, storageKeys, storageRemove, storageSet, storageSize, useAdmins, useAuthTokens, useSubjects, useSupportTickets, useSyncedResource, useUsers, useVirtualAdmins, useVirtualUsers };
package/dist/index.js CHANGED
@@ -24,6 +24,7 @@ var storageGet = (key) => getAdapter().getItem(key);
24
24
  var storageSet = (key, value) => getAdapter().setItem(key, value);
25
25
  var storageSize = () => getAdapter().getSize();
26
26
  var storageKeyAt = (idx) => getAdapter().keyAt(idx);
27
+ var storageKeys = () => getAdapter().keys();
27
28
  var storageRemove = (key) => getAdapter().removeItem(key);
28
29
 
29
30
  // src/lib/storage/cookies-adapter.ts
@@ -370,11 +371,22 @@ async function cacheUserDataClient() {
370
371
  else
371
372
  cookiesRemove(EMAIL_KEY);
372
373
  }
374
+ function arrayAny(arr, cond) {
375
+ for (let i = 0; i < arr.length; i++) {
376
+ if (cond(arr[i]))
377
+ return true;
378
+ }
379
+ return false;
380
+ }
373
381
  function emptyUserCacheClient() {
374
- for (let i = 0; i < storageSize(); i++) {
375
- const key = storageKeyAt(i);
376
- if (!PERSISTANT_LOCALS.includes(key))
377
- storageRemove(key);
382
+ while (arrayAny(storageKeys(), (k) => !PERSISTANT_LOCALS.includes(k))) {
383
+ for (let i = 0; i < storageSize(); i++) {
384
+ const key = storageKeyAt(i);
385
+ if (!PERSISTANT_LOCALS.includes(key)) {
386
+ storageRemove(key);
387
+ break;
388
+ }
389
+ }
378
390
  }
379
391
  Object.keys(cookiesGetAll()).forEach((name) => {
380
392
  if (PERSISTANT_COOKIES.includes(name.trim()))
@@ -884,7 +896,7 @@ var SubjectStatusConfig = {
884
896
  submitted: {
885
897
  label: "Envoy\xE9e",
886
898
  helper: {
887
- student: "Cette question est en attente de validation, vous ne pouvez plus la modifi\xE9e.",
899
+ student: "Cette question est en attente de validation, vous ne pouvez plus la modifier.",
888
900
  teacher: "Cette question est en attente de validation.",
889
901
  admin: "Cette question est en attente de validation.",
890
902
  none: "Role invalide"
@@ -1006,6 +1018,7 @@ export {
1006
1018
  separateNames,
1007
1019
  storageGet,
1008
1020
  storageKeyAt,
1021
+ storageKeys,
1009
1022
  storageRemove,
1010
1023
  storageSet,
1011
1024
  storageSize,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goralys/core",
3
- "version": "1.6.2",
3
+ "version": "1.6.4",
4
4
  "license": "LGPL-2.1-or-later",
5
5
  "description": "Shared business logic for the Goralys web application",
6
6
  "repository": {