@turnkey/http
Advanced tools
Comparing version 0.13.1 to 0.13.2
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.PublicApiService = exports.TurnkeyApi = exports.withAsyncPolling = exports.TurnkeyActivityError = exports.init = void 0; | ||
exports.PublicApiService = exports.TurnkeyApi = exports.withAsyncPolling = exports.TurnkeyRequestError = exports.TurnkeyActivityError = exports.init = void 0; | ||
const barrel_1 = require("./__generated__/barrel"); | ||
@@ -10,2 +10,3 @@ Object.defineProperty(exports, "TurnkeyApi", { enumerable: true, get: function () { return barrel_1.PublicApiService; } }); | ||
Object.defineProperty(exports, "TurnkeyActivityError", { enumerable: true, get: function () { return shared_1.TurnkeyActivityError; } }); | ||
Object.defineProperty(exports, "TurnkeyRequestError", { enumerable: true, get: function () { return shared_1.TurnkeyRequestError; } }); | ||
var async_1 = require("./async"); | ||
@@ -12,0 +13,0 @@ Object.defineProperty(exports, "withAsyncPolling", { enumerable: true, get: function () { return async_1.withAsyncPolling; } }); |
# @turnkey/http | ||
## 0.13.2 | ||
### Patch Changes | ||
- New `TurnkeyRequestError` error class that contains rich error details | ||
## 0.13.1 | ||
@@ -4,0 +10,0 @@ |
@@ -7,2 +7,3 @@ "use strict"; | ||
const encoding_1 = require("./encoding"); | ||
const shared_1 = require("./shared"); | ||
const sharedHeaders = {}; | ||
@@ -40,12 +41,10 @@ const sharedRequestOptions = { | ||
// https://node.green/#ES2022-features-Error-cause-property | ||
let turnkeyErrorMessage = null; | ||
let res; | ||
try { | ||
const { code, message, details } = (await response.json()); | ||
turnkeyErrorMessage = `Turnkey error ${code}: ${message}`; | ||
if (details != null) { | ||
turnkeyErrorMessage += ` (Details: ${JSON.stringify(details)})`; | ||
} | ||
res = await response.json(); | ||
} | ||
catch (_) { } | ||
throw new Error(turnkeyErrorMessage ?? `${response.status} ${response.statusText}`); | ||
catch (_) { | ||
throw new Error(`${response.status} ${response.statusText}`); | ||
} | ||
throw new shared_1.TurnkeyRequestError(res); | ||
} | ||
@@ -52,0 +51,0 @@ const data = await response.json(); |
type TConfig = { | ||
/** | ||
* Turnkey API public key | ||
*/ | ||
apiPublicKey: string; | ||
/** | ||
* Turnkey API private key | ||
*/ | ||
apiPrivateKey: string; | ||
/** | ||
* Turnkey API base URL | ||
*/ | ||
baseUrl: string; | ||
@@ -5,0 +14,0 @@ }; |
import { PublicApiService as TurnkeyApi } from "./__generated__/barrel"; | ||
export { init } from "./config"; | ||
export { TurnkeyActivityError } from "./shared"; | ||
export { TurnkeyActivityError, TurnkeyRequestError } from "./shared"; | ||
export { withAsyncPolling } from "./async"; | ||
@@ -5,0 +5,0 @@ export { TurnkeyApi }; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.PublicApiService = exports.TurnkeyApi = exports.withAsyncPolling = exports.TurnkeyActivityError = exports.init = void 0; | ||
exports.PublicApiService = exports.TurnkeyApi = exports.withAsyncPolling = exports.TurnkeyRequestError = exports.TurnkeyActivityError = exports.init = void 0; | ||
const barrel_1 = require("./__generated__/barrel"); | ||
@@ -10,2 +10,3 @@ Object.defineProperty(exports, "TurnkeyApi", { enumerable: true, get: function () { return barrel_1.PublicApiService; } }); | ||
Object.defineProperty(exports, "TurnkeyActivityError", { enumerable: true, get: function () { return shared_1.TurnkeyActivityError; } }); | ||
Object.defineProperty(exports, "TurnkeyRequestError", { enumerable: true, get: function () { return shared_1.TurnkeyRequestError; } }); | ||
var async_1 = require("./async"); | ||
@@ -12,0 +13,0 @@ Object.defineProperty(exports, "withAsyncPolling", { enumerable: true, get: function () { return async_1.withAsyncPolling; } }); |
@@ -29,2 +29,12 @@ import type { definitions } from "./__generated__/services/coordinator/public/v1/public_api.types"; | ||
}>; | ||
export type GrpcStatus = { | ||
message: string; | ||
code: number; | ||
details: unknown[] | null; | ||
}; | ||
export declare class TurnkeyRequestError extends Error { | ||
details: any[] | null; | ||
code: number; | ||
constructor(input: GrpcStatus); | ||
} | ||
//# sourceMappingURL=shared.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.TurnkeyActivityError = void 0; | ||
exports.TurnkeyRequestError = exports.TurnkeyActivityError = void 0; | ||
class TurnkeyActivityError extends Error { | ||
@@ -16,2 +16,15 @@ constructor(input) { | ||
exports.TurnkeyActivityError = TurnkeyActivityError; | ||
class TurnkeyRequestError extends Error { | ||
constructor(input) { | ||
let turnkeyErrorMessage = `Turnkey error ${input.code}: ${input.message}`; | ||
if (input.details != null) { | ||
turnkeyErrorMessage += ` (Details: ${JSON.stringify(input.details)})`; | ||
} | ||
super(turnkeyErrorMessage); | ||
this.name = "TurnkeyRequestError"; | ||
this.details = input.details ?? null; | ||
this.code = input.code; | ||
} | ||
} | ||
exports.TurnkeyRequestError = TurnkeyRequestError; | ||
//# sourceMappingURL=shared.js.map |
{ | ||
"name": "@turnkey/http", | ||
"version": "0.13.1", | ||
"version": "0.13.2", | ||
"main": "./dist/index.js", | ||
@@ -5,0 +5,0 @@ "types": "./dist/index.d.ts", |
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
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
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
613370
13249