@simpleapps-com/augur-server 2026.11.10 → 2026.11.11

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/README.md CHANGED
@@ -79,6 +79,15 @@ banners per entry. The decisions are proved (`src/rules.ts`, `src/scoped-client-
79
79
  models `models/AugurServer.dfy`, `models/AugurServerSitemap.dfy`, links
80
80
  `models/links/augur-server-*.dfy`); the rest is tested at 100%.
81
81
 
82
+ Every customer id (#95) goes through augur-utils' proved `resolveAddressId` / `addressIdOf`,
83
+ never `??` or `Number()`: pricing and tax (refused without one: in a price a customer is never 0;
84
+ a batch resolves it once and refuses before any item, never `{}`), the `customers` actions (the
85
+ doc, orders, invoices, quotes and ship-tos refuse 0 and any non-id, so no `customers/0/…`
86
+ request is made), `commerce.cartHdrLookup` (refused without one), the auth session and its cart
87
+ lookup (none for customer 0; a site's `cartHdrLookup` callback gets a resolved `number`), and `joomla.getUserProfile` (`customerId: AddressId | null`).
88
+ Each refusal is the proved `customerRefusalOf` (`src/rules.ts`), thrown by
89
+ `actions/require-customer.ts`.
90
+
82
91
  ```bash
83
92
  pnpm -C repo/packages/augur-server test
84
93
  pnpm -C repo/packages/augur-server proofs
@@ -1 +1 @@
1
- {"version":3,"file":"commerce.d.ts","sourceRoot":"","sources":["../../src/actions/commerce.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC3F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAM9C,sEAAsE;AACtE,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;AAE3D,MAAM,WAAW,qBAAqB;IACpC,gBAAgB,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACnC,iBAAi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+10,11 @@ export type CustomersApiClient = Pick<AugurAPI, "customers">;
10
10
  * cache.
11
11
  */
12
12
  export type CustomersActionsConfig = SpecReadConfig;
13
+ /**
14
+ * Each `customerId` is a P21 customer's `address.id`: 0 and anything that is not a whole number at
15
+ * least 1 (and, from untyped callers, "" and "0") are refused before any request (augur-utils
16
+ * `resolveAddressId`, atlas#95). Resolve a session's text with `resolveAddressId` first.
17
+ */
13
18
  export interface CustomersActions {
14
19
  customerLookup: (params: CustomersTypes.CustomerLookupGetParams) => Promise<ListResult<CustomersTypes.CustomerLookupGetItem>>;
15
20
  getCustomerDoc: (customerId: number) => Promise<CustomerDocument>;
@@ -35,8 +40,8 @@ export interface CustomersActions {
35
40
  * cachePrefix: "example:",
36
41
  * });
37
42
  *
38
- * const customer = await customersActions.getCustomerDoc(123);
39
- * const orders = await customersActions.getCustomerOrders(123);
43
+ * const customer = await customersActions.getCustomerDoc(4096);
44
+ * const orders = await customersActions.getCustomerOrders(4096);
40
45
  * ``` */
41
46
  export declare function createCustomersActions(api: CustomersApiClient, config?: CustomersActionsConfig): CustomersActions;
42
47
  //# sourceMappingURL=customers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"customers.d.ts","sourceRoot":"","sources":["../../src/actions/customers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC1E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAKL,KAAK,OAAO,EACZ,KAAK,cAAc,EACpB,MAAM,oBAAoB,CAAC;AAa5B,sEAAsE;AACtE,MAAM,MAAM,kBAAkB,GAAG,IAAI,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;AAE7D;;;;GAIG;AACH,MAAM,MAAM,sBAAsB,GAAG,cAAc,CAAC;AAEpD,MAAM,WAAW,gBAAgB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C,UAAU,CAAC,CAAC;IACjG,sBAAsB,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IAClF,2FAA2F;IAC3F,kBAAkB,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CAC9D;AAED;;;;;;;;;;;;;;;SAeS;AACT,wBAAgB,sBAAsB,CACpC,GAAG,EAAE,kBAAkB,EACvB,MAAM,GAAE,sBAA2B,GAClC,gBAAgB,CA2FlB"}
@@ -1,5 +1,5 @@
1
1
  import type { AugurAPI } from "@simpleapps-com/augur-api";
2
- import type { MenuItem, TJoomlaContent, TMenu, TPasswordVerification } from "@simpleapps-com/augur-utils";
2
+ import type { AddressId, MenuItem, TJoomlaContent, TMenu, TPasswordVerification } from "@simpleapps-com/augur-utils";
3
3
  import type { ListResult } from "../sdk-call";
4
4
  import { type SpecReadConfig } from "../cache/spec-read";
5
5
  /** Derived from augur-api SDK — keeps types in sync automatically. */
@@ -13,7 +13,8 @@ export interface NormalizedUserProfile {
13
13
  id: string;
14
14
  name: string;
15
15
  email: string;
16
- customerId: string;
16
+ /** The user's P21 customer, or null when the profile has none ("" or "0" in Joomla; atlas#95). */
17
+ customerId: AddressId | null;
17
18
  permissions: string[];
18
19
  }
19
20
  export interface JoomlaActions {
@@ -1 +1 @@
1
- {"version":3,"file":"joomla.d.ts","sourceRoot":"","sources":["../../src/actions/joomla.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,KAAK,EACV,QAAQ,EACR,cAAc,EACd,KAAK,EACL,qBAAqB,EAEtB,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAML,KAAK,cAAc,EACpB,MAAM,oBAAoB,CAAC;AAiB5B,sEAAsE;AACtE,MAAM,M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GAAE,oBAAyB,GAChC,cAAc,CAiFhB"}
@@ -0,0 +1,9 @@
1
+ import { type AddressIdInput } from "@simpleapps-com/augur-utils";
2
+ import type { AddressId } from "../address-id";
3
+ /**
4
+ * The customer a customer-scoped call is asked for: the first usable one of `candidates`
5
+ * (augur-utils `resolveAddressId`, so "", "0" and 0 are passed over), or a throw with the
6
+ * caller's `refusal` when none is (the proved `customerRefusalOf`, atlas#95).
7
+ */
8
+ export declare function requireCustomer(refusal: string, ...candidates: AddressIdInput[]): AddressId;
9
+ //# sourceMappingURL=require-customer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"require-customer.d.ts","sourceRoot":"","sources":["../../src/actions/require-customer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,cAAc,EAAE,MAAM,6BAA6B,CAAC;AACpF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAG/C;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,UAAU,EAAE,cAAc,EAAE,GAAG,SAAS,CAM3F"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * augur-server's `AddressId`: the same brand as augur-utils' (foundation's `PosInt`), so each is
3
+ * the other's type; `test/rules.test.ts` pins that. Declared here, not imported, because lsc reads
4
+ * a type from another package out of its built `.d.ts`, where the `//@ type` line is gone
5
+ * (models/LSC-GAPS.md); the proved `rules.ts` imports it. Make values with augur-utils'
6
+ * `resolveAddressId` / `addressIdOf` (atlas#95).
7
+ */
8
+ /** A usable P21 address id (a customer, ship-to, supplier or vendor id): a whole number ≥ 1. */
9
+ export type AddressId = number & {
10
+ readonly __posInt: true;
11
+ };
12
+ //# sourceMappingURL=address-id.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"address-id.d.ts","sourceRoot":"","sources":["../src/address-id.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,gGAAgG;AAEhG,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAA;CAAE,CAAC"}
package/dist/api.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  queryAction,
3
3
  queryActionRaw
4
- } from "./chunk-G5P4IDK7.js";
4
+ } from "./chunk-OTZUEADV.js";
5
5
  import {
6
6
  answersFullOf,
7
7
  apiMessageOf,
@@ -9,7 +9,7 @@ import {
9
9
  bodyOutcomeOf,
10
10
  isCrossOrigin,
11
11
  runsOf
12
- } from "./chunk-4KPTIVYO.js";
12
+ } from "./chunk-5X2QWOTO.js";
13
13
  import "./chunk-BG4G5QUQ.js";
14
14
 
15
15
  // src/api-handler.ts
package/dist/auth.d.ts CHANGED
@@ -33,8 +33,12 @@ export interface AugurJWT {
33
33
  export interface AugurAuthCallbacks {
34
34
  /** Fetch user profile from the Augur API given the user's Joomla ID. */
35
35
  getUserProfile: (userId: string) => Promise<AugurUser | null>;
36
- /** Look up or create a cart header for the authenticated user. */
37
- cartHdrLookup?: (userId: string | number, token: string, contactId: string | number, customerId: string | number) => Promise<{
36
+ /**
37
+ * Look up or create a cart header for the authenticated user. `customerId` is always a usable
38
+ * P21 customer id (resolved by augur-utils `resolveAddressId`): without one no lookup is made
39
+ * (atlas#95).
40
+ */
41
+ cartHdrLookup?: (userId: string | number, token: string, contactId: string | number, customerId: number) => Promise<{
38
42
  cartHdrUid?: number;
39
43
  } | null>;
40
44
  }
@@ -1 +1 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAKhD,sDAAsD;AACtD,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,OAAO,CAAC;IACpB,IAAI,CAAC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G,cAAc,CAsHjF"}
package/dist/auth.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  createAuthConfig
3
- } from "./chunk-AUIC4HS2.js";
4
- import "./chunk-4KPTIVYO.js";
3
+ } from "./chunk-AEFUT3MB.js";
4
+ import "./chunk-5X2QWOTO.js";
5
5
  import "./chunk-BG4G5QUQ.js";
6
6
  export {
7
7
  createAuthConfig
@@ -5,6 +5,7 @@ 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,7 +23,7 @@ import {
23
23
  shouldCache,
24
24
  takesItemId,
25
25
  ttlFor
26
- } from "./chunk-4KPTIVYO.js";
26
+ } from "./chunk-5X2QWOTO.js";
27
27
  import {
28
28
  isBlank,
29
29
  upperAscii
@@ -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-4CU4UNBH.js.map