@cyberskill/shared 2.27.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.
Files changed (98) hide show
  1. package/dist/config/config.util.cjs +1 -1
  2. package/dist/config/config.util.js +24 -33
  3. package/dist/config/eslint/index.cjs +1 -1
  4. package/dist/config/eslint/index.d.ts +6 -0
  5. package/dist/config/eslint/index.js +4 -12
  6. package/dist/config/graphql-codegen/graphql-codegen.util.cjs +1 -1
  7. package/dist/config/graphql-codegen/graphql-codegen.util.js +28 -33
  8. package/dist/config/storybook/storybook.preview.cjs +1 -1
  9. package/dist/config/storybook/storybook.preview.js +10 -13
  10. package/dist/config/vitest/vitest.e2e.cjs +1 -1
  11. package/dist/config/vitest/vitest.e2e.js +1 -1
  12. package/dist/config/vitest/vitest.unit.cjs +1 -1
  13. package/dist/config/vitest/vitest.unit.js +19 -8
  14. package/dist/constant/common.cjs +1 -1
  15. package/dist/constant/common.js +1 -1
  16. package/dist/node/apollo-server/apollo-server.util.cjs +1 -1
  17. package/dist/node/apollo-server/apollo-server.util.js +21 -48
  18. package/dist/node/cli/index.cjs +2 -5
  19. package/dist/node/cli/index.js +109 -170
  20. package/dist/node/command/command.util.cjs +2 -2
  21. package/dist/node/command/command.util.js +135 -170
  22. package/dist/node/express/express.util.cjs +1 -1
  23. package/dist/node/express/express.util.js +39 -72
  24. package/dist/node/fs/fs.util.cjs +4 -1
  25. package/dist/node/fs/fs.util.d.ts +8 -0
  26. package/dist/node/fs/fs.util.js +46 -53
  27. package/dist/node/fs/index.cjs +1 -1
  28. package/dist/node/fs/index.js +13 -12
  29. package/dist/node/log/log.util.cjs +1 -1
  30. package/dist/node/log/log.util.js +29 -30
  31. package/dist/node/mongo/mongo.controller.cjs +1 -1
  32. package/dist/node/mongo/mongo.controller.js +531 -629
  33. package/dist/node/mongo/mongo.type.js +3 -3
  34. package/dist/node/mongo/mongo.util.cjs +2 -5
  35. package/dist/node/mongo/mongo.util.js +308 -354
  36. package/dist/node/package/package.util.cjs +1 -1
  37. package/dist/node/package/package.util.js +197 -226
  38. package/dist/node/path/index.cjs +1 -1
  39. package/dist/node/path/index.js +26 -25
  40. package/dist/node/path/path.constant.cjs +1 -1
  41. package/dist/node/path/path.constant.d.ts +2 -0
  42. package/dist/node/path/path.constant.js +130 -150
  43. package/dist/node/storage/storage.util.cjs +1 -1
  44. package/dist/node/storage/storage.util.js +110 -158
  45. package/dist/node/upload/upload.util.cjs +1 -1
  46. package/dist/node/upload/upload.util.js +119 -150
  47. package/dist/node/ws/ts.util.cjs +1 -1
  48. package/dist/node/ws/ts.util.js +31 -54
  49. package/dist/react/apollo-client/apollo-client.component.cjs +1 -1
  50. package/dist/react/apollo-client/apollo-client.component.js +4 -4
  51. package/dist/react/apollo-client/apollo-client.util.cjs +1 -1
  52. package/dist/react/apollo-client/apollo-client.util.js +51 -58
  53. package/dist/react/apollo-client/links/upload.cjs +1 -1
  54. package/dist/react/apollo-client/links/upload.js +71 -74
  55. package/dist/react/apollo-client-nextjs/apollo-client-nextjs.util.cjs +1 -1
  56. package/dist/react/apollo-client-nextjs/apollo-client-nextjs.util.js +11 -18
  57. package/dist/react/apollo-error/apollo-error.component.cjs +1 -1
  58. package/dist/react/apollo-error/apollo-error.component.js +61 -23
  59. package/dist/react/apollo-error/apollo-error.module.scss.cjs +1 -1
  60. package/dist/react/apollo-error/apollo-error.module.scss.js +6 -6
  61. package/dist/react/apollo-error/apollo-error.test.unit.d.ts +1 -0
  62. package/dist/react/apollo-error/apollo-error.util.cjs +1 -1
  63. package/dist/react/apollo-error/apollo-error.util.js +6 -6
  64. package/dist/react/loading/loading.component.cjs +2 -2
  65. package/dist/react/loading/loading.component.js +30 -46
  66. package/dist/react/log/log.util.cjs +1 -1
  67. package/dist/react/log/log.util.js +4 -4
  68. package/dist/react/next-intl/next-intl.hoc.cjs +1 -1
  69. package/dist/react/next-intl/next-intl.hoc.js +13 -22
  70. package/dist/react/next-intl/next-intl.provider.cjs +1 -1
  71. package/dist/react/next-intl/next-intl.provider.js +7 -7
  72. package/dist/react/storage/storage.hook.cjs +1 -1
  73. package/dist/react/storage/storage.hook.js +43 -59
  74. package/dist/react/storage/storage.util.cjs +1 -1
  75. package/dist/react/storage/storage.util.js +28 -53
  76. package/dist/react/userback/userback.component.cjs +1 -1
  77. package/dist/react/userback/userback.component.js +18 -42
  78. package/dist/style.css +1 -1
  79. package/dist/util/common/common.util.cjs +1 -1
  80. package/dist/util/common/common.util.d.ts +11 -0
  81. package/dist/util/common/common.util.js +33 -37
  82. package/dist/util/common/index.cjs +1 -1
  83. package/dist/util/common/index.js +6 -5
  84. package/dist/util/index.cjs +1 -1
  85. package/dist/util/index.js +22 -20
  86. package/dist/util/object/object.util.cjs +1 -1
  87. package/dist/util/object/object.util.js +70 -70
  88. package/dist/util/string/index.cjs +1 -1
  89. package/dist/util/string/index.js +4 -3
  90. package/dist/util/string/string.util.cjs +1 -1
  91. package/dist/util/string/string.util.d.ts +12 -0
  92. package/dist/util/string/string.util.js +63 -44
  93. package/package.json +53 -44
  94. package/public/tsconfig.base.json +7 -3
  95. package/README.md +0 -470
  96. package/dist/node/mongo/mongo.util.d.ts +0 -1040
  97. /package/dist/node_modules/.pnpm/{vitest@4.0.17_@types_node@25.0.9_jiti@2.6.1_jsdom@27.4.0_@noble_hashes@1.8.0__sass@1.97.2_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
  98. /package/dist/node_modules/.pnpm/{vitest@4.0.17_@types_node@25.0.9_jiti@2.6.1_jsdom@27.4.0_@noble_hashes@1.8.0__sass@1.97.2_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,99 +1,99 @@
1
- var A = Object.defineProperty, d = Object.defineProperties, g = Object.getOwnPropertyDescriptors, f = Object.getOwnPropertySymbols, m = Object.prototype.hasOwnProperty, h = Object.prototype.propertyIsEnumerable, y = (e, r, n) => r in e ? A(e, r, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[r] = n, u = (e, r) => {
2
- for (var n in r || (r = {}))
3
- m.call(r, n) && y(e, n, r[n]);
4
- if (f)
5
- for (var n of f(r))
6
- h.call(r, n) && y(e, n, r[n]);
7
- return e;
8
- }, p = (e, r) => d(e, g(r));
9
- function P(e) {
1
+ function p(e) {
10
2
  try {
11
3
  return JSON.parse(e), !0;
12
- } catch (r) {
4
+ } catch {
13
5
  return !1;
14
6
  }
15
7
  }
16
- function _(e, r) {
8
+ function A(e, t) {
17
9
  let n = e;
18
- const o = r.length;
19
- for (let t = 0; t < o; t++) {
20
- const s = r[t];
21
- if (s !== void 0 && n && typeof n == "object" && s in n)
10
+ const o = t.length;
11
+ for (let r = 0; r < o; r++) {
12
+ if (n == null || typeof n != "object")
13
+ return;
14
+ const s = t[r];
15
+ if (s !== void 0 && s in n)
22
16
  n = n[s];
23
17
  else
24
18
  return;
25
19
  }
26
20
  return n;
27
21
  }
28
- function v(e, r, n) {
29
- if (r.length === 0)
22
+ function f(e, t, n, o) {
23
+ if (o >= t.length)
30
24
  return e;
31
- const [o, ...t] = r;
32
- if (t.length === 0)
33
- return p(u({}, e), {
34
- [o]: n
35
- });
36
- const s = e[o];
37
- return p(u({}, e), {
38
- [o]: v(
25
+ const r = t[o];
26
+ if (o === t.length - 1)
27
+ return {
28
+ ...e,
29
+ [r]: n
30
+ };
31
+ const s = e[r];
32
+ return {
33
+ ...e,
34
+ [r]: f(
39
35
  typeof s == "object" && s !== null ? s : {},
40
36
  t,
41
- n
37
+ n,
38
+ o + 1
42
39
  )
43
- });
40
+ };
44
41
  }
45
- function O(e) {
42
+ function g(e, t, n) {
43
+ return t.length === 0 ? e : f(e, t, n, 0);
44
+ }
45
+ function u(e) {
46
46
  if (e === null || typeof e != "object")
47
47
  return e;
48
48
  if (Array.isArray(e))
49
- return e.map((o) => O(o));
49
+ return e.map((o) => u(o));
50
50
  if (e instanceof Date)
51
51
  return new Date(e.getTime());
52
52
  if (e instanceof RegExp)
53
53
  return new RegExp(e.source, e.flags);
54
- const r = Object.getPrototypeOf(e);
55
- if (r !== Object.prototype && r !== null)
54
+ const t = Object.getPrototypeOf(e);
55
+ if (t !== Object.prototype && t !== null)
56
56
  return e;
57
57
  const n = {};
58
58
  for (const o in e)
59
- Object.prototype.hasOwnProperty.call(e, o) && (n[o] = O(e[o]));
59
+ Object.prototype.hasOwnProperty.call(e, o) && (n[o] = u(e[o]));
60
60
  return n;
61
61
  }
62
- function w(...e) {
62
+ function y(...e) {
63
63
  if (e.length === 0)
64
64
  return {};
65
- const r = e.filter((t) => t != null);
66
- if (r.length === 0)
65
+ const t = e.filter((r) => r != null);
66
+ if (t.length === 0)
67
67
  return {};
68
- if (r.length === 1)
69
- return r[0];
70
- if (r.every(Array.isArray))
71
- return [].concat(...r);
72
- if (r.every((t) => typeof t == "object" && t !== null && !Array.isArray(t))) {
73
- const t = {};
74
- for (const s of r) {
68
+ if (t.length === 1)
69
+ return t[0];
70
+ if (t.every(Array.isArray))
71
+ return [].concat(...t);
72
+ if (t.every((r) => typeof r == "object" && r !== null && !Array.isArray(r))) {
73
+ const r = {};
74
+ for (const s of t) {
75
75
  const i = s;
76
- for (const a in i)
77
- if (Object.prototype.hasOwnProperty.call(i, a)) {
78
- const l = i[a];
79
- if (Object.prototype.hasOwnProperty.call(t, a)) {
80
- const c = t[a];
81
- typeof l == "object" && l !== null && typeof c == "object" && c !== null ? Array.isArray(l) && Array.isArray(c) ? t[a] = c.concat(l) : !Array.isArray(l) && !Array.isArray(c) ? t[a] = w(
76
+ for (const l in i)
77
+ if (Object.prototype.hasOwnProperty.call(i, l)) {
78
+ const a = i[l];
79
+ if (Object.prototype.hasOwnProperty.call(r, l)) {
80
+ const c = r[l];
81
+ typeof a == "object" && a !== null && typeof c == "object" && c !== null ? Array.isArray(a) && Array.isArray(c) ? r[l] = c.concat(a) : !Array.isArray(a) && !Array.isArray(c) ? r[l] = y(
82
82
  c,
83
- l
84
- ) : t[a] = l : t[a] = l;
83
+ a
84
+ ) : r[l] = a : r[l] = a;
85
85
  } else
86
- t[a] = l;
86
+ r[l] = a;
87
87
  }
88
88
  }
89
- return t;
89
+ return r;
90
90
  }
91
- if (r.every((t) => typeof t != "object" || t === null))
91
+ if (t.every((r) => typeof r != "object" || r === null))
92
92
  throw new Error(
93
93
  "deepMerge: Cannot merge primitive values. All arguments must be objects or arrays."
94
94
  );
95
- const n = r.some(Array.isArray), o = r.some(
96
- (t) => typeof t == "object" && t !== null && !Array.isArray(t)
95
+ const n = t.some(Array.isArray), o = t.some(
96
+ (r) => typeof r == "object" && r !== null && !Array.isArray(r)
97
97
  );
98
98
  throw n && o ? new Error(
99
99
  "deepMerge: Cannot mix arrays and objects. All arguments must be either arrays or objects."
@@ -101,34 +101,34 @@ function w(...e) {
101
101
  "deepMerge: Invalid arguments provided. All arguments must be objects or arrays of the same type."
102
102
  );
103
103
  }
104
- function b(e) {
104
+ function h(e) {
105
105
  if (!e || typeof e != "object")
106
106
  return e;
107
- const r = {};
108
- function n(o, t) {
107
+ const t = {};
108
+ function n(o, r) {
109
109
  for (const s in o) {
110
110
  if (!Object.prototype.hasOwnProperty.call(o, s))
111
111
  continue;
112
- const i = o[s], a = t ? `${t}.${s}` : s;
112
+ const i = o[s], l = r ? `${r}.${s}` : s;
113
113
  if (i && typeof i == "object" && !Array.isArray(i)) {
114
- let l = !1;
114
+ let a = !1;
115
115
  for (const c in i)
116
116
  if (Object.prototype.hasOwnProperty.call(i, c) && c.startsWith("$")) {
117
- l = !0;
117
+ a = !0;
118
118
  break;
119
119
  }
120
- l ? r[a] = i : n(i, a);
120
+ a ? t[l] = i : n(i, l);
121
121
  } else
122
- r[a] = i;
122
+ t[l] = i;
123
123
  }
124
124
  }
125
- return n(e, ""), r;
125
+ return n(e, ""), t;
126
126
  }
127
127
  export {
128
- O as deepClone,
129
- w as deepMerge,
130
- _ as getNestedValue,
131
- P as isJSON,
132
- b as normalizeMongoFilter,
133
- v as setNestedValue
128
+ u as deepClone,
129
+ y as deepMerge,
130
+ A as getNestedValue,
131
+ p as isJSON,
132
+ h as normalizeMongoFilter,
133
+ g as setNestedValue
134
134
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./string.util.cjs");exports.generateRandomPassword=e.generateRandomPassword;exports.generateShortId=e.generateShortId;exports.generateSlug=e.generateSlug;exports.getFileName=e.getFileName;exports.substringBetween=e.substringBetween;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./string.util.cjs");exports.generateRandomPassword=e.generateRandomPassword;exports.generateRandomString=e.generateRandomString;exports.generateShortId=e.generateShortId;exports.generateSlug=e.generateSlug;exports.getFileName=e.getFileName;exports.substringBetween=e.substringBetween;
@@ -1,8 +1,9 @@
1
- import { generateRandomPassword as t, generateShortId as a, generateSlug as g, getFileName as n, substringBetween as o } from "./string.util.js";
1
+ import { generateRandomPassword as t, generateRandomString as n, generateShortId as a, generateSlug as g, getFileName as o, substringBetween as d } from "./string.util.js";
2
2
  export {
3
3
  t as generateRandomPassword,
4
+ n as generateRandomString,
4
5
  a as generateShortId,
5
6
  g as generateSlug,
6
- n as getFileName,
7
- o as substringBetween
7
+ o as getFileName,
8
+ d as substringBetween
8
9
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("../common/common.util.cjs");function a(t,r){let e=t.trim();return e=l.removeAccent(e),(r==null?void 0:r.lower)!==!1&&(e=e.toLowerCase()),e=e.replace(/[^a-z0-9\s-]/gi," "),e=e.replace(/[\s-]+/g,"-"),e=e.replace(/^-+|-+$/g,""),e}function c(t,r){const e=n=>a(n!=null?n:"",r);if(typeof t=="object"&&t!==null){const n={};for(const[o,s]of Object.entries(t))n[o]=e(s);return n}return e(t)}function i(t,r=4){let e=2166136261;for(let o=0;o<t.length;o++)e^=t.charCodeAt(o),e=Math.imul(e,16777619);const n=(e>>>0).toString(16).padStart(8,"0");return r>8?t.replace(/-/g,"").slice(0,r):n.slice(0,r)}function u(t=8){const r="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_+[]{}|;:,.<>?";return Array.from({length:t},()=>{const e=Math.floor(Math.random()*r.length);return r.charAt(e)}).join("")}function f(t="",r=!1){const e=t.split(/[?#]/)[0]||"",n=e.substring(e.lastIndexOf("/")+1);if(r)return n;const o=n.lastIndexOf(".");return o>0?n.slice(0,o):n}function g(t,r,e){const n=t.indexOf(r);if(n===-1)return"";const o=n+r.length,s=t.indexOf(e,o);return s===-1?"":t.slice(o,s)}exports.generateRandomPassword=u;exports.generateShortId=i;exports.generateSlug=c;exports.getFileName=f;exports.substringBetween=g;
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 l(t, r) {
3
- let e = t.trim();
4
- return e = c(e), (r == null ? void 0 : r.lower) !== !1 && (e = e.toLowerCase()), e = e.replace(/[^a-z0-9\s-]/gi, " "), e = e.replace(/[\s-]+/g, "-"), e = e.replace(/^-+|-+$/g, ""), e;
5
- }
6
- function a(t, r) {
7
- const e = (n) => l(n != null ? n : "", r);
8
- if (typeof t == "object" && t !== null) {
9
- const n = {};
10
- for (const [o, s] of Object.entries(t))
11
- n[o] = e(s);
12
- return n;
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 e(t);
15
- }
16
- function f(t, r = 4) {
17
- let e = 2166136261;
18
- for (let o = 0; o < t.length; o++)
19
- e ^= t.charCodeAt(o), e = Math.imul(e, 16777619);
20
- const n = (e >>> 0).toString(16).padStart(8, "0");
21
- return r > 8 ? t.replace(/-/g, "").slice(0, r) : n.slice(0, r);
22
- }
23
- function u(t = 8) {
24
- const r = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_+[]{}|;:,.<>?";
25
- return Array.from({ length: t }, () => {
26
- const e = Math.floor(Math.random() * r.length);
27
- return r.charAt(e);
28
- }).join("");
29
- }
30
- function g(t = "", r = !1) {
31
- const e = t.split(/[?#]/)[0] || "", n = e.substring(e.lastIndexOf("/") + 1);
32
- if (r)
33
- return n;
34
- const o = n.lastIndexOf(".");
35
- return o > 0 ? n.slice(0, o) : n;
36
- }
37
- function d(t, r, e) {
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 = n + r.length, s = t.indexOf(e, o);
42
- return s === -1 ? "" : t.slice(o, s);
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
- u as generateRandomPassword,
46
- f as generateShortId,
47
- a as generateSlug,
48
- g as getFileName,
49
- d as substringBetween
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": "2.27.0",
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,69 +216,69 @@
213
216
  "test:unit": "tsx src/node/cli/index.ts test:unit"
214
217
  },
215
218
  "dependencies": {
216
- "@antfu/eslint-config": "7.1.0",
217
- "@apollo/client": "4.1.0",
219
+ "@antfu/eslint-config": "7.6.1",
220
+ "@apollo/client": "4.1.6",
218
221
  "@apollo/client-integration-nextjs": "0.14.4",
219
- "@apollo/server": "5.2.0",
222
+ "@apollo/server": "5.4.0",
220
223
  "@as-integrations/express5": "1.1.2",
221
- "@dotenvx/dotenvx": "1.51.4",
224
+ "@dotenvx/dotenvx": "1.52.0",
222
225
  "@eddeee888/gcg-typescript-resolver-files": "0.15.0",
223
- "@eslint-react/eslint-plugin": "2.7.2",
224
- "@graphql-codegen/cli": "6.1.1",
225
- "@graphql-codegen/client-preset": "5.2.2",
226
- "@nestjs/common": "11.1.12",
227
- "@nestjs/core": "11.1.12",
226
+ "@eslint-react/eslint-plugin": "2.13.0",
227
+ "@graphql-codegen/cli": "6.1.2",
228
+ "@graphql-codegen/client-preset": "5.2.3",
229
+ "@nestjs/common": "11.1.14",
230
+ "@nestjs/core": "11.1.14",
228
231
  "@userback/widget": "0.3.12",
229
- "@vitejs/plugin-react-swc": "4.2.2",
232
+ "@vitejs/plugin-react-swc": "4.2.3",
230
233
  "body-parser": "2.2.2",
231
234
  "chalk": "5.6.2",
232
235
  "clsx": "2.1.1",
233
236
  "compression": "1.8.1",
234
237
  "consola": "3.4.2",
235
238
  "cookie-parser": "1.4.7",
236
- "cors": "2.8.5",
239
+ "cors": "2.8.6",
237
240
  "date-fns": "4.1.0",
238
241
  "envalid": "8.1.1",
239
- "eslint-plugin-format": "1.3.1",
242
+ "eslint-plugin-format": "2.0.1",
240
243
  "eslint-plugin-react-hooks": "7.0.1",
241
- "eslint-plugin-react-refresh": "0.4.26",
244
+ "eslint-plugin-react-refresh": "0.5.2",
242
245
  "express": "5.2.1",
243
- "express-session": "1.18.2",
244
- "express-useragent": "2.0.2",
246
+ "express-session": "1.19.0",
247
+ "express-useragent": "2.1.0",
245
248
  "extract-files": "13.0.0",
246
249
  "fs-extra": "11.3.3",
247
- "globals": "17.0.0",
248
- "graphql": "16.12.0",
250
+ "globals": "17.4.0",
251
+ "graphql": "16.13.0",
249
252
  "graphql-upload": "17.0.0",
250
- "graphql-ws": "6.0.6",
253
+ "graphql-ws": "6.0.7",
251
254
  "helmet": "8.1.0",
252
- "i18next": "25.8.0",
253
- "jsdom": "27.4.0",
255
+ "i18next": "25.8.13",
256
+ "jsdom": "28.1.0",
254
257
  "localforage": "1.10.0",
255
258
  "migrate-mongo": "14.0.7",
256
- "mongodb": "7.0.0",
257
- "mongoose": "9.1.5",
259
+ "mongodb": "7.1.0",
260
+ "mongoose": "9.2.3",
258
261
  "mongoose-aggregate-paginate-v2": "1.1.4",
259
262
  "mongoose-paginate-v2": "1.9.1",
260
- "next-intl": "4.7.0",
263
+ "next-intl": "4.8.3",
261
264
  "node-fetch": "3.3.2",
262
- "qs": "6.14.1",
263
- "react": "19.2.3",
264
- "react-dom": "19.2.3",
265
+ "qs": "6.15.0",
266
+ "react": "19.2.4",
267
+ "react-dom": "19.2.4",
265
268
  "react-hot-toast": "2.6.0",
266
- "react-i18next": "16.5.3",
269
+ "react-i18next": "16.5.4",
267
270
  "rxjs": "7.8.2",
268
271
  "vite": "7.3.1",
269
272
  "ws": "8.19.0",
270
273
  "yargs": "18.0.0"
271
274
  },
272
275
  "devDependencies": {
273
- "@commitlint/cli": "20.3.1",
274
- "@commitlint/config-conventional": "20.3.1",
276
+ "@commitlint/cli": "20.4.2",
277
+ "@commitlint/config-conventional": "20.4.2",
275
278
  "@eslint/config-inspector": "1.4.2",
276
- "@next/eslint-plugin-next": "16.1.4",
277
- "@storybook/react": "10.1.11",
278
- "@storybook/react-vite": "10.1.11",
279
+ "@next/eslint-plugin-next": "16.1.6",
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,28 +292,34 @@
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.0.9",
293
- "@types/react": "19.2.9",
295
+ "@types/node": "25.3.3",
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
- "@vitest/browser": "4.0.17",
298
- "eslint": "9.39.2",
299
- "eslint-config-next": "16.1.4",
300
- "glob": "13.0.0",
301
- "lint-staged": "16.2.7",
302
- "node-modules-inspector": "1.2.0",
300
+ "@vitest/browser": "4.0.18",
301
+ "eslint": "10.0.2",
302
+ "eslint-config-next": "16.1.6",
303
+ "glob": "13.0.6",
304
+ "lint-staged": "16.3.1",
305
+ "node-modules-inspector": "1.3.2",
303
306
  "npm-run-all2": "8.0.4",
304
- "sass": "1.97.2",
307
+ "sass": "1.97.3",
305
308
  "simple-git-hooks": "2.13.1",
306
309
  "tsx": "4.21.0",
307
310
  "typescript": "5.9.3",
308
311
  "vite": "7.3.1",
309
312
  "vite-plugin-dts": "4.5.4",
310
- "vitest": "4.0.17"
313
+ "vitest": "4.0.18"
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": "ES6",
3
+ "target": "ES2022",
4
4
  "jsx": "react",
5
- "lib": ["ESNext", "DOM", "DOM.Iterable"],
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
+ }