@cyberskill/shared 2.28.0 → 3.0.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/dist/config/config.util.cjs +1 -1
- package/dist/config/config.util.js +24 -33
- package/dist/config/eslint/index.cjs +1 -1
- package/dist/config/eslint/index.d.ts +4 -0
- package/dist/config/eslint/index.js +4 -12
- package/dist/config/graphql-codegen/graphql-codegen.util.cjs +1 -1
- package/dist/config/graphql-codegen/graphql-codegen.util.js +28 -33
- package/dist/config/storybook/storybook.preview.cjs +1 -1
- package/dist/config/storybook/storybook.preview.js +10 -13
- package/dist/config/vitest/vitest.e2e.cjs +1 -1
- package/dist/config/vitest/vitest.e2e.js +1 -1
- package/dist/config/vitest/vitest.unit.cjs +1 -1
- package/dist/config/vitest/vitest.unit.js +19 -8
- package/dist/constant/common.cjs +1 -1
- package/dist/constant/common.js +1 -1
- package/dist/node/apollo-server/apollo-server.util.cjs +1 -1
- package/dist/node/apollo-server/apollo-server.util.js +21 -48
- package/dist/node/cli/index.cjs +2 -2
- package/dist/node/cli/index.js +109 -165
- package/dist/node/command/command.util.cjs +2 -2
- package/dist/node/command/command.util.js +135 -170
- package/dist/node/express/express.util.cjs +1 -1
- package/dist/node/express/express.util.js +39 -72
- package/dist/node/fs/fs.util.cjs +3 -3
- package/dist/node/fs/fs.util.js +45 -60
- package/dist/node/log/log.util.cjs +1 -1
- package/dist/node/log/log.util.js +29 -30
- package/dist/node/mongo/mongo.controller.cjs +1 -1
- package/dist/node/mongo/mongo.controller.js +531 -629
- package/dist/node/mongo/mongo.util.cjs +2 -2
- package/dist/node/mongo/mongo.util.js +280 -321
- package/dist/node/package/package.util.cjs +1 -1
- package/dist/node/package/package.util.js +197 -226
- package/dist/node/path/index.cjs +1 -1
- package/dist/node/path/index.js +26 -25
- package/dist/node/path/path.constant.cjs +1 -1
- package/dist/node/path/path.constant.d.ts +2 -0
- package/dist/node/path/path.constant.js +130 -150
- package/dist/node/storage/storage.util.cjs +1 -1
- package/dist/node/storage/storage.util.js +110 -158
- package/dist/node/upload/upload.util.cjs +1 -1
- package/dist/node/upload/upload.util.js +119 -150
- package/dist/node/ws/ts.util.cjs +1 -1
- package/dist/node/ws/ts.util.js +31 -54
- package/dist/react/apollo-client/apollo-client.component.cjs +1 -1
- package/dist/react/apollo-client/apollo-client.component.js +4 -4
- package/dist/react/apollo-client/apollo-client.util.cjs +1 -1
- package/dist/react/apollo-client/apollo-client.util.js +51 -58
- package/dist/react/apollo-client/links/upload.cjs +1 -1
- package/dist/react/apollo-client/links/upload.js +71 -74
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.util.cjs +1 -1
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.util.js +11 -18
- package/dist/react/apollo-error/apollo-error.component.cjs +1 -1
- package/dist/react/apollo-error/apollo-error.component.js +61 -23
- package/dist/react/apollo-error/apollo-error.module.scss.cjs +1 -1
- package/dist/react/apollo-error/apollo-error.module.scss.js +6 -6
- package/dist/react/apollo-error/apollo-error.test.unit.d.ts +1 -0
- package/dist/react/apollo-error/apollo-error.util.cjs +1 -1
- package/dist/react/apollo-error/apollo-error.util.js +6 -6
- package/dist/react/loading/loading.component.cjs +2 -2
- package/dist/react/loading/loading.component.js +30 -46
- package/dist/react/log/log.util.cjs +1 -1
- package/dist/react/log/log.util.js +4 -4
- package/dist/react/next-intl/next-intl.hoc.cjs +1 -1
- package/dist/react/next-intl/next-intl.hoc.js +13 -22
- package/dist/react/next-intl/next-intl.provider.cjs +1 -1
- package/dist/react/next-intl/next-intl.provider.js +7 -7
- package/dist/react/storage/storage.hook.cjs +1 -1
- package/dist/react/storage/storage.hook.js +43 -59
- package/dist/react/storage/storage.util.cjs +1 -1
- package/dist/react/storage/storage.util.js +28 -53
- package/dist/react/userback/userback.component.cjs +1 -1
- package/dist/react/userback/userback.component.js +18 -42
- package/dist/style.css +1 -1
- package/dist/util/common/common.util.cjs +1 -1
- package/dist/util/common/common.util.d.ts +2 -0
- package/dist/util/common/common.util.js +29 -37
- package/dist/util/index.cjs +1 -1
- package/dist/util/index.js +10 -9
- package/dist/util/object/object.util.cjs +1 -1
- package/dist/util/object/object.util.js +72 -76
- package/dist/util/string/index.cjs +1 -1
- package/dist/util/string/index.js +4 -3
- package/dist/util/string/string.util.cjs +1 -1
- package/dist/util/string/string.util.d.ts +12 -0
- package/dist/util/string/string.util.js +63 -44
- package/package.json +25 -16
- package/public/tsconfig.base.json +7 -3
- package/README.md +0 -470
- /package/dist/node_modules/.pnpm/{vitest@4.0.18_@types_node@25.3.0_jiti@2.6.1_jsdom@28.1.0_@noble_hashes@1.8.0__sass@1.97.3_tsx@4.21.0_yaml@2.8.2 → vitest@4.0.18_@types_node@25.3.3_jiti@2.6.1_jsdom@28.1.0_@noble_hashes@1.8.0__sass@1.97.3_tsx@4.21.0_yaml@2.8.2}/node_modules/vitest/dist/config.cjs +0 -0
- /package/dist/node_modules/.pnpm/{vitest@4.0.18_@types_node@25.3.0_jiti@2.6.1_jsdom@28.1.0_@noble_hashes@1.8.0__sass@1.97.3_tsx@4.21.0_yaml@2.8.2 → vitest@4.0.18_@types_node@25.3.3_jiti@2.6.1_jsdom@28.1.0_@noble_hashes@1.8.0__sass@1.97.3_tsx@4.21.0_yaml@2.8.2}/node_modules/vitest/dist/config.js +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("../common/common.util.cjs");function c(e,n){let t=e.trim();return t=u.removeAccent(t),n?.lower!==!1&&(t=t.toLowerCase()),t=t.replace(/[^a-z0-9\s-]/gi," "),t=t.replace(/[\s-]+/g,"-"),t=t.replace(/^-+|-+$/g,""),t}function f(e,n){const t=r=>c(r??"",n);if(typeof e=="object"&&e!==null){const r={};for(const[o,i]of Object.entries(e))r[o]=t(i);return r}return t(e)}function m(e,n=4){let t=2166136261;for(let o=0;o<e.length;o++)t^=e.charCodeAt(o),t=Math.imul(t,16777619);const r=(t>>>0).toString(16).padStart(8,"0");return n>8?e.replace(/-/g,"").slice(0,n):r.slice(0,n)}function l(e,n){const t=Math.floor(4294967296/n.length)*n.length,r=[],o=16384;for(;r.length<e;){const i=e-r.length,g=i>o?o:i,s=new Uint32Array(g);crypto.getRandomValues(s);for(const a of s){if(r.length>=e)break;a<t&&r.push(n[a%n.length])}}return r.join("")}function d(e=8){if(!Number.isSafeInteger(e)||e<0)throw new RangeError("length must be a non-negative safe integer");return l(e,"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_+[]{}|;:,.<>?")}function h(e=8,n="abcdefghijklmnopqrstuvwxyz0123456789"){if(!Number.isSafeInteger(e)||e<0)throw new RangeError("length must be a non-negative safe integer");if(n.length===0||n.length>2**32)throw new RangeError("charset.length must be between 1 and 2^32");return l(e,n)}function w(e="",n=!1){const t=e.split(/[?#]/)[0]||"",r=t.substring(t.lastIndexOf("/")+1);if(n)return r;const o=r.lastIndexOf(".");return o>0?r.slice(0,o):r}function b(e,n,t){const r=e.indexOf(n);if(r===-1)return"";const o=r+n.length,i=e.indexOf(t,o);return i===-1?"":e.slice(o,i)}exports.generateRandomPassword=d;exports.generateRandomString=h;exports.generateShortId=m;exports.generateSlug=f;exports.getFileName=w;exports.substringBetween=b;
|
|
@@ -28,8 +28,20 @@ export declare function generateShortId(uuid: string, length?: number): string;
|
|
|
28
28
|
*
|
|
29
29
|
* @param length - The desired length of the password (default: 8 characters).
|
|
30
30
|
* @returns A randomly generated password string with the specified length.
|
|
31
|
+
* @throws {RangeError} If `length` is not a non-negative safe integer.
|
|
31
32
|
*/
|
|
32
33
|
export declare function generateRandomPassword(length?: number): string;
|
|
34
|
+
/**
|
|
35
|
+
* Generates a random string of a given length using a secure random number generator.
|
|
36
|
+
* This function is a cryptographically secure alternative to Math.random().toString(36).
|
|
37
|
+
*
|
|
38
|
+
* @param length - The desired length of the string (default: 8 characters).
|
|
39
|
+
* @param charset - The characters to use (default: lowercase alphanumeric).
|
|
40
|
+
* @returns A randomly generated string.
|
|
41
|
+
* @throws {RangeError} If `length` is not a non-negative safe integer.
|
|
42
|
+
* @throws {RangeError} If `charset` is empty or exceeds 2^32 characters.
|
|
43
|
+
*/
|
|
44
|
+
export declare function generateRandomString(length?: number, charset?: string): string;
|
|
33
45
|
/**
|
|
34
46
|
* Get the file name from a URL.
|
|
35
47
|
* This function extracts the file name from a URL, optionally including or excluding
|
|
@@ -1,50 +1,69 @@
|
|
|
1
1
|
import { removeAccent as c } from "../common/common.util.js";
|
|
2
|
-
function
|
|
3
|
-
let
|
|
4
|
-
return
|
|
5
|
-
}
|
|
6
|
-
function
|
|
7
|
-
const
|
|
8
|
-
if (typeof
|
|
9
|
-
const
|
|
10
|
-
for (const [o,
|
|
11
|
-
|
|
12
|
-
return
|
|
2
|
+
function u(e, n) {
|
|
3
|
+
let t = e.trim();
|
|
4
|
+
return t = c(t), n?.lower !== !1 && (t = t.toLowerCase()), t = t.replace(/[^a-z0-9\s-]/gi, " "), t = t.replace(/[\s-]+/g, "-"), t = t.replace(/^-+|-+$/g, ""), t;
|
|
5
|
+
}
|
|
6
|
+
function m(e, n) {
|
|
7
|
+
const t = (r) => u(r ?? "", n);
|
|
8
|
+
if (typeof e == "object" && e !== null) {
|
|
9
|
+
const r = {};
|
|
10
|
+
for (const [o, i] of Object.entries(e))
|
|
11
|
+
r[o] = t(i);
|
|
12
|
+
return r;
|
|
13
|
+
}
|
|
14
|
+
return t(e);
|
|
15
|
+
}
|
|
16
|
+
function h(e, n = 4) {
|
|
17
|
+
let t = 2166136261;
|
|
18
|
+
for (let o = 0; o < e.length; o++)
|
|
19
|
+
t ^= e.charCodeAt(o), t = Math.imul(t, 16777619);
|
|
20
|
+
const r = (t >>> 0).toString(16).padStart(8, "0");
|
|
21
|
+
return n > 8 ? e.replace(/-/g, "").slice(0, n) : r.slice(0, n);
|
|
22
|
+
}
|
|
23
|
+
function f(e, n) {
|
|
24
|
+
const t = Math.floor(4294967296 / n.length) * n.length, r = [], o = 16384;
|
|
25
|
+
for (; r.length < e; ) {
|
|
26
|
+
const i = e - r.length, l = i > o ? o : i, s = new Uint32Array(l);
|
|
27
|
+
crypto.getRandomValues(s);
|
|
28
|
+
for (const a of s) {
|
|
29
|
+
if (r.length >= e)
|
|
30
|
+
break;
|
|
31
|
+
a < t && r.push(n[a % n.length]);
|
|
32
|
+
}
|
|
13
33
|
}
|
|
14
|
-
return
|
|
15
|
-
}
|
|
16
|
-
function
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const n = t.indexOf(r);
|
|
39
|
-
if (n === -1)
|
|
34
|
+
return r.join("");
|
|
35
|
+
}
|
|
36
|
+
function d(e = 8) {
|
|
37
|
+
if (!Number.isSafeInteger(e) || e < 0)
|
|
38
|
+
throw new RangeError("length must be a non-negative safe integer");
|
|
39
|
+
return f(e, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_+[]{}|;:,.<>?");
|
|
40
|
+
}
|
|
41
|
+
function w(e = 8, n = "abcdefghijklmnopqrstuvwxyz0123456789") {
|
|
42
|
+
if (!Number.isSafeInteger(e) || e < 0)
|
|
43
|
+
throw new RangeError("length must be a non-negative safe integer");
|
|
44
|
+
if (n.length === 0 || n.length > 2 ** 32)
|
|
45
|
+
throw new RangeError("charset.length must be between 1 and 2^32");
|
|
46
|
+
return f(e, n);
|
|
47
|
+
}
|
|
48
|
+
function b(e = "", n = !1) {
|
|
49
|
+
const t = e.split(/[?#]/)[0] || "", r = t.substring(t.lastIndexOf("/") + 1);
|
|
50
|
+
if (n)
|
|
51
|
+
return r;
|
|
52
|
+
const o = r.lastIndexOf(".");
|
|
53
|
+
return o > 0 ? r.slice(0, o) : r;
|
|
54
|
+
}
|
|
55
|
+
function p(e, n, t) {
|
|
56
|
+
const r = e.indexOf(n);
|
|
57
|
+
if (r === -1)
|
|
40
58
|
return "";
|
|
41
|
-
const o =
|
|
42
|
-
return
|
|
59
|
+
const o = r + n.length, i = e.indexOf(t, o);
|
|
60
|
+
return i === -1 ? "" : e.slice(o, i);
|
|
43
61
|
}
|
|
44
62
|
export {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
63
|
+
d as generateRandomPassword,
|
|
64
|
+
w as generateRandomString,
|
|
65
|
+
h as generateShortId,
|
|
66
|
+
m as generateSlug,
|
|
67
|
+
b as getFileName,
|
|
68
|
+
p as substringBetween
|
|
50
69
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cyberskill/shared",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "3.0.0",
|
|
5
5
|
"description": "CyberSkill Shared",
|
|
6
6
|
"author": "Stephen Cheng",
|
|
7
7
|
"license": "MIT",
|
|
@@ -197,6 +197,9 @@
|
|
|
197
197
|
"dist",
|
|
198
198
|
"public"
|
|
199
199
|
],
|
|
200
|
+
"engines": {
|
|
201
|
+
"node": ">=24.0.0"
|
|
202
|
+
},
|
|
200
203
|
"scripts": {
|
|
201
204
|
"ai:setup": "tsx src/node/cli/index.ts ai:setup",
|
|
202
205
|
"build": "vite build",
|
|
@@ -213,15 +216,15 @@
|
|
|
213
216
|
"test:unit": "tsx src/node/cli/index.ts test:unit"
|
|
214
217
|
},
|
|
215
218
|
"dependencies": {
|
|
216
|
-
"@antfu/eslint-config": "7.
|
|
217
|
-
"@apollo/client": "4.1.
|
|
219
|
+
"@antfu/eslint-config": "7.6.1",
|
|
220
|
+
"@apollo/client": "4.1.6",
|
|
218
221
|
"@apollo/client-integration-nextjs": "0.14.4",
|
|
219
222
|
"@apollo/server": "5.4.0",
|
|
220
223
|
"@as-integrations/express5": "1.1.2",
|
|
221
224
|
"@dotenvx/dotenvx": "1.52.0",
|
|
222
225
|
"@eddeee888/gcg-typescript-resolver-files": "0.15.0",
|
|
223
226
|
"@eslint-react/eslint-plugin": "2.13.0",
|
|
224
|
-
"@graphql-codegen/cli": "6.1.
|
|
227
|
+
"@graphql-codegen/cli": "6.1.2",
|
|
225
228
|
"@graphql-codegen/client-preset": "5.2.3",
|
|
226
229
|
"@nestjs/common": "11.1.14",
|
|
227
230
|
"@nestjs/core": "11.1.14",
|
|
@@ -236,25 +239,25 @@
|
|
|
236
239
|
"cors": "2.8.6",
|
|
237
240
|
"date-fns": "4.1.0",
|
|
238
241
|
"envalid": "8.1.1",
|
|
239
|
-
"eslint-plugin-format": "
|
|
242
|
+
"eslint-plugin-format": "2.0.1",
|
|
240
243
|
"eslint-plugin-react-hooks": "7.0.1",
|
|
241
|
-
"eslint-plugin-react-refresh": "0.5.
|
|
244
|
+
"eslint-plugin-react-refresh": "0.5.2",
|
|
242
245
|
"express": "5.2.1",
|
|
243
246
|
"express-session": "1.19.0",
|
|
244
247
|
"express-useragent": "2.1.0",
|
|
245
248
|
"extract-files": "13.0.0",
|
|
246
249
|
"fs-extra": "11.3.3",
|
|
247
|
-
"globals": "17.
|
|
248
|
-
"graphql": "16.
|
|
250
|
+
"globals": "17.4.0",
|
|
251
|
+
"graphql": "16.13.0",
|
|
249
252
|
"graphql-upload": "17.0.0",
|
|
250
253
|
"graphql-ws": "6.0.7",
|
|
251
254
|
"helmet": "8.1.0",
|
|
252
|
-
"i18next": "25.8.
|
|
255
|
+
"i18next": "25.8.13",
|
|
253
256
|
"jsdom": "28.1.0",
|
|
254
257
|
"localforage": "1.10.0",
|
|
255
258
|
"migrate-mongo": "14.0.7",
|
|
256
259
|
"mongodb": "7.1.0",
|
|
257
|
-
"mongoose": "9.2.
|
|
260
|
+
"mongoose": "9.2.3",
|
|
258
261
|
"mongoose-aggregate-paginate-v2": "1.1.4",
|
|
259
262
|
"mongoose-paginate-v2": "1.9.1",
|
|
260
263
|
"next-intl": "4.8.3",
|
|
@@ -274,8 +277,8 @@
|
|
|
274
277
|
"@commitlint/config-conventional": "20.4.2",
|
|
275
278
|
"@eslint/config-inspector": "1.4.2",
|
|
276
279
|
"@next/eslint-plugin-next": "16.1.6",
|
|
277
|
-
"@storybook/react": "10.2.
|
|
278
|
-
"@storybook/react-vite": "10.2.
|
|
280
|
+
"@storybook/react": "10.2.14",
|
|
281
|
+
"@storybook/react-vite": "10.2.14",
|
|
279
282
|
"@testing-library/jest-dom": "6.9.1",
|
|
280
283
|
"@testing-library/react": "16.3.2",
|
|
281
284
|
"@types/body-parser": "1.19.6",
|
|
@@ -289,16 +292,16 @@
|
|
|
289
292
|
"@types/fs-extra": "11.0.4",
|
|
290
293
|
"@types/graphql-upload": "17.0.0",
|
|
291
294
|
"@types/migrate-mongo": "10.0.6",
|
|
292
|
-
"@types/node": "25.3.
|
|
295
|
+
"@types/node": "25.3.3",
|
|
293
296
|
"@types/react": "19.2.14",
|
|
294
297
|
"@types/react-dom": "19.2.3",
|
|
295
298
|
"@types/ws": "8.18.1",
|
|
296
299
|
"@types/yargs": "17.0.35",
|
|
297
300
|
"@vitest/browser": "4.0.18",
|
|
298
|
-
"eslint": "10.0.
|
|
301
|
+
"eslint": "10.0.2",
|
|
299
302
|
"eslint-config-next": "16.1.6",
|
|
300
303
|
"glob": "13.0.6",
|
|
301
|
-
"lint-staged": "16.
|
|
304
|
+
"lint-staged": "16.3.1",
|
|
302
305
|
"node-modules-inspector": "1.3.2",
|
|
303
306
|
"npm-run-all2": "8.0.4",
|
|
304
307
|
"sass": "1.97.3",
|
|
@@ -311,6 +314,12 @@
|
|
|
311
314
|
},
|
|
312
315
|
"publishConfig": {
|
|
313
316
|
"access": "public",
|
|
314
|
-
"registry": "https://registry.npmjs.org/"
|
|
317
|
+
"registry": "https://registry.npmjs.org/",
|
|
318
|
+
"provenance": true
|
|
319
|
+
},
|
|
320
|
+
"pnpm": {
|
|
321
|
+
"overrides": {
|
|
322
|
+
"minimatch": ">=10.2.3"
|
|
323
|
+
}
|
|
315
324
|
}
|
|
316
325
|
}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
-
"target": "
|
|
3
|
+
"target": "ES2022",
|
|
4
4
|
"jsx": "react",
|
|
5
|
-
"lib": [
|
|
5
|
+
"lib": [
|
|
6
|
+
"ESNext",
|
|
7
|
+
"DOM",
|
|
8
|
+
"DOM.Iterable"
|
|
9
|
+
],
|
|
6
10
|
"useDefineForClassFields": true,
|
|
7
11
|
"emitDecoratorMetadata": true,
|
|
8
12
|
"experimentalDecorators": true,
|
|
@@ -34,4 +38,4 @@
|
|
|
34
38
|
"noUncheckedSideEffectImports": true,
|
|
35
39
|
"skipLibCheck": true
|
|
36
40
|
}
|
|
37
|
-
}
|
|
41
|
+
}
|