@revenexx/cover 0.10.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.
- package/app/api/account.ts +4 -0
- package/app/assets/css/cover.css +9 -0
- package/app/components/RevenexxForm.vue +4 -0
- package/app/components/account/AccountSidebar.vue +2 -5
- package/app/components/account/dashboard/AccountDashboardKpis.vue +74 -34
- package/app/components/account/dashboard/AccountDashboardQuickActions.vue +24 -6
- package/app/components/account/organization/AccountOrganization.vue +3 -1
- package/app/components/account/team/AccountTeam.vue +32 -7
- package/app/components/auth/AuthForgotPasswordPanel.vue +9 -4
- package/app/components/auth/AuthLoginPanel.vue +5 -3
- package/app/components/cart/actions/CartSaveToListModal.vue +5 -0
- package/app/components/cart/item/CartItem.vue +17 -75
- package/app/components/cart/position/CartPosition.vue +17 -30
- package/app/components/cart/quote/CartQuoteRequestModal.vue +9 -1
- package/app/components/category/view/GridView.vue +10 -1
- package/app/components/category/view/ListView.vue +10 -1
- package/app/components/checkout/confirmation/CheckoutConfirmationActions.vue +2 -0
- package/app/components/checkout/onepage/CheckoutAddressSection.vue +4 -4
- package/app/components/checkout/onepage/CheckoutDeliverySection.vue +18 -2
- package/app/components/checkout/onepage/CheckoutGate.vue +2 -0
- package/app/components/checkout/onepage/CheckoutOnePageView.vue +1 -1
- package/app/components/checkout/onepage/CheckoutPaymentSection.vue +10 -0
- package/app/components/checkout/onepage/CheckoutSummarySection.vue +7 -1
- package/app/components/layout/Region.vue +13 -0
- package/app/components/layout/footer/Footer.vue +8 -0
- package/app/components/layout/header/AppBar.vue +4 -3
- package/app/components/layout/header/MainNav.vue +3 -3
- package/app/components/listing/ListingResults.vue +3 -1
- package/app/components/product/card/Compact.vue +10 -1
- package/app/components/product/detail/ProductDetailAddToCart.vue +51 -18
- package/app/components/product/detail/ProductDetailIdentity.vue +1 -1
- package/app/components/product/detail/ProductDetailPriceRequest.vue +1 -1
- package/app/components/product/detail/ProductDetailSaveToList.vue +10 -0
- package/app/composables/useAccountDashboard.ts +0 -10
- package/app/composables/useAccountNavigation.ts +35 -0
- package/app/composables/useAuthStore.ts +2 -0
- package/app/composables/useCategoryListing.ts +6 -0
- package/app/composables/useCheckoutOnePage.ts +21 -2
- package/app/composables/useMasterDataEditable.ts +23 -0
- package/app/composables/useProductCard.ts +29 -2
- package/app/composables/useProductListing.ts +79 -0
- package/app/composables/useQuantityStepper.ts +90 -0
- package/app/composables/useQuickActions.ts +35 -0
- package/app/composables/useRoleGrants.ts +32 -0
- package/app/composables/useSearchListing.ts +4 -0
- package/app/composables/useThemeEvents.ts +144 -0
- package/app/config/accountDashboard.ts +26 -0
- package/app/config/quickActions.ts +40 -5
- package/app/interfaces/account/dashboard.ts +2 -0
- package/app/interfaces/auth.ts +13 -2
- package/app/interfaces/quantity-stepper.ts +17 -0
- package/app/layouts/default.vue +19 -10
- package/app/layouts/focus.vue +28 -7
- package/app/middleware/checkout-guard.ts +7 -1
- package/app/pages/punchout/transfer.vue +22 -0
- package/app/plugins/theme-events.client.ts +132 -0
- package/app/shared/themeEvents.ts +445 -0
- package/i18n/locales/de/account.json +7 -0
- package/i18n/locales/de/auth.json +1 -0
- package/i18n/locales/de/cart.json +2 -1
- package/i18n/locales/de/checkout.json +2 -1
- package/i18n/locales/de/common.json +2 -0
- package/i18n/locales/de/cover.json +44 -0
- package/i18n/locales/de/editor.json +47 -1
- package/i18n/locales/en/account.json +7 -0
- package/i18n/locales/en/auth.json +1 -0
- package/i18n/locales/en/cart.json +2 -1
- package/i18n/locales/en/checkout.json +2 -1
- package/i18n/locales/en/common.json +2 -0
- package/i18n/locales/en/cover.json +44 -0
- package/i18n/locales/en/editor.json +47 -1
- package/nuxt.config.ts +15 -1
- package/package.json +5 -2
- package/server/api/account/orders/[id]/cancel.post.ts +1 -1
- package/server/api/account/orders/[id]/messages.get.ts +1 -1
- package/server/api/account/orders/[id]/messages.post.ts +1 -1
- package/server/api/account/orders/[id]/return.post.ts +1 -0
- package/server/api/account/orders/[id].get.ts +1 -1
- package/server/api/account/pending-approvals/index.get.ts +1 -0
- package/server/api/account/profile.get.ts +3 -1
- package/server/api/auth/login.post.ts +6 -0
- package/server/api/auth/magic-link.put.ts +6 -1
- package/server/api/auth/otp.put.ts +6 -1
- package/server/api/carts/[id]/activate.post.ts +1 -0
- package/server/api/carts/[id]/index.delete.ts +1 -0
- package/server/api/carts/[id]/index.put.ts +1 -0
- package/server/api/carts/[id]/items.post.ts +1 -0
- package/server/api/orders/index.post.ts +33 -0
- package/server/api/quick-actions.get.ts +6 -38
- package/server/middleware/buyer-principal.ts +18 -0
- package/server/routes/punchout/start.get.ts +2 -2
- package/server/services/ApiAddressBookService.ts +43 -1
- package/server/services/ApiAuthService.ts +98 -17
- package/server/services/ApiCartService.ts +3 -10
- package/server/services/ApiOrganizationService.ts +7 -2
- package/server/services/ApiTeamService.ts +93 -21
- package/server/utils/buyerIdentity.ts +168 -0
- package/server/utils/cartOwnership.ts +27 -0
- package/server/utils/liveOrderLists.ts +50 -23
- package/server/utils/liveOrders.ts +39 -24
- package/server/utils/livePrices.ts +7 -15
- package/server/utils/masterData.ts +29 -0
- package/server/utils/passwordlessSignIn.ts +13 -4
- package/server/utils/pendingApprovals.ts +29 -7
- package/server/utils/procurementCheckout.ts +2 -0
- package/server/utils/quickActionCatalogue.ts +53 -0
- package/server/utils/revenexxSdk.ts +116 -2
|
@@ -173,7 +173,8 @@
|
|
|
173
173
|
"guestTitle": "Order as a guest",
|
|
174
174
|
"guestDescription": "Order without an account. Your details are used for this order only.",
|
|
175
175
|
"guestBusiness": "Guest order — business",
|
|
176
|
-
"guestPrivate": "Guest order — private"
|
|
176
|
+
"guestPrivate": "Guest order — private",
|
|
177
|
+
"backToSelection": "Back to selection"
|
|
177
178
|
},
|
|
178
179
|
"guest": {
|
|
179
180
|
"email": "E-mail address",
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"knowledge": "Knowledge",
|
|
14
14
|
"mainNavigation": "Main navigation",
|
|
15
15
|
"backToShop": "Back to shop",
|
|
16
|
+
"backToCart": "Back to cart",
|
|
16
17
|
"catalog": {
|
|
17
18
|
"loading": "Loading product groups…",
|
|
18
19
|
"showAllGroups": "all {count} groups",
|
|
@@ -39,6 +40,7 @@
|
|
|
39
40
|
"footer": {
|
|
40
41
|
"tagline": "B2B supply solutions for modern businesses.",
|
|
41
42
|
"copyright": "© {year} Cover Corp — All rights reserved.",
|
|
43
|
+
"cookieSettings": "Cookie settings",
|
|
42
44
|
"columns": {
|
|
43
45
|
"products": {
|
|
44
46
|
"heading": "Products",
|
|
@@ -29,5 +29,49 @@
|
|
|
29
29
|
},
|
|
30
30
|
"actions": {
|
|
31
31
|
"tryAgain": "Try again"
|
|
32
|
+
},
|
|
33
|
+
"productMenu": {
|
|
34
|
+
"homeLabel": "Cover home",
|
|
35
|
+
"triggerLabel": "revenexx products and services",
|
|
36
|
+
"currentLabel": "Cover",
|
|
37
|
+
"closeLabel": "Close menu",
|
|
38
|
+
"items": {
|
|
39
|
+
"developerPortal": {
|
|
40
|
+
"title": "Developer Portal",
|
|
41
|
+
"subtitle": "Start to develop with the Revenue Cloud."
|
|
42
|
+
},
|
|
43
|
+
"help": {
|
|
44
|
+
"title": "Help",
|
|
45
|
+
"subtitle": "Learn how to use the Revenue Cloud."
|
|
46
|
+
},
|
|
47
|
+
"cover": {
|
|
48
|
+
"title": "Cover",
|
|
49
|
+
"subtitle": "Our design system for B2B storefronts."
|
|
50
|
+
},
|
|
51
|
+
"studio": {
|
|
52
|
+
"title": "Studio",
|
|
53
|
+
"subtitle": "Unified UI for apps inside the Cockpit."
|
|
54
|
+
},
|
|
55
|
+
"schemas": {
|
|
56
|
+
"title": "Schemas",
|
|
57
|
+
"subtitle": "Clear specifications for developers."
|
|
58
|
+
},
|
|
59
|
+
"changelog": {
|
|
60
|
+
"title": "Changelog",
|
|
61
|
+
"subtitle": "Stay up to date with what we ship every day."
|
|
62
|
+
},
|
|
63
|
+
"status": {
|
|
64
|
+
"title": "Status",
|
|
65
|
+
"subtitle": "Status insights and reports of all services."
|
|
66
|
+
},
|
|
67
|
+
"support": {
|
|
68
|
+
"title": "Support",
|
|
69
|
+
"subtitle": "Contact us whenever you need help."
|
|
70
|
+
},
|
|
71
|
+
"about": {
|
|
72
|
+
"title": "About revenexx",
|
|
73
|
+
"subtitle": "Learn more about the Revenue Cloud."
|
|
74
|
+
}
|
|
75
|
+
}
|
|
32
76
|
}
|
|
33
77
|
}
|
|
@@ -41,7 +41,10 @@
|
|
|
41
41
|
"slugHelp": "Lowercase letters, digits, \"-\" and \"/\" for nested paths.",
|
|
42
42
|
"bundleHelp": "Always treated as \"standard\" locally; the value only takes effect once the page is promoted and served by the live API.",
|
|
43
43
|
"warnings": {
|
|
44
|
-
"routeSlug": "This slug belongs to
|
|
44
|
+
"routeSlug": "This slug belongs to the route {path} — the page is served there, not at /{slug}."
|
|
45
|
+
},
|
|
46
|
+
"suggestions": {
|
|
47
|
+
"none": "No route slug matches — the page gets a free slug."
|
|
45
48
|
},
|
|
46
49
|
"errors": {
|
|
47
50
|
"duplicate": "A page with this slug already exists.",
|
|
@@ -118,7 +121,50 @@
|
|
|
118
121
|
"serif": "Serif",
|
|
119
122
|
"mono": "Monospace",
|
|
120
123
|
"geometric": "Geometric"
|
|
124
|
+
},
|
|
125
|
+
"design": {
|
|
126
|
+
"title": "Site design",
|
|
127
|
+
"brand": "Brand colour",
|
|
128
|
+
"neutral": "Neutral colour",
|
|
129
|
+
"radius": "Corner radius",
|
|
130
|
+
"font": "Web font",
|
|
131
|
+
"fontHint": "Font family name and its stylesheet URL (fonts.bunny.net, fonts.googleapis.com or cdn.revenexx.com).",
|
|
132
|
+
"customCss": "Custom CSS",
|
|
133
|
+
"customCssHint": "Applies to the whole shop and overrides theme styles. No imports; external URLs only via https.",
|
|
134
|
+
"save": "Save design",
|
|
135
|
+
"saving": "Saving …",
|
|
136
|
+
"saved": "Saved — every page now uses this design.",
|
|
137
|
+
"failed": "Could not save the design.",
|
|
138
|
+
"tenantScheme": "Own design"
|
|
121
139
|
}
|
|
140
|
+
},
|
|
141
|
+
"region": {
|
|
142
|
+
"title": "Region",
|
|
143
|
+
"hint": "How this region's blocks combine with the theme's default header or footer.",
|
|
144
|
+
"modes": {
|
|
145
|
+
"after": "After the default",
|
|
146
|
+
"before": "Before the default",
|
|
147
|
+
"replace": "Replace the default"
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
"accountNav": {
|
|
151
|
+
"title": "Account navigation",
|
|
152
|
+
"lead": "Groups and links of this tenant's account sidebar. Applies to every account page.",
|
|
153
|
+
"save": "Save",
|
|
154
|
+
"loading": "Loading navigation …",
|
|
155
|
+
"empty": "No custom navigation yet – the default navigation is shown.",
|
|
156
|
+
"seedDefault": "Start from the default navigation",
|
|
157
|
+
"groupLabel": "Group name",
|
|
158
|
+
"linkLabel": "Link text",
|
|
159
|
+
"linkTarget": "Choose target",
|
|
160
|
+
"addLink": "Add link",
|
|
161
|
+
"addGroup": "Add group",
|
|
162
|
+
"removeGroup": "Remove group",
|
|
163
|
+
"removeLink": "Remove link",
|
|
164
|
+
"moveUp": "Move up",
|
|
165
|
+
"moveDown": "Move down",
|
|
166
|
+
"saved": "Navigation saved",
|
|
167
|
+
"saveFailed": "The navigation could not be saved"
|
|
122
168
|
}
|
|
123
169
|
}
|
|
124
170
|
}
|
package/nuxt.config.ts
CHANGED
|
@@ -58,7 +58,21 @@ export default defineNuxtConfig({
|
|
|
58
58
|
|
|
59
59
|
// Forms: FormKit renders the BFF-served form schemas (SSR-safe). The
|
|
60
60
|
// module and config ship with the layer so every consumer gets them.
|
|
61
|
-
|
|
61
|
+
//
|
|
62
|
+
// Consent + tags (RAD-183): the layer registers them, not a theme, for the
|
|
63
|
+
// same reason — every storefront on cover (the blökkli theme, the custom
|
|
64
|
+
// theme, the demo shop) owes a cookie choice, and the layer's own layouts
|
|
65
|
+
// mount the banner and its footer link. Order matters: @nuxt/scripts is the
|
|
66
|
+
// loader both sit on; the consent module provides `$consentProvider`, which
|
|
67
|
+
// the tag manager reads at runtime (it never imports it). Without tenant
|
|
68
|
+
// credentials both fail closed — no banner, no tag — so a consumer that is
|
|
69
|
+
// not a deployed Site (the docs website) renders exactly as before.
|
|
70
|
+
modules: [
|
|
71
|
+
"@formkit/nuxt",
|
|
72
|
+
"@nuxt/scripts",
|
|
73
|
+
"@revenexx/consent-manager-nuxt",
|
|
74
|
+
"@revenexx/tag-manager-nuxt",
|
|
75
|
+
],
|
|
62
76
|
|
|
63
77
|
formkit: {
|
|
64
78
|
// autoImport's build-time transform produces conflicting sourcemaps in
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@revenexx/cover",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Cover
|
|
3
|
+
"version": "0.11.0",
|
|
4
|
+
"description": "Cover — revenexx design system for Nuxt. Distributed as a Nuxt layer: generic UI components, theming tokens and stores shared by the demo shop, custom storefronts and the Blokkli theme.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./nuxt.config.ts",
|
|
7
7
|
"license": "MIT",
|
|
@@ -41,8 +41,11 @@
|
|
|
41
41
|
"@formkit/vue": "^1.6.0",
|
|
42
42
|
"@iconify-json/lucide": "^1.2.111",
|
|
43
43
|
"@internationalized/date": "^3.12.0",
|
|
44
|
+
"@nuxt/scripts": "^1.3.0",
|
|
45
|
+
"@revenexx/consent-manager-nuxt": "^0.1.0",
|
|
44
46
|
"@revenexx/sdk": "^0.2.0",
|
|
45
47
|
"@revenexx/storage-model-viewer": "^0.3.0",
|
|
48
|
+
"@revenexx/tag-manager-nuxt": "^0.1.0",
|
|
46
49
|
"@vueuse/core": "^14.3.0",
|
|
47
50
|
"typesense": "^3.0.5"
|
|
48
51
|
},
|
|
@@ -22,7 +22,7 @@ export default defineEventHandler(async (event): Promise<{ ok: true }> => {
|
|
|
22
22
|
throw createError({ statusCode: 501, message: "This storefront does not cancel orders on demo data" });
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
const order = await getLiveOrderByNumber(number);
|
|
25
|
+
const order = await getLiveOrderByNumber(number, user.contactId);
|
|
26
26
|
if (!order) {
|
|
27
27
|
throw createError({ statusCode: 404, message: "Order not found" });
|
|
28
28
|
}
|
|
@@ -27,7 +27,7 @@ export default defineEventHandler(async (event): Promise<{ messages: AccountOrde
|
|
|
27
27
|
return { messages: [] };
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
const order = await getLiveOrderByNumber(number);
|
|
30
|
+
const order = await getLiveOrderByNumber(number, user.contactId);
|
|
31
31
|
if (!order) {
|
|
32
32
|
throw createError({ statusCode: 404, message: "Order not found" });
|
|
33
33
|
}
|
|
@@ -23,7 +23,7 @@ export default defineEventHandler(async (event): Promise<{ ok: true }> => {
|
|
|
23
23
|
throw createError({ statusCode: 501, message: "This storefront does not take order messages on demo data" });
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
const order = await getLiveOrderByNumber(number);
|
|
26
|
+
const order = await getLiveOrderByNumber(number, user.contactId);
|
|
27
27
|
if (!order) {
|
|
28
28
|
throw createError({ statusCode: 404, message: "Order not found" });
|
|
29
29
|
}
|
|
@@ -29,6 +29,7 @@ export default defineEventHandler(async (event): Promise<AccountOrder> => {
|
|
|
29
29
|
try {
|
|
30
30
|
const order = await requestOrderReturn(
|
|
31
31
|
id,
|
|
32
|
+
user.contactId,
|
|
32
33
|
positions.map(p => ({ orderItemId: p.orderItemId, quantity: Number(p.quantity) })),
|
|
33
34
|
body?.reason,
|
|
34
35
|
);
|
|
@@ -11,7 +11,7 @@ export default defineEventHandler(async (event) => {
|
|
|
11
11
|
|
|
12
12
|
if (resolveOrderServiceKey(event) === "api") {
|
|
13
13
|
try {
|
|
14
|
-
const order = await getLiveOrderByNumber(id);
|
|
14
|
+
const order = await getLiveOrderByNumber(id, user.contactId);
|
|
15
15
|
if (!order) {
|
|
16
16
|
throw createError({ statusCode: 404, message: "Order not found" });
|
|
17
17
|
}
|
|
@@ -20,6 +20,7 @@ export default defineEventHandler(async (event): Promise<PendingApprovalsRespons
|
|
|
20
20
|
const approvals = await listPendingApprovals(event, {
|
|
21
21
|
...(user.contactId ?? refs?.contact_id ? { contactId: (user.contactId ?? refs?.contact_id) as string } : {}),
|
|
22
22
|
...(user.role ? { role: user.role } : {}),
|
|
23
|
+
...(user.organizationId ? { organizationId: user.organizationId } : {}),
|
|
23
24
|
});
|
|
24
25
|
return { approvals };
|
|
25
26
|
});
|
|
@@ -66,7 +66,9 @@ export default defineEventHandler(async (event): Promise<AccountProfileResponse>
|
|
|
66
66
|
const live = resolveServiceKey(event, { domain: "accountService", mockKey: "mock", liveKey: "api" }) === "api";
|
|
67
67
|
if (live) {
|
|
68
68
|
const [phone, organization] = await Promise.all([
|
|
69
|
-
|
|
69
|
+
// The verified contact, not the cookie's: a contact id the browser
|
|
70
|
+
// wrote would read anybody's number (RAD-155).
|
|
71
|
+
contactPhone(sessionOrderRefs(event).contact_id),
|
|
70
72
|
getOrganizationService(event).get(event).catch(() => null),
|
|
71
73
|
]);
|
|
72
74
|
return {
|
|
@@ -22,6 +22,12 @@ export default defineEventHandler(async (event) => {
|
|
|
22
22
|
return result;
|
|
23
23
|
}
|
|
24
24
|
catch (err) {
|
|
25
|
+
// A blocked contact or company (customers >= 1.1.0) is told so, not
|
|
26
|
+
// shown an outage.
|
|
27
|
+
const refused = signInRefusalType(err);
|
|
28
|
+
if (refused) {
|
|
29
|
+
throw createError({ statusCode: 403, data: { type: refused } });
|
|
30
|
+
}
|
|
25
31
|
if (isApiUserError(err)) {
|
|
26
32
|
throw createError({ statusCode: err.code, data: { type: apiAuthErrorType(err) } });
|
|
27
33
|
}
|
|
@@ -16,9 +16,14 @@ export default defineEventHandler(async (event): Promise<AuthLoginResult> => {
|
|
|
16
16
|
userId,
|
|
17
17
|
secret,
|
|
18
18
|
}) as unknown as PasswordlessConfirm;
|
|
19
|
-
return completeSignIn(event, answer.session, answer.contact, "");
|
|
19
|
+
return completeSignIn(event, answer.session, answer.contact, "", answer.permissions);
|
|
20
20
|
}
|
|
21
21
|
catch (err) {
|
|
22
|
+
// A blocked contact or company is refused at the redeem, and told why.
|
|
23
|
+
const refused = signInRefusalType(err);
|
|
24
|
+
if (refused) {
|
|
25
|
+
throw createError({ statusCode: 403, message: "This account may not sign in", data: { type: refused } });
|
|
26
|
+
}
|
|
22
27
|
// A used or lapsed link is the ordinary case, not an outage: the buyer
|
|
23
28
|
// asks for another one.
|
|
24
29
|
if (err instanceof RevenexxException && [400, 401, 404].includes(err.code)) {
|
|
@@ -16,9 +16,14 @@ export default defineEventHandler(async (event): Promise<AuthLoginResult> => {
|
|
|
16
16
|
userId,
|
|
17
17
|
secret,
|
|
18
18
|
}) as unknown as PasswordlessConfirm;
|
|
19
|
-
return completeSignIn(event, answer.session, answer.contact, "");
|
|
19
|
+
return completeSignIn(event, answer.session, answer.contact, "", answer.permissions);
|
|
20
20
|
}
|
|
21
21
|
catch (err) {
|
|
22
|
+
// A blocked contact or company is refused at the redeem, and told why.
|
|
23
|
+
const refused = signInRefusalType(err);
|
|
24
|
+
if (refused) {
|
|
25
|
+
throw createError({ statusCode: 403, message: "This account may not sign in", data: { type: refused } });
|
|
26
|
+
}
|
|
22
27
|
if (err instanceof RevenexxException && [400, 401, 404].includes(err.code)) {
|
|
23
28
|
throw createError({ statusCode: 401, message: "This code is wrong or has expired" });
|
|
24
29
|
}
|
|
@@ -7,6 +7,7 @@ export default defineEventHandler(async (event) => {
|
|
|
7
7
|
if (!id) {
|
|
8
8
|
throw createError({ statusCode: 400, message: "Cart id is required" });
|
|
9
9
|
}
|
|
10
|
+
await assertOwnCart(event, manager, id);
|
|
10
11
|
try {
|
|
11
12
|
const items = await manager.activateCart(event, id);
|
|
12
13
|
return { items };
|
|
@@ -8,6 +8,7 @@ export default defineEventHandler(async (event) => {
|
|
|
8
8
|
if (!id || !name?.trim()) {
|
|
9
9
|
throw createError({ statusCode: 400, message: "Cart id and name are required" });
|
|
10
10
|
}
|
|
11
|
+
await assertOwnCart(event, manager, id);
|
|
11
12
|
try {
|
|
12
13
|
await manager.renameCart(event, id, name);
|
|
13
14
|
return { ok: true };
|
|
@@ -10,6 +10,7 @@ export default defineEventHandler(async (event) => {
|
|
|
10
10
|
if (!id || !item) {
|
|
11
11
|
throw createError({ statusCode: 400, message: "Cart id and item are required" });
|
|
12
12
|
}
|
|
13
|
+
await assertOwnCart(event, manager, id);
|
|
13
14
|
try {
|
|
14
15
|
await manager.addItemToCart(event, id, item);
|
|
15
16
|
return { ok: true };
|
|
@@ -450,6 +450,27 @@ export default defineEventHandler(async (event) => {
|
|
|
450
450
|
}
|
|
451
451
|
|
|
452
452
|
const placed = outcome.order;
|
|
453
|
+
|
|
454
|
+
// An attributed buyer (RAD-155) whose role only REQUESTS orders,
|
|
455
|
+
// or whose order is above the merchant's approval threshold, gets
|
|
456
|
+
// a pending order back rather than a placed one. Nothing is bought
|
|
457
|
+
// yet: no payment is taken and no promotion is spent until
|
|
458
|
+
// somebody approves it — the same answer a procurement request
|
|
459
|
+
// gets above.
|
|
460
|
+
if (placed.status === "pending") {
|
|
461
|
+
if (reserved === "held" && cartId) {
|
|
462
|
+
await releaseRedemption(event, { cartId, reason: PromotionsRedemptionsReleaseReason.CartReleased });
|
|
463
|
+
}
|
|
464
|
+
return {
|
|
465
|
+
orderId: placed.number,
|
|
466
|
+
status: "approval-pending",
|
|
467
|
+
createdAt: new Date().toISOString(),
|
|
468
|
+
payment,
|
|
469
|
+
approvalRequired: true,
|
|
470
|
+
approvers: [],
|
|
471
|
+
};
|
|
472
|
+
}
|
|
473
|
+
|
|
453
474
|
orderId = placed.number;
|
|
454
475
|
liveOrderUuid = placed.id;
|
|
455
476
|
liveOrderTotal = typeof placed.grand_total === "number" ? placed.grand_total : null;
|
|
@@ -479,6 +500,18 @@ export default defineEventHandler(async (event) => {
|
|
|
479
500
|
if (err instanceof RevenexxException && (err.code === 400 || err.code === 422)) {
|
|
480
501
|
throw createError({ status: 422, message: err.message });
|
|
481
502
|
}
|
|
503
|
+
// The buyer's role neither places nor requests orders (a viewer,
|
|
504
|
+
// a blocked contact, a role the merchant narrowed). The gateway or
|
|
505
|
+
// the orders app says so with a 403 once the call is attributed
|
|
506
|
+
// (RAD-155) — that is the buyer's answer, not an outage.
|
|
507
|
+
if (err instanceof RevenexxException && err.code === 403) {
|
|
508
|
+
throw createError({
|
|
509
|
+
status: 403,
|
|
510
|
+
statusMessage: "Your account may not place orders",
|
|
511
|
+
message: "Your account may not place orders.",
|
|
512
|
+
data: { type: "permission_missing", permission: "orders.create" },
|
|
513
|
+
});
|
|
514
|
+
}
|
|
482
515
|
getLogService().error("Order placement failed", apiErrorContext(err));
|
|
483
516
|
throw createError({ status: 502, message: "Order service unavailable" });
|
|
484
517
|
}
|
|
@@ -1,43 +1,11 @@
|
|
|
1
|
-
import { quickActions } from "../../app/config/quickActions";
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
|
-
* The shortcut catalogue behind the `quick_actions` block, with its i18n
|
|
5
|
-
* already resolved
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* nor `useI18n()` and cannot translate a key itself. The block on the page does
|
|
10
|
-
* NOT call this — it holds the same registry and resolves the keys through
|
|
11
|
-
* `useI18n()` with no round-trip.
|
|
2
|
+
* The full shortcut catalogue behind the `quick_actions` block, with its i18n
|
|
3
|
+
* keys already resolved — see `loadQuickActionCatalogue`. Themes that know a
|
|
4
|
+
* tenant's account navigation serve a narrowed catalogue of their own (the
|
|
5
|
+
* Blokkli theme: /api/blokkli/quick-actions); this one is the unfiltered layer
|
|
6
|
+
* default.
|
|
12
7
|
*
|
|
13
8
|
* Static config, not a BFF domain: no service interface, no app.config registry
|
|
14
9
|
* key, nothing to switch between mock and live.
|
|
15
10
|
*/
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* `serverT` scopes a key to one locale FILE, but the registry's keys span two
|
|
19
|
-
* (`header.cart` lives in common.json, the rest in account.json). A miss
|
|
20
|
-
* returns the key unchanged, which is the signal to try the next namespace.
|
|
21
|
-
*/
|
|
22
|
-
const NAMESPACES = ["account", "common"];
|
|
23
|
-
|
|
24
|
-
function translate(key: string, locale: string): string {
|
|
25
|
-
for (const namespace of NAMESPACES) {
|
|
26
|
-
const value = serverT(key, locale, namespace);
|
|
27
|
-
if (value !== key) {
|
|
28
|
-
return value;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return key;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export default defineEventHandler(async (event) => {
|
|
35
|
-
const locale = resolveLocale(event);
|
|
36
|
-
await preloadLocaleNamespaces(locale, NAMESPACES);
|
|
37
|
-
|
|
38
|
-
return quickActions.map(action => ({
|
|
39
|
-
id: action.id,
|
|
40
|
-
label: translate(action.labelKey, locale),
|
|
41
|
-
description: translate(action.descriptionKey, locale),
|
|
42
|
-
}));
|
|
43
|
-
});
|
|
11
|
+
export default defineEventHandler(event => loadQuickActionCatalogue(event));
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { getCookie } from "h3";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Resolve the signed-in buyer before any BFF handler runs (RAD-155).
|
|
5
|
+
*
|
|
6
|
+
* Every live service reads the buyer's contact and organization synchronously
|
|
7
|
+
* (sessionOrderRefs), and every SDK call puts the contact on the wire as its
|
|
8
|
+
* principal — both from what the identity service verified for THIS request,
|
|
9
|
+
* never from the cookie. Doing it here, once, is what makes both true for
|
|
10
|
+
* every route instead of only for the routes that remembered to ask.
|
|
11
|
+
* Which paths: needsVerifiedBuyer.
|
|
12
|
+
*/
|
|
13
|
+
export default defineEventHandler(async (event) => {
|
|
14
|
+
if (!needsVerifiedBuyer(event.path) || !getCookie(event, SESSION_COOKIE_NAME)) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
await getAuthService(event).me(event);
|
|
18
|
+
});
|
|
@@ -108,9 +108,9 @@ export default defineEventHandler(async (event) => {
|
|
|
108
108
|
const stored: StoredSession = {
|
|
109
109
|
id: session.$id,
|
|
110
110
|
expire: session.expire,
|
|
111
|
+
// The contact and organization are not written: the browser can rewrite
|
|
112
|
+
// this cookie, so they are re-resolved per request (RAD-155).
|
|
111
113
|
userId: session.userId,
|
|
112
|
-
...(signedIn.contact?.id ? { contactId: signedIn.contact.id } : {}),
|
|
113
|
-
...(signedIn.contact?.organization_id ? { organizationId: signedIn.contact.organization_id } : {}),
|
|
114
114
|
};
|
|
115
115
|
setCookie(event, SESSION_COOKIE_NAME, JSON.stringify(stored), sessionCookieOptions(session.expire));
|
|
116
116
|
|
|
@@ -57,7 +57,8 @@ function toAccountAddress(row: ApiAddressRow, companyFallback = ""): AccountAddr
|
|
|
57
57
|
/**
|
|
58
58
|
* Live address book: the signed-in buyer's addresses in the customers app —
|
|
59
59
|
* their own AND their company's, because in B2B the delivery addresses belong
|
|
60
|
-
* to the company. Both references
|
|
60
|
+
* to the company. Both references are the ones the identity service verified
|
|
61
|
+
* for this request (RAD-155), never ids the browser supplied; guests have no
|
|
61
62
|
* address book. The customers schema requires ISO 3166-1 alpha-2 countries.
|
|
62
63
|
*/
|
|
63
64
|
export class ApiAddressBookService implements IAddressBookService {
|
|
@@ -86,6 +87,33 @@ export class ApiAddressBookService implements IAddressBookService {
|
|
|
86
87
|
}
|
|
87
88
|
}
|
|
88
89
|
|
|
90
|
+
/**
|
|
91
|
+
* Refuse a change to an address that is neither the buyer's own nor their
|
|
92
|
+
* company's. The id comes from the URL, so without this any buyer could
|
|
93
|
+
* rewrite or delete any address they could name (RAD-155). Somebody else's
|
|
94
|
+
* address is answered exactly like one that does not exist.
|
|
95
|
+
*/
|
|
96
|
+
private async requireOwnAddress(event: H3Event, id: string): Promise<void> {
|
|
97
|
+
const { contact_id, organization_id } = this.contactRef(event);
|
|
98
|
+
let row: ApiAddressRow | null = null;
|
|
99
|
+
try {
|
|
100
|
+
row = await useRevenexxSdk().customersOrganizations.customersAddressesGet({ id }) as unknown as ApiAddressRow;
|
|
101
|
+
}
|
|
102
|
+
catch (err) {
|
|
103
|
+
if (!(err instanceof RevenexxException && (err.code === 404 || err.code === 403))) {
|
|
104
|
+
getLogService().error("API request failed: addresses/get", apiErrorContext(err));
|
|
105
|
+
throw createError({ statusCode: 502, statusMessage: "Address service unavailable" });
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
const own = !!row && (
|
|
109
|
+
(!!contact_id && row.contact_id === contact_id)
|
|
110
|
+
|| (!!organization_id && row.organization_id === organization_id)
|
|
111
|
+
);
|
|
112
|
+
if (!own) {
|
|
113
|
+
throw createError({ statusCode: 404, statusMessage: "Address not found" });
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
89
117
|
private requireContact(event: H3Event): string {
|
|
90
118
|
const { contact_id } = this.contactRef(event);
|
|
91
119
|
if (!contact_id) {
|
|
@@ -166,6 +194,10 @@ export class ApiAddressBookService implements IAddressBookService {
|
|
|
166
194
|
return toAccountAddress(row);
|
|
167
195
|
}
|
|
168
196
|
catch (err) {
|
|
197
|
+
const refused = selfServiceRefusal(err);
|
|
198
|
+
if (refused) {
|
|
199
|
+
throw refused;
|
|
200
|
+
}
|
|
169
201
|
if (err instanceof RevenexxException && (err.code === 400 || err.code === 422)) {
|
|
170
202
|
throw createError({ statusCode: 422, message: err.message });
|
|
171
203
|
}
|
|
@@ -176,6 +208,7 @@ export class ApiAddressBookService implements IAddressBookService {
|
|
|
176
208
|
|
|
177
209
|
async update(event: H3Event, id: string, input: AccountAddressFormState): Promise<AccountAddress> {
|
|
178
210
|
this.requireContact(event);
|
|
211
|
+
await this.requireOwnAddress(event, id);
|
|
179
212
|
try {
|
|
180
213
|
const row = await useRevenexxSdk().customersOrganizations.customersAddressesUpdate({
|
|
181
214
|
id,
|
|
@@ -191,6 +224,10 @@ export class ApiAddressBookService implements IAddressBookService {
|
|
|
191
224
|
return toAccountAddress(row);
|
|
192
225
|
}
|
|
193
226
|
catch (err) {
|
|
227
|
+
const refused = selfServiceRefusal(err);
|
|
228
|
+
if (refused) {
|
|
229
|
+
throw refused;
|
|
230
|
+
}
|
|
194
231
|
if (err instanceof RevenexxException && (err.code === 400 || err.code === 422)) {
|
|
195
232
|
throw createError({ statusCode: 422, message: err.message });
|
|
196
233
|
}
|
|
@@ -201,10 +238,15 @@ export class ApiAddressBookService implements IAddressBookService {
|
|
|
201
238
|
|
|
202
239
|
async remove(event: H3Event, id: string): Promise<AccountAddress[]> {
|
|
203
240
|
this.requireContact(event);
|
|
241
|
+
await this.requireOwnAddress(event, id);
|
|
204
242
|
try {
|
|
205
243
|
await useRevenexxSdk().customersOrganizations.customersAddressesDelete({ id });
|
|
206
244
|
}
|
|
207
245
|
catch (err) {
|
|
246
|
+
const refused = selfServiceRefusal(err);
|
|
247
|
+
if (refused) {
|
|
248
|
+
throw refused;
|
|
249
|
+
}
|
|
208
250
|
getLogService().error("API request failed: addresses/delete", apiErrorContext(err));
|
|
209
251
|
throw createError({ statusCode: 502, statusMessage: "Address service unavailable" });
|
|
210
252
|
}
|