@cripty2001/utils 0.0.48 → 0.0.50
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.
|
@@ -14,5 +14,7 @@ export declare class ClientValidationError extends ClientError {
|
|
|
14
14
|
export declare class Client {
|
|
15
15
|
private url;
|
|
16
16
|
constructor(url: string);
|
|
17
|
+
private authToken;
|
|
18
|
+
setAuthToken(token: string | null): void;
|
|
17
19
|
exec<I extends AppserverData, O extends AppserverData>(action: string, input: I): Promise<O>;
|
|
18
20
|
}
|
package/dist/Appserver/client.js
CHANGED
|
@@ -31,17 +31,26 @@ class Client {
|
|
|
31
31
|
constructor(url) {
|
|
32
32
|
this.url = url;
|
|
33
33
|
}
|
|
34
|
+
authToken = null;
|
|
35
|
+
setAuthToken(token) {
|
|
36
|
+
this.authToken = token;
|
|
37
|
+
}
|
|
34
38
|
async exec(action, input) {
|
|
35
39
|
const res = await fetch(`${this.url}/exec/${action}`, {
|
|
36
40
|
method: "POST",
|
|
37
41
|
headers: {
|
|
38
42
|
"Content-Type": "application/vnd.msgpack",
|
|
43
|
+
...(this.authToken !== null ? { "Authorization": `Bearer ${this.authToken}` } : {}),
|
|
39
44
|
},
|
|
40
45
|
body: new Blob([new Uint8Array((0, msgpack_1.encode)(input))], { type: 'application/msgpack' }),
|
|
41
46
|
});
|
|
42
47
|
const decoded = (0, msgpack_1.decode)(await res.arrayBuffer());
|
|
43
48
|
let responseData;
|
|
44
49
|
switch (res.status) {
|
|
50
|
+
case 401:
|
|
51
|
+
case 403:
|
|
52
|
+
this.authToken = null;
|
|
53
|
+
throw new ClientError("Permission denied");
|
|
45
54
|
case 200:
|
|
46
55
|
responseData = decoded;
|
|
47
56
|
return responseData;
|
|
@@ -25,10 +25,48 @@ function LoggerReactDisplay() {
|
|
|
25
25
|
}
|
|
26
26
|
};
|
|
27
27
|
const relTs = (0, react_whispr_1.useRelTime)();
|
|
28
|
-
return ((0, jsx_runtime_1.jsx)("div", {
|
|
28
|
+
return ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
29
|
+
position: 'fixed',
|
|
30
|
+
bottom: 0,
|
|
31
|
+
right: 0,
|
|
32
|
+
width: '100%',
|
|
33
|
+
zIndex: 50,
|
|
34
|
+
padding: '1rem',
|
|
35
|
+
borderRadius: '0.5rem',
|
|
36
|
+
}, children: (0, jsx_runtime_1.jsx)("div", { style: {
|
|
37
|
+
display: 'flex',
|
|
38
|
+
flexDirection: 'column',
|
|
39
|
+
gap: '0.5rem',
|
|
40
|
+
alignItems: 'center',
|
|
41
|
+
width: '100%',
|
|
42
|
+
justifyContent: 'center',
|
|
43
|
+
}, children: [...messages]
|
|
29
44
|
.reverse()
|
|
30
45
|
.slice(0, 3)
|
|
31
|
-
.map((message) => ((0, jsx_runtime_1.jsxs)("div", {
|
|
46
|
+
.map((message) => ((0, jsx_runtime_1.jsxs)("div", { style: {
|
|
47
|
+
padding: '0.5rem',
|
|
48
|
+
borderRadius: '0.375rem',
|
|
49
|
+
boxShadow: '0 1px 3px rgba(0,0,0,0.2)',
|
|
50
|
+
color: '#fff',
|
|
51
|
+
width: '100%',
|
|
52
|
+
maxWidth: '65ch',
|
|
53
|
+
cursor: 'pointer',
|
|
32
54
|
backgroundColor: getColor(message.severity)
|
|
33
|
-
},
|
|
55
|
+
}, onClick: message.dismiss, children: [(0, jsx_runtime_1.jsxs)("div", { style: {
|
|
56
|
+
display: 'flex',
|
|
57
|
+
justifyContent: 'space-between',
|
|
58
|
+
alignItems: 'center',
|
|
59
|
+
}, children: [(0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsxs)("strong", { children: ["[", relTs(message.date), "] "] }), message.context && (0, jsx_runtime_1.jsxs)("span", { style: {
|
|
60
|
+
marginLeft: '0.5rem',
|
|
61
|
+
}, children: [" - ", message.context, " "] })] }), (0, jsx_runtime_1.jsx)("button", { onClick: message.dismiss, style: {
|
|
62
|
+
marginLeft: '1rem',
|
|
63
|
+
color: '#fff',
|
|
64
|
+
fontWeight: 'bold',
|
|
65
|
+
background: 'none',
|
|
66
|
+
border: 'none',
|
|
67
|
+
cursor: 'pointer',
|
|
68
|
+
padding: 0,
|
|
69
|
+
}, children: (0, jsx_runtime_1.jsx)(lucide_react_1.X, { size: 16 }) })] }), (0, jsx_runtime_1.jsx)("div", { style: {
|
|
70
|
+
marginTop: '0.25rem',
|
|
71
|
+
}, children: message.message })] }, message.id))) }) }));
|
|
34
72
|
}
|
package/package.json
CHANGED