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β
Name | Type |
---|---|
B1 | extends boolean |
B2 | extends boolean |
Defined inβ
libs/ts-rest/core/src/lib/type-utils.ts:157
ApiFetcherβ
Ζ¬ ApiFetcher: (args
: ApiFetcherArgs
) => Promise
<{ body
: unknown
; headers
: Headers
; status
: number
}>
Type declarationβ
βΈ (args
): Promise
<{ body
: unknown
; headers
: Headers
; status
: number
}>
Parametersβ
Name | Type |
---|---|
args | ApiFetcherArgs |
Returnsβ
Promise
<{ body
: unknown
; headers
: Headers
; status
: number
}>
Defined inβ
libs/ts-rest/core/src/lib/client.ts:89
ApiFetcherArgsβ
Ζ¬ ApiFetcherArgs: Object
Type declarationβ
Name | Type | Description |
---|---|---|
body | FormData | URLSearchParams | string | null | undefined | - |
cache? | RequestCache | Deprecated Use fetchOptions.cache instead |
contentType | AppRouteMutation ["contentType" ] | - |
credentials? | RequestCredentials | Deprecated Use fetchOptions.credentials instead |
fetchOptions? | FetchOptions | - |
headers | Record <string , string > | - |
method | string | - |
next? | { revalidate? : number | false ; tags? : string [] } | Deprecated Use fetchOptions.next instead |
next.revalidate? | number | false | - |
next.tags? | string [] | - |
path | string | - |
rawBody | unknown | - |
rawQuery | unknown | - |
route | AppRoute | - |
signal? | AbortSignal | Deprecated Use fetchOptions.signal instead |
validateResponse? | boolean | - |
Defined inβ
libs/ts-rest/core/src/lib/client.ts:59
ApiResponseForRouteβ
Ζ¬ ApiResponseForRoute<T
>: ClientInferResponses
<T
>
Deprecated
Only safe to use on the client-side. Use ServerInferResponses
/ClientInferResponses
instead.
Type parametersβ
Name | Type |
---|---|
T | extends AppRoute |
Defined inβ
libs/ts-rest/core/src/lib/client.ts:25
AppRouteβ
Ζ¬ AppRoute: AppRouteQuery
| AppRouteMutation
A union of all possible endpoint types.
Defined inβ
libs/ts-rest/core/src/lib/dsl.ts:150
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β
Name | Type |
---|---|
TRoute | extends AppRoute |
TClientArgs | extends ClientArgs |
TArgs | PartialClientInferRequest <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
AppRouteStrictStatusCodesβ
Ζ¬ AppRouteStrictStatusCodes: Omit
<AppRoute
, "strictStatusCodes"
> & { strictStatusCodes
: true
}
Defined inβ
libs/ts-rest/core/src/lib/dsl.ts:151
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:159
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:105
ClientInferRequestβ
Ζ¬ ClientInferRequest<T
, TClientArgs
>: T
extends AppRoute
? ClientInferRequestBase
<T
, TClientArgs
> : T
extends AppRouter
? { [TKey in keyof T]: ClientInferRequest<T[TKey]> } : never
Type parametersβ
Name | Type |
---|---|
T | extends AppRoute | AppRouter |
TClientArgs | extends Omit <ClientArgs , "baseUrl" > = { baseHeaders : {} } |
Defined inβ
libs/ts-rest/core/src/lib/infer-types.ts:246
ClientInferResponseBodyβ
Ζ¬ ClientInferResponseBody<T
, TStatus
>: Prettify
<AppRouteResponses
<T
, TStatus
& HTTPStatusCode
, "client"
>["body"
]>
Type parametersβ
Name | Type |
---|---|
T | extends AppRoute |
TStatus | extends keyof T ["responses" ] = keyof T ["responses" ] |
Defined inβ
libs/ts-rest/core/src/lib/infer-types.ts:144
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β
Name | Type |
---|---|
T | extends AppRoute | AppRouter |
TStatus | extends HTTPStatusCode = HTTPStatusCode |
TStrictStatusCodes | extends "default" | "ignore" | "force" = "default" |
Defined inβ
libs/ts-rest/core/src/lib/infer-types.ts:123
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β
Name | Type |
---|---|
T | extends 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β
Name | Type |
---|---|
T | T |
K | extends keyof NonNullable <T > |
Defined inβ
libs/ts-rest/core/src/lib/type-utils.ts:126
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:155
FetchOptionsβ
Ζ¬ FetchOptions: Omit
<RequestInit
, "method"
| "headers"
| "body"
>
Defined inβ
libs/ts-rest/core/src/lib/client.ts:45
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
InitClientArgsβ
Ζ¬ InitClientArgs: ClientArgs
& { throwOnUnknownStatus?
: boolean
}
Defined inβ
libs/ts-rest/core/src/lib/client.ts:380
InitClientReturnβ
Ζ¬ InitClientReturn<T
, TClientArgs
>: RecursiveProxyObj
<T
, TClientArgs
>
Type parametersβ
Name | Type |
---|---|
T | extends AppRouter |
TClientArgs | extends ClientArgs |
Defined inβ
libs/ts-rest/core/src/lib/client.ts:375
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:151
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β
Name | Type |
---|---|
B | extends boolean |
Defined inβ
libs/ts-rest/core/src/lib/type-utils.ts:179
Opaqueβ
Ζ¬ Opaque<Type
, Token
>: Type
& Tagged
<Token
>
Type parametersβ
Name | Type |
---|---|
Type | Type |
Token | unknown |
Defined inβ
libs/ts-rest/core/src/lib/type-utils.ts:137
OptionalIfAllOptionalβ
Ζ¬ OptionalIfAllOptional<T
, Select
>: PartialBy
<T
, Select
& { [K in keyof T]: AreAllPropertiesOptional<T[K]> extends true ? K : never }[keyof T
]>
Type parametersβ
Name | Type |
---|---|
T | T |
Select | extends keyof T = keyof T |
Defined inβ
libs/ts-rest/core/src/lib/type-utils.ts:111
Orβ
Ζ¬ Or<B1
, B2
>: { false
: { false
: false
; true
: true
} ; true
: { false
: true
; true
: true
} }[`${B1}`][\`${B2}\`]
Type parametersβ
Name | Type |
---|---|
B1 | extends boolean |
B2 | extends boolean |
Defined inβ
libs/ts-rest/core/src/lib/type-utils.ts:168
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β
Name | Type |
---|---|
T | extends string |
Defined inβ
libs/ts-rest/core/src/lib/paths.ts:37
PartialByβ
Ζ¬ PartialBy<T
, K
>: Omit
<T
, K
> & Partial
<Pick
<T
, K
>>
Type parametersβ
Name | Type |
---|---|
T | T |
K | extends 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β
Name | Type |
---|---|
TRoute | extends AppRoute |
TClientArgs | extends Omit <ClientArgs , "baseUrl" > = { baseHeaders : {} } |
Defined inβ
libs/ts-rest/core/src/lib/infer-types.ts:257
Prettifyβ
Ζ¬ Prettify<T
>: { [K in keyof T]: T[K] } & {}
Type parametersβ
Name |
---|
T |
Defined inβ
libs/ts-rest/core/src/lib/type-utils.ts:122
ResolveResponseTypeβ
Ζ¬ ResolveResponseType<T
>: T
extends ContractOtherResponse
<infer U> ? U
: T
Type parametersβ
Name | Type |
---|---|
T | extends ContractAnyType | ContractNoBodyType | ContractOtherResponse <ContractAnyType > |
Defined inβ
libs/ts-rest/core/src/lib/infer-types.ts:63
RouterOptionsβ
Ζ¬ RouterOptions<TPrefix
>: Object
Type parametersβ
Name | Type |
---|---|
TPrefix | extends string = string |
Type declarationβ
Name | Type | Description |
---|---|---|
baseHeaders? | unknown | - |
pathPrefix? | TPrefix | - |
strictStatusCodes? | boolean | - |
validateResponseOnClient? | boolean | Deprecated Use validateResponse on the client options |
Defined inβ
libs/ts-rest/core/src/lib/dsl.ts:163
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β
Name | Type |
---|---|
T | extends AppRoute | AppRouter |
TServerHeaders | never |
Defined inβ
libs/ts-rest/core/src/lib/infer-types.ts:154
ServerInferResponseBodyβ
Ζ¬ ServerInferResponseBody<T
, TStatus
>: Prettify
<AppRouteResponses
<T
, TStatus
& HTTPStatusCode
, "server"
>["body"
]>
Type parametersβ
Name | Type |
---|---|
T | extends AppRoute |
TStatus | extends keyof T ["responses" ] = keyof T ["responses" ] |
Defined inβ
libs/ts-rest/core/src/lib/infer-types.ts:139
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β
Name | Type |
---|---|
T | extends AppRoute | AppRouter |
TStatus | extends HTTPStatusCode = HTTPStatusCode |
TStrictStatusCodes | extends "default" | "ignore" | "force" = "default" |
Defined inβ
libs/ts-rest/core/src/lib/infer-types.ts:107
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β
Name | Type |
---|---|
OpaqueType | extends Tagged <unknown > |
Defined inβ
libs/ts-rest/core/src/lib/type-utils.ts:139
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:144
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:282
Functionsβ
checkZodSchemaβ
βΈ checkZodSchema(data
, schema
, Β«destructuredΒ»?
): { data
: unknown
; success
: true
} | { error
: ZodError
<any
> ; success
: false
}
Parametersβ
Name | Type |
---|---|
data | unknown |
schema | unknown |
Β«destructuredΒ» | Object |
βΊΒ passThroughExtraKeys | undefined | 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β
Name | Type | Default value | Description |
---|---|---|---|
query | unknown | undefined | Any JSON object |
json | boolean | false | Use 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β
Name | Type |
---|---|
query | unknown |
Returnsβ
string
Defined inβ
libs/ts-rest/core/src/lib/query.ts:42
encodeQueryParamsJsonβ
βΈ encodeQueryParamsJson(query
): string
Parametersβ
Name | Type |
---|---|
query | unknown |
Returnsβ
string
Defined inβ
libs/ts-rest/core/src/lib/query.ts:14
evaluateFetchApiArgsβ
βΈ evaluateFetchApiArgs<TAppRoute
>(route
, clientArgs
, inputArgs?
): Object
Type parametersβ
Name | Type |
---|---|
TAppRoute | extends AppRoute |
Parametersβ
Name | Type | Description |
---|---|---|
route | TAppRoute | - |
clientArgs | InitClientArgs | - |
inputArgs? | Object | - |
inputArgs.body | any | - |
inputArgs.cache? | RequestCache | Deprecated Use fetchOptions.cache instead |
inputArgs.extraHeaders? | {} & Record <string , undefined | string > | - |
inputArgs.fetchOptions? | FetchOptions | - |
inputArgs.headers | { [x: Lowercase<string>]: any; } | - |
inputArgs.overrideClientOptions? | Partial <OverrideableClientArgs > | - |
inputArgs.params | { [x: string]: any; } | - |
inputArgs.query | any | - |
Returnsβ
Object
Name | Type |
---|---|
body | unknown |
clientArgs | ClientArgs |
extraInputArgs | Record <string , unknown > |
fetchOptions? | FetchOptions |
headers | Record <string , undefined | string > |
path | string |
query | unknown |
route | AppRoute |
Defined inβ
libs/ts-rest/core/src/lib/client.ts:271
extractZodObjectShapeβ
βΈ extractZodObjectShape<T
>(obj
): any
Type parametersβ
Name | Type |
---|---|
T | extends AnyZodObject | ZodEffects <ZodTypeAny , any , any > |
Parametersβ
Name | Type |
---|---|
obj | T |
Returnsβ
any
Defined inβ
libs/ts-rest/core/src/lib/zod-utils.ts:25
fetchApiβ
βΈ fetchApi(Β«destructuredΒ»
): Promise
<{ body
: unknown
; headers
: Headers
; status
: number
}>
Parametersβ
Name | Type |
---|---|
Β«destructuredΒ» | Object |
βΊΒ body | unknown |
βΊΒ clientArgs | ClientArgs |
βΊΒ extraInputArgs | Record <string , unknown > |
βΊΒ fetchOptions? | FetchOptions |
βΊΒ headers | Record <string , undefined | string > |
βΊΒ path | string |
βΊΒ query | unknown |
βΊΒ route | AppRoute |
Returnsβ
Promise
<{ body
: unknown
; headers
: Headers
; status
: number
}>
Defined inβ
libs/ts-rest/core/src/lib/client.ts:176
getRouteQueryβ
βΈ getRouteQuery<TAppRoute
>(route
, clientArgs
): (inputArgs?
: { body
: any
; cache?
: RequestCache
; extraHeaders?
: {} & Record
<string
, undefined
| string
> ; fetchOptions?
: FetchOptions
; headers
: { [x: Lowercase<string>]: any; } ; overrideClientOptions?
: Partial
<OverrideableClientArgs
> ; params
: { [x: string]: any; } ; query
: any
}) => Promise
<{ body
: unknown
; headers
: Headers
; status
: number
}>
Type parametersβ
Name | Type |
---|---|
TAppRoute | extends AppRoute |
Parametersβ
Name | Type |
---|---|
route | TAppRoute |
clientArgs | InitClientArgs |
Returnsβ
fn
βΈ (inputArgs?
): Promise
<{ body
: unknown
; headers
: Headers
; status
: number
}>
Parametersβ
Name | Type | Description |
---|---|---|
inputArgs? | Object | - |
inputArgs.body | any | - |
inputArgs.cache? | RequestCache | Deprecated Use fetchOptions.cache instead |
inputArgs.extraHeaders? | {} & Record <string , undefined | string > | - |
inputArgs.fetchOptions? | FetchOptions | - |
inputArgs.headers | { [x: Lowercase<string>]: any; } | - |
inputArgs.overrideClientOptions? | Partial <OverrideableClientArgs > | - |
inputArgs.params | { [x: string]: any; } | - |
inputArgs.query | any | - |
Returnsβ
Promise
<{ body
: unknown
; headers
: Headers
; status
: number
}>
Defined inβ
libs/ts-rest/core/src/lib/client.ts:352
getRouteResponsesβ
βΈ getRouteResponses<T
>(router
): ClientInferResponses
<T
>
Type parametersβ
Name | Type |
---|---|
T | extends AppRouter |
Parametersβ
Name | Type |
---|---|
router | T |
Returnsβ
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β
Name | Type |
---|---|
T | extends AppRouter |
TClientArgs | extends InitClientArgs |
Parametersβ
Name | Type |
---|---|
router | T |
args | TClientArgs |
Returnsβ
RecursiveProxyObj
<T
, TClientArgs
>
Defined inβ
libs/ts-rest/core/src/lib/client.ts:388
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:291
initTsRestβ
βΈ initTsRest(): ContractInstance
Returnsβ
ContractInstance
Deprecated
Please use initContract instead.
Defined inβ
libs/ts-rest/core/src/lib/dsl.ts:251
insertParamsIntoPathβ
βΈ insertParamsIntoPath<T
>(Β«destructuredΒ»
): string
Type parametersβ
Name | Type |
---|---|
T | extends string |
Parametersβ
Name | Type |
---|---|
Β«destructuredΒ» | Object |
βΊΒ params | ParamsFromUrl <T > |
βΊΒ path | T |
Returnsβ
string
- The URL with the params e.g. /posts/123
Defined inβ
libs/ts-rest/core/src/lib/paths.ts:51
isAppRouteβ
βΈ isAppRoute(obj
): obj is AppRoute
Differentiate between a route and a router
Parametersβ
Name | Type |
---|---|
obj | AppRoute | AppRouter |
Returnsβ
obj is AppRoute
Defined inβ
libs/ts-rest/core/src/lib/dsl.ts:180
isAppRouteNoBodyβ
βΈ isAppRouteNoBody(response
): response is typeof ContractNoBody
Parametersβ
Name | Type |
---|---|
response | typeof 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β
Name | Type |
---|---|
response | typeof ContractNoBody | ContractAnyType | ContractOtherResponse <ContractAnyType > |
Returnsβ
response is ContractOtherResponse<ContractAnyType>
Defined inβ
libs/ts-rest/core/src/lib/server.ts:23
isAppRouteResponseβ
βΈ isAppRouteResponse(value
): value is Object
Parametersβ
Name | Type |
---|---|
value | unknown |
Returnsβ
value is Object
Defined inβ
libs/ts-rest/core/src/lib/server.ts:12
isZodObjectβ
βΈ isZodObject(obj
): obj is AnyZodObject | ZodEffects<AnyZodObject, Object, Object>
Parametersβ
Name | Type |
---|---|
obj | unknown |
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β
Name | Type |
---|---|
obj | unknown |
Returnsβ
obj is AnyZodObject
Defined inβ
libs/ts-rest/core/src/lib/zod-utils.ts:21
isZodTypeβ
βΈ isZodType(obj
): obj is ZodTypeAny
Parametersβ
Name | Type |
---|---|
obj | unknown |
Returnsβ
obj is ZodTypeAny
Defined inβ
libs/ts-rest/core/src/lib/zod-utils.ts:3
parseJsonQueryObjectβ
βΈ parseJsonQueryObject(query
): Object
Parametersβ
Name | Type | Description |
---|---|---|
query | Record <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β
Name | Type |
---|---|
args | ApiFetcherArgs |
Returnsβ
Promise
<{ body
: unknown
; headers
: Headers
; status
: number
}>
Defined inβ
libs/ts-rest/core/src/lib/client.ts:89
validateResponseβ
βΈ validateResponse(Β«destructuredΒ»
): Object
Parametersβ
Name | Type |
---|---|
Β«destructuredΒ» | Object |
βΊΒ appRoute | AppRoute |
βΊΒ response | Object |
βΊΒ response.body? | unknown |
βΊΒ response.status | number |
Returnsβ
Object
Name | Type |
---|---|
body? | unknown |
status | number |
Defined inβ
libs/ts-rest/core/src/lib/server.ts:45
zodErrorResponseβ
βΈ zodErrorResponse(error
): Pick
<ZodError
<any
>, "name"
| "issues"
>
Parametersβ
Name | Type |
---|---|
error | ZodError <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β
Name | Type |
---|---|
objectA | unknown |
objectB | unknown |
Returnsβ
Object
Defined inβ
libs/ts-rest/core/src/lib/zod-utils.ts:41