@simpleapps-com/augur-api 2026.11.9 → 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/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
- return isSiteId2(value) ? value : void 0;
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 lowercase letters, digits, '_' and '-' (e.g. example-site)",
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);
@@ -40417,6 +40473,13 @@ function checkArgs(entry, args) {
40417
40473
  (key) => isQueryKeyAllowed(entry.queryParams.includes(key), entry.edgeCache, key)
40418
40474
  );
40419
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
+ }
40420
40483
  if (isBodyRefused(args.body !== void 0 && args.body !== null, entry.hasBody)) {
40421
40484
  throw invalid(noBodyMessage(entry.id), entry);
40422
40485
  }
@@ -40563,6 +40626,7 @@ var BaseServiceClient = class {
40563
40626
  */
40564
40627
  async executeRequest(config, params, pathParams, query) {
40565
40628
  this.refuseUnusableAddressIds(config, [params, query, pathParams]);
40629
+ this.refuseUnfitQuery(config, params, query);
40566
40630
  const endpoint = this.buildEndpointPath(config.path, pathParams, config.pathPatterns);
40567
40631
  try {
40568
40632
  const validatedParams = this.validateParameters(config, params);
@@ -40582,6 +40646,29 @@ var BaseServiceClient = class {
40582
40646
  * (atlas#95): "", "0", 0 and the like never reach a service as party 0. The decision is the
40583
40647
  * proved `paramRefused`; the error names the param, never its value.
40584
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
+ }
40585
40672
  refuseUnusableAddressIds(config, parts) {
40586
40673
  const refused = parts.flatMap(addressIdRefusals);
40587
40674
  if (refused.length === 0) return;
@@ -40801,7 +40888,9 @@ function createActionFunction(_serviceName, executeRequest, endpoint) {
40801
40888
  path,
40802
40889
  ...patterns,
40803
40890
  ...hasQueryParams ? { paramsSchema: PassthroughParamsSchema } : {},
40804
- responseSchema: PassthroughResponseSchema
40891
+ responseSchema: PassthroughResponseSchema,
40892
+ // The query is checked against these before the request (atlas#104, param-fit.ts)
40893
+ declaredParams: endpoint.params
40805
40894
  };
40806
40895
  const shape = requestShapeOf(
40807
40896
  Object.keys(pathParamMap).length > 0,
@@ -42577,13 +42666,15 @@ var AugurAPI = class _AugurAPI {
42577
42666
  /** Endpoint registry contract version (see shared/REGISTRY.md). */
42578
42667
  static registryVersion = REGISTRY_VERSION;
42579
42668
  /**
42580
- * @throws InvalidArgumentError when `config.siteId` is not a siteId (`isSiteId`: lowercase
42581
- * letters, digits, `_` and `-`). The config is copied, so changing the caller's object
42582
- * afterwards cannot put an empty or malformed one into `x-site-id`; use `setSiteId`.
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`.
42583
42675
  */
42584
42676
  constructor(config) {
42585
- assertSiteId(config.siteId);
42586
- this.config = { ...config };
42677
+ this.config = { ...config, siteId: assertSiteId(config.siteId) };
42587
42678
  }
42588
42679
  /**
42589
42680
  * Every endpoint the SDK exposes, one language-neutral entry each, sorted by id.
@@ -42608,6 +42699,20 @@ var AugurAPI = class _AugurAPI {
42608
42699
  call(id, args) {
42609
42700
  return callEndpoint(this.config, id, args, this.bounds);
42610
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
+ }
42611
42716
  /**
42612
42717
  * A view of this client whose every call is bounded by `options` (atlas#106): the caller's
42613
42718
  * `signal`, and a `deadline` in milliseconds for the whole call, retries and the waits between
@@ -43064,7 +43169,7 @@ async function authenticateUserForSite(params) {
43064
43169
  const { targetSiteId, username, password, augurInfoToken } = params;
43065
43170
  try {
43066
43171
  const augurInfoAPI = new AugurAPI({
43067
- siteId: "augur_info",
43172
+ siteId: systemSiteId(),
43068
43173
  bearerToken: augurInfoToken
43069
43174
  });
43070
43175
  const { data } = await augurInfoAPI.joomla.users.verifyPassword.create({
@@ -43124,8 +43229,13 @@ function createCrossSiteAuthenticator(augurInfoToken) {
43124
43229
  };
43125
43230
  }
43126
43231
 
43232
+ // src/core/site-id-check.ts
43233
+ function isSiteId2(s) {
43234
+ return isSiteId(s);
43235
+ }
43236
+
43127
43237
  // src/index.ts
43128
- var VERSION = "2026.11.9";
43238
+ var VERSION = "2026.11.10";
43129
43239
  export {
43130
43240
  AgrInfoClient,
43131
43241
  AgrIntClient,