@revenexx/cover 0.7.1 → 0.11.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 (175) hide show
  1. package/app/api/account.ts +4 -0
  2. package/app/api/forms.ts +1 -0
  3. package/app/app.config.ts +17 -12
  4. package/app/assets/css/cover.css +9 -0
  5. package/app/components/RevenexxForm.vue +84 -12
  6. package/app/components/account/AccountShell.vue +18 -0
  7. package/app/components/account/AccountSidebar.vue +2 -5
  8. package/app/components/account/approvals/AccountPendingApprovals.vue +178 -0
  9. package/app/components/account/dashboard/AccountDashboardKpis.vue +74 -34
  10. package/app/components/account/dashboard/AccountDashboardQuickActions.vue +24 -6
  11. package/app/components/account/orderlists/AccountOrderListDetail.vue +47 -4
  12. package/app/components/account/orders/AccountOrderDetail.vue +186 -1
  13. package/app/components/account/organization/AccountOrganization.vue +3 -1
  14. package/app/components/account/payments/AccountPayments.vue +129 -0
  15. package/app/components/account/quotes/AccountQuoteDetail.vue +48 -16
  16. package/app/components/account/team/AccountTeam.vue +32 -7
  17. package/app/components/auth/AuthForgotPasswordPanel.vue +9 -4
  18. package/app/components/auth/AuthLoginPanel.vue +136 -18
  19. package/app/components/auth/AuthMagicLinkPanel.vue +70 -0
  20. package/app/components/cart/actions/CartSaveToListModal.vue +5 -0
  21. package/app/components/cart/item/CartItem.vue +17 -75
  22. package/app/components/cart/position/CartPosition.vue +17 -30
  23. package/app/components/cart/quote/CartQuoteRequestModal.vue +9 -1
  24. package/app/components/cart/view/CartSummaryPanel.vue +54 -0
  25. package/app/components/category/view/GridView.vue +10 -1
  26. package/app/components/category/view/ListView.vue +10 -1
  27. package/app/components/checkout/confirmation/CheckoutConfirmationActions.vue +2 -0
  28. package/app/components/checkout/onepage/CheckoutAddressSection.vue +4 -4
  29. package/app/components/checkout/onepage/CheckoutDeliverySection.vue +31 -3
  30. package/app/components/checkout/onepage/CheckoutGate.vue +10 -7
  31. package/app/components/checkout/onepage/CheckoutOnePageView.vue +1 -1
  32. package/app/components/checkout/onepage/CheckoutPaymentSection.vue +10 -0
  33. package/app/components/checkout/onepage/CheckoutSummarySection.vue +7 -1
  34. package/app/components/form/FormPage.vue +40 -0
  35. package/app/components/layout/Region.vue +13 -0
  36. package/app/components/layout/footer/Footer.vue +8 -0
  37. package/app/components/layout/header/AppBar.vue +11 -4
  38. package/app/components/layout/header/MainNav.vue +26 -4
  39. package/app/components/layout/header/MobileMenu.vue +12 -0
  40. package/app/components/listing/ListingResults.vue +3 -1
  41. package/app/components/product/card/Compact.vue +10 -1
  42. package/app/components/product/detail/ProductDetailAddToCart.vue +51 -18
  43. package/app/components/product/detail/ProductDetailIdentity.vue +1 -1
  44. package/app/components/product/detail/ProductDetailPriceRequest.vue +39 -0
  45. package/app/components/product/detail/ProductDetailSaveToList.vue +10 -0
  46. package/app/components/product/detail/ProductDetailView.vue +57 -0
  47. package/app/composables/useAccountDashboard.ts +0 -10
  48. package/app/composables/useAccountHold.ts +45 -0
  49. package/app/composables/useAccountNavigation.ts +35 -0
  50. package/app/composables/useAccountPayments.ts +21 -0
  51. package/app/composables/useAccountQuotes.ts +15 -2
  52. package/app/composables/useAuthStore.ts +84 -2
  53. package/app/composables/useAuthoredForms.ts +26 -0
  54. package/app/composables/useAvailableOffers.ts +42 -0
  55. package/app/composables/useCategoryListing.ts +6 -0
  56. package/app/composables/useCheckoutOnePage.ts +21 -2
  57. package/app/composables/useGuestOrdering.ts +28 -0
  58. package/app/composables/useMasterDataEditable.ts +45 -7
  59. package/app/composables/useOrderListRules.ts +21 -1
  60. package/app/composables/usePendingApprovals.ts +37 -0
  61. package/app/composables/useProductCard.ts +29 -2
  62. package/app/composables/useProductListing.ts +79 -0
  63. package/app/composables/useQuantityStepper.ts +90 -0
  64. package/app/composables/useQuickActions.ts +35 -0
  65. package/app/composables/useRoleGrants.ts +32 -0
  66. package/app/composables/useSearchListing.ts +4 -0
  67. package/app/composables/useThemeEvents.ts +144 -0
  68. package/app/config/accountDashboard.ts +26 -0
  69. package/app/config/icons.ts +2 -0
  70. package/app/config/navigation.ts +2 -2
  71. package/app/config/quickActions.ts +40 -5
  72. package/app/formkit.config.ts +14 -0
  73. package/app/interfaces/account/approvals.ts +37 -0
  74. package/app/interfaces/account/dashboard.ts +2 -0
  75. package/app/interfaces/account/order-list.ts +29 -0
  76. package/app/interfaces/account/order-lists.ts +9 -0
  77. package/app/interfaces/account/payments.ts +48 -0
  78. package/app/interfaces/auth.ts +24 -2
  79. package/app/interfaces/b2b.ts +8 -8
  80. package/app/interfaces/offers.ts +35 -0
  81. package/app/interfaces/quantity-stepper.ts +17 -0
  82. package/app/interfaces/shopSettings.ts +77 -0
  83. package/app/layouts/default.vue +19 -10
  84. package/app/layouts/focus.vue +28 -7
  85. package/app/middleware/checkout-guard.ts +7 -1
  86. package/app/pages/punchout/transfer.vue +22 -0
  87. package/app/plugins/account-hold.client.ts +20 -0
  88. package/app/plugins/shop-settings.ts +27 -12
  89. package/app/plugins/theme-events.client.ts +132 -0
  90. package/app/shared/themeEvents.ts +445 -0
  91. package/i18n/locales/de/account.json +87 -0
  92. package/i18n/locales/de/auth.json +30 -0
  93. package/i18n/locales/de/cart.json +9 -1
  94. package/i18n/locales/de/checkout.json +4 -2
  95. package/i18n/locales/de/common.json +4 -0
  96. package/i18n/locales/de/cover.json +44 -0
  97. package/i18n/locales/de/editor.json +47 -1
  98. package/i18n/locales/de/forms.json +27 -0
  99. package/i18n/locales/en/account.json +87 -0
  100. package/i18n/locales/en/auth.json +30 -0
  101. package/i18n/locales/en/cart.json +9 -1
  102. package/i18n/locales/en/checkout.json +4 -2
  103. package/i18n/locales/en/common.json +4 -0
  104. package/i18n/locales/en/cover.json +44 -0
  105. package/i18n/locales/en/editor.json +47 -1
  106. package/i18n/locales/en/forms.json +27 -0
  107. package/nuxt.config.ts +15 -1
  108. package/package.json +6 -2
  109. package/server/api/account/address/[id].delete.ts +1 -1
  110. package/server/api/account/address/[id].put.ts +1 -1
  111. package/server/api/account/address/index.post.ts +1 -1
  112. package/server/api/account/order-lists/[id].get.ts +37 -3
  113. package/server/api/account/orders/[id]/cancel.post.ts +54 -0
  114. package/server/api/account/orders/[id]/messages.get.ts +63 -0
  115. package/server/api/account/orders/[id]/messages.post.ts +44 -0
  116. package/server/api/account/orders/[id]/return.post.ts +1 -0
  117. package/server/api/account/orders/[id].get.ts +1 -1
  118. package/server/api/account/organization.put.ts +1 -1
  119. package/server/api/account/payments.get.ts +54 -0
  120. package/server/api/account/pending-approvals/[id]/approve.post.ts +10 -0
  121. package/server/api/account/pending-approvals/[id]/decline.post.ts +10 -0
  122. package/server/api/account/pending-approvals/index.get.ts +26 -0
  123. package/server/api/account/profile.get.ts +3 -1
  124. package/server/api/account/profile.put.ts +1 -1
  125. package/server/api/account/quotes/[id]/decline.post.ts +35 -6
  126. package/server/api/account/team/[id].put.ts +1 -1
  127. package/server/api/account/team.post.ts +1 -1
  128. package/server/api/auth/login.post.ts +6 -0
  129. package/server/api/auth/magic-link.post.ts +32 -0
  130. package/server/api/auth/magic-link.put.ts +35 -0
  131. package/server/api/auth/otp.post.ts +33 -0
  132. package/server/api/auth/otp.put.ts +33 -0
  133. package/server/api/carts/[id]/activate.post.ts +1 -0
  134. package/server/api/carts/[id]/index.delete.ts +1 -0
  135. package/server/api/carts/[id]/index.put.ts +1 -0
  136. package/server/api/carts/[id]/items.post.ts +1 -0
  137. package/server/api/checkout/profile.get.ts +6 -3
  138. package/server/api/forms/[slug]/submit.post.ts +27 -16
  139. package/server/api/forms/[slug].get.ts +9 -1
  140. package/server/api/forms/index.get.ts +23 -0
  141. package/server/api/orders/index.post.ts +41 -0
  142. package/server/api/promotions/available.post.ts +37 -0
  143. package/server/api/quick-actions.get.ts +6 -38
  144. package/server/config/account/organization.json +0 -4
  145. package/server/config/shop/app-settings.json +4 -0
  146. package/server/data/forms/authored.json +337 -0
  147. package/server/interfaces/forms.ts +51 -0
  148. package/server/middleware/buyer-principal.ts +18 -0
  149. package/server/routes/punchout/start.get.ts +2 -2
  150. package/server/services/ApiAddressBookService.ts +43 -1
  151. package/server/services/ApiAuthService.ts +101 -10
  152. package/server/services/ApiCartService.ts +3 -10
  153. package/server/services/ApiFormsService.ts +56 -0
  154. package/server/services/ApiOrganizationService.ts +7 -2
  155. package/server/services/ApiTeamService.ts +93 -21
  156. package/server/services/MockB2BContextService.ts +1 -5
  157. package/server/services/MockFormsService.ts +63 -0
  158. package/server/utils/accountPayments.ts +45 -0
  159. package/server/utils/appSettings.ts +69 -4
  160. package/server/utils/buyerIdentity.ts +168 -0
  161. package/server/utils/cartOwnership.ts +27 -0
  162. package/server/utils/forms.ts +62 -14
  163. package/server/utils/formsService.ts +29 -0
  164. package/server/utils/liveOrderLists.ts +50 -23
  165. package/server/utils/liveOrders.ts +65 -24
  166. package/server/utils/livePrices.ts +7 -15
  167. package/server/utils/masterData.ts +60 -11
  168. package/server/utils/passwordlessSignIn.ts +82 -0
  169. package/server/utils/pendingApprovals.ts +175 -0
  170. package/server/utils/procurementCheckout.ts +2 -0
  171. package/server/utils/promotionsService.ts +90 -0
  172. package/server/utils/quickActionCatalogue.ts +53 -0
  173. package/server/utils/quotesService.ts +15 -0
  174. package/server/utils/revenexxSdk.ts +116 -2
  175. package/server/utils/shopSettings.ts +35 -4
@@ -0,0 +1,53 @@
1
+ import type { H3Event } from "h3";
2
+
3
+ import { quickActions } from "../../app/config/quickActions";
4
+
5
+ /**
6
+ * A catalogue row as the blökkli picker overlay consumes it: id plus the
7
+ * title and description already translated.
8
+ */
9
+ export interface QuickActionSummary {
10
+ readonly id: string;
11
+ readonly label: string;
12
+ readonly description: string;
13
+ }
14
+
15
+ /**
16
+ * `serverT` scopes a key to one locale FILE, but the registry's keys span two
17
+ * (`header.cart` lives in common.json, the rest in account.json). A miss
18
+ * returns the key unchanged, which is the signal to try the next namespace.
19
+ */
20
+ const NAMESPACES = ["account", "common"];
21
+
22
+ function translate(key: string, locale: string): string {
23
+ for (const namespace of NAMESPACES) {
24
+ const value = serverT(key, locale, namespace);
25
+ if (value !== key) {
26
+ return value;
27
+ }
28
+ }
29
+ return key;
30
+ }
31
+
32
+ /**
33
+ * The shortcut catalogue with its i18n keys resolved for the request's locale,
34
+ * optionally narrowed to `ids` (catalogue order is kept either way). Serves the
35
+ * picker overlay, which is compiled through the editor's own pipeline and has
36
+ * neither `$fetch` nor `useI18n()` to translate a key itself.
37
+ */
38
+ export async function loadQuickActionCatalogue(
39
+ event: H3Event,
40
+ ids?: readonly string[],
41
+ ): Promise<QuickActionSummary[]> {
42
+ const locale = resolveLocale(event);
43
+ await preloadLocaleNamespaces(locale, NAMESPACES);
44
+
45
+ const permitted = ids ? new Set(ids) : null;
46
+ return quickActions
47
+ .filter(action => permitted === null || permitted.has(action.id))
48
+ .map(action => ({
49
+ id: action.id,
50
+ label: translate(action.labelKey, locale),
51
+ description: translate(action.descriptionKey, locale),
52
+ }));
53
+ }
@@ -337,6 +337,21 @@ export async function liveQuoteDecline(id: string, reason?: string): Promise<voi
337
337
  await useRevenexxSdk().quotesAcceptance.quotesAcceptanceDecline({ id, ...(reason ? { reason } : {}) });
338
338
  }
339
339
 
340
+ /**
341
+ * Say no to SOME positions and leave the rest open.
342
+ *
343
+ * The same call that accepts positions carries a decision per line, so refusing a
344
+ * few is not a second mechanism — it is the other value of the same field. The
345
+ * whole-quote refusal above stays for what it is: a no to the offer as a whole,
346
+ * which also closes everything still open.
347
+ */
348
+ export async function liveQuoteDeclineLines(id: string, lineIds: string[]): Promise<void> {
349
+ await useRevenexxSdk().quotesAcceptance.quotesAcceptanceAccept({
350
+ id,
351
+ items: lineIds.map(lineId => ({ id: lineId, decision: AcceptLineDecision.Declined })),
352
+ });
353
+ }
354
+
340
355
  /**
341
356
  * The quote this buyer asked about, or a 404 — another organisation's quote
342
357
  * does not exist for them, and saying "not yours" would confirm it does.
@@ -23,6 +23,10 @@ import {
23
23
  ShippingMethods,
24
24
  } from "@revenexx/sdk";
25
25
 
26
+ // Explicit rather than a Nitro auto-import, so the header logic is reachable
27
+ // from a unit test that imports this module.
28
+ import { buyerPrincipal } from "./buyerIdentity";
29
+
26
30
  /**
27
31
  * The generated revenexx web SDK, configured for the BFF. Every live
28
32
  * "api"-keyed implementation goes through these service instances.
@@ -43,6 +47,15 @@ import {
43
47
  // from the package themselves (Nitro auto-imports this util's exports).
44
48
  export { RevenexxException };
45
49
 
50
+ export interface RevenexxSdkOptions {
51
+ /**
52
+ * The acting party, sent as `X-Revenexx-Principal` (e.g. `contact:<id>`).
53
+ * Apps that enforce access per principal (orderlists >= 1.0, RAD-134)
54
+ * apply no rule without it — the tenant key alone sees every record.
55
+ */
56
+ readonly principal?: string;
57
+ }
58
+
46
59
  export interface RevenexxSdkCallOptions {
47
60
  readonly query?: Record<string, string | number | boolean | undefined>;
48
61
  readonly body?: unknown;
@@ -106,6 +119,79 @@ export function apiAuthErrorType(err: RevenexxException): string {
106
119
  }
107
120
  }
108
121
 
122
+ /**
123
+ * The machine code an app put on a refusal (`{ error, code }` — e.g.
124
+ * `not_self_service`, `field_merchant_owned`, `contact_blocked`), or "" when
125
+ * there is none. The SDK keeps the body only as text, so it is read back here.
126
+ */
127
+ export function apiErrorCode(err: unknown): string {
128
+ if (!(err instanceof RevenexxException)) {
129
+ return "";
130
+ }
131
+ try {
132
+ const body = JSON.parse(String(err.response ?? "")) as { code?: unknown } | null;
133
+ if (body && typeof body.code === "string") {
134
+ return body.code;
135
+ }
136
+ }
137
+ catch {
138
+ // Not JSON — fall back to the type the SDK read, if any.
139
+ }
140
+ return err.type || "";
141
+ }
142
+
143
+ /**
144
+ * A sign-in the identity service refused because the account may not act
145
+ * (customers >= 1.1.0): the auth-store type to show, or null when the
146
+ * refusal is something else. A blocked contact reads as the existing
147
+ * "account blocked" line; a blocked company has its own, because the buyer
148
+ * did nothing to their own account and asking support about it is the wrong
149
+ * desk — their company's contact person is the right one.
150
+ */
151
+ export function signInRefusalType(err: unknown): string | null {
152
+ if (!(err instanceof RevenexxException) || err.code !== 403) {
153
+ return null;
154
+ }
155
+ switch (apiErrorCode(err)) {
156
+ case "contact_blocked": return "user_blocked";
157
+ case "organization_blocked": return "organization_blocked";
158
+ default: return null;
159
+ }
160
+ }
161
+
162
+ /**
163
+ * A buyer-attributed write the customers app refused (>= 1.1.0), as the error
164
+ * this BFF answers — or null when the failure is something else.
165
+ *
166
+ * A record outside the buyer's reach reads as not found, which is what the
167
+ * shop's own ownership checks answer too, so a probe learns nothing from the
168
+ * difference. The rest are 403s with a sentence a buyer can act on and the
169
+ * app's code beside it for the page to branch on.
170
+ */
171
+ export function selfServiceRefusal(err: unknown): Error | null {
172
+ if (!(err instanceof RevenexxException) || err.code !== 403) {
173
+ return null;
174
+ }
175
+ const code = apiErrorCode(err);
176
+ switch (code) {
177
+ case "not_own_record":
178
+ return createError({ statusCode: 404, statusMessage: "Not found" });
179
+ case "field_merchant_owned":
180
+ return createError({ statusCode: 403, message: "This is maintained by the merchant and cannot be changed here.", data: { type: code } });
181
+ case "not_self_service":
182
+ return createError({ statusCode: 403, message: "This change cannot be made in the shop.", data: { type: code } });
183
+ case "self_service_closed":
184
+ return createError({ statusCode: 403, message: "This is maintained by the merchant and cannot be changed here.", data: { type: "master_data_merchant_owned" } });
185
+ case "role_exceeds_own":
186
+ return createError({ statusCode: 403, message: "You cannot give anybody a role above your own.", data: { type: "role_above_own" } });
187
+ case "contact_blocked":
188
+ case "organization_blocked":
189
+ return createError({ statusCode: 403, message: "This account is on hold.", data: { type: code } });
190
+ default:
191
+ return null;
192
+ }
193
+ }
194
+
109
195
  /** Diagnostic fields for structured logs — never includes the API key. */
110
196
  export function apiErrorContext(err: unknown): Record<string, unknown> {
111
197
  if (err instanceof RevenexxException) {
@@ -182,12 +268,32 @@ export function revenexxTenantKey(): string {
182
268
  return resolveRevenexxCredentials().tenant;
183
269
  }
184
270
 
185
- export function useRevenexxSdk(): RevenexxSdk {
271
+ /**
272
+ * Who the current request acts for: `contact:<uuid>` for a signed-in buyer,
273
+ * "" otherwise. Read from what the identity service verified for this request
274
+ * (./buyerIdentity.ts) — never from the session cookie, which the browser can
275
+ * rewrite — so a request is attributed to exactly the contact whose live
276
+ * session it carries, or to nobody.
277
+ */
278
+ function activePrincipal(): string {
279
+ try {
280
+ return buyerPrincipal(useEvent());
281
+ }
282
+ catch {
283
+ // No async context — no buyer to act for.
284
+ return "";
285
+ }
286
+ }
287
+
288
+ export function useRevenexxSdk(options: RevenexxSdkOptions = {}): RevenexxSdk {
186
289
  const { tenant, apiKey, jwt, source } = resolveRevenexxCredentials();
187
290
  const market = activeMarket();
188
291
  const channel = activeChannel();
292
+ const principal = options.principal ?? activePrincipal();
189
293
 
190
- const isCacheable = source !== "brokered" && !market && !channel;
294
+ // A client carrying a principal is ONE buyer's: cached, it would hand that
295
+ // buyer's identity to whichever request came next.
296
+ const isCacheable = source !== "brokered" && !market && !channel && !principal;
191
297
  if (isCacheable) {
192
298
  const cached = clients.get(tenant);
193
299
  if (cached) {
@@ -224,6 +330,14 @@ export function useRevenexxSdk(): RevenexxSdk {
224
330
  if (channel) {
225
331
  client.headers["X-Revenexx-Channel"] = channel;
226
332
  }
333
+ // The signed-in buyer this call is made for (RAD-155). The gateway resolves
334
+ // it into the contact, organization and permissions every app sees, and the
335
+ // customers app holds such a request to its self-service allowlist. Without
336
+ // it the call is unattributed — operator-equivalent — so it goes on every
337
+ // call made for a buyer, and on none made for nobody.
338
+ if (principal) {
339
+ client.headers["X-Revenexx-Principal"] = principal;
340
+ }
227
341
  // Auth: the brokered context wins — it is a Zitadel JWT the gateway
228
342
  // verifies against the same JWKS as any interactive caller, so one theme
229
343
  // build serves any tenant without per-site credentials. The explicit
@@ -4,9 +4,9 @@ import type { ShopSettings } from "../../app/interfaces/shopSettings";
4
4
  /**
5
5
  * The shop's configured behaviour, assembled from the apps that own it.
6
6
  *
7
- * Eleven apps are asked in one round — carts, orders, shipping, prices, markets,
8
- * promotions, quotes, orderlists, customers, inventories and procurement — and
9
- * their answers are folded into the one shape the storefront reads
7
+ * Twelve apps are asked in one round — carts, orders, shipping, prices, markets,
8
+ * promotions, quotes, orderlists, customers, inventories, procurement and forms
9
+ * — and their answers are folded into the one shape the storefront reads
10
10
  * (app/interfaces/shopSettings.ts).
11
11
  *
12
12
  * Every fallback below is the app's OWN declared default, copied from its
@@ -38,6 +38,7 @@ export async function getShopSettings(event?: H3Event): Promise<ShopSettings> {
38
38
  "customers",
39
39
  "inventories",
40
40
  "procurement",
41
+ "forms",
41
42
  ] as const);
42
43
 
43
44
  return {
@@ -45,6 +46,7 @@ export async function getShopSettings(event?: H3Event): Promise<ShopSettings> {
45
46
  multipleCarts: boolSetting(s.carts, "multi_cart_enabled", true),
46
47
  maxLines: numberSetting(s.carts, "max_items_per_cart", 0),
47
48
  maxQuantityPerLine: numberSetting(s.carts, "max_quantity_per_line", 0),
49
+ currency: stringSetting(s.carts, "default_currency", "EUR"),
48
50
  },
49
51
  orders: {
50
52
  approvalAboveValue: numberSetting(s.orders, "require_approval_above_value", 0),
@@ -55,6 +57,8 @@ export async function getShopSettings(event?: H3Event): Promise<ShopSettings> {
55
57
  ["place", "drop", "refuse"] as const,
56
58
  "place",
57
59
  ),
60
+ guestOrdering: enumSetting(s.orders, "guest_ordering", ["both", "b2c", "b2b", "none"] as const, "both"),
61
+ partialShipment: enumSetting(s.orders, "partial_shipment", ["allowed", "never"] as const, "allowed"),
58
62
  },
59
63
  shipping: {
60
64
  // No default in the app, and none invented here.
@@ -85,6 +89,12 @@ export async function getShopSettings(event?: H3Event): Promise<ShopSettings> {
85
89
  maxItems: numberSetting(s.orderlists, "max_items_per_list", 200),
86
90
  maxLists: numberSetting(s.orderlists, "max_lists_per_owner", 100),
87
91
  sharedEditable: boolSetting(s.orderlists, "shared_lists_editable", false),
92
+ onMissingArticle: enumSetting(
93
+ s.orderlists,
94
+ "on_missing_article",
95
+ ["include", "skip", "fail"] as const,
96
+ "include",
97
+ ),
88
98
  cartMergeMode: enumSetting(s.orderlists, "cart_merge_mode", ["append", "replace"] as const, "append"),
89
99
  defaultKind: nullableEnum(s.orderlists, "default_kind", ["shopping", "label"] as const),
90
100
  },
@@ -108,6 +118,18 @@ export async function getShopSettings(event?: H3Event): Promise<ShopSettings> {
108
118
  },
109
119
  account: {
110
120
  singleDefaultAddressPerType: boolSetting(s.customers, "single_default_address_per_type", true),
121
+ selfService: enumSetting(
122
+ s.customers,
123
+ "self_service_master_data",
124
+ ["all", "addresses_only", "none"] as const,
125
+ "all",
126
+ ),
127
+ blockedBuyer: enumSetting(
128
+ s.customers,
129
+ "blocked_contact_behavior",
130
+ ["keep", "catalog_only", "deny_all"] as const,
131
+ "keep",
132
+ ),
111
133
  },
112
134
  inventory: {
113
135
  backorders: enumSetting(s.inventories, "backorder_policy", ["deny", "allow", "allow_per_sku"] as const, "deny"),
@@ -115,7 +137,16 @@ export async function getShopSettings(event?: H3Event): Promise<ShopSettings> {
115
137
  procurement: {
116
138
  gate: enumSetting(s.procurement, "approval_gate", ["none", "booking_account"] as const, "none"),
117
139
  },
118
- source: live ? "apps" : "demo",
140
+ forms: {
141
+ // The app's declared default is the empty string, which means no trap.
142
+ // Null says the same thing in a shape a template can test.
143
+ honeypotField: optionalStringSetting(s.forms, "honeypot_field"),
144
+ spamHandling: enumSetting(s.forms, "spam_handling", ["flag", "reject"] as const, "flag"),
145
+ },
146
+ // A tried-out setting makes the whole answer the demo's, whatever it was
147
+ // read from: a value somebody is experimenting with must never be mistaken
148
+ // for one the merchant configured.
149
+ source: live && !hasAppSettingsOverride(event) ? "apps" : "demo",
119
150
  };
120
151
  }
121
152