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:167
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:99
ApiFetcherArgs
Ƭ ApiFetcherArgs<TFetchOptions
>: Object
Type parameters
Name | Type |
---|---|
TFetchOptions | extends FetchOptions = FetchOptions |
Type declaration
Name | Type | Description |
---|---|---|
body | FormData | URLSearchParams | string | null | undefined | - |
cache? | "cache" extends keyof TFetchOptions ? TFetchOptions ["cache" ] : never | Deprecated Use fetchOptions.cache instead |
contentType | AppRouteMutation ["contentType" ] | - |
credentials? | TFetchOptions ["credentials" ] | Deprecated Use fetchOptions.credentials instead |
fetchOptions? | FetchOptions | - |
headers | Record <string , string > | - |
method | string | - |
next? | "next" extends keyof TFetchOptions ? TFetchOptions ["next" ] : never | Deprecated Use fetchOptions.next instead |
path | string | - |
rawBody | unknown | - |
rawQuery | unknown | - |
route | AppRoute | - |
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
Name | Type |
---|---|
T | extends 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
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: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
Name | Type |
---|---|
T | extends AppRoute | AppRouter |
TClientArgs | extends 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
Name | Type |
---|---|
T | extends AppRoute |
TStatus | extends 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
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: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
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: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
Name | Type |
---|---|
body | unknown |
clientArgs | ClientArgs |
extraInputArgs | Record <string , unknown > |
fetchOptions? | FetchOptions |
headers | Record <string , string | undefined > |
path | string |
query | unknown |
route | AppRoute |
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
Name | Type |
---|---|
T | extends 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
Name | Type |
---|---|
T | extends AppRoute |
TStatus | extends 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
Name | Type |
---|---|
T | extends AppRoute |
TStatus | extends 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
Name | Type |
---|---|
T | extends AppRouter |
TClientArgs | extends 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
Name | Type |
---|---|
B | extends boolean |
Defined in
libs/ts-rest/core/src/lib/type-utils.ts:189
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:147
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:121
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: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
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" > = {} |
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
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 > | - |
metadata? | unknown | - |
pathPrefix? | TPrefix | - |
strictStatusCodes? | boolean | - |
validateResponseOnClient? | boolean | Deprecated 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
Name | Type |
---|---|
T | extends AppRoute | AppRouter |
TServerHeaders | never |
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
Name | Type |
---|---|
T | extends AppRoute |
TStatus | extends 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
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: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
Name | Type |
---|---|
OpaqueType | extends 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
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?
): FetchApiOptions
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? | Omit <RequestInit , "headers" | "method" | "body" > | - |
inputArgs.headers | { [x: Lowercase<string>]: any; } | - |
inputArgs.overrideClientOptions? | Partial <OverrideableClientArgs > | - |
inputArgs.params | { [x: string]: any; } | - |
inputArgs.query | any | - |
Returns
Defined in
libs/ts-rest/core/src/lib/client.ts:309
exhaustiveGuard
▸ exhaustiveGuard<T
>(response
): never
Type parameters
Name | Type |
---|---|
T | extends Object |
Parameters
Name | Type |
---|---|
response | T |
Returns
never
Defined in
libs/ts-rest/core/src/lib/type-guards.ts:95
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(options
): Promise
<{ body
: unknown
; headers
: Headers
; status
: number
}>
Parameters
Name | Type |
---|---|
options | FetchApiOptions |
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
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? | Omit <RequestInit , "headers" | "method" | "body" > | - |
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:390
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: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
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:212
isAppRouteMutation
▸ isAppRouteMutation(route
): route is AppRouteMutation
Parameters
Name | Type |
---|---|
route | AppRoute |
Returns
route is AppRouteMutation
Defined in
libs/ts-rest/core/src/lib/dsl.ts:220
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
isAppRouteQuery
▸ isAppRouteQuery(route
): route is AppRouteQuery
Parameters
Name | Type |
---|---|
route | AppRoute |
Returns
route is AppRouteQuery
Defined in
libs/ts-rest/core/src/lib/dsl.ts:216
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
isErrorResponse
▸ isErrorResponse<T
>(response
, contractEndpoint?
): response is ClientInferResponses<T, ErrorHttpStatusCode>
Type parameters
Name | Type |
---|---|
T | extends AppRoute |
Parameters
Name | Type |
---|---|
response | unknown |
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
Name | Type |
---|---|
T | extends AppRoute |
Parameters
Name | Type |
---|---|
response | unknown |
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
Name | Type |
---|---|
T | extends AppRoute |
Parameters
Name | Type |
---|---|
response | unknown |
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
Name | Type |
---|---|
T | extends AppRoute |
Parameters
Name | Type |
---|---|
response | unknown |
contractEndpoint | T |
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
Name | Type |
---|---|
T | extends AppRoute |
Parameters
Name | Type |
---|---|
response | unknown |
contractEndpoint | T |
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
Name | Type |
---|---|
T | extends AppRoute |
Parameters
Name | Type |
---|---|
response | unknown |
contractEndpoint | T |
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
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 <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
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