@radixdlt/networking
Advanced tools
Comparing version 2.1.12 to 2.1.13
@@ -6,2 +6,10 @@ # Change Log | ||
## [2.1.13](https://github.com/radixdlt/radixdlt-javascript/compare/@radixdlt/networking@2.1.12...@radixdlt/networking@2.1.13) (2022-01-17) | ||
**Note:** Version bump only for package @radixdlt/networking | ||
## [2.1.12](https://github.com/radixdlt/radixdlt-javascript/compare/@radixdlt/networking@2.1.11...@radixdlt/networking@2.1.12) (2022-01-07) | ||
@@ -8,0 +16,0 @@ |
@@ -26,3 +26,3 @@ "use strict"; | ||
else { | ||
throw error; | ||
return (0, neverthrow_1.err)({ message: error.message }); | ||
} | ||
@@ -43,3 +43,5 @@ }; | ||
const openApiClient = (url) => { | ||
const configuration = new open_api_1.Configuration({ basePath: url.toString().slice(0, -1) }); | ||
const configuration = new open_api_1.Configuration({ | ||
basePath: url.toString().slice(0, -1), | ||
}); | ||
const api = [ | ||
@@ -46,0 +48,0 @@ _1.AccountEndpointApiFactory, |
{ | ||
"name": "@radixdlt/networking", | ||
"version": "2.1.12", | ||
"version": "2.1.13", | ||
"description": "Requesting and sending data from/to Radix Core RPC API over HTTP(s).", | ||
@@ -44,3 +44,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "d0555764c2a55733307606dbd24b73c99c839d62" | ||
"gitHead": "9a4124671e541c520c291b6aa4060baf969b6413" | ||
} |
@@ -27,6 +27,7 @@ import 'isomorphic-fetch' | ||
export type ReturnOfAPICall<Name extends MethodName> = | ||
Name extends 'transactionBuildPost' | ||
? AxiosResponse<TransactionBuildResponse> | ||
: Awaited<ReturnType<ClientInterface[Name]>> | ||
export type ReturnOfAPICall< | ||
Name extends MethodName | ||
> = Name extends 'transactionBuildPost' | ||
? AxiosResponse<TransactionBuildResponse> | ||
: Awaited<ReturnType<ClientInterface[Name]>> | ||
@@ -55,45 +56,43 @@ export type InputOfAPICall<Name extends MethodName> = Parameters< | ||
} else { | ||
throw error | ||
return err({ message: error.message }) | ||
} | ||
} | ||
const call = | ||
(client: ClientInterface) => | ||
<M extends MethodName>( | ||
method: M, | ||
params: InputOfAPICall<M>, | ||
headers?: Record<string, string> | ||
): ResultAsync<ReturnOfAPICall<M>, Error> => | ||
// @ts-ignore | ||
pipe( | ||
() => | ||
log.info( | ||
`Sending api request with method ${method}. ${JSON.stringify( | ||
params, | ||
null, | ||
2, | ||
)}`, | ||
), | ||
() => | ||
ResultAsync.fromPromise( | ||
// @ts-ignore | ||
client[method](params, { | ||
headers: { | ||
[defaultHeaders[0]]: method, | ||
[defaultHeaders[1]]: correlationID, | ||
[defaultHeaders[2]]: apiVersion, | ||
...headers | ||
}, | ||
}).then(response => { | ||
log.info( | ||
`Response from api with method ${method}`, | ||
JSON.stringify(response.data, null, 2), | ||
) | ||
const call = (client: ClientInterface) => <M extends MethodName>( | ||
method: M, | ||
params: InputOfAPICall<M>, | ||
headers?: Record<string, string>, | ||
): ResultAsync<ReturnOfAPICall<M>, Error> => | ||
// @ts-ignore | ||
pipe( | ||
() => | ||
log.info( | ||
`Sending api request with method ${method}. ${JSON.stringify( | ||
params, | ||
null, | ||
2, | ||
)}`, | ||
), | ||
() => | ||
ResultAsync.fromPromise( | ||
// @ts-ignore | ||
client[method](params, { | ||
headers: { | ||
[defaultHeaders[0]]: method, | ||
[defaultHeaders[1]]: correlationID, | ||
[defaultHeaders[2]]: apiVersion, | ||
...headers, | ||
}, | ||
}).then(response => { | ||
log.info( | ||
`Response from api with method ${method}`, | ||
JSON.stringify(response.data, null, 2), | ||
) | ||
return response | ||
}), | ||
// @ts-ignore | ||
handleError, | ||
), | ||
)() | ||
return response | ||
}), | ||
// @ts-ignore | ||
handleError, | ||
), | ||
)() | ||
@@ -103,3 +102,5 @@ export type OpenApiClientCall = ReturnType<typeof call> | ||
export const openApiClient: Client<'open-api'> = (url: URL) => { | ||
const configuration = new Configuration({ basePath: url.toString().slice(0, -1) }) | ||
const configuration = new Configuration({ | ||
basePath: url.toString().slice(0, -1), | ||
}) | ||
const api = [ | ||
@@ -111,6 +112,9 @@ AccountEndpointApiFactory, | ||
GatewayEndpointApiFactory, | ||
].reduce<ClientInterface>((acc, factory) => ({ | ||
].reduce<ClientInterface>( | ||
(acc, factory) => ({ | ||
...acc, | ||
...factory(configuration), | ||
}), {} as ClientInterface) | ||
}), | ||
{} as ClientInterface, | ||
) | ||
@@ -117,0 +121,0 @@ return { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
591590
9485