@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,31 +1,143 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import _ from "localforage";
|
|
2
|
+
import l from "node:fs/promises";
|
|
3
|
+
import g from "node:path";
|
|
4
|
+
import { STORAGE_KEY_EXTENSION as R, NODE_FS_DRIVER_NAME as I, STORAGE_STORE_NAME as p, STORAGE_INSTANCE_NAME as b } from "./storage.constant.js";
|
|
5
|
+
import { getEnv as N } from "../../config/env/env.util.js";
|
|
6
|
+
import { catchError as s, log as S } from "../log/log.util.js";
|
|
7
|
+
var n = (e, r, t) => new Promise((i, d) => {
|
|
8
|
+
var y = (u) => {
|
|
6
9
|
try {
|
|
7
|
-
|
|
8
|
-
} catch (
|
|
9
|
-
|
|
10
|
+
m(t.next(u));
|
|
11
|
+
} catch (v) {
|
|
12
|
+
d(v);
|
|
10
13
|
}
|
|
11
|
-
},
|
|
14
|
+
}, O = (u) => {
|
|
12
15
|
try {
|
|
13
|
-
|
|
14
|
-
} catch (
|
|
15
|
-
|
|
16
|
+
m(t.throw(u));
|
|
17
|
+
} catch (v) {
|
|
18
|
+
d(v);
|
|
16
19
|
}
|
|
17
|
-
},
|
|
18
|
-
|
|
20
|
+
}, m = (u) => u.done ? i(u.value) : Promise.resolve(u.value).then(y, O);
|
|
21
|
+
m((t = t.apply(e, r)).next());
|
|
19
22
|
});
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
const h = N(), o = {
|
|
24
|
+
baseDir: h.CYBERSKILL_STORAGE_DIRECTORY
|
|
25
|
+
};
|
|
26
|
+
function k(e) {
|
|
27
|
+
return `${encodeURIComponent(e)}${R}`;
|
|
28
|
+
}
|
|
29
|
+
function T(e) {
|
|
30
|
+
return decodeURIComponent(e.slice(0, -R.length));
|
|
31
|
+
}
|
|
32
|
+
function E(e, r) {
|
|
33
|
+
return g.join(r, k(e));
|
|
34
|
+
}
|
|
35
|
+
const a = {
|
|
36
|
+
_driver: I,
|
|
37
|
+
_support: !0,
|
|
38
|
+
/** Ensures the storage directory exists and respects custom baseDir overrides. */
|
|
39
|
+
_initStorage(e) {
|
|
40
|
+
return n(this, null, function* () {
|
|
41
|
+
try {
|
|
42
|
+
const r = typeof e == "object" && e !== null && "baseDir" in e ? e.baseDir : void 0;
|
|
43
|
+
typeof r == "string" && r.length > 0 ? o.baseDir = r : o.baseDir = h.CYBERSKILL_STORAGE_DIRECTORY, yield l.mkdir(o.baseDir, { recursive: !0 });
|
|
44
|
+
} catch (r) {
|
|
45
|
+
throw S.error("[Storage:init]", r), r;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
},
|
|
49
|
+
/** Deletes all stored entries by recreating the directory. */
|
|
50
|
+
clear() {
|
|
51
|
+
return n(this, null, function* () {
|
|
52
|
+
const { baseDir: e } = o;
|
|
53
|
+
yield l.rm(e, { recursive: !0, force: !0 }), yield l.mkdir(e, { recursive: !0 });
|
|
54
|
+
});
|
|
55
|
+
},
|
|
56
|
+
/** Reads and parses a stored value; returns null when the file is missing. */
|
|
57
|
+
getItem(e) {
|
|
58
|
+
return n(this, null, function* () {
|
|
59
|
+
const { baseDir: r } = o, t = E(e, r);
|
|
60
|
+
try {
|
|
61
|
+
const i = yield l.readFile(t, "utf8");
|
|
62
|
+
return JSON.parse(i);
|
|
63
|
+
} catch (i) {
|
|
64
|
+
if (i.code === "ENOENT")
|
|
65
|
+
return null;
|
|
66
|
+
throw i;
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
},
|
|
70
|
+
/** Iterates through all keys, invoking the iterator until it returns a value. */
|
|
71
|
+
iterate(e) {
|
|
72
|
+
return n(this, null, function* () {
|
|
73
|
+
const r = yield a.keys();
|
|
74
|
+
let t = 1;
|
|
75
|
+
for (const i of r) {
|
|
76
|
+
const d = yield a.getItem(i), y = e(d, i, t);
|
|
77
|
+
if (y !== void 0)
|
|
78
|
+
return y;
|
|
79
|
+
t += 1;
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
},
|
|
83
|
+
/** Returns the key name at the given index or null when out of bounds. */
|
|
84
|
+
key(e) {
|
|
85
|
+
return n(this, null, function* () {
|
|
86
|
+
var r;
|
|
87
|
+
return (r = (yield a.keys())[e]) != null ? r : null;
|
|
88
|
+
});
|
|
89
|
+
},
|
|
90
|
+
/** Lists all stored keys. */
|
|
91
|
+
keys() {
|
|
92
|
+
return n(this, null, function* () {
|
|
93
|
+
const { baseDir: e } = o;
|
|
94
|
+
try {
|
|
95
|
+
return (yield l.readdir(e)).filter((t) => t.endsWith(R)).map(T);
|
|
96
|
+
} catch (r) {
|
|
97
|
+
if (r.code === "ENOENT")
|
|
98
|
+
return [];
|
|
99
|
+
throw r;
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
},
|
|
103
|
+
/** Returns the count of stored keys. */
|
|
104
|
+
length() {
|
|
105
|
+
return n(this, null, function* () {
|
|
106
|
+
return (yield a.keys()).length;
|
|
107
|
+
});
|
|
108
|
+
},
|
|
109
|
+
/** Removes a stored value for the given key. */
|
|
110
|
+
removeItem(e) {
|
|
111
|
+
return n(this, null, function* () {
|
|
112
|
+
const { baseDir: r } = o, t = E(e, r);
|
|
113
|
+
yield l.rm(t, { force: !0 });
|
|
114
|
+
});
|
|
115
|
+
},
|
|
116
|
+
/** Stores a value as JSON on disk. */
|
|
117
|
+
setItem(e, r) {
|
|
118
|
+
return n(this, null, function* () {
|
|
119
|
+
const { baseDir: t } = o, i = E(e, t);
|
|
120
|
+
return yield l.mkdir(t, { recursive: !0 }), yield l.writeFile(i, JSON.stringify(r), "utf8"), r;
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
let c = null, D = null;
|
|
125
|
+
function f() {
|
|
126
|
+
return n(this, null, function* () {
|
|
127
|
+
return c ? (yield c, D) : (c = n(null, null, function* () {
|
|
128
|
+
yield _.defineDriver(a), o.baseDir = h.CYBERSKILL_STORAGE_DIRECTORY;
|
|
129
|
+
const e = yield _.getDriver(I), r = {
|
|
130
|
+
baseDir: o.baseDir,
|
|
131
|
+
name: b,
|
|
132
|
+
storeName: p
|
|
133
|
+
};
|
|
134
|
+
yield e._initStorage(r), D = e;
|
|
135
|
+
}).catch((e) => {
|
|
136
|
+
throw c = null, e;
|
|
137
|
+
}), yield c, D);
|
|
26
138
|
});
|
|
27
139
|
}
|
|
28
|
-
const
|
|
140
|
+
const w = {
|
|
29
141
|
/**
|
|
30
142
|
* Retrieves a value from persistent storage by key.
|
|
31
143
|
* This method fetches data that was previously stored using the set method.
|
|
@@ -34,14 +146,13 @@ const R = {
|
|
|
34
146
|
* @param key - The unique identifier for the stored value.
|
|
35
147
|
* @returns A promise that resolves to the stored value or null if not found.
|
|
36
148
|
*/
|
|
37
|
-
get(
|
|
38
|
-
return
|
|
149
|
+
get(e) {
|
|
150
|
+
return n(this, null, function* () {
|
|
39
151
|
try {
|
|
40
|
-
yield
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return i(e, { returnValue: null });
|
|
152
|
+
const t = yield (yield f()).getItem(e);
|
|
153
|
+
return t != null ? t : null;
|
|
154
|
+
} catch (r) {
|
|
155
|
+
return s(r, { returnValue: null });
|
|
45
156
|
}
|
|
46
157
|
});
|
|
47
158
|
},
|
|
@@ -54,12 +165,12 @@ const R = {
|
|
|
54
165
|
* @param value - The data to store (will be automatically serialized).
|
|
55
166
|
* @returns A promise that resolves when the storage operation is complete.
|
|
56
167
|
*/
|
|
57
|
-
set(
|
|
58
|
-
return
|
|
168
|
+
set(e, r) {
|
|
169
|
+
return n(this, null, function* () {
|
|
59
170
|
try {
|
|
60
|
-
yield
|
|
61
|
-
} catch (
|
|
62
|
-
|
|
171
|
+
yield (yield f()).setItem(e, r);
|
|
172
|
+
} catch (t) {
|
|
173
|
+
s(t);
|
|
63
174
|
}
|
|
64
175
|
});
|
|
65
176
|
},
|
|
@@ -70,12 +181,12 @@ const R = {
|
|
|
70
181
|
* @param key - The unique identifier of the value to remove.
|
|
71
182
|
* @returns A promise that resolves when the removal operation is complete.
|
|
72
183
|
*/
|
|
73
|
-
remove(
|
|
74
|
-
return
|
|
184
|
+
remove(e) {
|
|
185
|
+
return n(this, null, function* () {
|
|
75
186
|
try {
|
|
76
|
-
yield
|
|
77
|
-
} catch (
|
|
78
|
-
|
|
187
|
+
yield (yield f()).removeItem(e);
|
|
188
|
+
} catch (r) {
|
|
189
|
+
s(r);
|
|
79
190
|
}
|
|
80
191
|
});
|
|
81
192
|
},
|
|
@@ -87,13 +198,12 @@ const R = {
|
|
|
87
198
|
* @returns A promise that resolves to an array of storage keys.
|
|
88
199
|
*/
|
|
89
200
|
keys() {
|
|
90
|
-
return
|
|
201
|
+
return n(this, null, function* () {
|
|
91
202
|
try {
|
|
92
|
-
yield
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
return i(r, { returnValue: [] });
|
|
203
|
+
const r = yield (yield f()).keys();
|
|
204
|
+
return Array.isArray(r) ? r : (S.warn("[Storage:keys] Invalid keys response:", r), []);
|
|
205
|
+
} catch (e) {
|
|
206
|
+
return s(e, { returnValue: [] });
|
|
97
207
|
}
|
|
98
208
|
});
|
|
99
209
|
},
|
|
@@ -105,16 +215,16 @@ const R = {
|
|
|
105
215
|
* @param key - The storage key to generate a log link for.
|
|
106
216
|
* @returns A promise that resolves to a formatted log link string or null if an error occurs.
|
|
107
217
|
*/
|
|
108
|
-
getLogLink(
|
|
109
|
-
return
|
|
218
|
+
getLogLink(e) {
|
|
219
|
+
return n(this, null, function* () {
|
|
110
220
|
try {
|
|
111
|
-
return `${
|
|
112
|
-
} catch (
|
|
113
|
-
return
|
|
221
|
+
return `${g.join(h.CYBERSKILL_STORAGE_DIRECTORY, k(e))} (key: ${e})`;
|
|
222
|
+
} catch (r) {
|
|
223
|
+
return s(r, { returnValue: null });
|
|
114
224
|
}
|
|
115
225
|
});
|
|
116
226
|
}
|
|
117
227
|
};
|
|
118
228
|
export {
|
|
119
|
-
|
|
229
|
+
w as storage
|
|
120
230
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("clsx"),n=require("react"),l=require("./loading.module.scss.cjs");var p=Object.defineProperty,i=Object.getOwnPropertySymbols,m=Object.prototype.hasOwnProperty,f=Object.prototype.propertyIsEnumerable,u=(e,r,t)=>r in e?p(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,_=(e,r)=>{for(var t in r||(r={}))m.call(r,t)&&u(e,t,r[t]);if(i)for(var t of i(r))f.call(r,t)&&u(e,t,r[t]);return e},y=(e,r)=>{var t={};for(var a in e)m.call(e,a)&&r.indexOf(a)<0&&(t[a]=e[a]);if(e!=null&&i)for(var a of i(e))r.indexOf(a)<0&&f.call(e,a)&&(t[a]=e[a]);return t};function E(){if(document.getElementById("noscroll-style"))return;const e=document.createElement("style");e.id="noscroll-style",e.innerHTML=`
|
|
2
2
|
.noscroll {
|
|
3
3
|
overflow: hidden !important;
|
|
4
4
|
height: 100vh !important;
|
|
5
5
|
}
|
|
6
|
-
`,document.head.appendChild(e)}function
|
|
6
|
+
`,document.head.appendChild(e)}function h(e){var r=e,{full:t=!1,className:a="",message:o="Loading"}=r,v=y(r,["full","className","message"]);n.useEffect(()=>{if(t){document.body.classList.add("noscroll");const s=g=>g.preventDefault();return document.addEventListener("contextmenu",s),()=>{document.body.classList.remove("noscroll"),document.removeEventListener("contextmenu",s)}}},[t]),n.useEffect(()=>{E()},[]);function d(){return n.createElement("div",_({role:"status","aria-live":"polite","aria-label":o,className:l.default.container},v),n.createElement("div",{className:l.default.ring,"aria-hidden":"true"}),n.createElement("div",{className:l.default.ring,"aria-hidden":"true"}),n.createElement("div",{className:l.default.ring,"aria-hidden":"true"}),n.createElement("div",{className:l.default.ring,"aria-hidden":"true"}),o&&n.createElement("div",{className:l.default.message},o))}return t?n.createElement("div",{className:c(l.default.full,a)},d()):n.createElement("div",{className:c(l.default.block,a)},d())}exports.Loading=h;
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import m from "clsx";
|
|
2
|
-
import
|
|
2
|
+
import n, { useEffect as d } from "react";
|
|
3
3
|
import l from "./loading.module.scss.js";
|
|
4
|
-
var _ = Object.defineProperty,
|
|
4
|
+
var _ = Object.defineProperty, i = Object.getOwnPropertySymbols, u = Object.prototype.hasOwnProperty, v = Object.prototype.propertyIsEnumerable, f = (e, r, t) => r in e ? _(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t, y = (e, r) => {
|
|
5
5
|
for (var t in r || (r = {}))
|
|
6
|
-
|
|
7
|
-
if (
|
|
8
|
-
for (var t of
|
|
9
|
-
|
|
6
|
+
u.call(r, t) && f(e, t, r[t]);
|
|
7
|
+
if (i)
|
|
8
|
+
for (var t of i(r))
|
|
9
|
+
v.call(r, t) && f(e, t, r[t]);
|
|
10
10
|
return e;
|
|
11
11
|
}, E = (e, r) => {
|
|
12
12
|
var t = {};
|
|
13
|
-
for (var
|
|
14
|
-
|
|
15
|
-
if (e != null &&
|
|
16
|
-
for (var
|
|
17
|
-
r.indexOf(
|
|
13
|
+
for (var a in e)
|
|
14
|
+
u.call(e, a) && r.indexOf(a) < 0 && (t[a] = e[a]);
|
|
15
|
+
if (e != null && i)
|
|
16
|
+
for (var a of i(e))
|
|
17
|
+
r.indexOf(a) < 0 && v.call(e, a) && (t[a] = e[a]);
|
|
18
18
|
return t;
|
|
19
19
|
};
|
|
20
|
-
function
|
|
20
|
+
function h() {
|
|
21
21
|
if (document.getElementById("noscroll-style"))
|
|
22
22
|
return;
|
|
23
23
|
const e = document.createElement("style");
|
|
@@ -28,8 +28,8 @@ function N() {
|
|
|
28
28
|
}
|
|
29
29
|
`, document.head.appendChild(e);
|
|
30
30
|
}
|
|
31
|
-
function
|
|
32
|
-
var r = e, { full: t = !1, className:
|
|
31
|
+
function L(e) {
|
|
32
|
+
var r = e, { full: t = !1, className: a = "", message: o = "Loading" } = r, p = E(r, ["full", "className", "message"]);
|
|
33
33
|
d(() => {
|
|
34
34
|
if (t) {
|
|
35
35
|
document.body.classList.add("noscroll");
|
|
@@ -39,13 +39,26 @@ function b(e) {
|
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
41
|
}, [t]), d(() => {
|
|
42
|
-
|
|
42
|
+
h();
|
|
43
43
|
}, []);
|
|
44
|
-
function
|
|
45
|
-
return /* @__PURE__ */
|
|
44
|
+
function s() {
|
|
45
|
+
return /* @__PURE__ */ n.createElement(
|
|
46
|
+
"div",
|
|
47
|
+
y({
|
|
48
|
+
role: "status",
|
|
49
|
+
"aria-live": "polite",
|
|
50
|
+
"aria-label": o,
|
|
51
|
+
className: l.container
|
|
52
|
+
}, p),
|
|
53
|
+
/* @__PURE__ */ n.createElement("div", { className: l.ring, "aria-hidden": "true" }),
|
|
54
|
+
/* @__PURE__ */ n.createElement("div", { className: l.ring, "aria-hidden": "true" }),
|
|
55
|
+
/* @__PURE__ */ n.createElement("div", { className: l.ring, "aria-hidden": "true" }),
|
|
56
|
+
/* @__PURE__ */ n.createElement("div", { className: l.ring, "aria-hidden": "true" }),
|
|
57
|
+
o && /* @__PURE__ */ n.createElement("div", { className: l.message }, o)
|
|
58
|
+
);
|
|
46
59
|
}
|
|
47
|
-
return t ? /* @__PURE__ */
|
|
60
|
+
return t ? /* @__PURE__ */ n.createElement("div", { className: m(l.full, a) }, s()) : /* @__PURE__ */ n.createElement("div", { className: m(l.block, a) }, s());
|
|
48
61
|
}
|
|
49
62
|
export {
|
|
50
|
-
|
|
63
|
+
L as Loading
|
|
51
64
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { HTMLAttributes } from 'react';
|
|
1
2
|
export interface I_LoadingContext {
|
|
2
3
|
isLoading: boolean;
|
|
3
4
|
isGlobalLoading: boolean;
|
|
4
5
|
showLoading: (global?: boolean) => void;
|
|
5
6
|
hideLoading: () => void;
|
|
6
7
|
}
|
|
7
|
-
export interface I_LoadingProps {
|
|
8
|
+
export interface I_LoadingProps extends HTMLAttributes<HTMLDivElement> {
|
|
8
9
|
full?: boolean;
|
|
9
10
|
block?: boolean;
|
|
10
11
|
className?: string;
|
|
@@ -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 t=require("../../typescript/common.type.cjs");var s=Object.defineProperty,a=Object.getOwnPropertySymbols,m=Object.prototype.hasOwnProperty,_=Object.prototype.propertyIsEnumerable,c=(e,n,r)=>n in e?s(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r,p=(e,n)=>{for(var r in n||(n={}))m.call(n,r)&&c(e,r,n[r]);if(a)for(var r of a(n))_.call(n,r)&&c(e,r,n[r]);return e};const u={a:["à","á","ạ","ả","ã","â","ầ","ấ","ậ","ẩ","ẫ","ă","ằ","ắ","ặ","ẳ","ẵ"],e:["è","é","ẹ","ẻ","ẽ","ê","ề","ế","ệ","ể","ễ"],i:["ì","í","ị","ỉ","ĩ"],o:["ò","ó","ọ","ỏ","õ","ô","ồ","ố","ộ","ổ","ỗ","ơ","ờ","ớ","ợ","ở","ỡ"],u:["ù","ú","ụ","ủ","ũ","ư","ừ","ứ","ự","ử","ữ"],y:["ỳ","ý","ỵ","ỷ","ỹ"],d:["đ"]},O=Object.entries(u).reduce((e,[n,r])=>(e[n.toUpperCase()]=r.map(o=>o.toUpperCase()),e),{});function v(e){e=e.normalize("NFD");const n=p(p({},u),O);for(const[r,o]of Object.entries(n)){const i=`[${r}${o.join("")}]`,E=`(${[r,...o].join("|")})`;e=e.replace(new RegExp(i,"g"),E)}return e}function f(e){return e.normalize("NFD").replace(new RegExp("\\p{Diacritic}","gu"),"")}function l(e,n){if(!n)return Array.from(new Set(e));const r=new Set,o=[];for(const i of e){const E=n(i);r.has(E)||(r.add(E),o.push(i))}return o}function D(e){const{NODE_ENV:n=t.E_Environment.DEVELOPMENT,NODE_ENV_MODE:r=t.E_Environment.DEVELOPMENT}=e,o=n===t.E_Environment.DEVELOPMENT&&r===t.E_Environment.DEVELOPMENT,i=n===t.E_Environment.PRODUCTION&&r===t.E_Environment.STAGING,E=n===t.E_Environment.PRODUCTION&&r===t.E_Environment.PRODUCTION;if(n===t.E_Environment.PRODUCTION&&r===t.E_Environment.DEVELOPMENT)throw new Error("NODE_ENV_MODE must be set to staging or production in production environment");return{IS_DEV:o,IS_STAG:i,IS_PROD:E}}exports.mapEnvironment=D;exports.regexSearchMapper=v;exports.removeAccent=f;exports.uniqueArray=l;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import u from "unorm";
|
|
2
1
|
import { E_Environment as t } from "../../typescript/common.type.js";
|
|
3
|
-
var
|
|
2
|
+
var u = Object.defineProperty, i = Object.getOwnPropertySymbols, O = Object.prototype.hasOwnProperty, f = Object.prototype.propertyIsEnumerable, p = (e, r, n) => r in e ? u(e, r, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[r] = n, E = (e, r) => {
|
|
4
3
|
for (var n in r || (r = {}))
|
|
5
|
-
|
|
6
|
-
if (
|
|
7
|
-
for (var n of
|
|
8
|
-
|
|
4
|
+
O.call(r, n) && p(e, n, r[n]);
|
|
5
|
+
if (i)
|
|
6
|
+
for (var n of i(r))
|
|
7
|
+
f.call(r, n) && p(e, n, r[n]);
|
|
9
8
|
return e;
|
|
10
9
|
};
|
|
11
10
|
const s = {
|
|
@@ -20,8 +19,8 @@ const s = {
|
|
|
20
19
|
(e, [r, n]) => (e[r.toUpperCase()] = n.map((o) => o.toUpperCase()), e),
|
|
21
20
|
{}
|
|
22
21
|
);
|
|
23
|
-
function
|
|
24
|
-
e =
|
|
22
|
+
function D(e) {
|
|
23
|
+
e = e.normalize("NFD");
|
|
25
24
|
const r = E(E({}, s), _);
|
|
26
25
|
for (const [n, o] of Object.entries(r)) {
|
|
27
26
|
const a = `[${n}${o.join("")}]`, c = `(${[n, ...o].join("|")})`;
|
|
@@ -29,10 +28,10 @@ function P(e) {
|
|
|
29
28
|
}
|
|
30
29
|
return e;
|
|
31
30
|
}
|
|
32
|
-
function
|
|
31
|
+
function N(e) {
|
|
33
32
|
return e.normalize("NFD").replace(new RegExp("\\p{Diacritic}", "gu"), "");
|
|
34
33
|
}
|
|
35
|
-
function
|
|
34
|
+
function l(e, r) {
|
|
36
35
|
if (!r)
|
|
37
36
|
return Array.from(new Set(e));
|
|
38
37
|
const n = /* @__PURE__ */ new Set(), o = [];
|
|
@@ -42,15 +41,15 @@ function v(e, r) {
|
|
|
42
41
|
}
|
|
43
42
|
return o;
|
|
44
43
|
}
|
|
45
|
-
function
|
|
44
|
+
function P(e) {
|
|
46
45
|
const { NODE_ENV: r = t.DEVELOPMENT, NODE_ENV_MODE: n = t.DEVELOPMENT } = e, o = r === t.DEVELOPMENT && n === t.DEVELOPMENT, a = r === t.PRODUCTION && n === t.STAGING, c = r === t.PRODUCTION && n === t.PRODUCTION;
|
|
47
46
|
if (r === t.PRODUCTION && n === t.DEVELOPMENT)
|
|
48
47
|
throw new Error("NODE_ENV_MODE must be set to staging or production in production environment");
|
|
49
48
|
return { IS_DEV: o, IS_STAG: a, IS_PROD: c };
|
|
50
49
|
}
|
|
51
50
|
export {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
51
|
+
P as mapEnvironment,
|
|
52
|
+
D as regexSearchMapper,
|
|
53
|
+
N as removeAccent,
|
|
54
|
+
l as uniqueArray
|
|
56
55
|
};
|
package/dist/util/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./common/common.util.cjs"),e=require("./object/object.util.cjs"),a=require("./serializer/serializer.util.cjs"),r=require("./string/string.util.cjs"),i=require("./validate/validate.util.cjs");exports.mapEnvironment=t.mapEnvironment;exports.regexSearchMapper=t.regexSearchMapper;exports.removeAccent=t.removeAccent;exports.uniqueArray=t.uniqueArray;exports.deepMerge=e.deepMerge;exports.getNestedValue=e.getNestedValue;exports.isJSON=e.isJSON;exports.normalizeMongoFilter=e.normalizeMongoFilter;exports.setNestedValue=e.setNestedValue;exports.serializer=a.serializer;exports.generateRandomPassword=r.generateRandomPassword;exports.generateShortId=r.generateShortId;exports.generateSlug=r.generateSlug;exports.getFileName=r.getFileName;exports.substringBetween=r.substringBetween;exports.validate=i.validate;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./common/common.util.cjs"),e=require("./object/object.util.cjs"),a=require("./serializer/serializer.util.cjs"),r=require("./string/string.util.cjs"),i=require("./validate/validate.util.cjs");exports.mapEnvironment=t.mapEnvironment;exports.regexSearchMapper=t.regexSearchMapper;exports.removeAccent=t.removeAccent;exports.uniqueArray=t.uniqueArray;exports.deepClone=e.deepClone;exports.deepMerge=e.deepMerge;exports.getNestedValue=e.getNestedValue;exports.isJSON=e.isJSON;exports.normalizeMongoFilter=e.normalizeMongoFilter;exports.setNestedValue=e.setNestedValue;exports.serializer=a.serializer;exports.generateRandomPassword=r.generateRandomPassword;exports.generateShortId=r.generateShortId;exports.generateSlug=r.generateSlug;exports.getFileName=r.getFileName;exports.substringBetween=r.substringBetween;exports.validate=i.validate;
|
package/dist/util/index.js
CHANGED
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
import { mapEnvironment as t, regexSearchMapper as o, removeAccent as a, uniqueArray as n } from "./common/common.util.js";
|
|
2
|
-
import {
|
|
3
|
-
import { serializer as
|
|
4
|
-
import { generateRandomPassword as
|
|
5
|
-
import { validate as
|
|
2
|
+
import { deepClone as g, deepMerge as i, getNestedValue as p, isJSON as l, normalizeMongoFilter as s, setNestedValue as d } from "./object/object.util.js";
|
|
3
|
+
import { serializer as x } from "./serializer/serializer.util.js";
|
|
4
|
+
import { generateRandomPassword as N, generateShortId as S, generateSlug as c, getFileName as v, substringBetween as M } from "./string/string.util.js";
|
|
5
|
+
import { validate as w } from "./validate/validate.util.js";
|
|
6
6
|
export {
|
|
7
|
-
g as
|
|
8
|
-
|
|
9
|
-
N as
|
|
10
|
-
S as
|
|
11
|
-
c as
|
|
12
|
-
|
|
13
|
-
p as
|
|
7
|
+
g as deepClone,
|
|
8
|
+
i as deepMerge,
|
|
9
|
+
N as generateRandomPassword,
|
|
10
|
+
S as generateShortId,
|
|
11
|
+
c as generateSlug,
|
|
12
|
+
v as getFileName,
|
|
13
|
+
p as getNestedValue,
|
|
14
|
+
l as isJSON,
|
|
14
15
|
t as mapEnvironment,
|
|
15
16
|
s as normalizeMongoFilter,
|
|
16
17
|
o as regexSearchMapper,
|
|
17
18
|
a as removeAccent,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
x as serializer,
|
|
20
|
+
d as setNestedValue,
|
|
21
|
+
M as substringBetween,
|
|
21
22
|
n as uniqueArray,
|
|
22
|
-
|
|
23
|
+
w as validate
|
|
23
24
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./object.util.cjs");exports.deepMerge=e.deepMerge;exports.getNestedValue=e.getNestedValue;exports.isJSON=e.isJSON;exports.normalizeMongoFilter=e.normalizeMongoFilter;exports.setNestedValue=e.setNestedValue;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./object.util.cjs");exports.deepClone=e.deepClone;exports.deepMerge=e.deepMerge;exports.getNestedValue=e.getNestedValue;exports.isJSON=e.isJSON;exports.normalizeMongoFilter=e.normalizeMongoFilter;exports.setNestedValue=e.setNestedValue;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { deepMerge as
|
|
1
|
+
import { deepClone as t, deepMerge as l, getNestedValue as r, isJSON as d, normalizeMongoFilter as s, setNestedValue as a } from "./object.util.js";
|
|
2
2
|
export {
|
|
3
|
-
|
|
3
|
+
t as deepClone,
|
|
4
|
+
l as deepMerge,
|
|
4
5
|
r as getNestedValue,
|
|
5
|
-
|
|
6
|
+
d as isJSON,
|
|
6
7
|
s as normalizeMongoFilter,
|
|
7
8
|
a as setNestedValue
|
|
8
9
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var A=Object.defineProperty,v=Object.defineProperties,h=Object.getOwnPropertyDescriptors,f=Object.getOwnPropertySymbols,w=Object.prototype.hasOwnProperty,_=Object.prototype.propertyIsEnumerable,y=(e,r,n)=>r in e?A(e,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[r]=n,p=(e,r)=>{for(var n in r||(r={}))w.call(r,n)&&y(e,n,r[n]);if(f)for(var n of f(r))_.call(r,n)&&y(e,n,r[n]);return e},d=(e,r)=>v(e,h(r));function P(e){try{return JSON.parse(e),!0}catch(r){return!1}}function b(e,r){let n=e;const o=r.length;for(let t=0;t<o;t++)if(n&&typeof n=="object"&&r[t]in n)n=n[r[t]];else return;return n}function O(e,r,n){if(r.length===0)return e;const[o,...t]=r;if(t.length===0)return d(p({},e),{[o]:n});const i=e[o];return d(p({},e),{[o]:O(typeof i=="object"&&i!==null?i:{},t,n)})}function u(e){if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(o=>u(o));if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp)return new RegExp(e.source,e.flags);const r=Object.getPrototypeOf(e);if(r!==Object.prototype&&r!==null)return e;const n={};for(const o in e)Object.prototype.hasOwnProperty.call(e,o)&&(n[o]=u(e[o]));return n}function g(...e){if(e.length===0)return{};const r=e.filter(t=>t!=null);if(r.length===0)return{};if(r.length===1)return r[0];if(r.every(Array.isArray))return[].concat(...r);if(r.every(t=>typeof t=="object"&&t!==null&&!Array.isArray(t))){const t={};for(const i of r){const c=i;for(const s in c)if(Object.prototype.hasOwnProperty.call(c,s)){const a=c[s];if(Object.prototype.hasOwnProperty.call(t,s)){const l=t[s];typeof a=="object"&&a!==null&&typeof l=="object"&&l!==null?Array.isArray(a)&&Array.isArray(l)?t[s]=l.concat(a):!Array.isArray(a)&&!Array.isArray(l)?t[s]=g(l,a):t[s]=a:t[s]=a}else t[s]=a}}return t}if(r.every(t=>typeof t!="object"||t===null))throw new Error("deepMerge: Cannot merge primitive values. All arguments must be objects or arrays.");const n=r.some(Array.isArray),o=r.some(t=>typeof t=="object"&&t!==null&&!Array.isArray(t));throw n&&o?new Error("deepMerge: Cannot mix arrays and objects. All arguments must be either arrays or objects."):new Error("deepMerge: Invalid arguments provided. All arguments must be objects or arrays of the same type.")}function m(e){if(!e||typeof e!="object")return e;const r={};for(const[n,o]of Object.entries(e))if(o&&typeof o=="object"&&!Array.isArray(o))if(Object.keys(o).some(i=>i.startsWith("$")))r[n]=o;else{const i=m(o);for(const[c,s]of Object.entries(i)){const a=`${n}.${c}`;r[a]=s}}else r[n]=o;return r}exports.deepClone=u;exports.deepMerge=g;exports.getNestedValue=b;exports.isJSON=P;exports.normalizeMongoFilter=m;exports.setNestedValue=O;
|
|
@@ -29,48 +29,28 @@ export declare function getNestedValue<T>(obj: T, path: (string | number)[]): un
|
|
|
29
29
|
*/
|
|
30
30
|
export declare function setNestedValue<T>(obj: T, path: (string | number)[], value: unknown): T;
|
|
31
31
|
/**
|
|
32
|
-
* Deep
|
|
33
|
-
* This function
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* - Provides better type inference and safety
|
|
38
|
-
* - Throws descriptive errors for invalid input
|
|
32
|
+
* Deep clones an object or array.
|
|
33
|
+
* This function creates a deep copy of the input, recursively cloning objects and arrays.
|
|
34
|
+
* Primitive values, dates, and other non-plain objects are returned as is (or cloned if supported).
|
|
35
|
+
* Note: This implementation focuses on plain objects and arrays. For complex types like Map/Set/Buffer/ObjectId,
|
|
36
|
+
* it returns the reference or handles them according to specific logic.
|
|
39
37
|
*
|
|
40
|
-
* @param
|
|
41
|
-
* @returns
|
|
42
|
-
* @throws {Error} When arguments are mixed types (some arrays, some objects) or when all arguments are primitive values.
|
|
43
|
-
*
|
|
44
|
-
* @example
|
|
45
|
-
* ```typescript
|
|
46
|
-
* // Merge objects
|
|
47
|
-
* deepMerge({ a: 1 }, { b: 2 }, { a: 3 }) // { a: 3, b: 2 }
|
|
48
|
-
*
|
|
49
|
-
* // Merge arrays
|
|
50
|
-
* deepMerge([1, 2], [3, 4]) // [1, 2, 3, 4]
|
|
51
|
-
*
|
|
52
|
-
* // Handle null/undefined
|
|
53
|
-
* deepMerge({ a: 1 }, null, undefined, { b: 2 }) // { a: 1, b: 2 }
|
|
54
|
-
*
|
|
55
|
-
* // Nested objects with arrays
|
|
56
|
-
* deepMerge(
|
|
57
|
-
* { items: [1, 2], config: { theme: 'dark' } },
|
|
58
|
-
* { items: [3, 4], config: { size: 'large' } }
|
|
59
|
-
* ) // { items: [1, 2, 3, 4], config: { theme: 'dark', size: 'large' } }
|
|
60
|
-
* ```
|
|
38
|
+
* @param obj - The object to clone.
|
|
39
|
+
* @returns A deep copy of the object.
|
|
61
40
|
*/
|
|
41
|
+
export declare function deepClone<T>(obj: T): T;
|
|
62
42
|
/**
|
|
63
43
|
* Deep merges multiple objects into a single object.
|
|
64
44
|
* @param args - The objects to merge. Can be empty, in which case returns an empty object.
|
|
65
45
|
* @returns The merged object.
|
|
66
46
|
*/
|
|
67
|
-
export declare function deepMerge<T
|
|
47
|
+
export declare function deepMerge<T = Record<string, unknown>>(...args: (object | null | undefined)[]): T;
|
|
68
48
|
/**
|
|
69
49
|
* Deep merges multiple arrays into a single array.
|
|
70
50
|
* @param args - The arrays to merge. Can be empty, in which case returns an empty array.
|
|
71
51
|
* @returns The merged array.
|
|
72
52
|
*/
|
|
73
|
-
export declare function deepMerge<T
|
|
53
|
+
export declare function deepMerge<T = unknown[]>(...args: (unknown[] | null | undefined)[]): T;
|
|
74
54
|
/**
|
|
75
55
|
* Normalizes MongoDB filters to support both dot notation strings and nested objects.
|
|
76
56
|
* This function converts nested object filters to dot notation format while preserving
|