vovk 3.0.0-draft.62 → 3.0.0-draft.64
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.
|
@@ -4,7 +4,7 @@ exports.StreamJSONResponse = void 0;
|
|
|
4
4
|
require("./utils/shim");
|
|
5
5
|
class StreamJSONResponse extends Response {
|
|
6
6
|
static defaultHeaders = {
|
|
7
|
-
'content-type': 'text/plain;
|
|
7
|
+
'content-type': 'text/plain; format=jsonlines',
|
|
8
8
|
};
|
|
9
9
|
isClosed = false;
|
|
10
10
|
controller;
|
|
@@ -17,7 +17,7 @@ const defaultFetcher = async ({ httpMethod, getEndpoint, validate, defaultHandle
|
|
|
17
17
|
if (e instanceof HttpException_1.HttpException)
|
|
18
18
|
throw e;
|
|
19
19
|
// otherwise, throw HttpException with status 0
|
|
20
|
-
throw new HttpException_1.HttpException(types_1.HttpStatus.NULL, e.message ?? exports.DEFAULT_ERROR_MESSAGE);
|
|
20
|
+
throw new HttpException_1.HttpException(types_1.HttpStatus.NULL, e.message ?? exports.DEFAULT_ERROR_MESSAGE, { endpoint });
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
const init = {
|
|
@@ -36,13 +36,13 @@ const defaultFetcher = async ({ httpMethod, getEndpoint, validate, defaultHandle
|
|
|
36
36
|
}
|
|
37
37
|
catch (e) {
|
|
38
38
|
// handle network errors
|
|
39
|
-
throw new HttpException_1.HttpException(types_1.HttpStatus.NULL, e?.message ?? exports.DEFAULT_ERROR_MESSAGE);
|
|
39
|
+
throw new HttpException_1.HttpException(types_1.HttpStatus.NULL, e?.message ?? exports.DEFAULT_ERROR_MESSAGE, { endpoint });
|
|
40
40
|
}
|
|
41
41
|
const contentType = response.headers.get('content-type');
|
|
42
42
|
if (contentType?.startsWith('application/json')) {
|
|
43
43
|
return defaultHandler(response);
|
|
44
44
|
}
|
|
45
|
-
if (contentType === 'text/plain;
|
|
45
|
+
if (contentType === 'text/plain; format=jsonlines') {
|
|
46
46
|
return defaultStreamHandler(response);
|
|
47
47
|
}
|
|
48
48
|
return response;
|
package/package.json
CHANGED
|
@@ -19,7 +19,7 @@ const defaultFetcher: VovkClientFetcher<VovkDefaultFetcherOptions> = async (
|
|
|
19
19
|
// if HttpException is thrown, rethrow it
|
|
20
20
|
if (e instanceof HttpException) throw e;
|
|
21
21
|
// otherwise, throw HttpException with status 0
|
|
22
|
-
throw new HttpException(HttpStatus.NULL, (e as Error).message ?? DEFAULT_ERROR_MESSAGE);
|
|
22
|
+
throw new HttpException(HttpStatus.NULL, (e as Error).message ?? DEFAULT_ERROR_MESSAGE, { endpoint });
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
|
|
@@ -40,18 +40,16 @@ const defaultFetcher: VovkClientFetcher<VovkDefaultFetcherOptions> = async (
|
|
|
40
40
|
response = await fetch(endpoint, init);
|
|
41
41
|
} catch (e) {
|
|
42
42
|
// handle network errors
|
|
43
|
-
throw new HttpException(HttpStatus.NULL, (e as Error)?.message ?? DEFAULT_ERROR_MESSAGE);
|
|
43
|
+
throw new HttpException(HttpStatus.NULL, (e as Error)?.message ?? DEFAULT_ERROR_MESSAGE, { endpoint });
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
const contentType = response.headers.get('content-type');
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
|
|
50
48
|
if (contentType?.startsWith('application/json')) {
|
|
51
49
|
return defaultHandler(response);
|
|
52
50
|
}
|
|
53
51
|
|
|
54
|
-
if (contentType === 'text/plain;
|
|
52
|
+
if (contentType === 'text/plain; format=jsonlines') {
|
|
55
53
|
return defaultStreamHandler(response);
|
|
56
54
|
}
|
|
57
55
|
|