@simpleapps-com/augur-api 2026.11.3 → 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.
- package/README.md +40 -3
- package/dist/client.d.ts +31 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/core/call.d.ts +2 -2
- package/dist/core/call.d.ts.map +1 -1
- package/dist/core/client-rules.d.ts +122 -0
- package/dist/core/client-rules.d.ts.map +1 -0
- package/dist/core/client.d.ts +25 -4
- package/dist/core/client.d.ts.map +1 -1
- package/dist/core/config.d.ts +24 -0
- package/dist/core/config.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +405 -159
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +405 -159
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -253,11 +253,6 @@ function placeholderFilled(path, placeholder, segment) {
|
|
|
253
253
|
return replaceText(path, "{" + placeholder + "}", segment);
|
|
254
254
|
}
|
|
255
255
|
|
|
256
|
-
// ../json-values/src/index.ts
|
|
257
|
-
function isRecord(value) {
|
|
258
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
259
|
-
}
|
|
260
|
-
|
|
261
256
|
// ../foundation/src/duration.ts
|
|
262
257
|
function seconds(n) {
|
|
263
258
|
return n;
|
|
@@ -267,6 +262,7 @@ function toMillis(d) {
|
|
|
267
262
|
}
|
|
268
263
|
|
|
269
264
|
// src/core/config.ts
|
|
265
|
+
var NO_BOUNDS = { signals: [] };
|
|
270
266
|
var DEFAULT_CONFIG = {
|
|
271
267
|
timeout: toMillis(seconds(30)),
|
|
272
268
|
retries: 3,
|
|
@@ -281,6 +277,105 @@ var ContextCreationError = class extends Error {
|
|
|
281
277
|
field;
|
|
282
278
|
};
|
|
283
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
|
+
|
|
284
379
|
// src/core/errors.ts
|
|
285
380
|
var AugurError = class _AugurError extends Error {
|
|
286
381
|
code;
|
|
@@ -392,40 +487,6 @@ var InvalidArgumentError = class extends AugurError {
|
|
|
392
487
|
}
|
|
393
488
|
};
|
|
394
489
|
|
|
395
|
-
// src/core/http-rules.ts
|
|
396
|
-
function isRetryableStatus(status) {
|
|
397
|
-
return !(status >= 400 && status < 500 && status !== 429);
|
|
398
|
-
}
|
|
399
|
-
function exponentialDelay(base, attempt) {
|
|
400
|
-
if (attempt === 0) return base;
|
|
401
|
-
return 2 * exponentialDelay(base, attempt - 1);
|
|
402
|
-
}
|
|
403
|
-
function cappedDelay(d) {
|
|
404
|
-
return Math.min(d, 3e4);
|
|
405
|
-
}
|
|
406
|
-
function timeoutOf(hasRequest, request, hasClient, client, fallback) {
|
|
407
|
-
if (hasRequest) return request;
|
|
408
|
-
return hasClient ? client : fallback;
|
|
409
|
-
}
|
|
410
|
-
function isPublicEndpoint(url) {
|
|
411
|
-
return endsWith(url, "/health-check") || endsWith(url, "/ping");
|
|
412
|
-
}
|
|
413
|
-
function sendsBearer(url, hasToken) {
|
|
414
|
-
return hasToken && !isPublicEndpoint(url);
|
|
415
|
-
}
|
|
416
|
-
function sendsJsonBody(hasData, method) {
|
|
417
|
-
return hasData && method !== "GET";
|
|
418
|
-
}
|
|
419
|
-
function querySeparator(url) {
|
|
420
|
-
return includesFrom(url, "?", 0) ? "&" : "?";
|
|
421
|
-
}
|
|
422
|
-
function requestKey(method, url, params) {
|
|
423
|
-
return method + ":" + url + ":" + params;
|
|
424
|
-
}
|
|
425
|
-
function isEdgeCacheParam(key) {
|
|
426
|
-
return key === "edgeCache";
|
|
427
|
-
}
|
|
428
|
-
|
|
429
490
|
// src/core/client.ts
|
|
430
491
|
function parseJson(text) {
|
|
431
492
|
try {
|
|
@@ -460,10 +521,59 @@ function calculateBackoffDelay(attempt, baseDelay) {
|
|
|
460
521
|
return cappedDelay(exponential + jitter);
|
|
461
522
|
}
|
|
462
523
|
function isRetryableError(error) {
|
|
463
|
-
|
|
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
|
+
});
|
|
464
539
|
}
|
|
465
|
-
|
|
466
|
-
|
|
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;
|
|
549
|
+
}
|
|
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
|
+
};
|
|
467
577
|
}
|
|
468
578
|
function withoutEdgeCache(params) {
|
|
469
579
|
return Object.fromEntries(Object.entries(params).filter(([key]) => !isEdgeCacheParam(key)));
|
|
@@ -507,18 +617,22 @@ var HTTPClient = class {
|
|
|
507
617
|
config;
|
|
508
618
|
serviceName;
|
|
509
619
|
inflightRequests = /* @__PURE__ */ new Map();
|
|
510
|
-
|
|
620
|
+
bounds;
|
|
621
|
+
/** `bounds` bound every call this client makes (a view's, from `AugurAPI.withRequest`). */
|
|
622
|
+
constructor(serviceName, config, bounds = NO_BOUNDS) {
|
|
511
623
|
this.serviceName = serviceName;
|
|
512
624
|
this.config = { ...DEFAULT_CONFIG, ...config };
|
|
625
|
+
this.bounds = bounds;
|
|
513
626
|
}
|
|
514
627
|
/**
|
|
515
|
-
* 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).
|
|
516
630
|
*/
|
|
517
631
|
buildRequestHeaders(url, requestConfig) {
|
|
518
632
|
const headers = {
|
|
519
633
|
"Content-Type": "application/json",
|
|
520
|
-
|
|
521
|
-
|
|
634
|
+
...requestConfig?.headers,
|
|
635
|
+
"x-site-id": this.config.siteId
|
|
522
636
|
};
|
|
523
637
|
if (sendsBearer(url, Boolean(this.config.bearerToken))) {
|
|
524
638
|
headers["Authorization"] = `Bearer ${this.config.bearerToken}`;
|
|
@@ -594,30 +708,58 @@ var HTTPClient = class {
|
|
|
594
708
|
* Core request method using native fetch. `read` turns a 2xx response into
|
|
595
709
|
* the result, inside the same error handling and timeout as the fetch.
|
|
596
710
|
*/
|
|
597
|
-
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)) {
|
|
598
712
|
const { config: requestConfig } = options;
|
|
599
713
|
const endpoint = requestConfig?.endpoint ?? url;
|
|
600
|
-
const
|
|
601
|
-
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);
|
|
602
716
|
if (this.config.onRequest) {
|
|
603
717
|
augurConfig = await this.config.onRequest(augurConfig);
|
|
604
718
|
}
|
|
605
719
|
const fullUrl = buildUrlWithParams(augurConfig.url, augurConfig.params);
|
|
606
|
-
|
|
607
|
-
const
|
|
608
|
-
const signal = requestConfig?.signal ? this.mergeSignals(requestConfig.signal, controller.signal) : controller.signal;
|
|
720
|
+
throwIfEnded(call);
|
|
721
|
+
const attempt = this.attemptSignal(call, bounds);
|
|
609
722
|
try {
|
|
610
|
-
const response = await fetch(fullUrl, fetchOptionsFor(augurConfig, method, signal));
|
|
723
|
+
const response = await fetch(fullUrl, fetchOptionsFor(augurConfig, method, attempt.signal));
|
|
611
724
|
if (!response.ok) {
|
|
612
725
|
await this.handleFetchError(response, augurConfig, endpoint);
|
|
613
726
|
}
|
|
614
727
|
return await read(response, augurConfig);
|
|
615
728
|
} catch (error) {
|
|
729
|
+
throwIfEnded(call);
|
|
616
730
|
this.rethrowOrWrapError(error, endpoint);
|
|
617
731
|
} finally {
|
|
618
|
-
|
|
732
|
+
attempt.dispose();
|
|
619
733
|
}
|
|
620
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
|
+
}
|
|
621
763
|
/** The request's timeout: per request, else the client's, else the default (timeoutOf). */
|
|
622
764
|
timeoutFor(requestConfig) {
|
|
623
765
|
const request = requestConfig?.timeout;
|
|
@@ -642,17 +784,20 @@ var HTTPClient = class {
|
|
|
642
784
|
};
|
|
643
785
|
}
|
|
644
786
|
/**
|
|
645
|
-
* Merge
|
|
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).
|
|
646
790
|
*/
|
|
647
|
-
mergeSignals(
|
|
791
|
+
mergeSignals(callSignal, timeoutSignal) {
|
|
648
792
|
const controller = new AbortController();
|
|
649
|
-
const
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
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
|
+
};
|
|
656
801
|
}
|
|
657
802
|
/**
|
|
658
803
|
* The one status-to-error switch, shared by typed methods and `call()`.
|
|
@@ -682,7 +827,7 @@ var HTTPClient = class {
|
|
|
682
827
|
if (error instanceof AugurError) {
|
|
683
828
|
throw error;
|
|
684
829
|
}
|
|
685
|
-
if (error instanceof DOMException && error.name
|
|
830
|
+
if (error instanceof DOMException && isAbortName(error.name)) {
|
|
686
831
|
throw error;
|
|
687
832
|
}
|
|
688
833
|
this.handleNetworkError(error, endpoint);
|
|
@@ -699,25 +844,48 @@ var HTTPClient = class {
|
|
|
699
844
|
/**
|
|
700
845
|
* Executes a single request attempt
|
|
701
846
|
*/
|
|
702
|
-
async executeAttempt(requestFn, attempt, maxRetries, baseDelay) {
|
|
847
|
+
async executeAttempt(requestFn, attempt, maxRetries, baseDelay, call) {
|
|
703
848
|
try {
|
|
704
|
-
return await requestFn
|
|
849
|
+
return await this.attemptWithin(call, requestFn);
|
|
705
850
|
} catch (error) {
|
|
706
|
-
if (attempt
|
|
851
|
+
if (!retryAfterCall(attempt, maxRetries, isRetryableError(error), call.signal?.aborted === true)) {
|
|
707
852
|
throw error;
|
|
708
853
|
}
|
|
709
|
-
const backoffDelay =
|
|
710
|
-
|
|
711
|
-
|
|
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"));
|
|
712
870
|
}
|
|
871
|
+
return requestFn();
|
|
713
872
|
}
|
|
714
873
|
/**
|
|
715
874
|
* Executes a request with retry logic
|
|
716
875
|
*/
|
|
717
|
-
async executeWithRetry(requestFn) {
|
|
876
|
+
async executeWithRetry(requestFn, call) {
|
|
718
877
|
const maxRetries = this.config.retries ?? DEFAULT_CONFIG.retries;
|
|
719
878
|
const baseDelay = this.config.retryDelay ?? DEFAULT_CONFIG.retryDelay;
|
|
720
|
-
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
|
+
}
|
|
721
889
|
}
|
|
722
890
|
/**
|
|
723
891
|
* Transform edgeCache parameter to Cloudflare's cacheSiteId format
|
|
@@ -745,19 +913,13 @@ var HTTPClient = class {
|
|
|
745
913
|
if (edgeCache == null) {
|
|
746
914
|
return params;
|
|
747
915
|
}
|
|
748
|
-
const validSubHourValues = ["30s", "1m", "5m"];
|
|
749
|
-
const validHourlyValues = [1, 2, 3, 4, 5, 8];
|
|
750
|
-
let cacheSuffix;
|
|
751
916
|
const edgeCacheStr = String(edgeCache);
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
if (!validHourlyValues.includes(cacheHours)) {
|
|
757
|
-
return withoutEdgeCache(paramsObj);
|
|
758
|
-
}
|
|
759
|
-
cacheSuffix = String(cacheHours);
|
|
917
|
+
const cacheHours = parseInt(edgeCacheStr, 10);
|
|
918
|
+
const kind = edgeCacheKindOf(edgeCacheStr, cacheHours);
|
|
919
|
+
if (kind === "invalid") {
|
|
920
|
+
return withoutEdgeCache(paramsObj);
|
|
760
921
|
}
|
|
922
|
+
const cacheSuffix = kind === "sub-hour" ? edgeCacheStr : String(cacheHours);
|
|
761
923
|
const restParams = withoutEdgeCache(paramsObj);
|
|
762
924
|
const cacheKey = `cacheSiteId${cacheSuffix}`;
|
|
763
925
|
return {
|
|
@@ -769,40 +931,49 @@ var HTTPClient = class {
|
|
|
769
931
|
const transformedParams = this.transformEdgeCacheParams(params);
|
|
770
932
|
const method = "GET";
|
|
771
933
|
const requestKey2 = generateRequestKey(method, url, transformedParams);
|
|
772
|
-
const
|
|
934
|
+
const shares = sharesInFlight(config?.signal !== void 0);
|
|
935
|
+
const inflight = shares ? this.inflightRequests.get(requestKey2) : void 0;
|
|
773
936
|
if (inflight) {
|
|
774
937
|
return inflight;
|
|
775
938
|
}
|
|
776
|
-
const requestPromise = this.
|
|
777
|
-
|
|
778
|
-
|
|
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(() => {
|
|
779
948
|
this.inflightRequests.delete(requestKey2);
|
|
780
949
|
});
|
|
781
|
-
this.inflightRequests.set(requestKey2,
|
|
782
|
-
return
|
|
950
|
+
this.inflightRequests.set(requestKey2, shared);
|
|
951
|
+
return shared;
|
|
783
952
|
}
|
|
784
953
|
// The API declares query params on POST/PUT/DELETE as well as GET. `request`
|
|
785
954
|
// already carries both a body and a query slot; these wrappers simply never
|
|
786
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.
|
|
787
957
|
async post(url, data, params, config) {
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
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
|
+
);
|
|
793
963
|
}
|
|
794
964
|
async put(url, data, params, config) {
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
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
|
+
);
|
|
800
970
|
}
|
|
801
971
|
async delete(url, params, config) {
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
config
|
|
805
|
-
|
|
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
|
+
);
|
|
806
977
|
}
|
|
807
978
|
/**
|
|
808
979
|
* Send a request and return the 2xx response as text, with no schema
|
|
@@ -811,13 +982,17 @@ var HTTPClient = class {
|
|
|
811
982
|
* in-flight deduplication); other methods make one attempt, like `post()`.
|
|
812
983
|
*/
|
|
813
984
|
async raw(method, url, options = {}) {
|
|
814
|
-
const
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
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
|
+
});
|
|
821
996
|
}
|
|
822
997
|
};
|
|
823
998
|
|
|
@@ -39760,14 +39935,14 @@ function toEnvelope(body) {
|
|
|
39760
39935
|
}
|
|
39761
39936
|
return Object.fromEntries(ENVELOPE_KEYS.map((key) => [key, record32[key]]));
|
|
39762
39937
|
}
|
|
39763
|
-
async function callEndpoint(config, id, args = {}) {
|
|
39938
|
+
async function callEndpoint(config, id, args = {}, bounds = NO_BOUNDS) {
|
|
39764
39939
|
const entry = resolveEndpoint(id);
|
|
39765
39940
|
if (!entry) {
|
|
39766
39941
|
throw invalid(unknownIdMessage(id));
|
|
39767
39942
|
}
|
|
39768
39943
|
checkArgs(entry, args);
|
|
39769
39944
|
const url = serviceUrl(entry.service, fillPath(entry, args.pathParams ?? {}));
|
|
39770
|
-
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, {
|
|
39771
39946
|
params: args.query,
|
|
39772
39947
|
data: args.body ?? void 0,
|
|
39773
39948
|
config: { endpoint: entry.path }
|
|
@@ -41821,8 +41996,32 @@ var Basecamp2Client = class extends BaseServiceClient {
|
|
|
41821
41996
|
};
|
|
41822
41997
|
|
|
41823
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
|
+
};
|
|
41824
42021
|
var AugurAPI = class _AugurAPI {
|
|
41825
42022
|
config;
|
|
42023
|
+
/** This client's call bounds: none, unless it is a view from `withRequest`. */
|
|
42024
|
+
bounds = NO_BOUNDS;
|
|
41826
42025
|
_joomla;
|
|
41827
42026
|
_commerce;
|
|
41828
42027
|
_pricing;
|
|
@@ -41885,7 +42084,52 @@ var AugurAPI = class _AugurAPI {
|
|
|
41885
42084
|
* ```
|
|
41886
42085
|
*/
|
|
41887
42086
|
call(id, args) {
|
|
41888
|
-
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);
|
|
41889
42133
|
}
|
|
41890
42134
|
/**
|
|
41891
42135
|
* Create AugurAPI client from context object
|
|
@@ -41913,25 +42157,19 @@ var AugurAPI = class _AugurAPI {
|
|
|
41913
42157
|
* @throws {ContextCreationError} When context is invalid or missing required fields
|
|
41914
42158
|
*/
|
|
41915
42159
|
static fromContext(context, options = {}) {
|
|
41916
|
-
|
|
41917
|
-
throw new ContextCreationError("Context is required", "context");
|
|
41918
|
-
}
|
|
41919
|
-
if (!context.siteId) {
|
|
41920
|
-
throw new ContextCreationError("Context must contain siteId", "siteId");
|
|
41921
|
-
}
|
|
41922
|
-
const bearerToken = context.jwt || context.bearerToken;
|
|
41923
|
-
if (!bearerToken) {
|
|
41924
|
-
throw new ContextCreationError(
|
|
41925
|
-
"Context must contain jwt or bearerToken for authentication",
|
|
41926
|
-
"bearerToken"
|
|
41927
|
-
);
|
|
41928
|
-
}
|
|
42160
|
+
const bearerToken = context?.jwt || context?.bearerToken;
|
|
41929
42161
|
const config = {
|
|
41930
|
-
siteId: context
|
|
42162
|
+
siteId: context?.siteId ?? "",
|
|
41931
42163
|
bearerToken,
|
|
41932
42164
|
...options
|
|
41933
|
-
// Allow overrides
|
|
41934
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]();
|
|
41935
42173
|
return new _AugurAPI(config);
|
|
41936
42174
|
}
|
|
41937
42175
|
/**
|
|
@@ -41939,7 +42177,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
41939
42177
|
*/
|
|
41940
42178
|
get joomla() {
|
|
41941
42179
|
if (!this._joomla) {
|
|
41942
|
-
const httpClient =
|
|
42180
|
+
const httpClient = this.httpFor("joomla");
|
|
41943
42181
|
this._joomla = new JoomlaClient(httpClient);
|
|
41944
42182
|
}
|
|
41945
42183
|
return this._joomla;
|
|
@@ -41949,7 +42187,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
41949
42187
|
*/
|
|
41950
42188
|
get commerce() {
|
|
41951
42189
|
if (!this._commerce) {
|
|
41952
|
-
const httpClient =
|
|
42190
|
+
const httpClient = this.httpFor("commerce");
|
|
41953
42191
|
this._commerce = new CommerceClient(httpClient);
|
|
41954
42192
|
}
|
|
41955
42193
|
return this._commerce;
|
|
@@ -41959,7 +42197,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
41959
42197
|
*/
|
|
41960
42198
|
get pricing() {
|
|
41961
42199
|
if (!this._pricing) {
|
|
41962
|
-
const httpClient =
|
|
42200
|
+
const httpClient = this.httpFor("pricing");
|
|
41963
42201
|
this._pricing = new PricingClient(httpClient);
|
|
41964
42202
|
}
|
|
41965
42203
|
return this._pricing;
|
|
@@ -41969,7 +42207,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
41969
42207
|
*/
|
|
41970
42208
|
get vmi() {
|
|
41971
42209
|
if (!this._vmi) {
|
|
41972
|
-
const httpClient =
|
|
42210
|
+
const httpClient = this.httpFor("vmi");
|
|
41973
42211
|
this._vmi = new VMIClient(httpClient);
|
|
41974
42212
|
}
|
|
41975
42213
|
return this._vmi;
|
|
@@ -41979,7 +42217,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
41979
42217
|
*/
|
|
41980
42218
|
get openSearch() {
|
|
41981
42219
|
if (!this._openSearch) {
|
|
41982
|
-
const httpClient =
|
|
42220
|
+
const httpClient = this.httpFor("open-search");
|
|
41983
42221
|
this._openSearch = new OpenSearchClient(httpClient);
|
|
41984
42222
|
}
|
|
41985
42223
|
return this._openSearch;
|
|
@@ -41989,7 +42227,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
41989
42227
|
*/
|
|
41990
42228
|
get items() {
|
|
41991
42229
|
if (!this._items) {
|
|
41992
|
-
const httpClient =
|
|
42230
|
+
const httpClient = this.httpFor("items");
|
|
41993
42231
|
this._items = new ItemsClient(httpClient);
|
|
41994
42232
|
}
|
|
41995
42233
|
return this._items;
|
|
@@ -41999,7 +42237,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
41999
42237
|
*/
|
|
42000
42238
|
get legacy() {
|
|
42001
42239
|
if (!this._legacy) {
|
|
42002
|
-
const httpClient =
|
|
42240
|
+
const httpClient = this.httpFor("legacy");
|
|
42003
42241
|
this._legacy = new LegacyClient(httpClient);
|
|
42004
42242
|
}
|
|
42005
42243
|
return this._legacy;
|
|
@@ -42009,7 +42247,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
42009
42247
|
*/
|
|
42010
42248
|
get agrSite() {
|
|
42011
42249
|
if (!this._agrSite) {
|
|
42012
|
-
const httpClient =
|
|
42250
|
+
const httpClient = this.httpFor("agr-site");
|
|
42013
42251
|
this._agrSite = new AgrSiteClient(httpClient);
|
|
42014
42252
|
}
|
|
42015
42253
|
return this._agrSite;
|
|
@@ -42019,7 +42257,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
42019
42257
|
*/
|
|
42020
42258
|
get customers() {
|
|
42021
42259
|
if (!this._customers) {
|
|
42022
|
-
const httpClient =
|
|
42260
|
+
const httpClient = this.httpFor("customers");
|
|
42023
42261
|
this._customers = new CustomersClient(httpClient);
|
|
42024
42262
|
}
|
|
42025
42263
|
return this._customers;
|
|
@@ -42029,7 +42267,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
42029
42267
|
*/
|
|
42030
42268
|
get orders() {
|
|
42031
42269
|
if (!this._orders) {
|
|
42032
|
-
const httpClient =
|
|
42270
|
+
const httpClient = this.httpFor("orders");
|
|
42033
42271
|
this._orders = new OrdersClient(httpClient);
|
|
42034
42272
|
}
|
|
42035
42273
|
return this._orders;
|
|
@@ -42039,7 +42277,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
42039
42277
|
*/
|
|
42040
42278
|
get p21Pim() {
|
|
42041
42279
|
if (!this._p21Pim) {
|
|
42042
|
-
const httpClient =
|
|
42280
|
+
const httpClient = this.httpFor("p21-pim");
|
|
42043
42281
|
this._p21Pim = new P21PimClient(httpClient);
|
|
42044
42282
|
}
|
|
42045
42283
|
return this._p21Pim;
|
|
@@ -42049,7 +42287,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
42049
42287
|
*/
|
|
42050
42288
|
get payments() {
|
|
42051
42289
|
if (!this._payments) {
|
|
42052
|
-
const httpClient =
|
|
42290
|
+
const httpClient = this.httpFor("payments");
|
|
42053
42291
|
this._payments = new PaymentsClient(httpClient);
|
|
42054
42292
|
}
|
|
42055
42293
|
return this._payments;
|
|
@@ -42059,7 +42297,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
42059
42297
|
*/
|
|
42060
42298
|
get agrInfo() {
|
|
42061
42299
|
if (!this._agrInfo) {
|
|
42062
|
-
const httpClient =
|
|
42300
|
+
const httpClient = this.httpFor("agr-info");
|
|
42063
42301
|
this._agrInfo = new AgrInfoClient(httpClient);
|
|
42064
42302
|
}
|
|
42065
42303
|
return this._agrInfo;
|
|
@@ -42069,7 +42307,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
42069
42307
|
*/
|
|
42070
42308
|
get agrInt() {
|
|
42071
42309
|
if (!this._agrInt) {
|
|
42072
|
-
const httpClient =
|
|
42310
|
+
const httpClient = this.httpFor("agr-int");
|
|
42073
42311
|
this._agrInt = new AgrIntClient(httpClient);
|
|
42074
42312
|
}
|
|
42075
42313
|
return this._agrInt;
|
|
@@ -42079,7 +42317,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
42079
42317
|
*/
|
|
42080
42318
|
get agrWork() {
|
|
42081
42319
|
if (!this._agrWork) {
|
|
42082
|
-
const httpClient =
|
|
42320
|
+
const httpClient = this.httpFor("agr-work");
|
|
42083
42321
|
this._agrWork = new AgrWorkClient(httpClient);
|
|
42084
42322
|
}
|
|
42085
42323
|
return this._agrWork;
|
|
@@ -42089,7 +42327,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
42089
42327
|
*/
|
|
42090
42328
|
get avalara() {
|
|
42091
42329
|
if (!this._avalara) {
|
|
42092
|
-
const httpClient =
|
|
42330
|
+
const httpClient = this.httpFor("avalara");
|
|
42093
42331
|
this._avalara = new AvalaraClient(httpClient);
|
|
42094
42332
|
}
|
|
42095
42333
|
return this._avalara;
|
|
@@ -42099,7 +42337,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
42099
42337
|
*/
|
|
42100
42338
|
get brandFolder() {
|
|
42101
42339
|
if (!this._brandFolder) {
|
|
42102
|
-
const httpClient =
|
|
42340
|
+
const httpClient = this.httpFor("brand-folder");
|
|
42103
42341
|
this._brandFolder = new BrandFolderClient(httpClient);
|
|
42104
42342
|
}
|
|
42105
42343
|
return this._brandFolder;
|
|
@@ -42109,7 +42347,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
42109
42347
|
*/
|
|
42110
42348
|
get googMc() {
|
|
42111
42349
|
if (!this._googMc) {
|
|
42112
|
-
const httpClient =
|
|
42350
|
+
const httpClient = this.httpFor("goog-mc");
|
|
42113
42351
|
this._googMc = new GoogMcClient(httpClient);
|
|
42114
42352
|
}
|
|
42115
42353
|
return this._googMc;
|
|
@@ -42119,7 +42357,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
42119
42357
|
*/
|
|
42120
42358
|
get gregorovich() {
|
|
42121
42359
|
if (!this._gregorovich) {
|
|
42122
|
-
const httpClient =
|
|
42360
|
+
const httpClient = this.httpFor("gregorovich");
|
|
42123
42361
|
this._gregorovich = new GregorovichClient(httpClient);
|
|
42124
42362
|
}
|
|
42125
42363
|
return this._gregorovich;
|
|
@@ -42129,7 +42367,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
42129
42367
|
*/
|
|
42130
42368
|
get logistics() {
|
|
42131
42369
|
if (!this._logistics) {
|
|
42132
|
-
const httpClient =
|
|
42370
|
+
const httpClient = this.httpFor("logistics");
|
|
42133
42371
|
this._logistics = new LogisticsClient(httpClient);
|
|
42134
42372
|
}
|
|
42135
42373
|
return this._logistics;
|
|
@@ -42139,7 +42377,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
42139
42377
|
*/
|
|
42140
42378
|
get markets() {
|
|
42141
42379
|
if (!this._markets) {
|
|
42142
|
-
const httpClient =
|
|
42380
|
+
const httpClient = this.httpFor("markets");
|
|
42143
42381
|
this._markets = new MarketsClient(httpClient);
|
|
42144
42382
|
}
|
|
42145
42383
|
return this._markets;
|
|
@@ -42149,7 +42387,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
42149
42387
|
*/
|
|
42150
42388
|
get notifications() {
|
|
42151
42389
|
if (!this._notifications) {
|
|
42152
|
-
const httpClient =
|
|
42390
|
+
const httpClient = this.httpFor("notifications");
|
|
42153
42391
|
this._notifications = new NotificationsClient(httpClient);
|
|
42154
42392
|
}
|
|
42155
42393
|
return this._notifications;
|
|
@@ -42159,7 +42397,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
42159
42397
|
*/
|
|
42160
42398
|
get p21Apis() {
|
|
42161
42399
|
if (!this._p21Apis) {
|
|
42162
|
-
const httpClient =
|
|
42400
|
+
const httpClient = this.httpFor("p21-apis");
|
|
42163
42401
|
this._p21Apis = new P21ApisClient(httpClient);
|
|
42164
42402
|
}
|
|
42165
42403
|
return this._p21Apis;
|
|
@@ -42169,7 +42407,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
42169
42407
|
*/
|
|
42170
42408
|
get p21Core() {
|
|
42171
42409
|
if (!this._p21Core) {
|
|
42172
|
-
const httpClient =
|
|
42410
|
+
const httpClient = this.httpFor("p21-core");
|
|
42173
42411
|
this._p21Core = new P21CoreClient(httpClient);
|
|
42174
42412
|
}
|
|
42175
42413
|
return this._p21Core;
|
|
@@ -42179,7 +42417,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
42179
42417
|
*/
|
|
42180
42418
|
get p21Sism() {
|
|
42181
42419
|
if (!this._p21Sism) {
|
|
42182
|
-
const httpClient =
|
|
42420
|
+
const httpClient = this.httpFor("p21-sism");
|
|
42183
42421
|
this._p21Sism = new P21SismClient(httpClient);
|
|
42184
42422
|
}
|
|
42185
42423
|
return this._p21Sism;
|
|
@@ -42189,7 +42427,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
42189
42427
|
*/
|
|
42190
42428
|
get shipping() {
|
|
42191
42429
|
if (!this._shipping) {
|
|
42192
|
-
const httpClient =
|
|
42430
|
+
const httpClient = this.httpFor("shipping");
|
|
42193
42431
|
this._shipping = new ShippingClient(httpClient);
|
|
42194
42432
|
}
|
|
42195
42433
|
return this._shipping;
|
|
@@ -42199,7 +42437,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
42199
42437
|
*/
|
|
42200
42438
|
get smartyStreets() {
|
|
42201
42439
|
if (!this._smartyStreets) {
|
|
42202
|
-
const httpClient =
|
|
42440
|
+
const httpClient = this.httpFor("smarty-streets");
|
|
42203
42441
|
this._smartyStreets = new SmartyStreetsClient(httpClient);
|
|
42204
42442
|
}
|
|
42205
42443
|
return this._smartyStreets;
|
|
@@ -42209,7 +42447,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
42209
42447
|
*/
|
|
42210
42448
|
get ups() {
|
|
42211
42449
|
if (!this._ups) {
|
|
42212
|
-
const httpClient =
|
|
42450
|
+
const httpClient = this.httpFor("ups");
|
|
42213
42451
|
this._ups = new UPSClient(httpClient);
|
|
42214
42452
|
}
|
|
42215
42453
|
return this._ups;
|
|
@@ -42219,7 +42457,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
42219
42457
|
*/
|
|
42220
42458
|
get vendors() {
|
|
42221
42459
|
if (!this._vendors) {
|
|
42222
|
-
const httpClient =
|
|
42460
|
+
const httpClient = this.httpFor("vendors");
|
|
42223
42461
|
this._vendors = new VendorsClient(httpClient);
|
|
42224
42462
|
}
|
|
42225
42463
|
return this._vendors;
|
|
@@ -42229,13 +42467,18 @@ var AugurAPI = class _AugurAPI {
|
|
|
42229
42467
|
*/
|
|
42230
42468
|
get basecamp2() {
|
|
42231
42469
|
if (!this._basecamp2) {
|
|
42232
|
-
const httpClient =
|
|
42470
|
+
const httpClient = this.httpFor("basecamp2");
|
|
42233
42471
|
this._basecamp2 = new Basecamp2Client(httpClient);
|
|
42234
42472
|
}
|
|
42235
42473
|
return this._basecamp2;
|
|
42236
42474
|
}
|
|
42237
42475
|
/**
|
|
42238
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
|
+
*
|
|
42239
42482
|
* @param bearerToken New bearer token
|
|
42240
42483
|
*/
|
|
42241
42484
|
setAuthToken(bearerToken) {
|
|
@@ -42244,6 +42487,9 @@ var AugurAPI = class _AugurAPI {
|
|
|
42244
42487
|
}
|
|
42245
42488
|
/**
|
|
42246
42489
|
* Update site ID
|
|
42490
|
+
*
|
|
42491
|
+
* As with `setAuthToken`: a service object read before the change keeps the old siteId.
|
|
42492
|
+
*
|
|
42247
42493
|
* @param siteId New site ID
|
|
42248
42494
|
* @throws InvalidArgumentError when it is not a siteId (see the constructor)
|
|
42249
42495
|
*/
|
|
@@ -42340,7 +42586,7 @@ function createCrossSiteAuthenticator(augurInfoToken) {
|
|
|
42340
42586
|
}
|
|
42341
42587
|
|
|
42342
42588
|
// src/index.ts
|
|
42343
|
-
var VERSION = "2026.11.
|
|
42589
|
+
var VERSION = "2026.11.4";
|
|
42344
42590
|
// Annotate the CommonJS export names for ESM import in node:
|
|
42345
42591
|
0 && (module.exports = {
|
|
42346
42592
|
AgrInfoClient,
|