@simpleapps-com/augur-server 2026.11.10 → 2026.11.12

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 (61) hide show
  1. package/EXPORTS.md +2 -2
  2. package/README.md +45 -6
  3. package/dist/actions/commerce.d.ts.map +1 -1
  4. package/dist/actions/customers.d.ts +7 -2
  5. package/dist/actions/customers.d.ts.map +1 -1
  6. package/dist/actions/joomla.d.ts +3 -2
  7. package/dist/actions/joomla.d.ts.map +1 -1
  8. package/dist/actions/pricing.d.ts.map +1 -1
  9. package/dist/actions/require-customer.d.ts +9 -0
  10. package/dist/actions/require-customer.d.ts.map +1 -0
  11. package/dist/address-id.d.ts +12 -0
  12. package/dist/address-id.d.ts.map +1 -0
  13. package/dist/api-handler.d.ts.map +1 -1
  14. package/dist/api.js +7 -5
  15. package/dist/api.js.map +1 -1
  16. package/dist/auth.d.ts +44 -6
  17. package/dist/auth.d.ts.map +1 -1
  18. package/dist/auth.js +4 -3
  19. package/dist/{chunk-4KPTIVYO.js → chunk-5DBFTSWY.js} +11 -14
  20. package/dist/chunk-5DBFTSWY.js.map +1 -0
  21. package/dist/{chunk-AYHUM7SG.js → chunk-GKT4MAWC.js} +46 -64
  22. package/dist/chunk-GKT4MAWC.js.map +1 -0
  23. package/dist/{chunk-BG4G5QUQ.js → chunk-HGJF667G.js} +8 -1
  24. package/dist/{chunk-BG4G5QUQ.js.map → chunk-HGJF667G.js.map} +1 -1
  25. package/dist/chunk-ILXNFJVM.js +86 -0
  26. package/dist/chunk-ILXNFJVM.js.map +1 -0
  27. package/dist/{chunk-JIYVQWXK.js → chunk-IM7FDRER.js} +1 -1
  28. package/dist/chunk-IM7FDRER.js.map +1 -0
  29. package/dist/chunk-M35O5JDZ.js +257 -0
  30. package/dist/chunk-M35O5JDZ.js.map +1 -0
  31. package/dist/{chunk-G5P4IDK7.js → chunk-Y54RGILF.js} +35 -3
  32. package/dist/chunk-Y54RGILF.js.map +1 -0
  33. package/dist/hooks.js +4 -3
  34. package/dist/hooks.js.map +1 -1
  35. package/dist/index.js +6 -5
  36. package/dist/index.js.map +1 -1
  37. package/dist/query-action.d.ts +2 -8
  38. package/dist/query-action.d.ts.map +1 -1
  39. package/dist/query-action.js +4 -3
  40. package/dist/recaptcha.d.ts.map +1 -1
  41. package/dist/rules.d.ts +17 -17
  42. package/dist/rules.d.ts.map +1 -1
  43. package/dist/sdk-client-store.d.ts +4 -3
  44. package/dist/sdk-client-store.d.ts.map +1 -1
  45. package/dist/server-site.d.ts +6 -8
  46. package/dist/server-site.d.ts.map +1 -1
  47. package/dist/session-rules.d.ts +118 -0
  48. package/dist/session-rules.d.ts.map +1 -0
  49. package/dist/site.js +14 -9
  50. package/dist/site.js.map +1 -1
  51. package/dist/sitemap.js +2 -2
  52. package/dist/testing.js +4 -4
  53. package/llms.txt +4 -2
  54. package/next-auth.d.ts +2 -2
  55. package/package.json +6 -5
  56. package/dist/chunk-4KPTIVYO.js.map +0 -1
  57. package/dist/chunk-AUIC4HS2.js +0 -174
  58. package/dist/chunk-AUIC4HS2.js.map +0 -1
  59. package/dist/chunk-AYHUM7SG.js.map +0 -1
  60. package/dist/chunk-G5P4IDK7.js.map +0 -1
  61. package/dist/chunk-JIYVQWXK.js.map +0 -1
@@ -1,10 +1,11 @@
1
1
  import {
2
2
  decimal
3
- } from "./chunk-JIYVQWXK.js";
3
+ } from "./chunk-IM7FDRER.js";
4
4
  import {
5
5
  cacheTtlOf,
6
6
  circuitCheck,
7
7
  configuredModeOf,
8
+ customerRefusalOf,
8
9
  docUidOf,
9
10
  envOf,
10
11
  hasDocKey,
@@ -13,7 +14,6 @@ import {
13
14
  minutes,
14
15
  nextCursorOf,
15
16
  opensAt,
16
- positiveOrZero,
17
17
  recordFailureOf,
18
18
  recordSuccessOf,
19
19
  registerSdkCallWrapper,
@@ -23,11 +23,11 @@ import {
23
23
  shouldCache,
24
24
  takesItemId,
25
25
  ttlFor
26
- } from "./chunk-4KPTIVYO.js";
26
+ } from "./chunk-5DBFTSWY.js";
27
27
  import {
28
28
  isBlank,
29
29
  upperAscii
30
- } from "./chunk-BG4G5QUQ.js";
30
+ } from "./chunk-HGJF667G.js";
31
31
 
32
32
  // src/environment.ts
33
33
  function getEnvironment() {
@@ -414,9 +414,18 @@ function wrapCaches(isRead, hasTtl, ttl) {
414
414
 
415
415
  // src/actions/pricing.ts
416
416
  import { hours, minutes as minutes3 } from "@simpleapps-com/augur-utils";
417
- function resolveCustomerId(explicit, fallback) {
418
- return positiveOrZero(Number(explicit ?? fallback));
417
+
418
+ // src/actions/require-customer.ts
419
+ import { resolveAddressId } from "@simpleapps-com/augur-utils";
420
+ function requireCustomer(refusal, ...candidates) {
421
+ const customerId = resolveAddressId(...candidates);
422
+ const reason = customerRefusalOf(customerId, refusal);
423
+ if (reason !== null) throw new Error(reason);
424
+ return customerId;
419
425
  }
426
+
427
+ // src/actions/pricing.ts
428
+ var NO_CUSTOMER = "A price needs a customer: no usable customerId was given and there is no defaultCustomerId";
420
429
  function createPricingActions(api, config = {}) {
421
430
  const {
422
431
  defaultCustomerId,
@@ -426,7 +435,7 @@ function createPricingActions(api, config = {}) {
426
435
  taxRedisTtl = minutes3(30)
427
436
  } = config;
428
437
  async function getItemPrice(itemId, customerId, quantity = 1, unitOfMeasure) {
429
- const custId = resolveCustomerId(customerId, defaultCustomerId);
438
+ const custId = requireCustomer(NO_CUSTOMER, customerId, defaultCustomerId);
430
439
  const params = {
431
440
  customerId: custId,
432
441
  itemId,
@@ -446,14 +455,15 @@ function createPricingActions(api, config = {}) {
446
455
  );
447
456
  }
448
457
  async function batchGetItemPrices(itemIds, customerId, quantity = 1, unitOfMeasure) {
458
+ const custId = requireCustomer(NO_CUSTOMER, customerId, defaultCustomerId);
449
459
  return batchFetch(
450
460
  itemIds,
451
- (id) => getItemPrice(id, customerId, quantity, unitOfMeasure),
461
+ (id) => getItemPrice(id, custId, quantity, unitOfMeasure),
452
462
  (id) => id
453
463
  );
454
464
  }
455
465
  async function getTaxEstimate(customerId, postalCode, items = []) {
456
- const custId = resolveCustomerId(customerId, defaultCustomerId);
466
+ const custId = requireCustomer(NO_CUSTOMER, customerId, defaultCustomerId);
457
467
  const params = {
458
468
  customerId: custId,
459
469
  postalCode: postalCode ?? "",
@@ -916,12 +926,13 @@ function createItemActions(api, config = {}) {
916
926
  }
917
927
 
918
928
  // src/actions/commerce.ts
929
+ import { resolveAddressId as resolveAddressId2 } from "@simpleapps-com/augur-utils";
919
930
  function createCommerceActions(api, config = {}) {
920
931
  const { defaultContactId, defaultCustomerId, convertUnitOfMeasure } = config;
921
932
  async function cartHdrLookup(params) {
922
933
  const contactId = params.contactId ?? defaultContactId;
923
- const customerId = params.customerId ?? defaultCustomerId;
924
- if (!cartIdsPresent(contactId != null, customerId != null)) {
934
+ const customerId = resolveAddressId2(params.customerId, defaultCustomerId);
935
+ if (!cartIdsPresent(contactId != null, customerId !== null)) {
925
936
  throw new Error("cartHdrLookup requires contactId and customerId (param or config default)");
926
937
  }
927
938
  const userId = Number(params.userId);
@@ -931,7 +942,8 @@ function createCommerceActions(api, config = {}) {
931
942
  userId: cartUserId(userId, Number.isNaN(userId)),
932
943
  cartToken: params.cartToken,
933
944
  contactId: Number(contactId),
934
- customerId: Number(customerId)
945
+ // Not null: cartIdsPresent refused the lookup above without one.
946
+ customerId
935
947
  });
936
948
  return response.data;
937
949
  }
@@ -1149,6 +1161,7 @@ function createShippingActions(api, config) {
1149
1161
  }
1150
1162
 
1151
1163
  // src/actions/joomla.ts
1164
+ import { addressIdOf } from "@simpleapps-com/augur-utils";
1152
1165
  function normalizedProfile(answer) {
1153
1166
  const user = answer.data;
1154
1167
  if (!user) throw new Error("User not found");
@@ -1156,7 +1169,7 @@ function normalizedProfile(answer) {
1156
1169
  id: profileId(user.id),
1157
1170
  name: user.name,
1158
1171
  email: user.email,
1159
- customerId: user.customerId,
1172
+ customerId: addressIdOf(user.customerId),
1160
1173
  permissions: nonEmptyTitlesFrom(
1161
1174
  user.groups.map((group) => group.title),
1162
1175
  0
@@ -1302,6 +1315,7 @@ function createLegacyActions(api, config = {}) {
1302
1315
  }
1303
1316
 
1304
1317
  // src/actions/customers.ts
1318
+ var NO_CUSTOMER2 = "A customer's records need a customer: the customerId given is not a usable P21 customer id";
1305
1319
  function createCustomersActions(api, config = {}) {
1306
1320
  async function customerLookup(params) {
1307
1321
  return specRead(
@@ -1315,84 +1329,52 @@ function createCustomersActions(api, config = {}) {
1315
1329
  );
1316
1330
  }
1317
1331
  async function getCustomerDoc(customerId) {
1318
- return specRead(
1319
- api,
1320
- customerDocRead(),
1321
- config,
1322
- [customerId],
1323
- {},
1324
- [customerId],
1325
- asData
1326
- );
1332
+ const id = requireCustomer(NO_CUSTOMER2, customerId);
1333
+ return specRead(api, customerDocRead(), config, [id], {}, [id], asData);
1327
1334
  }
1328
1335
  async function getCustomerOrders(customerId, params) {
1329
- return specRead(
1330
- api,
1331
- customerOrdersRead(),
1332
- config,
1333
- [customerId],
1334
- { ...params },
1335
- [customerId, params],
1336
- asList
1337
- );
1336
+ const id = requireCustomer(NO_CUSTOMER2, customerId);
1337
+ return specRead(api, customerOrdersRead(), config, [id], { ...params }, [id, params], asList);
1338
1338
  }
1339
1339
  async function getCustomerOrderDetail(customerId, orderId) {
1340
+ const id = requireCustomer(NO_CUSTOMER2, customerId);
1340
1341
  return specRead(
1341
1342
  api,
1342
1343
  customerOrderRead(),
1343
1344
  config,
1344
- [customerId, String(orderId)],
1345
+ [id, String(orderId)],
1345
1346
  {},
1346
- [customerId, orderId],
1347
+ [id, orderId],
1347
1348
  asData
1348
1349
  );
1349
1350
  }
1350
1351
  async function getCustomerInvoices(customerId, params) {
1351
- return specRead(
1352
- api,
1353
- customerInvoicesRead(),
1354
- config,
1355
- [customerId],
1356
- { ...params },
1357
- [customerId, params],
1358
- asList
1359
- );
1352
+ const id = requireCustomer(NO_CUSTOMER2, customerId);
1353
+ return specRead(api, customerInvoicesRead(), config, [id], { ...params }, [id, params], asList);
1360
1354
  }
1361
1355
  async function getCustomerInvoiceDetail(customerId, invoiceNo) {
1356
+ const id = requireCustomer(NO_CUSTOMER2, customerId);
1362
1357
  return specRead(
1363
1358
  api,
1364
1359
  customerInvoiceRead(),
1365
1360
  config,
1366
- [customerId, invoiceNo],
1361
+ [id, invoiceNo],
1367
1362
  {},
1368
- [customerId, invoiceNo],
1363
+ [id, invoiceNo],
1369
1364
  asData
1370
1365
  );
1371
1366
  }
1372
1367
  async function getCustomerQuotes(customerId, params) {
1373
- return specRead(
1374
- api,
1375
- customerQuotesRead(),
1376
- config,
1377
- [customerId],
1378
- { ...params },
1379
- [customerId, params],
1380
- asList
1381
- );
1368
+ const id = requireCustomer(NO_CUSTOMER2, customerId);
1369
+ return specRead(api, customerQuotesRead(), config, [id], { ...params }, [id, params], asList);
1382
1370
  }
1383
1371
  async function getCustomerQuoteDetail(customerId, quoteNo) {
1384
- return specRead(
1385
- api,
1386
- customerQuoteRead(),
1387
- config,
1388
- [customerId, quoteNo],
1389
- {},
1390
- [customerId, quoteNo],
1391
- asData
1392
- );
1372
+ const id = requireCustomer(NO_CUSTOMER2, customerId);
1373
+ return specRead(api, customerQuoteRead(), config, [id, quoteNo], {}, [id, quoteNo], asData);
1393
1374
  }
1394
1375
  async function getShipToAddresses(customerId) {
1395
- return specRead(api, shipToRead(), config, [customerId], {}, [customerId], asAllRows);
1376
+ const id = requireCustomer(NO_CUSTOMER2, customerId);
1377
+ return specRead(api, shipToRead(), config, [id], {}, [id], asAllRows);
1396
1378
  }
1397
1379
  return {
1398
1380
  customerLookup,
@@ -2509,4 +2491,4 @@ export {
2509
2491
  getSiteActions,
2510
2492
  clearSiteActions2 as clearSiteActions
2511
2493
  };
2512
- //# sourceMappingURL=chunk-AYHUM7SG.js.map
2494
+ //# sourceMappingURL=chunk-GKT4MAWC.js.map