@rest-vir/define-service 0.21.0 → 0.22.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.
|
@@ -41,6 +41,11 @@ export type EndpointInit<AllowedMethods extends RequireAtLeastOne<Record<HttpMet
|
|
|
41
41
|
* - Any other set value overrides the service's origin requirement (if it has any).
|
|
42
42
|
*/
|
|
43
43
|
requiredClientOrigin?: OriginRequirement;
|
|
44
|
+
/**
|
|
45
|
+
* Set this to `true` to bypass shape validation. You might want to use this, for example, for
|
|
46
|
+
* large data sets that are being slow.
|
|
47
|
+
*/
|
|
48
|
+
bypassResponseValidation?: boolean | undefined;
|
|
44
49
|
/**
|
|
45
50
|
* A shape used to verify search params. This should match the entire search params object.
|
|
46
51
|
*
|
|
@@ -102,6 +107,7 @@ export declare const endpointInitShape: ShapeDefinition<{
|
|
|
102
107
|
values: boolean;
|
|
103
108
|
required: false;
|
|
104
109
|
}]>;
|
|
110
|
+
bypassResponseValidation: import("object-shape-tester").ShapeOptional<import("object-shape-tester").ShapeOr<[undefined, null, boolean]>>;
|
|
105
111
|
customProps: import("object-shape-tester").ShapeOptional<import("object-shape-tester").ShapeOr<[undefined, import("object-shape-tester").ShapeIndexedKeys<[{
|
|
106
112
|
keys: import("object-shape-tester").ShapeUnknown<[unknown]>;
|
|
107
113
|
values: import("object-shape-tester").ShapeUnknown<[unknown]>;
|
|
@@ -28,6 +28,7 @@ export const endpointInitShape = defineShape({
|
|
|
28
28
|
values: false,
|
|
29
29
|
required: false,
|
|
30
30
|
}),
|
|
31
|
+
bypassResponseValidation: optional(or(undefined, null, false)),
|
|
31
32
|
customProps: optional(or(undefined, indexedKeys({
|
|
32
33
|
keys: unknownShape(),
|
|
33
34
|
values: unknownShape(),
|
|
@@ -16,6 +16,7 @@ export type GenericFetchEndpointParams = {
|
|
|
16
16
|
pathParams?: Record<string, string> | undefined;
|
|
17
17
|
requestData?: any;
|
|
18
18
|
searchParams?: BaseSearchParams | undefined;
|
|
19
|
+
bypassResponseValidation?: undefined | boolean;
|
|
19
20
|
method?: HttpMethod | undefined;
|
|
20
21
|
options?: Omit<RequestInit, 'body' | 'method'> | undefined;
|
|
21
22
|
/**
|
|
@@ -52,7 +52,7 @@ function filterToValidMethod(endpoint, chosenMethod) {
|
|
|
52
52
|
* @package [`@rest-vir/define-service`](https://www.npmjs.com/package/@rest-vir/define-service)
|
|
53
53
|
*/
|
|
54
54
|
export async function fetchEndpoint(endpoint, ...params) {
|
|
55
|
-
const { requestData, fetch } = params[0] || {};
|
|
55
|
+
const { requestData, fetch, bypassResponseValidation } = params[0] || {};
|
|
56
56
|
if (requestData) {
|
|
57
57
|
if (endpoint.requestDataShape) {
|
|
58
58
|
assertValidShape(requestData, endpoint.requestDataShape, { allowExtraKeys: true });
|
|
@@ -68,7 +68,7 @@ export async function fetchEndpoint(endpoint, ...params) {
|
|
|
68
68
|
const responseData = endpoint.responseDataShape
|
|
69
69
|
? parseJsonWithUndefined(await response.text())
|
|
70
70
|
: undefined;
|
|
71
|
-
if (endpoint.responseDataShape) {
|
|
71
|
+
if (endpoint.responseDataShape && !bypassResponseValidation) {
|
|
72
72
|
assertValidShape(responseData, endpoint.responseDataShape, { allowExtraKeys: true });
|
|
73
73
|
}
|
|
74
74
|
return {
|