@simpleapps-com/augur-api 2026.11.4 → 2026.11.6

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.
Files changed (63) hide show
  1. package/dist/core/base-client.d.ts.map +1 -1
  2. package/dist/core/call-rules.d.ts +35 -0
  3. package/dist/core/call-rules.d.ts.map +1 -1
  4. package/dist/core/call.d.ts.map +1 -1
  5. package/dist/core/client-rules.d.ts +66 -36
  6. package/dist/core/client-rules.d.ts.map +1 -1
  7. package/dist/core/client.d.ts +12 -2
  8. package/dist/core/client.d.ts.map +1 -1
  9. package/dist/core/encoded-segment.d.ts +7 -1
  10. package/dist/core/encoded-segment.d.ts.map +1 -1
  11. package/dist/core/errors.d.ts.map +1 -1
  12. package/dist/core/http-rules.d.ts +0 -32
  13. package/dist/core/http-rules.d.ts.map +1 -1
  14. package/dist/core/proxy-rules.d.ts +53 -0
  15. package/dist/core/proxy-rules.d.ts.map +1 -1
  16. package/dist/core/registry-rules.d.ts +7 -0
  17. package/dist/core/registry-rules.d.ts.map +1 -1
  18. package/dist/core/registry.d.ts.map +1 -1
  19. package/dist/core/response-rules.d.ts +15 -0
  20. package/dist/core/response-rules.d.ts.map +1 -1
  21. package/dist/core/schemas.d.ts.map +1 -1
  22. package/dist/core/service-proxy.d.ts.map +1 -1
  23. package/dist/index.d.ts +1 -1
  24. package/dist/index.js +437 -233
  25. package/dist/index.js.map +1 -1
  26. package/dist/index.mjs +437 -233
  27. package/dist/index.mjs.map +1 -1
  28. package/dist/services/commerce/generated/schemas.d.ts +1 -0
  29. package/dist/services/commerce/generated/schemas.d.ts.map +1 -1
  30. package/dist/services/commerce/generated/types.d.ts +2 -0
  31. package/dist/services/commerce/generated/types.d.ts.map +1 -1
  32. package/dist/services/goog-mc/generated/schemas.d.ts +8 -0
  33. package/dist/services/goog-mc/generated/schemas.d.ts.map +1 -1
  34. package/dist/services/goog-mc/generated/types.d.ts +8 -0
  35. package/dist/services/goog-mc/generated/types.d.ts.map +1 -1
  36. package/dist/services/items/client.d.ts +1 -1
  37. package/dist/services/items/generated/endpoints.d.ts.map +1 -1
  38. package/dist/services/items/generated/schemas.d.ts +10 -0
  39. package/dist/services/items/generated/schemas.d.ts.map +1 -1
  40. package/dist/services/items/generated/types.d.ts +29 -13
  41. package/dist/services/items/generated/types.d.ts.map +1 -1
  42. package/dist/services/joomla/generated/endpoints.d.ts.map +1 -1
  43. package/dist/services/joomla/generated/schemas.d.ts +5 -0
  44. package/dist/services/joomla/generated/schemas.d.ts.map +1 -1
  45. package/dist/services/joomla/generated/types.d.ts +18 -2
  46. package/dist/services/joomla/generated/types.d.ts.map +1 -1
  47. package/dist/services/legacy/generated/endpoints.d.ts.map +1 -1
  48. package/dist/services/legacy/generated/schemas.d.ts +2 -0
  49. package/dist/services/legacy/generated/schemas.d.ts.map +1 -1
  50. package/dist/services/legacy/generated/types.d.ts +4 -0
  51. package/dist/services/legacy/generated/types.d.ts.map +1 -1
  52. package/dist/services/open-search/generated/endpoints.d.ts.map +1 -1
  53. package/dist/services/open-search/generated/schemas.d.ts +2 -0
  54. package/dist/services/open-search/generated/schemas.d.ts.map +1 -1
  55. package/dist/services/open-search/generated/types.d.ts +4 -0
  56. package/dist/services/open-search/generated/types.d.ts.map +1 -1
  57. package/dist/testing.d.ts.map +1 -1
  58. package/dist/testing.js +22 -9
  59. package/dist/testing.js.map +1 -1
  60. package/dist/testing.mjs +20 -9
  61. package/dist/testing.mjs.map +1 -1
  62. package/dist/utils/cross-site-auth.d.ts.map +1 -1
  63. package/package.json +2 -1
package/dist/index.js CHANGED
@@ -140,6 +140,9 @@ function joinFrom(xs, sep, i) {
140
140
  if (i >= xs.length) return "";
141
141
  return joinRange(xs, sep, i, xs.length);
142
142
  }
143
+ function joinOr(xs, sep, fallback) {
144
+ return xs.length === 0 ? fallback : joinFrom(xs, sep, 0);
145
+ }
143
146
  function joinRange(xs, sep, lo, hi) {
144
147
  if (hi - lo === 1) return xs[lo];
145
148
  const mid = lo + Math.floor((hi - lo) / 2);
@@ -156,6 +159,13 @@ function notInFrom(xs, allowed, i) {
156
159
  return hasItemFrom(allowed, xs[i], 0) ? rest : [xs[i], ...rest];
157
160
  }
158
161
 
162
+ // ../utils/src/pairs.ts
163
+ function allFrom(xs, i) {
164
+ if (i === xs.length) return true;
165
+ if (!xs[i]) return false;
166
+ return allFrom(xs, i + 1);
167
+ }
168
+
159
169
  // ../utils/src/uri.ts
160
170
  function isHigh(c) {
161
171
  return c >= 55296 && c <= 56319;
@@ -204,6 +214,25 @@ function isEncoded(s) {
204
214
  }
205
215
  return true;
206
216
  }
217
+ function pcharOf(hex) {
218
+ if (hex === "24") return "$";
219
+ if (hex === "26") return "&";
220
+ if (hex === "2B") return "+";
221
+ if (hex === "2C") return ",";
222
+ if (hex === "3B") return ";";
223
+ if (hex === "3D") return "=";
224
+ if (hex === "3A") return ":";
225
+ if (hex === "40") return "@";
226
+ return "";
227
+ }
228
+ function restorePcharFrom(s, i) {
229
+ if (i >= s.length) return "";
230
+ if (s.slice(i, i + 1) === "%" && i + 3 <= s.length) {
231
+ const ch = pcharOf(s.slice(i + 1, i + 3));
232
+ if (ch !== "") return ch + restorePcharFrom(s, i + 3);
233
+ }
234
+ return s.slice(i, i + 1) + restorePcharFrom(s, i + 1);
235
+ }
207
236
 
208
237
  // ../utils/src/replace.ts
209
238
  function replaceText(s, find, put) {
@@ -215,6 +244,21 @@ function replaceText(s, find, put) {
215
244
  }
216
245
 
217
246
  // src/core/call-rules.ts
247
+ function isEnvelopeBody(isPlainObject, allKeys) {
248
+ return isPlainObject && allKeys;
249
+ }
250
+ function callBodyKind(isJson) {
251
+ return isJson ? "json" : "text";
252
+ }
253
+ function validationMessageOf(kind) {
254
+ return kind === "params" ? "Invalid request parameters" : "Invalid API response structure\nThis appears to be a response validation error. The API returned data in an unexpected format.";
255
+ }
256
+ function issueCodeOf(type) {
257
+ return type !== void 0 ? type : "unknown";
258
+ }
259
+ function appendsIssues(count) {
260
+ return count > 0;
261
+ }
218
262
  function isQueryKeyAllowed(declared, edgeCache, key) {
219
263
  return declared || edgeCache && key === "edgeCache";
220
264
  }
@@ -277,12 +321,35 @@ var ContextCreationError = class extends Error {
277
321
  field;
278
322
  };
279
323
 
324
+ // ../foundation/src/optional.ts
325
+ function nonEmptyOr(s, fallback) {
326
+ return s !== "" ? s : fallback;
327
+ }
328
+
329
+ // ../foundation/src/decimal.ts
330
+ function decimal(n) {
331
+ const last = "0123456789".slice(n % 10, n % 10 + 1);
332
+ return n < 10 ? last : decimal(Math.floor(n / 10)) + last;
333
+ }
334
+
280
335
  // ../json-values/src/index.ts
281
336
  function isRecord(value) {
282
337
  return typeof value === "object" && value !== null && !Array.isArray(value);
283
338
  }
284
339
 
285
- // src/core/http-rules.ts
340
+ // ../utils/src/http.ts
341
+ function isPostOrPut(method) {
342
+ return method === "POST" || method === "PUT";
343
+ }
344
+ function querySeparator(url) {
345
+ return includesFrom(url, "?", 0) ? "&" : "?";
346
+ }
347
+ function queryValueSent(isUndefined, isNull) {
348
+ return !isUndefined && !isNull;
349
+ }
350
+ function urlWithQuery(url, query) {
351
+ return query === "" ? url : url + querySeparator(url) + query;
352
+ }
286
353
  function isRetryableStatus(status) {
287
354
  return !(status >= 400 && status < 500 && status !== 429);
288
355
  }
@@ -290,30 +357,24 @@ function exponentialDelay(base, attempt) {
290
357
  if (attempt === 0) return base;
291
358
  return 2 * exponentialDelay(base, attempt - 1);
292
359
  }
293
- function cappedDelay(d) {
294
- return Math.min(d, 3e4);
295
- }
296
- function timeoutOf(hasRequest, request, hasClient, client, fallback) {
297
- if (hasRequest) return request;
298
- return hasClient ? client : fallback;
299
- }
300
- function isPublicEndpoint(url) {
301
- return endsWith(url, "/health-check") || endsWith(url, "/ping");
360
+ function cappedAt(d, cap) {
361
+ return Math.min(d, cap);
302
362
  }
303
- function sendsBearer(url, hasToken) {
304
- return hasToken && !isPublicEndpoint(url);
363
+ function firstGiven(hasA, a, hasB, b, fallback) {
364
+ if (hasA) return a;
365
+ return hasB ? b : fallback;
305
366
  }
306
- function sendsJsonBody(hasData, method) {
307
- return hasData && method !== "GET";
367
+ function isAbortName(name) {
368
+ return name === "AbortError" || name === "TimeoutError";
308
369
  }
309
- function querySeparator(url) {
310
- return includesFrom(url, "?", 0) ? "&" : "?";
370
+ function remainingOf(deadline, elapsed) {
371
+ return elapsed < deadline ? deadline - elapsed : 0;
311
372
  }
312
- function requestKey(method, url, params) {
313
- return method + ":" + url + ":" + params;
373
+ function cutToRemaining(value, hasDeadline, remaining) {
374
+ return hasDeadline && remaining < value ? remaining : value;
314
375
  }
315
- function isEdgeCacheParam(key) {
316
- return key === "edgeCache";
376
+ function startsAttempt(hasDeadline, remaining) {
377
+ return !hasDeadline || remaining > 0;
317
378
  }
318
379
 
319
380
  // src/core/client-rules.ts
@@ -329,18 +390,6 @@ function retryableError(isAugurError, status) {
329
390
  function retryAfterCall(attempt, retries, retryable, callAborted) {
330
391
  return !callAborted && attempt < retries && retryable;
331
392
  }
332
- function isAbortName(name) {
333
- return name === "AbortError" || name === "TimeoutError";
334
- }
335
- function remainingOf(deadline, elapsed) {
336
- return elapsed < deadline ? deadline - elapsed : 0;
337
- }
338
- function attemptTimeoutOf(perAttempt, hasDeadline, remaining) {
339
- return hasDeadline && remaining < perAttempt ? remaining : perAttempt;
340
- }
341
- function waitOf(backoff, hasDeadline, remaining) {
342
- return hasDeadline && remaining < backoff ? remaining : backoff;
343
- }
344
393
  function needsAttemptTimer(perAttempt, hasDeadline, remaining) {
345
394
  return !(hasDeadline && remaining <= perAttempt);
346
395
  }
@@ -364,19 +413,53 @@ function mergedDeadlineOf(hasOuter, outer, hasInner, inner) {
364
413
  function hasMergedDeadline(hasOuter, hasInner) {
365
414
  return hasOuter || hasInner;
366
415
  }
367
- function edgeCacheKindOf(text, hours) {
416
+ function edgeCacheKindOf(text) {
368
417
  if (text === "30s" || text === "1m" || text === "5m") return "sub-hour";
369
- const hourly = hours === 1 || hours === 2 || hours === 3 || hours === 4 || hours === 5 || hours === 8;
418
+ const hourly = text === "1" || text === "2" || text === "3" || text === "4" || text === "5" || text === "8";
370
419
  return hourly ? "hourly" : "invalid";
371
420
  }
421
+ function edgeCacheKeyOf(kind, text) {
422
+ return kind === "invalid" ? "" : "cacheSiteId" + text;
423
+ }
424
+ function errorClassOf(status) {
425
+ if (status === 400) return "validation";
426
+ if (status === 401) return "authentication";
427
+ if (status === 404) return "notFound";
428
+ if (status === 429) return "rateLimit";
429
+ return "augur";
430
+ }
431
+ function detailMessageOf(isJson, isObject, isText, message) {
432
+ if (isJson && isObject && isText && message !== "") return message;
433
+ return void 0;
434
+ }
435
+ function defaultMessageOf(kind, status) {
436
+ if (kind === "validation") return "Validation failed";
437
+ if (kind === "authentication") return "Authentication failed";
438
+ if (kind === "notFound") return "Resource not found";
439
+ if (kind === "rateLimit") return "Rate limit exceeded";
440
+ return "Request failed with status " + decimal(status);
441
+ }
442
+ function errorMessageOf(given, kind, status) {
443
+ return given !== void 0 ? given : defaultMessageOf(kind, status);
444
+ }
445
+ function crossSiteUserIdOf(isId, id) {
446
+ return isId ? decimal(id) : void 0;
447
+ }
448
+ function responseHookOf(ok, hasOnError, hasOnResponse) {
449
+ if (ok) return hasOnResponse ? "onResponse" : "noHook";
450
+ return hasOnError ? "onError" : "noHook";
451
+ }
452
+ function crossSiteOutcomeOf(isVerified, tokenIsText, token) {
453
+ if (!isVerified) return "notVerified";
454
+ if (!tokenIsText || token === "") return "noToken";
455
+ return "signedIn";
456
+ }
372
457
  function rawRetries(method) {
373
458
  return method === "GET";
374
459
  }
375
- function startsAttempt(hasDeadline, remaining) {
376
- return !hasDeadline || remaining > 0;
377
- }
378
460
 
379
461
  // src/core/errors.ts
462
+ var ROOT_PATH = "root";
380
463
  var AugurError = class _AugurError extends Error {
381
464
  code;
382
465
  statusCode;
@@ -415,8 +498,7 @@ var ValidationError = class extends AugurError {
415
498
  return [];
416
499
  }
417
500
  return this.validationErrors.map((error) => {
418
- const path = error.path.length > 0 ? error.path.join(".") : "root";
419
- return `${path}: ${error.message}`;
501
+ return `${joinOr(error.path.map(String), ".", ROOT_PATH)}: ${error.message}`;
420
502
  });
421
503
  }
422
504
  /**
@@ -428,7 +510,7 @@ var ValidationError = class extends AugurError {
428
510
  return [];
429
511
  }
430
512
  return this.validationErrors.map((error) => ({
431
- path: error.path.length > 0 ? error.path.join(".") : "root",
513
+ path: joinOr(error.path.map(String), ".", ROOT_PATH),
432
514
  message: error.message,
433
515
  code: error.code,
434
516
  received: "received" in error ? error.received : void 0,
@@ -442,7 +524,7 @@ var ValidationError = class extends AugurError {
442
524
  toString() {
443
525
  const baseMessage = super.toString();
444
526
  const formattedErrors = this.getFormattedErrors();
445
- if (formattedErrors.length > 0) {
527
+ if (appendsIssues(formattedErrors.length)) {
446
528
  return `${baseMessage}
447
529
  Validation errors:
448
530
  ${formattedErrors.map((err) => ` - ${err}`).join("\n")}`;
@@ -487,7 +569,57 @@ var InvalidArgumentError = class extends AugurError {
487
569
  }
488
570
  };
489
571
 
572
+ // ../auth-core/src/site.ts
573
+ function isSiteChar(c) {
574
+ return c >= 97 && c <= 122 || c >= 48 && c <= 57 || c === 95 || c === 45;
575
+ }
576
+ function siteCharsFrom(s, i) {
577
+ return i >= s.length || isSiteChar(s.charCodeAt(i)) && siteCharsFrom(s, i + 1);
578
+ }
579
+ function isSiteId(s) {
580
+ return s.length > 0 && siteCharsFrom(s, 0);
581
+ }
582
+
583
+ // src/core/site-id-check.ts
584
+ function isSiteId2(s) {
585
+ return isSiteId(s);
586
+ }
587
+
588
+ // src/core/site-id.ts
589
+ function parseSiteId(value) {
590
+ return isSiteId2(value) ? value : void 0;
591
+ }
592
+ function assertSiteId(value) {
593
+ const site = parseSiteId(value);
594
+ if (site === void 0) {
595
+ throw new InvalidArgumentError({
596
+ message: "Invalid siteId: expected lowercase letters, digits, '_' and '-' (e.g. example-site)",
597
+ service: "",
598
+ endpoint: ""
599
+ });
600
+ }
601
+ return site;
602
+ }
603
+
604
+ // src/core/http-rules.ts
605
+ function isPublicEndpoint(url) {
606
+ return endsWith(url, "/health-check") || endsWith(url, "/ping");
607
+ }
608
+ function sendsBearer(url, hasToken) {
609
+ return hasToken && !isPublicEndpoint(url);
610
+ }
611
+ function sendsJsonBody(hasData, method) {
612
+ return hasData && method !== "GET";
613
+ }
614
+ function requestKey(method, url, params) {
615
+ return method + ":" + url + ":" + params;
616
+ }
617
+ function isEdgeCacheParam(key) {
618
+ return key === "edgeCache";
619
+ }
620
+
490
621
  // src/core/client.ts
622
+ var MAX_RETRY_DELAY_MS = 3e4;
491
623
  function parseJson(text) {
492
624
  try {
493
625
  return { json: true, value: JSON.parse(String(text)) };
@@ -501,16 +633,29 @@ function errorDetail(text) {
501
633
  return { detail: {} };
502
634
  }
503
635
  const body = parsed.value;
504
- const detail = typeof body === "object" && body !== null ? body : {};
505
- const message = typeof detail.message === "string" && detail.message !== "" ? detail.message : void 0;
636
+ const isObject = typeof body === "object" && body !== null;
637
+ const detail = isObject ? body : {};
638
+ const given = detail.message;
639
+ const isText = typeof given === "string";
640
+ const message = detailMessageOf(true, isObject, isText, isText ? given : "");
506
641
  return { detail, message };
507
642
  }
508
- var STATUS_ERRORS = {
509
- 400: (message, ctx) => new ValidationError({ message: message ?? "Validation failed", ...ctx, validationErrors: [] }),
510
- 401: (message, ctx) => new AuthenticationError({ message: message ?? "Authentication failed", ...ctx }),
511
- 404: (message, ctx) => new NotFoundError({ message: message ?? "Resource not found", ...ctx }),
512
- 429: (message, ctx) => new RateLimitError({ message: message ?? "Rate limit exceeded", ...ctx })
513
- };
643
+ function statusError(status, message, ctx, detail) {
644
+ const kind = errorClassOf(status);
645
+ const text = errorMessageOf(message, kind, status);
646
+ if (kind === "validation")
647
+ return new ValidationError({ message: text, ...ctx, validationErrors: [] });
648
+ if (kind === "authentication") return new AuthenticationError({ message: text, ...ctx });
649
+ if (kind === "notFound") return new NotFoundError({ message: text, ...ctx });
650
+ if (kind === "rateLimit") return new RateLimitError({ message: text, ...ctx });
651
+ return new AugurError({
652
+ message: text,
653
+ code: nonEmptyOr(detail.code ?? "", "API_ERROR"),
654
+ statusCode: status,
655
+ ...ctx,
656
+ requestId: detail.requestId
657
+ });
658
+ }
514
659
  function generateRequestKey(method, url, params) {
515
660
  const paramsStr = params ? JSON.stringify(params, Object.keys(params).sort()) : "";
516
661
  return requestKey(method, url, paramsStr);
@@ -518,7 +663,7 @@ function generateRequestKey(method, url, params) {
518
663
  function calculateBackoffDelay(attempt, baseDelay) {
519
664
  const exponential = exponentialDelay(baseDelay, attempt);
520
665
  const jitter = Math.random() * 0.3 * exponential;
521
- return cappedDelay(exponential + jitter);
666
+ return cappedAt(exponential + jitter, MAX_RETRY_DELAY_MS);
522
667
  }
523
668
  function isRetryableError(error) {
524
669
  const isAugurError = error instanceof AugurError;
@@ -596,15 +741,11 @@ function buildUrlWithParams(url, params) {
596
741
  const searchParams = new URLSearchParams();
597
742
  const paramsObj = params;
598
743
  for (const [key, value] of Object.entries(paramsObj)) {
599
- if (value !== void 0 && value !== null) {
744
+ if (queryValueSent(value === void 0, value === null)) {
600
745
  searchParams.append(key, String(value));
601
746
  }
602
747
  }
603
- const queryString = searchParams.toString();
604
- if (!queryString) {
605
- return url;
606
- }
607
- return `${url}${querySeparator(url)}${queryString}`;
748
+ return urlWithQuery(url, searchParams.toString());
608
749
  }
609
750
  function headersToRecord(headers) {
610
751
  const record32 = {};
@@ -618,10 +759,21 @@ var HTTPClient = class {
618
759
  serviceName;
619
760
  inflightRequests = /* @__PURE__ */ new Map();
620
761
  bounds;
621
- /** `bounds` bound every call this client makes (a view's, from `AugurAPI.withRequest`). */
762
+ /**
763
+ * The siteId this client sends (`x-site-id`, and the value of every `cacheSiteId` edge
764
+ * directive): a `SiteId`, so only a proved `isSiteId` string reaches the header or Cloudflare's
765
+ * cache key (AugurApiClient.EdgeDirectiveCarriesASiteId; owner 2026-11-10).
766
+ */
767
+ siteId;
768
+ /**
769
+ * `bounds` bound every call this client makes (a view's, from `AugurAPI.withRequest`).
770
+ *
771
+ * @throws InvalidArgumentError when `config.siteId` is not a siteId (as `AugurAPI` does)
772
+ */
622
773
  constructor(serviceName, config, bounds = NO_BOUNDS) {
623
774
  this.serviceName = serviceName;
624
775
  this.config = { ...DEFAULT_CONFIG, ...config };
776
+ this.siteId = assertSiteId(this.config.siteId);
625
777
  this.bounds = bounds;
626
778
  }
627
779
  /**
@@ -632,7 +784,7 @@ var HTTPClient = class {
632
784
  const headers = {
633
785
  "Content-Type": "application/json",
634
786
  ...requestConfig?.headers,
635
- "x-site-id": this.config.siteId
787
+ "x-site-id": this.siteId
636
788
  };
637
789
  if (sendsBearer(url, Boolean(this.config.bearerToken))) {
638
790
  headers["Authorization"] = `Bearer ${this.config.bearerToken}`;
@@ -649,9 +801,10 @@ var HTTPClient = class {
649
801
  } catch {
650
802
  }
651
803
  const { detail, message } = errorDetail(text);
652
- if (this.config.onError) {
804
+ const { onError, onResponse } = this.config;
805
+ if (responseHookOf(response.ok, onError !== void 0, onResponse !== void 0) === "onError") {
653
806
  const augurError = {
654
- message: message ?? `Request failed with status ${response.status}`,
807
+ message: errorMessageOf(message, "augur", response.status),
655
808
  config: augurConfig,
656
809
  response: {
657
810
  data: detail,
@@ -661,7 +814,7 @@ var HTTPClient = class {
661
814
  config: augurConfig
662
815
  }
663
816
  };
664
- await this.config.onError(augurError);
817
+ await onError(augurError);
665
818
  }
666
819
  this.handleHttpError(response.status, { ...detail, message }, endpoint);
667
820
  }
@@ -677,8 +830,9 @@ var HTTPClient = class {
677
830
  headers: headersToRecord(response.headers),
678
831
  config: augurConfig
679
832
  };
680
- if (this.config.onResponse) {
681
- const modified = await this.config.onResponse(augurResponse);
833
+ const { onError, onResponse } = this.config;
834
+ if (responseHookOf(response.ok, onError !== void 0, onResponse !== void 0) === "onResponse") {
835
+ const modified = await onResponse(augurResponse);
682
836
  return modified.data;
683
837
  }
684
838
  return responseData;
@@ -688,8 +842,9 @@ var HTTPClient = class {
688
842
  */
689
843
  async readRaw(response, augurConfig) {
690
844
  let text = await response.text();
691
- if (this.config.onResponse) {
692
- const modified = await this.config.onResponse({
845
+ const { onError, onResponse } = this.config;
846
+ if (responseHookOf(response.ok, onError !== void 0, onResponse !== void 0) === "onResponse") {
847
+ const modified = await onResponse({
693
848
  data: text,
694
849
  status: response.status,
695
850
  statusText: response.statusText,
@@ -742,7 +897,7 @@ var HTTPClient = class {
742
897
  const perAttempt = this.timeoutFor(requestConfig);
743
898
  const remaining = call.remaining();
744
899
  return {
745
- timeout: attemptTimeoutOf(perAttempt, call.hasDeadline, remaining),
900
+ timeout: cutToRemaining(perAttempt, call.hasDeadline, remaining),
746
901
  ownTimer: needsAttemptTimer(perAttempt, call.hasDeadline, remaining)
747
902
  };
748
903
  }
@@ -760,11 +915,11 @@ var HTTPClient = class {
760
915
  }
761
916
  };
762
917
  }
763
- /** The request's timeout: per request, else the client's, else the default (timeoutOf). */
918
+ /** The request's timeout: per request, else the client's, else the default (firstGiven). */
764
919
  timeoutFor(requestConfig) {
765
920
  const request = requestConfig?.timeout;
766
921
  const client = this.config.timeout;
767
- return timeoutOf(
922
+ return firstGiven(
768
923
  request !== void 0,
769
924
  request ?? 0,
770
925
  client !== void 0,
@@ -807,18 +962,7 @@ var HTTPClient = class {
807
962
  * @ensures thrown.endpoint = endpoint (callers pass the path template, so no param values leak)
808
963
  */
809
964
  handleHttpError(status, data, endpoint) {
810
- const ctx = { service: this.serviceName, endpoint };
811
- const specific = STATUS_ERRORS[status];
812
- if (specific) {
813
- throw specific(data.message, ctx);
814
- }
815
- throw new AugurError({
816
- message: data.message ?? `Request failed with status ${status}`,
817
- code: data.code || "API_ERROR",
818
- statusCode: status,
819
- ...ctx,
820
- requestId: data.requestId
821
- });
965
+ throw statusError(status, data.message, { service: this.serviceName, endpoint }, data);
822
966
  }
823
967
  /**
824
968
  * Re-throw known error types or wrap as network error
@@ -834,7 +978,7 @@ var HTTPClient = class {
834
978
  }
835
979
  handleNetworkError(error, endpoint) {
836
980
  throw new AugurError({
837
- message: error.message || "Network error",
981
+ message: nonEmptyOr(error.message ?? "", "Network error"),
838
982
  code: "NETWORK_ERROR",
839
983
  statusCode: 0,
840
984
  service: this.serviceName,
@@ -851,7 +995,7 @@ var HTTPClient = class {
851
995
  if (!retryAfterCall(attempt, maxRetries, isRetryableError(error), call.signal?.aborted === true)) {
852
996
  throw error;
853
997
  }
854
- const backoffDelay = waitOf(
998
+ const backoffDelay = cutToRemaining(
855
999
  calculateBackoffDelay(attempt, baseDelay),
856
1000
  call.hasDeadline,
857
1001
  call.remaining()
@@ -914,17 +1058,14 @@ var HTTPClient = class {
914
1058
  return params;
915
1059
  }
916
1060
  const edgeCacheStr = String(edgeCache);
917
- const cacheHours = parseInt(edgeCacheStr, 10);
918
- const kind = edgeCacheKindOf(edgeCacheStr, cacheHours);
1061
+ const kind = edgeCacheKindOf(edgeCacheStr);
919
1062
  if (kind === "invalid") {
920
1063
  return withoutEdgeCache(paramsObj);
921
1064
  }
922
- const cacheSuffix = kind === "sub-hour" ? edgeCacheStr : String(cacheHours);
923
- const restParams = withoutEdgeCache(paramsObj);
924
- const cacheKey = `cacheSiteId${cacheSuffix}`;
1065
+ const cacheKey = edgeCacheKeyOf(kind, edgeCacheStr);
925
1066
  return {
926
- ...restParams,
927
- [cacheKey]: this.config.siteId
1067
+ ...withoutEdgeCache(paramsObj),
1068
+ [cacheKey]: this.siteId
928
1069
  };
929
1070
  }
930
1071
  async get(url, params, config) {
@@ -997,9 +1138,8 @@ var HTTPClient = class {
997
1138
  };
998
1139
 
999
1140
  // src/core/encoded-segment.ts
1000
- var PCHAR_RESTORE_RE = /%(?:24|26|2B|2C|3B|3D|3A|40)/g;
1001
1141
  function encodePathSegment(value) {
1002
- const encoded = encodeURIComponent(value).replace(PCHAR_RESTORE_RE, decodeURIComponent);
1142
+ const encoded = restorePcharFrom(encodeURIComponent(value), 0);
1003
1143
  if (!isEncoded(encoded)) {
1004
1144
  throw new InvalidArgumentError({
1005
1145
  message: "Encoded path segment has an unexpected shape",
@@ -1013,17 +1153,20 @@ function fillPlaceholder(path, placeholder, segment) {
1013
1153
  return placeholderFilled(path, placeholder, segment);
1014
1154
  }
1015
1155
  function renderPath(template, segments) {
1016
- return template.replace(/\{([^}]+)\}/g, (_, name) => {
1017
- const segment = segments[name];
1018
- if (segment === void 0) {
1019
- throw new InvalidArgumentError({
1020
- message: `No path value for {${name}}`,
1021
- service: "",
1022
- endpoint: template
1023
- });
1024
- }
1025
- return segment;
1026
- });
1156
+ const names = templateNames(template, 0);
1157
+ const missing = notInFrom(names, Object.keys(segments), 0);
1158
+ if (missing.length > 0) {
1159
+ throw new InvalidArgumentError({
1160
+ message: `No path value for {${missing[0]}}`,
1161
+ service: "",
1162
+ endpoint: template
1163
+ });
1164
+ }
1165
+ let path = template;
1166
+ for (const name of names) {
1167
+ path = fillPlaceholder(path, name, segments[name]);
1168
+ }
1169
+ return path;
1027
1170
  }
1028
1171
 
1029
1172
  // src/core/path-validation.ts
@@ -1040,6 +1183,17 @@ var validatePathSegment = (pathTemplate, name, value, pattern, service = "http-c
1040
1183
  }
1041
1184
  };
1042
1185
 
1186
+ // ../utils/src/slices.ts
1187
+ function beforeLastCode(s, code) {
1188
+ return s.slice(0, endBefore(lastIndexOfCode(s, code, s.length), s.length));
1189
+ }
1190
+ function withLastSegment(id, segment) {
1191
+ return beforeLastCode(id, 46) + "." + segment;
1192
+ }
1193
+ function endBefore(k, len) {
1194
+ return k >= 0 ? k : Math.max(len - 1, 0);
1195
+ }
1196
+
1043
1197
  // ../utils/src/case-spec.ts
1044
1198
  var UPPER = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
1045
1199
  function upperFirst(s) {
@@ -1061,6 +1215,13 @@ function foldName(s) {
1061
1215
  if (c === 45 || c === 95) return foldName(s.slice(1));
1062
1216
  return lowerAscii(s.slice(0, 1)) + foldName(s.slice(1));
1063
1217
  }
1218
+ function foldMatchesFrom(names, key, k) {
1219
+ if (k === names.length) return [];
1220
+ const name = names[k];
1221
+ const rest = foldMatchesFrom(names, key, k + 1);
1222
+ if (foldName(name) !== foldName(key)) return rest;
1223
+ return [name, ...rest];
1224
+ }
1064
1225
  function snakeCamel(s) {
1065
1226
  if (codeAt(s, 0) === 95) {
1066
1227
  const c = codeAt(s, 1);
@@ -1074,20 +1235,10 @@ function kebabCamel(s) {
1074
1235
  return kebabCamelFrom(s, false);
1075
1236
  }
1076
1237
 
1077
- // ../utils/src/slices.ts
1078
- function beforeLastCode(s, code) {
1079
- return s.slice(0, endBefore(lastIndexOfCode(s, code, s.length), s.length));
1080
- }
1081
- function endBefore(k, len) {
1082
- return k >= 0 ? k : Math.max(len - 1, 0);
1083
- }
1084
-
1085
- // ../utils/src/http.ts
1086
- function isPostOrPut(method) {
1087
- return method === "POST" || method === "PUT";
1088
- }
1089
-
1090
1238
  // src/core/registry-rules.ts
1239
+ function endpointIdOf(service, chain, action) {
1240
+ return kebabCamel(service) + "." + chain + "." + action;
1241
+ }
1091
1242
  function hasBodyFor(method) {
1092
1243
  return isPostOrPut(method);
1093
1244
  }
@@ -1111,6 +1262,14 @@ function syncedTotal(total, totalResults) {
1111
1262
  function syncedTotalResults(total, totalResults) {
1112
1263
  return totalResults === 0 ? Math.max(total, 0) : totalResults;
1113
1264
  }
1265
+ function countChanged(count, dataLength) {
1266
+ return normalCount(count, dataLength) !== count;
1267
+ }
1268
+ function totalsChangeOf(total, totalResults) {
1269
+ if (syncedTotal(total, totalResults) !== total) return "total";
1270
+ if (syncedTotalResults(total, totalResults) !== totalResults) return "totalResults";
1271
+ return "kept";
1272
+ }
1114
1273
  function warnsOnNormalization(hasEnv, env) {
1115
1274
  return hasEnv && env !== "production";
1116
1275
  }
@@ -1124,23 +1283,23 @@ var logNormalizationWarning = (message) => {
1124
1283
  }
1125
1284
  };
1126
1285
  var normalizeCount = (count, actualDataLength) => {
1127
- const normal = normalCount(count, actualDataLength);
1128
- if (normal !== count) {
1286
+ if (countChanged(count, actualDataLength)) {
1129
1287
  logNormalizationWarning(`'count' was 0 but data has ${actualDataLength} items`);
1130
1288
  }
1131
- return normal;
1289
+ return normalCount(count, actualDataLength);
1132
1290
  };
1133
1291
  var normalizeTotals = (total, totalResults) => {
1134
- const synced = {
1135
- total: syncedTotal(total, totalResults),
1136
- totalResults: syncedTotalResults(total, totalResults)
1137
- };
1138
- if (synced.total !== total) {
1292
+ const change = totalsChangeOf(total, totalResults);
1293
+ if (change === "total") {
1139
1294
  logNormalizationWarning(`'total' was 0 but 'totalResults' is ${totalResults}`);
1140
- } else if (synced.totalResults !== totalResults) {
1295
+ }
1296
+ if (change === "totalResults") {
1141
1297
  logNormalizationWarning(`'totalResults' was 0 but 'total' is ${total}`);
1142
1298
  }
1143
- return synced;
1299
+ return {
1300
+ total: syncedTotal(total, totalResults),
1301
+ totalResults: syncedTotalResults(total, totalResults)
1302
+ };
1144
1303
  };
1145
1304
  var BaseResponseSchema = (dataSchema) => v.pipe(
1146
1305
  v.looseObject({
@@ -5573,6 +5732,7 @@ var CartHdrAlsoBoughtListDataSchema = v9.array(
5573
5732
  })
5574
5733
  ),
5575
5734
  images: v9.array(v9.string()),
5735
+ videos: v9.array(v9.string()),
5576
5736
  stock: v9.looseObject({
5577
5737
  stockData: v9.array(
5578
5738
  v9.looseObject({
@@ -8966,7 +9126,11 @@ var ProductsListDataSchema = v11.array(
8966
9126
  dateLastBuilt: v11.nullable(v11.string()),
8967
9127
  checkoutLinkTemplate: v11.nullable(v11.string()),
8968
9128
  dateLastStatus: v11.nullable(v11.string()),
8969
- dateLastChanged: v11.nullable(v11.string())
9129
+ dateLastChanged: v11.nullable(v11.string()),
9130
+ imageWidth: v11.nullable(v11.number()),
9131
+ imageHeight: v11.nullable(v11.number()),
9132
+ additionalImageWidth: v11.nullable(v11.number()),
9133
+ additionalImageHeight: v11.nullable(v11.number())
8970
9134
  })
8971
9135
  );
8972
9136
  var ProductsGetDataSchema = v11.looseObject({
@@ -9017,7 +9181,11 @@ var ProductsGetDataSchema = v11.looseObject({
9017
9181
  dateLastBuilt: v11.nullable(v11.string()),
9018
9182
  checkoutLinkTemplate: v11.nullable(v11.string()),
9019
9183
  dateLastStatus: v11.nullable(v11.string()),
9020
- dateLastChanged: v11.nullable(v11.string())
9184
+ dateLastChanged: v11.nullable(v11.string()),
9185
+ imageWidth: v11.nullable(v11.number()),
9186
+ imageHeight: v11.nullable(v11.number()),
9187
+ additionalImageWidth: v11.nullable(v11.number()),
9188
+ additionalImageHeight: v11.nullable(v11.number())
9021
9189
  });
9022
9190
  var SitemapsItemsListDataSchema = v11.array(
9023
9191
  v11.looseObject({ id: v11.string(), link: v11.string(), lastModified: v11.nullable(v11.string()) })
@@ -9630,6 +9798,8 @@ var InvMastFaqListParamsSchema = v13.looseObject({
9630
9798
  });
9631
9799
  var InvMastInvAccessoryListParamsSchema = v13.looseObject({
9632
9800
  ...EdgeCacheParamsSchema.entries,
9801
+ classId5ExcludeList: v13.optional(v13.string()),
9802
+ classId5List: v13.optional(v13.string()),
9633
9803
  limit: v13.optional(v13.pipe(v13.unknown(), v13.transform(Number))),
9634
9804
  offset: v13.optional(v13.pipe(v13.unknown(), v13.transform(Number))),
9635
9805
  orderBy: v13.optional(v13.string()),
@@ -9666,6 +9836,11 @@ var InvMastPromotionalGroupsListParamsSchema = v13.looseObject({
9666
9836
  ])
9667
9837
  )
9668
9838
  });
9839
+ var InvMastSimilarListParamsSchema = v13.looseObject({
9840
+ ...EdgeCacheParamsSchema.entries,
9841
+ classId5ExcludeList: v13.optional(v13.string()),
9842
+ classId5List: v13.optional(v13.string())
9843
+ });
9669
9844
  var InvPeriodUsageListParamsSchema = v13.looseObject({
9670
9845
  ...EdgeCacheParamsSchema.entries,
9671
9846
  demandPeriodUid: v13.optional(v13.pipe(v13.unknown(), v13.transform(Number))),
@@ -11196,6 +11371,7 @@ var InvMastListDataSchema = v13.array(
11196
11371
  })
11197
11372
  ),
11198
11373
  images: v13.array(v13.string()),
11374
+ videos: v13.array(v13.string()),
11199
11375
  stock: v13.looseObject({
11200
11376
  stockData: v13.array(
11201
11377
  v13.looseObject({
@@ -11874,6 +12050,7 @@ var InvMastDocListDataSchema = v13.looseObject({
11874
12050
  })
11875
12051
  ),
11876
12052
  images: v13.array(v13.string()),
12053
+ videos: v13.array(v13.string()),
11877
12054
  stock: v13.looseObject({
11878
12055
  stockData: v13.array(
11879
12056
  v13.looseObject({
@@ -15384,11 +15561,13 @@ var endpoints12 = [
15384
15561
  aliases: [],
15385
15562
  pathParams: ["invMastUid"],
15386
15563
  pathPatterns: { invMastUid: "^\\d+$" },
15387
- queryParams: ["limit", "offset", "orderBy", "statusCd"],
15564
+ queryParams: ["classId5ExcludeList", "classId5List", "limit", "offset", "orderBy", "statusCd"],
15388
15565
  edgeCache: true,
15389
15566
  summary: "List accessory items",
15390
15567
  params: {
15391
15568
  invMastUid: { in: "path", type: "integer", required: true },
15569
+ classId5ExcludeList: { in: "query", type: "string", required: false },
15570
+ classId5List: { in: "query", type: "string", required: false },
15392
15571
  limit: { in: "query", type: "integer", required: false },
15393
15572
  offset: { in: "query", type: "integer", required: false },
15394
15573
  orderBy: { in: "query", type: "string", required: false },
@@ -15488,10 +15667,14 @@ var endpoints12 = [
15488
15667
  aliases: [],
15489
15668
  pathParams: ["invMastUid"],
15490
15669
  pathPatterns: { invMastUid: "^\\d+$" },
15491
- queryParams: [],
15670
+ queryParams: ["classId5ExcludeList", "classId5List"],
15492
15671
  edgeCache: true,
15493
15672
  summary: "List similar items",
15494
- params: { invMastUid: { in: "path", type: "integer", required: true } },
15673
+ params: {
15674
+ invMastUid: { in: "path", type: "integer", required: true },
15675
+ classId5ExcludeList: { in: "query", type: "string", required: false },
15676
+ classId5List: { in: "query", type: "string", required: false }
15677
+ },
15495
15678
  responseSchema: InvMastSimilarListDataSchema,
15496
15679
  responseType: "array"
15497
15680
  },
@@ -17051,12 +17234,14 @@ var ContentListParamsSchema = v14.looseObject({
17051
17234
  var ContentGetParamsSchema = v14.looseObject({
17052
17235
  ...EdgeCacheParamsSchema.entries,
17053
17236
  alias: v14.optional(v14.string()),
17054
- catid: v14.optional(v14.pipe(v14.unknown(), v14.transform(Number)))
17237
+ catid: v14.optional(v14.pipe(v14.unknown(), v14.transform(Number))),
17238
+ includeUnpublished: v14.optional(v14.string())
17055
17239
  });
17056
17240
  var ContentDocListParamsSchema = v14.looseObject({
17057
17241
  ...EdgeCacheParamsSchema.entries,
17058
17242
  alias: v14.optional(v14.string()),
17059
- catid: v14.optional(v14.pipe(v14.unknown(), v14.transform(Number)))
17243
+ catid: v14.optional(v14.pipe(v14.unknown(), v14.transform(Number))),
17244
+ includeUnpublished: v14.optional(v14.string())
17060
17245
  });
17061
17246
  var MenuListParamsSchema = v14.looseObject({
17062
17247
  ...EdgeCacheParamsSchema.entries,
@@ -17221,7 +17406,8 @@ var ContentListDataSchema = v14.array(
17221
17406
  images: v14.union([v14.record(v14.string(), v14.unknown()), v14.array(v14.unknown())]),
17222
17407
  fields: v14.array(
17223
17408
  v14.looseObject({ value: v14.string(), title: v14.string(), name: v14.string(), label: v14.string() })
17224
- )
17409
+ ),
17410
+ state: v14.number()
17225
17411
  })
17226
17412
  );
17227
17413
  var ContentGetDataSchema = v14.looseObject({
@@ -17230,7 +17416,8 @@ var ContentGetDataSchema = v14.looseObject({
17230
17416
  alias: v14.string(),
17231
17417
  introtext: v14.nullable(v14.string()),
17232
17418
  fulltext: v14.nullable(v14.string()),
17233
- catid: v14.number()
17419
+ catid: v14.number(),
17420
+ state: v14.number()
17234
17421
  });
17235
17422
  var ContentDocListDataSchema = v14.looseObject({
17236
17423
  id: v14.number(),
@@ -17243,7 +17430,8 @@ var ContentDocListDataSchema = v14.looseObject({
17243
17430
  images: v14.union([v14.record(v14.string(), v14.unknown()), v14.array(v14.unknown())]),
17244
17431
  fields: v14.array(
17245
17432
  v14.looseObject({ value: v14.string(), title: v14.string(), name: v14.string(), label: v14.string() })
17246
- )
17433
+ ),
17434
+ state: v14.number()
17247
17435
  });
17248
17436
  var MenuListDataSchema = v14.array(
17249
17437
  v14.looseObject({
@@ -17654,13 +17842,14 @@ var endpoints13 = [
17654
17842
  aliases: [],
17655
17843
  pathParams: ["id"],
17656
17844
  pathPatterns: { id: "^\\d+$" },
17657
- queryParams: ["alias", "catid"],
17845
+ queryParams: ["alias", "catid", "includeUnpublished"],
17658
17846
  edgeCache: true,
17659
17847
  summary: "Get Content Detail",
17660
17848
  params: {
17661
17849
  id: { in: "path", type: "integer", required: true },
17662
17850
  alias: { in: "query", type: "string", required: false },
17663
- catid: { in: "query", type: "integer", required: false }
17851
+ catid: { in: "query", type: "integer", required: false },
17852
+ includeUnpublished: { in: "query", type: "string", required: false }
17664
17853
  },
17665
17854
  responseSchema: ContentGetDataSchema,
17666
17855
  responseType: "object"
@@ -17673,13 +17862,14 @@ var endpoints13 = [
17673
17862
  aliases: ["get"],
17674
17863
  pathParams: ["id"],
17675
17864
  pathPatterns: { id: "^\\d+$" },
17676
- queryParams: ["alias", "catid"],
17865
+ queryParams: ["alias", "catid", "includeUnpublished"],
17677
17866
  edgeCache: true,
17678
17867
  summary: "Get Content Doc",
17679
17868
  params: {
17680
17869
  id: { in: "path", type: "integer", required: true },
17681
17870
  alias: { in: "query", type: "string", required: false },
17682
- catid: { in: "query", type: "integer", required: false }
17871
+ catid: { in: "query", type: "integer", required: false },
17872
+ includeUnpublished: { in: "query", type: "string", required: false }
17683
17873
  },
17684
17874
  responseSchema: ContentDocListDataSchema,
17685
17875
  responseType: "object"
@@ -18032,6 +18222,8 @@ var endpoints13 = [
18032
18222
  var v15 = __toESM(require("valibot"));
18033
18223
  var InvMastAlsoBoughtListParamsSchema = v15.looseObject({
18034
18224
  ...EdgeCacheParamsSchema.entries,
18225
+ classId5ExcludeList: v15.optional(v15.string()),
18226
+ classId5List: v15.optional(v15.string()),
18035
18227
  statusCd: v15.optional(
18036
18228
  v15.union([
18037
18229
  v15.array(v15.pipe(v15.unknown(), v15.transform(Number))),
@@ -18535,11 +18727,13 @@ var endpoints14 = [
18535
18727
  aliases: [],
18536
18728
  pathParams: ["invMastUid"],
18537
18729
  pathPatterns: { invMastUid: "^\\d+$" },
18538
- queryParams: ["statusCd"],
18730
+ queryParams: ["classId5ExcludeList", "classId5List", "statusCd"],
18539
18731
  edgeCache: true,
18540
18732
  summary: "List item Also Bought",
18541
18733
  params: {
18542
18734
  invMastUid: { in: "path", type: "integer", required: true },
18735
+ classId5ExcludeList: { in: "query", type: "string", required: false },
18736
+ classId5List: { in: "query", type: "string", required: false },
18543
18737
  statusCd: { in: "query", type: "integer|integer[]", required: false }
18544
18738
  },
18545
18739
  responseSchema: InvMastAlsoBoughtListDataSchema,
@@ -20325,6 +20519,7 @@ var ItemSearchListParamsSchema = v19.looseObject({
20325
20519
  jobNumbers: v19.optional(v19.string()),
20326
20520
  operator: v19.optional(v19.string()),
20327
20521
  parentCategoryUid: v19.optional(v19.pipe(v19.unknown(), v19.transform(Number))),
20522
+ productGroupIdList: v19.optional(v19.string()),
20328
20523
  q: v19.string(),
20329
20524
  searchType: v19.string(),
20330
20525
  size: v19.optional(v19.pipe(v19.unknown(), v19.transform(Number))),
@@ -20347,6 +20542,7 @@ var ItemSearchFacetsListParamsSchema = v19.looseObject({
20347
20542
  jobNumbers: v19.optional(v19.string()),
20348
20543
  operator: v19.optional(v19.string()),
20349
20544
  parentCategoryUid: v19.optional(v19.pipe(v19.unknown(), v19.transform(Number))),
20545
+ productGroupIdList: v19.optional(v19.string()),
20350
20546
  q: v19.string(),
20351
20547
  searchType: v19.optional(v19.string()),
20352
20548
  size: v19.optional(v19.pipe(v19.unknown(), v19.transform(Number))),
@@ -20662,6 +20858,7 @@ var endpoints18 = [
20662
20858
  "jobNumbers",
20663
20859
  "operator",
20664
20860
  "parentCategoryUid",
20861
+ "productGroupIdList",
20665
20862
  "q",
20666
20863
  "searchType",
20667
20864
  "size",
@@ -20685,6 +20882,7 @@ var endpoints18 = [
20685
20882
  jobNumbers: { in: "query", type: "string", required: false },
20686
20883
  operator: { in: "query", type: "string", required: false },
20687
20884
  parentCategoryUid: { in: "query", type: "integer", required: false },
20885
+ productGroupIdList: { in: "query", type: "string", required: false },
20688
20886
  q: { in: "query", type: "string", required: true },
20689
20887
  searchType: { in: "query", type: "string", required: true },
20690
20888
  size: { in: "query", type: "integer", required: false },
@@ -20717,6 +20915,7 @@ var endpoints18 = [
20717
20915
  "jobNumbers",
20718
20916
  "operator",
20719
20917
  "parentCategoryUid",
20918
+ "productGroupIdList",
20720
20919
  "q",
20721
20920
  "searchType",
20722
20921
  "size",
@@ -20740,6 +20939,7 @@ var endpoints18 = [
20740
20939
  jobNumbers: { in: "query", type: "string", required: false },
20741
20940
  operator: { in: "query", type: "string", required: false },
20742
20941
  parentCategoryUid: { in: "query", type: "integer", required: false },
20942
+ productGroupIdList: { in: "query", type: "string", required: false },
20743
20943
  q: { in: "query", type: "string", required: true },
20744
20944
  searchType: { in: "query", type: "string", required: false },
20745
20945
  size: { in: "query", type: "integer", required: false },
@@ -39806,9 +40006,9 @@ function frozenParams(params) {
39806
40006
  }
39807
40007
  function fromRow(service, row) {
39808
40008
  return Object.freeze({
39809
- // the id root is the generator's rule too (utils kebabCamel, the model's ServiceId), so an
39810
- // id is the same whichever side built it: open-search → openSearch
39811
- id: `${kebabCamel(service)}.${row.chain}.${row.action}`,
40009
+ // the generator's rule too (proved endpointIdOf, the model's EndpointId), so an id is the
40010
+ // same whichever side built it: open-search → openSearch
40011
+ id: endpointIdOf(service, row.chain, row.action),
39812
40012
  service,
39813
40013
  method: row.method,
39814
40014
  path: row.path,
@@ -39827,7 +40027,7 @@ function fromRow(service, row) {
39827
40027
  function baseEntries(service) {
39828
40028
  return BASE_ENDPOINTS.map(
39829
40029
  ([chain, path, auth, summary]) => Object.freeze({
39830
- id: `${kebabCamel(service)}.${chain}.get`,
40030
+ id: endpointIdOf(service, chain, "get"),
39831
40031
  service,
39832
40032
  method: "GET",
39833
40033
  path,
@@ -39861,9 +40061,8 @@ function buildIndex() {
39861
40061
  const map = /* @__PURE__ */ new Map();
39862
40062
  for (const entry of registryEntries()) {
39863
40063
  map.set(entry.id, entry);
39864
- const chain = beforeLastCode(entry.id, 46);
39865
40064
  for (const alias of entry.aliases) {
39866
- map.set(`${chain}.${alias}`, entry);
40065
+ map.set(withLastSegment(entry.id, alias), entry);
39867
40066
  }
39868
40067
  }
39869
40068
  return map;
@@ -39902,7 +40101,7 @@ function rejectUnknown(entry, kind, keys, allowed) {
39902
40101
  }
39903
40102
  function checkArgs(entry, args) {
39904
40103
  const pathKeys = Object.keys(args.pathParams ?? {});
39905
- const missing = entry.pathParams.filter((name) => !pathKeys.includes(name));
40104
+ const missing = notInFrom([...entry.pathParams], pathKeys, 0);
39906
40105
  if (missing.length > 0) {
39907
40106
  throw invalid(missingPathMessage(entry.id, joinFrom(missing, ", ", 0)), entry);
39908
40107
  }
@@ -39926,11 +40125,10 @@ function fillPath(entry, pathParams) {
39926
40125
  return renderPath(entry.path, segments);
39927
40126
  }
39928
40127
  function toEnvelope(body) {
39929
- if (typeof body !== "object" || body === null || Array.isArray(body)) {
39930
- return null;
39931
- }
39932
- const record32 = body;
39933
- if (!ENVELOPE_KEYS.every((key) => key in record32)) {
40128
+ const isPlainObject = typeof body === "object" && body !== null && !Array.isArray(body);
40129
+ const record32 = isPlainObject ? body : {};
40130
+ const present = ENVELOPE_KEYS.map((key) => key in record32);
40131
+ if (!isEnvelopeBody(isPlainObject, allFrom(present, 0))) {
39934
40132
  return null;
39935
40133
  }
39936
40134
  return Object.fromEntries(ENVELOPE_KEYS.map((key) => [key, record32[key]]));
@@ -39948,40 +40146,41 @@ async function callEndpoint(config, id, args = {}, bounds = NO_BOUNDS) {
39948
40146
  config: { endpoint: entry.path }
39949
40147
  });
39950
40148
  const parsed = parseJson(raw.text);
39951
- const body = parsed.json ? parsed.value : raw.text;
40149
+ const body = callBodyKind(parsed.json) === "json" ? parsed.value : raw.text;
39952
40150
  return { httpStatus: raw.status, envelope: toEnvelope(body), body };
39953
40151
  }
39954
40152
 
39955
- // ../auth-core/src/site.ts
39956
- function isSiteChar(c) {
39957
- return c >= 97 && c <= 122 || c >= 48 && c <= 57 || c === 95 || c === 45;
40153
+ // src/core/proxy-rules.ts
40154
+ function renamesWireParams(method) {
40155
+ return method === "GET";
39958
40156
  }
39959
- function siteCharsFrom(s, i) {
39960
- return i >= s.length || isSiteChar(s.charCodeAt(i)) && siteCharsFrom(s, i + 1);
40157
+ function defaultsEmptyBody(hasQueryParams, hasBody) {
40158
+ return !hasQueryParams && !hasBody;
39961
40159
  }
39962
- function isSiteId(s) {
39963
- return s.length > 0 && siteCharsFrom(s, 0);
40160
+ function dataProxyRoute(isFunction, isObject) {
40161
+ if (isFunction) return "unwrap";
40162
+ return isObject ? "nest" : "copy";
39964
40163
  }
39965
-
39966
- // src/core/site-id-check.ts
39967
- function isSiteId2(s) {
39968
- return isSiteId(s);
40164
+ function requestShapeOf(hasPathParams, hasQueryParams, hasBody) {
40165
+ if (hasPathParams) return "withPathParams";
40166
+ return hasQueryParams || hasBody ? "paramsOnly" : "noParams";
39969
40167
  }
39970
-
39971
- // src/core/site-id.ts
39972
- function parseSiteId(value) {
39973
- return isSiteId2(value) ? value : void 0;
40168
+ function copiesLegacyValue(camelGiven) {
40169
+ return !camelGiven;
39974
40170
  }
39975
- function assertSiteId(value) {
39976
- const site = parseSiteId(value);
39977
- if (site === void 0) {
39978
- throw new InvalidArgumentError({
39979
- message: "Invalid siteId: expected lowercase letters, digits, '_' and '-' (e.g. example-site)",
39980
- service: "",
39981
- endpoint: ""
39982
- });
39983
- }
39984
- return site;
40171
+ function pathParamTargets(path, key) {
40172
+ if (includesFrom(path, braced(key), 0)) return [key];
40173
+ return foldMatchesFrom(templateNames(path, 0), key, 0);
40174
+ }
40175
+ function bodySlot(method) {
40176
+ return method === "DELETE" ? -1 : 0;
40177
+ }
40178
+ function querySlot(method) {
40179
+ if (method === "POST" || method === "PUT") return 1;
40180
+ return method === "DELETE" ? 0 : -1;
40181
+ }
40182
+ function isLegacyAlias(changed, declared) {
40183
+ return changed && declared;
39985
40184
  }
39986
40185
 
39987
40186
  // src/core/common-schemas.ts
@@ -40116,16 +40315,15 @@ var BaseServiceClient = class {
40116
40315
  * describe the expected type, and `received` is not copied)
40117
40316
  */
40118
40317
  createValidationError(valibotError, config, errorType) {
40119
- const message = errorType === "params" ? "Invalid request parameters" : "Invalid API response structure\nThis appears to be a response validation error. The API returned data in an unexpected format.";
40120
40318
  return new ValidationError({
40121
- message,
40319
+ message: validationMessageOf(errorType),
40122
40320
  service: this.serviceName,
40123
40321
  endpoint: config.path,
40124
40322
  validationErrors: valibotError.issues.map((issue) => ({
40125
40323
  path: (issue.path ?? []).map((segment) => segment.key),
40126
40324
  message: issue.message,
40127
40325
  // Typed as always present, but issues built outside valibot can lack it
40128
- code: issue.type ?? "unknown"
40326
+ code: issueCodeOf(issue.type)
40129
40327
  }))
40130
40328
  });
40131
40329
  }
@@ -40153,45 +40351,28 @@ var BaseServiceClient = class {
40153
40351
  let path = pathTemplate;
40154
40352
  for (const [key, value] of Object.entries(pathParams)) {
40155
40353
  const stringValue = String(value);
40156
- if (includesFrom(path, braced(key), 0)) {
40157
- validatePathSegment(pathTemplate, key, stringValue, pathPatterns[key], this.serviceName);
40158
- path = fillPlaceholder(path, key, encodePathSegment(stringValue));
40159
- } else {
40160
- const folded = foldName(key);
40161
- for (const placeholder of new Set(templateNames(path, 0))) {
40162
- if (foldName(placeholder) === folded) {
40163
- validatePathSegment(
40164
- pathTemplate,
40165
- placeholder,
40166
- stringValue,
40167
- pathPatterns[placeholder],
40168
- this.serviceName
40169
- );
40170
- path = fillPlaceholder(path, placeholder, encodePathSegment(stringValue));
40171
- }
40172
- }
40354
+ for (const placeholder of pathParamTargets(path, key)) {
40355
+ validatePathSegment(
40356
+ pathTemplate,
40357
+ placeholder,
40358
+ stringValue,
40359
+ pathPatterns[placeholder],
40360
+ this.serviceName
40361
+ );
40362
+ path = fillPlaceholder(path, placeholder, encodePathSegment(stringValue));
40173
40363
  }
40174
40364
  }
40175
40365
  return path;
40176
40366
  }
40177
40367
  };
40178
40368
 
40179
- // src/core/service-proxy.ts
40180
- var v33 = __toESM(require("valibot"));
40181
-
40182
- // src/core/proxy-rules.ts
40183
- function bodySlot(method) {
40184
- return method === "DELETE" ? -1 : 0;
40185
- }
40186
- function querySlot(method) {
40187
- if (method === "POST" || method === "PUT") return 1;
40188
- return method === "DELETE" ? 0 : -1;
40189
- }
40190
- function isLegacyAlias(changed, declared) {
40191
- return changed && declared;
40369
+ // ../utils/src/distance.ts
40370
+ function min2(x, y) {
40371
+ return Math.min(x, y);
40192
40372
  }
40193
40373
 
40194
40374
  // src/core/service-proxy.ts
40375
+ var v33 = __toESM(require("valibot"));
40195
40376
  var PassthroughResponseSchema = v33.looseObject({
40196
40377
  count: v33.number(),
40197
40378
  data: v33.unknown(),
@@ -40236,16 +40417,12 @@ function createNodeObject(serviceName, executeRequest, node) {
40236
40417
  return obj;
40237
40418
  }
40238
40419
  function splitPathArgs(pathParams, args) {
40420
+ const taken = min2(pathParams.length, args.length);
40239
40421
  const pathParamMap = {};
40240
- let index2 = 0;
40241
- for (const name of pathParams) {
40242
- if (index2 >= args.length) {
40243
- break;
40244
- }
40245
- pathParamMap[name] = String(args[index2]);
40246
- index2++;
40422
+ for (let index2 = 0; index2 < taken; index2++) {
40423
+ pathParamMap[pathParams[index2]] = String(args[index2]);
40247
40424
  }
40248
- return { pathParamMap, rest: args.slice(index2) };
40425
+ return { pathParamMap, rest: args.slice(taken) };
40249
40426
  }
40250
40427
  function splitBodyAndQuery(method, rest) {
40251
40428
  const at = (slot) => rest[slot];
@@ -40266,7 +40443,7 @@ function normaliseLegacyParamCase(params, declared) {
40266
40443
  }
40267
40444
  renamed = true;
40268
40445
  delete out[key];
40269
- if (!(camel in source)) {
40446
+ if (copiesLegacyValue(camel in source)) {
40270
40447
  out[camel] = value;
40271
40448
  }
40272
40449
  }
@@ -40283,7 +40460,7 @@ function createActionFunction(_serviceName, executeRequest, endpoint) {
40283
40460
  hasQueryParams ? trailing : void 0,
40284
40461
  endpoint.queryParams
40285
40462
  );
40286
- const wireParams = (value) => method === "GET" ? normaliseLegacyParamCase(value, endpoint.queryParams) : value;
40463
+ const wireParams = (value) => renamesWireParams(method) ? normaliseLegacyParamCase(value, endpoint.queryParams) : value;
40287
40464
  const config = {
40288
40465
  method,
40289
40466
  path,
@@ -40291,11 +40468,17 @@ function createActionFunction(_serviceName, executeRequest, endpoint) {
40291
40468
  ...hasQueryParams ? { paramsSchema: PassthroughParamsSchema } : {},
40292
40469
  responseSchema: PassthroughResponseSchema
40293
40470
  };
40294
- if (Object.keys(pathParamMap).length > 0) {
40295
- const params = wireParams(hasQueryParams ? body : body ?? {});
40471
+ const shape = requestShapeOf(
40472
+ Object.keys(pathParamMap).length > 0,
40473
+ hasQueryParams,
40474
+ body !== void 0
40475
+ );
40476
+ if (shape === "withPathParams") {
40477
+ const hasBody = body !== void 0 && body !== null;
40478
+ const params = wireParams(defaultsEmptyBody(hasQueryParams, hasBody) ? {} : body);
40296
40479
  return query === void 0 ? executeRequest(config, params, pathParamMap) : executeRequest(config, params, pathParamMap, query);
40297
40480
  }
40298
- if (hasQueryParams || body !== void 0) {
40481
+ if (shape === "paramsOnly") {
40299
40482
  return query === void 0 ? executeRequest(config, wireParams(body)) : executeRequest(config, wireParams(body), void 0, query);
40300
40483
  }
40301
40484
  return executeRequest(config);
@@ -40306,14 +40489,18 @@ function createDataProxy(resource) {
40306
40489
  const src = resource;
40307
40490
  for (const key of Object.keys(src)) {
40308
40491
  const value = src[key];
40309
- if (typeof value === "function") {
40492
+ const route = dataProxyRoute(
40493
+ typeof value === "function",
40494
+ typeof value === "object" && value !== null
40495
+ );
40496
+ if (route === "unwrap") {
40310
40497
  const propKey = key;
40311
40498
  obj[key] = async (...args) => {
40312
40499
  const fn = src[propKey];
40313
40500
  const response = await fn(...args);
40314
40501
  return response?.data;
40315
40502
  };
40316
- } else if (value && typeof value === "object") {
40503
+ } else if (route === "nest") {
40317
40504
  obj[key] = createDataProxy(value);
40318
40505
  } else {
40319
40506
  obj[key] = value;
@@ -42532,6 +42719,11 @@ var AugurAPI = class _AugurAPI {
42532
42719
  }
42533
42720
  };
42534
42721
 
42722
+ // ../foundation/src/pos-int.ts
42723
+ function posIntOf(n) {
42724
+ return Math.floor(n) === n && n >= 1 && n <= 9007199254740991 ? n : null;
42725
+ }
42726
+
42535
42727
  // src/utils/cross-site-auth.ts
42536
42728
  async function authenticateUserForSite(params) {
42537
42729
  const { targetSiteId, username, password, augurInfoToken } = params;
@@ -42546,23 +42738,35 @@ async function authenticateUserForSite(params) {
42546
42738
  siteId: targetSiteId
42547
42739
  // This tells the API to authenticate against the target site
42548
42740
  });
42549
- if (!data.isVerified) {
42741
+ const token = data.token;
42742
+ const tokenIsText = typeof token === "string";
42743
+ const outcome = crossSiteOutcomeOf(
42744
+ Boolean(data.isVerified),
42745
+ tokenIsText,
42746
+ tokenIsText ? token : ""
42747
+ );
42748
+ if (outcome === "notVerified") {
42550
42749
  return { success: false, targetSiteId, error: "Invalid username or password" };
42551
42750
  }
42552
- if (typeof data.token !== "string" || data.token === "") {
42751
+ if (outcome === "noToken") {
42553
42752
  return { success: false, targetSiteId, error: "Password verified, but no token was issued" };
42554
42753
  }
42754
+ const bearer = token;
42755
+ const rawId = data.id;
42756
+ const userId = posIntOf(typeof rawId === "number" ? rawId : Number.NaN);
42555
42757
  const targetSiteAPI = new AugurAPI({
42556
42758
  siteId: targetSiteId,
42557
- bearerToken: data.token
42759
+ bearerToken: bearer
42558
42760
  });
42559
42761
  return {
42560
42762
  success: true,
42561
- // `data` is typed, not validated at runtime: a missing id stays undefined, never "undefined"
42562
- userId: typeof data.id === "number" ? String(data.id) : void 0,
42763
+ // `data` is typed, not validated at runtime. A user id is an integer at least 1: it enters
42764
+ // as a PosInt (foundation's posIntOf; not a number reads as NaN, which it refuses) and the
42765
+ // proved crossSiteUserIdOf writes it, so 0, -1, 1.5 or a missing id report no id
42766
+ userId: crossSiteUserIdOf(userId !== null, userId ?? 0),
42563
42767
  username: data.username,
42564
42768
  email: data.email,
42565
- token: data.token,
42769
+ token: bearer,
42566
42770
  targetSiteId,
42567
42771
  targetSiteAPI
42568
42772
  };
@@ -42586,7 +42790,7 @@ function createCrossSiteAuthenticator(augurInfoToken) {
42586
42790
  }
42587
42791
 
42588
42792
  // src/index.ts
42589
- var VERSION = "2026.11.4";
42793
+ var VERSION = "2026.11.6";
42590
42794
  // Annotate the CommonJS export names for ESM import in node:
42591
42795
  0 && (module.exports = {
42592
42796
  AgrInfoClient,