vovk 3.0.0-draft.451 → 3.0.0-draft.453
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/client/defaultStreamHandler.d.ts +2 -2
- package/cjs/client/defaultStreamHandler.js +10 -10
- package/cjs/client/fetcher.js +1 -2
- package/mjs/client/defaultStreamHandler.d.ts +2 -2
- package/mjs/client/defaultStreamHandler.js +10 -10
- package/mjs/client/fetcher.js +1 -2
- package/package.json +1 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { VovkHandlerSchema } from '../types';
|
|
2
2
|
import type { VovkStreamAsyncIterable } from './types';
|
|
3
3
|
import '../utils/shim';
|
|
4
|
-
export declare const DEFAULT_ERROR_MESSAGE = "
|
|
4
|
+
export declare const DEFAULT_ERROR_MESSAGE = "An unknown error at defaultStreamHandler";
|
|
5
5
|
export declare const defaultStreamHandler: ({ response, abortController, }: {
|
|
6
6
|
response: Response;
|
|
7
7
|
abortController: AbortController;
|
|
8
8
|
schema: VovkHandlerSchema;
|
|
9
|
-
}) =>
|
|
9
|
+
}) => VovkStreamAsyncIterable<unknown>;
|
|
@@ -4,18 +4,18 @@ exports.defaultStreamHandler = exports.DEFAULT_ERROR_MESSAGE = void 0;
|
|
|
4
4
|
const types_1 = require("../types");
|
|
5
5
|
const HttpException_1 = require("../HttpException");
|
|
6
6
|
require("../utils/shim");
|
|
7
|
-
exports.DEFAULT_ERROR_MESSAGE = '
|
|
8
|
-
const defaultStreamHandler =
|
|
7
|
+
exports.DEFAULT_ERROR_MESSAGE = 'An unknown error at defaultStreamHandler';
|
|
8
|
+
const defaultStreamHandler = ({ response, abortController, }) => {
|
|
9
9
|
if (!response.ok) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
response
|
|
11
|
+
.json()
|
|
12
|
+
.then((res) => {
|
|
13
|
+
throw new HttpException_1.HttpException(response.status, res.message ?? exports.DEFAULT_ERROR_MESSAGE);
|
|
14
|
+
})
|
|
15
|
+
.catch(() => {
|
|
16
|
+
throw new HttpException_1.HttpException(response.status, exports.DEFAULT_ERROR_MESSAGE);
|
|
17
|
+
});
|
|
17
18
|
// handle server errors
|
|
18
|
-
throw new HttpException_1.HttpException(response.status, result.message ?? exports.DEFAULT_ERROR_MESSAGE);
|
|
19
19
|
}
|
|
20
20
|
if (!response.body)
|
|
21
21
|
throw new HttpException_1.HttpException(types_1.HttpStatus.NULL, 'Stream body is falsy. Check your controller code.');
|
package/cjs/client/fetcher.js
CHANGED
|
@@ -78,12 +78,11 @@ function createFetcher({ prepareRequestInit, transformResponse, onSuccess, onErr
|
|
|
78
78
|
respData = defaultStreamHandler({ response, abortController, schema });
|
|
79
79
|
}
|
|
80
80
|
else if (contentType?.startsWith('application/json')) {
|
|
81
|
-
respData = defaultHandler({ response, schema });
|
|
81
|
+
respData = await defaultHandler({ response, schema });
|
|
82
82
|
}
|
|
83
83
|
else {
|
|
84
84
|
respData = response;
|
|
85
85
|
}
|
|
86
|
-
respData = await respData;
|
|
87
86
|
respData = transformResponse ? await transformResponse(respData, inputOptions, response, requestInit) : respData;
|
|
88
87
|
await onSuccess?.(respData, inputOptions, response, requestInit);
|
|
89
88
|
return [respData, response];
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { VovkHandlerSchema } from '../types';
|
|
2
2
|
import type { VovkStreamAsyncIterable } from './types';
|
|
3
3
|
import '../utils/shim';
|
|
4
|
-
export declare const DEFAULT_ERROR_MESSAGE = "
|
|
4
|
+
export declare const DEFAULT_ERROR_MESSAGE = "An unknown error at defaultStreamHandler";
|
|
5
5
|
export declare const defaultStreamHandler: ({ response, abortController, }: {
|
|
6
6
|
response: Response;
|
|
7
7
|
abortController: AbortController;
|
|
8
8
|
schema: VovkHandlerSchema;
|
|
9
|
-
}) =>
|
|
9
|
+
}) => VovkStreamAsyncIterable<unknown>;
|
|
@@ -4,18 +4,18 @@ exports.defaultStreamHandler = exports.DEFAULT_ERROR_MESSAGE = void 0;
|
|
|
4
4
|
const types_1 = require("../types");
|
|
5
5
|
const HttpException_1 = require("../HttpException");
|
|
6
6
|
require("../utils/shim");
|
|
7
|
-
exports.DEFAULT_ERROR_MESSAGE = '
|
|
8
|
-
const defaultStreamHandler =
|
|
7
|
+
exports.DEFAULT_ERROR_MESSAGE = 'An unknown error at defaultStreamHandler';
|
|
8
|
+
const defaultStreamHandler = ({ response, abortController, }) => {
|
|
9
9
|
if (!response.ok) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
response
|
|
11
|
+
.json()
|
|
12
|
+
.then((res) => {
|
|
13
|
+
throw new HttpException_1.HttpException(response.status, res.message ?? exports.DEFAULT_ERROR_MESSAGE);
|
|
14
|
+
})
|
|
15
|
+
.catch(() => {
|
|
16
|
+
throw new HttpException_1.HttpException(response.status, exports.DEFAULT_ERROR_MESSAGE);
|
|
17
|
+
});
|
|
17
18
|
// handle server errors
|
|
18
|
-
throw new HttpException_1.HttpException(response.status, result.message ?? exports.DEFAULT_ERROR_MESSAGE);
|
|
19
19
|
}
|
|
20
20
|
if (!response.body)
|
|
21
21
|
throw new HttpException_1.HttpException(types_1.HttpStatus.NULL, 'Stream body is falsy. Check your controller code.');
|
package/mjs/client/fetcher.js
CHANGED
|
@@ -78,12 +78,11 @@ function createFetcher({ prepareRequestInit, transformResponse, onSuccess, onErr
|
|
|
78
78
|
respData = defaultStreamHandler({ response, abortController, schema });
|
|
79
79
|
}
|
|
80
80
|
else if (contentType?.startsWith('application/json')) {
|
|
81
|
-
respData = defaultHandler({ response, schema });
|
|
81
|
+
respData = await defaultHandler({ response, schema });
|
|
82
82
|
}
|
|
83
83
|
else {
|
|
84
84
|
respData = response;
|
|
85
85
|
}
|
|
86
|
-
respData = await respData;
|
|
87
86
|
respData = transformResponse ? await transformResponse(respData, inputOptions, response, requestInit) : respData;
|
|
88
87
|
await onSuccess?.(respData, inputOptions, response, requestInit);
|
|
89
88
|
return [respData, response];
|