@glodon-aiot/agent-cli-sdk 2.4.7 → 3.0.4
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/README.md +128 -41
- package/dist/agent-cli-sdk.js +28505 -30335
- package/dist/agent-cli-sdk.umd.cjs +113 -123
- package/dist/src/AgentSession.d.ts +4 -3
- package/dist/src/BotClient.d.ts +7 -5
- package/dist/src/DialogSession.d.ts +4 -3
- package/dist/src/Session.d.ts +70 -16
- package/dist/src/api/fetchEventSource/fetch.d.ts +1 -1
- package/dist/src/api/fetchEventSource/index.d.ts +1 -1
- package/package.json +13 -22
- package/dist/cdn/agent-cli-sdk.js +0 -32945
- package/dist/cdn/agent-cli-sdk.umd.cjs +0 -140
- package/dist/cdn/src/AgentPlugin.d.ts +0 -17
- package/dist/cdn/src/AgentSession.d.ts +0 -8
- package/dist/cdn/src/BotClient.d.ts +0 -46
- package/dist/cdn/src/Config.d.ts +0 -32
- package/dist/cdn/src/DialogSession.d.ts +0 -21
- package/dist/cdn/src/EventBus.d.ts +0 -23
- package/dist/cdn/src/Logger.d.ts +0 -12
- package/dist/cdn/src/PayloadTypes.d.ts +0 -84
- package/dist/cdn/src/Session.d.ts +0 -156
- package/dist/cdn/src/__ tests __/AgentClient.spec.d.ts +0 -1
- package/dist/cdn/src/__ tests __/AgentSession.spec.d.ts +0 -1
- package/dist/cdn/src/__ tests __/DialogClient.spec.d.ts +0 -1
- package/dist/cdn/src/api/fetchEventSource/fetch.d.ts +0 -44
- package/dist/cdn/src/api/fetchEventSource/index.d.ts +0 -1
- package/dist/cdn/src/api/fetchEventSource/parse.d.ts +0 -36
- package/dist/cdn/src/api/index.d.ts +0 -2
- package/dist/cdn/src/index.d.ts +0 -5
- package/dist/cdn/src/utils.d.ts +0 -4
- package/dist/es/AgentPlugin.mjs +0 -20
- package/dist/es/AgentSession.mjs +0 -243
- package/dist/es/BotClient.mjs +0 -242
- package/dist/es/Config.mjs +0 -34
- package/dist/es/DialogSession.mjs +0 -281
- package/dist/es/EventBus.mjs +0 -64
- package/dist/es/Logger.mjs +0 -31
- package/dist/es/PayloadTypes.mjs +0 -4
- package/dist/es/Session.mjs +0 -527
- package/dist/es/_virtual/_commonjsHelpers.mjs +0 -4
- package/dist/es/_virtual/index.mjs +0 -4
- package/dist/es/_virtual/index2.mjs +0 -4
- package/dist/es/_virtual/index3.mjs +0 -4
- package/dist/es/_virtual/minio-zj.mjs +0 -4
- package/dist/es/api/fetchEventSource/fetch.mjs +0 -112
- package/dist/es/api/fetchEventSource/parse.mjs +0 -97
- package/dist/es/api/index.mjs +0 -48
- package/dist/es/index.mjs +0 -11
- package/dist/es/node_modules/@glodon-aiot/minio/dist/minio-zj.mjs +0 -26485
- package/dist/es/node_modules/@socket.io/component-emitter/lib/esm/index.mjs +0 -54
- package/dist/es/node_modules/base64-js/index.mjs +0 -47
- package/dist/es/node_modules/buffer/index.mjs +0 -927
- package/dist/es/node_modules/engine.io-client/build/esm/contrib/has-cors.mjs +0 -9
- package/dist/es/node_modules/engine.io-client/build/esm/contrib/parseqs.mjs +0 -18
- package/dist/es/node_modules/engine.io-client/build/esm/contrib/parseuri.mjs +0 -24
- package/dist/es/node_modules/engine.io-client/build/esm/contrib/yeast.mjs +0 -19
- package/dist/es/node_modules/engine.io-client/build/esm/globalThis.browser.mjs +0 -4
- package/dist/es/node_modules/engine.io-client/build/esm/socket.mjs +0 -317
- package/dist/es/node_modules/engine.io-client/build/esm/transport.mjs +0 -113
- package/dist/es/node_modules/engine.io-client/build/esm/transports/index.mjs +0 -11
- package/dist/es/node_modules/engine.io-client/build/esm/transports/polling.mjs +0 -273
- package/dist/es/node_modules/engine.io-client/build/esm/transports/websocket-constructor.browser.mjs +0 -8
- package/dist/es/node_modules/engine.io-client/build/esm/transports/websocket.mjs +0 -87
- package/dist/es/node_modules/engine.io-client/build/esm/transports/webtransport.mjs +0 -52
- package/dist/es/node_modules/engine.io-client/build/esm/transports/xmlhttprequest.browser.mjs +0 -21
- package/dist/es/node_modules/engine.io-client/build/esm/util.mjs +0 -23
- package/dist/es/node_modules/engine.io-parser/build/esm/commons.mjs +0 -21
- package/dist/es/node_modules/engine.io-parser/build/esm/contrib/base64-arraybuffer.mjs +0 -14
- package/dist/es/node_modules/engine.io-parser/build/esm/decodePacket.browser.mjs +0 -39
- package/dist/es/node_modules/engine.io-parser/build/esm/encodePacket.browser.mjs +0 -28
- package/dist/es/node_modules/engine.io-parser/build/esm/index.mjs +0 -105
- package/dist/es/node_modules/ieee754/index.mjs +0 -28
- package/dist/es/node_modules/js-base64/base64.mjs +0 -31
- package/dist/es/node_modules/socket.io-client/build/esm/contrib/backo2.mjs +0 -26
- package/dist/es/node_modules/socket.io-client/build/esm/index.mjs +0 -25
- package/dist/es/node_modules/socket.io-client/build/esm/manager.mjs +0 -242
- package/dist/es/node_modules/socket.io-client/build/esm/on.mjs +0 -8
- package/dist/es/node_modules/socket.io-client/build/esm/socket.mjs +0 -608
- package/dist/es/node_modules/socket.io-client/build/esm/url.mjs +0 -19
- package/dist/es/node_modules/socket.io-parser/build/esm/binary.mjs +0 -52
- package/dist/es/node_modules/socket.io-parser/build/esm/index.mjs +0 -203
- package/dist/es/node_modules/socket.io-parser/build/esm/is-binary.mjs +0 -26
- package/dist/es/node_modules/uuid/dist/esm-browser/native.mjs +0 -6
- package/dist/es/node_modules/uuid/dist/esm-browser/rng.mjs +0 -10
- package/dist/es/node_modules/uuid/dist/esm-browser/stringify.mjs +0 -9
- package/dist/es/node_modules/uuid/dist/esm-browser/v4.mjs +0 -19
- package/dist/es/packages/apis/dist/es/aecpilot/model.mjs +0 -4
- package/dist/es/packages/apis/dist/es/aecpilotui/index.mjs +0 -8
- package/dist/es/packages/apis/dist/es/agentcliui/index.mjs +0 -8
- package/dist/es/packages/apis/dist/es/base/index.mjs +0 -154
- package/dist/es/packages/apis/dist/es/cvforce/index.mjs +0 -431
- package/dist/es/packages/apis/dist/es/cvforce/model.mjs +0 -5
- package/dist/es/packages/apis/dist/es/node_modules/uuid/dist/esm-browser/native.mjs +0 -1
- package/dist/es/packages/apis/dist/es/node_modules/uuid/dist/esm-browser/stringify.mjs +0 -3
- package/dist/es/utils.mjs +0 -11
- package/dist/lib/index.js +0 -126
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
import { Emitter as h } from "../../../@socket.io/component-emitter/lib/esm/index.mjs";
|
|
2
|
-
import { deconstructPacket as f, reconstructPacket as N } from "./binary.mjs";
|
|
3
|
-
import { hasBinary as E, isBinary as d } from "./is-binary.mjs";
|
|
4
|
-
const A = [
|
|
5
|
-
"connect",
|
|
6
|
-
"connect_error",
|
|
7
|
-
"disconnect",
|
|
8
|
-
"disconnecting",
|
|
9
|
-
"newListener",
|
|
10
|
-
"removeListener"
|
|
11
|
-
// used by the Node.js EventEmitter
|
|
12
|
-
], y = 5;
|
|
13
|
-
var r;
|
|
14
|
-
(function(n) {
|
|
15
|
-
n[n.CONNECT = 0] = "CONNECT", n[n.DISCONNECT = 1] = "DISCONNECT", n[n.EVENT = 2] = "EVENT", n[n.ACK = 3] = "ACK", n[n.CONNECT_ERROR = 4] = "CONNECT_ERROR", n[n.BINARY_EVENT = 5] = "BINARY_EVENT", n[n.BINARY_ACK = 6] = "BINARY_ACK";
|
|
16
|
-
})(r || (r = {}));
|
|
17
|
-
class g {
|
|
18
|
-
/**
|
|
19
|
-
* Encoder constructor
|
|
20
|
-
*
|
|
21
|
-
* @param {function} replacer - custom replacer to pass down to JSON.parse
|
|
22
|
-
*/
|
|
23
|
-
constructor(t) {
|
|
24
|
-
this.replacer = t;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Encode a packet as a single string if non-binary, or as a
|
|
28
|
-
* buffer sequence, depending on packet type.
|
|
29
|
-
*
|
|
30
|
-
* @param {Object} obj - packet object
|
|
31
|
-
*/
|
|
32
|
-
encode(t) {
|
|
33
|
-
return (t.type === r.EVENT || t.type === r.ACK) && E(t) ? this.encodeAsBinary({
|
|
34
|
-
type: t.type === r.EVENT ? r.BINARY_EVENT : r.BINARY_ACK,
|
|
35
|
-
nsp: t.nsp,
|
|
36
|
-
data: t.data,
|
|
37
|
-
id: t.id
|
|
38
|
-
}) : [this.encodeAsString(t)];
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Encode packet as string.
|
|
42
|
-
*/
|
|
43
|
-
encodeAsString(t) {
|
|
44
|
-
let e = "" + t.type;
|
|
45
|
-
return (t.type === r.BINARY_EVENT || t.type === r.BINARY_ACK) && (e += t.attachments + "-"), t.nsp && t.nsp !== "/" && (e += t.nsp + ","), t.id != null && (e += t.id), t.data != null && (e += JSON.stringify(t.data, this.replacer)), e;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Encode packet as 'buffer sequence' by removing blobs, and
|
|
49
|
-
* deconstructing packet into object with placeholders and
|
|
50
|
-
* a list of buffers.
|
|
51
|
-
*/
|
|
52
|
-
encodeAsBinary(t) {
|
|
53
|
-
const e = f(t), s = this.encodeAsString(e.packet), o = e.buffers;
|
|
54
|
-
return o.unshift(s), o;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
function a(n) {
|
|
58
|
-
return Object.prototype.toString.call(n) === "[object Object]";
|
|
59
|
-
}
|
|
60
|
-
class u extends h {
|
|
61
|
-
/**
|
|
62
|
-
* Decoder constructor
|
|
63
|
-
*
|
|
64
|
-
* @param {function} reviver - custom reviver to pass down to JSON.stringify
|
|
65
|
-
*/
|
|
66
|
-
constructor(t) {
|
|
67
|
-
super(), this.reviver = t;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Decodes an encoded packet string into packet JSON.
|
|
71
|
-
*
|
|
72
|
-
* @param {String} obj - encoded packet
|
|
73
|
-
*/
|
|
74
|
-
add(t) {
|
|
75
|
-
let e;
|
|
76
|
-
if (typeof t == "string") {
|
|
77
|
-
if (this.reconstructor)
|
|
78
|
-
throw new Error("got plaintext data when reconstructing a packet");
|
|
79
|
-
e = this.decodeString(t);
|
|
80
|
-
const s = e.type === r.BINARY_EVENT;
|
|
81
|
-
s || e.type === r.BINARY_ACK ? (e.type = s ? r.EVENT : r.ACK, this.reconstructor = new l(e), e.attachments === 0 && super.emitReserved("decoded", e)) : super.emitReserved("decoded", e);
|
|
82
|
-
} else if (d(t) || t.base64)
|
|
83
|
-
if (this.reconstructor)
|
|
84
|
-
e = this.reconstructor.takeBinaryData(t), e && (this.reconstructor = null, super.emitReserved("decoded", e));
|
|
85
|
-
else
|
|
86
|
-
throw new Error("got binary data when not reconstructing a packet");
|
|
87
|
-
else
|
|
88
|
-
throw new Error("Unknown type: " + t);
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Decode a packet String (JSON data)
|
|
92
|
-
*
|
|
93
|
-
* @param {String} str
|
|
94
|
-
* @return {Object} packet
|
|
95
|
-
*/
|
|
96
|
-
decodeString(t) {
|
|
97
|
-
let e = 0;
|
|
98
|
-
const s = {
|
|
99
|
-
type: Number(t.charAt(0))
|
|
100
|
-
};
|
|
101
|
-
if (r[s.type] === void 0)
|
|
102
|
-
throw new Error("unknown packet type " + s.type);
|
|
103
|
-
if (s.type === r.BINARY_EVENT || s.type === r.BINARY_ACK) {
|
|
104
|
-
const i = e + 1;
|
|
105
|
-
for (; t.charAt(++e) !== "-" && e != t.length; )
|
|
106
|
-
;
|
|
107
|
-
const c = t.substring(i, e);
|
|
108
|
-
if (c != Number(c) || t.charAt(e) !== "-")
|
|
109
|
-
throw new Error("Illegal attachments");
|
|
110
|
-
s.attachments = Number(c);
|
|
111
|
-
}
|
|
112
|
-
if (t.charAt(e + 1) === "/") {
|
|
113
|
-
const i = e + 1;
|
|
114
|
-
for (; ++e && !(t.charAt(e) === "," || e === t.length); )
|
|
115
|
-
;
|
|
116
|
-
s.nsp = t.substring(i, e);
|
|
117
|
-
} else
|
|
118
|
-
s.nsp = "/";
|
|
119
|
-
const o = t.charAt(e + 1);
|
|
120
|
-
if (o !== "" && Number(o) == o) {
|
|
121
|
-
const i = e + 1;
|
|
122
|
-
for (; ++e; ) {
|
|
123
|
-
const c = t.charAt(e);
|
|
124
|
-
if (c == null || Number(c) != c) {
|
|
125
|
-
--e;
|
|
126
|
-
break;
|
|
127
|
-
}
|
|
128
|
-
if (e === t.length)
|
|
129
|
-
break;
|
|
130
|
-
}
|
|
131
|
-
s.id = Number(t.substring(i, e + 1));
|
|
132
|
-
}
|
|
133
|
-
if (t.charAt(++e)) {
|
|
134
|
-
const i = this.tryParse(t.substr(e));
|
|
135
|
-
if (u.isPayloadValid(s.type, i))
|
|
136
|
-
s.data = i;
|
|
137
|
-
else
|
|
138
|
-
throw new Error("invalid payload");
|
|
139
|
-
}
|
|
140
|
-
return s;
|
|
141
|
-
}
|
|
142
|
-
tryParse(t) {
|
|
143
|
-
try {
|
|
144
|
-
return JSON.parse(t, this.reviver);
|
|
145
|
-
} catch (e) {
|
|
146
|
-
return !1;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
static isPayloadValid(t, e) {
|
|
150
|
-
switch (t) {
|
|
151
|
-
case r.CONNECT:
|
|
152
|
-
return a(e);
|
|
153
|
-
case r.DISCONNECT:
|
|
154
|
-
return e === void 0;
|
|
155
|
-
case r.CONNECT_ERROR:
|
|
156
|
-
return typeof e == "string" || a(e);
|
|
157
|
-
case r.EVENT:
|
|
158
|
-
case r.BINARY_EVENT:
|
|
159
|
-
return Array.isArray(e) && (typeof e[0] == "number" || typeof e[0] == "string" && A.indexOf(e[0]) === -1);
|
|
160
|
-
case r.ACK:
|
|
161
|
-
case r.BINARY_ACK:
|
|
162
|
-
return Array.isArray(e);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* Deallocates a parser's resources
|
|
167
|
-
*/
|
|
168
|
-
destroy() {
|
|
169
|
-
this.reconstructor && (this.reconstructor.finishedReconstruction(), this.reconstructor = null);
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
class l {
|
|
173
|
-
constructor(t) {
|
|
174
|
-
this.packet = t, this.buffers = [], this.reconPack = t;
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* Method to be called when binary data received from connection
|
|
178
|
-
* after a BINARY_EVENT packet.
|
|
179
|
-
*
|
|
180
|
-
* @param {Buffer | ArrayBuffer} binData - the raw binary data received
|
|
181
|
-
* @return {null | Object} returns null if more binary data is expected or
|
|
182
|
-
* a reconstructed packet object if all buffers have been received.
|
|
183
|
-
*/
|
|
184
|
-
takeBinaryData(t) {
|
|
185
|
-
if (this.buffers.push(t), this.buffers.length === this.reconPack.attachments) {
|
|
186
|
-
const e = N(this.reconPack, this.buffers);
|
|
187
|
-
return this.finishedReconstruction(), e;
|
|
188
|
-
}
|
|
189
|
-
return null;
|
|
190
|
-
}
|
|
191
|
-
/**
|
|
192
|
-
* Cleans up binary packet reconstruction variables.
|
|
193
|
-
*/
|
|
194
|
-
finishedReconstruction() {
|
|
195
|
-
this.reconPack = null, this.buffers = [];
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
export {
|
|
199
|
-
u as Decoder,
|
|
200
|
-
g as Encoder,
|
|
201
|
-
r as PacketType,
|
|
202
|
-
y as protocol
|
|
203
|
-
};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
const i = typeof ArrayBuffer == "function", o = (t) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(t) : t.buffer instanceof ArrayBuffer, n = Object.prototype.toString, u = typeof Blob == "function" || typeof Blob != "undefined" && n.call(Blob) === "[object BlobConstructor]", c = typeof File == "function" || typeof File != "undefined" && n.call(File) === "[object FileConstructor]";
|
|
2
|
-
function a(t) {
|
|
3
|
-
return i && (t instanceof ArrayBuffer || o(t)) || u && t instanceof Blob || c && t instanceof File;
|
|
4
|
-
}
|
|
5
|
-
function r(t, l) {
|
|
6
|
-
if (!t || typeof t != "object")
|
|
7
|
-
return !1;
|
|
8
|
-
if (Array.isArray(t)) {
|
|
9
|
-
for (let e = 0, f = t.length; e < f; e++)
|
|
10
|
-
if (r(t[e]))
|
|
11
|
-
return !0;
|
|
12
|
-
return !1;
|
|
13
|
-
}
|
|
14
|
-
if (a(t))
|
|
15
|
-
return !0;
|
|
16
|
-
if (t.toJSON && typeof t.toJSON == "function" && arguments.length === 1)
|
|
17
|
-
return r(t.toJSON(), !0);
|
|
18
|
-
for (const e in t)
|
|
19
|
-
if (Object.prototype.hasOwnProperty.call(t, e) && r(t[e]))
|
|
20
|
-
return !0;
|
|
21
|
-
return !1;
|
|
22
|
-
}
|
|
23
|
-
export {
|
|
24
|
-
r as hasBinary,
|
|
25
|
-
a as isBinary
|
|
26
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
let t;
|
|
2
|
-
const e = new Uint8Array(16);
|
|
3
|
-
function o() {
|
|
4
|
-
if (!t && (t = typeof crypto != "undefined" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !t))
|
|
5
|
-
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
6
|
-
return t(e);
|
|
7
|
-
}
|
|
8
|
-
export {
|
|
9
|
-
o as default
|
|
10
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
const i = [];
|
|
2
|
-
for (let n = 0; n < 256; ++n)
|
|
3
|
-
i.push((n + 256).toString(16).slice(1));
|
|
4
|
-
function c(n, u = 0) {
|
|
5
|
-
return i[n[u + 0]] + i[n[u + 1]] + i[n[u + 2]] + i[n[u + 3]] + "-" + i[n[u + 4]] + i[n[u + 5]] + "-" + i[n[u + 6]] + i[n[u + 7]] + "-" + i[n[u + 8]] + i[n[u + 9]] + "-" + i[n[u + 10]] + i[n[u + 11]] + i[n[u + 12]] + i[n[u + 13]] + i[n[u + 14]] + i[n[u + 15]];
|
|
6
|
-
}
|
|
7
|
-
export {
|
|
8
|
-
c as unsafeStringify
|
|
9
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import e from "./native.mjs";
|
|
2
|
-
import i from "./rng.mjs";
|
|
3
|
-
import { unsafeStringify as d } from "./stringify.mjs";
|
|
4
|
-
function g(n, m, t) {
|
|
5
|
-
if (e.randomUUID && !m && !n)
|
|
6
|
-
return e.randomUUID();
|
|
7
|
-
n = n || {};
|
|
8
|
-
const r = n.random || (n.rng || i)();
|
|
9
|
-
if (r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, m) {
|
|
10
|
-
t = t || 0;
|
|
11
|
-
for (let a = 0; a < 16; ++a)
|
|
12
|
-
m[t + a] = r[a];
|
|
13
|
-
return m;
|
|
14
|
-
}
|
|
15
|
-
return d(r);
|
|
16
|
-
}
|
|
17
|
-
export {
|
|
18
|
-
g as default
|
|
19
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import "axios";
|
|
2
|
-
import "../../../../../node_modules/@glodon-aiot/minio/dist/minio-zj.mjs";
|
|
3
|
-
import "dayjs";
|
|
4
|
-
import "../../../../../node_modules/buffer/index.mjs";
|
|
5
|
-
import "../node_modules/uuid/dist/esm-browser/native.mjs";
|
|
6
|
-
import "../node_modules/uuid/dist/esm-browser/stringify.mjs";
|
|
7
|
-
import { __exports as r } from "../../../../../_virtual/index.mjs";
|
|
8
|
-
globalThis.Buffer = r.Buffer;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import "axios";
|
|
2
|
-
import "../../../../../node_modules/@glodon-aiot/minio/dist/minio-zj.mjs";
|
|
3
|
-
import "dayjs";
|
|
4
|
-
import "../../../../../node_modules/buffer/index.mjs";
|
|
5
|
-
import "../node_modules/uuid/dist/esm-browser/native.mjs";
|
|
6
|
-
import "../node_modules/uuid/dist/esm-browser/stringify.mjs";
|
|
7
|
-
import { __exports as r } from "../../../../../_virtual/index.mjs";
|
|
8
|
-
window.Buffer = r.Buffer;
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
var f = Object.defineProperty, c = Object.getOwnPropertySymbols, g = Object.prototype.hasOwnProperty, m = Object.prototype.propertyIsEnumerable, d = (o, r, t) => r in o ? f(o, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[r] = t, p = (o, r) => {
|
|
2
|
-
for (var t in r || (r = {}))
|
|
3
|
-
g.call(r, t) && d(o, t, r[t]);
|
|
4
|
-
if (c)
|
|
5
|
-
for (var t of c(r))
|
|
6
|
-
m.call(r, t) && d(o, t, r[t]);
|
|
7
|
-
return o;
|
|
8
|
-
}, s = (o, r, t) => new Promise((e, n) => {
|
|
9
|
-
var i = (l) => {
|
|
10
|
-
try {
|
|
11
|
-
a(t.next(l));
|
|
12
|
-
} catch (h) {
|
|
13
|
-
n(h);
|
|
14
|
-
}
|
|
15
|
-
}, u = (l) => {
|
|
16
|
-
try {
|
|
17
|
-
a(t.throw(l));
|
|
18
|
-
} catch (h) {
|
|
19
|
-
n(h);
|
|
20
|
-
}
|
|
21
|
-
}, a = (l) => l.done ? e(l.value) : Promise.resolve(l.value).then(i, u);
|
|
22
|
-
a((t = t.apply(o, r)).next());
|
|
23
|
-
});
|
|
24
|
-
class E {
|
|
25
|
-
constructor(r, t) {
|
|
26
|
-
this.axios = r, this.errorHandler = t;
|
|
27
|
-
}
|
|
28
|
-
get(r, t, e) {
|
|
29
|
-
return s(this, null, function* () {
|
|
30
|
-
const n = this.axios.get(r, {
|
|
31
|
-
params: t
|
|
32
|
-
});
|
|
33
|
-
return this.handleResponse(n, e);
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
listPaged(r, t) {
|
|
37
|
-
return s(this, null, function* () {
|
|
38
|
-
const e = this.axios.get(r, {
|
|
39
|
-
params: t
|
|
40
|
-
});
|
|
41
|
-
return this.handleResponse(e);
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
list(r, t) {
|
|
45
|
-
return s(this, null, function* () {
|
|
46
|
-
const e = this.axios.get(r, {
|
|
47
|
-
params: t
|
|
48
|
-
});
|
|
49
|
-
return this.handleResponse(e);
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
delete(r, t) {
|
|
53
|
-
return s(this, null, function* () {
|
|
54
|
-
const e = this.axios.delete(r, {
|
|
55
|
-
params: t
|
|
56
|
-
});
|
|
57
|
-
return this.handleResponse(e);
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
post(r, t, e, n) {
|
|
61
|
-
return s(this, null, function* () {
|
|
62
|
-
const i = this.axios.post(r, t, p({
|
|
63
|
-
params: e
|
|
64
|
-
}, n));
|
|
65
|
-
return this.handleResponse(i);
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
postForm(r, t, e) {
|
|
69
|
-
return s(this, null, function* () {
|
|
70
|
-
const n = this.axios.post(r, t, {
|
|
71
|
-
params: e,
|
|
72
|
-
headers: {
|
|
73
|
-
"Content-Type": "multipart/form-data"
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
return this.handleResponse(n);
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
patch(r, t, e) {
|
|
80
|
-
return s(this, null, function* () {
|
|
81
|
-
const n = this.axios.patch(r, t, {
|
|
82
|
-
params: e
|
|
83
|
-
});
|
|
84
|
-
return this.handleResponse(n);
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
put(r, t) {
|
|
88
|
-
return s(this, null, function* () {
|
|
89
|
-
const e = this.axios.put(r, t);
|
|
90
|
-
return this.handleResponse(e);
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
upload(r, t, e) {
|
|
94
|
-
return s(this, null, function* () {
|
|
95
|
-
const n = this.axios.post(r, t, p({}, e));
|
|
96
|
-
return this.handleResponse(n);
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
getNonStandard(r, t) {
|
|
100
|
-
return s(this, null, function* () {
|
|
101
|
-
const e = this.axios.get(r, t);
|
|
102
|
-
try {
|
|
103
|
-
const n = yield e;
|
|
104
|
-
if (n.status === 200)
|
|
105
|
-
return n;
|
|
106
|
-
} catch (n) {
|
|
107
|
-
throw this.handleError(n);
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
postNonStandard(r, t, e, n) {
|
|
112
|
-
return s(this, null, function* () {
|
|
113
|
-
var i, u;
|
|
114
|
-
const a = yield this.axios.post(r, t, p({
|
|
115
|
-
params: e
|
|
116
|
-
}, n));
|
|
117
|
-
if (a.status === 200)
|
|
118
|
-
if ((i = a.data) != null && i.code)
|
|
119
|
-
(u = this.errorHandler) != null && u.onAppStatusError && this.errorHandler.onAppStatusError(a.data.code, a.data.message);
|
|
120
|
-
else
|
|
121
|
-
return a.data;
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
handleResponse(r, t) {
|
|
125
|
-
return s(this, null, function* () {
|
|
126
|
-
try {
|
|
127
|
-
const e = yield r;
|
|
128
|
-
return this.handleAppError(e.data, t).data;
|
|
129
|
-
} catch (e) {
|
|
130
|
-
throw this.handleError(e);
|
|
131
|
-
}
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
handleAppError(r, t) {
|
|
135
|
-
var e;
|
|
136
|
-
if (r.code < 200 || r.code >= 300)
|
|
137
|
-
throw (e = this.errorHandler) != null && e.onAppStatusError ? this.errorHandler.onAppStatusError(r.code, x(r.code, r.message), t) : console.error("未处理应用错误:", r), {
|
|
138
|
-
isAxiosError: !1,
|
|
139
|
-
message: r.message
|
|
140
|
-
};
|
|
141
|
-
return r;
|
|
142
|
-
}
|
|
143
|
-
// https://github.com/axios/axios#handling-errors
|
|
144
|
-
handleError(r) {
|
|
145
|
-
var t, e;
|
|
146
|
-
return r.response ? (console.log(r.response.data), console.log(r.response.status), console.log(r.response.headers), (t = this.errorHandler) != null && t.onHttpStatusError && (console.log("HTTP 错误", this.errorHandler), this.errorHandler.onHttpStatusError(r.response.status, "", r.response))) : r.request ? (console.log(r.request), (e = this.errorHandler) != null && e.onNetworkError && this.errorHandler.onNetworkError()) : console.error("axios request config error:", r), new Error(r.message);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
const y = (o) => o >= 10002 && o <= 10012, x = (o, r) => y(o) ? "数据操作错误" : r || "未知接口错误";
|
|
150
|
-
export {
|
|
151
|
-
E as BaseApi,
|
|
152
|
-
y as needPrettifyMsg,
|
|
153
|
-
x as prettifyMsg
|
|
154
|
-
};
|