@revenexx/cover 0.2.26 → 0.2.28
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/brands.ts +5 -0
- package/app/api/categories.ts +1 -0
- package/app/api/product.ts +2 -0
- package/app/app.config.ts +8 -0
- package/app/components/cart/quickadd/CartQuickAdd.vue +110 -34
- package/app/components/category/view/GridView.vue +34 -13
- package/app/components/category/view/ListView.vue +5 -5
- package/app/components/layout/AppLogo.vue +2 -1
- package/app/components/layout/footer/Footer.vue +9 -3
- package/app/components/layout/header/CategoryPanel.vue +92 -0
- package/app/components/layout/header/MainNav.vue +89 -2
- package/app/components/listing/ListingResults.vue +16 -2
- package/app/components/listing/ListingSubcategories.vue +124 -0
- package/app/components/product/card/Compact.vue +144 -0
- package/app/components/product/detail/ProductDetailAssociations.vue +96 -0
- package/app/components/product/detail/ProductDetailIdentity.vue +50 -5
- package/app/components/product/detail/ProductDetailVariantRow.vue +139 -0
- package/app/components/product/detail/ProductDetailVariants.vue +613 -0
- package/app/components/product/media/ProductMediaImage.vue +70 -0
- package/app/components/ui/forms/SearchInput.vue +14 -2
- package/app/components/ui/media/ImageSlider.vue +158 -0
- package/app/composables/useBranding.ts +22 -0
- package/app/composables/useBrands.ts +42 -0
- package/app/composables/useCategories.ts +55 -1
- package/app/composables/useProduct.ts +5 -4
- package/app/composables/useProductAssociations.ts +35 -0
- package/app/composables/useProductImage.ts +35 -2
- package/app/composables/useProductVariants.ts +46 -0
- package/app/composables/useSearchListing.ts +16 -5
- package/app/composables/useSubcategoryTiles.ts +36 -0
- package/app/config/navigation.ts +9 -0
- package/app/config/palette.ts +1 -0
- package/app/config/quickActions.ts +137 -0
- package/app/config/themes.ts +1 -0
- package/app/interfaces/brand.ts +16 -0
- package/app/interfaces/category.ts +45 -0
- package/app/interfaces/image-slider.ts +18 -0
- package/app/interfaces/product-associations.ts +32 -0
- package/app/interfaces/product-detail.ts +6 -0
- package/app/interfaces/product-variants.ts +73 -0
- package/i18n/locales/de/account.json +17 -0
- package/i18n/locales/de/cart.json +5 -1
- package/i18n/locales/de/common.json +42 -2
- package/i18n/locales/de/editor.json +91 -0
- package/i18n/locales/de/product.json +48 -2
- package/i18n/locales/de/search.json +4 -2
- package/i18n/locales/en/account.json +17 -0
- package/i18n/locales/en/cart.json +4 -0
- package/i18n/locales/en/common.json +42 -2
- package/i18n/locales/en/editor.json +91 -0
- package/i18n/locales/en/product.json +47 -1
- package/i18n/locales/en/search.json +3 -1
- package/nuxt.config.ts +10 -0
- package/package.json +3 -1
- package/public/img/brands/revenexx.svg +39 -0
- package/server/api/brands.get.ts +27 -0
- package/server/api/categories/[slug]/subcategories.get.ts +280 -0
- package/server/api/product/[id]/associations.get.ts +27 -0
- package/server/api/product/[id]/variants.get.ts +27 -0
- package/server/api/quick-actions.get.ts +43 -0
- package/server/api/typesense/search.post.ts +116 -13
- package/server/data/categories.json +5 -0
- package/server/data/product-associations.json +44 -0
- package/server/data/product-detail.json +346 -0
- package/server/data/product-list.json +340 -0
- package/server/data/product-variant-models.json +75 -0
- package/server/interfaces/brand.ts +17 -0
- package/server/interfaces/product.ts +14 -0
- package/server/services/ApiBrandService.ts +110 -0
- package/server/services/ApiProductService.ts +43 -9
- package/server/services/LocalFileProductService.ts +200 -6
- package/server/services/MockBrandService.ts +52 -0
- package/server/utils/brandService.ts +24 -0
- package/server/utils/contentTenant.ts +67 -0
- package/server/utils/liveCatalog.ts +759 -46
- package/server/utils/productService.ts +6 -1
- package/server/utils/productsSchema.ts +5 -2
- package/server/utils/revenexxCredentials.ts +258 -0
- package/server/utils/revenexxSdk.ts +38 -47
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ProductAssociations } from "../../../../app/interfaces/product-associations";
|
|
2
|
+
|
|
3
|
+
/** A product that relates to nothing — an answer, not an error. */
|
|
4
|
+
const NO_ASSOCIATIONS: ProductAssociations = { groups: [] };
|
|
5
|
+
|
|
6
|
+
export default defineEventHandler(async (event): Promise<ProductAssociations> => {
|
|
7
|
+
const id = getRouterParam(event, "id") ?? "";
|
|
8
|
+
if (!id) {
|
|
9
|
+
throw createError({ statusCode: 400, message: "Invalid product id" });
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const locale = resolveLocale(event);
|
|
13
|
+
|
|
14
|
+
try {
|
|
15
|
+
// A product with no relations answers 200 with no groups: the grid is an
|
|
16
|
+
// enrichment, so "this product has none" must not read as a failure the
|
|
17
|
+
// client has to special-case.
|
|
18
|
+
return await getProductService(event).getProductAssociations(id, locale) ?? NO_ASSOCIATIONS;
|
|
19
|
+
}
|
|
20
|
+
catch (err) {
|
|
21
|
+
if (err !== null && typeof err === "object" && "statusCode" in err) {
|
|
22
|
+
throw err;
|
|
23
|
+
}
|
|
24
|
+
getLogService().error("Service error: product/associations", { id, ...toErrorContext(err) });
|
|
25
|
+
throw createError({ statusCode: 500, message: "Internal server error" });
|
|
26
|
+
}
|
|
27
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ProductVariants } from "../../../../app/interfaces/product-variants";
|
|
2
|
+
|
|
3
|
+
/** A product that belongs to no model — an answer, not an error. */
|
|
4
|
+
const NO_VARIANTS: ProductVariants = { variants: [], axes: [], model: null };
|
|
5
|
+
|
|
6
|
+
export default defineEventHandler(async (event): Promise<ProductVariants> => {
|
|
7
|
+
const id = getRouterParam(event, "id") ?? "";
|
|
8
|
+
if (!id) {
|
|
9
|
+
throw createError({ statusCode: 400, message: "Invalid product id" });
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const locale = resolveLocale(event);
|
|
13
|
+
|
|
14
|
+
try {
|
|
15
|
+
// A standalone article answers 200 with an empty group: the variants
|
|
16
|
+
// section is an enrichment, so "this product has none" must not read as
|
|
17
|
+
// a failure the client has to special-case.
|
|
18
|
+
return await getProductService(event).getProductVariants(id, locale) ?? NO_VARIANTS;
|
|
19
|
+
}
|
|
20
|
+
catch (err) {
|
|
21
|
+
if (err !== null && typeof err === "object" && "statusCode" in err) {
|
|
22
|
+
throw err;
|
|
23
|
+
}
|
|
24
|
+
getLogService().error("Service error: product/variants", { id, ...toErrorContext(err) });
|
|
25
|
+
throw createError({ statusCode: 500, message: "Internal server error" });
|
|
26
|
+
}
|
|
27
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { quickActions } from "../../app/config/quickActions";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The shortcut catalogue behind the `quick_actions` block, with its i18n keys
|
|
5
|
+
* already resolved.
|
|
6
|
+
*
|
|
7
|
+
* This exists for the blökkli picker overlay: that component is compiled
|
|
8
|
+
* through the editor's own runtime pipeline, so it has neither Nuxt's `$fetch`
|
|
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.
|
|
12
|
+
*
|
|
13
|
+
* Static config, not a BFF domain: no service interface, no app.config registry
|
|
14
|
+
* key, nothing to switch between mock and live.
|
|
15
|
+
*/
|
|
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
|
+
});
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { ProductList } from "../../../app/interfaces/product-list";
|
|
2
2
|
import type { SearchFacet } from "../../../app/interfaces/search-facets";
|
|
3
|
+
import type { Locale } from "../../utils/locale";
|
|
3
4
|
|
|
4
|
-
import { loadLiveAttributeMeta } from "../../utils/liveCatalog";
|
|
5
|
+
import { liveCategorySubtreeCodes, liveSubcategoryIndex, loadLiveAttributeMeta, rollUpSubcategoryCounts } from "../../utils/liveCatalog";
|
|
5
6
|
import { FACET_FIELDS, PRODUCTS_COLLECTION } from "../../utils/productsSchema";
|
|
6
7
|
|
|
7
8
|
/**
|
|
@@ -29,6 +30,36 @@ function isMissingSortFieldError(err: unknown): boolean {
|
|
|
29
30
|
return /Could not find a field named .* in the schema for sorting/i.test(msg);
|
|
30
31
|
}
|
|
31
32
|
|
|
33
|
+
/**
|
|
34
|
+
* The live category codes behind the storefront's subcategory filter values.
|
|
35
|
+
*
|
|
36
|
+
* `subcategorySlug` carries a code already; the user-facing `subcategory` facet
|
|
37
|
+
* is LABEL-valued (it mirrors the mock schema, where the slug lives in its own
|
|
38
|
+
* field), so a value picked in the rail arrives as a label. Both are accepted —
|
|
39
|
+
* an unmatched value is passed through as a code so a hand-edited URL yields an
|
|
40
|
+
* honest zero-hit filter rather than silently dropping the constraint.
|
|
41
|
+
*/
|
|
42
|
+
async function resolveSubcategoryCodes(
|
|
43
|
+
values: string[],
|
|
44
|
+
parentCode: string,
|
|
45
|
+
locale: Locale,
|
|
46
|
+
): Promise<string[]> {
|
|
47
|
+
if (!parentCode) {
|
|
48
|
+
return values;
|
|
49
|
+
}
|
|
50
|
+
const { labels } = await liveSubcategoryIndex(parentCode, locale);
|
|
51
|
+
return values.map((value) => {
|
|
52
|
+
if (labels.has(value)) {
|
|
53
|
+
return value;
|
|
54
|
+
}
|
|
55
|
+
const match = [...labels.entries()].find(([, label]) => label === value);
|
|
56
|
+
return match?.[0] ?? value;
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Typesense's own ceiling for `max_facet_values`. */
|
|
61
|
+
const LIVE_MAX_FACET_VALUES = 250;
|
|
62
|
+
|
|
32
63
|
type SortOption = "relevance" | "price_asc" | "price_desc" | "name_asc" | "name_desc" | "sku_asc" | "sku_desc";
|
|
33
64
|
|
|
34
65
|
const SORT_MAP: Record<SortOption, string> = {
|
|
@@ -81,24 +112,34 @@ export default defineEventHandler(async (event) => {
|
|
|
81
112
|
.filter(([, m]) => m.isFilterable && !m.hidden)
|
|
82
113
|
.map(([code]) => code);
|
|
83
114
|
|
|
115
|
+
// The category this request is pinned to, kept for the facet mapping
|
|
116
|
+
// below — the live index facets on `categories` (codes), the storefront
|
|
117
|
+
// asks for a `subcategory` facet of that category's children.
|
|
118
|
+
let pinnedCategoryCode = "";
|
|
119
|
+
|
|
84
120
|
if (filters) {
|
|
85
121
|
// The storefront filters with the demo-schema field names; the
|
|
86
122
|
// live collection (search.json) names them differently. Category
|
|
87
123
|
// slugs ARE the live category codes, but products carry their
|
|
88
|
-
// LEAF code only — a
|
|
124
|
+
// LEAF code only — a branch expands to its whole subtree.
|
|
89
125
|
// Unknown fields are dropped instead of 400ing the request.
|
|
126
|
+
//
|
|
127
|
+
// Category and subcategory are collected SEPARATELY: they used to
|
|
128
|
+
// share one array and were emitted as a single OR'd clause, which
|
|
129
|
+
// made a subcategory page return its parent's entire catalogue
|
|
130
|
+
// instead of narrowing it. The narrower of the two wins.
|
|
90
131
|
const categoryCodes: string[] = [];
|
|
91
|
-
const
|
|
132
|
+
const subcategoryValues: string[] = [];
|
|
92
133
|
|
|
93
134
|
for (const [field, values] of Object.entries(filters)) {
|
|
94
135
|
if (!values?.length) {
|
|
95
136
|
continue;
|
|
96
137
|
}
|
|
97
|
-
if (field === "categorySlug" || field === "
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
138
|
+
if (field === "categorySlug" || field === "categories") {
|
|
139
|
+
categoryCodes.push(...values);
|
|
140
|
+
}
|
|
141
|
+
else if (field === "subcategorySlug" || field === "subcategory") {
|
|
142
|
+
subcategoryValues.push(...values);
|
|
102
143
|
}
|
|
103
144
|
else if (field === "manufacturer" || field === "kind") {
|
|
104
145
|
liveFilterParts.push(`${field}:=[${values.map(v => tsFilterValue(v)).join(",")}]`);
|
|
@@ -116,8 +157,22 @@ export default defineEventHandler(async (event) => {
|
|
|
116
157
|
}
|
|
117
158
|
}
|
|
118
159
|
|
|
119
|
-
|
|
120
|
-
|
|
160
|
+
pinnedCategoryCode = categoryCodes[0] ?? "";
|
|
161
|
+
|
|
162
|
+
// Resolved after the loop, not inside it: `filters` merges the
|
|
163
|
+
// user's selection over the page's fixed filters, so `subcategory`
|
|
164
|
+
// can be enumerated before `categorySlug` and the parent would not
|
|
165
|
+
// be known yet.
|
|
166
|
+
const subcategoryCodes = subcategoryValues.length
|
|
167
|
+
? await resolveSubcategoryCodes(subcategoryValues, pinnedCategoryCode, locale)
|
|
168
|
+
: [];
|
|
169
|
+
|
|
170
|
+
// Deepest wins: a subcategory replaces its parent's clause rather
|
|
171
|
+
// than being OR'd next to it.
|
|
172
|
+
const branchCodes = subcategoryCodes.length ? subcategoryCodes : categoryCodes;
|
|
173
|
+
if (branchCodes.length) {
|
|
174
|
+
const leafCodes = await liveCategorySubtreeCodes(branchCodes);
|
|
175
|
+
liveFilterParts.push(`categories:=[${leafCodes.map(tsFilterValue).join(",")}]`);
|
|
121
176
|
}
|
|
122
177
|
}
|
|
123
178
|
|
|
@@ -157,6 +212,11 @@ export default defineEventHandler(async (event) => {
|
|
|
157
212
|
queryBy: "name,sku,description,manufacturer",
|
|
158
213
|
filterBy: liveFilterParts.join(" && "),
|
|
159
214
|
facetBy,
|
|
215
|
+
// Typesense answers with 10 values per facet when this is unset,
|
|
216
|
+
// which silently truncates the rail AND undercounts the subcategory
|
|
217
|
+
// roll-up below (products are indexed at the leaf, so one child can
|
|
218
|
+
// span many facet values). 250 is Typesense's own ceiling.
|
|
219
|
+
maxFacetValues: LIVE_MAX_FACET_VALUES,
|
|
160
220
|
...(sortBy ? { sortBy } : {}),
|
|
161
221
|
page,
|
|
162
222
|
perPage,
|
|
@@ -206,6 +266,29 @@ export default defineEventHandler(async (event) => {
|
|
|
206
266
|
counts: (fc.counts ?? []).map(c => ({ value: c.value, count: c.count })),
|
|
207
267
|
}));
|
|
208
268
|
|
|
269
|
+
// The category page asks for a `subcategory` facet; the live index
|
|
270
|
+
// only knows `categories`. Without this bridge the field names never
|
|
271
|
+
// meet and the drill-down is invisible in live mode. Derived rather
|
|
272
|
+
// than renamed — the search page still consumes `categories`.
|
|
273
|
+
if (pinnedCategoryCode) {
|
|
274
|
+
const { labels, branchOf } = await liveSubcategoryIndex(pinnedCategoryCode, locale);
|
|
275
|
+
// Counts arrive on the LEAF codes, so they are summed back up
|
|
276
|
+
// onto the direct child each leaf belongs to.
|
|
277
|
+
const byBranch = rollUpSubcategoryCounts(
|
|
278
|
+
facets.find(f => f.fieldName === "categories")?.counts ?? [],
|
|
279
|
+
branchOf,
|
|
280
|
+
);
|
|
281
|
+
if (byBranch.size) {
|
|
282
|
+
facets.push({
|
|
283
|
+
fieldName: "subcategory",
|
|
284
|
+
counts: [...byBranch].map(([code, count]) => ({
|
|
285
|
+
value: labels.get(code) ?? code,
|
|
286
|
+
count,
|
|
287
|
+
})),
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
209
292
|
return {
|
|
210
293
|
products,
|
|
211
294
|
facets,
|
|
@@ -246,18 +329,38 @@ export default defineEventHandler(async (event) => {
|
|
|
246
329
|
|
|
247
330
|
const sortBy = SORT_MAP[sort] ?? SORT_MAP.relevance;
|
|
248
331
|
|
|
249
|
-
|
|
250
|
-
|
|
332
|
+
const runSearch = (sortByParam: string | undefined) =>
|
|
333
|
+
ts.collections(PRODUCTS_COLLECTION).documents().search({
|
|
251
334
|
q,
|
|
252
335
|
query_by: "name,sku",
|
|
253
336
|
facet_by: FACET_FIELDS.join(","),
|
|
254
337
|
num_typos: 2,
|
|
255
338
|
...(filterParts.length ? { filter_by: filterParts.join(" && ") } : {}),
|
|
256
|
-
sort_by:
|
|
339
|
+
...(sortByParam ? { sort_by: sortByParam } : {}),
|
|
257
340
|
page,
|
|
258
341
|
per_page: perPage,
|
|
259
342
|
});
|
|
260
343
|
|
|
344
|
+
try {
|
|
345
|
+
// Same fallback the live branch makes: a collection provisioned before
|
|
346
|
+
// `name`/`sku` were declared `sort: true` answers 404 for those sorts.
|
|
347
|
+
// Sorting is a nicety, the listing is not — retry unsorted rather than
|
|
348
|
+
// fail the page, and let it start working once the tenant re-seeds.
|
|
349
|
+
let results;
|
|
350
|
+
try {
|
|
351
|
+
results = await runSearch(sortBy);
|
|
352
|
+
}
|
|
353
|
+
catch (err) {
|
|
354
|
+
if (!isMissingSortFieldError(err)) {
|
|
355
|
+
throw err;
|
|
356
|
+
}
|
|
357
|
+
getLogService().warn(
|
|
358
|
+
"search: collection has no sortable field for this sort, retrying unsorted",
|
|
359
|
+
toErrorContext(err),
|
|
360
|
+
);
|
|
361
|
+
results = await runSearch(undefined);
|
|
362
|
+
}
|
|
363
|
+
|
|
261
364
|
// Catalog shell only. The index keeps a scalar `price` purely as a
|
|
262
365
|
// sort/filter key (catalog list price) and the catalog tax rate; the
|
|
263
366
|
// buyer-facing price tiers + availability are the Offer domain and
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_comment": "Demo product associations. `types` fixes the group order and their labels; `byProduct` wins over `byCategory`, which keys on the MAIN category slug so every phone gets the accessory set from one entry instead of twenty. Target ids point at product-list.json, where each item's name, sku and image are read from — nothing is duplicated here.",
|
|
3
|
+
"types": [
|
|
4
|
+
{
|
|
5
|
+
"code": "accessories",
|
|
6
|
+
"labels": {
|
|
7
|
+
"de": "Zubehör",
|
|
8
|
+
"en": "Accessories"
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"code": "mandatory",
|
|
13
|
+
"labels": {
|
|
14
|
+
"de": "Pflichtzubehör",
|
|
15
|
+
"en": "Mandatory accessories"
|
|
16
|
+
},
|
|
17
|
+
"isMandatory": true
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"code": "sparepart",
|
|
21
|
+
"labels": {
|
|
22
|
+
"de": "Ersatzteile",
|
|
23
|
+
"en": "Spare parts"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
],
|
|
27
|
+
"byCategory": {
|
|
28
|
+
"mobile-phones": {
|
|
29
|
+
"accessories": ["7001", "7002", "7003", "7005"],
|
|
30
|
+
"mandatory": ["7004"]
|
|
31
|
+
},
|
|
32
|
+
"technology": {
|
|
33
|
+
"accessories": ["7002", "7003", "7005"]
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"byProduct": {
|
|
37
|
+
"7001": {
|
|
38
|
+
"sparepart": ["7004"]
|
|
39
|
+
},
|
|
40
|
+
"7005": {
|
|
41
|
+
"accessories": ["7002", "7003"]
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|