@simpleapps-com/augur-server 2026.11.4 → 2026.11.6

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.
Files changed (80) hide show
  1. package/EXPORTS.md +28 -1
  2. package/README.md +42 -14
  3. package/dist/actions/action-rules.d.ts +99 -0
  4. package/dist/actions/action-rules.d.ts.map +1 -0
  5. package/dist/actions/agr-site.d.ts +7 -15
  6. package/dist/actions/agr-site.d.ts.map +1 -1
  7. package/dist/actions/commerce.d.ts.map +1 -1
  8. package/dist/actions/customers.d.ts +12 -15
  9. package/dist/actions/customers.d.ts.map +1 -1
  10. package/dist/actions/favorites.d.ts +9 -12
  11. package/dist/actions/favorites.d.ts.map +1 -1
  12. package/dist/actions/gregorovich.d.ts +7 -15
  13. package/dist/actions/gregorovich.d.ts.map +1 -1
  14. package/dist/actions/items.d.ts +8 -20
  15. package/dist/actions/items.d.ts.map +1 -1
  16. package/dist/actions/joomla.d.ts +8 -14
  17. package/dist/actions/joomla.d.ts.map +1 -1
  18. package/dist/actions/legacy.d.ts +10 -20
  19. package/dist/actions/legacy.d.ts.map +1 -1
  20. package/dist/actions/orders.d.ts +7 -14
  21. package/dist/actions/orders.d.ts.map +1 -1
  22. package/dist/actions/read-specs.d.ts +119 -0
  23. package/dist/actions/read-specs.d.ts.map +1 -0
  24. package/dist/actions/site.d.ts.map +1 -1
  25. package/dist/actions/vmi.d.ts +10 -16
  26. package/dist/actions/vmi.d.ts.map +1 -1
  27. package/dist/actions/wishlists.d.ts +11 -13
  28. package/dist/actions/wishlists.d.ts.map +1 -1
  29. package/dist/api.js +3 -2
  30. package/dist/api.js.map +1 -1
  31. package/dist/auth.js +3 -2
  32. package/dist/cache/redis-client.d.ts.map +1 -1
  33. package/dist/cache/redis-rules.d.ts +21 -0
  34. package/dist/cache/redis-rules.d.ts.map +1 -0
  35. package/dist/cache/spec-read.d.ts +39 -0
  36. package/dist/cache/spec-read.d.ts.map +1 -0
  37. package/dist/cache/with-cache.d.ts +2 -2
  38. package/dist/cache/with-cache.d.ts.map +1 -1
  39. package/dist/{chunk-WR7WT2FI.js → chunk-2RAKVFB5.js} +30 -9
  40. package/dist/chunk-2RAKVFB5.js.map +1 -0
  41. package/dist/{chunk-F7QWHMHH.js → chunk-4JPJQHT6.js} +2 -2
  42. package/dist/chunk-JIYVQWXK.js +10 -0
  43. package/dist/chunk-JIYVQWXK.js.map +1 -0
  44. package/dist/{chunk-34NCJS52.js → chunk-SFXO74RC.js} +874 -719
  45. package/dist/chunk-SFXO74RC.js.map +1 -0
  46. package/dist/chunk-V76GZZF3.js +66 -0
  47. package/dist/chunk-V76GZZF3.js.map +1 -0
  48. package/dist/{chunk-B4MGIUCU.js → chunk-Z53NEFEQ.js} +17 -16
  49. package/dist/chunk-Z53NEFEQ.js.map +1 -0
  50. package/dist/hooks.js +3 -2
  51. package/dist/hooks.js.map +1 -1
  52. package/dist/index.js +4 -2
  53. package/dist/index.js.map +1 -1
  54. package/dist/query-action.d.ts +24 -1
  55. package/dist/query-action.d.ts.map +1 -1
  56. package/dist/query-action.js +7 -2
  57. package/dist/read-rules.d.ts +45 -0
  58. package/dist/read-rules.d.ts.map +1 -0
  59. package/dist/rules.d.ts +16 -0
  60. package/dist/rules.d.ts.map +1 -1
  61. package/dist/server-site-registry.d.ts.map +1 -1
  62. package/dist/server-site.d.ts.map +1 -1
  63. package/dist/site.js +24 -14
  64. package/dist/site.js.map +1 -1
  65. package/dist/sitemap-rules.d.ts +154 -0
  66. package/dist/sitemap-rules.d.ts.map +1 -0
  67. package/dist/sitemap.d.ts +80 -0
  68. package/dist/sitemap.d.ts.map +1 -0
  69. package/dist/sitemap.js +242 -0
  70. package/dist/sitemap.js.map +1 -0
  71. package/dist/testing.js +4 -2
  72. package/dist/testing.js.map +1 -1
  73. package/dist/utils/read-all-pages.d.ts +17 -0
  74. package/dist/utils/read-all-pages.d.ts.map +1 -0
  75. package/llms.txt +54 -1
  76. package/package.json +9 -5
  77. package/dist/chunk-34NCJS52.js.map +0 -1
  78. package/dist/chunk-B4MGIUCU.js.map +0 -1
  79. package/dist/chunk-WR7WT2FI.js.map +0 -1
  80. /package/dist/{chunk-F7QWHMHH.js.map → chunk-4JPJQHT6.js.map} +0 -0
@@ -1,3 +1,6 @@
1
+ import {
2
+ decimal
3
+ } from "./chunk-JIYVQWXK.js";
1
4
  import {
2
5
  cacheTtlOf,
3
6
  circuitCheck,
@@ -7,6 +10,7 @@ import {
7
10
  hasDocKey,
8
11
  hasMoreOf,
9
12
  itemsLimitOf,
13
+ minutes,
10
14
  nextCursorOf,
11
15
  opensAt,
12
16
  positiveOrZero,
@@ -15,10 +19,14 @@ import {
15
19
  registerSdkCallWrapper,
16
20
  registerSdkClient,
17
21
  scopedPrefix,
22
+ seconds,
18
23
  shouldCache,
19
24
  takesItemId,
20
25
  ttlFor
21
- } from "./chunk-B4MGIUCU.js";
26
+ } from "./chunk-Z53NEFEQ.js";
27
+ import {
28
+ upperAscii
29
+ } from "./chunk-V76GZZF3.js";
22
30
 
23
31
  // src/environment.ts
24
32
  function getEnvironment() {
@@ -37,8 +45,36 @@ var isStaging = env === "staging";
37
45
  var isProduction = env === "production";
38
46
 
39
47
  // src/cache/redis-client.ts
40
- import { millis, minutes } from "@simpleapps-com/augur-utils";
41
- var CIRCUIT_BREAKER_RESET = minutes(1);
48
+ import { millis, minutes as minutes2 } from "@simpleapps-com/augur-utils";
49
+
50
+ // src/cache/redis-rules.ts
51
+ function redisUrl(servers, isDev2, isStaging2, dev, staging, prod) {
52
+ if (servers !== "") return "redis://" + servers;
53
+ if (isDev2) return dev;
54
+ if (isStaging2) return staging;
55
+ return prod;
56
+ }
57
+ function debugEnabled(isDev2, isStaging2) {
58
+ return isDev2 || isStaging2;
59
+ }
60
+ function wasOpen(openUntil) {
61
+ return openUntil !== 0;
62
+ }
63
+ function justClosed(wasOpenBefore, open) {
64
+ return wasOpenBefore && !open;
65
+ }
66
+ function circuitLabel(open) {
67
+ return open ? "open" : "closed";
68
+ }
69
+ function isReady(status) {
70
+ return status === "ready";
71
+ }
72
+ function isHit(cached) {
73
+ return cached !== null;
74
+ }
75
+
76
+ // src/cache/redis-client.ts
77
+ var CIRCUIT_BREAKER_RESET = minutes2(1);
42
78
  var g = globalThis;
43
79
  if (!g.__redisState) {
44
80
  g.__redisState = {
@@ -48,9 +84,9 @@ if (!g.__redisState) {
48
84
  };
49
85
  }
50
86
  var state = g.__redisState;
51
- var debugEnabled = isDev || isStaging;
87
+ var debugOn = debugEnabled(isDev, isStaging);
52
88
  function log(...args) {
53
- if (debugEnabled) {
89
+ if (debugOn) {
54
90
  console.log("[Redis]", ...args);
55
91
  }
56
92
  }
@@ -62,10 +98,10 @@ function setCircuit(next) {
62
98
  state.circuitOpenUntil = next.openUntil;
63
99
  }
64
100
  function isCircuitOpen() {
65
- const wasOpen = state.circuitOpenUntil !== 0;
101
+ const openBefore = wasOpen(state.circuitOpenUntil);
66
102
  const answer = circuitCheck(circuit(), millis(Date.now()));
67
103
  setCircuit(answer.next);
68
- if (wasOpen && !answer.open) log("Circuit breaker reset -- retrying Redis");
104
+ if (justClosed(openBefore, answer.open)) log("Circuit breaker reset -- retrying Redis");
69
105
  return answer.open;
70
106
  }
71
107
  function recordFailure() {
@@ -78,11 +114,14 @@ function recordSuccess() {
78
114
  setCircuit(recordSuccessOf(circuit()));
79
115
  }
80
116
  function getRedisUrl() {
81
- const containerRedis = process.env["REDIS_SERVERS"];
82
- if (containerRedis) return `redis://${containerRedis}`;
83
- if (isDev) return process.env["REDIS_URL_DEV"];
84
- if (isStaging) return process.env["REDIS_URL_STAGING"];
85
- return process.env["REDIS_URL_PROD"];
117
+ return redisUrl(
118
+ process.env["REDIS_SERVERS"] ?? "",
119
+ isDev,
120
+ isStaging,
121
+ process.env["REDIS_URL_DEV"],
122
+ process.env["REDIS_URL_STAGING"],
123
+ process.env["REDIS_URL_PROD"]
124
+ );
86
125
  }
87
126
  async function getClient() {
88
127
  if (state.client) return state.client;
@@ -137,10 +176,10 @@ async function cacheSet(key, value, ttl) {
137
176
  }
138
177
  }
139
178
  function getCircuitState() {
140
- return isCircuitOpen() ? "open" : "closed";
179
+ return circuitLabel(isCircuitOpen());
141
180
  }
142
181
  function isRedisConnected() {
143
- return state.client?.status === "ready";
182
+ return isReady(state.client?.status ?? "");
144
183
  }
145
184
 
146
185
  // src/sdk-call.ts
@@ -184,16 +223,53 @@ async function batchFetch(params, fetchOne, getKey) {
184
223
  return out;
185
224
  }
186
225
 
226
+ // src/read-rules.ts
227
+ function pageSize() {
228
+ return 100;
229
+ }
230
+ function pageCap() {
231
+ return 50;
232
+ }
233
+ function continues(pageLength, pagesRead, cap) {
234
+ return pageLength > 0 && pagesRead < cap;
235
+ }
236
+ function nextOffset(offset, pageLength) {
237
+ return offset + pageLength;
238
+ }
239
+ function capReached(lastPageLength, pagesRead, cap) {
240
+ return lastPageLength > 0 && pagesRead >= cap;
241
+ }
242
+ function readThroughTtl(missing, noCachePath, p21Path, ttl) {
243
+ if (noCachePath) return seconds(0);
244
+ if (p21Path && !missing) return minutes(1);
245
+ return cacheTtlOf(missing, ttl);
246
+ }
247
+ function serverTtlOf(hasRedisTtl, isP21, staleTime, redisTtl, longRedisTtl) {
248
+ if (!hasRedisTtl) return null;
249
+ if (isP21) return minutes(1);
250
+ return ttlFor(staleTime, redisTtl, longRedisTtl);
251
+ }
252
+
187
253
  // src/cache/with-cache.ts
188
- import { buildCacheKey, buildRawCacheKey } from "@simpleapps-com/augur-core";
189
- import { seconds } from "@simpleapps-com/augur-utils";
190
- async function readThrough(redisTtl, keyOf, fn) {
191
- const ttl = cacheTtlOf(redisTtl === void 0 || Number.isNaN(redisTtl), redisTtl ?? seconds(0));
254
+ import {
255
+ buildCacheKey,
256
+ buildRawCacheKey,
257
+ isP21Path,
258
+ isServerNoCachePath
259
+ } from "@simpleapps-com/augur-core";
260
+ import { seconds as seconds2 } from "@simpleapps-com/augur-utils";
261
+ async function readThrough(redisTtl, methodPath, keyOf, fn) {
262
+ const ttl = readThroughTtl(
263
+ redisTtl === void 0 || Number.isNaN(redisTtl),
264
+ isServerNoCachePath(methodPath),
265
+ isP21Path(methodPath),
266
+ redisTtl ?? seconds2(0)
267
+ );
192
268
  if (!shouldCache(ttl)) return fn();
193
269
  const key = keyOf();
194
270
  try {
195
271
  const cached = await cacheGet(key);
196
- if (cached != null) return JSON.parse(cached);
272
+ if (isHit(cached)) return JSON.parse(cached);
197
273
  } catch {
198
274
  }
199
275
  const result = await fn();
@@ -204,12 +280,13 @@ async function readThrough(redisTtl, keyOf, fn) {
204
280
  }
205
281
  return result;
206
282
  }
207
- async function withServerCache(prefix, redisTtl, methodPath, fn, ...keyArgs) {
208
- return readThrough(redisTtl, () => buildCacheKey(prefix, methodPath, keyArgs), fn);
209
- }
210
- async function withRawSdkCache(prefix, redisTtl, methodPath, fn, ...keyArgs) {
211
- return readThrough(redisTtl, () => buildRawCacheKey(prefix, methodPath, keyArgs), fn);
283
+ function cachedUnder(keyOf) {
284
+ return async function cached(prefix, redisTtl, methodPath, fn, ...keyArgs) {
285
+ return readThrough(redisTtl, methodPath, () => keyOf(prefix, methodPath, keyArgs), fn);
286
+ };
212
287
  }
288
+ var withServerCache = cachedUnder(buildCacheKey);
289
+ var withRawSdkCache = cachedUnder(buildRawCacheKey);
213
290
 
214
291
  // src/pagination.ts
215
292
  function paginateOffset(items, pageParam, limit, total) {
@@ -225,8 +302,114 @@ function paginateOffset(items, pageParam, limit, total) {
225
302
  // src/actions/site.ts
226
303
  import { createActionsProxy } from "@simpleapps-com/augur-core";
227
304
 
305
+ // src/actions/action-rules.ts
306
+ function insertBySeqFrom(x, xs, k) {
307
+ if (k === xs.length) return [x];
308
+ const first = xs[k];
309
+ if (x.seqNo <= first.seqNo) return [x, ...xs.slice(k)];
310
+ return [first, ...insertBySeqFrom(x, xs, k + 1)];
311
+ }
312
+ function sortBySeqFrom(xs, k) {
313
+ if (k === xs.length) return [];
314
+ return insertBySeqFrom(xs[k], sortBySeqFrom(xs, k + 1), 0);
315
+ }
316
+ function categoryChildren(sortChildren, xs) {
317
+ return sortChildren ? sortBySeqFrom(xs, 0) : xs;
318
+ }
319
+ function firstGiven(given, fallback) {
320
+ return given !== void 0 ? given : fallback;
321
+ }
322
+ function textOr(given, fallback) {
323
+ return given !== void 0 ? given : fallback;
324
+ }
325
+ function categoryArgKind(filtersIsArray, sortByIsString) {
326
+ if (filtersIsArray) return "typedFilters";
327
+ return sortByIsString ? "rawPrefixed" : "rawAsGiven";
328
+ }
329
+ function givenLimit(given, isNan) {
330
+ return isNan ? void 0 : given;
331
+ }
332
+ function totalOrZero(total, isNan) {
333
+ if (isNan || total === void 0) return 0;
334
+ return total;
335
+ }
336
+ function docItemId(itemId) {
337
+ return upperAscii(itemId).trim();
338
+ }
339
+ function sentItemId(itemId, taken) {
340
+ if (taken && itemId !== void 0) return docItemId(itemId);
341
+ return void 0;
342
+ }
343
+ function docBatchKey(itemId, uid) {
344
+ return itemId !== void 0 ? itemId : decimal(uid);
345
+ }
346
+ function cartIdsPresent(hasContact, hasCustomer) {
347
+ return hasContact && hasCustomer;
348
+ }
349
+ function cartUserId(n, isNan) {
350
+ return isNan ? 0 : n;
351
+ }
352
+ function lineUom(converted, uom) {
353
+ return converted !== void 0 ? converted : uom;
354
+ }
355
+ function contentByAlias(alias) {
356
+ return alias !== "";
357
+ }
358
+ function catIdParam(catId) {
359
+ if (catId === void 0 || catId === 0) return void 0;
360
+ return catId;
361
+ }
362
+ function directChildrenFrom(items, parentId, k) {
363
+ if (k === items.length) return [];
364
+ const item = items[k];
365
+ const rest = directChildrenFrom(items, parentId, k + 1);
366
+ return item.parentId === parentId ? [item, ...rest] : rest;
367
+ }
368
+ function nonEmptyTitlesFrom(titles, k) {
369
+ if (k === titles.length) return [];
370
+ const title = titles[k];
371
+ const rest = nonEmptyTitlesFrom(titles, k + 1);
372
+ return title !== "" ? [title, ...rest] : rest;
373
+ }
374
+ function profileId(id) {
375
+ return decimal(id);
376
+ }
377
+ function oneUid(uid) {
378
+ return [uid];
379
+ }
380
+ function sitePrefix(siteId) {
381
+ return siteId === "" ? "" : scopedPrefix(siteId);
382
+ }
383
+ function prefixOnlyService(service) {
384
+ return service === "smartyStreets" || service === "avalara" || service === "agrWork" || service === "payments";
385
+ }
386
+ function longService(service) {
387
+ return service === "items" || service === "legacy" || service === "logistics" || service === "p21Core" || service === "agrInfo" || service === "basecamp2";
388
+ }
389
+ function bundleOf(service) {
390
+ if (service === "commerce") return "noCacheConfig";
391
+ if (prefixOnlyService(service)) return "prefixOnly";
392
+ if (longService(service)) return "longBundle";
393
+ if (service === "agrSite") return "longOnly";
394
+ return "shortBundle";
395
+ }
396
+ function serviceRoute(isSymbol, memoHit, hasOwn) {
397
+ if (isSymbol) return "noRoute";
398
+ if (memoHit) return "memo";
399
+ if (hasOwn) return "legacy";
400
+ return "fallback";
401
+ }
402
+ function methodRoute(isSymbol, inService) {
403
+ if (isSymbol) return "noRoute";
404
+ if (inService) return "legacy";
405
+ return "fallback";
406
+ }
407
+ function wrapCaches(isRead, hasTtl, ttl) {
408
+ return isRead && hasTtl && ttl > 0;
409
+ }
410
+
228
411
  // src/actions/pricing.ts
229
- import { hours, minutes as minutes2 } from "@simpleapps-com/augur-utils";
412
+ import { hours, minutes as minutes3 } from "@simpleapps-com/augur-utils";
230
413
  function resolveCustomerId(explicit, fallback) {
231
414
  return positiveOrZero(Number(explicit ?? fallback));
232
415
  }
@@ -236,7 +419,7 @@ function createPricingActions(api, config = {}) {
236
419
  cachePrefix = "",
237
420
  edgeCache = 2,
238
421
  redisTtl = hours(1),
239
- taxRedisTtl = minutes2(30)
422
+ taxRedisTtl = minutes3(30)
240
423
  } = config;
241
424
  async function getItemPrice(itemId, customerId, quantity = 1) {
242
425
  const custId = resolveCustomerId(customerId, defaultCustomerId);
@@ -282,54 +465,293 @@ function createPricingActions(api, config = {}) {
282
465
  }
283
466
 
284
467
  // src/actions/items.ts
285
- import { hours as hours2 } from "@simpleapps-com/augur-utils";
286
468
  import { categorySortBy } from "@simpleapps-com/augur-utils";
469
+
470
+ // src/cache/spec-read.ts
471
+ import {
472
+ resolveMethod,
473
+ stripEdgeCacheForNoCachePaths
474
+ } from "@simpleapps-com/augur-core";
475
+ import { hours as hours2, minutes as minutes4 } from "@simpleapps-com/augur-utils";
476
+
477
+ // src/actions/read-specs.ts
478
+ function readSpec(sdkPath, keySuffix, tier, paging, top) {
479
+ return { sdkPath, keySuffix, tier, paging, top };
480
+ }
481
+ function keyPath(spec) {
482
+ return spec.keySuffix === "" ? spec.sdkPath : spec.sdkPath + "." + spec.keySuffix;
483
+ }
484
+ function tierRedis(tier, redisTtl, longRedisTtl, shortRedisTtl) {
485
+ if (tier === "long") return longRedisTtl;
486
+ if (tier === "shortRedis") return shortRedisTtl;
487
+ return redisTtl;
488
+ }
489
+ function edgeChoice(tier) {
490
+ if (tier === "long") return "longEdge";
491
+ if (tier === "itemEdge") return "fourHours";
492
+ if (tier === "shortNoEdge") return "noEdge";
493
+ return "shortEdge";
494
+ }
495
+ function edgeValueOf(choice, edge, longEdge, fourHours) {
496
+ if (choice === "noEdge") return void 0;
497
+ if (choice === "longEdge") return longEdge;
498
+ if (choice === "fourHours") return fourHours;
499
+ return edge;
500
+ }
501
+ function sentShape(hasParams, hasEdge) {
502
+ if (!hasParams) return "argsOnly";
503
+ return hasEdge ? "withParamsAndEdge" : "withParams";
504
+ }
505
+ function limitSent(paging, top, size) {
506
+ if (paging === "all") return size;
507
+ if (paging === "top") return top;
508
+ return void 0;
509
+ }
510
+ function categoryLookupRead() {
511
+ return readSpec("items.categories.lookup.get", "", "short", "one", 0);
512
+ }
513
+ function categoryRead() {
514
+ return readSpec("items.categories.get", "", "short", "one", 0);
515
+ }
516
+ function categoryItemsRead() {
517
+ return readSpec("items.categories.items.list", "", "short", "caller", 0);
518
+ }
519
+ function categoryAttributesRead() {
520
+ return readSpec("items.categories.attributes.list", "", "short", "one", 0);
521
+ }
522
+ function invMastRead() {
523
+ return readSpec("items.invMast.get", "", "itemEdge", "one", 0);
524
+ }
525
+ function invMastDocRead() {
526
+ return readSpec("items.invMast.doc.list", "", "itemEdge", "one", 0);
527
+ }
528
+ function stockRead() {
529
+ return readSpec("items.invMast.stock.get", "", "short", "one", 0);
530
+ }
531
+ function stockSummaryRead() {
532
+ return readSpec("items.invMast.stock.get", "companySummary", "short", "one", 0);
533
+ }
534
+ function faqsRead() {
535
+ return readSpec("items.invMast.faq.list", "", "long", "all", 0);
536
+ }
537
+ function substitutesRead() {
538
+ return readSpec("items.invMast.invSub.list", "", "long", "all", 0);
539
+ }
540
+ function accessoriesRead() {
541
+ return readSpec("items.invMast.invAccessory.list", "", "short", "all", 0);
542
+ }
543
+ function similarRead() {
544
+ return readSpec("items.invMast.similar.list", "", "long", "one", 0);
545
+ }
546
+ function customerLookupRead() {
547
+ return readSpec("customers.customer.lookup.get", "", "short", "caller", 0);
548
+ }
549
+ function customerDocRead() {
550
+ return readSpec("customers.customer.doc.get", "", "short", "one", 0);
551
+ }
552
+ function customerOrdersRead() {
553
+ return readSpec("customers.customer.orders.list", "", "short", "caller", 0);
554
+ }
555
+ function customerOrderRead() {
556
+ return readSpec("customers.customer.orders.get", "", "short", "one", 0);
557
+ }
558
+ function customerInvoicesRead() {
559
+ return readSpec("customers.customer.invoices.list", "", "short", "caller", 0);
560
+ }
561
+ function customerInvoiceRead() {
562
+ return readSpec("customers.customer.invoices.get", "", "short", "one", 0);
563
+ }
564
+ function customerQuotesRead() {
565
+ return readSpec("customers.customer.quotes.list", "", "short", "caller", 0);
566
+ }
567
+ function customerQuoteRead() {
568
+ return readSpec("customers.customer.quotes.get", "", "short", "one", 0);
569
+ }
570
+ function shipToRead() {
571
+ return readSpec("customers.customer.shipTo.list", "", "short", "all", 0);
572
+ }
573
+ function warehousesRead() {
574
+ return readSpec("vmi.warehouse.list", "", "short", "caller", 0);
575
+ }
576
+ function availabilityRead() {
577
+ return readSpec("vmi.warehouse.availability.list", "", "shortRedis", "caller", 0);
578
+ }
579
+ function distributorsRead() {
580
+ return readSpec("vmi.distributors.list", "", "short", "caller", 0);
581
+ }
582
+ function productsRead() {
583
+ return readSpec("vmi.products.list", "", "short", "caller", 0);
584
+ }
585
+ function inventoryProfilesRead() {
586
+ return readSpec("vmi.invProfileHdr.list", "", "short", "caller", 0);
587
+ }
588
+ function restockHeadersRead() {
589
+ return readSpec("vmi.restockHdr.list", "", "short", "caller", 0);
590
+ }
591
+ function sectionsRead() {
592
+ return readSpec("vmi.sections.list", "", "short", "caller", 0);
593
+ }
594
+ function wishlistsRead() {
595
+ return readSpec("items.itemWishlist.get", "", "short", "all", 0);
596
+ }
597
+ function wishlistLinesRead() {
598
+ return readSpec("items.itemWishlist.hdr.get", "", "short", "all", 0);
599
+ }
600
+ function favoritesRead() {
601
+ return readSpec("items.itemFavorites.items.list", "", "short", "all", 0);
602
+ }
603
+ function contentRead() {
604
+ return readSpec("joomla.content.doc.get", "", "short", "one", 0);
605
+ }
606
+ function contentListRead() {
607
+ return readSpec("joomla.content.list", "", "short", "caller", 0);
608
+ }
609
+ function menuRead() {
610
+ return readSpec("joomla.menu.list", "", "short", "all", 0);
611
+ }
612
+ function menuListRead() {
613
+ return readSpec("joomla.menu.list", "", "short", "caller", 0);
614
+ }
615
+ function menuDocRead() {
616
+ return readSpec("joomla.menu.doc.get", "", "shortNoEdge", "one", 0);
617
+ }
618
+ function userProfileRead() {
619
+ return readSpec("joomla.users.doc.get", "", "short", "one", 0);
620
+ }
621
+ function webDescRead() {
622
+ return readSpec("legacy.invMast.webDesc.list", "", "short", "one", 0);
623
+ }
624
+ function legacyAlsoBoughtRead() {
625
+ return readSpec("legacy.invMast.alsoBought.list", "", "short", "one", 0);
626
+ }
627
+ function tagsRead() {
628
+ return readSpec("legacy.invMast.tags.list", "", "short", "all", 0);
629
+ }
630
+ function statesRead() {
631
+ return readSpec("legacy.legacy.state.list", "", "long", "all", 0);
632
+ }
633
+ function settingsRead() {
634
+ return readSpec("agrSite.settings.list", "", "long", "all", 0);
635
+ }
636
+ function robotsRead() {
637
+ return readSpec("agrSite.metaFiles.robots.list", "", "long", "one", 0);
638
+ }
639
+ function orderDocRead() {
640
+ return readSpec("orders.oeHdr.doc.get", "", "short", "one", 0);
641
+ }
642
+ function documentsRead() {
643
+ return readSpec("gregorovich.documents.list", "", "shortNoEdge", "all", 0);
644
+ }
645
+ function cartAlsoBoughtRead() {
646
+ return readSpec("commerce.cartHdr.alsoBought.list", "", "short", "top", 10);
647
+ }
648
+
649
+ // src/utils/read-all-pages.ts
650
+ async function readAllPages(fetchPage, size = pageSize(), cap = pageCap()) {
651
+ const rows = [];
652
+ let offset = 0;
653
+ let pagesRead = 0;
654
+ for (; ; ) {
655
+ const page = await fetchPage(offset, size);
656
+ rows.push(...page);
657
+ pagesRead = pagesRead + 1;
658
+ if (!continues(page.length, pagesRead, cap)) {
659
+ return { rows, capReached: capReached(page.length, pagesRead, cap) };
660
+ }
661
+ offset = nextOffset(offset, page.length);
662
+ }
663
+ }
664
+
665
+ // src/cache/spec-read.ts
666
+ function settled(c) {
667
+ return {
668
+ cachePrefix: c.cachePrefix ?? "",
669
+ edgeCache: c.edgeCache ?? 1,
670
+ longEdgeCache: c.longEdgeCache ?? 8,
671
+ redisTtl: c.redisTtl ?? hours2(1),
672
+ longRedisTtl: c.longRedisTtl ?? hours2(8),
673
+ shortRedisTtl: c.shortRedisTtl ?? minutes4(5)
674
+ };
675
+ }
676
+ function sentArgs(spec, c, args, params) {
677
+ const edge = edgeValueOf(edgeChoice(spec.tier), c.edgeCache, c.longEdgeCache, 4);
678
+ const shape = sentShape(params !== void 0, edge !== void 0);
679
+ if (shape === "argsOnly") return args;
680
+ if (shape === "withParams") return [...args, params];
681
+ return [...args, { ...params, edgeCache: edge }];
682
+ }
683
+ function call(api, spec, c, args, params) {
684
+ const method = resolveMethod(api, spec.sdkPath.split("."));
685
+ const sent = sentArgs(spec, c, args, params);
686
+ return method(...stripEdgeCacheForNoCachePaths(spec.sdkPath, sent));
687
+ }
688
+ async function readBy(api, spec, c, args, params) {
689
+ if (spec.paging === "all") {
690
+ const all = await readAllPages(async (offset, size) => {
691
+ const limit2 = limitSent(spec.paging, spec.top, size);
692
+ const page = await call(api, spec, c, args, { ...params, limit: limit2, offset });
693
+ return toListResult(page).data;
694
+ });
695
+ return { data: all.rows, total: all.rows.length, capReached: all.capReached };
696
+ }
697
+ const limit = limitSent(spec.paging, spec.top, 0);
698
+ if (limit === void 0) return call(api, spec, c, args, params);
699
+ return call(api, spec, c, args, { ...params, limit });
700
+ }
701
+ function specRead(api, spec, config, args, params, keyArgs, shape) {
702
+ const c = settled(config);
703
+ return withServerCache(
704
+ c.cachePrefix,
705
+ tierRedis(spec.tier, c.redisTtl, c.longRedisTtl, c.shortRedisTtl),
706
+ keyPath(spec),
707
+ async () => shape(await readBy(api, spec, c, args, params)),
708
+ ...keyArgs
709
+ );
710
+ }
711
+ function asList(answer) {
712
+ return toListResult(answer);
713
+ }
714
+ function asAllRows(answer) {
715
+ return answer;
716
+ }
717
+ function asData(answer) {
718
+ return answer.data;
719
+ }
720
+
721
+ // src/actions/items.ts
722
+ function stockOf(answer) {
723
+ return answer.data ?? { stockData: [], companySummary: {} };
724
+ }
725
+ function companySummaryOf(answer) {
726
+ const data = answer.data;
727
+ return data?.["companySummary"] ?? {};
728
+ }
729
+ function attributesOf(answer) {
730
+ return { attributes: answer.data.attributes };
731
+ }
287
732
  function createItemActions(api, config = {}) {
288
- const {
289
- cachePrefix = "",
290
- edgeCache = 1,
291
- longEdgeCache = 8,
292
- redisTtl = hours2(1),
293
- longRedisTtl = hours2(8),
294
- sortChildren = true,
295
- sortByPrefix
296
- } = config;
733
+ const { sortChildren = true, sortByPrefix } = config;
297
734
  function sortCategoryChildren(children) {
298
- if (!sortChildren) return children;
299
- return [...children].sort((a, b) => a.sequenceNo - b.sequenceNo);
735
+ const entries = children.map((child, index) => ({ seqNo: child.sequenceNo, index }));
736
+ return categoryChildren(sortChildren, entries).map((e) => children[e.index]);
300
737
  }
301
738
  async function itemCategoryLookup(path) {
302
- return withServerCache(
303
- cachePrefix,
304
- redisTtl,
305
- "items.categories.lookup.get",
306
- async () => {
307
- const response = await api.items.categories.lookup.get({
308
- path,
309
- edgeCache
310
- });
311
- return response.data;
312
- },
313
- path
314
- );
739
+ return specRead(api, categoryLookupRead(), config, [], { path }, [path], asData);
315
740
  }
316
741
  async function getItemCategory(uid, options) {
317
742
  const { filters, ...rest } = options ?? {};
318
743
  const sdkParams = {
319
744
  ...rest,
320
- edgeCache,
321
745
  ...filters ? { filters: JSON.stringify(filters) } : {}
322
746
  };
323
- const category = await withServerCache(
324
- cachePrefix,
325
- redisTtl,
326
- "items.categories.get",
327
- async () => {
328
- const response = await api.items.categories.get(uid, sdkParams);
329
- return response.data;
330
- },
331
- uid,
332
- options
747
+ const category = await specRead(
748
+ api,
749
+ categoryRead(),
750
+ config,
751
+ [uid],
752
+ { ...sdkParams },
753
+ [uid, options],
754
+ asData
333
755
  );
334
756
  return {
335
757
  ...category,
@@ -337,200 +759,124 @@ function createItemActions(api, config = {}) {
337
759
  };
338
760
  }
339
761
  function buildCategoryParams(itemsFilters, overrides) {
340
- const params = { includeStock: "Y" };
341
- if (itemsFilters) {
342
- params["filters"] = JSON.stringify(itemsFilters.filters);
343
- params["limit"] = overrides?.limit ?? itemsFilters.limit;
344
- params["offset"] = overrides?.offset ?? itemsFilters.offset;
345
- params["q"] = itemsFilters.q;
346
- params["sortBy"] = itemsFilters.sortBy;
347
- } else {
348
- params["filters"] = JSON.stringify([]);
349
- params["q"] = "";
350
- params["sortBy"] = "desc";
351
- params["limit"] = overrides?.limit;
352
- params["offset"] = overrides?.offset;
353
- }
354
- return params;
355
- }
356
- function isItemsFilters(v) {
357
- return Array.isArray(v.filters);
762
+ const filtersText = itemsFilters && JSON.stringify(itemsFilters.filters);
763
+ return {
764
+ includeStock: "Y",
765
+ filters: textOr(filtersText, "[]"),
766
+ limit: firstGiven(overrides?.limit, itemsFilters?.limit),
767
+ offset: firstGiven(overrides?.offset, itemsFilters?.offset),
768
+ q: textOr(itemsFilters?.q, ""),
769
+ sortBy: prefixed(textOr(itemsFilters?.sortBy, "desc"))
770
+ };
358
771
  }
359
- function applySortByPrefix(params) {
360
- const sortBy = params["sortBy"];
361
- if (typeof sortBy === "string") params["sortBy"] = categorySortBy(sortByPrefix ?? "", sortBy);
772
+ function prefixed(sortBy) {
773
+ return categorySortBy(textOr(sortByPrefix, ""), sortBy);
362
774
  }
363
775
  function listCategoryItems(uid, params) {
364
- return withServerCache(
365
- cachePrefix,
366
- redisTtl,
367
- "items.categories.items.list",
368
- async () => {
369
- const response = await api.items.categories.items.list(uid, {
370
- ...params,
371
- edgeCache
372
- });
373
- return response.data;
374
- },
375
- uid,
376
- params
776
+ return specRead(
777
+ api,
778
+ categoryItemsRead(),
779
+ config,
780
+ [uid],
781
+ params,
782
+ [uid, params],
783
+ asData
377
784
  );
378
785
  }
379
786
  async function getCategoryItems(uid, filters) {
380
- const merged = isItemsFilters(filters) ? buildCategoryParams(filters) : { ...filters };
381
- applySortByPrefix(merged);
382
- return listCategoryItems(uid, merged);
787
+ const raw = filters;
788
+ const sortBy = raw["sortBy"];
789
+ const kind = categoryArgKind(Array.isArray(raw["filters"]), typeof sortBy === "string");
790
+ if (kind === "typedFilters")
791
+ return listCategoryItems(uid, buildCategoryParams(filters));
792
+ if (kind === "rawPrefixed")
793
+ return listCategoryItems(uid, { ...raw, sortBy: prefixed(sortBy) });
794
+ return listCategoryItems(uid, { ...raw });
383
795
  }
384
796
  async function getCategoryItemsInfinite(uid, itemsFilters, pageParam = 0) {
385
797
  const given = itemsFilters?.limit;
386
- const limit = itemsLimitOf(given === void 0 || Number.isNaN(given) ? void 0 : given);
798
+ const limit = itemsLimitOf(givenLimit(given, Number.isNaN(given)));
387
799
  const offset = pageParam * limit;
388
- const merged = buildCategoryParams(itemsFilters, { limit, offset });
389
- applySortByPrefix(merged);
390
- const result = await listCategoryItems(uid, merged);
391
- const items = result.items || [];
392
- const total = result.total || 0;
800
+ const result = await listCategoryItems(
801
+ uid,
802
+ buildCategoryParams(itemsFilters, { limit, offset })
803
+ );
804
+ const items = result.items ?? [];
805
+ const total = totalOrZero(result.total, Number.isNaN(result.total));
393
806
  return paginateOffset(items, pageParam, limit, total);
394
807
  }
395
808
  async function getItemAttributes(categoryUid) {
396
- return withServerCache(
397
- cachePrefix,
398
- redisTtl,
399
- "items.categories.attributes.list",
400
- async () => {
401
- const response = await api.items.categories.attributes.list(categoryUid, { edgeCache });
402
- return {
403
- attributes: response.data.attributes
404
- };
405
- },
406
- categoryUid
809
+ return specRead(
810
+ api,
811
+ categoryAttributesRead(),
812
+ config,
813
+ [categoryUid],
814
+ {},
815
+ [categoryUid],
816
+ attributesOf
407
817
  );
408
818
  }
409
819
  async function getInvMast(uid) {
410
- return withServerCache(
411
- cachePrefix,
412
- redisTtl,
413
- "items.invMast.get",
414
- async () => {
415
- const response = await api.items.invMast.get(uid, { edgeCache: 4 });
416
- return response.data;
417
- },
418
- uid
419
- );
820
+ return specRead(api, invMastRead(), config, [uid], {}, [uid], asData);
420
821
  }
421
822
  async function getInvMastDoc(paramsOrUid, itemIdArg, includePricingArg) {
422
823
  const params = typeof paramsOrUid === "number" ? {
423
824
  invMastUid: docUidOf(paramsOrUid),
424
- itemId: takesItemId(paramsOrUid, itemIdArg ?? "") ? itemIdArg.toUpperCase().trim() : void 0,
825
+ itemId: sentItemId(itemIdArg, takesItemId(paramsOrUid, itemIdArg ?? "")),
425
826
  includePricing: includePricingArg
426
- } : paramsOrUid;
827
+ } : { ...paramsOrUid, itemId: sentItemId(paramsOrUid.itemId, true) };
427
828
  if (!hasDocKey(!!params.invMastUid, params.itemId ?? "")) {
428
829
  throw new Error("Either invMastUid must be positive or itemId must be provided");
429
830
  }
430
- return withServerCache(
431
- cachePrefix,
432
- redisTtl,
433
- "items.invMast.doc.list",
434
- async () => {
435
- const response = await api.items.invMast.doc.list(params.invMastUid ?? 0, {
436
- itemId: params.itemId,
437
- includePricing: params.includePricing,
438
- edgeCache: 4
439
- });
440
- return response.data;
441
- },
442
- params.invMastUid,
443
- params.itemId,
444
- params.includePricing
831
+ return specRead(
832
+ api,
833
+ invMastDocRead(),
834
+ config,
835
+ [params.invMastUid ?? 0],
836
+ { itemId: params.itemId, includePricing: params.includePricing },
837
+ [params.invMastUid, params.itemId, params.includePricing],
838
+ asData
445
839
  );
446
840
  }
447
841
  async function getStock(invMastUid) {
448
- return withServerCache(
449
- cachePrefix,
450
- redisTtl,
451
- "items.invMast.stock.get",
452
- async () => {
453
- const response = await api.items.invMast.stock.get(invMastUid, {
454
- edgeCache
455
- });
456
- return response.data ?? { stockData: [], companySummary: {} };
457
- },
458
- invMastUid
459
- );
842
+ return specRead(api, stockRead(), config, [invMastUid], {}, [invMastUid], stockOf);
460
843
  }
461
844
  async function getStockCompanySummary(invMastUid) {
462
- return withServerCache(
463
- cachePrefix,
464
- redisTtl,
465
- "items.invMast.stock.get.companySummary",
466
- async () => {
467
- const response = await api.items.invMast.stock.get(invMastUid, {
468
- edgeCache
469
- });
470
- return response.data?.["companySummary"] ?? {};
471
- },
472
- invMastUid
845
+ return specRead(
846
+ api,
847
+ stockSummaryRead(),
848
+ config,
849
+ [invMastUid],
850
+ {},
851
+ [invMastUid],
852
+ companySummaryOf
473
853
  );
474
854
  }
475
855
  async function getItemFaqs(invMastUid) {
476
- return withServerCache(
477
- cachePrefix,
478
- longRedisTtl,
479
- "items.invMast.faq.list",
480
- async () => {
481
- const response = await api.items.invMast.faq.list(invMastUid, {
482
- edgeCache: longEdgeCache
483
- });
484
- return toListResult(response);
485
- },
486
- invMastUid
487
- );
856
+ return specRead(api, faqsRead(), config, [invMastUid], {}, [invMastUid], asAllRows);
488
857
  }
489
858
  async function getItemSubstitutes(invMastUid) {
490
- return withServerCache(
491
- cachePrefix,
492
- longRedisTtl,
493
- "items.invMast.invSub.list",
494
- async () => {
495
- const response = await api.items.invMast.invSub.list(invMastUid, {
496
- edgeCache: longEdgeCache
497
- });
498
- return toListResult(response);
499
- },
500
- invMastUid
501
- );
859
+ return specRead(api, substitutesRead(), config, [invMastUid], {}, [invMastUid], asAllRows);
502
860
  }
503
861
  async function getItemAccessories(invMastUid) {
504
- return withServerCache(
505
- cachePrefix,
506
- redisTtl,
507
- "items.invMast.invAccessory.list",
508
- async () => {
509
- const response = await api.items.invMast.invAccessory.list(invMastUid, { edgeCache });
510
- return toListResult(response);
511
- },
512
- invMastUid
862
+ return specRead(
863
+ api,
864
+ accessoriesRead(),
865
+ config,
866
+ [invMastUid],
867
+ {},
868
+ [invMastUid],
869
+ asAllRows
513
870
  );
514
871
  }
515
872
  async function getSimilarItems(invMastUid) {
516
- return withServerCache(
517
- cachePrefix,
518
- longRedisTtl,
519
- "items.invMast.similar.list",
520
- async () => {
521
- const response = await api.items.invMast.similar.list(invMastUid, {
522
- edgeCache: longEdgeCache
523
- });
524
- return toListResult(response);
525
- },
526
- invMastUid
527
- );
873
+ return specRead(api, similarRead(), config, [invMastUid], {}, [invMastUid], asList);
528
874
  }
529
875
  async function batchGetInvMastDocs(params) {
530
876
  return batchFetch(
531
877
  params,
532
878
  (p) => getInvMastDoc(p),
533
- (p) => p.itemId ?? String(p.invMastUid)
879
+ (p) => docBatchKey(p.itemId, p.invMastUid ?? 0)
534
880
  );
535
881
  }
536
882
  async function batchGetStockData(invMastUids) {
@@ -565,13 +911,14 @@ function createCommerceActions(api, config = {}) {
565
911
  async function cartHdrLookup(params) {
566
912
  const contactId = params.contactId ?? defaultContactId;
567
913
  const customerId = params.customerId ?? defaultCustomerId;
568
- if (contactId == null || customerId == null) {
914
+ if (!cartIdsPresent(contactId != null, customerId != null)) {
569
915
  throw new Error("cartHdrLookup requires contactId and customerId (param or config default)");
570
916
  }
917
+ const userId = Number(params.userId);
571
918
  const response = await api.commerce.cartHdr.lookup.get({
572
- // SDK: userId 0 = anonymous cart keyed on cartToken.
573
- // `|| 0` also maps a non-numeric userId (NaN) to anonymous, as auth.ts does.
574
- userId: Number(params.userId) || 0,
919
+ // SDK: userId 0 = anonymous cart keyed on cartToken. A non-numeric userId (NaN) is
920
+ // anonymous too, as auth.ts does (proved cartUserId).
921
+ userId: cartUserId(userId, Number.isNaN(userId)),
575
922
  cartToken: params.cartToken,
576
923
  contactId: Number(contactId),
577
924
  customerId: Number(customerId)
@@ -585,7 +932,7 @@ function createCommerceActions(api, config = {}) {
585
932
  async function addToCart(cartHdrUid, items) {
586
933
  const mappedItems = items.map((item) => ({
587
934
  ...item,
588
- unitOfMeasure: convertUnitOfMeasure ? convertUnitOfMeasure(item.unitOfMeasure) : item.unitOfMeasure
935
+ unitOfMeasure: lineUom(convertUnitOfMeasure?.(item.unitOfMeasure), item.unitOfMeasure)
589
936
  }));
590
937
  const response = await api.commerce.cartLine.add.create(cartHdrUid, mappedItems);
591
938
  return response.data;
@@ -593,7 +940,7 @@ function createCommerceActions(api, config = {}) {
593
940
  async function updateCartLines(cartHdrUid, lines) {
594
941
  const mappedLines = lines.map((line) => ({
595
942
  ...line,
596
- unitOfMeasure: convertUnitOfMeasure ? convertUnitOfMeasure(line.unitOfMeasure) : line.unitOfMeasure
943
+ unitOfMeasure: lineUom(convertUnitOfMeasure?.(line.unitOfMeasure), line.unitOfMeasure)
597
944
  }));
598
945
  const response = await api.commerce.cartLine.update.create(cartHdrUid, mappedLines);
599
946
  return response.data;
@@ -605,8 +952,15 @@ function createCommerceActions(api, config = {}) {
605
952
  }
606
953
  }
607
954
  async function getCartAlsoBought(cartHdrUid) {
608
- const response = await api.commerce.cartHdr.alsoBought.list(cartHdrUid);
609
- return toListResult(response);
955
+ return specRead(
956
+ api,
957
+ cartAlsoBoughtRead(),
958
+ {},
959
+ [cartHdrUid],
960
+ {},
961
+ [cartHdrUid],
962
+ asList
963
+ );
610
964
  }
611
965
  async function checkoutOrder(cartHdrUid, data) {
612
966
  const response = await api.commerce.checkout.create({
@@ -706,11 +1060,11 @@ function createSearchActions(api, config = {}) {
706
1060
  async () => {
707
1061
  const response = await openSearch.itemSearch.list(params);
708
1062
  const { items, totalResults } = response.data;
709
- const nextOffset = pageParam + filters.limit;
1063
+ const nextOffset2 = pageParam + filters.limit;
710
1064
  return {
711
1065
  data: items,
712
1066
  total: totalResults,
713
- nextCursor: nextOffset < totalResults ? nextOffset : void 0
1067
+ nextCursor: nextOffset2 < totalResults ? nextOffset2 : void 0
714
1068
  };
715
1069
  },
716
1070
  filters,
@@ -727,37 +1081,30 @@ function createSearchActions(api, config = {}) {
727
1081
  }
728
1082
 
729
1083
  // src/actions/orders.ts
730
- import { hours as hours4 } from "@simpleapps-com/augur-utils";
731
1084
  function createOrderActions(api, config = {}) {
732
- const { cachePrefix = "", edgeCache = 1, redisTtl = hours4(1) } = config;
733
1085
  async function getOrderDoc(orderNo, postalCode) {
734
- return withServerCache(
735
- cachePrefix,
736
- redisTtl,
737
- "orders.oeHdr.doc.get",
738
- async () => {
739
- const response = await api.orders.oeHdr.doc.get(orderNo, {
740
- postalCode,
741
- edgeCache
742
- });
743
- return response.data;
744
- },
745
- orderNo,
746
- postalCode
1086
+ return specRead(
1087
+ api,
1088
+ orderDocRead(),
1089
+ config,
1090
+ [orderNo],
1091
+ { postalCode },
1092
+ [orderNo, postalCode],
1093
+ asData
747
1094
  );
748
1095
  }
749
1096
  return { getOrderDoc };
750
1097
  }
751
1098
 
752
1099
  // src/actions/shipping.ts
753
- import { hours as hours5 } from "@simpleapps-com/augur-utils";
1100
+ import { hours as hours4 } from "@simpleapps-com/augur-utils";
754
1101
  function createShippingActions(api, config) {
755
1102
  const {
756
1103
  fromAddress,
757
1104
  defaultServiceCodes,
758
1105
  cachePrefix = "",
759
1106
  edgeCache = 1,
760
- redisTtl = hours5(1)
1107
+ redisTtl = hours4(1)
761
1108
  } = config;
762
1109
  async function getShippingRates(toAddress, weight, serviceCodes) {
763
1110
  const params = {
@@ -790,128 +1137,106 @@ function createShippingActions(api, config) {
790
1137
  }
791
1138
 
792
1139
  // src/actions/joomla.ts
793
- import { hours as hours6 } from "@simpleapps-com/augur-utils";
1140
+ function normalizedProfile(answer) {
1141
+ const user = answer.data;
1142
+ if (!user) throw new Error("User not found");
1143
+ return {
1144
+ id: profileId(user.id),
1145
+ name: user.name,
1146
+ email: user.email,
1147
+ customerId: user.customerId,
1148
+ permissions: nonEmptyTitlesFrom(
1149
+ user.groups.map((group) => group.title),
1150
+ 0
1151
+ )
1152
+ };
1153
+ }
1154
+ function directChildren(all, parentId) {
1155
+ const entries = all.data.map((item, index) => ({ parentId: Number(item.parentId), index }));
1156
+ const data = directChildrenFrom(entries, parentId, 0).map((e) => all.data[e.index]);
1157
+ return { ...all, data, total: data.length };
1158
+ }
794
1159
  function createJoomlaActions(api, config = {}) {
795
- const { cachePrefix = "", edgeCache = 1, redisTtl = hours6(1) } = config;
796
1160
  async function getJoomlaContent(articleId, options) {
797
- if (options?.alias) {
798
- return withServerCache(
799
- cachePrefix,
800
- redisTtl,
801
- "joomla.content.doc.get",
802
- async () => {
803
- const response = await api.joomla.content.doc.get(Number(articleId), {
804
- alias: options.alias,
805
- catid: options.catId ? Number(options.catId) : void 0,
806
- edgeCache
807
- });
808
- return response.data;
809
- },
810
- articleId,
811
- options.alias,
812
- options.catId
1161
+ const alias = options?.alias ?? "";
1162
+ if (contentByAlias(alias)) {
1163
+ const catId = options?.catId === void 0 ? void 0 : Number(options.catId);
1164
+ return specRead(
1165
+ api,
1166
+ contentRead(),
1167
+ config,
1168
+ [Number(articleId)],
1169
+ { alias, catid: catIdParam(catId) },
1170
+ [articleId, alias, options?.catId],
1171
+ asData
813
1172
  );
814
1173
  }
815
- return withServerCache(
816
- cachePrefix,
817
- redisTtl,
818
- "joomla.content.doc.get",
819
- async () => {
820
- const response = await api.joomla.content.doc.get(Number(articleId), {
821
- edgeCache
822
- });
823
- return response.data;
824
- },
825
- articleId
1174
+ return specRead(
1175
+ api,
1176
+ contentRead(),
1177
+ config,
1178
+ [Number(articleId)],
1179
+ {},
1180
+ [articleId],
1181
+ asData
826
1182
  );
827
1183
  }
828
1184
  async function getJoomlaContentList(params) {
829
- return withServerCache(
830
- cachePrefix,
831
- redisTtl,
832
- "joomla.content.list",
833
- async () => {
834
- const response = await api.joomla.content.list({
835
- ...params,
836
- edgeCache
837
- });
838
- return toListResult(response);
839
- },
840
- params
1185
+ return specRead(
1186
+ api,
1187
+ contentListRead(),
1188
+ config,
1189
+ [],
1190
+ { ...params },
1191
+ [params],
1192
+ asList
841
1193
  );
842
1194
  }
843
1195
  async function getJoomlaMenu(paramsOrParentId, menuType) {
844
1196
  if (typeof paramsOrParentId === "number") {
845
1197
  const parentId = paramsOrParentId;
846
- const sdkParams = {
847
- menutype: menuType,
848
- parentId,
849
- published: 1,
850
- limit: 100
851
- };
852
- const result = await withServerCache(
853
- cachePrefix,
854
- redisTtl,
855
- "joomla.menu.list",
856
- async () => {
857
- const response = await api.joomla.menu.list({
858
- ...sdkParams,
859
- edgeCache
860
- });
861
- return toListResult(response);
862
- },
863
- sdkParams
1198
+ const sdkParams = { menutype: menuType, parentId, published: 1 };
1199
+ const all = await specRead(
1200
+ api,
1201
+ menuRead(),
1202
+ config,
1203
+ [],
1204
+ sdkParams,
1205
+ [sdkParams],
1206
+ asAllRows
864
1207
  );
865
- const pid = String(parentId);
866
- const filtered = result.data.filter((item) => String(item.parentId) === pid);
867
- return { ...result, data: filtered, total: filtered.length };
1208
+ return directChildren(all, parentId);
868
1209
  }
869
- return withServerCache(
870
- cachePrefix,
871
- redisTtl,
872
- "joomla.menu.list",
873
- async () => {
874
- const response = await api.joomla.menu.list({
875
- ...paramsOrParentId,
876
- edgeCache
877
- });
878
- return toListResult(response);
879
- },
880
- paramsOrParentId
1210
+ return specRead(
1211
+ api,
1212
+ menuListRead(),
1213
+ config,
1214
+ [],
1215
+ { ...paramsOrParentId },
1216
+ [paramsOrParentId],
1217
+ asList
881
1218
  );
882
1219
  }
883
1220
  async function getJoomlaMenuDoc(menuId) {
884
- return withServerCache(
885
- cachePrefix,
886
- redisTtl,
887
- "joomla.menu.doc.get",
888
- async () => {
889
- const response = await api.joomla.menu.doc.get(Number(menuId));
890
- return response.data;
891
- },
892
- menuId
1221
+ return specRead(
1222
+ api,
1223
+ menuDocRead(),
1224
+ config,
1225
+ [Number(menuId)],
1226
+ void 0,
1227
+ [menuId],
1228
+ asData
893
1229
  );
894
1230
  }
895
1231
  async function getUserProfile(userId) {
896
- return withServerCache(
897
- cachePrefix,
898
- redisTtl,
899
- "joomla.users.doc.get",
900
- async () => {
901
- const response = await api.joomla.users.doc.get(Number(userId), {
902
- edgeCache
903
- });
904
- const user = response.data;
905
- if (!user) throw new Error("User not found");
906
- return {
907
- id: String(user.id),
908
- name: user.name,
909
- email: user.email,
910
- customerId: user.customerId,
911
- permissions: user.groups.map((group) => group.title).filter(Boolean)
912
- };
913
- },
914
- userId
1232
+ return specRead(
1233
+ api,
1234
+ userProfileRead(),
1235
+ config,
1236
+ [Number(userId)],
1237
+ {},
1238
+ [userId],
1239
+ normalizedProfile
915
1240
  );
916
1241
  }
917
1242
  async function verifyPassword(username, password) {
@@ -932,69 +1257,29 @@ function createJoomlaActions(api, config = {}) {
932
1257
  }
933
1258
 
934
1259
  // src/actions/legacy.ts
935
- import { hours as hours7 } from "@simpleapps-com/augur-utils";
1260
+ function firstWebDesc(answer) {
1261
+ return answer.data[0];
1262
+ }
936
1263
  function createLegacyActions(api, config = {}) {
937
- const {
938
- cachePrefix = "",
939
- edgeCache = 1,
940
- longEdgeCache = 8,
941
- redisTtl = hours7(1),
942
- longRedisTtl = hours7(8)
943
- } = config;
944
1264
  async function getItemWebDesc(invMastUid) {
945
- return withServerCache(
946
- cachePrefix,
947
- redisTtl,
948
- "legacy.invMast.webDesc.list",
949
- async () => {
950
- const response = await api.legacy.invMast.webDesc.list(invMastUid, {
951
- edgeCache
952
- });
953
- return response.data[0];
954
- },
955
- invMastUid
956
- );
1265
+ return specRead(api, webDescRead(), config, [invMastUid], {}, [invMastUid], firstWebDesc);
957
1266
  }
958
1267
  async function getAlsoBoughtItems(invMastUid) {
959
- return withServerCache(
960
- cachePrefix,
961
- redisTtl,
962
- "legacy.invMast.alsoBought.list",
963
- async () => {
964
- const response = await api.legacy.invMast.alsoBought.list(invMastUid, { edgeCache });
965
- return toListResult(response);
966
- },
967
- invMastUid
1268
+ return specRead(
1269
+ api,
1270
+ legacyAlsoBoughtRead(),
1271
+ config,
1272
+ [invMastUid],
1273
+ {},
1274
+ [invMastUid],
1275
+ asList
968
1276
  );
969
1277
  }
970
1278
  async function getItemTags(invMastUid) {
971
- return withServerCache(
972
- cachePrefix,
973
- redisTtl,
974
- "legacy.invMast.tags.list",
975
- async () => {
976
- const response = await api.legacy.invMast.tags.list(invMastUid, {
977
- edgeCache
978
- });
979
- return toListResult(response);
980
- },
981
- invMastUid
982
- );
1279
+ return specRead(api, tagsRead(), config, [invMastUid], {}, [invMastUid], asAllRows);
983
1280
  }
984
1281
  async function getStates(params) {
985
- return withServerCache(
986
- cachePrefix,
987
- longRedisTtl,
988
- "legacy.legacy.state.list",
989
- async () => {
990
- const response = await api.legacy.legacy.state.list({
991
- ...params,
992
- edgeCache: longEdgeCache
993
- });
994
- return toListResult(response);
995
- },
996
- params?.twoLetterCode
997
- );
1282
+ return specRead(api, statesRead(), config, [], { ...params }, [params], asAllRows);
998
1283
  }
999
1284
  return {
1000
1285
  getItemWebDesc,
@@ -1005,144 +1290,97 @@ function createLegacyActions(api, config = {}) {
1005
1290
  }
1006
1291
 
1007
1292
  // src/actions/customers.ts
1008
- import { hours as hours8 } from "@simpleapps-com/augur-utils";
1009
1293
  function createCustomersActions(api, config = {}) {
1010
- const { cachePrefix = "", edgeCache = 1, redisTtl = hours8(1) } = config;
1011
1294
  async function customerLookup(params) {
1012
- return withServerCache(
1013
- cachePrefix,
1014
- redisTtl,
1015
- "customers.customer.lookup.get",
1016
- async () => {
1017
- const response = await api.customers.customer.lookup.get({
1018
- ...params,
1019
- edgeCache
1020
- });
1021
- return toListResult(response);
1022
- },
1023
- params
1295
+ return specRead(
1296
+ api,
1297
+ customerLookupRead(),
1298
+ config,
1299
+ [],
1300
+ { ...params },
1301
+ [params],
1302
+ asList
1024
1303
  );
1025
1304
  }
1026
1305
  async function getCustomerDoc(customerId) {
1027
- return withServerCache(
1028
- cachePrefix,
1029
- redisTtl,
1030
- "customers.customer.doc.get",
1031
- async () => {
1032
- const response = await api.customers.customer.doc.get(customerId, {
1033
- edgeCache
1034
- });
1035
- return response.data;
1036
- },
1037
- customerId
1306
+ return specRead(
1307
+ api,
1308
+ customerDocRead(),
1309
+ config,
1310
+ [customerId],
1311
+ {},
1312
+ [customerId],
1313
+ asData
1038
1314
  );
1039
1315
  }
1040
1316
  async function getCustomerOrders(customerId, params) {
1041
- return withServerCache(
1042
- cachePrefix,
1043
- redisTtl,
1044
- "customers.customer.orders.list",
1045
- async () => {
1046
- const response = await api.customers.customer.orders.list(customerId, {
1047
- ...params,
1048
- edgeCache
1049
- });
1050
- return toListResult(response);
1051
- },
1052
- customerId,
1053
- params
1317
+ return specRead(
1318
+ api,
1319
+ customerOrdersRead(),
1320
+ config,
1321
+ [customerId],
1322
+ { ...params },
1323
+ [customerId, params],
1324
+ asList
1054
1325
  );
1055
1326
  }
1056
1327
  async function getCustomerOrderDetail(customerId, orderId) {
1057
- return withServerCache(
1058
- cachePrefix,
1059
- redisTtl,
1060
- "customers.customer.orders.get",
1061
- async () => {
1062
- const response = await api.customers.customer.orders.get(customerId, String(orderId), {
1063
- edgeCache
1064
- });
1065
- return response.data;
1066
- },
1067
- customerId,
1068
- orderId
1328
+ return specRead(
1329
+ api,
1330
+ customerOrderRead(),
1331
+ config,
1332
+ [customerId, String(orderId)],
1333
+ {},
1334
+ [customerId, orderId],
1335
+ asData
1069
1336
  );
1070
1337
  }
1071
1338
  async function getCustomerInvoices(customerId, params) {
1072
- return withServerCache(
1073
- cachePrefix,
1074
- redisTtl,
1075
- "customers.customer.invoices.list",
1076
- async () => {
1077
- const response = await api.customers.customer.invoices.list(customerId, {
1078
- ...params,
1079
- edgeCache
1080
- });
1081
- return toListResult(response);
1082
- },
1083
- customerId,
1084
- params
1339
+ return specRead(
1340
+ api,
1341
+ customerInvoicesRead(),
1342
+ config,
1343
+ [customerId],
1344
+ { ...params },
1345
+ [customerId, params],
1346
+ asList
1085
1347
  );
1086
1348
  }
1087
1349
  async function getCustomerInvoiceDetail(customerId, invoiceNo) {
1088
- return withServerCache(
1089
- cachePrefix,
1090
- redisTtl,
1091
- "customers.customer.invoices.get",
1092
- async () => {
1093
- const response = await api.customers.customer.invoices.get(customerId, invoiceNo, {
1094
- edgeCache
1095
- });
1096
- return response.data;
1097
- },
1098
- customerId,
1099
- invoiceNo
1350
+ return specRead(
1351
+ api,
1352
+ customerInvoiceRead(),
1353
+ config,
1354
+ [customerId, invoiceNo],
1355
+ {},
1356
+ [customerId, invoiceNo],
1357
+ asData
1100
1358
  );
1101
1359
  }
1102
1360
  async function getCustomerQuotes(customerId, params) {
1103
- return withServerCache(
1104
- cachePrefix,
1105
- redisTtl,
1106
- "customers.customer.quotes.list",
1107
- async () => {
1108
- const response = await api.customers.customer.quotes.list(customerId, {
1109
- ...params,
1110
- edgeCache
1111
- });
1112
- return toListResult(response);
1113
- },
1114
- customerId,
1115
- params
1361
+ return specRead(
1362
+ api,
1363
+ customerQuotesRead(),
1364
+ config,
1365
+ [customerId],
1366
+ { ...params },
1367
+ [customerId, params],
1368
+ asList
1116
1369
  );
1117
1370
  }
1118
1371
  async function getCustomerQuoteDetail(customerId, quoteNo) {
1119
- return withServerCache(
1120
- cachePrefix,
1121
- redisTtl,
1122
- "customers.customer.quotes.get",
1123
- async () => {
1124
- const response = await api.customers.customer.quotes.get(customerId, quoteNo, {
1125
- edgeCache
1126
- });
1127
- return response.data;
1128
- },
1129
- customerId,
1130
- quoteNo
1372
+ return specRead(
1373
+ api,
1374
+ customerQuoteRead(),
1375
+ config,
1376
+ [customerId, quoteNo],
1377
+ {},
1378
+ [customerId, quoteNo],
1379
+ asData
1131
1380
  );
1132
1381
  }
1133
1382
  async function getShipToAddresses(customerId) {
1134
- return withServerCache(
1135
- cachePrefix,
1136
- redisTtl,
1137
- "customers.customer.shipTo.list",
1138
- async () => {
1139
- const response = await api.customers.customer.shipTo.list(customerId, {
1140
- edgeCache
1141
- });
1142
- return toListResult(response);
1143
- },
1144
- customerId
1145
- );
1383
+ return specRead(api, shipToRead(), config, [customerId], {}, [customerId], asAllRows);
1146
1384
  }
1147
1385
  return {
1148
1386
  customerLookup,
@@ -1178,9 +1416,9 @@ function createSmartyStreetsActions(api, _config = {}) {
1178
1416
  }
1179
1417
 
1180
1418
  // src/actions/p21-pim.ts
1181
- import { hours as hours9 } from "@simpleapps-com/augur-utils";
1419
+ import { hours as hours5 } from "@simpleapps-com/augur-utils";
1182
1420
  function createP21PimActions(api, config = {}) {
1183
- const { cachePrefix = "", edgeCache = 1, redisTtl = hours9(1) } = config;
1421
+ const { cachePrefix = "", edgeCache = 1, redisTtl = hours5(1) } = config;
1184
1422
  async function getInvMastExt(invMastUid) {
1185
1423
  return withServerCache(
1186
1424
  cachePrefix,
@@ -1215,29 +1453,20 @@ function createP21PimActions(api, config = {}) {
1215
1453
  }
1216
1454
 
1217
1455
  // src/actions/agr-site.ts
1218
- import { hours as hours10 } from "@simpleapps-com/augur-utils";
1219
1456
  function createAgrSiteActions(api, config = {}) {
1220
- const { cachePrefix = "", longEdgeCache = 8, longRedisTtl = hours10(8) } = config;
1221
1457
  async function getSettings(serviceName) {
1222
- return withServerCache(
1223
- cachePrefix,
1224
- longRedisTtl,
1225
- "agrSite.settings.list",
1226
- async () => {
1227
- const response = await api.agrSite.settings.list({
1228
- serviceName,
1229
- edgeCache: longEdgeCache
1230
- });
1231
- return toListResult(response);
1232
- },
1233
- serviceName
1234
- );
1458
+ return specRead(api, settingsRead(), config, [], { serviceName }, [serviceName], asAllRows);
1235
1459
  }
1236
1460
  async function getRobots() {
1237
- return withServerCache(cachePrefix, longRedisTtl, "agrSite.metaFiles.robots.list", async () => {
1238
- const response = await api.agrSite.metaFiles.robots.list({ edgeCache: longEdgeCache });
1239
- return response.data;
1240
- });
1461
+ return specRead(
1462
+ api,
1463
+ robotsRead(),
1464
+ config,
1465
+ [],
1466
+ {},
1467
+ [],
1468
+ asData
1469
+ );
1241
1470
  }
1242
1471
  return {
1243
1472
  getSettings,
@@ -1321,9 +1550,9 @@ function createPaymentsActions(api, config = {}) {
1321
1550
  }
1322
1551
 
1323
1552
  // src/actions/logistics.ts
1324
- import { hours as hours11 } from "@simpleapps-com/augur-utils";
1553
+ import { hours as hours6 } from "@simpleapps-com/augur-utils";
1325
1554
  function createLogisticsActions(api, config = {}) {
1326
- const { cachePrefix = "", longEdgeCache = 8, longRedisTtl = hours11(8) } = config;
1555
+ const { cachePrefix = "", longEdgeCache = 8, longRedisTtl = hours6(8) } = config;
1327
1556
  async function getFreightRates(params) {
1328
1557
  try {
1329
1558
  const response = await api.logistics.speedship.freight.list(params);
@@ -1354,101 +1583,35 @@ function createLogisticsActions(api, config = {}) {
1354
1583
  }
1355
1584
 
1356
1585
  // src/actions/vmi.ts
1357
- import { hours as hours12, minutes as minutes3 } from "@simpleapps-com/augur-utils";
1358
1586
  function createVmiActions(api, config = {}) {
1359
- const {
1360
- cachePrefix = "",
1361
- edgeCache = 1,
1362
- redisTtl = hours12(1),
1363
- shortRedisTtl = minutes3(5)
1364
- } = config;
1365
1587
  async function getWarehouses(params) {
1366
- return withServerCache(
1367
- cachePrefix,
1368
- redisTtl,
1369
- "vmi.warehouse.list",
1370
- async () => {
1371
- const response = await api.vmi.warehouse.list({ ...params, edgeCache });
1372
- return toListResult(response);
1373
- },
1374
- JSON.stringify(params)
1375
- );
1588
+ return specRead(api, warehousesRead(), config, [], { ...params }, [params], asList);
1376
1589
  }
1377
1590
  async function getWarehouseAvailability(warehouseUid, params) {
1378
- return withServerCache(
1379
- cachePrefix,
1380
- shortRedisTtl,
1381
- "vmi.warehouse.availability.get",
1382
- async () => {
1383
- const response = await api.vmi.warehouse.availability.list(warehouseUid, {
1384
- ...params,
1385
- edgeCache
1386
- });
1387
- return toListResult(response);
1388
- },
1389
- warehouseUid,
1390
- JSON.stringify(params)
1591
+ return specRead(
1592
+ api,
1593
+ availabilityRead(),
1594
+ config,
1595
+ [warehouseUid],
1596
+ { ...params },
1597
+ [warehouseUid, params],
1598
+ asList
1391
1599
  );
1392
1600
  }
1393
1601
  async function getDistributors(params) {
1394
- return withServerCache(
1395
- cachePrefix,
1396
- redisTtl,
1397
- "vmi.distributors.list",
1398
- async () => {
1399
- const response = await api.vmi.distributors.list({ ...params, edgeCache });
1400
- return toListResult(response);
1401
- },
1402
- JSON.stringify(params)
1403
- );
1602
+ return specRead(api, distributorsRead(), config, [], { ...params }, [params], asList);
1404
1603
  }
1405
1604
  async function getProducts(params) {
1406
- return withServerCache(
1407
- cachePrefix,
1408
- redisTtl,
1409
- "vmi.products.list",
1410
- async () => {
1411
- const response = await api.vmi.products.list({ ...params, edgeCache });
1412
- return toListResult(response);
1413
- },
1414
- JSON.stringify(params)
1415
- );
1605
+ return specRead(api, productsRead(), config, [], { ...params }, [params], asList);
1416
1606
  }
1417
1607
  async function getInventoryProfiles(params) {
1418
- return withServerCache(
1419
- cachePrefix,
1420
- redisTtl,
1421
- "vmi.invProfileHdr.list",
1422
- async () => {
1423
- const response = await api.vmi.invProfileHdr.list({ ...params, edgeCache });
1424
- return toListResult(response);
1425
- },
1426
- JSON.stringify(params)
1427
- );
1608
+ return specRead(api, inventoryProfilesRead(), config, [], { ...params }, [params], asList);
1428
1609
  }
1429
1610
  async function getRestockHeaders(params) {
1430
- return withServerCache(
1431
- cachePrefix,
1432
- redisTtl,
1433
- "vmi.restockHdr.list",
1434
- async () => {
1435
- const response = await api.vmi.restockHdr.list({ ...params, edgeCache });
1436
- return toListResult(response);
1437
- },
1438
- params ? JSON.stringify(params) : void 0
1439
- );
1611
+ return specRead(api, restockHeadersRead(), config, [], { ...params }, [params], asList);
1440
1612
  }
1441
1613
  async function getSections(params) {
1442
- return withServerCache(
1443
- cachePrefix,
1444
- redisTtl,
1445
- "vmi.sections.list",
1446
- async () => {
1447
- const response = await api.vmi.sections.list({ ...params, edgeCache });
1448
- return toListResult(response);
1449
- },
1450
- JSON.stringify(params)
1451
- );
1614
+ return specRead(api, sectionsRead(), config, [], { ...params }, [params], asList);
1452
1615
  }
1453
1616
  return {
1454
1617
  getWarehouses,
@@ -1462,14 +1625,14 @@ function createVmiActions(api, config = {}) {
1462
1625
  }
1463
1626
 
1464
1627
  // src/actions/p21-core.ts
1465
- import { hours as hours13 } from "@simpleapps-com/augur-utils";
1628
+ import { hours as hours7 } from "@simpleapps-com/augur-utils";
1466
1629
  function createP21CoreActions(api, config = {}) {
1467
1630
  const {
1468
1631
  cachePrefix = "",
1469
1632
  edgeCache = 1,
1470
1633
  longEdgeCache = 8,
1471
- redisTtl = hours13(1),
1472
- longRedisTtl = hours13(8)
1634
+ redisTtl = hours7(1),
1635
+ longRedisTtl = hours7(8)
1473
1636
  } = config;
1474
1637
  async function getAddresses(params) {
1475
1638
  return withServerCache(
@@ -1611,9 +1774,9 @@ function createP21ApisActions(api, _config = {}) {
1611
1774
  }
1612
1775
 
1613
1776
  // src/actions/p21-sism.ts
1614
- import { hours as hours14 } from "@simpleapps-com/augur-utils";
1777
+ import { hours as hours8 } from "@simpleapps-com/augur-utils";
1615
1778
  function createP21SismActions(api, config = {}) {
1616
- const { cachePrefix = "", edgeCache = 1, redisTtl = hours14(1) } = config;
1779
+ const { cachePrefix = "", edgeCache = 1, redisTtl = hours8(1) } = config;
1617
1780
  async function getRecentImports(params) {
1618
1781
  return withServerCache(
1619
1782
  cachePrefix,
@@ -1688,14 +1851,14 @@ function createAgrWorkActions(api, _config = {}) {
1688
1851
  }
1689
1852
 
1690
1853
  // src/actions/agr-info.ts
1691
- import { hours as hours15 } from "@simpleapps-com/augur-utils";
1854
+ import { hours as hours9 } from "@simpleapps-com/augur-utils";
1692
1855
  function createAgrInfoActions(api, config = {}) {
1693
1856
  const {
1694
1857
  cachePrefix = "",
1695
1858
  edgeCache = 1,
1696
1859
  longEdgeCache = 8,
1697
- redisTtl = hours15(1),
1698
- longRedisTtl = hours15(8)
1860
+ redisTtl = hours9(1),
1861
+ longRedisTtl = hours9(8)
1699
1862
  } = config;
1700
1863
  async function getContext(params) {
1701
1864
  return withServerCache(
@@ -1769,14 +1932,14 @@ function createAgrInfoActions(api, config = {}) {
1769
1932
  }
1770
1933
 
1771
1934
  // src/actions/basecamp2.ts
1772
- import { hours as hours16 } from "@simpleapps-com/augur-utils";
1935
+ import { hours as hours10 } from "@simpleapps-com/augur-utils";
1773
1936
  function createBasecamp2Actions(api, config = {}) {
1774
1937
  const {
1775
1938
  cachePrefix = "",
1776
1939
  edgeCache = 1,
1777
1940
  longEdgeCache = 8,
1778
- redisTtl = hours16(1),
1779
- longRedisTtl = hours16(8)
1941
+ redisTtl = hours10(1),
1942
+ longRedisTtl = hours10(8)
1780
1943
  } = config;
1781
1944
  async function getTodos(params) {
1782
1945
  return withServerCache(
@@ -1903,9 +2066,9 @@ function createBasecamp2Actions(api, config = {}) {
1903
2066
  }
1904
2067
 
1905
2068
  // src/actions/brand-folder.ts
1906
- import { hours as hours17 } from "@simpleapps-com/augur-utils";
2069
+ import { hours as hours11 } from "@simpleapps-com/augur-utils";
1907
2070
  function createBrandFolderActions(api, config = {}) {
1908
- const { cachePrefix = "", edgeCache = 1, redisTtl = hours17(1) } = config;
2071
+ const { cachePrefix = "", edgeCache = 1, redisTtl = hours11(1) } = config;
1909
2072
  async function getCategories(params) {
1910
2073
  return withServerCache(
1911
2074
  cachePrefix,
@@ -1954,38 +2117,20 @@ function createBrandFolderActions(api, config = {}) {
1954
2117
  }
1955
2118
 
1956
2119
  // src/actions/gregorovich.ts
1957
- import { hours as hours18 } from "@simpleapps-com/augur-utils";
1958
2120
  function createGregorovichActions(api, config = {}) {
1959
- const { cachePrefix = "", redisTtl = hours18(1) } = config;
1960
2121
  async function getDocuments(_params) {
1961
- return withServerCache(cachePrefix, redisTtl, "gregorovich.documents.list", async () => {
1962
- const response = await api.gregorovich.documents.list();
1963
- return toListResult(response);
1964
- });
2122
+ return specRead(api, documentsRead(), config, [], {}, [], asAllRows);
1965
2123
  }
1966
2124
  return { getDocuments };
1967
2125
  }
1968
2126
 
1969
2127
  // src/actions/favorites.ts
1970
- import { hours as hours19 } from "@simpleapps-com/augur-utils";
1971
2128
  function createFavoritesActions(api, config = {}) {
1972
- const { cachePrefix = "", edgeCache = 1, redisTtl = hours19(1) } = config;
1973
2129
  async function getFavorites(userId) {
1974
- return withServerCache(
1975
- cachePrefix,
1976
- redisTtl,
1977
- "items.itemFavorites.list",
1978
- async () => {
1979
- const response = await api.items.itemFavorites.items.list(userId, {
1980
- edgeCache
1981
- });
1982
- return toListResult(response);
1983
- },
1984
- userId
1985
- );
2130
+ return specRead(api, favoritesRead(), config, [userId], {}, [userId], asAllRows);
1986
2131
  }
1987
2132
  async function addFavorite(userId, invMastUid) {
1988
- const response = await api.items.itemFavorites.items.create(userId, [invMastUid]);
2133
+ const response = await api.items.itemFavorites.items.create(userId, oneUid(invMastUid));
1989
2134
  return response.data;
1990
2135
  }
1991
2136
  async function removeFavorite(userId, invMastUid) {
@@ -1995,38 +2140,23 @@ function createFavoritesActions(api, config = {}) {
1995
2140
  }
1996
2141
 
1997
2142
  // src/actions/wishlists.ts
1998
- import { hours as hours20 } from "@simpleapps-com/augur-utils";
1999
2143
  function createWishlistActions(api, config = {}) {
2000
- const { cachePrefix = "", edgeCache = 1, redisTtl = hours20(1) } = config;
2001
2144
  async function getWishlists(userId) {
2002
- return withServerCache(
2003
- cachePrefix,
2004
- redisTtl,
2005
- "items.itemWishlist.list",
2006
- async () => {
2007
- const response = await api.items.itemWishlist.get(userId, {
2008
- edgeCache
2009
- });
2010
- return toListResult(response);
2011
- },
2012
- userId
2013
- );
2145
+ return specRead(api, wishlistsRead(), config, [userId], {}, [userId], asAllRows);
2014
2146
  }
2015
2147
  async function createWishlist(userId, data) {
2016
2148
  const response = await api.items.itemWishlist.create(userId, data);
2017
2149
  return response.data;
2018
2150
  }
2019
2151
  async function getWishlistDetail(userId, wishlistId) {
2020
- return withServerCache(
2021
- cachePrefix,
2022
- redisTtl,
2023
- "items.itemWishlist.hdr.get",
2024
- async () => {
2025
- const response = await api.items.itemWishlist.hdr.get(userId, wishlistId, { edgeCache });
2026
- return response.data;
2027
- },
2028
- userId,
2029
- wishlistId
2152
+ return specRead(
2153
+ api,
2154
+ wishlistLinesRead(),
2155
+ config,
2156
+ [userId, wishlistId],
2157
+ {},
2158
+ [userId, wishlistId],
2159
+ asAllRows
2030
2160
  );
2031
2161
  }
2032
2162
  async function deleteWishlist(userId, wishlistId) {
@@ -2053,7 +2183,7 @@ function createWishlistActions(api, config = {}) {
2053
2183
  function createSiteActions(api, config = {}) {
2054
2184
  const siteId = api.config?.siteId ?? "";
2055
2185
  const {
2056
- cachePrefix = siteId ? scopedPrefix(siteId) : "",
2186
+ cachePrefix = sitePrefix(siteId),
2057
2187
  edgeCache,
2058
2188
  redisTtl,
2059
2189
  longEdgeCache,
@@ -2065,6 +2195,14 @@ function createSiteActions(api, config = {}) {
2065
2195
  } = config;
2066
2196
  const cache = { cachePrefix, edgeCache, redisTtl };
2067
2197
  const longCache = { ...cache, longEdgeCache, longRedisTtl };
2198
+ const bundles = {
2199
+ noCacheConfig: {},
2200
+ prefixOnly: { cachePrefix },
2201
+ shortBundle: cache,
2202
+ longBundle: longCache,
2203
+ longOnly: { cachePrefix, longEdgeCache, longRedisTtl }
2204
+ };
2205
+ const base = (service) => bundles[bundleOf(service)];
2068
2206
  function castApi() {
2069
2207
  return api;
2070
2208
  }
@@ -2073,72 +2211,75 @@ function createSiteActions(api, config = {}) {
2073
2211
  }
2074
2212
  const pricing = lazy(
2075
2213
  () => createPricingActions(castApi(), {
2076
- ...cache,
2214
+ ...base("pricing"),
2077
2215
  defaultCustomerId,
2078
2216
  ...config.pricing
2079
2217
  })
2080
2218
  );
2081
2219
  const items = lazy(
2082
- () => createItemActions(castApi(), {
2083
- ...longCache,
2084
- ...config.items
2085
- })
2220
+ () => createItemActions(castApi(), { ...base("items"), ...config.items })
2086
2221
  );
2087
2222
  const commerce = lazy(
2088
2223
  () => createCommerceActions(castApi(), {
2224
+ ...base("commerce"),
2089
2225
  defaultContactId,
2090
2226
  defaultCustomerId,
2091
2227
  convertUnitOfMeasure
2092
2228
  })
2093
2229
  );
2094
2230
  const search = lazy(
2095
- () => createSearchActions(castApi(), {
2096
- ...cache,
2097
- ...config.search
2098
- })
2231
+ () => createSearchActions(castApi(), { ...base("search"), ...config.search })
2099
2232
  );
2100
- const orders = lazy(() => createOrderActions(castApi(), cache));
2233
+ const orders = lazy(() => createOrderActions(castApi(), base("orders")));
2101
2234
  const shipping = lazy(
2102
2235
  () => createShippingActions(castApi(), {
2103
- ...cache,
2236
+ ...base("shipping"),
2104
2237
  ...config.shipping
2105
2238
  })
2106
2239
  );
2107
- const joomla = lazy(() => createJoomlaActions(castApi(), cache));
2108
- const legacy = lazy(() => createLegacyActions(castApi(), longCache));
2109
- const customers = lazy(() => createCustomersActions(castApi(), cache));
2110
- const smartyStreets = lazy(
2111
- () => createSmartyStreetsActions(castApi(), {
2112
- cachePrefix
2113
- })
2240
+ const joomla = lazy(() => createJoomlaActions(castApi(), base("joomla")));
2241
+ const legacy = lazy(() => createLegacyActions(castApi(), base("legacy")));
2242
+ const customers = lazy(
2243
+ () => createCustomersActions(castApi(), base("customers"))
2114
2244
  );
2115
- const p21Pim = lazy(() => createP21PimActions(castApi(), cache));
2116
- const agrSite = lazy(
2117
- () => createAgrSiteActions(castApi(), {
2118
- cachePrefix,
2119
- longEdgeCache,
2120
- longRedisTtl
2121
- })
2245
+ const smartyStreets = lazy(
2246
+ () => createSmartyStreetsActions(castApi(), base("smartyStreets"))
2122
2247
  );
2123
- const avalara = lazy(() => createAvalaraActions(castApi(), { cachePrefix }));
2248
+ const p21Pim = lazy(() => createP21PimActions(castApi(), base("p21Pim")));
2249
+ const agrSite = lazy(() => createAgrSiteActions(castApi(), base("agrSite")));
2250
+ const avalara = lazy(() => createAvalaraActions(castApi(), base("avalara")));
2124
2251
  const payments = lazy(
2125
2252
  () => createPaymentsActions(castApi(), {
2126
- cachePrefix,
2253
+ ...base("payments"),
2127
2254
  ...config.payments
2128
2255
  })
2129
2256
  );
2130
- const logistics = lazy(() => createLogisticsActions(castApi(), longCache));
2131
- const vmi = lazy(() => createVmiActions(castApi(), { ...cache, ...config.vmi }));
2132
- const p21Core = lazy(() => createP21CoreActions(castApi(), longCache));
2133
- const p21Apis = lazy(() => createP21ApisActions(castApi(), cache));
2134
- const p21Sism = lazy(() => createP21SismActions(castApi(), cache));
2135
- const agrWork = lazy(() => createAgrWorkActions(castApi(), { cachePrefix }));
2136
- const agrInfo = lazy(() => createAgrInfoActions(castApi(), longCache));
2137
- const basecamp2 = lazy(() => createBasecamp2Actions(castApi(), longCache));
2138
- const brandFolder = lazy(() => createBrandFolderActions(castApi(), cache));
2139
- const gregorovich = lazy(() => createGregorovichActions(castApi(), cache));
2140
- const favorites = lazy(() => createFavoritesActions(castApi(), cache));
2141
- const wishlists = lazy(() => createWishlistActions(castApi(), cache));
2257
+ const logistics = lazy(
2258
+ () => createLogisticsActions(castApi(), base("logistics"))
2259
+ );
2260
+ const vmi = lazy(
2261
+ () => createVmiActions(castApi(), { ...base("vmi"), ...config.vmi })
2262
+ );
2263
+ const p21Core = lazy(() => createP21CoreActions(castApi(), base("p21Core")));
2264
+ const p21Apis = lazy(() => createP21ApisActions(castApi(), base("p21Apis")));
2265
+ const p21Sism = lazy(() => createP21SismActions(castApi(), base("p21Sism")));
2266
+ const agrWork = lazy(() => createAgrWorkActions(castApi(), base("agrWork")));
2267
+ const agrInfo = lazy(() => createAgrInfoActions(castApi(), base("agrInfo")));
2268
+ const basecamp2 = lazy(
2269
+ () => createBasecamp2Actions(castApi(), base("basecamp2"))
2270
+ );
2271
+ const brandFolder = lazy(
2272
+ () => createBrandFolderActions(castApi(), base("brandFolder"))
2273
+ );
2274
+ const gregorovich = lazy(
2275
+ () => createGregorovichActions(castApi(), base("gregorovich"))
2276
+ );
2277
+ const favorites = lazy(
2278
+ () => createFavoritesActions(castApi(), base("favorites"))
2279
+ );
2280
+ const wishlists = lazy(
2281
+ () => createWishlistActions(castApi(), base("wishlists"))
2282
+ );
2142
2283
  const legacyServices = {
2143
2284
  get pricing() {
2144
2285
  return pricing.get();
@@ -2222,7 +2363,7 @@ function createSiteActions(api, config = {}) {
2222
2363
  const proxyFallback = createActionsProxy(api, {
2223
2364
  cachePrefix,
2224
2365
  wrapCall: async ({ methodPath, args, sdkCall: sdkCall2, tier, isRead: read }) => {
2225
- if (read && tier.redisTtl) {
2366
+ if (wrapCaches(read, tier.redisTtl !== void 0, tier.redisTtl ?? 0)) {
2226
2367
  return withRawSdkCache(
2227
2368
  cachePrefix,
2228
2369
  tier.redisTtl,
@@ -2237,16 +2378,22 @@ function createSiteActions(api, config = {}) {
2237
2378
  const wrappedCache = /* @__PURE__ */ new Map();
2238
2379
  return new Proxy(legacyServices, {
2239
2380
  get(target, prop) {
2240
- if (typeof prop === "symbol") return void 0;
2241
- const key = prop;
2381
+ const key = String(prop);
2242
2382
  const cached = wrappedCache.get(key);
2243
- if (cached) return cached;
2244
- if (Object.hasOwn(target, key)) {
2383
+ const route = serviceRoute(
2384
+ typeof prop === "symbol",
2385
+ cached !== void 0,
2386
+ Object.hasOwn(target, key)
2387
+ );
2388
+ if (route === "noRoute") return void 0;
2389
+ if (route === "memo") return cached;
2390
+ if (route === "legacy") {
2245
2391
  const legacySvc = Reflect.get(target, key);
2246
2392
  const wrapped = new Proxy(legacySvc, {
2247
2393
  get(svc, method) {
2248
- if (typeof method === "symbol") return void 0;
2249
- if (method in svc) return svc[method];
2394
+ const to = methodRoute(typeof method === "symbol", method in svc);
2395
+ if (to === "noRoute") return void 0;
2396
+ if (to === "legacy") return svc[method];
2250
2397
  return proxyFallback[key]?.[method];
2251
2398
  }
2252
2399
  });
@@ -2283,8 +2430,8 @@ function clearSiteActions() {
2283
2430
  }
2284
2431
 
2285
2432
  // src/server-site-registry.ts
2286
- import { getCacheTier } from "@simpleapps-com/augur-core";
2287
- import { hours as hours21 } from "@simpleapps-com/augur-utils";
2433
+ import { getCacheTier, isP21Path as isP21Path2 } from "@simpleapps-com/augur-core";
2434
+ import { hours as hours12 } from "@simpleapps-com/augur-utils";
2288
2435
  import { AugurAPI } from "@simpleapps-com/augur-api";
2289
2436
  function registerSiteActions2(actions) {
2290
2437
  registerSiteActions(actions);
@@ -2292,7 +2439,14 @@ function registerSiteActions2(actions) {
2292
2439
  function registerClientAndWrapper(api) {
2293
2440
  registerSdkClient(api);
2294
2441
  registerSdkCallWrapper((methodPath, sdkCall2, ...keyArgs) => {
2295
- const ttl = ttlFor(getCacheTier(methodPath).staleTime, hours21(1), hours21(8));
2442
+ const tier = getCacheTier(methodPath);
2443
+ const ttl = serverTtlOf(
2444
+ tier.redisTtl !== void 0,
2445
+ isP21Path2(methodPath),
2446
+ tier.staleTime,
2447
+ hours12(1),
2448
+ hours12(8)
2449
+ );
2296
2450
  if (ttl === null) return sdkCall2();
2297
2451
  return withRawSdkCache("", ttl, methodPath, sdkCall2, ...keyArgs);
2298
2452
  });
@@ -2334,6 +2488,7 @@ export {
2334
2488
  unwrap,
2335
2489
  unwrapOr,
2336
2490
  batchFetch,
2491
+ serverTtlOf,
2337
2492
  withServerCache,
2338
2493
  withRawSdkCache,
2339
2494
  paginateOffset,
@@ -2342,4 +2497,4 @@ export {
2342
2497
  getSiteActions,
2343
2498
  clearSiteActions2 as clearSiteActions
2344
2499
  };
2345
- //# sourceMappingURL=chunk-34NCJS52.js.map
2500
+ //# sourceMappingURL=chunk-SFXO74RC.js.map