@fctc/edu-logic-lib 1.0.3 → 1.0.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.
Files changed (53) hide show
  1. package/dist/index.d.mts +1294 -23
  2. package/dist/index.d.ts +1294 -23
  3. package/package.json +96 -96
  4. package/dist/base-model-type-DvO53Lwi.d.mts +0 -7
  5. package/dist/base-model-type-DvO53Lwi.d.ts +0 -7
  6. package/dist/config.d.mts +0 -15
  7. package/dist/config.d.ts +0 -15
  8. package/dist/config.js +0 -262
  9. package/dist/config.mjs +0 -256
  10. package/dist/constants.d.mts +0 -120
  11. package/dist/constants.d.ts +0 -120
  12. package/dist/constants.js +0 -154
  13. package/dist/constants.mjs +0 -141
  14. package/dist/context-type-D5XefoL-.d.mts +0 -8
  15. package/dist/context-type-D5XefoL-.d.ts +0 -8
  16. package/dist/environment.d.mts +0 -37
  17. package/dist/environment.d.ts +0 -37
  18. package/dist/environment.js +0 -849
  19. package/dist/environment.mjs +0 -841
  20. package/dist/hooks.d.mts +0 -218
  21. package/dist/hooks.d.ts +0 -218
  22. package/dist/hooks.js +0 -4865
  23. package/dist/hooks.mjs +0 -4814
  24. package/dist/index-C_nK1Mii.d.mts +0 -19
  25. package/dist/index-C_nK1Mii.d.ts +0 -19
  26. package/dist/models.d.mts +0 -35
  27. package/dist/models.d.ts +0 -35
  28. package/dist/models.js +0 -3225
  29. package/dist/models.mjs +0 -3217
  30. package/dist/provider.d.mts +0 -16
  31. package/dist/provider.d.ts +0 -16
  32. package/dist/provider.js +0 -3232
  33. package/dist/provider.mjs +0 -3224
  34. package/dist/services.d.mts +0 -160
  35. package/dist/services.d.ts +0 -160
  36. package/dist/services.js +0 -4045
  37. package/dist/services.mjs +0 -4032
  38. package/dist/store.d.mts +0 -505
  39. package/dist/store.d.ts +0 -505
  40. package/dist/store.js +0 -582
  41. package/dist/store.mjs +0 -519
  42. package/dist/types.d.mts +0 -12
  43. package/dist/types.d.ts +0 -12
  44. package/dist/types.js +0 -2
  45. package/dist/types.mjs +0 -1
  46. package/dist/use-get-selection-DFh6sc49.d.mts +0 -26
  47. package/dist/use-get-selection-DFh6sc49.d.ts +0 -26
  48. package/dist/utils.d.mts +0 -52
  49. package/dist/utils.d.ts +0 -52
  50. package/dist/utils.js +0 -2360
  51. package/dist/utils.mjs +0 -2344
  52. package/dist/view-type-BTzRpkT7.d.mts +0 -106
  53. package/dist/view-type-BTzRpkT7.d.ts +0 -106
package/package.json CHANGED
@@ -1,96 +1,96 @@
1
- {
2
- "name": "@fctc/edu-logic-lib",
3
- "version": "1.0.3",
4
- "types": "dist/index.d.ts",
5
- "main": "dist/index.cjs",
6
- "module": "dist/index.mjs",
7
- "publishConfig": {
8
- "registry": "https://registry.npmjs.org/",
9
- "access": "public"
10
- },
11
- "exports": {
12
- ".": {
13
- "types": "./dist/index.d.ts",
14
- "import": "./dist/index.mjs",
15
- "require": "./dist/index.cjs"
16
- },
17
- "./config": {
18
- "types": "./dist/config.d.ts",
19
- "import": "./dist/config.mjs",
20
- "require": "./dist/config.cjs"
21
- },
22
- "./constants": {
23
- "types": "./dist/constants.d.ts",
24
- "import": "./dist/constants.mjs",
25
- "require": "./dist/constants.cjs"
26
- },
27
- "./environment": {
28
- "types": "./dist/environment.d.ts",
29
- "import": "./dist/environment.mjs",
30
- "require": "./dist/environment.cjs"
31
- },
32
- "./hooks": {
33
- "types": "./dist/hooks.d.ts",
34
- "import": "./dist/hooks.mjs",
35
- "require": "./dist/hooks.cjs"
36
- },
37
- "./provider": {
38
- "types": "./dist/provider.d.ts",
39
- "import": "./dist/provider.mjs",
40
- "require": "./dist/provider.cjs"
41
- },
42
- "./services": {
43
- "types": "./dist/services.d.ts",
44
- "import": "./dist/services.mjs",
45
- "require": "./dist/services.cjs"
46
- },
47
- "./store": {
48
- "types": "./dist/store.d.ts",
49
- "import": "./dist/store.mjs",
50
- "require": "./dist/store.cjs"
51
- },
52
- "./utils": {
53
- "types": "./dist/utils.d.ts",
54
- "import": "./dist/utils.mjs",
55
- "require": "./dist/utils.cjs"
56
- },
57
- "./types": {
58
- "types": "./dist/types.d.ts",
59
- "import": "./dist/types.mjs",
60
- "require": "./dist/types.cjs"
61
- },
62
- "./models": {
63
- "types": "./dist/models.d.ts",
64
- "import": "./dist/models.mjs",
65
- "require": "./dist/models.cjs"
66
- }
67
- },
68
- "files": [
69
- "dist"
70
- ],
71
- "scripts": {
72
- "build": "tsup",
73
- "prepublishOnly": "yarn build",
74
- "test": "jest"
75
- },
76
- "peerDependencies": {
77
- "react": "^18.0.0",
78
- "@tanstack/react-query": "^5.83.0",
79
- "react-redux": "^9.2.0",
80
- "@reduxjs/toolkit": "^2.8.2"
81
- },
82
- "dependencies": {
83
- "axios": "^1.11.0"
84
- },
85
- "devDependencies": {
86
- "@types/react": "^18.3.1",
87
- "jest": "^29.7.0",
88
- "react": "18.0.0",
89
- "react-redux": "^9.2.0",
90
- "@reduxjs/toolkit": "^2.8.2",
91
- "@tanstack/react-query": "^5.83.0",
92
- "tsup": "^8.0.0",
93
- "typescript": "^5.8.2"
94
- },
95
- "packageManager": "yarn@1.22.0"
96
- }
1
+ {
2
+ "name": "@fctc/edu-logic-lib",
3
+ "version": "1.0.5",
4
+ "types": "dist/index.d.ts",
5
+ "main": "dist/index.cjs",
6
+ "module": "dist/index.mjs",
7
+ "publishConfig": {
8
+ "registry": "https://registry.npmjs.org/",
9
+ "access": "public"
10
+ },
11
+ "exports": {
12
+ ".": {
13
+ "types": "./dist/index.d.ts",
14
+ "import": "./dist/index.mjs",
15
+ "require": "./dist/index.cjs"
16
+ },
17
+ "./config": {
18
+ "types": "./dist/index.d.ts",
19
+ "import": "./dist/index.mjs",
20
+ "require": "./dist/index.cjs"
21
+ },
22
+ "./constants": {
23
+ "types": "./dist/index.d.ts",
24
+ "import": "./dist/index.mjs",
25
+ "require": "./dist/index.cjs"
26
+ },
27
+ "./environment": {
28
+ "types": "./dist/index.d.ts",
29
+ "import": "./dist/index.mjs",
30
+ "require": "./dist/index.cjs"
31
+ },
32
+ "./hooks": {
33
+ "types": "./dist/index.d.ts",
34
+ "import": "./dist/index.mjs",
35
+ "require": "./dist/index.cjs"
36
+ },
37
+ "./provider": {
38
+ "types": "./dist/index.d.ts",
39
+ "import": "./dist/index.mjs",
40
+ "require": "./dist/index.cjs"
41
+ },
42
+ "./services": {
43
+ "types": "./dist/index.d.ts",
44
+ "import": "./dist/index.mjs",
45
+ "require": "./dist/index.cjs"
46
+ },
47
+ "./store": {
48
+ "types": "./dist/index.d.ts",
49
+ "import": "./dist/index.mjs",
50
+ "require": "./dist/index.cjs"
51
+ },
52
+ "./utils": {
53
+ "types": "./dist/index.d.ts",
54
+ "import": "./dist/index.mjs",
55
+ "require": "./dist/index.cjs"
56
+ },
57
+ "./types": {
58
+ "types": "./dist/index.d.ts",
59
+ "import": "./dist/index.mjs",
60
+ "require": "./dist/index.cjs"
61
+ },
62
+ "./models": {
63
+ "types": "./dist/index.d.ts",
64
+ "import": "./dist/index.mjs",
65
+ "require": "./dist/index.cjs"
66
+ }
67
+ },
68
+ "files": [
69
+ "dist"
70
+ ],
71
+ "scripts": {
72
+ "build": "tsup",
73
+ "prepublishOnly": "yarn build",
74
+ "test": "jest"
75
+ },
76
+ "peerDependencies": {
77
+ "react": "^18.0.0",
78
+ "@tanstack/react-query": "^5.83.0",
79
+ "react-redux": "^9.2.0",
80
+ "@reduxjs/toolkit": "^2.8.2"
81
+ },
82
+ "dependencies": {
83
+ "axios": "^1.11.0"
84
+ },
85
+ "devDependencies": {
86
+ "@types/react": "^18.3.1",
87
+ "jest": "^29.7.0",
88
+ "react": "18.0.0",
89
+ "react-redux": "^9.2.0",
90
+ "@reduxjs/toolkit": "^2.8.2",
91
+ "@tanstack/react-query": "^5.83.0",
92
+ "tsup": "^8.0.0",
93
+ "typescript": "^5.8.2"
94
+ },
95
+ "packageManager": "yarn@1.22.0"
96
+ }
@@ -1,7 +0,0 @@
1
- interface BaseModelInit {
2
- name: string;
3
- view: Record<string, any>;
4
- actContext?: Record<string, any>;
5
- }
6
-
7
- export type { BaseModelInit as B };
@@ -1,7 +0,0 @@
1
- interface BaseModelInit {
2
- name: string;
3
- view: Record<string, any>;
4
- actContext?: Record<string, any>;
5
- }
6
-
7
- export type { BaseModelInit as B };
package/dist/config.d.mts DELETED
@@ -1,15 +0,0 @@
1
- import { EnvStore } from './environment.mjs';
2
- import '@reduxjs/toolkit';
3
-
4
- declare const axiosClient: {
5
- init(config: EnvStore): {
6
- get: (url: string, headers: any) => Promise<any>;
7
- post: (url: string, body: any, headers: any) => Promise<any>;
8
- post_excel: (url: string, body: any, headers: any) => Promise<any>;
9
- put: (url: string, body: any, headers: any) => Promise<any>;
10
- patch: (url: string, body: any) => Promise<any>;
11
- delete: (url: string, body: any) => Promise<any>;
12
- };
13
- };
14
-
15
- export { axiosClient };
package/dist/config.d.ts DELETED
@@ -1,15 +0,0 @@
1
- import { EnvStore } from './environment.js';
2
- import '@reduxjs/toolkit';
3
-
4
- declare const axiosClient: {
5
- init(config: EnvStore): {
6
- get: (url: string, headers: any) => Promise<any>;
7
- post: (url: string, body: any, headers: any) => Promise<any>;
8
- post_excel: (url: string, body: any, headers: any) => Promise<any>;
9
- put: (url: string, body: any, headers: any) => Promise<any>;
10
- patch: (url: string, body: any) => Promise<any>;
11
- delete: (url: string, body: any) => Promise<any>;
12
- };
13
- };
14
-
15
- export { axiosClient };
package/dist/config.js DELETED
@@ -1,262 +0,0 @@
1
- 'use strict';
2
-
3
- var axios = require('axios');
4
-
5
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
6
-
7
- var axios__default = /*#__PURE__*/_interopDefault(axios);
8
-
9
- // src/config/axios-client.ts
10
- var MAINT_KEY = "MAINTENANCE_ACTIVE";
11
- var MAINT_AT = "MAINTENANCE_AT";
12
- var MAINT_LAST_PATH = "MAINTENANCE_LAST_PATH";
13
- var hasRedirectedToMaintenance = false;
14
- function setMaintenanceFlags() {
15
- if (typeof window === "undefined") return;
16
- const { pathname, search } = window.location;
17
- const lastPath = pathname + (search || "");
18
- if (pathname !== "/maintenance" && !window.localStorage.getItem(MAINT_LAST_PATH)) {
19
- window.localStorage.setItem(MAINT_LAST_PATH, lastPath);
20
- }
21
- window.localStorage.setItem(MAINT_KEY, "true");
22
- window.localStorage.setItem(MAINT_AT, String(Date.now()));
23
- }
24
- async function clearMaintenanceAndExit(getToken, opts) {
25
- if (typeof window === "undefined") return;
26
- const forceLogin = opts?.forceLogin === true;
27
- const clearTokenOnForce = opts?.clearTokenOnForce !== false;
28
- window.localStorage.removeItem(MAINT_KEY);
29
- window.localStorage.removeItem(MAINT_AT);
30
- const lastPath = window.localStorage.getItem(MAINT_LAST_PATH);
31
- window.localStorage.removeItem(MAINT_LAST_PATH);
32
- try {
33
- if (forceLogin) {
34
- if (clearTokenOnForce) {
35
- try {
36
- await opts?.clearToken?.();
37
- } catch {
38
- }
39
- }
40
- window.location.replace("/login");
41
- return;
42
- }
43
- const token = await getToken();
44
- if (token) {
45
- const target = lastPath && lastPath !== "/maintenance" ? lastPath : "/";
46
- window.location.replace(target);
47
- } else {
48
- window.location.replace("/login");
49
- }
50
- } catch {
51
- window.location.replace("/login");
52
- }
53
- }
54
- var axiosClient = {
55
- init(config) {
56
- const localStorage = config.localStorageUtils;
57
- const sessionStorage = config.sessionStorageUtils;
58
- const db = config.db;
59
- let isRefreshing = false;
60
- let failedQueue = [];
61
- const processQueue = (error, token = null) => {
62
- failedQueue?.forEach((prom) => {
63
- if (error) {
64
- prom.reject(error);
65
- } else {
66
- prom.resolve(token);
67
- }
68
- });
69
- failedQueue = [];
70
- };
71
- const instance = axios__default.default.create({
72
- adapter: axios__default.default.defaults.adapter,
73
- baseURL: config.baseUrl,
74
- timeout: 5e4,
75
- paramsSerializer: (params) => new URLSearchParams(params).toString()
76
- });
77
- if (typeof window !== "undefined") {
78
- const isMaint = window.localStorage.getItem(MAINT_KEY) === "true";
79
- const onMaintenancePage = window.location.pathname === "/maintenance";
80
- if (isMaint && !onMaintenancePage) {
81
- hasRedirectedToMaintenance = true;
82
- window.location.replace("/maintenance");
83
- }
84
- if (isMaint && onMaintenancePage) {
85
- const healthUrl = config.healthUrl || `${(config.baseUrl || "").replace(/\/+$/, "")}/health`;
86
- (async () => {
87
- try {
88
- await axios__default.default.get(healthUrl, { timeout: 8e3 });
89
- await clearMaintenanceAndExit(() => localStorage.getAccessToken(), {
90
- forceLogin: true,
91
- clearTokenOnForce: true,
92
- clearToken: () => localStorage.clearToken()
93
- });
94
- } catch {
95
- }
96
- })();
97
- }
98
- }
99
- instance.interceptors.request.use(
100
- async (configReq) => {
101
- const token = await localStorage.getAccessToken();
102
- if (token) {
103
- configReq.headers["Authorization"] = "Bearer " + token;
104
- }
105
- return configReq;
106
- },
107
- (error) => Promise.reject(error)
108
- );
109
- instance.interceptors.response.use(
110
- (response) => {
111
- if (typeof window !== "undefined") {
112
- const isMaint = window.localStorage.getItem(MAINT_KEY) === "true";
113
- const onMaintenancePage = window.location.pathname === "/maintenance";
114
- if (isMaint && onMaintenancePage) {
115
- (async () => {
116
- await clearMaintenanceAndExit(
117
- () => localStorage.getAccessToken(),
118
- {
119
- forceLogin: true,
120
- clearTokenOnForce: true,
121
- clearToken: () => localStorage.clearToken()
122
- }
123
- );
124
- })();
125
- } else if (isMaint) {
126
- window.localStorage.removeItem(MAINT_KEY);
127
- window.localStorage.removeItem(MAINT_AT);
128
- window.localStorage.removeItem(MAINT_LAST_PATH);
129
- }
130
- }
131
- return handleResponse(response);
132
- },
133
- async (error) => {
134
- const status = error?.response?.status;
135
- if (status === 503) {
136
- if (typeof window !== "undefined") {
137
- setMaintenanceFlags();
138
- if (!hasRedirectedToMaintenance && window.location.pathname !== "/maintenance") {
139
- hasRedirectedToMaintenance = true;
140
- window.location.replace("/maintenance");
141
- }
142
- }
143
- return Promise.reject({
144
- code: 503,
145
- message: "SERVICE_UNAVAILABLE",
146
- original: error?.response?.data
147
- });
148
- }
149
- const handleError = async (err) => {
150
- if (!err.response) {
151
- return err;
152
- }
153
- const { data } = err.response;
154
- if (data && data.code === 400 && ["invalid_grant"].includes(data.data?.error)) {
155
- await clearAuthToken();
156
- }
157
- return data;
158
- };
159
- const originalRequest = error.config;
160
- if ((error.response?.status === 403 || error.response?.status === 401 || error.response?.status === 404) && ["TOKEN_EXPIRED", "AUTHEN_FAIL", 401].includes(
161
- error.response.data.code
162
- )) {
163
- if (isRefreshing) {
164
- return new Promise(function(resolve, reject) {
165
- failedQueue.push({ resolve, reject });
166
- }).then((token) => {
167
- originalRequest.headers["Authorization"] = "Bearer " + token;
168
- return instance.request(originalRequest);
169
- }).catch(async (err) => {
170
- if ((err.response?.status === 400 || err.response?.status === 401) && ["invalid_grant"].includes(err.response.data.error)) {
171
- await clearAuthToken();
172
- }
173
- });
174
- }
175
- const browserSession = await sessionStorage.getBrowserSession();
176
- const refreshToken = await localStorage.getRefreshToken();
177
- const accessTokenExp = await localStorage.getAccessToken();
178
- isRefreshing = true;
179
- if (!refreshToken && (!browserSession || browserSession == "unActive")) {
180
- await clearAuthToken();
181
- } else {
182
- const payload = Object.fromEntries(
183
- Object.entries({
184
- refresh_token: refreshToken,
185
- grant_type: "refresh_token",
186
- client_id: config.config.clientId,
187
- client_secret: config.config.clientSecret
188
- }).filter(([_, value]) => !!value)
189
- );
190
- return new Promise(function(resolve) {
191
- axios__default.default.post(
192
- `${config.baseUrl}${"/authentication/oauth2/token" /* AUTH_TOKEN_PATH */}`,
193
- payload,
194
- {
195
- headers: {
196
- "Content-Type": "multipart/form-data",
197
- Authorization: `Bearer ${accessTokenExp}`
198
- }
199
- }
200
- ).then(async (res) => {
201
- const data = res.data;
202
- await localStorage.setToken(data.access_token);
203
- await localStorage.setRefreshToken(data.refresh_token);
204
- axios__default.default.defaults.headers.common["Authorization"] = "Bearer " + data.access_token;
205
- originalRequest.headers["Authorization"] = "Bearer " + data.access_token;
206
- processQueue(null, data.access_token);
207
- resolve(instance.request(originalRequest));
208
- }).catch(async (err) => {
209
- if (err && (err?.error_code === "AUTHEN_FAIL" || err?.error_code === "TOKEN_EXPIRED" || err?.error_code === "TOKEN_INCORRECT" || err?.code === "ERR_BAD_REQUEST")) {
210
- await clearAuthToken();
211
- }
212
- if (err && err.response) {
213
- const { error_code } = err.response?.data || {};
214
- if (error_code === "AUTHEN_FAIL") {
215
- await clearAuthToken();
216
- }
217
- }
218
- processQueue(err, null);
219
- }).finally(() => {
220
- isRefreshing = false;
221
- });
222
- });
223
- }
224
- }
225
- return Promise.reject(await handleError(error));
226
- }
227
- );
228
- const handleResponse = (res) => {
229
- if (res && res.data) {
230
- return res.data;
231
- }
232
- return res;
233
- };
234
- const clearAuthToken = async () => {
235
- await localStorage.clearToken();
236
- if (typeof window !== "undefined") {
237
- window.location.href = `/login`;
238
- }
239
- };
240
- function formatUrl(url, db2) {
241
- return url + (db2 ? "?db=" + db2 : "");
242
- }
243
- const responseBody = (response) => response;
244
- const requests = {
245
- get: (url, headers) => instance.get(formatUrl(url, db), headers).then(responseBody),
246
- post: (url, body, headers) => instance.post(formatUrl(url, db), body, { headers }).then(responseBody),
247
- post_excel: (url, body, headers) => instance.post(formatUrl(url, db), body, {
248
- responseType: "arraybuffer",
249
- headers: {
250
- "Content-Type": typeof window !== "undefined" ? "application/json" : "application/javascript",
251
- Accept: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
252
- }
253
- }).then(responseBody),
254
- put: (url, body, headers) => instance.put(formatUrl(url, db), body, headers).then(responseBody),
255
- patch: (url, body) => instance.patch(formatUrl(url, db), body).then(responseBody),
256
- delete: (url, body) => instance.delete(formatUrl(url, db), body).then(responseBody)
257
- };
258
- return requests;
259
- }
260
- };
261
-
262
- exports.axiosClient = axiosClient;