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