@marianmeres/http-utils 1.21.0 → 1.23.0
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/api.d.ts +1 -0
- package/dist/error.d.ts +6 -0
- package/dist/index.cjs +14 -0
- package/dist/index.js +14 -0
- package/package.json +3 -2
package/dist/api.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ export declare function createHttpApi(base?: string | null, defaults?: Partial<B
|
|
|
20
20
|
patch(path: string, data?: any, params?: FetchParams, respHeaders?: any, errorMessageExtractor?: ErrorMessageExtractor | null | undefined, _dumpParams?: boolean): Promise<any>;
|
|
21
21
|
del(path: string, data?: any, params?: FetchParams, respHeaders?: any, errorMessageExtractor?: ErrorMessageExtractor | null | undefined, _dumpParams?: boolean): Promise<any>;
|
|
22
22
|
url: (path: string) => string;
|
|
23
|
+
base: string | null | undefined;
|
|
23
24
|
};
|
|
24
25
|
export declare namespace createHttpApi {
|
|
25
26
|
var defaultErrorMessageExtractor: ErrorMessageExtractor | null | undefined;
|
package/dist/error.d.ts
CHANGED
|
@@ -44,6 +44,11 @@ declare class Gone extends HttpError {
|
|
|
44
44
|
status: number;
|
|
45
45
|
statusText: string;
|
|
46
46
|
}
|
|
47
|
+
declare class LengthRequired extends HttpError {
|
|
48
|
+
name: string;
|
|
49
|
+
status: number;
|
|
50
|
+
statusText: string;
|
|
51
|
+
}
|
|
47
52
|
declare class UnprocessableContent extends HttpError {
|
|
48
53
|
name: string;
|
|
49
54
|
status: number;
|
|
@@ -87,6 +92,7 @@ export declare const HTTP_ERROR: {
|
|
|
87
92
|
RequestTimeout: typeof RequestTimeout;
|
|
88
93
|
Conflict: typeof Conflict;
|
|
89
94
|
Gone: typeof Gone;
|
|
95
|
+
LengthRequired: typeof LengthRequired;
|
|
90
96
|
ImATeapot: typeof ImATeapot;
|
|
91
97
|
UnprocessableContent: typeof UnprocessableContent;
|
|
92
98
|
TooManyRequests: typeof TooManyRequests;
|
package/dist/index.cjs
CHANGED
|
@@ -175,6 +175,11 @@ class Gone extends HttpError {
|
|
|
175
175
|
status = HTTP_STATUS.ERROR_CLIENT.GONE.CODE;
|
|
176
176
|
statusText = HTTP_STATUS.ERROR_CLIENT.GONE.TEXT;
|
|
177
177
|
}
|
|
178
|
+
class LengthRequired extends HttpError {
|
|
179
|
+
name = 'HttpLengthRequiredError';
|
|
180
|
+
status = HTTP_STATUS.ERROR_CLIENT.LENGTH_REQUIRED.CODE;
|
|
181
|
+
statusText = HTTP_STATUS.ERROR_CLIENT.LENGTH_REQUIRED.TEXT;
|
|
182
|
+
}
|
|
178
183
|
class UnprocessableContent extends HttpError {
|
|
179
184
|
name = 'HttpUnprocessableContentError';
|
|
180
185
|
status = HTTP_STATUS.ERROR_CLIENT.UNPROCESSABLE_CONTENT.CODE;
|
|
@@ -222,6 +227,7 @@ const HTTP_ERROR = {
|
|
|
222
227
|
RequestTimeout,
|
|
223
228
|
Conflict,
|
|
224
229
|
Gone,
|
|
230
|
+
LengthRequired,
|
|
225
231
|
ImATeapot,
|
|
226
232
|
UnprocessableContent,
|
|
227
233
|
TooManyRequests,
|
|
@@ -240,6 +246,7 @@ const _wellKnownCtorMap = {
|
|
|
240
246
|
'408': RequestTimeout,
|
|
241
247
|
'409': Conflict,
|
|
242
248
|
'410': Gone,
|
|
249
|
+
'411': LengthRequired,
|
|
243
250
|
'418': ImATeapot,
|
|
244
251
|
'422': UnprocessableContent,
|
|
245
252
|
'429': TooManyRequests,
|
|
@@ -447,6 +454,13 @@ function createHttpApi(base, defaults, factoryErrorMessageExtractor) {
|
|
|
447
454
|
// helper method to return api's resolved url
|
|
448
455
|
// note: cannot use URL(...) as relative would be invalid
|
|
449
456
|
url: (path) => _buildPath(path, base),
|
|
457
|
+
//
|
|
458
|
+
get base() {
|
|
459
|
+
return base;
|
|
460
|
+
},
|
|
461
|
+
set base(v) {
|
|
462
|
+
base = v;
|
|
463
|
+
},
|
|
450
464
|
};
|
|
451
465
|
}
|
|
452
466
|
createHttpApi.defaultErrorMessageExtractor = null;
|
package/dist/index.js
CHANGED
|
@@ -173,6 +173,11 @@ class Gone extends HttpError {
|
|
|
173
173
|
status = HTTP_STATUS.ERROR_CLIENT.GONE.CODE;
|
|
174
174
|
statusText = HTTP_STATUS.ERROR_CLIENT.GONE.TEXT;
|
|
175
175
|
}
|
|
176
|
+
class LengthRequired extends HttpError {
|
|
177
|
+
name = 'HttpLengthRequiredError';
|
|
178
|
+
status = HTTP_STATUS.ERROR_CLIENT.LENGTH_REQUIRED.CODE;
|
|
179
|
+
statusText = HTTP_STATUS.ERROR_CLIENT.LENGTH_REQUIRED.TEXT;
|
|
180
|
+
}
|
|
176
181
|
class UnprocessableContent extends HttpError {
|
|
177
182
|
name = 'HttpUnprocessableContentError';
|
|
178
183
|
status = HTTP_STATUS.ERROR_CLIENT.UNPROCESSABLE_CONTENT.CODE;
|
|
@@ -220,6 +225,7 @@ const HTTP_ERROR = {
|
|
|
220
225
|
RequestTimeout,
|
|
221
226
|
Conflict,
|
|
222
227
|
Gone,
|
|
228
|
+
LengthRequired,
|
|
223
229
|
ImATeapot,
|
|
224
230
|
UnprocessableContent,
|
|
225
231
|
TooManyRequests,
|
|
@@ -238,6 +244,7 @@ const _wellKnownCtorMap = {
|
|
|
238
244
|
'408': RequestTimeout,
|
|
239
245
|
'409': Conflict,
|
|
240
246
|
'410': Gone,
|
|
247
|
+
'411': LengthRequired,
|
|
241
248
|
'418': ImATeapot,
|
|
242
249
|
'422': UnprocessableContent,
|
|
243
250
|
'429': TooManyRequests,
|
|
@@ -445,6 +452,13 @@ function createHttpApi(base, defaults, factoryErrorMessageExtractor) {
|
|
|
445
452
|
// helper method to return api's resolved url
|
|
446
453
|
// note: cannot use URL(...) as relative would be invalid
|
|
447
454
|
url: (path) => _buildPath(path, base),
|
|
455
|
+
//
|
|
456
|
+
get base() {
|
|
457
|
+
return base;
|
|
458
|
+
},
|
|
459
|
+
set base(v) {
|
|
460
|
+
base = v;
|
|
461
|
+
},
|
|
448
462
|
};
|
|
449
463
|
}
|
|
450
464
|
createHttpApi.defaultErrorMessageExtractor = null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@marianmeres/http-utils",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.23.0",
|
|
4
4
|
"description": "Misc DRY http fetch related helpers",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
"release": "release -v minor",
|
|
19
19
|
"release:patch": "release -v patch",
|
|
20
20
|
"test": "test-runner",
|
|
21
|
-
"build": "npm run clean && rollup -c"
|
|
21
|
+
"build": "npm run clean && rollup -c",
|
|
22
|
+
"build:watch": "npm run clean && rollup -w -c"
|
|
22
23
|
},
|
|
23
24
|
"types": "./dist/index.d.ts",
|
|
24
25
|
"repository": {
|