@ts-rest/core
Advanced tools
Comparing version 3.24.1-pre.0 to 3.24.1-pre.1
# @ts-rest/core | ||
## 3.24.1-pre.1 | ||
### Patch Changes | ||
- 20608f7: Internal refactor of types | ||
## 3.24.1-pre.0 | ||
@@ -4,0 +10,0 @@ |
{ | ||
"name": "@ts-rest/core", | ||
"version": "3.24.1-pre.0", | ||
"version": "3.24.1-pre.1", | ||
"description": "RPC-like experience over a regular REST API, with type safe server implementations 🪄", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -6,3 +6,3 @@ import { AppRoute, AppRouteMutation, AppRouter, AppRouteStrictStatusCodes } from './dsl'; | ||
import { ParamsFromUrl } from './paths'; | ||
type ExtractExtraParametersFromClientArgs<TClientArgs extends Pick<ClientArgs, 'api'>> = TClientArgs['api'] extends ApiFetcher ? Omit<Parameters<TClientArgs['api']>[0], keyof Parameters<ApiFetcher>[0]> : NonNullable<unknown>; | ||
type ExtractExtraParametersFromClientArgs<TClientArgs extends Pick<ClientArgs, 'api'>> = TClientArgs['api'] extends ApiFetcher ? Omit<Parameters<TClientArgs['api']>[0], keyof Parameters<ApiFetcher>[0]> : {}; | ||
/** | ||
@@ -22,3 +22,3 @@ * Extract the path params from the path in the contract | ||
headers: Headers; | ||
} : NonNullable<unknown>); | ||
} : {}); | ||
}[keyof T['responses'] & TStatus] | (Or<Extends<TStrictStatusCodes, 'force'>, And<Extends<T, AppRouteStrictStatusCodes>, Not<Extends<TStrictStatusCodes, 'ignore'>>>> extends true ? never : Exclude<TStatus, keyof T['responses']> extends never ? never : { | ||
@@ -29,3 +29,3 @@ status: Exclude<TStatus, keyof T['responses']>; | ||
headers: Headers; | ||
} : NonNullable<unknown>)); | ||
} : {})); | ||
export type ServerInferResponses<T extends AppRoute | AppRouter, TStatus extends HTTPStatusCode = HTTPStatusCode, TStrictStatusCodes extends 'default' | 'ignore' | 'force' = 'default'> = T extends AppRoute ? Prettify<AppRouteResponses<T, TStatus, 'server', TStrictStatusCodes>> : T extends AppRouter ? { | ||
@@ -40,12 +40,12 @@ [TKey in keyof T]: ServerInferResponses<T[TKey], TStatus, TStrictStatusCodes>; | ||
type BodyWithoutFileIfMultiPart<T extends AppRouteMutation> = Prettify<T['contentType'] extends 'multipart/form-data' ? Without<ZodInferOrType<T['body']>, File> : ZodInferOrType<T['body']>>; | ||
export type ServerInferRequest<T extends AppRoute | AppRouter> = T extends AppRoute ? Prettify<Without<{ | ||
export type ServerInferRequest<T extends AppRoute | AppRouter, TServerHeaders = never> = T extends AppRoute ? Prettify<Without<{ | ||
params: [undefined] extends PathParamsWithCustomValidators<T> ? never : Prettify<PathParamsWithCustomValidators<T>>; | ||
body: T extends AppRouteMutation ? BodyWithoutFileIfMultiPart<T> : never; | ||
query: 'query' extends keyof T ? ZodInferOrType<T['query']> : never; | ||
headers: 'headers' extends keyof T ? Prettify<LowercaseKeys<ZodInferOrType<T['headers']>>> : never; | ||
headers: 'headers' extends keyof T ? Prettify<LowercaseKeys<ZodInferOrType<T['headers']>> & ([TServerHeaders] extends [never] ? {} : Omit<TServerHeaders, keyof LowercaseKeys<ZodInferOrType<T['headers']>>>)> : TServerHeaders; | ||
}, never>> : T extends AppRouter ? { | ||
[TKey in keyof T]: ServerInferRequest<T[TKey]>; | ||
[TKey in keyof T]: ServerInferRequest<T[TKey], TServerHeaders>; | ||
} : never; | ||
type ClientInferRequestBase<T extends AppRoute, TClientArgs extends Omit<ClientArgs, 'baseUrl'> = { | ||
baseHeaders: NonNullable<unknown>; | ||
baseHeaders: {}; | ||
}, THeaders = 'headers' extends keyof T ? Prettify<PartialByLooseKeys<LowercaseKeys<ZodInputOrType<T['headers']>>, keyof LowercaseKeys<TClientArgs['baseHeaders']>>> : never> = Prettify<Without<{ | ||
@@ -61,3 +61,3 @@ params: [undefined] extends PathParamsWithCustomValidators<T, 'client'> ? never : Prettify<PathParamsWithCustomValidators<T, 'client'>>; | ||
export type ClientInferRequest<T extends AppRoute | AppRouter, TClientArgs extends Omit<ClientArgs, 'baseUrl'> = { | ||
baseHeaders: NonNullable<unknown>; | ||
baseHeaders: {}; | ||
}> = T extends AppRoute ? ClientInferRequestBase<T, TClientArgs> : T extends AppRouter ? { | ||
@@ -67,4 +67,4 @@ [TKey in keyof T]: ClientInferRequest<T[TKey]>; | ||
export type PartialClientInferRequest<TRoute extends AppRoute, TClientArgs extends Omit<ClientArgs, 'baseUrl'> = { | ||
baseHeaders: NonNullable<unknown>; | ||
baseHeaders: {}; | ||
}> = OptionalIfAllOptional<ClientInferRequest<TRoute, TClientArgs>>; | ||
export {}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
63423