@nymbalhq/platform 1.4.0 → 1.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.
Files changed (29) hide show
  1. package/dist/{chunk-SNNK2OX3.js → chunk-NNDIAIT6.js} +73 -5
  2. package/dist/chunk-NNDIAIT6.js.map +1 -0
  3. package/dist/{chunk-GMV3B3SC.js → chunk-TRLERRUI.js} +424 -137
  4. package/dist/chunk-TRLERRUI.js.map +1 -0
  5. package/dist/db/schema/index.d.ts +795 -105
  6. package/dist/db/schema/index.js +1 -1
  7. package/dist/index.d.ts +218 -85
  8. package/dist/index.js +658 -199
  9. package/dist/index.js.map +1 -1
  10. package/dist/register-SBGUI2L5.js +8 -0
  11. package/migrations/postgres/0016_email_suppressions.sql +7 -0
  12. package/migrations/postgres/0017_order_shipments.sql +14 -0
  13. package/migrations/postgres/0018_order_key_expiry.sql +8 -0
  14. package/migrations/postgres/meta/0016_snapshot.json +2233 -0
  15. package/migrations/postgres/meta/0017_snapshot.json +2300 -0
  16. package/migrations/postgres/meta/0018_snapshot.json +2306 -0
  17. package/migrations/postgres/meta/_journal.json +21 -0
  18. package/migrations/sqlite/0016_email_suppressions.sql +7 -0
  19. package/migrations/sqlite/0017_order_shipments.sql +9 -0
  20. package/migrations/sqlite/0018_order_key_expiry.sql +25 -0
  21. package/migrations/sqlite/meta/0016_snapshot.json +1981 -0
  22. package/migrations/sqlite/meta/0017_snapshot.json +2041 -0
  23. package/migrations/sqlite/meta/0018_snapshot.json +2048 -0
  24. package/migrations/sqlite/meta/_journal.json +21 -0
  25. package/package.json +17 -47
  26. package/dist/chunk-GMV3B3SC.js.map +0 -1
  27. package/dist/chunk-SNNK2OX3.js.map +0 -1
  28. package/dist/register-N2XGSFUF.js +0 -8
  29. /package/dist/{register-N2XGSFUF.js.map → register-SBGUI2L5.js.map} +0 -0
@@ -5,7 +5,7 @@ import {
5
5
  settings,
6
6
  settings2,
7
7
  sqlite_exports
8
- } from "./chunk-SNNK2OX3.js";
8
+ } from "./chunk-NNDIAIT6.js";
9
9
 
10
10
  // src/routes/register.ts
11
11
  import {
@@ -2420,6 +2420,18 @@ function createCustomerService(deps) {
2420
2420
  await repos.customer.update(tx, customerId, { addresses, updatedAt: now });
2421
2421
  await publishUpdated(tx, customerId);
2422
2422
  });
2423
+ },
2424
+ async addNote(customerId, note) {
2425
+ await store.transaction(async (tx) => {
2426
+ const customer = await loadOrThrow(tx, customerId);
2427
+ audit.note("customer.addNote", [{ type: "customer", id: customerId }]);
2428
+ const notes = customer.metadata.adminNotes ?? [];
2429
+ await repos.customer.update(tx, customerId, {
2430
+ metadata: { ...customer.metadata, adminNotes: [...notes, note] },
2431
+ updatedAt: /* @__PURE__ */ new Date()
2432
+ });
2433
+ await publishUpdated(tx, customerId);
2434
+ });
2423
2435
  }
2424
2436
  };
2425
2437
  }
@@ -2453,16 +2465,28 @@ function hashOrderKey(key) {
2453
2465
  function isOrderKey(value) {
2454
2466
  return typeof value === "string" && ORDER_KEY.test(value);
2455
2467
  }
2468
+ function orderEmailMatches(orderEmail, given) {
2469
+ return orderEmail.trim().toLowerCase() === given.trim().toLowerCase();
2470
+ }
2456
2471
 
2457
2472
  // src/services/order-service.ts
2458
2473
  var NO_CONFIRMATION_DUE = /* @__PURE__ */ new Set(["pending", "cancelled"]);
2459
2474
  function createOrderService(deps) {
2460
2475
  const { store, repos, publisher } = deps;
2476
+ async function keyState(orderId, key, now) {
2477
+ if (!isOrderKey(key)) return "none";
2478
+ return store.read((tx) => repos.orderAccessKey.opens(tx, orderId, hashOrderKey(key), now));
2479
+ }
2461
2480
  async function requireOrder(tx, id2) {
2462
2481
  const order = await repos.order.findById(tx, id2);
2463
2482
  if (!order) throw new NotFoundError7("order", id2);
2464
2483
  return order;
2465
2484
  }
2485
+ async function lockOrder(tx, id2) {
2486
+ const order = await repos.order.lock(tx, id2);
2487
+ if (!order) throw new NotFoundError7("order", id2);
2488
+ return order;
2489
+ }
2466
2490
  async function doTransition(tx, order, toStatus, actor, note) {
2467
2491
  assertOrderTransition(order.status, toStatus);
2468
2492
  const now = /* @__PURE__ */ new Date();
@@ -2534,8 +2558,19 @@ function createOrderService(deps) {
2534
2558
  return store.read((tx) => repos.order.listByCustomer(tx, customerId));
2535
2559
  },
2536
2560
  async keyOpens(orderId, key) {
2537
- if (!isOrderKey(key)) return false;
2538
- return store.read((tx) => repos.orderAccessKey.opens(tx, orderId, hashOrderKey(key)));
2561
+ return await keyState(orderId, key, /* @__PURE__ */ new Date()) === "open";
2562
+ },
2563
+ keyState(orderId, key, now = /* @__PURE__ */ new Date()) {
2564
+ return keyState(orderId, key, now);
2565
+ },
2566
+ async requestLink(orderNumber, email) {
2567
+ const order = await store.read((tx) => repos.order.findByOrderNumber(tx, orderNumber));
2568
+ if (order === null || NO_CONFIRMATION_DUE.has(order.status)) return;
2569
+ if (!orderEmailMatches(order.email, email)) return;
2570
+ await store.transaction(async () => {
2571
+ audit.note("order.requestLink", [{ type: "order", id: order.id }]);
2572
+ await publisher.publish(EVT_ORDER_CONFIRMATION_RESEND_REQUESTED, { orderId: order.id });
2573
+ });
2539
2574
  },
2540
2575
  async updateStatus(id2, toStatus, actor, note = "") {
2541
2576
  return store.transaction(async (tx) => {
@@ -2553,7 +2588,7 @@ function createOrderService(deps) {
2553
2588
  async markShipped(id2, trackingNumber, carrier, actor) {
2554
2589
  return store.transaction(async (tx) => {
2555
2590
  audit.note("order.ship", [{ type: "order", id: id2 }]);
2556
- const order = await requireOrder(tx, id2);
2591
+ const order = await lockOrder(tx, id2);
2557
2592
  const fresh = await doTransition(
2558
2593
  tx,
2559
2594
  order,
@@ -2561,6 +2596,12 @@ function createOrderService(deps) {
2561
2596
  actor,
2562
2597
  `Shipped via ${carrier}: ${trackingNumber}`
2563
2598
  );
2599
+ await repos.orderShipment.record(tx, {
2600
+ orderId: fresh.id,
2601
+ carrier,
2602
+ trackingNumber,
2603
+ at: /* @__PURE__ */ new Date()
2604
+ });
2564
2605
  await publisher.publish(EVT_ORDER_SHIPPED, {
2565
2606
  orderId: fresh.id,
2566
2607
  trackingNumber,
@@ -2572,7 +2613,7 @@ function createOrderService(deps) {
2572
2613
  async markDelivered(id2, actor) {
2573
2614
  return store.transaction(async (tx) => {
2574
2615
  audit.note("order.markDelivered", [{ type: "order", id: id2 }]);
2575
- const order = await requireOrder(tx, id2);
2616
+ const order = await lockOrder(tx, id2);
2576
2617
  const fresh = await doTransition(tx, order, "delivered", actor, "Delivered");
2577
2618
  await publisher.publish(EVT_ORDER_DELIVERED, { orderId: fresh.id });
2578
2619
  return fresh;
@@ -2952,7 +2993,10 @@ function settlementOf(answer, row) {
2952
2993
  async function refreshRefunded(repos, tx, orderId, at) {
2953
2994
  const refunds = await repos.orderRefund.listByOrder(tx, orderId);
2954
2995
  const refundedMinor = refunds.filter((r) => r.status === "succeeded").reduce((sum, r) => sum + r.amountMinor, 0);
2955
- await repos.order.setRefunded(tx, orderId, refundedMinor, at);
2996
+ const current = await repos.order.findById(tx, orderId);
2997
+ if (current.refundedMinor !== refundedMinor) {
2998
+ await repos.order.setRefunded(tx, orderId, refundedMinor, at);
2999
+ }
2956
3000
  return { refunds, refundedMinor };
2957
3001
  }
2958
3002
  function createRefundService(deps) {
@@ -3112,6 +3156,8 @@ function createRefundService(deps) {
3112
3156
  }
3113
3157
 
3114
3158
  // src/services/checkout-service.ts
3159
+ var CHECKOUT_KEYS_KEPT = 5;
3160
+ var DEFAULT_CHECKOUT_KEY_LIFETIME_MS = 48 * 36e5;
3115
3161
  var StockUnavailable = class extends Error {
3116
3162
  constructor(variantId) {
3117
3163
  super(`stock unavailable for variant ${variantId}`);
@@ -3148,24 +3194,33 @@ function sameLines(order, cart) {
3148
3194
  }
3149
3195
  function createCheckoutService(deps) {
3150
3196
  const { store, repos, publisher, logger, cart, orders, inventory, payments, currency } = deps;
3151
- async function mintKey(tx, orderId) {
3197
+ const keyLifetimeMs = deps.keyLifetimeMs ?? DEFAULT_CHECKOUT_KEY_LIFETIME_MS;
3198
+ async function mintKey(tx, order) {
3199
+ if (order.customerId !== null) return void 0;
3152
3200
  const { key, hash } = mintOrderKey();
3201
+ const createdAt = /* @__PURE__ */ new Date();
3153
3202
  await repos.orderAccessKey.insert(tx, {
3154
3203
  id: uuidv712(),
3155
- orderId,
3204
+ orderId: order.id,
3156
3205
  keyHash: hash,
3157
3206
  purpose: "checkout",
3158
- createdAt: /* @__PURE__ */ new Date()
3207
+ createdAt,
3208
+ expiresAt: new Date(createdAt.getTime() + keyLifetimeMs)
3159
3209
  });
3210
+ await repos.orderAccessKey.keepNewest(tx, order.id, "checkout", CHECKOUT_KEYS_KEPT);
3160
3211
  return key;
3161
3212
  }
3213
+ function withKey(answer, orderKey) {
3214
+ return orderKey === void 0 ? answer : { ...answer, orderKey };
3215
+ }
3162
3216
  async function withOrderKey(err) {
3163
3217
  if (!(err instanceof CheckoutError2)) return err;
3164
3218
  const orderNumber = err.context["orderNumber"];
3165
3219
  if (typeof orderNumber !== "string") return err;
3166
3220
  const order = await store.read((tx) => repos.order.findByOrderNumber(tx, orderNumber));
3167
3221
  if (order === null) return err;
3168
- err.context["orderKey"] = await store.transaction((tx) => mintKey(tx, order.id));
3222
+ const orderKey = await store.transaction((tx) => mintKey(tx, order));
3223
+ if (orderKey !== void 0) err.context["orderKey"] = orderKey;
3169
3224
  return err;
3170
3225
  }
3171
3226
  async function cartEmpty(token) {
@@ -3461,7 +3516,7 @@ function createCheckoutService(deps) {
3461
3516
  const reason = closed.get(paymentIntentId);
3462
3517
  if (reason === void 0) {
3463
3518
  if (sameLines(pending, cartDoc)) {
3464
- const orderKey = await mintKey(tx, pending.id);
3519
+ const orderKey = await mintKey(tx, pending);
3465
3520
  return { kind: "existing", order: { ...pending, paymentIntentId }, orderKey };
3466
3521
  }
3467
3522
  return { kind: "cancel-first", order: { ...pending, paymentIntentId } };
@@ -3519,7 +3574,7 @@ function createCheckoutService(deps) {
3519
3574
  },
3520
3575
  cartToken: cartDoc.token
3521
3576
  });
3522
- return { kind: "placed", order, orderKey: await mintKey(tx, order.id) };
3577
+ return { kind: "placed", order, orderKey: await mintKey(tx, order) };
3523
3578
  }
3524
3579
  async function answerExisting(order) {
3525
3580
  const paymentIntent = await payments.getPaymentIntent(order.paymentIntentId);
@@ -3659,11 +3714,11 @@ function createCheckoutService(deps) {
3659
3714
  for (let attempt = 0; ; attempt += 1) {
3660
3715
  const placement = await store.transaction((tx) => place(tx, input, closed));
3661
3716
  if (placement.kind === "placed") {
3662
- return { ...await pay(input, placement.order), orderKey: placement.orderKey };
3717
+ return withKey(await pay(input, placement.order), placement.orderKey);
3663
3718
  }
3664
3719
  if (placement.kind === "existing") {
3665
3720
  const answer = await answerExisting(placement.order);
3666
- if (!("closed" in answer)) return { ...answer, orderKey: placement.orderKey };
3721
+ if (!("closed" in answer)) return withKey(answer, placement.orderKey);
3667
3722
  closed.set(placement.order.paymentIntentId, answer.closed);
3668
3723
  continue;
3669
3724
  }
@@ -3771,12 +3826,18 @@ function createRecentlyViewedService(deps) {
3771
3826
  import { v7 as uuidv713 } from "uuid";
3772
3827
  import {
3773
3828
  EVT_ALERT_CONFIRMED,
3829
+ EVT_ALERT_REPEATED,
3774
3830
  EVT_ALERT_REQUESTED,
3775
3831
  EVT_ALERT_SENT,
3776
3832
  EVT_ALERT_UNSUBSCRIBED,
3777
3833
  HttpError as HttpError3
3778
3834
  } from "@nymbalhq/types";
3779
3835
 
3836
+ // src/email-address.ts
3837
+ function normaliseEmail(value) {
3838
+ return value.trim().toLowerCase();
3839
+ }
3840
+
3780
3841
  // src/services/alert-token.ts
3781
3842
  import { randomBytes as randomBytes2 } from "crypto";
3782
3843
  function newAlertToken() {
@@ -3820,7 +3881,7 @@ function createAlertService(deps) {
3820
3881
  }
3821
3882
  const row = await repos.alertSubscription.upsertPending(tx, {
3822
3883
  id: uuidv713(),
3823
- email: email.trim().toLowerCase(),
3884
+ email: normaliseEmail(email),
3824
3885
  kind,
3825
3886
  variantId,
3826
3887
  productId: variant.productId,
@@ -3830,14 +3891,15 @@ function createAlertService(deps) {
3830
3891
  baselinePriceMinor: kind === "price_drop" ? variant.priceMinor : null,
3831
3892
  at: /* @__PURE__ */ new Date()
3832
3893
  });
3833
- if (row.status === "pending") {
3834
- await publisher.publish(EVT_ALERT_REQUESTED, {
3894
+ await publisher.publish(
3895
+ row.status === "pending" ? EVT_ALERT_REQUESTED : EVT_ALERT_REPEATED,
3896
+ {
3835
3897
  subscriptionId: row.id,
3836
3898
  kind,
3837
3899
  variantId,
3838
3900
  productId: variant.productId
3839
- });
3840
- }
3901
+ }
3902
+ );
3841
3903
  return { status: "pending" };
3842
3904
  });
3843
3905
  },
@@ -3911,7 +3973,7 @@ function emailDelivers(email) {
3911
3973
  return email.providerName !== "native";
3912
3974
  }
3913
3975
  function buildServices(deps) {
3914
- const { config, store, repos, publisher, logger, payments, searchAdapter, email } = deps;
3976
+ const { config, store, repos, publisher, logger, payments, searchAdapter, email, jwtSecret } = deps;
3915
3977
  const inventory = createInventoryService({
3916
3978
  store,
3917
3979
  repos,
@@ -3942,7 +4004,8 @@ function buildServices(deps) {
3942
4004
  orders,
3943
4005
  inventory,
3944
4006
  payments,
3945
- currency: config.store.currency
4007
+ currency: config.store.currency,
4008
+ keyLifetimeMs: parseDurationToMs(config.commerce.orders.keyLifetime.checkout)
3946
4009
  });
3947
4010
  return {
3948
4011
  product: createProductService({
@@ -3967,7 +4030,7 @@ function buildServices(deps) {
3967
4030
  repos,
3968
4031
  publisher,
3969
4032
  logger: logger.child({ service: "auth" }),
3970
- jwtSecret: config.security.auth.jwtSecret,
4033
+ jwtSecret,
3971
4034
  accessTtl: config.security.auth.accessTtl,
3972
4035
  refreshTtl: config.security.auth.refreshTtl
3973
4036
  }),
@@ -4172,7 +4235,7 @@ function registerCheckoutRoutes(adapter, checkout) {
4172
4235
  totalMinor: result.totalMinor,
4173
4236
  orderStatus: result.orderStatus,
4174
4237
  payment: result.payment,
4175
- orderKey: result.orderKey
4238
+ ...result.orderKey !== void 0 && { orderKey: result.orderKey }
4176
4239
  });
4177
4240
  } catch (err) {
4178
4241
  return renderError(err);
@@ -4183,6 +4246,7 @@ function registerCheckoutRoutes(adapter, checkout) {
4183
4246
  // src/routes/orders.ts
4184
4247
  import {
4185
4248
  NotFoundError as NotFoundError11,
4249
+ ORDER_EMAIL_HEADER,
4186
4250
  ORDER_KEY_HEADER
4187
4251
  } from "@nymbalhq/types";
4188
4252
 
@@ -4209,10 +4273,45 @@ function requireRole(role, handler) {
4209
4273
  }
4210
4274
 
4211
4275
  // src/routes/orders.ts
4212
- function shopperOrder(doc) {
4213
- const { partitionKey: _partitionKey, sortKey: _sortKey, history: _history, ...order } = doc;
4214
- return { ...order, metadata: {}, notes: "", paymentIntentId: null };
4276
+ function keyedOrder(doc) {
4277
+ const { phone: _phone, company: _company, ...shippingAddress } = doc.shippingAddress;
4278
+ return {
4279
+ orderNumber: doc.orderNumber,
4280
+ status: doc.status,
4281
+ timeline: doc.timeline,
4282
+ lineItems: doc.lineItems,
4283
+ subtotalMinor: doc.subtotalMinor,
4284
+ taxTotalMinor: doc.taxTotalMinor,
4285
+ shippingTotalMinor: doc.shippingTotalMinor,
4286
+ discountTotalMinor: doc.discountTotalMinor,
4287
+ totalMinor: doc.totalMinor,
4288
+ currency: doc.currency,
4289
+ createdAt: doc.createdAt,
4290
+ shippingAddress
4291
+ };
4292
+ }
4293
+ function ownerOrder(doc) {
4294
+ return {
4295
+ id: doc.id,
4296
+ orderNumber: doc.orderNumber,
4297
+ status: doc.status,
4298
+ timeline: doc.timeline,
4299
+ lineItems: doc.lineItems,
4300
+ subtotalMinor: doc.subtotalMinor,
4301
+ taxTotalMinor: doc.taxTotalMinor,
4302
+ shippingTotalMinor: doc.shippingTotalMinor,
4303
+ discountTotalMinor: doc.discountTotalMinor,
4304
+ totalMinor: doc.totalMinor,
4305
+ refundedMinor: doc.refundedMinor,
4306
+ currency: doc.currency,
4307
+ email: doc.email,
4308
+ billingAddress: doc.billingAddress,
4309
+ shippingAddress: doc.shippingAddress,
4310
+ createdAt: doc.createdAt,
4311
+ updatedAt: doc.updatedAt
4312
+ };
4215
4313
  }
4314
+ var LINK_ANSWER = { sent: "if-matched" };
4216
4315
  function registerOrderRoutes(adapter, orders, documentStore) {
4217
4316
  adapter.registerRoute(
4218
4317
  "GET",
@@ -4224,7 +4323,7 @@ function registerOrderRoutes(adapter, orders, documentStore) {
4224
4323
  partitionKey: { field: "partitionKey", value: `customer:${customerId}` },
4225
4324
  limit: 50
4226
4325
  });
4227
- return ok(result.items.map(shopperOrder), { nextCursor: result.nextCursor });
4326
+ return ok(result.items.map(ownerOrder), { nextCursor: result.nextCursor });
4228
4327
  } catch (err) {
4229
4328
  return renderError(err);
4230
4329
  }
@@ -4237,12 +4336,26 @@ function registerOrderRoutes(adapter, orders, documentStore) {
4237
4336
  const doc = await documentStore.get("orders", orderNumber);
4238
4337
  if (!doc) throw new NotFoundError11("order", orderNumber);
4239
4338
  const userId = ctx.auth?.userId;
4240
- const owner = doc.customerId !== null && userId !== void 0 && doc.customerId === userId;
4339
+ if (doc.customerId !== null && userId !== void 0 && doc.customerId === userId) {
4340
+ return ok(ownerOrder(doc));
4341
+ }
4241
4342
  const key = ctx.headers[ORDER_KEY_HEADER];
4242
- if (!owner && !(typeof key === "string" && await orders.keyOpens(doc.id, key))) {
4243
- throw new NotFoundError11("order", orderNumber);
4343
+ const state = typeof key === "string" ? await orders.keyState(doc.id, key) : "none";
4344
+ if (state === "open") return ok(keyedOrder(doc));
4345
+ if (state === "expired") {
4346
+ const email = ctx.headers[ORDER_EMAIL_HEADER];
4347
+ if (email === void 0) {
4348
+ return fail(
4349
+ "orders.key_expired",
4350
+ "This order link has expired: give the order's email to open it",
4351
+ 404
4352
+ );
4353
+ }
4354
+ if (typeof email === "string" && orderEmailMatches(doc.email, email)) {
4355
+ return ok(keyedOrder(doc));
4356
+ }
4244
4357
  }
4245
- return ok(shopperOrder(doc));
4358
+ throw new NotFoundError11("order", orderNumber);
4246
4359
  } catch (err) {
4247
4360
  return renderError(err);
4248
4361
  }
@@ -4251,6 +4364,15 @@ function registerOrderRoutes(adapter, orders, documentStore) {
4251
4364
  ...await readOrder(ctx),
4252
4365
  headers: { "Cache-Control": "no-store" }
4253
4366
  }));
4367
+ adapter.registerRoute("POST", "/api/orders/link", async (ctx) => {
4368
+ try {
4369
+ const { orderNumber, email } = ctx.body;
4370
+ await orders.requestLink(orderNumber, email);
4371
+ return ok(LINK_ANSWER, void 0, 202);
4372
+ } catch (err) {
4373
+ return renderError(err);
4374
+ }
4375
+ });
4254
4376
  }
4255
4377
 
4256
4378
  // src/routes/customers.ts
@@ -5154,6 +5276,7 @@ function registerAdminInventoryRoutes(adapter, deps) {
5154
5276
  }
5155
5277
 
5156
5278
  // src/routes/admin-customers.ts
5279
+ import { NotFoundError as NotFoundError13 } from "@nymbalhq/types";
5157
5280
  function computeStats(orders) {
5158
5281
  if (orders.length === 0) {
5159
5282
  return {
@@ -5296,22 +5419,12 @@ function registerAdminCustomersRoutes(adapter, deps) {
5296
5419
  actor: `admin:${ctx.auth.userId}`,
5297
5420
  at: (/* @__PURE__ */ new Date()).toISOString()
5298
5421
  };
5299
- const noted = await store.transaction(async (tx) => {
5300
- const raw = await repos.customer.findById(tx, id2);
5301
- if (!raw) return false;
5302
- audit.note("customer.addNote", [{ type: "customer", id: id2 }]);
5303
- const existingNotes = raw.metadata.adminNotes ?? [];
5304
- const updatedMeta = {
5305
- ...raw.metadata,
5306
- adminNotes: [...existingNotes, newNote]
5307
- };
5308
- await repos.customer.update(tx, id2, {
5309
- metadata: updatedMeta,
5310
- updatedAt: /* @__PURE__ */ new Date()
5311
- });
5312
- return true;
5313
- });
5314
- if (!noted) return fail("customers.not_found", `Customer not found: ${id2}`, 404);
5422
+ try {
5423
+ await deps.customer.addNote(id2, newNote);
5424
+ } catch (err) {
5425
+ if (err instanceof NotFoundError13) return notFound3(id2)();
5426
+ throw err;
5427
+ }
5315
5428
  return ok({ note: newNote });
5316
5429
  } catch (err) {
5317
5430
  return renderError(err);
@@ -5463,26 +5576,39 @@ function settingAad(slot, path) {
5463
5576
  // src/settings/load.ts
5464
5577
  import { ConfigError as ConfigError4 } from "@nymbalhq/types";
5465
5578
 
5466
- // src/adapters/loader.ts
5467
- import { existsSync } from "fs";
5468
- import { join as join2 } from "path";
5579
+ // src/adapters/resolve.ts
5580
+ import { existsSync, readFileSync, realpathSync } from "fs";
5581
+ import { dirname, join as join2 } from "path";
5582
+ import { fileURLToPath, pathToFileURL } from "url";
5583
+ import {
5584
+ ADAPTER_CATALOGUE,
5585
+ BUILT_IN,
5586
+ conventionPackage,
5587
+ slotFolder,
5588
+ suggestProvider
5589
+ } from "@nymbalhq/config";
5469
5590
  import {
5470
5591
  ConfigError as ConfigError2
5471
5592
  } from "@nymbalhq/types";
5472
- var PROVIDER_PACKAGES = {
5473
- payments: { stripe: { package: "@nymbalhq/adapter-stripe", sdk: "stripe" } },
5474
- ai: { anthropic: { package: "@nymbalhq/adapter-anthropic", sdk: "@anthropic-ai/sdk" } },
5475
- email: { smtp: { package: "@nymbalhq/adapter-smtp", sdk: "nodemailer" } },
5476
- documentStore: {
5477
- redis: { package: "@nymbalhq/doc-store-redis", sdk: "ioredis" },
5478
- "postgres-jsonb": { package: "@nymbalhq/doc-store-postgres-jsonb", sdk: "pg" }
5479
- },
5480
- eventBus: {
5481
- "redis-streams": { package: "@nymbalhq/event-bus-redis-streams", sdk: "ioredis" }
5482
- },
5483
- media: { s3: { package: "@nymbalhq/media-s3", sdk: "@aws-sdk/client-s3" } },
5484
- security: { cloudflare: { package: "@nymbalhq/security-cloudflare" } }
5485
- };
5593
+ import { resolve as resolveFrom } from "import-meta-resolve";
5594
+ function catalogued(slot, provider) {
5595
+ const entries = ADAPTER_CATALOGUE[slot];
5596
+ return Object.hasOwn(entries, provider) ? entries[provider] : void 0;
5597
+ }
5598
+ function resolveChoice(slot, choice) {
5599
+ if (choice.provider === "custom") return { kind: "custom" };
5600
+ if (BUILT_IN[slot].includes(choice.provider)) return { kind: "built-in" };
5601
+ if (choice.package !== void 0) {
5602
+ return { kind: "package", package: choice.package, named: "package" };
5603
+ }
5604
+ const sdk = catalogued(slot, choice.provider)?.sdk;
5605
+ return {
5606
+ kind: "package",
5607
+ package: conventionPackage(slot, choice.provider),
5608
+ named: "convention",
5609
+ ...sdk !== void 0 && { sdk }
5610
+ };
5611
+ }
5486
5612
  var INFRASTRUCTURE_SLOTS = /* @__PURE__ */ new Set(["documentStore", "eventBus", "media"]);
5487
5613
  function choiceOf(slot, provider) {
5488
5614
  if (slot === "security") return `security.adapter '${provider}'`;
@@ -5512,6 +5638,14 @@ function packageManager(env, cwd) {
5512
5638
  function installLine(packages, env, cwd) {
5513
5639
  return [INSTALL_VERBS[packageManager(env, cwd)], ...packages].join(" ");
5514
5640
  }
5641
+ var DEDUPE_LINES = {
5642
+ npm: "npm dedupe",
5643
+ pnpm: "pnpm dedupe",
5644
+ yarn: "yarn dedupe",
5645
+ bun: "bun install --force"
5646
+ };
5647
+ var TYPES = "@nymbalhq/types";
5648
+ var TYPES_DUPLICATE = "adapter.types_duplicate";
5515
5649
  function packageOf(specifier) {
5516
5650
  const parts = specifier.split("/");
5517
5651
  return specifier.startsWith("@") ? parts.slice(0, 2).join("/") : parts[0];
@@ -5519,48 +5653,164 @@ function packageOf(specifier) {
5519
5653
  function missingPackage(error) {
5520
5654
  if (error?.code !== "ERR_MODULE_NOT_FOUND") return null;
5521
5655
  const match = /Cannot find (?:package|module) '([^']+)'/.exec(String(error.message));
5522
- return match?.[1] === void 0 ? null : packageOf(match[1]);
5656
+ const specifier = match?.[1];
5657
+ if (specifier === void 0 || /^(?:[/.]|file:)/.test(specifier)) return null;
5658
+ return packageOf(specifier);
5523
5659
  }
5524
5660
  function isSetting(value) {
5525
5661
  const s = value;
5526
5662
  return typeof s === "object" && s !== null && typeof s.path === "string" && s.path !== "" && typeof s.label === "string" && typeof s.secret === "boolean" && (s.env === void 0 || typeof s.env === "string");
5527
5663
  }
5528
- async function importProviderPackage(slot, provider, env) {
5529
- const entry = PROVIDER_PACKAGES[slot]?.[provider];
5530
- if (entry === void 0) return void 0;
5531
- let mod;
5664
+ var shown = (value) => typeof value === "string" ? `'${value}'` : value === void 0 ? "missing" : String(value);
5665
+ function checkAdapterModule(mod, slot, provider, pkg) {
5666
+ const m = typeof mod === "object" && mod !== null ? mod : {};
5667
+ const context2 = { slot, provider, package: pkg };
5668
+ if (typeof m["createAdapter"] !== "function") {
5669
+ throw new ConfigError2(
5670
+ `${pkg} exports no createAdapter(ctx) function (its createAdapter export is ${typeof m["createAdapter"]})`,
5671
+ { code: "adapter.package_invalid", context: { ...context2, export: "createAdapter" } }
5672
+ );
5673
+ }
5674
+ if (m["slot"] !== slot) {
5675
+ throw new ConfigError2(
5676
+ `${pkg} is loaded for the '${slot}' slot, but its slot export is ${shown(m["slot"])}: it must export slot = '${slot}'`,
5677
+ {
5678
+ code: "adapter.wrong_slot",
5679
+ context: { ...context2, export: "slot", expected: slot, actual: m["slot"] }
5680
+ }
5681
+ );
5682
+ }
5683
+ if (provider !== "custom" && m["provider"] !== provider) {
5684
+ throw new ConfigError2(
5685
+ `${pkg} is loaded for ${choiceOf(slot, provider)}, but its provider export is ${shown(m["provider"])}: it must export provider = '${provider}'`,
5686
+ {
5687
+ code: "adapter.package_invalid",
5688
+ context: { ...context2, export: "provider", expected: provider, actual: m["provider"] }
5689
+ }
5690
+ );
5691
+ }
5692
+ const settings3 = m["settings"];
5693
+ if (settings3 !== void 0 && !(Array.isArray(settings3) && settings3.every(isSetting))) {
5694
+ throw new ConfigError2(
5695
+ `${pkg} exports \`settings\` that is not an array of { path, label, secret, env? }`,
5696
+ { code: "adapter.package_invalid", context: { ...context2, export: "settings" } }
5697
+ );
5698
+ }
5699
+ return m;
5700
+ }
5701
+ function importFailure(slot, provider, resolution, error, env) {
5702
+ if (error instanceof ConfigError2 && error.code === TYPES_DUPLICATE) {
5703
+ return typesDuplicate(slot, provider, resolution.package, error, env);
5704
+ }
5705
+ const missing = missingPackage(error);
5706
+ if (missing === null) return error;
5707
+ const pkg = resolution.package;
5708
+ const context2 = { slot, provider, package: pkg };
5709
+ if (resolution.named === "convention" && missing === pkg && catalogued(slot, provider) === void 0) {
5710
+ const suggestion = suggestProvider(slot, provider);
5711
+ const unknown = `unknown ${slot === "security" ? "security adapter" : `${slotFolder(slot)} provider`} '${provider}'`;
5712
+ return new ConfigError2(
5713
+ suggestion === void 0 ? `${unknown}: no first-party adapter is named that; a third-party adapter is named with \`package:\`` : `${unknown}; did you mean '${suggestion}'?`,
5714
+ {
5715
+ code: "adapter.provider_unknown",
5716
+ cause: error,
5717
+ context: { ...context2, ...suggestion !== void 0 && { suggestion } }
5718
+ }
5719
+ );
5720
+ }
5721
+ const own = missing === pkg || missing === resolution.sdk;
5722
+ const packages = own ? [pkg, ...resolution.sdk === void 0 ? [] : [resolution.sdk]] : [missing];
5723
+ const install = installLine(packages, env, process.cwd());
5724
+ return new ConfigError2(
5725
+ own ? `${choiceOf(slot, provider)} needs ${pkg}: ${install}` : `${choiceOf(slot, provider)} needs ${missing}, which ${pkg} imports: ${install}`,
5726
+ { code: "adapter.package_missing", cause: error, context: { ...context2, missing, install } }
5727
+ );
5728
+ }
5729
+ function typesCopyAt(entryUrl) {
5730
+ const entry = realpathSync(fileURLToPath(entryUrl));
5731
+ for (let dir = dirname(entry); dirname(dir) !== dir; dir = dirname(dir)) {
5732
+ const path = join2(dir, "package.json");
5733
+ if (!existsSync(path)) continue;
5734
+ const manifest = JSON.parse(readFileSync(path, "utf8"));
5735
+ if (manifest.name === TYPES) return { dir, version: String(manifest.version) };
5736
+ }
5737
+ throw new Error(`${entry} lies in no ${TYPES} package`);
5738
+ }
5739
+ var kernelCopies = /* @__PURE__ */ new Map();
5740
+ function sameTypesCopy(adapterUrl, kernelUrl) {
5741
+ let kernel = kernelCopies.get(kernelUrl);
5742
+ if (kernel === void 0) {
5743
+ kernel = typesCopyAt(resolveFrom(TYPES, kernelUrl));
5744
+ kernelCopies.set(kernelUrl, kernel);
5745
+ }
5746
+ let adapter;
5532
5747
  try {
5533
- mod = await import(entry.package);
5748
+ adapter = typesCopyAt(resolveFrom(TYPES, adapterUrl));
5534
5749
  } catch (error) {
5535
- const missing = missingPackage(error);
5536
- if (missing !== entry.package && missing !== entry.sdk) throw error;
5537
- const packages = entry.sdk === void 0 ? [entry.package] : [entry.package, entry.sdk];
5538
- const install = installLine(packages, env, process.cwd());
5539
- throw new ConfigError2(`${choiceOf(slot, provider)} needs ${entry.package}: ${install}`, {
5540
- code: "adapter.package_missing",
5541
- cause: error,
5542
- context: { slot, provider, missing, install }
5543
- });
5750
+ const code = error?.code;
5751
+ if (code !== "ERR_MODULE_NOT_FOUND" && code !== "ENOENT") throw error;
5752
+ adapter = null;
5544
5753
  }
5545
- if (typeof mod.createAdapter !== "function") {
5546
- throw new ConfigError2(`${entry.package} exports no createAdapter(ctx)`, {
5547
- code: "adapter.package_invalid",
5548
- context: { slot, provider, package: entry.package }
5549
- });
5550
- }
5551
- if (mod.settings !== void 0 && !(Array.isArray(mod.settings) && mod.settings.every(isSetting))) {
5754
+ return {
5755
+ adapterTypes: adapter?.dir ?? null,
5756
+ kernelTypes: kernel.dir,
5757
+ adapterVersion: adapter?.version ?? null,
5758
+ kernelVersion: kernel.version
5759
+ };
5760
+ }
5761
+ function compareVersions(a, b) {
5762
+ const parse = (v) => {
5763
+ const core = v.split(/[-+]/, 1)[0] ?? "";
5764
+ const parts = core.split(".").map((n) => Number.parseInt(n, 10) || 0);
5765
+ return { parts, pre: /^[^+]*-/.test(v) };
5766
+ };
5767
+ const x = parse(a);
5768
+ const y = parse(b);
5769
+ for (let i = 0; i < 3; i++) {
5770
+ const diff = (x.parts[i] ?? 0) - (y.parts[i] ?? 0);
5771
+ if (diff !== 0) return diff;
5772
+ }
5773
+ return Number(y.pre) - Number(x.pre);
5774
+ }
5775
+ function typesDuplicate(slot, provider, pkg, error, env) {
5776
+ const { adapterVersion, kernelVersion } = error.context;
5777
+ const cwd = process.cwd();
5778
+ const dedupe = adapterVersion === kernelVersion;
5779
+ const install = dedupe ? DEDUPE_LINES[packageManager(env, cwd)] : installLine([pkg], env, cwd);
5780
+ const adapterAt = `${pkg} at a version whose ${TYPES} peer range includes ${String(kernelVersion)}`;
5781
+ const remedy = dedupe ? `Run ${install} so both load one copy.` : compareVersions(String(adapterVersion), String(kernelVersion)) < 0 ? `Install ${adapterAt}.` : `Update Nymbal's core (nymbal, @nymbalhq/platform) to a release whose ${TYPES} is at least ${String(adapterVersion)}, or install ${adapterAt}.`;
5782
+ return new ConfigError2(`${error.message} ${remedy}`, {
5783
+ code: TYPES_DUPLICATE,
5784
+ context: { slot, provider, ...error.context, install }
5785
+ });
5786
+ }
5787
+ var projectImport = async (specifier) => {
5788
+ const url = resolveFrom(specifier, pathToFileURL(join2(process.cwd(), "package.json")).href);
5789
+ const copies = sameTypesCopy(url, import.meta.url);
5790
+ if (copies.adapterTypes !== null && copies.adapterTypes !== copies.kernelTypes) {
5552
5791
  throw new ConfigError2(
5553
- `${entry.package} exports \`settings\` that is not an array of { path, label, secret, env? }`,
5554
- { code: "adapter.package_invalid", context: { slot, provider, package: entry.package } }
5792
+ `${specifier} loads ${TYPES} ${copies.adapterVersion} from ${copies.adapterTypes}, but the kernel loads ${copies.kernelVersion} from ${copies.kernelTypes}: two copies make errors the adapter throws unrecognisable.`,
5793
+ { code: TYPES_DUPLICATE, context: { package: specifier, ...copies } }
5555
5794
  );
5556
5795
  }
5557
- return mod;
5796
+ return import(url);
5797
+ };
5798
+ async function importAdapterModule(slot, choice, env, importer = projectImport) {
5799
+ const resolution = resolveChoice(slot, choice);
5800
+ if (resolution.kind !== "package") return void 0;
5801
+ let mod;
5802
+ try {
5803
+ mod = await importer(resolution.package);
5804
+ } catch (error) {
5805
+ throw importFailure(slot, choice.provider, resolution, error, env);
5806
+ }
5807
+ return checkAdapterModule(mod, slot, choice.provider, resolution.package);
5558
5808
  }
5559
5809
  function declaredSettings(mod) {
5560
5810
  return mod?.settings ?? [];
5561
5811
  }
5562
- async function loadProviderAdapter(slot, provider, ctx) {
5563
- const mod = await importProviderPackage(slot, provider, ctx.env);
5812
+ async function loadProviderAdapter(slot, choice, ctx) {
5813
+ const mod = await importAdapterModule(slot, choice, ctx.env);
5564
5814
  if (mod === void 0) return void 0;
5565
5815
  return await mod.createAdapter({ ...ctx, slot });
5566
5816
  }
@@ -6309,10 +6559,15 @@ function createNativeTaxAdapter(logger, defaultRate = 0) {
6309
6559
 
6310
6560
  // src/adapters/not-configured.ts
6311
6561
  import { AdapterError as AdapterError3 } from "@nymbalhq/types";
6562
+ var NOT_CONFIGURED = /* @__PURE__ */ Symbol.for("nymbal.adapter.notConfigured");
6563
+ function isNotConfigured(subject) {
6564
+ return typeof subject === "object" && subject !== null && subject[NOT_CONFIGURED] === true;
6565
+ }
6312
6566
  function createNotConfiguredAdapter(slot, provider, missing) {
6313
6567
  const fields = missing.map((path) => `${slot}.${path}`).join(", ");
6314
6568
  const detail = `${provider} is not configured: ${fields} not set (in the config, the environment or the admin's Settings)`;
6315
6569
  const base = {
6570
+ [NOT_CONFIGURED]: true,
6316
6571
  kind: slot,
6317
6572
  providerName: provider,
6318
6573
  capabilities: () => [],
@@ -6415,7 +6670,7 @@ async function resolveSlot(slot, config, logger, injected, builtIns, settings3)
6415
6670
  if (block.provider === "custom") {
6416
6671
  adapter = injected[slot];
6417
6672
  } else {
6418
- const mod = await importProviderPackage(slot, block.provider, process.env);
6673
+ const mod = await importAdapterModule(slot, block, process.env);
6419
6674
  if (mod !== void 0) {
6420
6675
  const declared = declaredSettings(mod);
6421
6676
  blockConfig = fillFromSettings(slot, blockConfig, declared, settings3, process.env);
@@ -6450,22 +6705,26 @@ function resolvePaymentsAdapter(config, logger, injected = {}, settings3 = []) {
6450
6705
  settings3
6451
6706
  );
6452
6707
  }
6708
+ function securityChoice(config) {
6709
+ const { adapter, package: pkg } = config.security;
6710
+ return { provider: adapter, ...pkg !== void 0 && { package: pkg } };
6711
+ }
6453
6712
  async function resolveSecurityAdapter(config, logger, env = process.env) {
6454
- const choice = config.security.adapter;
6713
+ const choice = securityChoice(config);
6455
6714
  const slotLogger = logger.child({ adapter: "security" });
6456
- if (choice === "middleware") return createMiddlewareSecurityAdapter({ logger: slotLogger });
6457
- const blockConfig = choice === "cloudflare" ? { ...config.security.cloudflare } : {};
6715
+ if (resolveChoice("security", choice).kind === "built-in") {
6716
+ return createMiddlewareSecurityAdapter({ logger: slotLogger });
6717
+ }
6718
+ const blockConfig = choice.provider === "cloudflare" ? { ...config.security.cloudflare } : { ...config.security.config };
6458
6719
  const adapter = await loadProviderAdapter("security", choice, {
6459
6720
  config: blockConfig,
6460
6721
  logger: slotLogger,
6461
6722
  env
6462
6723
  });
6463
6724
  if (adapter === void 0) {
6464
- const known = ["middleware", ...Object.keys(PROVIDER_PACKAGES.security)];
6465
- throw new ConfigError3(
6466
- `security.adapter '${choice}' has no adapter; the security adapters are ${known.join(", ")}`,
6467
- { code: "config.security_adapter_unknown", context: { adapter: choice, known } }
6468
- );
6725
+ throw new ConfigError3(`security.adapter '${choice.provider}' has no adapter`, {
6726
+ context: { slot: "security", provider: choice.provider }
6727
+ });
6469
6728
  }
6470
6729
  await adapter.initialize(blockConfig);
6471
6730
  return adapter;
@@ -6579,9 +6838,10 @@ function createSettingsRepository(store) {
6579
6838
  async function declaredSlots(config, env) {
6580
6839
  const out = [];
6581
6840
  for (const slot of COMMERCE_SLOTS) {
6582
- const provider = config.commerce[slot].provider;
6841
+ const block = config.commerce[slot];
6842
+ const provider = block.provider;
6583
6843
  if (provider === "custom") continue;
6584
- const declared = declaredSettings(await importProviderPackage(slot, provider, env));
6844
+ const declared = declaredSettings(await importAdapterModule(slot, block, env));
6585
6845
  if (declared.length > 0) out.push({ slot, provider, declared });
6586
6846
  }
6587
6847
  return out;
@@ -7129,14 +7389,14 @@ function createHistoryReader(deps) {
7129
7389
  });
7130
7390
  }
7131
7391
  const newest = entries.reverse().filter((e) => page.beforeSeq === void 0 || e.seq < page.beforeSeq);
7132
- const shown = newest.slice(0, page.limit);
7133
- await actorsOf(tx, shown);
7134
- const last = shown[shown.length - 1];
7392
+ const shown2 = newest.slice(0, page.limit);
7393
+ await actorsOf(tx, shown2);
7394
+ const last = shown2[shown2.length - 1];
7135
7395
  return {
7136
7396
  historyStartsAt: rows[start].createdAt.toISOString(),
7137
7397
  retentionDays,
7138
- entries: shown,
7139
- nextCursor: newest.length > shown.length && last !== void 0 ? String(last.seq) : null
7398
+ entries: shown2,
7399
+ nextCursor: newest.length > shown2.length && last !== void 0 ? String(last.seq) : null
7140
7400
  };
7141
7401
  });
7142
7402
  }
@@ -7170,7 +7430,12 @@ function registerAdminRoutes(adapter, deps) {
7170
7430
  product: services.product,
7171
7431
  repos
7172
7432
  });
7173
- registerAdminCustomersRoutes(adapter, { order: services.order, repos, history });
7433
+ registerAdminCustomersRoutes(adapter, {
7434
+ order: services.order,
7435
+ customer: services.customer,
7436
+ repos,
7437
+ history
7438
+ });
7174
7439
  registerAdminSearchRoute(adapter, {
7175
7440
  order: services.order,
7176
7441
  product: services.product,
@@ -7365,12 +7630,18 @@ function registerEventsSseRoute(adapter, deps) {
7365
7630
  import {
7366
7631
  ConfigError as ConfigError5,
7367
7632
  EVT_PAYMENT_FAILED as EVT_PAYMENT_FAILED3,
7633
+ emailFeedbackProblem,
7634
+ shippingTrackingProblem,
7368
7635
  webhookDeliveryProblem
7369
7636
  } from "@nymbalhq/types";
7370
7637
  var PAYMENTS_ALIAS = "stripe";
7371
7638
  function isHooked(adapter) {
7372
7639
  return "receiveWebhook" in adapter && typeof adapter.receiveWebhook === "function";
7373
7640
  }
7641
+ var SLOT_WEBHOOK_RULES = {
7642
+ email: emailFeedbackProblem,
7643
+ shipping: shippingTrackingProblem
7644
+ };
7374
7645
  function webhookTargets(adapters) {
7375
7646
  const bySlot = /* @__PURE__ */ new Map();
7376
7647
  const hookless = /* @__PURE__ */ new Map();
@@ -7475,7 +7746,7 @@ function registerInboundWebhookRoute(adapter, deps) {
7475
7746
  target.adapter.providerName,
7476
7747
  target.adapter.producesEvents,
7477
7748
  delivery
7478
- );
7749
+ ) ?? SLOT_WEBHOOK_RULES[target.slot]?.(target.adapter.providerName, delivery) ?? null;
7479
7750
  if (problem !== null) {
7480
7751
  ctx.logger.warn(
7481
7752
  { webhook: name, slot: target.slot, type: problem.type, reason: problem.reason },
@@ -7740,9 +8011,18 @@ var routeSchemas = {
7740
8011
  },
7741
8012
  "GET /api/orders/:orderNumber": {
7742
8013
  name: "orders.get",
7743
- description: "Get one order by its number, with a key that opens it in the x-nymbal-order-key header or as the order's signed-in customer.",
8014
+ description: "Get one order by its number, with a key that opens it in the x-nymbal-order-key header (an expired key with the order's email in x-nymbal-order-email) or as the order's signed-in customer.",
7744
8015
  params: orderNumberParams
7745
8016
  },
8017
+ "POST /api/orders/link": {
8018
+ name: "orders.requestLink",
8019
+ command: "order.requestLink",
8020
+ description: "Email the order's link again to the order's own email; the answer is the same whether or not the number and email matched an order.",
8021
+ body: z.object({
8022
+ orderNumber: z.string().trim().min(1).max(64),
8023
+ email: z.string().trim().min(1).max(254)
8024
+ })
8025
+ },
7746
8026
  // Recently viewed: the viewer is the bearer's customer or the visitor cookie's, never one the request names.
7747
8027
  "POST /api/recently-viewed": {
7748
8028
  name: "recentlyViewed.record",
@@ -8498,7 +8778,7 @@ function registerAllRoutes(deps) {
8498
8778
  registerEventsSseRoute(adapter, {
8499
8779
  eventBus,
8500
8780
  documentStore,
8501
- ticketSecret: config.security.auth.jwtSecret
8781
+ ticketSecret: deps.jwtSecret
8502
8782
  });
8503
8783
  registerInboundWebhookRoute(adapter, {
8504
8784
  adapters,
@@ -8512,9 +8792,11 @@ function registerAllRoutes(deps) {
8512
8792
  }
8513
8793
 
8514
8794
  export {
8515
- PROVIDER_PACKAGES,
8795
+ resolveChoice,
8516
8796
  installLine,
8517
- importProviderPackage,
8797
+ missingPackage,
8798
+ checkAdapterModule,
8799
+ importAdapterModule,
8518
8800
  declaredSettings,
8519
8801
  loadProviderAdapter,
8520
8802
  sqliteDb,
@@ -8529,6 +8811,7 @@ export {
8529
8811
  listAuditEntries,
8530
8812
  auditEntriesInOrder,
8531
8813
  createAuditEntryRepository,
8814
+ normaliseEmail,
8532
8815
  runWithCorrelation,
8533
8816
  currentCorrelationId,
8534
8817
  newCorrelationId,
@@ -8538,11 +8821,14 @@ export {
8538
8821
  currentActor,
8539
8822
  outsideActor,
8540
8823
  actorOf,
8824
+ addSecret,
8541
8825
  scrub,
8542
8826
  scrubbingLogger,
8543
8827
  outsideCommand,
8544
8828
  audit,
8545
8829
  auditedCommand,
8830
+ parseDurationToMs,
8831
+ createAuthService,
8546
8832
  CATEGORIES,
8547
8833
  PRODUCTS,
8548
8834
  PRODUCTS_BY_CATEGORY,
@@ -8563,8 +8849,30 @@ export {
8563
8849
  registerRecentlyViewedProjection,
8564
8850
  formatMoney,
8565
8851
  mintOrderKey,
8566
- parseDurationToMs,
8567
- createAuthService,
8852
+ CSRF_COOKIE,
8853
+ CSRF_HEADER,
8854
+ buildSecurityHeaders,
8855
+ createMiddlewareSecurityAdapter,
8856
+ createNativeStubPaymentsAdapter,
8857
+ createNativeEmailAdapter,
8858
+ encodeSearchCursor,
8859
+ nativeIndexDocuments,
8860
+ createNativeSearchAdapter,
8861
+ createNativeReviewsAdapter,
8862
+ createNativeAnalyticsAdapter,
8863
+ createNativeShippingAdapter,
8864
+ createNativeTaxAdapter,
8865
+ isNotConfigured,
8866
+ fillFromSettings,
8867
+ COMMERCE_SLOTS,
8868
+ checkInjectedAdapters,
8869
+ checkInjectedSlot,
8870
+ resolvePaymentsAdapter,
8871
+ securityChoice,
8872
+ resolveSecurityAdapter,
8873
+ slotBuilders,
8874
+ buildAdapters,
8875
+ isHooked,
8568
8876
  createProductService,
8569
8877
  createCategoryService,
8570
8878
  createCartService,
@@ -8591,27 +8899,6 @@ export {
8591
8899
  readSecretsKey,
8592
8900
  keyProblem,
8593
8901
  settingAad,
8594
- CSRF_COOKIE,
8595
- CSRF_HEADER,
8596
- buildSecurityHeaders,
8597
- createMiddlewareSecurityAdapter,
8598
- createNativeStubPaymentsAdapter,
8599
- createNativeEmailAdapter,
8600
- encodeSearchCursor,
8601
- nativeIndexDocuments,
8602
- createNativeSearchAdapter,
8603
- createNativeReviewsAdapter,
8604
- createNativeAnalyticsAdapter,
8605
- createNativeShippingAdapter,
8606
- createNativeTaxAdapter,
8607
- fillFromSettings,
8608
- COMMERCE_SLOTS,
8609
- checkInjectedAdapters,
8610
- checkInjectedSlot,
8611
- resolvePaymentsAdapter,
8612
- resolveSecurityAdapter,
8613
- slotBuilders,
8614
- buildAdapters,
8615
8902
  isMissingSettingsTable,
8616
8903
  listStoredSettings,
8617
8904
  settingValues,
@@ -8621,4 +8908,4 @@ export {
8621
8908
  registerAlertRoutes,
8622
8909
  registerAllRoutes
8623
8910
  };
8624
- //# sourceMappingURL=chunk-GMV3B3SC.js.map
8911
+ //# sourceMappingURL=chunk-TRLERRUI.js.map