@cyberskill/shared 1.210.0 → 1.211.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 (133) hide show
  1. package/dist/config/commitlint/index.cjs +1 -0
  2. package/dist/config/config.type.cjs +1 -0
  3. package/dist/config/config.util.cjs +1 -0
  4. package/dist/config/config.util.js +35 -26
  5. package/dist/config/env/env.constant.cjs +1 -0
  6. package/dist/config/env/env.util.cjs +1 -0
  7. package/dist/config/env/index.cjs +1 -0
  8. package/dist/config/eslint/index.cjs +1 -0
  9. package/dist/config/eslint/index.js +12 -4
  10. package/dist/config/graphql-codegen/graphql-codegen.util.cjs +1 -0
  11. package/dist/config/graphql-codegen/graphql-codegen.util.js +33 -28
  12. package/dist/config/graphql-codegen/index.cjs +1 -0
  13. package/dist/config/index.cjs +1 -0
  14. package/dist/config/lint-staged/index.cjs +1 -0
  15. package/dist/config/vitest/index.cjs +1 -0
  16. package/dist/config/vitest/vitest.e2e.cjs +1 -0
  17. package/dist/config/vitest/vitest.e2e.js +16 -9
  18. package/dist/config/vitest/vitest.unit.cjs +1 -0
  19. package/dist/config/vitest/vitest.unit.js +18 -11
  20. package/dist/constant/common.cjs +1 -0
  21. package/dist/constant/common.js +1 -1
  22. package/dist/constant/index.cjs +1 -0
  23. package/dist/constant/response-status.cjs +1 -0
  24. package/dist/node/apollo-server/apollo-server.util.cjs +1 -0
  25. package/dist/node/apollo-server/apollo-server.util.js +48 -21
  26. package/dist/node/apollo-server/index.cjs +1 -0
  27. package/dist/node/cli/index.cjs +6 -0
  28. package/dist/node/cli/index.js +140 -90
  29. package/dist/node/command/command.type.cjs +1 -0
  30. package/dist/node/command/command.util.cjs +2 -0
  31. package/dist/node/command/command.util.js +148 -117
  32. package/dist/node/command/index.cjs +1 -0
  33. package/dist/node/express/express.util.cjs +1 -0
  34. package/dist/node/express/express.util.js +70 -37
  35. package/dist/node/express/index.cjs +1 -0
  36. package/dist/node/fs/fs.util.cjs +1 -0
  37. package/dist/node/fs/fs.util.js +55 -40
  38. package/dist/node/fs/index.cjs +1 -0
  39. package/dist/node/log/index.cjs +1 -0
  40. package/dist/node/log/log.type.cjs +1 -0
  41. package/dist/node/log/log.util.cjs +1 -0
  42. package/dist/node/log/log.util.js +31 -30
  43. package/dist/node/mongo/index.cjs +1 -0
  44. package/dist/node/mongo/mongo.constant.cjs +1 -0
  45. package/dist/node/mongo/mongo.type.cjs +1 -0
  46. package/dist/node/mongo/mongo.util.cjs +5 -0
  47. package/dist/node/mongo/mongo.util.js +433 -365
  48. package/dist/node/package/index.cjs +1 -0
  49. package/dist/node/package/package.type.cjs +1 -0
  50. package/dist/node/package/package.util.cjs +1 -0
  51. package/dist/node/package/package.util.js +224 -195
  52. package/dist/node/path/index.cjs +1 -0
  53. package/dist/node/path/path.constant.cjs +1 -0
  54. package/dist/node/path/path.constant.js +205 -183
  55. package/dist/node/path/path.util.cjs +1 -0
  56. package/dist/node/storage/index.cjs +1 -0
  57. package/dist/node/storage/storage.util.cjs +1 -0
  58. package/dist/node/storage/storage.util.js +70 -40
  59. package/dist/node/upload/index.cjs +1 -0
  60. package/dist/node/upload/upload.type.cjs +1 -0
  61. package/dist/node/upload/upload.util.cjs +1 -0
  62. package/dist/node/upload/upload.util.js +119 -91
  63. package/dist/node/ws/index.cjs +1 -0
  64. package/dist/node/ws/ts.util.cjs +1 -0
  65. package/dist/node_modules/.pnpm/vitest@3.2.4_@types_debug@4.1.12_@types_node@24.0.13_@vitest_browser@3.2.4_jiti@2.4.2_j_cac3da623d5688a51c0b1a2270e144db/node_modules/vitest/dist/config.cjs +1 -0
  66. package/dist/react/apollo-client/apollo-client.component.cjs +1 -0
  67. package/dist/react/apollo-client/apollo-client.constant.cjs +1 -0
  68. package/dist/react/apollo-client/apollo-client.context.cjs +1 -0
  69. package/dist/react/apollo-client/apollo-client.util.cjs +1 -0
  70. package/dist/react/apollo-client/apollo-client.util.js +74 -64
  71. package/dist/react/apollo-client/index.cjs +1 -0
  72. package/dist/react/apollo-client-nextjs/apollo-client-nextjs.component.cjs +1 -0
  73. package/dist/react/apollo-client-nextjs/apollo-client-nextjs.rsc.cjs +1 -0
  74. package/dist/react/apollo-client-nextjs/apollo-client-nextjs.util.cjs +1 -0
  75. package/dist/react/apollo-client-nextjs/apollo-client-nextjs.util.js +18 -11
  76. package/dist/react/apollo-client-nextjs/index.cjs +1 -0
  77. package/dist/react/apollo-error/apollo-error.component.cjs +1 -0
  78. package/dist/react/apollo-error/apollo-error.component.js +6 -6
  79. package/dist/react/apollo-error/apollo-error.context.cjs +1 -0
  80. package/dist/react/apollo-error/apollo-error.hook.cjs +1 -0
  81. package/dist/react/apollo-error/apollo-error.module.scss.cjs +1 -0
  82. package/dist/react/apollo-error/apollo-error.provider.cjs +1 -0
  83. package/dist/react/apollo-error/apollo-error.util.cjs +1 -0
  84. package/dist/react/apollo-error/apollo-error.util.js +1 -1
  85. package/dist/react/apollo-error/index.cjs +1 -0
  86. package/dist/react/i18next/i18next.hook.cjs +1 -0
  87. package/dist/react/i18next/i18next.util.cjs +1 -0
  88. package/dist/react/i18next/index.cjs +1 -0
  89. package/dist/react/loading/index.cjs +1 -0
  90. package/dist/react/loading/loading.component.cjs +6 -0
  91. package/dist/react/loading/loading.component.js +36 -19
  92. package/dist/react/loading/loading.context.cjs +1 -0
  93. package/dist/react/loading/loading.hook.cjs +1 -0
  94. package/dist/react/loading/loading.module.scss.cjs +1 -0
  95. package/dist/react/loading/loading.provider.cjs +1 -0
  96. package/dist/react/log/index.cjs +1 -0
  97. package/dist/react/log/log.util.cjs +1 -0
  98. package/dist/react/log/log.util.js +4 -4
  99. package/dist/react/next-intl/index.cjs +1 -0
  100. package/dist/react/next-intl/next-intl.constant.cjs +1 -0
  101. package/dist/react/next-intl/next-intl.context.cjs +1 -0
  102. package/dist/react/next-intl/next-intl.hoc.cjs +1 -0
  103. package/dist/react/next-intl/next-intl.hoc.js +23 -14
  104. package/dist/react/next-intl/next-intl.hook.cjs +1 -0
  105. package/dist/react/next-intl/next-intl.provider.cjs +1 -0
  106. package/dist/react/next-intl/next-intl.provider.js +7 -7
  107. package/dist/react/storage/index.cjs +1 -0
  108. package/dist/react/storage/storage.hook.cjs +1 -0
  109. package/dist/react/storage/storage.hook.js +57 -41
  110. package/dist/react/storage/storage.util.cjs +1 -0
  111. package/dist/react/storage/storage.util.js +50 -25
  112. package/dist/react/toast/index.cjs +1 -0
  113. package/dist/react/userback/index.cjs +1 -0
  114. package/dist/react/userback/userback.component.cjs +1 -0
  115. package/dist/react/userback/userback.component.js +42 -18
  116. package/dist/style.css +1 -1
  117. package/dist/typescript/common.type.cjs +1 -0
  118. package/dist/typescript/index.cjs +1 -0
  119. package/dist/util/common/common.util.cjs +1 -0
  120. package/dist/util/common/common.util.js +37 -29
  121. package/dist/util/common/index.cjs +1 -0
  122. package/dist/util/index.cjs +1 -0
  123. package/dist/util/object/index.cjs +1 -0
  124. package/dist/util/object/object.util.cjs +1 -0
  125. package/dist/util/object/object.util.js +55 -49
  126. package/dist/util/serializer/index.cjs +1 -0
  127. package/dist/util/serializer/serializer.util.cjs +1 -0
  128. package/dist/util/string/index.cjs +1 -0
  129. package/dist/util/string/string.util.cjs +1 -0
  130. package/dist/util/string/string.util.js +46 -36
  131. package/dist/util/validate/index.cjs +1 -0
  132. package/dist/util/validate/validate.util.cjs +1 -0
  133. package/package.json +69 -35
@@ -1,6 +1,14 @@
1
- import a from "unorm";
2
- import { E_Environment as o } from "../../typescript/common.type.js";
3
- const E = {
1
+ import u from "unorm";
2
+ 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) => {
4
+ 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]);
9
+ return e;
10
+ };
11
+ const s = {
4
12
  a: ["à", "á", "ạ", "ả", "ã", "â", "ầ", "ấ", "ậ", "ẩ", "ẫ", "ă", "ằ", "ắ", "ặ", "ẳ", "ẵ"],
5
13
  e: ["è", "é", "ẹ", "ẻ", "ẽ", "ê", "ề", "ế", "ệ", "ể", "ễ"],
6
14
  i: ["ì", "í", "ị", "ỉ", "ĩ"],
@@ -8,41 +16,41 @@ const E = {
8
16
  u: ["ù", "ú", "ụ", "ủ", "ũ", "ư", "ừ", "ứ", "ự", "ử", "ữ"],
9
17
  y: ["ỳ", "ý", "ỵ", "ỷ", "ỹ"],
10
18
  d: ["đ"]
11
- }, p = Object.entries(E).reduce(
12
- (n, [r, e]) => (n[r.toUpperCase()] = e.map((t) => t.toUpperCase()), n),
19
+ }, _ = Object.entries(s).reduce(
20
+ (e, [r, n]) => (e[r.toUpperCase()] = n.map((o) => o.toUpperCase()), e),
13
21
  {}
14
22
  );
15
- function O(n) {
16
- n = a.nfkc(n);
17
- const r = { ...E, ...p };
18
- for (const [e, t] of Object.entries(r)) {
19
- const c = `[${e}${t.join("")}]`, i = `(${[e, ...t].join("|")})`;
20
- n = n.replace(new RegExp(c, "g"), i);
23
+ function P(e) {
24
+ e = u.nfkc(e);
25
+ const r = E(E({}, s), _);
26
+ for (const [n, o] of Object.entries(r)) {
27
+ const a = `[${n}${o.join("")}]`, c = `(${[n, ...o].join("|")})`;
28
+ e = e.replace(new RegExp(a, "g"), c);
21
29
  }
22
- return n;
30
+ return e;
23
31
  }
24
- function D(n) {
25
- return n.normalize("NFD").replace(new RegExp("\\p{Diacritic}", "gu"), "");
32
+ function l(e) {
33
+ return e.normalize("NFD").replace(new RegExp("\\p{Diacritic}", "gu"), "");
26
34
  }
27
- function N(n, r) {
35
+ function v(e, r) {
28
36
  if (!r)
29
- return Array.from(new Set(n));
30
- const e = /* @__PURE__ */ new Set(), t = [];
31
- for (const c of n) {
32
- const i = r(c);
33
- e.has(i) || (e.add(i), t.push(c));
37
+ return Array.from(new Set(e));
38
+ const n = /* @__PURE__ */ new Set(), o = [];
39
+ for (const a of e) {
40
+ const c = r(a);
41
+ n.has(c) || (n.add(c), o.push(a));
34
42
  }
35
- return t;
43
+ return o;
36
44
  }
37
- function m(n) {
38
- const { NODE_ENV: r = o.DEVELOPMENT, NODE_ENV_MODE: e = o.DEVELOPMENT } = n, t = r === o.DEVELOPMENT && e === o.DEVELOPMENT, c = r === o.PRODUCTION && e === o.STAGING, i = r === o.PRODUCTION && e === o.PRODUCTION;
39
- if (r === o.PRODUCTION && e === o.DEVELOPMENT)
45
+ function d(e) {
46
+ 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
+ if (r === t.PRODUCTION && n === t.DEVELOPMENT)
40
48
  throw new Error("NODE_ENV_MODE must be set to staging or production in production environment");
41
- return { IS_DEV: t, IS_STAG: c, IS_PROD: i };
49
+ return { IS_DEV: o, IS_STAG: a, IS_PROD: c };
42
50
  }
43
51
  export {
44
- m as mapEnvironment,
45
- O as regexSearchMapper,
46
- D as removeAccent,
47
- N as uniqueArray
52
+ d as mapEnvironment,
53
+ P as regexSearchMapper,
54
+ l as removeAccent,
55
+ v as uniqueArray
48
56
  };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./common.util.cjs");exports.mapEnvironment=e.mapEnvironment;exports.regexSearchMapper=e.regexSearchMapper;exports.removeAccent=e.removeAccent;exports.uniqueArray=e.uniqueArray;
@@ -0,0 +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.deepClone=e.deepClone;exports.deepMerge=e.deepMerge;exports.getNestedValue=e.getNestedValue;exports.isJson=e.isJson;exports.isObject=e.isObject;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;
@@ -0,0 +1 @@
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.isObject=e.isObject;exports.setNestedValue=e.setNestedValue;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var y=Object.defineProperty,O=Object.defineProperties,_=Object.getOwnPropertyDescriptors,i=Object.getOwnPropertySymbols,g=Object.prototype.hasOwnProperty,P=Object.prototype.propertyIsEnumerable,a=(e,r,t)=>r in e?y(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,c=(e,r)=>{for(var t in r||(r={}))g.call(r,t)&&a(e,t,r[t]);if(i)for(var t of i(r))P.call(r,t)&&a(e,t,r[t]);return e},f=(e,r)=>O(e,_(r));function b(e){try{return JSON.parse(e),!0}catch(r){return!1}}function u(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function p(...e){const r={};for(const t of e.flat())for(const[n,o]of Object.entries(t)){const s=r[n];if(Array.isArray(o)){const d=Array.isArray(s)?s:[];r[n]=[...new Set([...d,...o])];continue}if(u(o)){r[n]=p(u(s)?s:{},o);continue}r[n]=o}return r}function v(e){return JSON.parse(JSON.stringify(e))}function j(e,r){return r.reduce((t,n)=>{if(t&&typeof t=="object"&&n in t)return t[n]},e)}function l(e,r,t){if(r.length===0)return e;const[n,...o]=r;if(o.length===0)return f(c({},e),{[n]:t});const s=e[n];return f(c({},e),{[n]:l(typeof s=="object"&&s!==null?s:{},o,t)})}exports.deepClone=v;exports.deepMerge=p;exports.getNestedValue=j;exports.isJson=b;exports.isObject=u;exports.setNestedValue=l;
@@ -1,67 +1,73 @@
1
- function a(e) {
1
+ var l = Object.defineProperty, y = Object.defineProperties, _ = Object.getOwnPropertyDescriptors, u = Object.getOwnPropertySymbols, O = Object.prototype.hasOwnProperty, d = Object.prototype.propertyIsEnumerable, i = (r, e, t) => e in r ? l(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, f = (r, e) => {
2
+ for (var t in e || (e = {}))
3
+ O.call(e, t) && i(r, t, e[t]);
4
+ if (u)
5
+ for (var t of u(e))
6
+ d.call(e, t) && i(r, t, e[t]);
7
+ return r;
8
+ }, a = (r, e) => y(r, _(e));
9
+ function v(r) {
2
10
  try {
3
- return JSON.parse(e), !0;
4
- } catch {
11
+ return JSON.parse(r), !0;
12
+ } catch (e) {
5
13
  return !1;
6
14
  }
7
15
  }
8
- function s(e) {
9
- return typeof e == "object" && e !== null && !Array.isArray(e);
16
+ function c(r) {
17
+ return typeof r == "object" && r !== null && !Array.isArray(r);
10
18
  }
11
- function f(...e) {
12
- const t = {};
13
- for (const n of e.flat())
14
- for (const [r, u] of Object.entries(n)) {
15
- const o = t[r];
16
- if (Array.isArray(u)) {
17
- const i = Array.isArray(o) ? o : [];
18
- t[r] = [.../* @__PURE__ */ new Set([...i, ...u])];
19
+ function P(...r) {
20
+ const e = {};
21
+ for (const t of r.flat())
22
+ for (const [n, o] of Object.entries(t)) {
23
+ const s = e[n];
24
+ if (Array.isArray(o)) {
25
+ const p = Array.isArray(s) ? s : [];
26
+ e[n] = [.../* @__PURE__ */ new Set([...p, ...o])];
19
27
  continue;
20
28
  }
21
- if (s(u)) {
22
- t[r] = f(
23
- s(o) ? o : {},
24
- u
29
+ if (c(o)) {
30
+ e[n] = P(
31
+ c(s) ? s : {},
32
+ o
25
33
  );
26
34
  continue;
27
35
  }
28
- t[r] = u;
36
+ e[n] = o;
29
37
  }
30
- return t;
38
+ return e;
31
39
  }
32
- function l(e) {
33
- return JSON.parse(JSON.stringify(e));
40
+ function w(r) {
41
+ return JSON.parse(JSON.stringify(r));
34
42
  }
35
- function y(e, t) {
36
- return t.reduce((n, r) => {
37
- if (n && typeof n == "object" && r in n)
38
- return n[r];
39
- }, e);
43
+ function b(r, e) {
44
+ return e.reduce((t, n) => {
45
+ if (t && typeof t == "object" && n in t)
46
+ return t[n];
47
+ }, r);
40
48
  }
41
- function c(e, t, n) {
42
- if (t.length === 0)
43
- return e;
44
- const [r, ...u] = t;
45
- if (u.length === 0)
46
- return {
47
- ...e,
48
- [r]: n
49
- };
50
- const o = e[r];
51
- return {
52
- ...e,
53
- [r]: c(
54
- typeof o == "object" && o !== null ? o : {},
55
- u,
56
- n
49
+ function g(r, e, t) {
50
+ if (e.length === 0)
51
+ return r;
52
+ const [n, ...o] = e;
53
+ if (o.length === 0)
54
+ return a(f({}, r), {
55
+ [n]: t
56
+ });
57
+ const s = r[n];
58
+ return a(f({}, r), {
59
+ [n]: g(
60
+ typeof s == "object" && s !== null ? s : {},
61
+ o,
62
+ t
57
63
  )
58
- };
64
+ });
59
65
  }
60
66
  export {
61
- l as deepClone,
62
- f as deepMerge,
63
- y as getNestedValue,
64
- a as isJson,
65
- s as isObject,
66
- c as setNestedValue
67
+ w as deepClone,
68
+ P as deepMerge,
69
+ b as getNestedValue,
70
+ v as isJson,
71
+ c as isObject,
72
+ g as setNestedValue
67
73
  };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./serializer.util.cjs");exports.serializer=e.serializer;
@@ -0,0 +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;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./string.util.cjs");exports.generateRandomPassword=e.generateRandomPassword;exports.generateShortId=e.generateShortId;exports.generateSlug=e.generateSlug;exports.getFileName=e.getFileName;exports.substringBetween=e.substringBetween;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("crypto-js"),u=require("slugify"),c=require("../object/object.util.cjs");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,O=(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 m=u.default||u;function _(r,e){const t=n=>{var o,l;return m(n!=null?n:"",O({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 w(r,e=4){return a.SHA256(r).toString(a.enc.Hex).slice(0,e)}function y(r=8){const e="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_+[]{}|;:,.<>?";let t="";for(let n=0;n<r;n++){const o=Math.floor(Math.random()*e.length);t+=e.charAt(o)}return t}function p(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 h(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=y;exports.generateShortId=w;exports.generateSlug=_;exports.getFileName=p;exports.substringBetween=h;
@@ -1,51 +1,61 @@
1
- import i from "crypto-js";
2
- import c from "slugify";
3
- import { isObject as f } from "../object/object.util.js";
4
- const l = c.default || c;
5
- function g(e, r) {
6
- const n = (t) => l(t ?? "", {
7
- lower: r?.lower ?? !0,
8
- locale: r?.locale ?? "vi",
9
- ...r
10
- });
11
- if (f(e)) {
12
- const t = {};
13
- for (const [o, s] of Object.entries(e))
14
- t[o] = n(s);
15
- return t;
1
+ import a from "crypto-js";
2
+ import s from "slugify";
3
+ import { isObject as u } from "../object/object.util.js";
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 = s.default || s;
13
+ function y(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 (u(e)) {
22
+ const n = {};
23
+ for (const [o, l] of Object.entries(e))
24
+ n[o] = t(l);
25
+ return n;
16
26
  }
17
- return n(e);
27
+ return t(e);
18
28
  }
19
- function m(e, r = 4) {
20
- return i.SHA256(e).toString(i.enc.Hex).slice(0, r);
29
+ function h(e, r = 4) {
30
+ return a.SHA256(e).toString(a.enc.Hex).slice(0, r);
21
31
  }
22
- function h(e = 8) {
32
+ function v(e = 8) {
23
33
  const r = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_+[]{}|;:,.<>?";
24
- let n = "";
25
- for (let t = 0; t < e; t++) {
34
+ let t = "";
35
+ for (let n = 0; n < e; n++) {
26
36
  const o = Math.floor(Math.random() * r.length);
27
- n += r.charAt(o);
37
+ t += r.charAt(o);
28
38
  }
29
- return n;
39
+ return t;
30
40
  }
31
41
  function x(e = "", r = !1) {
32
- const n = e.split(/[?#]/)[0] || "", t = n.substring(n.lastIndexOf("/") + 1);
42
+ const t = e.split(/[?#]/)[0] || "", n = t.substring(t.lastIndexOf("/") + 1);
33
43
  if (r)
34
- return t;
35
- const o = t.lastIndexOf(".");
36
- return o > 0 ? t.slice(0, o) : t;
44
+ return n;
45
+ const o = n.lastIndexOf(".");
46
+ return o > 0 ? n.slice(0, o) : n;
37
47
  }
38
- function w(e, r, n) {
39
- const t = e.indexOf(r);
40
- if (t === -1)
48
+ function P(e, r, t) {
49
+ const n = e.indexOf(r);
50
+ if (n === -1)
41
51
  return "";
42
- const o = t + r.length, s = e.indexOf(n, o);
43
- return s === -1 ? "" : e.slice(o, s);
52
+ const o = n + r.length, l = e.indexOf(t, o);
53
+ return l === -1 ? "" : e.slice(o, l);
44
54
  }
45
55
  export {
46
- h as generateRandomPassword,
47
- m as generateShortId,
48
- g as generateSlug,
56
+ v as generateRandomPassword,
57
+ h as generateShortId,
58
+ y as generateSlug,
49
59
  x as getFileName,
50
- w as substringBetween
60
+ P as substringBetween
51
61
  };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./validate.util.cjs");exports.validate=e.validate;
@@ -0,0 +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;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cyberskill/shared",
3
3
  "type": "module",
4
- "version": "1.210.0",
4
+ "version": "1.211.0",
5
5
  "description": "CyberSkill Shared",
6
6
  "author": "Stephen Cheng",
7
7
  "license": "MIT",
@@ -17,138 +17,172 @@
17
17
  "exports": {
18
18
  "./config": {
19
19
  "types": "./dist/config/index.d.ts",
20
- "import": "./dist/config/index.js"
20
+ "import": "./dist/config/index.js",
21
+ "require": "./dist/config/index.cjs"
21
22
  },
22
23
  "./config/commitlint": {
23
24
  "types": "./dist/config/commitlint/index.d.ts",
24
- "import": "./dist/config/commitlint/index.js"
25
+ "import": "./dist/config/commitlint/index.js",
26
+ "require": "./dist/config/commitlint/index.cjs"
25
27
  },
26
28
  "./config/env": {
27
29
  "types": "./dist/config/env/index.d.ts",
28
- "import": "./dist/config/env/index.js"
30
+ "import": "./dist/config/env/index.js",
31
+ "require": "./dist/config/env/index.cjs"
29
32
  },
30
33
  "./config/eslint": {
31
34
  "types": "./dist/config/eslint/index.d.ts",
32
- "import": "./dist/config/eslint/index.js"
35
+ "import": "./dist/config/eslint/index.js",
36
+ "require": "./dist/config/eslint/index.cjs"
33
37
  },
34
38
  "./config/graphql-codegen": {
35
39
  "types": "./dist/config/graphql-codegen/index.d.ts",
36
- "import": "./dist/config/graphql-codegen/index.js"
40
+ "import": "./dist/config/graphql-codegen/index.js",
41
+ "require": "./dist/config/graphql-codegen/index.cjs"
37
42
  },
38
43
  "./config/lint-staged": {
39
44
  "types": "./dist/config/lint-staged/index.d.ts",
40
- "import": "./dist/config/lint-staged/index.js"
45
+ "import": "./dist/config/lint-staged/index.js",
46
+ "require": "./dist/config/lint-staged/index.cjs"
41
47
  },
42
48
  "./config/vitest": {
43
49
  "types": "./dist/config/vitest/index.d.ts",
44
- "import": "./dist/config/vitest/index.js"
50
+ "import": "./dist/config/vitest/index.js",
51
+ "require": "./dist/config/vitest/index.cjs"
45
52
  },
46
53
  "./constant": {
47
54
  "types": "./dist/constant/index.d.ts",
48
- "import": "./dist/constant/index.js"
55
+ "import": "./dist/constant/index.js",
56
+ "require": "./dist/constant/index.cjs"
49
57
  },
50
58
  "./node/apollo-server": {
51
59
  "types": "./dist/node/apollo-server/index.d.ts",
52
- "import": "./dist/node/apollo-server/index.js"
60
+ "import": "./dist/node/apollo-server/index.js",
61
+ "require": "./dist/node/apollo-server/index.cjs"
53
62
  },
54
63
  "./node/cli": {
55
64
  "types": "./dist/node/cli/index.d.ts",
56
- "import": "./dist/node/cli/index.js"
65
+ "import": "./dist/node/cli/index.js",
66
+ "require": "./dist/node/cli/index.cjs"
57
67
  },
58
68
  "./node/command": {
59
69
  "types": "./dist/node/command/index.d.ts",
60
- "import": "./dist/node/command/index.js"
70
+ "import": "./dist/node/command/index.js",
71
+ "require": "./dist/node/command/index.cjs"
61
72
  },
62
73
  "./node/express": {
63
74
  "types": "./dist/node/express/index.d.ts",
64
- "import": "./dist/node/express/index.js"
75
+ "import": "./dist/node/express/index.js",
76
+ "require": "./dist/node/express/index.cjs"
65
77
  },
66
78
  "./node/fs": {
67
79
  "types": "./dist/node/fs/index.d.ts",
68
- "import": "./dist/node/fs/index.js"
80
+ "import": "./dist/node/fs/index.js",
81
+ "require": "./dist/node/fs/index.cjs"
69
82
  },
70
83
  "./node/log": {
71
84
  "types": "./dist/node/log/index.d.ts",
72
- "import": "./dist/node/log/index.js"
85
+ "import": "./dist/node/log/index.js",
86
+ "require": "./dist/node/log/index.cjs"
73
87
  },
74
88
  "./node/mongo": {
75
89
  "types": "./dist/node/mongo/index.d.ts",
76
- "import": "./dist/node/mongo/index.js"
90
+ "import": "./dist/node/mongo/index.js",
91
+ "require": "./dist/node/mongo/index.cjs"
77
92
  },
78
93
  "./node/package": {
79
94
  "types": "./dist/node/package/index.d.ts",
80
- "import": "./dist/node/package/index.js"
95
+ "import": "./dist/node/package/index.js",
96
+ "require": "./dist/node/package/index.cjs"
81
97
  },
82
98
  "./node/path": {
83
99
  "types": "./dist/node/path/index.d.ts",
84
- "import": "./dist/node/path/index.js"
100
+ "import": "./dist/node/path/index.js",
101
+ "require": "./dist/node/path/index.cjs"
85
102
  },
86
103
  "./node/storage": {
87
104
  "types": "./dist/node/storage/index.d.ts",
88
- "import": "./dist/node/storage/index.js"
105
+ "import": "./dist/node/storage/index.js",
106
+ "require": "./dist/node/storage/index.cjs"
89
107
  },
90
108
  "./node/upload": {
91
109
  "types": "./dist/node/upload/index.d.ts",
92
- "import": "./dist/node/upload/index.js"
110
+ "import": "./dist/node/upload/index.js",
111
+ "require": "./dist/node/upload/index.cjs"
93
112
  },
94
113
  "./node/ws": {
95
114
  "types": "./dist/node/ws/index.d.ts",
96
- "import": "./dist/node/ws/index.js"
115
+ "import": "./dist/node/ws/index.js",
116
+ "require": "./dist/node/ws/index.cjs"
97
117
  },
98
118
  "./react/apollo-client": {
99
119
  "types": "./dist/react/apollo-client/index.d.ts",
100
- "import": "./dist/react/apollo-client/index.js"
120
+ "import": "./dist/react/apollo-client/index.js",
121
+ "require": "./dist/react/apollo-client/index.cjs"
101
122
  },
102
123
  "./react/apollo-client-nextjs": {
103
124
  "types": "./dist/react/apollo-client-nextjs/index.d.ts",
104
- "import": "./dist/react/apollo-client-nextjs/index.js"
125
+ "import": "./dist/react/apollo-client-nextjs/index.js",
126
+ "require": "./dist/react/apollo-client-nextjs/index.cjs"
105
127
  },
106
128
  "./react/apollo-client-nextjs/rsc": {
107
129
  "types": "./dist/react/apollo-client-nextjs/apollo-client-nextjs.rsc.d.ts",
108
- "import": "./dist/react/apollo-client-nextjs/apollo-client-nextjs.rsc.js"
130
+ "import": "./dist/react/apollo-client-nextjs/apollo-client-nextjs.rsc.js",
131
+ "require": "./dist/react/apollo-client-nextjs/apollo-client-nextjs.rsc.cjs"
109
132
  },
110
133
  "./react/apollo-error": {
111
134
  "types": "./dist/react/apollo-error/index.d.ts",
112
- "import": "./dist/react/apollo-error/index.js"
135
+ "import": "./dist/react/apollo-error/index.js",
136
+ "require": "./dist/react/apollo-error/index.cjs"
113
137
  },
114
138
  "./react/i18next": {
115
139
  "types": "./dist/react/i18next/index.d.ts",
116
- "import": "./dist/react/i18next/index.js"
140
+ "import": "./dist/react/i18next/index.js",
141
+ "require": "./dist/react/i18next/index.cjs"
117
142
  },
118
143
  "./react/loading": {
119
144
  "types": "./dist/react/loading/index.d.ts",
120
- "import": "./dist/react/loading/index.js"
145
+ "import": "./dist/react/loading/index.js",
146
+ "require": "./dist/react/loading/index.cjs"
121
147
  },
122
148
  "./react/log": {
123
149
  "types": "./dist/react/log/index.d.ts",
124
- "import": "./dist/react/log/index.js"
150
+ "import": "./dist/react/log/index.js",
151
+ "require": "./dist/react/log/index.cjs"
125
152
  },
126
153
  "./react/next-intl": {
127
154
  "types": "./dist/react/next-intl/index.d.ts",
128
- "import": "./dist/react/next-intl/index.js"
155
+ "import": "./dist/react/next-intl/index.js",
156
+ "require": "./dist/react/next-intl/index.cjs"
129
157
  },
130
158
  "./react/storage": {
131
159
  "types": "./dist/react/storage/index.d.ts",
132
- "import": "./dist/react/storage/index.js"
160
+ "import": "./dist/react/storage/index.js",
161
+ "require": "./dist/react/storage/index.cjs"
133
162
  },
134
163
  "./react/toast": {
135
164
  "types": "./dist/react/toast/index.d.ts",
136
- "import": "./dist/react/toast/index.js"
165
+ "import": "./dist/react/toast/index.js",
166
+ "require": "./dist/react/toast/index.cjs"
137
167
  },
138
168
  "./react/userback": {
139
169
  "types": "./dist/react/userback/index.d.ts",
140
- "import": "./dist/react/userback/index.js"
170
+ "import": "./dist/react/userback/index.js",
171
+ "require": "./dist/react/userback/index.cjs"
141
172
  },
142
173
  "./typescript": {
143
174
  "types": "./dist/typescript/index.d.ts",
144
- "import": "./dist/typescript/index.js"
175
+ "import": "./dist/typescript/index.js",
176
+ "require": "./dist/typescript/index.cjs"
145
177
  },
146
178
  "./util": {
147
179
  "types": "./dist/util/index.d.ts",
148
- "import": "./dist/util/index.js"
180
+ "import": "./dist/util/index.js",
181
+ "require": "./dist/util/index.cjs"
149
182
  },
150
183
  "./style.css": {
151
- "import": "./dist/style.css"
184
+ "import": "./dist/style.css",
185
+ "require": "./dist/style.css"
152
186
  }
153
187
  },
154
188
  "bin": {