vovk 3.0.0-draft.454 → 3.0.0-draft.455
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/JSONLinesResponse.js
CHANGED
|
@@ -34,6 +34,7 @@ class JSONLinesResponse extends Response {
|
|
|
34
34
|
this.encoder = request ? encoder : null;
|
|
35
35
|
this.controller = request ? readableController : null;
|
|
36
36
|
request?.signal?.addEventListener('abort', this.close, { once: true });
|
|
37
|
+
this.send({});
|
|
37
38
|
}
|
|
38
39
|
send = (data) => {
|
|
39
40
|
const { controller, encoder } = this;
|
package/cjs/client/fetcher.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { VovkFetcherOptions, VovkFetcher } from './types';
|
|
2
2
|
import { HttpException } from '../HttpException';
|
|
3
3
|
export declare const DEFAULT_ERROR_MESSAGE = "Unknown error at default fetcher";
|
|
4
|
-
export declare function createFetcher<T>({ prepareRequestInit, onError, }?: {
|
|
4
|
+
export declare function createFetcher<T>({ prepareRequestInit, transformResponse, onSuccess, onError, }?: {
|
|
5
5
|
prepareRequestInit?: (init: RequestInit, options: VovkFetcherOptions<T>) => RequestInit | Promise<RequestInit>;
|
|
6
6
|
transformResponse?: (respData: unknown, options: VovkFetcherOptions<T>, response: Response, init: RequestInit) => unknown | Promise<unknown>;
|
|
7
7
|
onSuccess?: (respData: unknown, options: VovkFetcherOptions<T>, response: Response, init: RequestInit) => void | Promise<void>;
|
package/cjs/client/fetcher.js
CHANGED
|
@@ -5,10 +5,7 @@ exports.createFetcher = createFetcher;
|
|
|
5
5
|
const types_1 = require("../types");
|
|
6
6
|
const HttpException_1 = require("../HttpException");
|
|
7
7
|
exports.DEFAULT_ERROR_MESSAGE = 'Unknown error at default fetcher';
|
|
8
|
-
function createFetcher({ prepareRequestInit,
|
|
9
|
-
// transformResponse,
|
|
10
|
-
// onSuccess,
|
|
11
|
-
onError, } = {}) {
|
|
8
|
+
function createFetcher({ prepareRequestInit, transformResponse, onSuccess, onError, } = {}) {
|
|
12
9
|
// fetcher uses HttpException class to throw errors of fake HTTP status 0 if client-side error occurs
|
|
13
10
|
// For normal HTTP errors, it uses message and status code from the response of VovkErrorResponse type
|
|
14
11
|
const newFetcher = async ({ httpMethod, getEndpoint, validate, defaultHandler, defaultStreamHandler, schema }, inputOptions) => {
|
|
@@ -86,8 +83,8 @@ onError, } = {}) {
|
|
|
86
83
|
else {
|
|
87
84
|
respData = response;
|
|
88
85
|
}
|
|
89
|
-
|
|
90
|
-
|
|
86
|
+
respData = transformResponse ? await transformResponse(respData, inputOptions, response, requestInit) : respData;
|
|
87
|
+
await onSuccess?.(respData, inputOptions, response, requestInit);
|
|
91
88
|
return [respData, response];
|
|
92
89
|
}
|
|
93
90
|
catch (error) {
|
package/mjs/JSONLinesResponse.js
CHANGED
|
@@ -34,6 +34,7 @@ class JSONLinesResponse extends Response {
|
|
|
34
34
|
this.encoder = request ? encoder : null;
|
|
35
35
|
this.controller = request ? readableController : null;
|
|
36
36
|
request?.signal?.addEventListener('abort', this.close, { once: true });
|
|
37
|
+
this.send({});
|
|
37
38
|
}
|
|
38
39
|
send = (data) => {
|
|
39
40
|
const { controller, encoder } = this;
|
package/mjs/client/fetcher.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { VovkFetcherOptions, VovkFetcher } from './types';
|
|
2
2
|
import { HttpException } from '../HttpException';
|
|
3
3
|
export declare const DEFAULT_ERROR_MESSAGE = "Unknown error at default fetcher";
|
|
4
|
-
export declare function createFetcher<T>({ prepareRequestInit, onError, }?: {
|
|
4
|
+
export declare function createFetcher<T>({ prepareRequestInit, transformResponse, onSuccess, onError, }?: {
|
|
5
5
|
prepareRequestInit?: (init: RequestInit, options: VovkFetcherOptions<T>) => RequestInit | Promise<RequestInit>;
|
|
6
6
|
transformResponse?: (respData: unknown, options: VovkFetcherOptions<T>, response: Response, init: RequestInit) => unknown | Promise<unknown>;
|
|
7
7
|
onSuccess?: (respData: unknown, options: VovkFetcherOptions<T>, response: Response, init: RequestInit) => void | Promise<void>;
|
package/mjs/client/fetcher.js
CHANGED
|
@@ -5,10 +5,7 @@ exports.createFetcher = createFetcher;
|
|
|
5
5
|
const types_1 = require("../types");
|
|
6
6
|
const HttpException_1 = require("../HttpException");
|
|
7
7
|
exports.DEFAULT_ERROR_MESSAGE = 'Unknown error at default fetcher';
|
|
8
|
-
function createFetcher({ prepareRequestInit,
|
|
9
|
-
// transformResponse,
|
|
10
|
-
// onSuccess,
|
|
11
|
-
onError, } = {}) {
|
|
8
|
+
function createFetcher({ prepareRequestInit, transformResponse, onSuccess, onError, } = {}) {
|
|
12
9
|
// fetcher uses HttpException class to throw errors of fake HTTP status 0 if client-side error occurs
|
|
13
10
|
// For normal HTTP errors, it uses message and status code from the response of VovkErrorResponse type
|
|
14
11
|
const newFetcher = async ({ httpMethod, getEndpoint, validate, defaultHandler, defaultStreamHandler, schema }, inputOptions) => {
|
|
@@ -86,8 +83,8 @@ onError, } = {}) {
|
|
|
86
83
|
else {
|
|
87
84
|
respData = response;
|
|
88
85
|
}
|
|
89
|
-
|
|
90
|
-
|
|
86
|
+
respData = transformResponse ? await transformResponse(respData, inputOptions, response, requestInit) : respData;
|
|
87
|
+
await onSuccess?.(respData, inputOptions, response, requestInit);
|
|
91
88
|
return [respData, response];
|
|
92
89
|
}
|
|
93
90
|
catch (error) {
|