@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.
- package/README.md +41 -4
- 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/core/http-rules.d.ts.map +1 -1
- package/dist/core/site-id-check.d.ts +2 -2
- package/dist/core/site-id.d.ts +3 -3
- package/dist/core/site-id.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +440 -179
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +440 -179
- package/dist/index.mjs.map +1 -1
- package/dist/services/agr-info/generated/endpoints.d.ts +1 -1
- package/dist/services/agr-info/generated/endpoints.d.ts.map +1 -1
- package/dist/services/agr-int/generated/endpoints.d.ts +1 -1
- package/dist/services/agr-int/generated/endpoints.d.ts.map +1 -1
- package/dist/services/agr-site/generated/endpoints.d.ts +1 -1
- package/dist/services/agr-site/generated/endpoints.d.ts.map +1 -1
- package/dist/services/agr-work/generated/endpoints.d.ts +1 -1
- package/dist/services/agr-work/generated/endpoints.d.ts.map +1 -1
- package/dist/services/avalara/generated/endpoints.d.ts +1 -1
- package/dist/services/avalara/generated/endpoints.d.ts.map +1 -1
- package/dist/services/basecamp2/generated/endpoints.d.ts +1 -1
- package/dist/services/basecamp2/generated/endpoints.d.ts.map +1 -1
- package/dist/services/brand-folder/generated/endpoints.d.ts +1 -1
- package/dist/services/brand-folder/generated/endpoints.d.ts.map +1 -1
- package/dist/services/commerce/generated/endpoints.d.ts +1 -1
- package/dist/services/commerce/generated/endpoints.d.ts.map +1 -1
- package/dist/services/customers/generated/endpoints.d.ts +1 -1
- package/dist/services/customers/generated/endpoints.d.ts.map +1 -1
- package/dist/services/goog-mc/generated/endpoints.d.ts +1 -1
- package/dist/services/goog-mc/generated/endpoints.d.ts.map +1 -1
- package/dist/services/gregorovich/generated/endpoints.d.ts +1 -1
- package/dist/services/gregorovich/generated/endpoints.d.ts.map +1 -1
- package/dist/services/items/generated/endpoints.d.ts +1 -1
- package/dist/services/items/generated/endpoints.d.ts.map +1 -1
- package/dist/services/joomla/generated/endpoints.d.ts +1 -1
- package/dist/services/joomla/generated/endpoints.d.ts.map +1 -1
- package/dist/services/legacy/generated/endpoints.d.ts +1 -1
- package/dist/services/legacy/generated/endpoints.d.ts.map +1 -1
- package/dist/services/logistics/generated/endpoints.d.ts +1 -1
- package/dist/services/logistics/generated/endpoints.d.ts.map +1 -1
- package/dist/services/markets/generated/endpoints.d.ts +1 -1
- package/dist/services/markets/generated/endpoints.d.ts.map +1 -1
- package/dist/services/notifications/generated/endpoints.d.ts +1 -1
- package/dist/services/notifications/generated/endpoints.d.ts.map +1 -1
- package/dist/services/open-search/generated/endpoints.d.ts +1 -1
- package/dist/services/open-search/generated/endpoints.d.ts.map +1 -1
- package/dist/services/orders/generated/endpoints.d.ts +1 -1
- package/dist/services/orders/generated/endpoints.d.ts.map +1 -1
- package/dist/services/p21-apis/generated/endpoints.d.ts +1 -1
- package/dist/services/p21-apis/generated/endpoints.d.ts.map +1 -1
- package/dist/services/p21-core/generated/endpoints.d.ts +1 -1
- package/dist/services/p21-core/generated/endpoints.d.ts.map +1 -1
- package/dist/services/p21-pim/generated/endpoints.d.ts +1 -1
- package/dist/services/p21-pim/generated/endpoints.d.ts.map +1 -1
- package/dist/services/p21-sism/generated/endpoints.d.ts +1 -1
- package/dist/services/p21-sism/generated/endpoints.d.ts.map +1 -1
- package/dist/services/payments/generated/endpoints.d.ts +1 -1
- package/dist/services/payments/generated/endpoints.d.ts.map +1 -1
- package/dist/services/pricing/generated/endpoints.d.ts +1 -1
- package/dist/services/pricing/generated/endpoints.d.ts.map +1 -1
- package/dist/services/shipping/generated/endpoints.d.ts +1 -1
- package/dist/services/shipping/generated/endpoints.d.ts.map +1 -1
- package/dist/services/smarty-streets/generated/endpoints.d.ts +1 -1
- package/dist/services/smarty-streets/generated/endpoints.d.ts.map +1 -1
- package/dist/services/ups/generated/endpoints.d.ts +1 -1
- package/dist/services/ups/generated/endpoints.d.ts.map +1 -1
- package/dist/services/vendors/generated/endpoints.d.ts +1 -1
- package/dist/services/vendors/generated/endpoints.d.ts.map +1 -1
- package/dist/services/vmi/generated/endpoints.d.ts +1 -1
- package/dist/services/vmi/generated/endpoints.d.ts.map +1 -1
- package/package.json +5 -2
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// ../
|
|
1
|
+
// ../foundation/src/chars.ts
|
|
2
2
|
function isAlnumChar(c) {
|
|
3
3
|
return c >= 65 && c <= 90 || c >= 97 && c <= 122 || c >= 48 && c <= 57;
|
|
4
4
|
}
|
|
@@ -43,17 +43,24 @@ function compareFrom(a, b, i) {
|
|
|
43
43
|
function compareCodeUnits(a, b) {
|
|
44
44
|
return compareFrom(a, b, 0);
|
|
45
45
|
}
|
|
46
|
+
|
|
47
|
+
// ../utils/src/includes.ts
|
|
46
48
|
function includesFrom(s, x, i) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
for (let k = i; k !== s.length + 1; k++) {
|
|
50
|
+
if (startsWithAt(s, x, k)) return true;
|
|
51
|
+
}
|
|
52
|
+
return false;
|
|
50
53
|
}
|
|
51
54
|
|
|
52
55
|
// ../utils/src/lists.ts
|
|
53
56
|
function joinFrom(xs, sep, i) {
|
|
54
57
|
if (i >= xs.length) return "";
|
|
55
|
-
|
|
56
|
-
|
|
58
|
+
return joinRange(xs, sep, i, xs.length);
|
|
59
|
+
}
|
|
60
|
+
function joinRange(xs, sep, lo, hi) {
|
|
61
|
+
if (hi - lo === 1) return xs[lo];
|
|
62
|
+
const mid = lo + Math.floor((hi - lo) / 2);
|
|
63
|
+
return joinRange(xs, sep, lo, mid) + sep + joinRange(xs, sep, mid, hi);
|
|
57
64
|
}
|
|
58
65
|
function hasItemFrom(xs, x, i) {
|
|
59
66
|
if (i === xs.length) return false;
|
|
@@ -163,18 +170,20 @@ function placeholderFilled(path, placeholder, segment) {
|
|
|
163
170
|
return replaceText(path, "{" + placeholder + "}", segment);
|
|
164
171
|
}
|
|
165
172
|
|
|
166
|
-
// ../
|
|
167
|
-
function
|
|
168
|
-
return
|
|
173
|
+
// ../foundation/src/duration.ts
|
|
174
|
+
function seconds(n) {
|
|
175
|
+
return n;
|
|
176
|
+
}
|
|
177
|
+
function toMillis(d) {
|
|
178
|
+
return d * 1e3;
|
|
169
179
|
}
|
|
170
180
|
|
|
171
181
|
// src/core/config.ts
|
|
182
|
+
var NO_BOUNDS = { signals: [] };
|
|
172
183
|
var DEFAULT_CONFIG = {
|
|
173
|
-
timeout:
|
|
174
|
-
// 30 seconds
|
|
184
|
+
timeout: toMillis(seconds(30)),
|
|
175
185
|
retries: 3,
|
|
176
|
-
retryDelay:
|
|
177
|
-
// 1 second
|
|
186
|
+
retryDelay: toMillis(seconds(1))
|
|
178
187
|
};
|
|
179
188
|
var ContextCreationError = class extends Error {
|
|
180
189
|
constructor(message, field) {
|
|
@@ -185,6 +194,105 @@ var ContextCreationError = class extends Error {
|
|
|
185
194
|
field;
|
|
186
195
|
};
|
|
187
196
|
|
|
197
|
+
// ../json-values/src/index.ts
|
|
198
|
+
function isRecord(value) {
|
|
199
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// src/core/http-rules.ts
|
|
203
|
+
function isRetryableStatus(status) {
|
|
204
|
+
return !(status >= 400 && status < 500 && status !== 429);
|
|
205
|
+
}
|
|
206
|
+
function exponentialDelay(base, attempt) {
|
|
207
|
+
if (attempt === 0) return base;
|
|
208
|
+
return 2 * exponentialDelay(base, attempt - 1);
|
|
209
|
+
}
|
|
210
|
+
function cappedDelay(d) {
|
|
211
|
+
return Math.min(d, 3e4);
|
|
212
|
+
}
|
|
213
|
+
function timeoutOf(hasRequest, request, hasClient, client, fallback) {
|
|
214
|
+
if (hasRequest) return request;
|
|
215
|
+
return hasClient ? client : fallback;
|
|
216
|
+
}
|
|
217
|
+
function isPublicEndpoint(url) {
|
|
218
|
+
return endsWith(url, "/health-check") || endsWith(url, "/ping");
|
|
219
|
+
}
|
|
220
|
+
function sendsBearer(url, hasToken) {
|
|
221
|
+
return hasToken && !isPublicEndpoint(url);
|
|
222
|
+
}
|
|
223
|
+
function sendsJsonBody(hasData, method) {
|
|
224
|
+
return hasData && method !== "GET";
|
|
225
|
+
}
|
|
226
|
+
function querySeparator(url) {
|
|
227
|
+
return includesFrom(url, "?", 0) ? "&" : "?";
|
|
228
|
+
}
|
|
229
|
+
function requestKey(method, url, params) {
|
|
230
|
+
return method + ":" + url + ":" + params;
|
|
231
|
+
}
|
|
232
|
+
function isEdgeCacheParam(key) {
|
|
233
|
+
return key === "edgeCache";
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// src/core/client-rules.ts
|
|
237
|
+
function contextRefusalOf(hasContext, siteIdTruthy, contextTokenTruthy, finalTokenTruthy) {
|
|
238
|
+
if (!hasContext) return "context";
|
|
239
|
+
if (!siteIdTruthy) return "site-id";
|
|
240
|
+
if (!contextTokenTruthy) return "token";
|
|
241
|
+
return finalTokenTruthy ? "ok" : "token-removed";
|
|
242
|
+
}
|
|
243
|
+
function retryableError(isAugurError, status) {
|
|
244
|
+
return !isAugurError || isRetryableStatus(status);
|
|
245
|
+
}
|
|
246
|
+
function retryAfterCall(attempt, retries, retryable, callAborted) {
|
|
247
|
+
return !callAborted && attempt < retries && retryable;
|
|
248
|
+
}
|
|
249
|
+
function isAbortName(name) {
|
|
250
|
+
return name === "AbortError" || name === "TimeoutError";
|
|
251
|
+
}
|
|
252
|
+
function remainingOf(deadline, elapsed) {
|
|
253
|
+
return elapsed < deadline ? deadline - elapsed : 0;
|
|
254
|
+
}
|
|
255
|
+
function attemptTimeoutOf(perAttempt, hasDeadline, remaining) {
|
|
256
|
+
return hasDeadline && remaining < perAttempt ? remaining : perAttempt;
|
|
257
|
+
}
|
|
258
|
+
function waitOf(backoff, hasDeadline, remaining) {
|
|
259
|
+
return hasDeadline && remaining < backoff ? remaining : backoff;
|
|
260
|
+
}
|
|
261
|
+
function needsAttemptTimer(perAttempt, hasDeadline, remaining) {
|
|
262
|
+
return !(hasDeadline && remaining <= perAttempt);
|
|
263
|
+
}
|
|
264
|
+
function boundedCall(hasSignal, hasDeadline) {
|
|
265
|
+
return hasSignal || hasDeadline;
|
|
266
|
+
}
|
|
267
|
+
function deadlineInRange(deadline) {
|
|
268
|
+
return 0 <= deadline && deadline <= 2147483647;
|
|
269
|
+
}
|
|
270
|
+
function callOptionsAccepted(hasSignal, isAbortSignal, hasDeadline, inRange) {
|
|
271
|
+
return (!hasSignal || isAbortSignal) && (!hasDeadline || inRange);
|
|
272
|
+
}
|
|
273
|
+
function sharesInFlight(hasRequestSignal) {
|
|
274
|
+
return !hasRequestSignal;
|
|
275
|
+
}
|
|
276
|
+
function mergedDeadlineOf(hasOuter, outer, hasInner, inner) {
|
|
277
|
+
if (!hasOuter) return inner;
|
|
278
|
+
if (!hasInner) return outer;
|
|
279
|
+
return inner < outer ? inner : outer;
|
|
280
|
+
}
|
|
281
|
+
function hasMergedDeadline(hasOuter, hasInner) {
|
|
282
|
+
return hasOuter || hasInner;
|
|
283
|
+
}
|
|
284
|
+
function edgeCacheKindOf(text, hours) {
|
|
285
|
+
if (text === "30s" || text === "1m" || text === "5m") return "sub-hour";
|
|
286
|
+
const hourly = hours === 1 || hours === 2 || hours === 3 || hours === 4 || hours === 5 || hours === 8;
|
|
287
|
+
return hourly ? "hourly" : "invalid";
|
|
288
|
+
}
|
|
289
|
+
function rawRetries(method) {
|
|
290
|
+
return method === "GET";
|
|
291
|
+
}
|
|
292
|
+
function startsAttempt(hasDeadline, remaining) {
|
|
293
|
+
return !hasDeadline || remaining > 0;
|
|
294
|
+
}
|
|
295
|
+
|
|
188
296
|
// src/core/errors.ts
|
|
189
297
|
var AugurError = class _AugurError extends Error {
|
|
190
298
|
code;
|
|
@@ -296,40 +404,6 @@ var InvalidArgumentError = class extends AugurError {
|
|
|
296
404
|
}
|
|
297
405
|
};
|
|
298
406
|
|
|
299
|
-
// src/core/http-rules.ts
|
|
300
|
-
function isRetryableStatus(status) {
|
|
301
|
-
return !(status >= 400 && status < 500 && status !== 429);
|
|
302
|
-
}
|
|
303
|
-
function exponentialDelay(base, attempt) {
|
|
304
|
-
if (attempt === 0) return base;
|
|
305
|
-
return 2 * exponentialDelay(base, attempt - 1);
|
|
306
|
-
}
|
|
307
|
-
function cappedDelay(d) {
|
|
308
|
-
return Math.min(d, 3e4);
|
|
309
|
-
}
|
|
310
|
-
function timeoutOf(hasRequest, request, hasClient, client, fallback) {
|
|
311
|
-
if (hasRequest) return request;
|
|
312
|
-
return hasClient ? client : fallback;
|
|
313
|
-
}
|
|
314
|
-
function isPublicEndpoint(url) {
|
|
315
|
-
return endsWith(url, "/health-check") || endsWith(url, "/ping");
|
|
316
|
-
}
|
|
317
|
-
function sendsBearer(url, hasToken) {
|
|
318
|
-
return hasToken && !isPublicEndpoint(url);
|
|
319
|
-
}
|
|
320
|
-
function sendsJsonBody(hasData, method) {
|
|
321
|
-
return hasData && method !== "GET";
|
|
322
|
-
}
|
|
323
|
-
function querySeparator(url) {
|
|
324
|
-
return includesFrom(url, "?", 0) ? "&" : "?";
|
|
325
|
-
}
|
|
326
|
-
function requestKey(method, url, params) {
|
|
327
|
-
return method + ":" + url + ":" + params;
|
|
328
|
-
}
|
|
329
|
-
function isEdgeCacheParam(key) {
|
|
330
|
-
return key === "edgeCache";
|
|
331
|
-
}
|
|
332
|
-
|
|
333
407
|
// src/core/client.ts
|
|
334
408
|
function parseJson(text) {
|
|
335
409
|
try {
|
|
@@ -364,10 +438,59 @@ function calculateBackoffDelay(attempt, baseDelay) {
|
|
|
364
438
|
return cappedDelay(exponential + jitter);
|
|
365
439
|
}
|
|
366
440
|
function isRetryableError(error) {
|
|
367
|
-
|
|
441
|
+
const isAugurError = error instanceof AugurError;
|
|
442
|
+
return retryableError(isAugurError, isAugurError ? error.statusCode : 0);
|
|
443
|
+
}
|
|
444
|
+
function delay(ms, signal) {
|
|
445
|
+
return new Promise((resolve, reject) => {
|
|
446
|
+
const onAbort = () => {
|
|
447
|
+
clearTimeout(timer);
|
|
448
|
+
reject(signal.reason);
|
|
449
|
+
};
|
|
450
|
+
const timer = setTimeout(() => {
|
|
451
|
+
signal?.removeEventListener("abort", onAbort);
|
|
452
|
+
resolve();
|
|
453
|
+
}, ms);
|
|
454
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
var UNBOUNDED = {
|
|
458
|
+
signal: void 0,
|
|
459
|
+
hasDeadline: false,
|
|
460
|
+
remaining: () => 0,
|
|
461
|
+
dispose: () => {
|
|
462
|
+
}
|
|
463
|
+
};
|
|
464
|
+
function throwIfEnded(call) {
|
|
465
|
+
if (call.signal?.aborted) throw call.signal.reason;
|
|
368
466
|
}
|
|
369
|
-
function
|
|
370
|
-
|
|
467
|
+
function startCall(bounds, requestSignal) {
|
|
468
|
+
const sources = requestSignal === void 0 ? [...bounds.signals] : [...bounds.signals, requestSignal];
|
|
469
|
+
const deadline = bounds.deadline;
|
|
470
|
+
if (!boundedCall(sources.length > 0, deadline !== void 0)) return UNBOUNDED;
|
|
471
|
+
const controller = new AbortController();
|
|
472
|
+
const started = Date.now();
|
|
473
|
+
const listeners = sources.map((source) => {
|
|
474
|
+
const onAbort = () => controller.abort(source.reason);
|
|
475
|
+
source.addEventListener("abort", onAbort, { once: true });
|
|
476
|
+
return { source, onAbort };
|
|
477
|
+
});
|
|
478
|
+
for (const source of sources) {
|
|
479
|
+
if (source.aborted) controller.abort(source.reason);
|
|
480
|
+
}
|
|
481
|
+
const timer = deadline === void 0 ? void 0 : setTimeout(
|
|
482
|
+
() => controller.abort(new DOMException("Call deadline exceeded", "TimeoutError")),
|
|
483
|
+
deadline
|
|
484
|
+
);
|
|
485
|
+
return {
|
|
486
|
+
signal: controller.signal,
|
|
487
|
+
hasDeadline: deadline !== void 0,
|
|
488
|
+
remaining: () => remainingOf(deadline ?? 0, Date.now() - started),
|
|
489
|
+
dispose: () => {
|
|
490
|
+
clearTimeout(timer);
|
|
491
|
+
for (const { source, onAbort } of listeners) source.removeEventListener("abort", onAbort);
|
|
492
|
+
}
|
|
493
|
+
};
|
|
371
494
|
}
|
|
372
495
|
function withoutEdgeCache(params) {
|
|
373
496
|
return Object.fromEntries(Object.entries(params).filter(([key]) => !isEdgeCacheParam(key)));
|
|
@@ -411,18 +534,22 @@ var HTTPClient = class {
|
|
|
411
534
|
config;
|
|
412
535
|
serviceName;
|
|
413
536
|
inflightRequests = /* @__PURE__ */ new Map();
|
|
414
|
-
|
|
537
|
+
bounds;
|
|
538
|
+
/** `bounds` bound every call this client makes (a view's, from `AugurAPI.withRequest`). */
|
|
539
|
+
constructor(serviceName, config, bounds = NO_BOUNDS) {
|
|
415
540
|
this.serviceName = serviceName;
|
|
416
541
|
this.config = { ...DEFAULT_CONFIG, ...config };
|
|
542
|
+
this.bounds = bounds;
|
|
417
543
|
}
|
|
418
544
|
/**
|
|
419
|
-
* Build request headers with auth
|
|
545
|
+
* Build request headers with auth. A request's own headers come before `x-site-id` and
|
|
546
|
+
* `Authorization`, so neither can be replaced by one (AugurApiClient.SiteIdHeaderIsTheClients).
|
|
420
547
|
*/
|
|
421
548
|
buildRequestHeaders(url, requestConfig) {
|
|
422
549
|
const headers = {
|
|
423
550
|
"Content-Type": "application/json",
|
|
424
|
-
|
|
425
|
-
|
|
551
|
+
...requestConfig?.headers,
|
|
552
|
+
"x-site-id": this.config.siteId
|
|
426
553
|
};
|
|
427
554
|
if (sendsBearer(url, Boolean(this.config.bearerToken))) {
|
|
428
555
|
headers["Authorization"] = `Bearer ${this.config.bearerToken}`;
|
|
@@ -498,30 +625,58 @@ var HTTPClient = class {
|
|
|
498
625
|
* Core request method using native fetch. `read` turns a 2xx response into
|
|
499
626
|
* the result, inside the same error handling and timeout as the fetch.
|
|
500
627
|
*/
|
|
501
|
-
async request(method, url, options, read = (r, c) => this.handleFetchSuccess(r, c)) {
|
|
628
|
+
async request(method, url, options, call, read = (r, c) => this.handleFetchSuccess(r, c)) {
|
|
502
629
|
const { config: requestConfig } = options;
|
|
503
630
|
const endpoint = requestConfig?.endpoint ?? url;
|
|
504
|
-
const
|
|
505
|
-
let augurConfig = this.baseRequest(method, url, options, timeout);
|
|
631
|
+
const bounds = this.attemptBounds(requestConfig, call);
|
|
632
|
+
let augurConfig = this.baseRequest(method, url, options, bounds.timeout);
|
|
506
633
|
if (this.config.onRequest) {
|
|
507
634
|
augurConfig = await this.config.onRequest(augurConfig);
|
|
508
635
|
}
|
|
509
636
|
const fullUrl = buildUrlWithParams(augurConfig.url, augurConfig.params);
|
|
510
|
-
|
|
511
|
-
const
|
|
512
|
-
const signal = requestConfig?.signal ? this.mergeSignals(requestConfig.signal, controller.signal) : controller.signal;
|
|
637
|
+
throwIfEnded(call);
|
|
638
|
+
const attempt = this.attemptSignal(call, bounds);
|
|
513
639
|
try {
|
|
514
|
-
const response = await fetch(fullUrl, fetchOptionsFor(augurConfig, method, signal));
|
|
640
|
+
const response = await fetch(fullUrl, fetchOptionsFor(augurConfig, method, attempt.signal));
|
|
515
641
|
if (!response.ok) {
|
|
516
642
|
await this.handleFetchError(response, augurConfig, endpoint);
|
|
517
643
|
}
|
|
518
644
|
return await read(response, augurConfig);
|
|
519
645
|
} catch (error) {
|
|
646
|
+
throwIfEnded(call);
|
|
520
647
|
this.rethrowOrWrapError(error, endpoint);
|
|
521
648
|
} finally {
|
|
522
|
-
|
|
649
|
+
attempt.dispose();
|
|
523
650
|
}
|
|
524
651
|
}
|
|
652
|
+
/**
|
|
653
|
+
* An attempt's timeout (the per-attempt one, cut to what is left of the call's deadline: what
|
|
654
|
+
* the onRequest hook sees) and whether it sets its own timer: only when it ends before the
|
|
655
|
+
* deadline; otherwise the call's one deadline timer cuts it, with a TimeoutError
|
|
656
|
+
* (client-rules.ts; AugurApiClient.OneTimerCutsEachAttempt).
|
|
657
|
+
*/
|
|
658
|
+
attemptBounds(requestConfig, call) {
|
|
659
|
+
const perAttempt = this.timeoutFor(requestConfig);
|
|
660
|
+
const remaining = call.remaining();
|
|
661
|
+
return {
|
|
662
|
+
timeout: attemptTimeoutOf(perAttempt, call.hasDeadline, remaining),
|
|
663
|
+
ownTimer: needsAttemptTimer(perAttempt, call.hasDeadline, remaining)
|
|
664
|
+
};
|
|
665
|
+
}
|
|
666
|
+
/** The signal one attempt is sent with, and how to clear its timer and listeners after. */
|
|
667
|
+
attemptSignal(call, bounds) {
|
|
668
|
+
const controller = new AbortController();
|
|
669
|
+
const timeoutId = bounds.ownTimer ? setTimeout(() => controller.abort(), bounds.timeout) : void 0;
|
|
670
|
+
const merged = call.signal ? this.mergeSignals(call.signal, controller.signal) : { signal: controller.signal, dispose: () => {
|
|
671
|
+
} };
|
|
672
|
+
return {
|
|
673
|
+
signal: merged.signal,
|
|
674
|
+
dispose: () => {
|
|
675
|
+
clearTimeout(timeoutId);
|
|
676
|
+
merged.dispose();
|
|
677
|
+
}
|
|
678
|
+
};
|
|
679
|
+
}
|
|
525
680
|
/** The request's timeout: per request, else the client's, else the default (timeoutOf). */
|
|
526
681
|
timeoutFor(requestConfig) {
|
|
527
682
|
const request = requestConfig?.timeout;
|
|
@@ -546,17 +701,20 @@ var HTTPClient = class {
|
|
|
546
701
|
};
|
|
547
702
|
}
|
|
548
703
|
/**
|
|
549
|
-
* Merge
|
|
704
|
+
* Merge the call's signal and an attempt's timer: aborts when either fires, with that one's
|
|
705
|
+
* reason. `dispose` removes the listener from the call's signal, which outlives the attempt
|
|
706
|
+
* (one per attempt would pile up on a long-lived caller signal).
|
|
550
707
|
*/
|
|
551
|
-
mergeSignals(
|
|
708
|
+
mergeSignals(callSignal, timeoutSignal) {
|
|
552
709
|
const controller = new AbortController();
|
|
553
|
-
const
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
710
|
+
const onCallAbort = () => controller.abort(callSignal.reason);
|
|
711
|
+
const onTimeout = () => controller.abort(timeoutSignal.reason);
|
|
712
|
+
callSignal.addEventListener("abort", onCallAbort, { once: true });
|
|
713
|
+
timeoutSignal.addEventListener("abort", onTimeout, { once: true });
|
|
714
|
+
return {
|
|
715
|
+
signal: controller.signal,
|
|
716
|
+
dispose: () => callSignal.removeEventListener("abort", onCallAbort)
|
|
717
|
+
};
|
|
560
718
|
}
|
|
561
719
|
/**
|
|
562
720
|
* The one status-to-error switch, shared by typed methods and `call()`.
|
|
@@ -586,7 +744,7 @@ var HTTPClient = class {
|
|
|
586
744
|
if (error instanceof AugurError) {
|
|
587
745
|
throw error;
|
|
588
746
|
}
|
|
589
|
-
if (error instanceof DOMException && error.name
|
|
747
|
+
if (error instanceof DOMException && isAbortName(error.name)) {
|
|
590
748
|
throw error;
|
|
591
749
|
}
|
|
592
750
|
this.handleNetworkError(error, endpoint);
|
|
@@ -603,25 +761,48 @@ var HTTPClient = class {
|
|
|
603
761
|
/**
|
|
604
762
|
* Executes a single request attempt
|
|
605
763
|
*/
|
|
606
|
-
async executeAttempt(requestFn, attempt, maxRetries, baseDelay) {
|
|
764
|
+
async executeAttempt(requestFn, attempt, maxRetries, baseDelay, call) {
|
|
607
765
|
try {
|
|
608
|
-
return await requestFn
|
|
766
|
+
return await this.attemptWithin(call, requestFn);
|
|
609
767
|
} catch (error) {
|
|
610
|
-
if (attempt
|
|
768
|
+
if (!retryAfterCall(attempt, maxRetries, isRetryableError(error), call.signal?.aborted === true)) {
|
|
611
769
|
throw error;
|
|
612
770
|
}
|
|
613
|
-
const backoffDelay =
|
|
614
|
-
|
|
615
|
-
|
|
771
|
+
const backoffDelay = waitOf(
|
|
772
|
+
calculateBackoffDelay(attempt, baseDelay),
|
|
773
|
+
call.hasDeadline,
|
|
774
|
+
call.remaining()
|
|
775
|
+
);
|
|
776
|
+
await delay(backoffDelay, call.signal);
|
|
777
|
+
return this.executeAttempt(requestFn, attempt + 1, maxRetries, baseDelay, call);
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
/**
|
|
781
|
+
* One attempt, started only while the call's deadline has time left (client-rules.ts
|
|
782
|
+
* startsAttempt); past it the call rejects with a TimeoutError.
|
|
783
|
+
*/
|
|
784
|
+
attemptWithin(call, requestFn) {
|
|
785
|
+
if (!startsAttempt(call.hasDeadline, call.remaining())) {
|
|
786
|
+
return Promise.reject(new DOMException("Call deadline exceeded", "TimeoutError"));
|
|
616
787
|
}
|
|
788
|
+
return requestFn();
|
|
617
789
|
}
|
|
618
790
|
/**
|
|
619
791
|
* Executes a request with retry logic
|
|
620
792
|
*/
|
|
621
|
-
async executeWithRetry(requestFn) {
|
|
793
|
+
async executeWithRetry(requestFn, call) {
|
|
622
794
|
const maxRetries = this.config.retries ?? DEFAULT_CONFIG.retries;
|
|
623
795
|
const baseDelay = this.config.retryDelay ?? DEFAULT_CONFIG.retryDelay;
|
|
624
|
-
return this.executeAttempt(requestFn, 0, maxRetries, baseDelay);
|
|
796
|
+
return this.executeAttempt(requestFn, 0, maxRetries, baseDelay, call);
|
|
797
|
+
}
|
|
798
|
+
/** Runs `fn` in a fresh call scope and disposes it, however `fn` settles. */
|
|
799
|
+
async withinCall(requestSignal, fn) {
|
|
800
|
+
const call = startCall(this.bounds, requestSignal);
|
|
801
|
+
try {
|
|
802
|
+
return await fn(call);
|
|
803
|
+
} finally {
|
|
804
|
+
call.dispose();
|
|
805
|
+
}
|
|
625
806
|
}
|
|
626
807
|
/**
|
|
627
808
|
* Transform edgeCache parameter to Cloudflare's cacheSiteId format
|
|
@@ -649,19 +830,13 @@ var HTTPClient = class {
|
|
|
649
830
|
if (edgeCache == null) {
|
|
650
831
|
return params;
|
|
651
832
|
}
|
|
652
|
-
const validSubHourValues = ["30s", "1m", "5m"];
|
|
653
|
-
const validHourlyValues = [1, 2, 3, 4, 5, 8];
|
|
654
|
-
let cacheSuffix;
|
|
655
833
|
const edgeCacheStr = String(edgeCache);
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
if (!validHourlyValues.includes(cacheHours)) {
|
|
661
|
-
return withoutEdgeCache(paramsObj);
|
|
662
|
-
}
|
|
663
|
-
cacheSuffix = String(cacheHours);
|
|
834
|
+
const cacheHours = parseInt(edgeCacheStr, 10);
|
|
835
|
+
const kind = edgeCacheKindOf(edgeCacheStr, cacheHours);
|
|
836
|
+
if (kind === "invalid") {
|
|
837
|
+
return withoutEdgeCache(paramsObj);
|
|
664
838
|
}
|
|
839
|
+
const cacheSuffix = kind === "sub-hour" ? edgeCacheStr : String(cacheHours);
|
|
665
840
|
const restParams = withoutEdgeCache(paramsObj);
|
|
666
841
|
const cacheKey = `cacheSiteId${cacheSuffix}`;
|
|
667
842
|
return {
|
|
@@ -673,40 +848,49 @@ var HTTPClient = class {
|
|
|
673
848
|
const transformedParams = this.transformEdgeCacheParams(params);
|
|
674
849
|
const method = "GET";
|
|
675
850
|
const requestKey2 = generateRequestKey(method, url, transformedParams);
|
|
676
|
-
const
|
|
851
|
+
const shares = sharesInFlight(config?.signal !== void 0);
|
|
852
|
+
const inflight = shares ? this.inflightRequests.get(requestKey2) : void 0;
|
|
677
853
|
if (inflight) {
|
|
678
854
|
return inflight;
|
|
679
855
|
}
|
|
680
|
-
const requestPromise = this.
|
|
681
|
-
|
|
682
|
-
|
|
856
|
+
const requestPromise = this.withinCall(
|
|
857
|
+
config?.signal,
|
|
858
|
+
(call) => this.executeWithRetry(
|
|
859
|
+
() => this.request(method, url, { params: transformedParams, config }, call),
|
|
860
|
+
call
|
|
861
|
+
)
|
|
862
|
+
);
|
|
863
|
+
if (!shares) return requestPromise;
|
|
864
|
+
const shared = requestPromise.finally(() => {
|
|
683
865
|
this.inflightRequests.delete(requestKey2);
|
|
684
866
|
});
|
|
685
|
-
this.inflightRequests.set(requestKey2,
|
|
686
|
-
return
|
|
867
|
+
this.inflightRequests.set(requestKey2, shared);
|
|
868
|
+
return shared;
|
|
687
869
|
}
|
|
688
870
|
// The API declares query params on POST/PUT/DELETE as well as GET. `request`
|
|
689
871
|
// already carries both a body and a query slot; these wrappers simply never
|
|
690
872
|
// exposed the latter, leaving those params unreachable from the clients.
|
|
873
|
+
// Writes make one attempt (never retried), bounded by the call's scope like a GET.
|
|
691
874
|
async post(url, data, params, config) {
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
875
|
+
const options = { data, params: this.transformEdgeCacheParams(params), config };
|
|
876
|
+
return this.withinCall(
|
|
877
|
+
config?.signal,
|
|
878
|
+
(call) => this.attemptWithin(call, () => this.request("POST", url, options, call))
|
|
879
|
+
);
|
|
697
880
|
}
|
|
698
881
|
async put(url, data, params, config) {
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
882
|
+
const options = { data, params: this.transformEdgeCacheParams(params), config };
|
|
883
|
+
return this.withinCall(
|
|
884
|
+
config?.signal,
|
|
885
|
+
(call) => this.attemptWithin(call, () => this.request("PUT", url, options, call))
|
|
886
|
+
);
|
|
704
887
|
}
|
|
705
888
|
async delete(url, params, config) {
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
config
|
|
709
|
-
|
|
889
|
+
const options = { params: this.transformEdgeCacheParams(params), config };
|
|
890
|
+
return this.withinCall(
|
|
891
|
+
config?.signal,
|
|
892
|
+
(call) => this.attemptWithin(call, () => this.request("DELETE", url, options, call))
|
|
893
|
+
);
|
|
710
894
|
}
|
|
711
895
|
/**
|
|
712
896
|
* Send a request and return the 2xx response as text, with no schema
|
|
@@ -715,13 +899,17 @@ var HTTPClient = class {
|
|
|
715
899
|
* in-flight deduplication); other methods make one attempt, like `post()`.
|
|
716
900
|
*/
|
|
717
901
|
async raw(method, url, options = {}) {
|
|
718
|
-
const
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
902
|
+
const requestOptions = { ...options, params: this.transformEdgeCacheParams(options.params) };
|
|
903
|
+
return this.withinCall(options.config?.signal, (call) => {
|
|
904
|
+
const send = () => this.request(
|
|
905
|
+
method,
|
|
906
|
+
url,
|
|
907
|
+
requestOptions,
|
|
908
|
+
call,
|
|
909
|
+
(response, augurConfig) => this.readRaw(response, augurConfig)
|
|
910
|
+
);
|
|
911
|
+
return rawRetries(method) ? this.executeWithRetry(send, call) : this.attemptWithin(call, send);
|
|
912
|
+
});
|
|
725
913
|
}
|
|
726
914
|
};
|
|
727
915
|
|
|
@@ -769,13 +957,21 @@ var validatePathSegment = (pathTemplate, name, value, pattern, service = "http-c
|
|
|
769
957
|
}
|
|
770
958
|
};
|
|
771
959
|
|
|
772
|
-
// ../utils/src/case.ts
|
|
960
|
+
// ../utils/src/case-spec.ts
|
|
773
961
|
var UPPER = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
774
962
|
function upperFirst(s) {
|
|
775
963
|
const c = codeAt(s, 0);
|
|
776
964
|
if (c >= 97 && c <= 122) return UPPER.slice(c - 97, c - 96) + s.slice(1);
|
|
777
965
|
return s;
|
|
778
966
|
}
|
|
967
|
+
function kebabCamelFrom(s, up) {
|
|
968
|
+
if (s.length === 0) return "";
|
|
969
|
+
if (s.charCodeAt(0) === 45) return kebabCamelFrom(s.slice(1), true);
|
|
970
|
+
const one = s.slice(0, 1);
|
|
971
|
+
return (up ? upperFirst(one) : one) + kebabCamelFrom(s.slice(1), false);
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
// ../utils/src/case.ts
|
|
779
975
|
function foldName(s) {
|
|
780
976
|
if (s.length === 0) return "";
|
|
781
977
|
const c = s.charCodeAt(0);
|
|
@@ -791,12 +987,6 @@ function snakeCamel(s) {
|
|
|
791
987
|
if (s.length === 0) return "";
|
|
792
988
|
return s.slice(0, 1) + snakeCamel(s.slice(1));
|
|
793
989
|
}
|
|
794
|
-
function kebabCamelFrom(s, up) {
|
|
795
|
-
if (s.length === 0) return "";
|
|
796
|
-
if (s.charCodeAt(0) === 45) return kebabCamelFrom(s.slice(1), true);
|
|
797
|
-
const one = s.slice(0, 1);
|
|
798
|
-
return (up ? upperFirst(one) : one) + kebabCamelFrom(s.slice(1), false);
|
|
799
|
-
}
|
|
800
990
|
function kebabCamel(s) {
|
|
801
991
|
return kebabCamelFrom(s, false);
|
|
802
992
|
}
|
|
@@ -39662,14 +39852,14 @@ function toEnvelope(body) {
|
|
|
39662
39852
|
}
|
|
39663
39853
|
return Object.fromEntries(ENVELOPE_KEYS.map((key) => [key, record32[key]]));
|
|
39664
39854
|
}
|
|
39665
|
-
async function callEndpoint(config, id, args = {}) {
|
|
39855
|
+
async function callEndpoint(config, id, args = {}, bounds = NO_BOUNDS) {
|
|
39666
39856
|
const entry = resolveEndpoint(id);
|
|
39667
39857
|
if (!entry) {
|
|
39668
39858
|
throw invalid(unknownIdMessage(id));
|
|
39669
39859
|
}
|
|
39670
39860
|
checkArgs(entry, args);
|
|
39671
39861
|
const url = serviceUrl(entry.service, fillPath(entry, args.pathParams ?? {}));
|
|
39672
|
-
const raw = await new HTTPClient(entry.service, config).raw(entry.method, url, {
|
|
39862
|
+
const raw = await new HTTPClient(entry.service, config, bounds).raw(entry.method, url, {
|
|
39673
39863
|
params: args.query,
|
|
39674
39864
|
data: args.body ?? void 0,
|
|
39675
39865
|
config: { endpoint: entry.path }
|
|
@@ -39686,18 +39876,18 @@ function isSiteChar(c) {
|
|
|
39686
39876
|
function siteCharsFrom(s, i) {
|
|
39687
39877
|
return i >= s.length || isSiteChar(s.charCodeAt(i)) && siteCharsFrom(s, i + 1);
|
|
39688
39878
|
}
|
|
39689
|
-
function
|
|
39879
|
+
function isSiteId(s) {
|
|
39690
39880
|
return s.length > 0 && siteCharsFrom(s, 0);
|
|
39691
39881
|
}
|
|
39692
39882
|
|
|
39693
39883
|
// src/core/site-id-check.ts
|
|
39694
|
-
function
|
|
39695
|
-
return
|
|
39884
|
+
function isSiteId2(s) {
|
|
39885
|
+
return isSiteId(s);
|
|
39696
39886
|
}
|
|
39697
39887
|
|
|
39698
39888
|
// src/core/site-id.ts
|
|
39699
39889
|
function parseSiteId(value) {
|
|
39700
|
-
return
|
|
39890
|
+
return isSiteId2(value) ? value : void 0;
|
|
39701
39891
|
}
|
|
39702
39892
|
function assertSiteId(value) {
|
|
39703
39893
|
const site = parseSiteId(value);
|
|
@@ -41723,8 +41913,32 @@ var Basecamp2Client = class extends BaseServiceClient {
|
|
|
41723
41913
|
};
|
|
41724
41914
|
|
|
41725
41915
|
// src/client.ts
|
|
41916
|
+
function mergedBounds(outer, signal, deadline) {
|
|
41917
|
+
const signals = signal === void 0 ? outer.signals : [...outer.signals, signal];
|
|
41918
|
+
const hasOuter = outer.deadline !== void 0;
|
|
41919
|
+
const hasInner = deadline !== void 0;
|
|
41920
|
+
if (!hasMergedDeadline(hasOuter, hasInner)) return { signals };
|
|
41921
|
+
return {
|
|
41922
|
+
signals,
|
|
41923
|
+
deadline: mergedDeadlineOf(hasOuter, outer.deadline ?? 0, hasInner, deadline ?? 0)
|
|
41924
|
+
};
|
|
41925
|
+
}
|
|
41926
|
+
var CONTEXT_REFUSALS = {
|
|
41927
|
+
context: () => new ContextCreationError("Context is required", "context"),
|
|
41928
|
+
"site-id": () => new ContextCreationError("Context must contain siteId", "siteId"),
|
|
41929
|
+
token: () => new ContextCreationError(
|
|
41930
|
+
"Context must contain jwt or bearerToken for authentication",
|
|
41931
|
+
"bearerToken"
|
|
41932
|
+
),
|
|
41933
|
+
"token-removed": () => new ContextCreationError(
|
|
41934
|
+
"fromContext options must not remove the context's bearer token",
|
|
41935
|
+
"bearerToken"
|
|
41936
|
+
)
|
|
41937
|
+
};
|
|
41726
41938
|
var AugurAPI = class _AugurAPI {
|
|
41727
41939
|
config;
|
|
41940
|
+
/** This client's call bounds: none, unless it is a view from `withRequest`. */
|
|
41941
|
+
bounds = NO_BOUNDS;
|
|
41728
41942
|
_joomla;
|
|
41729
41943
|
_commerce;
|
|
41730
41944
|
_pricing;
|
|
@@ -41787,7 +42001,52 @@ var AugurAPI = class _AugurAPI {
|
|
|
41787
42001
|
* ```
|
|
41788
42002
|
*/
|
|
41789
42003
|
call(id, args) {
|
|
41790
|
-
return callEndpoint(this.config, id, args);
|
|
42004
|
+
return callEndpoint(this.config, id, args, this.bounds);
|
|
42005
|
+
}
|
|
42006
|
+
/**
|
|
42007
|
+
* A view of this client whose every call is bounded by `options` (atlas#106): the caller's
|
|
42008
|
+
* `signal`, and a `deadline` in milliseconds for the whole call, retries and the waits between
|
|
42009
|
+
* them included. The view has this client's siteId, token, timeouts, retries and hooks, sends
|
|
42010
|
+
* the same headers, and builds its own service clients (sharing no in-flight request with this
|
|
42011
|
+
* one). Building a view and its first service costs about what building this client did, so
|
|
42012
|
+
* make one per bounded call, not per request inside a loop.
|
|
42013
|
+
*
|
|
42014
|
+
* @example
|
|
42015
|
+
* ```typescript
|
|
42016
|
+
* const items = await api.withRequest({ deadline: 5000 }).items.categories.items.list(uid, params);
|
|
42017
|
+
* ```
|
|
42018
|
+
*
|
|
42019
|
+
* @throws InvalidArgumentError when `signal` is given but not an AbortSignal, or `deadline` is
|
|
42020
|
+
* given but not a number from 0 to 2147483647 (NaN, Infinity or larger would fire at once).
|
|
42021
|
+
* Options can come from a browser through a server action, so their shape is checked.
|
|
42022
|
+
*/
|
|
42023
|
+
withRequest(options) {
|
|
42024
|
+
const signal = options?.signal;
|
|
42025
|
+
const deadline = options?.deadline;
|
|
42026
|
+
const accepted = callOptionsAccepted(
|
|
42027
|
+
signal !== void 0,
|
|
42028
|
+
signal instanceof AbortSignal,
|
|
42029
|
+
deadline !== void 0,
|
|
42030
|
+
typeof deadline === "number" && deadlineInRange(deadline)
|
|
42031
|
+
);
|
|
42032
|
+
if (!accepted) {
|
|
42033
|
+
throw new InvalidArgumentError({
|
|
42034
|
+
message: "Invalid call options: signal must be an AbortSignal, deadline a number of milliseconds from 0 to 2147483647",
|
|
42035
|
+
service: "",
|
|
42036
|
+
endpoint: ""
|
|
42037
|
+
});
|
|
42038
|
+
}
|
|
42039
|
+
const view = new _AugurAPI(this.config);
|
|
42040
|
+
view.bounds = mergedBounds(
|
|
42041
|
+
this.bounds,
|
|
42042
|
+
signal,
|
|
42043
|
+
deadline
|
|
42044
|
+
);
|
|
42045
|
+
return view;
|
|
42046
|
+
}
|
|
42047
|
+
/** The HTTP client a service is built with: this client's config and call bounds. */
|
|
42048
|
+
httpFor(service) {
|
|
42049
|
+
return new HTTPClient(service, this.config, this.bounds);
|
|
41791
42050
|
}
|
|
41792
42051
|
/**
|
|
41793
42052
|
* Create AugurAPI client from context object
|
|
@@ -41815,25 +42074,19 @@ var AugurAPI = class _AugurAPI {
|
|
|
41815
42074
|
* @throws {ContextCreationError} When context is invalid or missing required fields
|
|
41816
42075
|
*/
|
|
41817
42076
|
static fromContext(context, options = {}) {
|
|
41818
|
-
|
|
41819
|
-
throw new ContextCreationError("Context is required", "context");
|
|
41820
|
-
}
|
|
41821
|
-
if (!context.siteId) {
|
|
41822
|
-
throw new ContextCreationError("Context must contain siteId", "siteId");
|
|
41823
|
-
}
|
|
41824
|
-
const bearerToken = context.jwt || context.bearerToken;
|
|
41825
|
-
if (!bearerToken) {
|
|
41826
|
-
throw new ContextCreationError(
|
|
41827
|
-
"Context must contain jwt or bearerToken for authentication",
|
|
41828
|
-
"bearerToken"
|
|
41829
|
-
);
|
|
41830
|
-
}
|
|
42077
|
+
const bearerToken = context?.jwt || context?.bearerToken;
|
|
41831
42078
|
const config = {
|
|
41832
|
-
siteId: context
|
|
42079
|
+
siteId: context?.siteId ?? "",
|
|
41833
42080
|
bearerToken,
|
|
41834
42081
|
...options
|
|
41835
|
-
// Allow overrides
|
|
41836
42082
|
};
|
|
42083
|
+
const refusal = contextRefusalOf(
|
|
42084
|
+
Boolean(context),
|
|
42085
|
+
Boolean(context?.siteId),
|
|
42086
|
+
Boolean(bearerToken),
|
|
42087
|
+
Boolean(config.bearerToken)
|
|
42088
|
+
);
|
|
42089
|
+
if (refusal !== "ok") throw CONTEXT_REFUSALS[refusal]();
|
|
41837
42090
|
return new _AugurAPI(config);
|
|
41838
42091
|
}
|
|
41839
42092
|
/**
|
|
@@ -41841,7 +42094,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
41841
42094
|
*/
|
|
41842
42095
|
get joomla() {
|
|
41843
42096
|
if (!this._joomla) {
|
|
41844
|
-
const httpClient =
|
|
42097
|
+
const httpClient = this.httpFor("joomla");
|
|
41845
42098
|
this._joomla = new JoomlaClient(httpClient);
|
|
41846
42099
|
}
|
|
41847
42100
|
return this._joomla;
|
|
@@ -41851,7 +42104,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
41851
42104
|
*/
|
|
41852
42105
|
get commerce() {
|
|
41853
42106
|
if (!this._commerce) {
|
|
41854
|
-
const httpClient =
|
|
42107
|
+
const httpClient = this.httpFor("commerce");
|
|
41855
42108
|
this._commerce = new CommerceClient(httpClient);
|
|
41856
42109
|
}
|
|
41857
42110
|
return this._commerce;
|
|
@@ -41861,7 +42114,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
41861
42114
|
*/
|
|
41862
42115
|
get pricing() {
|
|
41863
42116
|
if (!this._pricing) {
|
|
41864
|
-
const httpClient =
|
|
42117
|
+
const httpClient = this.httpFor("pricing");
|
|
41865
42118
|
this._pricing = new PricingClient(httpClient);
|
|
41866
42119
|
}
|
|
41867
42120
|
return this._pricing;
|
|
@@ -41871,7 +42124,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
41871
42124
|
*/
|
|
41872
42125
|
get vmi() {
|
|
41873
42126
|
if (!this._vmi) {
|
|
41874
|
-
const httpClient =
|
|
42127
|
+
const httpClient = this.httpFor("vmi");
|
|
41875
42128
|
this._vmi = new VMIClient(httpClient);
|
|
41876
42129
|
}
|
|
41877
42130
|
return this._vmi;
|
|
@@ -41881,7 +42134,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
41881
42134
|
*/
|
|
41882
42135
|
get openSearch() {
|
|
41883
42136
|
if (!this._openSearch) {
|
|
41884
|
-
const httpClient =
|
|
42137
|
+
const httpClient = this.httpFor("open-search");
|
|
41885
42138
|
this._openSearch = new OpenSearchClient(httpClient);
|
|
41886
42139
|
}
|
|
41887
42140
|
return this._openSearch;
|
|
@@ -41891,7 +42144,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
41891
42144
|
*/
|
|
41892
42145
|
get items() {
|
|
41893
42146
|
if (!this._items) {
|
|
41894
|
-
const httpClient =
|
|
42147
|
+
const httpClient = this.httpFor("items");
|
|
41895
42148
|
this._items = new ItemsClient(httpClient);
|
|
41896
42149
|
}
|
|
41897
42150
|
return this._items;
|
|
@@ -41901,7 +42154,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
41901
42154
|
*/
|
|
41902
42155
|
get legacy() {
|
|
41903
42156
|
if (!this._legacy) {
|
|
41904
|
-
const httpClient =
|
|
42157
|
+
const httpClient = this.httpFor("legacy");
|
|
41905
42158
|
this._legacy = new LegacyClient(httpClient);
|
|
41906
42159
|
}
|
|
41907
42160
|
return this._legacy;
|
|
@@ -41911,7 +42164,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
41911
42164
|
*/
|
|
41912
42165
|
get agrSite() {
|
|
41913
42166
|
if (!this._agrSite) {
|
|
41914
|
-
const httpClient =
|
|
42167
|
+
const httpClient = this.httpFor("agr-site");
|
|
41915
42168
|
this._agrSite = new AgrSiteClient(httpClient);
|
|
41916
42169
|
}
|
|
41917
42170
|
return this._agrSite;
|
|
@@ -41921,7 +42174,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
41921
42174
|
*/
|
|
41922
42175
|
get customers() {
|
|
41923
42176
|
if (!this._customers) {
|
|
41924
|
-
const httpClient =
|
|
42177
|
+
const httpClient = this.httpFor("customers");
|
|
41925
42178
|
this._customers = new CustomersClient(httpClient);
|
|
41926
42179
|
}
|
|
41927
42180
|
return this._customers;
|
|
@@ -41931,7 +42184,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
41931
42184
|
*/
|
|
41932
42185
|
get orders() {
|
|
41933
42186
|
if (!this._orders) {
|
|
41934
|
-
const httpClient =
|
|
42187
|
+
const httpClient = this.httpFor("orders");
|
|
41935
42188
|
this._orders = new OrdersClient(httpClient);
|
|
41936
42189
|
}
|
|
41937
42190
|
return this._orders;
|
|
@@ -41941,7 +42194,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
41941
42194
|
*/
|
|
41942
42195
|
get p21Pim() {
|
|
41943
42196
|
if (!this._p21Pim) {
|
|
41944
|
-
const httpClient =
|
|
42197
|
+
const httpClient = this.httpFor("p21-pim");
|
|
41945
42198
|
this._p21Pim = new P21PimClient(httpClient);
|
|
41946
42199
|
}
|
|
41947
42200
|
return this._p21Pim;
|
|
@@ -41951,7 +42204,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
41951
42204
|
*/
|
|
41952
42205
|
get payments() {
|
|
41953
42206
|
if (!this._payments) {
|
|
41954
|
-
const httpClient =
|
|
42207
|
+
const httpClient = this.httpFor("payments");
|
|
41955
42208
|
this._payments = new PaymentsClient(httpClient);
|
|
41956
42209
|
}
|
|
41957
42210
|
return this._payments;
|
|
@@ -41961,7 +42214,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
41961
42214
|
*/
|
|
41962
42215
|
get agrInfo() {
|
|
41963
42216
|
if (!this._agrInfo) {
|
|
41964
|
-
const httpClient =
|
|
42217
|
+
const httpClient = this.httpFor("agr-info");
|
|
41965
42218
|
this._agrInfo = new AgrInfoClient(httpClient);
|
|
41966
42219
|
}
|
|
41967
42220
|
return this._agrInfo;
|
|
@@ -41971,7 +42224,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
41971
42224
|
*/
|
|
41972
42225
|
get agrInt() {
|
|
41973
42226
|
if (!this._agrInt) {
|
|
41974
|
-
const httpClient =
|
|
42227
|
+
const httpClient = this.httpFor("agr-int");
|
|
41975
42228
|
this._agrInt = new AgrIntClient(httpClient);
|
|
41976
42229
|
}
|
|
41977
42230
|
return this._agrInt;
|
|
@@ -41981,7 +42234,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
41981
42234
|
*/
|
|
41982
42235
|
get agrWork() {
|
|
41983
42236
|
if (!this._agrWork) {
|
|
41984
|
-
const httpClient =
|
|
42237
|
+
const httpClient = this.httpFor("agr-work");
|
|
41985
42238
|
this._agrWork = new AgrWorkClient(httpClient);
|
|
41986
42239
|
}
|
|
41987
42240
|
return this._agrWork;
|
|
@@ -41991,7 +42244,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
41991
42244
|
*/
|
|
41992
42245
|
get avalara() {
|
|
41993
42246
|
if (!this._avalara) {
|
|
41994
|
-
const httpClient =
|
|
42247
|
+
const httpClient = this.httpFor("avalara");
|
|
41995
42248
|
this._avalara = new AvalaraClient(httpClient);
|
|
41996
42249
|
}
|
|
41997
42250
|
return this._avalara;
|
|
@@ -42001,7 +42254,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
42001
42254
|
*/
|
|
42002
42255
|
get brandFolder() {
|
|
42003
42256
|
if (!this._brandFolder) {
|
|
42004
|
-
const httpClient =
|
|
42257
|
+
const httpClient = this.httpFor("brand-folder");
|
|
42005
42258
|
this._brandFolder = new BrandFolderClient(httpClient);
|
|
42006
42259
|
}
|
|
42007
42260
|
return this._brandFolder;
|
|
@@ -42011,7 +42264,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
42011
42264
|
*/
|
|
42012
42265
|
get googMc() {
|
|
42013
42266
|
if (!this._googMc) {
|
|
42014
|
-
const httpClient =
|
|
42267
|
+
const httpClient = this.httpFor("goog-mc");
|
|
42015
42268
|
this._googMc = new GoogMcClient(httpClient);
|
|
42016
42269
|
}
|
|
42017
42270
|
return this._googMc;
|
|
@@ -42021,7 +42274,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
42021
42274
|
*/
|
|
42022
42275
|
get gregorovich() {
|
|
42023
42276
|
if (!this._gregorovich) {
|
|
42024
|
-
const httpClient =
|
|
42277
|
+
const httpClient = this.httpFor("gregorovich");
|
|
42025
42278
|
this._gregorovich = new GregorovichClient(httpClient);
|
|
42026
42279
|
}
|
|
42027
42280
|
return this._gregorovich;
|
|
@@ -42031,7 +42284,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
42031
42284
|
*/
|
|
42032
42285
|
get logistics() {
|
|
42033
42286
|
if (!this._logistics) {
|
|
42034
|
-
const httpClient =
|
|
42287
|
+
const httpClient = this.httpFor("logistics");
|
|
42035
42288
|
this._logistics = new LogisticsClient(httpClient);
|
|
42036
42289
|
}
|
|
42037
42290
|
return this._logistics;
|
|
@@ -42041,7 +42294,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
42041
42294
|
*/
|
|
42042
42295
|
get markets() {
|
|
42043
42296
|
if (!this._markets) {
|
|
42044
|
-
const httpClient =
|
|
42297
|
+
const httpClient = this.httpFor("markets");
|
|
42045
42298
|
this._markets = new MarketsClient(httpClient);
|
|
42046
42299
|
}
|
|
42047
42300
|
return this._markets;
|
|
@@ -42051,7 +42304,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
42051
42304
|
*/
|
|
42052
42305
|
get notifications() {
|
|
42053
42306
|
if (!this._notifications) {
|
|
42054
|
-
const httpClient =
|
|
42307
|
+
const httpClient = this.httpFor("notifications");
|
|
42055
42308
|
this._notifications = new NotificationsClient(httpClient);
|
|
42056
42309
|
}
|
|
42057
42310
|
return this._notifications;
|
|
@@ -42061,7 +42314,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
42061
42314
|
*/
|
|
42062
42315
|
get p21Apis() {
|
|
42063
42316
|
if (!this._p21Apis) {
|
|
42064
|
-
const httpClient =
|
|
42317
|
+
const httpClient = this.httpFor("p21-apis");
|
|
42065
42318
|
this._p21Apis = new P21ApisClient(httpClient);
|
|
42066
42319
|
}
|
|
42067
42320
|
return this._p21Apis;
|
|
@@ -42071,7 +42324,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
42071
42324
|
*/
|
|
42072
42325
|
get p21Core() {
|
|
42073
42326
|
if (!this._p21Core) {
|
|
42074
|
-
const httpClient =
|
|
42327
|
+
const httpClient = this.httpFor("p21-core");
|
|
42075
42328
|
this._p21Core = new P21CoreClient(httpClient);
|
|
42076
42329
|
}
|
|
42077
42330
|
return this._p21Core;
|
|
@@ -42081,7 +42334,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
42081
42334
|
*/
|
|
42082
42335
|
get p21Sism() {
|
|
42083
42336
|
if (!this._p21Sism) {
|
|
42084
|
-
const httpClient =
|
|
42337
|
+
const httpClient = this.httpFor("p21-sism");
|
|
42085
42338
|
this._p21Sism = new P21SismClient(httpClient);
|
|
42086
42339
|
}
|
|
42087
42340
|
return this._p21Sism;
|
|
@@ -42091,7 +42344,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
42091
42344
|
*/
|
|
42092
42345
|
get shipping() {
|
|
42093
42346
|
if (!this._shipping) {
|
|
42094
|
-
const httpClient =
|
|
42347
|
+
const httpClient = this.httpFor("shipping");
|
|
42095
42348
|
this._shipping = new ShippingClient(httpClient);
|
|
42096
42349
|
}
|
|
42097
42350
|
return this._shipping;
|
|
@@ -42101,7 +42354,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
42101
42354
|
*/
|
|
42102
42355
|
get smartyStreets() {
|
|
42103
42356
|
if (!this._smartyStreets) {
|
|
42104
|
-
const httpClient =
|
|
42357
|
+
const httpClient = this.httpFor("smarty-streets");
|
|
42105
42358
|
this._smartyStreets = new SmartyStreetsClient(httpClient);
|
|
42106
42359
|
}
|
|
42107
42360
|
return this._smartyStreets;
|
|
@@ -42111,7 +42364,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
42111
42364
|
*/
|
|
42112
42365
|
get ups() {
|
|
42113
42366
|
if (!this._ups) {
|
|
42114
|
-
const httpClient =
|
|
42367
|
+
const httpClient = this.httpFor("ups");
|
|
42115
42368
|
this._ups = new UPSClient(httpClient);
|
|
42116
42369
|
}
|
|
42117
42370
|
return this._ups;
|
|
@@ -42121,7 +42374,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
42121
42374
|
*/
|
|
42122
42375
|
get vendors() {
|
|
42123
42376
|
if (!this._vendors) {
|
|
42124
|
-
const httpClient =
|
|
42377
|
+
const httpClient = this.httpFor("vendors");
|
|
42125
42378
|
this._vendors = new VendorsClient(httpClient);
|
|
42126
42379
|
}
|
|
42127
42380
|
return this._vendors;
|
|
@@ -42131,13 +42384,18 @@ var AugurAPI = class _AugurAPI {
|
|
|
42131
42384
|
*/
|
|
42132
42385
|
get basecamp2() {
|
|
42133
42386
|
if (!this._basecamp2) {
|
|
42134
|
-
const httpClient =
|
|
42387
|
+
const httpClient = this.httpFor("basecamp2");
|
|
42135
42388
|
this._basecamp2 = new Basecamp2Client(httpClient);
|
|
42136
42389
|
}
|
|
42137
42390
|
return this._basecamp2;
|
|
42138
42391
|
}
|
|
42139
42392
|
/**
|
|
42140
42393
|
* Update authentication token
|
|
42394
|
+
*
|
|
42395
|
+
* Every service read from this client afterwards (`api.items`, …) sends the new token. A
|
|
42396
|
+
* service object read BEFORE the change keeps the token it was built with: read services from
|
|
42397
|
+
* the client after a change, don't hold them across it (AugurApiClient.BuiltClientKeepsItsSnapshot).
|
|
42398
|
+
*
|
|
42141
42399
|
* @param bearerToken New bearer token
|
|
42142
42400
|
*/
|
|
42143
42401
|
setAuthToken(bearerToken) {
|
|
@@ -42146,6 +42404,9 @@ var AugurAPI = class _AugurAPI {
|
|
|
42146
42404
|
}
|
|
42147
42405
|
/**
|
|
42148
42406
|
* Update site ID
|
|
42407
|
+
*
|
|
42408
|
+
* As with `setAuthToken`: a service object read before the change keeps the old siteId.
|
|
42409
|
+
*
|
|
42149
42410
|
* @param siteId New site ID
|
|
42150
42411
|
* @throws InvalidArgumentError when it is not a siteId (see the constructor)
|
|
42151
42412
|
*/
|
|
@@ -42242,7 +42503,7 @@ function createCrossSiteAuthenticator(augurInfoToken) {
|
|
|
42242
42503
|
}
|
|
42243
42504
|
|
|
42244
42505
|
// src/index.ts
|
|
42245
|
-
var VERSION = "2026.11.
|
|
42506
|
+
var VERSION = "2026.11.4";
|
|
42246
42507
|
export {
|
|
42247
42508
|
AgrInfoClient,
|
|
42248
42509
|
AgrIntClient,
|
|
@@ -42290,7 +42551,7 @@ export {
|
|
|
42290
42551
|
authenticateUserForSite,
|
|
42291
42552
|
createCrossSiteAuthenticator,
|
|
42292
42553
|
isReadOnly,
|
|
42293
|
-
isSiteId,
|
|
42554
|
+
isSiteId2 as isSiteId,
|
|
42294
42555
|
parseSiteId
|
|
42295
42556
|
};
|
|
42296
42557
|
//# sourceMappingURL=index.mjs.map
|