@cyberskill/shared 2.20.0 → 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 (43) hide show
  1. package/dist/config/storybook/storybook.main.cjs +1 -1
  2. package/dist/config/storybook/storybook.main.js +1 -1
  3. package/dist/config/vitest/vitest.e2e.cjs +1 -1
  4. package/dist/config/vitest/vitest.e2e.js +6 -6
  5. package/dist/config/vitest/vitest.unit.cjs +1 -1
  6. package/dist/config/vitest/vitest.unit.js +5 -5
  7. package/dist/node/mongo/mongo-controller.test.unit.d.ts +1 -0
  8. package/dist/node/mongo/mongo.test.unit.d.ts +1 -0
  9. package/dist/node/mongo/mongo.util.cjs +2 -2
  10. package/dist/node/mongo/mongo.util.d.ts +9 -203
  11. package/dist/node/mongo/mongo.util.js +70 -68
  12. package/dist/node/path/path.constant.cjs +1 -1
  13. package/dist/node/path/path.constant.js +113 -109
  14. package/dist/node/path/path.test.unit.d.ts +1 -0
  15. package/dist/node/path/path.util.d.ts +2 -2
  16. package/dist/react/loading/loading.component.cjs +2 -2
  17. package/dist/react/loading/loading.component.js +32 -19
  18. package/dist/react/loading/loading.test.unit.d.ts +1 -0
  19. package/dist/react/loading/loading.type.d.ts +2 -1
  20. package/dist/util/common/common.test.unit.d.ts +1 -0
  21. package/dist/util/common/common.util.cjs +1 -1
  22. package/dist/util/common/common.util.js +14 -15
  23. package/dist/util/index.cjs +1 -1
  24. package/dist/util/index.js +16 -15
  25. package/dist/util/object/index.cjs +1 -1
  26. package/dist/util/object/index.js +4 -3
  27. package/dist/util/object/object.test.unit.d.ts +1 -0
  28. package/dist/util/object/object.util.cjs +1 -1
  29. package/dist/util/object/object.util.d.ts +10 -30
  30. package/dist/util/object/object.util.js +102 -69
  31. package/dist/util/serializer/serializer.test.unit.d.ts +1 -0
  32. package/dist/util/serializer/serializer.util.cjs +1 -1
  33. package/dist/util/serializer/serializer.util.js +19 -16
  34. package/dist/util/string/string.test.unit.d.ts +1 -0
  35. package/dist/util/string/string.util.cjs +1 -1
  36. package/dist/util/string/string.util.d.ts +4 -3
  37. package/dist/util/string/string.util.js +32 -41
  38. package/dist/util/validate/validate.test.unit.d.ts +1 -0
  39. package/dist/util/validate/validate.util.cjs +1 -1
  40. package/dist/util/validate/validate.util.js +9 -9
  41. package/package.json +37 -45
  42. /package/dist/node_modules/.pnpm/{vitest@4.0.13_@types_debug@4.1.12_@types_node@24.10.1_jiti@2.6.1_jsdom@27.2.0_sass@1.94.2_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
  43. /package/dist/node_modules/.pnpm/{vitest@4.0.13_@types_debug@4.1.12_@types_node@24.10.1_jiti@2.6.1_jsdom@27.2.0_sass@1.94.2_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,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
@@ -1,97 +1,130 @@
1
- import { isArray as i, mergeWith as d } from "lodash-es";
2
- var m = Object.defineProperty, v = Object.defineProperties, O = Object.getOwnPropertyDescriptors, a = Object.getOwnPropertySymbols, b = Object.prototype.hasOwnProperty, h = Object.prototype.propertyIsEnumerable, u = (r, e, t) => e in r ? m(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, f = (r, e) => {
3
- for (var t in e || (e = {}))
4
- b.call(e, t) && u(r, t, e[t]);
5
- if (a)
6
- for (var t of a(e))
7
- h.call(e, t) && u(r, t, e[t]);
8
- return r;
9
- }, c = (r, e) => v(r, O(e));
10
- function w(r) {
1
+ var d = Object.defineProperty, g = Object.defineProperties, m = Object.getOwnPropertyDescriptors, f = Object.getOwnPropertySymbols, A = Object.prototype.hasOwnProperty, v = Object.prototype.propertyIsEnumerable, u = (e, r, n) => r in e ? d(e, r, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[r] = n, y = (e, r) => {
2
+ for (var n in r || (r = {}))
3
+ A.call(r, n) && u(e, n, r[n]);
4
+ if (f)
5
+ for (var n of f(r))
6
+ v.call(r, n) && u(e, n, r[n]);
7
+ return e;
8
+ }, p = (e, r) => g(e, m(r));
9
+ function P(e) {
11
10
  try {
12
- return JSON.parse(r), !0;
13
- } catch (e) {
11
+ return JSON.parse(e), !0;
12
+ } catch (r) {
14
13
  return !1;
15
14
  }
16
15
  }
17
- function P(r, e) {
18
- return e.reduce((t, n) => {
19
- if (t && typeof t == "object" && n in t)
20
- return t[n];
21
- }, r);
16
+ function b(e, r) {
17
+ let n = e;
18
+ const o = r.length;
19
+ for (let t = 0; t < o; t++)
20
+ if (n && typeof n == "object" && r[t] in n)
21
+ n = n[r[t]];
22
+ else
23
+ return;
24
+ return n;
22
25
  }
23
- function _(r, e, t) {
24
- if (e.length === 0)
25
- return r;
26
- const [n, ...o] = e;
27
- if (o.length === 0)
28
- return c(f({}, r), {
29
- [n]: t
26
+ function h(e, r, n) {
27
+ if (r.length === 0)
28
+ return e;
29
+ const [o, ...t] = r;
30
+ if (t.length === 0)
31
+ return p(y({}, e), {
32
+ [o]: n
30
33
  });
31
- const s = r[n];
32
- return c(f({}, r), {
33
- [n]: _(
34
- typeof s == "object" && s !== null ? s : {},
35
- o,
36
- t
34
+ const i = e[o];
35
+ return p(y({}, e), {
36
+ [o]: h(
37
+ typeof i == "object" && i !== null ? i : {},
38
+ t,
39
+ n
37
40
  )
38
41
  });
39
42
  }
40
- function A(...r) {
41
- if (r.length === 0)
42
- return {};
43
- const e = r.filter((o) => o != null).map((o) => typeof o != "object" ? {} : o);
43
+ function O(e) {
44
+ if (e === null || typeof e != "object")
45
+ return e;
46
+ if (Array.isArray(e))
47
+ return e.map((o) => O(o));
48
+ if (e instanceof Date)
49
+ return new Date(e.getTime());
50
+ if (e instanceof RegExp)
51
+ return new RegExp(e.source, e.flags);
52
+ const r = Object.getPrototypeOf(e);
53
+ if (r !== Object.prototype && r !== null)
54
+ return e;
55
+ const n = {};
56
+ for (const o in e)
57
+ Object.prototype.hasOwnProperty.call(e, o) && (n[o] = O(e[o]));
58
+ return n;
59
+ }
60
+ function w(...e) {
44
61
  if (e.length === 0)
45
62
  return {};
46
- if (e.length === 1)
47
- return e[0];
48
- if (e.every(i))
49
- return [].concat(...e);
50
- if (e.every(
51
- (o) => typeof o == "object" && o !== null && !i(o)
52
- ))
53
- return d({}, ...e, (o, s) => {
54
- if (i(o) && i(s))
55
- return o.concat(s);
56
- });
57
- if (e.every((o) => typeof o != "object" || o === null))
63
+ const r = e.filter((t) => t != null);
64
+ if (r.length === 0)
65
+ return {};
66
+ if (r.length === 1)
67
+ return r[0];
68
+ if (r.every(Array.isArray))
69
+ return [].concat(...r);
70
+ if (r.every((t) => typeof t == "object" && t !== null && !Array.isArray(t))) {
71
+ const t = {};
72
+ for (const i of r) {
73
+ const l = i;
74
+ for (const s in l)
75
+ if (Object.prototype.hasOwnProperty.call(l, s)) {
76
+ const a = l[s];
77
+ if (Object.prototype.hasOwnProperty.call(t, s)) {
78
+ const c = t[s];
79
+ typeof a == "object" && a !== null && typeof c == "object" && c !== null ? Array.isArray(a) && Array.isArray(c) ? t[s] = c.concat(a) : !Array.isArray(a) && !Array.isArray(c) ? t[s] = w(
80
+ c,
81
+ a
82
+ ) : t[s] = a : t[s] = a;
83
+ } else
84
+ t[s] = a;
85
+ }
86
+ }
87
+ return t;
88
+ }
89
+ if (r.every((t) => typeof t != "object" || t === null))
58
90
  throw new Error(
59
91
  "deepMerge: Cannot merge primitive values. All arguments must be objects or arrays."
60
92
  );
61
- const t = e.some(i), n = e.some(
62
- (o) => typeof o == "object" && o !== null && !i(o)
93
+ const n = r.some(Array.isArray), o = r.some(
94
+ (t) => typeof t == "object" && t !== null && !Array.isArray(t)
63
95
  );
64
- throw t && n ? new Error(
96
+ throw n && o ? new Error(
65
97
  "deepMerge: Cannot mix arrays and objects. All arguments must be either arrays or objects."
66
98
  ) : new Error(
67
99
  "deepMerge: Invalid arguments provided. All arguments must be objects or arrays of the same type."
68
100
  );
69
101
  }
70
- function g(r) {
71
- if (!r || typeof r != "object")
72
- return r;
73
- const e = {};
74
- for (const [t, n] of Object.entries(r))
75
- if (n && typeof n == "object" && !Array.isArray(n))
76
- if (Object.keys(n).some(
77
- (s) => s.startsWith("$")
102
+ function _(e) {
103
+ if (!e || typeof e != "object")
104
+ return e;
105
+ const r = {};
106
+ for (const [n, o] of Object.entries(e))
107
+ if (o && typeof o == "object" && !Array.isArray(o))
108
+ if (Object.keys(o).some(
109
+ (i) => i.startsWith("$")
78
110
  ))
79
- e[t] = n;
111
+ r[n] = o;
80
112
  else {
81
- const s = g(n);
82
- for (const [l, p] of Object.entries(s)) {
83
- const y = `${t}.${l}`;
84
- e[y] = p;
113
+ const i = _(o);
114
+ for (const [l, s] of Object.entries(i)) {
115
+ const a = `${n}.${l}`;
116
+ r[a] = s;
85
117
  }
86
118
  }
87
119
  else
88
- e[t] = n;
89
- return e;
120
+ r[n] = o;
121
+ return r;
90
122
  }
91
123
  export {
92
- A as deepMerge,
93
- P as getNestedValue,
94
- w as isJSON,
95
- g as normalizeMongoFilter,
96
- _ as setNestedValue
124
+ O as deepClone,
125
+ w as deepMerge,
126
+ b as getNestedValue,
127
+ P as isJSON,
128
+ _ as normalizeMongoFilter,
129
+ h as setNestedValue
97
130
  };
@@ -0,0 +1 @@
1
+ export {};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n={Date:{is:e=>e instanceof Date,serialize:e=>({__type:"Date",value:e.toISOString()}),deserialize:e=>new Date(e)},Map:{is:e=>e instanceof Map,serialize:e=>({__type:"Map",value:Array.from(e.entries())}),deserialize:e=>new Map(e)},Set:{is:e=>e instanceof Set,serialize:e=>({__type:"Set",value:Array.from(e)}),deserialize:e=>new Set(e)},RegExp:{is:e=>e instanceof RegExp,serialize:e=>({__type:"RegExp",value:{source:e.source,flags:e.flags}}),deserialize:e=>{const{source:r,flags:i}=e;return new RegExp(r,i)}},BigInt:{is:e=>typeof e=="bigint",serialize:e=>({__type:"BigInt",value:e.toString()}),deserialize:e=>BigInt(e)}},a={serialize(e){return JSON.stringify(e,(r,i)=>{for(const s of Object.keys(n)){const t=n[s];if(t.is(i))return t.serialize(i)}return i})},deserialize(e){return JSON.parse(e,(r,i)=>{if(i&&typeof i=="object"&&"__type"in i&&typeof i.__type=="string"){const s=i.__type,t=n[s];if(t)return t.deserialize(i.value)}return i})}};exports.serializer=a;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s={Date:{is:e=>e instanceof Date,serialize:e=>({__type:"Date",value:e.toISOString()}),deserialize:e=>new Date(e)},Map:{is:e=>e instanceof Map,serialize:e=>({__type:"Map",value:Array.from(e.entries())}),deserialize:e=>new Map(e)},Set:{is:e=>e instanceof Set,serialize:e=>({__type:"Set",value:Array.from(e)}),deserialize:e=>new Set(e)},RegExp:{is:e=>e instanceof RegExp,serialize:e=>({__type:"RegExp",value:{source:e.source,flags:e.flags}}),deserialize:e=>{const{source:r,flags:t}=e;return new RegExp(r,t)}},BigInt:{is:e=>typeof e=="bigint",serialize:e=>({__type:"BigInt",value:e.toString()}),deserialize:e=>BigInt(e)}},l={serialize(e){return JSON.stringify(e,function(r,t){const i=this[r];if(i instanceof Date)return s.Date.serialize(i);for(const o of Object.keys(s)){const a=s[o];if(a.is(t))return a.serialize(t)}return t})},deserialize(e){return JSON.parse(e,(r,t)=>{if(t&&typeof t=="object"&&"__type"in t&&typeof t.__type=="string"){const n=t.__type,i=s[n];if(i)return i.deserialize(t.value)}return t})}};exports.serializer=l;
@@ -21,8 +21,8 @@ const n = {
21
21
  value: { source: e.source, flags: e.flags }
22
22
  }),
23
23
  deserialize: (e) => {
24
- const { source: r, flags: i } = e;
25
- return new RegExp(r, i);
24
+ const { source: r, flags: t } = e;
25
+ return new RegExp(r, t);
26
26
  }
27
27
  },
28
28
  BigInt: {
@@ -30,7 +30,7 @@ const n = {
30
30
  serialize: (e) => ({ __type: "BigInt", value: e.toString() }),
31
31
  deserialize: (e) => BigInt(e)
32
32
  }
33
- }, a = {
33
+ }, p = {
34
34
  /**
35
35
  * Serializes a value to a JSON string.
36
36
  * If the value is of a known type (Date, Map, Set, RegExp, BigInt),
@@ -41,13 +41,16 @@ const n = {
41
41
  * @returns The serialized JSON string that can be safely stored or transmitted.
42
42
  */
43
43
  serialize(e) {
44
- return JSON.stringify(e, (r, i) => {
45
- for (const s of Object.keys(n)) {
46
- const t = n[s];
47
- if (t.is(i))
48
- return t.serialize(i);
44
+ return JSON.stringify(e, function(r, t) {
45
+ const i = this[r];
46
+ if (i instanceof Date)
47
+ return n.Date.serialize(i);
48
+ for (const o of Object.keys(n)) {
49
+ const a = n[o];
50
+ if (a.is(t))
51
+ return a.serialize(t);
49
52
  }
50
- return i;
53
+ return t;
51
54
  });
52
55
  },
53
56
  /**
@@ -60,16 +63,16 @@ const n = {
60
63
  * @returns The deserialized value with all special types reconstructed.
61
64
  */
62
65
  deserialize(e) {
63
- return JSON.parse(e, (r, i) => {
64
- if (i && typeof i == "object" && "__type" in i && typeof i.__type == "string") {
65
- const s = i.__type, t = n[s];
66
- if (t)
67
- return t.deserialize(i.value);
66
+ return JSON.parse(e, (r, t) => {
67
+ if (t && typeof t == "object" && "__type" in t && typeof t.__type == "string") {
68
+ const s = t.__type, i = n[s];
69
+ if (i)
70
+ return i.deserialize(t.value);
68
71
  }
69
- return i;
72
+ return t;
70
73
  });
71
74
  }
72
75
  };
73
76
  export {
74
- a as serializer
77
+ p as serializer
75
78
  };
@@ -0,0 +1 @@
1
+ export {};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("crypto-js"),c=require("lodash-es"),u=require("slugify");var f=Object.defineProperty,s=Object.getOwnPropertySymbols,d=Object.prototype.hasOwnProperty,g=Object.prototype.propertyIsEnumerable,i=(r,e,t)=>e in r?f(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,m=(r,e)=>{for(var t in e||(e={}))d.call(e,t)&&i(r,t,e[t]);if(s)for(var t of s(e))g.call(e,t)&&i(r,t,e[t]);return r};const O=u.default||u;function y(r,e){const t=n=>{var o,l;return O(n!=null?n:"",m({lower:(o=e==null?void 0:e.lower)!=null?o:!0,locale:(l=e==null?void 0:e.locale)!=null?l:"vi"},e))};if(c.isObject(r)){const n={};for(const[o,l]of Object.entries(r))n[o]=t(l);return n}return t(r)}function _(r,e=4){return a.SHA256(r).toString(a.enc.Hex).slice(0,e)}function h(r=8){const e="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_+[]{}|;:,.<>?";return Array.from({length:r},()=>{const t=Math.floor(Math.random()*e.length);return e.charAt(t)}).join("")}function w(r="",e=!1){const t=r.split(/[?#]/)[0]||"",n=t.substring(t.lastIndexOf("/")+1);if(e)return n;const o=n.lastIndexOf(".");return o>0?n.slice(0,o):n}function p(r,e,t){const n=r.indexOf(e);if(n===-1)return"";const o=n+e.length,l=r.indexOf(t,o);return l===-1?"":r.slice(o,l)}exports.generateRandomPassword=h;exports.generateShortId=_;exports.generateSlug=y;exports.getFileName=w;exports.substringBetween=p;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("../common/common.util.cjs");function a(t,r){let e=t.trim();return e=l.removeAccent(e),(r==null?void 0:r.lower)!==!1&&(e=e.toLowerCase()),e=e.replace(/[^a-z0-9\s-]/gi," "),e=e.replace(/[\s-]+/g,"-"),e=e.replace(/^-+|-+$/g,""),e}function c(t,r){const e=n=>a(n!=null?n:"",r);if(typeof t=="object"&&t!==null){const n={};for(const[o,s]of Object.entries(t))n[o]=e(s);return n}return e(t)}function i(t,r=4){let e=2166136261;for(let o=0;o<t.length;o++)e^=t.charCodeAt(o),e=Math.imul(e,16777619);const n=(e>>>0).toString(16).padStart(8,"0");return r>8?t.replace(/-/g,"").slice(0,r):n.slice(0,r)}function u(t=8){const r="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_+[]{}|;:,.<>?";return Array.from({length:t},()=>{const e=Math.floor(Math.random()*r.length);return r.charAt(e)}).join("")}function f(t="",r=!1){const e=t.split(/[?#]/)[0]||"",n=e.substring(e.lastIndexOf("/")+1);if(r)return n;const o=n.lastIndexOf(".");return o>0?n.slice(0,o):n}function g(t,r,e){const n=t.indexOf(r);if(n===-1)return"";const o=n+r.length,s=t.indexOf(e,o);return s===-1?"":t.slice(o,s)}exports.generateRandomPassword=u;exports.generateShortId=i;exports.generateSlug=c;exports.getFileName=f;exports.substringBetween=g;
@@ -12,12 +12,13 @@ import { I_SlugifyOptions } from './string.type.js';
12
12
  export declare function generateSlug<T = string>(input: T, options?: I_SlugifyOptions): T;
13
13
  /**
14
14
  * Generates a short ID from a UUID.
15
- * The ID is a substring of the SHA256 hash of the UUID, providing a shorter
16
- * but still unique identifier based on the original UUID.
15
+ * The ID is a substring of the UUID, providing a shorter identifier.
16
+ * Note: This is NOT cryptographically secure and collisions are possible,
17
+ * but suitable for display purposes where uniqueness is handled elsewhere.
17
18
  *
18
19
  * @param uuid - The UUID to be converted to a short ID.
19
20
  * @param length - The desired length of the short ID (default: 4 characters).
20
- * @returns A short ID string of the specified length derived from the UUID's SHA256 hash.
21
+ * @returns A short ID string of the specified length derived from the UUID.
21
22
  */
22
23
  export declare function generateShortId(uuid: string, length?: number): string;
23
24
  /**
@@ -1,59 +1,50 @@
1
- import a from "crypto-js";
2
- import { isObject as s } from "lodash-es";
3
- import u from "slugify";
4
- var c = Object.defineProperty, f = Object.getOwnPropertySymbols, d = Object.prototype.hasOwnProperty, m = Object.prototype.propertyIsEnumerable, i = (e, r, t) => r in e ? c(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t, g = (e, r) => {
5
- for (var t in r || (r = {}))
6
- d.call(r, t) && i(e, t, r[t]);
7
- if (f)
8
- for (var t of f(r))
9
- m.call(r, t) && i(e, t, r[t]);
10
- return e;
11
- };
12
- const p = u.default || u;
13
- function h(e, r) {
14
- const t = (n) => {
15
- var o, l;
16
- return p(n != null ? n : "", g({
17
- lower: (o = r == null ? void 0 : r.lower) != null ? o : !0,
18
- locale: (l = r == null ? void 0 : r.locale) != null ? l : "vi"
19
- }, r));
20
- };
21
- if (s(e)) {
1
+ import { removeAccent as c } from "../common/common.util.js";
2
+ function l(t, r) {
3
+ let e = t.trim();
4
+ return e = c(e), (r == null ? void 0 : r.lower) !== !1 && (e = e.toLowerCase()), e = e.replace(/[^a-z0-9\s-]/gi, " "), e = e.replace(/[\s-]+/g, "-"), e = e.replace(/^-+|-+$/g, ""), e;
5
+ }
6
+ function a(t, r) {
7
+ const e = (n) => l(n != null ? n : "", r);
8
+ if (typeof t == "object" && t !== null) {
22
9
  const n = {};
23
- for (const [o, l] of Object.entries(e))
24
- n[o] = t(l);
10
+ for (const [o, s] of Object.entries(t))
11
+ n[o] = e(s);
25
12
  return n;
26
13
  }
27
- return t(e);
14
+ return e(t);
28
15
  }
29
- function v(e, r = 4) {
30
- return a.SHA256(e).toString(a.enc.Hex).slice(0, r);
16
+ function f(t, r = 4) {
17
+ let e = 2166136261;
18
+ for (let o = 0; o < t.length; o++)
19
+ e ^= t.charCodeAt(o), e = Math.imul(e, 16777619);
20
+ const n = (e >>> 0).toString(16).padStart(8, "0");
21
+ return r > 8 ? t.replace(/-/g, "").slice(0, r) : n.slice(0, r);
31
22
  }
32
- function w(e = 8) {
23
+ function u(t = 8) {
33
24
  const r = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_+[]{}|;:,.<>?";
34
- return Array.from({ length: e }, () => {
35
- const t = Math.floor(Math.random() * r.length);
36
- return r.charAt(t);
25
+ return Array.from({ length: t }, () => {
26
+ const e = Math.floor(Math.random() * r.length);
27
+ return r.charAt(e);
37
28
  }).join("");
38
29
  }
39
- function x(e = "", r = !1) {
40
- const t = e.split(/[?#]/)[0] || "", n = t.substring(t.lastIndexOf("/") + 1);
30
+ function g(t = "", r = !1) {
31
+ const e = t.split(/[?#]/)[0] || "", n = e.substring(e.lastIndexOf("/") + 1);
41
32
  if (r)
42
33
  return n;
43
34
  const o = n.lastIndexOf(".");
44
35
  return o > 0 ? n.slice(0, o) : n;
45
36
  }
46
- function P(e, r, t) {
47
- const n = e.indexOf(r);
37
+ function d(t, r, e) {
38
+ const n = t.indexOf(r);
48
39
  if (n === -1)
49
40
  return "";
50
- const o = n + r.length, l = e.indexOf(t, o);
51
- return l === -1 ? "" : e.slice(o, l);
41
+ const o = n + r.length, s = t.indexOf(e, o);
42
+ return s === -1 ? "" : t.slice(o, s);
52
43
  }
53
44
  export {
54
- w as generateRandomPassword,
55
- v as generateShortId,
56
- h as generateSlug,
57
- x as getFileName,
58
- P as substringBetween
45
+ u as generateRandomPassword,
46
+ f as generateShortId,
47
+ a as generateSlug,
48
+ g as getFileName,
49
+ d as substringBetween
59
50
  };
@@ -0,0 +1 @@
1
+ export {};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i={isEmpty(t){return t==null?!0:typeof t=="string"?t.trim().length===0:Array.isArray(t)?t.length===0:typeof t=="object"?t instanceof Date?!1:t instanceof Map||t instanceof Set?t.size===0:t instanceof WeakMap||t instanceof WeakSet?!0:ArrayBuffer.isView(t)?t.byteLength===0:Object.keys(t).length===0:!1},isValidIP(t){const r=t.split(".");return r.length===4&&r.every(e=>/^\d+$/.test(e)&&Number(e)>=0&&Number(e)<=255)?!0:/^(([a-f\d]{1,4}:){7}[a-f\d]{1,4}|((?:[a-f\d]{1,4}:){1,7}:)|((?:[a-f\d]{1,4}:){1,6}:[a-f\d]{1,4})|::)$/i.test(t)}};exports.validate=i;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r={isEmpty(d){return d==null?!0:typeof d=="string"?d.trim().length===0:Array.isArray(d)?d.length===0:typeof d=="object"?d instanceof Date?!1:d instanceof Map||d instanceof Set?d.size===0:d instanceof WeakMap||d instanceof WeakSet?!0:ArrayBuffer.isView(d)?d.byteLength===0:Object.keys(d).length===0:!1},isValidIP(d){const e=d.split(".");return e.length===4&&e.every(t=>/^\d+$/.test(t)&&Number(t)>=0&&Number(t)<=255)?!0:/^(?:(?:[a-fA-F\d]{1,4}:){7}(?:[a-fA-F\d]{1,4}|:)|(?:[a-fA-F\d]{1,4}:){6}(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|:[a-fA-F\d]{1,4}|:)|(?:[a-fA-F\d]{1,4}:){5}(?::(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(?::[a-fA-F\d]{1,4}){1,2}|:)|(?:[a-fA-F\d]{1,4}:){4}(?:(?::[a-fA-F\d]{1,4}){0,1}:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(?::[a-fA-F\d]{1,4}){1,3}|:)|(?:[a-fA-F\d]{1,4}:){3}(?:(?::[a-fA-F\d]{1,4}){0,2}:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(?::[a-fA-F\d]{1,4}){1,4}|:)|(?:[a-fA-F\d]{1,4}:){2}(?:(?::[a-fA-F\d]{1,4}){0,3}:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(?::[a-fA-F\d]{1,4}){1,5}|:)|(?:[a-fA-F\d]{1,4}:){1}(?:(?::[a-fA-F\d]{1,4}){0,4}:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(?::[a-fA-F\d]{1,4}){1,6}|:)|(?::(?:(?::[a-fA-F\d]{1,4}){0,5}:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\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 i = {
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(t) {
19
- return t == null ? !0 : typeof t == "string" ? t.trim().length === 0 : Array.isArray(t) ? t.length === 0 : typeof t == "object" ? t instanceof Date ? !1 : t instanceof Map || t instanceof Set ? t.size === 0 : t instanceof WeakMap || t instanceof WeakSet ? !0 : ArrayBuffer.isView(t) ? t.byteLength === 0 : Object.keys(t).length === 0 : !1;
18
+ isEmpty(d) {
19
+ return d == null ? !0 : typeof d == "string" ? d.trim().length === 0 : Array.isArray(d) ? d.length === 0 : typeof d == "object" ? d instanceof Date ? !1 : d instanceof Map || d instanceof Set ? d.size === 0 : d instanceof WeakMap || d instanceof WeakSet ? !0 : ArrayBuffer.isView(d) ? d.byteLength === 0 : Object.keys(d).length === 0 : !1;
20
20
  },
21
21
  /**
22
22
  * Checks if a string is a valid IP address (IPv4 or IPv6).
@@ -27,13 +27,13 @@ const i = {
27
27
  * @param ip - The IP address string to validate.
28
28
  * @returns True if the IP is valid IPv4 or IPv6, false otherwise.
29
29
  */
30
- isValidIP(t) {
31
- const e = t.split(".");
32
- return e.length === 4 && e.every(
33
- (r) => /^\d+$/.test(r) && Number(r) >= 0 && Number(r) <= 255
34
- ) ? !0 : /^(([a-f\d]{1,4}:){7}[a-f\d]{1,4}|((?:[a-f\d]{1,4}:){1,7}:)|((?:[a-f\d]{1,4}:){1,6}:[a-f\d]{1,4})|::)$/i.test(t);
30
+ isValidIP(d) {
31
+ const f = d.split(".");
32
+ return f.length === 4 && f.every(
33
+ (t) => /^\d+$/.test(t) && Number(t) >= 0 && Number(t) <= 255
34
+ ) ? !0 : /^(?:(?:[a-fA-F\d]{1,4}:){7}(?:[a-fA-F\d]{1,4}|:)|(?:[a-fA-F\d]{1,4}:){6}(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|:[a-fA-F\d]{1,4}|:)|(?:[a-fA-F\d]{1,4}:){5}(?::(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(?::[a-fA-F\d]{1,4}){1,2}|:)|(?:[a-fA-F\d]{1,4}:){4}(?:(?::[a-fA-F\d]{1,4}){0,1}:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(?::[a-fA-F\d]{1,4}){1,3}|:)|(?:[a-fA-F\d]{1,4}:){3}(?:(?::[a-fA-F\d]{1,4}){0,2}:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(?::[a-fA-F\d]{1,4}){1,4}|:)|(?:[a-fA-F\d]{1,4}:){2}(?:(?::[a-fA-F\d]{1,4}){0,3}:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(?::[a-fA-F\d]{1,4}){1,5}|:)|(?:[a-fA-F\d]{1,4}:){1}(?:(?::[a-fA-F\d]{1,4}){0,4}:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(?::[a-fA-F\d]{1,4}){1,6}|:)|(?::(?:(?::[a-fA-F\d]{1,4}){0,5}:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(?::[a-fA-F\d]{1,4}){1,7}|:)))(?:%[0-9a-zA-Z]{1,})?$/.test(d);
35
35
  }
36
36
  };
37
37
  export {
38
- i as validate
38
+ e as validate
39
39
  };