@simpleapps-com/augur-api 2026.11.3 → 2026.11.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +40 -3
- package/dist/client.d.ts +31 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/core/base-client.d.ts.map +1 -1
- package/dist/core/call-rules.d.ts +35 -0
- package/dist/core/call-rules.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 +152 -0
- package/dist/core/client-rules.d.ts.map +1 -0
- package/dist/core/client.d.ts +36 -5
- 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/encoded-segment.d.ts +7 -1
- package/dist/core/encoded-segment.d.ts.map +1 -1
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core/http-rules.d.ts +0 -32
- package/dist/core/http-rules.d.ts.map +1 -1
- package/dist/core/proxy-rules.d.ts +53 -0
- package/dist/core/proxy-rules.d.ts.map +1 -1
- package/dist/core/registry-rules.d.ts +7 -0
- package/dist/core/registry-rules.d.ts.map +1 -1
- package/dist/core/registry.d.ts.map +1 -1
- package/dist/core/response-rules.d.ts +15 -0
- package/dist/core/response-rules.d.ts.map +1 -1
- package/dist/core/schemas.d.ts.map +1 -1
- package/dist/core/service-proxy.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +774 -327
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +774 -327
- package/dist/index.mjs.map +1 -1
- package/dist/services/goog-mc/generated/schemas.d.ts +8 -0
- package/dist/services/goog-mc/generated/schemas.d.ts.map +1 -1
- package/dist/services/goog-mc/generated/types.d.ts +8 -0
- package/dist/services/goog-mc/generated/types.d.ts.map +1 -1
- package/dist/services/items/client.d.ts +1 -1
- package/dist/services/items/generated/endpoints.d.ts.map +1 -1
- package/dist/services/items/generated/schemas.d.ts +8 -0
- package/dist/services/items/generated/schemas.d.ts.map +1 -1
- package/dist/services/items/generated/types.d.ts +13 -4
- package/dist/services/items/generated/types.d.ts.map +1 -1
- package/dist/services/joomla/generated/endpoints.d.ts.map +1 -1
- package/dist/services/joomla/generated/schemas.d.ts +5 -0
- package/dist/services/joomla/generated/schemas.d.ts.map +1 -1
- package/dist/services/joomla/generated/types.d.ts +18 -2
- package/dist/services/joomla/generated/types.d.ts.map +1 -1
- package/dist/services/legacy/generated/endpoints.d.ts.map +1 -1
- package/dist/services/legacy/generated/schemas.d.ts +2 -0
- package/dist/services/legacy/generated/schemas.d.ts.map +1 -1
- package/dist/services/legacy/generated/types.d.ts +4 -0
- package/dist/services/legacy/generated/types.d.ts.map +1 -1
- package/dist/services/open-search/generated/endpoints.d.ts.map +1 -1
- package/dist/services/open-search/generated/schemas.d.ts +2 -0
- package/dist/services/open-search/generated/schemas.d.ts.map +1 -1
- package/dist/services/open-search/generated/types.d.ts +4 -0
- package/dist/services/open-search/generated/types.d.ts.map +1 -1
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +22 -9
- package/dist/testing.js.map +1 -1
- package/dist/testing.mjs +20 -9
- package/dist/testing.mjs.map +1 -1
- package/dist/utils/cross-site-auth.d.ts.map +1 -1
- package/package.json +3 -1
package/dist/index.mjs
CHANGED
|
@@ -57,6 +57,9 @@ function joinFrom(xs, sep, i) {
|
|
|
57
57
|
if (i >= xs.length) return "";
|
|
58
58
|
return joinRange(xs, sep, i, xs.length);
|
|
59
59
|
}
|
|
60
|
+
function joinOr(xs, sep, fallback) {
|
|
61
|
+
return xs.length === 0 ? fallback : joinFrom(xs, sep, 0);
|
|
62
|
+
}
|
|
60
63
|
function joinRange(xs, sep, lo, hi) {
|
|
61
64
|
if (hi - lo === 1) return xs[lo];
|
|
62
65
|
const mid = lo + Math.floor((hi - lo) / 2);
|
|
@@ -73,6 +76,13 @@ function notInFrom(xs, allowed, i) {
|
|
|
73
76
|
return hasItemFrom(allowed, xs[i], 0) ? rest : [xs[i], ...rest];
|
|
74
77
|
}
|
|
75
78
|
|
|
79
|
+
// ../utils/src/pairs.ts
|
|
80
|
+
function allFrom(xs, i) {
|
|
81
|
+
if (i === xs.length) return true;
|
|
82
|
+
if (!xs[i]) return false;
|
|
83
|
+
return allFrom(xs, i + 1);
|
|
84
|
+
}
|
|
85
|
+
|
|
76
86
|
// ../utils/src/uri.ts
|
|
77
87
|
function isHigh(c) {
|
|
78
88
|
return c >= 55296 && c <= 56319;
|
|
@@ -121,6 +131,25 @@ function isEncoded(s) {
|
|
|
121
131
|
}
|
|
122
132
|
return true;
|
|
123
133
|
}
|
|
134
|
+
function pcharOf(hex) {
|
|
135
|
+
if (hex === "24") return "$";
|
|
136
|
+
if (hex === "26") return "&";
|
|
137
|
+
if (hex === "2B") return "+";
|
|
138
|
+
if (hex === "2C") return ",";
|
|
139
|
+
if (hex === "3B") return ";";
|
|
140
|
+
if (hex === "3D") return "=";
|
|
141
|
+
if (hex === "3A") return ":";
|
|
142
|
+
if (hex === "40") return "@";
|
|
143
|
+
return "";
|
|
144
|
+
}
|
|
145
|
+
function restorePcharFrom(s, i) {
|
|
146
|
+
if (i >= s.length) return "";
|
|
147
|
+
if (s.slice(i, i + 1) === "%" && i + 3 <= s.length) {
|
|
148
|
+
const ch = pcharOf(s.slice(i + 1, i + 3));
|
|
149
|
+
if (ch !== "") return ch + restorePcharFrom(s, i + 3);
|
|
150
|
+
}
|
|
151
|
+
return s.slice(i, i + 1) + restorePcharFrom(s, i + 1);
|
|
152
|
+
}
|
|
124
153
|
|
|
125
154
|
// ../utils/src/replace.ts
|
|
126
155
|
function replaceText(s, find, put) {
|
|
@@ -132,6 +161,21 @@ function replaceText(s, find, put) {
|
|
|
132
161
|
}
|
|
133
162
|
|
|
134
163
|
// src/core/call-rules.ts
|
|
164
|
+
function isEnvelopeBody(isPlainObject, allKeys) {
|
|
165
|
+
return isPlainObject && allKeys;
|
|
166
|
+
}
|
|
167
|
+
function callBodyKind(isJson) {
|
|
168
|
+
return isJson ? "json" : "text";
|
|
169
|
+
}
|
|
170
|
+
function validationMessageOf(kind) {
|
|
171
|
+
return kind === "params" ? "Invalid request parameters" : "Invalid API response structure\nThis appears to be a response validation error. The API returned data in an unexpected format.";
|
|
172
|
+
}
|
|
173
|
+
function issueCodeOf(type) {
|
|
174
|
+
return type !== void 0 ? type : "unknown";
|
|
175
|
+
}
|
|
176
|
+
function appendsIssues(count) {
|
|
177
|
+
return count > 0;
|
|
178
|
+
}
|
|
135
179
|
function isQueryKeyAllowed(declared, edgeCache, key) {
|
|
136
180
|
return declared || edgeCache && key === "edgeCache";
|
|
137
181
|
}
|
|
@@ -170,11 +214,6 @@ function placeholderFilled(path, placeholder, segment) {
|
|
|
170
214
|
return replaceText(path, "{" + placeholder + "}", segment);
|
|
171
215
|
}
|
|
172
216
|
|
|
173
|
-
// ../json-values/src/index.ts
|
|
174
|
-
function isRecord(value) {
|
|
175
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
217
|
// ../foundation/src/duration.ts
|
|
179
218
|
function seconds(n) {
|
|
180
219
|
return n;
|
|
@@ -184,6 +223,7 @@ function toMillis(d) {
|
|
|
184
223
|
}
|
|
185
224
|
|
|
186
225
|
// src/core/config.ts
|
|
226
|
+
var NO_BOUNDS = { signals: [] };
|
|
187
227
|
var DEFAULT_CONFIG = {
|
|
188
228
|
timeout: toMillis(seconds(30)),
|
|
189
229
|
retries: 3,
|
|
@@ -198,7 +238,145 @@ var ContextCreationError = class extends Error {
|
|
|
198
238
|
field;
|
|
199
239
|
};
|
|
200
240
|
|
|
241
|
+
// ../foundation/src/optional.ts
|
|
242
|
+
function nonEmptyOr(s, fallback) {
|
|
243
|
+
return s !== "" ? s : fallback;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// ../foundation/src/decimal.ts
|
|
247
|
+
function decimal(n) {
|
|
248
|
+
const last = "0123456789".slice(n % 10, n % 10 + 1);
|
|
249
|
+
return n < 10 ? last : decimal(Math.floor(n / 10)) + last;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// ../json-values/src/index.ts
|
|
253
|
+
function isRecord(value) {
|
|
254
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
// ../utils/src/http.ts
|
|
258
|
+
function isPostOrPut(method) {
|
|
259
|
+
return method === "POST" || method === "PUT";
|
|
260
|
+
}
|
|
261
|
+
function querySeparator(url) {
|
|
262
|
+
return includesFrom(url, "?", 0) ? "&" : "?";
|
|
263
|
+
}
|
|
264
|
+
function queryValueSent(isUndefined, isNull) {
|
|
265
|
+
return !isUndefined && !isNull;
|
|
266
|
+
}
|
|
267
|
+
function urlWithQuery(url, query) {
|
|
268
|
+
return query === "" ? url : url + querySeparator(url) + query;
|
|
269
|
+
}
|
|
270
|
+
function isRetryableStatus(status) {
|
|
271
|
+
return !(status >= 400 && status < 500 && status !== 429);
|
|
272
|
+
}
|
|
273
|
+
function exponentialDelay(base, attempt) {
|
|
274
|
+
if (attempt === 0) return base;
|
|
275
|
+
return 2 * exponentialDelay(base, attempt - 1);
|
|
276
|
+
}
|
|
277
|
+
function cappedAt(d, cap) {
|
|
278
|
+
return Math.min(d, cap);
|
|
279
|
+
}
|
|
280
|
+
function firstGiven(hasA, a, hasB, b, fallback) {
|
|
281
|
+
if (hasA) return a;
|
|
282
|
+
return hasB ? b : fallback;
|
|
283
|
+
}
|
|
284
|
+
function isAbortName(name) {
|
|
285
|
+
return name === "AbortError" || name === "TimeoutError";
|
|
286
|
+
}
|
|
287
|
+
function remainingOf(deadline, elapsed) {
|
|
288
|
+
return elapsed < deadline ? deadline - elapsed : 0;
|
|
289
|
+
}
|
|
290
|
+
function cutToRemaining(value, hasDeadline, remaining) {
|
|
291
|
+
return hasDeadline && remaining < value ? remaining : value;
|
|
292
|
+
}
|
|
293
|
+
function startsAttempt(hasDeadline, remaining) {
|
|
294
|
+
return !hasDeadline || remaining > 0;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
// src/core/client-rules.ts
|
|
298
|
+
function contextRefusalOf(hasContext, siteIdTruthy, contextTokenTruthy, finalTokenTruthy) {
|
|
299
|
+
if (!hasContext) return "context";
|
|
300
|
+
if (!siteIdTruthy) return "site-id";
|
|
301
|
+
if (!contextTokenTruthy) return "token";
|
|
302
|
+
return finalTokenTruthy ? "ok" : "token-removed";
|
|
303
|
+
}
|
|
304
|
+
function retryableError(isAugurError, status) {
|
|
305
|
+
return !isAugurError || isRetryableStatus(status);
|
|
306
|
+
}
|
|
307
|
+
function retryAfterCall(attempt, retries, retryable, callAborted) {
|
|
308
|
+
return !callAborted && attempt < retries && retryable;
|
|
309
|
+
}
|
|
310
|
+
function needsAttemptTimer(perAttempt, hasDeadline, remaining) {
|
|
311
|
+
return !(hasDeadline && remaining <= perAttempt);
|
|
312
|
+
}
|
|
313
|
+
function boundedCall(hasSignal, hasDeadline) {
|
|
314
|
+
return hasSignal || hasDeadline;
|
|
315
|
+
}
|
|
316
|
+
function deadlineInRange(deadline) {
|
|
317
|
+
return 0 <= deadline && deadline <= 2147483647;
|
|
318
|
+
}
|
|
319
|
+
function callOptionsAccepted(hasSignal, isAbortSignal, hasDeadline, inRange) {
|
|
320
|
+
return (!hasSignal || isAbortSignal) && (!hasDeadline || inRange);
|
|
321
|
+
}
|
|
322
|
+
function sharesInFlight(hasRequestSignal) {
|
|
323
|
+
return !hasRequestSignal;
|
|
324
|
+
}
|
|
325
|
+
function mergedDeadlineOf(hasOuter, outer, hasInner, inner) {
|
|
326
|
+
if (!hasOuter) return inner;
|
|
327
|
+
if (!hasInner) return outer;
|
|
328
|
+
return inner < outer ? inner : outer;
|
|
329
|
+
}
|
|
330
|
+
function hasMergedDeadline(hasOuter, hasInner) {
|
|
331
|
+
return hasOuter || hasInner;
|
|
332
|
+
}
|
|
333
|
+
function edgeCacheKindOf(text) {
|
|
334
|
+
if (text === "30s" || text === "1m" || text === "5m") return "sub-hour";
|
|
335
|
+
const hourly = text === "1" || text === "2" || text === "3" || text === "4" || text === "5" || text === "8";
|
|
336
|
+
return hourly ? "hourly" : "invalid";
|
|
337
|
+
}
|
|
338
|
+
function edgeCacheKeyOf(kind, text) {
|
|
339
|
+
return kind === "invalid" ? "" : "cacheSiteId" + text;
|
|
340
|
+
}
|
|
341
|
+
function errorClassOf(status) {
|
|
342
|
+
if (status === 400) return "validation";
|
|
343
|
+
if (status === 401) return "authentication";
|
|
344
|
+
if (status === 404) return "notFound";
|
|
345
|
+
if (status === 429) return "rateLimit";
|
|
346
|
+
return "augur";
|
|
347
|
+
}
|
|
348
|
+
function detailMessageOf(isJson, isObject, isText, message) {
|
|
349
|
+
if (isJson && isObject && isText && message !== "") return message;
|
|
350
|
+
return void 0;
|
|
351
|
+
}
|
|
352
|
+
function defaultMessageOf(kind, status) {
|
|
353
|
+
if (kind === "validation") return "Validation failed";
|
|
354
|
+
if (kind === "authentication") return "Authentication failed";
|
|
355
|
+
if (kind === "notFound") return "Resource not found";
|
|
356
|
+
if (kind === "rateLimit") return "Rate limit exceeded";
|
|
357
|
+
return "Request failed with status " + decimal(status);
|
|
358
|
+
}
|
|
359
|
+
function errorMessageOf(given, kind, status) {
|
|
360
|
+
return given !== void 0 ? given : defaultMessageOf(kind, status);
|
|
361
|
+
}
|
|
362
|
+
function crossSiteUserIdOf(isId, id) {
|
|
363
|
+
return isId ? decimal(id) : void 0;
|
|
364
|
+
}
|
|
365
|
+
function responseHookOf(ok, hasOnError, hasOnResponse) {
|
|
366
|
+
if (ok) return hasOnResponse ? "onResponse" : "noHook";
|
|
367
|
+
return hasOnError ? "onError" : "noHook";
|
|
368
|
+
}
|
|
369
|
+
function crossSiteOutcomeOf(isVerified, tokenIsText, token) {
|
|
370
|
+
if (!isVerified) return "notVerified";
|
|
371
|
+
if (!tokenIsText || token === "") return "noToken";
|
|
372
|
+
return "signedIn";
|
|
373
|
+
}
|
|
374
|
+
function rawRetries(method) {
|
|
375
|
+
return method === "GET";
|
|
376
|
+
}
|
|
377
|
+
|
|
201
378
|
// src/core/errors.ts
|
|
379
|
+
var ROOT_PATH = "root";
|
|
202
380
|
var AugurError = class _AugurError extends Error {
|
|
203
381
|
code;
|
|
204
382
|
statusCode;
|
|
@@ -237,8 +415,7 @@ var ValidationError = class extends AugurError {
|
|
|
237
415
|
return [];
|
|
238
416
|
}
|
|
239
417
|
return this.validationErrors.map((error) => {
|
|
240
|
-
|
|
241
|
-
return `${path}: ${error.message}`;
|
|
418
|
+
return `${joinOr(error.path.map(String), ".", ROOT_PATH)}: ${error.message}`;
|
|
242
419
|
});
|
|
243
420
|
}
|
|
244
421
|
/**
|
|
@@ -250,7 +427,7 @@ var ValidationError = class extends AugurError {
|
|
|
250
427
|
return [];
|
|
251
428
|
}
|
|
252
429
|
return this.validationErrors.map((error) => ({
|
|
253
|
-
path: error.path.
|
|
430
|
+
path: joinOr(error.path.map(String), ".", ROOT_PATH),
|
|
254
431
|
message: error.message,
|
|
255
432
|
code: error.code,
|
|
256
433
|
received: "received" in error ? error.received : void 0,
|
|
@@ -264,7 +441,7 @@ var ValidationError = class extends AugurError {
|
|
|
264
441
|
toString() {
|
|
265
442
|
const baseMessage = super.toString();
|
|
266
443
|
const formattedErrors = this.getFormattedErrors();
|
|
267
|
-
if (formattedErrors.length
|
|
444
|
+
if (appendsIssues(formattedErrors.length)) {
|
|
268
445
|
return `${baseMessage}
|
|
269
446
|
Validation errors:
|
|
270
447
|
${formattedErrors.map((err) => ` - ${err}`).join("\n")}`;
|
|
@@ -309,21 +486,39 @@ var InvalidArgumentError = class extends AugurError {
|
|
|
309
486
|
}
|
|
310
487
|
};
|
|
311
488
|
|
|
312
|
-
// src/
|
|
313
|
-
function
|
|
314
|
-
return
|
|
489
|
+
// ../auth-core/src/site.ts
|
|
490
|
+
function isSiteChar(c) {
|
|
491
|
+
return c >= 97 && c <= 122 || c >= 48 && c <= 57 || c === 95 || c === 45;
|
|
315
492
|
}
|
|
316
|
-
function
|
|
317
|
-
|
|
318
|
-
return 2 * exponentialDelay(base, attempt - 1);
|
|
493
|
+
function siteCharsFrom(s, i) {
|
|
494
|
+
return i >= s.length || isSiteChar(s.charCodeAt(i)) && siteCharsFrom(s, i + 1);
|
|
319
495
|
}
|
|
320
|
-
function
|
|
321
|
-
return
|
|
496
|
+
function isSiteId(s) {
|
|
497
|
+
return s.length > 0 && siteCharsFrom(s, 0);
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
// src/core/site-id-check.ts
|
|
501
|
+
function isSiteId2(s) {
|
|
502
|
+
return isSiteId(s);
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
// src/core/site-id.ts
|
|
506
|
+
function parseSiteId(value) {
|
|
507
|
+
return isSiteId2(value) ? value : void 0;
|
|
322
508
|
}
|
|
323
|
-
function
|
|
324
|
-
|
|
325
|
-
|
|
509
|
+
function assertSiteId(value) {
|
|
510
|
+
const site = parseSiteId(value);
|
|
511
|
+
if (site === void 0) {
|
|
512
|
+
throw new InvalidArgumentError({
|
|
513
|
+
message: "Invalid siteId: expected lowercase letters, digits, '_' and '-' (e.g. example-site)",
|
|
514
|
+
service: "",
|
|
515
|
+
endpoint: ""
|
|
516
|
+
});
|
|
517
|
+
}
|
|
518
|
+
return site;
|
|
326
519
|
}
|
|
520
|
+
|
|
521
|
+
// src/core/http-rules.ts
|
|
327
522
|
function isPublicEndpoint(url) {
|
|
328
523
|
return endsWith(url, "/health-check") || endsWith(url, "/ping");
|
|
329
524
|
}
|
|
@@ -333,9 +528,6 @@ function sendsBearer(url, hasToken) {
|
|
|
333
528
|
function sendsJsonBody(hasData, method) {
|
|
334
529
|
return hasData && method !== "GET";
|
|
335
530
|
}
|
|
336
|
-
function querySeparator(url) {
|
|
337
|
-
return includesFrom(url, "?", 0) ? "&" : "?";
|
|
338
|
-
}
|
|
339
531
|
function requestKey(method, url, params) {
|
|
340
532
|
return method + ":" + url + ":" + params;
|
|
341
533
|
}
|
|
@@ -344,6 +536,7 @@ function isEdgeCacheParam(key) {
|
|
|
344
536
|
}
|
|
345
537
|
|
|
346
538
|
// src/core/client.ts
|
|
539
|
+
var MAX_RETRY_DELAY_MS = 3e4;
|
|
347
540
|
function parseJson(text) {
|
|
348
541
|
try {
|
|
349
542
|
return { json: true, value: JSON.parse(String(text)) };
|
|
@@ -357,16 +550,29 @@ function errorDetail(text) {
|
|
|
357
550
|
return { detail: {} };
|
|
358
551
|
}
|
|
359
552
|
const body = parsed.value;
|
|
360
|
-
const
|
|
361
|
-
const
|
|
553
|
+
const isObject = typeof body === "object" && body !== null;
|
|
554
|
+
const detail = isObject ? body : {};
|
|
555
|
+
const given = detail.message;
|
|
556
|
+
const isText = typeof given === "string";
|
|
557
|
+
const message = detailMessageOf(true, isObject, isText, isText ? given : "");
|
|
362
558
|
return { detail, message };
|
|
363
559
|
}
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
};
|
|
560
|
+
function statusError(status, message, ctx, detail) {
|
|
561
|
+
const kind = errorClassOf(status);
|
|
562
|
+
const text = errorMessageOf(message, kind, status);
|
|
563
|
+
if (kind === "validation")
|
|
564
|
+
return new ValidationError({ message: text, ...ctx, validationErrors: [] });
|
|
565
|
+
if (kind === "authentication") return new AuthenticationError({ message: text, ...ctx });
|
|
566
|
+
if (kind === "notFound") return new NotFoundError({ message: text, ...ctx });
|
|
567
|
+
if (kind === "rateLimit") return new RateLimitError({ message: text, ...ctx });
|
|
568
|
+
return new AugurError({
|
|
569
|
+
message: text,
|
|
570
|
+
code: nonEmptyOr(detail.code ?? "", "API_ERROR"),
|
|
571
|
+
statusCode: status,
|
|
572
|
+
...ctx,
|
|
573
|
+
requestId: detail.requestId
|
|
574
|
+
});
|
|
575
|
+
}
|
|
370
576
|
function generateRequestKey(method, url, params) {
|
|
371
577
|
const paramsStr = params ? JSON.stringify(params, Object.keys(params).sort()) : "";
|
|
372
578
|
return requestKey(method, url, paramsStr);
|
|
@@ -374,13 +580,62 @@ function generateRequestKey(method, url, params) {
|
|
|
374
580
|
function calculateBackoffDelay(attempt, baseDelay) {
|
|
375
581
|
const exponential = exponentialDelay(baseDelay, attempt);
|
|
376
582
|
const jitter = Math.random() * 0.3 * exponential;
|
|
377
|
-
return
|
|
583
|
+
return cappedAt(exponential + jitter, MAX_RETRY_DELAY_MS);
|
|
378
584
|
}
|
|
379
585
|
function isRetryableError(error) {
|
|
380
|
-
|
|
586
|
+
const isAugurError = error instanceof AugurError;
|
|
587
|
+
return retryableError(isAugurError, isAugurError ? error.statusCode : 0);
|
|
588
|
+
}
|
|
589
|
+
function delay(ms, signal) {
|
|
590
|
+
return new Promise((resolve, reject) => {
|
|
591
|
+
const onAbort = () => {
|
|
592
|
+
clearTimeout(timer);
|
|
593
|
+
reject(signal.reason);
|
|
594
|
+
};
|
|
595
|
+
const timer = setTimeout(() => {
|
|
596
|
+
signal?.removeEventListener("abort", onAbort);
|
|
597
|
+
resolve();
|
|
598
|
+
}, ms);
|
|
599
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
600
|
+
});
|
|
601
|
+
}
|
|
602
|
+
var UNBOUNDED = {
|
|
603
|
+
signal: void 0,
|
|
604
|
+
hasDeadline: false,
|
|
605
|
+
remaining: () => 0,
|
|
606
|
+
dispose: () => {
|
|
607
|
+
}
|
|
608
|
+
};
|
|
609
|
+
function throwIfEnded(call) {
|
|
610
|
+
if (call.signal?.aborted) throw call.signal.reason;
|
|
381
611
|
}
|
|
382
|
-
function
|
|
383
|
-
|
|
612
|
+
function startCall(bounds, requestSignal) {
|
|
613
|
+
const sources = requestSignal === void 0 ? [...bounds.signals] : [...bounds.signals, requestSignal];
|
|
614
|
+
const deadline = bounds.deadline;
|
|
615
|
+
if (!boundedCall(sources.length > 0, deadline !== void 0)) return UNBOUNDED;
|
|
616
|
+
const controller = new AbortController();
|
|
617
|
+
const started = Date.now();
|
|
618
|
+
const listeners = sources.map((source) => {
|
|
619
|
+
const onAbort = () => controller.abort(source.reason);
|
|
620
|
+
source.addEventListener("abort", onAbort, { once: true });
|
|
621
|
+
return { source, onAbort };
|
|
622
|
+
});
|
|
623
|
+
for (const source of sources) {
|
|
624
|
+
if (source.aborted) controller.abort(source.reason);
|
|
625
|
+
}
|
|
626
|
+
const timer = deadline === void 0 ? void 0 : setTimeout(
|
|
627
|
+
() => controller.abort(new DOMException("Call deadline exceeded", "TimeoutError")),
|
|
628
|
+
deadline
|
|
629
|
+
);
|
|
630
|
+
return {
|
|
631
|
+
signal: controller.signal,
|
|
632
|
+
hasDeadline: deadline !== void 0,
|
|
633
|
+
remaining: () => remainingOf(deadline ?? 0, Date.now() - started),
|
|
634
|
+
dispose: () => {
|
|
635
|
+
clearTimeout(timer);
|
|
636
|
+
for (const { source, onAbort } of listeners) source.removeEventListener("abort", onAbort);
|
|
637
|
+
}
|
|
638
|
+
};
|
|
384
639
|
}
|
|
385
640
|
function withoutEdgeCache(params) {
|
|
386
641
|
return Object.fromEntries(Object.entries(params).filter(([key]) => !isEdgeCacheParam(key)));
|
|
@@ -403,15 +658,11 @@ function buildUrlWithParams(url, params) {
|
|
|
403
658
|
const searchParams = new URLSearchParams();
|
|
404
659
|
const paramsObj = params;
|
|
405
660
|
for (const [key, value] of Object.entries(paramsObj)) {
|
|
406
|
-
if (value
|
|
661
|
+
if (queryValueSent(value === void 0, value === null)) {
|
|
407
662
|
searchParams.append(key, String(value));
|
|
408
663
|
}
|
|
409
664
|
}
|
|
410
|
-
|
|
411
|
-
if (!queryString) {
|
|
412
|
-
return url;
|
|
413
|
-
}
|
|
414
|
-
return `${url}${querySeparator(url)}${queryString}`;
|
|
665
|
+
return urlWithQuery(url, searchParams.toString());
|
|
415
666
|
}
|
|
416
667
|
function headersToRecord(headers) {
|
|
417
668
|
const record32 = {};
|
|
@@ -424,18 +675,33 @@ var HTTPClient = class {
|
|
|
424
675
|
config;
|
|
425
676
|
serviceName;
|
|
426
677
|
inflightRequests = /* @__PURE__ */ new Map();
|
|
427
|
-
|
|
678
|
+
bounds;
|
|
679
|
+
/**
|
|
680
|
+
* The siteId this client sends (`x-site-id`, and the value of every `cacheSiteId` edge
|
|
681
|
+
* directive): a `SiteId`, so only a proved `isSiteId` string reaches the header or Cloudflare's
|
|
682
|
+
* cache key (AugurApiClient.EdgeDirectiveCarriesASiteId; owner 2026-11-10).
|
|
683
|
+
*/
|
|
684
|
+
siteId;
|
|
685
|
+
/**
|
|
686
|
+
* `bounds` bound every call this client makes (a view's, from `AugurAPI.withRequest`).
|
|
687
|
+
*
|
|
688
|
+
* @throws InvalidArgumentError when `config.siteId` is not a siteId (as `AugurAPI` does)
|
|
689
|
+
*/
|
|
690
|
+
constructor(serviceName, config, bounds = NO_BOUNDS) {
|
|
428
691
|
this.serviceName = serviceName;
|
|
429
692
|
this.config = { ...DEFAULT_CONFIG, ...config };
|
|
693
|
+
this.siteId = assertSiteId(this.config.siteId);
|
|
694
|
+
this.bounds = bounds;
|
|
430
695
|
}
|
|
431
696
|
/**
|
|
432
|
-
* Build request headers with auth
|
|
697
|
+
* Build request headers with auth. A request's own headers come before `x-site-id` and
|
|
698
|
+
* `Authorization`, so neither can be replaced by one (AugurApiClient.SiteIdHeaderIsTheClients).
|
|
433
699
|
*/
|
|
434
700
|
buildRequestHeaders(url, requestConfig) {
|
|
435
701
|
const headers = {
|
|
436
702
|
"Content-Type": "application/json",
|
|
437
|
-
|
|
438
|
-
|
|
703
|
+
...requestConfig?.headers,
|
|
704
|
+
"x-site-id": this.siteId
|
|
439
705
|
};
|
|
440
706
|
if (sendsBearer(url, Boolean(this.config.bearerToken))) {
|
|
441
707
|
headers["Authorization"] = `Bearer ${this.config.bearerToken}`;
|
|
@@ -452,9 +718,10 @@ var HTTPClient = class {
|
|
|
452
718
|
} catch {
|
|
453
719
|
}
|
|
454
720
|
const { detail, message } = errorDetail(text);
|
|
455
|
-
|
|
721
|
+
const { onError, onResponse } = this.config;
|
|
722
|
+
if (responseHookOf(response.ok, onError !== void 0, onResponse !== void 0) === "onError") {
|
|
456
723
|
const augurError = {
|
|
457
|
-
message: message
|
|
724
|
+
message: errorMessageOf(message, "augur", response.status),
|
|
458
725
|
config: augurConfig,
|
|
459
726
|
response: {
|
|
460
727
|
data: detail,
|
|
@@ -464,7 +731,7 @@ var HTTPClient = class {
|
|
|
464
731
|
config: augurConfig
|
|
465
732
|
}
|
|
466
733
|
};
|
|
467
|
-
await
|
|
734
|
+
await onError(augurError);
|
|
468
735
|
}
|
|
469
736
|
this.handleHttpError(response.status, { ...detail, message }, endpoint);
|
|
470
737
|
}
|
|
@@ -480,8 +747,9 @@ var HTTPClient = class {
|
|
|
480
747
|
headers: headersToRecord(response.headers),
|
|
481
748
|
config: augurConfig
|
|
482
749
|
};
|
|
483
|
-
|
|
484
|
-
|
|
750
|
+
const { onError, onResponse } = this.config;
|
|
751
|
+
if (responseHookOf(response.ok, onError !== void 0, onResponse !== void 0) === "onResponse") {
|
|
752
|
+
const modified = await onResponse(augurResponse);
|
|
485
753
|
return modified.data;
|
|
486
754
|
}
|
|
487
755
|
return responseData;
|
|
@@ -491,8 +759,9 @@ var HTTPClient = class {
|
|
|
491
759
|
*/
|
|
492
760
|
async readRaw(response, augurConfig) {
|
|
493
761
|
let text = await response.text();
|
|
494
|
-
|
|
495
|
-
|
|
762
|
+
const { onError, onResponse } = this.config;
|
|
763
|
+
if (responseHookOf(response.ok, onError !== void 0, onResponse !== void 0) === "onResponse") {
|
|
764
|
+
const modified = await onResponse({
|
|
496
765
|
data: text,
|
|
497
766
|
status: response.status,
|
|
498
767
|
statusText: response.statusText,
|
|
@@ -511,35 +780,63 @@ var HTTPClient = class {
|
|
|
511
780
|
* Core request method using native fetch. `read` turns a 2xx response into
|
|
512
781
|
* the result, inside the same error handling and timeout as the fetch.
|
|
513
782
|
*/
|
|
514
|
-
async request(method, url, options, read = (r, c) => this.handleFetchSuccess(r, c)) {
|
|
783
|
+
async request(method, url, options, call, read = (r, c) => this.handleFetchSuccess(r, c)) {
|
|
515
784
|
const { config: requestConfig } = options;
|
|
516
785
|
const endpoint = requestConfig?.endpoint ?? url;
|
|
517
|
-
const
|
|
518
|
-
let augurConfig = this.baseRequest(method, url, options, timeout);
|
|
786
|
+
const bounds = this.attemptBounds(requestConfig, call);
|
|
787
|
+
let augurConfig = this.baseRequest(method, url, options, bounds.timeout);
|
|
519
788
|
if (this.config.onRequest) {
|
|
520
789
|
augurConfig = await this.config.onRequest(augurConfig);
|
|
521
790
|
}
|
|
522
791
|
const fullUrl = buildUrlWithParams(augurConfig.url, augurConfig.params);
|
|
523
|
-
|
|
524
|
-
const
|
|
525
|
-
const signal = requestConfig?.signal ? this.mergeSignals(requestConfig.signal, controller.signal) : controller.signal;
|
|
792
|
+
throwIfEnded(call);
|
|
793
|
+
const attempt = this.attemptSignal(call, bounds);
|
|
526
794
|
try {
|
|
527
|
-
const response = await fetch(fullUrl, fetchOptionsFor(augurConfig, method, signal));
|
|
795
|
+
const response = await fetch(fullUrl, fetchOptionsFor(augurConfig, method, attempt.signal));
|
|
528
796
|
if (!response.ok) {
|
|
529
797
|
await this.handleFetchError(response, augurConfig, endpoint);
|
|
530
798
|
}
|
|
531
799
|
return await read(response, augurConfig);
|
|
532
800
|
} catch (error) {
|
|
801
|
+
throwIfEnded(call);
|
|
533
802
|
this.rethrowOrWrapError(error, endpoint);
|
|
534
803
|
} finally {
|
|
535
|
-
|
|
804
|
+
attempt.dispose();
|
|
536
805
|
}
|
|
537
806
|
}
|
|
538
|
-
/**
|
|
807
|
+
/**
|
|
808
|
+
* An attempt's timeout (the per-attempt one, cut to what is left of the call's deadline: what
|
|
809
|
+
* the onRequest hook sees) and whether it sets its own timer: only when it ends before the
|
|
810
|
+
* deadline; otherwise the call's one deadline timer cuts it, with a TimeoutError
|
|
811
|
+
* (client-rules.ts; AugurApiClient.OneTimerCutsEachAttempt).
|
|
812
|
+
*/
|
|
813
|
+
attemptBounds(requestConfig, call) {
|
|
814
|
+
const perAttempt = this.timeoutFor(requestConfig);
|
|
815
|
+
const remaining = call.remaining();
|
|
816
|
+
return {
|
|
817
|
+
timeout: cutToRemaining(perAttempt, call.hasDeadline, remaining),
|
|
818
|
+
ownTimer: needsAttemptTimer(perAttempt, call.hasDeadline, remaining)
|
|
819
|
+
};
|
|
820
|
+
}
|
|
821
|
+
/** The signal one attempt is sent with, and how to clear its timer and listeners after. */
|
|
822
|
+
attemptSignal(call, bounds) {
|
|
823
|
+
const controller = new AbortController();
|
|
824
|
+
const timeoutId = bounds.ownTimer ? setTimeout(() => controller.abort(), bounds.timeout) : void 0;
|
|
825
|
+
const merged = call.signal ? this.mergeSignals(call.signal, controller.signal) : { signal: controller.signal, dispose: () => {
|
|
826
|
+
} };
|
|
827
|
+
return {
|
|
828
|
+
signal: merged.signal,
|
|
829
|
+
dispose: () => {
|
|
830
|
+
clearTimeout(timeoutId);
|
|
831
|
+
merged.dispose();
|
|
832
|
+
}
|
|
833
|
+
};
|
|
834
|
+
}
|
|
835
|
+
/** The request's timeout: per request, else the client's, else the default (firstGiven). */
|
|
539
836
|
timeoutFor(requestConfig) {
|
|
540
837
|
const request = requestConfig?.timeout;
|
|
541
838
|
const client = this.config.timeout;
|
|
542
|
-
return
|
|
839
|
+
return firstGiven(
|
|
543
840
|
request !== void 0,
|
|
544
841
|
request ?? 0,
|
|
545
842
|
client !== void 0,
|
|
@@ -559,17 +856,20 @@ var HTTPClient = class {
|
|
|
559
856
|
};
|
|
560
857
|
}
|
|
561
858
|
/**
|
|
562
|
-
* Merge
|
|
859
|
+
* Merge the call's signal and an attempt's timer: aborts when either fires, with that one's
|
|
860
|
+
* reason. `dispose` removes the listener from the call's signal, which outlives the attempt
|
|
861
|
+
* (one per attempt would pile up on a long-lived caller signal).
|
|
563
862
|
*/
|
|
564
|
-
mergeSignals(
|
|
863
|
+
mergeSignals(callSignal, timeoutSignal) {
|
|
565
864
|
const controller = new AbortController();
|
|
566
|
-
const
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
865
|
+
const onCallAbort = () => controller.abort(callSignal.reason);
|
|
866
|
+
const onTimeout = () => controller.abort(timeoutSignal.reason);
|
|
867
|
+
callSignal.addEventListener("abort", onCallAbort, { once: true });
|
|
868
|
+
timeoutSignal.addEventListener("abort", onTimeout, { once: true });
|
|
869
|
+
return {
|
|
870
|
+
signal: controller.signal,
|
|
871
|
+
dispose: () => callSignal.removeEventListener("abort", onCallAbort)
|
|
872
|
+
};
|
|
573
873
|
}
|
|
574
874
|
/**
|
|
575
875
|
* The one status-to-error switch, shared by typed methods and `call()`.
|
|
@@ -579,18 +879,7 @@ var HTTPClient = class {
|
|
|
579
879
|
* @ensures thrown.endpoint = endpoint (callers pass the path template, so no param values leak)
|
|
580
880
|
*/
|
|
581
881
|
handleHttpError(status, data, endpoint) {
|
|
582
|
-
|
|
583
|
-
const specific = STATUS_ERRORS[status];
|
|
584
|
-
if (specific) {
|
|
585
|
-
throw specific(data.message, ctx);
|
|
586
|
-
}
|
|
587
|
-
throw new AugurError({
|
|
588
|
-
message: data.message ?? `Request failed with status ${status}`,
|
|
589
|
-
code: data.code || "API_ERROR",
|
|
590
|
-
statusCode: status,
|
|
591
|
-
...ctx,
|
|
592
|
-
requestId: data.requestId
|
|
593
|
-
});
|
|
882
|
+
throw statusError(status, data.message, { service: this.serviceName, endpoint }, data);
|
|
594
883
|
}
|
|
595
884
|
/**
|
|
596
885
|
* Re-throw known error types or wrap as network error
|
|
@@ -599,14 +888,14 @@ var HTTPClient = class {
|
|
|
599
888
|
if (error instanceof AugurError) {
|
|
600
889
|
throw error;
|
|
601
890
|
}
|
|
602
|
-
if (error instanceof DOMException && error.name
|
|
891
|
+
if (error instanceof DOMException && isAbortName(error.name)) {
|
|
603
892
|
throw error;
|
|
604
893
|
}
|
|
605
894
|
this.handleNetworkError(error, endpoint);
|
|
606
895
|
}
|
|
607
896
|
handleNetworkError(error, endpoint) {
|
|
608
897
|
throw new AugurError({
|
|
609
|
-
message: error.message
|
|
898
|
+
message: nonEmptyOr(error.message ?? "", "Network error"),
|
|
610
899
|
code: "NETWORK_ERROR",
|
|
611
900
|
statusCode: 0,
|
|
612
901
|
service: this.serviceName,
|
|
@@ -616,25 +905,48 @@ var HTTPClient = class {
|
|
|
616
905
|
/**
|
|
617
906
|
* Executes a single request attempt
|
|
618
907
|
*/
|
|
619
|
-
async executeAttempt(requestFn, attempt, maxRetries, baseDelay) {
|
|
908
|
+
async executeAttempt(requestFn, attempt, maxRetries, baseDelay, call) {
|
|
620
909
|
try {
|
|
621
|
-
return await requestFn
|
|
910
|
+
return await this.attemptWithin(call, requestFn);
|
|
622
911
|
} catch (error) {
|
|
623
|
-
if (attempt
|
|
912
|
+
if (!retryAfterCall(attempt, maxRetries, isRetryableError(error), call.signal?.aborted === true)) {
|
|
624
913
|
throw error;
|
|
625
914
|
}
|
|
626
|
-
const backoffDelay =
|
|
627
|
-
|
|
628
|
-
|
|
915
|
+
const backoffDelay = cutToRemaining(
|
|
916
|
+
calculateBackoffDelay(attempt, baseDelay),
|
|
917
|
+
call.hasDeadline,
|
|
918
|
+
call.remaining()
|
|
919
|
+
);
|
|
920
|
+
await delay(backoffDelay, call.signal);
|
|
921
|
+
return this.executeAttempt(requestFn, attempt + 1, maxRetries, baseDelay, call);
|
|
629
922
|
}
|
|
630
923
|
}
|
|
924
|
+
/**
|
|
925
|
+
* One attempt, started only while the call's deadline has time left (client-rules.ts
|
|
926
|
+
* startsAttempt); past it the call rejects with a TimeoutError.
|
|
927
|
+
*/
|
|
928
|
+
attemptWithin(call, requestFn) {
|
|
929
|
+
if (!startsAttempt(call.hasDeadline, call.remaining())) {
|
|
930
|
+
return Promise.reject(new DOMException("Call deadline exceeded", "TimeoutError"));
|
|
931
|
+
}
|
|
932
|
+
return requestFn();
|
|
933
|
+
}
|
|
631
934
|
/**
|
|
632
935
|
* Executes a request with retry logic
|
|
633
936
|
*/
|
|
634
|
-
async executeWithRetry(requestFn) {
|
|
937
|
+
async executeWithRetry(requestFn, call) {
|
|
635
938
|
const maxRetries = this.config.retries ?? DEFAULT_CONFIG.retries;
|
|
636
939
|
const baseDelay = this.config.retryDelay ?? DEFAULT_CONFIG.retryDelay;
|
|
637
|
-
return this.executeAttempt(requestFn, 0, maxRetries, baseDelay);
|
|
940
|
+
return this.executeAttempt(requestFn, 0, maxRetries, baseDelay, call);
|
|
941
|
+
}
|
|
942
|
+
/** Runs `fn` in a fresh call scope and disposes it, however `fn` settles. */
|
|
943
|
+
async withinCall(requestSignal, fn) {
|
|
944
|
+
const call = startCall(this.bounds, requestSignal);
|
|
945
|
+
try {
|
|
946
|
+
return await fn(call);
|
|
947
|
+
} finally {
|
|
948
|
+
call.dispose();
|
|
949
|
+
}
|
|
638
950
|
}
|
|
639
951
|
/**
|
|
640
952
|
* Transform edgeCache parameter to Cloudflare's cacheSiteId format
|
|
@@ -662,64 +974,64 @@ var HTTPClient = class {
|
|
|
662
974
|
if (edgeCache == null) {
|
|
663
975
|
return params;
|
|
664
976
|
}
|
|
665
|
-
const validSubHourValues = ["30s", "1m", "5m"];
|
|
666
|
-
const validHourlyValues = [1, 2, 3, 4, 5, 8];
|
|
667
|
-
let cacheSuffix;
|
|
668
977
|
const edgeCacheStr = String(edgeCache);
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
const cacheHours = parseInt(edgeCacheStr, 10);
|
|
673
|
-
if (!validHourlyValues.includes(cacheHours)) {
|
|
674
|
-
return withoutEdgeCache(paramsObj);
|
|
675
|
-
}
|
|
676
|
-
cacheSuffix = String(cacheHours);
|
|
978
|
+
const kind = edgeCacheKindOf(edgeCacheStr);
|
|
979
|
+
if (kind === "invalid") {
|
|
980
|
+
return withoutEdgeCache(paramsObj);
|
|
677
981
|
}
|
|
678
|
-
const
|
|
679
|
-
const cacheKey = `cacheSiteId${cacheSuffix}`;
|
|
982
|
+
const cacheKey = edgeCacheKeyOf(kind, edgeCacheStr);
|
|
680
983
|
return {
|
|
681
|
-
...
|
|
682
|
-
[cacheKey]: this.
|
|
984
|
+
...withoutEdgeCache(paramsObj),
|
|
985
|
+
[cacheKey]: this.siteId
|
|
683
986
|
};
|
|
684
987
|
}
|
|
685
988
|
async get(url, params, config) {
|
|
686
989
|
const transformedParams = this.transformEdgeCacheParams(params);
|
|
687
990
|
const method = "GET";
|
|
688
991
|
const requestKey2 = generateRequestKey(method, url, transformedParams);
|
|
689
|
-
const
|
|
992
|
+
const shares = sharesInFlight(config?.signal !== void 0);
|
|
993
|
+
const inflight = shares ? this.inflightRequests.get(requestKey2) : void 0;
|
|
690
994
|
if (inflight) {
|
|
691
995
|
return inflight;
|
|
692
996
|
}
|
|
693
|
-
const requestPromise = this.
|
|
694
|
-
|
|
695
|
-
|
|
997
|
+
const requestPromise = this.withinCall(
|
|
998
|
+
config?.signal,
|
|
999
|
+
(call) => this.executeWithRetry(
|
|
1000
|
+
() => this.request(method, url, { params: transformedParams, config }, call),
|
|
1001
|
+
call
|
|
1002
|
+
)
|
|
1003
|
+
);
|
|
1004
|
+
if (!shares) return requestPromise;
|
|
1005
|
+
const shared = requestPromise.finally(() => {
|
|
696
1006
|
this.inflightRequests.delete(requestKey2);
|
|
697
1007
|
});
|
|
698
|
-
this.inflightRequests.set(requestKey2,
|
|
699
|
-
return
|
|
1008
|
+
this.inflightRequests.set(requestKey2, shared);
|
|
1009
|
+
return shared;
|
|
700
1010
|
}
|
|
701
1011
|
// The API declares query params on POST/PUT/DELETE as well as GET. `request`
|
|
702
1012
|
// already carries both a body and a query slot; these wrappers simply never
|
|
703
1013
|
// exposed the latter, leaving those params unreachable from the clients.
|
|
1014
|
+
// Writes make one attempt (never retried), bounded by the call's scope like a GET.
|
|
704
1015
|
async post(url, data, params, config) {
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
1016
|
+
const options = { data, params: this.transformEdgeCacheParams(params), config };
|
|
1017
|
+
return this.withinCall(
|
|
1018
|
+
config?.signal,
|
|
1019
|
+
(call) => this.attemptWithin(call, () => this.request("POST", url, options, call))
|
|
1020
|
+
);
|
|
710
1021
|
}
|
|
711
1022
|
async put(url, data, params, config) {
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
1023
|
+
const options = { data, params: this.transformEdgeCacheParams(params), config };
|
|
1024
|
+
return this.withinCall(
|
|
1025
|
+
config?.signal,
|
|
1026
|
+
(call) => this.attemptWithin(call, () => this.request("PUT", url, options, call))
|
|
1027
|
+
);
|
|
717
1028
|
}
|
|
718
1029
|
async delete(url, params, config) {
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
config
|
|
722
|
-
|
|
1030
|
+
const options = { params: this.transformEdgeCacheParams(params), config };
|
|
1031
|
+
return this.withinCall(
|
|
1032
|
+
config?.signal,
|
|
1033
|
+
(call) => this.attemptWithin(call, () => this.request("DELETE", url, options, call))
|
|
1034
|
+
);
|
|
723
1035
|
}
|
|
724
1036
|
/**
|
|
725
1037
|
* Send a request and return the 2xx response as text, with no schema
|
|
@@ -728,20 +1040,23 @@ var HTTPClient = class {
|
|
|
728
1040
|
* in-flight deduplication); other methods make one attempt, like `post()`.
|
|
729
1041
|
*/
|
|
730
1042
|
async raw(method, url, options = {}) {
|
|
731
|
-
const
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
1043
|
+
const requestOptions = { ...options, params: this.transformEdgeCacheParams(options.params) };
|
|
1044
|
+
return this.withinCall(options.config?.signal, (call) => {
|
|
1045
|
+
const send = () => this.request(
|
|
1046
|
+
method,
|
|
1047
|
+
url,
|
|
1048
|
+
requestOptions,
|
|
1049
|
+
call,
|
|
1050
|
+
(response, augurConfig) => this.readRaw(response, augurConfig)
|
|
1051
|
+
);
|
|
1052
|
+
return rawRetries(method) ? this.executeWithRetry(send, call) : this.attemptWithin(call, send);
|
|
1053
|
+
});
|
|
738
1054
|
}
|
|
739
1055
|
};
|
|
740
1056
|
|
|
741
1057
|
// src/core/encoded-segment.ts
|
|
742
|
-
var PCHAR_RESTORE_RE = /%(?:24|26|2B|2C|3B|3D|3A|40)/g;
|
|
743
1058
|
function encodePathSegment(value) {
|
|
744
|
-
const encoded = encodeURIComponent(value)
|
|
1059
|
+
const encoded = restorePcharFrom(encodeURIComponent(value), 0);
|
|
745
1060
|
if (!isEncoded(encoded)) {
|
|
746
1061
|
throw new InvalidArgumentError({
|
|
747
1062
|
message: "Encoded path segment has an unexpected shape",
|
|
@@ -755,17 +1070,20 @@ function fillPlaceholder(path, placeholder, segment) {
|
|
|
755
1070
|
return placeholderFilled(path, placeholder, segment);
|
|
756
1071
|
}
|
|
757
1072
|
function renderPath(template, segments) {
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
1073
|
+
const names = templateNames(template, 0);
|
|
1074
|
+
const missing = notInFrom(names, Object.keys(segments), 0);
|
|
1075
|
+
if (missing.length > 0) {
|
|
1076
|
+
throw new InvalidArgumentError({
|
|
1077
|
+
message: `No path value for {${missing[0]}}`,
|
|
1078
|
+
service: "",
|
|
1079
|
+
endpoint: template
|
|
1080
|
+
});
|
|
1081
|
+
}
|
|
1082
|
+
let path = template;
|
|
1083
|
+
for (const name of names) {
|
|
1084
|
+
path = fillPlaceholder(path, name, segments[name]);
|
|
1085
|
+
}
|
|
1086
|
+
return path;
|
|
769
1087
|
}
|
|
770
1088
|
|
|
771
1089
|
// src/core/path-validation.ts
|
|
@@ -782,6 +1100,17 @@ var validatePathSegment = (pathTemplate, name, value, pattern, service = "http-c
|
|
|
782
1100
|
}
|
|
783
1101
|
};
|
|
784
1102
|
|
|
1103
|
+
// ../utils/src/slices.ts
|
|
1104
|
+
function beforeLastCode(s, code) {
|
|
1105
|
+
return s.slice(0, endBefore(lastIndexOfCode(s, code, s.length), s.length));
|
|
1106
|
+
}
|
|
1107
|
+
function withLastSegment(id, segment) {
|
|
1108
|
+
return beforeLastCode(id, 46) + "." + segment;
|
|
1109
|
+
}
|
|
1110
|
+
function endBefore(k, len) {
|
|
1111
|
+
return k >= 0 ? k : Math.max(len - 1, 0);
|
|
1112
|
+
}
|
|
1113
|
+
|
|
785
1114
|
// ../utils/src/case-spec.ts
|
|
786
1115
|
var UPPER = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
787
1116
|
function upperFirst(s) {
|
|
@@ -803,6 +1132,13 @@ function foldName(s) {
|
|
|
803
1132
|
if (c === 45 || c === 95) return foldName(s.slice(1));
|
|
804
1133
|
return lowerAscii(s.slice(0, 1)) + foldName(s.slice(1));
|
|
805
1134
|
}
|
|
1135
|
+
function foldMatchesFrom(names, key, k) {
|
|
1136
|
+
if (k === names.length) return [];
|
|
1137
|
+
const name = names[k];
|
|
1138
|
+
const rest = foldMatchesFrom(names, key, k + 1);
|
|
1139
|
+
if (foldName(name) !== foldName(key)) return rest;
|
|
1140
|
+
return [name, ...rest];
|
|
1141
|
+
}
|
|
806
1142
|
function snakeCamel(s) {
|
|
807
1143
|
if (codeAt(s, 0) === 95) {
|
|
808
1144
|
const c = codeAt(s, 1);
|
|
@@ -816,20 +1152,10 @@ function kebabCamel(s) {
|
|
|
816
1152
|
return kebabCamelFrom(s, false);
|
|
817
1153
|
}
|
|
818
1154
|
|
|
819
|
-
// ../utils/src/slices.ts
|
|
820
|
-
function beforeLastCode(s, code) {
|
|
821
|
-
return s.slice(0, endBefore(lastIndexOfCode(s, code, s.length), s.length));
|
|
822
|
-
}
|
|
823
|
-
function endBefore(k, len) {
|
|
824
|
-
return k >= 0 ? k : Math.max(len - 1, 0);
|
|
825
|
-
}
|
|
826
|
-
|
|
827
|
-
// ../utils/src/http.ts
|
|
828
|
-
function isPostOrPut(method) {
|
|
829
|
-
return method === "POST" || method === "PUT";
|
|
830
|
-
}
|
|
831
|
-
|
|
832
1155
|
// src/core/registry-rules.ts
|
|
1156
|
+
function endpointIdOf(service, chain, action) {
|
|
1157
|
+
return kebabCamel(service) + "." + chain + "." + action;
|
|
1158
|
+
}
|
|
833
1159
|
function hasBodyFor(method) {
|
|
834
1160
|
return isPostOrPut(method);
|
|
835
1161
|
}
|
|
@@ -853,6 +1179,14 @@ function syncedTotal(total, totalResults) {
|
|
|
853
1179
|
function syncedTotalResults(total, totalResults) {
|
|
854
1180
|
return totalResults === 0 ? Math.max(total, 0) : totalResults;
|
|
855
1181
|
}
|
|
1182
|
+
function countChanged(count, dataLength) {
|
|
1183
|
+
return normalCount(count, dataLength) !== count;
|
|
1184
|
+
}
|
|
1185
|
+
function totalsChangeOf(total, totalResults) {
|
|
1186
|
+
if (syncedTotal(total, totalResults) !== total) return "total";
|
|
1187
|
+
if (syncedTotalResults(total, totalResults) !== totalResults) return "totalResults";
|
|
1188
|
+
return "kept";
|
|
1189
|
+
}
|
|
856
1190
|
function warnsOnNormalization(hasEnv, env) {
|
|
857
1191
|
return hasEnv && env !== "production";
|
|
858
1192
|
}
|
|
@@ -866,23 +1200,23 @@ var logNormalizationWarning = (message) => {
|
|
|
866
1200
|
}
|
|
867
1201
|
};
|
|
868
1202
|
var normalizeCount = (count, actualDataLength) => {
|
|
869
|
-
|
|
870
|
-
if (normal !== count) {
|
|
1203
|
+
if (countChanged(count, actualDataLength)) {
|
|
871
1204
|
logNormalizationWarning(`'count' was 0 but data has ${actualDataLength} items`);
|
|
872
1205
|
}
|
|
873
|
-
return
|
|
1206
|
+
return normalCount(count, actualDataLength);
|
|
874
1207
|
};
|
|
875
1208
|
var normalizeTotals = (total, totalResults) => {
|
|
876
|
-
const
|
|
877
|
-
|
|
878
|
-
totalResults: syncedTotalResults(total, totalResults)
|
|
879
|
-
};
|
|
880
|
-
if (synced.total !== total) {
|
|
1209
|
+
const change = totalsChangeOf(total, totalResults);
|
|
1210
|
+
if (change === "total") {
|
|
881
1211
|
logNormalizationWarning(`'total' was 0 but 'totalResults' is ${totalResults}`);
|
|
882
|
-
}
|
|
1212
|
+
}
|
|
1213
|
+
if (change === "totalResults") {
|
|
883
1214
|
logNormalizationWarning(`'totalResults' was 0 but 'total' is ${total}`);
|
|
884
1215
|
}
|
|
885
|
-
return
|
|
1216
|
+
return {
|
|
1217
|
+
total: syncedTotal(total, totalResults),
|
|
1218
|
+
totalResults: syncedTotalResults(total, totalResults)
|
|
1219
|
+
};
|
|
886
1220
|
};
|
|
887
1221
|
var BaseResponseSchema = (dataSchema) => v.pipe(
|
|
888
1222
|
v.looseObject({
|
|
@@ -8708,7 +9042,11 @@ var ProductsListDataSchema = v11.array(
|
|
|
8708
9042
|
dateLastBuilt: v11.nullable(v11.string()),
|
|
8709
9043
|
checkoutLinkTemplate: v11.nullable(v11.string()),
|
|
8710
9044
|
dateLastStatus: v11.nullable(v11.string()),
|
|
8711
|
-
dateLastChanged: v11.nullable(v11.string())
|
|
9045
|
+
dateLastChanged: v11.nullable(v11.string()),
|
|
9046
|
+
imageWidth: v11.nullable(v11.number()),
|
|
9047
|
+
imageHeight: v11.nullable(v11.number()),
|
|
9048
|
+
additionalImageWidth: v11.nullable(v11.number()),
|
|
9049
|
+
additionalImageHeight: v11.nullable(v11.number())
|
|
8712
9050
|
})
|
|
8713
9051
|
);
|
|
8714
9052
|
var ProductsGetDataSchema = v11.looseObject({
|
|
@@ -8759,7 +9097,11 @@ var ProductsGetDataSchema = v11.looseObject({
|
|
|
8759
9097
|
dateLastBuilt: v11.nullable(v11.string()),
|
|
8760
9098
|
checkoutLinkTemplate: v11.nullable(v11.string()),
|
|
8761
9099
|
dateLastStatus: v11.nullable(v11.string()),
|
|
8762
|
-
dateLastChanged: v11.nullable(v11.string())
|
|
9100
|
+
dateLastChanged: v11.nullable(v11.string()),
|
|
9101
|
+
imageWidth: v11.nullable(v11.number()),
|
|
9102
|
+
imageHeight: v11.nullable(v11.number()),
|
|
9103
|
+
additionalImageWidth: v11.nullable(v11.number()),
|
|
9104
|
+
additionalImageHeight: v11.nullable(v11.number())
|
|
8763
9105
|
});
|
|
8764
9106
|
var SitemapsItemsListDataSchema = v11.array(
|
|
8765
9107
|
v11.looseObject({ id: v11.string(), link: v11.string(), lastModified: v11.nullable(v11.string()) })
|
|
@@ -9372,6 +9714,8 @@ var InvMastFaqListParamsSchema = v13.looseObject({
|
|
|
9372
9714
|
});
|
|
9373
9715
|
var InvMastInvAccessoryListParamsSchema = v13.looseObject({
|
|
9374
9716
|
...EdgeCacheParamsSchema.entries,
|
|
9717
|
+
classId5ExcludeList: v13.optional(v13.string()),
|
|
9718
|
+
classId5List: v13.optional(v13.string()),
|
|
9375
9719
|
limit: v13.optional(v13.pipe(v13.unknown(), v13.transform(Number))),
|
|
9376
9720
|
offset: v13.optional(v13.pipe(v13.unknown(), v13.transform(Number))),
|
|
9377
9721
|
orderBy: v13.optional(v13.string()),
|
|
@@ -9408,6 +9752,11 @@ var InvMastPromotionalGroupsListParamsSchema = v13.looseObject({
|
|
|
9408
9752
|
])
|
|
9409
9753
|
)
|
|
9410
9754
|
});
|
|
9755
|
+
var InvMastSimilarListParamsSchema = v13.looseObject({
|
|
9756
|
+
...EdgeCacheParamsSchema.entries,
|
|
9757
|
+
classId5ExcludeList: v13.optional(v13.string()),
|
|
9758
|
+
classId5List: v13.optional(v13.string())
|
|
9759
|
+
});
|
|
9411
9760
|
var InvPeriodUsageListParamsSchema = v13.looseObject({
|
|
9412
9761
|
...EdgeCacheParamsSchema.entries,
|
|
9413
9762
|
demandPeriodUid: v13.optional(v13.pipe(v13.unknown(), v13.transform(Number))),
|
|
@@ -15126,11 +15475,13 @@ var endpoints12 = [
|
|
|
15126
15475
|
aliases: [],
|
|
15127
15476
|
pathParams: ["invMastUid"],
|
|
15128
15477
|
pathPatterns: { invMastUid: "^\\d+$" },
|
|
15129
|
-
queryParams: ["limit", "offset", "orderBy", "statusCd"],
|
|
15478
|
+
queryParams: ["classId5ExcludeList", "classId5List", "limit", "offset", "orderBy", "statusCd"],
|
|
15130
15479
|
edgeCache: true,
|
|
15131
15480
|
summary: "List accessory items",
|
|
15132
15481
|
params: {
|
|
15133
15482
|
invMastUid: { in: "path", type: "integer", required: true },
|
|
15483
|
+
classId5ExcludeList: { in: "query", type: "string", required: false },
|
|
15484
|
+
classId5List: { in: "query", type: "string", required: false },
|
|
15134
15485
|
limit: { in: "query", type: "integer", required: false },
|
|
15135
15486
|
offset: { in: "query", type: "integer", required: false },
|
|
15136
15487
|
orderBy: { in: "query", type: "string", required: false },
|
|
@@ -15230,10 +15581,14 @@ var endpoints12 = [
|
|
|
15230
15581
|
aliases: [],
|
|
15231
15582
|
pathParams: ["invMastUid"],
|
|
15232
15583
|
pathPatterns: { invMastUid: "^\\d+$" },
|
|
15233
|
-
queryParams: [],
|
|
15584
|
+
queryParams: ["classId5ExcludeList", "classId5List"],
|
|
15234
15585
|
edgeCache: true,
|
|
15235
15586
|
summary: "List similar items",
|
|
15236
|
-
params: {
|
|
15587
|
+
params: {
|
|
15588
|
+
invMastUid: { in: "path", type: "integer", required: true },
|
|
15589
|
+
classId5ExcludeList: { in: "query", type: "string", required: false },
|
|
15590
|
+
classId5List: { in: "query", type: "string", required: false }
|
|
15591
|
+
},
|
|
15237
15592
|
responseSchema: InvMastSimilarListDataSchema,
|
|
15238
15593
|
responseType: "array"
|
|
15239
15594
|
},
|
|
@@ -16793,12 +17148,14 @@ var ContentListParamsSchema = v14.looseObject({
|
|
|
16793
17148
|
var ContentGetParamsSchema = v14.looseObject({
|
|
16794
17149
|
...EdgeCacheParamsSchema.entries,
|
|
16795
17150
|
alias: v14.optional(v14.string()),
|
|
16796
|
-
catid: v14.optional(v14.pipe(v14.unknown(), v14.transform(Number)))
|
|
17151
|
+
catid: v14.optional(v14.pipe(v14.unknown(), v14.transform(Number))),
|
|
17152
|
+
includeUnpublished: v14.optional(v14.string())
|
|
16797
17153
|
});
|
|
16798
17154
|
var ContentDocListParamsSchema = v14.looseObject({
|
|
16799
17155
|
...EdgeCacheParamsSchema.entries,
|
|
16800
17156
|
alias: v14.optional(v14.string()),
|
|
16801
|
-
catid: v14.optional(v14.pipe(v14.unknown(), v14.transform(Number)))
|
|
17157
|
+
catid: v14.optional(v14.pipe(v14.unknown(), v14.transform(Number))),
|
|
17158
|
+
includeUnpublished: v14.optional(v14.string())
|
|
16802
17159
|
});
|
|
16803
17160
|
var MenuListParamsSchema = v14.looseObject({
|
|
16804
17161
|
...EdgeCacheParamsSchema.entries,
|
|
@@ -16963,7 +17320,8 @@ var ContentListDataSchema = v14.array(
|
|
|
16963
17320
|
images: v14.union([v14.record(v14.string(), v14.unknown()), v14.array(v14.unknown())]),
|
|
16964
17321
|
fields: v14.array(
|
|
16965
17322
|
v14.looseObject({ value: v14.string(), title: v14.string(), name: v14.string(), label: v14.string() })
|
|
16966
|
-
)
|
|
17323
|
+
),
|
|
17324
|
+
state: v14.number()
|
|
16967
17325
|
})
|
|
16968
17326
|
);
|
|
16969
17327
|
var ContentGetDataSchema = v14.looseObject({
|
|
@@ -16972,7 +17330,8 @@ var ContentGetDataSchema = v14.looseObject({
|
|
|
16972
17330
|
alias: v14.string(),
|
|
16973
17331
|
introtext: v14.nullable(v14.string()),
|
|
16974
17332
|
fulltext: v14.nullable(v14.string()),
|
|
16975
|
-
catid: v14.number()
|
|
17333
|
+
catid: v14.number(),
|
|
17334
|
+
state: v14.number()
|
|
16976
17335
|
});
|
|
16977
17336
|
var ContentDocListDataSchema = v14.looseObject({
|
|
16978
17337
|
id: v14.number(),
|
|
@@ -16985,7 +17344,8 @@ var ContentDocListDataSchema = v14.looseObject({
|
|
|
16985
17344
|
images: v14.union([v14.record(v14.string(), v14.unknown()), v14.array(v14.unknown())]),
|
|
16986
17345
|
fields: v14.array(
|
|
16987
17346
|
v14.looseObject({ value: v14.string(), title: v14.string(), name: v14.string(), label: v14.string() })
|
|
16988
|
-
)
|
|
17347
|
+
),
|
|
17348
|
+
state: v14.number()
|
|
16989
17349
|
});
|
|
16990
17350
|
var MenuListDataSchema = v14.array(
|
|
16991
17351
|
v14.looseObject({
|
|
@@ -17396,13 +17756,14 @@ var endpoints13 = [
|
|
|
17396
17756
|
aliases: [],
|
|
17397
17757
|
pathParams: ["id"],
|
|
17398
17758
|
pathPatterns: { id: "^\\d+$" },
|
|
17399
|
-
queryParams: ["alias", "catid"],
|
|
17759
|
+
queryParams: ["alias", "catid", "includeUnpublished"],
|
|
17400
17760
|
edgeCache: true,
|
|
17401
17761
|
summary: "Get Content Detail",
|
|
17402
17762
|
params: {
|
|
17403
17763
|
id: { in: "path", type: "integer", required: true },
|
|
17404
17764
|
alias: { in: "query", type: "string", required: false },
|
|
17405
|
-
catid: { in: "query", type: "integer", required: false }
|
|
17765
|
+
catid: { in: "query", type: "integer", required: false },
|
|
17766
|
+
includeUnpublished: { in: "query", type: "string", required: false }
|
|
17406
17767
|
},
|
|
17407
17768
|
responseSchema: ContentGetDataSchema,
|
|
17408
17769
|
responseType: "object"
|
|
@@ -17415,13 +17776,14 @@ var endpoints13 = [
|
|
|
17415
17776
|
aliases: ["get"],
|
|
17416
17777
|
pathParams: ["id"],
|
|
17417
17778
|
pathPatterns: { id: "^\\d+$" },
|
|
17418
|
-
queryParams: ["alias", "catid"],
|
|
17779
|
+
queryParams: ["alias", "catid", "includeUnpublished"],
|
|
17419
17780
|
edgeCache: true,
|
|
17420
17781
|
summary: "Get Content Doc",
|
|
17421
17782
|
params: {
|
|
17422
17783
|
id: { in: "path", type: "integer", required: true },
|
|
17423
17784
|
alias: { in: "query", type: "string", required: false },
|
|
17424
|
-
catid: { in: "query", type: "integer", required: false }
|
|
17785
|
+
catid: { in: "query", type: "integer", required: false },
|
|
17786
|
+
includeUnpublished: { in: "query", type: "string", required: false }
|
|
17425
17787
|
},
|
|
17426
17788
|
responseSchema: ContentDocListDataSchema,
|
|
17427
17789
|
responseType: "object"
|
|
@@ -17774,6 +18136,8 @@ var endpoints13 = [
|
|
|
17774
18136
|
import * as v15 from "valibot";
|
|
17775
18137
|
var InvMastAlsoBoughtListParamsSchema = v15.looseObject({
|
|
17776
18138
|
...EdgeCacheParamsSchema.entries,
|
|
18139
|
+
classId5ExcludeList: v15.optional(v15.string()),
|
|
18140
|
+
classId5List: v15.optional(v15.string()),
|
|
17777
18141
|
statusCd: v15.optional(
|
|
17778
18142
|
v15.union([
|
|
17779
18143
|
v15.array(v15.pipe(v15.unknown(), v15.transform(Number))),
|
|
@@ -18277,11 +18641,13 @@ var endpoints14 = [
|
|
|
18277
18641
|
aliases: [],
|
|
18278
18642
|
pathParams: ["invMastUid"],
|
|
18279
18643
|
pathPatterns: { invMastUid: "^\\d+$" },
|
|
18280
|
-
queryParams: ["statusCd"],
|
|
18644
|
+
queryParams: ["classId5ExcludeList", "classId5List", "statusCd"],
|
|
18281
18645
|
edgeCache: true,
|
|
18282
18646
|
summary: "List item Also Bought",
|
|
18283
18647
|
params: {
|
|
18284
18648
|
invMastUid: { in: "path", type: "integer", required: true },
|
|
18649
|
+
classId5ExcludeList: { in: "query", type: "string", required: false },
|
|
18650
|
+
classId5List: { in: "query", type: "string", required: false },
|
|
18285
18651
|
statusCd: { in: "query", type: "integer|integer[]", required: false }
|
|
18286
18652
|
},
|
|
18287
18653
|
responseSchema: InvMastAlsoBoughtListDataSchema,
|
|
@@ -20067,6 +20433,7 @@ var ItemSearchListParamsSchema = v19.looseObject({
|
|
|
20067
20433
|
jobNumbers: v19.optional(v19.string()),
|
|
20068
20434
|
operator: v19.optional(v19.string()),
|
|
20069
20435
|
parentCategoryUid: v19.optional(v19.pipe(v19.unknown(), v19.transform(Number))),
|
|
20436
|
+
productGroupIdList: v19.optional(v19.string()),
|
|
20070
20437
|
q: v19.string(),
|
|
20071
20438
|
searchType: v19.string(),
|
|
20072
20439
|
size: v19.optional(v19.pipe(v19.unknown(), v19.transform(Number))),
|
|
@@ -20089,6 +20456,7 @@ var ItemSearchFacetsListParamsSchema = v19.looseObject({
|
|
|
20089
20456
|
jobNumbers: v19.optional(v19.string()),
|
|
20090
20457
|
operator: v19.optional(v19.string()),
|
|
20091
20458
|
parentCategoryUid: v19.optional(v19.pipe(v19.unknown(), v19.transform(Number))),
|
|
20459
|
+
productGroupIdList: v19.optional(v19.string()),
|
|
20092
20460
|
q: v19.string(),
|
|
20093
20461
|
searchType: v19.optional(v19.string()),
|
|
20094
20462
|
size: v19.optional(v19.pipe(v19.unknown(), v19.transform(Number))),
|
|
@@ -20404,6 +20772,7 @@ var endpoints18 = [
|
|
|
20404
20772
|
"jobNumbers",
|
|
20405
20773
|
"operator",
|
|
20406
20774
|
"parentCategoryUid",
|
|
20775
|
+
"productGroupIdList",
|
|
20407
20776
|
"q",
|
|
20408
20777
|
"searchType",
|
|
20409
20778
|
"size",
|
|
@@ -20427,6 +20796,7 @@ var endpoints18 = [
|
|
|
20427
20796
|
jobNumbers: { in: "query", type: "string", required: false },
|
|
20428
20797
|
operator: { in: "query", type: "string", required: false },
|
|
20429
20798
|
parentCategoryUid: { in: "query", type: "integer", required: false },
|
|
20799
|
+
productGroupIdList: { in: "query", type: "string", required: false },
|
|
20430
20800
|
q: { in: "query", type: "string", required: true },
|
|
20431
20801
|
searchType: { in: "query", type: "string", required: true },
|
|
20432
20802
|
size: { in: "query", type: "integer", required: false },
|
|
@@ -20459,6 +20829,7 @@ var endpoints18 = [
|
|
|
20459
20829
|
"jobNumbers",
|
|
20460
20830
|
"operator",
|
|
20461
20831
|
"parentCategoryUid",
|
|
20832
|
+
"productGroupIdList",
|
|
20462
20833
|
"q",
|
|
20463
20834
|
"searchType",
|
|
20464
20835
|
"size",
|
|
@@ -20482,6 +20853,7 @@ var endpoints18 = [
|
|
|
20482
20853
|
jobNumbers: { in: "query", type: "string", required: false },
|
|
20483
20854
|
operator: { in: "query", type: "string", required: false },
|
|
20484
20855
|
parentCategoryUid: { in: "query", type: "integer", required: false },
|
|
20856
|
+
productGroupIdList: { in: "query", type: "string", required: false },
|
|
20485
20857
|
q: { in: "query", type: "string", required: true },
|
|
20486
20858
|
searchType: { in: "query", type: "string", required: false },
|
|
20487
20859
|
size: { in: "query", type: "integer", required: false },
|
|
@@ -39548,9 +39920,9 @@ function frozenParams(params) {
|
|
|
39548
39920
|
}
|
|
39549
39921
|
function fromRow(service, row) {
|
|
39550
39922
|
return Object.freeze({
|
|
39551
|
-
// the
|
|
39552
|
-
//
|
|
39553
|
-
id:
|
|
39923
|
+
// the generator's rule too (proved endpointIdOf, the model's EndpointId), so an id is the
|
|
39924
|
+
// same whichever side built it: open-search → openSearch
|
|
39925
|
+
id: endpointIdOf(service, row.chain, row.action),
|
|
39554
39926
|
service,
|
|
39555
39927
|
method: row.method,
|
|
39556
39928
|
path: row.path,
|
|
@@ -39569,7 +39941,7 @@ function fromRow(service, row) {
|
|
|
39569
39941
|
function baseEntries(service) {
|
|
39570
39942
|
return BASE_ENDPOINTS.map(
|
|
39571
39943
|
([chain, path, auth, summary]) => Object.freeze({
|
|
39572
|
-
id:
|
|
39944
|
+
id: endpointIdOf(service, chain, "get"),
|
|
39573
39945
|
service,
|
|
39574
39946
|
method: "GET",
|
|
39575
39947
|
path,
|
|
@@ -39603,9 +39975,8 @@ function buildIndex() {
|
|
|
39603
39975
|
const map = /* @__PURE__ */ new Map();
|
|
39604
39976
|
for (const entry of registryEntries()) {
|
|
39605
39977
|
map.set(entry.id, entry);
|
|
39606
|
-
const chain = beforeLastCode(entry.id, 46);
|
|
39607
39978
|
for (const alias of entry.aliases) {
|
|
39608
|
-
map.set(
|
|
39979
|
+
map.set(withLastSegment(entry.id, alias), entry);
|
|
39609
39980
|
}
|
|
39610
39981
|
}
|
|
39611
39982
|
return map;
|
|
@@ -39644,7 +40015,7 @@ function rejectUnknown(entry, kind, keys, allowed) {
|
|
|
39644
40015
|
}
|
|
39645
40016
|
function checkArgs(entry, args) {
|
|
39646
40017
|
const pathKeys = Object.keys(args.pathParams ?? {});
|
|
39647
|
-
const missing = entry.pathParams
|
|
40018
|
+
const missing = notInFrom([...entry.pathParams], pathKeys, 0);
|
|
39648
40019
|
if (missing.length > 0) {
|
|
39649
40020
|
throw invalid(missingPathMessage(entry.id, joinFrom(missing, ", ", 0)), entry);
|
|
39650
40021
|
}
|
|
@@ -39668,62 +40039,62 @@ function fillPath(entry, pathParams) {
|
|
|
39668
40039
|
return renderPath(entry.path, segments);
|
|
39669
40040
|
}
|
|
39670
40041
|
function toEnvelope(body) {
|
|
39671
|
-
|
|
39672
|
-
|
|
39673
|
-
|
|
39674
|
-
|
|
39675
|
-
if (!ENVELOPE_KEYS.every((key) => key in record32)) {
|
|
40042
|
+
const isPlainObject = typeof body === "object" && body !== null && !Array.isArray(body);
|
|
40043
|
+
const record32 = isPlainObject ? body : {};
|
|
40044
|
+
const present = ENVELOPE_KEYS.map((key) => key in record32);
|
|
40045
|
+
if (!isEnvelopeBody(isPlainObject, allFrom(present, 0))) {
|
|
39676
40046
|
return null;
|
|
39677
40047
|
}
|
|
39678
40048
|
return Object.fromEntries(ENVELOPE_KEYS.map((key) => [key, record32[key]]));
|
|
39679
40049
|
}
|
|
39680
|
-
async function callEndpoint(config, id, args = {}) {
|
|
40050
|
+
async function callEndpoint(config, id, args = {}, bounds = NO_BOUNDS) {
|
|
39681
40051
|
const entry = resolveEndpoint(id);
|
|
39682
40052
|
if (!entry) {
|
|
39683
40053
|
throw invalid(unknownIdMessage(id));
|
|
39684
40054
|
}
|
|
39685
40055
|
checkArgs(entry, args);
|
|
39686
40056
|
const url = serviceUrl(entry.service, fillPath(entry, args.pathParams ?? {}));
|
|
39687
|
-
const raw = await new HTTPClient(entry.service, config).raw(entry.method, url, {
|
|
40057
|
+
const raw = await new HTTPClient(entry.service, config, bounds).raw(entry.method, url, {
|
|
39688
40058
|
params: args.query,
|
|
39689
40059
|
data: args.body ?? void 0,
|
|
39690
40060
|
config: { endpoint: entry.path }
|
|
39691
40061
|
});
|
|
39692
40062
|
const parsed = parseJson(raw.text);
|
|
39693
|
-
const body = parsed.json ? parsed.value : raw.text;
|
|
40063
|
+
const body = callBodyKind(parsed.json) === "json" ? parsed.value : raw.text;
|
|
39694
40064
|
return { httpStatus: raw.status, envelope: toEnvelope(body), body };
|
|
39695
40065
|
}
|
|
39696
40066
|
|
|
39697
|
-
//
|
|
39698
|
-
function
|
|
39699
|
-
return
|
|
40067
|
+
// src/core/proxy-rules.ts
|
|
40068
|
+
function renamesWireParams(method) {
|
|
40069
|
+
return method === "GET";
|
|
39700
40070
|
}
|
|
39701
|
-
function
|
|
39702
|
-
return
|
|
40071
|
+
function defaultsEmptyBody(hasQueryParams, hasBody) {
|
|
40072
|
+
return !hasQueryParams && !hasBody;
|
|
39703
40073
|
}
|
|
39704
|
-
function
|
|
39705
|
-
|
|
40074
|
+
function dataProxyRoute(isFunction, isObject) {
|
|
40075
|
+
if (isFunction) return "unwrap";
|
|
40076
|
+
return isObject ? "nest" : "copy";
|
|
39706
40077
|
}
|
|
39707
|
-
|
|
39708
|
-
|
|
39709
|
-
|
|
39710
|
-
return isSiteId(s);
|
|
40078
|
+
function requestShapeOf(hasPathParams, hasQueryParams, hasBody) {
|
|
40079
|
+
if (hasPathParams) return "withPathParams";
|
|
40080
|
+
return hasQueryParams || hasBody ? "paramsOnly" : "noParams";
|
|
39711
40081
|
}
|
|
39712
|
-
|
|
39713
|
-
|
|
39714
|
-
function parseSiteId(value) {
|
|
39715
|
-
return isSiteId2(value) ? value : void 0;
|
|
40082
|
+
function copiesLegacyValue(camelGiven) {
|
|
40083
|
+
return !camelGiven;
|
|
39716
40084
|
}
|
|
39717
|
-
function
|
|
39718
|
-
|
|
39719
|
-
|
|
39720
|
-
|
|
39721
|
-
|
|
39722
|
-
|
|
39723
|
-
|
|
39724
|
-
|
|
39725
|
-
|
|
39726
|
-
return
|
|
40085
|
+
function pathParamTargets(path, key) {
|
|
40086
|
+
if (includesFrom(path, braced(key), 0)) return [key];
|
|
40087
|
+
return foldMatchesFrom(templateNames(path, 0), key, 0);
|
|
40088
|
+
}
|
|
40089
|
+
function bodySlot(method) {
|
|
40090
|
+
return method === "DELETE" ? -1 : 0;
|
|
40091
|
+
}
|
|
40092
|
+
function querySlot(method) {
|
|
40093
|
+
if (method === "POST" || method === "PUT") return 1;
|
|
40094
|
+
return method === "DELETE" ? 0 : -1;
|
|
40095
|
+
}
|
|
40096
|
+
function isLegacyAlias(changed, declared) {
|
|
40097
|
+
return changed && declared;
|
|
39727
40098
|
}
|
|
39728
40099
|
|
|
39729
40100
|
// src/core/common-schemas.ts
|
|
@@ -39858,16 +40229,15 @@ var BaseServiceClient = class {
|
|
|
39858
40229
|
* describe the expected type, and `received` is not copied)
|
|
39859
40230
|
*/
|
|
39860
40231
|
createValidationError(valibotError, config, errorType) {
|
|
39861
|
-
const message = errorType === "params" ? "Invalid request parameters" : "Invalid API response structure\nThis appears to be a response validation error. The API returned data in an unexpected format.";
|
|
39862
40232
|
return new ValidationError({
|
|
39863
|
-
message,
|
|
40233
|
+
message: validationMessageOf(errorType),
|
|
39864
40234
|
service: this.serviceName,
|
|
39865
40235
|
endpoint: config.path,
|
|
39866
40236
|
validationErrors: valibotError.issues.map((issue) => ({
|
|
39867
40237
|
path: (issue.path ?? []).map((segment) => segment.key),
|
|
39868
40238
|
message: issue.message,
|
|
39869
40239
|
// Typed as always present, but issues built outside valibot can lack it
|
|
39870
|
-
code: issue.type
|
|
40240
|
+
code: issueCodeOf(issue.type)
|
|
39871
40241
|
}))
|
|
39872
40242
|
});
|
|
39873
40243
|
}
|
|
@@ -39895,45 +40265,28 @@ var BaseServiceClient = class {
|
|
|
39895
40265
|
let path = pathTemplate;
|
|
39896
40266
|
for (const [key, value] of Object.entries(pathParams)) {
|
|
39897
40267
|
const stringValue = String(value);
|
|
39898
|
-
|
|
39899
|
-
validatePathSegment(
|
|
39900
|
-
|
|
39901
|
-
|
|
39902
|
-
|
|
39903
|
-
|
|
39904
|
-
|
|
39905
|
-
|
|
39906
|
-
|
|
39907
|
-
placeholder,
|
|
39908
|
-
stringValue,
|
|
39909
|
-
pathPatterns[placeholder],
|
|
39910
|
-
this.serviceName
|
|
39911
|
-
);
|
|
39912
|
-
path = fillPlaceholder(path, placeholder, encodePathSegment(stringValue));
|
|
39913
|
-
}
|
|
39914
|
-
}
|
|
40268
|
+
for (const placeholder of pathParamTargets(path, key)) {
|
|
40269
|
+
validatePathSegment(
|
|
40270
|
+
pathTemplate,
|
|
40271
|
+
placeholder,
|
|
40272
|
+
stringValue,
|
|
40273
|
+
pathPatterns[placeholder],
|
|
40274
|
+
this.serviceName
|
|
40275
|
+
);
|
|
40276
|
+
path = fillPlaceholder(path, placeholder, encodePathSegment(stringValue));
|
|
39915
40277
|
}
|
|
39916
40278
|
}
|
|
39917
40279
|
return path;
|
|
39918
40280
|
}
|
|
39919
40281
|
};
|
|
39920
40282
|
|
|
39921
|
-
// src/
|
|
39922
|
-
|
|
39923
|
-
|
|
39924
|
-
// src/core/proxy-rules.ts
|
|
39925
|
-
function bodySlot(method) {
|
|
39926
|
-
return method === "DELETE" ? -1 : 0;
|
|
39927
|
-
}
|
|
39928
|
-
function querySlot(method) {
|
|
39929
|
-
if (method === "POST" || method === "PUT") return 1;
|
|
39930
|
-
return method === "DELETE" ? 0 : -1;
|
|
39931
|
-
}
|
|
39932
|
-
function isLegacyAlias(changed, declared) {
|
|
39933
|
-
return changed && declared;
|
|
40283
|
+
// ../utils/src/distance.ts
|
|
40284
|
+
function min2(x, y) {
|
|
40285
|
+
return Math.min(x, y);
|
|
39934
40286
|
}
|
|
39935
40287
|
|
|
39936
40288
|
// src/core/service-proxy.ts
|
|
40289
|
+
import * as v33 from "valibot";
|
|
39937
40290
|
var PassthroughResponseSchema = v33.looseObject({
|
|
39938
40291
|
count: v33.number(),
|
|
39939
40292
|
data: v33.unknown(),
|
|
@@ -39978,16 +40331,12 @@ function createNodeObject(serviceName, executeRequest, node) {
|
|
|
39978
40331
|
return obj;
|
|
39979
40332
|
}
|
|
39980
40333
|
function splitPathArgs(pathParams, args) {
|
|
40334
|
+
const taken = min2(pathParams.length, args.length);
|
|
39981
40335
|
const pathParamMap = {};
|
|
39982
|
-
let index2 = 0;
|
|
39983
|
-
|
|
39984
|
-
if (index2 >= args.length) {
|
|
39985
|
-
break;
|
|
39986
|
-
}
|
|
39987
|
-
pathParamMap[name] = String(args[index2]);
|
|
39988
|
-
index2++;
|
|
40336
|
+
for (let index2 = 0; index2 < taken; index2++) {
|
|
40337
|
+
pathParamMap[pathParams[index2]] = String(args[index2]);
|
|
39989
40338
|
}
|
|
39990
|
-
return { pathParamMap, rest: args.slice(
|
|
40339
|
+
return { pathParamMap, rest: args.slice(taken) };
|
|
39991
40340
|
}
|
|
39992
40341
|
function splitBodyAndQuery(method, rest) {
|
|
39993
40342
|
const at = (slot) => rest[slot];
|
|
@@ -40008,7 +40357,7 @@ function normaliseLegacyParamCase(params, declared) {
|
|
|
40008
40357
|
}
|
|
40009
40358
|
renamed = true;
|
|
40010
40359
|
delete out[key];
|
|
40011
|
-
if (
|
|
40360
|
+
if (copiesLegacyValue(camel in source)) {
|
|
40012
40361
|
out[camel] = value;
|
|
40013
40362
|
}
|
|
40014
40363
|
}
|
|
@@ -40025,7 +40374,7 @@ function createActionFunction(_serviceName, executeRequest, endpoint) {
|
|
|
40025
40374
|
hasQueryParams ? trailing : void 0,
|
|
40026
40375
|
endpoint.queryParams
|
|
40027
40376
|
);
|
|
40028
|
-
const wireParams = (value) => method
|
|
40377
|
+
const wireParams = (value) => renamesWireParams(method) ? normaliseLegacyParamCase(value, endpoint.queryParams) : value;
|
|
40029
40378
|
const config = {
|
|
40030
40379
|
method,
|
|
40031
40380
|
path,
|
|
@@ -40033,11 +40382,17 @@ function createActionFunction(_serviceName, executeRequest, endpoint) {
|
|
|
40033
40382
|
...hasQueryParams ? { paramsSchema: PassthroughParamsSchema } : {},
|
|
40034
40383
|
responseSchema: PassthroughResponseSchema
|
|
40035
40384
|
};
|
|
40036
|
-
|
|
40037
|
-
|
|
40385
|
+
const shape = requestShapeOf(
|
|
40386
|
+
Object.keys(pathParamMap).length > 0,
|
|
40387
|
+
hasQueryParams,
|
|
40388
|
+
body !== void 0
|
|
40389
|
+
);
|
|
40390
|
+
if (shape === "withPathParams") {
|
|
40391
|
+
const hasBody = body !== void 0 && body !== null;
|
|
40392
|
+
const params = wireParams(defaultsEmptyBody(hasQueryParams, hasBody) ? {} : body);
|
|
40038
40393
|
return query === void 0 ? executeRequest(config, params, pathParamMap) : executeRequest(config, params, pathParamMap, query);
|
|
40039
40394
|
}
|
|
40040
|
-
if (
|
|
40395
|
+
if (shape === "paramsOnly") {
|
|
40041
40396
|
return query === void 0 ? executeRequest(config, wireParams(body)) : executeRequest(config, wireParams(body), void 0, query);
|
|
40042
40397
|
}
|
|
40043
40398
|
return executeRequest(config);
|
|
@@ -40048,14 +40403,18 @@ function createDataProxy(resource) {
|
|
|
40048
40403
|
const src = resource;
|
|
40049
40404
|
for (const key of Object.keys(src)) {
|
|
40050
40405
|
const value = src[key];
|
|
40051
|
-
|
|
40406
|
+
const route = dataProxyRoute(
|
|
40407
|
+
typeof value === "function",
|
|
40408
|
+
typeof value === "object" && value !== null
|
|
40409
|
+
);
|
|
40410
|
+
if (route === "unwrap") {
|
|
40052
40411
|
const propKey = key;
|
|
40053
40412
|
obj[key] = async (...args) => {
|
|
40054
40413
|
const fn = src[propKey];
|
|
40055
40414
|
const response = await fn(...args);
|
|
40056
40415
|
return response?.data;
|
|
40057
40416
|
};
|
|
40058
|
-
} else if (
|
|
40417
|
+
} else if (route === "nest") {
|
|
40059
40418
|
obj[key] = createDataProxy(value);
|
|
40060
40419
|
} else {
|
|
40061
40420
|
obj[key] = value;
|
|
@@ -41738,8 +42097,32 @@ var Basecamp2Client = class extends BaseServiceClient {
|
|
|
41738
42097
|
};
|
|
41739
42098
|
|
|
41740
42099
|
// src/client.ts
|
|
42100
|
+
function mergedBounds(outer, signal, deadline) {
|
|
42101
|
+
const signals = signal === void 0 ? outer.signals : [...outer.signals, signal];
|
|
42102
|
+
const hasOuter = outer.deadline !== void 0;
|
|
42103
|
+
const hasInner = deadline !== void 0;
|
|
42104
|
+
if (!hasMergedDeadline(hasOuter, hasInner)) return { signals };
|
|
42105
|
+
return {
|
|
42106
|
+
signals,
|
|
42107
|
+
deadline: mergedDeadlineOf(hasOuter, outer.deadline ?? 0, hasInner, deadline ?? 0)
|
|
42108
|
+
};
|
|
42109
|
+
}
|
|
42110
|
+
var CONTEXT_REFUSALS = {
|
|
42111
|
+
context: () => new ContextCreationError("Context is required", "context"),
|
|
42112
|
+
"site-id": () => new ContextCreationError("Context must contain siteId", "siteId"),
|
|
42113
|
+
token: () => new ContextCreationError(
|
|
42114
|
+
"Context must contain jwt or bearerToken for authentication",
|
|
42115
|
+
"bearerToken"
|
|
42116
|
+
),
|
|
42117
|
+
"token-removed": () => new ContextCreationError(
|
|
42118
|
+
"fromContext options must not remove the context's bearer token",
|
|
42119
|
+
"bearerToken"
|
|
42120
|
+
)
|
|
42121
|
+
};
|
|
41741
42122
|
var AugurAPI = class _AugurAPI {
|
|
41742
42123
|
config;
|
|
42124
|
+
/** This client's call bounds: none, unless it is a view from `withRequest`. */
|
|
42125
|
+
bounds = NO_BOUNDS;
|
|
41743
42126
|
_joomla;
|
|
41744
42127
|
_commerce;
|
|
41745
42128
|
_pricing;
|
|
@@ -41802,7 +42185,52 @@ var AugurAPI = class _AugurAPI {
|
|
|
41802
42185
|
* ```
|
|
41803
42186
|
*/
|
|
41804
42187
|
call(id, args) {
|
|
41805
|
-
return callEndpoint(this.config, id, args);
|
|
42188
|
+
return callEndpoint(this.config, id, args, this.bounds);
|
|
42189
|
+
}
|
|
42190
|
+
/**
|
|
42191
|
+
* A view of this client whose every call is bounded by `options` (atlas#106): the caller's
|
|
42192
|
+
* `signal`, and a `deadline` in milliseconds for the whole call, retries and the waits between
|
|
42193
|
+
* them included. The view has this client's siteId, token, timeouts, retries and hooks, sends
|
|
42194
|
+
* the same headers, and builds its own service clients (sharing no in-flight request with this
|
|
42195
|
+
* one). Building a view and its first service costs about what building this client did, so
|
|
42196
|
+
* make one per bounded call, not per request inside a loop.
|
|
42197
|
+
*
|
|
42198
|
+
* @example
|
|
42199
|
+
* ```typescript
|
|
42200
|
+
* const items = await api.withRequest({ deadline: 5000 }).items.categories.items.list(uid, params);
|
|
42201
|
+
* ```
|
|
42202
|
+
*
|
|
42203
|
+
* @throws InvalidArgumentError when `signal` is given but not an AbortSignal, or `deadline` is
|
|
42204
|
+
* given but not a number from 0 to 2147483647 (NaN, Infinity or larger would fire at once).
|
|
42205
|
+
* Options can come from a browser through a server action, so their shape is checked.
|
|
42206
|
+
*/
|
|
42207
|
+
withRequest(options) {
|
|
42208
|
+
const signal = options?.signal;
|
|
42209
|
+
const deadline = options?.deadline;
|
|
42210
|
+
const accepted = callOptionsAccepted(
|
|
42211
|
+
signal !== void 0,
|
|
42212
|
+
signal instanceof AbortSignal,
|
|
42213
|
+
deadline !== void 0,
|
|
42214
|
+
typeof deadline === "number" && deadlineInRange(deadline)
|
|
42215
|
+
);
|
|
42216
|
+
if (!accepted) {
|
|
42217
|
+
throw new InvalidArgumentError({
|
|
42218
|
+
message: "Invalid call options: signal must be an AbortSignal, deadline a number of milliseconds from 0 to 2147483647",
|
|
42219
|
+
service: "",
|
|
42220
|
+
endpoint: ""
|
|
42221
|
+
});
|
|
42222
|
+
}
|
|
42223
|
+
const view = new _AugurAPI(this.config);
|
|
42224
|
+
view.bounds = mergedBounds(
|
|
42225
|
+
this.bounds,
|
|
42226
|
+
signal,
|
|
42227
|
+
deadline
|
|
42228
|
+
);
|
|
42229
|
+
return view;
|
|
42230
|
+
}
|
|
42231
|
+
/** The HTTP client a service is built with: this client's config and call bounds. */
|
|
42232
|
+
httpFor(service) {
|
|
42233
|
+
return new HTTPClient(service, this.config, this.bounds);
|
|
41806
42234
|
}
|
|
41807
42235
|
/**
|
|
41808
42236
|
* Create AugurAPI client from context object
|
|
@@ -41830,25 +42258,19 @@ var AugurAPI = class _AugurAPI {
|
|
|
41830
42258
|
* @throws {ContextCreationError} When context is invalid or missing required fields
|
|
41831
42259
|
*/
|
|
41832
42260
|
static fromContext(context, options = {}) {
|
|
41833
|
-
|
|
41834
|
-
throw new ContextCreationError("Context is required", "context");
|
|
41835
|
-
}
|
|
41836
|
-
if (!context.siteId) {
|
|
41837
|
-
throw new ContextCreationError("Context must contain siteId", "siteId");
|
|
41838
|
-
}
|
|
41839
|
-
const bearerToken = context.jwt || context.bearerToken;
|
|
41840
|
-
if (!bearerToken) {
|
|
41841
|
-
throw new ContextCreationError(
|
|
41842
|
-
"Context must contain jwt or bearerToken for authentication",
|
|
41843
|
-
"bearerToken"
|
|
41844
|
-
);
|
|
41845
|
-
}
|
|
42261
|
+
const bearerToken = context?.jwt || context?.bearerToken;
|
|
41846
42262
|
const config = {
|
|
41847
|
-
siteId: context
|
|
42263
|
+
siteId: context?.siteId ?? "",
|
|
41848
42264
|
bearerToken,
|
|
41849
42265
|
...options
|
|
41850
|
-
// Allow overrides
|
|
41851
42266
|
};
|
|
42267
|
+
const refusal = contextRefusalOf(
|
|
42268
|
+
Boolean(context),
|
|
42269
|
+
Boolean(context?.siteId),
|
|
42270
|
+
Boolean(bearerToken),
|
|
42271
|
+
Boolean(config.bearerToken)
|
|
42272
|
+
);
|
|
42273
|
+
if (refusal !== "ok") throw CONTEXT_REFUSALS[refusal]();
|
|
41852
42274
|
return new _AugurAPI(config);
|
|
41853
42275
|
}
|
|
41854
42276
|
/**
|
|
@@ -41856,7 +42278,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
41856
42278
|
*/
|
|
41857
42279
|
get joomla() {
|
|
41858
42280
|
if (!this._joomla) {
|
|
41859
|
-
const httpClient =
|
|
42281
|
+
const httpClient = this.httpFor("joomla");
|
|
41860
42282
|
this._joomla = new JoomlaClient(httpClient);
|
|
41861
42283
|
}
|
|
41862
42284
|
return this._joomla;
|
|
@@ -41866,7 +42288,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
41866
42288
|
*/
|
|
41867
42289
|
get commerce() {
|
|
41868
42290
|
if (!this._commerce) {
|
|
41869
|
-
const httpClient =
|
|
42291
|
+
const httpClient = this.httpFor("commerce");
|
|
41870
42292
|
this._commerce = new CommerceClient(httpClient);
|
|
41871
42293
|
}
|
|
41872
42294
|
return this._commerce;
|
|
@@ -41876,7 +42298,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
41876
42298
|
*/
|
|
41877
42299
|
get pricing() {
|
|
41878
42300
|
if (!this._pricing) {
|
|
41879
|
-
const httpClient =
|
|
42301
|
+
const httpClient = this.httpFor("pricing");
|
|
41880
42302
|
this._pricing = new PricingClient(httpClient);
|
|
41881
42303
|
}
|
|
41882
42304
|
return this._pricing;
|
|
@@ -41886,7 +42308,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
41886
42308
|
*/
|
|
41887
42309
|
get vmi() {
|
|
41888
42310
|
if (!this._vmi) {
|
|
41889
|
-
const httpClient =
|
|
42311
|
+
const httpClient = this.httpFor("vmi");
|
|
41890
42312
|
this._vmi = new VMIClient(httpClient);
|
|
41891
42313
|
}
|
|
41892
42314
|
return this._vmi;
|
|
@@ -41896,7 +42318,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
41896
42318
|
*/
|
|
41897
42319
|
get openSearch() {
|
|
41898
42320
|
if (!this._openSearch) {
|
|
41899
|
-
const httpClient =
|
|
42321
|
+
const httpClient = this.httpFor("open-search");
|
|
41900
42322
|
this._openSearch = new OpenSearchClient(httpClient);
|
|
41901
42323
|
}
|
|
41902
42324
|
return this._openSearch;
|
|
@@ -41906,7 +42328,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
41906
42328
|
*/
|
|
41907
42329
|
get items() {
|
|
41908
42330
|
if (!this._items) {
|
|
41909
|
-
const httpClient =
|
|
42331
|
+
const httpClient = this.httpFor("items");
|
|
41910
42332
|
this._items = new ItemsClient(httpClient);
|
|
41911
42333
|
}
|
|
41912
42334
|
return this._items;
|
|
@@ -41916,7 +42338,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
41916
42338
|
*/
|
|
41917
42339
|
get legacy() {
|
|
41918
42340
|
if (!this._legacy) {
|
|
41919
|
-
const httpClient =
|
|
42341
|
+
const httpClient = this.httpFor("legacy");
|
|
41920
42342
|
this._legacy = new LegacyClient(httpClient);
|
|
41921
42343
|
}
|
|
41922
42344
|
return this._legacy;
|
|
@@ -41926,7 +42348,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
41926
42348
|
*/
|
|
41927
42349
|
get agrSite() {
|
|
41928
42350
|
if (!this._agrSite) {
|
|
41929
|
-
const httpClient =
|
|
42351
|
+
const httpClient = this.httpFor("agr-site");
|
|
41930
42352
|
this._agrSite = new AgrSiteClient(httpClient);
|
|
41931
42353
|
}
|
|
41932
42354
|
return this._agrSite;
|
|
@@ -41936,7 +42358,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
41936
42358
|
*/
|
|
41937
42359
|
get customers() {
|
|
41938
42360
|
if (!this._customers) {
|
|
41939
|
-
const httpClient =
|
|
42361
|
+
const httpClient = this.httpFor("customers");
|
|
41940
42362
|
this._customers = new CustomersClient(httpClient);
|
|
41941
42363
|
}
|
|
41942
42364
|
return this._customers;
|
|
@@ -41946,7 +42368,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
41946
42368
|
*/
|
|
41947
42369
|
get orders() {
|
|
41948
42370
|
if (!this._orders) {
|
|
41949
|
-
const httpClient =
|
|
42371
|
+
const httpClient = this.httpFor("orders");
|
|
41950
42372
|
this._orders = new OrdersClient(httpClient);
|
|
41951
42373
|
}
|
|
41952
42374
|
return this._orders;
|
|
@@ -41956,7 +42378,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
41956
42378
|
*/
|
|
41957
42379
|
get p21Pim() {
|
|
41958
42380
|
if (!this._p21Pim) {
|
|
41959
|
-
const httpClient =
|
|
42381
|
+
const httpClient = this.httpFor("p21-pim");
|
|
41960
42382
|
this._p21Pim = new P21PimClient(httpClient);
|
|
41961
42383
|
}
|
|
41962
42384
|
return this._p21Pim;
|
|
@@ -41966,7 +42388,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
41966
42388
|
*/
|
|
41967
42389
|
get payments() {
|
|
41968
42390
|
if (!this._payments) {
|
|
41969
|
-
const httpClient =
|
|
42391
|
+
const httpClient = this.httpFor("payments");
|
|
41970
42392
|
this._payments = new PaymentsClient(httpClient);
|
|
41971
42393
|
}
|
|
41972
42394
|
return this._payments;
|
|
@@ -41976,7 +42398,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
41976
42398
|
*/
|
|
41977
42399
|
get agrInfo() {
|
|
41978
42400
|
if (!this._agrInfo) {
|
|
41979
|
-
const httpClient =
|
|
42401
|
+
const httpClient = this.httpFor("agr-info");
|
|
41980
42402
|
this._agrInfo = new AgrInfoClient(httpClient);
|
|
41981
42403
|
}
|
|
41982
42404
|
return this._agrInfo;
|
|
@@ -41986,7 +42408,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
41986
42408
|
*/
|
|
41987
42409
|
get agrInt() {
|
|
41988
42410
|
if (!this._agrInt) {
|
|
41989
|
-
const httpClient =
|
|
42411
|
+
const httpClient = this.httpFor("agr-int");
|
|
41990
42412
|
this._agrInt = new AgrIntClient(httpClient);
|
|
41991
42413
|
}
|
|
41992
42414
|
return this._agrInt;
|
|
@@ -41996,7 +42418,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
41996
42418
|
*/
|
|
41997
42419
|
get agrWork() {
|
|
41998
42420
|
if (!this._agrWork) {
|
|
41999
|
-
const httpClient =
|
|
42421
|
+
const httpClient = this.httpFor("agr-work");
|
|
42000
42422
|
this._agrWork = new AgrWorkClient(httpClient);
|
|
42001
42423
|
}
|
|
42002
42424
|
return this._agrWork;
|
|
@@ -42006,7 +42428,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
42006
42428
|
*/
|
|
42007
42429
|
get avalara() {
|
|
42008
42430
|
if (!this._avalara) {
|
|
42009
|
-
const httpClient =
|
|
42431
|
+
const httpClient = this.httpFor("avalara");
|
|
42010
42432
|
this._avalara = new AvalaraClient(httpClient);
|
|
42011
42433
|
}
|
|
42012
42434
|
return this._avalara;
|
|
@@ -42016,7 +42438,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
42016
42438
|
*/
|
|
42017
42439
|
get brandFolder() {
|
|
42018
42440
|
if (!this._brandFolder) {
|
|
42019
|
-
const httpClient =
|
|
42441
|
+
const httpClient = this.httpFor("brand-folder");
|
|
42020
42442
|
this._brandFolder = new BrandFolderClient(httpClient);
|
|
42021
42443
|
}
|
|
42022
42444
|
return this._brandFolder;
|
|
@@ -42026,7 +42448,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
42026
42448
|
*/
|
|
42027
42449
|
get googMc() {
|
|
42028
42450
|
if (!this._googMc) {
|
|
42029
|
-
const httpClient =
|
|
42451
|
+
const httpClient = this.httpFor("goog-mc");
|
|
42030
42452
|
this._googMc = new GoogMcClient(httpClient);
|
|
42031
42453
|
}
|
|
42032
42454
|
return this._googMc;
|
|
@@ -42036,7 +42458,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
42036
42458
|
*/
|
|
42037
42459
|
get gregorovich() {
|
|
42038
42460
|
if (!this._gregorovich) {
|
|
42039
|
-
const httpClient =
|
|
42461
|
+
const httpClient = this.httpFor("gregorovich");
|
|
42040
42462
|
this._gregorovich = new GregorovichClient(httpClient);
|
|
42041
42463
|
}
|
|
42042
42464
|
return this._gregorovich;
|
|
@@ -42046,7 +42468,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
42046
42468
|
*/
|
|
42047
42469
|
get logistics() {
|
|
42048
42470
|
if (!this._logistics) {
|
|
42049
|
-
const httpClient =
|
|
42471
|
+
const httpClient = this.httpFor("logistics");
|
|
42050
42472
|
this._logistics = new LogisticsClient(httpClient);
|
|
42051
42473
|
}
|
|
42052
42474
|
return this._logistics;
|
|
@@ -42056,7 +42478,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
42056
42478
|
*/
|
|
42057
42479
|
get markets() {
|
|
42058
42480
|
if (!this._markets) {
|
|
42059
|
-
const httpClient =
|
|
42481
|
+
const httpClient = this.httpFor("markets");
|
|
42060
42482
|
this._markets = new MarketsClient(httpClient);
|
|
42061
42483
|
}
|
|
42062
42484
|
return this._markets;
|
|
@@ -42066,7 +42488,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
42066
42488
|
*/
|
|
42067
42489
|
get notifications() {
|
|
42068
42490
|
if (!this._notifications) {
|
|
42069
|
-
const httpClient =
|
|
42491
|
+
const httpClient = this.httpFor("notifications");
|
|
42070
42492
|
this._notifications = new NotificationsClient(httpClient);
|
|
42071
42493
|
}
|
|
42072
42494
|
return this._notifications;
|
|
@@ -42076,7 +42498,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
42076
42498
|
*/
|
|
42077
42499
|
get p21Apis() {
|
|
42078
42500
|
if (!this._p21Apis) {
|
|
42079
|
-
const httpClient =
|
|
42501
|
+
const httpClient = this.httpFor("p21-apis");
|
|
42080
42502
|
this._p21Apis = new P21ApisClient(httpClient);
|
|
42081
42503
|
}
|
|
42082
42504
|
return this._p21Apis;
|
|
@@ -42086,7 +42508,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
42086
42508
|
*/
|
|
42087
42509
|
get p21Core() {
|
|
42088
42510
|
if (!this._p21Core) {
|
|
42089
|
-
const httpClient =
|
|
42511
|
+
const httpClient = this.httpFor("p21-core");
|
|
42090
42512
|
this._p21Core = new P21CoreClient(httpClient);
|
|
42091
42513
|
}
|
|
42092
42514
|
return this._p21Core;
|
|
@@ -42096,7 +42518,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
42096
42518
|
*/
|
|
42097
42519
|
get p21Sism() {
|
|
42098
42520
|
if (!this._p21Sism) {
|
|
42099
|
-
const httpClient =
|
|
42521
|
+
const httpClient = this.httpFor("p21-sism");
|
|
42100
42522
|
this._p21Sism = new P21SismClient(httpClient);
|
|
42101
42523
|
}
|
|
42102
42524
|
return this._p21Sism;
|
|
@@ -42106,7 +42528,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
42106
42528
|
*/
|
|
42107
42529
|
get shipping() {
|
|
42108
42530
|
if (!this._shipping) {
|
|
42109
|
-
const httpClient =
|
|
42531
|
+
const httpClient = this.httpFor("shipping");
|
|
42110
42532
|
this._shipping = new ShippingClient(httpClient);
|
|
42111
42533
|
}
|
|
42112
42534
|
return this._shipping;
|
|
@@ -42116,7 +42538,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
42116
42538
|
*/
|
|
42117
42539
|
get smartyStreets() {
|
|
42118
42540
|
if (!this._smartyStreets) {
|
|
42119
|
-
const httpClient =
|
|
42541
|
+
const httpClient = this.httpFor("smarty-streets");
|
|
42120
42542
|
this._smartyStreets = new SmartyStreetsClient(httpClient);
|
|
42121
42543
|
}
|
|
42122
42544
|
return this._smartyStreets;
|
|
@@ -42126,7 +42548,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
42126
42548
|
*/
|
|
42127
42549
|
get ups() {
|
|
42128
42550
|
if (!this._ups) {
|
|
42129
|
-
const httpClient =
|
|
42551
|
+
const httpClient = this.httpFor("ups");
|
|
42130
42552
|
this._ups = new UPSClient(httpClient);
|
|
42131
42553
|
}
|
|
42132
42554
|
return this._ups;
|
|
@@ -42136,7 +42558,7 @@ var AugurAPI = class _AugurAPI {
|
|
|
42136
42558
|
*/
|
|
42137
42559
|
get vendors() {
|
|
42138
42560
|
if (!this._vendors) {
|
|
42139
|
-
const httpClient =
|
|
42561
|
+
const httpClient = this.httpFor("vendors");
|
|
42140
42562
|
this._vendors = new VendorsClient(httpClient);
|
|
42141
42563
|
}
|
|
42142
42564
|
return this._vendors;
|
|
@@ -42146,13 +42568,18 @@ var AugurAPI = class _AugurAPI {
|
|
|
42146
42568
|
*/
|
|
42147
42569
|
get basecamp2() {
|
|
42148
42570
|
if (!this._basecamp2) {
|
|
42149
|
-
const httpClient =
|
|
42571
|
+
const httpClient = this.httpFor("basecamp2");
|
|
42150
42572
|
this._basecamp2 = new Basecamp2Client(httpClient);
|
|
42151
42573
|
}
|
|
42152
42574
|
return this._basecamp2;
|
|
42153
42575
|
}
|
|
42154
42576
|
/**
|
|
42155
42577
|
* Update authentication token
|
|
42578
|
+
*
|
|
42579
|
+
* Every service read from this client afterwards (`api.items`, …) sends the new token. A
|
|
42580
|
+
* service object read BEFORE the change keeps the token it was built with: read services from
|
|
42581
|
+
* the client after a change, don't hold them across it (AugurApiClient.BuiltClientKeepsItsSnapshot).
|
|
42582
|
+
*
|
|
42156
42583
|
* @param bearerToken New bearer token
|
|
42157
42584
|
*/
|
|
42158
42585
|
setAuthToken(bearerToken) {
|
|
@@ -42161,6 +42588,9 @@ var AugurAPI = class _AugurAPI {
|
|
|
42161
42588
|
}
|
|
42162
42589
|
/**
|
|
42163
42590
|
* Update site ID
|
|
42591
|
+
*
|
|
42592
|
+
* As with `setAuthToken`: a service object read before the change keeps the old siteId.
|
|
42593
|
+
*
|
|
42164
42594
|
* @param siteId New site ID
|
|
42165
42595
|
* @throws InvalidArgumentError when it is not a siteId (see the constructor)
|
|
42166
42596
|
*/
|
|
@@ -42203,6 +42633,11 @@ var AugurAPI = class _AugurAPI {
|
|
|
42203
42633
|
}
|
|
42204
42634
|
};
|
|
42205
42635
|
|
|
42636
|
+
// ../foundation/src/pos-int.ts
|
|
42637
|
+
function posIntOf(n) {
|
|
42638
|
+
return Math.floor(n) === n && n >= 1 && n <= 9007199254740991 ? n : null;
|
|
42639
|
+
}
|
|
42640
|
+
|
|
42206
42641
|
// src/utils/cross-site-auth.ts
|
|
42207
42642
|
async function authenticateUserForSite(params) {
|
|
42208
42643
|
const { targetSiteId, username, password, augurInfoToken } = params;
|
|
@@ -42217,23 +42652,35 @@ async function authenticateUserForSite(params) {
|
|
|
42217
42652
|
siteId: targetSiteId
|
|
42218
42653
|
// This tells the API to authenticate against the target site
|
|
42219
42654
|
});
|
|
42220
|
-
|
|
42655
|
+
const token = data.token;
|
|
42656
|
+
const tokenIsText = typeof token === "string";
|
|
42657
|
+
const outcome = crossSiteOutcomeOf(
|
|
42658
|
+
Boolean(data.isVerified),
|
|
42659
|
+
tokenIsText,
|
|
42660
|
+
tokenIsText ? token : ""
|
|
42661
|
+
);
|
|
42662
|
+
if (outcome === "notVerified") {
|
|
42221
42663
|
return { success: false, targetSiteId, error: "Invalid username or password" };
|
|
42222
42664
|
}
|
|
42223
|
-
if (
|
|
42665
|
+
if (outcome === "noToken") {
|
|
42224
42666
|
return { success: false, targetSiteId, error: "Password verified, but no token was issued" };
|
|
42225
42667
|
}
|
|
42668
|
+
const bearer = token;
|
|
42669
|
+
const rawId = data.id;
|
|
42670
|
+
const userId = posIntOf(typeof rawId === "number" ? rawId : Number.NaN);
|
|
42226
42671
|
const targetSiteAPI = new AugurAPI({
|
|
42227
42672
|
siteId: targetSiteId,
|
|
42228
|
-
bearerToken:
|
|
42673
|
+
bearerToken: bearer
|
|
42229
42674
|
});
|
|
42230
42675
|
return {
|
|
42231
42676
|
success: true,
|
|
42232
|
-
// `data` is typed, not validated at runtime
|
|
42233
|
-
|
|
42677
|
+
// `data` is typed, not validated at runtime. A user id is an integer at least 1: it enters
|
|
42678
|
+
// as a PosInt (foundation's posIntOf; not a number reads as NaN, which it refuses) and the
|
|
42679
|
+
// proved crossSiteUserIdOf writes it, so 0, -1, 1.5 or a missing id report no id
|
|
42680
|
+
userId: crossSiteUserIdOf(userId !== null, userId ?? 0),
|
|
42234
42681
|
username: data.username,
|
|
42235
42682
|
email: data.email,
|
|
42236
|
-
token:
|
|
42683
|
+
token: bearer,
|
|
42237
42684
|
targetSiteId,
|
|
42238
42685
|
targetSiteAPI
|
|
42239
42686
|
};
|
|
@@ -42257,7 +42704,7 @@ function createCrossSiteAuthenticator(augurInfoToken) {
|
|
|
42257
42704
|
}
|
|
42258
42705
|
|
|
42259
42706
|
// src/index.ts
|
|
42260
|
-
var VERSION = "2026.11.
|
|
42707
|
+
var VERSION = "2026.11.5";
|
|
42261
42708
|
export {
|
|
42262
42709
|
AgrInfoClient,
|
|
42263
42710
|
AgrIntClient,
|