@scayle/storefront-nuxt 7.70.0 → 7.71.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @scayle/storefront-nuxt
2
2
 
3
+ ## 7.71.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Correctly set the `optimizeDeps` for the new `@scayle/storefront-api` package
8
+ - Updated dependencies
9
+ - @scayle/storefront-core@7.51.1
10
+
11
+ ## 7.71.0
12
+
13
+ ### Minor Changes
14
+
15
+ - Add new shopSelector mode `path_or_default`
16
+
17
+ The `path_or_default` mode is similar to `path`, but loading the root will open the default shop instead of redirecting to the first shop. So you can have a shop at `example.com/` and `example.com/de` instead of `example.com/en` and `example.com/de`. To set a default shop, add `isDefault: true` to the shop's configuration in the `nuxt.config`. When using `nuxt-i18n` the `strategy` option should be set to `prefix_except_default`. (This is the default value.)
18
+
3
19
  ## 7.70.0
4
20
 
5
21
  ### Minor Changes
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- export { f as AdditionalShopConfig, A as AppKeys, B as BapiConfig, b as CacheConfig, j as CheckoutEvent, C as CheckoutShopConfig, M as ModuleOptions, k as ModulePublicRuntimeConfig, O as OauthConfig, P as PublicShopConfig, e as RedirectsConfig, R as RedisConfig, a as SessionConfig, g as ShopConfig, h as ShopConfigIndexed, d as StorageConfig, c as StorageEntity, S as StorageProvider, i as StorefrontConfig } from './shared/storefront-nuxt.c7df291d.mjs';
1
+ export { f as AdditionalShopConfig, A as AppKeys, B as BapiConfig, b as CacheConfig, j as CheckoutEvent, C as CheckoutShopConfig, M as ModuleOptions, k as ModulePublicRuntimeConfig, O as OauthConfig, P as PublicShopConfig, e as RedirectsConfig, R as RedisConfig, a as SessionConfig, g as ShopConfig, h as ShopConfigIndexed, d as StorageConfig, c as StorageEntity, S as StorageProvider, i as StorefrontConfig } from './shared/storefront-nuxt.b9f5584c.mjs';
2
2
  export { rpcCall } from './rpc.mjs';
3
3
  export * from '@scayle/storefront-core';
4
4
  export { LogLevel } from '@scayle/storefront-core';
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { f as AdditionalShopConfig, A as AppKeys, B as BapiConfig, b as CacheConfig, j as CheckoutEvent, C as CheckoutShopConfig, M as ModuleOptions, k as ModulePublicRuntimeConfig, O as OauthConfig, P as PublicShopConfig, e as RedirectsConfig, R as RedisConfig, a as SessionConfig, g as ShopConfig, h as ShopConfigIndexed, d as StorageConfig, c as StorageEntity, S as StorageProvider, i as StorefrontConfig } from './shared/storefront-nuxt.c7df291d.js';
1
+ export { f as AdditionalShopConfig, A as AppKeys, B as BapiConfig, b as CacheConfig, j as CheckoutEvent, C as CheckoutShopConfig, M as ModuleOptions, k as ModulePublicRuntimeConfig, O as OauthConfig, P as PublicShopConfig, e as RedirectsConfig, R as RedisConfig, a as SessionConfig, g as ShopConfig, h as ShopConfigIndexed, d as StorageConfig, c as StorageEntity, S as StorageProvider, i as StorefrontConfig } from './shared/storefront-nuxt.b9f5584c.js';
2
2
  export { rpcCall } from './rpc.js';
3
3
  export * from '@scayle/storefront-core';
4
4
  export { LogLevel } from '@scayle/storefront-core';
package/dist/module.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as _nuxt_schema from '@nuxt/schema';
2
- import { M as ModuleOptions } from './shared/storefront-nuxt.c7df291d.mjs';
3
- export { f as AdditionalShopConfig, A as AppKeys, B as BapiConfig, b as CacheConfig, j as CheckoutEvent, C as CheckoutShopConfig, k as ModulePublicRuntimeConfig, O as OauthConfig, P as PublicShopConfig, e as RedirectsConfig, R as RedisConfig, a as SessionConfig, g as ShopConfig, h as ShopConfigIndexed, d as StorageConfig, c as StorageEntity, S as StorageProvider, i as StorefrontConfig } from './shared/storefront-nuxt.c7df291d.mjs';
2
+ import { M as ModuleOptions } from './shared/storefront-nuxt.b9f5584c.mjs';
3
+ export { f as AdditionalShopConfig, A as AppKeys, B as BapiConfig, b as CacheConfig, j as CheckoutEvent, C as CheckoutShopConfig, k as ModulePublicRuntimeConfig, O as OauthConfig, P as PublicShopConfig, e as RedirectsConfig, R as RedisConfig, a as SessionConfig, g as ShopConfig, h as ShopConfigIndexed, d as StorageConfig, c as StorageEntity, S as StorageProvider, i as StorefrontConfig } from './shared/storefront-nuxt.b9f5584c.mjs';
4
4
  export { LogLevel } from '@scayle/storefront-core';
5
5
  import '@scayle/unstorage-compression-driver';
6
6
  import 'unstorage';
package/dist/module.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as _nuxt_schema from '@nuxt/schema';
2
- import { M as ModuleOptions } from './shared/storefront-nuxt.c7df291d.js';
3
- export { f as AdditionalShopConfig, A as AppKeys, B as BapiConfig, b as CacheConfig, j as CheckoutEvent, C as CheckoutShopConfig, k as ModulePublicRuntimeConfig, O as OauthConfig, P as PublicShopConfig, e as RedirectsConfig, R as RedisConfig, a as SessionConfig, g as ShopConfig, h as ShopConfigIndexed, d as StorageConfig, c as StorageEntity, S as StorageProvider, i as StorefrontConfig } from './shared/storefront-nuxt.c7df291d.js';
2
+ import { M as ModuleOptions } from './shared/storefront-nuxt.b9f5584c.js';
3
+ export { f as AdditionalShopConfig, A as AppKeys, B as BapiConfig, b as CacheConfig, j as CheckoutEvent, C as CheckoutShopConfig, k as ModulePublicRuntimeConfig, O as OauthConfig, P as PublicShopConfig, e as RedirectsConfig, R as RedisConfig, a as SessionConfig, g as ShopConfig, h as ShopConfigIndexed, d as StorageConfig, c as StorageEntity, S as StorageProvider, i as StorefrontConfig } from './shared/storefront-nuxt.b9f5584c.js';
4
4
  export { LogLevel } from '@scayle/storefront-core';
5
5
  import '@scayle/unstorage-compression-driver';
6
6
  import 'unstorage';
package/dist/module.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scayle/storefront-nuxt",
3
- "version": "7.69.1",
3
+ "version": "7.71.0",
4
4
  "configKey": "storefront",
5
5
  "compatibility": {
6
6
  "nuxt": "^3.9.0"
package/dist/module.mjs CHANGED
@@ -4,6 +4,26 @@ import { rpcMethods } from '@scayle/storefront-core';
4
4
  import { defu } from 'defu';
5
5
  import { genImport, genSafeVariableName } from 'knitwork';
6
6
  import { builtinDrivers } from 'unstorage';
7
+ import 'h3';
8
+
9
+ const convertShopsToList = (stores) => {
10
+ if (Array.isArray(stores)) {
11
+ return stores;
12
+ }
13
+ return Object.values(stores);
14
+ };
15
+ function getApiBasePath(storefrontConfig, shop) {
16
+ const apiPath = shop.apiBasePath || storefrontConfig.apiBasePath || "/api";
17
+ if (storefrontConfig.shopSelector === "path") {
18
+ return `/${shop.path}${apiPath}`;
19
+ } else if (storefrontConfig.shopSelector === "path_or_default") {
20
+ if (shop.isDefault) {
21
+ return apiPath;
22
+ }
23
+ return `/${shop.path}${apiPath}`;
24
+ }
25
+ return apiPath;
26
+ }
7
27
 
8
28
  function getUsedDrivers(options) {
9
29
  const drivers = /* @__PURE__ */ new Set();
@@ -40,7 +60,7 @@ export default {
40
60
  }`;
41
61
  }
42
62
  const PACKAGE_NAME = "@scayle/storefront-nuxt";
43
- const PACKAGE_VERSION = "7.69.1";
63
+ const PACKAGE_VERSION = "7.71.0";
44
64
  const module = defineNuxtModule({
45
65
  meta: {
46
66
  name: PACKAGE_NAME,
@@ -104,7 +124,7 @@ const module = defineNuxtModule({
104
124
  config.optimizeDeps.include.push(
105
125
  PACKAGE_NAME,
106
126
  "@scayle/storefront-core",
107
- "@aboutyou/backbone",
127
+ "@scayle/storefront-api",
108
128
  "slugify"
109
129
  );
110
130
  });
@@ -138,10 +158,13 @@ const module = defineNuxtModule({
138
158
  method: "post"
139
159
  });
140
160
  }
141
- if (nuxt.options.runtimeConfig.storefront.shopSelector === "path") {
142
- const stores = Array.isArray(nuxt.options.runtimeConfig.storefront.stores) ? nuxt.options.runtimeConfig.storefront.stores : Object.values(nuxt.options.runtimeConfig.storefront.stores);
143
- stores.forEach((iteratedStore) => {
144
- const base = `/${iteratedStore.path}${apiBasePath}`;
161
+ const shops = convertShopsToList(
162
+ nuxt.options.runtimeConfig.storefront.stores
163
+ );
164
+ const shopSelector = nuxt.options.runtimeConfig.storefront.shopSelector;
165
+ if (shopSelector === "path" || shopSelector === "path_or_default") {
166
+ shops.forEach((shop) => {
167
+ const base = getApiBasePath(nuxt.options.runtimeConfig.storefront, shop);
145
168
  addCacheServerHandlers(base);
146
169
  addRPCServerHandlers(base);
147
170
  });
package/dist/rpc.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { RpcMethodName, RpcMethodParameters, RpcMethodReturnType, RpcContext } from '@scayle/storefront-core';
2
2
  import { NuxtApp } from 'nuxt/app';
3
- import { P as PublicShopConfig } from './shared/storefront-nuxt.c7df291d.mjs';
3
+ import { P as PublicShopConfig } from './shared/storefront-nuxt.b9f5584c.mjs';
4
4
  import '@nuxt/schema';
5
5
  import '@scayle/unstorage-compression-driver';
6
6
  import 'unstorage';
package/dist/rpc.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { RpcMethodName, RpcMethodParameters, RpcMethodReturnType, RpcContext } from '@scayle/storefront-core';
2
2
  import { NuxtApp } from 'nuxt/app';
3
- import { P as PublicShopConfig } from './shared/storefront-nuxt.c7df291d.js';
3
+ import { P as PublicShopConfig } from './shared/storefront-nuxt.b9f5584c.js';
4
4
  import '@nuxt/schema';
5
5
  import '@scayle/unstorage-compression-driver';
6
6
  import 'unstorage';
@@ -4,7 +4,7 @@ type Options = Partial<{
4
4
  key: string;
5
5
  }>;
6
6
  export declare function useShopConfiguration({ options, key, }?: Options): Promise<{
7
- data: import("vue").Ref<import("@scayle/storefront-api").ShopConfigurationResponseData | undefined>;
7
+ data: import("vue").Ref<import("@scayle/storefront-api").ShopConfiguration | undefined>;
8
8
  fetching: import("vue").Ref<boolean>;
9
9
  fetch: () => Promise<void>;
10
10
  error: import("vue").Ref<import("nuxt/app").NuxtError<unknown> | undefined>;
@@ -8,10 +8,11 @@ import {
8
8
  import { buildContext } from "../../context.mjs";
9
9
  import { useCacheStorage, useSessionStorage } from "../utils/cacheStorage.mjs";
10
10
  import {
11
- convertStoresToList,
11
+ convertShopsToList,
12
12
  getCurrentShopConfigForRequest,
13
13
  getPublicShopData,
14
- getBootstrapPath
14
+ getBootstrapPath,
15
+ getApiBasePath
15
16
  } from "./bootstrap.utils.mjs";
16
17
  import { useRedirects } from "./redirects.mjs";
17
18
  import { useRuntimeConfig } from "#imports";
@@ -100,7 +101,7 @@ async function bootstrap(event, $shopConfig, $storefrontConfig, apiBasePath, con
100
101
  apiBasePath,
101
102
  $storefrontConfig.publicShopData
102
103
  );
103
- event.context.$availableShops = convertStoresToList($storefrontConfig.stores).filter((store) => store.isEnabled !== false).map(
104
+ event.context.$availableShops = convertShopsToList($storefrontConfig.stores).filter((store) => store.isEnabled !== false).map(
104
105
  (config2) => getPublicShopData(
105
106
  config2,
106
107
  $shopConfig.shopId,
@@ -150,7 +151,7 @@ export default defineEventHandler(async (event) => {
150
151
  );
151
152
  return;
152
153
  }
153
- const apiBasePath = ($storefrontConfig.shopSelector === "path" && $shopConfig.path ? `/${$shopConfig.path}` : "") + ($shopConfig.apiBasePath || $storefrontConfig.apiBasePath || "/api");
154
+ const apiBasePath = getApiBasePath($storefrontConfig, $shopConfig);
154
155
  if (!event.context.$rpcContext) {
155
156
  event.context.$log.debug("Bootstrapping request: " + path);
156
157
  await bootstrap(
@@ -5,7 +5,8 @@ type BootstrapPath = {
5
5
  originalPath: string;
6
6
  };
7
7
  export declare function getBootstrapPath(event: H3Event): BootstrapPath;
8
- export declare const convertStoresToList: (stores: ShopConfig[] | ShopConfigIndexed) => ShopConfig[];
8
+ export declare const convertShopsToList: (stores: ShopConfig[] | ShopConfigIndexed) => ShopConfig[];
9
+ export declare function getApiBasePath(storefrontConfig: ModuleOptions, shop: ShopConfig): string;
9
10
  export declare function getCurrentShopConfigForRequest(event: H3Event, config: Pick<ModuleOptions, 'stores' | 'shopSelector'>): ShopConfig | undefined;
10
11
  export declare function getPublicShopData(data: ShopConfig, currentShopId: number, apiBasePath: string, publicShopData?: (keyof ShopConfig)[]): PublicShopConfig & {
11
12
  isActive: boolean;
@@ -3,39 +3,57 @@ import {
3
3
  getRequestHost,
4
4
  getRequestURL
5
5
  } from "h3";
6
- import { isArray, listify } from "radash";
7
6
  export function getBootstrapPath(event) {
8
7
  const url = getRequestURL(event);
9
8
  const path = url.pathname === "/__nuxt_error" ? url.searchParams.get("url") ?? url.pathname : url.pathname;
10
9
  return { path, originalPath: url.pathname };
11
10
  }
12
- const getStoreByDomain = (event, stores) => {
11
+ const getShopByDomain = (event, shops) => {
13
12
  const host = getRequestHost(event, { xForwardedHost: true });
14
- return stores.find((s) => s.domain === host);
13
+ return shops.find((s) => s.domain === host);
15
14
  };
16
- const getStoreByPath = (event, stores) => {
15
+ const getShopByPath = (event, shops) => {
17
16
  const { path } = getBootstrapPath(event);
18
17
  const prefix = path.split("/")[1];
19
- return stores.find((shop) => prefix === shop.path);
18
+ return shops.find((shop) => prefix === shop.path);
20
19
  };
21
- export const convertStoresToList = (stores) => {
22
- if (isArray(stores)) {
20
+ const getShopByPathOrDefault = (event, shops) => {
21
+ const defaultShop = shops.find((shop) => shop.isDefault);
22
+ const otherShops = shops.filter((shop) => !shop.isDefault);
23
+ return getShopByPath(event, otherShops) ?? defaultShop;
24
+ };
25
+ export const convertShopsToList = (stores) => {
26
+ if (Array.isArray(stores)) {
23
27
  return stores;
24
28
  }
25
- return listify(stores, (_key, value) => ({ ...value }));
29
+ return Object.values(stores);
26
30
  };
31
+ export function getApiBasePath(storefrontConfig, shop) {
32
+ const apiPath = shop.apiBasePath || storefrontConfig.apiBasePath || "/api";
33
+ if (storefrontConfig.shopSelector === "path") {
34
+ return `/${shop.path}${apiPath}`;
35
+ } else if (storefrontConfig.shopSelector === "path_or_default") {
36
+ if (shop.isDefault) {
37
+ return apiPath;
38
+ }
39
+ return `/${shop.path}${apiPath}`;
40
+ }
41
+ return apiPath;
42
+ }
27
43
  export function getCurrentShopConfigForRequest(event, config) {
28
44
  let $shopConfig;
29
45
  const { shopSelector, stores } = config;
30
- const storesList = convertStoresToList(stores);
46
+ const shopsList = convertShopsToList(stores);
31
47
  const headers = getRequestHeaders(event);
32
48
  const shopId = headers["x-shop-id"];
33
49
  if (shopId) {
34
- $shopConfig = storesList.find((s) => s.shopId === Number(shopId));
50
+ $shopConfig = shopsList.find((s) => s.shopId === Number(shopId));
35
51
  } else if (shopSelector === "domain") {
36
- $shopConfig = getStoreByDomain(event, storesList);
52
+ $shopConfig = getShopByDomain(event, shopsList);
37
53
  } else if (shopSelector === "path") {
38
- $shopConfig = getStoreByPath(event, storesList);
54
+ $shopConfig = getShopByPath(event, shopsList);
55
+ } else if (shopSelector === "path_or_default") {
56
+ $shopConfig = getShopByPathOrDefault(event, shopsList);
39
57
  }
40
58
  return $shopConfig;
41
59
  }
@@ -111,6 +111,7 @@ interface ShopConfig extends AdditionalShopConfig {
111
111
  currencyFractionDigits?: number;
112
112
  storeCampaignKeyword?: string;
113
113
  isEnabled?: boolean;
114
+ isDefault?: boolean;
114
115
  checkout: CheckoutShopConfig;
115
116
  sessionConfig?: SessionConfig;
116
117
  auth: {
@@ -144,7 +145,7 @@ interface StorefrontConfig {
144
145
  idp?: IDPConfig;
145
146
  }
146
147
  type ModuleOptions = StorefrontConfig & {
147
- shopSelector: 'domain' | 'path';
148
+ shopSelector: 'domain' | 'path' | 'path_or_default';
148
149
  stores: ShopConfigIndexed;
149
150
  rpcDir?: string;
150
151
  rpcMethodNames?: string[];
@@ -111,6 +111,7 @@ interface ShopConfig extends AdditionalShopConfig {
111
111
  currencyFractionDigits?: number;
112
112
  storeCampaignKeyword?: string;
113
113
  isEnabled?: boolean;
114
+ isDefault?: boolean;
114
115
  checkout: CheckoutShopConfig;
115
116
  sessionConfig?: SessionConfig;
116
117
  auth: {
@@ -144,7 +145,7 @@ interface StorefrontConfig {
144
145
  idp?: IDPConfig;
145
146
  }
146
147
  type ModuleOptions = StorefrontConfig & {
147
- shopSelector: 'domain' | 'path';
148
+ shopSelector: 'domain' | 'path' | 'path_or_default';
148
149
  stores: ShopConfigIndexed;
149
150
  rpcDir?: string;
150
151
  rpcMethodNames?: string[];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@scayle/storefront-nuxt",
3
3
  "type": "module",
4
- "version": "7.70.0",
4
+ "version": "7.71.1",
5
5
  "description": "Nuxt integration for the SCAYLE Commerce Engine and Storefront API",
6
6
  "author": "SCAYLE Commerce Engine",
7
7
  "license": "MIT",
@@ -63,7 +63,7 @@
63
63
  "@nuxt/kit": "3.11.1",
64
64
  "@opentelemetry/api": "1.8.0",
65
65
  "@scayle/h3-session": "0.4.0",
66
- "@scayle/storefront-core": "7.51.0",
66
+ "@scayle/storefront-core": "7.51.1",
67
67
  "@scayle/unstorage-compression-driver": "0.1.3",
68
68
  "@vueuse/core": "10.9.0",
69
69
  "consola": "3.2.3",
@@ -80,12 +80,12 @@
80
80
  "yn": "5.0.0"
81
81
  },
82
82
  "devDependencies": {
83
- "@nuxt/eslint": "0.3.12",
83
+ "@nuxt/eslint": "0.3.13",
84
84
  "@nuxt/module-builder": "0.5.5",
85
85
  "@nuxt/schema": "3.11.1",
86
86
  "@nuxt/test-utils": "3.13.0",
87
87
  "@scayle/eslint-config-storefront": "4.2.0",
88
- "@scayle/eslint-plugin-vue-composable": "0.1.1",
88
+ "@scayle/eslint-plugin-vue-composable": "0.2.0",
89
89
  "@types/node": "20.12.12",
90
90
  "dprint": "0.45.1",
91
91
  "eslint": "9.2.0",
@@ -95,7 +95,7 @@
95
95
  "node-mocks-http": "1.14.1",
96
96
  "nuxi": "3.11.1",
97
97
  "nuxt": "3.11.1",
98
- "publint": "0.2.7",
98
+ "publint": "0.2.8",
99
99
  "vitest": "1.6.0",
100
100
  "vue-tsc": "2.0.19"
101
101
  },