@cyberskill/shared 2.27.0 → 2.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config/eslint/index.d.ts +2 -0
- package/dist/config/vitest/vitest.e2e.cjs +1 -1
- package/dist/config/vitest/vitest.e2e.js +1 -1
- package/dist/config/vitest/vitest.unit.cjs +1 -1
- package/dist/config/vitest/vitest.unit.js +1 -1
- package/dist/node/cli/index.cjs +2 -5
- package/dist/node/cli/index.js +64 -69
- package/dist/node/fs/fs.util.cjs +4 -1
- package/dist/node/fs/fs.util.d.ts +8 -0
- package/dist/node/fs/fs.util.js +58 -50
- package/dist/node/fs/index.cjs +1 -1
- package/dist/node/fs/index.js +13 -12
- package/dist/node/mongo/mongo.type.js +3 -3
- package/dist/node/mongo/mongo.util.cjs +2 -5
- package/dist/node/mongo/mongo.util.js +206 -211
- package/dist/node/storage/storage.util.cjs +1 -1
- package/dist/node/storage/storage.util.js +1 -1
- package/dist/node/upload/upload.util.js +3 -3
- package/dist/util/common/common.util.cjs +1 -1
- package/dist/util/common/common.util.d.ts +9 -0
- package/dist/util/common/common.util.js +33 -29
- package/dist/util/common/index.cjs +1 -1
- package/dist/util/common/index.js +6 -5
- package/dist/util/index.cjs +1 -1
- package/dist/util/index.js +23 -22
- package/dist/util/object/object.util.cjs +1 -1
- package/dist/util/object/object.util.js +40 -36
- package/package.json +40 -40
- package/dist/node/mongo/mongo.util.d.ts +0 -1040
- /package/dist/node_modules/.pnpm/{vitest@4.0.17_@types_node@25.0.9_jiti@2.6.1_jsdom@27.4.0_@noble_hashes@1.8.0__sass@1.97.2_tsx@4.21.0_yaml@2.8.2 → vitest@4.0.18_@types_node@25.3.0_jiti@2.6.1_jsdom@28.1.0_@noble_hashes@1.8.0__sass@1.97.3_tsx@4.21.0_yaml@2.8.2}/node_modules/vitest/dist/config.cjs +0 -0
- /package/dist/node_modules/.pnpm/{vitest@4.0.17_@types_node@25.0.9_jiti@2.6.1_jsdom@27.4.0_@noble_hashes@1.8.0__sass@1.97.2_tsx@4.21.0_yaml@2.8.2 → vitest@4.0.18_@types_node@25.3.0_jiti@2.6.1_jsdom@28.1.0_@noble_hashes@1.8.0__sass@1.97.3_tsx@4.21.0_yaml@2.8.2}/node_modules/vitest/dist/config.js +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("localforage"),o=require("node:fs/promises"),D=require("node:path"),c=require("./storage.constant.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("localforage"),o=require("node:fs/promises"),D=require("node:path"),c=require("./storage.constant.cjs"),s=require("../log/log.util.cjs"),I=require("../../config/env/env.util.cjs");var n=(e,r,t)=>new Promise((i,y)=>{var h=u=>{try{v(t.next(u))}catch(_){y(_)}},O=u=>{try{v(t.throw(u))}catch(_){y(_)}},v=u=>u.done?i(u.value):Promise.resolve(u.value).then(h,O);v((t=t.apply(e,r)).next())});const E=I.getEnv(),l={baseDir:E.CYBERSKILL_STORAGE_DIRECTORY};function m(e){return`${encodeURIComponent(e)}${c.STORAGE_KEY_EXTENSION}`}function N(e){return decodeURIComponent(e.slice(0,-c.STORAGE_KEY_EXTENSION.length))}function R(e,r){return D.join(r,m(e))}const d={_driver:c.NODE_FS_DRIVER_NAME,_support:!0,_initStorage(e){return n(this,null,function*(){try{const r=typeof e=="object"&&e!==null&&"baseDir"in e?e.baseDir:void 0;typeof r=="string"&&r.length>0?l.baseDir=r:l.baseDir=E.CYBERSKILL_STORAGE_DIRECTORY,yield o.mkdir(l.baseDir,{recursive:!0})}catch(r){throw s.log.error("[Storage:init]",r),r}})},clear(){return n(this,null,function*(){const{baseDir:e}=l;yield o.rm(e,{recursive:!0,force:!0}),yield o.mkdir(e,{recursive:!0})})},getItem(e){return n(this,null,function*(){const{baseDir:r}=l,t=R(e,r);try{const i=yield o.readFile(t,"utf8");return JSON.parse(i)}catch(i){if(i.code==="ENOENT")return null;throw i}})},iterate(e){return n(this,null,function*(){const r=yield d.keys();let t=1;for(const i of r){const y=yield d.getItem(i),h=e(y,i,t);if(h!==void 0)return h;t+=1}})},key(e){return n(this,null,function*(){var r;return(r=(yield d.keys())[e])!=null?r:null})},keys(){return n(this,null,function*(){const{baseDir:e}=l;try{return(yield o.readdir(e)).filter(t=>t.endsWith(c.STORAGE_KEY_EXTENSION)).map(N)}catch(r){if(r.code==="ENOENT")return[];throw r}})},length(){return n(this,null,function*(){return(yield d.keys()).length})},removeItem(e){return n(this,null,function*(){const{baseDir:r}=l,t=R(e,r);yield o.rm(t,{force:!0})})},setItem(e,r){return n(this,null,function*(){const{baseDir:t}=l,i=R(e,t);return yield o.mkdir(t,{recursive:!0}),yield o.writeFile(i,JSON.stringify(r),"utf8"),r})}};let a=null,S=null;function f(){return n(this,null,function*(){return a?(yield a,S):(a=n(null,null,function*(){yield g.defineDriver(d),l.baseDir=E.CYBERSKILL_STORAGE_DIRECTORY;const e=yield g.getDriver(c.NODE_FS_DRIVER_NAME),r={baseDir:l.baseDir,name:c.STORAGE_INSTANCE_NAME,storeName:c.STORAGE_STORE_NAME};yield e._initStorage(r),S=e}).catch(e=>{throw a=null,e}),yield a,S)})}const T={get(e){return n(this,null,function*(){try{const t=yield(yield f()).getItem(e);return t!=null?t:null}catch(r){return s.catchError(r,{returnValue:null})}})},set(e,r){return n(this,null,function*(){try{yield(yield f()).setItem(e,r)}catch(t){s.catchError(t)}})},remove(e){return n(this,null,function*(){try{yield(yield f()).removeItem(e)}catch(r){s.catchError(r)}})},keys(){return n(this,null,function*(){try{const r=yield(yield f()).keys();return Array.isArray(r)?r:(s.log.warn("[Storage:keys] Invalid keys response:",r),[])}catch(e){return s.catchError(e,{returnValue:[]})}})},getLogLink(e){return n(this,null,function*(){try{return`${D.join(E.CYBERSKILL_STORAGE_DIRECTORY,m(e))} (key: ${e})`}catch(r){return s.catchError(r,{returnValue:null})}})}};exports.storage=T;
|
|
@@ -2,8 +2,8 @@ import _ from "localforage";
|
|
|
2
2
|
import l from "node:fs/promises";
|
|
3
3
|
import g from "node:path";
|
|
4
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
5
|
import { catchError as s, log as S } from "../log/log.util.js";
|
|
6
|
+
import { getEnv as N } from "../../config/env/env.util.js";
|
|
7
7
|
var n = (e, r, t) => new Promise((i, d) => {
|
|
8
8
|
var y = (u) => {
|
|
9
9
|
try {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Buffer as w } from "node:buffer";
|
|
2
2
|
import { Transform as C } from "node:stream";
|
|
3
3
|
import { ReadableStream as D } from "node:stream/web";
|
|
4
|
-
import {
|
|
4
|
+
import { DEFAULT_UPLOAD_CONFIG as R, BYTES_PER_MB as h } from "./upload.constant.js";
|
|
5
5
|
import { E_UploadType as p } from "./upload.type.js";
|
|
6
6
|
import { dirname as x } from "../path/path.util.js";
|
|
7
7
|
import { pathExistsSync as z, mkdirSync as A, createWriteStream as F } from "../fs/fs.util.js";
|
|
@@ -66,7 +66,7 @@ function G(t, r, e) {
|
|
|
66
66
|
let n = a.sizeLimit;
|
|
67
67
|
const l = new C({
|
|
68
68
|
transform(f, d, y) {
|
|
69
|
-
n -= f.length, n < 0 ? y(new Error(`File size exceeds limit of ${a.sizeLimit /
|
|
69
|
+
n -= f.length, n < 0 ? y(new Error(`File size exceeds limit of ${a.sizeLimit / h}MB`)) : y(null, f);
|
|
70
70
|
}
|
|
71
71
|
}), m = o().pipe(l);
|
|
72
72
|
return {
|
|
@@ -105,7 +105,7 @@ function U(t, r, e) {
|
|
|
105
105
|
return { isValid: !0 };
|
|
106
106
|
}
|
|
107
107
|
function O(t) {
|
|
108
|
-
return _(_({},
|
|
108
|
+
return _(_({}, R), t);
|
|
109
109
|
}
|
|
110
110
|
function W(t) {
|
|
111
111
|
return E(this, null, function* () {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../../typescript/common.type.cjs");var
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../../typescript/common.type.cjs");var O=Object.defineProperty,a=Object.getOwnPropertySymbols,f=Object.prototype.hasOwnProperty,l=Object.prototype.propertyIsEnumerable,i=(e,n,r)=>n in e?O(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r,p=(e,n)=>{for(var r in n||(n={}))f.call(n,r)&&i(e,r,n[r]);if(a)for(var r of a(n))l.call(n,r)&&i(e,r,n[r]);return e};const s={a:["à","á","ạ","ả","ã","â","ầ","ấ","ậ","ẩ","ẫ","ă","ằ","ắ","ặ","ẳ","ẵ"],e:["è","é","ẹ","ẻ","ẽ","ê","ề","ế","ệ","ể","ễ"],i:["ì","í","ị","ỉ","ĩ"],o:["ò","ó","ọ","ỏ","õ","ô","ồ","ố","ộ","ổ","ỗ","ơ","ờ","ớ","ợ","ở","ỡ"],u:["ù","ú","ụ","ủ","ũ","ư","ừ","ứ","ự","ử","ữ"],y:["ỳ","ý","ỵ","ỷ","ỹ"],d:["đ"]},v=Object.entries(s).reduce((e,[n,r])=>(e[n.toUpperCase()]=r.map(o=>o.toUpperCase()),e),{}),g=p(p({},s),v),u=new Map,m=new Set;Object.entries(g).forEach(([e,n])=>{const r=`(${[e,...n].join("|")})`;[e,...n].forEach(o=>{u.set(o,r),m.add(o)})});const D=Array.from(m).join(""),N=new RegExp(`[${D}]`,"g");function _(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function P(e){return e=_(e),e=e.normalize("NFD"),e.replace(N,n=>u.get(n)||n)}function M(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 c of e){const E=n(c);r.has(E)||(r.add(E),o.push(c))}return o}function S(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,c=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:c,IS_PROD:E}}exports.escapeRegExp=_;exports.mapEnvironment=S;exports.regexSearchMapper=P;exports.removeAccent=M;exports.uniqueArray=d;
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
import { I_EnvFlags, I_NodeEnvInput } from './common.type.js';
|
|
2
|
+
/**
|
|
3
|
+
* Escapes special characters in a string for use in a regular expression.
|
|
4
|
+
* This function escapes characters that have special meaning in regex (e.g., ., *, +, ?, etc.)
|
|
5
|
+
* so they are treated as literal characters.
|
|
6
|
+
*
|
|
7
|
+
* @param str - The string to escape.
|
|
8
|
+
* @returns The escaped string safe for use in a RegExp.
|
|
9
|
+
*/
|
|
10
|
+
export declare function escapeRegExp(str: string): string;
|
|
2
11
|
/**
|
|
3
12
|
* Convert a string to a regex pattern that matches the string and its accented variations.
|
|
4
13
|
* This function normalizes the input string and creates a regex pattern that can match
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { E_Environment as t } from "../../typescript/common.type.js";
|
|
2
|
-
var f = Object.defineProperty, p = Object.getOwnPropertySymbols, m = Object.prototype.hasOwnProperty, _ = Object.prototype.propertyIsEnumerable, i = (
|
|
3
|
-
for (var n in
|
|
4
|
-
m.call(
|
|
2
|
+
var f = Object.defineProperty, p = Object.getOwnPropertySymbols, m = Object.prototype.hasOwnProperty, _ = Object.prototype.propertyIsEnumerable, i = (e, r, n) => r in e ? f(e, r, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[r] = n, E = (e, r) => {
|
|
3
|
+
for (var n in r || (r = {}))
|
|
4
|
+
m.call(r, n) && i(e, n, r[n]);
|
|
5
5
|
if (p)
|
|
6
|
-
for (var n of p(
|
|
7
|
-
_.call(
|
|
8
|
-
return
|
|
6
|
+
for (var n of p(r))
|
|
7
|
+
_.call(r, n) && i(e, n, r[n]);
|
|
8
|
+
return e;
|
|
9
9
|
};
|
|
10
|
-
const
|
|
10
|
+
const s = {
|
|
11
11
|
a: ["à", "á", "ạ", "ả", "ã", "â", "ầ", "ấ", "ậ", "ẩ", "ẫ", "ă", "ằ", "ắ", "ặ", "ẳ", "ẵ"],
|
|
12
12
|
e: ["è", "é", "ẹ", "ẻ", "ẽ", "ê", "ề", "ế", "ệ", "ể", "ễ"],
|
|
13
13
|
i: ["ì", "í", "ị", "ỉ", "ĩ"],
|
|
@@ -15,42 +15,46 @@ const E = {
|
|
|
15
15
|
u: ["ù", "ú", "ụ", "ủ", "ũ", "ư", "ừ", "ứ", "ự", "ử", "ữ"],
|
|
16
16
|
y: ["ỳ", "ý", "ỵ", "ỷ", "ỹ"],
|
|
17
17
|
d: ["đ"]
|
|
18
|
-
},
|
|
19
|
-
(
|
|
18
|
+
}, l = Object.entries(s).reduce(
|
|
19
|
+
(e, [r, n]) => (e[r.toUpperCase()] = n.map((o) => o.toUpperCase()), e),
|
|
20
20
|
{}
|
|
21
|
-
),
|
|
22
|
-
Object.entries(
|
|
23
|
-
const n = `(${[
|
|
24
|
-
[
|
|
21
|
+
), D = E(E({}, s), l), u = /* @__PURE__ */ new Map(), O = /* @__PURE__ */ new Set();
|
|
22
|
+
Object.entries(D).forEach(([e, r]) => {
|
|
23
|
+
const n = `(${[e, ...r].join("|")})`;
|
|
24
|
+
[e, ...r].forEach((o) => {
|
|
25
25
|
u.set(o, n), O.add(o);
|
|
26
26
|
});
|
|
27
27
|
});
|
|
28
|
-
const
|
|
29
|
-
function
|
|
30
|
-
return
|
|
28
|
+
const N = Array.from(O).join(""), P = new RegExp(`[${N}]`, "g");
|
|
29
|
+
function g(e) {
|
|
30
|
+
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
31
31
|
}
|
|
32
|
-
function
|
|
33
|
-
return
|
|
32
|
+
function d(e) {
|
|
33
|
+
return e = g(e), e = e.normalize("NFD"), e.replace(P, (r) => u.get(r) || r);
|
|
34
34
|
}
|
|
35
|
-
function w(
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
function w(e) {
|
|
36
|
+
return e.normalize("NFD").replace(new RegExp("\\p{Diacritic}", "gu"), "");
|
|
37
|
+
}
|
|
38
|
+
function S(e, r) {
|
|
39
|
+
if (!r)
|
|
40
|
+
return Array.from(new Set(e));
|
|
38
41
|
const n = /* @__PURE__ */ new Set(), o = [];
|
|
39
|
-
for (const c of
|
|
40
|
-
const a =
|
|
42
|
+
for (const c of e) {
|
|
43
|
+
const a = r(c);
|
|
41
44
|
n.has(a) || (n.add(a), o.push(c));
|
|
42
45
|
}
|
|
43
46
|
return o;
|
|
44
47
|
}
|
|
45
|
-
function
|
|
46
|
-
const { NODE_ENV:
|
|
47
|
-
if (
|
|
48
|
+
function T(e) {
|
|
49
|
+
const { NODE_ENV: r = t.DEVELOPMENT, NODE_ENV_MODE: n = t.DEVELOPMENT } = e, o = r === t.DEVELOPMENT && n === t.DEVELOPMENT, c = r === t.PRODUCTION && n === t.STAGING, a = r === t.PRODUCTION && n === t.PRODUCTION;
|
|
50
|
+
if (r === t.PRODUCTION && n === t.DEVELOPMENT)
|
|
48
51
|
throw new Error("NODE_ENV_MODE must be set to staging or production in production environment");
|
|
49
52
|
return { IS_DEV: o, IS_STAG: c, IS_PROD: a };
|
|
50
53
|
}
|
|
51
54
|
export {
|
|
52
|
-
|
|
55
|
+
g as escapeRegExp,
|
|
56
|
+
T as mapEnvironment,
|
|
53
57
|
d as regexSearchMapper,
|
|
54
|
-
|
|
55
|
-
|
|
58
|
+
w as removeAccent,
|
|
59
|
+
S as uniqueArray
|
|
56
60
|
};
|
|
@@ -1 +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;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./common.util.cjs");exports.escapeRegExp=e.escapeRegExp;exports.mapEnvironment=e.mapEnvironment;exports.regexSearchMapper=e.regexSearchMapper;exports.removeAccent=e.removeAccent;exports.uniqueArray=e.uniqueArray;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { mapEnvironment as
|
|
1
|
+
import { escapeRegExp as p, mapEnvironment as a, regexSearchMapper as n, removeAccent as c, uniqueArray as m } from "./common.util.js";
|
|
2
2
|
export {
|
|
3
|
-
|
|
4
|
-
a as
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
p as escapeRegExp,
|
|
4
|
+
a as mapEnvironment,
|
|
5
|
+
n as regexSearchMapper,
|
|
6
|
+
c as removeAccent,
|
|
7
|
+
m as uniqueArray
|
|
7
8
|
};
|
package/dist/util/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./object/object.util.cjs"),r=require("./common/common.util.cjs"),t=require("./string/string.util.cjs"),a=require("./serializer/serializer.util.cjs"),i=require("./validate/validate.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;exports.escapeRegExp=r.escapeRegExp;exports.mapEnvironment=r.mapEnvironment;exports.regexSearchMapper=r.regexSearchMapper;exports.removeAccent=r.removeAccent;exports.uniqueArray=r.uniqueArray;exports.generateRandomPassword=t.generateRandomPassword;exports.generateShortId=t.generateShortId;exports.generateSlug=t.generateSlug;exports.getFileName=t.getFileName;exports.substringBetween=t.substringBetween;exports.serializer=a.serializer;exports.validate=i.validate;
|
package/dist/util/index.js
CHANGED
|
@@ -1,24 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { validate as
|
|
1
|
+
import { deepClone as t, deepMerge as o, getNestedValue as a, isJSON as n, normalizeMongoFilter as p, setNestedValue as g } from "./object/object.util.js";
|
|
2
|
+
import { escapeRegExp as i, mapEnvironment as s, regexSearchMapper as l, removeAccent as d, uniqueArray as x } from "./common/common.util.js";
|
|
3
|
+
import { generateRandomPassword as f, generateShortId as c, generateSlug as N, getFileName as S, substringBetween as v } from "./string/string.util.js";
|
|
4
|
+
import { serializer as h } from "./serializer/serializer.util.js";
|
|
5
|
+
import { validate as z } from "./validate/validate.util.js";
|
|
6
6
|
export {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
c as
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
s as
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
7
|
+
t as deepClone,
|
|
8
|
+
o as deepMerge,
|
|
9
|
+
i as escapeRegExp,
|
|
10
|
+
f as generateRandomPassword,
|
|
11
|
+
c as generateShortId,
|
|
12
|
+
N as generateSlug,
|
|
13
|
+
S as getFileName,
|
|
14
|
+
a as getNestedValue,
|
|
15
|
+
n as isJSON,
|
|
16
|
+
s as mapEnvironment,
|
|
17
|
+
p as normalizeMongoFilter,
|
|
18
|
+
l as regexSearchMapper,
|
|
19
|
+
d as removeAccent,
|
|
20
|
+
h as serializer,
|
|
21
|
+
g as setNestedValue,
|
|
22
|
+
v as substringBetween,
|
|
23
|
+
x as uniqueArray,
|
|
24
|
+
z as validate
|
|
24
25
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var m=Object.defineProperty,A=Object.defineProperties,v=Object.getOwnPropertyDescriptors,
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var m=Object.defineProperty,A=Object.defineProperties,v=Object.getOwnPropertyDescriptors,f=Object.getOwnPropertySymbols,w=Object.prototype.hasOwnProperty,h=Object.prototype.propertyIsEnumerable,y=(e,r,n)=>r in e?m(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))h.call(r,n)&&y(e,n,r[n]);return e},O=(e,r)=>A(e,v(r));function P(e){try{return JSON.parse(e),!0}catch(r){return!1}}function _(e,r){let n=e;const o=r.length;for(let t=0;t<o;t++){const s=r[t];if(s!==void 0&&n&&typeof n=="object"&&s in n)n=n[s];else return}return n}function g(e,r,n,o){if(o>=r.length)return e;const t=r[o];if(o===r.length-1)return O(p({},e),{[t]:n});const s=e[t];return O(p({},e),{[t]:g(typeof s=="object"&&s!==null?s:{},r,n,o+1)})}function b(e,r,n){return r.length===0?e:g(e,r,n,0)}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 d(...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 s of r){const l=s;for(const a in l)if(Object.prototype.hasOwnProperty.call(l,a)){const i=l[a];if(Object.prototype.hasOwnProperty.call(t,a)){const c=t[a];typeof i=="object"&&i!==null&&typeof c=="object"&&c!==null?Array.isArray(i)&&Array.isArray(c)?t[a]=c.concat(i):!Array.isArray(i)&&!Array.isArray(c)?t[a]=d(c,i):t[a]=i:t[a]=i}else t[a]=i}}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 j(e){if(!e||typeof e!="object")return e;const r={};function n(o,t){for(const s in o){if(!Object.prototype.hasOwnProperty.call(o,s))continue;const l=o[s],a=t?`${t}.${s}`:s;if(l&&typeof l=="object"&&!Array.isArray(l)){let i=!1;for(const c in l)if(Object.prototype.hasOwnProperty.call(l,c)&&c.startsWith("$")){i=!0;break}i?r[a]=l:n(l,a)}else r[a]=l}}return n(e,""),r}exports.deepClone=u;exports.deepMerge=d;exports.getNestedValue=_;exports.isJSON=P;exports.normalizeMongoFilter=j;exports.setNestedValue=b;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
var A = Object.defineProperty,
|
|
1
|
+
var A = Object.defineProperty, m = Object.defineProperties, d = Object.getOwnPropertyDescriptors, f = Object.getOwnPropertySymbols, v = Object.prototype.hasOwnProperty, w = Object.prototype.propertyIsEnumerable, u = (e, r, n) => r in e ? A(e, r, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[r] = n, y = (e, r) => {
|
|
2
2
|
for (var n in r || (r = {}))
|
|
3
|
-
|
|
3
|
+
v.call(r, n) && u(e, n, r[n]);
|
|
4
4
|
if (f)
|
|
5
5
|
for (var n of f(r))
|
|
6
|
-
|
|
6
|
+
w.call(r, n) && u(e, n, r[n]);
|
|
7
7
|
return e;
|
|
8
|
-
}, p = (e, r) =>
|
|
8
|
+
}, p = (e, r) => m(e, d(r));
|
|
9
9
|
function P(e) {
|
|
10
10
|
try {
|
|
11
11
|
return JSON.parse(e), !0;
|
|
@@ -25,23 +25,27 @@ function _(e, r) {
|
|
|
25
25
|
}
|
|
26
26
|
return n;
|
|
27
27
|
}
|
|
28
|
-
function
|
|
29
|
-
if (r.length
|
|
28
|
+
function g(e, r, n, o) {
|
|
29
|
+
if (o >= r.length)
|
|
30
30
|
return e;
|
|
31
|
-
const
|
|
32
|
-
if (
|
|
33
|
-
return p(
|
|
34
|
-
[
|
|
31
|
+
const t = r[o];
|
|
32
|
+
if (o === r.length - 1)
|
|
33
|
+
return p(y({}, e), {
|
|
34
|
+
[t]: n
|
|
35
35
|
});
|
|
36
|
-
const s = e[
|
|
37
|
-
return p(
|
|
38
|
-
[
|
|
36
|
+
const s = e[t];
|
|
37
|
+
return p(y({}, e), {
|
|
38
|
+
[t]: g(
|
|
39
39
|
typeof s == "object" && s !== null ? s : {},
|
|
40
|
-
|
|
41
|
-
n
|
|
40
|
+
r,
|
|
41
|
+
n,
|
|
42
|
+
o + 1
|
|
42
43
|
)
|
|
43
44
|
});
|
|
44
45
|
}
|
|
46
|
+
function b(e, r, n) {
|
|
47
|
+
return r.length === 0 ? e : g(e, r, n, 0);
|
|
48
|
+
}
|
|
45
49
|
function O(e) {
|
|
46
50
|
if (e === null || typeof e != "object")
|
|
47
51
|
return e;
|
|
@@ -59,7 +63,7 @@ function O(e) {
|
|
|
59
63
|
Object.prototype.hasOwnProperty.call(e, o) && (n[o] = O(e[o]));
|
|
60
64
|
return n;
|
|
61
65
|
}
|
|
62
|
-
function
|
|
66
|
+
function h(...e) {
|
|
63
67
|
if (e.length === 0)
|
|
64
68
|
return {};
|
|
65
69
|
const r = e.filter((t) => t != null);
|
|
@@ -72,18 +76,18 @@ function w(...e) {
|
|
|
72
76
|
if (r.every((t) => typeof t == "object" && t !== null && !Array.isArray(t))) {
|
|
73
77
|
const t = {};
|
|
74
78
|
for (const s of r) {
|
|
75
|
-
const
|
|
76
|
-
for (const a in
|
|
77
|
-
if (Object.prototype.hasOwnProperty.call(
|
|
78
|
-
const
|
|
79
|
+
const l = s;
|
|
80
|
+
for (const a in l)
|
|
81
|
+
if (Object.prototype.hasOwnProperty.call(l, a)) {
|
|
82
|
+
const i = l[a];
|
|
79
83
|
if (Object.prototype.hasOwnProperty.call(t, a)) {
|
|
80
84
|
const c = t[a];
|
|
81
|
-
typeof
|
|
85
|
+
typeof i == "object" && i !== null && typeof c == "object" && c !== null ? Array.isArray(i) && Array.isArray(c) ? t[a] = c.concat(i) : !Array.isArray(i) && !Array.isArray(c) ? t[a] = h(
|
|
82
86
|
c,
|
|
83
|
-
|
|
84
|
-
) : t[a] =
|
|
87
|
+
i
|
|
88
|
+
) : t[a] = i : t[a] = i;
|
|
85
89
|
} else
|
|
86
|
-
t[a] =
|
|
90
|
+
t[a] = i;
|
|
87
91
|
}
|
|
88
92
|
}
|
|
89
93
|
return t;
|
|
@@ -101,7 +105,7 @@ function w(...e) {
|
|
|
101
105
|
"deepMerge: Invalid arguments provided. All arguments must be objects or arrays of the same type."
|
|
102
106
|
);
|
|
103
107
|
}
|
|
104
|
-
function
|
|
108
|
+
function j(e) {
|
|
105
109
|
if (!e || typeof e != "object")
|
|
106
110
|
return e;
|
|
107
111
|
const r = {};
|
|
@@ -109,26 +113,26 @@ function b(e) {
|
|
|
109
113
|
for (const s in o) {
|
|
110
114
|
if (!Object.prototype.hasOwnProperty.call(o, s))
|
|
111
115
|
continue;
|
|
112
|
-
const
|
|
113
|
-
if (
|
|
114
|
-
let
|
|
115
|
-
for (const c in
|
|
116
|
-
if (Object.prototype.hasOwnProperty.call(
|
|
117
|
-
|
|
116
|
+
const l = o[s], a = t ? `${t}.${s}` : s;
|
|
117
|
+
if (l && typeof l == "object" && !Array.isArray(l)) {
|
|
118
|
+
let i = !1;
|
|
119
|
+
for (const c in l)
|
|
120
|
+
if (Object.prototype.hasOwnProperty.call(l, c) && c.startsWith("$")) {
|
|
121
|
+
i = !0;
|
|
118
122
|
break;
|
|
119
123
|
}
|
|
120
|
-
|
|
124
|
+
i ? r[a] = l : n(l, a);
|
|
121
125
|
} else
|
|
122
|
-
r[a] =
|
|
126
|
+
r[a] = l;
|
|
123
127
|
}
|
|
124
128
|
}
|
|
125
129
|
return n(e, ""), r;
|
|
126
130
|
}
|
|
127
131
|
export {
|
|
128
132
|
O as deepClone,
|
|
129
|
-
|
|
133
|
+
h as deepMerge,
|
|
130
134
|
_ as getNestedValue,
|
|
131
135
|
P as isJSON,
|
|
132
|
-
|
|
133
|
-
|
|
136
|
+
j as normalizeMongoFilter,
|
|
137
|
+
b as setNestedValue
|
|
134
138
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cyberskill/shared",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.28.0",
|
|
5
5
|
"description": "CyberSkill Shared",
|
|
6
6
|
"author": "Stephen Cheng",
|
|
7
7
|
"license": "MIT",
|
|
@@ -213,69 +213,69 @@
|
|
|
213
213
|
"test:unit": "tsx src/node/cli/index.ts test:unit"
|
|
214
214
|
},
|
|
215
215
|
"dependencies": {
|
|
216
|
-
"@antfu/eslint-config": "7.
|
|
217
|
-
"@apollo/client": "4.1.
|
|
216
|
+
"@antfu/eslint-config": "7.4.3",
|
|
217
|
+
"@apollo/client": "4.1.5",
|
|
218
218
|
"@apollo/client-integration-nextjs": "0.14.4",
|
|
219
|
-
"@apollo/server": "5.
|
|
219
|
+
"@apollo/server": "5.4.0",
|
|
220
220
|
"@as-integrations/express5": "1.1.2",
|
|
221
|
-
"@dotenvx/dotenvx": "1.
|
|
221
|
+
"@dotenvx/dotenvx": "1.52.0",
|
|
222
222
|
"@eddeee888/gcg-typescript-resolver-files": "0.15.0",
|
|
223
|
-
"@eslint-react/eslint-plugin": "2.
|
|
223
|
+
"@eslint-react/eslint-plugin": "2.13.0",
|
|
224
224
|
"@graphql-codegen/cli": "6.1.1",
|
|
225
|
-
"@graphql-codegen/client-preset": "5.2.
|
|
226
|
-
"@nestjs/common": "11.1.
|
|
227
|
-
"@nestjs/core": "11.1.
|
|
225
|
+
"@graphql-codegen/client-preset": "5.2.3",
|
|
226
|
+
"@nestjs/common": "11.1.14",
|
|
227
|
+
"@nestjs/core": "11.1.14",
|
|
228
228
|
"@userback/widget": "0.3.12",
|
|
229
|
-
"@vitejs/plugin-react-swc": "4.2.
|
|
229
|
+
"@vitejs/plugin-react-swc": "4.2.3",
|
|
230
230
|
"body-parser": "2.2.2",
|
|
231
231
|
"chalk": "5.6.2",
|
|
232
232
|
"clsx": "2.1.1",
|
|
233
233
|
"compression": "1.8.1",
|
|
234
234
|
"consola": "3.4.2",
|
|
235
235
|
"cookie-parser": "1.4.7",
|
|
236
|
-
"cors": "2.8.
|
|
236
|
+
"cors": "2.8.6",
|
|
237
237
|
"date-fns": "4.1.0",
|
|
238
238
|
"envalid": "8.1.1",
|
|
239
|
-
"eslint-plugin-format": "1.
|
|
239
|
+
"eslint-plugin-format": "1.4.0",
|
|
240
240
|
"eslint-plugin-react-hooks": "7.0.1",
|
|
241
|
-
"eslint-plugin-react-refresh": "0.
|
|
241
|
+
"eslint-plugin-react-refresh": "0.5.0",
|
|
242
242
|
"express": "5.2.1",
|
|
243
|
-
"express-session": "1.
|
|
244
|
-
"express-useragent": "2.0
|
|
243
|
+
"express-session": "1.19.0",
|
|
244
|
+
"express-useragent": "2.1.0",
|
|
245
245
|
"extract-files": "13.0.0",
|
|
246
246
|
"fs-extra": "11.3.3",
|
|
247
|
-
"globals": "17.
|
|
247
|
+
"globals": "17.3.0",
|
|
248
248
|
"graphql": "16.12.0",
|
|
249
249
|
"graphql-upload": "17.0.0",
|
|
250
|
-
"graphql-ws": "6.0.
|
|
250
|
+
"graphql-ws": "6.0.7",
|
|
251
251
|
"helmet": "8.1.0",
|
|
252
|
-
"i18next": "25.8.
|
|
253
|
-
"jsdom": "
|
|
252
|
+
"i18next": "25.8.11",
|
|
253
|
+
"jsdom": "28.1.0",
|
|
254
254
|
"localforage": "1.10.0",
|
|
255
255
|
"migrate-mongo": "14.0.7",
|
|
256
|
-
"mongodb": "7.
|
|
257
|
-
"mongoose": "9.1
|
|
256
|
+
"mongodb": "7.1.0",
|
|
257
|
+
"mongoose": "9.2.1",
|
|
258
258
|
"mongoose-aggregate-paginate-v2": "1.1.4",
|
|
259
259
|
"mongoose-paginate-v2": "1.9.1",
|
|
260
|
-
"next-intl": "4.
|
|
260
|
+
"next-intl": "4.8.3",
|
|
261
261
|
"node-fetch": "3.3.2",
|
|
262
|
-
"qs": "6.
|
|
263
|
-
"react": "19.2.
|
|
264
|
-
"react-dom": "19.2.
|
|
262
|
+
"qs": "6.15.0",
|
|
263
|
+
"react": "19.2.4",
|
|
264
|
+
"react-dom": "19.2.4",
|
|
265
265
|
"react-hot-toast": "2.6.0",
|
|
266
|
-
"react-i18next": "16.5.
|
|
266
|
+
"react-i18next": "16.5.4",
|
|
267
267
|
"rxjs": "7.8.2",
|
|
268
268
|
"vite": "7.3.1",
|
|
269
269
|
"ws": "8.19.0",
|
|
270
270
|
"yargs": "18.0.0"
|
|
271
271
|
},
|
|
272
272
|
"devDependencies": {
|
|
273
|
-
"@commitlint/cli": "20.
|
|
274
|
-
"@commitlint/config-conventional": "20.
|
|
273
|
+
"@commitlint/cli": "20.4.2",
|
|
274
|
+
"@commitlint/config-conventional": "20.4.2",
|
|
275
275
|
"@eslint/config-inspector": "1.4.2",
|
|
276
|
-
"@next/eslint-plugin-next": "16.1.
|
|
277
|
-
"@storybook/react": "10.
|
|
278
|
-
"@storybook/react-vite": "10.
|
|
276
|
+
"@next/eslint-plugin-next": "16.1.6",
|
|
277
|
+
"@storybook/react": "10.2.10",
|
|
278
|
+
"@storybook/react-vite": "10.2.10",
|
|
279
279
|
"@testing-library/jest-dom": "6.9.1",
|
|
280
280
|
"@testing-library/react": "16.3.2",
|
|
281
281
|
"@types/body-parser": "1.19.6",
|
|
@@ -289,25 +289,25 @@
|
|
|
289
289
|
"@types/fs-extra": "11.0.4",
|
|
290
290
|
"@types/graphql-upload": "17.0.0",
|
|
291
291
|
"@types/migrate-mongo": "10.0.6",
|
|
292
|
-
"@types/node": "25.0
|
|
293
|
-
"@types/react": "19.2.
|
|
292
|
+
"@types/node": "25.3.0",
|
|
293
|
+
"@types/react": "19.2.14",
|
|
294
294
|
"@types/react-dom": "19.2.3",
|
|
295
295
|
"@types/ws": "8.18.1",
|
|
296
296
|
"@types/yargs": "17.0.35",
|
|
297
|
-
"@vitest/browser": "4.0.
|
|
298
|
-
"eslint": "
|
|
299
|
-
"eslint-config-next": "16.1.
|
|
300
|
-
"glob": "13.0.
|
|
297
|
+
"@vitest/browser": "4.0.18",
|
|
298
|
+
"eslint": "10.0.0",
|
|
299
|
+
"eslint-config-next": "16.1.6",
|
|
300
|
+
"glob": "13.0.6",
|
|
301
301
|
"lint-staged": "16.2.7",
|
|
302
|
-
"node-modules-inspector": "1.2
|
|
302
|
+
"node-modules-inspector": "1.3.2",
|
|
303
303
|
"npm-run-all2": "8.0.4",
|
|
304
|
-
"sass": "1.97.
|
|
304
|
+
"sass": "1.97.3",
|
|
305
305
|
"simple-git-hooks": "2.13.1",
|
|
306
306
|
"tsx": "4.21.0",
|
|
307
307
|
"typescript": "5.9.3",
|
|
308
308
|
"vite": "7.3.1",
|
|
309
309
|
"vite-plugin-dts": "4.5.4",
|
|
310
|
-
"vitest": "4.0.
|
|
310
|
+
"vitest": "4.0.18"
|
|
311
311
|
},
|
|
312
312
|
"publishConfig": {
|
|
313
313
|
"access": "public",
|