@arkyn/server 3.0.1-beta.159 → 3.0.1-beta.166
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/index.js +1026 -1262
- package/dist/modules/http/api/_logRequest.js +55 -68
- package/dist/modules/http/api/_makeRequest.js +69 -68
- package/dist/modules/http/api/deleteRequest.js +12 -12
- package/dist/modules/http/api/getRequest.js +11 -11
- package/dist/modules/http/api/patchRequest.js +11 -11
- package/dist/modules/http/api/postRequest.js +11 -11
- package/dist/modules/http/api/putRequest.js +11 -11
- package/dist/modules/http/badResponses/_badResponse.js +62 -58
- package/dist/modules/http/badResponses/badGateway.js +22 -28
- package/dist/modules/http/badResponses/badRequest.js +22 -28
- package/dist/modules/http/badResponses/conflict.js +22 -28
- package/dist/modules/http/badResponses/forbidden.js +22 -28
- package/dist/modules/http/badResponses/notFound.js +22 -28
- package/dist/modules/http/badResponses/notImplemented.js +22 -28
- package/dist/modules/http/badResponses/serverError.js +22 -28
- package/dist/modules/http/badResponses/unauthorized.js +22 -28
- package/dist/modules/http/badResponses/unprocessableEntity.js +27 -35
- package/dist/modules/http/successResponses/_successResponse.js +61 -68
- package/dist/modules/http/successResponses/created.js +22 -28
- package/dist/modules/http/successResponses/found.js +22 -28
- package/dist/modules/http/successResponses/noContent.js +16 -20
- package/dist/modules/http/successResponses/success.js +22 -28
- package/dist/modules/http/successResponses/updated.js +22 -28
- package/dist/modules/index.js +33 -67
- package/dist/modules/services/apiService.js +108 -128
- package/dist/modules/services/debugService.js +35 -65
- package/dist/modules/services/logMapperService.js +28 -51
- package/dist/modules/services/logService.js +20 -30
- package/dist/modules/utilities/decodeRequestBody.js +19 -21
- package/dist/modules/utilities/decodeRequestErrorMessage.js +5 -6
- package/dist/modules/utilities/errorHandler.js +36 -51
- package/dist/modules/utilities/flushDebugLogs.js +15 -19
- package/dist/modules/utilities/formAsyncParse.js +13 -18
- package/dist/modules/utilities/formParse.js +13 -18
- package/dist/modules/utilities/getScopedParams.js +8 -10
- package/dist/modules/utilities/schemaValidator.js +53 -104
- package/dist/modules/validations/validateCep.js +8 -8
- package/dist/modules/validations/validateCnpj.js +49 -26
- package/dist/modules/validations/validateCpf.js +22 -23
- package/dist/modules/validations/validateDate.js +25 -26
- package/dist/modules/validations/validateEmail.js +54 -53
- package/dist/modules/validations/validatePassword.js +11 -15
- package/dist/modules/validations/validatePhone.js +8 -8
- package/dist/modules/validations/validateRg.js +7 -7
- package/generate-version.ts +74 -0
- package/package.json +17 -9
|
@@ -1,21 +1,17 @@
|
|
|
1
|
-
import { SuccessResponse as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
};
|
|
16
|
-
return new Response(null, t);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
export {
|
|
20
|
-
o as NoContent
|
|
1
|
+
import { SuccessResponse as e } from "./_successResponse.js";
|
|
2
|
+
//#region src/http/successResponses/noContent.ts
|
|
3
|
+
var t = class extends e {
|
|
4
|
+
constructor(e) {
|
|
5
|
+
super(), this.name = "NoContent", this.status = 204, this.statusText = e, this.onDebug();
|
|
6
|
+
}
|
|
7
|
+
toResponse() {
|
|
8
|
+
let e = {
|
|
9
|
+
headers: { "Content-Type": "application/json" },
|
|
10
|
+
status: this.status,
|
|
11
|
+
statusText: this.statusText
|
|
12
|
+
};
|
|
13
|
+
return new Response(null, e);
|
|
14
|
+
}
|
|
21
15
|
};
|
|
16
|
+
//#endregion
|
|
17
|
+
export { t as NoContent };
|
|
@@ -1,30 +1,24 @@
|
|
|
1
1
|
import { SuccessResponse as e } from "./_successResponse.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
status: this.status,
|
|
23
|
-
statusText: this.statusText
|
|
24
|
-
};
|
|
25
|
-
return Response.json(this.body, s);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
export {
|
|
29
|
-
i as Success
|
|
2
|
+
//#region src/http/successResponses/success.ts
|
|
3
|
+
var t = class extends e {
|
|
4
|
+
constructor(e, t) {
|
|
5
|
+
super(), this.name = "Success", this.status = 200, this.statusText = e, this.body = t || void 0, this.onDebug();
|
|
6
|
+
}
|
|
7
|
+
toResponse() {
|
|
8
|
+
let e = {
|
|
9
|
+
headers: { "Content-Type": "application/json" },
|
|
10
|
+
status: this.status,
|
|
11
|
+
statusText: this.statusText
|
|
12
|
+
};
|
|
13
|
+
return new Response(JSON.stringify(this.body), e);
|
|
14
|
+
}
|
|
15
|
+
toJson() {
|
|
16
|
+
let e = {
|
|
17
|
+
status: this.status,
|
|
18
|
+
statusText: this.statusText
|
|
19
|
+
};
|
|
20
|
+
return Response.json(this.body, e);
|
|
21
|
+
}
|
|
30
22
|
};
|
|
23
|
+
//#endregion
|
|
24
|
+
export { t as Success };
|
|
@@ -1,30 +1,24 @@
|
|
|
1
1
|
import { SuccessResponse as e } from "./_successResponse.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
status: this.status,
|
|
23
|
-
statusText: this.statusText
|
|
24
|
-
};
|
|
25
|
-
return Response.json(this.body, s);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
export {
|
|
29
|
-
i as Updated
|
|
2
|
+
//#region src/http/successResponses/updated.ts
|
|
3
|
+
var t = class extends e {
|
|
4
|
+
constructor(e, t) {
|
|
5
|
+
super(), this.name = "Updated", this.status = 200, this.statusText = e, this.body = t || void 0, this.onDebug();
|
|
6
|
+
}
|
|
7
|
+
toResponse() {
|
|
8
|
+
let e = {
|
|
9
|
+
headers: { "Content-Type": "application/json" },
|
|
10
|
+
status: this.status,
|
|
11
|
+
statusText: this.statusText
|
|
12
|
+
};
|
|
13
|
+
return new Response(JSON.stringify(this.body), e);
|
|
14
|
+
}
|
|
15
|
+
toJson() {
|
|
16
|
+
let e = {
|
|
17
|
+
status: this.status,
|
|
18
|
+
statusText: this.statusText
|
|
19
|
+
};
|
|
20
|
+
return Response.json(this.body, e);
|
|
21
|
+
}
|
|
30
22
|
};
|
|
23
|
+
//#endregion
|
|
24
|
+
export { t as Updated };
|
package/dist/modules/index.js
CHANGED
|
@@ -1,68 +1,34 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import { DebugService as e } from "./services/debugService.js";
|
|
2
|
+
import { flushDebugLogs as t } from "./utilities/flushDebugLogs.js";
|
|
3
|
+
import { BadGateway as n } from "./http/badResponses/badGateway.js";
|
|
4
|
+
import { BadRequest as r } from "./http/badResponses/badRequest.js";
|
|
5
|
+
import { Conflict as i } from "./http/badResponses/conflict.js";
|
|
6
|
+
import { Forbidden as a } from "./http/badResponses/forbidden.js";
|
|
7
|
+
import { NotFound as o } from "./http/badResponses/notFound.js";
|
|
8
|
+
import { NotImplemented as s } from "./http/badResponses/notImplemented.js";
|
|
7
9
|
import { ServerError as c } from "./http/badResponses/serverError.js";
|
|
8
|
-
import { Unauthorized as
|
|
9
|
-
import { UnprocessableEntity as
|
|
10
|
-
import { Created as
|
|
11
|
-
import { Found as
|
|
12
|
-
import { NoContent as
|
|
13
|
-
import { Success as
|
|
14
|
-
import { Updated as
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
|
|
33
|
-
import { validateRg as lr } from "./validations/validateRg.js";
|
|
34
|
-
export {
|
|
35
|
-
N as ApiService,
|
|
36
|
-
e as BadGateway,
|
|
37
|
-
p as BadRequest,
|
|
38
|
-
f as Conflict,
|
|
39
|
-
P as Created,
|
|
40
|
-
w as DebugService,
|
|
41
|
-
x as Forbidden,
|
|
42
|
-
h as Found,
|
|
43
|
-
L as LogService,
|
|
44
|
-
E as NoContent,
|
|
45
|
-
i as NotFound,
|
|
46
|
-
l as NotImplemented,
|
|
47
|
-
Y as SchemaValidator,
|
|
48
|
-
c as ServerError,
|
|
49
|
-
q as Success,
|
|
50
|
-
u as Unauthorized,
|
|
51
|
-
S as UnprocessableEntity,
|
|
52
|
-
D as Updated,
|
|
53
|
-
z as decodeRequestBody,
|
|
54
|
-
H as decodeRequestErrorMessage,
|
|
55
|
-
M as errorHandler,
|
|
56
|
-
k as flushDebugLogs,
|
|
57
|
-
K as formAsyncParse,
|
|
58
|
-
Q as formParse,
|
|
59
|
-
W as getScopedParams,
|
|
60
|
-
_ as validateCep,
|
|
61
|
-
rr as validateCnpj,
|
|
62
|
-
er as validateCpf,
|
|
63
|
-
pr as validateDate,
|
|
64
|
-
fr as validateEmail,
|
|
65
|
-
xr as validatePassword,
|
|
66
|
-
ir as validatePhone,
|
|
67
|
-
lr as validateRg
|
|
68
|
-
};
|
|
10
|
+
import { Unauthorized as l } from "./http/badResponses/unauthorized.js";
|
|
11
|
+
import { UnprocessableEntity as u } from "./http/badResponses/unprocessableEntity.js";
|
|
12
|
+
import { Created as d } from "./http/successResponses/created.js";
|
|
13
|
+
import { Found as f } from "./http/successResponses/found.js";
|
|
14
|
+
import { NoContent as p } from "./http/successResponses/noContent.js";
|
|
15
|
+
import { Success as m } from "./http/successResponses/success.js";
|
|
16
|
+
import { Updated as h } from "./http/successResponses/updated.js";
|
|
17
|
+
import { LogService as g } from "./services/logService.js";
|
|
18
|
+
import { ApiService as _ } from "./services/apiService.js";
|
|
19
|
+
import { decodeRequestBody as v } from "./utilities/decodeRequestBody.js";
|
|
20
|
+
import { decodeRequestErrorMessage as y } from "./utilities/decodeRequestErrorMessage.js";
|
|
21
|
+
import { errorHandler as b } from "./utilities/errorHandler.js";
|
|
22
|
+
import { formAsyncParse as x } from "./utilities/formAsyncParse.js";
|
|
23
|
+
import { formParse as S } from "./utilities/formParse.js";
|
|
24
|
+
import { getScopedParams as C } from "./utilities/getScopedParams.js";
|
|
25
|
+
import { SchemaValidator as w } from "./utilities/schemaValidator.js";
|
|
26
|
+
import { validateCep as T } from "./validations/validateCep.js";
|
|
27
|
+
import { validateCnpj as E } from "./validations/validateCnpj.js";
|
|
28
|
+
import { validateCpf as D } from "./validations/validateCpf.js";
|
|
29
|
+
import { validateDate as O } from "./validations/validateDate.js";
|
|
30
|
+
import { validateEmail as k } from "./validations/validateEmail.js";
|
|
31
|
+
import { validatePassword as A } from "./validations/validatePassword.js";
|
|
32
|
+
import { validatePhone as j } from "./validations/validatePhone.js";
|
|
33
|
+
import { validateRg as M } from "./validations/validateRg.js";
|
|
34
|
+
export { _ as ApiService, n as BadGateway, r as BadRequest, i as Conflict, d as Created, e as DebugService, a as Forbidden, f as Found, g as LogService, p as NoContent, o as NotFound, s as NotImplemented, w as SchemaValidator, c as ServerError, m as Success, l as Unauthorized, u as UnprocessableEntity, h as Updated, v as decodeRequestBody, y as decodeRequestErrorMessage, b as errorHandler, t as flushDebugLogs, x as formAsyncParse, S as formParse, C as getScopedParams, T as validateCep, E as validateCnpj, D as validateCpf, O as validateDate, k as validateEmail, A as validatePassword, j as validatePhone, M as validateRg };
|
|
@@ -1,129 +1,109 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
* Sends a delete request to the specified endpoint.
|
|
108
|
-
* @param endpoint - The API endpoint to send the delete request to.
|
|
109
|
-
* @param data - The request data, including body, optional headers, and token.
|
|
110
|
-
* @returns The API response data.
|
|
111
|
-
*/
|
|
112
|
-
async delete(s, e) {
|
|
113
|
-
const r = this.generateHeaders((e == null ? void 0 : e.headers) || {}, e == null ? void 0 : e.token), o = e == null ? void 0 : e.body, u = await g({
|
|
114
|
-
url: this.baseUrl + s,
|
|
115
|
-
urlParams: (e == null ? void 0 : e.urlParams) || {},
|
|
116
|
-
headers: r,
|
|
117
|
-
body: o
|
|
118
|
-
});
|
|
119
|
-
return this.onDebug(s, "delete", {
|
|
120
|
-
headers: r,
|
|
121
|
-
body: o,
|
|
122
|
-
message: u.message,
|
|
123
|
-
status: u.status
|
|
124
|
-
}), u;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
export {
|
|
128
|
-
w as ApiService
|
|
1
|
+
import { flushDebugLogs as e } from "../utilities/flushDebugLogs.js";
|
|
2
|
+
import { deleteRequest as t } from "../http/api/deleteRequest.js";
|
|
3
|
+
import { getRequest as n } from "../http/api/getRequest.js";
|
|
4
|
+
import { patchRequest as r } from "../http/api/patchRequest.js";
|
|
5
|
+
import { postRequest as i } from "../http/api/postRequest.js";
|
|
6
|
+
import { putRequest as a } from "../http/api/putRequest.js";
|
|
7
|
+
//#region src/services/apiService.ts
|
|
8
|
+
var o = class {
|
|
9
|
+
baseUrl;
|
|
10
|
+
baseHeaders;
|
|
11
|
+
baseToken;
|
|
12
|
+
enableDebug;
|
|
13
|
+
constructor(e) {
|
|
14
|
+
this.baseUrl = e.baseUrl, this.baseHeaders = e.baseHeaders || void 0, this.baseToken = e.baseToken || void 0, this.enableDebug = e.enableDebug || !1;
|
|
15
|
+
}
|
|
16
|
+
onDebug(t, n, r) {
|
|
17
|
+
if (this.enableDebug) {
|
|
18
|
+
let i = [], a = (e) => JSON.stringify(e, null, 2);
|
|
19
|
+
i.push(`Base URL: ${this.baseUrl}`), i.push(`Endpoint: ${t}`), i.push(`Status/Method: ${n} => ${r.status}`), i.push(`Message: ${r.message}`), r.headers && i.push(`Headers: ${a(r.headers)}`), r.body && i.push(`Body: ${a(r.body)}`), e({
|
|
20
|
+
debugs: i,
|
|
21
|
+
name: "ApiDebug",
|
|
22
|
+
scheme: "yellow"
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
generateHeaders(e, t) {
|
|
27
|
+
let n = {};
|
|
28
|
+
return this.baseToken && (n = { Authorization: `Bearer ${this.baseToken}` }), this.baseHeaders && (n = {
|
|
29
|
+
...n,
|
|
30
|
+
...this.baseHeaders
|
|
31
|
+
}), e && (n = {
|
|
32
|
+
...n,
|
|
33
|
+
...e
|
|
34
|
+
}), t && (n = {
|
|
35
|
+
...n,
|
|
36
|
+
Authorization: `Bearer ${t}`
|
|
37
|
+
}), n;
|
|
38
|
+
}
|
|
39
|
+
async get(e, t) {
|
|
40
|
+
let r = this.generateHeaders(t?.headers || {}, t?.token), i = await n({
|
|
41
|
+
url: this.baseUrl + e,
|
|
42
|
+
urlParams: t?.urlParams || {},
|
|
43
|
+
headers: r
|
|
44
|
+
});
|
|
45
|
+
return this.onDebug(e, "get", {
|
|
46
|
+
headers: r,
|
|
47
|
+
message: i.message,
|
|
48
|
+
status: i.status
|
|
49
|
+
}), i;
|
|
50
|
+
}
|
|
51
|
+
async post(e, t) {
|
|
52
|
+
let n = this.generateHeaders(t?.headers || {}, t?.token), r = t?.body, a = await i({
|
|
53
|
+
url: this.baseUrl + e,
|
|
54
|
+
urlParams: t?.urlParams || {},
|
|
55
|
+
headers: n,
|
|
56
|
+
body: r
|
|
57
|
+
});
|
|
58
|
+
return this.onDebug(e, "post", {
|
|
59
|
+
headers: n,
|
|
60
|
+
body: r,
|
|
61
|
+
message: a.message,
|
|
62
|
+
status: a.status
|
|
63
|
+
}), a;
|
|
64
|
+
}
|
|
65
|
+
async put(e, t) {
|
|
66
|
+
let n = this.generateHeaders(t?.headers || {}, t?.token), r = t?.body, i = await a({
|
|
67
|
+
url: this.baseUrl + e,
|
|
68
|
+
urlParams: t?.urlParams || {},
|
|
69
|
+
headers: n,
|
|
70
|
+
body: r
|
|
71
|
+
});
|
|
72
|
+
return this.onDebug(e, "put", {
|
|
73
|
+
headers: n,
|
|
74
|
+
body: r,
|
|
75
|
+
message: i.message,
|
|
76
|
+
status: i.status
|
|
77
|
+
}), i;
|
|
78
|
+
}
|
|
79
|
+
async patch(e, t) {
|
|
80
|
+
let n = this.generateHeaders(t?.headers || {}, t?.token), i = t?.body, a = await r({
|
|
81
|
+
url: this.baseUrl + e,
|
|
82
|
+
urlParams: t?.urlParams || {},
|
|
83
|
+
headers: n,
|
|
84
|
+
body: i
|
|
85
|
+
});
|
|
86
|
+
return this.onDebug(e, "patch", {
|
|
87
|
+
headers: n,
|
|
88
|
+
body: i,
|
|
89
|
+
message: a.message,
|
|
90
|
+
status: a.status
|
|
91
|
+
}), a;
|
|
92
|
+
}
|
|
93
|
+
async delete(e, n) {
|
|
94
|
+
let r = this.generateHeaders(n?.headers || {}, n?.token), i = n?.body, a = await t({
|
|
95
|
+
url: this.baseUrl + e,
|
|
96
|
+
urlParams: n?.urlParams || {},
|
|
97
|
+
headers: r,
|
|
98
|
+
body: i
|
|
99
|
+
});
|
|
100
|
+
return this.onDebug(e, "delete", {
|
|
101
|
+
headers: r,
|
|
102
|
+
body: i,
|
|
103
|
+
message: a.message,
|
|
104
|
+
status: a.status
|
|
105
|
+
}), a;
|
|
106
|
+
}
|
|
129
107
|
};
|
|
108
|
+
//#endregion
|
|
109
|
+
export { o as ApiService };
|
|
@@ -1,66 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
n++;
|
|
35
|
-
const h = c[n] || "";
|
|
36
|
-
let o = "Unknown function", e = "Unknown caller";
|
|
37
|
-
const a = h.match(/at\s+([^(\s]+)\s+\(([^)]+)\)/);
|
|
38
|
-
if (a)
|
|
39
|
-
o = a[1], e = a[2];
|
|
40
|
-
else {
|
|
41
|
-
const s = h.match(/at\s+(.+)/);
|
|
42
|
-
if (s) {
|
|
43
|
-
e = s[1];
|
|
44
|
-
const r = e.match(/at\s+([^(\s]+)\s+/);
|
|
45
|
-
r && r[1] !== "new" && (o = r[1]);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
e.includes("(") && (e = e.substring(
|
|
49
|
-
e.indexOf("(") + 1,
|
|
50
|
-
e.lastIndexOf(")")
|
|
51
|
-
)), e = e.split(":").slice(0, -2).join(":");
|
|
52
|
-
try {
|
|
53
|
-
e = m.relative(t, e);
|
|
54
|
-
} catch {
|
|
55
|
-
}
|
|
56
|
-
return { functionName: o, callerInfo: e };
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* The name of the file to ignore when analyzing the stack trace.
|
|
61
|
-
* When set, the `getCaller` function will skip stack frames containing this file name.
|
|
62
|
-
*/
|
|
63
|
-
d(f, "ignoreFiles", []);
|
|
64
|
-
export {
|
|
65
|
-
f as DebugService
|
|
1
|
+
import e from "node:path";
|
|
2
|
+
//#region src/services/debugService.ts
|
|
3
|
+
var t = class {
|
|
4
|
+
static ignoreFiles = [];
|
|
5
|
+
static setIgnoreFile(e) {
|
|
6
|
+
this.ignoreFiles.push(e);
|
|
7
|
+
}
|
|
8
|
+
static clearIgnoreFiles() {
|
|
9
|
+
this.ignoreFiles = [];
|
|
10
|
+
}
|
|
11
|
+
static getCaller() {
|
|
12
|
+
let t = process.cwd(), n = ((/* @__PURE__ */ Error()).stack || "").split("\n").map((e) => e.trim()), r = 2;
|
|
13
|
+
for (; r < n.length && (n[r].includes("node:internal") || n[r].includes("/node_modules/"));) r++;
|
|
14
|
+
if (this.ignoreFiles.length > 0) for (; r < n.length && this.ignoreFiles.some((e) => n[r].includes(e));) r++;
|
|
15
|
+
let i = n[r] || "", a = "Unknown function", o = "Unknown caller", s = i.match(/at\s+([^(\s]+)\s+\(([^)]+)\)/);
|
|
16
|
+
if (s) a = s[1], o = s[2];
|
|
17
|
+
else {
|
|
18
|
+
let e = i.match(/at\s+(.+)/);
|
|
19
|
+
if (e) {
|
|
20
|
+
o = e[1];
|
|
21
|
+
let t = o.match(/at\s+([^(\s]+)\s+/);
|
|
22
|
+
t && t[1] !== "new" && (a = t[1]);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
o.includes("(") && (o = o.substring(o.indexOf("(") + 1, o.lastIndexOf(")"))), o = o.split(":").slice(0, -2).join(":");
|
|
26
|
+
try {
|
|
27
|
+
o = e.relative(t, o);
|
|
28
|
+
} catch {}
|
|
29
|
+
return {
|
|
30
|
+
functionName: a,
|
|
31
|
+
callerInfo: o
|
|
32
|
+
};
|
|
33
|
+
}
|
|
66
34
|
};
|
|
35
|
+
//#endregion
|
|
36
|
+
export { t as DebugService };
|