@simpleapps-com/augur-server 0.4.3 → 0.5.0

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
@@ -3,9 +3,10 @@ import {
3
3
  createSuspenseQueryOptions
4
4
  } from "./chunk-I26RJDRF.js";
5
5
  import {
6
+ batchFetch,
6
7
  createServerQueryClient,
7
8
  getServerQueryClient
8
- } from "./chunk-I7EWYSPA.js";
9
+ } from "./chunk-R3XKAWHN.js";
9
10
 
10
11
  // src/environment.ts
11
12
  function getEnvironment() {
@@ -227,14 +228,11 @@ function createPricingActions(api, config = {}) {
227
228
  );
228
229
  }
229
230
  async function batchGetItemPrices(itemIds, customerId, quantity = 1) {
230
- const results = await Promise.all(
231
- itemIds.map((id) => getItemPrice(id, customerId, quantity).then((data) => [id, data]).catch(() => [id, null]))
231
+ return batchFetch(
232
+ itemIds,
233
+ (id) => getItemPrice(id, customerId, quantity),
234
+ (id) => id
232
235
  );
233
- const out = {};
234
- for (const [id, data] of results) {
235
- if (data) out[id] = data;
236
- }
237
- return out;
238
236
  }
239
237
  async function getTaxEstimate(customerId, postalCode, items) {
240
238
  const custId = resolveCustomerId(customerId, defaultCustomerId);
@@ -298,9 +296,10 @@ function createItemActions(api, config = {}) {
298
296
  uid,
299
297
  options
300
298
  );
299
+ const cat = category;
301
300
  return {
302
- ...category,
303
- children: sortCategoryChildren(category.children)
301
+ ...cat,
302
+ children: sortCategoryChildren(cat.children)
304
303
  };
305
304
  }
306
305
  async function getCategoryItems(uid, filters) {
@@ -457,28 +456,14 @@ function createItemActions(api, config = {}) {
457
456
  );
458
457
  }
459
458
  async function batchGetInvMastDocs(params) {
460
- const results = await Promise.all(
461
- params.map(
462
- (p) => getInvMastDoc(p).then((data) => [p.itemId ?? String(p.invMastUid), data]).catch(() => [p.itemId ?? String(p.invMastUid), void 0])
463
- )
464
- );
465
- const out = {};
466
- for (const [key, data] of results) {
467
- if (data) out[key] = data;
468
- }
469
- return out;
459
+ return batchFetch(
460
+ params,
461
+ (p) => getInvMastDoc(p),
462
+ (p) => p.itemId ?? String(p.invMastUid)
463
+ );
470
464
  }
471
465
  async function batchGetStockData(invMastUids) {
472
- const results = await Promise.all(
473
- invMastUids.map(
474
- (uid) => getStock(uid).then((data) => [uid, data]).catch(() => [uid, void 0])
475
- )
476
- );
477
- const out = {};
478
- for (const [uid, data] of results) {
479
- if (data) out[uid] = data;
480
- }
481
- return out;
466
+ return batchFetch(invMastUids, (uid) => getStock(uid), (uid) => uid);
482
467
  }
483
468
  return {
484
469
  itemCategoryLookup,
@@ -524,6 +509,7 @@ function createCommerceActions(api, config = {}) {
524
509
  }));
525
510
  const response = await api.commerce.cartLine.add.create(
526
511
  cartHdrUid,
512
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
527
513
  { items: mappedItems }
528
514
  );
529
515
  return response.data;
@@ -539,6 +525,7 @@ function createCommerceActions(api, config = {}) {
539
525
  }));
540
526
  const response = await api.commerce.cartLine.update.create(
541
527
  cartHdrUid,
528
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
542
529
  { lines: mappedLines }
543
530
  );
544
531
  return response.data;
@@ -581,26 +568,26 @@ function createCommerceActions(api, config = {}) {
581
568
  // src/actions/orders.ts
582
569
  function createOrderActions(api, config = {}) {
583
570
  const { cachePrefix = "", edgeCache = 1, redisTtl = 3600 } = config;
584
- async function getOrderDoc(orderNo, zipCode) {
585
- const params = { orderNo, zipCode, edgeCache };
571
+ async function getOrderDoc(orderNo, postalCode) {
586
572
  return withServerCache(
587
573
  cachePrefix,
588
574
  redisTtl,
589
575
  "orders.oeHdr.doc.get",
590
576
  async () => {
591
- const response = await api.orders.oeHdr.doc.get(params);
577
+ const response = await api.orders.oeHdr.doc.get(Number(orderNo), {
578
+ postalCode,
579
+ edgeCache
580
+ });
592
581
  return response.data;
593
582
  },
594
- params
583
+ orderNo,
584
+ postalCode
595
585
  );
596
586
  }
597
587
  return { getOrderDoc };
598
588
  }
599
589
 
600
590
  // src/actions/search.ts
601
- function getOpenSearch(api) {
602
- return "openSearch" in api ? api.openSearch : api.opensearch;
603
- }
604
591
  function createSearchActions(api, config = {}) {
605
592
  const {
606
593
  cachePrefix = "",
@@ -608,7 +595,7 @@ function createSearchActions(api, config = {}) {
608
595
  redisTtl = 3600,
609
596
  defaultSourceFields = "display_desc"
610
597
  } = config;
611
- const openSearch = getOpenSearch(api);
598
+ const openSearch = api.opensearch;
612
599
  async function getSearchAttributes(q) {
613
600
  const params = { q, edgeCache };
614
601
  return withServerCache(
@@ -616,7 +603,10 @@ function createSearchActions(api, config = {}) {
616
603
  redisTtl,
617
604
  "openSearch.itemSearch.attributes.list",
618
605
  async () => {
619
- const response = await openSearch.itemSearch.attributes.list(params);
606
+ const response = (
607
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
608
+ await openSearch.itemSearch.attributes.list(params)
609
+ );
620
610
  return response.data.attributes;
621
611
  },
622
612
  q
@@ -631,7 +621,10 @@ function createSearchActions(api, config = {}) {
631
621
  redisTtl,
632
622
  "openSearch.suggestions.suggest.list",
633
623
  async () => {
634
- const response = await openSearch.suggestions.suggest.list(params);
624
+ const response = (
625
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
626
+ await openSearch.suggestions.suggest.list(params)
627
+ );
635
628
  return response.data;
636
629
  },
637
630
  q
@@ -784,9 +777,7 @@ function createJoomlaActions(api, config = {}) {
784
777
  redisTtl,
785
778
  "joomla.menu.doc.get",
786
779
  async () => {
787
- const response = await api.joomla.menu.doc.get(menuId, {
788
- edgeCache
789
- });
780
+ const response = await api.joomla.menu.doc.get(String(menuId));
790
781
  return response.data;
791
782
  },
792
783
  menuId
@@ -925,6 +916,7 @@ function createCustomersActions(api, config = {}) {
925
916
  const response = await api.customers.customer.lookup.get({
926
917
  ...params,
927
918
  edgeCache
919
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
928
920
  });
929
921
  return response.data;
930
922
  },
@@ -935,9 +927,9 @@ function createCustomersActions(api, config = {}) {
935
927
  return withServerCache(
936
928
  cachePrefix,
937
929
  redisTtl,
938
- "customers.customer.doc.list",
930
+ "customers.customer.doc.get",
939
931
  async () => {
940
- const response = await api.customers.customer.doc.list(customerId, {
932
+ const response = await api.customers.customer.doc.get(customerId, {
941
933
  edgeCache
942
934
  });
943
935
  return response.data;
@@ -986,6 +978,7 @@ function createCustomersActions(api, config = {}) {
986
978
  async () => {
987
979
  const response = await api.customers.customer.invoices.list(
988
980
  customerId,
981
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
989
982
  { ...params, edgeCache }
990
983
  );
991
984
  return { data: response.data, total: response.total };
@@ -1118,9 +1111,7 @@ function createP21PimActions(api, config = {}) {
1118
1111
  redisTtl,
1119
1112
  "p21Pim.invMastExt.get",
1120
1113
  async () => {
1121
- const response = await api.p21Pim.invMastExt.get(invMastUid, {
1122
- edgeCache
1123
- });
1114
+ const response = await api.p21Pim.invMastExt.get(invMastUid);
1124
1115
  return response.data;
1125
1116
  },
1126
1117
  invMastUid
@@ -1163,6 +1154,7 @@ function createAgrSiteActions(api, config = {}) {
1163
1154
  const response = await api.agrSite.settings.list({
1164
1155
  ...serviceName ? { serviceName } : {},
1165
1156
  edgeCache: longEdgeCache
1157
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1166
1158
  });
1167
1159
  return response.data;
1168
1160
  },
@@ -1210,7 +1202,10 @@ function createPaymentsActions(api, config = {}) {
1210
1202
  }
1211
1203
  async function transactionSetup(params) {
1212
1204
  try {
1213
- const response = await api.payments.unified.transactionSetup.get(withMode(params));
1205
+ const response = (
1206
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1207
+ await api.payments.unified.transactionSetup.get(withMode(params))
1208
+ );
1214
1209
  return response.data;
1215
1210
  } catch {
1216
1211
  return void 0;
@@ -1218,7 +1213,10 @@ function createPaymentsActions(api, config = {}) {
1218
1213
  }
1219
1214
  async function accountQuery(params) {
1220
1215
  try {
1221
- const response = await api.payments.unified.accountQuery.get(withMode(params));
1216
+ const response = (
1217
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1218
+ await api.payments.unified.accountQuery.get(withMode(params))
1219
+ );
1222
1220
  return response.data;
1223
1221
  } catch {
1224
1222
  return void 0;
@@ -1226,7 +1224,10 @@ function createPaymentsActions(api, config = {}) {
1226
1224
  }
1227
1225
  async function getSurcharge(params) {
1228
1226
  try {
1229
- const response = await api.payments.unified.surcharge.get(withMode(params));
1227
+ const response = (
1228
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1229
+ await api.payments.unified.surcharge.get(withMode(params))
1230
+ );
1230
1231
  return response.data;
1231
1232
  } catch {
1232
1233
  return void 0;
@@ -1234,7 +1235,10 @@ function createPaymentsActions(api, config = {}) {
1234
1235
  }
1235
1236
  async function cardInfo(params) {
1236
1237
  try {
1237
- const response = await api.payments.unified.cardInfo.get(withMode(params));
1238
+ const response = (
1239
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1240
+ await api.payments.unified.cardInfo.get(withMode(params))
1241
+ );
1238
1242
  return response.data;
1239
1243
  } catch {
1240
1244
  return void 0;
@@ -1242,7 +1246,10 @@ function createPaymentsActions(api, config = {}) {
1242
1246
  }
1243
1247
  async function billingUpdate(params) {
1244
1248
  try {
1245
- const response = await api.payments.unified.billingUpdate.get(withMode(params));
1249
+ const response = (
1250
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1251
+ await api.payments.unified.billingUpdate.get(withMode(params))
1252
+ );
1246
1253
  return response.data;
1247
1254
  } catch {
1248
1255
  return void 0;
@@ -1250,7 +1257,10 @@ function createPaymentsActions(api, config = {}) {
1250
1257
  }
1251
1258
  async function validatePayment(params) {
1252
1259
  try {
1253
- const response = await api.payments.unified.validate.get(withMode(params));
1260
+ const response = (
1261
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1262
+ await api.payments.unified.validate.get(withMode(params))
1263
+ );
1254
1264
  return response.data;
1255
1265
  } catch {
1256
1266
  return void 0;
@@ -1306,6 +1316,7 @@ function createLogisticsActions(api, config = {}) {
1306
1316
  const response = await api.logistics.shipvia.rates.list({
1307
1317
  ...params,
1308
1318
  edgeCache: longEdgeCache
1319
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1309
1320
  });
1310
1321
  return response.data;
1311
1322
  },
@@ -1435,6 +1446,7 @@ function createVmiActions(api, config = {}) {
1435
1446
  async () => {
1436
1447
  const response = await api.vmi.warehouse.availability.get(
1437
1448
  warehouseUid,
1449
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1438
1450
  { ...params, edgeCache }
1439
1451
  );
1440
1452
  return response.data;
@@ -1482,6 +1494,7 @@ function createVmiActions(api, config = {}) {
1482
1494
  const response = await api.vmi.invProfileHdr.list({
1483
1495
  ...params,
1484
1496
  edgeCache
1497
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1485
1498
  });
1486
1499
  return response.data;
1487
1500
  },
@@ -1497,6 +1510,7 @@ function createVmiActions(api, config = {}) {
1497
1510
  const response = await api.vmi.restockHdr.list({
1498
1511
  ...params,
1499
1512
  edgeCache
1513
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1500
1514
  });
1501
1515
  return response.data;
1502
1516
  },
@@ -1512,6 +1526,7 @@ function createVmiActions(api, config = {}) {
1512
1526
  const response = await api.vmi.sections.list({
1513
1527
  ...params,
1514
1528
  edgeCache
1529
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1515
1530
  });
1516
1531
  return response.data;
1517
1532
  },
@@ -1637,6 +1652,7 @@ function createP21CoreActions(api, config = {}) {
1637
1652
  const response = await api.p21Core.codeP21.list({
1638
1653
  ...params,
1639
1654
  edgeCache: longEdgeCache
1655
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1640
1656
  });
1641
1657
  return response.data;
1642
1658
  },
@@ -1753,7 +1769,10 @@ function createP21ApisActions(api, config = {}) {
1753
1769
  }
1754
1770
  async function refreshContacts(params) {
1755
1771
  try {
1756
- const response = await api.p21Apis.entityContacts.refresh.create(params);
1772
+ const response = (
1773
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1774
+ await api.p21Apis.entityContacts.refresh.create(params)
1775
+ );
1757
1776
  return response.data;
1758
1777
  } catch {
1759
1778
  return void 0;
@@ -1761,7 +1780,10 @@ function createP21ApisActions(api, config = {}) {
1761
1780
  }
1762
1781
  async function refreshCustomers(params) {
1763
1782
  try {
1764
- const response = await api.p21Apis.entityCustomers.refresh.create(params);
1783
+ const response = (
1784
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1785
+ await api.p21Apis.entityCustomers.refresh.create(params)
1786
+ );
1765
1787
  return response.data;
1766
1788
  } catch {
1767
1789
  return void 0;
@@ -1975,6 +1997,7 @@ function createBasecamp2Actions(api, config = {}) {
1975
1997
  const response = await api.basecamp2.todos.list({
1976
1998
  ...params,
1977
1999
  edgeCache
2000
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1978
2001
  });
1979
2002
  return response.data;
1980
2003
  },
@@ -2002,6 +2025,7 @@ function createBasecamp2Actions(api, config = {}) {
2002
2025
  const response = await api.basecamp2.todosSummary.list({
2003
2026
  ...params,
2004
2027
  edgeCache
2028
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2005
2029
  });
2006
2030
  return response.data;
2007
2031
  },
@@ -2017,6 +2041,7 @@ function createBasecamp2Actions(api, config = {}) {
2017
2041
  const response = await api.basecamp2.comments.list({
2018
2042
  ...params,
2019
2043
  edgeCache
2044
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2020
2045
  });
2021
2046
  return response.data;
2022
2047
  },
@@ -2032,6 +2057,7 @@ function createBasecamp2Actions(api, config = {}) {
2032
2057
  const response = await api.basecamp2.people.list({
2033
2058
  ...params,
2034
2059
  edgeCache: longEdgeCache
2060
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2035
2061
  });
2036
2062
  return response.data;
2037
2063
  },
@@ -2047,6 +2073,7 @@ function createBasecamp2Actions(api, config = {}) {
2047
2073
  const response = await api.basecamp2.projects.list({
2048
2074
  ...params,
2049
2075
  edgeCache
2076
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2050
2077
  });
2051
2078
  return response.data;
2052
2079
  },
@@ -2062,6 +2089,7 @@ function createBasecamp2Actions(api, config = {}) {
2062
2089
  const response = await api.basecamp2.events.list({
2063
2090
  ...params,
2064
2091
  edgeCache
2092
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2065
2093
  });
2066
2094
  return response.data;
2067
2095
  },
@@ -2077,6 +2105,7 @@ function createBasecamp2Actions(api, config = {}) {
2077
2105
  const response = await api.basecamp2.metrics.list({
2078
2106
  ...params,
2079
2107
  edgeCache
2108
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2080
2109
  });
2081
2110
  return response.data;
2082
2111
  },
@@ -2092,6 +2121,7 @@ function createBasecamp2Actions(api, config = {}) {
2092
2121
  const response = await api.basecamp2.todolists.list({
2093
2122
  ...params,
2094
2123
  edgeCache
2124
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2095
2125
  });
2096
2126
  return response.data;
2097
2127
  },
@@ -2163,7 +2193,7 @@ function createBrandFolderActions(api, config = {}) {
2163
2193
 
2164
2194
  // src/actions/gregorovich.ts
2165
2195
  function createGregorovichActions(api, config = {}) {
2166
- const { cachePrefix = "", edgeCache = 1, redisTtl = 3600 } = config;
2196
+ const { cachePrefix = "", redisTtl = 3600 } = config;
2167
2197
  async function askChatGpt(params) {
2168
2198
  try {
2169
2199
  const response = await api.gregorovich.chatGpt.ask.get(params);
@@ -2178,10 +2208,7 @@ function createGregorovichActions(api, config = {}) {
2178
2208
  redisTtl,
2179
2209
  "gregorovich.documents.list",
2180
2210
  async () => {
2181
- const response = await api.gregorovich.documents.list({
2182
- ...params,
2183
- edgeCache
2184
- });
2211
+ const response = await api.gregorovich.documents.list();
2185
2212
  return response.data;
2186
2213
  },
2187
2214
  params
@@ -2288,6 +2315,7 @@ function createWishlistActions(api, config = {}) {
2288
2315
  const response = await api.items.itemWishlist.hdr.create(
2289
2316
  userId,
2290
2317
  wishlistId,
2318
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2291
2319
  items
2292
2320
  );
2293
2321
  return response.data;
@@ -2552,6 +2580,7 @@ function createSiteActions(api, config = {}) {
2552
2580
  };
2553
2581
  }
2554
2582
  export {
2583
+ batchFetch,
2555
2584
  cacheGet,
2556
2585
  cacheSet,
2557
2586
  createAgrInfoActions,