@seamapi/http
Advanced tools
Comparing version 1.0.0-rc.3 to 1.0.0-rc.4
@@ -8,2 +8,5 @@ export interface ApiErrorResponse { | ||
data?: unknown; | ||
validation_errors?: Record<string, { | ||
_errors: string[]; | ||
}>; | ||
} |
@@ -17,5 +17,7 @@ import type { ApiError } from './api-error-types.js'; | ||
export declare class SeamHttpInvalidInputError extends SeamHttpApiError { | ||
#private; | ||
code: 'invalid_input'; | ||
constructor(error: ApiError, statusCode: number, requestId: string); | ||
getValidationErrorMessages(paramName: string): string[]; | ||
} | ||
export declare const isSeamHttpInvalidInputError: (error: unknown) => error is SeamHttpInvalidInputError; |
@@ -0,1 +1,13 @@ | ||
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) { | ||
if (kind === "m") throw new TypeError("Private method is not writable"); | ||
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); | ||
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); | ||
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; | ||
}; | ||
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { | ||
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); | ||
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); | ||
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); | ||
}; | ||
var _SeamHttpInvalidInputError_validationErrors; | ||
export class SeamHttpApiError extends Error { | ||
@@ -33,6 +45,12 @@ constructor(error, statusCode, requestId) { | ||
super(error, statusCode, requestId); | ||
_SeamHttpInvalidInputError_validationErrors.set(this, void 0); | ||
this.name = this.constructor.name; | ||
this.code = 'invalid_input'; | ||
__classPrivateFieldSet(this, _SeamHttpInvalidInputError_validationErrors, error.validation_errors ?? {}, "f"); | ||
} | ||
getValidationErrorMessages(paramName) { | ||
return __classPrivateFieldGet(this, _SeamHttpInvalidInputError_validationErrors, "f")[paramName]?._errors ?? []; | ||
} | ||
} | ||
_SeamHttpInvalidInputError_validationErrors = new WeakMap(); | ||
export const isSeamHttpInvalidInputError = (error) => { | ||
@@ -39,0 +57,0 @@ return error instanceof SeamHttpInvalidInputError; |
@@ -1,2 +0,2 @@ | ||
declare const seamapiJavascriptHttpVersion = "1.0.0-rc.3"; | ||
declare const seamapiJavascriptHttpVersion = "1.0.0-rc.4"; | ||
export default seamapiJavascriptHttpVersion; |
@@ -1,3 +0,3 @@ | ||
const seamapiJavascriptHttpVersion = '1.0.0-rc.3'; | ||
const seamapiJavascriptHttpVersion = '1.0.0-rc.4'; | ||
export default seamapiJavascriptHttpVersion; | ||
//# sourceMappingURL=version.js.map |
{ | ||
"name": "@seamapi/http", | ||
"version": "1.0.0-rc.3", | ||
"version": "1.0.0-rc.4", | ||
"description": "JavaScript HTTP client for the Seam API written in TypeScript.", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -125,3 +125,3 @@ # Seam HTTP Client | ||
// Pass as an option the constructor | ||
// Pass as an option to the constructor | ||
const seam = new SeamHttp({ apiKey: 'your-api-key' }) | ||
@@ -138,3 +138,3 @@ | ||
```ts | ||
// Pass as an option the constructor | ||
// Pass as an option to the constructor | ||
const seam = new SeamHttp({ clientSessionToken: 'some-client-session-token' }) | ||
@@ -179,3 +179,3 @@ | ||
```ts | ||
// Pass as an option the constructor | ||
// Pass as an option to the constructor | ||
@@ -202,3 +202,3 @@ const seam = new SeamHttp({ | ||
```ts | ||
// Pass as an option the constructor | ||
// Pass as an option to the constructor | ||
const seam = new SeamHttp({ | ||
@@ -241,3 +241,3 @@ consoleSessionToken: 'some-console-session-token', | ||
Or, to get the current state of an action attempt by ID without waiting, | ||
Or, to get the current state of an action attempt by ID without waiting: | ||
@@ -253,3 +253,3 @@ ```ts | ||
To disable this behavior, set the default option for the client, | ||
To disable this behavior, set the default option for the client: | ||
@@ -265,3 +265,3 @@ ```ts | ||
or the behavior may be configured per-request, | ||
or the behavior may be configured per-request: | ||
@@ -277,3 +277,4 @@ ```ts | ||
The `pollingInterval` and `timeout` may be configured for the client or per-request, for example | ||
The `pollingInterval` and `timeout` may be configured for the client or per-request. | ||
For example: | ||
@@ -330,3 +331,3 @@ ```ts | ||
```ts | ||
// Pass as an option the constructor | ||
// Pass as an option to the constructor | ||
const seam = new SeamHttpMultiWorkspace({ | ||
@@ -351,3 +352,3 @@ personalAccessToken: 'your-personal-access-token', | ||
```ts | ||
// Pass as an option the constructor | ||
// Pass as an option to the constructor | ||
const seam = new SeamHttpMultiWorkspace({ | ||
@@ -354,0 +355,0 @@ consoleSessionToken: 'some-console-session-token', |
@@ -11,2 +11,3 @@ // UPSTREAM: These types should be provided by @seamapi/types/connect. | ||
data?: unknown | ||
validation_errors?: Record<string, { _errors: string[] }> | ||
} |
@@ -49,2 +49,3 @@ import type { ApiError } from './api-error-types.js' | ||
override code: 'invalid_input' | ||
readonly #validationErrors: NonNullable<ApiError['validation_errors']> | ||
@@ -55,3 +56,8 @@ constructor(error: ApiError, statusCode: number, requestId: string) { | ||
this.code = 'invalid_input' | ||
this.#validationErrors = error.validation_errors ?? {} | ||
} | ||
getValidationErrorMessages(paramName: string): string[] { | ||
return this.#validationErrors[paramName]?._errors ?? [] | ||
} | ||
} | ||
@@ -58,0 +64,0 @@ |
@@ -1,3 +0,3 @@ | ||
const seamapiJavascriptHttpVersion = '1.0.0-rc.3' | ||
const seamapiJavascriptHttpVersion = '1.0.0-rc.4' | ||
export default seamapiJavascriptHttpVersion |
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
1598346
19968
572