@foxnose/sdk 0.6.0 → 0.6.1

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.
package/dist/index.d.cts CHANGED
@@ -93,8 +93,8 @@ interface RetryConfig {
93
93
  methods: readonly string[];
94
94
  }
95
95
  declare const DEFAULT_RETRY_CONFIG: Readonly<RetryConfig>;
96
- declare const SDK_VERSION = "0.6.0";
97
- declare const DEFAULT_USER_AGENT = "foxnose-sdk-js/0.6.0";
96
+ declare const SDK_VERSION = "0.6.1";
97
+ declare const DEFAULT_USER_AGENT = "foxnose-sdk-js/0.6.1";
98
98
  /**
99
99
  * General transport-level configuration shared by all clients.
100
100
  */
@@ -229,6 +229,12 @@ declare class ExternalIdConflictError extends FoxnoseAPIError {
229
229
  }
230
230
  /**
231
231
  * Raised on HTTP 422 when submitted `data` fails the collection's schema.
232
+ *
233
+ * Two server error codes mean this, and both map here:
234
+ * `content_validation_failed` and `data_validation_error`. The latter is what
235
+ * a Flux resource write returns, so leaving it unmapped meant the most common
236
+ * way to hit a schema violation raised a bare {@link FoxnoseAPIError}, and
237
+ * `instanceof ContentValidationFailedError` never matched it.
232
238
  */
233
239
  declare class ContentValidationFailedError extends FoxnoseAPIError {
234
240
  /** Individual validation problems; each includes a `json_path`. */
package/dist/index.d.ts CHANGED
@@ -93,8 +93,8 @@ interface RetryConfig {
93
93
  methods: readonly string[];
94
94
  }
95
95
  declare const DEFAULT_RETRY_CONFIG: Readonly<RetryConfig>;
96
- declare const SDK_VERSION = "0.6.0";
97
- declare const DEFAULT_USER_AGENT = "foxnose-sdk-js/0.6.0";
96
+ declare const SDK_VERSION = "0.6.1";
97
+ declare const DEFAULT_USER_AGENT = "foxnose-sdk-js/0.6.1";
98
98
  /**
99
99
  * General transport-level configuration shared by all clients.
100
100
  */
@@ -229,6 +229,12 @@ declare class ExternalIdConflictError extends FoxnoseAPIError {
229
229
  }
230
230
  /**
231
231
  * Raised on HTTP 422 when submitted `data` fails the collection's schema.
232
+ *
233
+ * Two server error codes mean this, and both map here:
234
+ * `content_validation_failed` and `data_validation_error`. The latter is what
235
+ * a Flux resource write returns, so leaving it unmapped meant the most common
236
+ * way to hit a schema violation raised a bare {@link FoxnoseAPIError}, and
237
+ * `instanceof ContentValidationFailedError` never matched it.
232
238
  */
233
239
  declare class ContentValidationFailedError extends FoxnoseAPIError {
234
240
  /** Individual validation problems; each includes a `json_path`. */
package/dist/index.js CHANGED
@@ -165,6 +165,7 @@ function getHeader(headers, name) {
165
165
  }
166
166
  return void 0;
167
167
  }
168
+ var CONTENT_VALIDATION_CODES = /* @__PURE__ */ new Set(["content_validation_failed", "data_validation_error"]);
168
169
  function buildAPIError(options) {
169
170
  const { statusCode, errorCode, detail, responseHeaders, responseBody } = options;
170
171
  const body = isPlainObject(responseBody) ? responseBody : void 0;
@@ -210,7 +211,7 @@ function buildAPIError(options) {
210
211
  if (statusCode === 409 && errorCode === "external_id_conflict") {
211
212
  return new ExternalIdConflictError(options);
212
213
  }
213
- if (statusCode === 422 && errorCode === "content_validation_failed") {
214
+ if (statusCode === 422 && CONTENT_VALIDATION_CODES.has(errorCode)) {
214
215
  const d = isPlainObject(detail) ? detail : {};
215
216
  const errors = Array.isArray(d.errors) ? d.errors : typeof d.json_path === "string" ? [d] : [];
216
217
  return new ContentValidationFailedError({
@@ -308,7 +309,7 @@ var DEFAULT_RETRY_CONFIG = {
308
309
  statusCodes: [408, 425, 429, 500, 502, 503, 504],
309
310
  methods: ["GET", "HEAD", "OPTIONS", "PUT", "DELETE"]
310
311
  };
311
- var SDK_VERSION = "0.6.0";
312
+ var SDK_VERSION = "0.6.1";
312
313
  var DEFAULT_USER_AGENT = `foxnose-sdk-js/${SDK_VERSION}`;
313
314
  function createConfig(options) {
314
315
  if (!options.baseUrl) {