Skip to main content

Module: @ts-rest/core

Classes

Interfaces

Type Aliases

And

Ƭ And<B1, B2>: { false: { false: false ; true: false } ; true: { false: false ; true: true } }[`${B1}`][\`${B2}\`]

Type parameters

NameType
B1extends boolean
B2extends boolean

Defined in

libs/ts-rest/core/src/lib/type-utils.ts:167


ApiFetcher

Ƭ ApiFetcher: (args: ApiFetcherArgs) => Promise<{ body: unknown ; headers: Headers ; status: number }>

Type declaration

▸ (args): Promise<{ body: unknown ; headers: Headers ; status: number }>

Parameters
NameType
argsApiFetcherArgs
Returns

Promise<{ body: unknown ; headers: Headers ; status: number }>

Defined in

libs/ts-rest/core/src/lib/client.ts:99


ApiFetcherArgs

Ƭ ApiFetcherArgs<TFetchOptions>: Object

Type parameters

NameType
TFetchOptionsextends FetchOptions = FetchOptions

Type declaration

NameTypeDescription
bodyFormData | URLSearchParams | string | null | undefined-
cache?"cache" extends keyof TFetchOptions ? TFetchOptions["cache"] : neverDeprecated Use fetchOptions.cache instead
contentTypeAppRouteMutation["contentType"]-
credentials?TFetchOptions["credentials"]Deprecated Use fetchOptions.credentials instead
fetchOptions?FetchOptions-
headersRecord<string, string>-
methodstring-
next?"next" extends keyof TFetchOptions ? TFetchOptions["next"] : neverDeprecated Use fetchOptions.next instead
pathstring-
rawBodyunknown-
rawQueryunknown-
routeAppRoute-
signal?TFetchOptions["signal"]Deprecated Use fetchOptions.signal instead
validateResponse?boolean-

Defined in

libs/ts-rest/core/src/lib/client.ts:66


ApiResponseForRoute

Ƭ ApiResponseForRoute<T>: ClientInferResponses<T>

Deprecated

Only safe to use on the client-side. Use ServerInferResponses/ClientInferResponses instead.

Type parameters

NameType
Textends AppRoute

Defined in

libs/ts-rest/core/src/lib/client.ts:25


AppRoute

Ƭ AppRoute: AppRouteQuery | AppRouteMutation | AppRouteDeleteNoBody

A union of all possible endpoint types.

Defined in

libs/ts-rest/core/src/lib/dsl.ts:169


AppRouteDeleteNoBody

Ƭ AppRouteDeleteNoBody: AppRouteCommon & { method: "DELETE" }

A mutation endpoint. In REST terms, one using POST, PUT, PATCH, or DELETE.

Defined in

libs/ts-rest/core/src/lib/dsl.ts:76


AppRouteFunction

Ƭ AppRouteFunction<TRoute, TClientArgs, TArgs>: AreAllPropertiesOptional<TArgs> extends true ? (args?: Prettify<TArgs>) => Promise<Prettify<ClientInferResponses<TRoute>>> : (args: Prettify<TArgs>) => Promise<Prettify<ClientInferResponses<TRoute>>>

Returned from a mutation or query call

Type parameters

NameType
TRouteextends AppRoute
TClientArgsextends ClientArgs
TArgsPartialClientInferRequest<TRoute, TClientArgs>

Defined in

libs/ts-rest/core/src/lib/client.ts:37


AppRouteMutation

Ƭ AppRouteMutation: AppRouteCommon & { body: ContractAnyType | ContractNoBodyType ; contentType?: "application/json" | "multipart/form-data" | "application/x-www-form-urlencoded" ; method: "POST" | "DELETE" | "PUT" | "PATCH" }

A mutation endpoint. In REST terms, one using POST, PUT, PATCH, or DELETE.

Defined in

libs/ts-rest/core/src/lib/dsl.ts:63


AppRouteQuery

Ƭ AppRouteQuery: AppRouteCommon & { method: "GET" }

A query endpoint. In REST terms, one using GET.

Defined in

libs/ts-rest/core/src/lib/dsl.ts:55


AppRouteResponse

Ƭ AppRouteResponse: ContractAnyType | ContractNoBodyType | ContractOtherResponse<ContractAnyType>

Defined in

libs/ts-rest/core/src/lib/dsl.ts:29


AppRouteStrictStatusCodes

Ƭ AppRouteStrictStatusCodes: Omit<AppRoute, "strictStatusCodes"> & { strictStatusCodes: true }

Defined in

libs/ts-rest/core/src/lib/dsl.ts:170


AppRouter

Ƭ AppRouter: Object

A router (or contract) in @ts-rest is a collection of more routers or individual routes

Index signature

[key: string]: AppRouter | AppRoute

Defined in

libs/ts-rest/core/src/lib/dsl.ts:178


AreAllPropertiesOptional

Ƭ AreAllPropertiesOptional<T>: T extends Record<string, unknown> ? Exclude<keyof T, OptionalKeys<T>> extends never ? true : false : false

Type parameters

Name
T

Defined in

libs/ts-rest/core/src/lib/type-utils.ts:106


ClientInferRequest

Ƭ ClientInferRequest<T, TClientArgs>: T extends AppRoute ? ClientInferRequestBase<T, TClientArgs> : T extends AppRouter ? { [TKey in keyof T]: ClientInferRequest<T[TKey]> } : never

Type parameters

NameType
Textends AppRoute | AppRouter
TClientArgsextends Omit<ClientArgs, "baseUrl"> = {}

Defined in

libs/ts-rest/core/src/lib/infer-types.ts:258


ClientInferResponseBody

Ƭ ClientInferResponseBody<T, TStatus>: Prettify<AppRouteResponses<T, TStatus & HTTPStatusCode, "client">["body"]>

Type parameters

NameType
Textends AppRoute
TStatusextends keyof T["responses"] = keyof T["responses"]

Defined in

libs/ts-rest/core/src/lib/infer-types.ts:156


ClientInferResponses

Ƭ ClientInferResponses<T, TStatus, TStrictStatusCodes>: T extends AppRoute ? Prettify<AppRouteResponses<T, TStatus, "client", TStrictStatusCodes>> : T extends AppRouter ? { [TKey in keyof T]: ClientInferResponses<T[TKey], TStatus, TStrictStatusCodes> } : never

Type parameters

NameType
Textends AppRoute | AppRouter
TStatusextends HTTPStatusCode = HTTPStatusCode
TStrictStatusCodesextends "default" | "ignore" | "force" = "default"

Defined in

libs/ts-rest/core/src/lib/infer-types.ts:135


CommonAndEqual

Ƭ CommonAndEqual<T>: RemoveUnionProperties<Common<T>>

Type parameters

Name
T

Defined in

libs/ts-rest/core/src/lib/type-utils.ts:212


ContractAnyType

Ƭ ContractAnyType: z.ZodSchema | ContractPlainType<unknown> | ContractNullType | null

Defined in

libs/ts-rest/core/src/lib/dsl.ts:19


ContractNoBodyType

Ƭ ContractNoBodyType: typeof ContractNoBody

Defined in

libs/ts-rest/core/src/lib/dsl.ts:18


ContractNullType

Ƭ ContractNullType: Opaque<typeof NullSymbol, "ContractNullType">

Defined in

libs/ts-rest/core/src/lib/dsl.ts:17


ContractOtherResponse

Ƭ ContractOtherResponse<T>: Opaque<{ body: T ; contentType: string }, "ContractOtherResponse">

Type parameters

NameType
Textends ContractAnyType

Defined in

libs/ts-rest/core/src/lib/dsl.ts:24


ContractPlainType

Ƭ ContractPlainType<T>: Opaque<T, "ContractPlainType">

Type parameters

Name
T

Defined in

libs/ts-rest/core/src/lib/dsl.ts:16


DefinedOrEmpty

Ƭ DefinedOrEmpty<T, K>: undefined extends T ? {} : NonNullable<T>[K]

Type parameters

NameType
TT
Kextends keyof NonNullable<T>

Defined in

libs/ts-rest/core/src/lib/type-utils.ts:136


ErrorHttpStatusCode

Ƭ ErrorHttpStatusCode: Exclude<HTTPStatusCode, SuccessfulHttpStatusCode>

Defined in

libs/ts-rest/core/src/lib/status-codes.ts:72


Extends

Ƭ Extends<T, U>: T extends U ? true : false

Type parameters

Name
T
U

Defined in

libs/ts-rest/core/src/lib/type-utils.ts:165


FetchApiOptions

Ƭ FetchApiOptions: Object

Type declaration

NameType
bodyunknown
clientArgsClientArgs
extraInputArgsRecord<string, unknown>
fetchOptions?FetchOptions
headersRecord<string, string | undefined>
pathstring
queryunknown
routeAppRoute

Defined in

libs/ts-rest/core/src/lib/client.ts:196


FetchOptions

Ƭ FetchOptions: typeof globalThis extends { Request: infer T } ? Omit<NonNullable<ConstructorParameters<T>[1]>, "method" | "headers" | "body"> : never

Defined in

libs/ts-rest/core/src/lib/client.ts:45


FlattenAppRouter

Ƭ FlattenAppRouter<T>: T extends AppRoute ? T : { [TKey in keyof T]: T[TKey] extends AppRoute ? T[TKey] : T[TKey] extends AppRouter ? FlattenAppRouter<T[TKey]> : never }[keyof T]

Type parameters

NameType
Textends AppRouter | AppRoute

Defined in

libs/ts-rest/core/src/lib/dsl.ts:182


GetFieldType

Ƭ GetFieldType<T, P>: P extends `${infer Left}.${infer Right}` ? Left extends keyof T ? FieldWithPossiblyUndefined<T[Left], Right> : Left extends `${infer FieldKey}[${infer IndexKey}]` ? FieldKey extends keyof T ? FieldWithPossiblyUndefined<IndexedFieldWithPossiblyUndefined<T[FieldKey], IndexKey>, Right> : undefined : undefined : P extends keyof T ? T[P] : P extends `${infer FieldKey}[${infer IndexKey}]` ? FieldKey extends keyof T ? IndexedFieldWithPossiblyUndefined<T[FieldKey], IndexKey> : undefined : undefined

Type parameters

Name
T
P

Defined in

libs/ts-rest/core/src/lib/type-utils.ts:22


HTTPStatusCode

Ƭ HTTPStatusCode: 100 | 101 | 102 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 428 | 429 | 431 | 451 | 500 | 501 | 502 | 503 | 504 | 505 | 507 | 511

All available HTTP Status codes

Defined in

libs/ts-rest/core/src/lib/status-codes.ts:14


IfAllPropertiesOptional

Ƭ IfAllPropertiesOptional<T, TIf, TElse>: T extends Record<string, unknown> ? Exclude<keyof T, OptionalKeys<T>> extends never ? TIf : TElse : TElse

Type parameters

Name
T
TIf
TElse

Defined in

libs/ts-rest/core/src/lib/type-utils.ts:112


InferResponseDefinedStatusCodes

Ƭ InferResponseDefinedStatusCodes<T, TStatus>: { [K in keyof T["responses"] & TStatus]: K }[keyof T["responses"] & TStatus]

Type parameters

NameType
Textends AppRoute
TStatusextends HTTPStatusCode = HTTPStatusCode

Defined in

libs/ts-rest/core/src/lib/infer-types.ts:70


InferResponseUndefinedStatusCodes

Ƭ InferResponseUndefinedStatusCodes<T, TStatus>: Exclude<TStatus, InferResponseDefinedStatusCodes<T, TStatus>>

Type parameters

NameType
Textends AppRoute
TStatusextends HTTPStatusCode = HTTPStatusCode

Defined in

libs/ts-rest/core/src/lib/infer-types.ts:77


InitClientArgs

Ƭ InitClientArgs: ClientArgs & { throwOnUnknownStatus?: boolean }

Defined in

libs/ts-rest/core/src/lib/client.ts:420


InitClientReturn

Ƭ InitClientReturn<T, TClientArgs>: RecursiveProxyObj<T, TClientArgs>

Type parameters

NameType
Textends AppRouter
TClientArgsextends ClientArgs

Defined in

libs/ts-rest/core/src/lib/client.ts:414


LowercaseKeys

Ƭ LowercaseKeys<T>: Prettify<{ [K in keyof T as K extends string ? Lowercase<K> : K]: T[K] }>

Type parameters

Name
T

Defined in

libs/ts-rest/core/src/lib/type-utils.ts:161


Merge

Ƭ Merge<T, U>: Omit<T, keyof U> & U

Type parameters

Name
T
U

Defined in

libs/ts-rest/core/src/lib/type-utils.ts:74


Narrow

Ƭ Narrow<T>: Try<T, [], NarrowNotZod<T>>

Type parameters

Name
T

Defined in

libs/ts-rest/core/src/lib/type-utils.ts:89


Not

Ƭ Not<B>: { false: true ; true: false }[`${B}`]

Type parameters

NameType
Bextends boolean

Defined in

libs/ts-rest/core/src/lib/type-utils.ts:189


Opaque

Ƭ Opaque<Type, Token>: Type & Tagged<Token>

Type parameters

NameType
TypeType
Tokenunknown

Defined in

libs/ts-rest/core/src/lib/type-utils.ts:147


OptionalIfAllOptional

Ƭ OptionalIfAllOptional<T, Select>: PartialBy<T, Select & { [K in keyof T]: AreAllPropertiesOptional<T[K]> extends true ? K : never }[keyof T]>

Type parameters

NameType
TT
Selectextends keyof T = keyof T

Defined in

libs/ts-rest/core/src/lib/type-utils.ts:121


Or

Ƭ Or<B1, B2>: { false: { false: false ; true: true } ; true: { false: true ; true: true } }[`${B1}`][\`${B2}\`]

Type parameters

NameType
B1extends boolean
B2extends boolean

Defined in

libs/ts-rest/core/src/lib/type-utils.ts:178


ParamsFromUrl

Ƭ ParamsFromUrl<T>: RecursivelyExtractPathParams<T, {}> extends infer U ? { [key in keyof U]: U[key] } : never

Extract path params from path function

{ id: string, commentId: string }

Params

T - The URL e.g. /posts/:id

Type parameters

NameType
Textends string

Defined in

libs/ts-rest/core/src/lib/paths.ts:42


PartialBy

Ƭ PartialBy<T, K>: Omit<T, K> & Partial<Pick<T, K>>

Type parameters

NameType
TT
Kextends keyof T

Defined in

libs/ts-rest/core/src/lib/type-utils.ts:91


PartialByLooseKeys

Ƭ PartialByLooseKeys<T, K>: Omit<T, K extends keyof T ? K : never> & Partial<Pick<T, K extends keyof T ? K : never>>

Type parameters

Name
T
K

Defined in

libs/ts-rest/core/src/lib/type-utils.ts:93


PartialClientInferRequest

Ƭ PartialClientInferRequest<TRoute, TClientArgs>: OptionalIfAllOptional<ClientInferRequest<TRoute, TClientArgs>>

Type parameters

NameType
TRouteextends AppRoute
TClientArgsextends Omit<ClientArgs, "baseUrl"> = {}

Defined in

libs/ts-rest/core/src/lib/infer-types.ts:267


Prettify

Ƭ Prettify<T>: { [K in keyof T]: T[K] } & {}

Type parameters

Name
T

Defined in

libs/ts-rest/core/src/lib/type-utils.ts:132


ResolveResponseType

Ƭ ResolveResponseType<T>: T extends ContractOtherResponse<infer U> ? U : T

Type parameters

NameType
Textends ContractAnyType | ContractNoBodyType | ContractOtherResponse<ContractAnyType>

Defined in

libs/ts-rest/core/src/lib/infer-types.ts:63


RouterOptions

Ƭ RouterOptions<TPrefix>: Object

Type parameters

NameType
TPrefixextends string = string

Type declaration

NameTypeDescription
baseHeaders?unknown-
commonResponses?Record<number, AppRouteResponse>-
metadata?unknown-
pathPrefix?TPrefix-
strictStatusCodes?boolean-
validateResponseOnClient?booleanDeprecated Use validateResponse on the client options

Defined in

libs/ts-rest/core/src/lib/dsl.ts:193


ServerInferRequest

Ƭ ServerInferRequest<T, TServerHeaders>: T extends AppRoute ? Prettify<Without<{ body: T extends AppRouteMutation ? BodyWithoutFileIfMultiPart<T> : never ; headers: "headers" extends keyof T ? Prettify<LowercaseKeys<ZodInferOrType<T["headers"]>> & [TServerHeaders] extends [never] ? {} : Omit<TServerHeaders, keyof LowercaseKeys<ZodInferOrType<T["headers"]>>>> : TServerHeaders ; params: [keyof PathParamsWithCustomValidators<T>] extends [never] ? never : Prettify<PathParamsWithCustomValidators<T>> ; query: "query" extends keyof T ? ZodInferOrType<T["query"]> : never }, never>> : T extends AppRouter ? { [TKey in keyof T]: ServerInferRequest<T[TKey], TServerHeaders> } : never

Type parameters

NameType
Textends AppRoute | AppRouter
TServerHeadersnever

Defined in

libs/ts-rest/core/src/lib/infer-types.ts:166


ServerInferResponseBody

Ƭ ServerInferResponseBody<T, TStatus>: Prettify<AppRouteResponses<T, TStatus & HTTPStatusCode, "server">["body"]>

Type parameters

NameType
Textends AppRoute
TStatusextends keyof T["responses"] = keyof T["responses"]

Defined in

libs/ts-rest/core/src/lib/infer-types.ts:151


ServerInferResponses

Ƭ ServerInferResponses<T, TStatus, TStrictStatusCodes>: T extends AppRoute ? Prettify<AppRouteResponses<T, TStatus, "server", TStrictStatusCodes>> : T extends AppRouter ? { [TKey in keyof T]: ServerInferResponses<T[TKey], TStatus, TStrictStatusCodes> } : never

Type parameters

NameType
Textends AppRoute | AppRouter
TStatusextends HTTPStatusCode = HTTPStatusCode
TStrictStatusCodesextends "default" | "ignore" | "force" = "default"

Defined in

libs/ts-rest/core/src/lib/infer-types.ts:119


SuccessfulHttpStatusCode

Ƭ SuccessfulHttpStatusCode: 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207

Defined in

libs/ts-rest/core/src/lib/status-codes.ts:1


UnwrapOpaque

Ƭ UnwrapOpaque<OpaqueType>: OpaqueType extends Opaque<infer Type, OpaqueType[typeof tag]> ? Type : OpaqueType

Type parameters

NameType
OpaqueTypeextends Tagged<unknown>

Defined in

libs/ts-rest/core/src/lib/type-utils.ts:149


With

Ƭ With<T, V>: Pick<T, ExcludeKeysWithoutTypeOf<T, V>>

Type parameters

Name
T
V

Defined in

libs/ts-rest/core/src/lib/type-utils.ts:52


Without

Ƭ Without<T, V>: Pick<T, ExcludeKeysWithTypeOf<T, V>>

Type parameters

Name
T
V

Defined in

libs/ts-rest/core/src/lib/type-utils.ts:51


WithoutUnknown

Ƭ WithoutUnknown<T>: Pick<T, { [K in keyof T]: unknown extends Exclude<T[K], undefined> ? never : K }[keyof T]>

Type parameters

Name
T

Defined in

libs/ts-rest/core/src/lib/type-utils.ts:154


ZodInferOrType

Ƭ ZodInferOrType<T>: T extends ContractNullType ? null : T extends ContractNoBodyType ? undefined : T extends ContractPlainType<infer U> ? U : T extends z.ZodTypeAny ? z.infer<T> : T

Type parameters

Name
T

Defined in

libs/ts-rest/core/src/lib/type-utils.ts:54


ZodInputOrType

Ƭ ZodInputOrType<T>: T extends ContractNullType ? null : T extends ContractNoBodyType ? undefined : T extends ContractPlainType<infer U> ? U : T extends z.ZodTypeAny ? z.input<T> : T

Type parameters

Name
T

Defined in

libs/ts-rest/core/src/lib/type-utils.ts:64

Variables

ContractNoBody

Const ContractNoBody: typeof ContractNoBody

Defined in

libs/ts-rest/core/src/lib/dsl.ts:14


ContractPlainTypeRuntimeSymbol

Const ContractPlainTypeRuntimeSymbol: any

Defined in

libs/ts-rest/core/src/lib/dsl.ts:329


ZodErrorSchema

Const ZodErrorSchema: ZodObject<{ issues: ZodArray<ZodObject<{ code: ZodNativeEnum<{ custom: "custom" ; invalid_arguments: "invalid_arguments" ; invalid_date: "invalid_date" ; invalid_enum_value: "invalid_enum_value" ; invalid_intersection_types: "invalid_intersection_types" ; invalid_literal: "invalid_literal" ; invalid_return_type: "invalid_return_type" ; invalid_string: "invalid_string" ; invalid_type: "invalid_type" ; invalid_union: "invalid_union" ; invalid_union_discriminator: "invalid_union_discriminator" ; not_finite: "not_finite" ; not_multiple_of: "not_multiple_of" ; too_big: "too_big" ; too_small: "too_small" ; unrecognized_keys: "unrecognized_keys" }> ; message: ZodOptional<ZodString> ; path: ZodArray<ZodUnion<[ZodString, ZodNumber]>, "many"> }, "strip", ZodAny, objectOutputType<{ code: ZodNativeEnum<{ custom: "custom" ; invalid_arguments: "invalid_arguments" ; invalid_date: "invalid_date" ; invalid_enum_value: "invalid_enum_value" ; invalid_intersection_types: "invalid_intersection_types" ; invalid_literal: "invalid_literal" ; invalid_return_type: "invalid_return_type" ; invalid_string: "invalid_string" ; invalid_type: "invalid_type" ; invalid_union: "invalid_union" ; invalid_union_discriminator: "invalid_union_discriminator" ; not_finite: "not_finite" ; not_multiple_of: "not_multiple_of" ; too_big: "too_big" ; too_small: "too_small" ; unrecognized_keys: "unrecognized_keys" }> ; message: ZodOptional<ZodString> ; path: ZodArray<ZodUnion<[ZodString, ZodNumber]>, "many"> }, ZodAny, "strip">, objectInputType<{ code: ZodNativeEnum<{ custom: "custom" ; invalid_arguments: "invalid_arguments" ; invalid_date: "invalid_date" ; invalid_enum_value: "invalid_enum_value" ; invalid_intersection_types: "invalid_intersection_types" ; invalid_literal: "invalid_literal" ; invalid_return_type: "invalid_return_type" ; invalid_string: "invalid_string" ; invalid_type: "invalid_type" ; invalid_union: "invalid_union" ; invalid_union_discriminator: "invalid_union_discriminator" ; not_finite: "not_finite" ; not_multiple_of: "not_multiple_of" ; too_big: "too_big" ; too_small: "too_small" ; unrecognized_keys: "unrecognized_keys" }> ; message: ZodOptional<ZodString> ; path: ZodArray<ZodUnion<[ZodString, ZodNumber]>, "many"> }, ZodAny, "strip">>, "many"> ; name: ZodLiteral<"ZodError"> }, "strip", ZodTypeAny, { issues: objectOutputType<{ code: ZodNativeEnum<{ custom: "custom" ; invalid_arguments: "invalid_arguments" ; invalid_date: "invalid_date" ; invalid_enum_value: "invalid_enum_value" ; invalid_intersection_types: "invalid_intersection_types" ; invalid_literal: "invalid_literal" ; invalid_return_type: "invalid_return_type" ; invalid_string: "invalid_string" ; invalid_type: "invalid_type" ; invalid_union: "invalid_union" ; invalid_union_discriminator: "invalid_union_discriminator" ; not_finite: "not_finite" ; not_multiple_of: "not_multiple_of" ; too_big: "too_big" ; too_small: "too_small" ; unrecognized_keys: "unrecognized_keys" }> ; message: ZodOptional<ZodString> ; path: ZodArray<ZodUnion<[ZodString, ZodNumber]>, "many"> }, ZodAny, "strip">[] ; name: "ZodError" }, { issues: objectInputType<{ code: ZodNativeEnum<{ custom: "custom" ; invalid_arguments: "invalid_arguments" ; invalid_date: "invalid_date" ; invalid_enum_value: "invalid_enum_value" ; invalid_intersection_types: "invalid_intersection_types" ; invalid_literal: "invalid_literal" ; invalid_return_type: "invalid_return_type" ; invalid_string: "invalid_string" ; invalid_type: "invalid_type" ; invalid_union: "invalid_union" ; invalid_union_discriminator: "invalid_union_discriminator" ; not_finite: "not_finite" ; not_multiple_of: "not_multiple_of" ; too_big: "too_big" ; too_small: "too_small" ; unrecognized_keys: "unrecognized_keys" }> ; message: ZodOptional<ZodString> ; path: ZodArray<ZodUnion<[ZodString, ZodNumber]>, "many"> }, ZodAny, "strip">[] ; name: "ZodError" }>

Defined in

libs/ts-rest/core/src/lib/zod-utils.ts:105

Functions

checkZodSchema

checkZodSchema(data, schema, «destructured»?): { data: unknown ; success: true } | { error: ZodError<any> ; success: false }

Parameters

NameType
dataunknown
schemaunknown
«destructured»Object
› passThroughExtraKeysundefined | boolean

Returns

{ data: unknown ; success: true } | { error: ZodError<any> ; success: false }

Defined in

libs/ts-rest/core/src/lib/zod-utils.ts:57


convertQueryParamsToUrlString

convertQueryParamsToUrlString(query, json?): string

Parameters

NameTypeDefault valueDescription
queryunknownundefinedAny JSON object
jsonbooleanfalseUse JSON.stringify to encode the query values

Returns

string

  • The query url segment, using explode array syntax, and deep object syntax

Defined in

libs/ts-rest/core/src/lib/query.ts:7


encodeQueryParams

encodeQueryParams(query): string

Parameters

NameType
queryunknown

Returns

string

Defined in

libs/ts-rest/core/src/lib/query.ts:42


encodeQueryParamsJson

encodeQueryParamsJson(query): string

Parameters

NameType
queryunknown

Returns

string

Defined in

libs/ts-rest/core/src/lib/query.ts:14


evaluateFetchApiArgs

evaluateFetchApiArgs<TAppRoute>(route, clientArgs, inputArgs?): FetchApiOptions

Type parameters

NameType
TAppRouteextends AppRoute

Parameters

NameTypeDescription
routeTAppRoute-
clientArgsInitClientArgs-
inputArgs?Object-
inputArgs.bodyany-
inputArgs.cache?RequestCacheDeprecated Use fetchOptions.cache instead
inputArgs.extraHeaders?{} & Record<string, undefined | string>-
inputArgs.fetchOptions?Omit<RequestInit, "headers" | "method" | "body">-
inputArgs.headers{ [x: Lowercase<string>]: any; }-
inputArgs.overrideClientOptions?Partial<OverrideableClientArgs>-
inputArgs.params{ [x: string]: any; }-
inputArgs.queryany-

Returns

FetchApiOptions

Defined in

libs/ts-rest/core/src/lib/client.ts:309


exhaustiveGuard

exhaustiveGuard<T>(response): never

Type parameters

NameType
Textends Object

Parameters

NameType
responseT

Returns

never

Defined in

libs/ts-rest/core/src/lib/type-guards.ts:95


extractZodObjectShape

extractZodObjectShape<T>(obj): any

Type parameters

NameType
Textends AnyZodObject | ZodEffects<ZodTypeAny, any, any>

Parameters

NameType
objT

Returns

any

Defined in

libs/ts-rest/core/src/lib/zod-utils.ts:25


fetchApi

fetchApi(options): Promise<{ body: unknown ; headers: Headers ; status: number }>

Parameters

NameType
optionsFetchApiOptions

Returns

Promise<{ body: unknown ; headers: Headers ; status: number }>

Defined in

libs/ts-rest/core/src/lib/client.ts:207


getRouteQuery

getRouteQuery<TAppRoute>(route, clientArgs): (inputArgs?: { body: any ; cache?: RequestCache ; extraHeaders?: {} & Record<string, undefined | string> ; fetchOptions?: Omit<RequestInit, "headers" | "method" | "body"> ; headers: { [x: Lowercase<string>]: any; } ; overrideClientOptions?: Partial<OverrideableClientArgs> ; params: { [x: string]: any; } ; query: any }) => Promise<{ body: unknown ; headers: Headers ; status: number }>

Type parameters

NameType
TAppRouteextends AppRoute

Parameters

NameType
routeTAppRoute
clientArgsInitClientArgs

Returns

fn

▸ (inputArgs?): Promise<{ body: unknown ; headers: Headers ; status: number }>

Parameters
NameTypeDescription
inputArgs?Object-
inputArgs.bodyany-
inputArgs.cache?RequestCacheDeprecated Use fetchOptions.cache instead
inputArgs.extraHeaders?{} & Record<string, undefined | string>-
inputArgs.fetchOptions?Omit<RequestInit, "headers" | "method" | "body">-
inputArgs.headers{ [x: Lowercase<string>]: any; }-
inputArgs.overrideClientOptions?Partial<OverrideableClientArgs>-
inputArgs.params{ [x: string]: any; }-
inputArgs.queryany-
Returns

Promise<{ body: unknown ; headers: Headers ; status: number }>

Defined in

libs/ts-rest/core/src/lib/client.ts:390


getRouteResponses

getRouteResponses<T>(router): ClientInferResponses<T>

Type parameters

NameType
Textends AppRouter

Parameters

NameType
routerT

Returns

ClientInferResponses<T>

Deprecated

Only safe to use on the client-side. Use ServerInferResponses/ClientInferResponses instead.

Defined in

libs/ts-rest/core/src/lib/client.ts:30


initClient

initClient<T, TClientArgs>(router, args): RecursiveProxyObj<T, TClientArgs>

Type parameters

NameType
Textends AppRouter
TClientArgsextends InitClientArgs

Parameters

NameType
routerT
argsTClientArgs

Returns

RecursiveProxyObj<T, TClientArgs>

Defined in

libs/ts-rest/core/src/lib/client.ts:428


initContract

initContract(): ContractInstance

Instantiate a ts-rest client, primarily to access router, response, and body

Returns

ContractInstance

Defined in

libs/ts-rest/core/src/lib/dsl.ts:338


initTsRest

initTsRest(): ContractInstance

Returns

ContractInstance

Deprecated

Please use initContract instead.

Defined in

libs/ts-rest/core/src/lib/dsl.ts:288


insertParamsIntoPath

insertParamsIntoPath<T>(«destructured»): string

Type parameters

NameType
Textends string

Parameters

NameType
«destructured»Object
› paramsParamsFromUrl<T>
› pathT

Returns

string

  • The URL with the params e.g. /posts/123

Defined in

libs/ts-rest/core/src/lib/paths.ts:56


isAppRoute

isAppRoute(obj): obj is AppRoute

Differentiate between a route and a router

Parameters

NameType
objAppRoute | AppRouter

Returns

obj is AppRoute

Defined in

libs/ts-rest/core/src/lib/dsl.ts:212


isAppRouteMutation

isAppRouteMutation(route): route is AppRouteMutation

Parameters

NameType
routeAppRoute

Returns

route is AppRouteMutation

Defined in

libs/ts-rest/core/src/lib/dsl.ts:220


isAppRouteNoBody

isAppRouteNoBody(response): response is typeof ContractNoBody

Parameters

NameType
responsetypeof ContractNoBody | ContractAnyType | ContractOtherResponse<ContractAnyType>

Returns

response is typeof ContractNoBody

Defined in

libs/ts-rest/core/src/lib/server.ts:36


isAppRouteOtherResponse

isAppRouteOtherResponse(response): response is ContractOtherResponse<ContractAnyType>

Parameters

NameType
responsetypeof ContractNoBody | ContractAnyType | ContractOtherResponse<ContractAnyType>

Returns

response is ContractOtherResponse<ContractAnyType>

Defined in

libs/ts-rest/core/src/lib/server.ts:23


isAppRouteQuery

isAppRouteQuery(route): route is AppRouteQuery

Parameters

NameType
routeAppRoute

Returns

route is AppRouteQuery

Defined in

libs/ts-rest/core/src/lib/dsl.ts:216


isAppRouteResponse

isAppRouteResponse(value): value is Object

Parameters

NameType
valueunknown

Returns

value is Object

Defined in

libs/ts-rest/core/src/lib/server.ts:12


isErrorResponse

isErrorResponse<T>(response, contractEndpoint?): response is ClientInferResponses<T, ErrorHttpStatusCode>

Type parameters

NameType
Textends AppRoute

Parameters

NameType
responseunknown
contractEndpoint?T

Returns

response is ClientInferResponses<T, ErrorHttpStatusCode>

Defined in

libs/ts-rest/core/src/lib/type-guards.ts:43


isResponse

isResponse<T>(response, contractEndpoint?): response is ClientInferResponses<T, HTTPStatusCode>

Type parameters

NameType
Textends AppRoute

Parameters

NameType
responseunknown
contractEndpoint?T

Returns

response is ClientInferResponses<T, HTTPStatusCode>

Defined in

libs/ts-rest/core/src/lib/type-guards.ts:12


isSuccessResponse

isSuccessResponse<T>(response, contractEndpoint?): response is ClientInferResponses<T, SuccessfulHttpStatusCode>

Type parameters

NameType
Textends AppRoute

Parameters

NameType
responseunknown
contractEndpoint?T

Returns

response is ClientInferResponses<T, SuccessfulHttpStatusCode>

Defined in

libs/ts-rest/core/src/lib/type-guards.ts:32


isUnknownErrorResponse

isUnknownErrorResponse<T>(response, contractEndpoint): response is ClientInferResponses<T, InferResponseUndefinedStatusCodes<T, ErrorHttpStatusCode>, "ignore">

Type parameters

NameType
Textends AppRoute

Parameters

NameType
responseunknown
contractEndpointT

Returns

response is ClientInferResponses<T, InferResponseUndefinedStatusCodes<T, ErrorHttpStatusCode>, "ignore">

Defined in

libs/ts-rest/core/src/lib/type-guards.ts:82


isUnknownResponse

isUnknownResponse<T>(response, contractEndpoint): response is ClientInferResponses<T, InferResponseUndefinedStatusCodes<T>, "ignore">

Type parameters

NameType
Textends AppRoute

Parameters

NameType
responseunknown
contractEndpointT

Returns

response is ClientInferResponses<T, InferResponseUndefinedStatusCodes<T>, "ignore">

Defined in

libs/ts-rest/core/src/lib/type-guards.ts:53


isUnknownSuccessResponse

isUnknownSuccessResponse<T>(response, contractEndpoint): response is ClientInferResponses<T, InferResponseUndefinedStatusCodes<T, SuccessfulHttpStatusCode>, "ignore">

Type parameters

NameType
Textends AppRoute

Parameters

NameType
responseunknown
contractEndpointT

Returns

response is ClientInferResponses<T, InferResponseUndefinedStatusCodes<T, SuccessfulHttpStatusCode>, "ignore">

Defined in

libs/ts-rest/core/src/lib/type-guards.ts:69


isZodObject

isZodObject(obj): obj is AnyZodObject | ZodEffects<AnyZodObject, Object, Object>

Parameters

NameType
objunknown

Returns

obj is AnyZodObject | ZodEffects<AnyZodObject, Object, Object>

Defined in

libs/ts-rest/core/src/lib/zod-utils.ts:7


isZodObjectStrict

isZodObjectStrict(obj): obj is AnyZodObject

Parameters

NameType
objunknown

Returns

obj is AnyZodObject

Defined in

libs/ts-rest/core/src/lib/zod-utils.ts:21


isZodType

isZodType(obj): obj is ZodTypeAny

Parameters

NameType
objunknown

Returns

obj is ZodTypeAny

Defined in

libs/ts-rest/core/src/lib/zod-utils.ts:3


parseJsonQueryObject

parseJsonQueryObject(query): Object

Parameters

NameTypeDescription
queryRecord<string, string>A server-side query object where values have been encoded as JSON strings

Returns

Object

  • The same object with the JSON strings decoded. Objects that were encoded using toJSON such as Dates will remain as strings

Defined in

libs/ts-rest/core/src/lib/query.ts:100


tsRestFetchApi

tsRestFetchApi(args): Promise<{ body: unknown ; headers: Headers ; status: number }>

Default fetch api implementation:

Can be used as a reference for implementing your own fetcher, or used in the "api" field of ClientArgs to allow you to hook into the request to run custom logic

Parameters

NameType
argsApiFetcherArgs<Omit<RequestInit, "headers" | "method" | "body">>

Returns

Promise<{ body: unknown ; headers: Headers ; status: number }>

Defined in

libs/ts-rest/core/src/lib/client.ts:99


validateResponse

validateResponse(«destructured»): Object

Parameters

NameType
«destructured»Object
› appRouteAppRoute
› responseObject
› response.body?unknown
› response.statusnumber

Returns

Object

NameType
body?unknown
statusnumber

Defined in

libs/ts-rest/core/src/lib/server.ts:45


zodErrorResponse

zodErrorResponse(error): Pick<ZodError<any>, "name" | "issues">

Parameters

NameType
errorZodError<any>

Returns

Pick<ZodError<any>, "name" | "issues">

Defined in

libs/ts-rest/core/src/lib/zod-utils.ts:96


zodMerge

zodMerge(objectA, objectB): Object

Parameters

NameType
objectAunknown
objectBunknown

Returns

Object

Defined in

libs/ts-rest/core/src/lib/zod-utils.ts:41