@simpleapps-com/augur-api 2026.11.8 → 2026.11.10
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 +6 -2
- package/dist/client.d.ts +18 -3
- package/dist/client.d.ts.map +1 -1
- package/dist/core/base-client.d.ts +12 -0
- package/dist/core/base-client.d.ts.map +1 -1
- package/dist/core/call.d.ts.map +1 -1
- package/dist/core/param-fit.d.ts +30 -0
- package/dist/core/param-fit.d.ts.map +1 -0
- package/dist/core/service-proxy.d.ts.map +1 -1
- package/dist/core/site-id.d.ts +5 -2
- package/dist/core/site-id.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +139 -26
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +139 -26
- package/dist/index.mjs.map +1 -1
- package/dist/services/items/generated/schemas.d.ts +2 -0
- package/dist/services/items/generated/schemas.d.ts.map +1 -1
- package/dist/services/items/generated/types.d.ts +2 -0
- package/dist/services/items/generated/types.d.ts.map +1 -1
- package/dist/services/legacy/generated/schemas.d.ts +1 -0
- package/dist/services/legacy/generated/schemas.d.ts.map +1 -1
- package/dist/services/legacy/generated/types.d.ts +2 -0
- package/dist/services/legacy/generated/types.d.ts.map +1 -1
- package/dist/utils/cross-site-auth.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -410,6 +410,24 @@ function rawRetries(method) {
|
|
|
410
410
|
return method === "GET";
|
|
411
411
|
}
|
|
412
412
|
|
|
413
|
+
// ../auth-core/src/site.ts
|
|
414
|
+
function isSiteChar(c) {
|
|
415
|
+
return c >= 97 && c <= 122 || c >= 48 && c <= 57 || c === 95 || c === 45;
|
|
416
|
+
}
|
|
417
|
+
function siteCharsFrom(s, i) {
|
|
418
|
+
return i >= s.length || isSiteChar(s.charCodeAt(i)) && siteCharsFrom(s, i + 1);
|
|
419
|
+
}
|
|
420
|
+
function isSiteId(s) {
|
|
421
|
+
return s.length > 0 && siteCharsFrom(s, 0);
|
|
422
|
+
}
|
|
423
|
+
function siteIdOf(s) {
|
|
424
|
+
const lower = lowerAscii(s);
|
|
425
|
+
return isSiteId(lower) ? lower : null;
|
|
426
|
+
}
|
|
427
|
+
function systemSiteId() {
|
|
428
|
+
return "augur_info";
|
|
429
|
+
}
|
|
430
|
+
|
|
413
431
|
// src/core/errors.ts
|
|
414
432
|
var ROOT_PATH = "root";
|
|
415
433
|
var AugurError = class _AugurError extends Error {
|
|
@@ -521,31 +539,16 @@ var InvalidArgumentError = class extends AugurError {
|
|
|
521
539
|
}
|
|
522
540
|
};
|
|
523
541
|
|
|
524
|
-
// ../auth-core/src/site.ts
|
|
525
|
-
function isSiteChar(c) {
|
|
526
|
-
return c >= 97 && c <= 122 || c >= 48 && c <= 57 || c === 95 || c === 45;
|
|
527
|
-
}
|
|
528
|
-
function siteCharsFrom(s, i) {
|
|
529
|
-
return i >= s.length || isSiteChar(s.charCodeAt(i)) && siteCharsFrom(s, i + 1);
|
|
530
|
-
}
|
|
531
|
-
function isSiteId(s) {
|
|
532
|
-
return s.length > 0 && siteCharsFrom(s, 0);
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
// src/core/site-id-check.ts
|
|
536
|
-
function isSiteId2(s) {
|
|
537
|
-
return isSiteId(s);
|
|
538
|
-
}
|
|
539
|
-
|
|
540
542
|
// src/core/site-id.ts
|
|
541
543
|
function parseSiteId(value) {
|
|
542
|
-
|
|
544
|
+
const site = siteIdOf(value);
|
|
545
|
+
return site === null ? void 0 : site;
|
|
543
546
|
}
|
|
544
547
|
function assertSiteId(value) {
|
|
545
548
|
const site = parseSiteId(value);
|
|
546
549
|
if (site === void 0) {
|
|
547
550
|
throw new InvalidArgumentError({
|
|
548
|
-
message: "Invalid siteId: expected
|
|
551
|
+
message: "Invalid siteId: expected letters, digits, '_' and '-' (e.g. example-site)",
|
|
549
552
|
service: "",
|
|
550
553
|
endpoint: ""
|
|
551
554
|
});
|
|
@@ -1089,6 +1092,59 @@ var HTTPClient = class {
|
|
|
1089
1092
|
}
|
|
1090
1093
|
};
|
|
1091
1094
|
|
|
1095
|
+
// src/core/param-fit.ts
|
|
1096
|
+
function integerTextOf(t) {
|
|
1097
|
+
if (t === "0") return true;
|
|
1098
|
+
if (isPosDigits(t)) return true;
|
|
1099
|
+
return t.length > 1 && t.charCodeAt(0) === 45 && isPosDigits(t.slice(1));
|
|
1100
|
+
}
|
|
1101
|
+
function valueFits(declaredType, wholeNumber, finiteNumber, integerText, numericText, isBoolean, booleanText, isText, integerList) {
|
|
1102
|
+
const integer8 = eitherFits(wholeNumber, integerText);
|
|
1103
|
+
if (declaredType === "integer") return integer8;
|
|
1104
|
+
if (declaredType === "integer|integer[]") return eitherFits(integer8, integerList);
|
|
1105
|
+
if (declaredType === "number") return eitherFits(finiteNumber, numericText);
|
|
1106
|
+
if (declaredType === "boolean") return eitherFits(isBoolean, booleanText);
|
|
1107
|
+
if (declaredType === "string") return eitherFits(isText, eitherFits(finiteNumber, isBoolean));
|
|
1108
|
+
return true;
|
|
1109
|
+
}
|
|
1110
|
+
function eitherFits(a, b) {
|
|
1111
|
+
return a || b;
|
|
1112
|
+
}
|
|
1113
|
+
function paramFitRefused(sent, fits2) {
|
|
1114
|
+
return sent && !fits2;
|
|
1115
|
+
}
|
|
1116
|
+
function isWhole(value) {
|
|
1117
|
+
return typeof value === "number" && Number.isSafeInteger(value) || typeof value === "string" && integerTextOf(value.trim());
|
|
1118
|
+
}
|
|
1119
|
+
function isIntegerList(value) {
|
|
1120
|
+
if (Array.isArray(value)) return value.length > 0 && value.every(isWhole);
|
|
1121
|
+
return typeof value === "string" && value.includes(",") && value.split(",").every(isWhole);
|
|
1122
|
+
}
|
|
1123
|
+
function fits(type, value) {
|
|
1124
|
+
const isText = typeof value === "string";
|
|
1125
|
+
const text = isText ? value.trim() : "";
|
|
1126
|
+
const isNumber = typeof value === "number";
|
|
1127
|
+
return valueFits(
|
|
1128
|
+
type,
|
|
1129
|
+
isNumber && Number.isSafeInteger(value),
|
|
1130
|
+
isNumber && Number.isFinite(value),
|
|
1131
|
+
integerTextOf(text),
|
|
1132
|
+
text !== "" && Number.isFinite(Number(text)),
|
|
1133
|
+
typeof value === "boolean",
|
|
1134
|
+
value === "true" || value === "false",
|
|
1135
|
+
isText,
|
|
1136
|
+
isIntegerList(value)
|
|
1137
|
+
);
|
|
1138
|
+
}
|
|
1139
|
+
function paramFitRefusals(declared, query) {
|
|
1140
|
+
const record32 = query !== null && typeof query === "object" && !Array.isArray(query) ? query : {};
|
|
1141
|
+
return Object.entries(declared).filter(([name, param]) => {
|
|
1142
|
+
const value = param.in === "query" ? record32[name] : void 0;
|
|
1143
|
+
const sent = value !== void 0 && value !== null;
|
|
1144
|
+
return paramFitRefused(sent, sent && fits(param.type, value));
|
|
1145
|
+
}).map(([name]) => name);
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1092
1148
|
// src/core/encoded-segment.ts
|
|
1093
1149
|
function encodePathSegment(value) {
|
|
1094
1150
|
const encoded = restorePcharFrom(encodeURIComponent(value), 0);
|
|
@@ -11473,6 +11529,7 @@ var InvMastListDataSchema = v13.array(
|
|
|
11473
11529
|
),
|
|
11474
11530
|
images: v13.array(v13.string()),
|
|
11475
11531
|
videos: v13.array(v13.string()),
|
|
11532
|
+
specsheets: v13.array(v13.string()),
|
|
11476
11533
|
stock: v13.looseObject({
|
|
11477
11534
|
stockData: v13.array(
|
|
11478
11535
|
v13.looseObject({
|
|
@@ -12152,6 +12209,7 @@ var InvMastDocListDataSchema = v13.looseObject({
|
|
|
12152
12209
|
),
|
|
12153
12210
|
images: v13.array(v13.string()),
|
|
12154
12211
|
videos: v13.array(v13.string()),
|
|
12212
|
+
specsheets: v13.array(v13.string()),
|
|
12155
12213
|
stock: v13.looseObject({
|
|
12156
12214
|
stockData: v13.array(
|
|
12157
12215
|
v13.looseObject({
|
|
@@ -18517,6 +18575,7 @@ var InvMastAlsoBoughtListDataSchema = v15.array(
|
|
|
18517
18575
|
})
|
|
18518
18576
|
),
|
|
18519
18577
|
images: v15.array(v15.string()),
|
|
18578
|
+
videos: v15.array(v15.string()),
|
|
18520
18579
|
stock: v15.looseObject({
|
|
18521
18580
|
stockData: v15.array(
|
|
18522
18581
|
v15.looseObject({
|
|
@@ -40414,6 +40473,13 @@ function checkArgs(entry, args) {
|
|
|
40414
40473
|
(key) => isQueryKeyAllowed(entry.queryParams.includes(key), entry.edgeCache, key)
|
|
40415
40474
|
);
|
|
40416
40475
|
rejectUnknown(entry, "query params", queryKeys, allowed);
|
|
40476
|
+
const unfit = paramFitRefusals(entry.params, args.query);
|
|
40477
|
+
if (unfit.length > 0) {
|
|
40478
|
+
throw invalid(
|
|
40479
|
+
`${entry.id}: query params not of their declared type: ${joinFrom(unfit, ", ", 0)}`,
|
|
40480
|
+
entry
|
|
40481
|
+
);
|
|
40482
|
+
}
|
|
40417
40483
|
if (isBodyRefused(args.body !== void 0 && args.body !== null, entry.hasBody)) {
|
|
40418
40484
|
throw invalid(noBodyMessage(entry.id), entry);
|
|
40419
40485
|
}
|
|
@@ -40560,6 +40626,7 @@ var BaseServiceClient = class {
|
|
|
40560
40626
|
*/
|
|
40561
40627
|
async executeRequest(config, params, pathParams, query) {
|
|
40562
40628
|
this.refuseUnusableAddressIds(config, [params, query, pathParams]);
|
|
40629
|
+
this.refuseUnfitQuery(config, params, query);
|
|
40563
40630
|
const endpoint = this.buildEndpointPath(config.path, pathParams, config.pathPatterns);
|
|
40564
40631
|
try {
|
|
40565
40632
|
const validatedParams = this.validateParameters(config, params);
|
|
@@ -40579,6 +40646,29 @@ var BaseServiceClient = class {
|
|
|
40579
40646
|
* (atlas#95): "", "0", 0 and the like never reach a service as party 0. The decision is the
|
|
40580
40647
|
* proved `paramRefused`; the error names the param, never its value.
|
|
40581
40648
|
*/
|
|
40649
|
+
/**
|
|
40650
|
+
* Refuse a sent declared query param whose value does not fit its type (atlas#104). A GET's
|
|
40651
|
+
* query is its `params`; a write's rides in `query` (proved `renamesWireParams`). Names only,
|
|
40652
|
+
* never values.
|
|
40653
|
+
*/
|
|
40654
|
+
refuseUnfitQuery(config, params, query) {
|
|
40655
|
+
if (config.declaredParams === void 0) return;
|
|
40656
|
+
const refused = paramFitRefusals(
|
|
40657
|
+
config.declaredParams,
|
|
40658
|
+
renamesWireParams(config.method) ? params : query
|
|
40659
|
+
);
|
|
40660
|
+
if (refused.length === 0) return;
|
|
40661
|
+
throw new ValidationError({
|
|
40662
|
+
message: validationMessageOf("params"),
|
|
40663
|
+
service: this.serviceName,
|
|
40664
|
+
endpoint: config.path,
|
|
40665
|
+
validationErrors: refused.map((name) => ({
|
|
40666
|
+
path: [name],
|
|
40667
|
+
message: "Not a declared query param, or missing, or not of its declared type",
|
|
40668
|
+
code: "param_fit"
|
|
40669
|
+
}))
|
|
40670
|
+
});
|
|
40671
|
+
}
|
|
40582
40672
|
refuseUnusableAddressIds(config, parts) {
|
|
40583
40673
|
const refused = parts.flatMap(addressIdRefusals);
|
|
40584
40674
|
if (refused.length === 0) return;
|
|
@@ -40798,7 +40888,9 @@ function createActionFunction(_serviceName, executeRequest, endpoint) {
|
|
|
40798
40888
|
path,
|
|
40799
40889
|
...patterns,
|
|
40800
40890
|
...hasQueryParams ? { paramsSchema: PassthroughParamsSchema } : {},
|
|
40801
|
-
responseSchema: PassthroughResponseSchema
|
|
40891
|
+
responseSchema: PassthroughResponseSchema,
|
|
40892
|
+
// The query is checked against these before the request (atlas#104, param-fit.ts)
|
|
40893
|
+
declaredParams: endpoint.params
|
|
40802
40894
|
};
|
|
40803
40895
|
const shape = requestShapeOf(
|
|
40804
40896
|
Object.keys(pathParamMap).length > 0,
|
|
@@ -42574,13 +42666,15 @@ var AugurAPI = class _AugurAPI {
|
|
|
42574
42666
|
/** Endpoint registry contract version (see shared/REGISTRY.md). */
|
|
42575
42667
|
static registryVersion = REGISTRY_VERSION;
|
|
42576
42668
|
/**
|
|
42577
|
-
*
|
|
42578
|
-
*
|
|
42579
|
-
*
|
|
42669
|
+
* `config.siteId` is lowercased (owner 2026-11-16: every siteId is lowercase), so
|
|
42670
|
+
* "Example-Site" sends `x-site-id: example-site`.
|
|
42671
|
+
*
|
|
42672
|
+
* @throws InvalidArgumentError when `config.siteId` names no siteId (letters, digits, `_` and
|
|
42673
|
+
* `-`). The config is copied, so changing the caller's object afterwards cannot put an
|
|
42674
|
+
* empty or malformed one into `x-site-id`; use `setSiteId`.
|
|
42580
42675
|
*/
|
|
42581
42676
|
constructor(config) {
|
|
42582
|
-
assertSiteId(config.siteId);
|
|
42583
|
-
this.config = { ...config };
|
|
42677
|
+
this.config = { ...config, siteId: assertSiteId(config.siteId) };
|
|
42584
42678
|
}
|
|
42585
42679
|
/**
|
|
42586
42680
|
* Every endpoint the SDK exposes, one language-neutral entry each, sorted by id.
|
|
@@ -42605,6 +42699,20 @@ var AugurAPI = class _AugurAPI {
|
|
|
42605
42699
|
call(id, args) {
|
|
42606
42700
|
return callEndpoint(this.config, id, args, this.bounds);
|
|
42607
42701
|
}
|
|
42702
|
+
/**
|
|
42703
|
+
* Whether `id` names an endpoint in this client's registry: a canonical id
|
|
42704
|
+
* (`items.invMast.list`) or an alias id. A server that runs paths from a browser (augur-server's
|
|
42705
|
+
* `queryAction`, atlas#104) refuses any path this answers false for.
|
|
42706
|
+
*
|
|
42707
|
+
* @example
|
|
42708
|
+
* ```typescript
|
|
42709
|
+
* api.hasEndpoint("items.invMast.list"); // true
|
|
42710
|
+
* api.hasEndpoint("setAuthToken"); // false
|
|
42711
|
+
* ```
|
|
42712
|
+
*/
|
|
42713
|
+
hasEndpoint(id) {
|
|
42714
|
+
return resolveEndpoint(id) !== void 0;
|
|
42715
|
+
}
|
|
42608
42716
|
/**
|
|
42609
42717
|
* A view of this client whose every call is bounded by `options` (atlas#106): the caller's
|
|
42610
42718
|
* `signal`, and a `deadline` in milliseconds for the whole call, retries and the waits between
|
|
@@ -43061,7 +43169,7 @@ async function authenticateUserForSite(params) {
|
|
|
43061
43169
|
const { targetSiteId, username, password, augurInfoToken } = params;
|
|
43062
43170
|
try {
|
|
43063
43171
|
const augurInfoAPI = new AugurAPI({
|
|
43064
|
-
siteId:
|
|
43172
|
+
siteId: systemSiteId(),
|
|
43065
43173
|
bearerToken: augurInfoToken
|
|
43066
43174
|
});
|
|
43067
43175
|
const { data } = await augurInfoAPI.joomla.users.verifyPassword.create({
|
|
@@ -43121,8 +43229,13 @@ function createCrossSiteAuthenticator(augurInfoToken) {
|
|
|
43121
43229
|
};
|
|
43122
43230
|
}
|
|
43123
43231
|
|
|
43232
|
+
// src/core/site-id-check.ts
|
|
43233
|
+
function isSiteId2(s) {
|
|
43234
|
+
return isSiteId(s);
|
|
43235
|
+
}
|
|
43236
|
+
|
|
43124
43237
|
// src/index.ts
|
|
43125
|
-
var VERSION = "2026.11.
|
|
43238
|
+
var VERSION = "2026.11.10";
|
|
43126
43239
|
export {
|
|
43127
43240
|
AgrInfoClient,
|
|
43128
43241
|
AgrIntClient,
|