@ts-rest/core
Advanced tools
Comparing version 3.19.4 to 3.19.5
22
index.js
@@ -194,5 +194,21 @@ const isAppRoute = (obj) => { | ||
const isZodObject = (body) => { | ||
return (body === null || body === void 0 ? void 0 : body.safeParse) !== undefined; | ||
const isZodType = (obj) => { | ||
return typeof (obj === null || obj === void 0 ? void 0 : obj.safeParse) === 'function'; | ||
}; | ||
const isZodObject = (obj) => { | ||
const isZodEffects = typeof (obj === null || obj === void 0 ? void 0 : obj.innerType) === 'function'; | ||
const maybeZodObject = isZodEffects | ||
? obj === null || obj === void 0 ? void 0 : obj.innerType() | ||
: obj; | ||
return typeof (maybeZodObject === null || maybeZodObject === void 0 ? void 0 : maybeZodObject.passthrough) === 'function'; | ||
}; | ||
const extractZodObjectShape = (obj) => { | ||
if (!isZodObject(obj)) { | ||
throw new Error('Unknown zod object type'); | ||
} | ||
if ('innerType' in obj) { | ||
return obj.innerType().shape; | ||
} | ||
return obj.shape; | ||
}; | ||
const checkZodSchema = (data, schema, { passThroughExtraKeys = false } = {}) => { | ||
@@ -255,2 +271,2 @@ if (isZodObject(schema)) { | ||
export { ResponseValidationError, checkZodSchema, convertQueryParamsToUrlString, encodeQueryParams, encodeQueryParamsJson, fetchApi, getCompleteUrl, getRouteQuery, getRouteResponses, initClient, initContract, initTsRest, insertParamsIntoPath, isAppRoute, isAppRouteResponse, isZodObject, parseJsonQueryObject, tsRestFetchApi, validateResponse, zodErrorResponse }; | ||
export { ResponseValidationError, checkZodSchema, convertQueryParamsToUrlString, encodeQueryParams, encodeQueryParamsJson, extractZodObjectShape, fetchApi, getCompleteUrl, getRouteQuery, getRouteResponses, initClient, initContract, initTsRest, insertParamsIntoPath, isAppRoute, isAppRouteResponse, isZodObject, isZodType, parseJsonQueryObject, tsRestFetchApi, validateResponse, zodErrorResponse }; |
{ | ||
"name": "@ts-rest/core", | ||
"version": "3.19.4", | ||
"version": "3.19.5", | ||
"description": "RPC-like experience over a regular REST API, with type safe server implementations 🪄", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
import { z } from 'zod'; | ||
export declare const isZodObject: (body: unknown) => body is z.AnyZodObject; | ||
export declare const isZodType: (obj: unknown) => obj is z.ZodTypeAny; | ||
export declare const isZodObject: (obj: unknown) => obj is z.AnyZodObject | z.ZodEffects<z.AnyZodObject, { | ||
[x: string]: any; | ||
}, { | ||
[x: string]: any; | ||
}>; | ||
export declare const extractZodObjectShape: <T extends z.AnyZodObject | z.ZodEffects<z.AnyZodObject, { | ||
[x: string]: any; | ||
}, { | ||
[x: string]: any; | ||
}>>(obj: T) => any; | ||
export declare const checkZodSchema: (data: unknown, schema: unknown, { passThroughExtraKeys }?: { | ||
@@ -4,0 +14,0 @@ passThroughExtraKeys?: boolean | undefined; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
45795
948