@glodon-aiot/agent-cli-sdk 2.4.7

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.
Files changed (108) hide show
  1. package/README.md +70 -0
  2. package/dist/agent-cli-sdk.js +34975 -0
  3. package/dist/agent-cli-sdk.umd.cjs +150 -0
  4. package/dist/cdn/agent-cli-sdk.js +32945 -0
  5. package/dist/cdn/agent-cli-sdk.umd.cjs +140 -0
  6. package/dist/cdn/src/AgentPlugin.d.ts +17 -0
  7. package/dist/cdn/src/AgentSession.d.ts +8 -0
  8. package/dist/cdn/src/BotClient.d.ts +46 -0
  9. package/dist/cdn/src/Config.d.ts +32 -0
  10. package/dist/cdn/src/DialogSession.d.ts +21 -0
  11. package/dist/cdn/src/EventBus.d.ts +23 -0
  12. package/dist/cdn/src/Logger.d.ts +12 -0
  13. package/dist/cdn/src/PayloadTypes.d.ts +84 -0
  14. package/dist/cdn/src/Session.d.ts +156 -0
  15. package/dist/cdn/src/__ tests __/AgentClient.spec.d.ts +1 -0
  16. package/dist/cdn/src/__ tests __/AgentSession.spec.d.ts +1 -0
  17. package/dist/cdn/src/__ tests __/DialogClient.spec.d.ts +1 -0
  18. package/dist/cdn/src/api/fetchEventSource/fetch.d.ts +44 -0
  19. package/dist/cdn/src/api/fetchEventSource/index.d.ts +1 -0
  20. package/dist/cdn/src/api/fetchEventSource/parse.d.ts +36 -0
  21. package/dist/cdn/src/api/index.d.ts +2 -0
  22. package/dist/cdn/src/index.d.ts +5 -0
  23. package/dist/cdn/src/utils.d.ts +4 -0
  24. package/dist/es/AgentPlugin.mjs +20 -0
  25. package/dist/es/AgentSession.mjs +243 -0
  26. package/dist/es/BotClient.mjs +242 -0
  27. package/dist/es/Config.mjs +34 -0
  28. package/dist/es/DialogSession.mjs +281 -0
  29. package/dist/es/EventBus.mjs +64 -0
  30. package/dist/es/Logger.mjs +31 -0
  31. package/dist/es/PayloadTypes.mjs +4 -0
  32. package/dist/es/Session.mjs +527 -0
  33. package/dist/es/_virtual/_commonjsHelpers.mjs +4 -0
  34. package/dist/es/_virtual/index.mjs +4 -0
  35. package/dist/es/_virtual/index2.mjs +4 -0
  36. package/dist/es/_virtual/index3.mjs +4 -0
  37. package/dist/es/_virtual/minio-zj.mjs +4 -0
  38. package/dist/es/api/fetchEventSource/fetch.mjs +112 -0
  39. package/dist/es/api/fetchEventSource/parse.mjs +97 -0
  40. package/dist/es/api/index.mjs +48 -0
  41. package/dist/es/index.mjs +11 -0
  42. package/dist/es/node_modules/@glodon-aiot/minio/dist/minio-zj.mjs +26485 -0
  43. package/dist/es/node_modules/@socket.io/component-emitter/lib/esm/index.mjs +54 -0
  44. package/dist/es/node_modules/base64-js/index.mjs +47 -0
  45. package/dist/es/node_modules/buffer/index.mjs +927 -0
  46. package/dist/es/node_modules/engine.io-client/build/esm/contrib/has-cors.mjs +9 -0
  47. package/dist/es/node_modules/engine.io-client/build/esm/contrib/parseqs.mjs +18 -0
  48. package/dist/es/node_modules/engine.io-client/build/esm/contrib/parseuri.mjs +24 -0
  49. package/dist/es/node_modules/engine.io-client/build/esm/contrib/yeast.mjs +19 -0
  50. package/dist/es/node_modules/engine.io-client/build/esm/globalThis.browser.mjs +4 -0
  51. package/dist/es/node_modules/engine.io-client/build/esm/socket.mjs +317 -0
  52. package/dist/es/node_modules/engine.io-client/build/esm/transport.mjs +113 -0
  53. package/dist/es/node_modules/engine.io-client/build/esm/transports/index.mjs +11 -0
  54. package/dist/es/node_modules/engine.io-client/build/esm/transports/polling.mjs +273 -0
  55. package/dist/es/node_modules/engine.io-client/build/esm/transports/websocket-constructor.browser.mjs +8 -0
  56. package/dist/es/node_modules/engine.io-client/build/esm/transports/websocket.mjs +87 -0
  57. package/dist/es/node_modules/engine.io-client/build/esm/transports/webtransport.mjs +52 -0
  58. package/dist/es/node_modules/engine.io-client/build/esm/transports/xmlhttprequest.browser.mjs +21 -0
  59. package/dist/es/node_modules/engine.io-client/build/esm/util.mjs +23 -0
  60. package/dist/es/node_modules/engine.io-parser/build/esm/commons.mjs +21 -0
  61. package/dist/es/node_modules/engine.io-parser/build/esm/contrib/base64-arraybuffer.mjs +14 -0
  62. package/dist/es/node_modules/engine.io-parser/build/esm/decodePacket.browser.mjs +39 -0
  63. package/dist/es/node_modules/engine.io-parser/build/esm/encodePacket.browser.mjs +28 -0
  64. package/dist/es/node_modules/engine.io-parser/build/esm/index.mjs +105 -0
  65. package/dist/es/node_modules/ieee754/index.mjs +28 -0
  66. package/dist/es/node_modules/js-base64/base64.mjs +31 -0
  67. package/dist/es/node_modules/socket.io-client/build/esm/contrib/backo2.mjs +26 -0
  68. package/dist/es/node_modules/socket.io-client/build/esm/index.mjs +25 -0
  69. package/dist/es/node_modules/socket.io-client/build/esm/manager.mjs +242 -0
  70. package/dist/es/node_modules/socket.io-client/build/esm/on.mjs +8 -0
  71. package/dist/es/node_modules/socket.io-client/build/esm/socket.mjs +608 -0
  72. package/dist/es/node_modules/socket.io-client/build/esm/url.mjs +19 -0
  73. package/dist/es/node_modules/socket.io-parser/build/esm/binary.mjs +52 -0
  74. package/dist/es/node_modules/socket.io-parser/build/esm/index.mjs +203 -0
  75. package/dist/es/node_modules/socket.io-parser/build/esm/is-binary.mjs +26 -0
  76. package/dist/es/node_modules/uuid/dist/esm-browser/native.mjs +6 -0
  77. package/dist/es/node_modules/uuid/dist/esm-browser/rng.mjs +10 -0
  78. package/dist/es/node_modules/uuid/dist/esm-browser/stringify.mjs +9 -0
  79. package/dist/es/node_modules/uuid/dist/esm-browser/v4.mjs +19 -0
  80. package/dist/es/packages/apis/dist/es/aecpilot/model.mjs +4 -0
  81. package/dist/es/packages/apis/dist/es/aecpilotui/index.mjs +8 -0
  82. package/dist/es/packages/apis/dist/es/agentcliui/index.mjs +8 -0
  83. package/dist/es/packages/apis/dist/es/base/index.mjs +154 -0
  84. package/dist/es/packages/apis/dist/es/cvforce/index.mjs +431 -0
  85. package/dist/es/packages/apis/dist/es/cvforce/model.mjs +5 -0
  86. package/dist/es/packages/apis/dist/es/node_modules/uuid/dist/esm-browser/native.mjs +1 -0
  87. package/dist/es/packages/apis/dist/es/node_modules/uuid/dist/esm-browser/stringify.mjs +3 -0
  88. package/dist/es/utils.mjs +11 -0
  89. package/dist/lib/index.js +126 -0
  90. package/dist/src/AgentPlugin.d.ts +17 -0
  91. package/dist/src/AgentSession.d.ts +8 -0
  92. package/dist/src/BotClient.d.ts +46 -0
  93. package/dist/src/Config.d.ts +32 -0
  94. package/dist/src/DialogSession.d.ts +21 -0
  95. package/dist/src/EventBus.d.ts +23 -0
  96. package/dist/src/Logger.d.ts +12 -0
  97. package/dist/src/PayloadTypes.d.ts +84 -0
  98. package/dist/src/Session.d.ts +155 -0
  99. package/dist/src/__ tests __/AgentClient.spec.d.ts +1 -0
  100. package/dist/src/__ tests __/AgentSession.spec.d.ts +1 -0
  101. package/dist/src/__ tests __/DialogClient.spec.d.ts +1 -0
  102. package/dist/src/api/fetchEventSource/fetch.d.ts +44 -0
  103. package/dist/src/api/fetchEventSource/index.d.ts +1 -0
  104. package/dist/src/api/fetchEventSource/parse.d.ts +36 -0
  105. package/dist/src/api/index.d.ts +2 -0
  106. package/dist/src/index.d.ts +5 -0
  107. package/dist/src/utils.d.ts +4 -0
  108. package/package.json +102 -0
@@ -0,0 +1,203 @@
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
+ };
@@ -0,0 +1,26 @@
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
+ };
@@ -0,0 +1,6 @@
1
+ const o = typeof crypto != "undefined" && crypto.randomUUID && crypto.randomUUID.bind(crypto), t = {
2
+ randomUUID: o
3
+ };
4
+ export {
5
+ t as default
6
+ };
@@ -0,0 +1,10 @@
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
+ };
@@ -0,0 +1,9 @@
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
+ };
@@ -0,0 +1,19 @@
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
+ };
@@ -0,0 +1,4 @@
1
+ var e = /* @__PURE__ */ ((o) => (o[o.Robot = 1] = "Robot", o[o.User = 2] = "User", o[o.System = 3] = "System", o))(e || {});
2
+ export {
3
+ e as IHistoryRole
4
+ };
@@ -0,0 +1,8 @@
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;
@@ -0,0 +1,8 @@
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;
@@ -0,0 +1,154 @@
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
+ };