@revenexx/cover 0.14.0 → 0.16.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 +1 -0
- package/app/components/RevenexxForm.vue +183 -19
- package/app/components/account/address/AccountAddressCard.vue +8 -2
- package/app/components/account/address/AccountAddressView.vue +5 -1
- package/app/components/account/carts/AccountCartsTable.vue +85 -3
- package/app/components/account/dashboard/AccountDashboardBudgets.vue +2 -1
- package/app/components/account/dashboard/AccountDashboardRecentOrders.vue +2 -1
- package/app/components/account/dashboard/AccountDashboardRequisitions.vue +2 -1
- package/app/components/account/directorder/AccountDirectOrder.vue +100 -12
- package/app/components/account/governance/AccountApprovalLimitsTable.vue +124 -8
- package/app/components/account/governance/AccountCostCenterDetail.vue +3 -2
- package/app/components/account/governance/AccountCostCentersTable.vue +133 -6
- package/app/components/account/governance/AccountRequisitionDetail.vue +2 -1
- package/app/components/account/governance/AccountRequisitionsTable.vue +102 -6
- package/app/components/account/governance/AccountWorkflowDetail.vue +3 -2
- package/app/components/account/governance/AccountWorkflowsTable.vue +76 -1
- package/app/components/account/governance/GovernanceApprovalLimitModal.vue +8 -0
- package/app/components/account/governance/GovernanceCostCenterModal.vue +7 -0
- package/app/components/account/governance/GovernanceWorkflowModal.vue +7 -0
- package/app/components/account/orderlists/AccountOrderListDetail.vue +14 -4
- package/app/components/account/orderlists/AccountOrderListsTable.vue +115 -7
- package/app/components/account/orders/AccountOrderDetail.vue +67 -3
- package/app/components/account/orders/AccountOrderPay.vue +211 -0
- package/app/components/account/orders/AccountOrdersTable.vue +119 -10
- package/app/components/account/organization/AccountOrganization.vue +6 -0
- package/app/components/account/profile/AccountPasswordForm.vue +2 -0
- package/app/components/account/profile/AccountProfileForm.vue +4 -0
- package/app/components/account/quotes/AccountQuoteDetail.vue +7 -10
- package/app/components/account/team/AccountTeam.vue +91 -0
- package/app/components/auth/AuthLoginTeaser.vue +1 -1
- package/app/components/auth/AuthRegisterPanel.vue +22 -3
- package/app/components/cart/manage/CartNameModal.vue +4 -0
- package/app/components/checkout/onepage/CheckoutAddressSection.vue +5 -1
- package/app/components/checkout/onepage/CheckoutGuestDetailsSection.vue +9 -1
- package/app/components/checkout/onepage/CheckoutSummarySection.vue +6 -1
- package/app/components/form/FormPage.vue +7 -4
- package/app/components/layout/footer/Footer.vue +15 -2
- package/app/components/layout/header/LocaleSwitcher.vue +79 -12
- package/app/components/ui/forms/PasswordInput.vue +2 -0
- package/app/components/ui/forms/SearchInput.vue +205 -8
- package/app/components/ui/table/TableCardList.vue +69 -0
- package/app/components/ui/table/TableSortButton.vue +1 -1
- package/app/components/ui/table/TableToolbar.vue +2 -0
- package/app/components/withdrawal/WithdrawalDeclaration.vue +286 -0
- package/app/composables/useCheckoutOnePage.ts +22 -0
- package/app/composables/useMobileTableSort.ts +82 -0
- package/app/composables/useProductCard.ts +14 -0
- package/app/composables/useProductListing.ts +27 -1
- package/app/composables/useSearchEvents.ts +67 -0
- package/app/config/forms.ts +8 -0
- package/app/config/navigation.ts +8 -0
- package/app/formkit.config.ts +21 -0
- package/app/interfaces/account/order-list.ts +11 -0
- package/app/interfaces/account/quotes.ts +7 -3
- package/app/interfaces/market.ts +7 -0
- package/app/pages/punchout/transfer.vue +36 -1
- package/app/pages/widerruf.vue +33 -0
- package/app/plugins/search-events.client.ts +41 -0
- package/app/shared/addressLines.ts +66 -0
- package/app/shared/checkoutAddressRefusal.ts +63 -0
- package/app/shared/locale.ts +133 -0
- package/app/shared/searchAttribution.ts +91 -0
- package/app/shared/themeEvents.ts +1 -1
- package/i18n/locales/de/account.json +13 -1
- package/i18n/locales/de/cart.json +1 -0
- package/i18n/locales/de/checkout.json +1 -1
- package/i18n/locales/de/common.json +7 -0
- package/i18n/locales/de/search.json +7 -0
- package/i18n/locales/de/withdrawal.json +34 -0
- package/i18n/locales/en/account.json +13 -1
- package/i18n/locales/en/cart.json +1 -0
- package/i18n/locales/en/checkout.json +1 -1
- package/i18n/locales/en/common.json +7 -0
- package/i18n/locales/en/search.json +7 -0
- package/i18n/locales/en/withdrawal.json +34 -0
- package/nuxt.config.ts +3 -0
- package/package.json +1 -1
- package/server/api/account/orders/[id]/pay.post.ts +100 -0
- package/server/api/account/orders/[id].get.ts +5 -1
- package/server/api/account/quotes/[id]/order.post.ts +22 -22
- package/server/api/brands.get.ts +3 -2
- package/server/api/categories/[slug]/subcategories.get.ts +9 -6
- package/server/api/forms/[slug].get.ts +1 -3
- package/server/api/orders/index.post.ts +33 -50
- package/server/api/products/index.get.ts +6 -1
- package/server/api/punchout/return.post.ts +3 -1
- package/server/api/search/events.post.ts +65 -0
- package/server/api/typesense/search.post.ts +12 -1
- package/server/api/typesense/suggest.post.ts +43 -22
- package/server/data/forms/authored.json +69 -8
- package/server/dev/errorHandler.ts +47 -0
- package/server/interfaces/brand.ts +3 -2
- package/server/interfaces/product.ts +5 -0
- package/server/interfaces/punchout.ts +5 -0
- package/server/middleware/missing-media.ts +35 -0
- package/server/middleware/punchout-hand-back-csp.ts +17 -0
- package/server/plugins/vue-devtools-sink.ts +28 -0
- package/server/services/ApiBrandService.ts +8 -8
- package/server/services/ApiMarketService.ts +9 -2
- package/server/services/ApiProductService.ts +1 -1
- package/server/services/MockFormsService.ts +3 -1
- package/server/utils/addressRefusal.ts +63 -0
- package/server/utils/country.ts +23 -0
- package/server/utils/forms.ts +23 -1
- package/server/utils/liveOrders.ts +44 -2
- package/server/utils/locale.ts +58 -4
- package/server/utils/orderPayment.ts +155 -0
- package/server/utils/punchoutFormAction.ts +44 -0
- package/server/utils/searchClient.ts +27 -4
- package/server/utils/searchEvents.ts +46 -0
- package/server/utils/searchMultiSearchFallback.ts +2 -0
- package/server/utils/searchSuggest.ts +207 -0
- package/server/utils/suggestTiles.ts +141 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
|
|
3
|
+
import { searchLocaleKeys } from "../../../app/shared/locale";
|
|
4
|
+
import type { SearchEventInput } from "../../utils/searchEvents";
|
|
5
|
+
import { searchEventBody } from "../../utils/searchEvents";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A shopper's click on a search result or tile, and the add-to-cart and
|
|
9
|
+
* purchase that follow (PE-867), handed to the search service's events
|
|
10
|
+
* endpoint. Answers 202 and never fails the storefront: an event the gateway
|
|
11
|
+
* refuses is logged and dropped.
|
|
12
|
+
*
|
|
13
|
+
* An anonymous shopper is a pseudonymous token in a session cookie — a
|
|
14
|
+
* random id, nothing about the person, gone with the browser session. The
|
|
15
|
+
* search service stores it only salted and hashed.
|
|
16
|
+
*
|
|
17
|
+
* A signed-in buyer is the contact (and company) the identity service
|
|
18
|
+
* verified for this request: the SDK client sends it as X-Revenexx-Principal,
|
|
19
|
+
* as on every call made for a buyer, and the gateway resolves it into the
|
|
20
|
+
* contact and organization the search analytics count per customer. The same
|
|
21
|
+
* holds for the searches and quick searches, which go through the same client.
|
|
22
|
+
* Nothing here reads either id from the browser.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
const TOKEN_COOKIE = "rvx_search";
|
|
26
|
+
|
|
27
|
+
export default defineEventHandler(async (event) => {
|
|
28
|
+
const input = await readBody<SearchEventInput>(event).catch(() => ({}) as SearchEventInput);
|
|
29
|
+
setResponseStatus(event, 202);
|
|
30
|
+
|
|
31
|
+
// The local docker index has no search service to tell.
|
|
32
|
+
if (resolveProductServiceKey(event) !== "api") {
|
|
33
|
+
return { accepted: false };
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
let token = getCookie(event, TOKEN_COOKIE);
|
|
37
|
+
if (!token || !/^[\w-]{8,64}$/.test(token)) {
|
|
38
|
+
token = randomUUID();
|
|
39
|
+
setCookie(event, TOKEN_COOKIE, token, {
|
|
40
|
+
httpOnly: true,
|
|
41
|
+
sameSite: "lax",
|
|
42
|
+
secure: !import.meta.dev,
|
|
43
|
+
path: "/",
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const body = searchEventBody(input, token);
|
|
48
|
+
if (!body) {
|
|
49
|
+
return { accepted: false };
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// The market locale the search was sent with (PE-866), so the event is
|
|
53
|
+
// logged for the same language index that answered it.
|
|
54
|
+
const locale = searchLocaleKeys(await resolveMarketLocale(event))[0];
|
|
55
|
+
try {
|
|
56
|
+
await useRevenexxSdk().call("POST", "/v1/search/events", {
|
|
57
|
+
body,
|
|
58
|
+
headers: locale ? { "X-Revenexx-Locale": locale } : {},
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
catch (err) {
|
|
62
|
+
getLogService().warn("search event not delivered", { type: body.type, ...apiErrorContext(err) });
|
|
63
|
+
}
|
|
64
|
+
return { accepted: true };
|
|
65
|
+
});
|
|
@@ -55,6 +55,12 @@ interface SearchAnswer {
|
|
|
55
55
|
* or an http(s) URL). Only the search page follows it.
|
|
56
56
|
*/
|
|
57
57
|
redirect?: string;
|
|
58
|
+
/** The search's id, for the click events its results send (PE-867); live mode only. */
|
|
59
|
+
queryId?: string;
|
|
60
|
+
/** The locale whose index answered (live only; see SearchClientResult.locale). */
|
|
61
|
+
locale?: string;
|
|
62
|
+
/** True when the index of another language answered (see SearchClientResult.localeFallback). */
|
|
63
|
+
localeFallback?: boolean;
|
|
58
64
|
}
|
|
59
65
|
|
|
60
66
|
export default defineEventHandler(async (event): Promise<SearchAnswer | null> => {
|
|
@@ -78,6 +84,9 @@ export default defineEventHandler(async (event): Promise<SearchAnswer | null> =>
|
|
|
78
84
|
// storefront's filter names and maps the facets back.
|
|
79
85
|
if (resolveProductServiceKey(event) === "api") {
|
|
80
86
|
const locale = resolveLocale(event);
|
|
87
|
+
// The market's locale for this page (`de-CH`, `fr-FR`): the search
|
|
88
|
+
// service routes it to that language's index (PE-866).
|
|
89
|
+
const searchLocale = await resolveMarketLocale(event);
|
|
81
90
|
try {
|
|
82
91
|
const request = await buildLiveListingFilters(filters, priceRange, locale);
|
|
83
92
|
const view = request.pinnedCategoryCode ? "category" : "search";
|
|
@@ -89,7 +98,7 @@ export default defineEventHandler(async (event): Promise<SearchAnswer | null> =>
|
|
|
89
98
|
sort,
|
|
90
99
|
page,
|
|
91
100
|
perPage,
|
|
92
|
-
locale,
|
|
101
|
+
locale: searchLocale,
|
|
93
102
|
});
|
|
94
103
|
|
|
95
104
|
// Catalog shell only — offers (price + availability) hydrate
|
|
@@ -108,6 +117,8 @@ export default defineEventHandler(async (event): Promise<SearchAnswer | null> =>
|
|
|
108
117
|
perPage,
|
|
109
118
|
priceFilter: liveListingPriceFilter(result, request.priceRequested),
|
|
110
119
|
...(redirect ? { redirect } : {}),
|
|
120
|
+
...(result.queryId ? { queryId: result.queryId } : {}),
|
|
121
|
+
...(result.locale ? { locale: result.locale, localeFallback: result.localeFallback } : {}),
|
|
111
122
|
};
|
|
112
123
|
}
|
|
113
124
|
catch (err) {
|
|
@@ -1,39 +1,58 @@
|
|
|
1
|
+
import type { CategoryTile, ManufacturerTile, PageTile, ProductSuggestion } from "../../utils/suggestTiles";
|
|
2
|
+
import {
|
|
3
|
+
categoryTiles,
|
|
4
|
+
manufacturerTiles,
|
|
5
|
+
pageTiles,
|
|
6
|
+
productSuggestion,
|
|
7
|
+
} from "../../utils/suggestTiles";
|
|
8
|
+
|
|
1
9
|
const SUGGESTION_COUNT = 6;
|
|
10
|
+
const TILE_COUNT = 4;
|
|
11
|
+
const PAGE_COUNT = 3;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The quick search answer: product suggestions plus category, manufacturer and
|
|
15
|
+
* page tiles (PE-867), the `queryId` the dropdown sends back with its click
|
|
16
|
+
* events, and where curation sends the query on Enter, if anywhere.
|
|
17
|
+
*/
|
|
18
|
+
export interface SuggestAnswer {
|
|
19
|
+
suggestions: ProductSuggestion[];
|
|
20
|
+
categories: CategoryTile[];
|
|
21
|
+
manufacturers: ManufacturerTile[];
|
|
22
|
+
pages: PageTile[];
|
|
23
|
+
queryId: string;
|
|
24
|
+
redirect?: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const EMPTY: SuggestAnswer = { suggestions: [], categories: [], manufacturers: [], pages: [], queryId: "" };
|
|
2
28
|
|
|
3
|
-
export default defineEventHandler(async (event) => {
|
|
29
|
+
export default defineEventHandler(async (event): Promise<SuggestAnswer> => {
|
|
4
30
|
const { q } = await readBody<{ q: string }>(event);
|
|
5
31
|
|
|
6
32
|
if (!q?.trim()) {
|
|
7
|
-
return {
|
|
33
|
+
return { ...EMPTY };
|
|
8
34
|
}
|
|
9
35
|
|
|
10
|
-
// Live mode
|
|
11
|
-
//
|
|
36
|
+
// Live mode: one request to the search service's suggest endpoint, every
|
|
37
|
+
// collection with its own `suggest` preset (searchSuggest.ts); the local
|
|
38
|
+
// docker index stays the mock implementation, products only.
|
|
12
39
|
if (resolveProductServiceKey(event) === "api") {
|
|
13
|
-
const locale =
|
|
40
|
+
const locale = await resolveMarketLocale(event);
|
|
14
41
|
try {
|
|
15
42
|
// Twice the suggestions: on the deprecated multi_search fallback a
|
|
16
43
|
// product still indexed under both `de` and `de-DE` comes back twice
|
|
17
44
|
// and is folded into one, which would leave the list short.
|
|
18
|
-
const result = await
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
perPage: SUGGESTION_COUNT * 2,
|
|
22
|
-
locale,
|
|
23
|
-
});
|
|
24
|
-
const docs = result.docs.slice(0, SUGGESTION_COUNT);
|
|
45
|
+
const result = await searchSuggestClient.suggest({ q, locale, perPage: SUGGESTION_COUNT * 2 });
|
|
46
|
+
const tree = result.categories.length ? await getLiveCategories(locale) : [];
|
|
47
|
+
const redirect = searchRedirect(result);
|
|
25
48
|
|
|
26
49
|
return {
|
|
27
|
-
suggestions:
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
categorySlug: doc.categories?.[0] ?? "",
|
|
34
|
-
subcategorySlug: undefined,
|
|
35
|
-
};
|
|
36
|
-
}),
|
|
50
|
+
suggestions: result.products.slice(0, SUGGESTION_COUNT).map(productSuggestion),
|
|
51
|
+
categories: categoryTiles(result.categories, tree, TILE_COUNT),
|
|
52
|
+
manufacturers: manufacturerTiles(result.manufacturers, TILE_COUNT),
|
|
53
|
+
pages: pageTiles(result.pages, PAGE_COUNT),
|
|
54
|
+
queryId: result.queryId,
|
|
55
|
+
...(redirect ? { redirect } : {}),
|
|
37
56
|
};
|
|
38
57
|
}
|
|
39
58
|
catch (err) {
|
|
@@ -54,10 +73,12 @@ export default defineEventHandler(async (event) => {
|
|
|
54
73
|
});
|
|
55
74
|
|
|
56
75
|
return {
|
|
76
|
+
...EMPTY,
|
|
57
77
|
suggestions: (results.hits ?? []).map((hit) => {
|
|
58
78
|
const doc = hit.document as Record<string, unknown>;
|
|
59
79
|
return {
|
|
60
80
|
id: String(doc.id),
|
|
81
|
+
docId: String(doc.id),
|
|
61
82
|
name: doc.name as string,
|
|
62
83
|
sku: doc.sku as string,
|
|
63
84
|
category: doc.category as string,
|
|
@@ -121,13 +121,6 @@
|
|
|
121
121
|
"slug": "price-request",
|
|
122
122
|
"status": "live",
|
|
123
123
|
"definition": [
|
|
124
|
-
{
|
|
125
|
-
"$el": "p",
|
|
126
|
-
"children": "Für einen Artikel und eine Frage. Ganze Warenkörbe gehen als Angebotsanfrage.",
|
|
127
|
-
"attrs": {
|
|
128
|
-
"class": "text-sm text-muted"
|
|
129
|
-
}
|
|
130
|
-
},
|
|
131
124
|
{
|
|
132
125
|
"$formkit": "text",
|
|
133
126
|
"name": "product",
|
|
@@ -166,13 +159,14 @@
|
|
|
166
159
|
"$formkit": "email",
|
|
167
160
|
"name": "email",
|
|
168
161
|
"label": "E-Mail",
|
|
169
|
-
"validation": "
|
|
162
|
+
"validation": "requiredIf:reply_via,email|email",
|
|
170
163
|
"autocomplete": "email"
|
|
171
164
|
},
|
|
172
165
|
{
|
|
173
166
|
"$formkit": "tel",
|
|
174
167
|
"name": "phone",
|
|
175
168
|
"label": "Telefon",
|
|
169
|
+
"validation": "requiredIf:reply_via,phone",
|
|
176
170
|
"autocomplete": "tel"
|
|
177
171
|
},
|
|
178
172
|
{
|
|
@@ -222,6 +216,13 @@
|
|
|
222
216
|
"slug": "callback",
|
|
223
217
|
"status": "live",
|
|
224
218
|
"definition": [
|
|
219
|
+
{
|
|
220
|
+
"$rxStep": {
|
|
221
|
+
"id": "step_1",
|
|
222
|
+
"kind": "fields",
|
|
223
|
+
"title": "Ihre Kontaktdaten"
|
|
224
|
+
}
|
|
225
|
+
},
|
|
225
226
|
{
|
|
226
227
|
"$formkit": "text",
|
|
227
228
|
"name": "name",
|
|
@@ -333,5 +334,65 @@
|
|
|
333
334
|
}
|
|
334
335
|
}
|
|
335
336
|
}
|
|
337
|
+
},
|
|
338
|
+
{
|
|
339
|
+
"id": "demo-form-widerruf",
|
|
340
|
+
"name": "Widerruf",
|
|
341
|
+
"slug": "widerruf",
|
|
342
|
+
"status": "live",
|
|
343
|
+
"definition": [
|
|
344
|
+
{
|
|
345
|
+
"$formkit": "text",
|
|
346
|
+
"name": "name",
|
|
347
|
+
"label": "Name",
|
|
348
|
+
"validation": "required",
|
|
349
|
+
"autocomplete": "name"
|
|
350
|
+
},
|
|
351
|
+
{
|
|
352
|
+
"$formkit": "email",
|
|
353
|
+
"name": "email",
|
|
354
|
+
"label": "E-Mail-Adresse",
|
|
355
|
+
"validation": "required|email",
|
|
356
|
+
"autocomplete": "email"
|
|
357
|
+
},
|
|
358
|
+
{
|
|
359
|
+
"$formkit": "text",
|
|
360
|
+
"name": "order_id",
|
|
361
|
+
"label": "Bestellnummer",
|
|
362
|
+
"validation": "required"
|
|
363
|
+
},
|
|
364
|
+
{
|
|
365
|
+
"$formkit": "textarea",
|
|
366
|
+
"name": "statement",
|
|
367
|
+
"label": "Ihre Erklärung",
|
|
368
|
+
"validation": "required",
|
|
369
|
+
"rows": 5
|
|
370
|
+
}
|
|
371
|
+
],
|
|
372
|
+
"settings": {
|
|
373
|
+
"submit_label": "Widerruf bestätigen",
|
|
374
|
+
"success_message": "Ihr Widerruf ist eingegangen.",
|
|
375
|
+
"default_locale": "de",
|
|
376
|
+
"locales": [
|
|
377
|
+
"de",
|
|
378
|
+
"en"
|
|
379
|
+
],
|
|
380
|
+
"i18n": {
|
|
381
|
+
"en": {
|
|
382
|
+
"name": {
|
|
383
|
+
"label": "Name"
|
|
384
|
+
},
|
|
385
|
+
"email": {
|
|
386
|
+
"label": "Email address"
|
|
387
|
+
},
|
|
388
|
+
"order_id": {
|
|
389
|
+
"label": "Order number"
|
|
390
|
+
},
|
|
391
|
+
"statement": {
|
|
392
|
+
"label": "Your declaration"
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
}
|
|
336
397
|
}
|
|
337
398
|
]
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { NitroErrorHandler } from "nitropack";
|
|
2
|
+
import { getRequestHeader, send, setResponseHeader, setResponseStatus } from "h3";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Dev-only replacement for Nitro's error handler.
|
|
6
|
+
*
|
|
7
|
+
* Nitro's dev handler resolves every stack frame through `source-map@0.7`, which
|
|
8
|
+
* keeps each parsed map in WebAssembly memory until `destroy()` is called — and
|
|
9
|
+
* Nitro never calls it. With a ~3 MB bundle map that is tens of MB per error,
|
|
10
|
+
* never released: a few hundred 404s, or one broken endpoint called on every
|
|
11
|
+
* page view, exhaust the dev container (the wasm heap is capped at 4 GB, which
|
|
12
|
+
* is also the point where the parser starts failing with `unreachable`).
|
|
13
|
+
*
|
|
14
|
+
* So no error is run through the source maps. Client errors are answered with
|
|
15
|
+
* a bare status; server errors (5xx) keep their raw stack in the log and in the
|
|
16
|
+
* JSON body, which is what Nitro's default handler would print minus the
|
|
17
|
+
* source-mapped code frame.
|
|
18
|
+
*/
|
|
19
|
+
const handler: NitroErrorHandler = async function devErrorHandler(error, event) {
|
|
20
|
+
const statusCode = error.statusCode || 500;
|
|
21
|
+
const statusMessage = error.statusMessage || (statusCode >= 500 ? "Server Error" : "Not Found");
|
|
22
|
+
const wantsHtml = getRequestHeader(event, "accept")?.includes("text/html") ?? false;
|
|
23
|
+
|
|
24
|
+
setResponseStatus(event, statusCode, statusMessage);
|
|
25
|
+
setResponseHeader(event, "cache-control", "no-cache");
|
|
26
|
+
setResponseHeader(event, "content-type", wantsHtml ? "text/html" : "application/json");
|
|
27
|
+
|
|
28
|
+
if (statusCode < 500) {
|
|
29
|
+
return send(
|
|
30
|
+
event,
|
|
31
|
+
wantsHtml
|
|
32
|
+
? `<!doctype html><title>${statusCode} ${statusMessage}</title><h1>${statusCode} ${statusMessage}</h1>`
|
|
33
|
+
: JSON.stringify({ error: true, statusCode, statusMessage }),
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
console.error(`[request error] [${event.method}] ${event.path}\n`, error.stack ?? error.message);
|
|
38
|
+
const stack = error.stack?.split("\n").map(line => line.trim());
|
|
39
|
+
return send(
|
|
40
|
+
event,
|
|
41
|
+
wantsHtml
|
|
42
|
+
? `<!doctype html><title>${statusCode} ${statusMessage}</title><h1>${statusCode} ${statusMessage}</h1><pre>${(error.stack ?? error.message).replace(/</g, "<")}</pre>`
|
|
43
|
+
: JSON.stringify({ error: true, url: event.path, statusCode, statusMessage, message: error.message, stack }, null, 2),
|
|
44
|
+
);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export default handler;
|
|
@@ -7,11 +7,12 @@ import type { Locale } from "../utils/locale";
|
|
|
7
7
|
* Register the active implementation via app.config → brandService.
|
|
8
8
|
*/
|
|
9
9
|
export interface IBrandService {
|
|
10
|
-
|
|
10
|
+
/** `searchLocale`: the market locale to search in, defaults to `locale` (PE-866). */
|
|
11
|
+
listBrands(limit: number, locale: Locale, searchLocale?: string): Promise<ShopBrand[]>;
|
|
11
12
|
/**
|
|
12
13
|
* The complete manufacturer list without logos (`logo: null`) — for pickers
|
|
13
14
|
* that must offer every brand, not the top N a grid shows. Cheaper than
|
|
14
15
|
* `listBrands`: no per-brand logo lookups.
|
|
15
16
|
*/
|
|
16
|
-
listBrandNames(locale: Locale): Promise<ShopBrand[]>;
|
|
17
|
+
listBrandNames(locale: Locale, searchLocale?: string): Promise<ShopBrand[]>;
|
|
17
18
|
}
|
|
@@ -9,6 +9,11 @@ export interface ProductListFilter {
|
|
|
9
9
|
subcategory?: string;
|
|
10
10
|
/** Request locale — live implementations serve locale-scoped documents. */
|
|
11
11
|
locale?: Locale;
|
|
12
|
+
/**
|
|
13
|
+
* The market locale to search in (`de-CH`, `fr-FR`); defaults to `locale`.
|
|
14
|
+
* The search service routes it to that language's index (PE-866).
|
|
15
|
+
*/
|
|
16
|
+
searchLocale?: string;
|
|
12
17
|
}
|
|
13
18
|
|
|
14
19
|
/**
|
|
@@ -47,6 +47,11 @@ export interface PunchoutVisit {
|
|
|
47
47
|
readonly readOnly: boolean;
|
|
48
48
|
/** Set once the cart has been handed back; a repeat ask replays the payload. */
|
|
49
49
|
readonly handedBack: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* The origin the hand-back form posts to, once the punchout app has
|
|
52
|
+
* answered it — what the hand-back page's `form-action` allows (PE-994).
|
|
53
|
+
*/
|
|
54
|
+
readonly handBackOrigin?: string | null;
|
|
50
55
|
}
|
|
51
56
|
|
|
52
57
|
/** Where a claimed visit lands the buyer, before it is turned into a path. */
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { getMethod } from "h3";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Paths that own their own 404 handling, or that Vite serves in dev.
|
|
5
|
+
* `/_nuxt` and `/@` are the dev bundler's, `/api` and `/cdn` answer for
|
|
6
|
+
* themselves, `/_ipx` is @nuxt/image.
|
|
7
|
+
*/
|
|
8
|
+
const OWN_NOT_FOUND = ["/api/", "/cdn/", "/_nuxt/", "/_ipx/", "/@", "/node_modules/"];
|
|
9
|
+
|
|
10
|
+
const MEDIA_EXTENSION = /\.(?:png|jpe?g|gif|webp|avif|svg|ico)$/i;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Answer a request for a media file nothing serves with a bare 404.
|
|
14
|
+
*
|
|
15
|
+
* A URL such as `/de/5498-1.png` matches no route, so it falls into the
|
|
16
|
+
* storefront's catch-all page, which throws a 404 inside SSR. Rendering that
|
|
17
|
+
* error costs a full page render per broken image, and in dev the formatted
|
|
18
|
+
* stack (source maps, code frame) is retained until the process is restarted —
|
|
19
|
+
* a cart of broken thumbnails was enough to exhaust the container's memory.
|
|
20
|
+
*
|
|
21
|
+
* Public assets are served before middleware runs, so only requests that no
|
|
22
|
+
* file answers reach this handler.
|
|
23
|
+
*/
|
|
24
|
+
export default defineEventHandler((event) => {
|
|
25
|
+
const method = getMethod(event);
|
|
26
|
+
if (method !== "GET" && method !== "HEAD") {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const path = event.path.split("?")[0] ?? "";
|
|
30
|
+
if (!MEDIA_EXTENSION.test(path) || OWN_NOT_FOUND.some(prefix => path.startsWith(prefix))) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
setResponseStatus(event, 404, "Not Found");
|
|
34
|
+
return "";
|
|
35
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { setResponseHeader } from "h3";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Let the hand-back page submit its form to the visit's return address
|
|
5
|
+
* (PE-994). Which origin: the one the punchout app answered on the first
|
|
6
|
+
* hand-back, kept on the visit cookie. The page is rendered with it in
|
|
7
|
+
* `event.context` so it can tell whether THIS document may submit the form, or
|
|
8
|
+
* has to be loaded once more with the header that allows it.
|
|
9
|
+
*/
|
|
10
|
+
export default defineEventHandler((event) => {
|
|
11
|
+
if (!isHandBackPath(event.path)) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const visit = readPunchoutVisit(event);
|
|
15
|
+
event.context.punchoutHandBackOrigin = visit?.handBackOrigin ?? null;
|
|
16
|
+
setResponseHeader(event, "Content-Security-Policy", handBackFormAction(visit));
|
|
17
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stop the dev server from keeping every rendered page alive.
|
|
3
|
+
*
|
|
4
|
+
* In dev, vue-router, pinia and vue-i18n register a Vue devtools plugin per app
|
|
5
|
+
* through `setupDevtoolsPlugin`. With no devtools hook present — which is always
|
|
6
|
+
* the case on the server — it queues the registration on
|
|
7
|
+
* `globalThis.__VUE_DEVTOOLS_PLUGINS__`, a list nobody ever drains. SSR creates
|
|
8
|
+
* a fresh app per request, so the list grows by one app per page view, and each
|
|
9
|
+
* entry holds that app's whole context: the head tags, the payload and a deep
|
|
10
|
+
* copy of every locale message (~4 MB per request). A few hundred page views
|
|
11
|
+
* exhausted the dev container's memory.
|
|
12
|
+
*
|
|
13
|
+
* The list is only meant for a browser devtools extension, so on the server it
|
|
14
|
+
* is replaced by a sink that discards what is pushed. Builds never queue
|
|
15
|
+
* registrations (devtools-api is compiled out), hence dev only.
|
|
16
|
+
*/
|
|
17
|
+
export default defineNitroPlugin(() => {
|
|
18
|
+
if (!import.meta.dev) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const sink: unknown[] = [];
|
|
22
|
+
sink.push = () => sink.length;
|
|
23
|
+
Object.defineProperty(globalThis, "__VUE_DEVTOOLS_PLUGINS__", {
|
|
24
|
+
configurable: true,
|
|
25
|
+
get: () => sink,
|
|
26
|
+
set: () => {},
|
|
27
|
+
});
|
|
28
|
+
});
|
|
@@ -26,14 +26,14 @@ const cache = new Map<string, { brands: ShopBrand[]; loadedAt: number }>();
|
|
|
26
26
|
* for the same brand.
|
|
27
27
|
*/
|
|
28
28
|
export class ApiBrandService implements IBrandService {
|
|
29
|
-
async listBrands(limit: number, locale: Locale): Promise<ShopBrand[]> {
|
|
30
|
-
const cacheKey = `${revenexxTenantKey()}:${
|
|
29
|
+
async listBrands(limit: number, locale: Locale, searchLocale: string = locale): Promise<ShopBrand[]> {
|
|
30
|
+
const cacheKey = `${revenexxTenantKey()}:${searchLocale}:${limit}`;
|
|
31
31
|
const cached = cache.get(cacheKey);
|
|
32
32
|
if (cached && Date.now() - cached.loadedAt < BRAND_CACHE_TTL_MS) {
|
|
33
33
|
return cached.brands;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
const counts = await this.facetManufacturers(
|
|
36
|
+
const counts = await this.facetManufacturers(searchLocale);
|
|
37
37
|
const top = counts.filter(entry => entry.value.trim().length > 0).slice(0, limit);
|
|
38
38
|
|
|
39
39
|
if (top.length === 0) {
|
|
@@ -53,7 +53,7 @@ export class ApiBrandService implements IBrandService {
|
|
|
53
53
|
view: "brand",
|
|
54
54
|
filters: { manufacturer: [entry.value] },
|
|
55
55
|
perPage: 1,
|
|
56
|
-
locale,
|
|
56
|
+
locale: searchLocale,
|
|
57
57
|
}))));
|
|
58
58
|
}
|
|
59
59
|
|
|
@@ -70,15 +70,15 @@ export class ApiBrandService implements IBrandService {
|
|
|
70
70
|
return brands;
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
async listBrandNames(locale: Locale): Promise<ShopBrand[]> {
|
|
73
|
+
async listBrandNames(locale: Locale, searchLocale: string = locale): Promise<ShopBrand[]> {
|
|
74
74
|
// "names" cannot collide with a numeric limit key.
|
|
75
|
-
const cacheKey = `${revenexxTenantKey()}:${
|
|
75
|
+
const cacheKey = `${revenexxTenantKey()}:${searchLocale}:names`;
|
|
76
76
|
const cached = cache.get(cacheKey);
|
|
77
77
|
if (cached && Date.now() - cached.loadedAt < BRAND_CACHE_TTL_MS) {
|
|
78
78
|
return cached.brands;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
const counts = await this.facetManufacturers(
|
|
81
|
+
const counts = await this.facetManufacturers(searchLocale);
|
|
82
82
|
const brands = counts
|
|
83
83
|
.filter(entry => entry.value.trim().length > 0)
|
|
84
84
|
.map((entry): ShopBrand => ({ name: entry.value, logo: null, productCount: entry.count }));
|
|
@@ -88,7 +88,7 @@ export class ApiBrandService implements IBrandService {
|
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
/** Round trip 1 of listBrands: names + counts, count-descending. */
|
|
91
|
-
private async facetManufacturers(locale:
|
|
91
|
+
private async facetManufacturers(locale: string): Promise<{ value: string; count: number }[]> {
|
|
92
92
|
const result = await searchClient.search({ view: "brand", locale });
|
|
93
93
|
|
|
94
94
|
return result.facets.find(facet => facet.field === "manufacturer")?.counts ?? [];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ShopMarket, ShopMarketCurrency, ShopMarketLocale } from "../../app/interfaces/market";
|
|
2
|
+
import { offeredLocales } from "../../app/shared/locale";
|
|
2
3
|
import type { IMarketService } from "../interfaces/market";
|
|
3
4
|
|
|
4
5
|
interface ApiMarketRow {
|
|
@@ -17,6 +18,8 @@ interface ApiLocaleRow {
|
|
|
17
18
|
country: string;
|
|
18
19
|
is_default: boolean;
|
|
19
20
|
position: number;
|
|
21
|
+
/** `preparing` | `active`; absent on markets builds before PE-866 (= active). */
|
|
22
|
+
status?: string | null;
|
|
20
23
|
}
|
|
21
24
|
|
|
22
25
|
interface ApiCurrencyRow {
|
|
@@ -72,12 +75,16 @@ export class ApiMarketService implements IMarketService {
|
|
|
72
75
|
name: market.name,
|
|
73
76
|
currency: market.currency,
|
|
74
77
|
isDefault: market.is_default,
|
|
75
|
-
|
|
78
|
+
// Default first, a `preparing` locale left out: the shop never
|
|
79
|
+
// offers a language whose catalogue and search are still being
|
|
80
|
+
// built (PE-866).
|
|
81
|
+
locales: offeredLocales(locales.map((locale): ShopMarketLocale => ({
|
|
76
82
|
code: locale.code,
|
|
77
83
|
language: locale.language,
|
|
78
84
|
country: locale.country,
|
|
79
85
|
isDefault: locale.is_default,
|
|
80
|
-
|
|
86
|
+
status: locale.status === "preparing" ? "preparing" : "active",
|
|
87
|
+
}))),
|
|
81
88
|
currencies: currencies.map((currency): ShopMarketCurrency => ({
|
|
82
89
|
code: currency.code,
|
|
83
90
|
isDefault: currency.is_default,
|
|
@@ -32,7 +32,7 @@ export class ApiProductService implements IProductService {
|
|
|
32
32
|
view: "listing",
|
|
33
33
|
...(categories.length ? { filters: { categories } } : {}),
|
|
34
34
|
perPage: LIST_PAGE_SIZE,
|
|
35
|
-
locale,
|
|
35
|
+
locale: filter?.searchLocale ?? locale,
|
|
36
36
|
});
|
|
37
37
|
|
|
38
38
|
return result.docs.map(doc => mapLiveDocToProduct(doc));
|
|
@@ -5,7 +5,9 @@ import type { FormRow, FormSpamPolicy, FormSubmissionResult, FormSummary, IForms
|
|
|
5
5
|
* can produce rather than to look tidy: a contact form (text, email, tel,
|
|
6
6
|
* select, textarea, checkbox), a price request (the `rxKind: product` field a
|
|
7
7
|
* product page pre-fills, plus a radio group), and a two-step return request
|
|
8
|
-
* with a designed thank-you page.
|
|
8
|
+
* with a designed thank-you page. Beside them the `widerruf` form the
|
|
9
|
+
* withdrawal page (§ 356a BGB) submits to: not rendered from its definition,
|
|
10
|
+
* but its fields have to be declared or the submit route drops them.
|
|
9
11
|
*
|
|
10
12
|
* They are authored in German with an English overlay, which is the shape a
|
|
11
13
|
* live form has: the app stores one base definition and per-locale field texts
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { RevenexxException } from "@revenexx/sdk";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* An address the orders app refused (RAD-234, RAD-236).
|
|
5
|
+
*
|
|
6
|
+
* The orders app holds billing and shipping address to the platform's address
|
|
7
|
+
* type and the rules of its country, so a postal code the checkout's own check
|
|
8
|
+
* let through can come back as a 400 `invalid_address` with one sentence
|
|
9
|
+
* naming the field (`shipping_address.postal_code: 2045 is not a postal code in
|
|
10
|
+
* Germany, e.g. 10115.`). This reads that refusal back so the checkout can put
|
|
11
|
+
* the sentence on the field it names rather than in a generic error.
|
|
12
|
+
*/
|
|
13
|
+
export interface AddressRefusal {
|
|
14
|
+
/** The field as the orders app named it, e.g. `shipping_address.postal_code`. */
|
|
15
|
+
field: string;
|
|
16
|
+
/** Which of the two addresses it is, or null when the app named neither. */
|
|
17
|
+
address: "billing" | "shipping" | null;
|
|
18
|
+
/** The key of the address type it faults (`postal_code`), or null for the whole address. */
|
|
19
|
+
key: string | null;
|
|
20
|
+
/** The sentence, without the field it names in front. */
|
|
21
|
+
message: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
interface RefusalBody {
|
|
25
|
+
code?: unknown;
|
|
26
|
+
type?: unknown;
|
|
27
|
+
error?: unknown;
|
|
28
|
+
message?: unknown;
|
|
29
|
+
details?: {
|
|
30
|
+
field?: unknown;
|
|
31
|
+
errors?: Array<{ field?: unknown; message?: unknown }>;
|
|
32
|
+
} | null;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const str = (value: unknown): string => (typeof value === "string" ? value.trim() : "");
|
|
36
|
+
|
|
37
|
+
export function addressRefusalOf(err: unknown): AddressRefusal | null {
|
|
38
|
+
if (!(err instanceof RevenexxException) || err.code !== 400) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
let body: RefusalBody;
|
|
42
|
+
try {
|
|
43
|
+
body = JSON.parse(String(err.response ?? "")) as RefusalBody;
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
if (!body || typeof body !== "object" || (body.code ?? body.type) !== "invalid_address") {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const raw = str(body.error) || str(body.message) || err.message;
|
|
53
|
+
const field = str(body.details?.field) || raw.match(/^([\w.]+_address(?:\.[\w.]+)?):/)?.[1] || "";
|
|
54
|
+
const listed = body.details?.errors?.find(e => str(e.field) === field);
|
|
55
|
+
const message = str(listed?.message)
|
|
56
|
+
|| (field && raw.startsWith(`${field}:`) ? raw.slice(field.length + 1).trim() : raw);
|
|
57
|
+
|
|
58
|
+
const [column, ...rest] = field.split(".");
|
|
59
|
+
const address = column === "billing_address" ? "billing" : column === "shipping_address" ? "shipping" : null;
|
|
60
|
+
const key = rest.length ? rest.join(".") : null;
|
|
61
|
+
|
|
62
|
+
return { field, address, key, message };
|
|
63
|
+
}
|