@happyvertical/smrt-web 0.60.18 → 0.61.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.
@@ -3204,12 +3204,16 @@ var SmrtWebRequestError = class extends Error {
3204
3204
  payload;
3205
3205
  status;
3206
3206
  code;
3207
- constructor(message, payload, status, code) {
3207
+ requestId;
3208
+ publicMessage;
3209
+ constructor(message, payload, status, code, requestId, publicMessage) {
3208
3210
  super(message);
3209
3211
  this.name = "SmrtWebRequestError";
3210
3212
  this.payload = payload;
3211
3213
  if (status !== void 0) this.status = status;
3212
3214
  if (code !== void 0) this.code = code;
3215
+ if (requestId !== void 0) this.requestId = requestId;
3216
+ if (publicMessage !== void 0) this.publicMessage = publicMessage;
3213
3217
  }
3214
3218
  };
3215
3219
  function getWebErrorDetail(payload) {
@@ -3224,9 +3228,13 @@ function getWebErrorDetail(payload) {
3224
3228
  };
3225
3229
  }
3226
3230
  function createHttpRequestError(collectionName, status, payload) {
3227
- if (status >= 500) return new SmrtWebRequestError(`[smrt-web] ${collectionName} request failed: server error`, void 0, status);
3231
+ if (status >= 500) {
3232
+ const candidate = payload && typeof payload === "object" ? payload.requestId : void 0;
3233
+ const requestId = typeof candidate === "string" && /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(candidate) ? candidate : void 0;
3234
+ return new SmrtWebRequestError(`[smrt-web] ${collectionName} request failed: server error`, void 0, status, void 0, requestId);
3235
+ }
3228
3236
  const detail = getWebErrorDetail(payload);
3229
- return new SmrtWebRequestError(`[smrt-web] ${collectionName} request failed: ${detail.message ?? `HTTP ${status}`}`, payload, status, detail.code);
3237
+ return new SmrtWebRequestError(`[smrt-web] ${collectionName} request failed: ${detail.message ?? `HTTP ${status}`}`, payload, status, detail.code, void 0, detail.code ? detail.message : void 0);
3230
3238
  }
3231
3239
  function unwrapListResult(result, collectionName) {
3232
3240
  throwIfSmrtWebError(result, `list(${collectionName})`);
@@ -3290,7 +3298,6 @@ function createDefinitionFetchers(definition, basePath = "/api/v1", fetchFn = (.
3290
3298
  const headers = { "Content-Type": "application/json" };
3291
3299
  const parse = async (response) => {
3292
3300
  if (!response.ok) {
3293
- if (response.status >= 500) throw createHttpRequestError(definition.name, response.status);
3294
3301
  const payload = await response.json().catch(() => null);
3295
3302
  throw createHttpRequestError(definition.name, response.status, payload);
3296
3303
  }
@@ -3315,7 +3322,6 @@ function createDefinitionFetchers(definition, basePath = "/api/v1", fetchFn = (.
3315
3322
  headers
3316
3323
  });
3317
3324
  if (!response.ok) {
3318
- if (response.status >= 500) throw createHttpRequestError(definition.name, response.status);
3319
3325
  const payload = await response.json().catch(() => null);
3320
3326
  throw createHttpRequestError(definition.name, response.status, payload);
3321
3327
  }
@@ -3760,4 +3766,4 @@ function createSmrtCollection(definition, options) {
3760
3766
  //#endregion
3761
3767
  export { wipeDurableStore as A, MAX_SMRT_WEB_DATA_QUERY_FACETS as B, getOutboxHandle as C, pruneDurableNamespace as D, listDurableNamespaces as E, classifySmrtWebDataSurfaceActionResult as F, MAX_SMRT_WEB_DATA_QUERY_ROWS as G, MAX_SMRT_WEB_DATA_QUERY_OFFSET as H, dataSurfaceActionCommandTransport as I, executeSmrtWebDataQuery as J, MAX_SMRT_WEB_DATA_QUERY_STRING_LENGTH as K, executeSmrtWebDataSurfaceAction as L, MAX_SMRT_WEB_DATA_SURFACE_ACTION_IDENTIFIER_LENGTH as M, MAX_SMRT_WEB_DATA_SURFACE_ACTION_JSON_DEPTH as N, durableStoreNamespace as O, MAX_SMRT_WEB_DATA_SURFACE_ACTION_RESULT_BYTES as P, normalizeSmrtWebDataSurfaceActionResult as R, persistDataSurface as S, offlineOutbox as T, MAX_SMRT_WEB_DATA_QUERY_PAGE_LIMIT as U, MAX_SMRT_WEB_DATA_QUERY_FACET_VALUES as V, MAX_SMRT_WEB_DATA_QUERY_RESULT_BYTES as W, runWrapMutation as X, normalizeSmrtWebDataQueryResult as Y, createSmrtWebEventSubscriber as _, createSmrtWebClient as a, DEFAULT_PERSIST_DEBOUNCE_MS as b, newLocalId as c, unwrapListResult as d, validateSmrtWebClient as f, createUpdateState as g, registerWebMcpTools as h, createSmrtCollection as i, MAX_SMRT_WEB_DATA_SURFACE_ACTION_CONTAINER_ITEMS as j, registerDurableResource as k, throwIfSmrtWebError as l, registerWebMcpBespokeTool as m, buildListQuery as n, getEngineCollection as o, registerViewIntent as p, MAX_SMRT_WEB_DATA_QUERY_WARNINGS as q, createDefinitionFetchers as r, invalidateSmrtWebCollections as s, SmrtWebRequestError as t, unwrapItemResult as u, liveInvalidation as v, offlineCommandQueue as w, persistCollection as x, createSmrtWebQuery as y, MAX_SMRT_WEB_DATA_QUERY_CONTAINER_ITEMS as z };
3762
3768
 
3763
- //# sourceMappingURL=src-1YdIJK9X.js.map
3769
+ //# sourceMappingURL=src-DDrjDgMA.js.map