@simpleapps-com/augur-api 2026.11.4 → 2026.11.5

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 (59) 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 +434 -233
  25. package/dist/index.js.map +1 -1
  26. package/dist/index.mjs +434 -233
  27. package/dist/index.mjs.map +1 -1
  28. package/dist/services/goog-mc/generated/schemas.d.ts +8 -0
  29. package/dist/services/goog-mc/generated/schemas.d.ts.map +1 -1
  30. package/dist/services/goog-mc/generated/types.d.ts +8 -0
  31. package/dist/services/goog-mc/generated/types.d.ts.map +1 -1
  32. package/dist/services/items/client.d.ts +1 -1
  33. package/dist/services/items/generated/endpoints.d.ts.map +1 -1
  34. package/dist/services/items/generated/schemas.d.ts +8 -0
  35. package/dist/services/items/generated/schemas.d.ts.map +1 -1
  36. package/dist/services/items/generated/types.d.ts +13 -4
  37. package/dist/services/items/generated/types.d.ts.map +1 -1
  38. package/dist/services/joomla/generated/endpoints.d.ts.map +1 -1
  39. package/dist/services/joomla/generated/schemas.d.ts +5 -0
  40. package/dist/services/joomla/generated/schemas.d.ts.map +1 -1
  41. package/dist/services/joomla/generated/types.d.ts +18 -2
  42. package/dist/services/joomla/generated/types.d.ts.map +1 -1
  43. package/dist/services/legacy/generated/endpoints.d.ts.map +1 -1
  44. package/dist/services/legacy/generated/schemas.d.ts +2 -0
  45. package/dist/services/legacy/generated/schemas.d.ts.map +1 -1
  46. package/dist/services/legacy/generated/types.d.ts +4 -0
  47. package/dist/services/legacy/generated/types.d.ts.map +1 -1
  48. package/dist/services/open-search/generated/endpoints.d.ts.map +1 -1
  49. package/dist/services/open-search/generated/schemas.d.ts +2 -0
  50. package/dist/services/open-search/generated/schemas.d.ts.map +1 -1
  51. package/dist/services/open-search/generated/types.d.ts +4 -0
  52. package/dist/services/open-search/generated/types.d.ts.map +1 -1
  53. package/dist/testing.d.ts.map +1 -1
  54. package/dist/testing.js +22 -9
  55. package/dist/testing.js.map +1 -1
  56. package/dist/testing.mjs +20 -9
  57. package/dist/testing.mjs.map +1 -1
  58. package/dist/utils/cross-site-auth.d.ts.map +1 -1
  59. 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({
@@ -8966,7 +9125,11 @@ var ProductsListDataSchema = v11.array(
8966
9125
  dateLastBuilt: v11.nullable(v11.string()),
8967
9126
  checkoutLinkTemplate: v11.nullable(v11.string()),
8968
9127
  dateLastStatus: v11.nullable(v11.string()),
8969
- dateLastChanged: v11.nullable(v11.string())
9128
+ dateLastChanged: v11.nullable(v11.string()),
9129
+ imageWidth: v11.nullable(v11.number()),
9130
+ imageHeight: v11.nullable(v11.number()),
9131
+ additionalImageWidth: v11.nullable(v11.number()),
9132
+ additionalImageHeight: v11.nullable(v11.number())
8970
9133
  })
8971
9134
  );
8972
9135
  var ProductsGetDataSchema = v11.looseObject({
@@ -9017,7 +9180,11 @@ var ProductsGetDataSchema = v11.looseObject({
9017
9180
  dateLastBuilt: v11.nullable(v11.string()),
9018
9181
  checkoutLinkTemplate: v11.nullable(v11.string()),
9019
9182
  dateLastStatus: v11.nullable(v11.string()),
9020
- dateLastChanged: v11.nullable(v11.string())
9183
+ dateLastChanged: v11.nullable(v11.string()),
9184
+ imageWidth: v11.nullable(v11.number()),
9185
+ imageHeight: v11.nullable(v11.number()),
9186
+ additionalImageWidth: v11.nullable(v11.number()),
9187
+ additionalImageHeight: v11.nullable(v11.number())
9021
9188
  });
9022
9189
  var SitemapsItemsListDataSchema = v11.array(
9023
9190
  v11.looseObject({ id: v11.string(), link: v11.string(), lastModified: v11.nullable(v11.string()) })
@@ -9630,6 +9797,8 @@ var InvMastFaqListParamsSchema = v13.looseObject({
9630
9797
  });
9631
9798
  var InvMastInvAccessoryListParamsSchema = v13.looseObject({
9632
9799
  ...EdgeCacheParamsSchema.entries,
9800
+ classId5ExcludeList: v13.optional(v13.string()),
9801
+ classId5List: v13.optional(v13.string()),
9633
9802
  limit: v13.optional(v13.pipe(v13.unknown(), v13.transform(Number))),
9634
9803
  offset: v13.optional(v13.pipe(v13.unknown(), v13.transform(Number))),
9635
9804
  orderBy: v13.optional(v13.string()),
@@ -9666,6 +9835,11 @@ var InvMastPromotionalGroupsListParamsSchema = v13.looseObject({
9666
9835
  ])
9667
9836
  )
9668
9837
  });
9838
+ var InvMastSimilarListParamsSchema = v13.looseObject({
9839
+ ...EdgeCacheParamsSchema.entries,
9840
+ classId5ExcludeList: v13.optional(v13.string()),
9841
+ classId5List: v13.optional(v13.string())
9842
+ });
9669
9843
  var InvPeriodUsageListParamsSchema = v13.looseObject({
9670
9844
  ...EdgeCacheParamsSchema.entries,
9671
9845
  demandPeriodUid: v13.optional(v13.pipe(v13.unknown(), v13.transform(Number))),
@@ -15384,11 +15558,13 @@ var endpoints12 = [
15384
15558
  aliases: [],
15385
15559
  pathParams: ["invMastUid"],
15386
15560
  pathPatterns: { invMastUid: "^\\d+$" },
15387
- queryParams: ["limit", "offset", "orderBy", "statusCd"],
15561
+ queryParams: ["classId5ExcludeList", "classId5List", "limit", "offset", "orderBy", "statusCd"],
15388
15562
  edgeCache: true,
15389
15563
  summary: "List accessory items",
15390
15564
  params: {
15391
15565
  invMastUid: { in: "path", type: "integer", required: true },
15566
+ classId5ExcludeList: { in: "query", type: "string", required: false },
15567
+ classId5List: { in: "query", type: "string", required: false },
15392
15568
  limit: { in: "query", type: "integer", required: false },
15393
15569
  offset: { in: "query", type: "integer", required: false },
15394
15570
  orderBy: { in: "query", type: "string", required: false },
@@ -15488,10 +15664,14 @@ var endpoints12 = [
15488
15664
  aliases: [],
15489
15665
  pathParams: ["invMastUid"],
15490
15666
  pathPatterns: { invMastUid: "^\\d+$" },
15491
- queryParams: [],
15667
+ queryParams: ["classId5ExcludeList", "classId5List"],
15492
15668
  edgeCache: true,
15493
15669
  summary: "List similar items",
15494
- params: { invMastUid: { in: "path", type: "integer", required: true } },
15670
+ params: {
15671
+ invMastUid: { in: "path", type: "integer", required: true },
15672
+ classId5ExcludeList: { in: "query", type: "string", required: false },
15673
+ classId5List: { in: "query", type: "string", required: false }
15674
+ },
15495
15675
  responseSchema: InvMastSimilarListDataSchema,
15496
15676
  responseType: "array"
15497
15677
  },
@@ -17051,12 +17231,14 @@ var ContentListParamsSchema = v14.looseObject({
17051
17231
  var ContentGetParamsSchema = v14.looseObject({
17052
17232
  ...EdgeCacheParamsSchema.entries,
17053
17233
  alias: v14.optional(v14.string()),
17054
- catid: v14.optional(v14.pipe(v14.unknown(), v14.transform(Number)))
17234
+ catid: v14.optional(v14.pipe(v14.unknown(), v14.transform(Number))),
17235
+ includeUnpublished: v14.optional(v14.string())
17055
17236
  });
17056
17237
  var ContentDocListParamsSchema = v14.looseObject({
17057
17238
  ...EdgeCacheParamsSchema.entries,
17058
17239
  alias: v14.optional(v14.string()),
17059
- catid: v14.optional(v14.pipe(v14.unknown(), v14.transform(Number)))
17240
+ catid: v14.optional(v14.pipe(v14.unknown(), v14.transform(Number))),
17241
+ includeUnpublished: v14.optional(v14.string())
17060
17242
  });
17061
17243
  var MenuListParamsSchema = v14.looseObject({
17062
17244
  ...EdgeCacheParamsSchema.entries,
@@ -17221,7 +17403,8 @@ var ContentListDataSchema = v14.array(
17221
17403
  images: v14.union([v14.record(v14.string(), v14.unknown()), v14.array(v14.unknown())]),
17222
17404
  fields: v14.array(
17223
17405
  v14.looseObject({ value: v14.string(), title: v14.string(), name: v14.string(), label: v14.string() })
17224
- )
17406
+ ),
17407
+ state: v14.number()
17225
17408
  })
17226
17409
  );
17227
17410
  var ContentGetDataSchema = v14.looseObject({
@@ -17230,7 +17413,8 @@ var ContentGetDataSchema = v14.looseObject({
17230
17413
  alias: v14.string(),
17231
17414
  introtext: v14.nullable(v14.string()),
17232
17415
  fulltext: v14.nullable(v14.string()),
17233
- catid: v14.number()
17416
+ catid: v14.number(),
17417
+ state: v14.number()
17234
17418
  });
17235
17419
  var ContentDocListDataSchema = v14.looseObject({
17236
17420
  id: v14.number(),
@@ -17243,7 +17427,8 @@ var ContentDocListDataSchema = v14.looseObject({
17243
17427
  images: v14.union([v14.record(v14.string(), v14.unknown()), v14.array(v14.unknown())]),
17244
17428
  fields: v14.array(
17245
17429
  v14.looseObject({ value: v14.string(), title: v14.string(), name: v14.string(), label: v14.string() })
17246
- )
17430
+ ),
17431
+ state: v14.number()
17247
17432
  });
17248
17433
  var MenuListDataSchema = v14.array(
17249
17434
  v14.looseObject({
@@ -17654,13 +17839,14 @@ var endpoints13 = [
17654
17839
  aliases: [],
17655
17840
  pathParams: ["id"],
17656
17841
  pathPatterns: { id: "^\\d+$" },
17657
- queryParams: ["alias", "catid"],
17842
+ queryParams: ["alias", "catid", "includeUnpublished"],
17658
17843
  edgeCache: true,
17659
17844
  summary: "Get Content Detail",
17660
17845
  params: {
17661
17846
  id: { in: "path", type: "integer", required: true },
17662
17847
  alias: { in: "query", type: "string", required: false },
17663
- catid: { in: "query", type: "integer", required: false }
17848
+ catid: { in: "query", type: "integer", required: false },
17849
+ includeUnpublished: { in: "query", type: "string", required: false }
17664
17850
  },
17665
17851
  responseSchema: ContentGetDataSchema,
17666
17852
  responseType: "object"
@@ -17673,13 +17859,14 @@ var endpoints13 = [
17673
17859
  aliases: ["get"],
17674
17860
  pathParams: ["id"],
17675
17861
  pathPatterns: { id: "^\\d+$" },
17676
- queryParams: ["alias", "catid"],
17862
+ queryParams: ["alias", "catid", "includeUnpublished"],
17677
17863
  edgeCache: true,
17678
17864
  summary: "Get Content Doc",
17679
17865
  params: {
17680
17866
  id: { in: "path", type: "integer", required: true },
17681
17867
  alias: { in: "query", type: "string", required: false },
17682
- catid: { in: "query", type: "integer", required: false }
17868
+ catid: { in: "query", type: "integer", required: false },
17869
+ includeUnpublished: { in: "query", type: "string", required: false }
17683
17870
  },
17684
17871
  responseSchema: ContentDocListDataSchema,
17685
17872
  responseType: "object"
@@ -18032,6 +18219,8 @@ var endpoints13 = [
18032
18219
  var v15 = __toESM(require("valibot"));
18033
18220
  var InvMastAlsoBoughtListParamsSchema = v15.looseObject({
18034
18221
  ...EdgeCacheParamsSchema.entries,
18222
+ classId5ExcludeList: v15.optional(v15.string()),
18223
+ classId5List: v15.optional(v15.string()),
18035
18224
  statusCd: v15.optional(
18036
18225
  v15.union([
18037
18226
  v15.array(v15.pipe(v15.unknown(), v15.transform(Number))),
@@ -18535,11 +18724,13 @@ var endpoints14 = [
18535
18724
  aliases: [],
18536
18725
  pathParams: ["invMastUid"],
18537
18726
  pathPatterns: { invMastUid: "^\\d+$" },
18538
- queryParams: ["statusCd"],
18727
+ queryParams: ["classId5ExcludeList", "classId5List", "statusCd"],
18539
18728
  edgeCache: true,
18540
18729
  summary: "List item Also Bought",
18541
18730
  params: {
18542
18731
  invMastUid: { in: "path", type: "integer", required: true },
18732
+ classId5ExcludeList: { in: "query", type: "string", required: false },
18733
+ classId5List: { in: "query", type: "string", required: false },
18543
18734
  statusCd: { in: "query", type: "integer|integer[]", required: false }
18544
18735
  },
18545
18736
  responseSchema: InvMastAlsoBoughtListDataSchema,
@@ -20325,6 +20516,7 @@ var ItemSearchListParamsSchema = v19.looseObject({
20325
20516
  jobNumbers: v19.optional(v19.string()),
20326
20517
  operator: v19.optional(v19.string()),
20327
20518
  parentCategoryUid: v19.optional(v19.pipe(v19.unknown(), v19.transform(Number))),
20519
+ productGroupIdList: v19.optional(v19.string()),
20328
20520
  q: v19.string(),
20329
20521
  searchType: v19.string(),
20330
20522
  size: v19.optional(v19.pipe(v19.unknown(), v19.transform(Number))),
@@ -20347,6 +20539,7 @@ var ItemSearchFacetsListParamsSchema = v19.looseObject({
20347
20539
  jobNumbers: v19.optional(v19.string()),
20348
20540
  operator: v19.optional(v19.string()),
20349
20541
  parentCategoryUid: v19.optional(v19.pipe(v19.unknown(), v19.transform(Number))),
20542
+ productGroupIdList: v19.optional(v19.string()),
20350
20543
  q: v19.string(),
20351
20544
  searchType: v19.optional(v19.string()),
20352
20545
  size: v19.optional(v19.pipe(v19.unknown(), v19.transform(Number))),
@@ -20662,6 +20855,7 @@ var endpoints18 = [
20662
20855
  "jobNumbers",
20663
20856
  "operator",
20664
20857
  "parentCategoryUid",
20858
+ "productGroupIdList",
20665
20859
  "q",
20666
20860
  "searchType",
20667
20861
  "size",
@@ -20685,6 +20879,7 @@ var endpoints18 = [
20685
20879
  jobNumbers: { in: "query", type: "string", required: false },
20686
20880
  operator: { in: "query", type: "string", required: false },
20687
20881
  parentCategoryUid: { in: "query", type: "integer", required: false },
20882
+ productGroupIdList: { in: "query", type: "string", required: false },
20688
20883
  q: { in: "query", type: "string", required: true },
20689
20884
  searchType: { in: "query", type: "string", required: true },
20690
20885
  size: { in: "query", type: "integer", required: false },
@@ -20717,6 +20912,7 @@ var endpoints18 = [
20717
20912
  "jobNumbers",
20718
20913
  "operator",
20719
20914
  "parentCategoryUid",
20915
+ "productGroupIdList",
20720
20916
  "q",
20721
20917
  "searchType",
20722
20918
  "size",
@@ -20740,6 +20936,7 @@ var endpoints18 = [
20740
20936
  jobNumbers: { in: "query", type: "string", required: false },
20741
20937
  operator: { in: "query", type: "string", required: false },
20742
20938
  parentCategoryUid: { in: "query", type: "integer", required: false },
20939
+ productGroupIdList: { in: "query", type: "string", required: false },
20743
20940
  q: { in: "query", type: "string", required: true },
20744
20941
  searchType: { in: "query", type: "string", required: false },
20745
20942
  size: { in: "query", type: "integer", required: false },
@@ -39806,9 +40003,9 @@ function frozenParams(params) {
39806
40003
  }
39807
40004
  function fromRow(service, row) {
39808
40005
  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}`,
40006
+ // the generator's rule too (proved endpointIdOf, the model's EndpointId), so an id is the
40007
+ // same whichever side built it: open-search → openSearch
40008
+ id: endpointIdOf(service, row.chain, row.action),
39812
40009
  service,
39813
40010
  method: row.method,
39814
40011
  path: row.path,
@@ -39827,7 +40024,7 @@ function fromRow(service, row) {
39827
40024
  function baseEntries(service) {
39828
40025
  return BASE_ENDPOINTS.map(
39829
40026
  ([chain, path, auth, summary]) => Object.freeze({
39830
- id: `${kebabCamel(service)}.${chain}.get`,
40027
+ id: endpointIdOf(service, chain, "get"),
39831
40028
  service,
39832
40029
  method: "GET",
39833
40030
  path,
@@ -39861,9 +40058,8 @@ function buildIndex() {
39861
40058
  const map = /* @__PURE__ */ new Map();
39862
40059
  for (const entry of registryEntries()) {
39863
40060
  map.set(entry.id, entry);
39864
- const chain = beforeLastCode(entry.id, 46);
39865
40061
  for (const alias of entry.aliases) {
39866
- map.set(`${chain}.${alias}`, entry);
40062
+ map.set(withLastSegment(entry.id, alias), entry);
39867
40063
  }
39868
40064
  }
39869
40065
  return map;
@@ -39902,7 +40098,7 @@ function rejectUnknown(entry, kind, keys, allowed) {
39902
40098
  }
39903
40099
  function checkArgs(entry, args) {
39904
40100
  const pathKeys = Object.keys(args.pathParams ?? {});
39905
- const missing = entry.pathParams.filter((name) => !pathKeys.includes(name));
40101
+ const missing = notInFrom([...entry.pathParams], pathKeys, 0);
39906
40102
  if (missing.length > 0) {
39907
40103
  throw invalid(missingPathMessage(entry.id, joinFrom(missing, ", ", 0)), entry);
39908
40104
  }
@@ -39926,11 +40122,10 @@ function fillPath(entry, pathParams) {
39926
40122
  return renderPath(entry.path, segments);
39927
40123
  }
39928
40124
  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)) {
40125
+ const isPlainObject = typeof body === "object" && body !== null && !Array.isArray(body);
40126
+ const record32 = isPlainObject ? body : {};
40127
+ const present = ENVELOPE_KEYS.map((key) => key in record32);
40128
+ if (!isEnvelopeBody(isPlainObject, allFrom(present, 0))) {
39934
40129
  return null;
39935
40130
  }
39936
40131
  return Object.fromEntries(ENVELOPE_KEYS.map((key) => [key, record32[key]]));
@@ -39948,40 +40143,41 @@ async function callEndpoint(config, id, args = {}, bounds = NO_BOUNDS) {
39948
40143
  config: { endpoint: entry.path }
39949
40144
  });
39950
40145
  const parsed = parseJson(raw.text);
39951
- const body = parsed.json ? parsed.value : raw.text;
40146
+ const body = callBodyKind(parsed.json) === "json" ? parsed.value : raw.text;
39952
40147
  return { httpStatus: raw.status, envelope: toEnvelope(body), body };
39953
40148
  }
39954
40149
 
39955
- // ../auth-core/src/site.ts
39956
- function isSiteChar(c) {
39957
- return c >= 97 && c <= 122 || c >= 48 && c <= 57 || c === 95 || c === 45;
40150
+ // src/core/proxy-rules.ts
40151
+ function renamesWireParams(method) {
40152
+ return method === "GET";
39958
40153
  }
39959
- function siteCharsFrom(s, i) {
39960
- return i >= s.length || isSiteChar(s.charCodeAt(i)) && siteCharsFrom(s, i + 1);
40154
+ function defaultsEmptyBody(hasQueryParams, hasBody) {
40155
+ return !hasQueryParams && !hasBody;
39961
40156
  }
39962
- function isSiteId(s) {
39963
- return s.length > 0 && siteCharsFrom(s, 0);
40157
+ function dataProxyRoute(isFunction, isObject) {
40158
+ if (isFunction) return "unwrap";
40159
+ return isObject ? "nest" : "copy";
39964
40160
  }
39965
-
39966
- // src/core/site-id-check.ts
39967
- function isSiteId2(s) {
39968
- return isSiteId(s);
40161
+ function requestShapeOf(hasPathParams, hasQueryParams, hasBody) {
40162
+ if (hasPathParams) return "withPathParams";
40163
+ return hasQueryParams || hasBody ? "paramsOnly" : "noParams";
39969
40164
  }
39970
-
39971
- // src/core/site-id.ts
39972
- function parseSiteId(value) {
39973
- return isSiteId2(value) ? value : void 0;
40165
+ function copiesLegacyValue(camelGiven) {
40166
+ return !camelGiven;
39974
40167
  }
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;
40168
+ function pathParamTargets(path, key) {
40169
+ if (includesFrom(path, braced(key), 0)) return [key];
40170
+ return foldMatchesFrom(templateNames(path, 0), key, 0);
40171
+ }
40172
+ function bodySlot(method) {
40173
+ return method === "DELETE" ? -1 : 0;
40174
+ }
40175
+ function querySlot(method) {
40176
+ if (method === "POST" || method === "PUT") return 1;
40177
+ return method === "DELETE" ? 0 : -1;
40178
+ }
40179
+ function isLegacyAlias(changed, declared) {
40180
+ return changed && declared;
39985
40181
  }
39986
40182
 
39987
40183
  // src/core/common-schemas.ts
@@ -40116,16 +40312,15 @@ var BaseServiceClient = class {
40116
40312
  * describe the expected type, and `received` is not copied)
40117
40313
  */
40118
40314
  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
40315
  return new ValidationError({
40121
- message,
40316
+ message: validationMessageOf(errorType),
40122
40317
  service: this.serviceName,
40123
40318
  endpoint: config.path,
40124
40319
  validationErrors: valibotError.issues.map((issue) => ({
40125
40320
  path: (issue.path ?? []).map((segment) => segment.key),
40126
40321
  message: issue.message,
40127
40322
  // Typed as always present, but issues built outside valibot can lack it
40128
- code: issue.type ?? "unknown"
40323
+ code: issueCodeOf(issue.type)
40129
40324
  }))
40130
40325
  });
40131
40326
  }
@@ -40153,45 +40348,28 @@ var BaseServiceClient = class {
40153
40348
  let path = pathTemplate;
40154
40349
  for (const [key, value] of Object.entries(pathParams)) {
40155
40350
  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
- }
40351
+ for (const placeholder of pathParamTargets(path, key)) {
40352
+ validatePathSegment(
40353
+ pathTemplate,
40354
+ placeholder,
40355
+ stringValue,
40356
+ pathPatterns[placeholder],
40357
+ this.serviceName
40358
+ );
40359
+ path = fillPlaceholder(path, placeholder, encodePathSegment(stringValue));
40173
40360
  }
40174
40361
  }
40175
40362
  return path;
40176
40363
  }
40177
40364
  };
40178
40365
 
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;
40366
+ // ../utils/src/distance.ts
40367
+ function min2(x, y) {
40368
+ return Math.min(x, y);
40192
40369
  }
40193
40370
 
40194
40371
  // src/core/service-proxy.ts
40372
+ var v33 = __toESM(require("valibot"));
40195
40373
  var PassthroughResponseSchema = v33.looseObject({
40196
40374
  count: v33.number(),
40197
40375
  data: v33.unknown(),
@@ -40236,16 +40414,12 @@ function createNodeObject(serviceName, executeRequest, node) {
40236
40414
  return obj;
40237
40415
  }
40238
40416
  function splitPathArgs(pathParams, args) {
40417
+ const taken = min2(pathParams.length, args.length);
40239
40418
  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++;
40419
+ for (let index2 = 0; index2 < taken; index2++) {
40420
+ pathParamMap[pathParams[index2]] = String(args[index2]);
40247
40421
  }
40248
- return { pathParamMap, rest: args.slice(index2) };
40422
+ return { pathParamMap, rest: args.slice(taken) };
40249
40423
  }
40250
40424
  function splitBodyAndQuery(method, rest) {
40251
40425
  const at = (slot) => rest[slot];
@@ -40266,7 +40440,7 @@ function normaliseLegacyParamCase(params, declared) {
40266
40440
  }
40267
40441
  renamed = true;
40268
40442
  delete out[key];
40269
- if (!(camel in source)) {
40443
+ if (copiesLegacyValue(camel in source)) {
40270
40444
  out[camel] = value;
40271
40445
  }
40272
40446
  }
@@ -40283,7 +40457,7 @@ function createActionFunction(_serviceName, executeRequest, endpoint) {
40283
40457
  hasQueryParams ? trailing : void 0,
40284
40458
  endpoint.queryParams
40285
40459
  );
40286
- const wireParams = (value) => method === "GET" ? normaliseLegacyParamCase(value, endpoint.queryParams) : value;
40460
+ const wireParams = (value) => renamesWireParams(method) ? normaliseLegacyParamCase(value, endpoint.queryParams) : value;
40287
40461
  const config = {
40288
40462
  method,
40289
40463
  path,
@@ -40291,11 +40465,17 @@ function createActionFunction(_serviceName, executeRequest, endpoint) {
40291
40465
  ...hasQueryParams ? { paramsSchema: PassthroughParamsSchema } : {},
40292
40466
  responseSchema: PassthroughResponseSchema
40293
40467
  };
40294
- if (Object.keys(pathParamMap).length > 0) {
40295
- const params = wireParams(hasQueryParams ? body : body ?? {});
40468
+ const shape = requestShapeOf(
40469
+ Object.keys(pathParamMap).length > 0,
40470
+ hasQueryParams,
40471
+ body !== void 0
40472
+ );
40473
+ if (shape === "withPathParams") {
40474
+ const hasBody = body !== void 0 && body !== null;
40475
+ const params = wireParams(defaultsEmptyBody(hasQueryParams, hasBody) ? {} : body);
40296
40476
  return query === void 0 ? executeRequest(config, params, pathParamMap) : executeRequest(config, params, pathParamMap, query);
40297
40477
  }
40298
- if (hasQueryParams || body !== void 0) {
40478
+ if (shape === "paramsOnly") {
40299
40479
  return query === void 0 ? executeRequest(config, wireParams(body)) : executeRequest(config, wireParams(body), void 0, query);
40300
40480
  }
40301
40481
  return executeRequest(config);
@@ -40306,14 +40486,18 @@ function createDataProxy(resource) {
40306
40486
  const src = resource;
40307
40487
  for (const key of Object.keys(src)) {
40308
40488
  const value = src[key];
40309
- if (typeof value === "function") {
40489
+ const route = dataProxyRoute(
40490
+ typeof value === "function",
40491
+ typeof value === "object" && value !== null
40492
+ );
40493
+ if (route === "unwrap") {
40310
40494
  const propKey = key;
40311
40495
  obj[key] = async (...args) => {
40312
40496
  const fn = src[propKey];
40313
40497
  const response = await fn(...args);
40314
40498
  return response?.data;
40315
40499
  };
40316
- } else if (value && typeof value === "object") {
40500
+ } else if (route === "nest") {
40317
40501
  obj[key] = createDataProxy(value);
40318
40502
  } else {
40319
40503
  obj[key] = value;
@@ -42532,6 +42716,11 @@ var AugurAPI = class _AugurAPI {
42532
42716
  }
42533
42717
  };
42534
42718
 
42719
+ // ../foundation/src/pos-int.ts
42720
+ function posIntOf(n) {
42721
+ return Math.floor(n) === n && n >= 1 && n <= 9007199254740991 ? n : null;
42722
+ }
42723
+
42535
42724
  // src/utils/cross-site-auth.ts
42536
42725
  async function authenticateUserForSite(params) {
42537
42726
  const { targetSiteId, username, password, augurInfoToken } = params;
@@ -42546,23 +42735,35 @@ async function authenticateUserForSite(params) {
42546
42735
  siteId: targetSiteId
42547
42736
  // This tells the API to authenticate against the target site
42548
42737
  });
42549
- if (!data.isVerified) {
42738
+ const token = data.token;
42739
+ const tokenIsText = typeof token === "string";
42740
+ const outcome = crossSiteOutcomeOf(
42741
+ Boolean(data.isVerified),
42742
+ tokenIsText,
42743
+ tokenIsText ? token : ""
42744
+ );
42745
+ if (outcome === "notVerified") {
42550
42746
  return { success: false, targetSiteId, error: "Invalid username or password" };
42551
42747
  }
42552
- if (typeof data.token !== "string" || data.token === "") {
42748
+ if (outcome === "noToken") {
42553
42749
  return { success: false, targetSiteId, error: "Password verified, but no token was issued" };
42554
42750
  }
42751
+ const bearer = token;
42752
+ const rawId = data.id;
42753
+ const userId = posIntOf(typeof rawId === "number" ? rawId : Number.NaN);
42555
42754
  const targetSiteAPI = new AugurAPI({
42556
42755
  siteId: targetSiteId,
42557
- bearerToken: data.token
42756
+ bearerToken: bearer
42558
42757
  });
42559
42758
  return {
42560
42759
  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,
42760
+ // `data` is typed, not validated at runtime. A user id is an integer at least 1: it enters
42761
+ // as a PosInt (foundation's posIntOf; not a number reads as NaN, which it refuses) and the
42762
+ // proved crossSiteUserIdOf writes it, so 0, -1, 1.5 or a missing id report no id
42763
+ userId: crossSiteUserIdOf(userId !== null, userId ?? 0),
42563
42764
  username: data.username,
42564
42765
  email: data.email,
42565
- token: data.token,
42766
+ token: bearer,
42566
42767
  targetSiteId,
42567
42768
  targetSiteAPI
42568
42769
  };
@@ -42586,7 +42787,7 @@ function createCrossSiteAuthenticator(augurInfoToken) {
42586
42787
  }
42587
42788
 
42588
42789
  // src/index.ts
42589
- var VERSION = "2026.11.4";
42790
+ var VERSION = "2026.11.5";
42590
42791
  // Annotate the CommonJS export names for ESM import in node:
42591
42792
  0 && (module.exports = {
42592
42793
  AgrInfoClient,