@ahoo-wang/fetcher-decorator 0.10.0 → 0.11.1
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 +13 -13
- package/README.zh-CN.md +12 -12
- package/dist/index.es.js +121 -120
- package/dist/index.umd.js +2 -2
- package/dist/resultExtractor.d.ts +12 -20
- package/dist/resultExtractor.d.ts.map +1 -1
- package/package.json +3 -4
package/README.md
CHANGED
|
@@ -58,12 +58,12 @@ const userFetcher = new NamedFetcher('user', {
|
|
|
58
58
|
@api('/users', { fetcher: 'user', timeout: 10000 })
|
|
59
59
|
class UserService {
|
|
60
60
|
@post('/', { timeout: 5000 })
|
|
61
|
-
createUser(@body() user: User): Promise<
|
|
61
|
+
createUser(@body() user: User): Promise<User> {
|
|
62
62
|
throw new Error('Implementation will be generated automatically.');
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
@get('/{id}')
|
|
66
|
-
getUser(@path() id: number, @query() include: string): Promise<
|
|
66
|
+
getUser(@path() id: number, @query() include: string): Promise<User> {
|
|
67
67
|
throw new Error('Implementation will be generated automatically.');
|
|
68
68
|
}
|
|
69
69
|
}
|
|
@@ -145,7 +145,7 @@ Defines an OPTIONS endpoint.
|
|
|
145
145
|
```typescript
|
|
146
146
|
class UserService {
|
|
147
147
|
@get('/{id}', { timeout: 3000 })
|
|
148
|
-
getUser(@path() id: number): Promise<
|
|
148
|
+
getUser(@path() id: number): Promise<User> {
|
|
149
149
|
throw new Error('Implementation will be generated automatically.');
|
|
150
150
|
}
|
|
151
151
|
|
|
@@ -292,11 +292,11 @@ They allow you to customize how the response from an HTTP request is processed a
|
|
|
292
292
|
#### Available Result Extractors
|
|
293
293
|
|
|
294
294
|
- **ExchangeResultExtractor**: Returns the original FetchExchange object
|
|
295
|
-
- **ResponseResultExtractor**: Returns the response object from FetchExchange
|
|
296
|
-
- **JsonResultExtractor**: Parses the response content as JSON format
|
|
295
|
+
- **ResponseResultExtractor**: Returns the response object from FetchExchange
|
|
296
|
+
- **JsonResultExtractor**: Parses the response content as JSON format (default)
|
|
297
297
|
- **TextResultExtractor**: Parses the response content as text format
|
|
298
|
-
- **
|
|
299
|
-
- **
|
|
298
|
+
- **EventStreamResultExtractor**: Extracts server-sent event stream from FetchExchange
|
|
299
|
+
- **JsonEventStreamResultExtractor**: Extracts JSON server-sent event stream from FetchExchange
|
|
300
300
|
|
|
301
301
|
#### Using Result Extractors
|
|
302
302
|
|
|
@@ -313,17 +313,17 @@ class UserService {
|
|
|
313
313
|
throw new Error('Implementation will be generated automatically.');
|
|
314
314
|
}
|
|
315
315
|
|
|
316
|
-
// Overrides with
|
|
317
|
-
@get('/events', { resultExtractor: ResultExtractors.
|
|
316
|
+
// Overrides with EventStream result extractor
|
|
317
|
+
@get('/events', { resultExtractor: ResultExtractors.EventStream })
|
|
318
318
|
getUserEvents(): Promise<ServerSentEventStream> {
|
|
319
319
|
throw new Error('Implementation will be generated automatically.');
|
|
320
320
|
}
|
|
321
321
|
|
|
322
|
-
// Uses
|
|
323
|
-
@
|
|
324
|
-
resultExtractor: ResultExtractors.
|
|
322
|
+
// Uses JsonEventStream result extractor for JSON event handling
|
|
323
|
+
@get('/json-events', {
|
|
324
|
+
resultExtractor: ResultExtractors.JsonEventStream,
|
|
325
325
|
})
|
|
326
|
-
|
|
326
|
+
getJsonEvents(): Promise<JsonServerSentEventStream<MyDataType>> {
|
|
327
327
|
throw new Error('Implementation will be generated automatically.');
|
|
328
328
|
}
|
|
329
329
|
}
|
package/README.zh-CN.md
CHANGED
|
@@ -57,12 +57,12 @@ const userFetcher = new NamedFetcher('user', {
|
|
|
57
57
|
@api('/users', { fetcher: 'user', timeout: 10000 })
|
|
58
58
|
class UserService {
|
|
59
59
|
@post('/', { timeout: 5000 })
|
|
60
|
-
createUser(@body() user: User): Promise<
|
|
60
|
+
createUser(@body() user: User): Promise<User> {
|
|
61
61
|
throw new Error('实现将自动生成');
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
@get('/{id}')
|
|
65
|
-
getUser(@path() id: number, @query() include: string): Promise<
|
|
65
|
+
getUser(@path() id: number, @query() include: string): Promise<User> {
|
|
66
66
|
throw new Error('实现将自动生成');
|
|
67
67
|
}
|
|
68
68
|
}
|
|
@@ -285,11 +285,11 @@ class UserService {
|
|
|
285
285
|
#### 可用的结果提取器
|
|
286
286
|
|
|
287
287
|
- **ExchangeResultExtractor**: 返回原始的 FetchExchange 对象
|
|
288
|
-
- **ResponseResultExtractor**: 返回 FetchExchange
|
|
289
|
-
- **JsonResultExtractor**: 将响应内容解析为 JSON
|
|
288
|
+
- **ResponseResultExtractor**: 返回 FetchExchange 中的响应对象
|
|
289
|
+
- **JsonResultExtractor**: 将响应内容解析为 JSON 格式(默认)
|
|
290
290
|
- **TextResultExtractor**: 将响应内容解析为文本格式
|
|
291
|
-
- **
|
|
292
|
-
- **
|
|
291
|
+
- **EventStreamResultExtractor**: 从 FetchExchange 中提取服务器发送事件流
|
|
292
|
+
- **JsonEventStreamResultExtractor**: 从 FetchExchange 中提取 JSON 服务器发送事件流
|
|
293
293
|
|
|
294
294
|
#### 使用结果提取器
|
|
295
295
|
|
|
@@ -306,17 +306,17 @@ class UserService {
|
|
|
306
306
|
throw new Error('实现将自动生成');
|
|
307
307
|
}
|
|
308
308
|
|
|
309
|
-
// 使用
|
|
310
|
-
@get('/events', { resultExtractor: ResultExtractors.
|
|
309
|
+
// 使用 EventStream 结果提取器覆盖
|
|
310
|
+
@get('/events', { resultExtractor: ResultExtractors.EventStream })
|
|
311
311
|
getUserEvents(): Promise<ServerSentEventStream> {
|
|
312
312
|
throw new Error('实现将自动生成');
|
|
313
313
|
}
|
|
314
314
|
|
|
315
|
-
// 使用
|
|
316
|
-
@
|
|
317
|
-
resultExtractor: ResultExtractors.
|
|
315
|
+
// 使用 JsonEventStream 结果提取器处理 JSON 事件
|
|
316
|
+
@get('/json-events', {
|
|
317
|
+
resultExtractor: ResultExtractors.JsonEventStream,
|
|
318
318
|
})
|
|
319
|
-
|
|
319
|
+
getJsonEvents(): Promise<JsonServerSentEventStream<MyDataType>> {
|
|
320
320
|
throw new Error('实现将自动生成');
|
|
321
321
|
}
|
|
322
322
|
}
|
package/dist/index.es.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { HttpMethod as I, ExchangeError as
|
|
2
|
-
import { toCommandResultEventStream as Xe } from "@ahoo-wang/fetcher-wow";
|
|
1
|
+
import { HttpMethod as I, ExchangeError as me, fetcherRegistrar as Ve, Fetcher as Be, fetcher as Je, mergeRequest as ze, combineURLs as Ze } from "@ahoo-wang/fetcher";
|
|
3
2
|
var he = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, ve = {};
|
|
4
3
|
/*! *****************************************************************************
|
|
5
4
|
Copyright (C) Microsoft. All rights reserved.
|
|
@@ -16,7 +15,7 @@ See the Apache Version 2.0 License for specific language governing permissions
|
|
|
16
15
|
and limitations under the License.
|
|
17
16
|
***************************************************************************** */
|
|
18
17
|
var pe;
|
|
19
|
-
function
|
|
18
|
+
function $e() {
|
|
20
19
|
if (pe) return ve;
|
|
21
20
|
pe = 1;
|
|
22
21
|
var n;
|
|
@@ -48,11 +47,11 @@ function Ke() {
|
|
|
48
47
|
var v = Object.prototype.hasOwnProperty, M = typeof Symbol == "function", O = M && typeof Symbol.toPrimitive < "u" ? Symbol.toPrimitive : "@@toPrimitive", R = M && typeof Symbol.iterator < "u" ? Symbol.iterator : "@@iterator", S = typeof Object.create == "function", A = { __proto__: [] } instanceof Array, b = !S && !A, P = {
|
|
49
48
|
// create an object in dictionary mode (a.k.a. "slow" mode in v8)
|
|
50
49
|
create: S ? function() {
|
|
51
|
-
return
|
|
50
|
+
return J(/* @__PURE__ */ Object.create(null));
|
|
52
51
|
} : A ? function() {
|
|
53
|
-
return
|
|
52
|
+
return J({ __proto__: null });
|
|
54
53
|
} : function() {
|
|
55
|
-
return
|
|
54
|
+
return J({});
|
|
56
55
|
},
|
|
57
56
|
has: b ? function(e, t) {
|
|
58
57
|
return v.call(e, t);
|
|
@@ -64,7 +63,7 @@ function Ke() {
|
|
|
64
63
|
} : function(e, t) {
|
|
65
64
|
return e[t];
|
|
66
65
|
}
|
|
67
|
-
}, k = Object.getPrototypeOf(Function), G = typeof Map == "function" && typeof Map.prototype.entries == "function" ? Map : We(), Y = typeof Set == "function" && typeof Set.prototype.entries == "function" ? Set : Ne(), L = typeof WeakMap == "function" ? WeakMap : Ye(),
|
|
66
|
+
}, k = Object.getPrototypeOf(Function), G = typeof Map == "function" && typeof Map.prototype.entries == "function" ? Map : We(), Y = typeof Set == "function" && typeof Set.prototype.entries == "function" ? Set : Ne(), L = typeof WeakMap == "function" ? WeakMap : Ye(), j = M ? Symbol.for("@reflect-metadata:registry") : void 0, W = Fe(), Z = He(W);
|
|
68
67
|
function Me(e, t, r, a) {
|
|
69
68
|
if (h(r)) {
|
|
70
69
|
if (!ie(e))
|
|
@@ -77,9 +76,9 @@ function Ke() {
|
|
|
77
76
|
throw new TypeError();
|
|
78
77
|
if (!g(t))
|
|
79
78
|
throw new TypeError();
|
|
80
|
-
if (!g(a) && !h(a) && !
|
|
79
|
+
if (!g(a) && !h(a) && !D(a))
|
|
81
80
|
throw new TypeError();
|
|
82
|
-
return
|
|
81
|
+
return D(a) && (a = void 0), r = x(r), Ae(e, t, r, a);
|
|
83
82
|
}
|
|
84
83
|
}
|
|
85
84
|
c("decorate", Me);
|
|
@@ -154,7 +153,7 @@ function Ke() {
|
|
|
154
153
|
function Se(e, t) {
|
|
155
154
|
for (var r = e.length - 1; r >= 0; --r) {
|
|
156
155
|
var a = e[r], l = a(t);
|
|
157
|
-
if (!h(l) && !
|
|
156
|
+
if (!h(l) && !D(l)) {
|
|
158
157
|
if (!oe(l))
|
|
159
158
|
throw new TypeError();
|
|
160
159
|
t = l;
|
|
@@ -165,7 +164,7 @@ function Ke() {
|
|
|
165
164
|
function Ae(e, t, r, a) {
|
|
166
165
|
for (var l = e.length - 1; l >= 0; --l) {
|
|
167
166
|
var m = e[l], E = m(t, r, a);
|
|
168
|
-
if (!h(E) && !
|
|
167
|
+
if (!h(E) && !D(E)) {
|
|
169
168
|
if (!g(E))
|
|
170
169
|
throw new TypeError();
|
|
171
170
|
a = E;
|
|
@@ -178,7 +177,7 @@ function Ke() {
|
|
|
178
177
|
if (a)
|
|
179
178
|
return !0;
|
|
180
179
|
var l = B(t);
|
|
181
|
-
return
|
|
180
|
+
return D(l) ? !1 : $(e, l, r);
|
|
182
181
|
}
|
|
183
182
|
function Q(e, t, r) {
|
|
184
183
|
var a = F(
|
|
@@ -194,7 +193,7 @@ function Ke() {
|
|
|
194
193
|
if (a)
|
|
195
194
|
return K(e, t, r);
|
|
196
195
|
var l = B(t);
|
|
197
|
-
if (!
|
|
196
|
+
if (!D(l))
|
|
198
197
|
return X(e, l, r);
|
|
199
198
|
}
|
|
200
199
|
function K(e, t, r) {
|
|
@@ -267,7 +266,7 @@ function Ke() {
|
|
|
267
266
|
function h(e) {
|
|
268
267
|
return e === void 0;
|
|
269
268
|
}
|
|
270
|
-
function
|
|
269
|
+
function D(e) {
|
|
271
270
|
return e === null;
|
|
272
271
|
}
|
|
273
272
|
function Ie(e) {
|
|
@@ -298,9 +297,9 @@ function Ke() {
|
|
|
298
297
|
throw new TypeError();
|
|
299
298
|
return l;
|
|
300
299
|
}
|
|
301
|
-
return
|
|
300
|
+
return je(e);
|
|
302
301
|
}
|
|
303
|
-
function
|
|
302
|
+
function je(e, t) {
|
|
304
303
|
var r, a, l;
|
|
305
304
|
{
|
|
306
305
|
var m = e.toString;
|
|
@@ -321,12 +320,12 @@ function Ke() {
|
|
|
321
320
|
function ae(e) {
|
|
322
321
|
return !!e;
|
|
323
322
|
}
|
|
324
|
-
function
|
|
323
|
+
function De(e) {
|
|
325
324
|
return "" + e;
|
|
326
325
|
}
|
|
327
326
|
function x(e) {
|
|
328
327
|
var t = qe(e);
|
|
329
|
-
return Ie(t) ? t :
|
|
328
|
+
return Ie(t) ? t : De(t);
|
|
330
329
|
}
|
|
331
330
|
function ie(e) {
|
|
332
331
|
return Array.isArray ? Array.isArray(e) : e instanceof Object ? e instanceof Array : Object.prototype.toString.call(e) === "[object Array]";
|
|
@@ -390,7 +389,7 @@ function Ke() {
|
|
|
390
389
|
}
|
|
391
390
|
function Ge() {
|
|
392
391
|
var e;
|
|
393
|
-
!h(
|
|
392
|
+
!h(j) && typeof d.Reflect < "u" && !(j in d.Reflect) && typeof d.Reflect.defineMetadata == "function" && (e = Ue(d.Reflect));
|
|
394
393
|
var t, r, a, l = new L(), m = {
|
|
395
394
|
registerProvider: E,
|
|
396
395
|
getProvider: o,
|
|
@@ -463,7 +462,7 @@ function Ke() {
|
|
|
463
462
|
}
|
|
464
463
|
function Fe() {
|
|
465
464
|
var e;
|
|
466
|
-
return !h(
|
|
465
|
+
return !h(j) && g(d.Reflect) && Object.isExtensible(d.Reflect) && (e = d.Reflect[j]), h(e) && (e = Ge()), !h(j) && g(d.Reflect) && Object.isExtensible(d.Reflect) && Object.defineProperty(d.Reflect, j, {
|
|
467
466
|
enumerable: !1,
|
|
468
467
|
configurable: !1,
|
|
469
468
|
writable: !1,
|
|
@@ -811,14 +810,14 @@ function Ke() {
|
|
|
811
810
|
return u;
|
|
812
811
|
}
|
|
813
812
|
}
|
|
814
|
-
function
|
|
813
|
+
function J(e) {
|
|
815
814
|
return e.__ = void 0, delete e.__, e;
|
|
816
815
|
}
|
|
817
816
|
});
|
|
818
817
|
})(n || (n = {})), ve;
|
|
819
818
|
}
|
|
820
|
-
|
|
821
|
-
const
|
|
819
|
+
$e();
|
|
820
|
+
const _e = Symbol("endpoint:metadata");
|
|
822
821
|
function q(n, i = "", c = {}) {
|
|
823
822
|
return function(d, v) {
|
|
824
823
|
const M = {
|
|
@@ -827,70 +826,70 @@ function q(n, i = "", c = {}) {
|
|
|
827
826
|
...c
|
|
828
827
|
};
|
|
829
828
|
Reflect.defineMetadata(
|
|
830
|
-
|
|
829
|
+
_e,
|
|
831
830
|
M,
|
|
832
831
|
d,
|
|
833
832
|
v
|
|
834
833
|
);
|
|
835
834
|
};
|
|
836
835
|
}
|
|
837
|
-
function
|
|
836
|
+
function gt(n = "", i = {}) {
|
|
838
837
|
return q(I.GET, n, i);
|
|
839
838
|
}
|
|
840
|
-
function
|
|
839
|
+
function Et(n = "", i = {}) {
|
|
841
840
|
return q(I.POST, n, i);
|
|
842
841
|
}
|
|
843
|
-
function
|
|
842
|
+
function bt(n = "", i = {}) {
|
|
844
843
|
return q(I.PUT, n, i);
|
|
845
844
|
}
|
|
846
|
-
function
|
|
845
|
+
function Ot(n = "", i = {}) {
|
|
847
846
|
return q(I.DELETE, n, i);
|
|
848
847
|
}
|
|
849
|
-
function
|
|
848
|
+
function Rt(n = "", i = {}) {
|
|
850
849
|
return q(I.PATCH, n, i);
|
|
851
850
|
}
|
|
852
|
-
function
|
|
851
|
+
function Pt(n = "", i = {}) {
|
|
853
852
|
return q(I.HEAD, n, i);
|
|
854
853
|
}
|
|
855
|
-
function
|
|
854
|
+
function Tt(n = "", i = {}) {
|
|
856
855
|
return q(I.OPTIONS, n, i);
|
|
857
856
|
}
|
|
858
857
|
const H = /* @__PURE__ */ new WeakMap();
|
|
859
|
-
function
|
|
858
|
+
function Xe(n) {
|
|
860
859
|
if (typeof n != "function")
|
|
861
860
|
throw new TypeError("Expected a function");
|
|
862
861
|
if (H.has(n))
|
|
863
862
|
return H.get(n);
|
|
864
863
|
try {
|
|
865
|
-
const i = n.toString().trim(), c =
|
|
866
|
-
if (!
|
|
864
|
+
const i = n.toString().trim(), c = tt(i);
|
|
865
|
+
if (!et(c)) {
|
|
867
866
|
const v = [];
|
|
868
867
|
return H.set(n, v), v;
|
|
869
868
|
}
|
|
870
|
-
const d =
|
|
869
|
+
const d = rt(c);
|
|
871
870
|
return H.set(n, d), d;
|
|
872
871
|
} catch {
|
|
873
872
|
const i = [];
|
|
874
873
|
return H.set(n, i), i;
|
|
875
874
|
}
|
|
876
875
|
}
|
|
877
|
-
function
|
|
876
|
+
function Ke(n, i, c, d) {
|
|
878
877
|
if (d)
|
|
879
878
|
return d;
|
|
880
879
|
try {
|
|
881
880
|
const v = n[i];
|
|
882
881
|
if (v && typeof v == "function") {
|
|
883
|
-
const M =
|
|
882
|
+
const M = Xe(v);
|
|
884
883
|
if (c < M.length)
|
|
885
884
|
return M[c];
|
|
886
885
|
}
|
|
887
886
|
} catch {
|
|
888
887
|
}
|
|
889
888
|
}
|
|
890
|
-
function
|
|
889
|
+
function et(n) {
|
|
891
890
|
return n != null && n.trim() !== "";
|
|
892
891
|
}
|
|
893
|
-
function
|
|
892
|
+
function tt(n) {
|
|
894
893
|
if (n.startsWith("(")) {
|
|
895
894
|
const d = ye(n, 0);
|
|
896
895
|
return d === -1 ? "" : n.substring(1, d);
|
|
@@ -911,93 +910,95 @@ function ye(n, i) {
|
|
|
911
910
|
}
|
|
912
911
|
return -1;
|
|
913
912
|
}
|
|
914
|
-
function
|
|
915
|
-
return n.split(",").map(
|
|
913
|
+
function rt(n) {
|
|
914
|
+
return n.split(",").map(nt).filter(at).map(it);
|
|
916
915
|
}
|
|
917
|
-
function
|
|
916
|
+
function nt(n) {
|
|
918
917
|
return n.trim();
|
|
919
918
|
}
|
|
920
|
-
function
|
|
919
|
+
function at(n) {
|
|
921
920
|
return n.length > 0;
|
|
922
921
|
}
|
|
923
|
-
function
|
|
924
|
-
let i =
|
|
925
|
-
return i =
|
|
922
|
+
function it(n) {
|
|
923
|
+
let i = ot(n);
|
|
924
|
+
return i = ut(i), i.trim();
|
|
926
925
|
}
|
|
927
|
-
function
|
|
926
|
+
function ot(n) {
|
|
928
927
|
const i = n.indexOf("=");
|
|
929
928
|
return i !== -1 ? n.substring(0, i) : n;
|
|
930
929
|
}
|
|
931
|
-
function
|
|
930
|
+
function ut(n) {
|
|
932
931
|
const i = n.indexOf(":");
|
|
933
932
|
return i !== -1 ? n.substring(0, i) : n;
|
|
934
933
|
}
|
|
935
934
|
var C = /* @__PURE__ */ ((n) => (n.PATH = "path", n.QUERY = "query", n.HEADER = "header", n.BODY = "body", n.REQUEST = "request", n))(C || {});
|
|
936
|
-
const
|
|
935
|
+
const z = Symbol("parameter:metadata");
|
|
937
936
|
function U(n, i = "") {
|
|
938
937
|
return function(c, d, v) {
|
|
939
|
-
const M =
|
|
938
|
+
const M = Ke(
|
|
940
939
|
c,
|
|
941
940
|
d,
|
|
942
941
|
v,
|
|
943
942
|
i
|
|
944
|
-
), O = Reflect.getMetadata(
|
|
943
|
+
), O = Reflect.getMetadata(z, c, d) || [];
|
|
945
944
|
O.push({
|
|
946
945
|
type: n,
|
|
947
946
|
name: M,
|
|
948
947
|
index: v
|
|
949
948
|
}), Reflect.defineMetadata(
|
|
950
|
-
|
|
949
|
+
z,
|
|
951
950
|
O,
|
|
952
951
|
c,
|
|
953
952
|
d
|
|
954
953
|
);
|
|
955
954
|
};
|
|
956
955
|
}
|
|
957
|
-
function
|
|
956
|
+
function kt(n = "") {
|
|
958
957
|
return U("path", n);
|
|
959
958
|
}
|
|
960
|
-
function
|
|
959
|
+
function xt(n = "") {
|
|
961
960
|
return U("query", n);
|
|
962
961
|
}
|
|
963
|
-
function
|
|
962
|
+
function St(n = "") {
|
|
964
963
|
return U("header", n);
|
|
965
964
|
}
|
|
966
|
-
function
|
|
965
|
+
function At() {
|
|
967
966
|
return U(
|
|
968
967
|
"body"
|
|
969
968
|
/* BODY */
|
|
970
969
|
);
|
|
971
970
|
}
|
|
972
|
-
function
|
|
971
|
+
function It() {
|
|
973
972
|
return U(
|
|
974
973
|
"request"
|
|
975
974
|
/* REQUEST */
|
|
976
975
|
);
|
|
977
976
|
}
|
|
978
|
-
const
|
|
977
|
+
const st = (n) => n, ft = (n) => n.requiredResponse, we = (n) => n.requiredResponse.json(), ct = (n) => n.requiredResponse.text(), dt = (n) => {
|
|
979
978
|
if (!n.requiredResponse.eventStream)
|
|
980
|
-
throw new
|
|
979
|
+
throw new me(n, "ServerSentEventStream is not supported");
|
|
981
980
|
return n.requiredResponse.eventStream();
|
|
982
|
-
},
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
981
|
+
}, lt = (n) => {
|
|
982
|
+
if (!n.requiredResponse.jsonEventStream)
|
|
983
|
+
throw new me(
|
|
984
|
+
n,
|
|
985
|
+
"JsonServerSentEventStream is not supported"
|
|
986
|
+
);
|
|
987
|
+
return n.requiredResponse.jsonEventStream();
|
|
988
|
+
}, ht = {
|
|
989
|
+
Exchange: st,
|
|
990
|
+
Response: ft,
|
|
991
|
+
Json: we,
|
|
992
|
+
Text: ct,
|
|
993
|
+
EventStream: dt,
|
|
994
|
+
JsonEventStream: lt,
|
|
994
995
|
DEFAULT: we
|
|
995
996
|
};
|
|
996
|
-
function
|
|
997
|
+
function vt(n) {
|
|
997
998
|
if (n)
|
|
998
|
-
return n instanceof
|
|
999
|
+
return n instanceof Be ? n : Ve.requiredGet(n);
|
|
999
1000
|
}
|
|
1000
|
-
class
|
|
1001
|
+
class pt {
|
|
1001
1002
|
/**
|
|
1002
1003
|
* Creates a new FunctionMetadata instance.
|
|
1003
1004
|
*
|
|
@@ -1018,7 +1019,7 @@ class yt {
|
|
|
1018
1019
|
* @returns The fetcher instance
|
|
1019
1020
|
*/
|
|
1020
1021
|
get fetcher() {
|
|
1021
|
-
return
|
|
1022
|
+
return vt(this.endpoint.fetcher ?? this.api.fetcher) ?? Je;
|
|
1022
1023
|
}
|
|
1023
1024
|
/**
|
|
1024
1025
|
* Resolves the request configuration from the method arguments.
|
|
@@ -1109,7 +1110,7 @@ class yt {
|
|
|
1109
1110
|
timeout: this.resolveTimeout(),
|
|
1110
1111
|
signal: O
|
|
1111
1112
|
};
|
|
1112
|
-
return
|
|
1113
|
+
return ze(A, R);
|
|
1113
1114
|
}
|
|
1114
1115
|
processPathParam(i, c, d) {
|
|
1115
1116
|
const v = i.name || `param${i.index}`;
|
|
@@ -1159,7 +1160,7 @@ class yt {
|
|
|
1159
1160
|
*/
|
|
1160
1161
|
resolvePath() {
|
|
1161
1162
|
const i = this.endpoint.basePath || this.api.basePath || "", c = this.endpoint.path || "";
|
|
1162
|
-
return
|
|
1163
|
+
return Ze(i, c);
|
|
1163
1164
|
}
|
|
1164
1165
|
/**
|
|
1165
1166
|
* Resolves the timeout for the request.
|
|
@@ -1173,10 +1174,10 @@ class yt {
|
|
|
1173
1174
|
return this.endpoint.timeout || this.api.timeout;
|
|
1174
1175
|
}
|
|
1175
1176
|
resolveResultExtractor() {
|
|
1176
|
-
return this.endpoint.resultExtractor || this.api.resultExtractor ||
|
|
1177
|
+
return this.endpoint.resultExtractor || this.api.resultExtractor || ht.DEFAULT;
|
|
1177
1178
|
}
|
|
1178
1179
|
}
|
|
1179
|
-
class
|
|
1180
|
+
class yt {
|
|
1180
1181
|
/**
|
|
1181
1182
|
* Creates a new RequestExecutor instance.
|
|
1182
1183
|
*
|
|
@@ -1202,81 +1203,81 @@ class wt {
|
|
|
1202
1203
|
return await this.metadata.resolveResultExtractor()(M);
|
|
1203
1204
|
}
|
|
1204
1205
|
}
|
|
1205
|
-
const
|
|
1206
|
-
function
|
|
1206
|
+
const wt = Symbol("api:metadata");
|
|
1207
|
+
function mt(n, i, c) {
|
|
1207
1208
|
const d = n.prototype[i];
|
|
1208
1209
|
if (i === "constructor" || typeof d != "function")
|
|
1209
1210
|
return;
|
|
1210
1211
|
const v = Reflect.getMetadata(
|
|
1211
|
-
|
|
1212
|
+
_e,
|
|
1212
1213
|
n.prototype,
|
|
1213
1214
|
i
|
|
1214
1215
|
);
|
|
1215
1216
|
if (!v)
|
|
1216
1217
|
return;
|
|
1217
1218
|
const M = Reflect.getMetadata(
|
|
1218
|
-
|
|
1219
|
+
z,
|
|
1219
1220
|
n.prototype,
|
|
1220
1221
|
i
|
|
1221
|
-
) || [], O = new
|
|
1222
|
+
) || [], O = new pt(
|
|
1222
1223
|
i,
|
|
1223
1224
|
c,
|
|
1224
1225
|
v,
|
|
1225
1226
|
M
|
|
1226
|
-
), R = new
|
|
1227
|
+
), R = new yt(O);
|
|
1227
1228
|
n.prototype[i] = function(...S) {
|
|
1228
1229
|
return R.execute(S);
|
|
1229
1230
|
};
|
|
1230
1231
|
}
|
|
1231
|
-
function
|
|
1232
|
+
function qt(n = "", i = {}) {
|
|
1232
1233
|
return function(c) {
|
|
1233
1234
|
const d = {
|
|
1234
1235
|
basePath: n,
|
|
1235
1236
|
...i
|
|
1236
1237
|
};
|
|
1237
|
-
return Reflect.defineMetadata(
|
|
1238
|
-
|
|
1238
|
+
return Reflect.defineMetadata(wt, d, c), Object.getOwnPropertyNames(c.prototype).forEach((v) => {
|
|
1239
|
+
mt(c, v, d);
|
|
1239
1240
|
}), c;
|
|
1240
1241
|
};
|
|
1241
1242
|
}
|
|
1242
|
-
class
|
|
1243
|
+
class _t extends Error {
|
|
1243
1244
|
constructor() {
|
|
1244
1245
|
super("Implementation will be generated automatically."), this.name = "AutoGenerated";
|
|
1245
1246
|
}
|
|
1246
1247
|
}
|
|
1247
|
-
const
|
|
1248
|
+
const jt = () => new _t();
|
|
1248
1249
|
export {
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1250
|
+
wt as API_METADATA_KEY,
|
|
1251
|
+
_t as AutoGenerated,
|
|
1252
|
+
_e as ENDPOINT_METADATA_KEY,
|
|
1253
|
+
dt as EventStreamResultExtractor,
|
|
1254
|
+
st as ExchangeResultExtractor,
|
|
1255
|
+
pt as FunctionMetadata,
|
|
1256
|
+
lt as JsonEventStreamResultExtractor,
|
|
1257
|
+
we as JsonResultExtractor,
|
|
1258
|
+
z as PARAMETER_METADATA_KEY,
|
|
1257
1259
|
C as ParameterType,
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
jt as
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
Pt as del,
|
|
1260
|
+
yt as RequestExecutor,
|
|
1261
|
+
ft as ResponseResultExtractor,
|
|
1262
|
+
ht as ResultExtractors,
|
|
1263
|
+
ct as TextResultExtractor,
|
|
1264
|
+
qt as api,
|
|
1265
|
+
jt as autoGeneratedError,
|
|
1266
|
+
At as body,
|
|
1267
|
+
Ot as del,
|
|
1267
1268
|
q as endpoint,
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1269
|
+
gt as get,
|
|
1270
|
+
vt as getFetcher,
|
|
1271
|
+
Ke as getParameterName,
|
|
1272
|
+
Xe as getParameterNames,
|
|
1273
|
+
Pt as head,
|
|
1274
|
+
St as header,
|
|
1275
|
+
Tt as options,
|
|
1275
1276
|
U as parameter,
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1277
|
+
Rt as patch,
|
|
1278
|
+
kt as path,
|
|
1279
|
+
Et as post,
|
|
1280
|
+
bt as put,
|
|
1281
|
+
xt as query,
|
|
1282
|
+
It as request
|
|
1282
1283
|
};
|
package/dist/index.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(v,R){typeof exports=="object"&&typeof module<"u"?R(exports,require("@ahoo-wang/fetcher")
|
|
1
|
+
(function(v,R){typeof exports=="object"&&typeof module<"u"?R(exports,require("@ahoo-wang/fetcher")):typeof define=="function"&&define.amd?define(["exports","@ahoo-wang/fetcher"],R):(v=typeof globalThis<"u"?globalThis:v||self,R(v.FetcherDecorator={},v.Fetcher))})(this,(function(v,R){"use strict";var K=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},ee={};/*! *****************************************************************************
|
|
2
2
|
Copyright (C) Microsoft. All rights reserved.
|
|
3
3
|
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
4
4
|
this file except in compliance with the License. You may obtain a copy of the
|
|
@@ -11,4 +11,4 @@
|
|
|
11
11
|
|
|
12
12
|
See the Apache Version 2.0 License for specific language governing permissions
|
|
13
13
|
and limitations under the License.
|
|
14
|
-
***************************************************************************** */var re;function De(){if(re)return te;re=1;var n;return(function(i){(function(c){var d=typeof globalThis=="object"?globalThis:typeof ee=="object"?ee:typeof self=="object"?self:typeof this=="object"?this:x(),y=_(i);typeof d.Reflect<"u"&&(y=_(d.Reflect,y)),c(y,d),typeof d.Reflect>"u"&&(d.Reflect=i);function _(D,O){return function(k,A){Object.defineProperty(D,k,{configurable:!0,writable:!0,value:A}),O&&O(k,A)}}function T(){try{return Function("return this;")()}catch{}}function P(){try{return(0,eval)("(function() { return this; })()")}catch{}}function x(){return T()||P()}})(function(c,d){var y=Object.prototype.hasOwnProperty,_=typeof Symbol=="function",T=_&&typeof Symbol.toPrimitive<"u"?Symbol.toPrimitive:"@@toPrimitive",P=_&&typeof Symbol.iterator<"u"?Symbol.iterator:"@@iterator",x=typeof Object.create=="function",D={__proto__:[]}instanceof Array,O=!x&&!D,k={create:x?function(){return K(Object.create(null))}:D?function(){return K({__proto__:null})}:function(){return K({})},has:O?function(e,t){return y.call(e,t)}:function(e,t){return t in e},get:O?function(e,t){return y.call(e,t)?e[t]:void 0}:function(e,t){return e[t]}},A=Object.getPrototypeOf(Function),U=typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:Ot(),z=typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:Tt(),J=typeof WeakMap=="function"?WeakMap:Pt(),G=_?Symbol.for("@reflect-metadata:registry"):void 0,Y=gt(),pe=bt(Y);function at(e,t,r,a){if(h(r)){if(!Oe(e))throw new TypeError;if(!Te(t))throw new TypeError;return vt(e,t)}else{if(!Oe(e))throw new TypeError;if(!g(t))throw new TypeError;if(!g(a)&&!h(a)&&!H(a))throw new TypeError;return H(a)&&(a=void 0),r=I(r),yt(e,t,r,a)}}c("decorate",at);function it(e,t){function r(a,l){if(!g(a))throw new TypeError;if(!h(l)&&!Mt(l))throw new TypeError;Me(e,t,a,l)}return r}c("metadata",it);function ot(e,t,r,a){if(!g(r))throw new TypeError;return h(a)||(a=I(a)),Me(e,t,r,a)}c("defineMetadata",ot);function ut(e,t,r){if(!g(t))throw new TypeError;return h(r)||(r=I(r)),we(e,t,r)}c("hasMetadata",ut);function st(e,t,r){if(!g(t))throw new TypeError;return h(r)||(r=I(r)),Z(e,t,r)}c("hasOwnMetadata",st);function ft(e,t,r){if(!g(t))throw new TypeError;return h(r)||(r=I(r)),me(e,t,r)}c("getMetadata",ft);function ct(e,t,r){if(!g(t))throw new TypeError;return h(r)||(r=I(r)),Ee(e,t,r)}c("getOwnMetadata",ct);function dt(e,t){if(!g(e))throw new TypeError;return h(t)||(t=I(t)),_e(e,t)}c("getMetadataKeys",dt);function lt(e,t){if(!g(e))throw new TypeError;return h(t)||(t=I(t)),ge(e,t)}c("getOwnMetadataKeys",lt);function ht(e,t,r){if(!g(t))throw new TypeError;if(h(r)||(r=I(r)),!g(t))throw new TypeError;h(r)||(r=I(r));var a=N(t,r,!1);return h(a)?!1:a.OrdinaryDeleteMetadata(e,t,r)}c("deleteMetadata",ht);function vt(e,t){for(var r=e.length-1;r>=0;--r){var a=e[r],l=a(t);if(!h(l)&&!H(l)){if(!Te(l))throw new TypeError;t=l}}return t}function yt(e,t,r,a){for(var l=e.length-1;l>=0;--l){var E=e[l],b=E(t,r,a);if(!h(b)&&!H(b)){if(!g(b))throw new TypeError;a=b}}return a}function we(e,t,r){var a=Z(e,t,r);if(a)return!0;var l=$(t);return H(l)?!1:we(e,l,r)}function Z(e,t,r){var a=N(t,r,!1);return h(a)?!1:Re(a.OrdinaryHasOwnMetadata(e,t,r))}function me(e,t,r){var a=Z(e,t,r);if(a)return Ee(e,t,r);var l=$(t);if(!H(l))return me(e,l,r)}function Ee(e,t,r){var a=N(t,r,!1);if(!h(a))return a.OrdinaryGetOwnMetadata(e,t,r)}function Me(e,t,r,a){var l=N(r,a,!0);l.OrdinaryDefineOwnMetadata(e,t,r,a)}function _e(e,t){var r=ge(e,t),a=$(e);if(a===null)return r;var l=_e(a,t);if(l.length<=0)return r;if(r.length<=0)return l;for(var E=new z,b=[],p=0,o=r;p<o.length;p++){var u=o[p],s=E.has(u);s||(E.add(u),b.push(u))}for(var f=0,w=l;f<w.length;f++){var u=w[f],s=E.has(u);s||(E.add(u),b.push(u))}return b}function ge(e,t){var r=N(e,t,!1);return r?r.OrdinaryOwnMetadataKeys(e,t):[]}function be(e){if(e===null)return 1;switch(typeof e){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return e===null?1:6;default:return 6}}function h(e){return e===void 0}function H(e){return e===null}function pt(e){return typeof e=="symbol"}function g(e){return typeof e=="object"?e!==null:typeof e=="function"}function wt(e,t){switch(be(e)){case 0:return e;case 1:return e;case 2:return e;case 3:return e;case 4:return e;case 5:return e}var r="string",a=Pe(e,T);if(a!==void 0){var l=a.call(e,r);if(g(l))throw new TypeError;return l}return mt(e)}function mt(e,t){var r,a,l;{var E=e.toString;if(L(E)){var a=E.call(e);if(!g(a))return a}var r=e.valueOf;if(L(r)){var a=r.call(e);if(!g(a))return a}}throw new TypeError}function Re(e){return!!e}function Et(e){return""+e}function I(e){var t=wt(e);return pt(t)?t:Et(t)}function Oe(e){return Array.isArray?Array.isArray(e):e instanceof Object?e instanceof Array:Object.prototype.toString.call(e)==="[object Array]"}function L(e){return typeof e=="function"}function Te(e){return typeof e=="function"}function Mt(e){switch(be(e)){case 3:return!0;case 4:return!0;default:return!1}}function X(e,t){return e===t||e!==e&&t!==t}function Pe(e,t){var r=e[t];if(r!=null){if(!L(r))throw new TypeError;return r}}function ke(e){var t=Pe(e,P);if(!L(t))throw new TypeError;var r=t.call(e);if(!g(r))throw new TypeError;return r}function Se(e){return e.value}function Ae(e){var t=e.next();return t.done?!1:t}function Ie(e){var t=e.return;t&&t.call(e)}function $(e){var t=Object.getPrototypeOf(e);if(typeof e!="function"||e===A||t!==A)return t;var r=e.prototype,a=r&&Object.getPrototypeOf(r);if(a==null||a===Object.prototype)return t;var l=a.constructor;return typeof l!="function"||l===e?t:l}function _t(){var e;!h(G)&&typeof d.Reflect<"u"&&!(G in d.Reflect)&&typeof d.Reflect.defineMetadata=="function"&&(e=Rt(d.Reflect));var t,r,a,l=new J,E={registerProvider:b,getProvider:o,setProvider:s};return E;function b(f){if(!Object.isExtensible(E))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case e===f:break;case h(t):t=f;break;case t===f:break;case h(r):r=f;break;case r===f:break;default:a===void 0&&(a=new z),a.add(f);break}}function p(f,w){if(!h(t)){if(t.isProviderFor(f,w))return t;if(!h(r)){if(r.isProviderFor(f,w))return t;if(!h(a))for(var m=ke(a);;){var M=Ae(m);if(!M)return;var S=Se(M);if(S.isProviderFor(f,w))return Ie(m),S}}}if(!h(e)&&e.isProviderFor(f,w))return e}function o(f,w){var m=l.get(f),M;return h(m)||(M=m.get(w)),h(M)&&(M=p(f,w),h(M)||(h(m)&&(m=new U,l.set(f,m)),m.set(w,M))),M}function u(f){if(h(f))throw new TypeError;return t===f||r===f||!h(a)&&a.has(f)}function s(f,w,m){if(!u(m))throw new Error("Metadata provider not registered.");var M=o(f,w);if(M!==m){if(!h(M))return!1;var S=l.get(f);h(S)&&(S=new U,l.set(f,S)),S.set(w,m)}return!0}}function gt(){var e;return!h(G)&&g(d.Reflect)&&Object.isExtensible(d.Reflect)&&(e=d.Reflect[G]),h(e)&&(e=_t()),!h(G)&&g(d.Reflect)&&Object.isExtensible(d.Reflect)&&Object.defineProperty(d.Reflect,G,{enumerable:!1,configurable:!1,writable:!1,value:e}),e}function bt(e){var t=new J,r={isProviderFor:function(u,s){var f=t.get(u);return h(f)?!1:f.has(s)},OrdinaryDefineOwnMetadata:b,OrdinaryHasOwnMetadata:l,OrdinaryGetOwnMetadata:E,OrdinaryOwnMetadataKeys:p,OrdinaryDeleteMetadata:o};return Y.registerProvider(r),r;function a(u,s,f){var w=t.get(u),m=!1;if(h(w)){if(!f)return;w=new U,t.set(u,w),m=!0}var M=w.get(s);if(h(M)){if(!f)return;if(M=new U,w.set(s,M),!e.setProvider(u,s,r))throw w.delete(s),m&&t.delete(u),new Error("Wrong provider for target.")}return M}function l(u,s,f){var w=a(s,f,!1);return h(w)?!1:Re(w.has(u))}function E(u,s,f){var w=a(s,f,!1);if(!h(w))return w.get(u)}function b(u,s,f,w){var m=a(f,w,!0);m.set(u,s)}function p(u,s){var f=[],w=a(u,s,!1);if(h(w))return f;for(var m=w.keys(),M=ke(m),S=0;;){var qe=Ae(M);if(!qe)return f.length=S,f;var kt=Se(qe);try{f[S]=kt}catch(St){try{Ie(M)}finally{throw St}}S++}}function o(u,s,f){var w=a(s,f,!1);if(h(w)||!w.delete(u))return!1;if(w.size===0){var m=t.get(s);h(m)||(m.delete(f),m.size===0&&t.delete(m))}return!0}}function Rt(e){var t=e.defineMetadata,r=e.hasOwnMetadata,a=e.getOwnMetadata,l=e.getOwnMetadataKeys,E=e.deleteMetadata,b=new J,p={isProviderFor:function(o,u){var s=b.get(o);return!h(s)&&s.has(u)?!0:l(o,u).length?(h(s)&&(s=new z,b.set(o,s)),s.add(u),!0):!1},OrdinaryDefineOwnMetadata:t,OrdinaryHasOwnMetadata:r,OrdinaryGetOwnMetadata:a,OrdinaryOwnMetadataKeys:l,OrdinaryDeleteMetadata:E};return p}function N(e,t,r){var a=Y.getProvider(e,t);if(!h(a))return a;if(r){if(Y.setProvider(e,t,pe))return pe;throw new Error("Illegal state.")}}function Ot(){var e={},t=[],r=(function(){function p(o,u,s){this._index=0,this._keys=o,this._values=u,this._selector=s}return p.prototype["@@iterator"]=function(){return this},p.prototype[P]=function(){return this},p.prototype.next=function(){var o=this._index;if(o>=0&&o<this._keys.length){var u=this._selector(this._keys[o],this._values[o]);return o+1>=this._keys.length?(this._index=-1,this._keys=t,this._values=t):this._index++,{value:u,done:!1}}return{value:void 0,done:!0}},p.prototype.throw=function(o){throw this._index>=0&&(this._index=-1,this._keys=t,this._values=t),o},p.prototype.return=function(o){return this._index>=0&&(this._index=-1,this._keys=t,this._values=t),{value:o,done:!0}},p})(),a=(function(){function p(){this._keys=[],this._values=[],this._cacheKey=e,this._cacheIndex=-2}return Object.defineProperty(p.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),p.prototype.has=function(o){return this._find(o,!1)>=0},p.prototype.get=function(o){var u=this._find(o,!1);return u>=0?this._values[u]:void 0},p.prototype.set=function(o,u){var s=this._find(o,!0);return this._values[s]=u,this},p.prototype.delete=function(o){var u=this._find(o,!1);if(u>=0){for(var s=this._keys.length,f=u+1;f<s;f++)this._keys[f-1]=this._keys[f],this._values[f-1]=this._values[f];return this._keys.length--,this._values.length--,X(o,this._cacheKey)&&(this._cacheKey=e,this._cacheIndex=-2),!0}return!1},p.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=e,this._cacheIndex=-2},p.prototype.keys=function(){return new r(this._keys,this._values,l)},p.prototype.values=function(){return new r(this._keys,this._values,E)},p.prototype.entries=function(){return new r(this._keys,this._values,b)},p.prototype["@@iterator"]=function(){return this.entries()},p.prototype[P]=function(){return this.entries()},p.prototype._find=function(o,u){if(!X(this._cacheKey,o)){this._cacheIndex=-1;for(var s=0;s<this._keys.length;s++)if(X(this._keys[s],o)){this._cacheIndex=s;break}}return this._cacheIndex<0&&u&&(this._cacheIndex=this._keys.length,this._keys.push(o),this._values.push(void 0)),this._cacheIndex},p})();return a;function l(p,o){return p}function E(p,o){return o}function b(p,o){return[p,o]}}function Tt(){var e=(function(){function t(){this._map=new U}return Object.defineProperty(t.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),t.prototype.has=function(r){return this._map.has(r)},t.prototype.add=function(r){return this._map.set(r,r),this},t.prototype.delete=function(r){return this._map.delete(r)},t.prototype.clear=function(){this._map.clear()},t.prototype.keys=function(){return this._map.keys()},t.prototype.values=function(){return this._map.keys()},t.prototype.entries=function(){return this._map.entries()},t.prototype["@@iterator"]=function(){return this.keys()},t.prototype[P]=function(){return this.keys()},t})();return e}function Pt(){var e=16,t=k.create(),r=a();return(function(){function o(){this._key=a()}return o.prototype.has=function(u){var s=l(u,!1);return s!==void 0?k.has(s,this._key):!1},o.prototype.get=function(u){var s=l(u,!1);return s!==void 0?k.get(s,this._key):void 0},o.prototype.set=function(u,s){var f=l(u,!0);return f[this._key]=s,this},o.prototype.delete=function(u){var s=l(u,!1);return s!==void 0?delete s[this._key]:!1},o.prototype.clear=function(){this._key=a()},o})();function a(){var o;do o="@@WeakMap@@"+p();while(k.has(t,o));return t[o]=!0,o}function l(o,u){if(!y.call(o,r)){if(!u)return;Object.defineProperty(o,r,{value:k.create()})}return o[r]}function E(o,u){for(var s=0;s<u;++s)o[s]=Math.random()*255|0;return o}function b(o){if(typeof Uint8Array=="function"){var u=new Uint8Array(o);return typeof crypto<"u"?crypto.getRandomValues(u):typeof msCrypto<"u"?msCrypto.getRandomValues(u):E(u,o),u}return E(new Array(o),o)}function p(){var o=b(e);o[6]=o[6]&79|64,o[8]=o[8]&191|128;for(var u="",s=0;s<e;++s){var f=o[s];(s===4||s===6||s===8)&&(u+="-"),f<16&&(u+="0"),u+=f.toString(16).toLowerCase()}return u}}function K(e){return e.__=void 0,delete e.__,e}})})(n||(n={})),te}De();const Q=Symbol("endpoint:metadata");function q(n,i="",c={}){return function(d,y){const _={method:n,path:i,...c};Reflect.defineMetadata(Q,_,d,y)}}function je(n="",i={}){return q(R.HttpMethod.GET,n,i)}function Ce(n="",i={}){return q(R.HttpMethod.POST,n,i)}function Ge(n="",i={}){return q(R.HttpMethod.PUT,n,i)}function He(n="",i={}){return q(R.HttpMethod.DELETE,n,i)}function Fe(n="",i={}){return q(R.HttpMethod.PATCH,n,i)}function Ue(n="",i={}){return q(R.HttpMethod.HEAD,n,i)}function Ne(n="",i={}){return q(R.HttpMethod.OPTIONS,n,i)}const F=new WeakMap;function ne(n){if(typeof n!="function")throw new TypeError("Expected a function");if(F.has(n))return F.get(n);try{const i=n.toString().trim(),c=Ye(i);if(!We(c)){const y=[];return F.set(n,y),y}const d=Le(c);return F.set(n,d),d}catch{const i=[];return F.set(n,i),i}}function ae(n,i,c,d){if(d)return d;try{const y=n[i];if(y&&typeof y=="function"){const _=ne(y);if(c<_.length)return _[c]}}catch{}}function We(n){return n!=null&&n.trim()!==""}function Ye(n){if(n.startsWith("(")){const d=ie(n,0);return d===-1?"":n.substring(1,d)}const i=n.indexOf("(");if(i===-1)return"";const c=ie(n,i);return c===-1?"":n.substring(i+1,c)}function ie(n,i){let c=1;for(let d=i+1;d<n.length;d++){const y=n[d];if(y==="(")c++;else if(y===")"&&(c--,c===0))return d}return-1}function Le(n){return n.split(",").map(Qe).filter(Ve).map(Be)}function Qe(n){return n.trim()}function Ve(n){return n.length>0}function Be(n){let i=ze(n);return i=Je(i),i.trim()}function ze(n){const i=n.indexOf("=");return i!==-1?n.substring(0,i):n}function Je(n){const i=n.indexOf(":");return i!==-1?n.substring(0,i):n}var j=(n=>(n.PATH="path",n.QUERY="query",n.HEADER="header",n.BODY="body",n.REQUEST="request",n))(j||{});const W=Symbol("parameter:metadata");function C(n,i=""){return function(c,d,y){const _=ae(c,d,y,i),T=Reflect.getMetadata(W,c,d)||[];T.push({type:n,name:_,index:y}),Reflect.defineMetadata(W,T,c,d)}}function Ze(n=""){return C("path",n)}function Xe(n=""){return C("query",n)}function $e(n=""){return C("header",n)}function Ke(){return C("body")}function et(){return C("request")}const oe=n=>n,V=n=>n.requiredResponse,ue=n=>n.requiredResponse.json(),se=n=>n.requiredResponse.text(),B=n=>{if(!n.requiredResponse.eventStream)throw new R.ExchangeError(n,"ServerSentEventStream is not supported");return n.requiredResponse.eventStream()},fe=n=>{const i=B(n);return xe.toCommandResultEventStream(i)},ce={Exchange:oe,Response:V,Json:ue,Text:se,ServerSentEventStream:B,CommandResultEventStream:fe,DEFAULT:V};function de(n){if(n)return n instanceof R.Fetcher?n:R.fetcherRegistrar.requiredGet(n)}class le{constructor(i,c,d,y){this.name=i,this.api=c,this.endpoint=d,this.parameters=y}get fetcher(){return de(this.endpoint.fetcher??this.api.fetcher)??R.fetcher}resolveRequest(i){const c={},d={},y={...this.api.headers,...this.endpoint.headers};let _,T,P={};i.forEach((O,k)=>{if(O instanceof AbortSignal){T=O;return}if(k<this.parameters.length){const A=this.parameters[k];switch(A.type){case j.PATH:this.processPathParam(A,O,c);break;case j.QUERY:this.processQueryParam(A,O,d);break;case j.HEADER:this.processHeaderParam(A,O,y);break;case j.BODY:_=O;break;case j.REQUEST:P=this.processRequestParam(O);break}}});const x={path:c,query:d},D={method:this.endpoint.method,urlParams:x,headers:y,body:_,timeout:this.resolveTimeout(),signal:T};return R.mergeRequest(D,P)}processPathParam(i,c,d){const y=i.name||`param${i.index}`;d[y]=c}processQueryParam(i,c,d){const y=i.name||`param${i.index}`;d[y]=c}processHeaderParam(i,c,d){i.name&&c!==void 0&&(d[i.name]=String(c))}processRequestParam(i){return i}resolvePath(){const i=this.endpoint.basePath||this.api.basePath||"",c=this.endpoint.path||"";return R.combineURLs(i,c)}resolveTimeout(){return this.endpoint.timeout||this.api.timeout}resolveResultExtractor(){return this.endpoint.resultExtractor||this.api.resultExtractor||ce.DEFAULT}}class he{constructor(i){this.metadata=i}async execute(i){const c=this.metadata.resolvePath(),d=this.metadata.resolveRequest(i),y={url:c,...d},_=await this.metadata.fetcher.request(y);return await this.metadata.resolveResultExtractor()(_)}}const ve=Symbol("api:metadata");function tt(n,i,c){const d=n.prototype[i];if(i==="constructor"||typeof d!="function")return;const y=Reflect.getMetadata(Q,n.prototype,i);if(!y)return;const _=Reflect.getMetadata(W,n.prototype,i)||[],T=new le(i,c,y,_),P=new he(T);n.prototype[i]=function(...x){return P.execute(x)}}function rt(n="",i={}){return function(c){const d={basePath:n,...i};return Reflect.defineMetadata(ve,d,c),Object.getOwnPropertyNames(c.prototype).forEach(y=>{tt(c,y,d)}),c}}class ye extends Error{constructor(){super("Implementation will be generated automatically."),this.name="AutoGenerated"}}const nt=()=>new ye;v.API_METADATA_KEY=ve,v.AutoGenerated=ye,v.CommandResultEventStreamResultExtractor=fe,v.ENDPOINT_METADATA_KEY=Q,v.ExchangeResultExtractor=oe,v.FunctionMetadata=le,v.JsonResultExtractor=ue,v.PARAMETER_METADATA_KEY=W,v.ParameterType=j,v.RequestExecutor=he,v.ResponseResultExtractor=V,v.ResultExtractors=ce,v.ServerSentEventStreamResultExtractor=B,v.TextResultExtractor=se,v.api=rt,v.autoGeneratedError=nt,v.body=Ke,v.del=He,v.endpoint=q,v.get=je,v.getFetcher=de,v.getParameterName=ae,v.getParameterNames=ne,v.head=Ue,v.header=$e,v.options=Ne,v.parameter=C,v.patch=Fe,v.path=Ze,v.post=Ce,v.put=Ge,v.query=Xe,v.request=et,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})}));
|
|
14
|
+
***************************************************************************** */var te;function De(){if(te)return ee;te=1;var n;return(function(i){(function(c){var d=typeof globalThis=="object"?globalThis:typeof K=="object"?K:typeof self=="object"?self:typeof this=="object"?this:D(),y=_(i);typeof d.Reflect<"u"&&(y=_(d.Reflect,y)),c(y,d),typeof d.Reflect>"u"&&(d.Reflect=i);function _(x,O){return function(k,A){Object.defineProperty(x,k,{configurable:!0,writable:!0,value:A}),O&&O(k,A)}}function T(){try{return Function("return this;")()}catch{}}function P(){try{return(0,eval)("(function() { return this; })()")}catch{}}function D(){return T()||P()}})(function(c,d){var y=Object.prototype.hasOwnProperty,_=typeof Symbol=="function",T=_&&typeof Symbol.toPrimitive<"u"?Symbol.toPrimitive:"@@toPrimitive",P=_&&typeof Symbol.iterator<"u"?Symbol.iterator:"@@iterator",D=typeof Object.create=="function",x={__proto__:[]}instanceof Array,O=!D&&!x,k={create:D?function(){return $(Object.create(null))}:x?function(){return $({__proto__:null})}:function(){return $({})},has:O?function(e,t){return y.call(e,t)}:function(e,t){return t in e},get:O?function(e,t){return y.call(e,t)?e[t]:void 0}:function(e,t){return e[t]}},A=Object.getPrototypeOf(Function),U=typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:Rt(),V=typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:Ot(),B=typeof WeakMap=="function"?WeakMap:Tt(),G=_?Symbol.for("@reflect-metadata:registry"):void 0,Y=_t(),pe=gt(Y);function nt(e,t,r,a){if(h(r)){if(!Oe(e))throw new TypeError;if(!Te(t))throw new TypeError;return ht(e,t)}else{if(!Oe(e))throw new TypeError;if(!g(t))throw new TypeError;if(!g(a)&&!h(a)&&!H(a))throw new TypeError;return H(a)&&(a=void 0),r=I(r),vt(e,t,r,a)}}c("decorate",nt);function at(e,t){function r(a,l){if(!g(a))throw new TypeError;if(!h(l)&&!Et(l))throw new TypeError;Me(e,t,a,l)}return r}c("metadata",at);function it(e,t,r,a){if(!g(r))throw new TypeError;return h(a)||(a=I(a)),Me(e,t,r,a)}c("defineMetadata",it);function ot(e,t,r){if(!g(t))throw new TypeError;return h(r)||(r=I(r)),we(e,t,r)}c("hasMetadata",ot);function ut(e,t,r){if(!g(t))throw new TypeError;return h(r)||(r=I(r)),z(e,t,r)}c("hasOwnMetadata",ut);function st(e,t,r){if(!g(t))throw new TypeError;return h(r)||(r=I(r)),me(e,t,r)}c("getMetadata",st);function ft(e,t,r){if(!g(t))throw new TypeError;return h(r)||(r=I(r)),Ee(e,t,r)}c("getOwnMetadata",ft);function ct(e,t){if(!g(e))throw new TypeError;return h(t)||(t=I(t)),_e(e,t)}c("getMetadataKeys",ct);function dt(e,t){if(!g(e))throw new TypeError;return h(t)||(t=I(t)),ge(e,t)}c("getOwnMetadataKeys",dt);function lt(e,t,r){if(!g(t))throw new TypeError;if(h(r)||(r=I(r)),!g(t))throw new TypeError;h(r)||(r=I(r));var a=N(t,r,!1);return h(a)?!1:a.OrdinaryDeleteMetadata(e,t,r)}c("deleteMetadata",lt);function ht(e,t){for(var r=e.length-1;r>=0;--r){var a=e[r],l=a(t);if(!h(l)&&!H(l)){if(!Te(l))throw new TypeError;t=l}}return t}function vt(e,t,r,a){for(var l=e.length-1;l>=0;--l){var E=e[l],b=E(t,r,a);if(!h(b)&&!H(b)){if(!g(b))throw new TypeError;a=b}}return a}function we(e,t,r){var a=z(e,t,r);if(a)return!0;var l=X(t);return H(l)?!1:we(e,l,r)}function z(e,t,r){var a=N(t,r,!1);return h(a)?!1:Re(a.OrdinaryHasOwnMetadata(e,t,r))}function me(e,t,r){var a=z(e,t,r);if(a)return Ee(e,t,r);var l=X(t);if(!H(l))return me(e,l,r)}function Ee(e,t,r){var a=N(t,r,!1);if(!h(a))return a.OrdinaryGetOwnMetadata(e,t,r)}function Me(e,t,r,a){var l=N(r,a,!0);l.OrdinaryDefineOwnMetadata(e,t,r,a)}function _e(e,t){var r=ge(e,t),a=X(e);if(a===null)return r;var l=_e(a,t);if(l.length<=0)return r;if(r.length<=0)return l;for(var E=new V,b=[],p=0,o=r;p<o.length;p++){var u=o[p],s=E.has(u);s||(E.add(u),b.push(u))}for(var f=0,w=l;f<w.length;f++){var u=w[f],s=E.has(u);s||(E.add(u),b.push(u))}return b}function ge(e,t){var r=N(e,t,!1);return r?r.OrdinaryOwnMetadataKeys(e,t):[]}function be(e){if(e===null)return 1;switch(typeof e){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return e===null?1:6;default:return 6}}function h(e){return e===void 0}function H(e){return e===null}function yt(e){return typeof e=="symbol"}function g(e){return typeof e=="object"?e!==null:typeof e=="function"}function pt(e,t){switch(be(e)){case 0:return e;case 1:return e;case 2:return e;case 3:return e;case 4:return e;case 5:return e}var r="string",a=Pe(e,T);if(a!==void 0){var l=a.call(e,r);if(g(l))throw new TypeError;return l}return wt(e)}function wt(e,t){var r,a,l;{var E=e.toString;if(J(E)){var a=E.call(e);if(!g(a))return a}var r=e.valueOf;if(J(r)){var a=r.call(e);if(!g(a))return a}}throw new TypeError}function Re(e){return!!e}function mt(e){return""+e}function I(e){var t=pt(e);return yt(t)?t:mt(t)}function Oe(e){return Array.isArray?Array.isArray(e):e instanceof Object?e instanceof Array:Object.prototype.toString.call(e)==="[object Array]"}function J(e){return typeof e=="function"}function Te(e){return typeof e=="function"}function Et(e){switch(be(e)){case 3:return!0;case 4:return!0;default:return!1}}function Z(e,t){return e===t||e!==e&&t!==t}function Pe(e,t){var r=e[t];if(r!=null){if(!J(r))throw new TypeError;return r}}function ke(e){var t=Pe(e,P);if(!J(t))throw new TypeError;var r=t.call(e);if(!g(r))throw new TypeError;return r}function Se(e){return e.value}function Ae(e){var t=e.next();return t.done?!1:t}function Ie(e){var t=e.return;t&&t.call(e)}function X(e){var t=Object.getPrototypeOf(e);if(typeof e!="function"||e===A||t!==A)return t;var r=e.prototype,a=r&&Object.getPrototypeOf(r);if(a==null||a===Object.prototype)return t;var l=a.constructor;return typeof l!="function"||l===e?t:l}function Mt(){var e;!h(G)&&typeof d.Reflect<"u"&&!(G in d.Reflect)&&typeof d.Reflect.defineMetadata=="function"&&(e=bt(d.Reflect));var t,r,a,l=new B,E={registerProvider:b,getProvider:o,setProvider:s};return E;function b(f){if(!Object.isExtensible(E))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case e===f:break;case h(t):t=f;break;case t===f:break;case h(r):r=f;break;case r===f:break;default:a===void 0&&(a=new V),a.add(f);break}}function p(f,w){if(!h(t)){if(t.isProviderFor(f,w))return t;if(!h(r)){if(r.isProviderFor(f,w))return t;if(!h(a))for(var m=ke(a);;){var M=Ae(m);if(!M)return;var S=Se(M);if(S.isProviderFor(f,w))return Ie(m),S}}}if(!h(e)&&e.isProviderFor(f,w))return e}function o(f,w){var m=l.get(f),M;return h(m)||(M=m.get(w)),h(M)&&(M=p(f,w),h(M)||(h(m)&&(m=new U,l.set(f,m)),m.set(w,M))),M}function u(f){if(h(f))throw new TypeError;return t===f||r===f||!h(a)&&a.has(f)}function s(f,w,m){if(!u(m))throw new Error("Metadata provider not registered.");var M=o(f,w);if(M!==m){if(!h(M))return!1;var S=l.get(f);h(S)&&(S=new U,l.set(f,S)),S.set(w,m)}return!0}}function _t(){var e;return!h(G)&&g(d.Reflect)&&Object.isExtensible(d.Reflect)&&(e=d.Reflect[G]),h(e)&&(e=Mt()),!h(G)&&g(d.Reflect)&&Object.isExtensible(d.Reflect)&&Object.defineProperty(d.Reflect,G,{enumerable:!1,configurable:!1,writable:!1,value:e}),e}function gt(e){var t=new B,r={isProviderFor:function(u,s){var f=t.get(u);return h(f)?!1:f.has(s)},OrdinaryDefineOwnMetadata:b,OrdinaryHasOwnMetadata:l,OrdinaryGetOwnMetadata:E,OrdinaryOwnMetadataKeys:p,OrdinaryDeleteMetadata:o};return Y.registerProvider(r),r;function a(u,s,f){var w=t.get(u),m=!1;if(h(w)){if(!f)return;w=new U,t.set(u,w),m=!0}var M=w.get(s);if(h(M)){if(!f)return;if(M=new U,w.set(s,M),!e.setProvider(u,s,r))throw w.delete(s),m&&t.delete(u),new Error("Wrong provider for target.")}return M}function l(u,s,f){var w=a(s,f,!1);return h(w)?!1:Re(w.has(u))}function E(u,s,f){var w=a(s,f,!1);if(!h(w))return w.get(u)}function b(u,s,f,w){var m=a(f,w,!0);m.set(u,s)}function p(u,s){var f=[],w=a(u,s,!1);if(h(w))return f;for(var m=w.keys(),M=ke(m),S=0;;){var qe=Ae(M);if(!qe)return f.length=S,f;var Pt=Se(qe);try{f[S]=Pt}catch(kt){try{Ie(M)}finally{throw kt}}S++}}function o(u,s,f){var w=a(s,f,!1);if(h(w)||!w.delete(u))return!1;if(w.size===0){var m=t.get(s);h(m)||(m.delete(f),m.size===0&&t.delete(m))}return!0}}function bt(e){var t=e.defineMetadata,r=e.hasOwnMetadata,a=e.getOwnMetadata,l=e.getOwnMetadataKeys,E=e.deleteMetadata,b=new B,p={isProviderFor:function(o,u){var s=b.get(o);return!h(s)&&s.has(u)?!0:l(o,u).length?(h(s)&&(s=new V,b.set(o,s)),s.add(u),!0):!1},OrdinaryDefineOwnMetadata:t,OrdinaryHasOwnMetadata:r,OrdinaryGetOwnMetadata:a,OrdinaryOwnMetadataKeys:l,OrdinaryDeleteMetadata:E};return p}function N(e,t,r){var a=Y.getProvider(e,t);if(!h(a))return a;if(r){if(Y.setProvider(e,t,pe))return pe;throw new Error("Illegal state.")}}function Rt(){var e={},t=[],r=(function(){function p(o,u,s){this._index=0,this._keys=o,this._values=u,this._selector=s}return p.prototype["@@iterator"]=function(){return this},p.prototype[P]=function(){return this},p.prototype.next=function(){var o=this._index;if(o>=0&&o<this._keys.length){var u=this._selector(this._keys[o],this._values[o]);return o+1>=this._keys.length?(this._index=-1,this._keys=t,this._values=t):this._index++,{value:u,done:!1}}return{value:void 0,done:!0}},p.prototype.throw=function(o){throw this._index>=0&&(this._index=-1,this._keys=t,this._values=t),o},p.prototype.return=function(o){return this._index>=0&&(this._index=-1,this._keys=t,this._values=t),{value:o,done:!0}},p})(),a=(function(){function p(){this._keys=[],this._values=[],this._cacheKey=e,this._cacheIndex=-2}return Object.defineProperty(p.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),p.prototype.has=function(o){return this._find(o,!1)>=0},p.prototype.get=function(o){var u=this._find(o,!1);return u>=0?this._values[u]:void 0},p.prototype.set=function(o,u){var s=this._find(o,!0);return this._values[s]=u,this},p.prototype.delete=function(o){var u=this._find(o,!1);if(u>=0){for(var s=this._keys.length,f=u+1;f<s;f++)this._keys[f-1]=this._keys[f],this._values[f-1]=this._values[f];return this._keys.length--,this._values.length--,Z(o,this._cacheKey)&&(this._cacheKey=e,this._cacheIndex=-2),!0}return!1},p.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=e,this._cacheIndex=-2},p.prototype.keys=function(){return new r(this._keys,this._values,l)},p.prototype.values=function(){return new r(this._keys,this._values,E)},p.prototype.entries=function(){return new r(this._keys,this._values,b)},p.prototype["@@iterator"]=function(){return this.entries()},p.prototype[P]=function(){return this.entries()},p.prototype._find=function(o,u){if(!Z(this._cacheKey,o)){this._cacheIndex=-1;for(var s=0;s<this._keys.length;s++)if(Z(this._keys[s],o)){this._cacheIndex=s;break}}return this._cacheIndex<0&&u&&(this._cacheIndex=this._keys.length,this._keys.push(o),this._values.push(void 0)),this._cacheIndex},p})();return a;function l(p,o){return p}function E(p,o){return o}function b(p,o){return[p,o]}}function Ot(){var e=(function(){function t(){this._map=new U}return Object.defineProperty(t.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),t.prototype.has=function(r){return this._map.has(r)},t.prototype.add=function(r){return this._map.set(r,r),this},t.prototype.delete=function(r){return this._map.delete(r)},t.prototype.clear=function(){this._map.clear()},t.prototype.keys=function(){return this._map.keys()},t.prototype.values=function(){return this._map.keys()},t.prototype.entries=function(){return this._map.entries()},t.prototype["@@iterator"]=function(){return this.keys()},t.prototype[P]=function(){return this.keys()},t})();return e}function Tt(){var e=16,t=k.create(),r=a();return(function(){function o(){this._key=a()}return o.prototype.has=function(u){var s=l(u,!1);return s!==void 0?k.has(s,this._key):!1},o.prototype.get=function(u){var s=l(u,!1);return s!==void 0?k.get(s,this._key):void 0},o.prototype.set=function(u,s){var f=l(u,!0);return f[this._key]=s,this},o.prototype.delete=function(u){var s=l(u,!1);return s!==void 0?delete s[this._key]:!1},o.prototype.clear=function(){this._key=a()},o})();function a(){var o;do o="@@WeakMap@@"+p();while(k.has(t,o));return t[o]=!0,o}function l(o,u){if(!y.call(o,r)){if(!u)return;Object.defineProperty(o,r,{value:k.create()})}return o[r]}function E(o,u){for(var s=0;s<u;++s)o[s]=Math.random()*255|0;return o}function b(o){if(typeof Uint8Array=="function"){var u=new Uint8Array(o);return typeof crypto<"u"?crypto.getRandomValues(u):typeof msCrypto<"u"?msCrypto.getRandomValues(u):E(u,o),u}return E(new Array(o),o)}function p(){var o=b(e);o[6]=o[6]&79|64,o[8]=o[8]&191|128;for(var u="",s=0;s<e;++s){var f=o[s];(s===4||s===6||s===8)&&(u+="-"),f<16&&(u+="0"),u+=f.toString(16).toLowerCase()}return u}}function $(e){return e.__=void 0,delete e.__,e}})})(n||(n={})),ee}De();const L=Symbol("endpoint:metadata");function q(n,i="",c={}){return function(d,y){const _={method:n,path:i,...c};Reflect.defineMetadata(L,_,d,y)}}function xe(n="",i={}){return q(R.HttpMethod.GET,n,i)}function je(n="",i={}){return q(R.HttpMethod.POST,n,i)}function Ce(n="",i={}){return q(R.HttpMethod.PUT,n,i)}function Ge(n="",i={}){return q(R.HttpMethod.DELETE,n,i)}function He(n="",i={}){return q(R.HttpMethod.PATCH,n,i)}function Fe(n="",i={}){return q(R.HttpMethod.HEAD,n,i)}function Ue(n="",i={}){return q(R.HttpMethod.OPTIONS,n,i)}const F=new WeakMap;function re(n){if(typeof n!="function")throw new TypeError("Expected a function");if(F.has(n))return F.get(n);try{const i=n.toString().trim(),c=We(i);if(!Ne(c)){const y=[];return F.set(n,y),y}const d=Ye(c);return F.set(n,d),d}catch{const i=[];return F.set(n,i),i}}function ne(n,i,c,d){if(d)return d;try{const y=n[i];if(y&&typeof y=="function"){const _=re(y);if(c<_.length)return _[c]}}catch{}}function Ne(n){return n!=null&&n.trim()!==""}function We(n){if(n.startsWith("(")){const d=ae(n,0);return d===-1?"":n.substring(1,d)}const i=n.indexOf("(");if(i===-1)return"";const c=ae(n,i);return c===-1?"":n.substring(i+1,c)}function ae(n,i){let c=1;for(let d=i+1;d<n.length;d++){const y=n[d];if(y==="(")c++;else if(y===")"&&(c--,c===0))return d}return-1}function Ye(n){return n.split(",").map(Je).filter(Le).map(Qe)}function Je(n){return n.trim()}function Le(n){return n.length>0}function Qe(n){let i=Ve(n);return i=Be(i),i.trim()}function Ve(n){const i=n.indexOf("=");return i!==-1?n.substring(0,i):n}function Be(n){const i=n.indexOf(":");return i!==-1?n.substring(0,i):n}var j=(n=>(n.PATH="path",n.QUERY="query",n.HEADER="header",n.BODY="body",n.REQUEST="request",n))(j||{});const W=Symbol("parameter:metadata");function C(n,i=""){return function(c,d,y){const _=ne(c,d,y,i),T=Reflect.getMetadata(W,c,d)||[];T.push({type:n,name:_,index:y}),Reflect.defineMetadata(W,T,c,d)}}function ze(n=""){return C("path",n)}function Ze(n=""){return C("query",n)}function Xe(n=""){return C("header",n)}function $e(){return C("body")}function Ke(){return C("request")}const ie=n=>n,oe=n=>n.requiredResponse,Q=n=>n.requiredResponse.json(),ue=n=>n.requiredResponse.text(),se=n=>{if(!n.requiredResponse.eventStream)throw new R.ExchangeError(n,"ServerSentEventStream is not supported");return n.requiredResponse.eventStream()},fe=n=>{if(!n.requiredResponse.jsonEventStream)throw new R.ExchangeError(n,"JsonServerSentEventStream is not supported");return n.requiredResponse.jsonEventStream()},ce={Exchange:ie,Response:oe,Json:Q,Text:ue,EventStream:se,JsonEventStream:fe,DEFAULT:Q};function de(n){if(n)return n instanceof R.Fetcher?n:R.fetcherRegistrar.requiredGet(n)}class le{constructor(i,c,d,y){this.name=i,this.api=c,this.endpoint=d,this.parameters=y}get fetcher(){return de(this.endpoint.fetcher??this.api.fetcher)??R.fetcher}resolveRequest(i){const c={},d={},y={...this.api.headers,...this.endpoint.headers};let _,T,P={};i.forEach((O,k)=>{if(O instanceof AbortSignal){T=O;return}if(k<this.parameters.length){const A=this.parameters[k];switch(A.type){case j.PATH:this.processPathParam(A,O,c);break;case j.QUERY:this.processQueryParam(A,O,d);break;case j.HEADER:this.processHeaderParam(A,O,y);break;case j.BODY:_=O;break;case j.REQUEST:P=this.processRequestParam(O);break}}});const D={path:c,query:d},x={method:this.endpoint.method,urlParams:D,headers:y,body:_,timeout:this.resolveTimeout(),signal:T};return R.mergeRequest(x,P)}processPathParam(i,c,d){const y=i.name||`param${i.index}`;d[y]=c}processQueryParam(i,c,d){const y=i.name||`param${i.index}`;d[y]=c}processHeaderParam(i,c,d){i.name&&c!==void 0&&(d[i.name]=String(c))}processRequestParam(i){return i}resolvePath(){const i=this.endpoint.basePath||this.api.basePath||"",c=this.endpoint.path||"";return R.combineURLs(i,c)}resolveTimeout(){return this.endpoint.timeout||this.api.timeout}resolveResultExtractor(){return this.endpoint.resultExtractor||this.api.resultExtractor||ce.DEFAULT}}class he{constructor(i){this.metadata=i}async execute(i){const c=this.metadata.resolvePath(),d=this.metadata.resolveRequest(i),y={url:c,...d},_=await this.metadata.fetcher.request(y);return await this.metadata.resolveResultExtractor()(_)}}const ve=Symbol("api:metadata");function et(n,i,c){const d=n.prototype[i];if(i==="constructor"||typeof d!="function")return;const y=Reflect.getMetadata(L,n.prototype,i);if(!y)return;const _=Reflect.getMetadata(W,n.prototype,i)||[],T=new le(i,c,y,_),P=new he(T);n.prototype[i]=function(...D){return P.execute(D)}}function tt(n="",i={}){return function(c){const d={basePath:n,...i};return Reflect.defineMetadata(ve,d,c),Object.getOwnPropertyNames(c.prototype).forEach(y=>{et(c,y,d)}),c}}class ye extends Error{constructor(){super("Implementation will be generated automatically."),this.name="AutoGenerated"}}const rt=()=>new ye;v.API_METADATA_KEY=ve,v.AutoGenerated=ye,v.ENDPOINT_METADATA_KEY=L,v.EventStreamResultExtractor=se,v.ExchangeResultExtractor=ie,v.FunctionMetadata=le,v.JsonEventStreamResultExtractor=fe,v.JsonResultExtractor=Q,v.PARAMETER_METADATA_KEY=W,v.ParameterType=j,v.RequestExecutor=he,v.ResponseResultExtractor=oe,v.ResultExtractors=ce,v.TextResultExtractor=ue,v.api=tt,v.autoGeneratedError=rt,v.body=$e,v.del=Ge,v.endpoint=q,v.get=xe,v.getFetcher=de,v.getParameterName=ne,v.getParameterNames=re,v.head=Fe,v.header=Xe,v.options=Ue,v.parameter=C,v.patch=He,v.path=ze,v.post=je,v.put=Ce,v.query=Ze,v.request=Ke,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})}));
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { FetchExchange } from '@ahoo-wang/fetcher';
|
|
2
|
-
import { ServerSentEventStream } from '@ahoo-wang/fetcher-eventstream';
|
|
3
|
-
import { CommandResultEventStream } from '@ahoo-wang/fetcher-wow';
|
|
2
|
+
import { JsonServerSentEventStream, ServerSentEventStream } from '@ahoo-wang/fetcher-eventstream';
|
|
4
3
|
/**
|
|
5
4
|
* Result extractor interface
|
|
6
5
|
* Defines a function type for extracting results from a FetchExchange
|
|
@@ -8,7 +7,7 @@ import { CommandResultEventStream } from '@ahoo-wang/fetcher-wow';
|
|
|
8
7
|
* @returns Returns a value of type FetchExchange, Response, or Promise<any>
|
|
9
8
|
*/
|
|
10
9
|
export interface ResultExtractor {
|
|
11
|
-
(exchange: FetchExchange): FetchExchange | Response | Promise<any> | ServerSentEventStream |
|
|
10
|
+
(exchange: FetchExchange): FetchExchange | Response | Promise<any> | ServerSentEventStream | JsonServerSentEventStream<any>;
|
|
12
11
|
}
|
|
13
12
|
/**
|
|
14
13
|
* Interface with result extractor capability
|
|
@@ -48,22 +47,15 @@ export declare const TextResultExtractor: ResultExtractor;
|
|
|
48
47
|
* @returns Readable stream object of server-sent event stream
|
|
49
48
|
* @throws ExchangeError exception when server does not support ServerSentEventStream
|
|
50
49
|
*/
|
|
51
|
-
export declare const
|
|
50
|
+
export declare const EventStreamResultExtractor: ResultExtractor;
|
|
52
51
|
/**
|
|
53
|
-
*
|
|
54
|
-
* This function transforms a server-sent event stream into a command result event stream.
|
|
52
|
+
* JsonServerSentEventStream result extractor, used to extract JSON server-sent event stream from FetchExchange
|
|
55
53
|
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
* @param exchange - The exchange object containing the server-sent event stream data
|
|
60
|
-
* 包含服务器发送事件流数据的交换对象
|
|
61
|
-
* @returns A command result event stream derived from the server-sent event stream
|
|
62
|
-
* 从服务器发送事件流派生的命令结果事件流
|
|
63
|
-
* @throws ExchangeError exception when server does not support ServerSentEventStream
|
|
64
|
-
* 当服务器不支持ServerSentEventStream时抛出ExchangeError异常
|
|
54
|
+
* @param exchange - FetchExchange object containing request and response information
|
|
55
|
+
* @returns Readable stream object of JSON server-sent event stream
|
|
56
|
+
* @throws ExchangeError exception when server does not support JsonServerSentEventStream
|
|
65
57
|
*/
|
|
66
|
-
export declare const
|
|
58
|
+
export declare const JsonEventStreamResultExtractor: ResultExtractor;
|
|
67
59
|
/**
|
|
68
60
|
* ResultExtractors is an object that maps result extractor names to their corresponding
|
|
69
61
|
* extractor functions. These extractors are used to process and extract data from different
|
|
@@ -74,16 +66,16 @@ export declare const CommandResultEventStreamResultExtractor: ResultExtractor;
|
|
|
74
66
|
* - Response: Handles general response result extraction
|
|
75
67
|
* - Json: Handles JSON format result extraction
|
|
76
68
|
* - Text: Handles plain text result extraction
|
|
77
|
-
* -
|
|
78
|
-
* -
|
|
69
|
+
* - EventStream: Handles server-sent event stream result extraction
|
|
70
|
+
* - JsonEventStream: Handles JSON server-sent event stream result extraction
|
|
79
71
|
*/
|
|
80
72
|
export declare const ResultExtractors: {
|
|
81
73
|
Exchange: ResultExtractor;
|
|
82
74
|
Response: ResultExtractor;
|
|
83
75
|
Json: ResultExtractor;
|
|
84
76
|
Text: ResultExtractor;
|
|
85
|
-
|
|
86
|
-
|
|
77
|
+
EventStream: ResultExtractor;
|
|
78
|
+
JsonEventStream: ResultExtractor;
|
|
87
79
|
DEFAULT: ResultExtractor;
|
|
88
80
|
};
|
|
89
81
|
//# sourceMappingURL=resultExtractor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resultExtractor.d.ts","sourceRoot":"","sources":["../src/resultExtractor.ts"],"names":[],"mappings":"AAaA,OAAO,EAAiB,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,
|
|
1
|
+
{"version":3,"file":"resultExtractor.d.ts","sourceRoot":"","sources":["../src/resultExtractor.ts"],"names":[],"mappings":"AAaA,OAAO,EAAiB,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EACL,yBAAyB,EACzB,qBAAqB,EACtB,MAAM,gCAAgC,CAAC;AAExC;;;;;GAKG;AACH,MAAM,WAAW,eAAe;IAC9B,CACE,QAAQ,EAAE,aAAa,GAErB,aAAa,GACb,QAAQ,GACR,OAAO,CAAC,GAAG,CAAC,GACZ,qBAAqB,GACrB,yBAAyB,CAAC,GAAG,CAAC,CAAC;CACpC;AAED;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC,eAAe,CAAC,EAAE,eAAe,CAAC;CACnC;AAED;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,EAAE,eAIrC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,EAAE,eAIrC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,EAAE,eAIjC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,EAAE,eAIjC,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,0BAA0B,EAAE,eASxC,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,8BAA8B,EAAE,eAY5C,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;CAQ5B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ahoo-wang/fetcher-decorator",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.1",
|
|
4
4
|
"description": "TypeScript decorators for clean API service definitions with Fetcher HTTP client",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"fetch",
|
|
@@ -36,9 +36,8 @@
|
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"reflect-metadata": "^0.2.2",
|
|
39
|
-
"@ahoo-wang/fetcher": "0.
|
|
40
|
-
"@ahoo-wang/fetcher
|
|
41
|
-
"@ahoo-wang/fetcher-eventstream": "0.10.0"
|
|
39
|
+
"@ahoo-wang/fetcher-eventstream": "0.11.1",
|
|
40
|
+
"@ahoo-wang/fetcher": "0.11.1"
|
|
42
41
|
},
|
|
43
42
|
"devDependencies": {
|
|
44
43
|
"@vitest/coverage-v8": "^3.2.4",
|