@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,31 +1,143 @@
1
- import u from "node-persist";
2
- import { getEnv as m } from "../../config/env/env.util.js";
3
- import { catchError as i, log as v } from "../log/log.util.js";
4
- var l = (r, e, n) => new Promise((h, a) => {
5
- var d = (t) => {
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
- s(n.next(t));
8
- } catch (c) {
9
- a(c);
10
+ m(t.next(u));
11
+ } catch (v) {
12
+ d(v);
10
13
  }
11
- }, f = (t) => {
14
+ }, O = (u) => {
12
15
  try {
13
- s(n.throw(t));
14
- } catch (c) {
15
- a(c);
16
+ m(t.throw(u));
17
+ } catch (v) {
18
+ d(v);
16
19
  }
17
- }, s = (t) => t.done ? h(t.value) : Promise.resolve(t.value).then(d, f);
18
- s((n = n.apply(r, e)).next());
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 y = m();
21
- function o() {
22
- return l(this, null, function* () {
23
- u.defaultInstance || (yield u.init({
24
- dir: y.CYBERSKILL_STORAGE_DIRECTORY
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 R = {
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(r) {
38
- return l(this, null, function* () {
149
+ get(e) {
150
+ return n(this, null, function* () {
39
151
  try {
40
- yield o();
41
- const e = yield u.getItem(r);
42
- return e != null ? e : null;
43
- } catch (e) {
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(r, e) {
58
- return l(this, null, function* () {
168
+ set(e, r) {
169
+ return n(this, null, function* () {
59
170
  try {
60
- yield o(), yield u.setItem(r, e);
61
- } catch (n) {
62
- i(n);
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(r) {
74
- return l(this, null, function* () {
184
+ remove(e) {
185
+ return n(this, null, function* () {
75
186
  try {
76
- yield o(), yield u.removeItem(r);
77
- } catch (e) {
78
- i(e);
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 l(this, null, function* () {
201
+ return n(this, null, function* () {
91
202
  try {
92
- yield o();
93
- const r = yield u.keys();
94
- return Array.isArray(r) ? r : (v.warn("[Storage:keys] Invalid keys response:", r), []);
95
- } catch (r) {
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(r) {
109
- return l(this, null, function* () {
218
+ getLogLink(e) {
219
+ return n(this, null, function* () {
110
220
  try {
111
- return `${y.CYBERSKILL_STORAGE_DIRECTORY} (key: ${r})`;
112
- } catch (e) {
113
- return i(e, { returnValue: null });
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
- R as storage
229
+ w as storage
120
230
  };
@@ -1,6 +1,6 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("clsx"),a=require("react"),l=require("./loading.module.scss.cjs");var _=Object.defineProperty,o=Object.getOwnPropertySymbols,f=Object.prototype.hasOwnProperty,u=Object.prototype.propertyIsEnumerable,m=(e,r,t)=>r in e?_(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,p=(e,r)=>{for(var t in r||(r={}))f.call(r,t)&&m(e,t,r[t]);if(o)for(var t of o(r))u.call(r,t)&&m(e,t,r[t]);return e},y=(e,r)=>{var t={};for(var n in e)f.call(e,n)&&r.indexOf(n)<0&&(t[n]=e[n]);if(e!=null&&o)for(var n of o(e))r.indexOf(n)<0&&u.call(e,n)&&(t[n]=e[n]);return t};function E(){if(document.getElementById("noscroll-style"))return;const e=document.createElement("style");e.id="noscroll-style",e.innerHTML=`
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 N(e){var r=e,{full:t=!1,className:n="",message:i="Loading"}=r,v=y(r,["full","className","message"]);a.useEffect(()=>{if(t){document.body.classList.add("noscroll");const c=g=>g.preventDefault();return document.addEventListener("contextmenu",c),()=>{document.body.classList.remove("noscroll"),document.removeEventListener("contextmenu",c)}}},[t]),a.useEffect(()=>{E()},[]);function s(){return a.createElement("div",p({className:l.default.container},v),a.createElement("div",{className:l.default.ring}),a.createElement("div",{className:l.default.ring}),a.createElement("div",{className:l.default.ring}),a.createElement("div",{className:l.default.ring}),i&&a.createElement("div",{className:l.default.message},i))}return t?a.createElement("div",{className:d(l.default.full,n)},s()):a.createElement("div",{className:d(l.default.block,n)},s())}exports.Loading=N;
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 a, { useEffect as d } from "react";
2
+ import n, { useEffect as d } from "react";
3
3
  import l from "./loading.module.scss.js";
4
- var _ = Object.defineProperty, o = Object.getOwnPropertySymbols, v = Object.prototype.hasOwnProperty, u = 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) => {
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
- v.call(r, t) && f(e, t, r[t]);
7
- if (o)
8
- for (var t of o(r))
9
- u.call(r, t) && f(e, t, r[t]);
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 n in e)
14
- v.call(e, n) && r.indexOf(n) < 0 && (t[n] = e[n]);
15
- if (e != null && o)
16
- for (var n of o(e))
17
- r.indexOf(n) < 0 && u.call(e, n) && (t[n] = e[n]);
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 N() {
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 b(e) {
32
- var r = e, { full: t = !1, className: n = "", message: s = "Loading" } = r, p = E(r, ["full", "className", "message"]);
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
- N();
42
+ h();
43
43
  }, []);
44
- function i() {
45
- return /* @__PURE__ */ a.createElement("div", y({ className: l.container }, p), /* @__PURE__ */ a.createElement("div", { className: l.ring }), /* @__PURE__ */ a.createElement("div", { className: l.ring }), /* @__PURE__ */ a.createElement("div", { className: l.ring }), /* @__PURE__ */ a.createElement("div", { className: l.ring }), s && /* @__PURE__ */ a.createElement("div", { className: l.message }, s));
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__ */ a.createElement("div", { className: m(l.full, n) }, i()) : /* @__PURE__ */ a.createElement("div", { className: m(l.block, n) }, i());
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
- b as Loading
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 s=require("unorm"),t=require("../../typescript/common.type.cjs");var m=Object.defineProperty,c=Object.getOwnPropertySymbols,_=Object.prototype.hasOwnProperty,O=Object.prototype.propertyIsEnumerable,a=(e,n,r)=>n in e?m(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r,p=(e,n)=>{for(var r in n||(n={}))_.call(n,r)&&a(e,r,n[r]);if(c)for(var r of c(n))O.call(n,r)&&a(e,r,n[r]);return e};const u={a:["à","á","ạ","ả","ã","â","ầ","ấ","ậ","ẩ","ẫ","ă","ằ","ắ","ặ","ẳ","ẵ"],e:["è","é","ẹ","ẻ","ẽ","ê","ề","ế","ệ","ể","ễ"],i:["ì","í","ị","ỉ","ĩ"],o:["ò","ó","ọ","ỏ","õ","ô","ồ","ố","ộ","ổ","ỗ","ơ","ờ","ớ","ợ","ở","ỡ"],u:["ù","ú","ụ","ủ","ũ","ư","ừ","ứ","ự","ử","ữ"],y:["ỳ","ý","ỵ","ỷ","ỹ"],d:["đ"]},f=Object.entries(u).reduce((e,[n,r])=>(e[n.toUpperCase()]=r.map(o=>o.toUpperCase()),e),{});function v(e){e=s.nfkc(e);const n=p(p({},u),f);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 l(e){return e.normalize("NFD").replace(new RegExp("\\p{Diacritic}","gu"),"")}function D(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 N(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=N;exports.regexSearchMapper=v;exports.removeAccent=l;exports.uniqueArray=D;
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 O = Object.defineProperty, p = Object.getOwnPropertySymbols, f = Object.prototype.hasOwnProperty, m = Object.prototype.propertyIsEnumerable, i = (e, r, n) => r in e ? O(e, r, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[r] = n, E = (e, r) => {
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
- f.call(r, n) && i(e, n, r[n]);
6
- if (p)
7
- for (var n of p(r))
8
- m.call(r, n) && i(e, n, r[n]);
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 P(e) {
24
- e = u.nfkc(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 l(e) {
31
+ function N(e) {
33
32
  return e.normalize("NFD").replace(new RegExp("\\p{Diacritic}", "gu"), "");
34
33
  }
35
- function v(e, r) {
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 d(e) {
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
- d as mapEnvironment,
53
- P as regexSearchMapper,
54
- l as removeAccent,
55
- v as uniqueArray
51
+ P as mapEnvironment,
52
+ D as regexSearchMapper,
53
+ N as removeAccent,
54
+ l as uniqueArray
56
55
  };
@@ -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;
@@ -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 { deepMerge as g, getNestedValue as i, isJSON as p, normalizeMongoFilter as s, setNestedValue as l } from "./object/object.util.js";
3
- import { serializer as u } from "./serializer/serializer.util.js";
4
- import { generateRandomPassword as f, generateShortId as N, generateSlug as S, getFileName as c, substringBetween as v } from "./string/string.util.js";
5
- import { validate as h } from "./validate/validate.util.js";
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 deepMerge,
8
- f as generateRandomPassword,
9
- N as generateShortId,
10
- S as generateSlug,
11
- c as getFileName,
12
- i as getNestedValue,
13
- p as isJSON,
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
- u as serializer,
19
- l as setNestedValue,
20
- v as substringBetween,
19
+ x as serializer,
20
+ d as setNestedValue,
21
+ M as substringBetween,
21
22
  n as uniqueArray,
22
- h as validate
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 o, getNestedValue as r, isJSON as l, normalizeMongoFilter as s, setNestedValue as a } from "./object.util.js";
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
- o as deepMerge,
3
+ t as deepClone,
4
+ l as deepMerge,
4
5
  r as getNestedValue,
5
- l as isJSON,
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"});const i=require("lodash-es");var g=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?g(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,l=(r,e)=>{for(var t in e||(e={}))b.call(e,t)&&u(r,t,e[t]);if(a)for(var t of a(e))h.call(e,t)&&u(r,t,e[t]);return r},c=(r,e)=>v(r,O(e));function _(r){try{return JSON.parse(r),!0}catch(e){return!1}}function j(r,e){return e.reduce((t,n)=>{if(t&&typeof t=="object"&&n in t)return t[n]},r)}function f(r,e,t){if(e.length===0)return r;const[n,...o]=e;if(o.length===0)return c(l({},r),{[n]:t});const s=r[n];return c(l({},r),{[n]:f(typeof s=="object"&&s!==null?s:{},o,t)})}function w(...r){if(r.length===0)return{};const e=r.filter(o=>o!=null).map(o=>typeof o!="object"?{}:o);if(e.length===0)return{};if(e.length===1)return e[0];if(e.every(i.isArray))return[].concat(...e);if(e.every(o=>typeof o=="object"&&o!==null&&!i.isArray(o)))return i.mergeWith({},...e,(o,s)=>{if(i.isArray(o)&&i.isArray(s))return o.concat(s)});if(e.every(o=>typeof o!="object"||o===null))throw new Error("deepMerge: Cannot merge primitive values. All arguments must be objects or arrays.");const t=e.some(i.isArray),n=e.some(o=>typeof o=="object"&&o!==null&&!i.isArray(o));throw t&&n?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 p(r){if(!r||typeof r!="object")return r;const e={};for(const[t,n]of Object.entries(r))if(n&&typeof n=="object"&&!Array.isArray(n))if(Object.keys(n).some(s=>s.startsWith("$")))e[t]=n;else{const s=p(n);for(const[y,d]of Object.entries(s)){const m=`${t}.${y}`;e[m]=d}}else e[t]=n;return e}exports.deepMerge=w;exports.getNestedValue=j;exports.isJSON=_;exports.normalizeMongoFilter=p;exports.setNestedValue=f;
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 merges multiple objects or arrays into a single object or array.
33
- * This function handles different types of merging with improved type safety and error handling:
34
- * - If all arguments are arrays, it concatenates them
35
- * - If all arguments are objects, it deeply merges them (concatenating arrays within objects)
36
- * - Handles null/undefined values gracefully by treating them as empty objects
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 args - The objects or arrays to merge. Can be empty, in which case returns an empty object.
41
- * @returns The merged result - either a concatenated array or a deeply merged object.
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 extends Record<string, unknown>>(...args: (T | null | undefined)[]): 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 extends unknown[]>(...args: (T | null | undefined)[]): 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