@goralys/core 1.2.2 → 1.3.0

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/LICENSE CHANGED
@@ -1,165 +1,165 @@
1
- GNU LESSER GENERAL PUBLIC LICENSE
2
- Version 3, 29 June 2007
3
-
4
- Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
5
- Everyone is permitted to copy and distribute verbatim copies
6
- of this license document, but changing it is not allowed.
7
-
8
-
9
- This version of the GNU Lesser General Public License incorporates
10
- the terms and conditions of version 3 of the GNU General Public
11
- License, supplemented by the additional permissions listed below.
12
-
13
- 0. Additional Definitions.
14
-
15
- As used herein, "this License" refers to version 3 of the GNU Lesser
16
- General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
- General Public License.
18
-
19
- "The Library" refers to a covered work governed by this License,
20
- other than an Application or a Combined Work as defined below.
21
-
22
- An "Application" is any work that makes use of an interface provided
23
- by the Library, but which is not otherwise based on the Library.
24
- Defining a subclass of a class defined by the Library is deemed a mode
25
- of using an interface provided by the Library.
26
-
27
- A "Combined Work" is a work produced by combining or linking an
28
- Application with the Library. The particular version of the Library
29
- with which the Combined Work was made is also called the "Linked
30
- Version".
31
-
32
- The "Minimal Corresponding Source" for a Combined Work means the
33
- Corresponding Source for the Combined Work, excluding any source code
34
- for portions of the Combined Work that, considered in isolation, are
35
- based on the Application, and not on the Linked Version.
36
-
37
- The "Corresponding Application Code" for a Combined Work means the
38
- object code and/or source code for the Application, including any data
39
- and utility programs needed for reproducing the Combined Work from the
40
- Application, but excluding the System Libraries of the Combined Work.
41
-
42
- 1. Exception to Section 3 of the GNU GPL.
43
-
44
- You may convey a covered work under sections 3 and 4 of this License
45
- without being bound by section 3 of the GNU GPL.
46
-
47
- 2. Conveying Modified Versions.
48
-
49
- If you modify a copy of the Library, and, in your modifications, a
50
- facility refers to a function or data to be supplied by an Application
51
- that uses the facility (other than as an argument passed when the
52
- facility is invoked), then you may convey a copy of the modified
53
- version:
54
-
55
- a) under this License, provided that you make a good faith effort to
56
- ensure that, in the event an Application does not supply the
57
- function or data, the facility still operates, and performs
58
- whatever part of its purpose remains meaningful, or
59
-
60
- b) under the GNU GPL, with none of the additional permissions of
61
- this License applicable to that copy.
62
-
63
- 3. Object Code Incorporating Material from Library Header Files.
64
-
65
- The object code form of an Application may incorporate material from
66
- a header file that is part of the Library. You may convey such object
67
- code under terms of your choice, provided that, if the incorporated
68
- material is not limited to numerical parameters, data structure
69
- layouts and accessors, or small macros, inline functions and templates
70
- (ten or fewer lines in length), you do both of the following:
71
-
72
- a) Give prominent notice with each copy of the object code that the
73
- Library is used in it and that the Library and its use are
74
- covered by this License.
75
-
76
- b) Accompany the object code with a copy of the GNU GPL and this license
77
- document.
78
-
79
- 4. Combined Works.
80
-
81
- You may convey a Combined Work under terms of your choice that,
82
- taken together, effectively do not restrict modification of the
83
- portions of the Library contained in the Combined Work and reverse
84
- engineering for debugging such modifications, if you also do each of
85
- the following:
86
-
87
- a) Give prominent notice with each copy of the Combined Work that
88
- the Library is used in it and that the Library and its use are
89
- covered by this License.
90
-
91
- b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
- document.
93
-
94
- c) For a Combined Work that displays copyright notices during
95
- execution, include the copyright notice for the Library among
96
- these notices, as well as a reference directing the user to the
97
- copies of the GNU GPL and this license document.
98
-
99
- d) Do one of the following:
100
-
101
- 0) Convey the Minimal Corresponding Source under the terms of this
102
- License, and the Corresponding Application Code in a form
103
- suitable for, and under terms that permit, the user to
104
- recombine or relink the Application with a modified version of
105
- the Linked Version to produce a modified Combined Work, in the
106
- manner specified by section 6 of the GNU GPL for conveying
107
- Corresponding Source.
108
-
109
- 1) Use a suitable shared library mechanism for linking with the
110
- Library. A suitable mechanism is one that (a) uses at run time
111
- a copy of the Library already present on the user's computer
112
- system, and (b) will operate properly with a modified version
113
- of the Library that is interface-compatible with the Linked
114
- Version.
115
-
116
- e) Provide Installation Information, but only if you would otherwise
117
- be required to provide such information under section 6 of the
118
- GNU GPL, and only to the extent that such information is
119
- necessary to install and execute a modified version of the
120
- Combined Work produced by recombining or relinking the
121
- Application with a modified version of the Linked Version. (If
122
- you use option 4d0, the Installation Information must accompany
123
- the Minimal Corresponding Source and Corresponding Application
124
- Code. If you use option 4d1, you must provide the Installation
125
- Information in the manner specified by section 6 of the GNU GPL
126
- for conveying Corresponding Source.)
127
-
128
- 5. Combined Libraries.
129
-
130
- You may place library facilities that are a work based on the
131
- Library side by side in a single library together with other library
132
- facilities that are not Applications and are not covered by this
133
- License, and convey such a combined library under terms of your
134
- choice, if you do both of the following:
135
-
136
- a) Accompany the combined library with a copy of the same work based
137
- on the Library, uncombined with any other library facilities,
138
- conveyed under the terms of this License.
139
-
140
- b) Give prominent notice with the combined library that part of it
141
- is a work based on the Library, and explaining where to find the
142
- accompanying uncombined form of the same work.
143
-
144
- 6. Revised Versions of the GNU Lesser General Public License.
145
-
146
- The Free Software Foundation may publish revised and/or new versions
147
- of the GNU Lesser General Public License from time to time. Such new
148
- versions will be similar in spirit to the present version, but may
149
- differ in detail to address new problems or concerns.
150
-
151
- Each version is given a distinguishing version number. If the
152
- Library as you received it specifies that a certain numbered version
153
- of the GNU Lesser General Public License "or any later version"
154
- applies to it, you have the option of following the terms and
155
- conditions either of that published version or of any later version
156
- published by the Free Software Foundation. If the Library as you
157
- received it does not specify a version number of the GNU Lesser
158
- General Public License, you may choose any version of the GNU Lesser
159
- General Public License ever published by the Free Software Foundation.
160
-
161
- If the Library as you received it specifies that a proxy can decide
162
- whether future versions of the GNU Lesser General Public License shall
163
- apply, that proxy's public statement of acceptance of any version is
164
- permanent authorization for you to choose that version for the
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+
9
+ This version of the GNU Lesser General Public License incorporates
10
+ the terms and conditions of version 3 of the GNU General Public
11
+ License, supplemented by the additional permissions listed below.
12
+
13
+ 0. Additional Definitions.
14
+
15
+ As used herein, "this License" refers to version 3 of the GNU Lesser
16
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
+ General Public License.
18
+
19
+ "The Library" refers to a covered work governed by this License,
20
+ other than an Application or a Combined Work as defined below.
21
+
22
+ An "Application" is any work that makes use of an interface provided
23
+ by the Library, but which is not otherwise based on the Library.
24
+ Defining a subclass of a class defined by the Library is deemed a mode
25
+ of using an interface provided by the Library.
26
+
27
+ A "Combined Work" is a work produced by combining or linking an
28
+ Application with the Library. The particular version of the Library
29
+ with which the Combined Work was made is also called the "Linked
30
+ Version".
31
+
32
+ The "Minimal Corresponding Source" for a Combined Work means the
33
+ Corresponding Source for the Combined Work, excluding any source code
34
+ for portions of the Combined Work that, considered in isolation, are
35
+ based on the Application, and not on the Linked Version.
36
+
37
+ The "Corresponding Application Code" for a Combined Work means the
38
+ object code and/or source code for the Application, including any data
39
+ and utility programs needed for reproducing the Combined Work from the
40
+ Application, but excluding the System Libraries of the Combined Work.
41
+
42
+ 1. Exception to Section 3 of the GNU GPL.
43
+
44
+ You may convey a covered work under sections 3 and 4 of this License
45
+ without being bound by section 3 of the GNU GPL.
46
+
47
+ 2. Conveying Modified Versions.
48
+
49
+ If you modify a copy of the Library, and, in your modifications, a
50
+ facility refers to a function or data to be supplied by an Application
51
+ that uses the facility (other than as an argument passed when the
52
+ facility is invoked), then you may convey a copy of the modified
53
+ version:
54
+
55
+ a) under this License, provided that you make a good faith effort to
56
+ ensure that, in the event an Application does not supply the
57
+ function or data, the facility still operates, and performs
58
+ whatever part of its purpose remains meaningful, or
59
+
60
+ b) under the GNU GPL, with none of the additional permissions of
61
+ this License applicable to that copy.
62
+
63
+ 3. Object Code Incorporating Material from Library Header Files.
64
+
65
+ The object code form of an Application may incorporate material from
66
+ a header file that is part of the Library. You may convey such object
67
+ code under terms of your choice, provided that, if the incorporated
68
+ material is not limited to numerical parameters, data structure
69
+ layouts and accessors, or small macros, inline functions and templates
70
+ (ten or fewer lines in length), you do both of the following:
71
+
72
+ a) Give prominent notice with each copy of the object code that the
73
+ Library is used in it and that the Library and its use are
74
+ covered by this License.
75
+
76
+ b) Accompany the object code with a copy of the GNU GPL and this license
77
+ document.
78
+
79
+ 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that,
82
+ taken together, effectively do not restrict modification of the
83
+ portions of the Library contained in the Combined Work and reverse
84
+ engineering for debugging such modifications, if you also do each of
85
+ the following:
86
+
87
+ a) Give prominent notice with each copy of the Combined Work that
88
+ the Library is used in it and that the Library and its use are
89
+ covered by this License.
90
+
91
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
+ document.
93
+
94
+ c) For a Combined Work that displays copyright notices during
95
+ execution, include the copyright notice for the Library among
96
+ these notices, as well as a reference directing the user to the
97
+ copies of the GNU GPL and this license document.
98
+
99
+ d) Do one of the following:
100
+
101
+ 0) Convey the Minimal Corresponding Source under the terms of this
102
+ License, and the Corresponding Application Code in a form
103
+ suitable for, and under terms that permit, the user to
104
+ recombine or relink the Application with a modified version of
105
+ the Linked Version to produce a modified Combined Work, in the
106
+ manner specified by section 6 of the GNU GPL for conveying
107
+ Corresponding Source.
108
+
109
+ 1) Use a suitable shared library mechanism for linking with the
110
+ Library. A suitable mechanism is one that (a) uses at run time
111
+ a copy of the Library already present on the user's computer
112
+ system, and (b) will operate properly with a modified version
113
+ of the Library that is interface-compatible with the Linked
114
+ Version.
115
+
116
+ e) Provide Installation Information, but only if you would otherwise
117
+ be required to provide such information under section 6 of the
118
+ GNU GPL, and only to the extent that such information is
119
+ necessary to install and execute a modified version of the
120
+ Combined Work produced by recombining or relinking the
121
+ Application with a modified version of the Linked Version. (If
122
+ you use option 4d0, the Installation Information must accompany
123
+ the Minimal Corresponding Source and Corresponding Application
124
+ Code. If you use option 4d1, you must provide the Installation
125
+ Information in the manner specified by section 6 of the GNU GPL
126
+ for conveying Corresponding Source.)
127
+
128
+ 5. Combined Libraries.
129
+
130
+ You may place library facilities that are a work based on the
131
+ Library side by side in a single library together with other library
132
+ facilities that are not Applications and are not covered by this
133
+ License, and convey such a combined library under terms of your
134
+ choice, if you do both of the following:
135
+
136
+ a) Accompany the combined library with a copy of the same work based
137
+ on the Library, uncombined with any other library facilities,
138
+ conveyed under the terms of this License.
139
+
140
+ b) Give prominent notice with the combined library that part of it
141
+ is a work based on the Library, and explaining where to find the
142
+ accompanying uncombined form of the same work.
143
+
144
+ 6. Revised Versions of the GNU Lesser General Public License.
145
+
146
+ The Free Software Foundation may publish revised and/or new versions
147
+ of the GNU Lesser General Public License from time to time. Such new
148
+ versions will be similar in spirit to the present version, but may
149
+ differ in detail to address new problems or concerns.
150
+
151
+ Each version is given a distinguishing version number. If the
152
+ Library as you received it specifies that a certain numbered version
153
+ of the GNU Lesser General Public License "or any later version"
154
+ applies to it, you have the option of following the terms and
155
+ conditions either of that published version or of any later version
156
+ published by the Free Software Foundation. If the Library as you
157
+ received it does not specify a version number of the GNU Lesser
158
+ General Public License, you may choose any version of the GNU Lesser
159
+ General Public License ever published by the Free Software Foundation.
160
+
161
+ If the Library as you received it specifies that a proxy can decide
162
+ whether future versions of the GNU Lesser General Public License shall
163
+ apply, that proxy's public statement of acceptance of any version is
164
+ permanent authorization for you to choose that version for the
165
165
  Library.
package/README.md CHANGED
@@ -1,47 +1,47 @@
1
- ## Goralys Core
2
-
3
- ---
4
-
5
- This package contains the shared business logic for the [Goralys](https://github.com/SAMSAM-55/Goralys) applications –
6
- web
7
- and mobile.
8
-
9
- This package bundles the reusable code for the web frontend and the mobile app to avoid code redundancy and duplication
10
- accross
11
- platforms.
12
-
13
- ### Content Overview
14
-
15
- - `hooks/` – Reusable React hooks (independant from the DOM)
16
- - `lib/` – Fetch logic, event listeners, etc.
17
- - `types/` – Shared TypeScript types
18
-
19
- The UI components are **not** part of this package as they are specific to each platform (web / mobile), because the
20
- technologies
21
- used for rendering are different (HTML/CSS for the web vs React Native components).
22
-
23
- ### Setup
24
-
25
- ```bash
26
- pnpm add @goralys/core
27
- ```
28
-
29
- ### Development
30
-
31
- This package is part of the Goralys monorepo and is managed via pnpm workspaces
32
-
33
- ```bash
34
- # From the project root
35
- cd goralys-core
36
- pnpm install
37
- pnpm build
38
- pnpm dev
39
- ```
40
-
41
- ### License
42
-
43
- This package is distributed under the LGPL-2.1-or-later license, see [LICENSE](LICENSE) for more information.
44
-
45
- ### Contact
46
-
1
+ ## Goralys Core
2
+
3
+ ---
4
+
5
+ This package contains the shared business logic for the [Goralys](https://github.com/SAMSAM-55/Goralys) applications –
6
+ web
7
+ and mobile.
8
+
9
+ This package bundles the reusable code for the web frontend and the mobile app to avoid code redundancy and duplication
10
+ accross
11
+ platforms.
12
+
13
+ ### Content Overview
14
+
15
+ - `hooks/` – Reusable React hooks (independant from the DOM)
16
+ - `lib/` – Fetch logic, event listeners, etc.
17
+ - `types/` – Shared TypeScript types
18
+
19
+ The UI components are **not** part of this package as they are specific to each platform (web / mobile), because the
20
+ technologies
21
+ used for rendering are different (HTML/CSS for the web vs React Native components).
22
+
23
+ ### Setup
24
+
25
+ ```bash
26
+ pnpm add @goralys/core
27
+ ```
28
+
29
+ ### Development
30
+
31
+ This package is part of the Goralys monorepo and is managed via pnpm workspaces
32
+
33
+ ```bash
34
+ # From the project root
35
+ cd goralys-core
36
+ pnpm install
37
+ pnpm build
38
+ pnpm dev
39
+ ```
40
+
41
+ ### License
42
+
43
+ This package is distributed under the LGPL-2.1-or-later license, see [LICENSE](LICENSE) for more information.
44
+
45
+ ### Contact
46
+
47
47
  sami.saubion@gmail.com – main developer and maintainer of the project
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  interface GoralysClientConfig {
2
2
  apiDomain: string;
3
+ schoolToken: string;
3
4
  }
4
5
  declare function configureGoralysClient(cfg: GoralysClientConfig): void;
5
6
  declare function getGoralysClientConfig(): GoralysClientConfig;
@@ -172,6 +173,7 @@ declare const LOGO_PATH: {
172
173
 
173
174
  declare const COOKIES_DISMISSED_KEY = "cookie-banner-dismissed";
174
175
  declare const PERSISTANT_COOKIES: string[];
176
+ declare const FLASH_TOAST_KEY = "flash-toast";
175
177
  declare const PERSISTANT_LOCALS: string[];
176
178
  declare const USERNAME_KEY = "username";
177
179
  declare const ROLE_KEY = "user-role";
@@ -270,6 +272,14 @@ declare function onNavigationEvent(listener: Listener): () => void;
270
272
  * @returns The full subject name if a match is found; otherwise, returns the input string itself.
271
273
  */
272
274
  declare function getLongFromShort(short: string): string;
275
+ /**
276
+ * Returns the full name of a subject based on its short name or an alias.
277
+ * It searches for the first subject in {@link SUBJECTS} whose short name starts with the given string.
278
+ *
279
+ * @param long The long name tp search for.
280
+ * @returns The subject short name, alias, or prefix if a match is found; otherwise, returns the input string itself.
281
+ */
282
+ declare function getShortFromLong(long: string): string;
273
283
 
274
284
  declare function fetchSubjectsForRoleClient(role: UserRole): Promise<Response | null>;
275
285
 
@@ -280,4 +290,4 @@ declare function fetchVirtualUsersClient(): Promise<Response>;
280
290
  declare function fetchAdminsClient(): Promise<Response>;
281
291
  declare function fetchVirtualAdminsClient(): Promise<Response>;
282
292
 
283
- export { ADMIN_CACHE_RADIX, ADMIN_SYNC_RADIX, type AuthEvent, COOKIES_DISMISSED_KEY, type CheckAuthImpl, type ConfirmOptions, type CookieValue, type CookiesAdapter, type DraftModalResult, EMAIL_KEY, FULL_NAME_KEY, GoralysActionHandler, type GoralysClientConfig, 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 ToastFn, USERNAME_KEY, USER_CACHES, USER_CACHE_RADIX, USER_ROLES, USER_SYNCS, USER_SYNC_RADIX, type User, type UserData, type UserEvent, type UserRole, type UserType, buildApiUrl, buildArray, cacheUserDataClient, configGoralysCore, configureCheckAuth, configureCookies, configureGoralysClient, configureStorage, cookiesGet, cookiesGetAll, cookiesOnChange, cookiesRemove, cookiesSet, emitAuthEvent, emitNavigationEvent, emitUserEvent, emptyUserCacheClient, fetchAdminsClient, fetchCsrfClient, fetchSubjectsForRoleClient, fetchUsersClient, fetchVirtualAdminsClient, fetchVirtualUsersClient, getGoralysClientConfig, getLongFromShort, getStatusHelper, getStatusLabel, goralysFetchClient, handleToastRequest, helpContent, isAuthenticated, isFoolsDay, isHTTPMethod, onAuthEvent, onNavigationEvent, onUserEvent, parsePhpDateTime, reasonsConfig, searchFields, storageGet, storageKeyAt, storageRemove, storageSet, storageSize, useAdmins, useSubjects, useSupportTickets, useUsers, useVirtualAdmins, useVirtualUsers };
293
+ export { ADMIN_CACHE_RADIX, ADMIN_SYNC_RADIX, type AuthEvent, COOKIES_DISMISSED_KEY, type CheckAuthImpl, type ConfirmOptions, type CookieValue, type CookiesAdapter, type DraftModalResult, EMAIL_KEY, FLASH_TOAST_KEY, FULL_NAME_KEY, GoralysActionHandler, type GoralysClientConfig, 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 ToastFn, USERNAME_KEY, USER_CACHES, USER_CACHE_RADIX, USER_ROLES, USER_SYNCS, USER_SYNC_RADIX, type User, type UserData, type UserEvent, type UserRole, type UserType, buildApiUrl, buildArray, cacheUserDataClient, configGoralysCore, configureCheckAuth, configureCookies, configureGoralysClient, configureStorage, cookiesGet, cookiesGetAll, cookiesOnChange, cookiesRemove, cookiesSet, emitAuthEvent, emitNavigationEvent, emitUserEvent, emptyUserCacheClient, fetchAdminsClient, fetchCsrfClient, fetchSubjectsForRoleClient, fetchUsersClient, fetchVirtualAdminsClient, fetchVirtualUsersClient, getGoralysClientConfig, getLongFromShort, getShortFromLong, getStatusHelper, getStatusLabel, goralysFetchClient, handleToastRequest, helpContent, isAuthenticated, isFoolsDay, isHTTPMethod, onAuthEvent, onNavigationEvent, onUserEvent, parsePhpDateTime, reasonsConfig, searchFields, storageGet, storageKeyAt, storageRemove, storageSet, storageSize, useAdmins, useSubjects, useSupportTickets, useUsers, useVirtualAdmins, useVirtualUsers };
package/dist/index.js CHANGED
@@ -92,7 +92,8 @@ function onNavigationEvent(listener) {
92
92
  // src/lib/config.ts
93
93
  var COOKIES_DISMISSED_KEY = "cookie-banner-dismissed";
94
94
  var PERSISTANT_COOKIES = [COOKIES_DISMISSED_KEY, "rate_limit_token"];
95
- var PERSISTANT_LOCALS = ["goralys-cookies-expire", "flash_toast"];
95
+ var FLASH_TOAST_KEY = "flash-toast";
96
+ var PERSISTANT_LOCALS = ["goralys-cookies-expire", FLASH_TOAST_KEY];
96
97
  var USERNAME_KEY = "username";
97
98
  var ROLE_KEY = "user-role";
98
99
  var FULL_NAME_KEY = "full-name";
@@ -413,12 +414,19 @@ var GoralysActionHandler = class {
413
414
  // src/lib/fetch/fetch.client.ts
414
415
  var actionHandler = new GoralysActionHandler();
415
416
  async function goralysFetchClient(method, input, payload, requestOptions) {
416
- const { apiDomain } = getGoralysClientConfig();
417
+ const { apiDomain, schoolToken } = getGoralysClientConfig();
418
+ let finalPayload = payload;
419
+ if (payload instanceof FormData) {
420
+ payload.append("high-school-token", schoolToken ?? "");
421
+ finalPayload = payload;
422
+ } else if (payload !== void 0) {
423
+ finalPayload = { ...payload, "high-school-token": schoolToken };
424
+ }
417
425
  const res = await fetch(`${apiDomain}/${input}`, {
418
426
  credentials: "include",
419
427
  method: method === "BREW" ? "POST" : method,
420
428
  headers: method === "BREW" ? { "X-HTTP-Method-Override": method } : {},
421
- body: payload ? payload instanceof FormData ? payload : JSON.stringify(payload) : void 0,
429
+ body: finalPayload ? finalPayload instanceof FormData ? finalPayload : JSON.stringify(finalPayload) : void 0,
422
430
  ...requestOptions
423
431
  });
424
432
  const clone = res.clone();
@@ -446,12 +454,12 @@ async function goralysFetchClient(method, input, payload, requestOptions) {
446
454
  return res;
447
455
  }
448
456
  async function fetchCsrfClient(formId) {
449
- const { apiDomain } = getGoralysClientConfig();
457
+ const { apiDomain, schoolToken } = getGoralysClientConfig();
450
458
  const res = await fetch(`${apiDomain}/csrf`, {
451
459
  method: "POST",
452
460
  headers: { "Content-Type": "application/json" },
453
461
  credentials: "include",
454
- body: JSON.stringify({ form: formId })
462
+ body: JSON.stringify({ form: formId, "high-school-token": schoolToken })
455
463
  });
456
464
  if (!res.ok)
457
465
  return null;
@@ -462,9 +470,10 @@ function buildQueryString(params) {
462
470
  return Object.entries(params).filter(([, value]) => value !== null && value !== void 0).map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`).join("&");
463
471
  }
464
472
  function buildApiUrl(endpoint, params, domain = false) {
465
- const { apiDomain } = getGoralysClientConfig();
473
+ const { apiDomain, schoolToken } = getGoralysClientConfig();
466
474
  const queryString = buildQueryString(params);
467
- return `${domain ? apiDomain + "/" : ""}${endpoint}${queryString ? `?${queryString}` : ""}`;
475
+ return `${domain ? apiDomain + "/" : ""}${endpoint + "?high-school-token=" + encodeURIComponent(schoolToken)}
476
+ ${queryString ? `&${queryString}` : ""}`;
468
477
  }
469
478
  async function handleToastRequest(r, showToast, redirect = true, duration) {
470
479
  const res = r.clone();
@@ -789,31 +798,96 @@ var parsePhpDateTime = (phpDate) => {
789
798
 
790
799
  // src/lib/subjects/subjects-utils.ts
791
800
  var SUBJECTS = [
801
+ // Arts plastiques
802
+ ["arts", "arts plastiques"],
803
+ ["arpla", "arts plastiques"],
792
804
  ["apla", "arts plastiques"],
793
805
  ["arts-plastiques", "arts plastiques"],
794
- ["arts", "arts plastiques"],
806
+ // Cinéma - audiovisuel
807
+ ["cine.av", "cin\xE9ma audiovisuel"],
795
808
  ["ciav", "cin\xE9ma audiovisuel"],
796
809
  ["cinema", "cin\xE9ma audiovisuel"],
797
810
  ["cav", "cin\xE9ma audiovisuel"],
811
+ // Arts du cirque
812
+ ["a.cirque", "arts du cirque"],
813
+ ["cirque", "arts du cirque"],
814
+ // Danse
815
+ ["danse", "danse"],
816
+ // Histoire des arts
817
+ ["hist.arts", "histoire des arts"],
818
+ ["histoire-arts", "histoire des arts"],
819
+ ["hda", "histoire des arts"],
820
+ // Musique
821
+ ["mus", "musique"],
822
+ ["musique", "musique"],
823
+ // Théâtre
824
+ ["thea", "th\xE9\xE2tre"],
825
+ ["th\xE9\xE2tre", "th\xE9\xE2tre"],
826
+ ["theatre", "th\xE9\xE2tre"],
827
+ // Histoire-géographie, géopolitique et sciences politiques
828
+ ["HGGSP", "histoire g\xE9ographie g\xE9opolitique et sciences politiques"],
798
829
  ["hggsp", "histoire g\xE9ographie g\xE9opolitique et sciences politiques"],
799
- ["hlphi", "humanit\xE9 litt\xE9rature et philosophie"],
830
+ // Humanités, littérature et philosophie
831
+ ["HLP", "humanit\xE9 litt\xE9rature et philosophie"],
800
832
  ["hlp", "humanit\xE9 litt\xE9rature et philosophie"],
833
+ ["hlphi", "humanit\xE9 litt\xE9rature et philosophie"],
834
+ // Langues, littératures et cultures étrangères et régionales
835
+ ["LLCER", "langue litt\xE9rature et culture \xE9trang\xE8re"],
801
836
  ["llce", "langue litt\xE9rature et culture \xE9trang\xE8re"],
802
837
  ["llcer", "langue litt\xE9rature et culture \xE9trang\xE8re"],
838
+ // Littérature et langues et cultures de l'Antiquité
839
+ ["LLCA", "litt\xE9rature et langues et cultures de l'antiquit\xE9"],
840
+ ["llca", "litt\xE9rature et langues et cultures de l'antiquit\xE9"],
841
+ ["lca", "litt\xE9rature et langues et cultures de l'antiquit\xE9"],
842
+ // Mathématiques
803
843
  ["maths", "math\xE9matiques"],
804
844
  ["math", "math\xE9matiques"],
805
- ["nsinf", "num\xE9rique et sciences informatiques"],
845
+ // Numérique et sciences informatiques
846
+ ["num.sci.inf", "num\xE9rique et sciences informatiques"],
806
847
  ["nsi", "num\xE9rique et sciences informatiques"],
848
+ ["nsinf", "num\xE9rique et sciences informatiques"],
849
+ ["n.s.i", "num\xE9rique et sciences informatiques"],
850
+ // Physique-chimie
851
+ ["PCH", "physique-chimie"],
807
852
  ["phch", "physique-chimie"],
808
853
  ["pc", "physique-chimie"],
854
+ // Sciences de la vie et de la Terre
855
+ ["SVT", "sciences et vie de la terre"],
856
+ ["svt", "sciences et vie de la terre"],
857
+ // Sciences économiques et sociales
858
+ ["SES", "sciences \xE9conomiques et sociales"],
809
859
  ["ses", "sciences \xE9conomiques et sociales"],
810
- ["svt", "sciences et vie de la terre"]
860
+ // Sciences de l'ingénieur
861
+ ["sci.ing", "sciences de l'ing\xE9nieur"],
862
+ ["si", "sciences de l'ing\xE9nieur"],
863
+ ["scing", "sciences de l'ing\xE9nieur"],
864
+ // Éducation physique, pratiques et culture sportives
865
+ ["EPS", "\xE9ducation physique pratiques et culture sportives"],
866
+ ["sport", "\xE9ducation physique pratiques et culture sportives"],
867
+ ["eppcs", "\xE9ducation physique pratiques et culture sportives"]
811
868
  ];
869
+ function formatAlias(a) {
870
+ if (a.toUpperCase() === a)
871
+ return a;
872
+ const hasPoints = a.includes(".");
873
+ if (!hasPoints)
874
+ return capitalize(a);
875
+ let result = "";
876
+ const clean = a.toLowerCase().replace(" ", "");
877
+ clean.split(".").forEach((part) => result += capitalize(part) + ". ");
878
+ return result.trim();
879
+ }
880
+ var capitalize = (s) => s.charAt(0).toUpperCase() + s.slice(1).toLowerCase();
812
881
  function getLongFromShort(short) {
813
882
  const search = short.toLowerCase().trim();
814
883
  const match = SUBJECTS.find(([key]) => key.startsWith(search));
815
884
  return match ? match[1] : search;
816
885
  }
886
+ function getShortFromLong(long) {
887
+ const search = long.toLowerCase().trim();
888
+ const match = SUBJECTS.find(([, value]) => value.startsWith(search));
889
+ return match ? formatAlias(match[0]) : search;
890
+ }
817
891
 
818
892
  // src/types/subjects.ts
819
893
  var SubjectStatusConfig = {
@@ -878,6 +952,7 @@ export {
878
952
  ADMIN_SYNC_RADIX,
879
953
  COOKIES_DISMISSED_KEY,
880
954
  EMAIL_KEY,
955
+ FLASH_TOAST_KEY,
881
956
  FULL_NAME_KEY,
882
957
  GoralysActionHandler,
883
958
  LOGO_PATH,
@@ -923,6 +998,7 @@ export {
923
998
  fetchVirtualUsersClient,
924
999
  getGoralysClientConfig,
925
1000
  getLongFromShort,
1001
+ getShortFromLong,
926
1002
  getStatusHelper,
927
1003
  getStatusLabel,
928
1004
  goralysFetchClient,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goralys/core",
3
- "version": "1.2.2",
3
+ "version": "1.3.0",
4
4
  "license": "LGPL-2.1-or-later",
5
5
  "description": "Shared business logic for the Goralys web application",
6
6
  "repository": {