@evomap/evolver-adapter-public 2.0.39 → 2.0.41

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.
@@ -965,9 +965,23 @@ function recipeListFromRecord(value) {
965
965
  }
966
966
  return undefined;
967
967
  }
968
+ class MalformedRecipeSearchPageError extends Error {
969
+ constructor() {
970
+ super('Hub recipe search page is malformed');
971
+ this.name = 'MalformedRecipeSearchPageError';
972
+ }
973
+ }
968
974
  function recipeSearchReceiptFromBody(body) {
975
+ if (!asRecord(body))
976
+ throw new MalformedRecipeSearchPageError();
969
977
  const payload = recipePayload(body);
970
- const recipes = recipeListFromRecord(payload) ?? recipeListFromRecord(body) ?? [];
978
+ const sources = [body, payload, asRecord(body['data']), asRecord(payload['data'])];
979
+ if (sources.some((source) => source?.['search_status'] === 'degraded' || source?.['retryable'] === true || source?.['complete'] === false)) {
980
+ throw new Error('recipe_search_degraded');
981
+ }
982
+ const recipes = recipeListFromRecord(payload) ?? recipeListFromRecord(body);
983
+ if (recipes === undefined)
984
+ throw new MalformedRecipeSearchPageError();
971
985
  const nextCursor = stringField(payload, 'next_cursor')
972
986
  ?? stringField(payload, 'nextCursor')
973
987
  ?? stringField(body, 'next_cursor')
@@ -58,6 +58,7 @@ export declare class HubUnreachableError extends Error {
58
58
  bodySnippet?: string;
59
59
  context?: string;
60
60
  retryAfterMs?: number;
61
+ retryAfterSource?: 'server' | 'local_backoff';
61
62
  operation?: HubOperation;
62
63
  timeoutMs?: number;
63
64
  };
@@ -68,6 +69,7 @@ export declare class HubUnreachableError extends Error {
68
69
  bodySnippet?: string;
69
70
  context?: string;
70
71
  retryAfterMs?: number;
72
+ retryAfterSource?: 'server' | 'local_backoff';
71
73
  operation?: HubOperation;
72
74
  timeoutMs?: number;
73
75
  });
package/dist/hubFetch.js CHANGED
@@ -151,6 +151,7 @@ export async function authenticateHubRequest(deps, method, path, bodyObj) {
151
151
  throw new HubUnreachableError('hub authentication timed out', {
152
152
  context: `${method} ${path}`,
153
153
  retryAfterMs: HUB_UNREACHABLE_BACKOFF_BASE_MS,
154
+ retryAfterSource: 'local_backoff',
154
155
  operation,
155
156
  });
156
157
  }
@@ -228,7 +229,7 @@ export class HubFetch {
228
229
  if (deadline.signal.aborted)
229
230
  throw deadline.error;
230
231
  if (isHubUnreachableError(err)) {
231
- throw new HubUnreachableError(`${method} ${path} failed before a Hub API response arrived`, { context: `${method} ${path}`, retryAfterMs: HUB_UNREACHABLE_BACKOFF_BASE_MS });
232
+ throw new HubUnreachableError(`${method} ${path} failed before a Hub API response arrived`, { context: `${method} ${path}`, retryAfterMs: HUB_UNREACHABLE_BACKOFF_BASE_MS, retryAfterSource: 'local_backoff' });
232
233
  }
233
234
  throw err;
234
235
  }
@@ -239,7 +240,7 @@ export class HubFetch {
239
240
  await drainHubResponse(res, { signal: deadline.signal });
240
241
  if (deadline.signal.aborted)
241
242
  throw deadline.error;
242
- throw new HubUnreachableError(`${method} ${path} refused an unexpected Hub redirect`, { status: res.status, context: `${method} ${path}`, retryAfterMs: retryAfterMs ?? HUB_UNREACHABLE_BACKOFF_BASE_MS });
243
+ throw new HubUnreachableError(`${method} ${path} refused an unexpected Hub redirect`, { status: res.status, context: `${method} ${path}`, retryAfterMs: retryAfterMs ?? HUB_UNREACHABLE_BACKOFF_BASE_MS, retryAfterSource: retryAfterMs === undefined ? 'local_backoff' : 'server' });
243
244
  }
244
245
  const parsed = await readHubResponseJsonForClassification(res, deadline.signal);
245
246
  if (deadline.signal.aborted)
@@ -306,6 +307,7 @@ function createHubDeadline(scheduler, method, path, operation, timeoutMs) {
306
307
  const error = new HubUnreachableError(`${method} ${path} timed out after ${timeoutMs}ms`, {
307
308
  context: `${method} ${path}`,
308
309
  retryAfterMs: HUB_UNREACHABLE_BACKOFF_BASE_MS,
310
+ retryAfterSource: 'local_backoff',
309
311
  operation,
310
312
  timeoutMs,
311
313
  });
@@ -547,6 +549,7 @@ export async function throwIfHubUnreachableResponse(res, context = 'hub') {
547
549
  contentType,
548
550
  context,
549
551
  retryAfterMs: retryAfterMs ?? HUB_UNREACHABLE_BACKOFF_BASE_MS,
552
+ retryAfterSource: retryAfterMs === undefined ? 'local_backoff' : 'server',
550
553
  });
551
554
  }
552
555
  async function readHubResponseJsonForClassification(res, signal) {
@@ -574,6 +577,7 @@ function throwIfParsedHubUnreachableResponse(res, parsed, context, retryAfterMs)
574
577
  contentType: contentType || 'unknown content-type',
575
578
  context,
576
579
  retryAfterMs: retryAfterMs ?? HUB_UNREACHABLE_BACKOFF_BASE_MS,
580
+ retryAfterSource: retryAfterMs === undefined ? 'local_backoff' : 'server',
577
581
  });
578
582
  }
579
583
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evomap/evolver-adapter-public",
3
- "version": "2.0.39",
3
+ "version": "2.0.41",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "engines": {
@@ -17,8 +17,8 @@
17
17
  },
18
18
  "dependencies": {
19
19
  "@evomap/atp-sdk": "^0.1.0",
20
- "@evomap/evolver-core": "2.0.39",
21
- "undici": "^6.28.0"
20
+ "@evomap/evolver-core": "2.0.41",
21
+ "undici": "^6.28.1"
22
22
  },
23
23
  "optionalDependencies": {
24
24
  "@napi-rs/keyring": "^1.1.6"