@shopbite-de/storefront 2.2.1 → 2.4.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 (69) hide show
  1. package/.github/workflows/build.yaml +2 -2
  2. package/.github/workflows/ci.yaml +11 -11
  3. package/.nuxtrc +1 -1
  4. package/CLAUDE.md +13 -7
  5. package/app/app.vue +10 -7
  6. package/app/components/Address/Fields.vue +1 -2
  7. package/app/components/Category/Breadcrumb.vue +9 -10
  8. package/app/components/Checkout/Summary.vue +27 -2
  9. package/app/components/Header.vue +6 -2
  10. package/app/components/Menu/BonCard.vue +1 -2
  11. package/app/components/Order/Confirmation.vue +1 -2
  12. package/app/components/Product/QuickView.vue +1 -2
  13. package/app/composables/useBusinessHours.ts +35 -14
  14. package/app/composables/useHolidays.ts +31 -11
  15. package/app/composables/useHomeMenuCategories.ts +6 -34
  16. package/app/composables/useLiveShopData.ts +17 -0
  17. package/app/composables/useNavigation.ts +14 -66
  18. package/app/composables/useNavigationSearch.ts +8 -31
  19. package/app/composables/useRestaurantSchema.ts +2 -13
  20. package/app/composables/useSeoUrlRoute.ts +21 -0
  21. package/app/composables/useShopBiteConfig.ts +50 -6
  22. package/app/composables/useTopSellers.ts +2 -43
  23. package/app/error.vue +4 -0
  24. package/docs/notes/2026-09-10-issue-275-accessibility.md +2 -2
  25. package/docs/notes/2026-09-12-issue-327-home-hero.md +1 -1
  26. package/docs/notes/2026-09-13-issue-332-home-info-cards.md +1 -3
  27. package/docs/notes/2026-09-21-issue-273-cache-and-demo-video.md +1 -1
  28. package/docs/notes/2026-09-21-issue-363-non-fatal-404.md +1 -1
  29. package/docs/notes/2026-09-23-issue-388-home-sections.md +2 -2
  30. package/docs/notes/2026-10-05-issue-401-restaurant-schema-ordering.md +1 -1
  31. package/docs/notes/2026-11-18-dependency-update.md +118 -0
  32. package/modules/theme.ts +1 -1
  33. package/node.dockerfile +7 -7
  34. package/nuxt.config.ts +22 -1
  35. package/package.json +40 -40
  36. package/pnpm-workspace.yaml +0 -2
  37. package/server/api/_cache/purge.post.ts +6 -3
  38. package/server/api/breadcrumb/[categoryId].get.ts +31 -0
  39. package/server/api/navigation/[type].get.ts +97 -0
  40. package/server/api/payment-methods.get.ts +29 -0
  41. package/server/api/seo-url/index.get.ts +17 -0
  42. package/server/api/seo-url/known.get.ts +33 -0
  43. package/server/api/shopbite/business-hours.get.ts +22 -0
  44. package/server/api/shopbite/config.get.ts +6 -0
  45. package/server/api/shopbite/holidays.get.ts +20 -0
  46. package/server/api/top-sellers.get.ts +59 -0
  47. package/server/plugins/ai-crawlers.ts +1 -1
  48. package/server/plugins/site-url.ts +2 -2
  49. package/server/routes/llms.txt.ts +6 -2
  50. package/server/utils/backoff.ts +67 -0
  51. package/server/utils/cachePurge.ts +45 -12
  52. package/server/utils/menuRoot.ts +24 -18
  53. package/server/utils/seoPaths.ts +130 -0
  54. package/server/utils/seoUrlCache.ts +98 -0
  55. package/server/utils/shopBiteConfig.ts +30 -0
  56. package/server/utils/storeApi.ts +25 -1
  57. package/test/a11y/presets.test.ts +3 -1
  58. package/test/layer/nuxt.config.ts +1 -1
  59. package/test/nuxt/CheckoutOnePage.test.ts +2 -0
  60. package/test/nuxt/CheckoutSummary.test.ts +38 -2
  61. package/test/nuxt/HeaderFooterPreset.test.ts +13 -4
  62. package/test/nuxt/liveShopData.test.ts +114 -0
  63. package/test/nuxt/useShopBiteConfig.test.ts +22 -0
  64. package/test/nuxt/useTopSellers.test.ts +10 -27
  65. package/test/unit/cachePurge.spec.ts +41 -0
  66. package/test/unit/layoutCacheRoutes.spec.ts +566 -0
  67. package/test/unit/nitroStubs.ts +99 -0
  68. package/test/unit/seoPaths.spec.ts +117 -0
  69. package/patches/@shopware__nuxt-module@1.5.2.patch +0 -13
@@ -0,0 +1,99 @@
1
+ import { vi } from "vitest";
2
+
3
+ /**
4
+ * Nitro's auto-imports as globals, so server route files can be imported in
5
+ * the Node test project: the cache wrappers return the handler/function and
6
+ * their options instead of caching.
7
+ */
8
+ export interface CachedHandler {
9
+ handler: (event: TestEvent) => Promise<unknown>;
10
+ opts: {
11
+ name: string;
12
+ maxAge: number;
13
+ swr?: boolean;
14
+ getKey: (event: TestEvent) => string | Promise<string>;
15
+ };
16
+ }
17
+
18
+ export interface CachedFunction<A extends unknown[], R> {
19
+ (...args: A): Promise<R>;
20
+ opts: {
21
+ name: string;
22
+ maxAge: number;
23
+ swr?: boolean;
24
+ getKey: (...args: A) => string;
25
+ validate?: (entry: { value?: unknown }) => boolean;
26
+ };
27
+ }
28
+
29
+ export interface TestEvent {
30
+ params?: Record<string, string>;
31
+ query?: Record<string, unknown>;
32
+ context?: Record<string, unknown>;
33
+ }
34
+
35
+ export const CACHE_TTL = {
36
+ product: 86400,
37
+ crossSelling: 86400,
38
+ listing: 86400,
39
+ variant: 3600,
40
+ category: 86400,
41
+ navigation: 86400,
42
+ seoUrl: 600,
43
+ paymentMethods: 3600,
44
+ config: 60,
45
+ businessHours: 300,
46
+ holidays: 300,
47
+ };
48
+
49
+ export function stubNitro(globals: Record<string, unknown> = {}) {
50
+ const stubs: Record<string, unknown> = {
51
+ defineCachedEventHandler: (
52
+ handler: CachedHandler["handler"],
53
+ opts: CachedHandler["opts"],
54
+ ) => ({ handler, opts }),
55
+ // Like Nitro: stores what `validate` accepts (default: not undefined)
56
+ // under `getKey`, for `maxAge` seconds; a thrown error is not stored.
57
+ defineCachedFunction: vi.fn(
58
+ (
59
+ fn: (...args: unknown[]) => Promise<unknown>,
60
+ opts: CachedFunction<unknown[], unknown>["opts"],
61
+ ) => {
62
+ const store = new Map<string, { value: unknown; mtime: number }>();
63
+ const cached = async (...args: unknown[]) => {
64
+ const key = opts.getKey ? opts.getKey(...args) : "";
65
+ const hit = store.get(key);
66
+ if (hit && Date.now() - hit.mtime <= (opts.maxAge ?? 0) * 1000) {
67
+ return hit.value;
68
+ }
69
+ const value = await fn(...args);
70
+ const entry = { value, mtime: Date.now() };
71
+ const valid = opts.validate
72
+ ? opts.validate(entry) !== false
73
+ : value !== undefined;
74
+ if (valid) store.set(key, entry);
75
+ return value;
76
+ };
77
+ return Object.assign(cached, { opts, store });
78
+ },
79
+ ),
80
+ defineEventHandler: (handler: unknown) => handler,
81
+ useRuntimeConfig: () => ({
82
+ public: {
83
+ shopBite: { cacheTtl: CACHE_TTL, menuCategoryId: "" },
84
+ shopware: { endpoint: "http://shopware/store-api", accessToken: "k" },
85
+ },
86
+ }),
87
+ createError: (input: { statusCode: number; statusMessage?: string }) =>
88
+ Object.assign(new Error(input.statusMessage ?? `${input.statusCode}`), {
89
+ statusCode: input.statusCode,
90
+ }),
91
+ getRouterParam: (event: TestEvent, name: string) => event.params?.[name],
92
+ getQuery: (event: TestEvent) => event.query ?? {},
93
+ storeApiPost: vi.fn(),
94
+ storeApiGet: vi.fn(),
95
+ ...globals,
96
+ };
97
+ for (const [name, value] of Object.entries(stubs)) vi.stubGlobal(name, value);
98
+ return stubs as Record<string, ReturnType<typeof vi.fn>>;
99
+ }
@@ -0,0 +1,117 @@
1
+ import { describe, expect, it, vi } from "vitest";
2
+ import { createBackoff } from "../../server/utils/backoff";
3
+ import { mayBeSeoPath, seoPathKey } from "../../server/utils/seoPaths";
4
+
5
+ const KNOWN = new Set(
6
+ [
7
+ "Speisekarte/Pizza/",
8
+ "Speisekarte/Gemüse-Gerichte/",
9
+ "c/Old-Name/",
10
+ "c/Straße/",
11
+ "c/A&B/",
12
+ ].map(seoPathKey),
13
+ );
14
+
15
+ describe("seoPathKey", () => {
16
+ it("compares paths like Shopware's lookup", () => {
17
+ expect(seoPathKey("/Speisekarte/Pizza/")).toBe("speisekarte/pizza");
18
+ expect(seoPathKey("Speisekarte/Pizza")).toBe("speisekarte/pizza");
19
+ expect(seoPathKey("/speisekarte/gem%C3%BCse-gerichte/")).toBe(
20
+ "speisekarte/gemuse-gerichte",
21
+ );
22
+ expect(seoPathKey("/c/STRASSE/")).toBe(seoPathKey("/c/Straße/"));
23
+ expect(seoPathKey("/c/a%26b/")).toBe("c/a&b");
24
+ });
25
+
26
+ it("keeps a path that is not valid URI encoding", () => {
27
+ expect(seoPathKey("/a%E0%A4%A/")).toBe("a%e0%a4%a");
28
+ });
29
+ });
30
+
31
+ describe("mayBeSeoPath", () => {
32
+ it("accepts known paths in every casing, with or without slash", () => {
33
+ expect(mayBeSeoPath("/Speisekarte/Pizza/", KNOWN)).toBe(true);
34
+ expect(mayBeSeoPath("/speisekarte/pizza", KNOWN)).toBe(true);
35
+ expect(mayBeSeoPath("/Speisekarte/Gem%C3%BCse-Gerichte/", KNOWN)).toBe(
36
+ true,
37
+ );
38
+ expect(mayBeSeoPath("/c/old-name/", KNOWN)).toBe(true);
39
+ expect(mayBeSeoPath("/c/strasse/", KNOWN)).toBe(true);
40
+ expect(mayBeSeoPath("/c/a%26b/", KNOWN)).toBe(true);
41
+ });
42
+
43
+ it("rejects ASCII paths no category had", () => {
44
+ expect(mayBeSeoPath("/wp-admin/", KNOWN)).toBe(false);
45
+ expect(mayBeSeoPath("/.git/HEAD", KNOWN)).toBe(false);
46
+ });
47
+
48
+ it("lets through what it cannot compare like the database", () => {
49
+ expect(mayBeSeoPath("/c/%C3%B8l/", KNOWN)).toBe(true);
50
+ });
51
+
52
+ it("leaves technical URLs and an unknown list to the lookup", () => {
53
+ expect(
54
+ mayBeSeoPath("/navigation/0123456789abcdef0123456789abcdef", KNOWN),
55
+ ).toBe(true);
56
+ expect(mayBeSeoPath("/wp-admin/", null)).toBe(true);
57
+ });
58
+ });
59
+
60
+ describe("createBackoff", () => {
61
+ it("is active for the given time after a failure", () => {
62
+ const now = vi.fn(() => 1000);
63
+ const backoff = createBackoff(30_000, now);
64
+ expect(backoff.active()).toBe(false);
65
+ backoff.trip();
66
+ now.mockReturnValue(30_999);
67
+ expect(backoff.active()).toBe(true);
68
+ now.mockReturnValue(31_000);
69
+ expect(backoff.active()).toBe(false);
70
+ });
71
+ });
72
+
73
+ describe("hostile paths", () => {
74
+ const HOSTILE = [
75
+ "/%c0%ae%c0%ae/etc/passwd",
76
+ "/%252e%252e/etc/passwd",
77
+ "/..%252f..%252fetc%252fpasswd",
78
+ "/../etc/passwd",
79
+ "/%2e%2e/etc/passwd",
80
+ "/%ff",
81
+ "/navigation/zzz",
82
+ "/detail/abc",
83
+ "/landingPage/x",
84
+ "/navigation/0123456789abcdef0123456789abcdef/x",
85
+ ];
86
+
87
+ it("are rejected, even without a list of known paths", () => {
88
+ for (const path of HOSTILE) {
89
+ expect(mayBeSeoPath(path, KNOWN), path).toBe(false);
90
+ expect(mayBeSeoPath(path, null), path).toBe(false);
91
+ }
92
+ });
93
+
94
+ it("leave real technical URLs and non-ASCII paths to the lookup", () => {
95
+ const id = "0123456789ABCDEF0123456789abcdef";
96
+ expect(mayBeSeoPath(`/navigation/${id}`, KNOWN)).toBe(true);
97
+ expect(mayBeSeoPath(`/detail/${id}/`, KNOWN)).toBe(true);
98
+ expect(mayBeSeoPath(`/landingPage/${id}`, null)).toBe(true);
99
+ expect(mayBeSeoPath("/c/%C3%B8l/", KNOWN)).toBe(true);
100
+ });
101
+ });
102
+
103
+ describe("isOutage", () => {
104
+ it("counts fetch errors without a response and 5xx, not bugs or 4xx", async () => {
105
+ const { isOutage } = await import("../../server/utils/backoff");
106
+ const fetchError = (status?: number) =>
107
+ Object.assign(new Error("[GET] fetch failed"), {
108
+ name: "FetchError",
109
+ ...(status ? { status, statusCode: status } : {}),
110
+ });
111
+
112
+ expect(isOutage(fetchError())).toBe(true);
113
+ expect(isOutage(fetchError(503))).toBe(true);
114
+ expect(isOutage(fetchError(404))).toBe(false);
115
+ expect(isOutage(new TypeError("x is undefined"))).toBe(false);
116
+ });
117
+ });
@@ -1,13 +0,0 @@
1
- diff --git a/plugin.ts b/plugin.ts
2
- index 2b843eaa6d89f38ef4bd1bce3a0090aa41034572..3a59bd45ac795e80d668fa195f5f311bb92c8a4b 100644
3
- --- a/plugin.ts
4
- +++ b/plugin.ts
5
- @@ -16,7 +16,7 @@ import {
6
- } from "#imports";
7
- import type { ApiClient } from "#shopware";
8
-
9
- -import type { ShopwareNuxtOptions } from "./src";
10
- +import type { ShopwareNuxtOptions } from "./dist/index";
11
-
12
- type ShopwarePluginInjections = {
13
- shopwareApiClient: ApiClient;