@seamapi/http 1.0.0-rc.3 → 1.0.0-rc.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2054,6 +2054,9 @@ interface ApiError {
2054
2054
  type: string;
2055
2055
  message: string;
2056
2056
  data?: unknown;
2057
+ validation_errors?: Record<string, {
2058
+ _errors: string[];
2059
+ }>;
2057
2060
  }
2058
2061
 
2059
2062
  declare class SeamHttpApiError extends Error {
@@ -2071,8 +2074,10 @@ declare class SeamHttpUnauthorizedError extends SeamHttpApiError {
2071
2074
  }
2072
2075
  declare const isSeamHttpUnauthorizedError: (error: unknown) => error is SeamHttpUnauthorizedError;
2073
2076
  declare class SeamHttpInvalidInputError extends SeamHttpApiError {
2077
+ #private;
2074
2078
  code: 'invalid_input';
2075
2079
  constructor(error: ApiError, statusCode: number, requestId: string);
2080
+ getValidationErrorMessages(paramName: string): string[];
2076
2081
  }
2077
2082
  declare const isSeamHttpInvalidInputError: (error: unknown) => error is SeamHttpInvalidInputError;
2078
2083
 
@@ -5,4 +5,7 @@ export interface ApiError {
5
5
  type: string;
6
6
  message: string;
7
7
  data?: unknown;
8
+ validation_errors?: Record<string, {
9
+ _errors: string[];
10
+ }>;
8
11
  }
@@ -14,7 +14,9 @@ export declare class SeamHttpUnauthorizedError extends SeamHttpApiError {
14
14
  }
15
15
  export declare const isSeamHttpUnauthorizedError: (error: unknown) => error is SeamHttpUnauthorizedError;
16
16
  export declare class SeamHttpInvalidInputError extends SeamHttpApiError {
17
+ #private;
17
18
  code: 'invalid_input';
18
19
  constructor(error: ApiError, statusCode: number, requestId: string);
20
+ getValidationErrorMessages(paramName: string): string[];
19
21
  }
20
22
  export declare const isSeamHttpInvalidInputError: (error: unknown) => error is SeamHttpInvalidInputError;
@@ -1,3 +1,15 @@
1
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
+ if (kind === "m") throw new TypeError("Private method is not writable");
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
+ 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");
5
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
+ };
7
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
+ 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");
10
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
+ };
12
+ var _SeamHttpInvalidInputError_validationErrors;
1
13
  export class SeamHttpApiError extends Error {
2
14
  constructor(error, statusCode, requestId) {
3
15
  const { type, message, data } = error;
@@ -30,10 +42,16 @@ export const isSeamHttpUnauthorizedError = (error) => {
30
42
  export class SeamHttpInvalidInputError extends SeamHttpApiError {
31
43
  constructor(error, statusCode, requestId) {
32
44
  super(error, statusCode, requestId);
45
+ _SeamHttpInvalidInputError_validationErrors.set(this, void 0);
33
46
  this.name = this.constructor.name;
34
47
  this.code = 'invalid_input';
48
+ __classPrivateFieldSet(this, _SeamHttpInvalidInputError_validationErrors, error.validation_errors ?? {}, "f");
49
+ }
50
+ getValidationErrorMessages(paramName) {
51
+ return __classPrivateFieldGet(this, _SeamHttpInvalidInputError_validationErrors, "f")[paramName]?._errors ?? [];
35
52
  }
36
53
  }
54
+ _SeamHttpInvalidInputError_validationErrors = new WeakMap();
37
55
  export const isSeamHttpInvalidInputError = (error) => {
38
56
  return error instanceof SeamHttpInvalidInputError;
39
57
  };
@@ -1 +1 @@
1
- {"version":3,"file":"seam-http-error.js","sourceRoot":"","sources":["../../../src/lib/seam/connect/seam-http-error.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IAMzC,YAAY,KAAe,EAAE,UAAkB,E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I,CAAA;QACjC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,UAAU,GAAG,MAAM,CAAA;QACxB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;IAC5B,CAAC;CACF;AAED,MAAM,CAAC,MAAM,2BAA2B,GAAG,CACzC,KAAc,EACsB,EAAE;IACtC,OAAO,KAAK,YAAY,yBAAyB,CAAA;AACnD,CAAC,CAAA;AAED,MAAM,OAAO,yBAA0B,SAAQ,gBAAgB;IAI7D,YAAY,KAAe,EAAE,UAAkB,EAAE,SAAiB;QAChE,KAAK,CAAC,KAAK,EAAE,UAAU,EAAE,SAAS,CAAC,CAAA;QAH5B,8DAA6D;QAIpE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAA;QACjC,IAAI,CAAC,IAAI,GAAG,eAAe,CAAA;QAC3B,uBAAA,IAAI,+CAAqB,KAAK,CAAC,iBAAiB,IAAI,EAAE,MAAA,CAAA;IACxD,CAAC;IAED,0BAA0B,CAAC,SAAiB;QAC1C,OAAO,uBAAA,IAAI,mDAAkB,CAAC,SAAS,CAAC,EAAE,OAAO,IAAI,EAAE,CAAA;IACzD,CAAC;CACF;;AAED,MAAM,CAAC,MAAM,2BAA2B,GAAG,CACzC,KAAc,EACsB,EAAE;IACtC,OAAO,KAAK,YAAY,yBAAyB,CAAA;AACnD,CAAC,CAAA"}
package/lib/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- declare const seamapiJavascriptHttpVersion = "1.0.0-rc.3";
1
+ declare const seamapiJavascriptHttpVersion = "1.0.0-rc.4";
2
2
  export default seamapiJavascriptHttpVersion;
package/lib/version.js CHANGED
@@ -1,3 +1,3 @@
1
- const seamapiJavascriptHttpVersion = '1.0.0-rc.3';
1
+ const seamapiJavascriptHttpVersion = '1.0.0-rc.4';
2
2
  export default seamapiJavascriptHttpVersion;
3
3
  //# sourceMappingURL=version.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seamapi/http",
3
- "version": "1.0.0-rc.3",
3
+ "version": "1.0.0-rc.4",
4
4
  "description": "JavaScript HTTP client for the Seam API written in TypeScript.",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -8,4 +8,5 @@ export interface ApiError {
8
8
  type: string
9
9
  message: string
10
10
  data?: unknown
11
+ validation_errors?: Record<string, { _errors: string[] }>
11
12
  }
@@ -46,11 +46,17 @@ export const isSeamHttpUnauthorizedError = (
46
46
 
47
47
  export class SeamHttpInvalidInputError extends SeamHttpApiError {
48
48
  override code: 'invalid_input'
49
+ readonly #validationErrors: NonNullable<ApiError['validation_errors']>
49
50
 
50
51
  constructor(error: ApiError, statusCode: number, requestId: string) {
51
52
  super(error, statusCode, requestId)
52
53
  this.name = this.constructor.name
53
54
  this.code = 'invalid_input'
55
+ this.#validationErrors = error.validation_errors ?? {}
56
+ }
57
+
58
+ getValidationErrorMessages(paramName: string): string[] {
59
+ return this.#validationErrors[paramName]?._errors ?? []
54
60
  }
55
61
  }
56
62
 
@@ -1,3 +1,3 @@
1
- const seamapiJavascriptHttpVersion = '1.0.0-rc.3'
1
+ const seamapiJavascriptHttpVersion = '1.0.0-rc.4'
2
2
 
3
3
  export default seamapiJavascriptHttpVersion