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:153
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
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:154
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:162
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:390
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:385
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:42
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 | - |
commonResponses? | Record <number , AppRouteResponse > | - |
pathPrefix? | TPrefix | - |
strictStatusCodes? | boolean | - |
validateResponseOnClient? | boolean | Deprecated Use validateResponse on the client options |
Defined in
libs/ts-rest/core/src/lib/dsl.ts:166
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:285
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:281
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:186
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:362
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:398
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:294
initTsRest
▸ initTsRest(): ContractInstance
Returns
ContractInstance
Deprecated
Please use initContract instead.
Defined in
libs/ts-rest/core/src/lib/dsl.ts:250
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:56
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:184
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