api-def 0.9.0 → 0.9.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/cjs/Api.d.ts +35 -35
- package/cjs/Api.js +140 -144
- package/cjs/ApiConstants.d.ts +58 -58
- package/cjs/ApiConstants.js +55 -55
- package/cjs/ApiTypes.d.ts +103 -103
- package/cjs/ApiTypes.js +4 -4
- package/cjs/ApiUtils.d.ts +6 -6
- package/cjs/ApiUtils.js +51 -53
- package/cjs/Endpoint.d.ts +52 -52
- package/cjs/Endpoint.js +104 -108
- package/cjs/EndpointBuilder.d.ts +14 -14
- package/cjs/EndpointBuilder.js +46 -46
- package/cjs/MockingTypes.d.ts +30 -30
- package/cjs/MockingTypes.js +2 -2
- package/cjs/QueryHandling.d.ts +3 -3
- package/cjs/QueryHandling.js +24 -24
- package/cjs/RequestConfig.d.ts +2 -2
- package/cjs/RequestConfig.js +74 -74
- package/cjs/RequestContext.d.ts +48 -48
- package/cjs/RequestContext.js +235 -238
- package/cjs/RequestError.d.ts +30 -30
- package/cjs/RequestError.js +47 -47
- package/cjs/Requester.d.ts +3 -3
- package/cjs/Requester.js +335 -336
- package/cjs/TextDecoding.d.ts +1 -1
- package/cjs/TextDecoding.js +152 -139
- package/cjs/UtilTypes.d.ts +5 -5
- package/cjs/UtilTypes.js +2 -2
- package/cjs/Utils.d.ts +15 -15
- package/cjs/Utils.js +79 -77
- package/cjs/Validation.d.ts +8 -8
- package/cjs/Validation.js +2 -2
- package/cjs/backend/AxiosRequestBackend.d.ts +13 -13
- package/cjs/backend/AxiosRequestBackend.js +99 -99
- package/cjs/backend/FetchRequestBackend.d.ts +15 -15
- package/cjs/backend/FetchRequestBackend.js +202 -197
- package/cjs/backend/MockRequestBackend.d.ts +11 -11
- package/cjs/backend/MockRequestBackend.js +164 -164
- package/cjs/backend/RequestBackend.d.ts +19 -19
- package/cjs/backend/RequestBackend.js +2 -2
- package/cjs/cache/CacheBackend.d.ts +6 -6
- package/cjs/cache/CacheBackend.js +2 -2
- package/cjs/cache/Caching.d.ts +10 -10
- package/cjs/cache/Caching.js +88 -88
- package/cjs/cache/LocalForageCacheBackend.d.ts +9 -9
- package/cjs/cache/LocalForageCacheBackend.js +24 -24
- package/cjs/cache/LocalStorageCacheBackend.d.ts +7 -7
- package/cjs/cache/LocalStorageCacheBackend.js +77 -77
- package/cjs/index.d.ts +13 -13
- package/cjs/index.js +41 -41
- package/cjs/middleware/CacheMiddleware.d.ts +7 -7
- package/cjs/middleware/CacheMiddleware.js +107 -107
- package/cjs/middleware/LoggingMiddleware.d.ts +6 -6
- package/cjs/middleware/LoggingMiddleware.js +82 -88
- package/cjs/util/retry/index.d.ts +3 -3
- package/cjs/util/retry/index.js +52 -52
- package/cjs/util/retry/lib/retry.d.ts +3 -3
- package/cjs/util/retry/lib/retry.js +50 -54
- package/cjs/util/retry/lib/retryOperation.d.ts +27 -27
- package/cjs/util/retry/lib/retryOperation.js +130 -134
- package/esm/Api.d.ts +35 -35
- package/esm/Api.js +92 -98
- package/esm/ApiConstants.d.ts +58 -58
- package/esm/ApiConstants.js +52 -52
- package/esm/ApiTypes.d.ts +103 -103
- package/esm/ApiTypes.js +1 -1
- package/esm/ApiUtils.d.ts +6 -6
- package/esm/ApiUtils.js +43 -45
- package/esm/Endpoint.d.ts +52 -52
- package/esm/Endpoint.js +66 -70
- package/esm/EndpointBuilder.d.ts +14 -14
- package/esm/EndpointBuilder.js +31 -31
- package/esm/MockingTypes.d.ts +30 -30
- package/esm/MockingTypes.js +1 -1
- package/esm/QueryHandling.d.ts +3 -3
- package/esm/QueryHandling.js +19 -19
- package/esm/RequestConfig.d.ts +2 -2
- package/esm/RequestConfig.js +56 -56
- package/esm/RequestContext.d.ts +48 -48
- package/esm/RequestContext.js +167 -170
- package/esm/RequestError.d.ts +30 -30
- package/esm/RequestError.js +42 -42
- package/esm/Requester.d.ts +3 -3
- package/esm/Requester.js +252 -253
- package/esm/TextDecoding.d.ts +1 -1
- package/esm/TextDecoding.js +148 -135
- package/esm/UtilTypes.d.ts +5 -5
- package/esm/UtilTypes.js +1 -1
- package/esm/Utils.d.ts +15 -15
- package/esm/Utils.js +66 -68
- package/esm/Validation.d.ts +8 -8
- package/esm/Validation.js +1 -1
- package/esm/backend/AxiosRequestBackend.d.ts +13 -13
- package/esm/backend/AxiosRequestBackend.js +62 -62
- package/esm/backend/FetchRequestBackend.d.ts +15 -15
- package/esm/backend/FetchRequestBackend.js +136 -126
- package/esm/backend/MockRequestBackend.d.ts +11 -11
- package/esm/backend/MockRequestBackend.js +116 -116
- package/esm/backend/RequestBackend.d.ts +19 -19
- package/esm/backend/RequestBackend.js +1 -1
- package/esm/cache/CacheBackend.d.ts +6 -6
- package/esm/cache/CacheBackend.js +1 -1
- package/esm/cache/Caching.d.ts +10 -10
- package/esm/cache/Caching.js +39 -39
- package/esm/cache/LocalForageCacheBackend.d.ts +9 -9
- package/esm/cache/LocalForageCacheBackend.js +20 -20
- package/esm/cache/LocalStorageCacheBackend.d.ts +7 -7
- package/esm/cache/LocalStorageCacheBackend.js +32 -32
- package/esm/index.d.ts +13 -13
- package/esm/index.js +14 -15
- package/esm/middleware/CacheMiddleware.d.ts +7 -7
- package/esm/middleware/CacheMiddleware.js +58 -58
- package/esm/middleware/LoggingMiddleware.d.ts +6 -6
- package/esm/middleware/LoggingMiddleware.js +77 -83
- package/esm/util/retry/index.d.ts +3 -3
- package/esm/util/retry/index.js +50 -50
- package/esm/util/retry/lib/retry.d.ts +3 -3
- package/esm/util/retry/lib/retry.js +35 -39
- package/esm/util/retry/lib/retryOperation.d.ts +27 -27
- package/esm/util/retry/lib/retryOperation.js +126 -132
- package/package.json +12 -32
package/cjs/TextDecoding.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const textDecode: (inputArrayOrBuffer: any, options?: any) => string;
|
|
1
|
+
export declare const textDecode: (inputArrayOrBuffer: any, options?: any) => string;
|
package/cjs/TextDecoding.js
CHANGED
|
@@ -1,139 +1,152 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/* eslint-disable prefer-const */
|
|
3
|
-
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
|
4
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.textDecode = void 0;
|
|
6
|
-
// polyfill from https://github.com/anonyco/FastestSmallestTextEncoderDecoder/blob/master/EncoderDecoderTogether.src.js
|
|
7
|
-
var textDecode = function (inputArrayOrBuffer, options) {
|
|
8
|
-
if (typeof TextDecoder !== "undefined") {
|
|
9
|
-
return new TextDecoder("utf-8").decode(inputArrayOrBuffer);
|
|
10
|
-
}
|
|
11
|
-
var fromCharCode = String.fromCharCode;
|
|
12
|
-
var Object_prototype_toString =
|
|
13
|
-
var sharedArrayBufferString = Object_prototype_toString.call(window
|
|
14
|
-
var undefinedObjectString = Object_prototype_toString();
|
|
15
|
-
var NativeUint8Array = window.Uint8Array;
|
|
16
|
-
var patchedU8Array = NativeUint8Array || Array;
|
|
17
|
-
var nativeArrayBuffer = NativeUint8Array ? ArrayBuffer : patchedU8Array;
|
|
18
|
-
var arrayBuffer_isView = nativeArrayBuffer.isView || function (x) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
var
|
|
22
|
-
var
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
var
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
//
|
|
48
|
-
case
|
|
49
|
-
cp1 = inputAs8[index = index + 1 | 0] & 0xff;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
case
|
|
114
|
-
case
|
|
115
|
-
case
|
|
116
|
-
case
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable prefer-const */
|
|
3
|
+
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.textDecode = void 0;
|
|
6
|
+
// polyfill from https://github.com/anonyco/FastestSmallestTextEncoderDecoder/blob/master/EncoderDecoderTogether.src.js
|
|
7
|
+
var textDecode = function (inputArrayOrBuffer, options) {
|
|
8
|
+
if (typeof TextDecoder !== "undefined") {
|
|
9
|
+
return new TextDecoder("utf-8").decode(inputArrayOrBuffer);
|
|
10
|
+
}
|
|
11
|
+
var fromCharCode = String.fromCharCode;
|
|
12
|
+
var Object_prototype_toString = {}.toString;
|
|
13
|
+
var sharedArrayBufferString = Object_prototype_toString.call(window.SharedArrayBuffer);
|
|
14
|
+
var undefinedObjectString = Object_prototype_toString();
|
|
15
|
+
var NativeUint8Array = window.Uint8Array;
|
|
16
|
+
var patchedU8Array = NativeUint8Array || Array;
|
|
17
|
+
var nativeArrayBuffer = NativeUint8Array ? ArrayBuffer : patchedU8Array;
|
|
18
|
+
var arrayBuffer_isView = nativeArrayBuffer.isView || (function (x) { return x && "length" in x; });
|
|
19
|
+
var arrayBufferString = Object_prototype_toString.call(nativeArrayBuffer.prototype);
|
|
20
|
+
var tmpBufferU16 = new (NativeUint8Array ? Uint16Array : patchedU8Array)(32);
|
|
21
|
+
var inputAs8 = inputArrayOrBuffer;
|
|
22
|
+
var asObjectString;
|
|
23
|
+
if (!arrayBuffer_isView(inputAs8)) {
|
|
24
|
+
asObjectString = Object_prototype_toString.call(inputAs8);
|
|
25
|
+
if (asObjectString !== arrayBufferString && asObjectString !== sharedArrayBufferString && asObjectString !== undefinedObjectString)
|
|
26
|
+
throw TypeError("Failed to execute 'decode' on 'TextDecoder': The provided value is not of type '(ArrayBuffer or ArrayBufferView)'");
|
|
27
|
+
inputAs8 = NativeUint8Array ? new patchedU8Array(inputAs8) : inputAs8 || [];
|
|
28
|
+
}
|
|
29
|
+
var resultingString = "";
|
|
30
|
+
var tmpStr = "";
|
|
31
|
+
var index = 0;
|
|
32
|
+
var len = inputAs8.length | 0;
|
|
33
|
+
var lenMinus32 = (len - 32) | 0;
|
|
34
|
+
var nextEnd = 0;
|
|
35
|
+
var cp0 = 0;
|
|
36
|
+
var codePoint = 0;
|
|
37
|
+
var minBits = 0;
|
|
38
|
+
var cp1 = 0;
|
|
39
|
+
var pos = 0;
|
|
40
|
+
var tmp = -1;
|
|
41
|
+
// Note that tmp represents the 2nd half of a surrogate pair incase a surrogate gets divided between blocks
|
|
42
|
+
while (index < len) {
|
|
43
|
+
nextEnd = index <= lenMinus32 ? 32 : (len - index) | 0;
|
|
44
|
+
for (; pos < nextEnd; index = (index + 1) | 0, pos = (pos + 1) | 0) {
|
|
45
|
+
cp0 = inputAs8[index] & 0xff;
|
|
46
|
+
switch (cp0 >> 4) {
|
|
47
|
+
// biome-ignore lint: optimised code
|
|
48
|
+
case 15:
|
|
49
|
+
cp1 = inputAs8[(index = (index + 1) | 0)] & 0xff;
|
|
50
|
+
if (cp1 >> 6 !== 2 || 247 < cp0) {
|
|
51
|
+
index = (index - 1) | 0;
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
codePoint = ((cp0 & 7) << 6) | (cp1 & 63);
|
|
55
|
+
minBits = 5; // 20 ensures it never passes -> all invalid replacements
|
|
56
|
+
cp0 = 0x100; // keep track of th bit size
|
|
57
|
+
// biome-ignore lint: optimised code
|
|
58
|
+
case 14:
|
|
59
|
+
cp1 = inputAs8[(index = (index + 1) | 0)] & 0xff;
|
|
60
|
+
codePoint <<= 6;
|
|
61
|
+
codePoint |= ((cp0 & 15) << 6) | (cp1 & 63);
|
|
62
|
+
minBits = cp1 >> 6 === 2 ? (minBits + 4) | 0 : 24; // 24 ensures it never passes -> all invalid replacements
|
|
63
|
+
cp0 = (cp0 + 0x100) & 0x300; // keep track of th bit size
|
|
64
|
+
case 13:
|
|
65
|
+
// biome-ignore lint: optimised code
|
|
66
|
+
case 12:
|
|
67
|
+
cp1 = inputAs8[(index = (index + 1) | 0)] & 0xff;
|
|
68
|
+
codePoint <<= 6;
|
|
69
|
+
codePoint |= ((cp0 & 31) << 6) | (cp1 & 63);
|
|
70
|
+
minBits = (minBits + 7) | 0;
|
|
71
|
+
// Now, process the code point
|
|
72
|
+
if (index < len && cp1 >> 6 === 2 && codePoint >> minBits && codePoint < 0x110000) {
|
|
73
|
+
cp0 = codePoint;
|
|
74
|
+
codePoint = (codePoint - 0x10000) | 0;
|
|
75
|
+
if (0 <= codePoint /*0xffff < codePoint*/) {
|
|
76
|
+
// BMP code point
|
|
77
|
+
//nextEnd = nextEnd - 1|0;
|
|
78
|
+
tmp = ((codePoint >> 10) + 0xd800) | 0; // highSurrogate
|
|
79
|
+
cp0 = ((codePoint & 0x3ff) + 0xdc00) | 0; // lowSurrogate (will be inserted later in the switch-statement)
|
|
80
|
+
if (pos < 31) {
|
|
81
|
+
// notice 31 instead of 32
|
|
82
|
+
tmpBufferU16[pos] = tmp;
|
|
83
|
+
pos = (pos + 1) | 0;
|
|
84
|
+
tmp = -1;
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
// else, we are at the end of the inputAs8 and let tmp0 be filled in later on
|
|
88
|
+
// NOTE that cp1 is being used as a temporary variable for the swapping of tmp with cp0
|
|
89
|
+
cp1 = tmp;
|
|
90
|
+
tmp = cp0;
|
|
91
|
+
cp0 = cp1;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
else
|
|
95
|
+
nextEnd = (nextEnd + 1) | 0; // because we are advancing i without advancing pos
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
// invalid code point means replacing the whole thing with null replacement characters
|
|
99
|
+
cp0 >>= 8;
|
|
100
|
+
index = (index - cp0 - 1) | 0; // reset index back to what it was before
|
|
101
|
+
cp0 = 0xfffd;
|
|
102
|
+
}
|
|
103
|
+
// Finally, reset the variables for the next go-around
|
|
104
|
+
minBits = 0;
|
|
105
|
+
codePoint = 0;
|
|
106
|
+
nextEnd = index <= lenMinus32 ? 32 : (len - index) | 0;
|
|
107
|
+
/*case 11:
|
|
108
|
+
case 10:
|
|
109
|
+
case 9:
|
|
110
|
+
case 8:
|
|
111
|
+
codePoint ? codePoint = 0 : cp0 = 0xfffd; // fill with invalid replacement character
|
|
112
|
+
case 7:
|
|
113
|
+
case 6:
|
|
114
|
+
case 5:
|
|
115
|
+
case 4:
|
|
116
|
+
case 3:
|
|
117
|
+
case 2:
|
|
118
|
+
case 1:
|
|
119
|
+
case 0:
|
|
120
|
+
tmpBufferU16[pos] = cp0;
|
|
121
|
+
continue;*/
|
|
122
|
+
// biome-ignore lint: optimised code
|
|
123
|
+
default: // fill with invalid replacement character
|
|
124
|
+
tmpBufferU16[pos] = cp0;
|
|
125
|
+
continue;
|
|
126
|
+
case 11:
|
|
127
|
+
case 10:
|
|
128
|
+
case 9:
|
|
129
|
+
case 8:
|
|
130
|
+
}
|
|
131
|
+
tmpBufferU16[pos] = 0xfffd; // fill with invalid replacement character
|
|
132
|
+
}
|
|
133
|
+
tmpStr += fromCharCode(tmpBufferU16[0], tmpBufferU16[1], tmpBufferU16[2], tmpBufferU16[3], tmpBufferU16[4], tmpBufferU16[5], tmpBufferU16[6], tmpBufferU16[7], tmpBufferU16[8], tmpBufferU16[9], tmpBufferU16[10], tmpBufferU16[11], tmpBufferU16[12], tmpBufferU16[13], tmpBufferU16[14], tmpBufferU16[15], tmpBufferU16[16], tmpBufferU16[17], tmpBufferU16[18], tmpBufferU16[19], tmpBufferU16[20], tmpBufferU16[21], tmpBufferU16[22], tmpBufferU16[23], tmpBufferU16[24], tmpBufferU16[25], tmpBufferU16[26], tmpBufferU16[27], tmpBufferU16[28], tmpBufferU16[29], tmpBufferU16[30], tmpBufferU16[31]);
|
|
134
|
+
if (pos < 32)
|
|
135
|
+
tmpStr = tmpStr.slice(0, (pos - 32) | 0); //-(32-pos));
|
|
136
|
+
if (index < len) {
|
|
137
|
+
//fromCharCode.apply(0, tmpBufferU16 : NativeUint8Array ? tmpBufferU16.subarray(0,pos) : tmpBufferU16.slice(0,pos));
|
|
138
|
+
tmpBufferU16[0] = tmp;
|
|
139
|
+
pos = ~tmp >>> 31; //tmp !== -1 ? 1 : 0;
|
|
140
|
+
tmp = -1;
|
|
141
|
+
if (tmpStr.length < resultingString.length)
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
else if (tmp !== -1) {
|
|
145
|
+
tmpStr += fromCharCode(tmp);
|
|
146
|
+
}
|
|
147
|
+
resultingString += tmpStr;
|
|
148
|
+
tmpStr = "";
|
|
149
|
+
}
|
|
150
|
+
return resultingString;
|
|
151
|
+
};
|
|
152
|
+
exports.textDecode = textDecode;
|
package/cjs/UtilTypes.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import Endpoint from "./Endpoint";
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
1
|
+
import Endpoint from "./Endpoint";
|
|
2
|
+
export type ResponseOf<E extends Endpoint<any, any, any, any>> = E extends Endpoint<infer R, any, any, any> ? R : never;
|
|
3
|
+
export type ParamsOf<E extends Endpoint<any, any, any, any>> = E extends Endpoint<any, infer P, any, any> ? P : never;
|
|
4
|
+
export type QueryOf<E extends Endpoint<any, any, any, any>> = E extends Endpoint<any, any, infer Q, any> ? Q : never;
|
|
5
|
+
export type BodyOf<E extends Endpoint<any, any, any, any>> = E extends Endpoint<any, any, any, infer B> ? B : never;
|
package/cjs/UtilTypes.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
package/cjs/Utils.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
export declare const assign: typeof Object["assign"];
|
|
2
|
-
export declare const padNumber: (stringOrNumber: string | number, maxLength: number) => string;
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export declare const getGlobal: () => any;
|
|
6
|
-
export declare const getGlobalFetch: () => Fetch | undefined;
|
|
7
|
-
export declare const noop: () => void;
|
|
8
|
-
/**
|
|
9
|
-
* Just used to simulate lag, or loading times.
|
|
10
|
-
* @param value The value you want to return after the delay
|
|
11
|
-
* @param delayMs The delay in ms
|
|
12
|
-
* @returns The `value` param as a Promise
|
|
13
|
-
*/
|
|
14
|
-
export declare const delayThenReturn: <T>(value: T, delayMs: number) => Promise<T>;
|
|
15
|
-
export declare const randInt: (min: number, max: number) => number;
|
|
1
|
+
export declare const assign: (typeof Object)["assign"];
|
|
2
|
+
export declare const padNumber: (stringOrNumber: string | number, maxLength: number) => string;
|
|
3
|
+
export type EnumOf<T extends Record<string, any>> = T[keyof T];
|
|
4
|
+
export type Fetch = typeof window.fetch;
|
|
5
|
+
export declare const getGlobal: () => any;
|
|
6
|
+
export declare const getGlobalFetch: () => Fetch | undefined;
|
|
7
|
+
export declare const noop: () => void;
|
|
8
|
+
/**
|
|
9
|
+
* Just used to simulate lag, or loading times.
|
|
10
|
+
* @param value The value you want to return after the delay
|
|
11
|
+
* @param delayMs The delay in ms
|
|
12
|
+
* @returns The `value` param as a Promise
|
|
13
|
+
*/
|
|
14
|
+
export declare const delayThenReturn: <T>(value: T, delayMs: number) => Promise<T>;
|
|
15
|
+
export declare const randInt: (min: number, max: number) => number;
|
package/cjs/Utils.js
CHANGED
|
@@ -1,77 +1,79 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.randInt = exports.delayThenReturn = exports.noop = exports.getGlobalFetch = exports.getGlobal = exports.padNumber = exports.assign = void 0;
|
|
4
|
-
// polyfill from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
|
|
5
|
-
exports.assign = Object.assign ||
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if (typeof
|
|
36
|
-
return
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
*
|
|
57
|
-
* @
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.randInt = exports.delayThenReturn = exports.noop = exports.getGlobalFetch = exports.getGlobal = exports.padNumber = exports.assign = void 0;
|
|
4
|
+
// polyfill from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
|
|
5
|
+
exports.assign = Object.assign ||
|
|
6
|
+
(function (target) {
|
|
7
|
+
var varArgs = [];
|
|
8
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
9
|
+
varArgs[_i - 1] = arguments[_i];
|
|
10
|
+
}
|
|
11
|
+
if (target === null || target === undefined) {
|
|
12
|
+
throw new TypeError("Cannot convert undefined or null to object");
|
|
13
|
+
}
|
|
14
|
+
var to = Object(target);
|
|
15
|
+
for (var index = 0; index < varArgs.length; index++) {
|
|
16
|
+
// eslint-disable-next-line prefer-rest-params
|
|
17
|
+
var nextSource = varArgs[index];
|
|
18
|
+
if (nextSource !== null && nextSource !== undefined) {
|
|
19
|
+
for (var nextKey in nextSource) {
|
|
20
|
+
// Avoid bugs when hasOwnProperty is shadowed
|
|
21
|
+
if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
|
|
22
|
+
to[nextKey] = nextSource[nextKey];
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return to;
|
|
28
|
+
});
|
|
29
|
+
var padNumber = function (stringOrNumber, maxLength) {
|
|
30
|
+
var string = stringOrNumber.toString();
|
|
31
|
+
return string.length >= maxLength ? string : "0".repeat(maxLength - string.length) + string;
|
|
32
|
+
};
|
|
33
|
+
exports.padNumber = padNumber;
|
|
34
|
+
var getGlobal = function () {
|
|
35
|
+
if (typeof global !== "undefined") {
|
|
36
|
+
return global;
|
|
37
|
+
}
|
|
38
|
+
if (typeof window !== "undefined") {
|
|
39
|
+
return window;
|
|
40
|
+
}
|
|
41
|
+
return undefined;
|
|
42
|
+
};
|
|
43
|
+
exports.getGlobal = getGlobal;
|
|
44
|
+
var getGlobalFetch = function () {
|
|
45
|
+
var global = (0, exports.getGlobal)();
|
|
46
|
+
if (global && typeof global.fetch === "function") {
|
|
47
|
+
return global.fetch.bind(global);
|
|
48
|
+
}
|
|
49
|
+
return undefined;
|
|
50
|
+
};
|
|
51
|
+
exports.getGlobalFetch = getGlobalFetch;
|
|
52
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
53
|
+
var noop = function () { };
|
|
54
|
+
exports.noop = noop;
|
|
55
|
+
/**
|
|
56
|
+
* Just used to simulate lag, or loading times.
|
|
57
|
+
* @param value The value you want to return after the delay
|
|
58
|
+
* @param delayMs The delay in ms
|
|
59
|
+
* @returns The `value` param as a Promise
|
|
60
|
+
*/
|
|
61
|
+
var delayThenReturn = function (value, delayMs) {
|
|
62
|
+
return new Promise(function (resolve) {
|
|
63
|
+
if (delayMs > 0) {
|
|
64
|
+
setTimeout(function () {
|
|
65
|
+
resolve(value);
|
|
66
|
+
}, delayMs);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
resolve(value);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
exports.delayThenReturn = delayThenReturn;
|
|
74
|
+
var randInt = function (min, max) {
|
|
75
|
+
var minI = Math.ceil(min);
|
|
76
|
+
var maxI = Math.floor(max);
|
|
77
|
+
return Math.floor(Math.random() * (maxI - minI + 1)) + minI;
|
|
78
|
+
};
|
|
79
|
+
exports.randInt = randInt;
|
package/cjs/Validation.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import * as zod from "zod";
|
|
2
|
-
import { Body, Params, Query } from "./ApiTypes";
|
|
3
|
-
export interface Validation<R = any, P extends Params | undefined = Params | undefined, Q extends Query | undefined = Query | undefined, B extends Body | undefined = Body | undefined> {
|
|
4
|
-
query?: zod.Schema<Q>;
|
|
5
|
-
params?: zod.Schema<P>;
|
|
6
|
-
body?: zod.Schema<B>;
|
|
7
|
-
response?: zod.Schema<R>;
|
|
8
|
-
}
|
|
1
|
+
import * as zod from "zod";
|
|
2
|
+
import { Body, Params, Query } from "./ApiTypes";
|
|
3
|
+
export interface Validation<R = any, P extends Params | undefined = Params | undefined, Q extends Query | undefined = Query | undefined, B extends Body | undefined = Body | undefined> {
|
|
4
|
+
query?: zod.Schema<Q>;
|
|
5
|
+
params?: zod.Schema<P>;
|
|
6
|
+
body?: zod.Schema<B>;
|
|
7
|
+
response?: zod.Schema<R>;
|
|
8
|
+
}
|
package/cjs/Validation.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { ApiResponse } from "../ApiTypes";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
export declare const isAxiosError: (error: Error) => error is AxiosError<unknown, any>;
|
|
6
|
-
export default class AxiosRequestBackend implements RequestBackend<AxiosResponse> {
|
|
7
|
-
readonly id = "axios";
|
|
8
|
-
constructor(axiosLibrary: any);
|
|
9
|
-
extractResponseFromError(error: Error): Promise<AxiosResponse | null | undefined>;
|
|
10
|
-
convertResponse<T>(context: RequestContext, response: AxiosResponse): Promise<ConvertedApiResponse<T>>;
|
|
11
|
-
makeRequest(context: RequestContext): RequestOperation<AxiosResponse>;
|
|
12
|
-
getErrorInfo(error: Error, response: ApiResponse | undefined | null): RequestBackendErrorInfo | undefined;
|
|
13
|
-
}
|
|
1
|
+
import type { AxiosError, AxiosResponse } from "axios";
|
|
2
|
+
import { ApiResponse } from "../ApiTypes";
|
|
3
|
+
import RequestContext from "../RequestContext";
|
|
4
|
+
import RequestBackend, { ConvertedApiResponse, RequestBackendErrorInfo, RequestOperation } from "./RequestBackend";
|
|
5
|
+
export declare const isAxiosError: (error: Error) => error is AxiosError<unknown, any>;
|
|
6
|
+
export default class AxiosRequestBackend implements RequestBackend<AxiosResponse> {
|
|
7
|
+
readonly id = "axios";
|
|
8
|
+
constructor(axiosLibrary: any);
|
|
9
|
+
extractResponseFromError(error: Error): Promise<AxiosResponse | null | undefined>;
|
|
10
|
+
convertResponse<T>(context: RequestContext, response: AxiosResponse): Promise<ConvertedApiResponse<T>>;
|
|
11
|
+
makeRequest(context: RequestContext): RequestOperation<AxiosResponse>;
|
|
12
|
+
getErrorInfo(error: Error, response: ApiResponse | undefined | null): RequestBackendErrorInfo | undefined;
|
|
13
|
+
}
|