mp-front-cli 0.0.30 → 0.0.31
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/mp-front-cli-core.es.js +38 -38
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
var p = Object.defineProperty;
|
|
2
|
-
var b = (a, s,
|
|
3
|
-
var c = (a, s,
|
|
2
|
+
var b = (a, s, t) => s in a ? p(a, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[s] = t;
|
|
3
|
+
var c = (a, s, t) => (b(a, typeof s != "symbol" ? s + "" : s, t), t);
|
|
4
4
|
import { C as l, M as g } from "./custom-validator-16ec563a.js";
|
|
5
5
|
import { E as N } from "./custom-validator-16ec563a.js";
|
|
6
6
|
import { C as f, f as S } from "./custom-header-9a9c64e2.js";
|
|
@@ -12,62 +12,62 @@ import "./custom-encoder-b2078b5c.js";
|
|
|
12
12
|
import "./mp-front-cli-logger.es.js";
|
|
13
13
|
import "./index-6f6eb615.js";
|
|
14
14
|
class H extends l {
|
|
15
|
-
returnData(s,
|
|
15
|
+
returnData(s, t) {
|
|
16
16
|
n.getInstance().unsubscribeSubject();
|
|
17
|
-
const
|
|
18
|
-
s.status(200).json(
|
|
17
|
+
const e = this.encode(t);
|
|
18
|
+
s.status(200).json(e);
|
|
19
19
|
}
|
|
20
20
|
get(s) {
|
|
21
|
-
return this.logDebug("get ApiMiddleware"), (
|
|
21
|
+
return this.logDebug("get ApiMiddleware"), (t, e) => {
|
|
22
22
|
this.logDebug("return ApiMiddleware"), n.getInstance().subscribe({
|
|
23
23
|
next: (r) => (this.logError(
|
|
24
24
|
`ApiMiddleware MessageHandler ${JSON.stringify(r)}`
|
|
25
|
-
), n.getInstance().unsubscribeSubject(),
|
|
26
|
-
}), o(
|
|
25
|
+
), n.getInstance().unsubscribeSubject(), e.status(r.code ?? 520).json(r))
|
|
26
|
+
}), o(t).pipe(
|
|
27
27
|
i((r) => this.validateTokenFront(r)),
|
|
28
28
|
i((r) => o(this.decode(r.body))),
|
|
29
29
|
i((r) => s(r)),
|
|
30
30
|
m((r) => (n.getInstance().setSubject(r), o({})))
|
|
31
31
|
).subscribe({
|
|
32
32
|
next: (r) => {
|
|
33
|
-
this.returnData(
|
|
33
|
+
this.returnData(e, r);
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
class C extends f {
|
|
40
|
-
constructor(
|
|
40
|
+
constructor(t, e) {
|
|
41
41
|
super();
|
|
42
42
|
c(this, "apiUrl");
|
|
43
43
|
c(this, "method");
|
|
44
|
-
this.apiUrl =
|
|
44
|
+
this.apiUrl = t, this.method = e ?? "POST";
|
|
45
45
|
}
|
|
46
|
-
errorHandler(
|
|
47
|
-
return
|
|
48
|
-
new g(
|
|
49
|
-
), !(
|
|
46
|
+
errorHandler(t) {
|
|
47
|
+
return t != null && t.errors && n.getInstance().setSubject(
|
|
48
|
+
new g(t.errors[0]).get()
|
|
49
|
+
), !(t != null && t.errors);
|
|
50
50
|
}
|
|
51
|
-
customCatchError(
|
|
52
|
-
return n.getInstance().setSubject(new g(
|
|
51
|
+
customCatchError(t) {
|
|
52
|
+
return n.getInstance().setSubject(new g(t).get()), o({ error: !0 }).pipe(d(({ error: e }) => !e));
|
|
53
53
|
}
|
|
54
|
-
fetchData(
|
|
55
|
-
return this.logDebug("fetchData", JSON.stringify(
|
|
54
|
+
fetchData(t = {}) {
|
|
55
|
+
return this.logDebug("fetchData", JSON.stringify(t)), o(t).pipe(
|
|
56
56
|
i(
|
|
57
|
-
(
|
|
57
|
+
(e) => this.getHeaders().pipe(i((r) => o({ params: e, headers: r })))
|
|
58
58
|
),
|
|
59
59
|
i(
|
|
60
|
-
({ params:
|
|
60
|
+
({ params: e, headers: r }) => S(this.apiUrl, {
|
|
61
61
|
method: this.method,
|
|
62
62
|
headers: r,
|
|
63
|
-
body: JSON.stringify(
|
|
63
|
+
body: this.method === "GET" ? null : JSON.stringify(e)
|
|
64
64
|
}).pipe(
|
|
65
65
|
i((h) => h.json()),
|
|
66
66
|
i((h) => (this.logDebug(
|
|
67
67
|
`FetchServiceBE \x1B[37m <URL>: \x1B[33m ${this.apiUrl} \x1B[37m <HEADERS>: \x1B[33m ${JSON.stringify(
|
|
68
68
|
r
|
|
69
69
|
)} \x1B[37m <BODY>: \x1B[33m ${JSON.stringify(
|
|
70
|
-
|
|
70
|
+
e
|
|
71
71
|
)} \x1B[37m <RESPONSE>: \x1B[33m ${JSON.stringify(h)} \x1B[33m`
|
|
72
72
|
), o(h)))
|
|
73
73
|
)
|
|
@@ -78,37 +78,37 @@ class C extends f {
|
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
class F extends l {
|
|
81
|
-
constructor(
|
|
81
|
+
constructor(t, e = "POST", r = {}) {
|
|
82
82
|
super();
|
|
83
83
|
c(this, "apiUrl");
|
|
84
84
|
c(this, "method");
|
|
85
85
|
c(this, "headers");
|
|
86
|
-
this.apiUrl =
|
|
86
|
+
this.apiUrl = t, this.method = e, this.headers = {
|
|
87
87
|
"Content-Type": "application/json",
|
|
88
88
|
...r
|
|
89
89
|
};
|
|
90
90
|
}
|
|
91
|
-
errorHandler(
|
|
92
|
-
return
|
|
91
|
+
errorHandler(t) {
|
|
92
|
+
return t.code && (n.getInstance().setSubject(t), u.getInstance().setSubject(!1)), !t.code;
|
|
93
93
|
}
|
|
94
|
-
customCatchError(
|
|
95
|
-
return n.getInstance().setSubject(new g(
|
|
96
|
-
d(({ error:
|
|
94
|
+
customCatchError(t) {
|
|
95
|
+
return n.getInstance().setSubject(new g(t).get()), u.getInstance().setSubject(!1), o({ error: !0 }).pipe(
|
|
96
|
+
d(({ error: e }) => !e)
|
|
97
97
|
);
|
|
98
98
|
}
|
|
99
|
-
fetchData(
|
|
99
|
+
fetchData(t = {}) {
|
|
100
100
|
return u.getInstance().setSubject(!0), S(this.apiUrl, {
|
|
101
101
|
method: this.method,
|
|
102
102
|
headers: this.headers,
|
|
103
|
-
body: this.encode(
|
|
103
|
+
body: this.encode(t)
|
|
104
104
|
}).pipe(
|
|
105
|
-
i((
|
|
106
|
-
i((
|
|
107
|
-
`FetchServiceFE <URL>: ${this.apiUrl} <HEADERS>: ${JSON.stringify(this.headers)} <BODY>: ${JSON.stringify(
|
|
108
|
-
), o(
|
|
105
|
+
i((e) => e.json()),
|
|
106
|
+
i((e) => (this.logDebug(
|
|
107
|
+
`FetchServiceFE <URL>: ${this.apiUrl} <HEADERS>: ${JSON.stringify(this.headers)} <BODY>: ${JSON.stringify(e)}`
|
|
108
|
+
), o(e))),
|
|
109
109
|
d(this.errorHandler),
|
|
110
|
-
i((
|
|
111
|
-
i((
|
|
110
|
+
i((e) => o(this.decode(e))),
|
|
111
|
+
i((e) => (u.getInstance().setSubject(!1), o(e))),
|
|
112
112
|
m(this.customCatchError)
|
|
113
113
|
);
|
|
114
114
|
}
|