@simpleapps-com/augur-api 2026.10.15 → 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.js CHANGED
@@ -71,7 +71,10 @@ __export(index_exports, {
71
71
  ValidationError: () => ValidationError,
72
72
  WhoamiDataSchema: () => WhoamiDataSchema,
73
73
  authenticateUserForSite: () => authenticateUserForSite,
74
- createCrossSiteAuthenticator: () => createCrossSiteAuthenticator
74
+ createCrossSiteAuthenticator: () => createCrossSiteAuthenticator,
75
+ isReadOnly: () => isReadOnly,
76
+ isSiteId: () => isSiteId,
77
+ parseSiteId: () => parseSiteId
75
78
  });
76
79
  module.exports = __toCommonJS(index_exports);
77
80
 
@@ -576,16 +579,99 @@ var HTTPClient = class {
576
579
  }
577
580
  };
578
581
 
579
- // src/core/path-validation.ts
582
+ // src/core/path-encode.ts
583
+ function isHigh(c) {
584
+ return c >= 55296 && c <= 56319;
585
+ }
586
+ function isLow(c) {
587
+ return c >= 56320 && c <= 57343;
588
+ }
589
+ function isUpperHex(c) {
590
+ return c >= 48 && c <= 57 || c >= 65 && c <= 70;
591
+ }
592
+ function isAlnum(c) {
593
+ return c >= 65 && c <= 90 || c >= 97 && c <= 122 || c >= 48 && c <= 57;
594
+ }
595
+ function isMark(c) {
596
+ return c === 45 || c === 46 || c === 95 || c === 126;
597
+ }
598
+ function isDelimOrAt(c) {
599
+ return c === 33 || c === 36 || c >= 38 && c <= 44 || c === 58 || c === 59 || c === 61 || c === 64;
600
+ }
601
+ function isPchar(c) {
602
+ return isAlnum(c) || isMark(c) || isDelimOrAt(c);
603
+ }
604
+ function loneAt(s, k) {
605
+ 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)));
606
+ }
607
+ function isPairAt(s, i) {
608
+ return isHigh(s.charCodeAt(i)) && i + 1 < s.length && isLow(s.charCodeAt(i + 1));
609
+ }
610
+ function okAt(s, k) {
611
+ return isPchar(s.charCodeAt(k)) || s.charCodeAt(k) === 37 && k + 2 < s.length && isUpperHex(s.charCodeAt(k + 1)) && isUpperHex(s.charCodeAt(k + 2));
612
+ }
613
+ function hasLoneSurrogate(value) {
614
+ let i = 0;
615
+ while (i < value.length) {
616
+ if (loneAt(value, i)) return true;
617
+ if (isPairAt(value, i)) {
618
+ i = i + 2;
619
+ } else {
620
+ i = i + 1;
621
+ }
622
+ }
623
+ return false;
624
+ }
625
+ function isEncoded(s) {
626
+ let i = 0;
627
+ while (i < s.length) {
628
+ if (!okAt(s, i)) return false;
629
+ if (s.charCodeAt(i) === 37) {
630
+ i = i + 3;
631
+ } else {
632
+ i = i + 1;
633
+ }
634
+ }
635
+ return true;
636
+ }
637
+
638
+ // src/core/encoded-segment.ts
580
639
  var PCHAR_RESTORE_RE = /%(?:24|26|2B|2C|3B|3D|3A|40)/g;
581
- var LONE_SURROGATE_RE = /[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/;
582
- var encodePathSegment = (value) => encodeURIComponent(value).replace(PCHAR_RESTORE_RE, decodeURIComponent);
640
+ function encodePathSegment(value) {
641
+ const encoded = encodeURIComponent(value).replace(PCHAR_RESTORE_RE, decodeURIComponent);
642
+ if (!isEncoded(encoded)) {
643
+ throw new InvalidArgumentError({
644
+ message: "Encoded path segment has an unexpected shape",
645
+ service: "",
646
+ endpoint: ""
647
+ });
648
+ }
649
+ return encoded;
650
+ }
651
+ function fillPlaceholder(path, placeholder, segment) {
652
+ return path.split(`{${placeholder}}`).join(segment);
653
+ }
654
+ function renderPath(template, segments) {
655
+ return template.replace(/\{([^}]+)\}/g, (_, name) => {
656
+ const segment = segments[name];
657
+ if (segment === void 0) {
658
+ throw new InvalidArgumentError({
659
+ message: `No path value for {${name}}`,
660
+ service: "",
661
+ endpoint: template
662
+ });
663
+ }
664
+ return segment;
665
+ });
666
+ }
667
+
668
+ // src/core/path-validation.ts
583
669
  var pathValueProblem = (value, pattern) => {
584
670
  if (pattern !== void 0 && !new RegExp(pattern).test(value)) {
585
671
  return `expected a value matching ${pattern}`;
586
672
  }
587
673
  if (value === "") return "expected a non-empty string";
588
- return LONE_SURROGATE_RE.test(value) ? "expected a well-formed string" : void 0;
674
+ return hasLoneSurrogate(value) ? "expected a well-formed string" : void 0;
589
675
  };
590
676
  var validatePathSegment = (pathTemplate, name, value, pattern, service = "http-client") => {
591
677
  const problem = pathValueProblem(value, pattern);
@@ -13025,6 +13111,31 @@ var LegacyStateGetParamsSchema = v14.looseObject({
13025
13111
  ...EdgeCacheParamsSchema.entries,
13026
13112
  twoLetterCode: v14.optional(v14.string())
13027
13113
  });
13114
+ var SavedCartsListParamsSchema = v14.looseObject({
13115
+ ...EdgeCacheParamsSchema.entries,
13116
+ limit: v14.optional(v14.pipe(v14.unknown(), v14.transform(Number))),
13117
+ offset: v14.optional(v14.pipe(v14.unknown(), v14.transform(Number))),
13118
+ orderBy: v14.optional(v14.string()),
13119
+ statusCd: v14.optional(
13120
+ v14.union([
13121
+ v14.array(v14.pipe(v14.unknown(), v14.transform(Number))),
13122
+ v14.pipe(v14.unknown(), v14.transform(Number))
13123
+ ])
13124
+ ),
13125
+ userId: v14.optional(v14.pipe(v14.unknown(), v14.transform(Number)))
13126
+ });
13127
+ var SavedCartsItemsListParamsSchema = v14.looseObject({
13128
+ ...EdgeCacheParamsSchema.entries,
13129
+ limit: v14.optional(v14.pipe(v14.unknown(), v14.transform(Number))),
13130
+ offset: v14.optional(v14.pipe(v14.unknown(), v14.transform(Number))),
13131
+ orderBy: v14.optional(v14.string()),
13132
+ statusCd: v14.optional(
13133
+ v14.union([
13134
+ v14.array(v14.pipe(v14.unknown(), v14.transform(Number))),
13135
+ v14.pipe(v14.unknown(), v14.transform(Number))
13136
+ ])
13137
+ )
13138
+ });
13028
13139
  var InvMastAlsoBoughtListDataSchema = v14.array(
13029
13140
  v14.looseObject({
13030
13141
  invMastUid: v14.number(),
@@ -13390,6 +13501,54 @@ var LegacyStateCreateDataSchema = v14.looseObject({
13390
13501
  var LegacyStateGetDataSchema = LegacyStateCreateDataSchema;
13391
13502
  var LegacyStateUpdateDataSchema = LegacyStateCreateDataSchema;
13392
13503
  var LegacyStateDeleteDataSchema = LegacyStateCreateDataSchema;
13504
+ var SavedCartsListDataSchema = v14.array(
13505
+ v14.looseObject({
13506
+ id: v14.number(),
13507
+ userId: v14.number(),
13508
+ oldId: v14.nullable(v14.number()),
13509
+ cartName: v14.string(),
13510
+ cartData: v14.nullable(v14.string()),
13511
+ itemList: v14.nullable(v14.string()),
13512
+ shared: v14.nullable(v14.number()),
13513
+ dateLastModified: v14.string(),
13514
+ dateLastNotify: v14.nullable(v14.string()),
13515
+ dateCreated: v14.nullable(v14.string()),
13516
+ updateCd: v14.number(),
13517
+ statusCd: v14.number(),
13518
+ processCd: v14.number()
13519
+ })
13520
+ );
13521
+ var SavedCartsGetDataSchema = v14.looseObject({
13522
+ id: v14.number(),
13523
+ userId: v14.number(),
13524
+ oldId: v14.nullable(v14.number()),
13525
+ cartName: v14.string(),
13526
+ cartData: v14.nullable(v14.string()),
13527
+ itemList: v14.nullable(v14.string()),
13528
+ shared: v14.nullable(v14.number()),
13529
+ dateLastModified: v14.string(),
13530
+ dateLastNotify: v14.nullable(v14.string()),
13531
+ dateCreated: v14.nullable(v14.string()),
13532
+ updateCd: v14.number(),
13533
+ statusCd: v14.number(),
13534
+ processCd: v14.number()
13535
+ });
13536
+ var SavedCartsItemsListDataSchema = v14.array(
13537
+ v14.looseObject({
13538
+ savedCartsId: v14.number(),
13539
+ keyData: v14.nullable(v14.string()),
13540
+ invMastUid: v14.nullable(v14.number()),
13541
+ qty: v14.nullable(v14.number()),
13542
+ uom: v14.nullable(v14.string()),
13543
+ otherData: v14.nullable(v14.string()),
13544
+ keyNames: v14.nullable(v14.string()),
13545
+ ordering: v14.nullable(v14.number()),
13546
+ savedCartsItemsUid: v14.string(),
13547
+ updateCd: v14.number(),
13548
+ statusCd: v14.number(),
13549
+ processCd: v14.number()
13550
+ })
13551
+ );
13393
13552
  var PassthroughDataSchema13 = v14.record(v14.string(), v14.unknown());
13394
13553
 
13395
13554
  // src/services/legacy/generated/endpoints.ts
@@ -13701,6 +13860,63 @@ var endpoints14 = [
13701
13860
  params: { stateUid: { in: "path", type: "integer", required: true } },
13702
13861
  responseSchema: LegacyStateDeleteDataSchema,
13703
13862
  responseType: "object"
13863
+ },
13864
+ {
13865
+ method: "GET",
13866
+ path: "/saved-carts",
13867
+ chain: "savedCarts",
13868
+ action: "list",
13869
+ aliases: [],
13870
+ pathParams: [],
13871
+ pathPatterns: {},
13872
+ queryParams: ["limit", "offset", "orderBy", "statusCd", "userId"],
13873
+ edgeCache: true,
13874
+ summary: "List Saved Carts",
13875
+ params: {
13876
+ limit: { in: "query", type: "integer", required: false },
13877
+ offset: { in: "query", type: "integer", required: false },
13878
+ orderBy: { in: "query", type: "string", required: false },
13879
+ statusCd: { in: "query", type: "integer|integer[]", required: false },
13880
+ userId: { in: "query", type: "integer", required: false }
13881
+ },
13882
+ responseSchema: SavedCartsListDataSchema,
13883
+ responseType: "array"
13884
+ },
13885
+ {
13886
+ method: "GET",
13887
+ path: "/saved-carts/{id}",
13888
+ chain: "savedCarts",
13889
+ action: "get",
13890
+ aliases: [],
13891
+ pathParams: ["id"],
13892
+ pathPatterns: { id: "^\\d+$" },
13893
+ queryParams: [],
13894
+ edgeCache: true,
13895
+ summary: "Get Saved Cart",
13896
+ params: { id: { in: "path", type: "integer", required: true } },
13897
+ responseSchema: SavedCartsGetDataSchema,
13898
+ responseType: "object"
13899
+ },
13900
+ {
13901
+ method: "GET",
13902
+ path: "/saved-carts/{id}/items",
13903
+ chain: "savedCarts.items",
13904
+ action: "list",
13905
+ aliases: [],
13906
+ pathParams: ["id"],
13907
+ pathPatterns: { id: "^\\d+$" },
13908
+ queryParams: ["limit", "offset", "orderBy", "statusCd"],
13909
+ edgeCache: true,
13910
+ summary: "List Saved Cart Lines",
13911
+ params: {
13912
+ id: { in: "path", type: "integer", required: true },
13913
+ limit: { in: "query", type: "integer", required: false },
13914
+ offset: { in: "query", type: "integer", required: false },
13915
+ orderBy: { in: "query", type: "string", required: false },
13916
+ statusCd: { in: "query", type: "integer|integer[]", required: false }
13917
+ },
13918
+ responseSchema: SavedCartsItemsListDataSchema,
13919
+ responseType: "array"
13704
13920
  }
13705
13921
  ];
13706
13922
 
@@ -22016,6 +22232,9 @@ function resolveEndpoint(id) {
22016
22232
  index ?? (index = buildIndex());
22017
22233
  return index.get(id);
22018
22234
  }
22235
+ function isReadOnly(entry) {
22236
+ return entry.readOnly ?? entry.method === "GET";
22237
+ }
22019
22238
 
22020
22239
  // src/core/call.ts
22021
22240
  var ENVELOPE_KEYS = [
@@ -22056,11 +22275,14 @@ function checkArgs(entry, args) {
22056
22275
  }
22057
22276
  }
22058
22277
  function fillPath(entry, pathParams) {
22059
- return entry.path.replace(/\{([^}]+)\}/g, (_, name) => {
22278
+ const segments = {};
22279
+ for (const match of entry.path.matchAll(/\{([^}]+)\}/g)) {
22280
+ const name = match[1];
22060
22281
  const value = String(pathParams[name]);
22061
22282
  validatePathSegment(entry.path, name, value, entry.pathPatterns[name], entry.service);
22062
- return encodePathSegment(value);
22063
- });
22283
+ segments[name] = encodePathSegment(value);
22284
+ }
22285
+ return renderPath(entry.path, segments);
22064
22286
  }
22065
22287
  function toEnvelope(body) {
22066
22288
  if (typeof body !== "object" || body === null || Array.isArray(body)) {
@@ -22089,6 +22311,36 @@ async function callEndpoint(config, id, args = {}) {
22089
22311
  return { httpStatus: raw.status, envelope: toEnvelope(body), body };
22090
22312
  }
22091
22313
 
22314
+ // src/core/site-id-check.ts
22315
+ function isSiteChar(c) {
22316
+ return c >= 97 && c <= 122 || c >= 48 && c <= 57 || c === 95 || c === 45;
22317
+ }
22318
+ function isSiteId(s) {
22319
+ if (s.length === 0) return false;
22320
+ let i = 0;
22321
+ while (i < s.length) {
22322
+ if (!isSiteChar(s.charCodeAt(i))) return false;
22323
+ i = i + 1;
22324
+ }
22325
+ return true;
22326
+ }
22327
+
22328
+ // src/core/site-id.ts
22329
+ function parseSiteId(value) {
22330
+ return isSiteId(value) ? value : void 0;
22331
+ }
22332
+ function assertSiteId(value) {
22333
+ const site = parseSiteId(value);
22334
+ if (site === void 0) {
22335
+ throw new InvalidArgumentError({
22336
+ message: "Invalid siteId: expected lowercase letters, digits, '_' and '-' (e.g. ampro-online)",
22337
+ service: "",
22338
+ endpoint: ""
22339
+ });
22340
+ }
22341
+ return site;
22342
+ }
22343
+
22092
22344
  // src/core/common-schemas.ts
22093
22345
  var CommonHealthCheckResponseSchema = BaseResponseSchema(HealthCheckDataSchema);
22094
22346
  var CommonPingResponseSchema = BaseResponseSchema(PingDataSchema);
@@ -22258,11 +22510,11 @@ var BaseServiceClient = class {
22258
22510
  const stringValue = String(value);
22259
22511
  if (path.includes(`{${key}}`)) {
22260
22512
  validatePathSegment(pathTemplate, key, stringValue, pathPatterns[key], this.serviceName);
22261
- const encoded = encodePathSegment(stringValue);
22262
- path = path.replace(`{${key}}`, () => encoded);
22513
+ path = fillPlaceholder(path, key, encodePathSegment(stringValue));
22263
22514
  } else {
22264
22515
  const normKey = normalise(key);
22265
- path = path.replace(/\{([^}]+)\}/g, (match, placeholder) => {
22516
+ for (const match of new Set(path.matchAll(/\{([^}]+)\}/g))) {
22517
+ const placeholder = match[1];
22266
22518
  if (normalise(placeholder) === normKey) {
22267
22519
  validatePathSegment(
22268
22520
  pathTemplate,
@@ -22271,10 +22523,9 @@ var BaseServiceClient = class {
22271
22523
  pathPatterns[placeholder],
22272
22524
  this.serviceName
22273
22525
  );
22274
- return encodePathSegment(stringValue);
22526
+ path = fillPlaceholder(path, placeholder, encodePathSegment(stringValue));
22275
22527
  }
22276
- return match;
22277
- });
22528
+ }
22278
22529
  }
22279
22530
  }
22280
22531
  return path;
@@ -22598,9 +22849,11 @@ var LegacyClient = class extends BaseServiceClient {
22598
22849
  this.invMast = proxy.invMast;
22599
22850
  this.itemCategory = proxy.itemCategory;
22600
22851
  this.legacy = proxy.legacy;
22852
+ this.savedCarts = proxy.savedCarts;
22601
22853
  this.invMastData = dataProxy.invMast;
22602
22854
  this.itemCategoryData = dataProxy.itemCategory;
22603
22855
  this.legacyData = dataProxy.legacy;
22856
+ this.savedCartsData = dataProxy.savedCarts;
22604
22857
  }
22605
22858
  };
22606
22859
 
@@ -23033,8 +23286,14 @@ var Basecamp2Client = class extends BaseServiceClient {
23033
23286
 
23034
23287
  // src/client.ts
23035
23288
  var _AugurAPI = class _AugurAPI {
23289
+ /**
23290
+ * @throws InvalidArgumentError when `config.siteId` is not a siteId (`isSiteId`: lowercase
23291
+ * letters, digits, `_` and `-`). The config is copied, so changing the caller's object
23292
+ * afterwards cannot put an empty or malformed one into `x-site-id`; use `setSiteId`.
23293
+ */
23036
23294
  constructor(config) {
23037
- this.config = config;
23295
+ assertSiteId(config.siteId);
23296
+ this.config = { ...config };
23038
23297
  }
23039
23298
  /**
23040
23299
  * Every endpoint the SDK exposes, one language-neutral entry each, sorted by id.
@@ -23413,9 +23672,10 @@ var _AugurAPI = class _AugurAPI {
23413
23672
  /**
23414
23673
  * Update site ID
23415
23674
  * @param siteId New site ID
23675
+ * @throws InvalidArgumentError when it is not a siteId (see the constructor)
23416
23676
  */
23417
23677
  setSiteId(siteId) {
23418
- this.config.siteId = siteId;
23678
+ this.config.siteId = assertSiteId(siteId);
23419
23679
  this._joomla = void 0;
23420
23680
  this._commerce = void 0;
23421
23681
  this._pricing = void 0;
@@ -23503,7 +23763,7 @@ function createCrossSiteAuthenticator(augurInfoToken) {
23503
23763
  }
23504
23764
 
23505
23765
  // src/index.ts
23506
- var VERSION = "2026.10.15";
23766
+ var VERSION = "2026.10.17";
23507
23767
  // Annotate the CommonJS export names for ESM import in node:
23508
23768
  0 && (module.exports = {
23509
23769
  AgrInfoClient,
@@ -23547,6 +23807,9 @@ var VERSION = "2026.10.15";
23547
23807
  ValidationError,
23548
23808
  WhoamiDataSchema,
23549
23809
  authenticateUserForSite,
23550
- createCrossSiteAuthenticator
23810
+ createCrossSiteAuthenticator,
23811
+ isReadOnly,
23812
+ isSiteId,
23813
+ parseSiteId
23551
23814
  });
23552
23815
  //# sourceMappingURL=index.js.map