@ahoo-wang/fetcher-decorator 0.11.0 → 0.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/apiDecorator.d.ts.map +1 -1
- package/dist/index.es.js +81 -81
- package/dist/index.es.js.map +1 -0
- package/dist/index.umd.js +2 -1
- package/dist/index.umd.js.map +1 -0
- package/dist/parameterDecorator.d.ts.map +1 -1
- package/dist/requestExecutor.d.ts +11 -3
- package/dist/requestExecutor.d.ts.map +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apiDecorator.d.ts","sourceRoot":"","sources":["../src/apiDecorator.ts"],"names":[],"mappings":"AAaA,OAAO,EACL,OAAO,EACP,cAAc,EACd,qBAAqB,EACrB,cAAc,EACf,MAAM,oBAAoB,CAAC;AAI5B,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD;;;;;;GAMG;AACH,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"apiDecorator.d.ts","sourceRoot":"","sources":["../src/apiDecorator.ts"],"names":[],"mappings":"AAaA,OAAO,EACL,OAAO,EACP,cAAc,EACd,qBAAqB,EACrB,cAAc,EACf,MAAM,oBAAoB,CAAC;AAI5B,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD;;;;;;GAMG;AACH,MAAM,WAAW,WACf,SAAQ,cAAc,EACpB,qBAAqB,EACrB,sBAAsB,EACtB,cAAc;IAChB;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,cAAc,CAAC;IAEzB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AAED,eAAO,MAAM,gBAAgB,eAAyB,CAAC;AAwDvD,wBAAgB,GAAG,CACjB,QAAQ,GAAE,MAAW,EACrB,QAAQ,GAAE,IAAI,CAAC,WAAW,EAAE,UAAU,CAAM,IAE3B,CAAC,SAAS,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EAAE,aAAa,CAAC,KAAG,CAAC,CAgB3E"}
|
package/dist/index.es.js
CHANGED
|
@@ -21,30 +21,30 @@ function $e() {
|
|
|
21
21
|
var n;
|
|
22
22
|
return (function(i) {
|
|
23
23
|
(function(c) {
|
|
24
|
-
var d = typeof globalThis == "object" ? globalThis : typeof he == "object" ? he : typeof self == "object" ? self : typeof this == "object" ? this : S(), v =
|
|
25
|
-
typeof d.Reflect < "u" && (v =
|
|
26
|
-
function
|
|
27
|
-
return function(
|
|
28
|
-
Object.defineProperty(A,
|
|
24
|
+
var d = typeof globalThis == "object" ? globalThis : typeof he == "object" ? he : typeof self == "object" ? self : typeof this == "object" ? this : S(), v = _(i);
|
|
25
|
+
typeof d.Reflect < "u" && (v = _(d.Reflect, v)), c(v, d), typeof d.Reflect > "u" && (d.Reflect = i);
|
|
26
|
+
function _(A, O) {
|
|
27
|
+
return function(k, P) {
|
|
28
|
+
Object.defineProperty(A, k, { configurable: !0, writable: !0, value: P }), O && O(k, P);
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
|
-
function
|
|
31
|
+
function R() {
|
|
32
32
|
try {
|
|
33
33
|
return Function("return this;")();
|
|
34
34
|
} catch {
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
function
|
|
37
|
+
function b() {
|
|
38
38
|
try {
|
|
39
39
|
return (0, eval)("(function() { return this; })()");
|
|
40
40
|
} catch {
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
function S() {
|
|
44
|
-
return
|
|
44
|
+
return R() || b();
|
|
45
45
|
}
|
|
46
46
|
})(function(c, d) {
|
|
47
|
-
var v = Object.prototype.hasOwnProperty,
|
|
47
|
+
var v = Object.prototype.hasOwnProperty, _ = typeof Symbol == "function", R = _ && typeof Symbol.toPrimitive < "u" ? Symbol.toPrimitive : "@@toPrimitive", b = _ && typeof Symbol.iterator < "u" ? Symbol.iterator : "@@iterator", S = typeof Object.create == "function", A = { __proto__: [] } instanceof Array, O = !S && !A, k = {
|
|
48
48
|
// create an object in dictionary mode (a.k.a. "slow" mode in v8)
|
|
49
49
|
create: S ? function() {
|
|
50
50
|
return J(/* @__PURE__ */ Object.create(null));
|
|
@@ -53,18 +53,18 @@ function $e() {
|
|
|
53
53
|
} : function() {
|
|
54
54
|
return J({});
|
|
55
55
|
},
|
|
56
|
-
has:
|
|
56
|
+
has: O ? function(e, t) {
|
|
57
57
|
return v.call(e, t);
|
|
58
58
|
} : function(e, t) {
|
|
59
59
|
return t in e;
|
|
60
60
|
},
|
|
61
|
-
get:
|
|
61
|
+
get: O ? function(e, t) {
|
|
62
62
|
return v.call(e, t) ? e[t] : void 0;
|
|
63
63
|
} : function(e, t) {
|
|
64
64
|
return e[t];
|
|
65
65
|
}
|
|
66
|
-
},
|
|
67
|
-
function
|
|
66
|
+
}, P = 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 = _ ? Symbol.for("@reflect-metadata:registry") : void 0, W = Fe(), Z = He(W);
|
|
67
|
+
function _e(e, t, r, a) {
|
|
68
68
|
if (h(r)) {
|
|
69
69
|
if (!ie(e))
|
|
70
70
|
throw new TypeError();
|
|
@@ -81,7 +81,7 @@ function $e() {
|
|
|
81
81
|
return D(a) && (a = void 0), r = x(r), Ae(e, t, r, a);
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
|
-
c("decorate",
|
|
84
|
+
c("decorate", _e);
|
|
85
85
|
function ge(e, t) {
|
|
86
86
|
function r(a, l) {
|
|
87
87
|
if (!g(a))
|
|
@@ -290,7 +290,7 @@ function $e() {
|
|
|
290
290
|
case 5:
|
|
291
291
|
return e;
|
|
292
292
|
}
|
|
293
|
-
var r = "string", a = ue(e,
|
|
293
|
+
var r = "string", a = ue(e, R);
|
|
294
294
|
if (a !== void 0) {
|
|
295
295
|
var l = a.call(e, r);
|
|
296
296
|
if (g(l))
|
|
@@ -358,7 +358,7 @@ function $e() {
|
|
|
358
358
|
}
|
|
359
359
|
}
|
|
360
360
|
function se(e) {
|
|
361
|
-
var t = ue(e,
|
|
361
|
+
var t = ue(e, b);
|
|
362
362
|
if (!N(t))
|
|
363
363
|
throw new TypeError();
|
|
364
364
|
var r = t.call(e);
|
|
@@ -379,7 +379,7 @@ function $e() {
|
|
|
379
379
|
}
|
|
380
380
|
function B(e) {
|
|
381
381
|
var t = Object.getPrototypeOf(e);
|
|
382
|
-
if (typeof e != "function" || e ===
|
|
382
|
+
if (typeof e != "function" || e === P || t !== P)
|
|
383
383
|
return t;
|
|
384
384
|
var r = e.prototype, a = r && Object.getPrototypeOf(r);
|
|
385
385
|
if (a == null || a === Object.prototype)
|
|
@@ -426,10 +426,10 @@ function $e() {
|
|
|
426
426
|
return t;
|
|
427
427
|
if (!h(a))
|
|
428
428
|
for (var w = se(a); ; ) {
|
|
429
|
-
var
|
|
430
|
-
if (!
|
|
429
|
+
var M = ce(w);
|
|
430
|
+
if (!M)
|
|
431
431
|
return;
|
|
432
|
-
var T = fe(
|
|
432
|
+
var T = fe(M);
|
|
433
433
|
if (T.isProviderFor(f, y))
|
|
434
434
|
return de(w), T;
|
|
435
435
|
}
|
|
@@ -439,8 +439,8 @@ function $e() {
|
|
|
439
439
|
return e;
|
|
440
440
|
}
|
|
441
441
|
function o(f, y) {
|
|
442
|
-
var w = l.get(f),
|
|
443
|
-
return h(w) || (
|
|
442
|
+
var w = l.get(f), M;
|
|
443
|
+
return h(w) || (M = w.get(y)), h(M) && (M = p(f, y), h(M) || (h(w) && (w = new G(), l.set(f, w)), w.set(y, M))), M;
|
|
444
444
|
}
|
|
445
445
|
function u(f) {
|
|
446
446
|
if (h(f))
|
|
@@ -450,9 +450,9 @@ function $e() {
|
|
|
450
450
|
function s(f, y, w) {
|
|
451
451
|
if (!u(w))
|
|
452
452
|
throw new Error("Metadata provider not registered.");
|
|
453
|
-
var
|
|
454
|
-
if (
|
|
455
|
-
if (!h(
|
|
453
|
+
var M = o(f, y);
|
|
454
|
+
if (M !== w) {
|
|
455
|
+
if (!h(M))
|
|
456
456
|
return !1;
|
|
457
457
|
var T = l.get(f);
|
|
458
458
|
h(T) && (T = new G(), l.set(f, T)), T.set(y, w);
|
|
@@ -489,14 +489,14 @@ function $e() {
|
|
|
489
489
|
return;
|
|
490
490
|
y = new G(), t.set(u, y), w = !0;
|
|
491
491
|
}
|
|
492
|
-
var
|
|
493
|
-
if (h(
|
|
492
|
+
var M = y.get(s);
|
|
493
|
+
if (h(M)) {
|
|
494
494
|
if (!f)
|
|
495
495
|
return;
|
|
496
|
-
if (
|
|
496
|
+
if (M = new G(), y.set(s, M), !e.setProvider(u, s, r))
|
|
497
497
|
throw y.delete(s), w && t.delete(u), new Error("Wrong provider for target.");
|
|
498
498
|
}
|
|
499
|
-
return
|
|
499
|
+
return M;
|
|
500
500
|
}
|
|
501
501
|
function l(u, s, f) {
|
|
502
502
|
var y = a(
|
|
@@ -535,8 +535,8 @@ function $e() {
|
|
|
535
535
|
);
|
|
536
536
|
if (h(y))
|
|
537
537
|
return f;
|
|
538
|
-
for (var w = y.keys(),
|
|
539
|
-
var le = ce(
|
|
538
|
+
for (var w = y.keys(), M = se(w), T = 0; ; ) {
|
|
539
|
+
var le = ce(M);
|
|
540
540
|
if (!le)
|
|
541
541
|
return f.length = T, f;
|
|
542
542
|
var Le = fe(le);
|
|
@@ -544,7 +544,7 @@ function $e() {
|
|
|
544
544
|
f[T] = Le;
|
|
545
545
|
} catch (Qe) {
|
|
546
546
|
try {
|
|
547
|
-
de(
|
|
547
|
+
de(M);
|
|
548
548
|
} finally {
|
|
549
549
|
throw Qe;
|
|
550
550
|
}
|
|
@@ -601,7 +601,7 @@ function $e() {
|
|
|
601
601
|
}
|
|
602
602
|
return p.prototype["@@iterator"] = function() {
|
|
603
603
|
return this;
|
|
604
|
-
}, p.prototype[
|
|
604
|
+
}, p.prototype[b] = function() {
|
|
605
605
|
return this;
|
|
606
606
|
}, p.prototype.next = function() {
|
|
607
607
|
var o = this._index;
|
|
@@ -670,7 +670,7 @@ function $e() {
|
|
|
670
670
|
return new r(this._keys, this._values, E);
|
|
671
671
|
}, p.prototype["@@iterator"] = function() {
|
|
672
672
|
return this.entries();
|
|
673
|
-
}, p.prototype[
|
|
673
|
+
}, p.prototype[b] = function() {
|
|
674
674
|
return this.entries();
|
|
675
675
|
}, p.prototype._find = function(o, u) {
|
|
676
676
|
if (!V(this._cacheKey, o)) {
|
|
@@ -725,7 +725,7 @@ function $e() {
|
|
|
725
725
|
return this._map.entries();
|
|
726
726
|
}, t.prototype["@@iterator"] = function() {
|
|
727
727
|
return this.keys();
|
|
728
|
-
}, t.prototype[
|
|
728
|
+
}, t.prototype[b] = function() {
|
|
729
729
|
return this.keys();
|
|
730
730
|
}, t;
|
|
731
731
|
})()
|
|
@@ -733,7 +733,7 @@ function $e() {
|
|
|
733
733
|
return e;
|
|
734
734
|
}
|
|
735
735
|
function Ye() {
|
|
736
|
-
var e = 16, t =
|
|
736
|
+
var e = 16, t = k.create(), r = a();
|
|
737
737
|
return (
|
|
738
738
|
/** @class */
|
|
739
739
|
(function() {
|
|
@@ -746,14 +746,14 @@ function $e() {
|
|
|
746
746
|
/*create*/
|
|
747
747
|
!1
|
|
748
748
|
);
|
|
749
|
-
return s !== void 0 ?
|
|
749
|
+
return s !== void 0 ? k.has(s, this._key) : !1;
|
|
750
750
|
}, o.prototype.get = function(u) {
|
|
751
751
|
var s = l(
|
|
752
752
|
u,
|
|
753
753
|
/*create*/
|
|
754
754
|
!1
|
|
755
755
|
);
|
|
756
|
-
return s !== void 0 ?
|
|
756
|
+
return s !== void 0 ? k.get(s, this._key) : void 0;
|
|
757
757
|
}, o.prototype.set = function(u, s) {
|
|
758
758
|
var f = l(
|
|
759
759
|
u,
|
|
@@ -777,14 +777,14 @@ function $e() {
|
|
|
777
777
|
var o;
|
|
778
778
|
do
|
|
779
779
|
o = "@@WeakMap@@" + p();
|
|
780
|
-
while (
|
|
780
|
+
while (k.has(t, o));
|
|
781
781
|
return t[o] = !0, o;
|
|
782
782
|
}
|
|
783
783
|
function l(o, u) {
|
|
784
784
|
if (!v.call(o, r)) {
|
|
785
785
|
if (!u)
|
|
786
786
|
return;
|
|
787
|
-
Object.defineProperty(o, r, { value:
|
|
787
|
+
Object.defineProperty(o, r, { value: k.create() });
|
|
788
788
|
}
|
|
789
789
|
return o[r];
|
|
790
790
|
}
|
|
@@ -817,17 +817,17 @@ function $e() {
|
|
|
817
817
|
})(n || (n = {})), ve;
|
|
818
818
|
}
|
|
819
819
|
$e();
|
|
820
|
-
const
|
|
820
|
+
const Me = Symbol("endpoint:metadata");
|
|
821
821
|
function q(n, i = "", c = {}) {
|
|
822
822
|
return function(d, v) {
|
|
823
|
-
const
|
|
823
|
+
const _ = {
|
|
824
824
|
method: n,
|
|
825
825
|
path: i,
|
|
826
826
|
...c
|
|
827
827
|
};
|
|
828
828
|
Reflect.defineMetadata(
|
|
829
|
-
|
|
830
|
-
|
|
829
|
+
Me,
|
|
830
|
+
_,
|
|
831
831
|
d,
|
|
832
832
|
v
|
|
833
833
|
);
|
|
@@ -879,9 +879,9 @@ function Ke(n, i, c, d) {
|
|
|
879
879
|
try {
|
|
880
880
|
const v = n[i];
|
|
881
881
|
if (v && typeof v == "function") {
|
|
882
|
-
const
|
|
883
|
-
if (c <
|
|
884
|
-
return
|
|
882
|
+
const _ = Xe(v);
|
|
883
|
+
if (c < _.length)
|
|
884
|
+
return _[c];
|
|
885
885
|
}
|
|
886
886
|
} catch {
|
|
887
887
|
}
|
|
@@ -935,19 +935,19 @@ var C = /* @__PURE__ */ ((n) => (n.PATH = "path", n.QUERY = "query", n.HEADER =
|
|
|
935
935
|
const z = Symbol("parameter:metadata");
|
|
936
936
|
function U(n, i = "") {
|
|
937
937
|
return function(c, d, v) {
|
|
938
|
-
const
|
|
938
|
+
const _ = Ke(
|
|
939
939
|
c,
|
|
940
940
|
d,
|
|
941
941
|
v,
|
|
942
942
|
i
|
|
943
|
-
),
|
|
944
|
-
O.push({
|
|
943
|
+
), R = Reflect.getMetadata(z, c, d) || /* @__PURE__ */ new Map(), b = {
|
|
945
944
|
type: n,
|
|
946
|
-
name:
|
|
945
|
+
name: _,
|
|
947
946
|
index: v
|
|
948
|
-
}
|
|
947
|
+
};
|
|
948
|
+
R.set(v, b), Reflect.defineMetadata(
|
|
949
949
|
z,
|
|
950
|
-
|
|
950
|
+
R,
|
|
951
951
|
c,
|
|
952
952
|
d
|
|
953
953
|
);
|
|
@@ -1072,32 +1072,31 @@ class pt {
|
|
|
1072
1072
|
...this.api.headers,
|
|
1073
1073
|
...this.endpoint.headers
|
|
1074
1074
|
};
|
|
1075
|
-
let
|
|
1076
|
-
i.forEach((
|
|
1077
|
-
if (
|
|
1078
|
-
|
|
1075
|
+
let _, R, b = {};
|
|
1076
|
+
i.forEach((O, k) => {
|
|
1077
|
+
if (O instanceof AbortSignal) {
|
|
1078
|
+
R = O;
|
|
1079
1079
|
return;
|
|
1080
1080
|
}
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
switch (
|
|
1081
|
+
const P = this.parameters.get(k);
|
|
1082
|
+
if (P)
|
|
1083
|
+
switch (P.type) {
|
|
1084
1084
|
case C.PATH:
|
|
1085
|
-
this.processPathParam(
|
|
1085
|
+
this.processPathParam(P, O, c);
|
|
1086
1086
|
break;
|
|
1087
1087
|
case C.QUERY:
|
|
1088
|
-
this.processQueryParam(
|
|
1088
|
+
this.processQueryParam(P, O, d);
|
|
1089
1089
|
break;
|
|
1090
1090
|
case C.HEADER:
|
|
1091
|
-
this.processHeaderParam(
|
|
1091
|
+
this.processHeaderParam(P, O, v);
|
|
1092
1092
|
break;
|
|
1093
1093
|
case C.BODY:
|
|
1094
|
-
|
|
1094
|
+
_ = O;
|
|
1095
1095
|
break;
|
|
1096
1096
|
case C.REQUEST:
|
|
1097
|
-
|
|
1097
|
+
b = this.processRequestParam(O);
|
|
1098
1098
|
break;
|
|
1099
1099
|
}
|
|
1100
|
-
}
|
|
1101
1100
|
});
|
|
1102
1101
|
const S = {
|
|
1103
1102
|
path: c,
|
|
@@ -1106,11 +1105,11 @@ class pt {
|
|
|
1106
1105
|
method: this.endpoint.method,
|
|
1107
1106
|
urlParams: S,
|
|
1108
1107
|
headers: v,
|
|
1109
|
-
body:
|
|
1108
|
+
body: _,
|
|
1110
1109
|
timeout: this.resolveTimeout(),
|
|
1111
|
-
signal:
|
|
1110
|
+
signal: R
|
|
1112
1111
|
};
|
|
1113
|
-
return ze(A,
|
|
1112
|
+
return ze(A, b);
|
|
1114
1113
|
}
|
|
1115
1114
|
processPathParam(i, c, d) {
|
|
1116
1115
|
const v = i.name || `param${i.index}`;
|
|
@@ -1199,8 +1198,8 @@ class yt {
|
|
|
1199
1198
|
const c = this.metadata.resolvePath(), d = this.metadata.resolveRequest(i), v = {
|
|
1200
1199
|
url: c,
|
|
1201
1200
|
...d
|
|
1202
|
-
},
|
|
1203
|
-
return await this.metadata.resolveResultExtractor()(
|
|
1201
|
+
}, _ = await this.metadata.fetcher.request(v);
|
|
1202
|
+
return await this.metadata.resolveResultExtractor()(_);
|
|
1204
1203
|
}
|
|
1205
1204
|
}
|
|
1206
1205
|
const wt = Symbol("api:metadata");
|
|
@@ -1209,24 +1208,24 @@ function mt(n, i, c) {
|
|
|
1209
1208
|
if (i === "constructor" || typeof d != "function")
|
|
1210
1209
|
return;
|
|
1211
1210
|
const v = Reflect.getMetadata(
|
|
1212
|
-
|
|
1211
|
+
Me,
|
|
1213
1212
|
n.prototype,
|
|
1214
1213
|
i
|
|
1215
1214
|
);
|
|
1216
1215
|
if (!v)
|
|
1217
1216
|
return;
|
|
1218
|
-
const
|
|
1217
|
+
const _ = Reflect.getMetadata(
|
|
1219
1218
|
z,
|
|
1220
1219
|
n.prototype,
|
|
1221
1220
|
i
|
|
1222
|
-
) ||
|
|
1221
|
+
) || /* @__PURE__ */ new Map(), R = new pt(
|
|
1223
1222
|
i,
|
|
1224
1223
|
c,
|
|
1225
1224
|
v,
|
|
1226
|
-
|
|
1227
|
-
),
|
|
1225
|
+
_
|
|
1226
|
+
), b = new yt(R);
|
|
1228
1227
|
n.prototype[i] = function(...S) {
|
|
1229
|
-
return
|
|
1228
|
+
return b.execute(S);
|
|
1230
1229
|
};
|
|
1231
1230
|
}
|
|
1232
1231
|
function qt(n = "", i = {}) {
|
|
@@ -1240,16 +1239,16 @@ function qt(n = "", i = {}) {
|
|
|
1240
1239
|
}), c;
|
|
1241
1240
|
};
|
|
1242
1241
|
}
|
|
1243
|
-
class
|
|
1242
|
+
class Mt extends Error {
|
|
1244
1243
|
constructor() {
|
|
1245
1244
|
super("Implementation will be generated automatically."), this.name = "AutoGenerated";
|
|
1246
1245
|
}
|
|
1247
1246
|
}
|
|
1248
|
-
const jt = () => new
|
|
1247
|
+
const jt = () => new Mt();
|
|
1249
1248
|
export {
|
|
1250
1249
|
wt as API_METADATA_KEY,
|
|
1251
|
-
|
|
1252
|
-
|
|
1250
|
+
Mt as AutoGenerated,
|
|
1251
|
+
Me as ENDPOINT_METADATA_KEY,
|
|
1253
1252
|
dt as EventStreamResultExtractor,
|
|
1254
1253
|
st as ExchangeResultExtractor,
|
|
1255
1254
|
pt as FunctionMetadata,
|
|
@@ -1281,3 +1280,4 @@ export {
|
|
|
1281
1280
|
xt as query,
|
|
1282
1281
|
It as request
|
|
1283
1282
|
};
|
|
1283
|
+
//# sourceMappingURL=index.es.js.map
|