@scayle/storefront-nuxt 7.70.0 → 7.71.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/CHANGELOG.md +8 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/module.d.mts +2 -2
- package/dist/module.d.ts +2 -2
- package/dist/module.json +1 -1
- package/dist/module.mjs +28 -5
- package/dist/rpc.d.mts +1 -1
- package/dist/rpc.d.ts +1 -1
- package/dist/runtime/server/middleware/bootstrap.mjs +5 -4
- package/dist/runtime/server/middleware/bootstrap.utils.d.ts +2 -1
- package/dist/runtime/server/middleware/bootstrap.utils.mjs +30 -12
- package/dist/shared/{storefront-nuxt.c7df291d.d.mts → storefront-nuxt.b9f5584c.d.mts} +2 -1
- package/dist/shared/{storefront-nuxt.c7df291d.d.ts → storefront-nuxt.b9f5584c.d.ts} +2 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @scayle/storefront-nuxt
|
|
2
2
|
|
|
3
|
+
## 7.71.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Add new shopSelector mode `path_or_default`
|
|
8
|
+
|
|
9
|
+
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.)
|
|
10
|
+
|
|
3
11
|
## 7.70.0
|
|
4
12
|
|
|
5
13
|
### 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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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
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.
|
|
63
|
+
const PACKAGE_VERSION = "7.70.0";
|
|
44
64
|
const module = defineNuxtModule({
|
|
45
65
|
meta: {
|
|
46
66
|
name: PACKAGE_NAME,
|
|
@@ -138,10 +158,13 @@ const module = defineNuxtModule({
|
|
|
138
158
|
method: "post"
|
|
139
159
|
});
|
|
140
160
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
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.
|
|
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.
|
|
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';
|
|
@@ -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
|
-
|
|
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 =
|
|
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
|
|
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
|
|
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
|
|
11
|
+
const getShopByDomain = (event, shops) => {
|
|
13
12
|
const host = getRequestHost(event, { xForwardedHost: true });
|
|
14
|
-
return
|
|
13
|
+
return shops.find((s) => s.domain === host);
|
|
15
14
|
};
|
|
16
|
-
const
|
|
15
|
+
const getShopByPath = (event, shops) => {
|
|
17
16
|
const { path } = getBootstrapPath(event);
|
|
18
17
|
const prefix = path.split("/")[1];
|
|
19
|
-
return
|
|
18
|
+
return shops.find((shop) => prefix === shop.path);
|
|
20
19
|
};
|
|
21
|
-
|
|
22
|
-
|
|
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
|
|
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
|
|
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 =
|
|
50
|
+
$shopConfig = shopsList.find((s) => s.shopId === Number(shopId));
|
|
35
51
|
} else if (shopSelector === "domain") {
|
|
36
|
-
$shopConfig =
|
|
52
|
+
$shopConfig = getShopByDomain(event, shopsList);
|
|
37
53
|
} else if (shopSelector === "path") {
|
|
38
|
-
$shopConfig =
|
|
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