@simpleapps-com/augur-api 2026.11.2 → 2026.11.4

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 (82) hide show
  1. package/README.md +41 -4
  2. package/dist/client.d.ts +31 -1
  3. package/dist/client.d.ts.map +1 -1
  4. package/dist/core/call.d.ts +2 -2
  5. package/dist/core/call.d.ts.map +1 -1
  6. package/dist/core/client-rules.d.ts +122 -0
  7. package/dist/core/client-rules.d.ts.map +1 -0
  8. package/dist/core/client.d.ts +25 -4
  9. package/dist/core/client.d.ts.map +1 -1
  10. package/dist/core/config.d.ts +24 -0
  11. package/dist/core/config.d.ts.map +1 -1
  12. package/dist/core/http-rules.d.ts.map +1 -1
  13. package/dist/core/site-id-check.d.ts +2 -2
  14. package/dist/core/site-id.d.ts +3 -3
  15. package/dist/core/site-id.d.ts.map +1 -1
  16. package/dist/index.d.ts +2 -2
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +440 -179
  19. package/dist/index.js.map +1 -1
  20. package/dist/index.mjs +440 -179
  21. package/dist/index.mjs.map +1 -1
  22. package/dist/services/agr-info/generated/endpoints.d.ts +1 -1
  23. package/dist/services/agr-info/generated/endpoints.d.ts.map +1 -1
  24. package/dist/services/agr-int/generated/endpoints.d.ts +1 -1
  25. package/dist/services/agr-int/generated/endpoints.d.ts.map +1 -1
  26. package/dist/services/agr-site/generated/endpoints.d.ts +1 -1
  27. package/dist/services/agr-site/generated/endpoints.d.ts.map +1 -1
  28. package/dist/services/agr-work/generated/endpoints.d.ts +1 -1
  29. package/dist/services/agr-work/generated/endpoints.d.ts.map +1 -1
  30. package/dist/services/avalara/generated/endpoints.d.ts +1 -1
  31. package/dist/services/avalara/generated/endpoints.d.ts.map +1 -1
  32. package/dist/services/basecamp2/generated/endpoints.d.ts +1 -1
  33. package/dist/services/basecamp2/generated/endpoints.d.ts.map +1 -1
  34. package/dist/services/brand-folder/generated/endpoints.d.ts +1 -1
  35. package/dist/services/brand-folder/generated/endpoints.d.ts.map +1 -1
  36. package/dist/services/commerce/generated/endpoints.d.ts +1 -1
  37. package/dist/services/commerce/generated/endpoints.d.ts.map +1 -1
  38. package/dist/services/customers/generated/endpoints.d.ts +1 -1
  39. package/dist/services/customers/generated/endpoints.d.ts.map +1 -1
  40. package/dist/services/goog-mc/generated/endpoints.d.ts +1 -1
  41. package/dist/services/goog-mc/generated/endpoints.d.ts.map +1 -1
  42. package/dist/services/gregorovich/generated/endpoints.d.ts +1 -1
  43. package/dist/services/gregorovich/generated/endpoints.d.ts.map +1 -1
  44. package/dist/services/items/generated/endpoints.d.ts +1 -1
  45. package/dist/services/items/generated/endpoints.d.ts.map +1 -1
  46. package/dist/services/joomla/generated/endpoints.d.ts +1 -1
  47. package/dist/services/joomla/generated/endpoints.d.ts.map +1 -1
  48. package/dist/services/legacy/generated/endpoints.d.ts +1 -1
  49. package/dist/services/legacy/generated/endpoints.d.ts.map +1 -1
  50. package/dist/services/logistics/generated/endpoints.d.ts +1 -1
  51. package/dist/services/logistics/generated/endpoints.d.ts.map +1 -1
  52. package/dist/services/markets/generated/endpoints.d.ts +1 -1
  53. package/dist/services/markets/generated/endpoints.d.ts.map +1 -1
  54. package/dist/services/notifications/generated/endpoints.d.ts +1 -1
  55. package/dist/services/notifications/generated/endpoints.d.ts.map +1 -1
  56. package/dist/services/open-search/generated/endpoints.d.ts +1 -1
  57. package/dist/services/open-search/generated/endpoints.d.ts.map +1 -1
  58. package/dist/services/orders/generated/endpoints.d.ts +1 -1
  59. package/dist/services/orders/generated/endpoints.d.ts.map +1 -1
  60. package/dist/services/p21-apis/generated/endpoints.d.ts +1 -1
  61. package/dist/services/p21-apis/generated/endpoints.d.ts.map +1 -1
  62. package/dist/services/p21-core/generated/endpoints.d.ts +1 -1
  63. package/dist/services/p21-core/generated/endpoints.d.ts.map +1 -1
  64. package/dist/services/p21-pim/generated/endpoints.d.ts +1 -1
  65. package/dist/services/p21-pim/generated/endpoints.d.ts.map +1 -1
  66. package/dist/services/p21-sism/generated/endpoints.d.ts +1 -1
  67. package/dist/services/p21-sism/generated/endpoints.d.ts.map +1 -1
  68. package/dist/services/payments/generated/endpoints.d.ts +1 -1
  69. package/dist/services/payments/generated/endpoints.d.ts.map +1 -1
  70. package/dist/services/pricing/generated/endpoints.d.ts +1 -1
  71. package/dist/services/pricing/generated/endpoints.d.ts.map +1 -1
  72. package/dist/services/shipping/generated/endpoints.d.ts +1 -1
  73. package/dist/services/shipping/generated/endpoints.d.ts.map +1 -1
  74. package/dist/services/smarty-streets/generated/endpoints.d.ts +1 -1
  75. package/dist/services/smarty-streets/generated/endpoints.d.ts.map +1 -1
  76. package/dist/services/ups/generated/endpoints.d.ts +1 -1
  77. package/dist/services/ups/generated/endpoints.d.ts.map +1 -1
  78. package/dist/services/vendors/generated/endpoints.d.ts +1 -1
  79. package/dist/services/vendors/generated/endpoints.d.ts.map +1 -1
  80. package/dist/services/vmi/generated/endpoints.d.ts +1 -1
  81. package/dist/services/vmi/generated/endpoints.d.ts.map +1 -1
  82. package/package.json +5 -2
package/dist/index.js CHANGED
@@ -76,12 +76,12 @@ __export(index_exports, {
76
76
  authenticateUserForSite: () => authenticateUserForSite,
77
77
  createCrossSiteAuthenticator: () => createCrossSiteAuthenticator,
78
78
  isReadOnly: () => isReadOnly,
79
- isSiteId: () => isSiteId,
79
+ isSiteId: () => isSiteId2,
80
80
  parseSiteId: () => parseSiteId
81
81
  });
82
82
  module.exports = __toCommonJS(index_exports);
83
83
 
84
- // ../utils/src/chars.ts
84
+ // ../foundation/src/chars.ts
85
85
  function isAlnumChar(c) {
86
86
  return c >= 65 && c <= 90 || c >= 97 && c <= 122 || c >= 48 && c <= 57;
87
87
  }
@@ -126,17 +126,24 @@ function compareFrom(a, b, i) {
126
126
  function compareCodeUnits(a, b) {
127
127
  return compareFrom(a, b, 0);
128
128
  }
129
+
130
+ // ../utils/src/includes.ts
129
131
  function includesFrom(s, x, i) {
130
- if (i > s.length) return false;
131
- if (startsWithAt(s, x, i)) return true;
132
- return includesFrom(s, x, i + 1);
132
+ for (let k = i; k !== s.length + 1; k++) {
133
+ if (startsWithAt(s, x, k)) return true;
134
+ }
135
+ return false;
133
136
  }
134
137
 
135
138
  // ../utils/src/lists.ts
136
139
  function joinFrom(xs, sep, i) {
137
140
  if (i >= xs.length) return "";
138
- if (i === xs.length - 1) return xs[i];
139
- return xs[i] + sep + joinFrom(xs, sep, i + 1);
141
+ return joinRange(xs, sep, i, xs.length);
142
+ }
143
+ function joinRange(xs, sep, lo, hi) {
144
+ if (hi - lo === 1) return xs[lo];
145
+ const mid = lo + Math.floor((hi - lo) / 2);
146
+ return joinRange(xs, sep, lo, mid) + sep + joinRange(xs, sep, mid, hi);
140
147
  }
141
148
  function hasItemFrom(xs, x, i) {
142
149
  if (i === xs.length) return false;
@@ -246,18 +253,20 @@ function placeholderFilled(path, placeholder, segment) {
246
253
  return replaceText(path, "{" + placeholder + "}", segment);
247
254
  }
248
255
 
249
- // ../utils/src/json.ts
250
- function isRecord(value) {
251
- return typeof value === "object" && value !== null && !Array.isArray(value);
256
+ // ../foundation/src/duration.ts
257
+ function seconds(n) {
258
+ return n;
259
+ }
260
+ function toMillis(d) {
261
+ return d * 1e3;
252
262
  }
253
263
 
254
264
  // src/core/config.ts
265
+ var NO_BOUNDS = { signals: [] };
255
266
  var DEFAULT_CONFIG = {
256
- timeout: 3e4,
257
- // 30 seconds
267
+ timeout: toMillis(seconds(30)),
258
268
  retries: 3,
259
- retryDelay: 1e3
260
- // 1 second
269
+ retryDelay: toMillis(seconds(1))
261
270
  };
262
271
  var ContextCreationError = class extends Error {
263
272
  constructor(message, field) {
@@ -268,6 +277,105 @@ var ContextCreationError = class extends Error {
268
277
  field;
269
278
  };
270
279
 
280
+ // ../json-values/src/index.ts
281
+ function isRecord(value) {
282
+ return typeof value === "object" && value !== null && !Array.isArray(value);
283
+ }
284
+
285
+ // src/core/http-rules.ts
286
+ function isRetryableStatus(status) {
287
+ return !(status >= 400 && status < 500 && status !== 429);
288
+ }
289
+ function exponentialDelay(base, attempt) {
290
+ if (attempt === 0) return base;
291
+ return 2 * exponentialDelay(base, attempt - 1);
292
+ }
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");
302
+ }
303
+ function sendsBearer(url, hasToken) {
304
+ return hasToken && !isPublicEndpoint(url);
305
+ }
306
+ function sendsJsonBody(hasData, method) {
307
+ return hasData && method !== "GET";
308
+ }
309
+ function querySeparator(url) {
310
+ return includesFrom(url, "?", 0) ? "&" : "?";
311
+ }
312
+ function requestKey(method, url, params) {
313
+ return method + ":" + url + ":" + params;
314
+ }
315
+ function isEdgeCacheParam(key) {
316
+ return key === "edgeCache";
317
+ }
318
+
319
+ // src/core/client-rules.ts
320
+ function contextRefusalOf(hasContext, siteIdTruthy, contextTokenTruthy, finalTokenTruthy) {
321
+ if (!hasContext) return "context";
322
+ if (!siteIdTruthy) return "site-id";
323
+ if (!contextTokenTruthy) return "token";
324
+ return finalTokenTruthy ? "ok" : "token-removed";
325
+ }
326
+ function retryableError(isAugurError, status) {
327
+ return !isAugurError || isRetryableStatus(status);
328
+ }
329
+ function retryAfterCall(attempt, retries, retryable, callAborted) {
330
+ return !callAborted && attempt < retries && retryable;
331
+ }
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
+ function needsAttemptTimer(perAttempt, hasDeadline, remaining) {
345
+ return !(hasDeadline && remaining <= perAttempt);
346
+ }
347
+ function boundedCall(hasSignal, hasDeadline) {
348
+ return hasSignal || hasDeadline;
349
+ }
350
+ function deadlineInRange(deadline) {
351
+ return 0 <= deadline && deadline <= 2147483647;
352
+ }
353
+ function callOptionsAccepted(hasSignal, isAbortSignal, hasDeadline, inRange) {
354
+ return (!hasSignal || isAbortSignal) && (!hasDeadline || inRange);
355
+ }
356
+ function sharesInFlight(hasRequestSignal) {
357
+ return !hasRequestSignal;
358
+ }
359
+ function mergedDeadlineOf(hasOuter, outer, hasInner, inner) {
360
+ if (!hasOuter) return inner;
361
+ if (!hasInner) return outer;
362
+ return inner < outer ? inner : outer;
363
+ }
364
+ function hasMergedDeadline(hasOuter, hasInner) {
365
+ return hasOuter || hasInner;
366
+ }
367
+ function edgeCacheKindOf(text, hours) {
368
+ 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;
370
+ return hourly ? "hourly" : "invalid";
371
+ }
372
+ function rawRetries(method) {
373
+ return method === "GET";
374
+ }
375
+ function startsAttempt(hasDeadline, remaining) {
376
+ return !hasDeadline || remaining > 0;
377
+ }
378
+
271
379
  // src/core/errors.ts
272
380
  var AugurError = class _AugurError extends Error {
273
381
  code;
@@ -379,40 +487,6 @@ var InvalidArgumentError = class extends AugurError {
379
487
  }
380
488
  };
381
489
 
382
- // src/core/http-rules.ts
383
- function isRetryableStatus(status) {
384
- return !(status >= 400 && status < 500 && status !== 429);
385
- }
386
- function exponentialDelay(base, attempt) {
387
- if (attempt === 0) return base;
388
- return 2 * exponentialDelay(base, attempt - 1);
389
- }
390
- function cappedDelay(d) {
391
- return Math.min(d, 3e4);
392
- }
393
- function timeoutOf(hasRequest, request, hasClient, client, fallback) {
394
- if (hasRequest) return request;
395
- return hasClient ? client : fallback;
396
- }
397
- function isPublicEndpoint(url) {
398
- return endsWith(url, "/health-check") || endsWith(url, "/ping");
399
- }
400
- function sendsBearer(url, hasToken) {
401
- return hasToken && !isPublicEndpoint(url);
402
- }
403
- function sendsJsonBody(hasData, method) {
404
- return hasData && method !== "GET";
405
- }
406
- function querySeparator(url) {
407
- return includesFrom(url, "?", 0) ? "&" : "?";
408
- }
409
- function requestKey(method, url, params) {
410
- return method + ":" + url + ":" + params;
411
- }
412
- function isEdgeCacheParam(key) {
413
- return key === "edgeCache";
414
- }
415
-
416
490
  // src/core/client.ts
417
491
  function parseJson(text) {
418
492
  try {
@@ -447,10 +521,59 @@ function calculateBackoffDelay(attempt, baseDelay) {
447
521
  return cappedDelay(exponential + jitter);
448
522
  }
449
523
  function isRetryableError(error) {
450
- return !(error instanceof AugurError) || isRetryableStatus(error.statusCode);
524
+ const isAugurError = error instanceof AugurError;
525
+ return retryableError(isAugurError, isAugurError ? error.statusCode : 0);
526
+ }
527
+ function delay(ms, signal) {
528
+ return new Promise((resolve, reject) => {
529
+ const onAbort = () => {
530
+ clearTimeout(timer);
531
+ reject(signal.reason);
532
+ };
533
+ const timer = setTimeout(() => {
534
+ signal?.removeEventListener("abort", onAbort);
535
+ resolve();
536
+ }, ms);
537
+ signal?.addEventListener("abort", onAbort, { once: true });
538
+ });
539
+ }
540
+ var UNBOUNDED = {
541
+ signal: void 0,
542
+ hasDeadline: false,
543
+ remaining: () => 0,
544
+ dispose: () => {
545
+ }
546
+ };
547
+ function throwIfEnded(call) {
548
+ if (call.signal?.aborted) throw call.signal.reason;
451
549
  }
452
- function delay(ms) {
453
- return new Promise((resolve) => setTimeout(resolve, ms));
550
+ function startCall(bounds, requestSignal) {
551
+ const sources = requestSignal === void 0 ? [...bounds.signals] : [...bounds.signals, requestSignal];
552
+ const deadline = bounds.deadline;
553
+ if (!boundedCall(sources.length > 0, deadline !== void 0)) return UNBOUNDED;
554
+ const controller = new AbortController();
555
+ const started = Date.now();
556
+ const listeners = sources.map((source) => {
557
+ const onAbort = () => controller.abort(source.reason);
558
+ source.addEventListener("abort", onAbort, { once: true });
559
+ return { source, onAbort };
560
+ });
561
+ for (const source of sources) {
562
+ if (source.aborted) controller.abort(source.reason);
563
+ }
564
+ const timer = deadline === void 0 ? void 0 : setTimeout(
565
+ () => controller.abort(new DOMException("Call deadline exceeded", "TimeoutError")),
566
+ deadline
567
+ );
568
+ return {
569
+ signal: controller.signal,
570
+ hasDeadline: deadline !== void 0,
571
+ remaining: () => remainingOf(deadline ?? 0, Date.now() - started),
572
+ dispose: () => {
573
+ clearTimeout(timer);
574
+ for (const { source, onAbort } of listeners) source.removeEventListener("abort", onAbort);
575
+ }
576
+ };
454
577
  }
455
578
  function withoutEdgeCache(params) {
456
579
  return Object.fromEntries(Object.entries(params).filter(([key]) => !isEdgeCacheParam(key)));
@@ -494,18 +617,22 @@ var HTTPClient = class {
494
617
  config;
495
618
  serviceName;
496
619
  inflightRequests = /* @__PURE__ */ new Map();
497
- constructor(serviceName, config) {
620
+ bounds;
621
+ /** `bounds` bound every call this client makes (a view's, from `AugurAPI.withRequest`). */
622
+ constructor(serviceName, config, bounds = NO_BOUNDS) {
498
623
  this.serviceName = serviceName;
499
624
  this.config = { ...DEFAULT_CONFIG, ...config };
625
+ this.bounds = bounds;
500
626
  }
501
627
  /**
502
- * Build request headers with auth
628
+ * Build request headers with auth. A request's own headers come before `x-site-id` and
629
+ * `Authorization`, so neither can be replaced by one (AugurApiClient.SiteIdHeaderIsTheClients).
503
630
  */
504
631
  buildRequestHeaders(url, requestConfig) {
505
632
  const headers = {
506
633
  "Content-Type": "application/json",
507
- "x-site-id": this.config.siteId,
508
- ...requestConfig?.headers
634
+ ...requestConfig?.headers,
635
+ "x-site-id": this.config.siteId
509
636
  };
510
637
  if (sendsBearer(url, Boolean(this.config.bearerToken))) {
511
638
  headers["Authorization"] = `Bearer ${this.config.bearerToken}`;
@@ -581,30 +708,58 @@ var HTTPClient = class {
581
708
  * Core request method using native fetch. `read` turns a 2xx response into
582
709
  * the result, inside the same error handling and timeout as the fetch.
583
710
  */
584
- async request(method, url, options, read = (r, c) => this.handleFetchSuccess(r, c)) {
711
+ async request(method, url, options, call, read = (r, c) => this.handleFetchSuccess(r, c)) {
585
712
  const { config: requestConfig } = options;
586
713
  const endpoint = requestConfig?.endpoint ?? url;
587
- const timeout = this.timeoutFor(requestConfig);
588
- let augurConfig = this.baseRequest(method, url, options, timeout);
714
+ const bounds = this.attemptBounds(requestConfig, call);
715
+ let augurConfig = this.baseRequest(method, url, options, bounds.timeout);
589
716
  if (this.config.onRequest) {
590
717
  augurConfig = await this.config.onRequest(augurConfig);
591
718
  }
592
719
  const fullUrl = buildUrlWithParams(augurConfig.url, augurConfig.params);
593
- const controller = new AbortController();
594
- const timeoutId = setTimeout(() => controller.abort(), timeout);
595
- const signal = requestConfig?.signal ? this.mergeSignals(requestConfig.signal, controller.signal) : controller.signal;
720
+ throwIfEnded(call);
721
+ const attempt = this.attemptSignal(call, bounds);
596
722
  try {
597
- const response = await fetch(fullUrl, fetchOptionsFor(augurConfig, method, signal));
723
+ const response = await fetch(fullUrl, fetchOptionsFor(augurConfig, method, attempt.signal));
598
724
  if (!response.ok) {
599
725
  await this.handleFetchError(response, augurConfig, endpoint);
600
726
  }
601
727
  return await read(response, augurConfig);
602
728
  } catch (error) {
729
+ throwIfEnded(call);
603
730
  this.rethrowOrWrapError(error, endpoint);
604
731
  } finally {
605
- clearTimeout(timeoutId);
732
+ attempt.dispose();
606
733
  }
607
734
  }
735
+ /**
736
+ * An attempt's timeout (the per-attempt one, cut to what is left of the call's deadline: what
737
+ * the onRequest hook sees) and whether it sets its own timer: only when it ends before the
738
+ * deadline; otherwise the call's one deadline timer cuts it, with a TimeoutError
739
+ * (client-rules.ts; AugurApiClient.OneTimerCutsEachAttempt).
740
+ */
741
+ attemptBounds(requestConfig, call) {
742
+ const perAttempt = this.timeoutFor(requestConfig);
743
+ const remaining = call.remaining();
744
+ return {
745
+ timeout: attemptTimeoutOf(perAttempt, call.hasDeadline, remaining),
746
+ ownTimer: needsAttemptTimer(perAttempt, call.hasDeadline, remaining)
747
+ };
748
+ }
749
+ /** The signal one attempt is sent with, and how to clear its timer and listeners after. */
750
+ attemptSignal(call, bounds) {
751
+ const controller = new AbortController();
752
+ const timeoutId = bounds.ownTimer ? setTimeout(() => controller.abort(), bounds.timeout) : void 0;
753
+ const merged = call.signal ? this.mergeSignals(call.signal, controller.signal) : { signal: controller.signal, dispose: () => {
754
+ } };
755
+ return {
756
+ signal: merged.signal,
757
+ dispose: () => {
758
+ clearTimeout(timeoutId);
759
+ merged.dispose();
760
+ }
761
+ };
762
+ }
608
763
  /** The request's timeout: per request, else the client's, else the default (timeoutOf). */
609
764
  timeoutFor(requestConfig) {
610
765
  const request = requestConfig?.timeout;
@@ -629,17 +784,20 @@ var HTTPClient = class {
629
784
  };
630
785
  }
631
786
  /**
632
- * Merge two AbortSignals — aborts when either fires
787
+ * Merge the call's signal and an attempt's timer: aborts when either fires, with that one's
788
+ * reason. `dispose` removes the listener from the call's signal, which outlives the attempt
789
+ * (one per attempt would pile up on a long-lived caller signal).
633
790
  */
634
- mergeSignals(userSignal, timeoutSignal) {
791
+ mergeSignals(callSignal, timeoutSignal) {
635
792
  const controller = new AbortController();
636
- const onAbort = () => controller.abort();
637
- userSignal.addEventListener("abort", onAbort, { once: true });
638
- timeoutSignal.addEventListener("abort", onAbort, { once: true });
639
- if (userSignal.aborted) {
640
- controller.abort();
641
- }
642
- return controller.signal;
793
+ const onCallAbort = () => controller.abort(callSignal.reason);
794
+ const onTimeout = () => controller.abort(timeoutSignal.reason);
795
+ callSignal.addEventListener("abort", onCallAbort, { once: true });
796
+ timeoutSignal.addEventListener("abort", onTimeout, { once: true });
797
+ return {
798
+ signal: controller.signal,
799
+ dispose: () => callSignal.removeEventListener("abort", onCallAbort)
800
+ };
643
801
  }
644
802
  /**
645
803
  * The one status-to-error switch, shared by typed methods and `call()`.
@@ -669,7 +827,7 @@ var HTTPClient = class {
669
827
  if (error instanceof AugurError) {
670
828
  throw error;
671
829
  }
672
- if (error instanceof DOMException && error.name === "AbortError") {
830
+ if (error instanceof DOMException && isAbortName(error.name)) {
673
831
  throw error;
674
832
  }
675
833
  this.handleNetworkError(error, endpoint);
@@ -686,25 +844,48 @@ var HTTPClient = class {
686
844
  /**
687
845
  * Executes a single request attempt
688
846
  */
689
- async executeAttempt(requestFn, attempt, maxRetries, baseDelay) {
847
+ async executeAttempt(requestFn, attempt, maxRetries, baseDelay, call) {
690
848
  try {
691
- return await requestFn();
849
+ return await this.attemptWithin(call, requestFn);
692
850
  } catch (error) {
693
- if (attempt >= maxRetries || !isRetryableError(error)) {
851
+ if (!retryAfterCall(attempt, maxRetries, isRetryableError(error), call.signal?.aborted === true)) {
694
852
  throw error;
695
853
  }
696
- const backoffDelay = calculateBackoffDelay(attempt, baseDelay);
697
- await delay(backoffDelay);
698
- return this.executeAttempt(requestFn, attempt + 1, maxRetries, baseDelay);
854
+ const backoffDelay = waitOf(
855
+ calculateBackoffDelay(attempt, baseDelay),
856
+ call.hasDeadline,
857
+ call.remaining()
858
+ );
859
+ await delay(backoffDelay, call.signal);
860
+ return this.executeAttempt(requestFn, attempt + 1, maxRetries, baseDelay, call);
861
+ }
862
+ }
863
+ /**
864
+ * One attempt, started only while the call's deadline has time left (client-rules.ts
865
+ * startsAttempt); past it the call rejects with a TimeoutError.
866
+ */
867
+ attemptWithin(call, requestFn) {
868
+ if (!startsAttempt(call.hasDeadline, call.remaining())) {
869
+ return Promise.reject(new DOMException("Call deadline exceeded", "TimeoutError"));
699
870
  }
871
+ return requestFn();
700
872
  }
701
873
  /**
702
874
  * Executes a request with retry logic
703
875
  */
704
- async executeWithRetry(requestFn) {
876
+ async executeWithRetry(requestFn, call) {
705
877
  const maxRetries = this.config.retries ?? DEFAULT_CONFIG.retries;
706
878
  const baseDelay = this.config.retryDelay ?? DEFAULT_CONFIG.retryDelay;
707
- return this.executeAttempt(requestFn, 0, maxRetries, baseDelay);
879
+ return this.executeAttempt(requestFn, 0, maxRetries, baseDelay, call);
880
+ }
881
+ /** Runs `fn` in a fresh call scope and disposes it, however `fn` settles. */
882
+ async withinCall(requestSignal, fn) {
883
+ const call = startCall(this.bounds, requestSignal);
884
+ try {
885
+ return await fn(call);
886
+ } finally {
887
+ call.dispose();
888
+ }
708
889
  }
709
890
  /**
710
891
  * Transform edgeCache parameter to Cloudflare's cacheSiteId format
@@ -732,19 +913,13 @@ var HTTPClient = class {
732
913
  if (edgeCache == null) {
733
914
  return params;
734
915
  }
735
- const validSubHourValues = ["30s", "1m", "5m"];
736
- const validHourlyValues = [1, 2, 3, 4, 5, 8];
737
- let cacheSuffix;
738
916
  const edgeCacheStr = String(edgeCache);
739
- if (validSubHourValues.includes(edgeCacheStr)) {
740
- cacheSuffix = edgeCacheStr;
741
- } else {
742
- const cacheHours = parseInt(edgeCacheStr, 10);
743
- if (!validHourlyValues.includes(cacheHours)) {
744
- return withoutEdgeCache(paramsObj);
745
- }
746
- cacheSuffix = String(cacheHours);
917
+ const cacheHours = parseInt(edgeCacheStr, 10);
918
+ const kind = edgeCacheKindOf(edgeCacheStr, cacheHours);
919
+ if (kind === "invalid") {
920
+ return withoutEdgeCache(paramsObj);
747
921
  }
922
+ const cacheSuffix = kind === "sub-hour" ? edgeCacheStr : String(cacheHours);
748
923
  const restParams = withoutEdgeCache(paramsObj);
749
924
  const cacheKey = `cacheSiteId${cacheSuffix}`;
750
925
  return {
@@ -756,40 +931,49 @@ var HTTPClient = class {
756
931
  const transformedParams = this.transformEdgeCacheParams(params);
757
932
  const method = "GET";
758
933
  const requestKey2 = generateRequestKey(method, url, transformedParams);
759
- const inflight = this.inflightRequests.get(requestKey2);
934
+ const shares = sharesInFlight(config?.signal !== void 0);
935
+ const inflight = shares ? this.inflightRequests.get(requestKey2) : void 0;
760
936
  if (inflight) {
761
937
  return inflight;
762
938
  }
763
- const requestPromise = this.executeWithRetry(
764
- () => this.request(method, url, { params: transformedParams, config })
765
- ).finally(() => {
939
+ const requestPromise = this.withinCall(
940
+ config?.signal,
941
+ (call) => this.executeWithRetry(
942
+ () => this.request(method, url, { params: transformedParams, config }, call),
943
+ call
944
+ )
945
+ );
946
+ if (!shares) return requestPromise;
947
+ const shared = requestPromise.finally(() => {
766
948
  this.inflightRequests.delete(requestKey2);
767
949
  });
768
- this.inflightRequests.set(requestKey2, requestPromise);
769
- return requestPromise;
950
+ this.inflightRequests.set(requestKey2, shared);
951
+ return shared;
770
952
  }
771
953
  // The API declares query params on POST/PUT/DELETE as well as GET. `request`
772
954
  // already carries both a body and a query slot; these wrappers simply never
773
955
  // exposed the latter, leaving those params unreachable from the clients.
956
+ // Writes make one attempt (never retried), bounded by the call's scope like a GET.
774
957
  async post(url, data, params, config) {
775
- return this.request("POST", url, {
776
- data,
777
- params: this.transformEdgeCacheParams(params),
778
- config
779
- });
958
+ const options = { data, params: this.transformEdgeCacheParams(params), config };
959
+ return this.withinCall(
960
+ config?.signal,
961
+ (call) => this.attemptWithin(call, () => this.request("POST", url, options, call))
962
+ );
780
963
  }
781
964
  async put(url, data, params, config) {
782
- return this.request("PUT", url, {
783
- data,
784
- params: this.transformEdgeCacheParams(params),
785
- config
786
- });
965
+ const options = { data, params: this.transformEdgeCacheParams(params), config };
966
+ return this.withinCall(
967
+ config?.signal,
968
+ (call) => this.attemptWithin(call, () => this.request("PUT", url, options, call))
969
+ );
787
970
  }
788
971
  async delete(url, params, config) {
789
- return this.request("DELETE", url, {
790
- params: this.transformEdgeCacheParams(params),
791
- config
792
- });
972
+ const options = { params: this.transformEdgeCacheParams(params), config };
973
+ return this.withinCall(
974
+ config?.signal,
975
+ (call) => this.attemptWithin(call, () => this.request("DELETE", url, options, call))
976
+ );
793
977
  }
794
978
  /**
795
979
  * Send a request and return the 2xx response as text, with no schema
@@ -798,13 +982,17 @@ var HTTPClient = class {
798
982
  * in-flight deduplication); other methods make one attempt, like `post()`.
799
983
  */
800
984
  async raw(method, url, options = {}) {
801
- const send = () => this.request(
802
- method,
803
- url,
804
- { ...options, params: this.transformEdgeCacheParams(options.params) },
805
- (response, augurConfig) => this.readRaw(response, augurConfig)
806
- );
807
- return method === "GET" ? this.executeWithRetry(send) : send();
985
+ const requestOptions = { ...options, params: this.transformEdgeCacheParams(options.params) };
986
+ return this.withinCall(options.config?.signal, (call) => {
987
+ const send = () => this.request(
988
+ method,
989
+ url,
990
+ requestOptions,
991
+ call,
992
+ (response, augurConfig) => this.readRaw(response, augurConfig)
993
+ );
994
+ return rawRetries(method) ? this.executeWithRetry(send, call) : this.attemptWithin(call, send);
995
+ });
808
996
  }
809
997
  };
810
998
 
@@ -852,13 +1040,21 @@ var validatePathSegment = (pathTemplate, name, value, pattern, service = "http-c
852
1040
  }
853
1041
  };
854
1042
 
855
- // ../utils/src/case.ts
1043
+ // ../utils/src/case-spec.ts
856
1044
  var UPPER = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
857
1045
  function upperFirst(s) {
858
1046
  const c = codeAt(s, 0);
859
1047
  if (c >= 97 && c <= 122) return UPPER.slice(c - 97, c - 96) + s.slice(1);
860
1048
  return s;
861
1049
  }
1050
+ function kebabCamelFrom(s, up) {
1051
+ if (s.length === 0) return "";
1052
+ if (s.charCodeAt(0) === 45) return kebabCamelFrom(s.slice(1), true);
1053
+ const one = s.slice(0, 1);
1054
+ return (up ? upperFirst(one) : one) + kebabCamelFrom(s.slice(1), false);
1055
+ }
1056
+
1057
+ // ../utils/src/case.ts
862
1058
  function foldName(s) {
863
1059
  if (s.length === 0) return "";
864
1060
  const c = s.charCodeAt(0);
@@ -874,12 +1070,6 @@ function snakeCamel(s) {
874
1070
  if (s.length === 0) return "";
875
1071
  return s.slice(0, 1) + snakeCamel(s.slice(1));
876
1072
  }
877
- function kebabCamelFrom(s, up) {
878
- if (s.length === 0) return "";
879
- if (s.charCodeAt(0) === 45) return kebabCamelFrom(s.slice(1), true);
880
- const one = s.slice(0, 1);
881
- return (up ? upperFirst(one) : one) + kebabCamelFrom(s.slice(1), false);
882
- }
883
1073
  function kebabCamel(s) {
884
1074
  return kebabCamelFrom(s, false);
885
1075
  }
@@ -39745,14 +39935,14 @@ function toEnvelope(body) {
39745
39935
  }
39746
39936
  return Object.fromEntries(ENVELOPE_KEYS.map((key) => [key, record32[key]]));
39747
39937
  }
39748
- async function callEndpoint(config, id, args = {}) {
39938
+ async function callEndpoint(config, id, args = {}, bounds = NO_BOUNDS) {
39749
39939
  const entry = resolveEndpoint(id);
39750
39940
  if (!entry) {
39751
39941
  throw invalid(unknownIdMessage(id));
39752
39942
  }
39753
39943
  checkArgs(entry, args);
39754
39944
  const url = serviceUrl(entry.service, fillPath(entry, args.pathParams ?? {}));
39755
- const raw = await new HTTPClient(entry.service, config).raw(entry.method, url, {
39945
+ const raw = await new HTTPClient(entry.service, config, bounds).raw(entry.method, url, {
39756
39946
  params: args.query,
39757
39947
  data: args.body ?? void 0,
39758
39948
  config: { endpoint: entry.path }
@@ -39769,18 +39959,18 @@ function isSiteChar(c) {
39769
39959
  function siteCharsFrom(s, i) {
39770
39960
  return i >= s.length || isSiteChar(s.charCodeAt(i)) && siteCharsFrom(s, i + 1);
39771
39961
  }
39772
- function isSiteKey(s) {
39962
+ function isSiteId(s) {
39773
39963
  return s.length > 0 && siteCharsFrom(s, 0);
39774
39964
  }
39775
39965
 
39776
39966
  // src/core/site-id-check.ts
39777
- function isSiteId(s) {
39778
- return isSiteKey(s);
39967
+ function isSiteId2(s) {
39968
+ return isSiteId(s);
39779
39969
  }
39780
39970
 
39781
39971
  // src/core/site-id.ts
39782
39972
  function parseSiteId(value) {
39783
- return isSiteId(value) ? value : void 0;
39973
+ return isSiteId2(value) ? value : void 0;
39784
39974
  }
39785
39975
  function assertSiteId(value) {
39786
39976
  const site = parseSiteId(value);
@@ -41806,8 +41996,32 @@ var Basecamp2Client = class extends BaseServiceClient {
41806
41996
  };
41807
41997
 
41808
41998
  // src/client.ts
41999
+ function mergedBounds(outer, signal, deadline) {
42000
+ const signals = signal === void 0 ? outer.signals : [...outer.signals, signal];
42001
+ const hasOuter = outer.deadline !== void 0;
42002
+ const hasInner = deadline !== void 0;
42003
+ if (!hasMergedDeadline(hasOuter, hasInner)) return { signals };
42004
+ return {
42005
+ signals,
42006
+ deadline: mergedDeadlineOf(hasOuter, outer.deadline ?? 0, hasInner, deadline ?? 0)
42007
+ };
42008
+ }
42009
+ var CONTEXT_REFUSALS = {
42010
+ context: () => new ContextCreationError("Context is required", "context"),
42011
+ "site-id": () => new ContextCreationError("Context must contain siteId", "siteId"),
42012
+ token: () => new ContextCreationError(
42013
+ "Context must contain jwt or bearerToken for authentication",
42014
+ "bearerToken"
42015
+ ),
42016
+ "token-removed": () => new ContextCreationError(
42017
+ "fromContext options must not remove the context's bearer token",
42018
+ "bearerToken"
42019
+ )
42020
+ };
41809
42021
  var AugurAPI = class _AugurAPI {
41810
42022
  config;
42023
+ /** This client's call bounds: none, unless it is a view from `withRequest`. */
42024
+ bounds = NO_BOUNDS;
41811
42025
  _joomla;
41812
42026
  _commerce;
41813
42027
  _pricing;
@@ -41870,7 +42084,52 @@ var AugurAPI = class _AugurAPI {
41870
42084
  * ```
41871
42085
  */
41872
42086
  call(id, args) {
41873
- return callEndpoint(this.config, id, args);
42087
+ return callEndpoint(this.config, id, args, this.bounds);
42088
+ }
42089
+ /**
42090
+ * A view of this client whose every call is bounded by `options` (atlas#106): the caller's
42091
+ * `signal`, and a `deadline` in milliseconds for the whole call, retries and the waits between
42092
+ * them included. The view has this client's siteId, token, timeouts, retries and hooks, sends
42093
+ * the same headers, and builds its own service clients (sharing no in-flight request with this
42094
+ * one). Building a view and its first service costs about what building this client did, so
42095
+ * make one per bounded call, not per request inside a loop.
42096
+ *
42097
+ * @example
42098
+ * ```typescript
42099
+ * const items = await api.withRequest({ deadline: 5000 }).items.categories.items.list(uid, params);
42100
+ * ```
42101
+ *
42102
+ * @throws InvalidArgumentError when `signal` is given but not an AbortSignal, or `deadline` is
42103
+ * given but not a number from 0 to 2147483647 (NaN, Infinity or larger would fire at once).
42104
+ * Options can come from a browser through a server action, so their shape is checked.
42105
+ */
42106
+ withRequest(options) {
42107
+ const signal = options?.signal;
42108
+ const deadline = options?.deadline;
42109
+ const accepted = callOptionsAccepted(
42110
+ signal !== void 0,
42111
+ signal instanceof AbortSignal,
42112
+ deadline !== void 0,
42113
+ typeof deadline === "number" && deadlineInRange(deadline)
42114
+ );
42115
+ if (!accepted) {
42116
+ throw new InvalidArgumentError({
42117
+ message: "Invalid call options: signal must be an AbortSignal, deadline a number of milliseconds from 0 to 2147483647",
42118
+ service: "",
42119
+ endpoint: ""
42120
+ });
42121
+ }
42122
+ const view = new _AugurAPI(this.config);
42123
+ view.bounds = mergedBounds(
42124
+ this.bounds,
42125
+ signal,
42126
+ deadline
42127
+ );
42128
+ return view;
42129
+ }
42130
+ /** The HTTP client a service is built with: this client's config and call bounds. */
42131
+ httpFor(service) {
42132
+ return new HTTPClient(service, this.config, this.bounds);
41874
42133
  }
41875
42134
  /**
41876
42135
  * Create AugurAPI client from context object
@@ -41898,25 +42157,19 @@ var AugurAPI = class _AugurAPI {
41898
42157
  * @throws {ContextCreationError} When context is invalid or missing required fields
41899
42158
  */
41900
42159
  static fromContext(context, options = {}) {
41901
- if (!context) {
41902
- throw new ContextCreationError("Context is required", "context");
41903
- }
41904
- if (!context.siteId) {
41905
- throw new ContextCreationError("Context must contain siteId", "siteId");
41906
- }
41907
- const bearerToken = context.jwt || context.bearerToken;
41908
- if (!bearerToken) {
41909
- throw new ContextCreationError(
41910
- "Context must contain jwt or bearerToken for authentication",
41911
- "bearerToken"
41912
- );
41913
- }
42160
+ const bearerToken = context?.jwt || context?.bearerToken;
41914
42161
  const config = {
41915
- siteId: context.siteId,
42162
+ siteId: context?.siteId ?? "",
41916
42163
  bearerToken,
41917
42164
  ...options
41918
- // Allow overrides
41919
42165
  };
42166
+ const refusal = contextRefusalOf(
42167
+ Boolean(context),
42168
+ Boolean(context?.siteId),
42169
+ Boolean(bearerToken),
42170
+ Boolean(config.bearerToken)
42171
+ );
42172
+ if (refusal !== "ok") throw CONTEXT_REFUSALS[refusal]();
41920
42173
  return new _AugurAPI(config);
41921
42174
  }
41922
42175
  /**
@@ -41924,7 +42177,7 @@ var AugurAPI = class _AugurAPI {
41924
42177
  */
41925
42178
  get joomla() {
41926
42179
  if (!this._joomla) {
41927
- const httpClient = new HTTPClient("joomla", this.config);
42180
+ const httpClient = this.httpFor("joomla");
41928
42181
  this._joomla = new JoomlaClient(httpClient);
41929
42182
  }
41930
42183
  return this._joomla;
@@ -41934,7 +42187,7 @@ var AugurAPI = class _AugurAPI {
41934
42187
  */
41935
42188
  get commerce() {
41936
42189
  if (!this._commerce) {
41937
- const httpClient = new HTTPClient("commerce", this.config);
42190
+ const httpClient = this.httpFor("commerce");
41938
42191
  this._commerce = new CommerceClient(httpClient);
41939
42192
  }
41940
42193
  return this._commerce;
@@ -41944,7 +42197,7 @@ var AugurAPI = class _AugurAPI {
41944
42197
  */
41945
42198
  get pricing() {
41946
42199
  if (!this._pricing) {
41947
- const httpClient = new HTTPClient("pricing", this.config);
42200
+ const httpClient = this.httpFor("pricing");
41948
42201
  this._pricing = new PricingClient(httpClient);
41949
42202
  }
41950
42203
  return this._pricing;
@@ -41954,7 +42207,7 @@ var AugurAPI = class _AugurAPI {
41954
42207
  */
41955
42208
  get vmi() {
41956
42209
  if (!this._vmi) {
41957
- const httpClient = new HTTPClient("vmi", this.config);
42210
+ const httpClient = this.httpFor("vmi");
41958
42211
  this._vmi = new VMIClient(httpClient);
41959
42212
  }
41960
42213
  return this._vmi;
@@ -41964,7 +42217,7 @@ var AugurAPI = class _AugurAPI {
41964
42217
  */
41965
42218
  get openSearch() {
41966
42219
  if (!this._openSearch) {
41967
- const httpClient = new HTTPClient("open-search", this.config);
42220
+ const httpClient = this.httpFor("open-search");
41968
42221
  this._openSearch = new OpenSearchClient(httpClient);
41969
42222
  }
41970
42223
  return this._openSearch;
@@ -41974,7 +42227,7 @@ var AugurAPI = class _AugurAPI {
41974
42227
  */
41975
42228
  get items() {
41976
42229
  if (!this._items) {
41977
- const httpClient = new HTTPClient("items", this.config);
42230
+ const httpClient = this.httpFor("items");
41978
42231
  this._items = new ItemsClient(httpClient);
41979
42232
  }
41980
42233
  return this._items;
@@ -41984,7 +42237,7 @@ var AugurAPI = class _AugurAPI {
41984
42237
  */
41985
42238
  get legacy() {
41986
42239
  if (!this._legacy) {
41987
- const httpClient = new HTTPClient("legacy", this.config);
42240
+ const httpClient = this.httpFor("legacy");
41988
42241
  this._legacy = new LegacyClient(httpClient);
41989
42242
  }
41990
42243
  return this._legacy;
@@ -41994,7 +42247,7 @@ var AugurAPI = class _AugurAPI {
41994
42247
  */
41995
42248
  get agrSite() {
41996
42249
  if (!this._agrSite) {
41997
- const httpClient = new HTTPClient("agr-site", this.config);
42250
+ const httpClient = this.httpFor("agr-site");
41998
42251
  this._agrSite = new AgrSiteClient(httpClient);
41999
42252
  }
42000
42253
  return this._agrSite;
@@ -42004,7 +42257,7 @@ var AugurAPI = class _AugurAPI {
42004
42257
  */
42005
42258
  get customers() {
42006
42259
  if (!this._customers) {
42007
- const httpClient = new HTTPClient("customers", this.config);
42260
+ const httpClient = this.httpFor("customers");
42008
42261
  this._customers = new CustomersClient(httpClient);
42009
42262
  }
42010
42263
  return this._customers;
@@ -42014,7 +42267,7 @@ var AugurAPI = class _AugurAPI {
42014
42267
  */
42015
42268
  get orders() {
42016
42269
  if (!this._orders) {
42017
- const httpClient = new HTTPClient("orders", this.config);
42270
+ const httpClient = this.httpFor("orders");
42018
42271
  this._orders = new OrdersClient(httpClient);
42019
42272
  }
42020
42273
  return this._orders;
@@ -42024,7 +42277,7 @@ var AugurAPI = class _AugurAPI {
42024
42277
  */
42025
42278
  get p21Pim() {
42026
42279
  if (!this._p21Pim) {
42027
- const httpClient = new HTTPClient("p21-pim", this.config);
42280
+ const httpClient = this.httpFor("p21-pim");
42028
42281
  this._p21Pim = new P21PimClient(httpClient);
42029
42282
  }
42030
42283
  return this._p21Pim;
@@ -42034,7 +42287,7 @@ var AugurAPI = class _AugurAPI {
42034
42287
  */
42035
42288
  get payments() {
42036
42289
  if (!this._payments) {
42037
- const httpClient = new HTTPClient("payments", this.config);
42290
+ const httpClient = this.httpFor("payments");
42038
42291
  this._payments = new PaymentsClient(httpClient);
42039
42292
  }
42040
42293
  return this._payments;
@@ -42044,7 +42297,7 @@ var AugurAPI = class _AugurAPI {
42044
42297
  */
42045
42298
  get agrInfo() {
42046
42299
  if (!this._agrInfo) {
42047
- const httpClient = new HTTPClient("agr-info", this.config);
42300
+ const httpClient = this.httpFor("agr-info");
42048
42301
  this._agrInfo = new AgrInfoClient(httpClient);
42049
42302
  }
42050
42303
  return this._agrInfo;
@@ -42054,7 +42307,7 @@ var AugurAPI = class _AugurAPI {
42054
42307
  */
42055
42308
  get agrInt() {
42056
42309
  if (!this._agrInt) {
42057
- const httpClient = new HTTPClient("agr-int", this.config);
42310
+ const httpClient = this.httpFor("agr-int");
42058
42311
  this._agrInt = new AgrIntClient(httpClient);
42059
42312
  }
42060
42313
  return this._agrInt;
@@ -42064,7 +42317,7 @@ var AugurAPI = class _AugurAPI {
42064
42317
  */
42065
42318
  get agrWork() {
42066
42319
  if (!this._agrWork) {
42067
- const httpClient = new HTTPClient("agr-work", this.config);
42320
+ const httpClient = this.httpFor("agr-work");
42068
42321
  this._agrWork = new AgrWorkClient(httpClient);
42069
42322
  }
42070
42323
  return this._agrWork;
@@ -42074,7 +42327,7 @@ var AugurAPI = class _AugurAPI {
42074
42327
  */
42075
42328
  get avalara() {
42076
42329
  if (!this._avalara) {
42077
- const httpClient = new HTTPClient("avalara", this.config);
42330
+ const httpClient = this.httpFor("avalara");
42078
42331
  this._avalara = new AvalaraClient(httpClient);
42079
42332
  }
42080
42333
  return this._avalara;
@@ -42084,7 +42337,7 @@ var AugurAPI = class _AugurAPI {
42084
42337
  */
42085
42338
  get brandFolder() {
42086
42339
  if (!this._brandFolder) {
42087
- const httpClient = new HTTPClient("brand-folder", this.config);
42340
+ const httpClient = this.httpFor("brand-folder");
42088
42341
  this._brandFolder = new BrandFolderClient(httpClient);
42089
42342
  }
42090
42343
  return this._brandFolder;
@@ -42094,7 +42347,7 @@ var AugurAPI = class _AugurAPI {
42094
42347
  */
42095
42348
  get googMc() {
42096
42349
  if (!this._googMc) {
42097
- const httpClient = new HTTPClient("goog-mc", this.config);
42350
+ const httpClient = this.httpFor("goog-mc");
42098
42351
  this._googMc = new GoogMcClient(httpClient);
42099
42352
  }
42100
42353
  return this._googMc;
@@ -42104,7 +42357,7 @@ var AugurAPI = class _AugurAPI {
42104
42357
  */
42105
42358
  get gregorovich() {
42106
42359
  if (!this._gregorovich) {
42107
- const httpClient = new HTTPClient("gregorovich", this.config);
42360
+ const httpClient = this.httpFor("gregorovich");
42108
42361
  this._gregorovich = new GregorovichClient(httpClient);
42109
42362
  }
42110
42363
  return this._gregorovich;
@@ -42114,7 +42367,7 @@ var AugurAPI = class _AugurAPI {
42114
42367
  */
42115
42368
  get logistics() {
42116
42369
  if (!this._logistics) {
42117
- const httpClient = new HTTPClient("logistics", this.config);
42370
+ const httpClient = this.httpFor("logistics");
42118
42371
  this._logistics = new LogisticsClient(httpClient);
42119
42372
  }
42120
42373
  return this._logistics;
@@ -42124,7 +42377,7 @@ var AugurAPI = class _AugurAPI {
42124
42377
  */
42125
42378
  get markets() {
42126
42379
  if (!this._markets) {
42127
- const httpClient = new HTTPClient("markets", this.config);
42380
+ const httpClient = this.httpFor("markets");
42128
42381
  this._markets = new MarketsClient(httpClient);
42129
42382
  }
42130
42383
  return this._markets;
@@ -42134,7 +42387,7 @@ var AugurAPI = class _AugurAPI {
42134
42387
  */
42135
42388
  get notifications() {
42136
42389
  if (!this._notifications) {
42137
- const httpClient = new HTTPClient("notifications", this.config);
42390
+ const httpClient = this.httpFor("notifications");
42138
42391
  this._notifications = new NotificationsClient(httpClient);
42139
42392
  }
42140
42393
  return this._notifications;
@@ -42144,7 +42397,7 @@ var AugurAPI = class _AugurAPI {
42144
42397
  */
42145
42398
  get p21Apis() {
42146
42399
  if (!this._p21Apis) {
42147
- const httpClient = new HTTPClient("p21-apis", this.config);
42400
+ const httpClient = this.httpFor("p21-apis");
42148
42401
  this._p21Apis = new P21ApisClient(httpClient);
42149
42402
  }
42150
42403
  return this._p21Apis;
@@ -42154,7 +42407,7 @@ var AugurAPI = class _AugurAPI {
42154
42407
  */
42155
42408
  get p21Core() {
42156
42409
  if (!this._p21Core) {
42157
- const httpClient = new HTTPClient("p21-core", this.config);
42410
+ const httpClient = this.httpFor("p21-core");
42158
42411
  this._p21Core = new P21CoreClient(httpClient);
42159
42412
  }
42160
42413
  return this._p21Core;
@@ -42164,7 +42417,7 @@ var AugurAPI = class _AugurAPI {
42164
42417
  */
42165
42418
  get p21Sism() {
42166
42419
  if (!this._p21Sism) {
42167
- const httpClient = new HTTPClient("p21-sism", this.config);
42420
+ const httpClient = this.httpFor("p21-sism");
42168
42421
  this._p21Sism = new P21SismClient(httpClient);
42169
42422
  }
42170
42423
  return this._p21Sism;
@@ -42174,7 +42427,7 @@ var AugurAPI = class _AugurAPI {
42174
42427
  */
42175
42428
  get shipping() {
42176
42429
  if (!this._shipping) {
42177
- const httpClient = new HTTPClient("shipping", this.config);
42430
+ const httpClient = this.httpFor("shipping");
42178
42431
  this._shipping = new ShippingClient(httpClient);
42179
42432
  }
42180
42433
  return this._shipping;
@@ -42184,7 +42437,7 @@ var AugurAPI = class _AugurAPI {
42184
42437
  */
42185
42438
  get smartyStreets() {
42186
42439
  if (!this._smartyStreets) {
42187
- const httpClient = new HTTPClient("smarty-streets", this.config);
42440
+ const httpClient = this.httpFor("smarty-streets");
42188
42441
  this._smartyStreets = new SmartyStreetsClient(httpClient);
42189
42442
  }
42190
42443
  return this._smartyStreets;
@@ -42194,7 +42447,7 @@ var AugurAPI = class _AugurAPI {
42194
42447
  */
42195
42448
  get ups() {
42196
42449
  if (!this._ups) {
42197
- const httpClient = new HTTPClient("ups", this.config);
42450
+ const httpClient = this.httpFor("ups");
42198
42451
  this._ups = new UPSClient(httpClient);
42199
42452
  }
42200
42453
  return this._ups;
@@ -42204,7 +42457,7 @@ var AugurAPI = class _AugurAPI {
42204
42457
  */
42205
42458
  get vendors() {
42206
42459
  if (!this._vendors) {
42207
- const httpClient = new HTTPClient("vendors", this.config);
42460
+ const httpClient = this.httpFor("vendors");
42208
42461
  this._vendors = new VendorsClient(httpClient);
42209
42462
  }
42210
42463
  return this._vendors;
@@ -42214,13 +42467,18 @@ var AugurAPI = class _AugurAPI {
42214
42467
  */
42215
42468
  get basecamp2() {
42216
42469
  if (!this._basecamp2) {
42217
- const httpClient = new HTTPClient("basecamp2", this.config);
42470
+ const httpClient = this.httpFor("basecamp2");
42218
42471
  this._basecamp2 = new Basecamp2Client(httpClient);
42219
42472
  }
42220
42473
  return this._basecamp2;
42221
42474
  }
42222
42475
  /**
42223
42476
  * Update authentication token
42477
+ *
42478
+ * Every service read from this client afterwards (`api.items`, …) sends the new token. A
42479
+ * service object read BEFORE the change keeps the token it was built with: read services from
42480
+ * the client after a change, don't hold them across it (AugurApiClient.BuiltClientKeepsItsSnapshot).
42481
+ *
42224
42482
  * @param bearerToken New bearer token
42225
42483
  */
42226
42484
  setAuthToken(bearerToken) {
@@ -42229,6 +42487,9 @@ var AugurAPI = class _AugurAPI {
42229
42487
  }
42230
42488
  /**
42231
42489
  * Update site ID
42490
+ *
42491
+ * As with `setAuthToken`: a service object read before the change keeps the old siteId.
42492
+ *
42232
42493
  * @param siteId New site ID
42233
42494
  * @throws InvalidArgumentError when it is not a siteId (see the constructor)
42234
42495
  */
@@ -42325,7 +42586,7 @@ function createCrossSiteAuthenticator(augurInfoToken) {
42325
42586
  }
42326
42587
 
42327
42588
  // src/index.ts
42328
- var VERSION = "2026.11.1";
42589
+ var VERSION = "2026.11.4";
42329
42590
  // Annotate the CommonJS export names for ESM import in node:
42330
42591
  0 && (module.exports = {
42331
42592
  AgrInfoClient,