@cyberskill/shared 1.202.0 → 1.204.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.util-Ci2CZDut.cjs +1 -0
- package/dist/config.util-DKBwEBKR.js +61 -0
- package/dist/log.type-CMvG6Box.cjs +1 -0
- package/dist/{src/node/log/log.type.js → log.type-DTOvZHyz.js} +1 -1
- package/dist/path.constant-CWtb99gS.cjs +2 -0
- package/dist/{path.constant-DJq0jtD0.js → path.constant-CvSr0Rrx.js} +186 -185
- package/dist/src/config/config.util.cjs +1 -1
- package/dist/src/config/config.util.js +7 -58
- package/dist/src/config/index.cjs +1 -1
- package/dist/src/config/index.js +2 -3
- package/dist/src/config/vitest/vitest.unit.cjs +1 -1
- package/dist/src/config/vitest/vitest.unit.js +1 -1
- package/dist/src/node/cli/cli.util.cjs +1 -1
- package/dist/src/node/cli/cli.util.js +15 -15
- package/dist/src/node/command/command.util.cjs +1 -1
- package/dist/src/node/command/command.util.js +2 -2
- package/dist/src/node/command/index.cjs +1 -1
- package/dist/src/node/command/index.js +6 -7
- package/dist/src/node/log/index.cjs +1 -1
- package/dist/src/node/log/index.js +5 -5
- package/dist/src/node/mongo/index.cjs +1 -1
- package/dist/src/node/mongo/index.js +24 -15
- package/dist/src/node/mongo/mongo.util.cjs +1 -1
- package/dist/src/node/mongo/mongo.util.js +1 -1
- package/dist/src/node/package/index.cjs +1 -1
- package/dist/src/node/package/index.js +5 -6
- package/dist/src/node/package/package.util.cjs +1 -1
- package/dist/src/node/package/package.util.js +5 -6
- package/dist/src/node/path/index.cjs +1 -1
- package/dist/src/node/path/index.js +1 -1
- package/dist/src/node/path/path.constant.cjs +1 -1
- package/dist/src/node/path/path.constant.js +43 -45
- package/dist/src/node/upload/index.cjs +1 -1
- package/dist/src/node/upload/index.js +3 -4
- package/dist/src/node/upload/upload.util.cjs +1 -1
- package/dist/src/node/upload/upload.util.js +6 -157
- package/dist/src/react/apollo-client/apollo-client.util.cjs +1 -1
- package/dist/src/react/apollo-client/apollo-client.util.js +27 -27
- package/dist/upload.util-CE3MjBdh.cjs +1 -0
- package/dist/upload.util-D4aUdmPo.js +160 -0
- package/package.json +6 -6
- package/dist/path.constant-CPGOAxEp.cjs +0 -2
- package/dist/src/config/config.type.cjs +0 -1
- package/dist/src/config/config.type.js +0 -4
- package/dist/src/config/env/env.type.cjs +0 -1
- package/dist/src/config/env/env.type.js +0 -1
- package/dist/src/config/graphql-codegen/graphql-codegen.type.cjs +0 -1
- package/dist/src/config/graphql-codegen/graphql-codegen.type.js +0 -1
- package/dist/src/node/apollo-server/apollo-server.type.cjs +0 -1
- package/dist/src/node/apollo-server/apollo-server.type.js +0 -1
- package/dist/src/node/command/command.type.cjs +0 -1
- package/dist/src/node/command/command.type.js +0 -4
- package/dist/src/node/express/express.type.cjs +0 -1
- package/dist/src/node/express/express.type.js +0 -4
- package/dist/src/node/fs/fs.type.cjs +0 -1
- package/dist/src/node/fs/fs.type.js +0 -1
- package/dist/src/node/log/log.type.cjs +0 -1
- package/dist/src/node/mongo/mongo.type.cjs +0 -1
- package/dist/src/node/mongo/mongo.type.js +0 -16
- package/dist/src/node/package/package.type.cjs +0 -1
- package/dist/src/node/package/package.type.js +0 -4
- package/dist/src/node/upload/upload.type.cjs +0 -1
- package/dist/src/node/upload/upload.type.js +0 -4
- package/dist/src/node/ws/ws.type.cjs +0 -1
- package/dist/src/node/ws/ws.type.js +0 -1
- package/dist/src/react/apollo-client/apollo-client.type.cjs +0 -1
- package/dist/src/react/apollo-client/apollo-client.type.js +0 -1
- package/dist/src/react/apollo-error/apollo-error.type.cjs +0 -1
- package/dist/src/react/apollo-error/apollo-error.type.js +0 -1
- package/dist/src/react/loading/loading.type.cjs +0 -1
- package/dist/src/react/loading/loading.type.js +0 -1
- package/dist/src/react/log/log.type.cjs +0 -1
- package/dist/src/react/log/log.type.js +0 -1
- package/dist/src/react/next-intl/next-intl.type.cjs +0 -1
- package/dist/src/react/next-intl/next-intl.type.js +0 -1
- package/dist/src/react/userback/userback.type.cjs +0 -1
- package/dist/src/react/userback/userback.type.js +0 -1
- package/dist/src/util/common/common.type.cjs +0 -1
- package/dist/src/util/common/common.type.js +0 -1
- package/dist/src/util/serializer/serializer.type.cjs +0 -1
- package/dist/src/util/serializer/serializer.type.js +0 -1
- package/dist/src/util/string/string.type.cjs +0 -1
- package/dist/src/util/string/string.type.js +0 -1
|
@@ -1,51 +1,49 @@
|
|
|
1
1
|
import "fs-extra";
|
|
2
2
|
import "../../config/env/env.util.js";
|
|
3
|
-
import "
|
|
4
|
-
import { B as T, m as s, l as L, k as O, g as M, h as G, f as S, C as P, i as K, x as R, w as D, E as o, r as m, e as r, d as t, G as Y, n as i, L as H, D as p, M as B, A as U, N as e, z as F, y as J, a as V, b as c, F as f, s as n, t as d, c as g, P as k, u as x, v as W, S as X, T as b, p as h, o as j, q as l, j as q, V as u, W as v, I as w, H as y } from "../../../path.constant-DJq0jtD0.js";
|
|
5
|
-
import "../package/package.type.js";
|
|
3
|
+
import { B as a, m as N, l as T, k as s, g as L, h as O, f as M, C as G, i as S, x as P, w as K, E as R, r as D, e as o, d as Y, G as H, n as m, L as r, D as t, M as B, A as i, N as p, z as U, y as e, a as F, b as J, F as V, s as c, t as f, c as n, P as d, u as g, v as k, S as x, T as W, p as X, o as b, q as h, j, V as l, W as q, I as u, H as v } from "../../../path.constant-CvSr0Rrx.js";
|
|
6
4
|
import "./path.util.js";
|
|
7
5
|
export {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
6
|
+
a as BUILD_DIRECTORY,
|
|
7
|
+
N as COMMIT_LINT_CLI,
|
|
8
|
+
T as COMMIT_LINT_CONVENTIONAL_CONFIG_PACKAGE_NAME,
|
|
9
|
+
s as COMMIT_LINT_PACKAGE_NAME,
|
|
10
|
+
L as CYBERSKILL_CLI,
|
|
11
|
+
O as CYBERSKILL_CLI_PATH,
|
|
12
|
+
M as CYBERSKILL_DIRECTORY,
|
|
13
|
+
G as CYBERSKILL_PACKAGE_NAME,
|
|
14
|
+
S as ESLINT_CLI,
|
|
15
|
+
P as ESLINT_INSPECT_CLI,
|
|
16
|
+
K as ESLINT_INSPECT_PACKAGE_NAME,
|
|
17
|
+
R as ESLINT_PACKAGE_NAME,
|
|
18
|
+
D as GIT_CLI,
|
|
19
|
+
o as GIT_COMMIT_EDITMSG,
|
|
20
|
+
Y as GIT_HOOK,
|
|
21
|
+
H as GIT_IGNORE,
|
|
22
|
+
m as LINT_STAGED_CLI,
|
|
23
|
+
r as LINT_STAGED_PACKAGE_NAME,
|
|
24
|
+
t as MIGRATE_MONGO_CLI,
|
|
27
25
|
B as MIGRATE_MONGO_CONFIG,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
26
|
+
i as MIGRATE_MONGO_PACKAGE_NAME,
|
|
27
|
+
p as NODE_MODULES,
|
|
28
|
+
U as NODE_MODULES_INSPECT_CLI,
|
|
29
|
+
e as NODE_MODULES_INSPECT_PACKAGE_NAME,
|
|
30
|
+
F as PACKAGE_JSON,
|
|
31
|
+
J as PACKAGE_LOCK_JSON,
|
|
32
|
+
V as PATH,
|
|
33
|
+
c as PNPM_CLI,
|
|
34
|
+
f as PNPM_EXEC_CLI,
|
|
35
|
+
n as PNPM_LOCK_YAML,
|
|
36
|
+
d as PUBLIC_DIRECTORY,
|
|
37
|
+
g as SIMPLE_GIT_HOOKS_PACKAGE_NAME,
|
|
38
|
+
k as SIMPLE_GIT_HOOK_CLI,
|
|
39
|
+
x as SIMPLE_GIT_HOOK_JSON,
|
|
40
|
+
W as TSCONFIG_JSON,
|
|
41
|
+
X as TSC_CLI,
|
|
42
|
+
b as TSC_PACKAGE_NAME,
|
|
43
|
+
h as TSX_CLI,
|
|
44
|
+
j as VITEST_CLI,
|
|
45
|
+
l as VITEST_PACKAGE_NAME,
|
|
46
|
+
q as WORKING_DIRECTORY,
|
|
47
|
+
u as command,
|
|
48
|
+
v as createGitHooksConfig
|
|
51
49
|
};
|
|
@@ -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("../../../upload.util-CE3MjBdh.cjs");exports.E_UploadType=e.E_UploadType;exports.createUploadConfig=e.createUploadConfig;exports.upload=e.upload;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { createUploadConfig as a, upload as d } from "./upload.util.js";
|
|
1
|
+
import { E as p, c as e, u as d } from "../../../upload.util-D4aUdmPo.js";
|
|
3
2
|
export {
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
p as E_UploadType,
|
|
4
|
+
e as createUploadConfig,
|
|
6
5
|
d as upload
|
|
7
6
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../fs/fs.util.cjs");require("../../../path.constant-CWtb99gS.cjs");require("../path/path.util.cjs");const e=require("../../../upload.util-CE3MjBdh.cjs");exports.createUploadConfig=e.createUploadConfig;exports.upload=e.upload;
|
|
@@ -1,159 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
for (var e in i || (i = {}))
|
|
6
|
-
z.call(i, e) && E(s, e, i[e]);
|
|
7
|
-
if (x)
|
|
8
|
-
for (var e of x(i))
|
|
9
|
-
y.call(i, e) && E(s, e, i[e]);
|
|
10
|
-
return s;
|
|
11
|
-
};
|
|
12
|
-
var g = (s, i, e) => new Promise((t, a) => {
|
|
13
|
-
var n = (o) => {
|
|
14
|
-
try {
|
|
15
|
-
l(e.next(o));
|
|
16
|
-
} catch (c) {
|
|
17
|
-
a(c);
|
|
18
|
-
}
|
|
19
|
-
}, r = (o) => {
|
|
20
|
-
try {
|
|
21
|
-
l(e.throw(o));
|
|
22
|
-
} catch (c) {
|
|
23
|
-
a(c);
|
|
24
|
-
}
|
|
25
|
-
}, l = (o) => o.done ? t(o.value) : Promise.resolve(o.value).then(n, r);
|
|
26
|
-
l((e = e.apply(s, i)).next());
|
|
27
|
-
});
|
|
28
|
-
import { pathExistsSync as L, mkdirSync as C, createWriteStream as I } from "../fs/fs.util.js";
|
|
29
|
-
import "../../../path.constant-DJq0jtD0.js";
|
|
30
|
-
import { dirname as S } from "../path/path.util.js";
|
|
31
|
-
import { E_UploadType as f } from "./upload.type.js";
|
|
32
|
-
function h(s) {
|
|
33
|
-
return g(this, null, function* () {
|
|
34
|
-
return new Promise((i, e) => {
|
|
35
|
-
let t = 0;
|
|
36
|
-
s.on("data", (a) => {
|
|
37
|
-
t += a.length;
|
|
38
|
-
}), s.on("end", () => i(t)), s.on("error", e);
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
function F(s, i) {
|
|
43
|
-
const e = s.lastIndexOf(".");
|
|
44
|
-
if (e === -1)
|
|
45
|
-
return !1;
|
|
46
|
-
const t = s.substring(e + 1).toLowerCase();
|
|
47
|
-
return i.includes(t);
|
|
48
|
-
}
|
|
49
|
-
function M(s, i, e) {
|
|
50
|
-
const { filename: t, fileSize: a } = s, n = i[e], { allowedExtensions: r, sizeLimit: l } = n;
|
|
51
|
-
if (!F(t, r))
|
|
52
|
-
return {
|
|
53
|
-
isValid: !1,
|
|
54
|
-
error: `File extension not allowed for ${e.toLowerCase()} files. Allowed extensions: ${r.join(", ")}`
|
|
55
|
-
};
|
|
56
|
-
if (a !== void 0 && a > l) {
|
|
57
|
-
const o = Math.round(l / 1048576);
|
|
58
|
-
return {
|
|
59
|
-
isValid: !1,
|
|
60
|
-
error: `File size exceeds limit for ${e.toLowerCase()} files. Maximum size: ${o}MB`
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
return { isValid: !0 };
|
|
64
|
-
}
|
|
65
|
-
function A(s) {
|
|
66
|
-
const i = {
|
|
67
|
-
[f.IMAGE]: {
|
|
68
|
-
allowedExtensions: ["jpg", "jpeg", "png", "gif", "webp", "svg"],
|
|
69
|
-
sizeLimit: 5242880
|
|
70
|
-
// 5MB
|
|
71
|
-
},
|
|
72
|
-
[f.VIDEO]: {
|
|
73
|
-
allowedExtensions: ["mp4", "avi", "mov", "wmv", "flv", "webm"],
|
|
74
|
-
sizeLimit: 524288e3
|
|
75
|
-
// 500MB
|
|
76
|
-
},
|
|
77
|
-
[f.DOCUMENT]: {
|
|
78
|
-
allowedExtensions: ["pdf", "doc", "docx", "txt", "rtf"],
|
|
79
|
-
sizeLimit: 10485760
|
|
80
|
-
// 10MB
|
|
81
|
-
},
|
|
82
|
-
[f.OTHER]: {
|
|
83
|
-
allowedExtensions: ["zip", "rar", "tar", "gz"],
|
|
84
|
-
sizeLimit: 5242880
|
|
85
|
-
// 5MB
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
return p(p({}, i), s);
|
|
89
|
-
}
|
|
90
|
-
function T(s) {
|
|
91
|
-
return g(this, null, function* () {
|
|
92
|
-
const { path: i, file: e, config: t, type: a } = s;
|
|
93
|
-
if (!i || typeof i != "string")
|
|
94
|
-
return {
|
|
95
|
-
success: !1,
|
|
96
|
-
message: "Invalid path provided",
|
|
97
|
-
result: ""
|
|
98
|
-
};
|
|
99
|
-
if (!e || typeof e != "object")
|
|
100
|
-
return {
|
|
101
|
-
success: !1,
|
|
102
|
-
message: "Invalid file provided",
|
|
103
|
-
result: ""
|
|
104
|
-
};
|
|
105
|
-
if (t) {
|
|
106
|
-
const n = [f.IMAGE, f.VIDEO, f.DOCUMENT, f.OTHER];
|
|
107
|
-
for (const r of n) {
|
|
108
|
-
if (!t[r] || !Array.isArray(t[r].allowedExtensions) || t[r].allowedExtensions.length === 0)
|
|
109
|
-
return {
|
|
110
|
-
success: !1,
|
|
111
|
-
message: `Invalid config for ${r.toLowerCase()} files`,
|
|
112
|
-
result: ""
|
|
113
|
-
};
|
|
114
|
-
if (typeof t[r].sizeLimit != "number" || t[r].sizeLimit <= 0)
|
|
115
|
-
return {
|
|
116
|
-
success: !1,
|
|
117
|
-
message: `Invalid size limit for ${r.toLowerCase()} files`,
|
|
118
|
-
result: ""
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
try {
|
|
123
|
-
const n = yield (yield e).file, { filename: r, createReadStream: l } = n;
|
|
124
|
-
if (t) {
|
|
125
|
-
const m = l(), d = yield h(m), w = M(
|
|
126
|
-
{ filename: r, fileSize: d },
|
|
127
|
-
t,
|
|
128
|
-
a
|
|
129
|
-
);
|
|
130
|
-
if (!w.isValid)
|
|
131
|
-
return {
|
|
132
|
-
success: !1,
|
|
133
|
-
message: w.error || "File validation failed",
|
|
134
|
-
result: ""
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
const o = S(i);
|
|
138
|
-
L(o) || C(o, { recursive: !0 });
|
|
139
|
-
const c = l(), u = I(i);
|
|
140
|
-
return c.pipe(u), yield new Promise((m, d) => {
|
|
141
|
-
u.on("finish", () => m()), u.on("error", d), c.on("error", d);
|
|
142
|
-
}), {
|
|
143
|
-
success: !0,
|
|
144
|
-
message: "File uploaded successfully",
|
|
145
|
-
result: i
|
|
146
|
-
};
|
|
147
|
-
} catch (n) {
|
|
148
|
-
return {
|
|
149
|
-
success: !1,
|
|
150
|
-
message: n instanceof Error ? n.message : "File upload failed",
|
|
151
|
-
result: ""
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
});
|
|
155
|
-
}
|
|
1
|
+
import "../fs/fs.util.js";
|
|
2
|
+
import "../../../path.constant-CvSr0Rrx.js";
|
|
3
|
+
import "../path/path.util.js";
|
|
4
|
+
import { c as i, u as m } from "../../../upload.util-D4aUdmPo.js";
|
|
156
5
|
export {
|
|
157
|
-
|
|
158
|
-
|
|
6
|
+
i as createUploadConfig,
|
|
7
|
+
m as upload
|
|
159
8
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var N=Object.defineProperty;var
|
|
1
|
+
"use strict";var N=Object.defineProperty;var $=Object.getOwnPropertySymbols;var R=Object.prototype.hasOwnProperty,x=Object.prototype.propertyIsEnumerable;var d=(t,e,n)=>e in t?N(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,h=(t,e)=>{for(var n in e||(e={}))R.call(e,n)&&d(t,n,e[n]);if($)for(var n of $(e))x.call(e,n)&&d(t,n,e[n]);return t};var T=(t,e,n)=>d(t,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const q=require("@apollo/client/core/core.cjs"),m=require("@apollo/client/link/core/core.cjs"),G=require("@apollo/client/link/error/error.cjs"),P=require("@apollo/client/link/http/http.cjs"),S=require("@apollo/client/link/remove-typename/remove-typename.cjs"),H=require("@apollo/client/link/subscriptions/subscriptions.cjs"),I=require("@apollo/client/utilities/utilities.cjs"),F=require("graphql-ws"),k=require("react"),M=require("../apollo-error/apollo-error.util.cjs"),c=require("../log/log.util.cjs"),U=require("react-hot-toast"),v=require("./apollo-client.constant.cjs");class C extends m.ApolloLink{constructor(){super(...arguments);T(this,"count",0)}request(n,r){const g=Date.now();return this.count+=1,r(n).map(_=>{const p=Date.now()-g,a=n.operationName||"Unnamed";return c.log.info(`[Apollo] #${this.count}: ${a} (${p}ms)`),_})}}function D(t){const{uri:e,wsUrl:n,customLinks:r}=t,g=new C,_=G.onError(({graphQLErrors:o,networkError:i,protocolErrors:s,operation:f})=>{var w,y;const j=(f==null?void 0:f.operationName)||"Unknown";if(o&&o.forEach(({message:l,locations:u,path:L})=>{c.log.error(`[GraphQL error] ${j}: ${l}, Location: ${JSON.stringify(u,null,4)}, Path: ${L}`)}),s&&s.forEach(({message:l,extensions:u})=>{c.log.error(`[Protocol error]: ${l}, Extensions: ${JSON.stringify(u,null,4)}`)}),i&&c.log.error(`[Network error]: ${i}`),o||s||i){const l=((w=o==null?void 0:o[0])==null?void 0:w.message)||((y=s==null?void 0:s[0])==null?void 0:y.message)||(i==null?void 0:i.message)||"Unexpected error",u=new q.ApolloError({graphQLErrors:o||[],protocolErrors:s||[],clientErrors:[],networkError:i||null,errorMessage:l,extraInfo:{operation:f}});typeof window!="undefined"&&U.toast.error(L=>k.createElement(k.Fragment,null,l," ",k.createElement("button",{type:"button",className:"text-blue-500 hover:text-blue-700",onClick:()=>{setTimeout(()=>{M.showGlobalApolloError(u)},0),U.toast.dismiss(L.id)}},"Show Details")))}}),p=S.removeTypenameFromVariables();e||c.log.warn(`[Apollo] No GraphQL URI provided — using "${v.GRAPHQL_URI_DEFAULT}" as default`);const a=new P.HttpLink({uri:e!=null?e:v.GRAPHQL_URI_DEFAULT,credentials:"include"}),A=n?new H.GraphQLWsLink(F.createClient({url:n})):m.ApolloLink.empty(),b=A instanceof m.ApolloLink?m.split(({query:o})=>{const i=I.getMainDefinition(o);return i.kind==="OperationDefinition"&&i.operation==="subscription"},A,a):a;return b===a&&n&&c.log.warn("[Apollo] WS URL is set, but subscriptions fallback to HTTP. Check your wsLink config."),[g,_,p,...r!=null?r:[],b]}function O(t={}){const e=m.from(D(t));return new q.ApolloClient(h({link:e,cache:new q.InMemoryCache},t))}exports.DevLoggerLink=C;exports.createApolloLinks=D;exports.getClient=O;
|
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
var C = Object.defineProperty;
|
|
2
|
-
var
|
|
2
|
+
var h = Object.getOwnPropertySymbols;
|
|
3
3
|
var T = Object.prototype.hasOwnProperty, G = Object.prototype.propertyIsEnumerable;
|
|
4
|
-
var
|
|
4
|
+
var w = (t, e, n) => e in t ? C(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n, N = (t, e) => {
|
|
5
5
|
for (var n in e || (e = {}))
|
|
6
|
-
T.call(e, n) &&
|
|
7
|
-
if (
|
|
8
|
-
for (var n of
|
|
9
|
-
G.call(e, n) &&
|
|
6
|
+
T.call(e, n) && w(t, n, e[n]);
|
|
7
|
+
if (h)
|
|
8
|
+
for (var n of h(e))
|
|
9
|
+
G.call(e, n) && w(t, n, e[n]);
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
var U = (t, e, n) =>
|
|
12
|
+
var U = (t, e, n) => w(t, typeof e != "symbol" ? e + "" : e, n);
|
|
13
13
|
import { ApolloError as R, ApolloClient as I, InMemoryCache as P } from "@apollo/client/core/core.cjs";
|
|
14
|
-
import { ApolloLink as
|
|
14
|
+
import { ApolloLink as $, split as S, from as _ } from "@apollo/client/link/core/core.cjs";
|
|
15
15
|
import { onError as F } from "@apollo/client/link/error/error.cjs";
|
|
16
16
|
import { HttpLink as H } from "@apollo/client/link/http/http.cjs";
|
|
17
17
|
import { removeTypenameFromVariables as M } from "@apollo/client/link/remove-typename/remove-typename.cjs";
|
|
18
18
|
import { GraphQLWsLink as O } from "@apollo/client/link/subscriptions/subscriptions.cjs";
|
|
19
19
|
import { getMainDefinition as J } from "@apollo/client/utilities/utilities.cjs";
|
|
20
20
|
import { createClient as W } from "graphql-ws";
|
|
21
|
-
import
|
|
21
|
+
import k from "react";
|
|
22
22
|
import { showGlobalApolloError as q } from "../apollo-error/apollo-error.util.js";
|
|
23
23
|
import { log as l } from "../log/log.util.js";
|
|
24
24
|
import { toast as x } from "react-hot-toast";
|
|
25
25
|
import { GRAPHQL_URI_DEFAULT as D } from "./apollo-client.constant.js";
|
|
26
|
-
class V extends
|
|
26
|
+
class V extends $ {
|
|
27
27
|
constructor() {
|
|
28
28
|
super(...arguments);
|
|
29
29
|
U(this, "count", 0);
|
|
@@ -31,25 +31,25 @@ class V extends b {
|
|
|
31
31
|
request(n, a) {
|
|
32
32
|
const u = Date.now();
|
|
33
33
|
return this.count += 1, a(n).map((p) => {
|
|
34
|
-
const d = Date.now() - u,
|
|
35
|
-
return l.info(`[Apollo] #${this.count}: ${
|
|
34
|
+
const d = Date.now() - u, f = n.operationName || "Unnamed";
|
|
35
|
+
return l.info(`[Apollo] #${this.count}: ${f} (${d}ms)`), p;
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
function j(t) {
|
|
40
40
|
const { uri: e, wsUrl: n, customLinks: a } = t, u = new V(), p = F(({ graphQLErrors: o, networkError: i, protocolErrors: m, operation: r }) => {
|
|
41
|
-
var A,
|
|
41
|
+
var A, y;
|
|
42
42
|
const v = (r == null ? void 0 : r.operationName) || "Unknown";
|
|
43
|
-
if (o && o.forEach(({ message: s, locations:
|
|
43
|
+
if (o && o.forEach(({ message: s, locations: c, path: L }) => {
|
|
44
44
|
l.error(
|
|
45
|
-
`[GraphQL error] ${v}: ${s}, Location: ${JSON.stringify(
|
|
45
|
+
`[GraphQL error] ${v}: ${s}, Location: ${JSON.stringify(c, null, 4)}, Path: ${L}`
|
|
46
46
|
);
|
|
47
|
-
}), m && m.forEach(({ message: s, extensions:
|
|
47
|
+
}), m && m.forEach(({ message: s, extensions: c }) => {
|
|
48
48
|
l.error(
|
|
49
|
-
`[Protocol error]: ${s}, Extensions: ${JSON.stringify(
|
|
49
|
+
`[Protocol error]: ${s}, Extensions: ${JSON.stringify(c, null, 4)}`
|
|
50
50
|
);
|
|
51
51
|
}), i && l.error(`[Network error]: ${i}`), o || m || i) {
|
|
52
|
-
const s = ((A = o == null ? void 0 : o[0]) == null ? void 0 : A.message) || ((
|
|
52
|
+
const s = ((A = o == null ? void 0 : o[0]) == null ? void 0 : A.message) || ((y = m == null ? void 0 : m[0]) == null ? void 0 : y.message) || (i == null ? void 0 : i.message) || "Unexpected error", c = new R({
|
|
53
53
|
graphQLErrors: o || [],
|
|
54
54
|
protocolErrors: m || [],
|
|
55
55
|
clientErrors: [],
|
|
@@ -59,14 +59,14 @@ function j(t) {
|
|
|
59
59
|
operation: r
|
|
60
60
|
}
|
|
61
61
|
});
|
|
62
|
-
x.error((L) => /* @__PURE__ */
|
|
62
|
+
typeof window != "undefined" && x.error((L) => /* @__PURE__ */ k.createElement(k.Fragment, null, s, " ", /* @__PURE__ */ k.createElement(
|
|
63
63
|
"button",
|
|
64
64
|
{
|
|
65
65
|
type: "button",
|
|
66
66
|
className: "text-blue-500 hover:text-blue-700",
|
|
67
67
|
onClick: () => {
|
|
68
68
|
setTimeout(() => {
|
|
69
|
-
q(
|
|
69
|
+
q(c);
|
|
70
70
|
}, 0), x.dismiss(L.id);
|
|
71
71
|
}
|
|
72
72
|
},
|
|
@@ -75,18 +75,18 @@ function j(t) {
|
|
|
75
75
|
}
|
|
76
76
|
}), d = M();
|
|
77
77
|
e || l.warn(`[Apollo] No GraphQL URI provided — using "${D}" as default`);
|
|
78
|
-
const
|
|
78
|
+
const f = new H({
|
|
79
79
|
uri: e != null ? e : D,
|
|
80
80
|
credentials: "include"
|
|
81
|
-
}),
|
|
81
|
+
}), b = n ? new O(W({ url: n })) : $.empty(), g = b instanceof $ ? S(
|
|
82
82
|
({ query: o }) => {
|
|
83
83
|
const i = J(o);
|
|
84
84
|
return i.kind === "OperationDefinition" && i.operation === "subscription";
|
|
85
85
|
},
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
) :
|
|
89
|
-
return
|
|
86
|
+
b,
|
|
87
|
+
f
|
|
88
|
+
) : f;
|
|
89
|
+
return g === f && n && l.warn("[Apollo] WS URL is set, but subscriptions fallback to HTTP. Check your wsLink config."), [
|
|
90
90
|
u,
|
|
91
91
|
// 🪵 custom logger
|
|
92
92
|
p,
|
|
@@ -95,7 +95,7 @@ function j(t) {
|
|
|
95
95
|
// 🧼 cleans up __typename
|
|
96
96
|
...a != null ? a : [],
|
|
97
97
|
// 🔗 custom links
|
|
98
|
-
|
|
98
|
+
g
|
|
99
99
|
// 📡 HTTP vs WS routing
|
|
100
100
|
];
|
|
101
101
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var z=Object.defineProperty;var x=Object.getOwnPropertySymbols;var I=Object.prototype.hasOwnProperty,C=Object.prototype.propertyIsEnumerable;var v=(e,i,s)=>i in e?z(e,i,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[i]=s,g=(e,i)=>{for(var s in i||(i={}))I.call(i,s)&&v(e,s,i[s]);if(x)for(var s of x(i))C.call(i,s)&&v(e,s,i[s]);return e};var w=(e,i,s)=>new Promise((t,l)=>{var o=n=>{try{f(s.next(n))}catch(c){l(c)}},r=n=>{try{f(s.throw(n))}catch(c){l(c)}},f=n=>n.done?t(n.value):Promise.resolve(n.value).then(o,r);f((s=s.apply(e,i)).next())});const E=require("./src/node/fs/fs.util.cjs");require("./path.constant-CWtb99gS.cjs");const O=require("./src/node/path/path.util.cjs");var a=(e=>(e.IMAGE="IMAGE",e.VIDEO="VIDEO",e.DOCUMENT="DOCUMENT",e.OTHER="OTHER",e))(a||{});function L(e){return w(this,null,function*(){return new Promise((i,s)=>{let t=0;e.on("data",l=>{t+=l.length}),e.on("end",()=>i(t)),e.on("error",s)})})}function M(e,i){const s=e.lastIndexOf(".");if(s===-1)return!1;const t=e.substring(s+1).toLowerCase();return i.includes(t)}function y(e,i,s){const{filename:t,fileSize:l}=e,o=i[s],{allowedExtensions:r,sizeLimit:f}=o;if(!M(t,r))return{isValid:!1,error:`File extension not allowed for ${s.toLowerCase()} files. Allowed extensions: ${r.join(", ")}`};if(l!==void 0&&l>f){const n=Math.round(f/1048576);return{isValid:!1,error:`File size exceeds limit for ${s.toLowerCase()} files. Maximum size: ${n}MB`}}return{isValid:!0}}function h(e){const i={[a.IMAGE]:{allowedExtensions:["jpg","jpeg","png","gif","webp","svg"],sizeLimit:5242880},[a.VIDEO]:{allowedExtensions:["mp4","avi","mov","wmv","flv","webm"],sizeLimit:524288e3},[a.DOCUMENT]:{allowedExtensions:["pdf","doc","docx","txt","rtf"],sizeLimit:10485760},[a.OTHER]:{allowedExtensions:["zip","rar","tar","gz"],sizeLimit:5242880}};return g(g({},i),e)}function D(e){return w(this,null,function*(){const{path:i,file:s,config:t,type:l}=e;if(!i||typeof i!="string")return{success:!1,message:"Invalid path provided",result:""};if(!s||typeof s!="object")return{success:!1,message:"Invalid file provided",result:""};if(t){const o=[a.IMAGE,a.VIDEO,a.DOCUMENT,a.OTHER];for(const r of o){if(!t[r]||!Array.isArray(t[r].allowedExtensions)||t[r].allowedExtensions.length===0)return{success:!1,message:`Invalid config for ${r.toLowerCase()} files`,result:""};if(typeof t[r].sizeLimit!="number"||t[r].sizeLimit<=0)return{success:!1,message:`Invalid size limit for ${r.toLowerCase()} files`,result:""}}}try{const o=yield(yield s).file,{filename:r,createReadStream:f}=o;if(t){const m=f(),u=yield L(m),p=y({filename:r,fileSize:u},t,l);if(!p.isValid)return{success:!1,message:p.error||"File validation failed",result:""}}const n=O.dirname(i);E.pathExistsSync(n)||E.mkdirSync(n,{recursive:!0});const c=f(),d=E.createWriteStream(i);return c.pipe(d),yield new Promise((m,u)=>{d.on("finish",()=>m()),d.on("error",u),c.on("error",u)}),{success:!0,message:"File uploaded successfully",result:i}}catch(o){return{success:!1,message:o instanceof Error?o.message:"File upload failed",result:""}}})}exports.E_UploadType=a;exports.createUploadConfig=h;exports.upload=D;
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
var v = Object.defineProperty;
|
|
2
|
+
var p = Object.getOwnPropertySymbols;
|
|
3
|
+
var z = Object.prototype.hasOwnProperty, I = Object.prototype.propertyIsEnumerable;
|
|
4
|
+
var x = (e, i, s) => i in e ? v(e, i, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[i] = s, g = (e, i) => {
|
|
5
|
+
for (var s in i || (i = {}))
|
|
6
|
+
z.call(i, s) && x(e, s, i[s]);
|
|
7
|
+
if (p)
|
|
8
|
+
for (var s of p(i))
|
|
9
|
+
I.call(i, s) && x(e, s, i[s]);
|
|
10
|
+
return e;
|
|
11
|
+
};
|
|
12
|
+
var w = (e, i, s) => new Promise((t, a) => {
|
|
13
|
+
var o = (n) => {
|
|
14
|
+
try {
|
|
15
|
+
l(s.next(n));
|
|
16
|
+
} catch (c) {
|
|
17
|
+
a(c);
|
|
18
|
+
}
|
|
19
|
+
}, r = (n) => {
|
|
20
|
+
try {
|
|
21
|
+
l(s.throw(n));
|
|
22
|
+
} catch (c) {
|
|
23
|
+
a(c);
|
|
24
|
+
}
|
|
25
|
+
}, l = (n) => n.done ? t(n.value) : Promise.resolve(n.value).then(o, r);
|
|
26
|
+
l((s = s.apply(e, i)).next());
|
|
27
|
+
});
|
|
28
|
+
import { pathExistsSync as O, mkdirSync as C, createWriteStream as L } from "./src/node/fs/fs.util.js";
|
|
29
|
+
import "./path.constant-CvSr0Rrx.js";
|
|
30
|
+
import { dirname as M } from "./src/node/path/path.util.js";
|
|
31
|
+
var f = /* @__PURE__ */ ((e) => (e.IMAGE = "IMAGE", e.VIDEO = "VIDEO", e.DOCUMENT = "DOCUMENT", e.OTHER = "OTHER", e))(f || {});
|
|
32
|
+
function y(e) {
|
|
33
|
+
return w(this, null, function* () {
|
|
34
|
+
return new Promise((i, s) => {
|
|
35
|
+
let t = 0;
|
|
36
|
+
e.on("data", (a) => {
|
|
37
|
+
t += a.length;
|
|
38
|
+
}), e.on("end", () => i(t)), e.on("error", s);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
function D(e, i) {
|
|
43
|
+
const s = e.lastIndexOf(".");
|
|
44
|
+
if (s === -1)
|
|
45
|
+
return !1;
|
|
46
|
+
const t = e.substring(s + 1).toLowerCase();
|
|
47
|
+
return i.includes(t);
|
|
48
|
+
}
|
|
49
|
+
function S(e, i, s) {
|
|
50
|
+
const { filename: t, fileSize: a } = e, o = i[s], { allowedExtensions: r, sizeLimit: l } = o;
|
|
51
|
+
if (!D(t, r))
|
|
52
|
+
return {
|
|
53
|
+
isValid: !1,
|
|
54
|
+
error: `File extension not allowed for ${s.toLowerCase()} files. Allowed extensions: ${r.join(", ")}`
|
|
55
|
+
};
|
|
56
|
+
if (a !== void 0 && a > l) {
|
|
57
|
+
const n = Math.round(l / 1048576);
|
|
58
|
+
return {
|
|
59
|
+
isValid: !1,
|
|
60
|
+
error: `File size exceeds limit for ${s.toLowerCase()} files. Maximum size: ${n}MB`
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
return { isValid: !0 };
|
|
64
|
+
}
|
|
65
|
+
function R(e) {
|
|
66
|
+
const i = {
|
|
67
|
+
[f.IMAGE]: {
|
|
68
|
+
allowedExtensions: ["jpg", "jpeg", "png", "gif", "webp", "svg"],
|
|
69
|
+
sizeLimit: 5242880
|
|
70
|
+
// 5MB
|
|
71
|
+
},
|
|
72
|
+
[f.VIDEO]: {
|
|
73
|
+
allowedExtensions: ["mp4", "avi", "mov", "wmv", "flv", "webm"],
|
|
74
|
+
sizeLimit: 524288e3
|
|
75
|
+
// 500MB
|
|
76
|
+
},
|
|
77
|
+
[f.DOCUMENT]: {
|
|
78
|
+
allowedExtensions: ["pdf", "doc", "docx", "txt", "rtf"],
|
|
79
|
+
sizeLimit: 10485760
|
|
80
|
+
// 10MB
|
|
81
|
+
},
|
|
82
|
+
[f.OTHER]: {
|
|
83
|
+
allowedExtensions: ["zip", "rar", "tar", "gz"],
|
|
84
|
+
sizeLimit: 5242880
|
|
85
|
+
// 5MB
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
return g(g({}, i), e);
|
|
89
|
+
}
|
|
90
|
+
function $(e) {
|
|
91
|
+
return w(this, null, function* () {
|
|
92
|
+
const { path: i, file: s, config: t, type: a } = e;
|
|
93
|
+
if (!i || typeof i != "string")
|
|
94
|
+
return {
|
|
95
|
+
success: !1,
|
|
96
|
+
message: "Invalid path provided",
|
|
97
|
+
result: ""
|
|
98
|
+
};
|
|
99
|
+
if (!s || typeof s != "object")
|
|
100
|
+
return {
|
|
101
|
+
success: !1,
|
|
102
|
+
message: "Invalid file provided",
|
|
103
|
+
result: ""
|
|
104
|
+
};
|
|
105
|
+
if (t) {
|
|
106
|
+
const o = [f.IMAGE, f.VIDEO, f.DOCUMENT, f.OTHER];
|
|
107
|
+
for (const r of o) {
|
|
108
|
+
if (!t[r] || !Array.isArray(t[r].allowedExtensions) || t[r].allowedExtensions.length === 0)
|
|
109
|
+
return {
|
|
110
|
+
success: !1,
|
|
111
|
+
message: `Invalid config for ${r.toLowerCase()} files`,
|
|
112
|
+
result: ""
|
|
113
|
+
};
|
|
114
|
+
if (typeof t[r].sizeLimit != "number" || t[r].sizeLimit <= 0)
|
|
115
|
+
return {
|
|
116
|
+
success: !1,
|
|
117
|
+
message: `Invalid size limit for ${r.toLowerCase()} files`,
|
|
118
|
+
result: ""
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
try {
|
|
123
|
+
const o = yield (yield s).file, { filename: r, createReadStream: l } = o;
|
|
124
|
+
if (t) {
|
|
125
|
+
const m = l(), u = yield y(m), E = S(
|
|
126
|
+
{ filename: r, fileSize: u },
|
|
127
|
+
t,
|
|
128
|
+
a
|
|
129
|
+
);
|
|
130
|
+
if (!E.isValid)
|
|
131
|
+
return {
|
|
132
|
+
success: !1,
|
|
133
|
+
message: E.error || "File validation failed",
|
|
134
|
+
result: ""
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
const n = M(i);
|
|
138
|
+
O(n) || C(n, { recursive: !0 });
|
|
139
|
+
const c = l(), d = L(i);
|
|
140
|
+
return c.pipe(d), yield new Promise((m, u) => {
|
|
141
|
+
d.on("finish", () => m()), d.on("error", u), c.on("error", u);
|
|
142
|
+
}), {
|
|
143
|
+
success: !0,
|
|
144
|
+
message: "File uploaded successfully",
|
|
145
|
+
result: i
|
|
146
|
+
};
|
|
147
|
+
} catch (o) {
|
|
148
|
+
return {
|
|
149
|
+
success: !1,
|
|
150
|
+
message: o instanceof Error ? o.message : "File upload failed",
|
|
151
|
+
result: ""
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
export {
|
|
157
|
+
f as E,
|
|
158
|
+
R as c,
|
|
159
|
+
$ as u
|
|
160
|
+
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cyberskill/shared",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.204.0",
|
|
5
5
|
"description": "CyberSkill Shared",
|
|
6
6
|
"author": "Stephen Cheng",
|
|
7
7
|
"license": "MIT",
|
|
@@ -211,6 +211,7 @@
|
|
|
211
211
|
"@apollo/server": "4.12.2",
|
|
212
212
|
"@dotenvx/dotenvx": "1.45.1",
|
|
213
213
|
"@eddeee888/gcg-typescript-resolver-files": "0.12.1",
|
|
214
|
+
"@eslint-react/eslint-plugin": "1.52.2",
|
|
214
215
|
"@graphql-codegen/cli": "5.0.7",
|
|
215
216
|
"@graphql-codegen/client-preset": "4.8.3",
|
|
216
217
|
"@nestjs/common": "11.1.3",
|
|
@@ -227,6 +228,9 @@
|
|
|
227
228
|
"crypto-js": "4.2.0",
|
|
228
229
|
"date-fns": "4.1.0",
|
|
229
230
|
"envalid": "8.0.0",
|
|
231
|
+
"eslint-plugin-format": "1.0.1",
|
|
232
|
+
"eslint-plugin-react-hooks": "5.2.0",
|
|
233
|
+
"eslint-plugin-react-refresh": "0.4.20",
|
|
230
234
|
"express": "4.21.2",
|
|
231
235
|
"express-session": "1.18.1",
|
|
232
236
|
"express-useragent": "1.0.15",
|
|
@@ -261,7 +265,6 @@
|
|
|
261
265
|
"devDependencies": {
|
|
262
266
|
"@commitlint/cli": "19.8.1",
|
|
263
267
|
"@commitlint/config-conventional": "19.8.1",
|
|
264
|
-
"@eslint-react/eslint-plugin": "1.52.2",
|
|
265
268
|
"@eslint/config-inspector": "1.1.0",
|
|
266
269
|
"@microsoft/api-extractor": "7.52.8",
|
|
267
270
|
"@next/eslint-plugin-next": "15.3.4",
|
|
@@ -278,7 +281,7 @@
|
|
|
278
281
|
"@types/fs-extra": "11.0.4",
|
|
279
282
|
"@types/graphql-upload": "17.0.0",
|
|
280
283
|
"@types/migrate-mongo": "10.0.5",
|
|
281
|
-
"@types/node": "24.0.
|
|
284
|
+
"@types/node": "24.0.8",
|
|
282
285
|
"@types/node-persist": "3.1.8",
|
|
283
286
|
"@types/react": "19.1.8",
|
|
284
287
|
"@types/react-dom": "19.1.6",
|
|
@@ -289,9 +292,6 @@
|
|
|
289
292
|
"@vitest/browser": "3.2.4",
|
|
290
293
|
"eslint": "9.30.0",
|
|
291
294
|
"eslint-config-next": "15.3.4",
|
|
292
|
-
"eslint-plugin-format": "1.0.1",
|
|
293
|
-
"eslint-plugin-react-hooks": "5.2.0",
|
|
294
|
-
"eslint-plugin-react-refresh": "0.4.20",
|
|
295
295
|
"glob": "11.0.3",
|
|
296
296
|
"lint-staged": "16.1.2",
|
|
297
297
|
"node-modules-inspector": "1.0.0",
|