@simpleapps-com/augur-api 2026.10.16 → 2026.10.17

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
@@ -499,16 +499,99 @@ var HTTPClient = class {
499
499
  }
500
500
  };
501
501
 
502
- // src/core/path-validation.ts
502
+ // src/core/path-encode.ts
503
+ function isHigh(c) {
504
+ return c >= 55296 && c <= 56319;
505
+ }
506
+ function isLow(c) {
507
+ return c >= 56320 && c <= 57343;
508
+ }
509
+ function isUpperHex(c) {
510
+ return c >= 48 && c <= 57 || c >= 65 && c <= 70;
511
+ }
512
+ function isAlnum(c) {
513
+ return c >= 65 && c <= 90 || c >= 97 && c <= 122 || c >= 48 && c <= 57;
514
+ }
515
+ function isMark(c) {
516
+ return c === 45 || c === 46 || c === 95 || c === 126;
517
+ }
518
+ function isDelimOrAt(c) {
519
+ return c === 33 || c === 36 || c >= 38 && c <= 44 || c === 58 || c === 59 || c === 61 || c === 64;
520
+ }
521
+ function isPchar(c) {
522
+ return isAlnum(c) || isMark(c) || isDelimOrAt(c);
523
+ }
524
+ function loneAt(s, k) {
525
+ return isHigh(s.charCodeAt(k)) && !(k + 1 < s.length && isLow(s.charCodeAt(k + 1))) || isLow(s.charCodeAt(k)) && !(k > 0 && isHigh(s.charCodeAt(k - 1)));
526
+ }
527
+ function isPairAt(s, i) {
528
+ return isHigh(s.charCodeAt(i)) && i + 1 < s.length && isLow(s.charCodeAt(i + 1));
529
+ }
530
+ function okAt(s, k) {
531
+ return isPchar(s.charCodeAt(k)) || s.charCodeAt(k) === 37 && k + 2 < s.length && isUpperHex(s.charCodeAt(k + 1)) && isUpperHex(s.charCodeAt(k + 2));
532
+ }
533
+ function hasLoneSurrogate(value) {
534
+ let i = 0;
535
+ while (i < value.length) {
536
+ if (loneAt(value, i)) return true;
537
+ if (isPairAt(value, i)) {
538
+ i = i + 2;
539
+ } else {
540
+ i = i + 1;
541
+ }
542
+ }
543
+ return false;
544
+ }
545
+ function isEncoded(s) {
546
+ let i = 0;
547
+ while (i < s.length) {
548
+ if (!okAt(s, i)) return false;
549
+ if (s.charCodeAt(i) === 37) {
550
+ i = i + 3;
551
+ } else {
552
+ i = i + 1;
553
+ }
554
+ }
555
+ return true;
556
+ }
557
+
558
+ // src/core/encoded-segment.ts
503
559
  var PCHAR_RESTORE_RE = /%(?:24|26|2B|2C|3B|3D|3A|40)/g;
504
- var LONE_SURROGATE_RE = /[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/;
505
- var encodePathSegment = (value) => encodeURIComponent(value).replace(PCHAR_RESTORE_RE, decodeURIComponent);
560
+ function encodePathSegment(value) {
561
+ const encoded = encodeURIComponent(value).replace(PCHAR_RESTORE_RE, decodeURIComponent);
562
+ if (!isEncoded(encoded)) {
563
+ throw new InvalidArgumentError({
564
+ message: "Encoded path segment has an unexpected shape",
565
+ service: "",
566
+ endpoint: ""
567
+ });
568
+ }
569
+ return encoded;
570
+ }
571
+ function fillPlaceholder(path, placeholder, segment) {
572
+ return path.split(`{${placeholder}}`).join(segment);
573
+ }
574
+ function renderPath(template, segments) {
575
+ return template.replace(/\{([^}]+)\}/g, (_, name) => {
576
+ const segment = segments[name];
577
+ if (segment === void 0) {
578
+ throw new InvalidArgumentError({
579
+ message: `No path value for {${name}}`,
580
+ service: "",
581
+ endpoint: template
582
+ });
583
+ }
584
+ return segment;
585
+ });
586
+ }
587
+
588
+ // src/core/path-validation.ts
506
589
  var pathValueProblem = (value, pattern) => {
507
590
  if (pattern !== void 0 && !new RegExp(pattern).test(value)) {
508
591
  return `expected a value matching ${pattern}`;
509
592
  }
510
593
  if (value === "") return "expected a non-empty string";
511
- return LONE_SURROGATE_RE.test(value) ? "expected a well-formed string" : void 0;
594
+ return hasLoneSurrogate(value) ? "expected a well-formed string" : void 0;
512
595
  };
513
596
  var validatePathSegment = (pathTemplate, name, value, pattern, service = "http-client") => {
514
597
  const problem = pathValueProblem(value, pattern);
@@ -22069,6 +22152,9 @@ function resolveEndpoint(id) {
22069
22152
  index ?? (index = buildIndex());
22070
22153
  return index.get(id);
22071
22154
  }
22155
+ function isReadOnly(entry) {
22156
+ return entry.readOnly ?? entry.method === "GET";
22157
+ }
22072
22158
 
22073
22159
  // src/core/call.ts
22074
22160
  var ENVELOPE_KEYS = [
@@ -22109,11 +22195,14 @@ function checkArgs(entry, args) {
22109
22195
  }
22110
22196
  }
22111
22197
  function fillPath(entry, pathParams) {
22112
- return entry.path.replace(/\{([^}]+)\}/g, (_, name) => {
22198
+ const segments = {};
22199
+ for (const match of entry.path.matchAll(/\{([^}]+)\}/g)) {
22200
+ const name = match[1];
22113
22201
  const value = String(pathParams[name]);
22114
22202
  validatePathSegment(entry.path, name, value, entry.pathPatterns[name], entry.service);
22115
- return encodePathSegment(value);
22116
- });
22203
+ segments[name] = encodePathSegment(value);
22204
+ }
22205
+ return renderPath(entry.path, segments);
22117
22206
  }
22118
22207
  function toEnvelope(body) {
22119
22208
  if (typeof body !== "object" || body === null || Array.isArray(body)) {
@@ -22142,6 +22231,36 @@ async function callEndpoint(config, id, args = {}) {
22142
22231
  return { httpStatus: raw.status, envelope: toEnvelope(body), body };
22143
22232
  }
22144
22233
 
22234
+ // src/core/site-id-check.ts
22235
+ function isSiteChar(c) {
22236
+ return c >= 97 && c <= 122 || c >= 48 && c <= 57 || c === 95 || c === 45;
22237
+ }
22238
+ function isSiteId(s) {
22239
+ if (s.length === 0) return false;
22240
+ let i = 0;
22241
+ while (i < s.length) {
22242
+ if (!isSiteChar(s.charCodeAt(i))) return false;
22243
+ i = i + 1;
22244
+ }
22245
+ return true;
22246
+ }
22247
+
22248
+ // src/core/site-id.ts
22249
+ function parseSiteId(value) {
22250
+ return isSiteId(value) ? value : void 0;
22251
+ }
22252
+ function assertSiteId(value) {
22253
+ const site = parseSiteId(value);
22254
+ if (site === void 0) {
22255
+ throw new InvalidArgumentError({
22256
+ message: "Invalid siteId: expected lowercase letters, digits, '_' and '-' (e.g. ampro-online)",
22257
+ service: "",
22258
+ endpoint: ""
22259
+ });
22260
+ }
22261
+ return site;
22262
+ }
22263
+
22145
22264
  // src/core/common-schemas.ts
22146
22265
  var CommonHealthCheckResponseSchema = BaseResponseSchema(HealthCheckDataSchema);
22147
22266
  var CommonPingResponseSchema = BaseResponseSchema(PingDataSchema);
@@ -22311,11 +22430,11 @@ var BaseServiceClient = class {
22311
22430
  const stringValue = String(value);
22312
22431
  if (path.includes(`{${key}}`)) {
22313
22432
  validatePathSegment(pathTemplate, key, stringValue, pathPatterns[key], this.serviceName);
22314
- const encoded = encodePathSegment(stringValue);
22315
- path = path.replace(`{${key}}`, () => encoded);
22433
+ path = fillPlaceholder(path, key, encodePathSegment(stringValue));
22316
22434
  } else {
22317
22435
  const normKey = normalise(key);
22318
- path = path.replace(/\{([^}]+)\}/g, (match, placeholder) => {
22436
+ for (const match of new Set(path.matchAll(/\{([^}]+)\}/g))) {
22437
+ const placeholder = match[1];
22319
22438
  if (normalise(placeholder) === normKey) {
22320
22439
  validatePathSegment(
22321
22440
  pathTemplate,
@@ -22324,10 +22443,9 @@ var BaseServiceClient = class {
22324
22443
  pathPatterns[placeholder],
22325
22444
  this.serviceName
22326
22445
  );
22327
- return encodePathSegment(stringValue);
22446
+ path = fillPlaceholder(path, placeholder, encodePathSegment(stringValue));
22328
22447
  }
22329
- return match;
22330
- });
22448
+ }
22331
22449
  }
22332
22450
  }
22333
22451
  return path;
@@ -23088,8 +23206,14 @@ var Basecamp2Client = class extends BaseServiceClient {
23088
23206
 
23089
23207
  // src/client.ts
23090
23208
  var _AugurAPI = class _AugurAPI {
23209
+ /**
23210
+ * @throws InvalidArgumentError when `config.siteId` is not a siteId (`isSiteId`: lowercase
23211
+ * letters, digits, `_` and `-`). The config is copied, so changing the caller's object
23212
+ * afterwards cannot put an empty or malformed one into `x-site-id`; use `setSiteId`.
23213
+ */
23091
23214
  constructor(config) {
23092
- this.config = config;
23215
+ assertSiteId(config.siteId);
23216
+ this.config = { ...config };
23093
23217
  }
23094
23218
  /**
23095
23219
  * Every endpoint the SDK exposes, one language-neutral entry each, sorted by id.
@@ -23468,9 +23592,10 @@ var _AugurAPI = class _AugurAPI {
23468
23592
  /**
23469
23593
  * Update site ID
23470
23594
  * @param siteId New site ID
23595
+ * @throws InvalidArgumentError when it is not a siteId (see the constructor)
23471
23596
  */
23472
23597
  setSiteId(siteId) {
23473
- this.config.siteId = siteId;
23598
+ this.config.siteId = assertSiteId(siteId);
23474
23599
  this._joomla = void 0;
23475
23600
  this._commerce = void 0;
23476
23601
  this._pricing = void 0;
@@ -23558,7 +23683,7 @@ function createCrossSiteAuthenticator(augurInfoToken) {
23558
23683
  }
23559
23684
 
23560
23685
  // src/index.ts
23561
- var VERSION = "2026.10.16";
23686
+ var VERSION = "2026.10.17";
23562
23687
  export {
23563
23688
  AgrInfoClient,
23564
23689
  AgrIntClient,
@@ -23601,6 +23726,9 @@ export {
23601
23726
  ValidationError,
23602
23727
  WhoamiDataSchema,
23603
23728
  authenticateUserForSite,
23604
- createCrossSiteAuthenticator
23729
+ createCrossSiteAuthenticator,
23730
+ isReadOnly,
23731
+ isSiteId,
23732
+ parseSiteId
23605
23733
  };
23606
23734
  //# sourceMappingURL=index.mjs.map