@cyberskill/shared 2.19.1 → 2.21.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 (68) hide show
  1. package/dist/config/storybook/index.cjs +1 -0
  2. package/dist/config/storybook/index.d.ts +2 -0
  3. package/dist/config/storybook/index.js +6 -0
  4. package/dist/config/storybook/storybook.main.cjs +1 -0
  5. package/dist/config/storybook/storybook.main.d.ts +17 -0
  6. package/dist/config/storybook/storybook.main.js +18 -0
  7. package/dist/config/storybook/storybook.preview.cjs +1 -0
  8. package/dist/config/storybook/storybook.preview.d.ts +18 -0
  9. package/dist/config/storybook/storybook.preview.js +39 -0
  10. package/dist/config/vitest/vitest.e2e.cjs +1 -1
  11. package/dist/config/vitest/vitest.e2e.js +6 -6
  12. package/dist/config/vitest/vitest.unit.cjs +1 -1
  13. package/dist/config/vitest/vitest.unit.js +5 -5
  14. package/dist/node/cli/index.cjs +2 -2
  15. package/dist/node/cli/index.js +51 -41
  16. package/dist/node/express/express.util.cjs +1 -1
  17. package/dist/node/express/express.util.js +21 -21
  18. package/dist/node/mongo/mongo-controller.test.unit.d.ts +1 -0
  19. package/dist/node/mongo/mongo.test.unit.d.ts +1 -0
  20. package/dist/node/mongo/mongo.type.d.ts +2 -2
  21. package/dist/node/mongo/mongo.util.cjs +2 -2
  22. package/dist/node/mongo/mongo.util.d.ts +847 -147
  23. package/dist/node/mongo/mongo.util.js +70 -68
  24. package/dist/node/path/index.cjs +1 -1
  25. package/dist/node/path/index.js +27 -25
  26. package/dist/node/path/path.constant.cjs +1 -1
  27. package/dist/node/path/path.constant.d.ts +6 -0
  28. package/dist/node/path/path.constant.js +171 -143
  29. package/dist/node/path/path.test.unit.d.ts +1 -0
  30. package/dist/node/path/path.util.d.ts +2 -2
  31. package/dist/node/storage/index.cjs +1 -1
  32. package/dist/node/storage/index.d.ts +2 -0
  33. package/dist/node/storage/index.js +7 -2
  34. package/dist/node/storage/storage.constant.cjs +1 -0
  35. package/dist/node/storage/storage.constant.d.ts +4 -0
  36. package/dist/node/storage/storage.constant.js +7 -0
  37. package/dist/node/storage/storage.type.d.ts +14 -0
  38. package/dist/node/storage/storage.util.cjs +1 -1
  39. package/dist/node/storage/storage.util.d.ts +1 -1
  40. package/dist/node/storage/storage.util.js +160 -50
  41. package/dist/react/loading/loading.component.cjs +2 -2
  42. package/dist/react/loading/loading.component.js +32 -19
  43. package/dist/react/loading/loading.test.unit.d.ts +1 -0
  44. package/dist/react/loading/loading.type.d.ts +2 -1
  45. package/dist/util/common/common.test.unit.d.ts +1 -0
  46. package/dist/util/common/common.util.cjs +1 -1
  47. package/dist/util/common/common.util.js +14 -15
  48. package/dist/util/index.cjs +1 -1
  49. package/dist/util/index.js +16 -15
  50. package/dist/util/object/index.cjs +1 -1
  51. package/dist/util/object/index.js +4 -3
  52. package/dist/util/object/object.test.unit.d.ts +1 -0
  53. package/dist/util/object/object.util.cjs +1 -1
  54. package/dist/util/object/object.util.d.ts +10 -30
  55. package/dist/util/object/object.util.js +102 -69
  56. package/dist/util/serializer/serializer.test.unit.d.ts +1 -0
  57. package/dist/util/serializer/serializer.util.cjs +1 -1
  58. package/dist/util/serializer/serializer.util.js +19 -16
  59. package/dist/util/string/string.test.unit.d.ts +1 -0
  60. package/dist/util/string/string.util.cjs +1 -1
  61. package/dist/util/string/string.util.d.ts +4 -3
  62. package/dist/util/string/string.util.js +32 -41
  63. package/dist/util/validate/validate.test.unit.d.ts +1 -0
  64. package/dist/util/validate/validate.util.cjs +1 -1
  65. package/dist/util/validate/validate.util.js +9 -9
  66. package/package.json +49 -52
  67. /package/dist/node_modules/.pnpm/{vitest@4.0.9_@types_debug@4.1.12_@types_node@24.10.1_jiti@2.6.1_jsdom@27.2.0_sass@1.94.0_tsx@4.20.6_yaml@2.8.1 → vitest@4.0.16_@types_node@25.0.3_jiti@2.6.1_jsdom@27.3.0_sass@1.97.0_tsx@4.21.0_yaml@2.8.2}/node_modules/vitest/dist/config.cjs +0 -0
  68. /package/dist/node_modules/.pnpm/{vitest@4.0.9_@types_debug@4.1.12_@types_node@24.10.1_jiti@2.6.1_jsdom@27.2.0_sass@1.94.0_tsx@4.20.6_yaml@2.8.1 → vitest@4.0.16_@types_node@25.0.3_jiti@2.6.1_jsdom@27.3.0_sass@1.97.0_tsx@4.21.0_yaml@2.8.2}/node_modules/vitest/dist/config.js +0 -0
@@ -1,97 +1,130 @@
1
- import { isArray as i, mergeWith as d } from "lodash-es";
2
- var m = Object.defineProperty, v = Object.defineProperties, O = Object.getOwnPropertyDescriptors, a = Object.getOwnPropertySymbols, b = Object.prototype.hasOwnProperty, h = Object.prototype.propertyIsEnumerable, u = (r, e, t) => e in r ? m(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, f = (r, e) => {
3
- for (var t in e || (e = {}))
4
- b.call(e, t) && u(r, t, e[t]);
5
- if (a)
6
- for (var t of a(e))
7
- h.call(e, t) && u(r, t, e[t]);
8
- return r;
9
- }, c = (r, e) => v(r, O(e));
10
- function w(r) {
1
+ var d = Object.defineProperty, g = Object.defineProperties, m = Object.getOwnPropertyDescriptors, f = Object.getOwnPropertySymbols, A = Object.prototype.hasOwnProperty, v = Object.prototype.propertyIsEnumerable, u = (e, r, n) => r in e ? d(e, r, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[r] = n, y = (e, r) => {
2
+ for (var n in r || (r = {}))
3
+ A.call(r, n) && u(e, n, r[n]);
4
+ if (f)
5
+ for (var n of f(r))
6
+ v.call(r, n) && u(e, n, r[n]);
7
+ return e;
8
+ }, p = (e, r) => g(e, m(r));
9
+ function P(e) {
11
10
  try {
12
- return JSON.parse(r), !0;
13
- } catch (e) {
11
+ return JSON.parse(e), !0;
12
+ } catch (r) {
14
13
  return !1;
15
14
  }
16
15
  }
17
- function P(r, e) {
18
- return e.reduce((t, n) => {
19
- if (t && typeof t == "object" && n in t)
20
- return t[n];
21
- }, r);
16
+ function b(e, r) {
17
+ let n = e;
18
+ const o = r.length;
19
+ for (let t = 0; t < o; t++)
20
+ if (n && typeof n == "object" && r[t] in n)
21
+ n = n[r[t]];
22
+ else
23
+ return;
24
+ return n;
22
25
  }
23
- function _(r, e, t) {
24
- if (e.length === 0)
25
- return r;
26
- const [n, ...o] = e;
27
- if (o.length === 0)
28
- return c(f({}, r), {
29
- [n]: t
26
+ function h(e, r, n) {
27
+ if (r.length === 0)
28
+ return e;
29
+ const [o, ...t] = r;
30
+ if (t.length === 0)
31
+ return p(y({}, e), {
32
+ [o]: n
30
33
  });
31
- const s = r[n];
32
- return c(f({}, r), {
33
- [n]: _(
34
- typeof s == "object" && s !== null ? s : {},
35
- o,
36
- t
34
+ const i = e[o];
35
+ return p(y({}, e), {
36
+ [o]: h(
37
+ typeof i == "object" && i !== null ? i : {},
38
+ t,
39
+ n
37
40
  )
38
41
  });
39
42
  }
40
- function A(...r) {
41
- if (r.length === 0)
42
- return {};
43
- const e = r.filter((o) => o != null).map((o) => typeof o != "object" ? {} : o);
43
+ function O(e) {
44
+ if (e === null || typeof e != "object")
45
+ return e;
46
+ if (Array.isArray(e))
47
+ return e.map((o) => O(o));
48
+ if (e instanceof Date)
49
+ return new Date(e.getTime());
50
+ if (e instanceof RegExp)
51
+ return new RegExp(e.source, e.flags);
52
+ const r = Object.getPrototypeOf(e);
53
+ if (r !== Object.prototype && r !== null)
54
+ return e;
55
+ const n = {};
56
+ for (const o in e)
57
+ Object.prototype.hasOwnProperty.call(e, o) && (n[o] = O(e[o]));
58
+ return n;
59
+ }
60
+ function w(...e) {
44
61
  if (e.length === 0)
45
62
  return {};
46
- if (e.length === 1)
47
- return e[0];
48
- if (e.every(i))
49
- return [].concat(...e);
50
- if (e.every(
51
- (o) => typeof o == "object" && o !== null && !i(o)
52
- ))
53
- return d({}, ...e, (o, s) => {
54
- if (i(o) && i(s))
55
- return o.concat(s);
56
- });
57
- if (e.every((o) => typeof o != "object" || o === null))
63
+ const r = e.filter((t) => t != null);
64
+ if (r.length === 0)
65
+ return {};
66
+ if (r.length === 1)
67
+ return r[0];
68
+ if (r.every(Array.isArray))
69
+ return [].concat(...r);
70
+ if (r.every((t) => typeof t == "object" && t !== null && !Array.isArray(t))) {
71
+ const t = {};
72
+ for (const i of r) {
73
+ const l = i;
74
+ for (const s in l)
75
+ if (Object.prototype.hasOwnProperty.call(l, s)) {
76
+ const a = l[s];
77
+ if (Object.prototype.hasOwnProperty.call(t, s)) {
78
+ const c = t[s];
79
+ typeof a == "object" && a !== null && typeof c == "object" && c !== null ? Array.isArray(a) && Array.isArray(c) ? t[s] = c.concat(a) : !Array.isArray(a) && !Array.isArray(c) ? t[s] = w(
80
+ c,
81
+ a
82
+ ) : t[s] = a : t[s] = a;
83
+ } else
84
+ t[s] = a;
85
+ }
86
+ }
87
+ return t;
88
+ }
89
+ if (r.every((t) => typeof t != "object" || t === null))
58
90
  throw new Error(
59
91
  "deepMerge: Cannot merge primitive values. All arguments must be objects or arrays."
60
92
  );
61
- const t = e.some(i), n = e.some(
62
- (o) => typeof o == "object" && o !== null && !i(o)
93
+ const n = r.some(Array.isArray), o = r.some(
94
+ (t) => typeof t == "object" && t !== null && !Array.isArray(t)
63
95
  );
64
- throw t && n ? new Error(
96
+ throw n && o ? new Error(
65
97
  "deepMerge: Cannot mix arrays and objects. All arguments must be either arrays or objects."
66
98
  ) : new Error(
67
99
  "deepMerge: Invalid arguments provided. All arguments must be objects or arrays of the same type."
68
100
  );
69
101
  }
70
- function g(r) {
71
- if (!r || typeof r != "object")
72
- return r;
73
- const e = {};
74
- for (const [t, n] of Object.entries(r))
75
- if (n && typeof n == "object" && !Array.isArray(n))
76
- if (Object.keys(n).some(
77
- (s) => s.startsWith("$")
102
+ function _(e) {
103
+ if (!e || typeof e != "object")
104
+ return e;
105
+ const r = {};
106
+ for (const [n, o] of Object.entries(e))
107
+ if (o && typeof o == "object" && !Array.isArray(o))
108
+ if (Object.keys(o).some(
109
+ (i) => i.startsWith("$")
78
110
  ))
79
- e[t] = n;
111
+ r[n] = o;
80
112
  else {
81
- const s = g(n);
82
- for (const [l, p] of Object.entries(s)) {
83
- const y = `${t}.${l}`;
84
- e[y] = p;
113
+ const i = _(o);
114
+ for (const [l, s] of Object.entries(i)) {
115
+ const a = `${n}.${l}`;
116
+ r[a] = s;
85
117
  }
86
118
  }
87
119
  else
88
- e[t] = n;
89
- return e;
120
+ r[n] = o;
121
+ return r;
90
122
  }
91
123
  export {
92
- A as deepMerge,
93
- P as getNestedValue,
94
- w as isJSON,
95
- g as normalizeMongoFilter,
96
- _ as setNestedValue
124
+ O as deepClone,
125
+ w as deepMerge,
126
+ b as getNestedValue,
127
+ P as isJSON,
128
+ _ as normalizeMongoFilter,
129
+ h as setNestedValue
97
130
  };
@@ -0,0 +1 @@
1
+ export {};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n={Date:{is:e=>e instanceof Date,serialize:e=>({__type:"Date",value:e.toISOString()}),deserialize:e=>new Date(e)},Map:{is:e=>e instanceof Map,serialize:e=>({__type:"Map",value:Array.from(e.entries())}),deserialize:e=>new Map(e)},Set:{is:e=>e instanceof Set,serialize:e=>({__type:"Set",value:Array.from(e)}),deserialize:e=>new Set(e)},RegExp:{is:e=>e instanceof RegExp,serialize:e=>({__type:"RegExp",value:{source:e.source,flags:e.flags}}),deserialize:e=>{const{source:r,flags:i}=e;return new RegExp(r,i)}},BigInt:{is:e=>typeof e=="bigint",serialize:e=>({__type:"BigInt",value:e.toString()}),deserialize:e=>BigInt(e)}},a={serialize(e){return JSON.stringify(e,(r,i)=>{for(const s of Object.keys(n)){const t=n[s];if(t.is(i))return t.serialize(i)}return i})},deserialize(e){return JSON.parse(e,(r,i)=>{if(i&&typeof i=="object"&&"__type"in i&&typeof i.__type=="string"){const s=i.__type,t=n[s];if(t)return t.deserialize(i.value)}return i})}};exports.serializer=a;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s={Date:{is:e=>e instanceof Date,serialize:e=>({__type:"Date",value:e.toISOString()}),deserialize:e=>new Date(e)},Map:{is:e=>e instanceof Map,serialize:e=>({__type:"Map",value:Array.from(e.entries())}),deserialize:e=>new Map(e)},Set:{is:e=>e instanceof Set,serialize:e=>({__type:"Set",value:Array.from(e)}),deserialize:e=>new Set(e)},RegExp:{is:e=>e instanceof RegExp,serialize:e=>({__type:"RegExp",value:{source:e.source,flags:e.flags}}),deserialize:e=>{const{source:r,flags:t}=e;return new RegExp(r,t)}},BigInt:{is:e=>typeof e=="bigint",serialize:e=>({__type:"BigInt",value:e.toString()}),deserialize:e=>BigInt(e)}},l={serialize(e){return JSON.stringify(e,function(r,t){const i=this[r];if(i instanceof Date)return s.Date.serialize(i);for(const o of Object.keys(s)){const a=s[o];if(a.is(t))return a.serialize(t)}return t})},deserialize(e){return JSON.parse(e,(r,t)=>{if(t&&typeof t=="object"&&"__type"in t&&typeof t.__type=="string"){const n=t.__type,i=s[n];if(i)return i.deserialize(t.value)}return t})}};exports.serializer=l;
@@ -21,8 +21,8 @@ const n = {
21
21
  value: { source: e.source, flags: e.flags }
22
22
  }),
23
23
  deserialize: (e) => {
24
- const { source: r, flags: i } = e;
25
- return new RegExp(r, i);
24
+ const { source: r, flags: t } = e;
25
+ return new RegExp(r, t);
26
26
  }
27
27
  },
28
28
  BigInt: {
@@ -30,7 +30,7 @@ const n = {
30
30
  serialize: (e) => ({ __type: "BigInt", value: e.toString() }),
31
31
  deserialize: (e) => BigInt(e)
32
32
  }
33
- }, a = {
33
+ }, p = {
34
34
  /**
35
35
  * Serializes a value to a JSON string.
36
36
  * If the value is of a known type (Date, Map, Set, RegExp, BigInt),
@@ -41,13 +41,16 @@ const n = {
41
41
  * @returns The serialized JSON string that can be safely stored or transmitted.
42
42
  */
43
43
  serialize(e) {
44
- return JSON.stringify(e, (r, i) => {
45
- for (const s of Object.keys(n)) {
46
- const t = n[s];
47
- if (t.is(i))
48
- return t.serialize(i);
44
+ return JSON.stringify(e, function(r, t) {
45
+ const i = this[r];
46
+ if (i instanceof Date)
47
+ return n.Date.serialize(i);
48
+ for (const o of Object.keys(n)) {
49
+ const a = n[o];
50
+ if (a.is(t))
51
+ return a.serialize(t);
49
52
  }
50
- return i;
53
+ return t;
51
54
  });
52
55
  },
53
56
  /**
@@ -60,16 +63,16 @@ const n = {
60
63
  * @returns The deserialized value with all special types reconstructed.
61
64
  */
62
65
  deserialize(e) {
63
- return JSON.parse(e, (r, i) => {
64
- if (i && typeof i == "object" && "__type" in i && typeof i.__type == "string") {
65
- const s = i.__type, t = n[s];
66
- if (t)
67
- return t.deserialize(i.value);
66
+ return JSON.parse(e, (r, t) => {
67
+ if (t && typeof t == "object" && "__type" in t && typeof t.__type == "string") {
68
+ const s = t.__type, i = n[s];
69
+ if (i)
70
+ return i.deserialize(t.value);
68
71
  }
69
- return i;
72
+ return t;
70
73
  });
71
74
  }
72
75
  };
73
76
  export {
74
- a as serializer
77
+ p as serializer
75
78
  };
@@ -0,0 +1 @@
1
+ export {};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("crypto-js"),c=require("lodash-es"),u=require("slugify");var f=Object.defineProperty,s=Object.getOwnPropertySymbols,d=Object.prototype.hasOwnProperty,g=Object.prototype.propertyIsEnumerable,i=(r,e,t)=>e in r?f(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,m=(r,e)=>{for(var t in e||(e={}))d.call(e,t)&&i(r,t,e[t]);if(s)for(var t of s(e))g.call(e,t)&&i(r,t,e[t]);return r};const O=u.default||u;function y(r,e){const t=n=>{var o,l;return O(n!=null?n:"",m({lower:(o=e==null?void 0:e.lower)!=null?o:!0,locale:(l=e==null?void 0:e.locale)!=null?l:"vi"},e))};if(c.isObject(r)){const n={};for(const[o,l]of Object.entries(r))n[o]=t(l);return n}return t(r)}function _(r,e=4){return a.SHA256(r).toString(a.enc.Hex).slice(0,e)}function h(r=8){const e="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_+[]{}|;:,.<>?";return Array.from({length:r},()=>{const t=Math.floor(Math.random()*e.length);return e.charAt(t)}).join("")}function w(r="",e=!1){const t=r.split(/[?#]/)[0]||"",n=t.substring(t.lastIndexOf("/")+1);if(e)return n;const o=n.lastIndexOf(".");return o>0?n.slice(0,o):n}function p(r,e,t){const n=r.indexOf(e);if(n===-1)return"";const o=n+e.length,l=r.indexOf(t,o);return l===-1?"":r.slice(o,l)}exports.generateRandomPassword=h;exports.generateShortId=_;exports.generateSlug=y;exports.getFileName=w;exports.substringBetween=p;
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;
@@ -12,12 +12,13 @@ import { I_SlugifyOptions } from './string.type.js';
12
12
  export declare function generateSlug<T = string>(input: T, options?: I_SlugifyOptions): T;
13
13
  /**
14
14
  * Generates a short ID from a UUID.
15
- * The ID is a substring of the SHA256 hash of the UUID, providing a shorter
16
- * but still unique identifier based on the original UUID.
15
+ * The ID is a substring of the UUID, providing a shorter identifier.
16
+ * Note: This is NOT cryptographically secure and collisions are possible,
17
+ * but suitable for display purposes where uniqueness is handled elsewhere.
17
18
  *
18
19
  * @param uuid - The UUID to be converted to a short ID.
19
20
  * @param length - The desired length of the short ID (default: 4 characters).
20
- * @returns A short ID string of the specified length derived from the UUID's SHA256 hash.
21
+ * @returns A short ID string of the specified length derived from the UUID.
21
22
  */
22
23
  export declare function generateShortId(uuid: string, length?: number): string;
23
24
  /**
@@ -1,59 +1,50 @@
1
- import a from "crypto-js";
2
- import { isObject as s } from "lodash-es";
3
- import u from "slugify";
4
- var c = Object.defineProperty, f = Object.getOwnPropertySymbols, d = Object.prototype.hasOwnProperty, m = Object.prototype.propertyIsEnumerable, i = (e, r, t) => r in e ? c(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t, g = (e, r) => {
5
- for (var t in r || (r = {}))
6
- d.call(r, t) && i(e, t, r[t]);
7
- if (f)
8
- for (var t of f(r))
9
- m.call(r, t) && i(e, t, r[t]);
10
- return e;
11
- };
12
- const p = u.default || u;
13
- function h(e, r) {
14
- const t = (n) => {
15
- var o, l;
16
- return p(n != null ? n : "", g({
17
- lower: (o = r == null ? void 0 : r.lower) != null ? o : !0,
18
- locale: (l = r == null ? void 0 : r.locale) != null ? l : "vi"
19
- }, r));
20
- };
21
- if (s(e)) {
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) {
22
9
  const n = {};
23
- for (const [o, l] of Object.entries(e))
24
- n[o] = t(l);
10
+ for (const [o, s] of Object.entries(t))
11
+ n[o] = e(s);
25
12
  return n;
26
13
  }
27
- return t(e);
14
+ return e(t);
28
15
  }
29
- function v(e, r = 4) {
30
- return a.SHA256(e).toString(a.enc.Hex).slice(0, r);
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);
31
22
  }
32
- function w(e = 8) {
23
+ function u(t = 8) {
33
24
  const r = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_+[]{}|;:,.<>?";
34
- return Array.from({ length: e }, () => {
35
- const t = Math.floor(Math.random() * r.length);
36
- return r.charAt(t);
25
+ return Array.from({ length: t }, () => {
26
+ const e = Math.floor(Math.random() * r.length);
27
+ return r.charAt(e);
37
28
  }).join("");
38
29
  }
39
- function x(e = "", r = !1) {
40
- const t = e.split(/[?#]/)[0] || "", n = t.substring(t.lastIndexOf("/") + 1);
30
+ function g(t = "", r = !1) {
31
+ const e = t.split(/[?#]/)[0] || "", n = e.substring(e.lastIndexOf("/") + 1);
41
32
  if (r)
42
33
  return n;
43
34
  const o = n.lastIndexOf(".");
44
35
  return o > 0 ? n.slice(0, o) : n;
45
36
  }
46
- function P(e, r, t) {
47
- const n = e.indexOf(r);
37
+ function d(t, r, e) {
38
+ const n = t.indexOf(r);
48
39
  if (n === -1)
49
40
  return "";
50
- const o = n + r.length, l = e.indexOf(t, o);
51
- return l === -1 ? "" : e.slice(o, l);
41
+ const o = n + r.length, s = t.indexOf(e, o);
42
+ return s === -1 ? "" : t.slice(o, s);
52
43
  }
53
44
  export {
54
- w as generateRandomPassword,
55
- v as generateShortId,
56
- h as generateSlug,
57
- x as getFileName,
58
- P as substringBetween
45
+ u as generateRandomPassword,
46
+ f as generateShortId,
47
+ a as generateSlug,
48
+ g as getFileName,
49
+ d as substringBetween
59
50
  };
@@ -0,0 +1 @@
1
+ export {};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i={isEmpty(t){return t==null?!0:typeof t=="string"?t.trim().length===0:Array.isArray(t)?t.length===0:typeof t=="object"?t instanceof Date?!1:t instanceof Map||t instanceof Set?t.size===0:t instanceof WeakMap||t instanceof WeakSet?!0:ArrayBuffer.isView(t)?t.byteLength===0:Object.keys(t).length===0:!1},isValidIP(t){const r=t.split(".");return r.length===4&&r.every(e=>/^\d+$/.test(e)&&Number(e)>=0&&Number(e)<=255)?!0:/^(([a-f\d]{1,4}:){7}[a-f\d]{1,4}|((?:[a-f\d]{1,4}:){1,7}:)|((?:[a-f\d]{1,4}:){1,6}:[a-f\d]{1,4})|::)$/i.test(t)}};exports.validate=i;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r={isEmpty(d){return d==null?!0:typeof d=="string"?d.trim().length===0:Array.isArray(d)?d.length===0:typeof d=="object"?d instanceof Date?!1:d instanceof Map||d instanceof Set?d.size===0:d instanceof WeakMap||d instanceof WeakSet?!0:ArrayBuffer.isView(d)?d.byteLength===0:Object.keys(d).length===0:!1},isValidIP(d){const e=d.split(".");return e.length===4&&e.every(t=>/^\d+$/.test(t)&&Number(t)>=0&&Number(t)<=255)?!0:/^(?:(?:[a-fA-F\d]{1,4}:){7}(?:[a-fA-F\d]{1,4}|:)|(?:[a-fA-F\d]{1,4}:){6}(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|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
4
  * This function provides comprehensive empty checking for different data types:
@@ -15,8 +15,8 @@ const i = {
15
15
  * @param value - The value to check for emptiness.
16
16
  * @returns True if the value is empty, false otherwise.
17
17
  */
18
- isEmpty(t) {
19
- return t == null ? !0 : typeof t == "string" ? t.trim().length === 0 : Array.isArray(t) ? t.length === 0 : typeof t == "object" ? t instanceof Date ? !1 : t instanceof Map || t instanceof Set ? t.size === 0 : t instanceof WeakMap || t instanceof WeakSet ? !0 : ArrayBuffer.isView(t) ? t.byteLength === 0 : Object.keys(t).length === 0 : !1;
18
+ isEmpty(d) {
19
+ return d == null ? !0 : typeof d == "string" ? d.trim().length === 0 : Array.isArray(d) ? d.length === 0 : typeof d == "object" ? d instanceof Date ? !1 : d instanceof Map || d instanceof Set ? d.size === 0 : d instanceof WeakMap || d instanceof WeakSet ? !0 : ArrayBuffer.isView(d) ? d.byteLength === 0 : Object.keys(d).length === 0 : !1;
20
20
  },
21
21
  /**
22
22
  * Checks if a string is a valid IP address (IPv4 or IPv6).
@@ -27,13 +27,13 @@ const i = {
27
27
  * @param ip - The IP address string to validate.
28
28
  * @returns True if the IP is valid IPv4 or IPv6, false otherwise.
29
29
  */
30
- isValidIP(t) {
31
- const e = t.split(".");
32
- return e.length === 4 && e.every(
33
- (r) => /^\d+$/.test(r) && Number(r) >= 0 && Number(r) <= 255
34
- ) ? !0 : /^(([a-f\d]{1,4}:){7}[a-f\d]{1,4}|((?:[a-f\d]{1,4}:){1,7}:)|((?:[a-f\d]{1,4}:){1,6}:[a-f\d]{1,4})|::)$/i.test(t);
30
+ isValidIP(d) {
31
+ const f = d.split(".");
32
+ return f.length === 4 && f.every(
33
+ (t) => /^\d+$/.test(t) && Number(t) >= 0 && Number(t) <= 255
34
+ ) ? !0 : /^(?:(?:[a-fA-F\d]{1,4}:){7}(?:[a-fA-F\d]{1,4}|:)|(?:[a-fA-F\d]{1,4}:){6}(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|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package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cyberskill/shared",
3
3
  "type": "module",
4
- "version": "2.19.1",
4
+ "version": "2.21.0",
5
5
  "description": "CyberSkill Shared",
6
6
  "author": "Stephen Cheng",
7
7
  "license": "MIT",
@@ -50,6 +50,11 @@
50
50
  "import": "./dist/config/vitest/index.js",
51
51
  "require": "./dist/config/vitest/index.cjs"
52
52
  },
53
+ "./config/storybook": {
54
+ "types": "./dist/config/storybook/index.d.ts",
55
+ "import": "./dist/config/storybook/index.js",
56
+ "require": "./dist/config/storybook/index.cjs"
57
+ },
53
58
  "./constant": {
54
59
  "types": "./dist/constant/index.d.ts",
55
60
  "import": "./dist/constant/index.js",
@@ -207,108 +212,100 @@
207
212
  "test:unit": "tsx src/node/cli/index.ts test:unit"
208
213
  },
209
214
  "dependencies": {
210
- "@antfu/eslint-config": "6.2.0",
211
- "@apollo/client": "4.0.9",
212
- "@apollo/client-integration-nextjs": "0.14.1",
213
- "@apollo/server": "5.1.0",
215
+ "@antfu/eslint-config": "6.7.1",
216
+ "@apollo/client": "4.0.11",
217
+ "@apollo/client-integration-nextjs": "0.14.3",
218
+ "@apollo/server": "5.2.0",
214
219
  "@as-integrations/express5": "1.1.2",
215
- "@dotenvx/dotenvx": "1.51.1",
216
- "@eddeee888/gcg-typescript-resolver-files": "0.14.0",
217
- "@eslint-react/eslint-plugin": "2.3.5",
218
- "@graphql-codegen/cli": "6.0.2",
219
- "@graphql-codegen/client-preset": "5.1.3",
220
+ "@dotenvx/dotenvx": "1.51.2",
221
+ "@eddeee888/gcg-typescript-resolver-files": "0.14.1",
222
+ "@eslint-react/eslint-plugin": "2.3.13",
223
+ "@graphql-codegen/cli": "6.1.0",
224
+ "@graphql-codegen/client-preset": "5.2.2",
220
225
  "@nestjs/common": "11.1.9",
221
226
  "@nestjs/core": "11.1.9",
222
- "@userback/widget": "0.3.11",
227
+ "@userback/widget": "0.3.12",
223
228
  "@vitejs/plugin-react-swc": "4.2.2",
224
- "body-parser": "2.2.0",
229
+ "body-parser": "2.2.1",
225
230
  "chalk": "5.6.2",
226
231
  "clsx": "2.1.1",
227
232
  "compression": "1.8.1",
228
233
  "consola": "3.4.2",
229
234
  "cookie-parser": "1.4.7",
230
235
  "cors": "2.8.5",
231
- "crypto-js": "4.2.0",
232
236
  "date-fns": "4.1.0",
233
237
  "envalid": "8.1.1",
234
- "eslint-plugin-format": "1.0.2",
238
+ "eslint-plugin-format": "1.1.0",
235
239
  "eslint-plugin-react-hooks": "7.0.1",
236
- "eslint-plugin-react-refresh": "0.4.24",
237
- "express": "5.1.0",
240
+ "eslint-plugin-react-refresh": "0.4.26",
241
+ "express": "5.2.1",
238
242
  "express-session": "1.18.2",
239
243
  "express-useragent": "2.0.2",
240
244
  "extract-files": "13.0.0",
241
- "fs-extra": "11.3.2",
245
+ "fs-extra": "11.3.3",
242
246
  "globals": "16.5.0",
243
247
  "graphql": "16.12.0",
244
248
  "graphql-upload": "17.0.0",
245
249
  "graphql-ws": "6.0.6",
246
- "i18next": "25.6.2",
247
- "jsdom": "27.2.0",
250
+ "i18next": "25.7.3",
251
+ "jsdom": "27.3.0",
248
252
  "localforage": "1.10.0",
249
- "lodash-es": "4.17.21",
250
- "migrate-mongo": "12.1.3",
253
+ "migrate-mongo": "14.0.7",
251
254
  "mongodb": "7.0.0",
252
- "mongoose": "8.19.4",
255
+ "mongoose": "9.0.2",
253
256
  "mongoose-aggregate-paginate-v2": "1.1.4",
254
257
  "mongoose-paginate-v2": "1.9.1",
255
- "next-intl": "4.5.3",
258
+ "next-intl": "4.6.1",
256
259
  "node-fetch": "3.3.2",
257
- "node-persist": "4.0.4",
258
260
  "qs": "6.14.0",
259
- "react": "19.2.0",
260
- "react-dom": "19.2.0",
261
+ "react": "19.2.3",
262
+ "react-dom": "19.2.3",
261
263
  "react-hot-toast": "2.6.0",
262
- "react-i18next": "16.3.3",
264
+ "react-i18next": "16.5.0",
263
265
  "rxjs": "7.8.2",
264
- "slugify": "1.6.6",
265
- "unorm": "1.6.0",
266
- "uuid": "13.0.0",
267
- "vite": "7.2.2",
266
+ "vite": "7.3.0",
268
267
  "ws": "8.18.3",
269
268
  "yargs": "18.0.0"
270
269
  },
271
270
  "devDependencies": {
272
- "@commitlint/cli": "20.1.0",
273
- "@commitlint/config-conventional": "20.0.0",
274
- "@eslint/config-inspector": "1.3.0",
275
- "@next/eslint-plugin-next": "16.0.3",
271
+ "@commitlint/cli": "20.2.0",
272
+ "@commitlint/config-conventional": "20.2.0",
273
+ "@eslint/config-inspector": "1.4.2",
274
+ "@next/eslint-plugin-next": "16.1.0",
275
+ "@storybook/react": "10.1.10",
276
+ "@storybook/react-vite": "10.1.10",
276
277
  "@testing-library/jest-dom": "6.9.1",
277
- "@testing-library/react": "16.3.0",
278
+ "@testing-library/react": "16.3.1",
278
279
  "@types/body-parser": "1.19.6",
279
280
  "@types/compression": "1.8.1",
280
281
  "@types/cookie-parser": "1.4.10",
281
282
  "@types/cors": "2.8.19",
282
- "@types/crypto-js": "4.2.2",
283
- "@types/express": "5.0.5",
283
+ "@types/express": "5.0.6",
284
284
  "@types/express-session": "1.18.2",
285
285
  "@types/express-useragent": "1.0.5",
286
286
  "@types/extract-files": "13.0.2",
287
287
  "@types/fs-extra": "11.0.4",
288
288
  "@types/graphql-upload": "17.0.0",
289
- "@types/lodash-es": "4.17.12",
290
289
  "@types/migrate-mongo": "10.0.6",
291
- "@types/node": "24.10.1",
292
- "@types/node-persist": "3.1.8",
293
- "@types/react": "19.2.4",
290
+ "@types/node": "25.0.3",
291
+ "@types/react": "19.2.7",
294
292
  "@types/react-dom": "19.2.3",
295
- "@types/unorm": "1.3.31",
296
293
  "@types/ws": "8.18.1",
297
294
  "@types/yargs": "17.0.35",
298
- "@vitest/browser": "4.0.9",
299
- "eslint": "9.39.1",
300
- "eslint-config-next": "16.0.3",
301
- "glob": "11.0.3",
302
- "lint-staged": "16.2.6",
295
+ "@vitest/browser": "4.0.16",
296
+ "eslint": "9.39.2",
297
+ "eslint-config-next": "16.1.0",
298
+ "glob": "13.0.0",
299
+ "lint-staged": "16.2.7",
303
300
  "node-modules-inspector": "1.2.0",
304
301
  "npm-run-all2": "8.0.4",
305
- "sass": "1.94.0",
302
+ "sass": "1.97.0",
306
303
  "simple-git-hooks": "2.13.1",
307
- "tsx": "4.20.6",
304
+ "tsx": "4.21.0",
308
305
  "typescript": "5.9.3",
309
- "vite": "7.2.2",
306
+ "vite": "7.3.0",
310
307
  "vite-plugin-dts": "4.5.4",
311
- "vitest": "4.0.9"
308
+ "vitest": "4.0.16"
312
309
  },
313
310
  "publishConfig": {
314
311
  "access": "public",