@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.
- package/dist/config/storybook/index.cjs +1 -0
- package/dist/config/storybook/index.d.ts +2 -0
- package/dist/config/storybook/index.js +6 -0
- package/dist/config/storybook/storybook.main.cjs +1 -0
- package/dist/config/storybook/storybook.main.d.ts +17 -0
- package/dist/config/storybook/storybook.main.js +18 -0
- package/dist/config/storybook/storybook.preview.cjs +1 -0
- package/dist/config/storybook/storybook.preview.d.ts +18 -0
- package/dist/config/storybook/storybook.preview.js +39 -0
- package/dist/config/vitest/vitest.e2e.cjs +1 -1
- package/dist/config/vitest/vitest.e2e.js +6 -6
- package/dist/config/vitest/vitest.unit.cjs +1 -1
- package/dist/config/vitest/vitest.unit.js +5 -5
- package/dist/node/cli/index.cjs +2 -2
- package/dist/node/cli/index.js +51 -41
- package/dist/node/express/express.util.cjs +1 -1
- package/dist/node/express/express.util.js +21 -21
- package/dist/node/mongo/mongo-controller.test.unit.d.ts +1 -0
- package/dist/node/mongo/mongo.test.unit.d.ts +1 -0
- package/dist/node/mongo/mongo.type.d.ts +2 -2
- package/dist/node/mongo/mongo.util.cjs +2 -2
- package/dist/node/mongo/mongo.util.d.ts +847 -147
- package/dist/node/mongo/mongo.util.js +70 -68
- package/dist/node/path/index.cjs +1 -1
- package/dist/node/path/index.js +27 -25
- package/dist/node/path/path.constant.cjs +1 -1
- package/dist/node/path/path.constant.d.ts +6 -0
- package/dist/node/path/path.constant.js +171 -143
- package/dist/node/path/path.test.unit.d.ts +1 -0
- package/dist/node/path/path.util.d.ts +2 -2
- package/dist/node/storage/index.cjs +1 -1
- package/dist/node/storage/index.d.ts +2 -0
- package/dist/node/storage/index.js +7 -2
- package/dist/node/storage/storage.constant.cjs +1 -0
- package/dist/node/storage/storage.constant.d.ts +4 -0
- package/dist/node/storage/storage.constant.js +7 -0
- package/dist/node/storage/storage.type.d.ts +14 -0
- package/dist/node/storage/storage.util.cjs +1 -1
- package/dist/node/storage/storage.util.d.ts +1 -1
- package/dist/node/storage/storage.util.js +160 -50
- package/dist/react/loading/loading.component.cjs +2 -2
- package/dist/react/loading/loading.component.js +32 -19
- package/dist/react/loading/loading.test.unit.d.ts +1 -0
- package/dist/react/loading/loading.type.d.ts +2 -1
- package/dist/util/common/common.test.unit.d.ts +1 -0
- package/dist/util/common/common.util.cjs +1 -1
- package/dist/util/common/common.util.js +14 -15
- package/dist/util/index.cjs +1 -1
- package/dist/util/index.js +16 -15
- package/dist/util/object/index.cjs +1 -1
- package/dist/util/object/index.js +4 -3
- package/dist/util/object/object.test.unit.d.ts +1 -0
- package/dist/util/object/object.util.cjs +1 -1
- package/dist/util/object/object.util.d.ts +10 -30
- package/dist/util/object/object.util.js +102 -69
- package/dist/util/serializer/serializer.test.unit.d.ts +1 -0
- package/dist/util/serializer/serializer.util.cjs +1 -1
- package/dist/util/serializer/serializer.util.js +19 -16
- package/dist/util/string/string.test.unit.d.ts +1 -0
- package/dist/util/string/string.util.cjs +1 -1
- package/dist/util/string/string.util.d.ts +4 -3
- package/dist/util/string/string.util.js +32 -41
- package/dist/util/validate/validate.test.unit.d.ts +1 -0
- package/dist/util/validate/validate.util.cjs +1 -1
- package/dist/util/validate/validate.util.js +9 -9
- package/package.json +49 -52
- /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
- /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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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(
|
|
13
|
-
} catch (
|
|
11
|
+
return JSON.parse(e), !0;
|
|
12
|
+
} catch (r) {
|
|
14
13
|
return !1;
|
|
15
14
|
}
|
|
16
15
|
}
|
|
17
|
-
function
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
|
24
|
-
if (
|
|
25
|
-
return
|
|
26
|
-
const [
|
|
27
|
-
if (
|
|
28
|
-
return
|
|
29
|
-
[
|
|
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
|
|
32
|
-
return
|
|
33
|
-
[
|
|
34
|
-
typeof
|
|
35
|
-
|
|
36
|
-
|
|
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
|
|
41
|
-
if (
|
|
42
|
-
return
|
|
43
|
-
|
|
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
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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
|
|
62
|
-
(
|
|
93
|
+
const n = r.some(Array.isArray), o = r.some(
|
|
94
|
+
(t) => typeof t == "object" && t !== null && !Array.isArray(t)
|
|
63
95
|
);
|
|
64
|
-
throw
|
|
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
|
|
71
|
-
if (!
|
|
72
|
-
return
|
|
73
|
-
const
|
|
74
|
-
for (const [
|
|
75
|
-
if (
|
|
76
|
-
if (Object.keys(
|
|
77
|
-
(
|
|
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
|
-
|
|
111
|
+
r[n] = o;
|
|
80
112
|
else {
|
|
81
|
-
const
|
|
82
|
-
for (const [l,
|
|
83
|
-
const
|
|
84
|
-
|
|
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
|
-
|
|
89
|
-
return
|
|
120
|
+
r[n] = o;
|
|
121
|
+
return r;
|
|
90
122
|
}
|
|
91
123
|
export {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
_ as
|
|
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
|
|
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:
|
|
25
|
-
return new RegExp(r,
|
|
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
|
-
},
|
|
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,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
|
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,
|
|
64
|
-
if (
|
|
65
|
-
const s =
|
|
66
|
-
if (
|
|
67
|
-
return
|
|
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
|
|
72
|
+
return t;
|
|
70
73
|
});
|
|
71
74
|
}
|
|
72
75
|
};
|
|
73
76
|
export {
|
|
74
|
-
|
|
77
|
+
p as serializer
|
|
75
78
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
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
|
|
16
|
-
*
|
|
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
|
|
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
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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,
|
|
24
|
-
n[o] =
|
|
10
|
+
for (const [o, s] of Object.entries(t))
|
|
11
|
+
n[o] = e(s);
|
|
25
12
|
return n;
|
|
26
13
|
}
|
|
27
|
-
return t
|
|
14
|
+
return e(t);
|
|
28
15
|
}
|
|
29
|
-
function
|
|
30
|
-
|
|
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
|
|
23
|
+
function u(t = 8) {
|
|
33
24
|
const r = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_+[]{}|;:,.<>?";
|
|
34
|
-
return Array.from({ length:
|
|
35
|
-
const
|
|
36
|
-
return r.charAt(
|
|
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
|
|
40
|
-
const
|
|
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
|
|
47
|
-
const n =
|
|
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,
|
|
51
|
-
return
|
|
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
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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
|
|
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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1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(?::[a-fA-F\d]{1,4}){1,7}|:)))(?:%[0-9a-zA-Z]{1,})?$/.test(d)}};exports.validate=r;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const e = {
|
|
2
2
|
/**
|
|
3
3
|
* Checks if a value is empty.
|
|
4
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(
|
|
19
|
-
return
|
|
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(
|
|
31
|
-
const
|
|
32
|
-
return
|
|
33
|
-
(
|
|
34
|
-
) ? !0 : /^(([a-
|
|
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]|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
35
|
}
|
|
36
36
|
};
|
|
37
37
|
export {
|
|
38
|
-
|
|
38
|
+
e as validate
|
|
39
39
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cyberskill/shared",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.
|
|
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.
|
|
211
|
-
"@apollo/client": "4.0.
|
|
212
|
-
"@apollo/client-integration-nextjs": "0.14.
|
|
213
|
-
"@apollo/server": "5.
|
|
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.
|
|
216
|
-
"@eddeee888/gcg-typescript-resolver-files": "0.14.
|
|
217
|
-
"@eslint-react/eslint-plugin": "2.3.
|
|
218
|
-
"@graphql-codegen/cli": "6.0
|
|
219
|
-
"@graphql-codegen/client-preset": "5.
|
|
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.
|
|
227
|
+
"@userback/widget": "0.3.12",
|
|
223
228
|
"@vitejs/plugin-react-swc": "4.2.2",
|
|
224
|
-
"body-parser": "2.2.
|
|
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
|
|
238
|
+
"eslint-plugin-format": "1.1.0",
|
|
235
239
|
"eslint-plugin-react-hooks": "7.0.1",
|
|
236
|
-
"eslint-plugin-react-refresh": "0.4.
|
|
237
|
-
"express": "5.1
|
|
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.
|
|
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.
|
|
247
|
-
"jsdom": "27.
|
|
250
|
+
"i18next": "25.7.3",
|
|
251
|
+
"jsdom": "27.3.0",
|
|
248
252
|
"localforage": "1.10.0",
|
|
249
|
-
"
|
|
250
|
-
"migrate-mongo": "12.1.3",
|
|
253
|
+
"migrate-mongo": "14.0.7",
|
|
251
254
|
"mongodb": "7.0.0",
|
|
252
|
-
"mongoose": "
|
|
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.
|
|
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.
|
|
260
|
-
"react-dom": "19.2.
|
|
261
|
+
"react": "19.2.3",
|
|
262
|
+
"react-dom": "19.2.3",
|
|
261
263
|
"react-hot-toast": "2.6.0",
|
|
262
|
-
"react-i18next": "16.
|
|
264
|
+
"react-i18next": "16.5.0",
|
|
263
265
|
"rxjs": "7.8.2",
|
|
264
|
-
"
|
|
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.
|
|
273
|
-
"@commitlint/config-conventional": "20.
|
|
274
|
-
"@eslint/config-inspector": "1.
|
|
275
|
-
"@next/eslint-plugin-next": "16.0
|
|
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.
|
|
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/
|
|
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": "
|
|
292
|
-
"@types/
|
|
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.
|
|
299
|
-
"eslint": "9.39.
|
|
300
|
-
"eslint-config-next": "16.0
|
|
301
|
-
"glob": "
|
|
302
|
-
"lint-staged": "16.2.
|
|
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.
|
|
302
|
+
"sass": "1.97.0",
|
|
306
303
|
"simple-git-hooks": "2.13.1",
|
|
307
|
-
"tsx": "4.
|
|
304
|
+
"tsx": "4.21.0",
|
|
308
305
|
"typescript": "5.9.3",
|
|
309
|
-
"vite": "7.
|
|
306
|
+
"vite": "7.3.0",
|
|
310
307
|
"vite-plugin-dts": "4.5.4",
|
|
311
|
-
"vitest": "4.0.
|
|
308
|
+
"vitest": "4.0.16"
|
|
312
309
|
},
|
|
313
310
|
"publishConfig": {
|
|
314
311
|
"access": "public",
|