@rest-vir/define-service 0.21.0 → 0.22.1

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
  /**
@@ -72,7 +73,7 @@ export type FetchEndpointParams<EndpointToFetch extends SelectFrom<EndpointDefin
72
73
  method?: never;
73
74
  } : {
74
75
  method: FetchMethod<EndpointToFetch>;
75
- }) & (AllowFetchMock extends true ? Pick<GenericFetchEndpointParams, 'options' | 'fetch'> : Pick<GenericFetchEndpointParams, 'options'>)> : GenericFetchEndpointParams;
76
+ }) & (AllowFetchMock extends true ? Pick<GenericFetchEndpointParams, 'options' | 'fetch' | 'bypassResponseValidation'> : Pick<GenericFetchEndpointParams, 'options' | 'bypassResponseValidation'>)> : GenericFetchEndpointParams;
76
77
  /**
77
78
  * Type safe output from sending a request to an endpoint definition. Used by {@link fetchEndpoint}.
78
79
  *
@@ -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 {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rest-vir/define-service",
3
- "version": "0.21.0",
3
+ "version": "0.22.1",
4
4
  "description": "Define an connect to a declarative and type safe REST and WebSocket service.",
5
5
  "keywords": [
6
6
  "rest",