@api-ts/superagent-wrapper
Advanced tools
Comparing version 1.1.14-beta.2 to 1.1.14
import * as h from '@api-ts/io-ts-http'; | ||
type SuccessfulResponses<Route extends h.HttpRoute> = { | ||
declare type SuccessfulResponses<Route extends h.HttpRoute> = { | ||
[R in keyof Route['response']]: { | ||
@@ -10,3 +10,3 @@ status: R; | ||
}[keyof Route['response']]; | ||
export type DecodedResponse<Route extends h.HttpRoute> = SuccessfulResponses<Route> | { | ||
export declare type DecodedResponse<Route extends h.HttpRoute> = SuccessfulResponses<Route> | { | ||
status: 'decodeError'; | ||
@@ -21,13 +21,13 @@ error: string; | ||
} | ||
type ExpectedDecodedResponse<Route extends h.HttpRoute, StatusCode extends keyof Route['response']> = DecodedResponse<Route> & { | ||
declare type ExpectedDecodedResponse<Route extends h.HttpRoute, StatusCode extends keyof Route['response']> = DecodedResponse<Route> & { | ||
status: StatusCode; | ||
}; | ||
type PatchedRequest<Req, Route extends h.HttpRoute> = Req & { | ||
declare type PatchedRequest<Req, Route extends h.HttpRoute> = Req & { | ||
decode: () => Promise<DecodedResponse<Route>>; | ||
decodeExpecting: <StatusCode extends keyof Route['response']>(status: StatusCode) => Promise<ExpectedDecodedResponse<Route, StatusCode>>; | ||
}; | ||
type SuperagentLike<Req> = { | ||
declare type SuperagentLike<Req> = { | ||
[K in h.Method]: (url: string) => Req; | ||
}; | ||
export type Response = { | ||
export declare type Response = { | ||
body: unknown; | ||
@@ -42,8 +42,8 @@ status: number; | ||
} | ||
export type RequestFactory<Req> = <Route extends h.HttpRoute>(route: Route, params: Record<string, string>) => Req; | ||
export declare type RequestFactory<Req> = <Route extends h.HttpRoute>(route: Route, params: Record<string, string>) => Req; | ||
export declare const superagentRequestFactory: <Req>(superagent: SuperagentLike<Req>, base: string) => RequestFactory<Req>; | ||
export declare const supertestRequestFactory: <Req>(supertest: SuperagentLike<Req>) => RequestFactory<Req>; | ||
export type BoundRequestFactory<Req extends SuperagentRequest<Response>, Route extends h.HttpRoute> = (params: h.RequestType<Route>) => PatchedRequest<Req, Route>; | ||
export declare type BoundRequestFactory<Req extends SuperagentRequest<Response>, Route extends h.HttpRoute> = (params: h.RequestType<Route>) => PatchedRequest<Req, Route>; | ||
export declare const requestForRoute: <Req extends SuperagentRequest<Response>, Route extends h.HttpRoute<"get" | "post" | "put" | "delete" | "patch">>(requestFactory: RequestFactory<Req>, route: Route) => BoundRequestFactory<Req, Route>; | ||
export {}; | ||
//# sourceMappingURL=request.d.ts.map |
import * as h from '@api-ts/io-ts-http'; | ||
import type { SuperagentRequest, Response } from './request'; | ||
import { BoundRequestFactory, RequestFactory } from './request'; | ||
export type ApiClient<Req extends SuperagentRequest<Response>, Spec extends h.ApiSpec> = { | ||
export declare type ApiClient<Req extends SuperagentRequest<Response>, Spec extends h.ApiSpec> = { | ||
[A in keyof Spec]: { | ||
@@ -6,0 +6,0 @@ [B in keyof Spec[A] & h.Method]: BoundRequestFactory<Req, NonNullable<Spec[A][B]>>; |
{ | ||
"name": "@api-ts/superagent-wrapper", | ||
"version": "1.1.14-beta.2", | ||
"version": "1.1.14", | ||
"description": "Make type-safe HTTP requests with superagent", | ||
@@ -20,3 +20,3 @@ "author": "Patrick McLaughlin <patrickmclaughlin@bitgo.com>", | ||
"dependencies": { | ||
"@api-ts/io-ts-http": "2.4.1-beta.1", | ||
"@api-ts/io-ts-http": "2.4.1", | ||
"fp-ts": "^2.0.0", | ||
@@ -27,14 +27,14 @@ "io-ts": "2.1.3", | ||
"devDependencies": { | ||
"@swc-node/register": "1.6.8", | ||
"@types/express": "4.17.18", | ||
"@types/node": "20.8.0", | ||
"@types/superagent": "4.1.19", | ||
"@types/supertest": "2.0.14", | ||
"@swc-node/register": "1.9.0", | ||
"@types/express": "4.17.21", | ||
"@types/node": "20.12.2", | ||
"@types/superagent": "8.1.6", | ||
"@types/supertest": "6.0.2", | ||
"@types/whatwg-url": "11.0.0", | ||
"c8": "8.0.1", | ||
"express": "4.18.2", | ||
"c8": "9.1.0", | ||
"express": "4.19.2", | ||
"io-ts-types": "0.5.19", | ||
"superagent": "8.1.2", | ||
"supertest": "6.3.3", | ||
"typescript": "5.2.2" | ||
"supertest": "6.3.4", | ||
"typescript": "4.7.4" | ||
}, | ||
@@ -41,0 +41,0 @@ "peerDependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
26331
1
+ Added@api-ts/io-ts-http@2.4.1(transitive)
+ Added@api-ts/response@2.1.0(transitive)
- Removed@api-ts/io-ts-http@2.4.1-beta.1(transitive)
- Removed@api-ts/response@2.1.1-beta.1(transitive)
Updated@api-ts/io-ts-http@2.4.1