@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.mjs CHANGED
@@ -57,6 +57,9 @@ function joinFrom(xs, sep, i) {
57
57
  if (i >= xs.length) return "";
58
58
  return joinRange(xs, sep, i, xs.length);
59
59
  }
60
+ function joinOr(xs, sep, fallback) {
61
+ return xs.length === 0 ? fallback : joinFrom(xs, sep, 0);
62
+ }
60
63
  function joinRange(xs, sep, lo, hi) {
61
64
  if (hi - lo === 1) return xs[lo];
62
65
  const mid = lo + Math.floor((hi - lo) / 2);
@@ -73,6 +76,13 @@ function notInFrom(xs, allowed, i) {
73
76
  return hasItemFrom(allowed, xs[i], 0) ? rest : [xs[i], ...rest];
74
77
  }
75
78
 
79
+ // ../utils/src/pairs.ts
80
+ function allFrom(xs, i) {
81
+ if (i === xs.length) return true;
82
+ if (!xs[i]) return false;
83
+ return allFrom(xs, i + 1);
84
+ }
85
+
76
86
  // ../utils/src/uri.ts
77
87
  function isHigh(c) {
78
88
  return c >= 55296 && c <= 56319;
@@ -121,6 +131,25 @@ function isEncoded(s) {
121
131
  }
122
132
  return true;
123
133
  }
134
+ function pcharOf(hex) {
135
+ if (hex === "24") return "$";
136
+ if (hex === "26") return "&";
137
+ if (hex === "2B") return "+";
138
+ if (hex === "2C") return ",";
139
+ if (hex === "3B") return ";";
140
+ if (hex === "3D") return "=";
141
+ if (hex === "3A") return ":";
142
+ if (hex === "40") return "@";
143
+ return "";
144
+ }
145
+ function restorePcharFrom(s, i) {
146
+ if (i >= s.length) return "";
147
+ if (s.slice(i, i + 1) === "%" && i + 3 <= s.length) {
148
+ const ch = pcharOf(s.slice(i + 1, i + 3));
149
+ if (ch !== "") return ch + restorePcharFrom(s, i + 3);
150
+ }
151
+ return s.slice(i, i + 1) + restorePcharFrom(s, i + 1);
152
+ }
124
153
 
125
154
  // ../utils/src/replace.ts
126
155
  function replaceText(s, find, put) {
@@ -132,6 +161,21 @@ function replaceText(s, find, put) {
132
161
  }
133
162
 
134
163
  // src/core/call-rules.ts
164
+ function isEnvelopeBody(isPlainObject, allKeys) {
165
+ return isPlainObject && allKeys;
166
+ }
167
+ function callBodyKind(isJson) {
168
+ return isJson ? "json" : "text";
169
+ }
170
+ function validationMessageOf(kind) {
171
+ 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.";
172
+ }
173
+ function issueCodeOf(type) {
174
+ return type !== void 0 ? type : "unknown";
175
+ }
176
+ function appendsIssues(count) {
177
+ return count > 0;
178
+ }
135
179
  function isQueryKeyAllowed(declared, edgeCache, key) {
136
180
  return declared || edgeCache && key === "edgeCache";
137
181
  }
@@ -194,12 +238,35 @@ var ContextCreationError = class extends Error {
194
238
  field;
195
239
  };
196
240
 
241
+ // ../foundation/src/optional.ts
242
+ function nonEmptyOr(s, fallback) {
243
+ return s !== "" ? s : fallback;
244
+ }
245
+
246
+ // ../foundation/src/decimal.ts
247
+ function decimal(n) {
248
+ const last = "0123456789".slice(n % 10, n % 10 + 1);
249
+ return n < 10 ? last : decimal(Math.floor(n / 10)) + last;
250
+ }
251
+
197
252
  // ../json-values/src/index.ts
198
253
  function isRecord(value) {
199
254
  return typeof value === "object" && value !== null && !Array.isArray(value);
200
255
  }
201
256
 
202
- // src/core/http-rules.ts
257
+ // ../utils/src/http.ts
258
+ function isPostOrPut(method) {
259
+ return method === "POST" || method === "PUT";
260
+ }
261
+ function querySeparator(url) {
262
+ return includesFrom(url, "?", 0) ? "&" : "?";
263
+ }
264
+ function queryValueSent(isUndefined, isNull) {
265
+ return !isUndefined && !isNull;
266
+ }
267
+ function urlWithQuery(url, query) {
268
+ return query === "" ? url : url + querySeparator(url) + query;
269
+ }
203
270
  function isRetryableStatus(status) {
204
271
  return !(status >= 400 && status < 500 && status !== 429);
205
272
  }
@@ -207,30 +274,24 @@ function exponentialDelay(base, attempt) {
207
274
  if (attempt === 0) return base;
208
275
  return 2 * exponentialDelay(base, attempt - 1);
209
276
  }
210
- function cappedDelay(d) {
211
- return Math.min(d, 3e4);
212
- }
213
- function timeoutOf(hasRequest, request, hasClient, client, fallback) {
214
- if (hasRequest) return request;
215
- return hasClient ? client : fallback;
216
- }
217
- function isPublicEndpoint(url) {
218
- return endsWith(url, "/health-check") || endsWith(url, "/ping");
277
+ function cappedAt(d, cap) {
278
+ return Math.min(d, cap);
219
279
  }
220
- function sendsBearer(url, hasToken) {
221
- return hasToken && !isPublicEndpoint(url);
280
+ function firstGiven(hasA, a, hasB, b, fallback) {
281
+ if (hasA) return a;
282
+ return hasB ? b : fallback;
222
283
  }
223
- function sendsJsonBody(hasData, method) {
224
- return hasData && method !== "GET";
284
+ function isAbortName(name) {
285
+ return name === "AbortError" || name === "TimeoutError";
225
286
  }
226
- function querySeparator(url) {
227
- return includesFrom(url, "?", 0) ? "&" : "?";
287
+ function remainingOf(deadline, elapsed) {
288
+ return elapsed < deadline ? deadline - elapsed : 0;
228
289
  }
229
- function requestKey(method, url, params) {
230
- return method + ":" + url + ":" + params;
290
+ function cutToRemaining(value, hasDeadline, remaining) {
291
+ return hasDeadline && remaining < value ? remaining : value;
231
292
  }
232
- function isEdgeCacheParam(key) {
233
- return key === "edgeCache";
293
+ function startsAttempt(hasDeadline, remaining) {
294
+ return !hasDeadline || remaining > 0;
234
295
  }
235
296
 
236
297
  // src/core/client-rules.ts
@@ -246,18 +307,6 @@ function retryableError(isAugurError, status) {
246
307
  function retryAfterCall(attempt, retries, retryable, callAborted) {
247
308
  return !callAborted && attempt < retries && retryable;
248
309
  }
249
- function isAbortName(name) {
250
- return name === "AbortError" || name === "TimeoutError";
251
- }
252
- function remainingOf(deadline, elapsed) {
253
- return elapsed < deadline ? deadline - elapsed : 0;
254
- }
255
- function attemptTimeoutOf(perAttempt, hasDeadline, remaining) {
256
- return hasDeadline && remaining < perAttempt ? remaining : perAttempt;
257
- }
258
- function waitOf(backoff, hasDeadline, remaining) {
259
- return hasDeadline && remaining < backoff ? remaining : backoff;
260
- }
261
310
  function needsAttemptTimer(perAttempt, hasDeadline, remaining) {
262
311
  return !(hasDeadline && remaining <= perAttempt);
263
312
  }
@@ -281,19 +330,53 @@ function mergedDeadlineOf(hasOuter, outer, hasInner, inner) {
281
330
  function hasMergedDeadline(hasOuter, hasInner) {
282
331
  return hasOuter || hasInner;
283
332
  }
284
- function edgeCacheKindOf(text, hours) {
333
+ function edgeCacheKindOf(text) {
285
334
  if (text === "30s" || text === "1m" || text === "5m") return "sub-hour";
286
- const hourly = hours === 1 || hours === 2 || hours === 3 || hours === 4 || hours === 5 || hours === 8;
335
+ const hourly = text === "1" || text === "2" || text === "3" || text === "4" || text === "5" || text === "8";
287
336
  return hourly ? "hourly" : "invalid";
288
337
  }
338
+ function edgeCacheKeyOf(kind, text) {
339
+ return kind === "invalid" ? "" : "cacheSiteId" + text;
340
+ }
341
+ function errorClassOf(status) {
342
+ if (status === 400) return "validation";
343
+ if (status === 401) return "authentication";
344
+ if (status === 404) return "notFound";
345
+ if (status === 429) return "rateLimit";
346
+ return "augur";
347
+ }
348
+ function detailMessageOf(isJson, isObject, isText, message) {
349
+ if (isJson && isObject && isText && message !== "") return message;
350
+ return void 0;
351
+ }
352
+ function defaultMessageOf(kind, status) {
353
+ if (kind === "validation") return "Validation failed";
354
+ if (kind === "authentication") return "Authentication failed";
355
+ if (kind === "notFound") return "Resource not found";
356
+ if (kind === "rateLimit") return "Rate limit exceeded";
357
+ return "Request failed with status " + decimal(status);
358
+ }
359
+ function errorMessageOf(given, kind, status) {
360
+ return given !== void 0 ? given : defaultMessageOf(kind, status);
361
+ }
362
+ function crossSiteUserIdOf(isId, id) {
363
+ return isId ? decimal(id) : void 0;
364
+ }
365
+ function responseHookOf(ok, hasOnError, hasOnResponse) {
366
+ if (ok) return hasOnResponse ? "onResponse" : "noHook";
367
+ return hasOnError ? "onError" : "noHook";
368
+ }
369
+ function crossSiteOutcomeOf(isVerified, tokenIsText, token) {
370
+ if (!isVerified) return "notVerified";
371
+ if (!tokenIsText || token === "") return "noToken";
372
+ return "signedIn";
373
+ }
289
374
  function rawRetries(method) {
290
375
  return method === "GET";
291
376
  }
292
- function startsAttempt(hasDeadline, remaining) {
293
- return !hasDeadline || remaining > 0;
294
- }
295
377
 
296
378
  // src/core/errors.ts
379
+ var ROOT_PATH = "root";
297
380
  var AugurError = class _AugurError extends Error {
298
381
  code;
299
382
  statusCode;
@@ -332,8 +415,7 @@ var ValidationError = class extends AugurError {
332
415
  return [];
333
416
  }
334
417
  return this.validationErrors.map((error) => {
335
- const path = error.path.length > 0 ? error.path.join(".") : "root";
336
- return `${path}: ${error.message}`;
418
+ return `${joinOr(error.path.map(String), ".", ROOT_PATH)}: ${error.message}`;
337
419
  });
338
420
  }
339
421
  /**
@@ -345,7 +427,7 @@ var ValidationError = class extends AugurError {
345
427
  return [];
346
428
  }
347
429
  return this.validationErrors.map((error) => ({
348
- path: error.path.length > 0 ? error.path.join(".") : "root",
430
+ path: joinOr(error.path.map(String), ".", ROOT_PATH),
349
431
  message: error.message,
350
432
  code: error.code,
351
433
  received: "received" in error ? error.received : void 0,
@@ -359,7 +441,7 @@ var ValidationError = class extends AugurError {
359
441
  toString() {
360
442
  const baseMessage = super.toString();
361
443
  const formattedErrors = this.getFormattedErrors();
362
- if (formattedErrors.length > 0) {
444
+ if (appendsIssues(formattedErrors.length)) {
363
445
  return `${baseMessage}
364
446
  Validation errors:
365
447
  ${formattedErrors.map((err) => ` - ${err}`).join("\n")}`;
@@ -404,7 +486,57 @@ var InvalidArgumentError = class extends AugurError {
404
486
  }
405
487
  };
406
488
 
489
+ // ../auth-core/src/site.ts
490
+ function isSiteChar(c) {
491
+ return c >= 97 && c <= 122 || c >= 48 && c <= 57 || c === 95 || c === 45;
492
+ }
493
+ function siteCharsFrom(s, i) {
494
+ return i >= s.length || isSiteChar(s.charCodeAt(i)) && siteCharsFrom(s, i + 1);
495
+ }
496
+ function isSiteId(s) {
497
+ return s.length > 0 && siteCharsFrom(s, 0);
498
+ }
499
+
500
+ // src/core/site-id-check.ts
501
+ function isSiteId2(s) {
502
+ return isSiteId(s);
503
+ }
504
+
505
+ // src/core/site-id.ts
506
+ function parseSiteId(value) {
507
+ return isSiteId2(value) ? value : void 0;
508
+ }
509
+ function assertSiteId(value) {
510
+ const site = parseSiteId(value);
511
+ if (site === void 0) {
512
+ throw new InvalidArgumentError({
513
+ message: "Invalid siteId: expected lowercase letters, digits, '_' and '-' (e.g. example-site)",
514
+ service: "",
515
+ endpoint: ""
516
+ });
517
+ }
518
+ return site;
519
+ }
520
+
521
+ // src/core/http-rules.ts
522
+ function isPublicEndpoint(url) {
523
+ return endsWith(url, "/health-check") || endsWith(url, "/ping");
524
+ }
525
+ function sendsBearer(url, hasToken) {
526
+ return hasToken && !isPublicEndpoint(url);
527
+ }
528
+ function sendsJsonBody(hasData, method) {
529
+ return hasData && method !== "GET";
530
+ }
531
+ function requestKey(method, url, params) {
532
+ return method + ":" + url + ":" + params;
533
+ }
534
+ function isEdgeCacheParam(key) {
535
+ return key === "edgeCache";
536
+ }
537
+
407
538
  // src/core/client.ts
539
+ var MAX_RETRY_DELAY_MS = 3e4;
408
540
  function parseJson(text) {
409
541
  try {
410
542
  return { json: true, value: JSON.parse(String(text)) };
@@ -418,16 +550,29 @@ function errorDetail(text) {
418
550
  return { detail: {} };
419
551
  }
420
552
  const body = parsed.value;
421
- const detail = typeof body === "object" && body !== null ? body : {};
422
- const message = typeof detail.message === "string" && detail.message !== "" ? detail.message : void 0;
553
+ const isObject = typeof body === "object" && body !== null;
554
+ const detail = isObject ? body : {};
555
+ const given = detail.message;
556
+ const isText = typeof given === "string";
557
+ const message = detailMessageOf(true, isObject, isText, isText ? given : "");
423
558
  return { detail, message };
424
559
  }
425
- var STATUS_ERRORS = {
426
- 400: (message, ctx) => new ValidationError({ message: message ?? "Validation failed", ...ctx, validationErrors: [] }),
427
- 401: (message, ctx) => new AuthenticationError({ message: message ?? "Authentication failed", ...ctx }),
428
- 404: (message, ctx) => new NotFoundError({ message: message ?? "Resource not found", ...ctx }),
429
- 429: (message, ctx) => new RateLimitError({ message: message ?? "Rate limit exceeded", ...ctx })
430
- };
560
+ function statusError(status, message, ctx, detail) {
561
+ const kind = errorClassOf(status);
562
+ const text = errorMessageOf(message, kind, status);
563
+ if (kind === "validation")
564
+ return new ValidationError({ message: text, ...ctx, validationErrors: [] });
565
+ if (kind === "authentication") return new AuthenticationError({ message: text, ...ctx });
566
+ if (kind === "notFound") return new NotFoundError({ message: text, ...ctx });
567
+ if (kind === "rateLimit") return new RateLimitError({ message: text, ...ctx });
568
+ return new AugurError({
569
+ message: text,
570
+ code: nonEmptyOr(detail.code ?? "", "API_ERROR"),
571
+ statusCode: status,
572
+ ...ctx,
573
+ requestId: detail.requestId
574
+ });
575
+ }
431
576
  function generateRequestKey(method, url, params) {
432
577
  const paramsStr = params ? JSON.stringify(params, Object.keys(params).sort()) : "";
433
578
  return requestKey(method, url, paramsStr);
@@ -435,7 +580,7 @@ function generateRequestKey(method, url, params) {
435
580
  function calculateBackoffDelay(attempt, baseDelay) {
436
581
  const exponential = exponentialDelay(baseDelay, attempt);
437
582
  const jitter = Math.random() * 0.3 * exponential;
438
- return cappedDelay(exponential + jitter);
583
+ return cappedAt(exponential + jitter, MAX_RETRY_DELAY_MS);
439
584
  }
440
585
  function isRetryableError(error) {
441
586
  const isAugurError = error instanceof AugurError;
@@ -513,15 +658,11 @@ function buildUrlWithParams(url, params) {
513
658
  const searchParams = new URLSearchParams();
514
659
  const paramsObj = params;
515
660
  for (const [key, value] of Object.entries(paramsObj)) {
516
- if (value !== void 0 && value !== null) {
661
+ if (queryValueSent(value === void 0, value === null)) {
517
662
  searchParams.append(key, String(value));
518
663
  }
519
664
  }
520
- const queryString = searchParams.toString();
521
- if (!queryString) {
522
- return url;
523
- }
524
- return `${url}${querySeparator(url)}${queryString}`;
665
+ return urlWithQuery(url, searchParams.toString());
525
666
  }
526
667
  function headersToRecord(headers) {
527
668
  const record32 = {};
@@ -535,10 +676,21 @@ var HTTPClient = class {
535
676
  serviceName;
536
677
  inflightRequests = /* @__PURE__ */ new Map();
537
678
  bounds;
538
- /** `bounds` bound every call this client makes (a view's, from `AugurAPI.withRequest`). */
679
+ /**
680
+ * The siteId this client sends (`x-site-id`, and the value of every `cacheSiteId` edge
681
+ * directive): a `SiteId`, so only a proved `isSiteId` string reaches the header or Cloudflare's
682
+ * cache key (AugurApiClient.EdgeDirectiveCarriesASiteId; owner 2026-11-10).
683
+ */
684
+ siteId;
685
+ /**
686
+ * `bounds` bound every call this client makes (a view's, from `AugurAPI.withRequest`).
687
+ *
688
+ * @throws InvalidArgumentError when `config.siteId` is not a siteId (as `AugurAPI` does)
689
+ */
539
690
  constructor(serviceName, config, bounds = NO_BOUNDS) {
540
691
  this.serviceName = serviceName;
541
692
  this.config = { ...DEFAULT_CONFIG, ...config };
693
+ this.siteId = assertSiteId(this.config.siteId);
542
694
  this.bounds = bounds;
543
695
  }
544
696
  /**
@@ -549,7 +701,7 @@ var HTTPClient = class {
549
701
  const headers = {
550
702
  "Content-Type": "application/json",
551
703
  ...requestConfig?.headers,
552
- "x-site-id": this.config.siteId
704
+ "x-site-id": this.siteId
553
705
  };
554
706
  if (sendsBearer(url, Boolean(this.config.bearerToken))) {
555
707
  headers["Authorization"] = `Bearer ${this.config.bearerToken}`;
@@ -566,9 +718,10 @@ var HTTPClient = class {
566
718
  } catch {
567
719
  }
568
720
  const { detail, message } = errorDetail(text);
569
- if (this.config.onError) {
721
+ const { onError, onResponse } = this.config;
722
+ if (responseHookOf(response.ok, onError !== void 0, onResponse !== void 0) === "onError") {
570
723
  const augurError = {
571
- message: message ?? `Request failed with status ${response.status}`,
724
+ message: errorMessageOf(message, "augur", response.status),
572
725
  config: augurConfig,
573
726
  response: {
574
727
  data: detail,
@@ -578,7 +731,7 @@ var HTTPClient = class {
578
731
  config: augurConfig
579
732
  }
580
733
  };
581
- await this.config.onError(augurError);
734
+ await onError(augurError);
582
735
  }
583
736
  this.handleHttpError(response.status, { ...detail, message }, endpoint);
584
737
  }
@@ -594,8 +747,9 @@ var HTTPClient = class {
594
747
  headers: headersToRecord(response.headers),
595
748
  config: augurConfig
596
749
  };
597
- if (this.config.onResponse) {
598
- const modified = await this.config.onResponse(augurResponse);
750
+ const { onError, onResponse } = this.config;
751
+ if (responseHookOf(response.ok, onError !== void 0, onResponse !== void 0) === "onResponse") {
752
+ const modified = await onResponse(augurResponse);
599
753
  return modified.data;
600
754
  }
601
755
  return responseData;
@@ -605,8 +759,9 @@ var HTTPClient = class {
605
759
  */
606
760
  async readRaw(response, augurConfig) {
607
761
  let text = await response.text();
608
- if (this.config.onResponse) {
609
- const modified = await this.config.onResponse({
762
+ const { onError, onResponse } = this.config;
763
+ if (responseHookOf(response.ok, onError !== void 0, onResponse !== void 0) === "onResponse") {
764
+ const modified = await onResponse({
610
765
  data: text,
611
766
  status: response.status,
612
767
  statusText: response.statusText,
@@ -659,7 +814,7 @@ var HTTPClient = class {
659
814
  const perAttempt = this.timeoutFor(requestConfig);
660
815
  const remaining = call.remaining();
661
816
  return {
662
- timeout: attemptTimeoutOf(perAttempt, call.hasDeadline, remaining),
817
+ timeout: cutToRemaining(perAttempt, call.hasDeadline, remaining),
663
818
  ownTimer: needsAttemptTimer(perAttempt, call.hasDeadline, remaining)
664
819
  };
665
820
  }
@@ -677,11 +832,11 @@ var HTTPClient = class {
677
832
  }
678
833
  };
679
834
  }
680
- /** The request's timeout: per request, else the client's, else the default (timeoutOf). */
835
+ /** The request's timeout: per request, else the client's, else the default (firstGiven). */
681
836
  timeoutFor(requestConfig) {
682
837
  const request = requestConfig?.timeout;
683
838
  const client = this.config.timeout;
684
- return timeoutOf(
839
+ return firstGiven(
685
840
  request !== void 0,
686
841
  request ?? 0,
687
842
  client !== void 0,
@@ -724,18 +879,7 @@ var HTTPClient = class {
724
879
  * @ensures thrown.endpoint = endpoint (callers pass the path template, so no param values leak)
725
880
  */
726
881
  handleHttpError(status, data, endpoint) {
727
- const ctx = { service: this.serviceName, endpoint };
728
- const specific = STATUS_ERRORS[status];
729
- if (specific) {
730
- throw specific(data.message, ctx);
731
- }
732
- throw new AugurError({
733
- message: data.message ?? `Request failed with status ${status}`,
734
- code: data.code || "API_ERROR",
735
- statusCode: status,
736
- ...ctx,
737
- requestId: data.requestId
738
- });
882
+ throw statusError(status, data.message, { service: this.serviceName, endpoint }, data);
739
883
  }
740
884
  /**
741
885
  * Re-throw known error types or wrap as network error
@@ -751,7 +895,7 @@ var HTTPClient = class {
751
895
  }
752
896
  handleNetworkError(error, endpoint) {
753
897
  throw new AugurError({
754
- message: error.message || "Network error",
898
+ message: nonEmptyOr(error.message ?? "", "Network error"),
755
899
  code: "NETWORK_ERROR",
756
900
  statusCode: 0,
757
901
  service: this.serviceName,
@@ -768,7 +912,7 @@ var HTTPClient = class {
768
912
  if (!retryAfterCall(attempt, maxRetries, isRetryableError(error), call.signal?.aborted === true)) {
769
913
  throw error;
770
914
  }
771
- const backoffDelay = waitOf(
915
+ const backoffDelay = cutToRemaining(
772
916
  calculateBackoffDelay(attempt, baseDelay),
773
917
  call.hasDeadline,
774
918
  call.remaining()
@@ -831,17 +975,14 @@ var HTTPClient = class {
831
975
  return params;
832
976
  }
833
977
  const edgeCacheStr = String(edgeCache);
834
- const cacheHours = parseInt(edgeCacheStr, 10);
835
- const kind = edgeCacheKindOf(edgeCacheStr, cacheHours);
978
+ const kind = edgeCacheKindOf(edgeCacheStr);
836
979
  if (kind === "invalid") {
837
980
  return withoutEdgeCache(paramsObj);
838
981
  }
839
- const cacheSuffix = kind === "sub-hour" ? edgeCacheStr : String(cacheHours);
840
- const restParams = withoutEdgeCache(paramsObj);
841
- const cacheKey = `cacheSiteId${cacheSuffix}`;
982
+ const cacheKey = edgeCacheKeyOf(kind, edgeCacheStr);
842
983
  return {
843
- ...restParams,
844
- [cacheKey]: this.config.siteId
984
+ ...withoutEdgeCache(paramsObj),
985
+ [cacheKey]: this.siteId
845
986
  };
846
987
  }
847
988
  async get(url, params, config) {
@@ -914,9 +1055,8 @@ var HTTPClient = class {
914
1055
  };
915
1056
 
916
1057
  // src/core/encoded-segment.ts
917
- var PCHAR_RESTORE_RE = /%(?:24|26|2B|2C|3B|3D|3A|40)/g;
918
1058
  function encodePathSegment(value) {
919
- const encoded = encodeURIComponent(value).replace(PCHAR_RESTORE_RE, decodeURIComponent);
1059
+ const encoded = restorePcharFrom(encodeURIComponent(value), 0);
920
1060
  if (!isEncoded(encoded)) {
921
1061
  throw new InvalidArgumentError({
922
1062
  message: "Encoded path segment has an unexpected shape",
@@ -930,17 +1070,20 @@ function fillPlaceholder(path, placeholder, segment) {
930
1070
  return placeholderFilled(path, placeholder, segment);
931
1071
  }
932
1072
  function renderPath(template, segments) {
933
- return template.replace(/\{([^}]+)\}/g, (_, name) => {
934
- const segment = segments[name];
935
- if (segment === void 0) {
936
- throw new InvalidArgumentError({
937
- message: `No path value for {${name}}`,
938
- service: "",
939
- endpoint: template
940
- });
941
- }
942
- return segment;
943
- });
1073
+ const names = templateNames(template, 0);
1074
+ const missing = notInFrom(names, Object.keys(segments), 0);
1075
+ if (missing.length > 0) {
1076
+ throw new InvalidArgumentError({
1077
+ message: `No path value for {${missing[0]}}`,
1078
+ service: "",
1079
+ endpoint: template
1080
+ });
1081
+ }
1082
+ let path = template;
1083
+ for (const name of names) {
1084
+ path = fillPlaceholder(path, name, segments[name]);
1085
+ }
1086
+ return path;
944
1087
  }
945
1088
 
946
1089
  // src/core/path-validation.ts
@@ -957,6 +1100,17 @@ var validatePathSegment = (pathTemplate, name, value, pattern, service = "http-c
957
1100
  }
958
1101
  };
959
1102
 
1103
+ // ../utils/src/slices.ts
1104
+ function beforeLastCode(s, code) {
1105
+ return s.slice(0, endBefore(lastIndexOfCode(s, code, s.length), s.length));
1106
+ }
1107
+ function withLastSegment(id, segment) {
1108
+ return beforeLastCode(id, 46) + "." + segment;
1109
+ }
1110
+ function endBefore(k, len) {
1111
+ return k >= 0 ? k : Math.max(len - 1, 0);
1112
+ }
1113
+
960
1114
  // ../utils/src/case-spec.ts
961
1115
  var UPPER = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
962
1116
  function upperFirst(s) {
@@ -978,6 +1132,13 @@ function foldName(s) {
978
1132
  if (c === 45 || c === 95) return foldName(s.slice(1));
979
1133
  return lowerAscii(s.slice(0, 1)) + foldName(s.slice(1));
980
1134
  }
1135
+ function foldMatchesFrom(names, key, k) {
1136
+ if (k === names.length) return [];
1137
+ const name = names[k];
1138
+ const rest = foldMatchesFrom(names, key, k + 1);
1139
+ if (foldName(name) !== foldName(key)) return rest;
1140
+ return [name, ...rest];
1141
+ }
981
1142
  function snakeCamel(s) {
982
1143
  if (codeAt(s, 0) === 95) {
983
1144
  const c = codeAt(s, 1);
@@ -991,20 +1152,10 @@ function kebabCamel(s) {
991
1152
  return kebabCamelFrom(s, false);
992
1153
  }
993
1154
 
994
- // ../utils/src/slices.ts
995
- function beforeLastCode(s, code) {
996
- return s.slice(0, endBefore(lastIndexOfCode(s, code, s.length), s.length));
997
- }
998
- function endBefore(k, len) {
999
- return k >= 0 ? k : Math.max(len - 1, 0);
1000
- }
1001
-
1002
- // ../utils/src/http.ts
1003
- function isPostOrPut(method) {
1004
- return method === "POST" || method === "PUT";
1005
- }
1006
-
1007
1155
  // src/core/registry-rules.ts
1156
+ function endpointIdOf(service, chain, action) {
1157
+ return kebabCamel(service) + "." + chain + "." + action;
1158
+ }
1008
1159
  function hasBodyFor(method) {
1009
1160
  return isPostOrPut(method);
1010
1161
  }
@@ -1028,6 +1179,14 @@ function syncedTotal(total, totalResults) {
1028
1179
  function syncedTotalResults(total, totalResults) {
1029
1180
  return totalResults === 0 ? Math.max(total, 0) : totalResults;
1030
1181
  }
1182
+ function countChanged(count, dataLength) {
1183
+ return normalCount(count, dataLength) !== count;
1184
+ }
1185
+ function totalsChangeOf(total, totalResults) {
1186
+ if (syncedTotal(total, totalResults) !== total) return "total";
1187
+ if (syncedTotalResults(total, totalResults) !== totalResults) return "totalResults";
1188
+ return "kept";
1189
+ }
1031
1190
  function warnsOnNormalization(hasEnv, env) {
1032
1191
  return hasEnv && env !== "production";
1033
1192
  }
@@ -1041,23 +1200,23 @@ var logNormalizationWarning = (message) => {
1041
1200
  }
1042
1201
  };
1043
1202
  var normalizeCount = (count, actualDataLength) => {
1044
- const normal = normalCount(count, actualDataLength);
1045
- if (normal !== count) {
1203
+ if (countChanged(count, actualDataLength)) {
1046
1204
  logNormalizationWarning(`'count' was 0 but data has ${actualDataLength} items`);
1047
1205
  }
1048
- return normal;
1206
+ return normalCount(count, actualDataLength);
1049
1207
  };
1050
1208
  var normalizeTotals = (total, totalResults) => {
1051
- const synced = {
1052
- total: syncedTotal(total, totalResults),
1053
- totalResults: syncedTotalResults(total, totalResults)
1054
- };
1055
- if (synced.total !== total) {
1209
+ const change = totalsChangeOf(total, totalResults);
1210
+ if (change === "total") {
1056
1211
  logNormalizationWarning(`'total' was 0 but 'totalResults' is ${totalResults}`);
1057
- } else if (synced.totalResults !== totalResults) {
1212
+ }
1213
+ if (change === "totalResults") {
1058
1214
  logNormalizationWarning(`'totalResults' was 0 but 'total' is ${total}`);
1059
1215
  }
1060
- return synced;
1216
+ return {
1217
+ total: syncedTotal(total, totalResults),
1218
+ totalResults: syncedTotalResults(total, totalResults)
1219
+ };
1061
1220
  };
1062
1221
  var BaseResponseSchema = (dataSchema) => v.pipe(
1063
1222
  v.looseObject({
@@ -5490,6 +5649,7 @@ var CartHdrAlsoBoughtListDataSchema = v9.array(
5490
5649
  })
5491
5650
  ),
5492
5651
  images: v9.array(v9.string()),
5652
+ videos: v9.array(v9.string()),
5493
5653
  stock: v9.looseObject({
5494
5654
  stockData: v9.array(
5495
5655
  v9.looseObject({
@@ -8883,7 +9043,11 @@ var ProductsListDataSchema = v11.array(
8883
9043
  dateLastBuilt: v11.nullable(v11.string()),
8884
9044
  checkoutLinkTemplate: v11.nullable(v11.string()),
8885
9045
  dateLastStatus: v11.nullable(v11.string()),
8886
- dateLastChanged: v11.nullable(v11.string())
9046
+ dateLastChanged: v11.nullable(v11.string()),
9047
+ imageWidth: v11.nullable(v11.number()),
9048
+ imageHeight: v11.nullable(v11.number()),
9049
+ additionalImageWidth: v11.nullable(v11.number()),
9050
+ additionalImageHeight: v11.nullable(v11.number())
8887
9051
  })
8888
9052
  );
8889
9053
  var ProductsGetDataSchema = v11.looseObject({
@@ -8934,7 +9098,11 @@ var ProductsGetDataSchema = v11.looseObject({
8934
9098
  dateLastBuilt: v11.nullable(v11.string()),
8935
9099
  checkoutLinkTemplate: v11.nullable(v11.string()),
8936
9100
  dateLastStatus: v11.nullable(v11.string()),
8937
- dateLastChanged: v11.nullable(v11.string())
9101
+ dateLastChanged: v11.nullable(v11.string()),
9102
+ imageWidth: v11.nullable(v11.number()),
9103
+ imageHeight: v11.nullable(v11.number()),
9104
+ additionalImageWidth: v11.nullable(v11.number()),
9105
+ additionalImageHeight: v11.nullable(v11.number())
8938
9106
  });
8939
9107
  var SitemapsItemsListDataSchema = v11.array(
8940
9108
  v11.looseObject({ id: v11.string(), link: v11.string(), lastModified: v11.nullable(v11.string()) })
@@ -9547,6 +9715,8 @@ var InvMastFaqListParamsSchema = v13.looseObject({
9547
9715
  });
9548
9716
  var InvMastInvAccessoryListParamsSchema = v13.looseObject({
9549
9717
  ...EdgeCacheParamsSchema.entries,
9718
+ classId5ExcludeList: v13.optional(v13.string()),
9719
+ classId5List: v13.optional(v13.string()),
9550
9720
  limit: v13.optional(v13.pipe(v13.unknown(), v13.transform(Number))),
9551
9721
  offset: v13.optional(v13.pipe(v13.unknown(), v13.transform(Number))),
9552
9722
  orderBy: v13.optional(v13.string()),
@@ -9583,6 +9753,11 @@ var InvMastPromotionalGroupsListParamsSchema = v13.looseObject({
9583
9753
  ])
9584
9754
  )
9585
9755
  });
9756
+ var InvMastSimilarListParamsSchema = v13.looseObject({
9757
+ ...EdgeCacheParamsSchema.entries,
9758
+ classId5ExcludeList: v13.optional(v13.string()),
9759
+ classId5List: v13.optional(v13.string())
9760
+ });
9586
9761
  var InvPeriodUsageListParamsSchema = v13.looseObject({
9587
9762
  ...EdgeCacheParamsSchema.entries,
9588
9763
  demandPeriodUid: v13.optional(v13.pipe(v13.unknown(), v13.transform(Number))),
@@ -11113,6 +11288,7 @@ var InvMastListDataSchema = v13.array(
11113
11288
  })
11114
11289
  ),
11115
11290
  images: v13.array(v13.string()),
11291
+ videos: v13.array(v13.string()),
11116
11292
  stock: v13.looseObject({
11117
11293
  stockData: v13.array(
11118
11294
  v13.looseObject({
@@ -11791,6 +11967,7 @@ var InvMastDocListDataSchema = v13.looseObject({
11791
11967
  })
11792
11968
  ),
11793
11969
  images: v13.array(v13.string()),
11970
+ videos: v13.array(v13.string()),
11794
11971
  stock: v13.looseObject({
11795
11972
  stockData: v13.array(
11796
11973
  v13.looseObject({
@@ -15301,11 +15478,13 @@ var endpoints12 = [
15301
15478
  aliases: [],
15302
15479
  pathParams: ["invMastUid"],
15303
15480
  pathPatterns: { invMastUid: "^\\d+$" },
15304
- queryParams: ["limit", "offset", "orderBy", "statusCd"],
15481
+ queryParams: ["classId5ExcludeList", "classId5List", "limit", "offset", "orderBy", "statusCd"],
15305
15482
  edgeCache: true,
15306
15483
  summary: "List accessory items",
15307
15484
  params: {
15308
15485
  invMastUid: { in: "path", type: "integer", required: true },
15486
+ classId5ExcludeList: { in: "query", type: "string", required: false },
15487
+ classId5List: { in: "query", type: "string", required: false },
15309
15488
  limit: { in: "query", type: "integer", required: false },
15310
15489
  offset: { in: "query", type: "integer", required: false },
15311
15490
  orderBy: { in: "query", type: "string", required: false },
@@ -15405,10 +15584,14 @@ var endpoints12 = [
15405
15584
  aliases: [],
15406
15585
  pathParams: ["invMastUid"],
15407
15586
  pathPatterns: { invMastUid: "^\\d+$" },
15408
- queryParams: [],
15587
+ queryParams: ["classId5ExcludeList", "classId5List"],
15409
15588
  edgeCache: true,
15410
15589
  summary: "List similar items",
15411
- params: { invMastUid: { in: "path", type: "integer", required: true } },
15590
+ params: {
15591
+ invMastUid: { in: "path", type: "integer", required: true },
15592
+ classId5ExcludeList: { in: "query", type: "string", required: false },
15593
+ classId5List: { in: "query", type: "string", required: false }
15594
+ },
15412
15595
  responseSchema: InvMastSimilarListDataSchema,
15413
15596
  responseType: "array"
15414
15597
  },
@@ -16968,12 +17151,14 @@ var ContentListParamsSchema = v14.looseObject({
16968
17151
  var ContentGetParamsSchema = v14.looseObject({
16969
17152
  ...EdgeCacheParamsSchema.entries,
16970
17153
  alias: v14.optional(v14.string()),
16971
- catid: v14.optional(v14.pipe(v14.unknown(), v14.transform(Number)))
17154
+ catid: v14.optional(v14.pipe(v14.unknown(), v14.transform(Number))),
17155
+ includeUnpublished: v14.optional(v14.string())
16972
17156
  });
16973
17157
  var ContentDocListParamsSchema = v14.looseObject({
16974
17158
  ...EdgeCacheParamsSchema.entries,
16975
17159
  alias: v14.optional(v14.string()),
16976
- catid: v14.optional(v14.pipe(v14.unknown(), v14.transform(Number)))
17160
+ catid: v14.optional(v14.pipe(v14.unknown(), v14.transform(Number))),
17161
+ includeUnpublished: v14.optional(v14.string())
16977
17162
  });
16978
17163
  var MenuListParamsSchema = v14.looseObject({
16979
17164
  ...EdgeCacheParamsSchema.entries,
@@ -17138,7 +17323,8 @@ var ContentListDataSchema = v14.array(
17138
17323
  images: v14.union([v14.record(v14.string(), v14.unknown()), v14.array(v14.unknown())]),
17139
17324
  fields: v14.array(
17140
17325
  v14.looseObject({ value: v14.string(), title: v14.string(), name: v14.string(), label: v14.string() })
17141
- )
17326
+ ),
17327
+ state: v14.number()
17142
17328
  })
17143
17329
  );
17144
17330
  var ContentGetDataSchema = v14.looseObject({
@@ -17147,7 +17333,8 @@ var ContentGetDataSchema = v14.looseObject({
17147
17333
  alias: v14.string(),
17148
17334
  introtext: v14.nullable(v14.string()),
17149
17335
  fulltext: v14.nullable(v14.string()),
17150
- catid: v14.number()
17336
+ catid: v14.number(),
17337
+ state: v14.number()
17151
17338
  });
17152
17339
  var ContentDocListDataSchema = v14.looseObject({
17153
17340
  id: v14.number(),
@@ -17160,7 +17347,8 @@ var ContentDocListDataSchema = v14.looseObject({
17160
17347
  images: v14.union([v14.record(v14.string(), v14.unknown()), v14.array(v14.unknown())]),
17161
17348
  fields: v14.array(
17162
17349
  v14.looseObject({ value: v14.string(), title: v14.string(), name: v14.string(), label: v14.string() })
17163
- )
17350
+ ),
17351
+ state: v14.number()
17164
17352
  });
17165
17353
  var MenuListDataSchema = v14.array(
17166
17354
  v14.looseObject({
@@ -17571,13 +17759,14 @@ var endpoints13 = [
17571
17759
  aliases: [],
17572
17760
  pathParams: ["id"],
17573
17761
  pathPatterns: { id: "^\\d+$" },
17574
- queryParams: ["alias", "catid"],
17762
+ queryParams: ["alias", "catid", "includeUnpublished"],
17575
17763
  edgeCache: true,
17576
17764
  summary: "Get Content Detail",
17577
17765
  params: {
17578
17766
  id: { in: "path", type: "integer", required: true },
17579
17767
  alias: { in: "query", type: "string", required: false },
17580
- catid: { in: "query", type: "integer", required: false }
17768
+ catid: { in: "query", type: "integer", required: false },
17769
+ includeUnpublished: { in: "query", type: "string", required: false }
17581
17770
  },
17582
17771
  responseSchema: ContentGetDataSchema,
17583
17772
  responseType: "object"
@@ -17590,13 +17779,14 @@ var endpoints13 = [
17590
17779
  aliases: ["get"],
17591
17780
  pathParams: ["id"],
17592
17781
  pathPatterns: { id: "^\\d+$" },
17593
- queryParams: ["alias", "catid"],
17782
+ queryParams: ["alias", "catid", "includeUnpublished"],
17594
17783
  edgeCache: true,
17595
17784
  summary: "Get Content Doc",
17596
17785
  params: {
17597
17786
  id: { in: "path", type: "integer", required: true },
17598
17787
  alias: { in: "query", type: "string", required: false },
17599
- catid: { in: "query", type: "integer", required: false }
17788
+ catid: { in: "query", type: "integer", required: false },
17789
+ includeUnpublished: { in: "query", type: "string", required: false }
17600
17790
  },
17601
17791
  responseSchema: ContentDocListDataSchema,
17602
17792
  responseType: "object"
@@ -17949,6 +18139,8 @@ var endpoints13 = [
17949
18139
  import * as v15 from "valibot";
17950
18140
  var InvMastAlsoBoughtListParamsSchema = v15.looseObject({
17951
18141
  ...EdgeCacheParamsSchema.entries,
18142
+ classId5ExcludeList: v15.optional(v15.string()),
18143
+ classId5List: v15.optional(v15.string()),
17952
18144
  statusCd: v15.optional(
17953
18145
  v15.union([
17954
18146
  v15.array(v15.pipe(v15.unknown(), v15.transform(Number))),
@@ -18452,11 +18644,13 @@ var endpoints14 = [
18452
18644
  aliases: [],
18453
18645
  pathParams: ["invMastUid"],
18454
18646
  pathPatterns: { invMastUid: "^\\d+$" },
18455
- queryParams: ["statusCd"],
18647
+ queryParams: ["classId5ExcludeList", "classId5List", "statusCd"],
18456
18648
  edgeCache: true,
18457
18649
  summary: "List item Also Bought",
18458
18650
  params: {
18459
18651
  invMastUid: { in: "path", type: "integer", required: true },
18652
+ classId5ExcludeList: { in: "query", type: "string", required: false },
18653
+ classId5List: { in: "query", type: "string", required: false },
18460
18654
  statusCd: { in: "query", type: "integer|integer[]", required: false }
18461
18655
  },
18462
18656
  responseSchema: InvMastAlsoBoughtListDataSchema,
@@ -20242,6 +20436,7 @@ var ItemSearchListParamsSchema = v19.looseObject({
20242
20436
  jobNumbers: v19.optional(v19.string()),
20243
20437
  operator: v19.optional(v19.string()),
20244
20438
  parentCategoryUid: v19.optional(v19.pipe(v19.unknown(), v19.transform(Number))),
20439
+ productGroupIdList: v19.optional(v19.string()),
20245
20440
  q: v19.string(),
20246
20441
  searchType: v19.string(),
20247
20442
  size: v19.optional(v19.pipe(v19.unknown(), v19.transform(Number))),
@@ -20264,6 +20459,7 @@ var ItemSearchFacetsListParamsSchema = v19.looseObject({
20264
20459
  jobNumbers: v19.optional(v19.string()),
20265
20460
  operator: v19.optional(v19.string()),
20266
20461
  parentCategoryUid: v19.optional(v19.pipe(v19.unknown(), v19.transform(Number))),
20462
+ productGroupIdList: v19.optional(v19.string()),
20267
20463
  q: v19.string(),
20268
20464
  searchType: v19.optional(v19.string()),
20269
20465
  size: v19.optional(v19.pipe(v19.unknown(), v19.transform(Number))),
@@ -20579,6 +20775,7 @@ var endpoints18 = [
20579
20775
  "jobNumbers",
20580
20776
  "operator",
20581
20777
  "parentCategoryUid",
20778
+ "productGroupIdList",
20582
20779
  "q",
20583
20780
  "searchType",
20584
20781
  "size",
@@ -20602,6 +20799,7 @@ var endpoints18 = [
20602
20799
  jobNumbers: { in: "query", type: "string", required: false },
20603
20800
  operator: { in: "query", type: "string", required: false },
20604
20801
  parentCategoryUid: { in: "query", type: "integer", required: false },
20802
+ productGroupIdList: { in: "query", type: "string", required: false },
20605
20803
  q: { in: "query", type: "string", required: true },
20606
20804
  searchType: { in: "query", type: "string", required: true },
20607
20805
  size: { in: "query", type: "integer", required: false },
@@ -20634,6 +20832,7 @@ var endpoints18 = [
20634
20832
  "jobNumbers",
20635
20833
  "operator",
20636
20834
  "parentCategoryUid",
20835
+ "productGroupIdList",
20637
20836
  "q",
20638
20837
  "searchType",
20639
20838
  "size",
@@ -20657,6 +20856,7 @@ var endpoints18 = [
20657
20856
  jobNumbers: { in: "query", type: "string", required: false },
20658
20857
  operator: { in: "query", type: "string", required: false },
20659
20858
  parentCategoryUid: { in: "query", type: "integer", required: false },
20859
+ productGroupIdList: { in: "query", type: "string", required: false },
20660
20860
  q: { in: "query", type: "string", required: true },
20661
20861
  searchType: { in: "query", type: "string", required: false },
20662
20862
  size: { in: "query", type: "integer", required: false },
@@ -39723,9 +39923,9 @@ function frozenParams(params) {
39723
39923
  }
39724
39924
  function fromRow(service, row) {
39725
39925
  return Object.freeze({
39726
- // the id root is the generator's rule too (utils kebabCamel, the model's ServiceId), so an
39727
- // id is the same whichever side built it: open-search → openSearch
39728
- id: `${kebabCamel(service)}.${row.chain}.${row.action}`,
39926
+ // the generator's rule too (proved endpointIdOf, the model's EndpointId), so an id is the
39927
+ // same whichever side built it: open-search → openSearch
39928
+ id: endpointIdOf(service, row.chain, row.action),
39729
39929
  service,
39730
39930
  method: row.method,
39731
39931
  path: row.path,
@@ -39744,7 +39944,7 @@ function fromRow(service, row) {
39744
39944
  function baseEntries(service) {
39745
39945
  return BASE_ENDPOINTS.map(
39746
39946
  ([chain, path, auth, summary]) => Object.freeze({
39747
- id: `${kebabCamel(service)}.${chain}.get`,
39947
+ id: endpointIdOf(service, chain, "get"),
39748
39948
  service,
39749
39949
  method: "GET",
39750
39950
  path,
@@ -39778,9 +39978,8 @@ function buildIndex() {
39778
39978
  const map = /* @__PURE__ */ new Map();
39779
39979
  for (const entry of registryEntries()) {
39780
39980
  map.set(entry.id, entry);
39781
- const chain = beforeLastCode(entry.id, 46);
39782
39981
  for (const alias of entry.aliases) {
39783
- map.set(`${chain}.${alias}`, entry);
39982
+ map.set(withLastSegment(entry.id, alias), entry);
39784
39983
  }
39785
39984
  }
39786
39985
  return map;
@@ -39819,7 +40018,7 @@ function rejectUnknown(entry, kind, keys, allowed) {
39819
40018
  }
39820
40019
  function checkArgs(entry, args) {
39821
40020
  const pathKeys = Object.keys(args.pathParams ?? {});
39822
- const missing = entry.pathParams.filter((name) => !pathKeys.includes(name));
40021
+ const missing = notInFrom([...entry.pathParams], pathKeys, 0);
39823
40022
  if (missing.length > 0) {
39824
40023
  throw invalid(missingPathMessage(entry.id, joinFrom(missing, ", ", 0)), entry);
39825
40024
  }
@@ -39843,11 +40042,10 @@ function fillPath(entry, pathParams) {
39843
40042
  return renderPath(entry.path, segments);
39844
40043
  }
39845
40044
  function toEnvelope(body) {
39846
- if (typeof body !== "object" || body === null || Array.isArray(body)) {
39847
- return null;
39848
- }
39849
- const record32 = body;
39850
- if (!ENVELOPE_KEYS.every((key) => key in record32)) {
40045
+ const isPlainObject = typeof body === "object" && body !== null && !Array.isArray(body);
40046
+ const record32 = isPlainObject ? body : {};
40047
+ const present = ENVELOPE_KEYS.map((key) => key in record32);
40048
+ if (!isEnvelopeBody(isPlainObject, allFrom(present, 0))) {
39851
40049
  return null;
39852
40050
  }
39853
40051
  return Object.fromEntries(ENVELOPE_KEYS.map((key) => [key, record32[key]]));
@@ -39865,40 +40063,41 @@ async function callEndpoint(config, id, args = {}, bounds = NO_BOUNDS) {
39865
40063
  config: { endpoint: entry.path }
39866
40064
  });
39867
40065
  const parsed = parseJson(raw.text);
39868
- const body = parsed.json ? parsed.value : raw.text;
40066
+ const body = callBodyKind(parsed.json) === "json" ? parsed.value : raw.text;
39869
40067
  return { httpStatus: raw.status, envelope: toEnvelope(body), body };
39870
40068
  }
39871
40069
 
39872
- // ../auth-core/src/site.ts
39873
- function isSiteChar(c) {
39874
- return c >= 97 && c <= 122 || c >= 48 && c <= 57 || c === 95 || c === 45;
40070
+ // src/core/proxy-rules.ts
40071
+ function renamesWireParams(method) {
40072
+ return method === "GET";
39875
40073
  }
39876
- function siteCharsFrom(s, i) {
39877
- return i >= s.length || isSiteChar(s.charCodeAt(i)) && siteCharsFrom(s, i + 1);
40074
+ function defaultsEmptyBody(hasQueryParams, hasBody) {
40075
+ return !hasQueryParams && !hasBody;
39878
40076
  }
39879
- function isSiteId(s) {
39880
- return s.length > 0 && siteCharsFrom(s, 0);
40077
+ function dataProxyRoute(isFunction, isObject) {
40078
+ if (isFunction) return "unwrap";
40079
+ return isObject ? "nest" : "copy";
39881
40080
  }
39882
-
39883
- // src/core/site-id-check.ts
39884
- function isSiteId2(s) {
39885
- return isSiteId(s);
40081
+ function requestShapeOf(hasPathParams, hasQueryParams, hasBody) {
40082
+ if (hasPathParams) return "withPathParams";
40083
+ return hasQueryParams || hasBody ? "paramsOnly" : "noParams";
39886
40084
  }
39887
-
39888
- // src/core/site-id.ts
39889
- function parseSiteId(value) {
39890
- return isSiteId2(value) ? value : void 0;
40085
+ function copiesLegacyValue(camelGiven) {
40086
+ return !camelGiven;
39891
40087
  }
39892
- function assertSiteId(value) {
39893
- const site = parseSiteId(value);
39894
- if (site === void 0) {
39895
- throw new InvalidArgumentError({
39896
- message: "Invalid siteId: expected lowercase letters, digits, '_' and '-' (e.g. example-site)",
39897
- service: "",
39898
- endpoint: ""
39899
- });
39900
- }
39901
- return site;
40088
+ function pathParamTargets(path, key) {
40089
+ if (includesFrom(path, braced(key), 0)) return [key];
40090
+ return foldMatchesFrom(templateNames(path, 0), key, 0);
40091
+ }
40092
+ function bodySlot(method) {
40093
+ return method === "DELETE" ? -1 : 0;
40094
+ }
40095
+ function querySlot(method) {
40096
+ if (method === "POST" || method === "PUT") return 1;
40097
+ return method === "DELETE" ? 0 : -1;
40098
+ }
40099
+ function isLegacyAlias(changed, declared) {
40100
+ return changed && declared;
39902
40101
  }
39903
40102
 
39904
40103
  // src/core/common-schemas.ts
@@ -40033,16 +40232,15 @@ var BaseServiceClient = class {
40033
40232
  * describe the expected type, and `received` is not copied)
40034
40233
  */
40035
40234
  createValidationError(valibotError, config, errorType) {
40036
- 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.";
40037
40235
  return new ValidationError({
40038
- message,
40236
+ message: validationMessageOf(errorType),
40039
40237
  service: this.serviceName,
40040
40238
  endpoint: config.path,
40041
40239
  validationErrors: valibotError.issues.map((issue) => ({
40042
40240
  path: (issue.path ?? []).map((segment) => segment.key),
40043
40241
  message: issue.message,
40044
40242
  // Typed as always present, but issues built outside valibot can lack it
40045
- code: issue.type ?? "unknown"
40243
+ code: issueCodeOf(issue.type)
40046
40244
  }))
40047
40245
  });
40048
40246
  }
@@ -40070,45 +40268,28 @@ var BaseServiceClient = class {
40070
40268
  let path = pathTemplate;
40071
40269
  for (const [key, value] of Object.entries(pathParams)) {
40072
40270
  const stringValue = String(value);
40073
- if (includesFrom(path, braced(key), 0)) {
40074
- validatePathSegment(pathTemplate, key, stringValue, pathPatterns[key], this.serviceName);
40075
- path = fillPlaceholder(path, key, encodePathSegment(stringValue));
40076
- } else {
40077
- const folded = foldName(key);
40078
- for (const placeholder of new Set(templateNames(path, 0))) {
40079
- if (foldName(placeholder) === folded) {
40080
- validatePathSegment(
40081
- pathTemplate,
40082
- placeholder,
40083
- stringValue,
40084
- pathPatterns[placeholder],
40085
- this.serviceName
40086
- );
40087
- path = fillPlaceholder(path, placeholder, encodePathSegment(stringValue));
40088
- }
40089
- }
40271
+ for (const placeholder of pathParamTargets(path, key)) {
40272
+ validatePathSegment(
40273
+ pathTemplate,
40274
+ placeholder,
40275
+ stringValue,
40276
+ pathPatterns[placeholder],
40277
+ this.serviceName
40278
+ );
40279
+ path = fillPlaceholder(path, placeholder, encodePathSegment(stringValue));
40090
40280
  }
40091
40281
  }
40092
40282
  return path;
40093
40283
  }
40094
40284
  };
40095
40285
 
40096
- // src/core/service-proxy.ts
40097
- import * as v33 from "valibot";
40098
-
40099
- // src/core/proxy-rules.ts
40100
- function bodySlot(method) {
40101
- return method === "DELETE" ? -1 : 0;
40102
- }
40103
- function querySlot(method) {
40104
- if (method === "POST" || method === "PUT") return 1;
40105
- return method === "DELETE" ? 0 : -1;
40106
- }
40107
- function isLegacyAlias(changed, declared) {
40108
- return changed && declared;
40286
+ // ../utils/src/distance.ts
40287
+ function min2(x, y) {
40288
+ return Math.min(x, y);
40109
40289
  }
40110
40290
 
40111
40291
  // src/core/service-proxy.ts
40292
+ import * as v33 from "valibot";
40112
40293
  var PassthroughResponseSchema = v33.looseObject({
40113
40294
  count: v33.number(),
40114
40295
  data: v33.unknown(),
@@ -40153,16 +40334,12 @@ function createNodeObject(serviceName, executeRequest, node) {
40153
40334
  return obj;
40154
40335
  }
40155
40336
  function splitPathArgs(pathParams, args) {
40337
+ const taken = min2(pathParams.length, args.length);
40156
40338
  const pathParamMap = {};
40157
- let index2 = 0;
40158
- for (const name of pathParams) {
40159
- if (index2 >= args.length) {
40160
- break;
40161
- }
40162
- pathParamMap[name] = String(args[index2]);
40163
- index2++;
40339
+ for (let index2 = 0; index2 < taken; index2++) {
40340
+ pathParamMap[pathParams[index2]] = String(args[index2]);
40164
40341
  }
40165
- return { pathParamMap, rest: args.slice(index2) };
40342
+ return { pathParamMap, rest: args.slice(taken) };
40166
40343
  }
40167
40344
  function splitBodyAndQuery(method, rest) {
40168
40345
  const at = (slot) => rest[slot];
@@ -40183,7 +40360,7 @@ function normaliseLegacyParamCase(params, declared) {
40183
40360
  }
40184
40361
  renamed = true;
40185
40362
  delete out[key];
40186
- if (!(camel in source)) {
40363
+ if (copiesLegacyValue(camel in source)) {
40187
40364
  out[camel] = value;
40188
40365
  }
40189
40366
  }
@@ -40200,7 +40377,7 @@ function createActionFunction(_serviceName, executeRequest, endpoint) {
40200
40377
  hasQueryParams ? trailing : void 0,
40201
40378
  endpoint.queryParams
40202
40379
  );
40203
- const wireParams = (value) => method === "GET" ? normaliseLegacyParamCase(value, endpoint.queryParams) : value;
40380
+ const wireParams = (value) => renamesWireParams(method) ? normaliseLegacyParamCase(value, endpoint.queryParams) : value;
40204
40381
  const config = {
40205
40382
  method,
40206
40383
  path,
@@ -40208,11 +40385,17 @@ function createActionFunction(_serviceName, executeRequest, endpoint) {
40208
40385
  ...hasQueryParams ? { paramsSchema: PassthroughParamsSchema } : {},
40209
40386
  responseSchema: PassthroughResponseSchema
40210
40387
  };
40211
- if (Object.keys(pathParamMap).length > 0) {
40212
- const params = wireParams(hasQueryParams ? body : body ?? {});
40388
+ const shape = requestShapeOf(
40389
+ Object.keys(pathParamMap).length > 0,
40390
+ hasQueryParams,
40391
+ body !== void 0
40392
+ );
40393
+ if (shape === "withPathParams") {
40394
+ const hasBody = body !== void 0 && body !== null;
40395
+ const params = wireParams(defaultsEmptyBody(hasQueryParams, hasBody) ? {} : body);
40213
40396
  return query === void 0 ? executeRequest(config, params, pathParamMap) : executeRequest(config, params, pathParamMap, query);
40214
40397
  }
40215
- if (hasQueryParams || body !== void 0) {
40398
+ if (shape === "paramsOnly") {
40216
40399
  return query === void 0 ? executeRequest(config, wireParams(body)) : executeRequest(config, wireParams(body), void 0, query);
40217
40400
  }
40218
40401
  return executeRequest(config);
@@ -40223,14 +40406,18 @@ function createDataProxy(resource) {
40223
40406
  const src = resource;
40224
40407
  for (const key of Object.keys(src)) {
40225
40408
  const value = src[key];
40226
- if (typeof value === "function") {
40409
+ const route = dataProxyRoute(
40410
+ typeof value === "function",
40411
+ typeof value === "object" && value !== null
40412
+ );
40413
+ if (route === "unwrap") {
40227
40414
  const propKey = key;
40228
40415
  obj[key] = async (...args) => {
40229
40416
  const fn = src[propKey];
40230
40417
  const response = await fn(...args);
40231
40418
  return response?.data;
40232
40419
  };
40233
- } else if (value && typeof value === "object") {
40420
+ } else if (route === "nest") {
40234
40421
  obj[key] = createDataProxy(value);
40235
40422
  } else {
40236
40423
  obj[key] = value;
@@ -42449,6 +42636,11 @@ var AugurAPI = class _AugurAPI {
42449
42636
  }
42450
42637
  };
42451
42638
 
42639
+ // ../foundation/src/pos-int.ts
42640
+ function posIntOf(n) {
42641
+ return Math.floor(n) === n && n >= 1 && n <= 9007199254740991 ? n : null;
42642
+ }
42643
+
42452
42644
  // src/utils/cross-site-auth.ts
42453
42645
  async function authenticateUserForSite(params) {
42454
42646
  const { targetSiteId, username, password, augurInfoToken } = params;
@@ -42463,23 +42655,35 @@ async function authenticateUserForSite(params) {
42463
42655
  siteId: targetSiteId
42464
42656
  // This tells the API to authenticate against the target site
42465
42657
  });
42466
- if (!data.isVerified) {
42658
+ const token = data.token;
42659
+ const tokenIsText = typeof token === "string";
42660
+ const outcome = crossSiteOutcomeOf(
42661
+ Boolean(data.isVerified),
42662
+ tokenIsText,
42663
+ tokenIsText ? token : ""
42664
+ );
42665
+ if (outcome === "notVerified") {
42467
42666
  return { success: false, targetSiteId, error: "Invalid username or password" };
42468
42667
  }
42469
- if (typeof data.token !== "string" || data.token === "") {
42668
+ if (outcome === "noToken") {
42470
42669
  return { success: false, targetSiteId, error: "Password verified, but no token was issued" };
42471
42670
  }
42671
+ const bearer = token;
42672
+ const rawId = data.id;
42673
+ const userId = posIntOf(typeof rawId === "number" ? rawId : Number.NaN);
42472
42674
  const targetSiteAPI = new AugurAPI({
42473
42675
  siteId: targetSiteId,
42474
- bearerToken: data.token
42676
+ bearerToken: bearer
42475
42677
  });
42476
42678
  return {
42477
42679
  success: true,
42478
- // `data` is typed, not validated at runtime: a missing id stays undefined, never "undefined"
42479
- userId: typeof data.id === "number" ? String(data.id) : void 0,
42680
+ // `data` is typed, not validated at runtime. A user id is an integer at least 1: it enters
42681
+ // as a PosInt (foundation's posIntOf; not a number reads as NaN, which it refuses) and the
42682
+ // proved crossSiteUserIdOf writes it, so 0, -1, 1.5 or a missing id report no id
42683
+ userId: crossSiteUserIdOf(userId !== null, userId ?? 0),
42480
42684
  username: data.username,
42481
42685
  email: data.email,
42482
- token: data.token,
42686
+ token: bearer,
42483
42687
  targetSiteId,
42484
42688
  targetSiteAPI
42485
42689
  };
@@ -42503,7 +42707,7 @@ function createCrossSiteAuthenticator(augurInfoToken) {
42503
42707
  }
42504
42708
 
42505
42709
  // src/index.ts
42506
- var VERSION = "2026.11.4";
42710
+ var VERSION = "2026.11.6";
42507
42711
  export {
42508
42712
  AgrInfoClient,
42509
42713
  AgrIntClient,