@revenexx/cover 0.5.0 → 0.7.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 (57) hide show
  1. package/app/app.config.ts +12 -0
  2. package/app/components/account/address/AccountAddressView.vue +12 -1
  3. package/app/components/account/orderlists/AccountOrderListDetail.vue +16 -2
  4. package/app/components/account/orderlists/AccountOrderListsTable.vue +9 -1
  5. package/app/components/account/quotes/AccountQuoteDetail.vue +77 -3
  6. package/app/components/auth/AuthLoginPanel.vue +31 -0
  7. package/app/components/auth/AuthRegisterPanel.vue +71 -3
  8. package/app/components/cart/drawer/CartDrawer.vue +2 -1
  9. package/app/components/cart/item/CartItem.vue +4 -1
  10. package/app/components/cart/position/CartPosition.vue +7 -2
  11. package/app/components/cart/quote/CartQuoteRequestModal.vue +9 -0
  12. package/app/components/cart/view/CartSummaryPanel.vue +42 -5
  13. package/app/components/category/info/CategoryPrice.vue +4 -2
  14. package/app/components/layout/header/TopBar.vue +13 -4
  15. package/app/components/product/card/Compact.vue +4 -2
  16. package/app/components/product/detail/ProductDetailAddToCart.vue +8 -3
  17. package/app/composables/useCartLimits.ts +54 -0
  18. package/app/composables/useCartStore.ts +39 -6
  19. package/app/composables/useCartSummaryFormatting.ts +21 -3
  20. package/app/composables/useDeliveryPromise.ts +112 -0
  21. package/app/composables/useOrderListRules.ts +72 -0
  22. package/app/composables/useProduct.ts +5 -2
  23. package/app/composables/useRegistrationConfig.ts +27 -6
  24. package/app/composables/useShopSettings.ts +66 -0
  25. package/app/config/navigation.ts +16 -2
  26. package/app/interfaces/account/quotes.ts +20 -0
  27. package/app/interfaces/cart-calculation.ts +9 -1
  28. package/app/interfaces/shopSettings.ts +246 -0
  29. package/app/plugins/shop-settings.ts +52 -0
  30. package/i18n/locales/de/account.json +6 -0
  31. package/i18n/locales/de/auth.json +12 -0
  32. package/i18n/locales/de/cart.json +12 -3
  33. package/i18n/locales/de/common.json +3 -2
  34. package/i18n/locales/en/account.json +6 -0
  35. package/i18n/locales/en/auth.json +12 -0
  36. package/i18n/locales/en/cart.json +12 -3
  37. package/i18n/locales/en/common.json +3 -2
  38. package/nuxt.config.ts +0 -1
  39. package/package.json +1 -1
  40. package/server/api/account/quotes/[id]/decline.post.ts +1 -1
  41. package/server/api/account/quotes/[id]/order.post.ts +25 -5
  42. package/server/api/account/quotes/[id].get.ts +1 -1
  43. package/server/api/account/quotes.get.ts +10 -3
  44. package/server/api/auth/registration-config.get.ts +19 -33
  45. package/server/api/cart/calculate.post.ts +35 -18
  46. package/server/api/orders/index.post.ts +68 -2
  47. package/server/api/shop/settings.get.ts +14 -0
  48. package/server/config/shop/app-settings.json +54 -0
  49. package/server/interfaces/cartCalculation.ts +22 -0
  50. package/server/services/MockB2BContextService.ts +52 -2
  51. package/server/services/MockCartCalculationService.ts +117 -11
  52. package/server/utils/appSettings.ts +242 -0
  53. package/server/utils/b2bService.ts +1 -1
  54. package/server/utils/livePrices.ts +24 -2
  55. package/server/utils/procurementCheckout.ts +98 -0
  56. package/server/utils/quotesService.ts +109 -16
  57. package/server/utils/shopSettings.ts +130 -0
@@ -0,0 +1,130 @@
1
+ import type { H3Event } from "h3";
2
+ import type { ShopSettings } from "../../app/interfaces/shopSettings";
3
+
4
+ /**
5
+ * The shop's configured behaviour, assembled from the apps that own it.
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
10
+ * (app/interfaces/shopSettings.ts).
11
+ *
12
+ * Every fallback below is the app's OWN declared default, copied from its
13
+ * settings.json. That is deliberate: it means the demo tenant and a live tenant
14
+ * that never touched a setting behave identically, and it means the value in
15
+ * this file can be checked against the app that owns it. Where an app declares
16
+ * no default the fallback is null, and the surface says nothing rather than
17
+ * inventing a figure.
18
+ *
19
+ * Only settings a code path READS are here. A field nothing acts on is the same
20
+ * lie as a setting nothing enforces, one layer further out — so a key that
21
+ * looks useful but reaches no surface stays in the apps until a surface needs
22
+ * it, and the specs record what is still unanswered.
23
+ *
24
+ * Keep this file boring. It maps keys to fields and nothing else; anything that
25
+ * decides something belongs where the deciding is done.
26
+ */
27
+ export async function getShopSettings(event?: H3Event): Promise<ShopSettings> {
28
+ const live = isAppSettingsLive(event);
29
+ const s = await readAppSettingsMany(event, [
30
+ "carts",
31
+ "orders",
32
+ "shipping",
33
+ "prices",
34
+ "markets",
35
+ "promotions",
36
+ "quotes",
37
+ "orderlists",
38
+ "customers",
39
+ "inventories",
40
+ "procurement",
41
+ ] as const);
42
+
43
+ return {
44
+ cart: {
45
+ multipleCarts: boolSetting(s.carts, "multi_cart_enabled", true),
46
+ maxLines: numberSetting(s.carts, "max_items_per_cart", 0),
47
+ maxQuantityPerLine: numberSetting(s.carts, "max_quantity_per_line", 0),
48
+ },
49
+ orders: {
50
+ approvalAboveValue: numberSetting(s.orders, "require_approval_above_value", 0),
51
+ maxPositions: numberSetting(s.orders, "max_items_per_order", 500),
52
+ onUnorderablePosition: enumSetting(
53
+ s.orders,
54
+ "on_unorderable_position",
55
+ ["place", "drop", "refuse"] as const,
56
+ "place",
57
+ ),
58
+ },
59
+ shipping: {
60
+ // No default in the app, and none invented here.
61
+ freeThreshold: optionalNumberSetting(s.shipping, "free_shipping_threshold"),
62
+ freeCompares: enumSetting(s.shipping, "free_above_compares", ["net", "gross"] as const, "gross"),
63
+ cutoffTime: stringSetting(s.shipping, "cutoff_time", "14:00"),
64
+ handlingDays: numberSetting(s.shipping, "handling_days", 1),
65
+ },
66
+ prices: {
67
+ stored: enumSetting(s.prices, "tax_inclusive_default", ["net", "gross"] as const, "net"),
68
+ marketIncludesTax: optionalBoolSetting(s.markets, "prices_include_tax"),
69
+ anonymousAllowed: boolSetting(s.prices, "anonymous_resolve_allowed", true),
70
+ precision: numberSetting(s.prices, "price_precision", 2),
71
+ },
72
+ promotions: {
73
+ maxCodesPerCart: numberSetting(s.promotions, "max_codes_per_cart", 1),
74
+ codeCaseSensitive: boolSetting(s.promotions, "code_case_sensitive", false),
75
+ anonymousAllowed: boolSetting(s.promotions, "anonymous_promotions_allowed", true),
76
+ },
77
+ quotes: {
78
+ partialAcceptance: boolSetting(s.quotes, "partial_acceptance_enabled", true),
79
+ acceptanceScope: enumSetting(s.quotes, "acceptance_scope", ["requester", "organization"] as const, "organization"),
80
+ defaultValidityDays: numberSetting(s.quotes, "default_validity_days", 30),
81
+ expiryGraceHours: numberSetting(s.quotes, "expiry_grace_hours", 0),
82
+ expiryWarningDays: numberSetting(s.quotes, "expiry_warning_days", 3),
83
+ },
84
+ orderLists: {
85
+ maxItems: numberSetting(s.orderlists, "max_items_per_list", 200),
86
+ maxLists: numberSetting(s.orderlists, "max_lists_per_owner", 100),
87
+ sharedEditable: boolSetting(s.orderlists, "shared_lists_editable", false),
88
+ cartMergeMode: enumSetting(s.orderlists, "cart_merge_mode", ["append", "replace"] as const, "append"),
89
+ defaultKind: nullableEnum(s.orderlists, "default_kind", ["shopping", "label"] as const),
90
+ },
91
+ registration: {
92
+ b2b: boolSetting(s.customers, "b2b_registration_enabled", true),
93
+ b2c: boolSetting(s.customers, "b2c_registration_enabled", true),
94
+ vatRequired: boolSetting(s.customers, "organization_vat_id_required", false),
95
+ mode: enumSetting(s.customers, "registration_mode", ["open", "approval_required"] as const, "open"),
96
+ vatValidation: enumSetting(s.customers, "vat_id_validation", ["off", "format", "vies"] as const, "off"),
97
+ },
98
+ signIn: {
99
+ password: boolSetting(s.customers, "login_password", true),
100
+ magicLink: boolSetting(s.customers, "login_magic_link", false),
101
+ emailOtp: boolSetting(s.customers, "login_email_otp", false),
102
+ emailVerification: enumSetting(
103
+ s.customers,
104
+ "email_verification",
105
+ ["off", "on_registration", "required_for_login"] as const,
106
+ "off",
107
+ ),
108
+ },
109
+ account: {
110
+ singleDefaultAddressPerType: boolSetting(s.customers, "single_default_address_per_type", true),
111
+ },
112
+ inventory: {
113
+ backorders: enumSetting(s.inventories, "backorder_policy", ["deny", "allow", "allow_per_sku"] as const, "deny"),
114
+ },
115
+ procurement: {
116
+ gate: enumSetting(s.procurement, "approval_gate", ["none", "booking_account"] as const, "none"),
117
+ },
118
+ source: live ? "apps" : "demo",
119
+ };
120
+ }
121
+
122
+ /** An enum the app leaves unset — absent means unset, not the first value. */
123
+ function nullableEnum<T extends string>(
124
+ settings: Record<string, unknown>,
125
+ key: string,
126
+ allowed: readonly T[],
127
+ ): T | null {
128
+ const raw = settings[key];
129
+ return typeof raw === "string" && (allowed as readonly string[]).includes(raw) ? raw as T : null;
130
+ }