Options
All
  • Public
  • Public/Protected
  • All
Menu

Index

Type aliases

AddResponseType

AddResponseType<T, S, A>: T extends IGetApiRequestType<infer P1, infer H1, infer Q1, infer R1> ? IGetApiRequestType<P1, H1, Q1, R1 | IResponseType<S, A>> : T extends IPostApiRequestType<infer P2, infer H2, infer Q2, infer R2> ? IPostApiRequestType<P2, H2, Q2, R2 | IResponseType<S, A>> : T extends IPutApiRequestType<infer P3, infer H3, infer Q3, infer R3> ? IPutApiRequestType<P3, H3, Q3, R3 | IResponseType<S, A>> : T extends IDeleteApiRequestType<infer P4, infer H4, infer Q4, infer R4> ? IDeleteApiRequestType<P4, H4, Q4, R4 | IResponseType<S, A>> : never

Adds the status S with response type A to the responses of the request

Type parameters

  • T

  • S: number

  • A

ApiRequestType

ApiRequestType<P, KH, Q, R>: IGetApiRequestType<P, KH, Q, R> | IPostApiRequestType<P, KH, Q, R> | IPutApiRequestType<P, KH, Q, R> | IDeleteApiRequestType<P, KH, Q, R>

The union of the possible ApiRequest types

Type parameters

ApiRequestTypeForMethod

ApiRequestTypeForMethod<M, P, KH, Q, R>: M extends "get" ? IGetApiRequestType<P, KH, Q, R> : M extends "post" ? IPostApiRequestType<P, KH, Q, R> : M extends "put" ? IPutApiRequestType<P, KH, Q, R> : never

Type parameters

BasicResponseHeaderKey

BasicResponseHeaderKey: "Cache-Control" | "Content-Encoding" | "Content-Type" | "Date" | "ETag" | "Expires" | "Transfer-Encoding"

BasicResponseType

BasicResponseType<R, H>: IResponseType<200, R, H> | IResponseType<404, string, H> | IResponseType<500, string, H>

A basic set of responses where the 200 status corresponds to a payload of type R and 404 and 500 to an Error

Type parameters

  • R

  • H: string = never

EmptyApiRequestBuilder

EmptyApiRequestBuilder<M, P, KH, Q, R>: ApiRequestBuilder<M, P, KH, Q, R, ApiRequestTypeForMethod<M, P, KH, Q, R>>

Type parameters

MapResponseType

MapResponseType<T, S, B>: T extends IGetApiRequestType<infer P1, infer H1, infer Q1, infer R1> ? IGetApiRequestType<P1, H1, Q1, MapTypeInApiResponse<R1, S, B>> : T extends IPostApiRequestType<infer P2, infer H2, infer Q2, infer R2> ? IPostApiRequestType<P2, H2, Q2, MapTypeInApiResponse<R2, S, B>> : T extends IPutApiRequestType<infer P3, infer H3, infer Q3, infer R3> ? IPutApiRequestType<P3, H3, Q3, MapTypeInApiResponse<R3, S, B>> : T extends IDeleteApiRequestType<infer P4, infer H4, infer Q4, infer R4> ? IDeleteApiRequestType<P4, H4, Q4, MapTypeInApiResponse<R4, S, B>> : never

Changes the response with status S to have type B

Type parameters

  • T

  • S: number

  • B

OmitStatusFromResponse

OmitStatusFromResponse<T, S>: T extends IResponseType<S, any> ? never : T

Removes a status from the union of IResponseType(s)

Type parameters

  • T

  • S: number

ReplaceRequestParams

ReplaceRequestParams<T, P>: T extends IGetApiRequestType<infer _P1, infer H1, infer Q1, infer R1> ? IGetApiRequestType<P, H1, Q1, R1> : T extends IPostApiRequestType<infer _P2, infer H2, infer Q2, infer R2> ? IPostApiRequestType<P, H2, Q2, R2> : T extends IPutApiRequestType<infer _P3, infer H3, infer Q3, infer R3> ? IPutApiRequestType<P, H3, Q3, R3> : T extends IDeleteApiRequestType<infer _P4, infer H4, infer Q4, infer R4> ? IDeleteApiRequestType<P, H4, Q4, R4> : never

Replaces the parameters of the request T with the type P

Type parameters

  • T

  • P

RequestHeaderKey

RequestHeaderKey: "Accept-Encoding" | "Authorization" | "Content-Type" | "Host" | "If-None-Match" | "Ocp-Apim-Subscription-Key" | "X-Functions-Key"

Describes the possible header keys of a request

RequestHeaderProducer

RequestHeaderProducer<P, KH>: (params: P) => RequestHeaders<KH>

Generates a set of headers with certain keys (KH) from a parameters object of type P.

Type parameters

Type declaration

RequestHeaders

RequestHeaders<HS>: {[ key in HS]: string }

Describes a set of headers whose keys are of type RequestHeaderKey

Type parameters

RequestMethod

RequestMethod: "get" | "post" | "put" | "delete"

Describes the possible methods of a request

RequestParams

RequestParams<T>: T extends IGetApiRequestType<infer P1, infer _H1, infer _Q1, infer _R1> ? P1 : T extends IPostApiRequestType<infer P2, infer _H2, infer _Q2, infer _R2> ? P2 : T extends IPutApiRequestType<infer P3, infer _H3, infer _Q3, infer _R3> ? P3 : T extends IDeleteApiRequestType<infer P4, infer _H4, infer _Q4, infer _R4> ? P4 : never

The parameters of the request T

Type parameters

  • T

RequestQuery

RequestQuery<K>: Record<K, string>

Describes the query params for this request

Type parameters

  • K: string

ResponseDecoder

ResponseDecoder<R>: (response: Response) => Promise<t.Validation<R> | undefined>

A function that generates a typed representation of a response. It should return undefined in case the response cannot be decoded (e.g. in case of a parsing error).

Type parameters

  • R

Type declaration

    • (response: Response): Promise<t.Validation<R> | undefined>
    • Parameters

      • response: Response

      Returns Promise<t.Validation<R> | undefined>

ResponseHeaders

ResponseHeaders<H>: {[ key in BasicResponseHeaderKey | H]: string }

Type parameters

  • H: string = never

TypeOfApiResponseStatus

TypeOfApiResponseStatus<T>: TypeofApiResponse<T> extends IResponseType<infer S, any> ? S : never

A union type of the Response statuses of an ApiRequestType

Type parameters

  • T

TypeofApiCall

TypeofApiCall<T>: (params: TypeofApiParams<T>) => Promise<t.Validation<TypeofApiResponse<T>>>

The type of the method that runs an ApiRequestType

Type parameters

  • T

Type declaration

TypeofApiParams

TypeofApiParams<T>: T extends ApiRequestType<infer P, infer _KH, infer _Q, infer _R> ? P : never

The type of the Params of an ApiRequestType

Type parameters

  • T

TypeofApiResponse

TypeofApiResponse<T>: T extends ApiRequestType<infer _P, infer _KH, infer _Q, infer R> ? R : never

The type of the Response of an ApiRequestType

Type parameters

  • T

Functions

Const ApiHeaderJson

AuthorizationBearerHeaderProducer

  • Returns a RequestHeaderProducer that produces an Authorization header of type "bearer token" with a fixed token value.

    Type parameters

    • P

    Parameters

    • token: string

    Returns RequestHeaderProducer<P, "Authorization">

ParamAuthorizationBearerHeaderProducer

  • Returns a RequestHeaderProducer that produces an Authorization header of type "bearer token" taking the value from the "token" parameter of each request.

    Type parameters

    • P: { token: string }

    Returns RequestHeaderProducer<P, "Authorization">

basicErrorResponseDecoder

  • A basic ResponseDecoder that returns an Error with the status text if the response status is S.

    Type parameters

    • S: number

    • H: string = never

    Parameters

    • status: S

    Returns ResponseDecoder<IResponseType<S, string, H>>

basicResponseDecoder

  • Returns a ResponseDecoder for BasicResponseType

    Type parameters

    • R

    • O = R

    • H: string = never

    Parameters

    • type: t.Type<R, O>
    • Optional preprocessor: (i: any) => any
        • (i: any): any
        • Parameters

          • i: any

          Returns any

    Returns ResponseDecoder<BasicResponseType<R, H>>

composeHeaderProducers

composeResponseDecoders

constantResponseDecoder

createFetchRequestForApi

  • createFetchRequestForApi<P, KH, Q, R>(requestType: ApiRequestType<P, KH, Q, R>, options?: { baseUrl?: string; fetchApi?: typeof __type }): (params: P) => Promise<t.Validation<R>>
  • Returns an async method that implements the provided ApiRequestType backed by the "fetch" API.

    Type parameters

    Parameters

    • requestType: ApiRequestType<P, KH, Q, R>
    • options: { baseUrl?: string; fetchApi?: typeof __type } = ...
      • Optional Readonly baseUrl?: string
      • Optional Readonly fetchApi?: typeof __type

    Returns (params: P) => Promise<t.Validation<R>>

      • (params: P): Promise<t.Validation<R>>
      • Parameters

        • params: P

        Returns Promise<t.Validation<R>>

ioResponseDecoder

  • An io-ts based ResponseDecoder, it checks the response status and the payload against the provided type.

    Type parameters

    • S: number

    • R

    • O = R

    • H: string = never

    Parameters

    • status: S

      The response status handled by this decoder

    • type: t.Type<R, O>

      The response type corresponding to the status

    • preprocessor: (i: any) => any = ...

      A function that takes the object corresponding to the json response as input and returns the processed object (usefull when you want alterate the json body received)

        • (i: any): any
        • Parameters

          • i: any

          Returns any

    Returns ResponseDecoder<IResponseType<S, R, H>>

Legend

  • Variable
  • Function
  • Function with type parameter
  • Type alias
  • Type alias with type parameter
  • Interface
  • Interface with type parameter
  • Enumeration
  • Class with type parameter

Generated using TypeDoc